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