s2n_ktls_crypto.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #pragma once
  16. #include "utils/s2n_blob.h"
  17. /* clang-format off */
  18. #if defined(S2N_KTLS_SUPPORTED)
  19. #include <linux/tls.h>
  20. typedef struct tls12_crypto_info_aes_gcm_128 s2n_ktls_crypto_info_tls12_aes_gcm_128;
  21. typedef struct tls12_crypto_info_aes_gcm_256 s2n_ktls_crypto_info_tls12_aes_gcm_256;
  22. #else
  23. #define TLS_1_2_VERSION 0
  24. #define TLS_CIPHER_AES_GCM_128 0
  25. typedef struct s2n_ktls_crypto_info_stub s2n_ktls_crypto_info_tls12_aes_gcm_128;
  26. #define TLS_CIPHER_AES_GCM_256 0
  27. typedef struct s2n_ktls_crypto_info_stub s2n_ktls_crypto_info_tls12_aes_gcm_256;
  28. #endif
  29. /* clang-format on */
  30. /* To avoid compile-time errors, this must contain every field that we reference
  31. * from any crypto_info. However, it is only a placeholder-- it should never
  32. * actually be used.
  33. */
  34. struct s2n_ktls_crypto_info_stub {
  35. struct {
  36. uint8_t version;
  37. uint8_t cipher_type;
  38. } info;
  39. uint8_t iv[1];
  40. uint8_t key[1];
  41. uint8_t salt[1];
  42. uint8_t rec_seq[1];
  43. };
  44. struct s2n_ktls_crypto_info {
  45. struct s2n_blob value;
  46. union {
  47. s2n_ktls_crypto_info_tls12_aes_gcm_128 aes_gcm_128;
  48. s2n_ktls_crypto_info_tls12_aes_gcm_256 aes_gcm_256;
  49. } ciphers;
  50. };
  51. struct s2n_ktls_crypto_info_inputs {
  52. struct s2n_blob iv;
  53. struct s2n_blob key;
  54. struct s2n_blob seq;
  55. };