source: trunk/packages/xen-3.1/xen-3.1/tools/vnet/vnet-module/esp.h @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 3.0 KB
Line 
1/*
2 * Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free software Foundation, Inc.,
16 * 59 Temple Place, suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19#ifndef __VNET_ESP_H__
20#define __VNET_ESP_H__
21
22#ifdef __KERNEL__
23#include <linux/config.h>
24#include <linux/types.h>
25#include <linux/crypto.h>
26
27#else
28
29#include "sys_kernel.h"
30
31struct crypto_tfm;
32
33#endif
34
35/** Header used by IPSEC ESP (Encapsulated Security Payload). */
36typedef struct ESPHdr {
37    /** The spi (security parameters index). */
38    u32 spi;
39    /** Sequence number. */
40    u32 seq;
41    /* Variable length data (depends on crypto suite).
42       Mind the 64 bit alignment! */
43    u8  data[0];
44} ESPHdr;
45
46/** Padding trailer used by IPSEC ESP.
47 * Follows the padding itself with the padding length and the
48 * protocol being encapsulated.
49 */
50typedef struct ESPPadding {
51    u8 pad_n;
52    u8 protocol;
53} ESPPadding;
54
55/** Size of the esp header (spi and seq). */
56static const int ESP_HDR_N = sizeof(ESPHdr);
57
58/** Size of the esp pad and next protocol field. */
59static const int ESP_PAD_N = sizeof(ESPPadding);
60
61enum {
62    SASTATE_VOID,
63    SASTATE_ACQUIRE,
64    SASTATE_VALID,
65    SASTATE_ERROR,
66    SASTATE_EXPIRED,
67    SASTATE_DEAD,
68};
69
70struct ESPState;
71
72/** A cipher instance. */
73typedef struct ESPCipher {
74    /** Cipher key. */
75    u8 *key;
76    /** Key size (bytes). */
77    int key_n;
78    /** Initialization vector (IV). */
79    u8 *iv;
80    /** IV size (bytes). */
81    int iv_n;
82    /** Block size for padding (bytes). */
83    int pad_n;
84    /** Cipher block size (bytes). */
85    int block_n;
86    /** Cipher crypto transform. */
87    struct crypto_tfm *tfm;
88} ESPCipher;
89
90/** A digest instance. */
91typedef struct ESPDigest {
92    /** Digest key. */
93    u8 *key;
94    /** Key size (bytes) */
95    int key_n;
96    /** ICV size used (bytes). */
97    u8 icv_n;
98    /** Full ICV size when computed (bytes). */
99    u8 icv_full_n;
100    /** Working storage for computing ICV. */
101    u8 *icv_tmp;
102    /** Function used to compute ICV (e.g. HMAC). */
103    void (*icv)(struct ESPState *esp,
104                struct sk_buff *skb,
105                int offset,
106                int len,
107                u8 *icv);
108    /** Digest crypto transform (e.g. SHA). */
109    struct crypto_tfm *tfm;
110} ESPDigest;
111
112typedef struct ESPState {
113    struct ESPCipher cipher;
114    struct ESPDigest digest;
115} ESPState;
116
117extern int esp_module_init(void);
118extern void esp_module_exit(void);
119
120#endif /* !__VNET_ESP_H__ */
Note: See TracBrowser for help on using the repository browser.