cipher_camellia.c 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2019-2021 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. /*
  10. * Camellia low level APIs are deprecated for public use, but still ok for
  11. * internal use.
  12. */
  13. #include "internal/deprecated.h"
  14. /* Dispatch functions for CAMELLIA cipher modes ecb, cbc, ofb, cfb, ctr */
  15. #include "cipher_camellia.h"
  16. #include "prov/implementations.h"
  17. #include "prov/providercommon.h"
  18. static OSSL_FUNC_cipher_freectx_fn camellia_freectx;
  19. static OSSL_FUNC_cipher_dupctx_fn camellia_dupctx;
  20. static void camellia_freectx(void *vctx)
  21. {
  22. PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx;
  23. ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
  24. OPENSSL_clear_free(ctx, sizeof(*ctx));
  25. }
  26. static void *camellia_dupctx(void *ctx)
  27. {
  28. PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx;
  29. PROV_CAMELLIA_CTX *ret;
  30. if (!ossl_prov_is_running())
  31. return NULL;
  32. ret = OPENSSL_malloc(sizeof(*ret));
  33. if (ret == NULL)
  34. return NULL;
  35. in->base.hw->copyctx(&ret->base, &in->base);
  36. return ret;
  37. }
  38. /* ossl_camellia256ecb_functions */
  39. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
  40. /* ossl_camellia192ecb_functions */
  41. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
  42. /* ossl_camellia128ecb_functions */
  43. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
  44. /* ossl_camellia256cbc_functions */
  45. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
  46. /* ossl_camellia192cbc_functions */
  47. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
  48. /* ossl_camellia128cbc_functions */
  49. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
  50. /* ossl_camellia256ofb_functions */
  51. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
  52. /* ossl_camellia192ofb_functions */
  53. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
  54. /* ossl_camellia128ofb_functions */
  55. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
  56. /* ossl_camellia256cfb_functions */
  57. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
  58. /* ossl_camellia192cfb_functions */
  59. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
  60. /* ossl_camellia128cfb_functions */
  61. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
  62. /* ossl_camellia256cfb1_functions */
  63. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
  64. /* ossl_camellia192cfb1_functions */
  65. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
  66. /* ossl_camellia128cfb1_functions */
  67. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
  68. /* ossl_camellia256cfb8_functions */
  69. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
  70. /* ossl_camellia192cfb8_functions */
  71. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
  72. /* ossl_camellia128cfb8_functions */
  73. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
  74. /* ossl_camellia256ctr_functions */
  75. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
  76. /* ossl_camellia192ctr_functions */
  77. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
  78. /* ossl_camellia128ctr_functions */
  79. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream)
  80. #include "cipher_camellia_cts.inc"