aesarm.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * This file is adapted from https://github.com/CriticalBlue/mbedtls
  3. */
  4. /**
  5. * \file aes_armv8a_ce.h
  6. *
  7. * \brief AES support functions using the ARMv8-A Cryptography Extension for
  8. * hardware acceleration on some ARM processors.
  9. *
  10. * Copyright (C) 2016, CriticalBlue Limited, All Rights Reserved
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. * This file is part of mbed TLS (https://tls.mbed.org)
  26. */
  27. #ifndef UDP2RAW_AESARM_H_
  28. #define UDP2RAW_AESARM_H_
  29. #ifndef AES_ENCRYPT
  30. #define AES_ENCRYPT 1
  31. #endif
  32. #ifndef AES_DECRYPT
  33. #define AES_DECRYPT 0
  34. #endif
  35. #if defined(__GNUC__) && \
  36. __ARM_ARCH >= 8 && \
  37. __ARM_ARCH_PROFILE == 'A' && \
  38. defined(__aarch64__) && \
  39. defined(__ARM_FEATURE_CRYPTO) && \
  40. defined(__linux__) && \
  41. !defined(NO_AESACC)
  42. #define HAVE_ARM64
  43. #endif
  44. #if defined(HAVE_ARM64)
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /**
  49. * \brief ARMv8-A features detection routine
  50. *
  51. * \return 1 if the CPU has support for the feature, 0 otherwise
  52. */
  53. int aesarm_supported( void );
  54. /**
  55. * \brief AES ARMv8-A Cryptography Extension AES-ECB block en(de)cryption
  56. *
  57. * \param nr number of rounds
  58. * \param rk AES round keys
  59. * \param mode AESARM_ENCRYPT or AESARM_DECRYPT
  60. * \param input 16-byte input block
  61. * \param output 16-byte output block
  62. */
  63. void aesarm_crypt_ecb( int nr,
  64. unsigned char *rk,
  65. int mode,
  66. const unsigned char input[16],
  67. unsigned char output[16] );
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* HAVE_ARM64 */
  72. #endif /* _AESARM_H_ */