cipher_camellia.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2019 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. /* Dispatch functions for CAMELLIA cipher modes ecb, cbc, ofb, cfb, ctr */
  10. #include "cipher_camellia.h"
  11. #include "internal/provider_algs.h"
  12. static OSSL_OP_cipher_freectx_fn camellia_freectx;
  13. static OSSL_OP_cipher_dupctx_fn camellia_dupctx;
  14. static void camellia_freectx(void *vctx)
  15. {
  16. PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx;
  17. OPENSSL_clear_free(ctx, sizeof(*ctx));
  18. }
  19. static void *camellia_dupctx(void *ctx)
  20. {
  21. PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx;
  22. PROV_CAMELLIA_CTX *ret = OPENSSL_malloc(sizeof(*ret));
  23. if (ret == NULL) {
  24. ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
  25. return NULL;
  26. }
  27. *ret = *in;
  28. return ret;
  29. }
  30. /* camellia256ecb_functions */
  31. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
  32. /* camellia192ecb_functions */
  33. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
  34. /* camellia128ecb_functions */
  35. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
  36. /* camellia256cbc_functions */
  37. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
  38. /* camellia192cbc_functions */
  39. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
  40. /* camellia128cbc_functions */
  41. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
  42. /* camellia256ofb_functions */
  43. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
  44. /* camellia192ofb_functions */
  45. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
  46. /* camellia128ofb_functions */
  47. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
  48. /* camellia256cfb_functions */
  49. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
  50. /* camellia192cfb_functions */
  51. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
  52. /* camellia128cfb_functions */
  53. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
  54. /* camellia256cfb1_functions */
  55. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
  56. /* camellia192cfb1_functions */
  57. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
  58. /* camellia128cfb1_functions */
  59. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
  60. /* camellia256cfb8_functions */
  61. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
  62. /* camellia192cfb8_functions */
  63. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
  64. /* camellia128cfb8_functions */
  65. IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
  66. /* camellia256ctr_functions */
  67. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
  68. /* camellia192ctr_functions */
  69. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
  70. /* camellia128ctr_functions */
  71. IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream)