Module Name: othersrc Committed By: agc Date: Sun Sep 18 17:36:41 UTC 2011
Modified Files: othersrc/external/bsd/hmac/dist: hmac.c hmac.h hmacwrap.c hmacwrap.h libhmac.c Log Message: some const posioning for the HMAC key arguments to functions print out the resulting hmac with an "hmac" prefix, if it doesn't already have one. for the -a algorithm argument, recognise hmac-sha1, hmac-md5, etc as well as sha1, md5... To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/hmac/dist/hmac.c \ othersrc/external/bsd/hmac/dist/hmacwrap.c \ othersrc/external/bsd/hmac/dist/hmacwrap.h \ othersrc/external/bsd/hmac/dist/libhmac.c cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/hmac/dist/hmac.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/external/bsd/hmac/dist/hmac.c diff -u othersrc/external/bsd/hmac/dist/hmac.c:1.1.1.1 othersrc/external/bsd/hmac/dist/hmac.c:1.2 --- othersrc/external/bsd/hmac/dist/hmac.c:1.1.1.1 Thu Apr 14 04:52:46 2011 +++ othersrc/external/bsd/hmac/dist/hmac.c Sun Sep 18 17:36:41 2011 @@ -58,6 +58,9 @@ } if ((len = hmac(alg, key, strlen((char *)key), msg, st.st_size, mac, sizeof(mac))) != 0) { hmac_bin2str(mac, len, strmac, sizeof(strmac)); + if (strncmp(alg, "hmac", 4) != 0) { + printf("hmac-"); + } printf("%s (%s) = %s\n", alg, f, strmac); ret = 1; } else { Index: othersrc/external/bsd/hmac/dist/hmacwrap.c diff -u othersrc/external/bsd/hmac/dist/hmacwrap.c:1.1.1.1 othersrc/external/bsd/hmac/dist/hmacwrap.c:1.2 --- othersrc/external/bsd/hmac/dist/hmacwrap.c:1.1.1.1 Thu Apr 14 04:52:46 2011 +++ othersrc/external/bsd/hmac/dist/hmacwrap.c Sun Sep 18 17:36:41 2011 @@ -31,9 +31,9 @@ /*************************************************************************/ void -hmac_rmd160_init(hmac_rmd160_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_rmd160_init(hmac_rmd160_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(RMD160_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[RMD160_DIGEST_SIZE]; size_t fillc; @@ -101,7 +101,7 @@ } void -hmac_rmd160(uint8_t *key, size_t key_size, +hmac_rmd160(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { @@ -115,9 +115,9 @@ /*************************************************************************/ void -hmac_md5_init(hmac_md5_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_md5_init(hmac_md5_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(MD5_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[MD5_DIGEST_SIZE]; size_t fillc; @@ -185,7 +185,7 @@ } void -hmac_md5(uint8_t *key, size_t key_size, +hmac_md5(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { @@ -199,9 +199,9 @@ /*************************************************************************/ void -hmac_sha1_init(hmac_sha1_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_sha1_init(hmac_sha1_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(SHA1_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[SHA1_DIGEST_SIZE]; size_t fillc; @@ -270,7 +270,7 @@ } void -hmac_sha1(uint8_t *key, size_t key_size, +hmac_sha1(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { @@ -284,9 +284,9 @@ /****************************************************************************/ void -hmac_sha224_init(hmac_sha224_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_sha224_init(hmac_sha224_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(SHA224_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[SHA224_DIGEST_SIZE]; size_t fillc; @@ -355,7 +355,7 @@ } void -hmac_sha224(uint8_t *key, size_t key_size, +hmac_sha224(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { @@ -369,9 +369,9 @@ /****************************************************************************/ void -hmac_sha256_init(hmac_sha256_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_sha256_init(hmac_sha256_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(SHA256_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[SHA256_DIGEST_SIZE]; size_t fillc; @@ -441,7 +441,7 @@ } void -hmac_sha256(uint8_t *key, size_t key_size, +hmac_sha256(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { @@ -455,9 +455,9 @@ /****************************************************************************/ void -hmac_sha384_init(hmac_sha384_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_sha384_init(hmac_sha384_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(SHA384_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[SHA384_DIGEST_SIZE]; size_t fillc; @@ -525,7 +525,7 @@ } void -hmac_sha384(uint8_t *key, size_t key_size, +hmac_sha384(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { @@ -539,9 +539,9 @@ /****************************************************************************/ void -hmac_sha512_init(hmac_sha512_ctx_t *ctx, uint8_t *keyarg, size_t key_size) +hmac_sha512_init(hmac_sha512_ctx_t *ctx, const uint8_t *keyarg, size_t key_size) { - uint8_t *key; + const uint8_t *key; uint8_t key_dig[(SHA512_DIGEST_SIZE * 2) + 1]; uint8_t key_temp[SHA512_DIGEST_SIZE]; size_t fillc; @@ -609,7 +609,7 @@ } void -hmac_sha512(uint8_t *key, size_t key_size, +hmac_sha512(const uint8_t *key, size_t key_size, const uint8_t *message, size_t message_len, uint8_t *mac, size_t mac_size) { Index: othersrc/external/bsd/hmac/dist/hmacwrap.h diff -u othersrc/external/bsd/hmac/dist/hmacwrap.h:1.1.1.1 othersrc/external/bsd/hmac/dist/hmacwrap.h:1.2 --- othersrc/external/bsd/hmac/dist/hmacwrap.h:1.1.1.1 Thu Apr 14 04:52:46 2011 +++ othersrc/external/bsd/hmac/dist/hmacwrap.h Sun Sep 18 17:36:41 2011 @@ -134,47 +134,47 @@ uint8_t block_opad[SHA512_BLOCK_SIZE]; } hmac_sha512_ctx_t; -void hmac_md5_init(hmac_md5_ctx_t *, uint8_t *, size_t); +void hmac_md5_init(hmac_md5_ctx_t *, const uint8_t *, size_t); void hmac_md5_reinit(hmac_md5_ctx_t *); void hmac_md5_update(hmac_md5_ctx_t *, const uint8_t *, size_t); void hmac_md5_final(hmac_md5_ctx_t *, uint8_t *, size_t); -void hmac_md5(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_md5(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -void hmac_rmd160_init(hmac_rmd160_ctx_t *, uint8_t *, size_t); +void hmac_rmd160_init(hmac_rmd160_ctx_t *, const uint8_t *, size_t); void hmac_rmd160_reinit(hmac_rmd160_ctx_t *); void hmac_rmd160_update(hmac_rmd160_ctx_t *, const uint8_t *, size_t); void hmac_rmd160_final(hmac_rmd160_ctx_t *, uint8_t *, size_t); -void hmac_rmd160(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_rmd160(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -void hmac_sha1_init(hmac_sha1_ctx_t *, uint8_t *, size_t); +void hmac_sha1_init(hmac_sha1_ctx_t *, const uint8_t *, size_t); void hmac_sha1_reinit(hmac_sha1_ctx_t *); void hmac_sha1_update(hmac_sha1_ctx_t *, const uint8_t *, size_t); void hmac_sha1_final(hmac_sha1_ctx_t *, uint8_t *, size_t); -void hmac_sha1(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_sha1(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -void hmac_sha224_init(hmac_sha224_ctx_t *, uint8_t *, size_t); +void hmac_sha224_init(hmac_sha224_ctx_t *, const uint8_t *, size_t); void hmac_sha224_reinit(hmac_sha224_ctx_t *); void hmac_sha224_update(hmac_sha224_ctx_t *, const uint8_t *, size_t); void hmac_sha224_final(hmac_sha224_ctx_t *, uint8_t *, size_t); -void hmac_sha224(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_sha224(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -void hmac_sha256_init(hmac_sha256_ctx_t *, uint8_t *, size_t); +void hmac_sha256_init(hmac_sha256_ctx_t *, const uint8_t *, size_t); void hmac_sha256_reinit(hmac_sha256_ctx_t *); void hmac_sha256_update(hmac_sha256_ctx_t *, const uint8_t *, size_t); void hmac_sha256_final(hmac_sha256_ctx_t *, uint8_t *, size_t); -void hmac_sha256(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_sha256(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -void hmac_sha384_init(hmac_sha384_ctx_t *, uint8_t *, size_t); +void hmac_sha384_init(hmac_sha384_ctx_t *, const uint8_t *, size_t); void hmac_sha384_reinit(hmac_sha384_ctx_t *); void hmac_sha384_update(hmac_sha384_ctx_t *, const uint8_t *, size_t); void hmac_sha384_final(hmac_sha384_ctx_t *, uint8_t *, size_t); -void hmac_sha384(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_sha384(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -void hmac_sha512_init(hmac_sha512_ctx_t *, uint8_t *, size_t); +void hmac_sha512_init(hmac_sha512_ctx_t *, const uint8_t *, size_t); void hmac_sha512_reinit(hmac_sha512_ctx_t *); void hmac_sha512_update(hmac_sha512_ctx_t *, const uint8_t *, size_t); void hmac_sha512_final(hmac_sha512_ctx_t *, uint8_t *, size_t); -void hmac_sha512(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); +void hmac_sha512(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); #ifdef __cplusplus } Index: othersrc/external/bsd/hmac/dist/libhmac.c diff -u othersrc/external/bsd/hmac/dist/libhmac.c:1.1.1.1 othersrc/external/bsd/hmac/dist/libhmac.c:1.2 --- othersrc/external/bsd/hmac/dist/libhmac.c:1.1.1.1 Thu Apr 14 04:52:46 2011 +++ othersrc/external/bsd/hmac/dist/libhmac.c Sun Sep 18 17:36:41 2011 @@ -34,10 +34,17 @@ typedef struct hmac_t { const char *alg; /* digest algorithm name */ const size_t macsize; /* size of raw MAC digest */ - void (*func)(uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); + void (*func)(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); } hmac_t; static hmac_t hmacs[] = { + { "hmac-sha512", SHA512_DIGEST_SIZE, hmac_sha512 }, + { "hmac-sha256", SHA256_DIGEST_SIZE, hmac_sha256 }, + { "hmac-sha224", SHA224_DIGEST_SIZE, hmac_sha224 }, + { "hmac-sha384", SHA384_DIGEST_SIZE, hmac_sha384 }, + { "hmac-sha1", SHA1_DIGEST_SIZE, hmac_sha1 }, + { "hmac-rmd160", RMD160_DIGEST_SIZE, hmac_rmd160 }, + { "hmac-md5", MD5_DIGEST_SIZE, hmac_md5 }, { "sha512", SHA512_DIGEST_SIZE, hmac_sha512 }, { "sha256", SHA256_DIGEST_SIZE, hmac_sha256 }, { "sha224", SHA224_DIGEST_SIZE, hmac_sha224 }, Index: othersrc/external/bsd/hmac/dist/hmac.h diff -u othersrc/external/bsd/hmac/dist/hmac.h:1.2 othersrc/external/bsd/hmac/dist/hmac.h:1.3 --- othersrc/external/bsd/hmac/dist/hmac.h:1.2 Tue May 3 06:28:22 2011 +++ othersrc/external/bsd/hmac/dist/hmac.h Sun Sep 18 17:36:41 2011 @@ -39,10 +39,9 @@ __BEGIN_DECLS - -int hmac(const char *, uint8_t *, size_t, const uint8_t *, size_t, uint8_t *, size_t); -size_t hmac_bin2str(uint8_t *, size_t, char *, size_t); -size_t hmac_str2bin(uint8_t *, size_t, uint8_t *, size_t); +int hmac(const char */*alg*/, uint8_t */*key*/, size_t /*keylen*/, const uint8_t */*msg*/, size_t/*msglen*/, uint8_t */*mac*/, size_t/*macsize*/); +size_t hmac_bin2str(uint8_t */*digest*/, size_t /*digestsize*/, char */*str*/, size_t /*strsize*/); +size_t hmac_str2bin(uint8_t */*str*/, size_t /*strsize*/, uint8_t */*out*/, size_t /*outsize*/); enum { HMAC_MAX_DIGEST_SIZE = 64,