diff options
author | Jonas Smedegaard <dr@jones.dk> | 2016-12-21 21:25:09 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2016-12-21 21:25:09 +0100 |
commit | f820d86aadb7a5473bcc0a0a3669732ab0182555 (patch) | |
tree | a6a673c444ea3df75fe0a5d53e905030c2f617ce /louloulibs/utils/sha1.cpp | |
parent | eda4b75b1cff83336e87da90efca9fd6b4ced2c7 (diff) | |
parent | 9634cdaba2e5d2343fcbc1f07264d55609640273 (diff) | |
download | biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.tar.gz biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.tar.bz2 biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.tar.xz biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.zip |
New upstream version 4.0upstream/4.0
Diffstat (limited to 'louloulibs/utils/sha1.cpp')
-rw-r--r-- | louloulibs/utils/sha1.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/louloulibs/utils/sha1.cpp b/louloulibs/utils/sha1.cpp index 76476df..f75bc2a 100644 --- a/louloulibs/utils/sha1.cpp +++ b/louloulibs/utils/sha1.cpp @@ -119,36 +119,3 @@ uint8_t* sha1_result(sha1nfo *s) { // Return pointer to hash (20 characters) return s->state.b; } - -#define HMAC_IPAD 0x36 -#define HMAC_OPAD 0x5c - -void sha1_initHmac(sha1nfo *s, const uint8_t* key, int keyLength) { - uint8_t i; - memset(s->keyBuffer, 0, BLOCK_LENGTH); - if (keyLength > BLOCK_LENGTH) { - // Hash long keys - sha1_init(s); - for (;keyLength--;) sha1_writebyte(s, *key++); - memcpy(s->keyBuffer, sha1_result(s), HASH_LENGTH); - } else { - // Block length keys are used as is - memcpy(s->keyBuffer, key, keyLength); - } - // Start inner hash - sha1_init(s); - for (i=0; i<BLOCK_LENGTH; i++) { - sha1_writebyte(s, s->keyBuffer[i] ^ HMAC_IPAD); - } -} - -uint8_t* sha1_resultHmac(sha1nfo *s) { - uint8_t i; - // Complete inner hash - memcpy(s->innerHash,sha1_result(s),HASH_LENGTH); - // Calculate outer hash - sha1_init(s); - for (i=0; i<BLOCK_LENGTH; i++) sha1_writebyte(s, s->keyBuffer[i] ^ HMAC_OPAD); - for (i=0; i<HASH_LENGTH; i++) sha1_writebyte(s, s->innerHash[i]); - return sha1_result(s); -} |