camellia-api.c revision 1.1.6.2 1 1.1.6.2 jruoho /* $NetBSD: camellia-api.c,v 1.1.6.2 2011/06/06 09:07:36 jruoho Exp $ */
2 1.1.6.2 jruoho
3 1.1.6.2 jruoho /*
4 1.1.6.2 jruoho *
5 1.1.6.2 jruoho * Copyright (c) 2006
6 1.1.6.2 jruoho * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
7 1.1.6.2 jruoho *
8 1.1.6.2 jruoho * Redistribution and use in source and binary forms, with or without
9 1.1.6.2 jruoho * modification, are permitted provided that the following conditions
10 1.1.6.2 jruoho * are met:
11 1.1.6.2 jruoho * 1. Redistributions of source code must retain the above copyright
12 1.1.6.2 jruoho * notice, this list of conditions and the following disclaimer as
13 1.1.6.2 jruoho * the first lines of this file unmodified.
14 1.1.6.2 jruoho * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.6.2 jruoho * notice, this list of conditions and the following disclaimer in the
16 1.1.6.2 jruoho * documentation and/or other materials provided with the distribution.
17 1.1.6.2 jruoho *
18 1.1.6.2 jruoho * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
19 1.1.6.2 jruoho * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1.6.2 jruoho * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1.6.2 jruoho * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1.6.2 jruoho * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1.6.2 jruoho * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1.6.2 jruoho * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1.6.2 jruoho * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1.6.2 jruoho * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1.6.2 jruoho * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1.6.2 jruoho */
29 1.1.6.2 jruoho
30 1.1.6.2 jruoho #include <sys/cdefs.h>
31 1.1.6.2 jruoho
32 1.1.6.2 jruoho #include <sys/types.h>
33 1.1.6.2 jruoho #include <crypto/camellia/camellia.h>
34 1.1.6.2 jruoho
35 1.1.6.2 jruoho void
36 1.1.6.2 jruoho camellia_set_key(camellia_ctx *ctx, const u_char *key, int bits)
37 1.1.6.2 jruoho {
38 1.1.6.2 jruoho
39 1.1.6.2 jruoho Camellia_Ekeygen(bits, key, ctx->subkey);
40 1.1.6.2 jruoho ctx->bits = bits;
41 1.1.6.2 jruoho }
42 1.1.6.2 jruoho
43 1.1.6.2 jruoho void
44 1.1.6.2 jruoho camellia_decrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)
45 1.1.6.2 jruoho {
46 1.1.6.2 jruoho
47 1.1.6.2 jruoho Camellia_DecryptBlock(ctx->bits, src, ctx->subkey, dst);
48 1.1.6.2 jruoho }
49 1.1.6.2 jruoho
50 1.1.6.2 jruoho void
51 1.1.6.2 jruoho camellia_encrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)
52 1.1.6.2 jruoho {
53 1.1.6.2 jruoho
54 1.1.6.2 jruoho Camellia_EncryptBlock(ctx->bits, src, ctx->subkey, dst);
55 1.1.6.2 jruoho }
56