xref: /linux/include/uapi/linux/if_alg.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * if_alg: User-space algorithm interface
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  * This program is free software; you can redistribute it and/or modify it
8607ca46eSDavid Howells  * under the terms of the GNU General Public License as published by the Free
9607ca46eSDavid Howells  * Software Foundation; either version 2 of the License, or (at your option)
10607ca46eSDavid Howells  * any later version.
11607ca46eSDavid Howells  *
12607ca46eSDavid Howells  */
13607ca46eSDavid Howells 
14607ca46eSDavid Howells #ifndef _LINUX_IF_ALG_H
15607ca46eSDavid Howells #define _LINUX_IF_ALG_H
16607ca46eSDavid Howells 
17607ca46eSDavid Howells #include <linux/types.h>
18607ca46eSDavid Howells 
19607ca46eSDavid Howells struct sockaddr_alg {
20607ca46eSDavid Howells 	__u16	salg_family;
21607ca46eSDavid Howells 	__u8	salg_type[14];
22607ca46eSDavid Howells 	__u32	salg_feat;
23607ca46eSDavid Howells 	__u32	salg_mask;
24607ca46eSDavid Howells 	__u8	salg_name[64];
25607ca46eSDavid Howells };
26607ca46eSDavid Howells 
2792eb6c30SEric Biggers /*
2892eb6c30SEric Biggers  * Linux v4.12 and later removed the 64-byte limit on salg_name[]; it's now an
2992eb6c30SEric Biggers  * arbitrary-length field.  We had to keep the original struct above for source
3092eb6c30SEric Biggers  * compatibility with existing userspace programs, though.  Use the new struct
3192eb6c30SEric Biggers  * below if support for very long algorithm names is needed.  To do this,
3292eb6c30SEric Biggers  * allocate 'sizeof(struct sockaddr_alg_new) + strlen(algname) + 1' bytes, and
3392eb6c30SEric Biggers  * copy algname (including the null terminator) into salg_name.
3492eb6c30SEric Biggers  */
3592eb6c30SEric Biggers struct sockaddr_alg_new {
3692eb6c30SEric Biggers 	__u16	salg_family;
3792eb6c30SEric Biggers 	__u8	salg_type[14];
3892eb6c30SEric Biggers 	__u32	salg_feat;
3992eb6c30SEric Biggers 	__u32	salg_mask;
4092eb6c30SEric Biggers 	__u8	salg_name[];
4192eb6c30SEric Biggers };
4292eb6c30SEric Biggers 
43607ca46eSDavid Howells struct af_alg_iv {
44607ca46eSDavid Howells 	__u32	ivlen;
4594dfc73eSGustavo A. R. Silva 	__u8	iv[];
46607ca46eSDavid Howells };
47607ca46eSDavid Howells 
48607ca46eSDavid Howells /* Socket options */
49607ca46eSDavid Howells #define ALG_SET_KEY			1
50607ca46eSDavid Howells #define ALG_SET_IV			2
51607ca46eSDavid Howells #define ALG_SET_OP			3
52af8e8073SStephan Mueller #define ALG_SET_AEAD_ASSOCLEN		4
53af8e8073SStephan Mueller #define ALG_SET_AEAD_AUTHSIZE		5
5477ebdabeSElena Petrova #define ALG_SET_DRBG_ENTROPY		6
55*7984ceb1SFrederick Lawler #define ALG_SET_KEY_BY_KEY_SERIAL	7
56607ca46eSDavid Howells 
57607ca46eSDavid Howells /* Operations */
58607ca46eSDavid Howells #define ALG_OP_DECRYPT			0
59607ca46eSDavid Howells #define ALG_OP_ENCRYPT			1
60607ca46eSDavid Howells 
61607ca46eSDavid Howells #endif	/* _LINUX_IF_ALG_H */
62