Skip to content

Commit

Permalink
Include magic in header/HMAC
Browse files Browse the repository at this point in the history
  • Loading branch information
rnapier committed Jun 27, 2015
1 parent 2ed070a commit 04378bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions draft-RNCryptor-Spec-v4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ Expand().
def Encrypt(prk[64], options[1], salt[16], plaintext) =
(encryptionKey[32], hmacKey[32], iv[16], validator[16]) = Expand(prk)
magic = "RNC" (0x52 0x4e 0x43)
version = 0x04
header = version || options || salt || validator
header = magic || version || options || salt || validator
ciphertext = AESEncrypt(256 bits, CBCMode, encryptionKey, iv, plaintext)
hmac = HMAC(SHA512, hmacKey, header || ciphertext, 256 bits)
return header || ciphertext || hmac
Expand All @@ -96,8 +97,9 @@ def Decrypt(prk[64], options[1], salt[16], validator[16], ciphertext, hmac[32])
(encryptionKey[32], hmacKey[32], iv[16], validator[16]) = Expand(prk)
if (! ConsistentTimeEqual(expectedValidator, validator) return KEY_MISMATCH
magic = "RNC" (0x52 0x4e 0x43)
version = 0x04
header = version || options || salt || validator
header = magic || version || options || salt || validator
expectedHmac = HMAC(SHA512, hmacKey, header || ciphertext, 256 bits)
if ! ConsistentTimeEqual(expectedHmac, hmac) return CORRUPT
Expand Down

0 comments on commit 04378bc

Please sign in to comment.