Commit a4d89a90 authored by Niels Möller's avatar Niels Möller

* Makefile.in (nettle_SOURCES): Added camellia.c and

camellia-meta.c.
(HEADERS): Added camellia.h.

* camellia-meta.c: New file.

* camellia.h: Rewrote interface to match nettle conventions.

* camellia.c: Converted to nettle conventions.
(camellia_encrypt128, camellia_encrypt256): Unified to new
function...
(camellia_encrypt): ...New function, with a loop doing 6
regular rounds, one FL round and one FLINV round per iteration,
with iteration count depending on the key size.

Rev: nettle/ChangeLog:1.89
Rev: nettle/Makefile.in:1.25
Rev: nettle/camellia-meta.c:1.1
Rev: nettle/camellia.c:1.2
Rev: nettle/camellia.h:1.2
parent 0357ab51
2010-07-07 Niels Mller <nisse@lysator.liu.se>
* Makefile.in (nettle_SOURCES): Added camellia.c and
camellia-meta.c.
(HEADERS): Added camellia.h.
* nettle-meta.h (nettle_camellia128): Declare.
(nettle_camellia192): Likewise.
(nettle_camellia256): Likewise.
* camellia-meta.c: New file.
* camellia.h: Rewrote interface to match nettle conventions.
* camellia.c: Converted to nettle conventions.
(camellia_encrypt128, camellia_encrypt256): Unified to new
function...
(camellia_encrypt): ...New function, with a loop doing 6
regular rounds, one FL round and one FLINV round per iteration,
with iteration count depending on the key size.
(camellia_decrypt128, camellia_decrypt256): Similarly unified
as...
(camellia_decrypt): ...New function, analogous to
camellia_encrypt.
2010-07-06 Niels Mller <nisse@lysator.liu.se>
* camellia.c, camellia.h: New files, copied from
http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/camellia-LGPL-1.2.0.tar.gz.
* testsuite/camellia-test.c: New file.
2010-07-05 Niels Mller <nisse@lysator.liu.se>
* nettle.texinfo: Document new conventions for weak key and des
......
......@@ -55,7 +55,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
arctwo.c arctwo-meta.c \
base16-encode.c base16-decode.c base16-meta.c \
base64-encode.c base64-decode.c base64-meta.c \
cast128.c cast128-meta.c \
camellia.c camellia-meta.c cast128.c cast128-meta.c \
blowfish.c \
cbc.c ctr.c \
des.c \
......@@ -97,7 +97,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \
der-iterator.c der2rsa.c der2dsa.c
HEADERS = aes.h arcfour.h arctwo.h asn1.h bignum.h blowfish.h \
base16.h base64.h buffer.h cast128.h \
base16.h base64.h buffer.h camellia.h cast128.h \
cbc.h ctr.h \
des.h des-compat.h dsa.h \
hmac.h \
......
/* camellia-meta.c */
/* nettle, low-level cryptographics library
*
* Copyright (C) 2010 Niels Mller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "nettle-meta.h"
#include "camellia.h"
const struct nettle_cipher nettle_camellia128
= _NETTLE_CIPHER(camellia, CAMELLIA, 128);
const struct nettle_cipher nettle_camellia192
= _NETTLE_CIPHER(camellia, CAMELLIA, 192);
const struct nettle_cipher nettle_camellia256
= _NETTLE_CIPHER(camellia, CAMELLIA, 256);
This diff is collapsed.
/* camellia.h ver 1.2.0
/* camellia.h
*
* Copyright (C) 2006,2007
* NTT (Nippon Telegraph and Telephone Corporation).
*
* Copyright (C) 2010 Niels Mller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
......@@ -18,37 +20,80 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HEADER_CAMELLIA_H
#define HEADER_CAMELLIA_H
#ifndef NETTLE_CAMELLIA_H_INCLUDED
#define NETTLE_CAMELLIA_H_INCLUDED
#ifdef __cplusplus
#include "nettle-types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Name mangling */
#define camellia_set_key nettle_camellia_set_key
#define camellia_encrypt nettle_camellia_encrypt
#define camellia_decrypt nettle_camellia_decrypt
#define CAMELLIA_BLOCK_SIZE 16
#define CAMELLIA_TABLE_BYTE_LEN 272
#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
/* Valid key sizes are 128, 192 or 256 bits (16, 24 or 32 bytes) */
#define CAMELLIA_MIN_KEY_SIZE 16
#define CAMELLIA_MAX_KEY_SIZE 32
#define CAMELLIA_KEY_SIZE 32
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
struct camellia_ctx
{
int camellia128;
/* For 128-bit keys, there are 18 regular rounds, pre- and
post-whitening, and two FL and FLINV rounds, using a total of 26
subkeys, each of 64 bit. For 192- and 256-bit keys, there are 6
additional regular rounds and one additional FL and FLINV, using
a total of 34 subkeys. */
/* The clever combination of subkeys imply one of the pre- and
post-whitening keys is folded fith the round keys, so that subkey
subkey #1 and the last one (#25 or #33) is not used. FIXME:
Renumber to eliminate them. */
/* FIXME: For 64-bit machines, don't split in 32-bit halves. */
uint32_t keys[34][2];
};
void Camellia_Ekeygen(const int keyBitLength,
const unsigned char *rawKey,
KEY_TABLE_TYPE keyTable);
void
camellia_set_key(struct camellia_ctx *ctx,
unsigned length, const uint8_t *key);
void Camellia_EncryptBlock(const int keyBitLength,
const unsigned char *plaintext,
const KEY_TABLE_TYPE keyTable,
unsigned char *cipherText);
void
camellia_encrypt(const struct camellia_ctx *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src);
void
camellia_decrypt(const struct camellia_ctx *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src);
void Camellia_DecryptBlock(const int keyBitLength,
const unsigned char *cipherText,
const KEY_TABLE_TYPE keyTable,
unsigned char *plaintext);
#if 0
/* FIXME: Use a single crypt function, and let key setup for
decryption reverse the order of the subkeys. */
void
camellia_set_encrypt_key(struct camellia_ctx *ctx,
unsigned length, const uint8_t *key);
void
camellia_set_decrypt_key(struct camellia_ctx *ctx,
unsigned length, const uint8_t *key);
void
camellia_crypt(struct camellia_ctx *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src);
void
camellia_invert_key(struct camellia_ctx *dst,
const struct camellia_ctx *src);
#endif
#ifdef __cplusplus
}
#endif
#endif /* HEADER_CAMELLIA_H */
#endif /* NETTLE_CAMELLIA_H_INCLUDED */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment