2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
5 * NBMK Encryption Technologies provides no support of any kind for
6 * this software. Questions or concerns about it may be addressed to
7 * the members of the relevant open-source community at
8 * <tech-crypto@netbsd.org>.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /*****************************************************************************
36 * @(#) n8_pub_symmetric.h 1.7@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
40 /** @file n8_pub_symmetric
41 * @brief Common declarations for symmetric (encrypt/decrypt) operations.
43 * Public header file for encrypt/decrypt symmetric (private key) operations.
45 *****************************************************************************/
47 /*****************************************************************************
49 * 05/20/03 brr Move defines for message length to this public include.
50 * 06/12/02 bac Corrected lengthof keyARC4 in N8_Key_t (Bug #768)
51 * 11/28/01 mel Fixed bug #365 : ARC4 key type N8_RC4_t incorrectly declared
52 * 11/12/01 hml Added structureID to N8_EncryptObject_t.
53 * 10/12/01 dkm Original version. Adapted from n8_types.h.
54 ****************************************************************************/
55 #ifndef N8_PUB_SYMMETRIC_H
56 #define N8_PUB_SYMMETRIC_H
63 #include "n8_pub_common.h"
65 /*****************************************************************************
67 *****************************************************************************/
68 #define N8_DES_BLOCK_LENGTH 8
69 #define N8_ARC4_MAX_LENGTH 256
71 #define N8_MAX_MESSAGE_LENGTH (18 * 1024)
72 #define N8_MIN_MESSAGE_LENGTH 0
74 /*****************************************************************************
75 * Structures/type definitions
76 *****************************************************************************/
80 char IV
[N8_DES_KEY_LENGTH
];
81 char key1
[N8_DES_KEY_LENGTH
];
82 char key2
[N8_DES_KEY_LENGTH
];
83 char key3
[N8_DES_KEY_LENGTH
];
89 N8_Buffer_t keyARC4
[N8_ARC4_MAX_LENGTH
]; /* specifies ARC4 key to use */
90 N8_DES_t keyDES
; /* specifies data to use with IPSec*/
95 uint32_t sequence_number
[2];
96 unsigned int keySize
; /* keys size for verification */
97 N8_Key_t key
; /* specific protocol data */
98 N8_Unit_t unitID
; /* The unit number for ops using this */
104 N8_Cipher_t cipher
; /* cipher: ARC4, DES*/
105 N8_ContextHandle_t contextHandle
;
106 N8_EncryptCipher_t cipherInfo
; /* keys to use */
107 N8_Buffer_t residual_p
[N8_DES_BLOCK_LENGTH
];
108 unsigned int residualLength
;
109 N8_Unit_t unitID
; /* The unit number for ops using this */
110 unsigned int structureID
;
111 } N8_EncryptObject_t
;
113 /*****************************************************************************
114 * Function prototypes
115 *****************************************************************************/
116 N8_Status_t
N8_EncryptInitialize(N8_EncryptObject_t
*encryptObject_p
,
117 const N8_ContextHandle_t
*contextHandle_p
,
118 const N8_Cipher_t cipher
,
119 N8_EncryptCipher_t
*cipherInfo_p
,
120 N8_Event_t
*event_p
);
122 N8_Status_t
N8_Encrypt(N8_EncryptObject_t
*encryptObject_p
,
123 const N8_Buffer_t
*message_p
,
124 const unsigned int messageLength
,
125 N8_Buffer_t
*encryptedMessage_p
,
126 N8_Event_t
*event_p
);
128 N8_Status_t
N8_Encrypt_uio(N8_EncryptObject_t
*encryptObject_p
,
129 struct uio
*message_p
,
130 const unsigned int messageLength
,
131 struct uio
*encryptedMessage_p
,
132 N8_Event_t
*event_p
);
134 N8_Status_t
N8_EncryptPartial(N8_EncryptObject_t
*encryptObject_p
,
135 const N8_Buffer_t
*message_p
,
136 const unsigned int messageLength
,
137 N8_Buffer_t
*encryptedMessage_p
,
138 unsigned int *encryptedMsgLen_p
,
139 N8_Event_t
*event_p
);
141 N8_Status_t
N8_EncryptEnd(N8_EncryptObject_t
*encryptObject_p
,
142 N8_Buffer_t
*encryptedMessage_p
,
143 unsigned int *encryptedMessageLength
,
144 N8_Event_t
*event_p
);
146 N8_Status_t
N8_Decrypt(N8_EncryptObject_t
*encryptObject_p
,
147 const N8_Buffer_t
*encryptedMessage_p
,
148 const unsigned int encryptedMessageLength
,
149 N8_Buffer_t
*message_p
,
150 N8_Event_t
*event_p
);
152 N8_Status_t
N8_Decrypt_uio(N8_EncryptObject_t
*encryptObject_p
,
153 struct uio
*encryptedMessage_p
,
154 const unsigned int encryptedMessageLength
,
155 struct uio
*message_p
,
156 N8_Event_t
*event_p
);
158 N8_Status_t
N8_DecryptPartial(N8_EncryptObject_t
*encryptObject_p
,
159 const N8_Buffer_t
*encryptedMessage_p
,
160 const unsigned int encryptedMessageLength
,
161 N8_Buffer_t
*message_p
,
162 unsigned int *messageLength
,
163 N8_Event_t
*event_p
);
165 N8_Status_t
N8_DecryptEnd(N8_EncryptObject_t
*encryptObject_p
,
166 N8_Buffer_t
*message_p
,
167 unsigned int *messageLength
,
168 N8_Event_t
*event_p
);