tls.h 16.6 KB
Newer Older
D
Dave Watson 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*
 * Copyright (c) 2016-2017, Mellanox Technologies. All rights reserved.
 * Copyright (c) 2016-2017, Dave Watson <davejwatson@fb.com>. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#ifndef _TLS_OFFLOAD_H
#define _TLS_OFFLOAD_H

#include <linux/types.h>
38
#include <asm/byteorder.h>
39
#include <linux/crypto.h>
40 41
#include <linux/socket.h>
#include <linux/tcp.h>
42
#include <linux/skmsg.h>
43
#include <linux/netdevice.h>
44

45
#include <net/tcp.h>
D
Dave Watson 已提交
46
#include <net/strparser.h>
47
#include <crypto/aead.h>
D
Dave Watson 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61
#include <uapi/linux/tls.h>


/* Maximum data size carried in a TLS record */
#define TLS_MAX_PAYLOAD_SIZE		((size_t)1 << 14)

#define TLS_HEADER_SIZE			5
#define TLS_NONCE_OFFSET		TLS_HEADER_SIZE

#define TLS_CRYPTO_INFO_READY(info)	((info)->cipher_type)

#define TLS_RECORD_TYPE_DATA		0x17

#define TLS_AAD_SPACE_SIZE		13
A
Atul Gupta 已提交
62 63
#define TLS_DEVICE_NAME_MAX		32

64
#define MAX_IV_SIZE			16
65
#define TLS_MAX_REC_SEQ_SIZE		8
66 67 68 69 70 71 72 73 74 75

/* For AES-CCM, the full 16-bytes of IV is made of '4' fields of given sizes.
 *
 * IV[16] = b0[1] || implicit nonce[4] || explicit nonce[8] || length[3]
 *
 * The field 'length' is encoded in field 'b0' as '(length width - 1)'.
 * Hence b0 contains (3 - 1) = 2.
 */
#define TLS_AES_CCM_IV_B0_BYTE		2

A
Atul Gupta 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
/*
 * This structure defines the routines for Inline TLS driver.
 * The following routines are optional and filled with a
 * null pointer if not defined.
 *
 * @name: Its the name of registered Inline tls device
 * @dev_list: Inline tls device list
 * int (*feature)(struct tls_device *device);
 *     Called to return Inline TLS driver capability
 *
 * int (*hash)(struct tls_device *device, struct sock *sk);
 *     This function sets Inline driver for listen and program
 *     device specific functioanlity as required
 *
 * void (*unhash)(struct tls_device *device, struct sock *sk);
 *     This function cleans listen state set by Inline TLS driver
92 93 94 95
 *
 * void (*release)(struct kref *kref);
 *     Release the registered device and allocated resources
 * @kref: Number of reference to tls_device
A
Atul Gupta 已提交
96 97 98 99 100 101 102
 */
struct tls_device {
	char name[TLS_DEVICE_NAME_MAX];
	struct list_head dev_list;
	int  (*feature)(struct tls_device *device);
	int  (*hash)(struct tls_device *device, struct sock *sk);
	void (*unhash)(struct tls_device *device, struct sock *sk);
103 104
	void (*release)(struct kref *kref);
	struct kref kref;
A
Atul Gupta 已提交
105
};
D
Dave Watson 已提交
106

107 108 109 110 111 112 113 114 115 116
enum {
	TLS_BASE,
	TLS_SW,
#ifdef CONFIG_TLS_DEVICE
	TLS_HW,
#endif
	TLS_HW_RECORD,
	TLS_NUM_CONFIG,
};

117 118 119 120 121 122
/* TLS records are maintained in 'struct tls_rec'. It stores the memory pages
 * allocated or mapped for each TLS record. After encryption, the records are
 * stores in a linked list.
 */
struct tls_rec {
	struct list_head list;
123
	int tx_ready;
124
	int tx_flags;
125
	int inplace_crypto;
D
Dave Watson 已提交
126

127 128
	struct sk_msg msg_plaintext;
	struct sk_msg msg_encrypted;
129

130 131 132 133
	/* AAD | msg_plaintext.sg.data | sg_tag */
	struct scatterlist sg_aead_in[2];
	/* AAD | msg_encrypted.sg.data (data contains overhead for hdr & iv & tag) */
	struct scatterlist sg_aead_out[2];
134

D
Dave Watson 已提交
135 136 137
	char content_type;
	struct scatterlist sg_content_type;

138
	char aad_space[TLS_AAD_SPACE_SIZE];
139
	u8 iv_data[MAX_IV_SIZE];
140 141 142 143
	struct aead_request aead_req;
	u8 aead_req_ctx[];
};

144 145 146 147 148
struct tls_msg {
	struct strp_msg rxm;
	u8 control;
};

149 150 151 152 153 154 155 156 157 158
struct tx_work {
	struct delayed_work work;
	struct sock *sk;
};

struct tls_sw_context_tx {
	struct crypto_aead *aead_send;
	struct crypto_wait async_wait;
	struct tx_work tx_work;
	struct tls_rec *open_rec;
159
	struct list_head tx_list;
160 161
	atomic_t encrypt_pending;
	int async_notify;
162
	int async_capable;
163 164 165

#define BIT_TX_SCHEDULED	0
	unsigned long tx_bitmask;
D
Dave Watson 已提交
166 167
};

B
Boris Pismenny 已提交
168 169 170 171
struct tls_sw_context_rx {
	struct crypto_aead *aead_recv;
	struct crypto_wait async_wait;
	struct strparser strp;
172
	struct sk_buff_head rx_list;	/* list of decrypted 'data' records */
B
Boris Pismenny 已提交
173
	void (*saved_data_ready)(struct sock *sk);
174

B
Boris Pismenny 已提交
175 176
	struct sk_buff *recv_pkt;
	u8 control;
177
	int async_capable;
B
Boris Pismenny 已提交
178
	bool decrypted;
179 180 181 182
	atomic_t decrypt_pending;
	bool async_notify;
};

183 184 185 186 187 188 189 190
struct tls_record_info {
	struct list_head list;
	u32 end_seq;
	int len;
	int num_frags;
	skb_frag_t frags[MAX_SKB_FRAGS];
};

191
struct tls_offload_context_tx {
192 193 194 195 196 197 198 199 200 201
	struct crypto_aead *aead_send;
	spinlock_t lock;	/* protects records list */
	struct list_head records_list;
	struct tls_record_info *open_record;
	struct tls_record_info *retransmit_hint;
	u64 hint_record_sn;
	u64 unacked_record_sn;

	struct scatterlist sg_tx_data[MAX_SKB_FRAGS];
	void (*sk_destruct)(struct sock *sk);
202
	u8 driver_state[] __aligned(8);
203 204 205 206
	/* The TLS layer reserves room for driver specific state
	 * Currently the belief is that there is not enough
	 * driver specific state to justify another layer of indirection
	 */
207
#define TLS_DRIVER_STATE_SIZE_TX	16
208 209
};

210
#define TLS_OFFLOAD_CONTEXT_SIZE_TX                                            \
211
	(sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX)
212

213 214 215 216
enum tls_context_flags {
	TLS_RX_SYNC_RUNNING = 0,
};

217 218 219 220 221
struct cipher_context {
	char *iv;
	char *rec_seq;
};

222 223
union tls_crypto_context {
	struct tls_crypto_info info;
D
Dave Watson 已提交
224 225 226 227
	union {
		struct tls12_crypto_info_aes_gcm_128 aes_gcm_128;
		struct tls12_crypto_info_aes_gcm_256 aes_gcm_256;
	};
228 229
};

230 231 232 233 234 235 236
struct tls_prot_info {
	u16 version;
	u16 cipher_type;
	u16 prepend_size;
	u16 tag_size;
	u16 overhead_size;
	u16 iv_size;
237
	u16 salt_size;
238 239 240 241 242
	u16 rec_seq_size;
	u16 aad_size;
	u16 tail_size;
};

D
Dave Watson 已提交
243
struct tls_context {
244
	/* read-only cache line */
245 246
	struct tls_prot_info prot_info;

247 248
	u8 tx_conf:3;
	u8 rx_conf:3;
D
Dave Watson 已提交
249

250 251
	int (*push_pending_record)(struct sock *sk, int flags);
	void (*sk_write_space)(struct sock *sk);
B
Boris Pismenny 已提交
252 253 254

	void *priv_ctx_tx;
	void *priv_ctx_rx;
D
Dave Watson 已提交
255

256
	struct net_device *netdev;
257

258
	/* rw cache line */
259
	struct cipher_context tx;
D
Dave Watson 已提交
260
	struct cipher_context rx;
D
Dave Watson 已提交
261 262 263

	struct scatterlist *partially_sent_record;
	u16 partially_sent_offset;
264

265
	bool in_tcp_sendpages;
266
	bool pending_open_record_frags;
267
	unsigned long flags;
D
Dave Watson 已提交
268

269
	/* cache cold stuff */
270
	void (*sk_destruct)(struct sock *sk);
D
Dave Watson 已提交
271 272 273 274 275 276 277 278
	void (*sk_proto_close)(struct sock *sk, long timeout);

	int  (*setsockopt)(struct sock *sk, int level,
			   int optname, char __user *optval,
			   unsigned int optlen);
	int  (*getsockopt)(struct sock *sk, int level,
			   int optname, char __user *optval,
			   int __user *optlen);
A
Atul Gupta 已提交
279 280
	int  (*hash)(struct sock *sk);
	void (*unhash)(struct sock *sk);
281 282 283 284 285 286

	union tls_crypto_context crypto_send;
	union tls_crypto_context crypto_recv;

	struct list_head list;
	refcount_t refcount;
D
Dave Watson 已提交
287 288
};

289 290 291 292 293 294 295 296 297 298 299 300 301 302
enum tls_offload_ctx_dir {
	TLS_OFFLOAD_CTX_DIR_RX,
	TLS_OFFLOAD_CTX_DIR_TX,
};

struct tlsdev_ops {
	int (*tls_dev_add)(struct net_device *netdev, struct sock *sk,
			   enum tls_offload_ctx_dir direction,
			   struct tls_crypto_info *crypto_info,
			   u32 start_offload_tcp_sn);
	void (*tls_dev_del)(struct net_device *netdev,
			    struct tls_context *ctx,
			    enum tls_offload_ctx_dir direction);
	void (*tls_dev_resync_rx)(struct net_device *netdev,
303
				  struct sock *sk, u32 seq, u8 *rcd_sn);
304 305
};

306 307 308 309
struct tls_offload_context_rx {
	/* sw must be the first member of tls_offload_context_rx */
	struct tls_sw_context_rx sw;
	atomic64_t resync_req;
310
	u8 driver_state[] __aligned(8);
311 312 313 314
	/* The TLS layer reserves room for driver specific state
	 * Currently the belief is that there is not enough
	 * driver specific state to justify another layer of indirection
	 */
315
#define TLS_DRIVER_STATE_SIZE_RX	8
316 317 318
};

#define TLS_OFFLOAD_CONTEXT_SIZE_RX					\
319
	(sizeof(struct tls_offload_context_rx) + TLS_DRIVER_STATE_SIZE_RX)
320

D
Dave Watson 已提交
321 322 323 324 325 326
int wait_on_pending_writer(struct sock *sk, long *timeo);
int tls_sk_query(struct sock *sk, int optname, char __user *optval,
		int __user *optlen);
int tls_sk_attach(struct sock *sk, int optname, char __user *optval,
		  unsigned int optlen);

D
Dave Watson 已提交
327
int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx);
D
Dave Watson 已提交
328 329 330 331
int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
int tls_sw_sendpage(struct sock *sk, struct page *page,
		    int offset, size_t size, int flags);
void tls_sw_close(struct sock *sk, long timeout);
B
Boris Pismenny 已提交
332 333
void tls_sw_free_resources_tx(struct sock *sk);
void tls_sw_free_resources_rx(struct sock *sk);
334
void tls_sw_release_resources_rx(struct sock *sk);
D
Dave Watson 已提交
335 336
int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
		   int nonblock, int flags, int *addr_len);
337
bool tls_sw_stream_read(const struct sock *sk);
D
Dave Watson 已提交
338 339 340
ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
			   struct pipe_inode_info *pipe,
			   size_t len, unsigned int flags);
D
Dave Watson 已提交
341

342 343 344 345
int tls_set_device_offload(struct sock *sk, struct tls_context *ctx);
int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
int tls_device_sendpage(struct sock *sk, struct page *page,
			int offset, size_t size, int flags);
346
void tls_device_free_resources_tx(struct sock *sk);
347 348
void tls_device_init(void);
void tls_device_cleanup(void);
349
int tls_tx_records(struct sock *sk, int flags);
350

351
struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context,
352 353 354 355 356 357 358 359 360 361 362
				       u32 seq, u64 *p_record_sn);

static inline bool tls_record_is_start_marker(struct tls_record_info *rec)
{
	return rec->len == 0;
}

static inline u32 tls_record_start_seq(struct tls_record_info *rec)
{
	return rec->end_seq - rec->len;
}
D
Dave Watson 已提交
363 364 365 366

int tls_push_sg(struct sock *sk, struct tls_context *ctx,
		struct scatterlist *sg, u16 first_offset,
		int flags);
367 368
int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
			    int flags);
369
bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx);
370

371 372 373 374 375
static inline struct tls_msg *tls_msg(struct sk_buff *skb)
{
	return (struct tls_msg *)strp_msg(skb);
}

376
static inline bool tls_is_partially_sent_record(struct tls_context *ctx)
D
Dave Watson 已提交
377
{
378
	return !!ctx->partially_sent_record;
D
Dave Watson 已提交
379 380 381 382 383 384 385 386 387 388 389
}

static inline int tls_complete_pending_work(struct sock *sk,
					    struct tls_context *ctx,
					    int flags, long *timeo)
{
	int rc = 0;

	if (unlikely(sk->sk_write_pending))
		rc = wait_on_pending_writer(sk, timeo);

390 391
	if (!rc && tls_is_partially_sent_record(ctx))
		rc = tls_push_partial_record(sk, ctx, flags);
D
Dave Watson 已提交
392 393 394 395 396 397 398 399 400

	return rc;
}

static inline bool tls_is_pending_open_record(struct tls_context *tls_ctx)
{
	return tls_ctx->pending_open_record_frags;
}

401
static inline bool is_tx_ready(struct tls_sw_context_tx *ctx)
402 403 404
{
	struct tls_rec *rec;

405
	rec = list_first_entry(&ctx->tx_list, struct tls_rec, list);
406 407 408
	if (!rec)
		return false;

409
	return READ_ONCE(rec->tx_ready);
410 411
}

412 413 414 415
struct sk_buff *
tls_validate_xmit_skb(struct sock *sk, struct net_device *dev,
		      struct sk_buff *skb);

416 417
static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk)
{
418
#ifdef CONFIG_SOCK_VALIDATE_XMIT
419
	return sk_fullsock(sk) &&
420 421 422 423 424
	       (smp_load_acquire(&sk->sk_validate_xmit_skb) ==
	       &tls_validate_xmit_skb);
#else
	return false;
#endif
425 426
}

427
static inline void tls_err_abort(struct sock *sk, int err)
D
Dave Watson 已提交
428
{
429
	sk->sk_err = err;
D
Dave Watson 已提交
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
	sk->sk_error_report(sk);
}

static inline bool tls_bigint_increment(unsigned char *seq, int len)
{
	int i;

	for (i = len - 1; i >= 0; i--) {
		++seq[i];
		if (seq[i] != 0)
			break;
	}

	return (i == -1);
}

446 447 448 449 450 451 452
static inline struct tls_context *tls_get_ctx(const struct sock *sk)
{
	struct inet_connection_sock *icsk = inet_csk(sk);

	return icsk->icsk_ulp_data;
}

D
Dave Watson 已提交
453
static inline void tls_advance_record_sn(struct sock *sk,
454 455
					 struct tls_prot_info *prot,
					 struct cipher_context *ctx)
D
Dave Watson 已提交
456
{
457
	if (tls_bigint_increment(ctx->rec_seq, prot->rec_seq_size))
458
		tls_err_abort(sk, EBADMSG);
D
Dave Watson 已提交
459

460
	if (prot->version != TLS_1_3_VERSION)
D
Dave Watson 已提交
461
		tls_bigint_increment(ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
462
				     prot->iv_size);
D
Dave Watson 已提交
463 464 465 466 467
}

static inline void tls_fill_prepend(struct tls_context *ctx,
			     char *buf,
			     size_t plaintext_len,
D
Dave Watson 已提交
468 469
			     unsigned char record_type,
			     int version)
D
Dave Watson 已提交
470
{
471 472
	struct tls_prot_info *prot = &ctx->prot_info;
	size_t pkt_len, iv_size = prot->iv_size;
D
Dave Watson 已提交
473

474
	pkt_len = plaintext_len + prot->tag_size;
D
Dave Watson 已提交
475 476 477 478 479 480
	if (version != TLS_1_3_VERSION) {
		pkt_len += iv_size;

		memcpy(buf + TLS_NONCE_OFFSET,
		       ctx->tx.iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, iv_size);
	}
D
Dave Watson 已提交
481 482 483 484

	/* we cover nonce explicit here as well, so buf should be of
	 * size KTLS_DTLS_HEADER_SIZE + KTLS_DTLS_NONCE_EXPLICIT_SIZE
	 */
D
Dave Watson 已提交
485 486 487 488 489
	buf[0] = version == TLS_1_3_VERSION ?
		   TLS_RECORD_TYPE_DATA : record_type;
	/* Note that VERSION must be TLS_1_2 for both TLS1.2 and TLS1.3 */
	buf[1] = TLS_1_2_VERSION_MINOR;
	buf[2] = TLS_1_2_VERSION_MAJOR;
D
Dave Watson 已提交
490 491 492 493 494
	/* we can use IV for nonce explicit according to spec */
	buf[3] = pkt_len >> 8;
	buf[4] = pkt_len & 0xFF;
}

495 496 497 498
static inline void tls_make_aad(char *buf,
				size_t size,
				char *record_sequence,
				int record_sequence_size,
D
Dave Watson 已提交
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
				unsigned char record_type,
				int version)
{
	if (version != TLS_1_3_VERSION) {
		memcpy(buf, record_sequence, record_sequence_size);
		buf += 8;
	} else {
		size += TLS_CIPHER_AES_GCM_128_TAG_SIZE;
	}

	buf[0] = version == TLS_1_3_VERSION ?
		  TLS_RECORD_TYPE_DATA : record_type;
	buf[1] = TLS_1_2_VERSION_MAJOR;
	buf[2] = TLS_1_2_VERSION_MINOR;
	buf[3] = size >> 8;
	buf[4] = size & 0xFF;
}

static inline void xor_iv_with_seq(int version, char *iv, char *seq)
518
{
D
Dave Watson 已提交
519
	int i;
520

D
Dave Watson 已提交
521 522 523 524
	if (version == TLS_1_3_VERSION) {
		for (i = 0; i < 8; i++)
			iv[i + 4] ^= seq[i];
	}
525 526
}

D
Dave Watson 已提交
527

B
Boris Pismenny 已提交
528 529 530 531 532 533 534
static inline struct tls_sw_context_rx *tls_sw_ctx_rx(
		const struct tls_context *tls_ctx)
{
	return (struct tls_sw_context_rx *)tls_ctx->priv_ctx_rx;
}

static inline struct tls_sw_context_tx *tls_sw_ctx_tx(
D
Dave Watson 已提交
535 536
		const struct tls_context *tls_ctx)
{
B
Boris Pismenny 已提交
537
	return (struct tls_sw_context_tx *)tls_ctx->priv_ctx_tx;
D
Dave Watson 已提交
538 539
}

540 541
static inline struct tls_offload_context_tx *
tls_offload_ctx_tx(const struct tls_context *tls_ctx)
D
Dave Watson 已提交
542
{
543
	return (struct tls_offload_context_tx *)tls_ctx->priv_ctx_tx;
D
Dave Watson 已提交
544 545
}

546 547 548 549 550 551 552 553 554
static inline bool tls_sw_has_ctx_tx(const struct sock *sk)
{
	struct tls_context *ctx = tls_get_ctx(sk);

	if (!ctx)
		return false;
	return !!tls_sw_ctx_tx(ctx);
}

B
Boris Pismenny 已提交
555 556 557
void tls_sw_write_space(struct sock *sk, struct tls_context *ctx);
void tls_device_write_space(struct sock *sk, struct tls_context *ctx);

558 559 560 561 562 563
static inline struct tls_offload_context_rx *
tls_offload_ctx_rx(const struct tls_context *tls_ctx)
{
	return (struct tls_offload_context_rx *)tls_ctx->priv_ctx_rx;
}

564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
#if IS_ENABLED(CONFIG_TLS_DEVICE)
static inline void *__tls_driver_ctx(struct tls_context *tls_ctx,
				     enum tls_offload_ctx_dir direction)
{
	if (direction == TLS_OFFLOAD_CTX_DIR_TX)
		return tls_offload_ctx_tx(tls_ctx)->driver_state;
	else
		return tls_offload_ctx_rx(tls_ctx)->driver_state;
}

static inline void *
tls_driver_ctx(const struct sock *sk, enum tls_offload_ctx_dir direction)
{
	return __tls_driver_ctx(tls_get_ctx(sk), direction);
}
#endif

581 582 583 584 585 586
/* The TLS context is valid until sk_destruct is called */
static inline void tls_offload_rx_resync_request(struct sock *sk, __be32 seq)
{
	struct tls_context *tls_ctx = tls_get_ctx(sk);
	struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx);

587
	atomic64_set(&rx_ctx->resync_req, ((u64)ntohl(seq) << 32) | 1);
588 589 590
}


D
Dave Watson 已提交
591 592
int tls_proccess_cmsg(struct sock *sk, struct msghdr *msg,
		      unsigned char *record_type);
A
Atul Gupta 已提交
593 594
void tls_register_device(struct tls_device *device);
void tls_unregister_device(struct tls_device *device);
595
int tls_device_decrypted(struct sock *sk, struct sk_buff *skb);
596 597
int decrypt_skb(struct sock *sk, struct sk_buff *skb,
		struct scatterlist *sgout);
598
struct sk_buff *tls_encrypt_skb(struct sk_buff *skb);
D
Dave Watson 已提交
599

600 601 602 603 604
struct sk_buff *tls_validate_xmit_skb(struct sock *sk,
				      struct net_device *dev,
				      struct sk_buff *skb);

int tls_sw_fallback_init(struct sock *sk,
605
			 struct tls_offload_context_tx *offload_ctx,
606 607
			 struct tls_crypto_info *crypto_info);

608 609 610
int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx);

void tls_device_offload_cleanup_rx(struct sock *sk);
611
void tls_device_rx_resync_new_rec(struct sock *sk, u32 seq);
612

D
Dave Watson 已提交
613
#endif /* _TLS_OFFLOAD_H */