diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-05-09 16:35:45 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-05-09 23:36:11 +0000 |
commit | acf7985f7377806e23d7ec9daa14a3a6886a51c7 (patch) | |
tree | 3c46c8ceb05fc7feee052c138c437f83f5381a53 /wsutil/sha1.h | |
parent | bb89e7724220098e7b7fba5d31daf0d916b2d553 (diff) | |
download | wireshark-acf7985f7377806e23d7ec9daa14a3a6886a51c7.tar.gz wireshark-acf7985f7377806e23d7ec9daa14a3a6886a51c7.tar.bz2 wireshark-acf7985f7377806e23d7ec9daa14a3a6886a51c7.zip |
Define the SHA-1 digest length in wsutil/sha1.h and use it.
Hopefully that'll make it a little easier to make sure that we're not
overflowing arrays.
Change-Id: I770df045ef9a45fd486c1271ea424b3334bb39d2
Reviewed-on: https://code.wireshark.org/review/8370
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/sha1.h')
-rw-r--r-- | wsutil/sha1.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/wsutil/sha1.h b/wsutil/sha1.h index f4f9d86a1c..52a9842d57 100644 --- a/wsutil/sha1.h +++ b/wsutil/sha1.h @@ -30,6 +30,11 @@ #include "ws_symbol_export.h" +/* + * Length of a SHA-1 digest, in bytes. 160 bits = 20 bytes. + */ +#define SHA1_DIGEST_LEN 20 + typedef struct { guint32 total[2]; @@ -43,7 +48,7 @@ void sha1_starts( sha1_context *ctx ); WS_DLL_PUBLIC void sha1_update( sha1_context *ctx, const guint8 *input, guint32 length ); WS_DLL_PUBLIC -void sha1_finish( sha1_context *ctx, guint8 digest[20] ); +void sha1_finish( sha1_context *ctx, guint8 digest[SHA1_DIGEST_LEN] ); typedef struct { sha1_context ctx; @@ -56,9 +61,9 @@ void sha1_hmac_starts( sha1_hmac_context *hctx, const guint8 *key, guint32 keyle WS_DLL_PUBLIC void sha1_hmac_update( sha1_hmac_context *hctx, const guint8 *buf, guint32 buflen ); WS_DLL_PUBLIC -void sha1_hmac_finish( sha1_hmac_context *hctx, guint8 digest[20] ); +void sha1_hmac_finish( sha1_hmac_context *hctx, guint8 digest[SHA1_DIGEST_LEN] ); WS_DLL_PUBLIC void sha1_hmac( const guint8 *key, guint32 keylen, const guint8 *buf, guint32 buflen, - guint8 digest[20] ); + guint8 digest[SHA1_DIGEST_LEN] ); #endif /* sha1.h */ |