xref: /minix3/crypto/external/bsd/heimdal/dist/lib/hcrypto/camellia-ntt.h (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc /*	$NetBSD: camellia-ntt.h,v 1.1.1.1 2011/04/13 18:14:49 elric Exp $	*/
2*ebfedea0SLionel Sambuc 
3*ebfedea0SLionel Sambuc /* camellia.h ver 1.2.0
4*ebfedea0SLionel Sambuc  *
5*ebfedea0SLionel Sambuc  * Copyright (c) 2006,2007
6*ebfedea0SLionel Sambuc  * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
7*ebfedea0SLionel Sambuc  *
8*ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
9*ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
10*ebfedea0SLionel Sambuc  * are met:
11*ebfedea0SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
12*ebfedea0SLionel Sambuc  *   notice, this list of conditions and the following disclaimer as
13*ebfedea0SLionel Sambuc  *   the first lines of this file unmodified.
14*ebfedea0SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
15*ebfedea0SLionel Sambuc  *   notice, this list of conditions and the following disclaimer in the
16*ebfedea0SLionel Sambuc  *   documentation and/or other materials provided with the distribution.
17*ebfedea0SLionel Sambuc  *
18*ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
19*ebfedea0SLionel Sambuc  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20*ebfedea0SLionel Sambuc  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21*ebfedea0SLionel Sambuc  * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
22*ebfedea0SLionel Sambuc  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23*ebfedea0SLionel Sambuc  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*ebfedea0SLionel Sambuc  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*ebfedea0SLionel Sambuc  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*ebfedea0SLionel Sambuc  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27*ebfedea0SLionel Sambuc  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*ebfedea0SLionel Sambuc  */
29*ebfedea0SLionel Sambuc 
30*ebfedea0SLionel Sambuc #ifndef HEADER_CAMELLIA_H
31*ebfedea0SLionel Sambuc #define HEADER_CAMELLIA_H
32*ebfedea0SLionel Sambuc 
33*ebfedea0SLionel Sambuc #ifdef  __cplusplus
34*ebfedea0SLionel Sambuc extern "C" {
35*ebfedea0SLionel Sambuc #endif
36*ebfedea0SLionel Sambuc 
37*ebfedea0SLionel Sambuc #define CAMELLIA_BLOCK_SIZE 16
38*ebfedea0SLionel Sambuc #define CAMELLIA_TABLE_BYTE_LEN 272
39*ebfedea0SLionel Sambuc #define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
40*ebfedea0SLionel Sambuc 
41*ebfedea0SLionel Sambuc /* u32 must be 32bit word */
42*ebfedea0SLionel Sambuc typedef uint32_t u32;
43*ebfedea0SLionel Sambuc typedef unsigned char u8;
44*ebfedea0SLionel Sambuc 
45*ebfedea0SLionel Sambuc typedef u32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
46*ebfedea0SLionel Sambuc 
47*ebfedea0SLionel Sambuc 
48*ebfedea0SLionel Sambuc void Camellia_Ekeygen(const int keyBitLength,
49*ebfedea0SLionel Sambuc 		      const unsigned char *rawKey,
50*ebfedea0SLionel Sambuc 		      KEY_TABLE_TYPE keyTable);
51*ebfedea0SLionel Sambuc 
52*ebfedea0SLionel Sambuc void Camellia_EncryptBlock(const int keyBitLength,
53*ebfedea0SLionel Sambuc 			   const unsigned char *plaintext,
54*ebfedea0SLionel Sambuc 			   const KEY_TABLE_TYPE keyTable,
55*ebfedea0SLionel Sambuc 			   unsigned char *cipherText);
56*ebfedea0SLionel Sambuc 
57*ebfedea0SLionel Sambuc void Camellia_DecryptBlock(const int keyBitLength,
58*ebfedea0SLionel Sambuc 			   const unsigned char *cipherText,
59*ebfedea0SLionel Sambuc 			   const KEY_TABLE_TYPE keyTable,
60*ebfedea0SLionel Sambuc 			   unsigned char *plaintext);
61*ebfedea0SLionel Sambuc 
62*ebfedea0SLionel Sambuc 
63*ebfedea0SLionel Sambuc #ifdef  __cplusplus
64*ebfedea0SLionel Sambuc }
65*ebfedea0SLionel Sambuc #endif
66*ebfedea0SLionel Sambuc 
67*ebfedea0SLionel Sambuc #endif /* HEADER_CAMELLIA_H */
68