1169425Sgnn/* camellia.h ver 1.1.0 2169425Sgnn * 3169425Sgnn * Copyright (c) 2006 4169425Sgnn * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved. 5169425Sgnn * 6169425Sgnn * Redistribution and use in source and binary forms, with or without 7169425Sgnn * modification, are permitted provided that the following conditions 8169425Sgnn * are met: 9169425Sgnn * 1. Redistributions of source code must retain the above copyright 10169425Sgnn * notice, this list of conditions and the following disclaimer as 11169425Sgnn * the first lines of this file unmodified. 12169425Sgnn * 2. Redistributions in binary form must reproduce the above copyright 13169425Sgnn * notice, this list of conditions and the following disclaimer in the 14169425Sgnn * documentation and/or other materials provided with the distribution. 15169425Sgnn * 16169425Sgnn * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR 17169425Sgnn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18169425Sgnn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19169425Sgnn * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT, 20169425Sgnn * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21169425Sgnn * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22169425Sgnn * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23169425Sgnn * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24169425Sgnn * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25169425Sgnn * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26169425Sgnn * 27169425Sgnn * $FreeBSD$ 28169425Sgnn */ 29169425Sgnn 30169425Sgnn#ifndef _CAMELLIA_H 31169425Sgnn#define _CAMELLIA_H 32169425Sgnn 33169425Sgnn#define CAMELLIA_BLOCK_SIZE 16 34169425Sgnn#define CAMELLIA_SUBKEYWORD 68 /* (34*8/4) */ 35169425Sgnn 36169425Sgnntypedef struct { 37169425Sgnn int bits; /* key-length */ 38169425Sgnn uint32_t subkey[CAMELLIA_SUBKEYWORD]; /* encrypt/decrypt key schedule */ 39169425Sgnn} camellia_ctx; 40169425Sgnn 41169425Sgnnvoid camellia_set_key(camellia_ctx *, const u_char *, int); 42169425Sgnnvoid camellia_decrypt(const camellia_ctx *, const u_char *, u_char *); 43169425Sgnnvoid camellia_encrypt(const camellia_ctx *, const u_char *, u_char *); 44169425Sgnn 45169425Sgnn 46169425Sgnnvoid Camellia_Ekeygen(const int keyBitLength, 47169425Sgnn const unsigned char *rawKey, 48169425Sgnn uint32_t *subkey); 49169425Sgnn 50169425Sgnnvoid Camellia_EncryptBlock(const int keyBitLength, 51169425Sgnn const unsigned char *plaintext, 52169425Sgnn const uint32_t *subkey, 53169425Sgnn unsigned char *cipherText); 54169425Sgnn 55169425Sgnnvoid Camellia_DecryptBlock(const int keyBitLength, 56169425Sgnn const unsigned char *cipherText, 57169425Sgnn const uint32_t *subkey, 58169425Sgnn unsigned char *plaintext); 59169425Sgnn 60169425Sgnnvoid camellia_setup128(const unsigned char *key, uint32_t *subkey); 61169425Sgnnvoid camellia_setup192(const unsigned char *key, uint32_t *subkey); 62169425Sgnnvoid camellia_setup256(const unsigned char *key, uint32_t *subkey); 63169425Sgnnvoid camellia_encrypt128(const uint32_t *subkey, uint32_t *io); 64169425Sgnnvoid camellia_encrypt256(const uint32_t *subkey, uint32_t *io); 65169425Sgnnvoid camellia_decrypt128(const uint32_t *subkey, uint32_t *io); 66169425Sgnnvoid camellia_decrypt256(const uint32_t *subkey, uint32_t *io); 67169425Sgnn 68169425Sgnn 69169425Sgnn#endif /* _CAMELLIA_H */ 70