xref: /titanic_50/usr/src/uts/common/inet/kssl/kssl.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_KSSL_KSSL_H
27 #define	_INET_KSSL_KSSL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/types.h>
36 #include <netinet/in.h>
37 #include <sys/crypto/common.h>
38 
39 /* These are re-definition from <crypto/ioctl.h>  */
40 typedef struct kssl_object_attribute {
41 	uint64_t	ka_type;		/* attribute type */
42 	uint32_t	ka_value_offset;	/* offset to attribute value */
43 	uint32_t	ka_value_len;		/* length of attribute value */
44 } kssl_object_attribute_t;
45 
46 typedef struct kssl_key {
47 	crypto_key_format_t ks_format;	/* format identifier */
48 	uint32_t ks_count;		/* number of attributes */
49 	uint32_t ks_attrs_offset;	/* offset to the attributes */
50 } kssl_key_t;
51 
52 typedef struct kssl_certs_s {
53 	uint32_t sc_count;		/* number of certificates */
54 	uint32_t sc_sizes_offset;	/* offset to certificates sizes array */
55 	uint32_t sc_certs_offset;	/* offset to certificates array */
56 } kssl_certs_t;
57 
58 #define	MAX_PIN_LENGTH			1024
59 
60 typedef struct kssl_tokinfo_s {
61 	uint8_t toklabel[CRYPTO_EXT_SIZE_LABEL];
62 	uint32_t pinlen;
63 	uint32_t tokpin_offset;		/* offset to the pin */
64 	uint32_t ck_rv;			/* PKCS #11 specific error */
65 } kssl_tokinfo_t;
66 
67 #define	SSL_RSA_WITH_NULL_SHA		0x0002
68 #define	SSL_RSA_WITH_RC4_128_MD5	0x0004
69 #define	SSL_RSA_WITH_RC4_128_SHA	0x0005
70 #define	SSL_RSA_WITH_DES_CBC_SHA	0x0009
71 #define	SSL_RSA_WITH_3DES_EDE_CBC_SHA	0x000a
72 #define	CIPHER_SUITE_COUNT		5
73 #define	CIPHER_NOTSET			0xffff
74 
75 #define	DEFAULT_SID_TIMEOUT		86400	/* 24 hours in seconds */
76 #define	DEFAULT_SID_CACHE_NENTRIES	5000
77 
78 typedef struct kssl_params_s {
79 	uint64_t		kssl_params_size; /* total params buf len */
80 	/* address and port number */
81 	struct sockaddr_in	kssl_addr;
82 	uint16_t		kssl_proxy_port;
83 
84 	uint32_t		kssl_session_cache_timeout;	/* In seconds */
85 	uint32_t		kssl_session_cache_size;
86 
87 	/*
88 	 * Contains ordered list of cipher suites. We do not include
89 	 * the one suite with no encryption. Hence the -1.
90 	 */
91 	uint16_t		kssl_suites[CIPHER_SUITE_COUNT - 1];
92 
93 	uint8_t			kssl_is_nxkey;
94 	kssl_tokinfo_t		kssl_token;
95 
96 	/* certificates */
97 	kssl_certs_t		kssl_certs;
98 
99 	/* private key */
100 	kssl_key_t		kssl_privkey;
101 } kssl_params_t;
102 
103 /* The ioctls to /dev/kssl */
104 #define	KSSL_IOC(x)		(('s' << 24) | ('s' << 16) | ('l' << 8) | (x))
105 #define	KSSL_ADD_ENTRY		KSSL_IOC(1)
106 #define	KSSL_DELETE_ENTRY	KSSL_IOC(2)
107 
108 #ifdef	_KERNEL
109 
110 extern int kssl_add_entry(kssl_params_t *);
111 extern int kssl_delete_entry(struct sockaddr_in *);
112 
113 #endif	/* _KERNEL */
114 
115 #ifdef	__cplusplus
116 }
117 #endif
118 
119 #endif /* _INET_KSSL_KSSL_H */
120