| Commit | Line | Data |
|---|---|---|
| 42ee1e6b | 1 | /* $FreeBSD: src/sys/opencrypto/xform.h,v 1.4 2007/05/09 19:37:02 gnn Exp $ */ |
| 1de703da | 2 | /* $DragonFly: src/sys/opencrypto/xform.h,v 1.2 2003/06/17 04:28:54 dillon Exp $ */ |
| 984263bc MD |
3 | /* $OpenBSD: xform.h,v 1.8 2001/08/28 12:20:43 ben Exp $ */ |
| 4 | ||
| 42ee1e6b | 5 | /*- |
| 984263bc MD |
6 | * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) |
| 7 | * | |
| 8 | * This code was written by Angelos D. Keromytis in Athens, Greece, in | |
| 9 | * February 2000. Network Security Technologies Inc. (NSTI) kindly | |
| 10 | * supported the development of this code. | |
| 11 | * | |
| 12 | * Copyright (c) 2000 Angelos D. Keromytis | |
| 13 | * | |
| 14 | * Permission to use, copy, and modify this software without fee | |
| 15 | * is hereby granted, provided that this entire notice is included in | |
| 16 | * all source code copies of any software which is or includes a copy or | |
| 17 | * modification of this software. | |
| 18 | * | |
| 19 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR | |
| 20 | * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY | |
| 21 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE | |
| 22 | * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR | |
| 23 | * PURPOSE. | |
| 24 | */ | |
| 25 | ||
| 26 | #ifndef _CRYPTO_XFORM_H_ | |
| 27 | #define _CRYPTO_XFORM_H_ | |
| 28 | ||
| 29 | #include <sys/md5.h> | |
| 30 | #include <crypto/sha1.h> | |
| 31 | #include <crypto/sha2/sha2.h> | |
| 32 | #include <opencrypto/rmd160.h> | |
| aface142 | 33 | #include <opencrypto/gmac.h> |
| 984263bc MD |
34 | |
| 35 | /* Declarations */ | |
| 36 | struct auth_hash { | |
| 37 | int type; | |
| 38 | char *name; | |
| 39 | u_int16_t keysize; | |
| 40 | u_int16_t hashsize; | |
| 54734da1 | 41 | u_int16_t blocksize; |
| 984263bc MD |
42 | u_int16_t ctxsize; |
| 43 | void (*Init) (void *); | |
| aface142 AH |
44 | void (*Setkey) (void *, const u_int8_t *, u_int16_t); |
| 45 | void (*Reinit) (void *, const u_int8_t *, u_int16_t); | |
| 984263bc MD |
46 | int (*Update) (void *, u_int8_t *, u_int16_t); |
| 47 | void (*Final) (u_int8_t *, void *); | |
| 48 | }; | |
| 49 | ||
| 50 | #define AH_ALEN_MAX 20 /* max authenticator hash length */ | |
| 51 | ||
| 52 | struct enc_xform { | |
| 53 | int type; | |
| 54 | char *name; | |
| da41e4e5 | 55 | u_int16_t blocksize, ivsize; |
| 984263bc | 56 | u_int16_t minkey, maxkey; |
| 400158c1 AH |
57 | void (*encrypt) (caddr_t, u_int8_t *, u_int8_t *); |
| 58 | void (*decrypt) (caddr_t, u_int8_t *, u_int8_t *); | |
| 984263bc MD |
59 | int (*setkey) (u_int8_t **, u_int8_t *, int len); |
| 60 | void (*zerokey) (u_int8_t **); | |
| da41e4e5 | 61 | void (*reinit) (caddr_t, u_int8_t *); |
| 984263bc MD |
62 | }; |
| 63 | ||
| 64 | struct comp_algo { | |
| 65 | int type; | |
| 66 | char *name; | |
| 67 | size_t minlen; | |
| 68 | u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **); | |
| 69 | u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **); | |
| 70 | }; | |
| 71 | ||
| 72 | union authctx { | |
| 73 | MD5_CTX md5ctx; | |
| 74 | SHA1_CTX sha1ctx; | |
| 75 | RMD160_CTX rmd160ctx; | |
| 76 | SHA256_CTX sha256ctx; | |
| 77 | SHA384_CTX sha384ctx; | |
| 78 | SHA512_CTX sha512ctx; | |
| aface142 | 79 | AES_GMAC_CTX aes_gmac_ctx; |
| 984263bc MD |
80 | }; |
| 81 | ||
| 82 | extern struct enc_xform enc_xform_null; | |
| 83 | extern struct enc_xform enc_xform_des; | |
| 84 | extern struct enc_xform enc_xform_3des; | |
| 85 | extern struct enc_xform enc_xform_blf; | |
| 86 | extern struct enc_xform enc_xform_cast5; | |
| 87 | extern struct enc_xform enc_xform_skipjack; | |
| 88 | extern struct enc_xform enc_xform_rijndael128; | |
| da41e4e5 AH |
89 | extern struct enc_xform enc_xform_aes_xts; |
| 90 | extern struct enc_xform enc_xform_aes_ctr; | |
| aface142 AH |
91 | extern struct enc_xform enc_xform_aes_gcm; |
| 92 | extern struct enc_xform enc_xform_aes_gmac; | |
| 984263bc | 93 | extern struct enc_xform enc_xform_arc4; |
| 42ee1e6b | 94 | extern struct enc_xform enc_xform_camellia; |
| 984263bc MD |
95 | |
| 96 | extern struct auth_hash auth_hash_null; | |
| 97 | extern struct auth_hash auth_hash_key_md5; | |
| 98 | extern struct auth_hash auth_hash_key_sha1; | |
| 42ee1e6b SW |
99 | extern struct auth_hash auth_hash_hmac_md5; |
| 100 | extern struct auth_hash auth_hash_hmac_sha1; | |
| 101 | extern struct auth_hash auth_hash_hmac_ripemd_160; | |
| 984263bc MD |
102 | extern struct auth_hash auth_hash_hmac_sha2_256; |
| 103 | extern struct auth_hash auth_hash_hmac_sha2_384; | |
| 104 | extern struct auth_hash auth_hash_hmac_sha2_512; | |
| aface142 AH |
105 | extern struct auth_hash auth_hash_gmac_aes_128; |
| 106 | extern struct auth_hash auth_hash_gmac_aes_192; | |
| 107 | extern struct auth_hash auth_hash_gmac_aes_256; | |
| 984263bc MD |
108 | |
| 109 | extern struct comp_algo comp_algo_deflate; | |
| 110 | ||
| 111 | #ifdef _KERNEL | |
| 112 | #include <sys/malloc.h> | |
| 113 | MALLOC_DECLARE(M_XDATA); | |
| 114 | #endif | |
| 115 | #endif /* _CRYPTO_XFORM_H_ */ |