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