]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netinet6/esp_camellia.c
This commit was generated by cvs2svn to compensate for changes in r170349,
[FreeBSD/FreeBSD.git] / sys / netinet6 / esp_camellia.c
1 /*
2  *
3  * Copyright (c) 2006
4  * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer as
11  *   the first lines of this file unmodified.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
30
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/socket.h>
34 #include <sys/queue.h>
35
36 #include <net/if.h>
37 #include <net/route.h>
38 #include <netinet/in.h>
39
40 #include <netinet6/ipsec.h>
41 #include <netinet6/esp.h>
42 #include <netinet6/esp_camellia.h>
43
44 #include <crypto/camellia/camellia.h>
45
46 size_t
47 esp_camellia_schedlen(algo)
48         const struct esp_algorithm *algo;
49 {
50
51         return sizeof(camellia_ctx);
52 }
53
54 int
55 esp_camellia_schedule(algo, sav)
56         const struct esp_algorithm *algo;
57         struct secasvar *sav;
58 {
59         camellia_ctx *ctx;
60
61         ctx = (camellia_ctx *)sav->sched;
62         camellia_set_key(ctx,
63             (u_char *)_KEYBUF(sav->key_enc), _KEYLEN(sav->key_enc) * 8);
64         return 0;
65 }
66
67 int
68 esp_camellia_blockdecrypt(algo, sav, s, d)
69         const struct esp_algorithm *algo;
70         struct secasvar *sav;
71         u_int8_t *s;
72         u_int8_t *d;
73 {
74         camellia_ctx *ctx;
75
76         ctx = (camellia_ctx *)sav->sched;
77         camellia_decrypt(ctx, s, d);
78         return 0;
79 }
80
81 int
82 esp_camellia_blockencrypt(algo, sav, s, d)
83         const struct esp_algorithm *algo;
84         struct secasvar *sav;
85         u_int8_t *s;
86         u_int8_t *d;
87 {
88         camellia_ctx *ctx;
89
90         ctx = (camellia_ctx *)sav->sched;
91         camellia_encrypt(ctx, s, d);
92         return 0;
93 }