FreeBSD/Linux Kernel Cross Reference
sys/crypto/xform.h
1 /* $OpenBSD: xform.h,v 1.32 2021/10/22 12:30:53 bluhm Exp $ */
2
3 /*
4 * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
5 *
6 * This code was written by Angelos D. Keromytis in Athens, Greece, in
7 * February 2000. Network Security Technologies Inc. (NSTI) kindly
8 * supported the development of this code.
9 *
10 * Copyright (c) 2000 Angelos D. Keromytis
11 *
12 * Permission to use, copy, and modify this software with or without fee
13 * is hereby granted, provided that this entire notice is included in
14 * all source code copies of any software which is or includes a copy or
15 * modification of this software.
16 *
17 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
18 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
19 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
20 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
21 * PURPOSE.
22 */
23
24 #ifndef _CRYPTO_XFORM_H_
25 #define _CRYPTO_XFORM_H_
26
27 #include <crypto/md5.h>
28 #include <crypto/sha1.h>
29 #include <crypto/rmd160.h>
30 #include <crypto/sha2.h>
31 #include <crypto/gmac.h>
32
33 #define AESCTR_NONCESIZE 4
34 #define AESCTR_IVSIZE 8
35 #define AESCTR_BLOCKSIZE 16
36
37 #define AES_XTS_BLOCKSIZE 16
38 #define AES_XTS_IVSIZE 8
39 #define AES_XTS_ALPHA 0x87 /* GF(2^128) generator polynomial */
40
41 /* Declarations */
42 struct auth_hash {
43 int type;
44 char *name;
45 u_int16_t keysize;
46 u_int16_t hashsize;
47 u_int16_t authsize;
48 u_int16_t ctxsize;
49 u_int16_t blocksize;
50 void (*Init) (void *);
51 void (*Setkey) (void *, const u_int8_t *, u_int16_t);
52 void (*Reinit) (void *, const u_int8_t *, u_int16_t);
53 int (*Update) (void *, const u_int8_t *, u_int16_t);
54 void (*Final) (u_int8_t *, void *);
55 };
56
57 struct enc_xform {
58 int type;
59 char *name;
60 u_int16_t blocksize;
61 u_int16_t ivsize;
62 u_int16_t minkey;
63 u_int16_t maxkey;
64 u_int16_t ctxsize;
65 void (*encrypt) (caddr_t, u_int8_t *);
66 void (*decrypt) (caddr_t, u_int8_t *);
67 int (*setkey) (void *, u_int8_t *, int len);
68 void (*reinit) (caddr_t, u_int8_t *);
69 };
70
71 struct comp_algo {
72 int type;
73 char *name;
74 size_t minlen;
75 u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
76 u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
77 };
78
79 union authctx {
80 MD5_CTX md5ctx;
81 SHA1_CTX sha1ctx;
82 RMD160_CTX rmd160ctx;
83 SHA2_CTX sha2_ctx;
84 AES_GMAC_CTX aes_gmac_ctx;
85 };
86
87 extern const struct enc_xform enc_xform_3des;
88 extern const struct enc_xform enc_xform_blf;
89 extern const struct enc_xform enc_xform_cast5;
90 extern const struct enc_xform enc_xform_aes;
91 extern const struct enc_xform enc_xform_aes_ctr;
92 extern const struct enc_xform enc_xform_aes_gcm;
93 extern const struct enc_xform enc_xform_aes_gmac;
94 extern const struct enc_xform enc_xform_aes_xts;
95 extern const struct enc_xform enc_xform_chacha20_poly1305;
96 extern const struct enc_xform enc_xform_null;
97
98 extern const struct auth_hash auth_hash_hmac_md5_96;
99 extern const struct auth_hash auth_hash_hmac_sha1_96;
100 extern const struct auth_hash auth_hash_hmac_ripemd_160_96;
101 extern const struct auth_hash auth_hash_hmac_sha2_256_128;
102 extern const struct auth_hash auth_hash_hmac_sha2_384_192;
103 extern const struct auth_hash auth_hash_hmac_sha2_512_256;
104 extern const struct auth_hash auth_hash_gmac_aes_128;
105 extern const struct auth_hash auth_hash_gmac_aes_192;
106 extern const struct auth_hash auth_hash_gmac_aes_256;
107 extern const struct auth_hash auth_hash_chacha20_poly1305;
108
109 extern const struct comp_algo comp_algo_deflate;
110
111 #endif /* _CRYPTO_XFORM_H_ */
Cache object: 9dd103b5bb7f74c7b073c7b02c68187a
|