camellia.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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 HEADER_CAMELLIA_H
  10. # define HEADER_CAMELLIA_H
  11. # include <openssl/opensslconf.h>
  12. # ifndef OPENSSL_NO_CAMELLIA
  13. # include <stddef.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. # define CAMELLIA_ENCRYPT 1
  18. # define CAMELLIA_DECRYPT 0
  19. /*
  20. * Because array size can't be a const in C, the following two are macros.
  21. * Both sizes are in bytes.
  22. */
  23. /* This should be a hidden type, but EVP requires that the size be known */
  24. # define CAMELLIA_BLOCK_SIZE 16
  25. # define CAMELLIA_TABLE_BYTE_LEN 272
  26. # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
  27. typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
  28. * with WORD */
  29. struct camellia_key_st {
  30. union {
  31. double d; /* ensures 64-bit align */
  32. KEY_TABLE_TYPE rd_key;
  33. } u;
  34. int grand_rounds;
  35. };
  36. typedef struct camellia_key_st CAMELLIA_KEY;
  37. int Camellia_set_key(const unsigned char *userKey, const int bits,
  38. CAMELLIA_KEY *key);
  39. void Camellia_encrypt(const unsigned char *in, unsigned char *out,
  40. const CAMELLIA_KEY *key);
  41. void Camellia_decrypt(const unsigned char *in, unsigned char *out,
  42. const CAMELLIA_KEY *key);
  43. void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
  44. const CAMELLIA_KEY *key, const int enc);
  45. void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
  46. size_t length, const CAMELLIA_KEY *key,
  47. unsigned char *ivec, const int enc);
  48. void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
  49. size_t length, const CAMELLIA_KEY *key,
  50. unsigned char *ivec, int *num, const int enc);
  51. void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
  52. size_t length, const CAMELLIA_KEY *key,
  53. unsigned char *ivec, int *num, const int enc);
  54. void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
  55. size_t length, const CAMELLIA_KEY *key,
  56. unsigned char *ivec, int *num, const int enc);
  57. void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
  58. size_t length, const CAMELLIA_KEY *key,
  59. unsigned char *ivec, int *num);
  60. void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
  61. size_t length, const CAMELLIA_KEY *key,
  62. unsigned char ivec[CAMELLIA_BLOCK_SIZE],
  63. unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
  64. unsigned int *num);
  65. # ifdef __cplusplus
  66. }
  67. # endif
  68. # endif
  69. #endif