]> git.karo-electronics.de Git - linux-beck.git/commitdiff
crypto: af_alg - add setsockopt for auth tag size
authorStephan Mueller <smueller@chronox.de>
Sun, 7 Dec 2014 22:21:42 +0000 (23:21 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 22 Dec 2014 12:02:37 +0000 (23:02 +1100)
Use setsockopt on the tfm FD to provide the authentication tag size for
an AEAD cipher. This is achieved by adding a callback function which is
intended to be used by the AEAD AF_ALG implementation.

The optlen argument of the setsockopt specifies the authentication tag
size to be used with the AEAD tfm.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/af_alg.c
include/crypto/if_alg.h

index 8ffc174a015427378054b4a277012be37222d181..a8ff3c44e13ca6ec0ad3aadbca1988665857da16 100644 (file)
@@ -215,6 +215,13 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
                        goto unlock;
 
                err = alg_setkey(sk, optval, optlen);
+               break;
+       case ALG_SET_AEAD_AUTHSIZE:
+               if (sock->state == SS_CONNECTED)
+                       goto unlock;
+               if (!type->setauthsize)
+                       goto unlock;
+               err = type->setauthsize(ask->private, optlen);
        }
 
 unlock:
index cd62bf4289e9573301b25c5559ac91b412883dc6..5c7b6c53e96f17edbf530c1c5f7c10ce59c73de0 100644 (file)
@@ -50,6 +50,7 @@ struct af_alg_type {
        void (*release)(void *private);
        int (*setkey)(void *private, const u8 *key, unsigned int keylen);
        int (*accept)(void *private, struct sock *sk);
+       int (*setauthsize)(void *private, unsigned int authsize);
 
        struct proto_ops *ops;
        struct module *owner;