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