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