]>
Commit | Line | Data |
---|---|---|
21dcbebc RS |
1 | /* |
2 | * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. | |
67912e00 | 3 | * |
48f4ad77 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
21dcbebc RS |
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 | |
67912e00 BM |
8 | */ |
9 | ||
ae4186b0 DMSP |
10 | #ifndef OPENSSL_CAMELLIA_H |
11 | # define OPENSSL_CAMELLIA_H | |
d86167ec DMSP |
12 | # pragma once |
13 | ||
14 | # include <openssl/macros.h> | |
15 | # if !OPENSSL_API_3 | |
16 | # define HEADER_CAMELLIA_H | |
17 | # endif | |
67912e00 | 18 | |
0f113f3e | 19 | # include <openssl/opensslconf.h> |
67912e00 | 20 | |
3c27208f | 21 | # ifndef OPENSSL_NO_CAMELLIA |
0f113f3e | 22 | # include <stddef.h> |
3c27208f RS |
23 | #ifdef __cplusplus |
24 | extern "C" { | |
25 | #endif | |
f768be81 | 26 | |
0f113f3e MC |
27 | # define CAMELLIA_ENCRYPT 1 |
28 | # define CAMELLIA_DECRYPT 0 | |
67912e00 | 29 | |
0f113f3e MC |
30 | /* |
31 | * Because array size can't be a const in C, the following two are macros. | |
32 | * Both sizes are in bytes. | |
33 | */ | |
67912e00 | 34 | |
67912e00 BM |
35 | /* This should be a hidden type, but EVP requires that the size be known */ |
36 | ||
0f113f3e MC |
37 | # define CAMELLIA_BLOCK_SIZE 16 |
38 | # define CAMELLIA_TABLE_BYTE_LEN 272 | |
39 | # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) | |
67912e00 | 40 | |
0f113f3e MC |
41 | typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match |
42 | * with WORD */ | |
67912e00 | 43 | |
0f113f3e MC |
44 | struct camellia_key_st { |
45 | union { | |
46 | double d; /* ensures 64-bit align */ | |
47 | KEY_TABLE_TYPE rd_key; | |
48 | } u; | |
49 | int grand_rounds; | |
50 | }; | |
67912e00 BM |
51 | typedef struct camellia_key_st CAMELLIA_KEY; |
52 | ||
53 | int Camellia_set_key(const unsigned char *userKey, const int bits, | |
0f113f3e | 54 | CAMELLIA_KEY *key); |
67912e00 BM |
55 | |
56 | void Camellia_encrypt(const unsigned char *in, unsigned char *out, | |
0f113f3e | 57 | const CAMELLIA_KEY *key); |
67912e00 | 58 | void Camellia_decrypt(const unsigned char *in, unsigned char *out, |
0f113f3e | 59 | const CAMELLIA_KEY *key); |
67912e00 BM |
60 | |
61 | void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, | |
0f113f3e | 62 | const CAMELLIA_KEY *key, const int enc); |
67912e00 | 63 | void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, |
0f113f3e MC |
64 | size_t length, const CAMELLIA_KEY *key, |
65 | unsigned char *ivec, const int enc); | |
67912e00 | 66 | void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, |
0f113f3e MC |
67 | size_t length, const CAMELLIA_KEY *key, |
68 | unsigned char *ivec, int *num, const int enc); | |
67912e00 | 69 | void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, |
0f113f3e MC |
70 | size_t length, const CAMELLIA_KEY *key, |
71 | unsigned char *ivec, int *num, const int enc); | |
67912e00 | 72 | void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, |
0f113f3e MC |
73 | size_t length, const CAMELLIA_KEY *key, |
74 | unsigned char *ivec, int *num, const int enc); | |
67912e00 | 75 | void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, |
0f113f3e MC |
76 | size_t length, const CAMELLIA_KEY *key, |
77 | unsigned char *ivec, int *num); | |
67912e00 | 78 | void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, |
0f113f3e MC |
79 | size_t length, const CAMELLIA_KEY *key, |
80 | unsigned char ivec[CAMELLIA_BLOCK_SIZE], | |
81 | unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], | |
82 | unsigned int *num); | |
67912e00 | 83 | |
3c27208f | 84 | # ifdef __cplusplus |
67912e00 | 85 | } |
3c27208f RS |
86 | # endif |
87 | # endif | |
67912e00 | 88 | |
3c27208f | 89 | #endif |