mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-29 07:53:30 +01:00
Remove unused HMAC-SHA1 function
(We're not adding any new SHA1 instances in our protocols, so this should never actually be needed.)
This commit is contained in:
parent
289653c392
commit
a05dc378e3
@ -1631,21 +1631,6 @@ crypto_digest_assign(crypto_digest_t *into,
|
|||||||
memcpy(into,from,sizeof(crypto_digest_t));
|
memcpy(into,from,sizeof(crypto_digest_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compute the HMAC-SHA-1 of the <b>msg_len</b> bytes in <b>msg</b>, using
|
|
||||||
* the <b>key</b> of length <b>key_len</b>. Store the DIGEST_LEN-byte result
|
|
||||||
* in <b>hmac_out</b>.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
crypto_hmac_sha1(char *hmac_out,
|
|
||||||
const char *key, size_t key_len,
|
|
||||||
const char *msg, size_t msg_len)
|
|
||||||
{
|
|
||||||
tor_assert(key_len < INT_MAX);
|
|
||||||
tor_assert(msg_len < INT_MAX);
|
|
||||||
HMAC(EVP_sha1(), key, (int)key_len, (unsigned char*)msg, (int)msg_len,
|
|
||||||
(unsigned char*)hmac_out, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Compute the HMAC-SHA-256 of the <b>msg_len</b> bytes in <b>msg</b>, using
|
/** Compute the HMAC-SHA-256 of the <b>msg_len</b> bytes in <b>msg</b>, using
|
||||||
* the <b>key</b> of length <b>key_len</b>. Store the DIGEST256_LEN-byte
|
* the <b>key</b> of length <b>key_len</b>. Store the DIGEST256_LEN-byte
|
||||||
* result in <b>hmac_out</b>.
|
* result in <b>hmac_out</b>.
|
||||||
|
@ -218,9 +218,6 @@ void crypto_digest_get_digest(crypto_digest_t *digest,
|
|||||||
crypto_digest_t *crypto_digest_dup(const crypto_digest_t *digest);
|
crypto_digest_t *crypto_digest_dup(const crypto_digest_t *digest);
|
||||||
void crypto_digest_assign(crypto_digest_t *into,
|
void crypto_digest_assign(crypto_digest_t *into,
|
||||||
const crypto_digest_t *from);
|
const crypto_digest_t *from);
|
||||||
void crypto_hmac_sha1(char *hmac_out,
|
|
||||||
const char *key, size_t key_len,
|
|
||||||
const char *msg, size_t msg_len);
|
|
||||||
void crypto_hmac_sha256(char *hmac_out,
|
void crypto_hmac_sha256(char *hmac_out,
|
||||||
const char *key, size_t key_len,
|
const char *key, size_t key_len,
|
||||||
const char *msg, size_t msg_len);
|
const char *msg, size_t msg_len);
|
||||||
|
@ -269,34 +269,6 @@ test_crypto_sha(void)
|
|||||||
"96177A9CB410FF61F20015AD");
|
"96177A9CB410FF61F20015AD");
|
||||||
tt_int_op(i, ==, 0);
|
tt_int_op(i, ==, 0);
|
||||||
|
|
||||||
/* Test HMAC-SHA-1 with test cases from RFC2202. */
|
|
||||||
|
|
||||||
/* Case 1. */
|
|
||||||
memset(key, 0x0b, 20);
|
|
||||||
crypto_hmac_sha1(digest, key, 20, "Hi There", 8);
|
|
||||||
test_streq(hex_str(digest, 20),
|
|
||||||
"B617318655057264E28BC0B6FB378C8EF146BE00");
|
|
||||||
/* Case 2. */
|
|
||||||
crypto_hmac_sha1(digest, "Jefe", 4, "what do ya want for nothing?", 28);
|
|
||||||
test_streq(hex_str(digest, 20),
|
|
||||||
"EFFCDF6AE5EB2FA2D27416D5F184DF9C259A7C79");
|
|
||||||
|
|
||||||
/* Case 4. */
|
|
||||||
base16_decode(key, 25,
|
|
||||||
"0102030405060708090a0b0c0d0e0f10111213141516171819", 50);
|
|
||||||
memset(data, 0xcd, 50);
|
|
||||||
crypto_hmac_sha1(digest, key, 25, data, 50);
|
|
||||||
test_streq(hex_str(digest, 20),
|
|
||||||
"4C9007F4026250C6BC8414F9BF50C86C2D7235DA");
|
|
||||||
|
|
||||||
/* Case 5. */
|
|
||||||
memset(key, 0xaa, 80);
|
|
||||||
crypto_hmac_sha1(digest, key, 80,
|
|
||||||
"Test Using Larger Than Block-Size Key - Hash Key First",
|
|
||||||
54);
|
|
||||||
test_streq(hex_str(digest, 20),
|
|
||||||
"AA4AE5E15272D00E95705637CE8A3B55ED402112");
|
|
||||||
|
|
||||||
/* Test HMAC-SHA256 with test cases from wikipedia and RFC 4231 */
|
/* Test HMAC-SHA256 with test cases from wikipedia and RFC 4231 */
|
||||||
|
|
||||||
/* Case empty (wikipedia) */
|
/* Case empty (wikipedia) */
|
||||||
|
Loading…
Reference in New Issue
Block a user