camellia.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2006-2020 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. #ifndef OPENSSL_CAMELLIA_H
  10. # define OPENSSL_CAMELLIA_H
  11. # pragma once
  12. # include <openssl/macros.h>
  13. # ifndef OPENSSL_NO_DEPRECATED_3_0
  14. # define HEADER_CAMELLIA_H
  15. # endif
  16. # include <openssl/opensslconf.h>
  17. # ifndef OPENSSL_NO_CAMELLIA
  18. # include <stddef.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. # define CAMELLIA_BLOCK_SIZE 16
  23. # ifndef OPENSSL_NO_DEPRECATED_3_0
  24. # define CAMELLIA_ENCRYPT 1
  25. # define CAMELLIA_DECRYPT 0
  26. /*
  27. * Because array size can't be a const in C, the following two are macros.
  28. * Both sizes are in bytes.
  29. */
  30. /* This should be a hidden type, but EVP requires that the size be known */
  31. # define CAMELLIA_TABLE_BYTE_LEN 272
  32. # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
  33. typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
  34. * with WORD */
  35. struct camellia_key_st {
  36. union {
  37. double d; /* ensures 64-bit align */
  38. KEY_TABLE_TYPE rd_key;
  39. } u;
  40. int grand_rounds;
  41. };
  42. typedef struct camellia_key_st CAMELLIA_KEY;
  43. # endif /* OPENSSL_NO_DEPRECATED_3_0 */
  44. # ifndef OPENSSL_NO_DEPRECATED_3_0
  45. OSSL_DEPRECATEDIN_3_0 int Camellia_set_key(const unsigned char *userKey,
  46. const int bits,
  47. CAMELLIA_KEY *key);
  48. OSSL_DEPRECATEDIN_3_0 void Camellia_encrypt(const unsigned char *in,
  49. unsigned char *out,
  50. const CAMELLIA_KEY *key);
  51. OSSL_DEPRECATEDIN_3_0 void Camellia_decrypt(const unsigned char *in,
  52. unsigned char *out,
  53. const CAMELLIA_KEY *key);
  54. OSSL_DEPRECATEDIN_3_0 void Camellia_ecb_encrypt(const unsigned char *in,
  55. unsigned char *out,
  56. const CAMELLIA_KEY *key,
  57. const int enc);
  58. OSSL_DEPRECATEDIN_3_0 void Camellia_cbc_encrypt(const unsigned char *in,
  59. unsigned char *out,
  60. size_t length,
  61. const CAMELLIA_KEY *key,
  62. unsigned char *ivec,
  63. const int enc);
  64. OSSL_DEPRECATEDIN_3_0 void Camellia_cfb128_encrypt(const unsigned char *in,
  65. unsigned char *out,
  66. size_t length,
  67. const CAMELLIA_KEY *key,
  68. unsigned char *ivec,
  69. int *num,
  70. const int enc);
  71. OSSL_DEPRECATEDIN_3_0 void Camellia_cfb1_encrypt(const unsigned char *in,
  72. unsigned char *out,
  73. size_t length,
  74. const CAMELLIA_KEY *key,
  75. unsigned char *ivec,
  76. int *num,
  77. const int enc);
  78. OSSL_DEPRECATEDIN_3_0 void Camellia_cfb8_encrypt(const unsigned char *in,
  79. unsigned char *out,
  80. size_t length,
  81. const CAMELLIA_KEY *key,
  82. unsigned char *ivec,
  83. int *num,
  84. const int enc);
  85. OSSL_DEPRECATEDIN_3_0 void Camellia_ofb128_encrypt(const unsigned char *in,
  86. unsigned char *out,
  87. size_t length,
  88. const CAMELLIA_KEY *key,
  89. unsigned char *ivec,
  90. int *num);
  91. OSSL_DEPRECATEDIN_3_0
  92. void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
  93. size_t length, const CAMELLIA_KEY *key,
  94. unsigned char ivec[CAMELLIA_BLOCK_SIZE],
  95. unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
  96. unsigned int *num);
  97. # endif
  98. # ifdef __cplusplus
  99. }
  100. # endif
  101. # endif
  102. #endif