#define USE_SHA224 0
#endif
+#ifndef USE_SHA384
+ #define USE_SHA384 0
+#endif
+
/*
* Description:
* This file implements the Secure Hash Signature Standard
SHA224HashSize = 28,
SHA224HashSizeBits = 224,
#endif
- SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128,
+#if defined(USE_SHA384) && USE_SHA384
+ SHA384_Message_Block_Size = 128,
+ SHA384HashSize = 48,
+ SHA384HashSizeBits = 384,
+#endif
+ SHA256_Message_Block_Size = 64,
SHA512_Message_Block_Size = 128,
USHA_Max_Message_Block_Size = SHA512_Message_Block_Size,
SHA256HashSize = 32,
- SHA384HashSize = 48, SHA512HashSize = 64,
+ SHA512HashSize = 64,
USHAMaxHashSize = SHA512HashSize,
- SHA256HashSizeBits = 256, SHA384HashSizeBits = 384,
+ SHA256HashSizeBits = 256,
SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits
};
#if defined(USE_SHA224) && USE_SHA224
SHA224,
#endif
- SHA256, SHA384, SHA512
+ SHA256,
+#if defined(USE_SHA384) && USE_SHA384
+ SHA384,
+#endif
+ SHA512
} SHAversion;
#if defined(USE_SHA1) && USE_SHA1
typedef struct SHA256Context SHA224Context;
#endif
+#if defined(USE_SHA384) && USE_SHA384
/*
* This structure will hold context information for the SHA-384
* hashing operation. It uses the SHA-512 structure for computation.
*/
typedef struct SHA512Context SHA384Context;
+#endif
/*
* This structure holds context information for all SHA
SHA224Context sha224Context;
#endif
SHA256Context sha256Context;
+#if defined(USE_SHA384) && USE_SHA384
SHA384Context sha384Context;
+#endif
SHA512Context sha512Context;
} ctx;
} USHAContext;
extern int SHA256Result (SHA256Context *,
uint8_t Message_Digest[SHA256HashSize]);
+#if defined(USE_SHA384) && USE_SHA384
/* SHA-384 */
extern int SHA384Reset (SHA384Context *);
extern int SHA384Input (SHA384Context *, const uint8_t * bytes,
unsigned int bitcount);
extern int SHA384Result (SHA384Context *,
uint8_t Message_Digest[SHA384HashSize]);
+#endif
/* SHA-512 */
extern int SHA512Reset (SHA512Context *);
static int SHA384_512ResultN (SHA512Context * context,
uint8_t Message_Digest[], int HashSize);
+#if defined(USE_SHA384) && USE_SHA384
/* Initial Hash Values: FIPS-180-2 sections 5.3.3 and 5.3.4 */
static uint64_t SHA384_H0[] = {
0xCBBB9D5DC1059ED8ll, 0x629A292A367CD507ll, 0x9159015A3070DD17ll,
0x152FECD8F70E5939ll, 0x67332667FFC00B31ll, 0x8EB44A8768581511ll,
0xDB0C2E0D64F98FA7ll, 0x47B5481DBEFA4FA4ll
};
+#endif
static uint64_t SHA512_H0[] = {
0x6A09E667F3BCC908ll, 0xBB67AE8584CAA73Bll, 0x3C6EF372FE94F82Bll,
#endif /* USE_32BIT_ONLY */
+#if defined(USE_SHA384) && USE_SHA384
/*
* SHA384Reset
*
{
return SHA384_512ResultN (context, Message_Digest, SHA384HashSize);
}
+#endif
/*
* SHA512Reset
#endif
case SHA256:
return SHA256Reset ((SHA256Context *) & ctx->ctx);
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384Reset ((SHA384Context *) & ctx->ctx);
+#endif
case SHA512:
return SHA512Reset ((SHA512Context *) & ctx->ctx);
default:
#endif
case SHA256:
return SHA256Input ((SHA256Context *) & ctx->ctx, bytes, bytecount);
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384Input ((SHA384Context *) & ctx->ctx, bytes, bytecount);
+#endif
case SHA512:
return SHA512Input ((SHA512Context *) & ctx->ctx, bytes, bytecount);
default:
case SHA256:
return SHA256FinalBits ((SHA256Context *) & ctx->ctx, bits,
bitcount);
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384FinalBits ((SHA384Context *) & ctx->ctx, bits,
bitcount);
+#endif
case SHA512:
return SHA512FinalBits ((SHA512Context *) & ctx->ctx, bits,
bitcount);
#endif
case SHA256:
return SHA256Result ((SHA256Context *) & ctx->ctx, Message_Digest);
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384Result ((SHA384Context *) & ctx->ctx, Message_Digest);
+#endif
case SHA512:
return SHA512Result ((SHA512Context *) & ctx->ctx, Message_Digest);
default:
#endif
case SHA256:
return SHA256_Message_Block_Size;
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384_Message_Block_Size;
+#endif
default:
case SHA512:
return SHA512_Message_Block_Size;
#endif
case SHA256:
return SHA256HashSize;
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384HashSize;
+#endif
default:
case SHA512:
return SHA512HashSize;
#endif
case SHA256:
return SHA256HashSizeBits;
+#if defined(USE_SHA384) && USE_SHA384
case SHA384:
return SHA384HashSizeBits;
+#endif
default:
case SHA512:
return SHA512HashSizeBits;