cryspr-openssl-evp.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * SRT - Secure, Reliable, Transport
  3. * Copyright (c) 2019 Haivision Systems Inc.
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. *
  9. */
  10. /*****************************************************************************
  11. written by
  12. Haivision Systems Inc.
  13. 2022-05-19 (jdube)
  14. OpenSSL EVP AES CRYSPR/4SRT (CRYypto Service PRovider for SRT).
  15. *****************************************************************************/
  16. #ifndef CRYSPR_OPENSSL_H
  17. #define CRYSPR_OPENSSL_H
  18. #include <openssl/evp.h> /* PKCS5_xxx() */
  19. #include <openssl/aes.h> /* AES_xxx() */
  20. #if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(OPENSSL_IS_BORINGSSL))
  21. #include <openssl/modes.h> /* CRYPTO_xxx() */
  22. #endif
  23. #include <openssl/rand.h>
  24. #include <openssl/err.h>
  25. #include <openssl/opensslv.h> /* OPENSSL_VERSION_NUMBER */
  26. /* Define CRYSPR_HAS_AESCTR to 1 if this CRYSPR has AESCTR cipher mode
  27. if not set it 0 to use enable CTR cipher mode implementation using ECB cipher mode
  28. and provide the aes_ecb_cipher method.
  29. */
  30. #define CRYSPR_HAS_AESCTR 1
  31. /* Define CRYSPR_HAS_AESGCM to 1 if this CRYSPR has AES GCM cipher mode. OpenSSL EVP supports GCM.
  32. */
  33. #define CRYSPR_HAS_AESGCM 1
  34. /* Define CRYSPR_HAS_AESKWRAP to 1 if this CRYSPR has AES Key Wrap
  35. if not set to 0 to enable default/fallback crysprFallback_AES_WrapKey/crysprFallback_AES_UnwrapKey methods
  36. and provide the aes_ecb_cipher method .
  37. */
  38. #if 1 // Force internal AES-WRAP (using AES-ECB) until implemented with EVP (OPENSSL_VERSION_NUMBER < 0x00xxxxxxL)
  39. #define CRYSPR_HAS_AESKWRAP 0
  40. #else
  41. #define CRYSPR_HAS_AESKWRAP 1
  42. #endif
  43. /* Define CRYSPR_HAS_PBKDF2 to 1 if this CRYSPR has SHA1-HMAC Password-based Key Derivaion Function 2
  44. if not set to 0 to enable not-yet-implemented/fallback crysprFallback.km_pbkdf2 method
  45. and provide the sha1_msg_digest method.
  46. */
  47. #define CRYSPR_HAS_PBKDF2 1 /* Define to 1 if CRYSPR has Password-based Key Derivaion Function 2 */
  48. /*
  49. #define CRYSPR_AESCTX to the CRYSPR specifix AES key context object.
  50. This type reserves room in the CRYPSPR control block for Haicrypt KEK and SEK
  51. It is set from hte keystring through CRYSPR_methods.aes_set_key and passed
  52. to CRYSPR_methods.aes_*.
  53. */
  54. typedef EVP_CIPHER_CTX CRYSPR_AESCTX; /* CRYpto Service PRovider AES key context */
  55. struct tag_CRYSPR_methods* crysprOpenSSL_EVP(void);
  56. #endif /* CRYSPR_OPENSSL_H */