Skip to content

Instantly share code, notes, and snippets.

@mykiimike
Created June 9, 2015 08:07
Show Gist options
  • Save mykiimike/fb225d035f8cd0717e5c to your computer and use it in GitHub Desktop.
Save mykiimike/fb225d035f8cd0717e5c to your computer and use it in GitHub Desktop.
ar1s code in my gist
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);
}
@mykiimike
Copy link
Author

Find the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment