diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/aes.h | 32 | ||||
-rw-r--r-- | include/des.h | 45 | ||||
-rw-r--r-- | include/md5.h | 32 | ||||
-rw-r--r-- | include/rc4.h | 20 | ||||
-rw-r--r-- | include/sha1.h | 32 | ||||
-rw-r--r-- | include/sha256.h | 32 |
6 files changed, 193 insertions, 0 deletions
diff --git a/include/aes.h b/include/aes.h new file mode 100644 index 0000000..8f9c64f --- /dev/null +++ b/include/aes.h @@ -0,0 +1,32 @@ +#ifndef _AES_H +#define _AES_H + +#ifndef uint8 +#define uint8 unsigned char +#endif + +#ifndef uint32 +#define uint32 unsigned long int +#endif + +typedef struct +{ + uint32 erk[64]; /* encryption round keys */ + uint32 drk[64]; /* decryption round keys */ + int nr; /* number of rounds */ +} +aes_context; + +#ifdef __cplusplus +extern "C" { +#endif + +int aes_set_key( aes_context *ctx, uint8 *key, int nbits ); +void aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ); +void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ); + +#ifdef __cplusplus +} +#endif + +#endif /* aes.h */ diff --git a/include/des.h b/include/des.h new file mode 100644 index 0000000..27619aa --- /dev/null +++ b/include/des.h @@ -0,0 +1,45 @@ +#ifndef _DES_H +#define _DES_H + +#ifndef uint8 +#define uint8 unsigned char +#endif + +#ifndef uint32 +#define uint32 unsigned long int +#endif + +typedef struct +{ + uint32 esk[32]; /* DES encryption subkeys */ + uint32 dsk[32]; /* DES decryption subkeys */ +} +des_context; + +typedef struct +{ + uint32 esk[96]; /* Triple-DES encryption subkeys */ + uint32 dsk[96]; /* Triple-DES decryption subkeys */ +} +des3_context; + +#ifdef __cplusplus +extern "C" { +#endif + +int des_set_key( des_context *ctx, uint8 key[8] ); +void des_encrypt( des_context *ctx, uint8 input[8], uint8 output[8] ); +void des_decrypt( des_context *ctx, uint8 input[8], uint8 output[8] ); + +int des3_set_2keys( des3_context *ctx, uint8 key1[8], uint8 key2[8] ); +int des3_set_3keys( des3_context *ctx, uint8 key1[8], uint8 key2[8], + uint8 key3[8] ); + +void des3_encrypt( des3_context *ctx, uint8 input[8], uint8 output[8] ); +void des3_decrypt( des3_context *ctx, uint8 input[8], uint8 output[8] ); + +#ifdef __cplusplus +} +#endif + +#endif /* des.h */ diff --git a/include/md5.h b/include/md5.h new file mode 100644 index 0000000..53d54b9 --- /dev/null +++ b/include/md5.h @@ -0,0 +1,32 @@ +#ifndef _MD5_H +#define _MD5_H + +#ifndef uint8 +#define uint8 unsigned char +#endif + +#ifndef uint32 +#define uint32 unsigned long int +#endif + +typedef struct +{ + uint32 total[2]; + uint32 state[4]; + uint8 buffer[64]; +} +md5_context; + +#ifdef __cplusplus +extern "C" { +#endif + +void md5_starts( md5_context *ctx ); +void md5_update( md5_context *ctx, uint8 *input, uint32 length ); +void md5_finish( md5_context *ctx, uint8 digest[16] ); + +#ifdef __cplusplus +} +#endif + +#endif /* md5.h */ diff --git a/include/rc4.h b/include/rc4.h new file mode 100644 index 0000000..45b3e1e --- /dev/null +++ b/include/rc4.h @@ -0,0 +1,20 @@ +#ifndef _RC4_H +#define _RC4_H + +struct rc4_state +{ + int x, y, m[256]; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +void rc4_setup( struct rc4_state *s, unsigned char *key, int length ); +void rc4_crypt( struct rc4_state *s, unsigned char *data, int length ); + +#ifdef __cplusplus +} +#endif + +#endif /* rc4.h */ diff --git a/include/sha1.h b/include/sha1.h new file mode 100644 index 0000000..11b3cbd --- /dev/null +++ b/include/sha1.h @@ -0,0 +1,32 @@ +#ifndef _SHA1_H +#define _SHA1_H + +#ifndef uint8 +#define uint8 unsigned char +#endif + +#ifndef uint32 +#define uint32 unsigned long int +#endif + +typedef struct +{ + uint32 total[2]; + uint32 state[5]; + uint8 buffer[64]; +} +sha1_context; + +#ifdef __cplusplus +extern "C" { +#endif + +void sha1_starts( sha1_context *ctx ); +void sha1_update( sha1_context *ctx, uint8 *input, uint32 length ); +void sha1_finish( sha1_context *ctx, uint8 digest[20] ); + +#ifdef __cplusplus +} +#endif + +#endif /* sha1.h */ diff --git a/include/sha256.h b/include/sha256.h new file mode 100644 index 0000000..91b5adc --- /dev/null +++ b/include/sha256.h @@ -0,0 +1,32 @@ +#ifndef _SHA256_H +#define _SHA256_H + +#ifndef uint8 +#define uint8 unsigned char +#endif + +#ifndef uint32 +#define uint32 unsigned long int +#endif + +typedef struct +{ + uint32 total[2]; + uint32 state[8]; + uint8 buffer[64]; +} +sha256_context; + +#ifdef __cplusplus +extern "C" { +#endif + +void sha256_starts( sha256_context *ctx ); +void sha256_update( sha256_context *ctx, uint8 *input, uint32 length ); +void sha256_finish( sha256_context *ctx, uint8 digest[32] ); + +#ifdef __cplusplus +} +#endif + +#endif /* sha256.h */ |