Avoids creating a byte array and recreating it again inside of the Mac instance.
This commit is contained in:
@@ -210,7 +210,7 @@ class Nip44v2 {
|
|||||||
"AAD associated data must be 32 bytes, but it was ${aad.size} bytes"
|
"AAD associated data must be 32 bytes, but it was ${aad.size} bytes"
|
||||||
}
|
}
|
||||||
|
|
||||||
return hkdf.extract(aad + message, key)
|
return hkdf.extract(aad, message, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMessageKeys(
|
fun getMessageKeys(
|
||||||
|
|||||||
@@ -37,6 +37,18 @@ class Hkdf(
|
|||||||
return mac.doFinal(key)
|
return mac.doFinal(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun extract(
|
||||||
|
key1: ByteArray,
|
||||||
|
key2: ByteArray,
|
||||||
|
salt: ByteArray,
|
||||||
|
): ByteArray {
|
||||||
|
val mac = Mac.getInstance(algorithm)
|
||||||
|
mac.init(SecretKeySpec(salt, algorithm))
|
||||||
|
mac.update(key1)
|
||||||
|
mac.update(key2)
|
||||||
|
return mac.doFinal()
|
||||||
|
}
|
||||||
|
|
||||||
fun expand(
|
fun expand(
|
||||||
key: ByteArray,
|
key: ByteArray,
|
||||||
nonce: ByteArray,
|
nonce: ByteArray,
|
||||||
|
|||||||
Reference in New Issue
Block a user