Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * if_alg: User-space algorithm interface
0004  *
0005  * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
0006  *
0007  * This program is free software; you can redistribute it and/or modify it
0008  * under the terms of the GNU General Public License as published by the Free
0009  * Software Foundation; either version 2 of the License, or (at your option)
0010  * any later version.
0011  *
0012  */
0013 
0014 #ifndef _LINUX_IF_ALG_H
0015 #define _LINUX_IF_ALG_H
0016 
0017 #include <linux/types.h>
0018 
0019 struct sockaddr_alg {
0020     __u16   salg_family;
0021     __u8    salg_type[14];
0022     __u32   salg_feat;
0023     __u32   salg_mask;
0024     __u8    salg_name[64];
0025 };
0026 
0027 /*
0028  * Linux v4.12 and later removed the 64-byte limit on salg_name[]; it's now an
0029  * arbitrary-length field.  We had to keep the original struct above for source
0030  * compatibility with existing userspace programs, though.  Use the new struct
0031  * below if support for very long algorithm names is needed.  To do this,
0032  * allocate 'sizeof(struct sockaddr_alg_new) + strlen(algname) + 1' bytes, and
0033  * copy algname (including the null terminator) into salg_name.
0034  */
0035 struct sockaddr_alg_new {
0036     __u16   salg_family;
0037     __u8    salg_type[14];
0038     __u32   salg_feat;
0039     __u32   salg_mask;
0040     __u8    salg_name[];
0041 };
0042 
0043 struct af_alg_iv {
0044     __u32   ivlen;
0045     __u8    iv[];
0046 };
0047 
0048 /* Socket options */
0049 #define ALG_SET_KEY         1
0050 #define ALG_SET_IV          2
0051 #define ALG_SET_OP          3
0052 #define ALG_SET_AEAD_ASSOCLEN       4
0053 #define ALG_SET_AEAD_AUTHSIZE       5
0054 #define ALG_SET_DRBG_ENTROPY        6
0055 
0056 /* Operations */
0057 #define ALG_OP_DECRYPT          0
0058 #define ALG_OP_ENCRYPT          1
0059 
0060 #endif  /* _LINUX_IF_ALG_H */