Created
June 9, 2015 08:07
-
-
Save mykiimike/fb225d035f8cd0717e5c to your computer and use it in GitHub Desktop.
ar1s code in my gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void compute_session_keys(uint8_t encryptkey[AES128_KEY_LEN], | |
uint8_t IV[AES128_KEY_LEN], | |
uint8_t integrity[AES128_KEY_LEN], | |
uint8_t master_key[AES128_KEY_LEN], | |
uint8_t encryption_salt[8]){ | |
uint8_t long_encryptkey[SHA256_DIGEST_LEN]; | |
uint8_t long_IV[SHA256_DIGEST_LEN]; | |
uint8_t long_integrity[SHA256_DIGEST_LEN]; | |
HMAC_SHA256_CTX ctx; | |
HMAC_SHA256_Init(&ctx, master_key, sizeof(master_key)); | |
HMAC_SHA256_Update(&ctx,encryption_salt, 8); | |
HMAC_SHA256_Update(&ctx, "encryption", 10); | |
HMAC_SHA256_Final(long_encryptkey, &ctx); | |
HMAC_SHA256_Init(&ctx, master_key, sizeof(master_key)); | |
HMAC_SHA256_Update(&ctx,encryption_salt, 8); | |
HMAC_SHA256_Update(&ctx, "IV", 2); | |
HMAC_SHA256_Final(long_IV, &ctx); | |
HMAC_SHA256_Init(&ctx, master_key, sizeof(master_key)); | |
HMAC_SHA256_Update(&ctx,encryption_salt, 8); | |
HMAC_SHA256_Update(&ctx, "integrity", 9); | |
HMAC_SHA256_Final(long_integrity, &ctx); | |
memcpy(encryptkey, long_encryptkey, AES128_KEY_LEN); | |
memcpy(IV, long_IV, AES128_KEY_LEN); | |
memcpy(integrity, long_integrity, AES128_KEY_LEN); | |
ZERO(long_encryptkey); | |
ZERO(long_IV); | |
ZERO(long_integrity); | |
ZERO(ctx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find the bug