jpayne@69: /* jpayne@69: * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. jpayne@69: * jpayne@69: * Licensed under the OpenSSL license (the "License"). You may not use jpayne@69: * this file except in compliance with the License. You can obtain a copy jpayne@69: * in the file LICENSE in the source distribution or at jpayne@69: * https://www.openssl.org/source/license.html jpayne@69: */ jpayne@69: jpayne@69: #ifndef HEADER_CAMELLIA_H jpayne@69: # define HEADER_CAMELLIA_H jpayne@69: jpayne@69: # include jpayne@69: jpayne@69: # ifndef OPENSSL_NO_CAMELLIA jpayne@69: # include jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: # define CAMELLIA_ENCRYPT 1 jpayne@69: # define CAMELLIA_DECRYPT 0 jpayne@69: jpayne@69: /* jpayne@69: * Because array size can't be a const in C, the following two are macros. jpayne@69: * Both sizes are in bytes. jpayne@69: */ jpayne@69: jpayne@69: /* This should be a hidden type, but EVP requires that the size be known */ jpayne@69: jpayne@69: # define CAMELLIA_BLOCK_SIZE 16 jpayne@69: # define CAMELLIA_TABLE_BYTE_LEN 272 jpayne@69: # define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) jpayne@69: jpayne@69: typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match jpayne@69: * with WORD */ jpayne@69: jpayne@69: struct camellia_key_st { jpayne@69: union { jpayne@69: double d; /* ensures 64-bit align */ jpayne@69: KEY_TABLE_TYPE rd_key; jpayne@69: } u; jpayne@69: int grand_rounds; jpayne@69: }; jpayne@69: typedef struct camellia_key_st CAMELLIA_KEY; jpayne@69: jpayne@69: int Camellia_set_key(const unsigned char *userKey, const int bits, jpayne@69: CAMELLIA_KEY *key); jpayne@69: jpayne@69: void Camellia_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: const CAMELLIA_KEY *key); jpayne@69: void Camellia_decrypt(const unsigned char *in, unsigned char *out, jpayne@69: const CAMELLIA_KEY *key); jpayne@69: jpayne@69: void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: const CAMELLIA_KEY *key, const int enc); jpayne@69: void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: size_t length, const CAMELLIA_KEY *key, jpayne@69: unsigned char *ivec, const int enc); jpayne@69: void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: size_t length, const CAMELLIA_KEY *key, jpayne@69: unsigned char *ivec, int *num, const int enc); jpayne@69: void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: size_t length, const CAMELLIA_KEY *key, jpayne@69: unsigned char *ivec, int *num, const int enc); jpayne@69: void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: size_t length, const CAMELLIA_KEY *key, jpayne@69: unsigned char *ivec, int *num, const int enc); jpayne@69: void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: size_t length, const CAMELLIA_KEY *key, jpayne@69: unsigned char *ivec, int *num); jpayne@69: void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, jpayne@69: size_t length, const CAMELLIA_KEY *key, jpayne@69: unsigned char ivec[CAMELLIA_BLOCK_SIZE], jpayne@69: unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], jpayne@69: unsigned int *num); jpayne@69: jpayne@69: # ifdef __cplusplus jpayne@69: } jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: #endif