]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/net/tls.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / include / net / tls.h
index a5a938583295c0789df287c737b7a1c87556c9f1..d9d0ac66f0402deb90d5f622c7c40b4d32dbbec0 100644 (file)
 #define TLS_AAD_SPACE_SIZE             13
 #define TLS_DEVICE_NAME_MAX            32
 
+#define MAX_IV_SIZE                    16
+
+/* 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
+
 /*
  * This structure defines the routines for Inline TLS driver.
  * The following routines are optional and filled with a
@@ -123,8 +134,7 @@ struct tls_rec {
        struct scatterlist sg_content_type;
 
        char aad_space[TLS_AAD_SPACE_SIZE];
-       u8 iv_data[TLS_CIPHER_AES_GCM_128_IV_SIZE +
-                  TLS_CIPHER_AES_GCM_128_SALT_SIZE];
+       u8 iv_data[MAX_IV_SIZE];
        struct aead_request aead_req;
        u8 aead_req_ctx[];
 };
@@ -219,6 +229,7 @@ struct tls_prot_info {
        u16 tag_size;
        u16 overhead_size;
        u16 iv_size;
+       u16 salt_size;
        u16 rec_seq_size;
        u16 aad_size;
        u16 tail_size;
@@ -307,6 +318,7 @@ 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);
 void tls_device_sk_destruct(struct sock *sk);
+void tls_device_free_resources_tx(struct sock *sk);
 void tls_device_init(void);
 void tls_device_cleanup(void);
 int tls_tx_records(struct sock *sk, int flags);
@@ -330,6 +342,7 @@ int tls_push_sg(struct sock *sk, struct tls_context *ctx,
                int flags);
 int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
                            int flags);
+bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx);
 
 static inline struct tls_msg *tls_msg(struct sk_buff *skb)
 {
@@ -379,7 +392,7 @@ tls_validate_xmit_skb(struct sock *sk, struct net_device *dev,
 static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk)
 {
 #ifdef CONFIG_SOCK_VALIDATE_XMIT
-       return sk_fullsock(sk) &
+       return sk_fullsock(sk) &&
               (smp_load_acquire(&sk->sk_validate_xmit_skb) ==
               &tls_validate_xmit_skb);
 #else