camellia.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2006-2016 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. # if !OPENSSL_API_3
  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_ENCRYPT 1
  23. # define CAMELLIA_DECRYPT 0
  24. /*
  25. * Because array size can't be a const in C, the following two are macros.
  26. * Both sizes are in bytes.
  27. */
  28. /* This should be a hidden type, but EVP requires that the size be known */
  29. # define CAMELLIA_BLOCK_SIZE 16
  30. # define CAMELLIA_TABLE_BYTE_LEN 272
  31. # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
  32. typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
  33. * with WORD */
  34. struct camellia_key_st {
  35. union {
  36. double d; /* ensures 64-bit align */
  37. KEY_TABLE_TYPE rd_key;
  38. } u;
  39. int grand_rounds;
  40. };
  41. typedef struct camellia_key_st CAMELLIA_KEY;
  42. int Camellia_set_key(const unsigned char *userKey, const int bits,
  43. CAMELLIA_KEY *key);
  44. void Camellia_encrypt(const unsigned char *in, unsigned char *out,
  45. const CAMELLIA_KEY *key);
  46. void Camellia_decrypt(const unsigned char *in, unsigned char *out,
  47. const CAMELLIA_KEY *key);
  48. void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
  49. const CAMELLIA_KEY *key, const int enc);
  50. void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
  51. size_t length, const CAMELLIA_KEY *key,
  52. unsigned char *ivec, const int enc);
  53. void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
  54. size_t length, const CAMELLIA_KEY *key,
  55. unsigned char *ivec, int *num, const int enc);
  56. void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
  57. size_t length, const CAMELLIA_KEY *key,
  58. unsigned char *ivec, int *num, const int enc);
  59. void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
  60. size_t length, const CAMELLIA_KEY *key,
  61. unsigned char *ivec, int *num, const int enc);
  62. void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
  63. size_t length, const CAMELLIA_KEY *key,
  64. unsigned char *ivec, int *num);
  65. void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
  66. size_t length, const CAMELLIA_KEY *key,
  67. unsigned char ivec[CAMELLIA_BLOCK_SIZE],
  68. unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
  69. unsigned int *num);
  70. # ifdef __cplusplus
  71. }
  72. # endif
  73. # endif
  74. #endif