xref: /titanic_51/usr/src/uts/common/inet/kssl/ksslapi.h (revision dd49f125507979bb2ab505a8daf2a46d1be27051)
1c28749e9Skais /*
2c28749e9Skais  * CDDL HEADER START
3c28749e9Skais  *
4c28749e9Skais  * The contents of this file are subject to the terms of the
551dd2c77Svk199839  * Common Development and Distribution License (the "License").
651dd2c77Svk199839  * You may not use this file except in compliance with the License.
7c28749e9Skais  *
8c28749e9Skais  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c28749e9Skais  * or http://www.opensolaris.org/os/licensing.
10c28749e9Skais  * See the License for the specific language governing permissions
11c28749e9Skais  * and limitations under the License.
12c28749e9Skais  *
13c28749e9Skais  * When distributing Covered Code, include this CDDL HEADER in each
14c28749e9Skais  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c28749e9Skais  * If applicable, add the following below this CDDL HEADER, with the
16c28749e9Skais  * fields enclosed by brackets "[]" replaced with your own identifying
17c28749e9Skais  * information: Portions Copyright [yyyy] [name of copyright owner]
18c28749e9Skais  *
19c28749e9Skais  * CDDL HEADER END
20c28749e9Skais  */
21c28749e9Skais /*
22*dd49f125SAnders Persson  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23c28749e9Skais  */
24c28749e9Skais 
25c28749e9Skais #ifndef	_INET_KSSL_KSSLAPI_H
26c28749e9Skais #define	_INET_KSSL_KSSLAPI_H
27c28749e9Skais 
28c28749e9Skais /*
29c28749e9Skais  * The kernel SSL proxy interface
30c28749e9Skais  */
31c28749e9Skais 
32c28749e9Skais 
33c28749e9Skais #ifdef	__cplusplus
34c28749e9Skais extern "C" {
35c28749e9Skais #endif
36c28749e9Skais 
37c28749e9Skais #include	<sys/socket.h>
38c28749e9Skais #include	<netinet/in.h>
39c28749e9Skais 
40c28749e9Skais /* return status for the kssl API functions */
41c28749e9Skais 
42c28749e9Skais typedef enum {
43c28749e9Skais 	KSSL_STS_OK,	/* No further processing required */
44c28749e9Skais 	KSSL_STS_ERR	/* bogus argument  ... */
45c28749e9Skais } kssl_status_t;
46c28749e9Skais 
47c28749e9Skais /* Endpoint type */
48c28749e9Skais typedef	enum {
49c28749e9Skais 	KSSL_NO_PROXY = 0,	/* Not configured for use with KSSL */
50c28749e9Skais 	KSSL_IS_PROXY,		/* Acts as a proxy for someone else */
51c28749e9Skais 	KSSL_HAS_PROXY		/* A proxy is handling its work */
52c28749e9Skais } kssl_endpt_type_t;
53c28749e9Skais 
54c28749e9Skais /* Return codes/commands from kssl_handle_record */
55c28749e9Skais typedef enum {
56c28749e9Skais 	KSSL_CMD_NOT_SUPPORTED,	/* Not supported */
57c28749e9Skais 	KSSL_CMD_SEND,		/* send this packet out on the wire */
58c28749e9Skais 	KSSL_CMD_DELIVER_PROXY,	/* deliver this packet to proxy listener */
59c28749e9Skais 	KSSL_CMD_DELIVER_SSL,	/* Deliver to the SSL listener */
60c28749e9Skais 	KSSL_CMD_NONE,		/* consider it consumed. (ACK it, ... */
61c28749e9Skais 	KSSL_CMD_QUEUED		/* Queued, a call back will finish it */
62c28749e9Skais } kssl_cmd_t;
63c28749e9Skais 
64c28749e9Skais /* Un opaque context of an SSL connection */
65c28749e9Skais typedef void *kssl_ctx_t;
66c28749e9Skais 
67c28749e9Skais /* Un opaque handle for an SSL map entry */
68c28749e9Skais typedef	void *kssl_ent_t;
69c28749e9Skais 
70c28749e9Skais #define	SSL3_HDR_LEN		5
71c28749e9Skais #define	SSL3_WROFFSET		7	/* 5 hdr + 2 byte-alignment */
72c28749e9Skais #define	SSL3_MAX_TAIL_LEN	36	/* 16 AES blocks +  20 SHA1 digest */
73c28749e9Skais #define	SSL3_MAX_RECORD_LEN	16384 - 1 - SSL3_HDR_LEN - SSL3_MAX_TAIL_LEN
74c28749e9Skais 
75c28749e9Skais 
76*dd49f125SAnders Persson kssl_endpt_type_t kssl_check_proxy(struct sockaddr *, socklen_t, void *,
77*dd49f125SAnders Persson     kssl_ent_t *);
78c28749e9Skais 
79*dd49f125SAnders Persson kssl_status_t kssl_init_context(kssl_ent_t, struct sockaddr *, int,
80*dd49f125SAnders Persson     kssl_ctx_t *);
81*dd49f125SAnders Persson void kssl_set_mss(kssl_ctx_t, uint32_t);
82c28749e9Skais 
83c28749e9Skais void kssl_hold_ent(kssl_ent_t);
84c28749e9Skais void kssl_release_ent(kssl_ent_t, void *, kssl_endpt_type_t);
85c28749e9Skais void *kssl_find_fallback(kssl_ent_t);
86c28749e9Skais 
87c28749e9Skais void kssl_release_ctx(kssl_ctx_t);
88*dd49f125SAnders Persson void kssl_async_done(kssl_ctx_t);
89c28749e9Skais 
90c28749e9Skais typedef void (*kssl_callback_t)(void *arg, mblk_t *mp, kssl_cmd_t cmd);
91c28749e9Skais 
92c28749e9Skais kssl_cmd_t kssl_input(kssl_ctx_t, mblk_t *, mblk_t **, boolean_t *,
93c28749e9Skais     kssl_callback_t cbfn, void *arg);
94c28749e9Skais 
9551dd2c77Svk199839 kssl_cmd_t kssl_handle_mblk(kssl_ctx_t, mblk_t **, mblk_t **);
96c28749e9Skais 
97c28749e9Skais mblk_t *kssl_build_record(kssl_ctx_t, mblk_t *);
98c28749e9Skais 
99c28749e9Skais 
100c28749e9Skais #ifdef	__cplusplus
101c28749e9Skais }
102c28749e9Skais #endif
103c28749e9Skais 
104c28749e9Skais #endif	/* _INET_KSSL_KSSLAPI_H */
105