cipher_cts.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include "crypto/evp.h"
  10. /* NOTE: The underlying block cipher is CBC so we reuse most of the code */
  11. #define IMPLEMENT_cts_cipher(alg, UCALG, lcmode, UCMODE, flags, kbits, \
  12. blkbits, ivbits, typ) \
  13. static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lcmode##_get_params; \
  14. static int alg##_cts_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \
  15. { \
  16. return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
  17. flags, kbits, blkbits, ivbits); \
  18. } \
  19. const OSSL_DISPATCH ossl_##alg##kbits##lcmode##_cts_functions[] = { \
  20. { OSSL_FUNC_CIPHER_NEWCTX, \
  21. (void (*)(void)) alg##_##kbits##_##lcmode##_newctx }, \
  22. { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void)) alg##_freectx }, \
  23. { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void)) alg##_dupctx }, \
  24. { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void)) alg##_cbc_cts_einit }, \
  25. { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void)) alg##_cbc_cts_dinit }, \
  26. { OSSL_FUNC_CIPHER_UPDATE, \
  27. (void (*)(void)) ossl_cipher_cbc_cts_block_update }, \
  28. { OSSL_FUNC_CIPHER_FINAL, \
  29. (void (*)(void)) ossl_cipher_cbc_cts_block_final }, \
  30. { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))ossl_cipher_generic_cipher }, \
  31. { OSSL_FUNC_CIPHER_GET_PARAMS, \
  32. (void (*)(void)) alg##_cts_##kbits##_##lcmode##_get_params }, \
  33. { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \
  34. (void (*)(void))ossl_cipher_generic_gettable_params }, \
  35. { OSSL_FUNC_CIPHER_GET_CTX_PARAMS, \
  36. (void (*)(void)) alg##_cbc_cts_get_ctx_params }, \
  37. { OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \
  38. (void (*)(void)) alg##_cbc_cts_set_ctx_params }, \
  39. { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \
  40. (void (*)(void)) alg##_cbc_cts_gettable_ctx_params }, \
  41. { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \
  42. (void (*)(void)) alg##_cbc_cts_settable_ctx_params }, \
  43. OSSL_DISPATCH_END \
  44. };
  45. OSSL_FUNC_cipher_update_fn ossl_cipher_cbc_cts_block_update;
  46. OSSL_FUNC_cipher_final_fn ossl_cipher_cbc_cts_block_final;
  47. const char *ossl_cipher_cbc_cts_mode_id2name(unsigned int id);
  48. int ossl_cipher_cbc_cts_mode_name2id(const char *name);