xref: /titanic_44/usr/src/uts/common/inet/kssl/kssl.h (revision 1cb875ae88fb9463b368e725c2444776595895cb)
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 2009 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 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <netinet/in.h>
35 #include <sys/crypto/common.h>
36 
37 /* These are re-definition from <crypto/ioctl.h>  */
38 typedef struct kssl_object_attribute {
39 	uint64_t	ka_type;		/* attribute type */
40 	uint32_t	ka_value_offset;	/* offset to attribute value */
41 	uint32_t	ka_value_len;		/* length of attribute value */
42 } kssl_object_attribute_t;
43 
44 typedef struct kssl_key {
45 	crypto_key_format_t ks_format;	/* format identifier */
46 	uint32_t ks_count;		/* number of attributes */
47 	uint32_t ks_attrs_offset;	/* offset to the attributes */
48 } kssl_key_t;
49 
50 typedef struct kssl_certs_s {
51 	uint32_t sc_count;		/* number of certificates */
52 	uint32_t sc_sizes_offset;	/* offset to certificates sizes array */
53 	uint32_t sc_certs_offset;	/* offset to certificates array */
54 } kssl_certs_t;
55 
56 #define	MAX_PIN_LENGTH			1024
57 
58 typedef struct kssl_tokinfo_s {
59 	uint8_t toklabel[CRYPTO_EXT_SIZE_LABEL];
60 	uint32_t pinlen;
61 	uint32_t tokpin_offset;		/* offset to the pin */
62 	uint32_t ck_rv;			/* PKCS #11 specific error */
63 } kssl_tokinfo_t;
64 
65 #define	SSL_RSA_WITH_NULL_SHA		0x0002
66 #define	SSL_RSA_WITH_RC4_128_MD5	0x0004
67 #define	SSL_RSA_WITH_RC4_128_SHA	0x0005
68 #define	SSL_RSA_WITH_DES_CBC_SHA	0x0009
69 #define	SSL_RSA_WITH_3DES_EDE_CBC_SHA	0x000a
70 #define	TLS_RSA_WITH_AES_128_CBC_SHA	0x002f
71 #define	TLS_RSA_WITH_AES_256_CBC_SHA	0x0035
72 #define	CIPHER_SUITE_COUNT		7
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_in6	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_in6 *);
112 
113 #endif	/* _KERNEL */
114 
115 #ifdef	__cplusplus
116 }
117 #endif
118 
119 #endif /* _INET_KSSL_KSSL_H */
120