xref: /onnv-gate/usr/src/uts/common/inet/kssl/ksslapi.h (revision 5850:0ec7030e8335)
1898Skais /*
2898Skais  * CDDL HEADER START
3898Skais  *
4898Skais  * The contents of this file are subject to the terms of the
5*5850Svk199839  * Common Development and Distribution License (the "License").
6*5850Svk199839  * You may not use this file except in compliance with the License.
7898Skais  *
8898Skais  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9898Skais  * or http://www.opensolaris.org/os/licensing.
10898Skais  * See the License for the specific language governing permissions
11898Skais  * and limitations under the License.
12898Skais  *
13898Skais  * When distributing Covered Code, include this CDDL HEADER in each
14898Skais  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15898Skais  * If applicable, add the following below this CDDL HEADER, with the
16898Skais  * fields enclosed by brackets "[]" replaced with your own identifying
17898Skais  * information: Portions Copyright [yyyy] [name of copyright owner]
18898Skais  *
19898Skais  * CDDL HEADER END
20898Skais  */
21898Skais /*
22*5850Svk199839  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23898Skais  * Use is subject to license terms.
24898Skais  */
25898Skais 
26898Skais #ifndef	_INET_KSSL_KSSLAPI_H
27898Skais #define	_INET_KSSL_KSSLAPI_H
28898Skais 
29898Skais #pragma ident	"%Z%%M%	%I%	%E% SMI"
30898Skais 
31898Skais /*
32898Skais  * The kernel SSL proxy interface
33898Skais  */
34898Skais 
35898Skais 
36898Skais #ifdef	__cplusplus
37898Skais extern "C" {
38898Skais #endif
39898Skais 
40898Skais #include	<sys/socket.h>
41898Skais #include	<netinet/in.h>
42898Skais 
43898Skais /* return status for the kssl API functions */
44898Skais 
45898Skais typedef enum {
46898Skais 	KSSL_STS_OK,	/* No further processing required */
47898Skais 	KSSL_STS_ERR	/* bogus argument  ... */
48898Skais } kssl_status_t;
49898Skais 
50898Skais /* Endpoint type */
51898Skais typedef	enum {
52898Skais 	KSSL_NO_PROXY = 0,	/* Not configured for use with KSSL */
53898Skais 	KSSL_IS_PROXY,		/* Acts as a proxy for someone else */
54898Skais 	KSSL_HAS_PROXY		/* A proxy is handling its work */
55898Skais } kssl_endpt_type_t;
56898Skais 
57898Skais /* Return codes/commands from kssl_handle_record */
58898Skais typedef enum {
59898Skais 	KSSL_CMD_NOT_SUPPORTED,	/* Not supported */
60898Skais 	KSSL_CMD_SEND,		/* send this packet out on the wire */
61898Skais 	KSSL_CMD_DELIVER_PROXY,	/* deliver this packet to proxy listener */
62898Skais 	KSSL_CMD_DELIVER_SSL,	/* Deliver to the SSL listener */
63898Skais 	KSSL_CMD_NONE,		/* consider it consumed. (ACK it, ... */
64898Skais 	KSSL_CMD_QUEUED		/* Queued, a call back will finish it */
65898Skais } kssl_cmd_t;
66898Skais 
67898Skais typedef enum {
68898Skais 	KSSL_EVENT_CLOSE	/* close this context */
69898Skais } kssl_event_t;
70898Skais 
71898Skais /* Un opaque context of an SSL connection */
72898Skais typedef void *kssl_ctx_t;
73898Skais 
74898Skais /* Un opaque handle for an SSL map entry */
75898Skais typedef	void *kssl_ent_t;
76898Skais 
77898Skais #define	SSL3_HDR_LEN		5
78898Skais #define	SSL3_WROFFSET		7	/* 5 hdr + 2 byte-alignment */
79898Skais #define	SSL3_MAX_TAIL_LEN	36	/* 16 AES blocks +  20 SHA1 digest */
80898Skais #define	SSL3_MAX_RECORD_LEN	16384 - 1 - SSL3_HDR_LEN - SSL3_MAX_TAIL_LEN
81898Skais 
82898Skais 
83898Skais kssl_endpt_type_t kssl_check_proxy(mblk_t *, void *, kssl_ent_t *);
84898Skais 
85898Skais kssl_status_t kssl_init_context(kssl_ent_t, uint32_t, int, kssl_ctx_t *);
86898Skais 
87898Skais void kssl_hold_ent(kssl_ent_t);
88898Skais void kssl_release_ent(kssl_ent_t, void *, kssl_endpt_type_t);
89898Skais void *kssl_find_fallback(kssl_ent_t);
90898Skais 
91898Skais void kssl_hold_ctx(kssl_ctx_t);
92898Skais void kssl_release_ctx(kssl_ctx_t);
93898Skais 
94898Skais typedef void (*kssl_callback_t)(void *arg, mblk_t *mp, kssl_cmd_t cmd);
95898Skais 
96898Skais kssl_cmd_t kssl_input(kssl_ctx_t, mblk_t *, mblk_t **, boolean_t *,
97898Skais     kssl_callback_t cbfn, void *arg);
98898Skais 
99*5850Svk199839 kssl_cmd_t kssl_handle_mblk(kssl_ctx_t, mblk_t **, mblk_t **);
100898Skais 
101898Skais mblk_t *kssl_build_record(kssl_ctx_t, mblk_t *);
102898Skais 
103898Skais 
104898Skais #ifdef	__cplusplus
105898Skais }
106898Skais #endif
107898Skais 
108898Skais #endif	/* _INET_KSSL_KSSLAPI_H */
109