ssl_tls: fix format warning in ssl_parse_certificate() on x86_64
[tropicssl.git] / include / tropicssl / camellia.h
blob1f8589cc86761b580b0ed4b4c62b11c962c597ba
1 /**
2 * \file camellia.h
4 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the names of PolarSSL or XySSL nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef TROPICSSL_CAMELLIA_H
34 #define TROPICSSL_CAMELLIA_H
36 #define CAMELLIA_ENCRYPT 1
37 #define CAMELLIA_DECRYPT 0
39 /**
40 * \brief CAMELLIA context structure
42 typedef struct {
43 int nr; /*!< number of rounds */
44 unsigned long rk[68]; /*!< CAMELLIA round keys */
45 } camellia_context;
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 /**
52 * \brief CAMELLIA key schedule (encryption)
54 * \param ctx CAMELLIA context to be initialized
55 * \param key encryption key
56 * \param keysize must be 128, 192 or 256
58 void camellia_setkey_enc(camellia_context * ctx, const unsigned char *key,
59 int keysize);
61 /**
62 * \brief CAMELLIA key schedule (decryption)
64 * \param ctx CAMELLIA context to be initialized
65 * \param key decryption key
66 * \param keysize must be 128, 192 or 256
68 void camellia_setkey_dec(camellia_context * ctx, const unsigned char *key,
69 int keysize);
71 /**
72 * \brief CAMELLIA-ECB block encryption/decryption
74 * \param ctx CAMELLIA context
75 * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT
76 * \param input 16-byte input block
77 * \param output 16-byte output block
79 void camellia_crypt_ecb(camellia_context * ctx,
80 int mode,
81 const unsigned char input[16],
82 unsigned char output[16]);
84 /**
85 * \brief CAMELLIA-CBC buffer encryption/decryption
87 * \param ctx CAMELLIA context
88 * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT
89 * \param length length of the input data
90 * \param iv initialization vector (updated after use)
91 * \param input buffer holding the input data
92 * \param output buffer holding the output data
94 void camellia_crypt_cbc(camellia_context * ctx,
95 int mode,
96 int length,
97 unsigned char iv[16],
98 const unsigned char *input,
99 unsigned char *output);
102 * \brief CAMELLIA-CFB128 buffer encryption/decryption
104 * \param ctx CAMELLIA context
105 * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT
106 * \param length length of the input data
107 * \param iv_off offset in IV (updated after use)
108 * \param iv initialization vector (updated after use)
109 * \param input buffer holding the input data
110 * \param output buffer holding the output data
112 void camellia_crypt_cfb128(camellia_context * ctx,
113 int mode,
114 int length,
115 int *iv_off,
116 unsigned char iv[16],
117 const unsigned char *input,
118 unsigned char *output);
121 * \brief Checkup routine
123 * \return 0 if successful, or 1 if the test failed
125 int camellia_self_test(int verbose);
127 #ifdef __cplusplus
129 #endif
130 #endif /* camellia.h */