xref: /titanic_44/usr/src/uts/common/inet/kssl/kssl.h (revision 349b53dd4e695e3d833b5380540385145b2d3ae8)
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 2008 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	TLS_RSA_WITH_AES_128_CBC_SHA	0x002f
73 #define	TLS_RSA_WITH_AES_256_CBC_SHA	0x0035
74 #define	CIPHER_SUITE_COUNT		7
75 #define	CIPHER_NOTSET			0xffff
76 
77 #define	DEFAULT_SID_TIMEOUT		86400	/* 24 hours in seconds */
78 #define	DEFAULT_SID_CACHE_NENTRIES	5000
79 
80 typedef struct kssl_params_s {
81 	uint64_t		kssl_params_size; /* total params buf len */
82 	/* address and port number */
83 	struct sockaddr_in	kssl_addr;
84 	uint16_t		kssl_proxy_port;
85 
86 	uint32_t		kssl_session_cache_timeout;	/* In seconds */
87 	uint32_t		kssl_session_cache_size;
88 
89 	/*
90 	 * Contains ordered list of cipher suites. We do not include
91 	 * the one suite with no encryption. Hence the -1.
92 	 */
93 	uint16_t		kssl_suites[CIPHER_SUITE_COUNT - 1];
94 
95 	uint8_t			kssl_is_nxkey;
96 	kssl_tokinfo_t		kssl_token;
97 
98 	/* certificates */
99 	kssl_certs_t		kssl_certs;
100 
101 	/* private key */
102 	kssl_key_t		kssl_privkey;
103 } kssl_params_t;
104 
105 /* The ioctls to /dev/kssl */
106 #define	KSSL_IOC(x)		(('s' << 24) | ('s' << 16) | ('l' << 8) | (x))
107 #define	KSSL_ADD_ENTRY		KSSL_IOC(1)
108 #define	KSSL_DELETE_ENTRY	KSSL_IOC(2)
109 
110 #ifdef	_KERNEL
111 
112 extern int kssl_add_entry(kssl_params_t *);
113 extern int kssl_delete_entry(struct sockaddr_in *);
114 
115 #endif	/* _KERNEL */
116 
117 #ifdef	__cplusplus
118 }
119 #endif
120 
121 #endif /* _INET_KSSL_KSSL_H */
122