xref: /freebsd/sys/crypto/camellia/camellia.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1559d3390SGeorge V. Neville-Neil /* camellia.h ver 1.1.0
2559d3390SGeorge V. Neville-Neil  *
3559d3390SGeorge V. Neville-Neil  * Copyright (c) 2006
4559d3390SGeorge V. Neville-Neil  * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
5559d3390SGeorge V. Neville-Neil  *
6559d3390SGeorge V. Neville-Neil  * Redistribution and use in source and binary forms, with or without
7559d3390SGeorge V. Neville-Neil  * modification, are permitted provided that the following conditions
8559d3390SGeorge V. Neville-Neil  * are met:
9559d3390SGeorge V. Neville-Neil  * 1. Redistributions of source code must retain the above copyright
10559d3390SGeorge V. Neville-Neil  *   notice, this list of conditions and the following disclaimer as
11559d3390SGeorge V. Neville-Neil  *   the first lines of this file unmodified.
12559d3390SGeorge V. Neville-Neil  * 2. Redistributions in binary form must reproduce the above copyright
13559d3390SGeorge V. Neville-Neil  *   notice, this list of conditions and the following disclaimer in the
14559d3390SGeorge V. Neville-Neil  *   documentation and/or other materials provided with the distribution.
15559d3390SGeorge V. Neville-Neil  *
16559d3390SGeorge V. Neville-Neil  * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
17559d3390SGeorge V. Neville-Neil  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18559d3390SGeorge V. Neville-Neil  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19559d3390SGeorge V. Neville-Neil  * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
20559d3390SGeorge V. Neville-Neil  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21559d3390SGeorge V. Neville-Neil  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22559d3390SGeorge V. Neville-Neil  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23559d3390SGeorge V. Neville-Neil  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24559d3390SGeorge V. Neville-Neil  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25559d3390SGeorge V. Neville-Neil  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26559d3390SGeorge V. Neville-Neil  */
27559d3390SGeorge V. Neville-Neil 
28559d3390SGeorge V. Neville-Neil #ifndef _CAMELLIA_H
29559d3390SGeorge V. Neville-Neil #define _CAMELLIA_H
30559d3390SGeorge V. Neville-Neil 
31559d3390SGeorge V. Neville-Neil #define CAMELLIA_BLOCK_SIZE 16
32559d3390SGeorge V. Neville-Neil #define CAMELLIA_SUBKEYWORD 68 /* (34*8/4) */
33559d3390SGeorge V. Neville-Neil 
34559d3390SGeorge V. Neville-Neil typedef struct {
35559d3390SGeorge V. Neville-Neil     int	bits;				      /* key-length */
36559d3390SGeorge V. Neville-Neil     uint32_t subkey[CAMELLIA_SUBKEYWORD]; /* encrypt/decrypt key schedule */
37559d3390SGeorge V. Neville-Neil } camellia_ctx;
38559d3390SGeorge V. Neville-Neil 
39559d3390SGeorge V. Neville-Neil void camellia_set_key(camellia_ctx *, const u_char *, int);
40559d3390SGeorge V. Neville-Neil void camellia_decrypt(const camellia_ctx *, const u_char *, u_char *);
41559d3390SGeorge V. Neville-Neil void camellia_encrypt(const camellia_ctx *, const u_char *, u_char *);
42559d3390SGeorge V. Neville-Neil 
43559d3390SGeorge V. Neville-Neil 
44559d3390SGeorge V. Neville-Neil void Camellia_Ekeygen(const int keyBitLength,
45559d3390SGeorge V. Neville-Neil 		      const unsigned char *rawKey,
46559d3390SGeorge V. Neville-Neil 		      uint32_t *subkey);
47559d3390SGeorge V. Neville-Neil 
48559d3390SGeorge V. Neville-Neil void Camellia_EncryptBlock(const int keyBitLength,
49559d3390SGeorge V. Neville-Neil 			   const unsigned char *plaintext,
50559d3390SGeorge V. Neville-Neil 			   const uint32_t *subkey,
51559d3390SGeorge V. Neville-Neil 			   unsigned char *cipherText);
52559d3390SGeorge V. Neville-Neil 
53559d3390SGeorge V. Neville-Neil void Camellia_DecryptBlock(const int keyBitLength,
54559d3390SGeorge V. Neville-Neil 			   const unsigned char *cipherText,
55559d3390SGeorge V. Neville-Neil 			   const uint32_t *subkey,
56559d3390SGeorge V. Neville-Neil 			   unsigned char *plaintext);
57559d3390SGeorge V. Neville-Neil 
58559d3390SGeorge V. Neville-Neil void camellia_setup128(const unsigned char *key, uint32_t *subkey);
59559d3390SGeorge V. Neville-Neil void camellia_setup192(const unsigned char *key, uint32_t *subkey);
60559d3390SGeorge V. Neville-Neil void camellia_setup256(const unsigned char *key, uint32_t *subkey);
61559d3390SGeorge V. Neville-Neil void camellia_encrypt128(const uint32_t *subkey, uint32_t *io);
62559d3390SGeorge V. Neville-Neil void camellia_encrypt256(const uint32_t *subkey, uint32_t *io);
63559d3390SGeorge V. Neville-Neil void camellia_decrypt128(const uint32_t *subkey, uint32_t *io);
64559d3390SGeorge V. Neville-Neil void camellia_decrypt256(const uint32_t *subkey, uint32_t *io);
65559d3390SGeorge V. Neville-Neil 
66559d3390SGeorge V. Neville-Neil 
67559d3390SGeorge V. Neville-Neil #endif /* _CAMELLIA_H */
68