From aa83760418f5ed5ce35a9add6517b2ca98ccb5bd Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Wed, 22 Mar 2023 16:44:03 +0100 Subject: Add crypto sources for future use. * the goal is to support AES-CBC-HMAC-SHA as AEAD cipher Signed-off-by: Toni Uhlig --- crypto/sha1.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 crypto/sha1.h (limited to 'crypto/sha1.h') diff --git a/crypto/sha1.h b/crypto/sha1.h new file mode 100644 index 0000000..58817ce --- /dev/null +++ b/crypto/sha1.h @@ -0,0 +1,61 @@ +/* + * sha1.h + * + * Description: + * This is the header file for code which implements the Secure + * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published + * April 17, 1995. + * + * Many of the variable names in this code, especially the + * single character names, were used because those were the names + * used in the publication. + * + * Please read the file sha1.c for more information. + * + */ + +#ifndef _SHA1_H_ +#define _SHA1_H_ + +#include + +#define SHA1HashSize 20 + +enum +{ + shaSuccess = 0, + shaNull, /* Null pointer parameter */ + shaInputTooLong, /* input data too long */ + shaStateError /* called Input after Result */ +}; + +#define FLAG_COMPUTED 1 +#define FLAG_CORRUPTED 2 + +/* + * Data structure holding contextual information about the SHA-1 hash + */ +struct sha1 +{ + uint8_t Message_Block[64]; /* 512-bit message blocks */ + uint32_t Intermediate_Hash[5]; /* Message Digest */ + uint32_t Length_Low; /* Message length in bits */ + uint32_t Length_High; /* Message length in bits */ + uint16_t Message_Block_Index; /* Index into message block array */ + uint8_t flags; +}; + + + +/* + * Public API + */ +int sha1_reset (struct sha1* context); +int sha1_input (struct sha1* context, const uint8_t* message_array, unsigned length); +int sha1_result(struct sha1* context, uint8_t Message_Digest[SHA1HashSize]); + + + +#endif /* #ifndef _SHA1_H_ */ + + -- cgit v1.2.3