xref: /freebsd/sys/crypto/camellia/camellia.h (revision 559d3390d07890da9ca8ad6427f1ae7df7a9257a)
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  * $FreeBSD$
28559d3390SGeorge V. Neville-Neil  */
29559d3390SGeorge V. Neville-Neil 
30559d3390SGeorge V. Neville-Neil #ifndef _CAMELLIA_H
31559d3390SGeorge V. Neville-Neil #define _CAMELLIA_H
32559d3390SGeorge V. Neville-Neil 
33559d3390SGeorge V. Neville-Neil #define CAMELLIA_BLOCK_SIZE 16
34559d3390SGeorge V. Neville-Neil #define CAMELLIA_SUBKEYWORD 68 /* (34*8/4) */
35559d3390SGeorge V. Neville-Neil 
36559d3390SGeorge V. Neville-Neil typedef struct {
37559d3390SGeorge V. Neville-Neil     int	bits;				      /* key-length */
38559d3390SGeorge V. Neville-Neil     uint32_t subkey[CAMELLIA_SUBKEYWORD]; /* encrypt/decrypt key schedule */
39559d3390SGeorge V. Neville-Neil } camellia_ctx;
40559d3390SGeorge V. Neville-Neil 
41559d3390SGeorge V. Neville-Neil void camellia_set_key(camellia_ctx *, const u_char *, int);
42559d3390SGeorge V. Neville-Neil void camellia_decrypt(const camellia_ctx *, const u_char *, u_char *);
43559d3390SGeorge V. Neville-Neil void camellia_encrypt(const camellia_ctx *, const u_char *, u_char *);
44559d3390SGeorge V. Neville-Neil 
45559d3390SGeorge V. Neville-Neil 
46559d3390SGeorge V. Neville-Neil void Camellia_Ekeygen(const int keyBitLength,
47559d3390SGeorge V. Neville-Neil 		      const unsigned char *rawKey,
48559d3390SGeorge V. Neville-Neil 		      uint32_t *subkey);
49559d3390SGeorge V. Neville-Neil 
50559d3390SGeorge V. Neville-Neil void Camellia_EncryptBlock(const int keyBitLength,
51559d3390SGeorge V. Neville-Neil 			   const unsigned char *plaintext,
52559d3390SGeorge V. Neville-Neil 			   const uint32_t *subkey,
53559d3390SGeorge V. Neville-Neil 			   unsigned char *cipherText);
54559d3390SGeorge V. Neville-Neil 
55559d3390SGeorge V. Neville-Neil void Camellia_DecryptBlock(const int keyBitLength,
56559d3390SGeorge V. Neville-Neil 			   const unsigned char *cipherText,
57559d3390SGeorge V. Neville-Neil 			   const uint32_t *subkey,
58559d3390SGeorge V. Neville-Neil 			   unsigned char *plaintext);
59559d3390SGeorge V. Neville-Neil 
60559d3390SGeorge V. Neville-Neil void camellia_setup128(const unsigned char *key, uint32_t *subkey);
61559d3390SGeorge V. Neville-Neil void camellia_setup192(const unsigned char *key, uint32_t *subkey);
62559d3390SGeorge V. Neville-Neil void camellia_setup256(const unsigned char *key, uint32_t *subkey);
63559d3390SGeorge V. Neville-Neil void camellia_encrypt128(const uint32_t *subkey, uint32_t *io);
64559d3390SGeorge V. Neville-Neil void camellia_encrypt256(const uint32_t *subkey, uint32_t *io);
65559d3390SGeorge V. Neville-Neil void camellia_decrypt128(const uint32_t *subkey, uint32_t *io);
66559d3390SGeorge V. Neville-Neil void camellia_decrypt256(const uint32_t *subkey, uint32_t *io);
67559d3390SGeorge V. Neville-Neil 
68559d3390SGeorge V. Neville-Neil 
69559d3390SGeorge V. Neville-Neil #endif /* _CAMELLIA_H */
70