| OLD | NEW |
| 1 /* crypto/camellia/camellia.h -*- mode:C; c-file-style: "eay" -*- */ | 1 /* crypto/camellia/camellia.h -*- mode:C; c-file-style: "eay" -*- */ |
| 2 /* ==================================================================== | 2 /* ==================================================================== |
| 3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | 3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 #ifndef HEADER_CAMELLIA_H | 52 #ifndef HEADER_CAMELLIA_H |
| 53 #define HEADER_CAMELLIA_H | 53 #define HEADER_CAMELLIA_H |
| 54 | 54 |
| 55 #include <openssl/opensslconf.h> | 55 #include <openssl/opensslconf.h> |
| 56 | 56 |
| 57 #ifdef OPENSSL_NO_CAMELLIA | 57 #ifdef OPENSSL_NO_CAMELLIA |
| 58 #error CAMELLIA is disabled. | 58 #error CAMELLIA is disabled. |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #include <stddef.h> |
| 62 |
| 61 #define CAMELLIA_ENCRYPT 1 | 63 #define CAMELLIA_ENCRYPT 1 |
| 62 #define CAMELLIA_DECRYPT 0 | 64 #define CAMELLIA_DECRYPT 0 |
| 63 | 65 |
| 64 /* Because array size can't be a const in C, the following two are macros. | 66 /* Because array size can't be a const in C, the following two are macros. |
| 65 Both sizes are in bytes. */ | 67 Both sizes are in bytes. */ |
| 66 | 68 |
| 67 #ifdef __cplusplus | 69 #ifdef __cplusplus |
| 68 extern "C" { | 70 extern "C" { |
| 69 #endif | 71 #endif |
| 70 | 72 |
| 71 /* This should be a hidden type, but EVP requires that the size be known */ | 73 /* This should be a hidden type, but EVP requires that the size be known */ |
| 72 | 74 |
| 73 #define CAMELLIA_BLOCK_SIZE 16 | 75 #define CAMELLIA_BLOCK_SIZE 16 |
| 74 #define CAMELLIA_TABLE_BYTE_LEN 272 | 76 #define CAMELLIA_TABLE_BYTE_LEN 272 |
| 75 #define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) | 77 #define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) |
| 76 | 78 |
| 77 /* to match with WORD */ | 79 typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match with W
ORD */ |
| 78 typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; | |
| 79 | 80 |
| 80 struct camellia_key_st | 81 struct camellia_key_st |
| 81 { | 82 { |
| 82 » KEY_TABLE_TYPE rd_key; | 83 » union» { |
| 83 » int bitLength; | 84 » » double d;» /* ensures 64-bit align */ |
| 84 » void (*enc)(const unsigned int *subkey, unsigned int *io); | 85 » » KEY_TABLE_TYPE rd_key; |
| 85 » void (*dec)(const unsigned int *subkey, unsigned int *io); | 86 » » } u; |
| 87 » int grand_rounds; |
| 86 }; | 88 }; |
| 87 | |
| 88 typedef struct camellia_key_st CAMELLIA_KEY; | 89 typedef struct camellia_key_st CAMELLIA_KEY; |
| 89 | 90 |
| 90 #ifdef OPENSSL_FIPS | |
| 91 int private_Camellia_set_key(const unsigned char *userKey, const int bits, | |
| 92 CAMELLIA_KEY *key); | |
| 93 #endif | |
| 94 | |
| 95 int Camellia_set_key(const unsigned char *userKey, const int bits, | 91 int Camellia_set_key(const unsigned char *userKey, const int bits, |
| 96 CAMELLIA_KEY *key); | 92 CAMELLIA_KEY *key); |
| 97 | 93 |
| 98 void Camellia_encrypt(const unsigned char *in, unsigned char *out, | 94 void Camellia_encrypt(const unsigned char *in, unsigned char *out, |
| 99 const CAMELLIA_KEY *key); | 95 const CAMELLIA_KEY *key); |
| 100 void Camellia_decrypt(const unsigned char *in, unsigned char *out, | 96 void Camellia_decrypt(const unsigned char *in, unsigned char *out, |
| 101 const CAMELLIA_KEY *key); | 97 const CAMELLIA_KEY *key); |
| 102 | 98 |
| 103 void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, | 99 void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, |
| 104 const CAMELLIA_KEY *key, const int enc); | 100 const CAMELLIA_KEY *key, const int enc); |
| 105 void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, | 101 void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, |
| 106 » const unsigned long length, const CAMELLIA_KEY *key, | 102 » size_t length, const CAMELLIA_KEY *key, |
| 107 unsigned char *ivec, const int enc); | 103 unsigned char *ivec, const int enc); |
| 108 void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, | 104 void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, |
| 109 » const unsigned long length, const CAMELLIA_KEY *key, | 105 » size_t length, const CAMELLIA_KEY *key, |
| 110 unsigned char *ivec, int *num, const int enc); | 106 unsigned char *ivec, int *num, const int enc); |
| 111 void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, | 107 void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, |
| 112 » const unsigned long length, const CAMELLIA_KEY *key, | 108 » size_t length, const CAMELLIA_KEY *key, |
| 113 unsigned char *ivec, int *num, const int enc); | 109 unsigned char *ivec, int *num, const int enc); |
| 114 void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, | 110 void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, |
| 115 » const unsigned long length, const CAMELLIA_KEY *key, | 111 » size_t length, const CAMELLIA_KEY *key, |
| 116 unsigned char *ivec, int *num, const int enc); | 112 unsigned char *ivec, int *num, const int enc); |
| 117 void Camellia_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, | |
| 118 const int nbits,const CAMELLIA_KEY *key, | |
| 119 unsigned char *ivec,const int enc); | |
| 120 void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, | 113 void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, |
| 121 » const unsigned long length, const CAMELLIA_KEY *key, | 114 » size_t length, const CAMELLIA_KEY *key, |
| 122 unsigned char *ivec, int *num); | 115 unsigned char *ivec, int *num); |
| 123 void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, | 116 void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, |
| 124 » const unsigned long length, const CAMELLIA_KEY *key, | 117 » size_t length, const CAMELLIA_KEY *key, |
| 125 unsigned char ivec[CAMELLIA_BLOCK_SIZE], | 118 unsigned char ivec[CAMELLIA_BLOCK_SIZE], |
| 126 unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], | 119 unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], |
| 127 unsigned int *num); | 120 unsigned int *num); |
| 128 | 121 |
| 129 #ifdef __cplusplus | 122 #ifdef __cplusplus |
| 130 } | 123 } |
| 131 #endif | 124 #endif |
| 132 | 125 |
| 133 #endif /* !HEADER_Camellia_H */ | 126 #endif /* !HEADER_Camellia_H */ |
| 134 | |
| OLD | NEW |