|
@@ -1311,56 +1311,6 @@ crypto_digest_assign(crypto_digest_env_t *into,
|
|
|
memcpy(into,from,sizeof(crypto_digest_env_t));
|
|
|
}
|
|
|
|
|
|
-#if 0
|
|
|
-
|
|
|
-#define DIGEST_BLOCKSIZE 64
|
|
|
-
|
|
|
-
|
|
|
- * 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)
|
|
|
-{
|
|
|
- SHA_CTX sha;
|
|
|
- uint8_t K[DIGEST_BLOCKSIZE], D[DIGEST_LEN], K_SHORT[DIGEST_LEN];
|
|
|
- const uint8_t *real_key;
|
|
|
- unsigned int i;
|
|
|
-
|
|
|
- if (key_len > DIGEST_BLOCKSIZE) {
|
|
|
- SHA1((const unsigned char*)key, key_len, K_SHORT);
|
|
|
- key_len = DIGEST_LEN;
|
|
|
- real_key = K_SHORT;
|
|
|
- } else {
|
|
|
- real_key = (const uint8_t*)key;
|
|
|
- }
|
|
|
-
|
|
|
- memset(K, 0, sizeof(K));
|
|
|
- memcpy(K, real_key, key_len);
|
|
|
- for (i=0; i < sizeof(K); ++i)
|
|
|
- K[i] ^= 0x36;
|
|
|
- SHA1_Init(&sha);
|
|
|
- SHA1_Update(&sha, K, sizeof(K));
|
|
|
- SHA1_Update(&sha, msg, msg_len);
|
|
|
- SHA1_Final(D, &sha);
|
|
|
-
|
|
|
-
|
|
|
- memset(K, 0, sizeof(K));
|
|
|
- memcpy(K, real_key, key_len);
|
|
|
- for (i=0; i < sizeof(K); ++i)
|
|
|
- K[i] ^= 0x5c;
|
|
|
- */
|
|
|
- for (i=0; i < sizeof(K); ++i)
|
|
|
- K[i] ^= (0x36 ^ 0x5c);
|
|
|
- SHA1_Init(&sha);
|
|
|
- SHA1_Update(&sha, K, sizeof(K));
|
|
|
- SHA1_Update(&sha, D, sizeof(D));
|
|
|
- SHA1_Final((unsigned char*)hmac_out, &sha);
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
|
|
|
* the <b>key</b> of length <b>key_len</b>. Store the DIGEST_LEN-byte result
|
|
|
* in <b>hmac_out</b>.
|