#ifndef _SHA_H_
#define _SHA_H_
+#ifndef USE_SHA1
+ #define USE_SHA1 0
+#endif
+
#ifndef USE_SHA224
#define USE_SHA224 0
#endif
*/
enum
{
+#if defined(USE_SHA1) && USE_SHA1
+ SHA1_Message_Block_Size = 64,
+ SHA1HashSize = 20,
+ SHA1HashSizeBits = 160,
+#endif
#if defined(USE_SHA224) && USE_SHA224
SHA224_Message_Block_Size = 64,
SHA224HashSize = 28,
SHA224HashSizeBits = 224,
#endif
- SHA1_Message_Block_Size = 64,
SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128,
SHA512_Message_Block_Size = 128,
USHA_Max_Message_Block_Size = SHA512_Message_Block_Size,
- SHA1HashSize = 20, SHA256HashSize = 32,
+ SHA256HashSize = 32,
SHA384HashSize = 48, SHA512HashSize = 64,
USHAMaxHashSize = SHA512HashSize,
- SHA1HashSizeBits = 160,
SHA256HashSizeBits = 256, SHA384HashSizeBits = 384,
SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits
};
*/
typedef enum SHAversion
{
+#if defined(USE_SHA1) && USE_SHA1
+ SHA1,
+#endif
#if defined(USE_SHA224) && USE_SHA224
SHA224,
#endif
- SHA1, SHA256, SHA384, SHA512
+ SHA256, SHA384, SHA512
} SHAversion;
+#if defined(USE_SHA1) && USE_SHA1
/*
* This structure will hold context information for the SHA-1
* hashing operation.
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the digest corrupted? */
} SHA1Context;
+#endif
/*
* This structure will hold context information for the SHA-256
int whichSha; /* which SHA is being used */
union
{
+#if defined(USE_SHA1) && USE_SHA1
SHA1Context sha1Context;
+#endif
#if defined(USE_SHA224) && USE_SHA224
SHA224Context sha224Context;
#endif
* Function Prototypes
*/
+#if defined(USE_SHA1) && USE_SHA1
/* SHA-1 */
extern int SHA1Reset (SHA1Context *);
extern int SHA1Input (SHA1Context *, const uint8_t * bytes,
extern int SHA1FinalBits (SHA1Context *, const uint8_t bits,
unsigned int bitcount);
extern int SHA1Result (SHA1Context *, uint8_t Message_Digest[SHA1HashSize]);
+#endif
#if defined(USE_SHA224) && USE_SHA224
/* SHA-224 */
#include "sha.h"
#include "sha-private.h"
+#if defined(USE_SHA1) && USE_SHA1
+
/*
* Define the SHA1 circular left shift macro
*/
context->Message_Block_Index = 0;
}
+
+#endif /* defined(USE_SHA1) && USE_SHA1 */
ctx->whichSha = whichSha;
switch (whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1Reset ((SHA1Context *) & ctx->ctx);
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224Reset ((SHA224Context *) & ctx->ctx);
#endif
- case SHA1:
- return SHA1Reset ((SHA1Context *) & ctx->ctx);
case SHA256:
return SHA256Reset ((SHA256Context *) & ctx->ctx);
case SHA384:
{
switch (ctx->whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1Input ((SHA1Context *) & ctx->ctx, bytes, bytecount);
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224Input ((SHA224Context *) & ctx->ctx, bytes, bytecount);
#endif
- case SHA1:
- return SHA1Input ((SHA1Context *) & ctx->ctx, bytes, bytecount);
case SHA256:
return SHA256Input ((SHA256Context *) & ctx->ctx, bytes, bytecount);
case SHA384:
{
switch (ctx->whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1FinalBits ((SHA1Context *) & ctx->ctx, bits, bitcount);
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224FinalBits ((SHA224Context *) & ctx->ctx, bits,
bitcount);
#endif
- case SHA1:
- return SHA1FinalBits ((SHA1Context *) & ctx->ctx, bits, bitcount);
case SHA256:
return SHA256FinalBits ((SHA256Context *) & ctx->ctx, bits,
bitcount);
{
switch (ctx->whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1Result ((SHA1Context *) & ctx->ctx, Message_Digest);
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224Result ((SHA224Context *) & ctx->ctx, Message_Digest);
#endif
- case SHA1:
- return SHA1Result ((SHA1Context *) & ctx->ctx, Message_Digest);
case SHA256:
return SHA256Result ((SHA256Context *) & ctx->ctx, Message_Digest);
case SHA384:
{
switch (whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1_Message_Block_Size;
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224_Message_Block_Size;
#endif
- case SHA1:
- return SHA1_Message_Block_Size;
case SHA256:
return SHA256_Message_Block_Size;
case SHA384:
{
switch (whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1HashSize;
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224HashSize;
#endif
- case SHA1:
- return SHA1HashSize;
case SHA256:
return SHA256HashSize;
case SHA384:
{
switch (whichSha)
{
+#if defined(USE_SHA1) && USE_SHA1
+ case SHA1:
+ return SHA1HashSizeBits;
+#endif
#if defined(USE_SHA224) && USE_SHA224
case SHA224:
return SHA224HashSizeBits;
#endif
- case SHA1:
- return SHA1HashSizeBits;
case SHA256:
return SHA256HashSizeBits;
case SHA384: