mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-18 22:28:27 +00:00
Add info to MessageKey HKDF, change order of RootKey derivation.
This commit is contained in:
parent
44092a3eff
commit
f7b71e5e28
@ -38,7 +38,7 @@ public class ChainKey {
|
|||||||
public MessageKeys getMessageKeys() {
|
public MessageKeys getMessageKeys() {
|
||||||
HKDF kdf = new HKDF();
|
HKDF kdf = new HKDF();
|
||||||
byte[] inputKeyMaterial = getBaseMaterial(MESSAGE_KEY_SEED);
|
byte[] inputKeyMaterial = getBaseMaterial(MESSAGE_KEY_SEED);
|
||||||
DerivedSecrets keyMaterial = kdf.deriveSecrets(inputKeyMaterial, null);
|
DerivedSecrets keyMaterial = kdf.deriveSecrets(inputKeyMaterial, "WhisperMessageKeys".getBytes());
|
||||||
|
|
||||||
return new MessageKeys(keyMaterial.getCipherKey(), keyMaterial.getMacKey(), index);
|
return new MessageKeys(keyMaterial.getCipherKey(), keyMaterial.getMacKey(), index);
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,8 @@ public class RatchetingSession {
|
|||||||
sessionRecord.setRootKey(sendingChain.first);
|
sessionRecord.setRootKey(sendingChain.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<RootKey, ChainKey> calculate3DHE(ECKeyPair ourEphemeral, ECPublicKey theirEphemeral,
|
private static Pair<RootKey, ChainKey> calculate3DHE(ECKeyPair ourEphemeral, ECPublicKey theirEphemeral,
|
||||||
IdentityKeyPair ourIdentity, IdentityKey theirIdentity)
|
IdentityKeyPair ourIdentity, IdentityKey theirIdentity)
|
||||||
throws InvalidKeyException
|
throws InvalidKeyException
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -30,8 +30,8 @@ public class RootKey {
|
|||||||
HKDF kdf = new HKDF();
|
HKDF kdf = new HKDF();
|
||||||
byte[] sharedSecret = Curve.calculateAgreement(theirEphemeral, ourEphemeral.getPrivateKey());
|
byte[] sharedSecret = Curve.calculateAgreement(theirEphemeral, ourEphemeral.getPrivateKey());
|
||||||
DerivedSecrets keys = kdf.deriveSecrets(sharedSecret, key, "WhisperRatchet".getBytes());
|
DerivedSecrets keys = kdf.deriveSecrets(sharedSecret, key, "WhisperRatchet".getBytes());
|
||||||
RootKey newRootKey = new RootKey(keys.getMacKey().getEncoded());
|
RootKey newRootKey = new RootKey(keys.getCipherKey().getEncoded());
|
||||||
ChainKey newChainKey = new ChainKey(keys.getCipherKey().getEncoded(), 0);
|
ChainKey newChainKey = new ChainKey(keys.getMacKey().getEncoded(), 0);
|
||||||
|
|
||||||
return new Pair<RootKey, ChainKey>(newRootKey, newChainKey);
|
return new Pair<RootKey, ChainKey>(newRootKey, newChainKey);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user