Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / common / api / n8_ssltls.h
blobef3b09c71f5818583e992f26276fb812b04289ad
1 /*-
2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
3 * All rights reserved.
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>.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
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_ssltls.h 1.2@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
40 /** @file n8_ssltls.h
41 * @brief Header for SSL/TLS functionality.
43 * Protoypes and structures for SSL/TLS functions.
45 *****************************************************************************/
47 /*****************************************************************************
48 * Revision history:
49 * 05/20/03 brr Moved public constants to n8_pub_packet.h.
50 * 10/12/01 dkm Moved public portion to n8_pub_packet.h.
51 * 06/17/01 bac Added N8_TLS_VERSION.
52 * 06/14/01 bac Changes per code review: comment changes, create defines
53 * for N8_SSLTLS_MAX_DATA_SIZE_[ENCRYPT,DECRYPT] and
54 * N8_DES_BLOCK_MULTIPLE
55 * 06/05/01 bac Changes to not rely on N8_SSLTLSPacket_t being packed (Bug
56 * #31). This includes changing the definition of
57 * N8_SSLTLSPacket_t, adding SSLTLS_*_OFFSET defines, and adding
58 * macros for SSLTLS_EXTRACT_* and SSLTLS_SET_*.
59 * 05/30/01 bac Changed structure comments. Changed type of the verify_p in
60 * DecryptVerify.
61 * 05/22/01 bac Changed data definition in N8_SSLTLSPacket_t. Changed
62 * interfaces to SSLTLSDecrypt and SSLTLSAuthenticate to take and
63 * return packets instead buffers. Added prototypes for
64 * N8_GetHashLength and N8_ComputeEncryptedLength.
65 * 05/18/01 bac Converted to N8_xMALLOC and N8_xFREE
66 * 05/18/01 bac Fixed N8_SSLTLSEncryptAuthenticate prototype to match new
67 * API.
68 * 05/02/01 bac Original version.
69 ****************************************************************************/
71 #ifndef N8_SSLTLS_H
72 #define N8_SSLTLS_H
74 #include "n8_pub_packet.h"
75 #include "n8_packet.h"
77 #define N8_DES_BLOCK_MULTIPLE 8
78 #define N8_DES_MD5_MIN_LENGTH 24
79 #define N8_DES_SHA1_MIN_LENGTH 24
80 #define N8_ARC4_MD5_MIN_LENGTH 16
81 #define N8_ARC4_SHA1_MIN_LENGTH 20
83 #define SSLTLS_TYPE_OFFSET 0
84 #define SSLTLS_VERSION_OFFSET 1
85 #define SSLTLS_LENGTH_OFFSET 3
86 #define SSLTLS_DATA_OFFSET 5
87 #define SSLTLS_HEADER_LEN 5
89 #define SSLTLS_EXTRACT_TYPE(PACKET_P) (const uint8_t) (PACKET_P[SSLTLS_TYPE_OFFSET])
90 #define SSLTLS_EXTRACT_VERSION(PACKET_P) ntohs(*((const uint16_t *) &PACKET_P[SSLTLS_VERSION_OFFSET]))
91 #define SSLTLS_EXTRACT_LENGTH(PACKET_P) ntohs(*((const uint16_t *) &PACKET_P[SSLTLS_LENGTH_OFFSET]))
93 #define SSLTLS_SET_TYPE(PACKET_P, VALUE) PACKET_P[SSLTLS_TYPE_OFFSET] = (VALUE)
94 #define SSLTLS_SET_VERSION(PACKET_P, VALUE) *((uint16_t *) &PACKET_P[SSLTLS_VERSION_OFFSET]) = htons((VALUE))
95 #define SSLTLS_SET_LENGTH(PACKET_P, VALUE) *((uint16_t *) &PACKET_P[SSLTLS_LENGTH_OFFSET]) = htons((VALUE))
98 * SSL/TLS content types as defined by the protocol. Do not change the values.
100 typedef enum
102 N8_CHANGE_CIPHER_SPEC = 20,
103 N8_ALERT = 21,
104 N8_HANDSHAKE = 22,
105 N8_APPLICATION_DATA = 23
106 } N8_SSLTLS_ContentType_t;
108 /* prototypes */
110 short int N8_GetHashLength(N8_HashAlgorithm_t hash);
112 short int N8_ComputeEncryptedLength(int size, int hashLen, N8_Cipher_t cipher);
114 #endif /* N8_SSLTLS_H */