Skip to content

Commit

Permalink
All to store Receiver Key
Browse files Browse the repository at this point in the history
  • Loading branch information
scampion committed May 2, 2019
1 parent 58b1fd8 commit 3d2b789
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,9 @@ private ChainKey getOrCreateChainKey(SessionState sessionState, ECPublicKey thei
sessionState.addReceiverChain(theirEphemeral, receiverChain.second());
sessionState.setPreviousCounter(Math.max(sessionState.getSenderChainKey().getIndex()-1, 0));
sessionState.setSenderChain(ourNewEphemeral, senderChain.second());
sessionState.setReceiverRootKey(receiverChain.first());

return receiverChain.second();
return receiverChain.second();
}
} catch (InvalidKeyException e) {
throw new InvalidMessageException(e);
Expand Down Expand Up @@ -427,7 +428,6 @@ private Cipher getCipher(int mode, SecretKeySpec key, IvParameterSpec iv) {
public void half_ratchet(SessionState sessionState) throws InvalidKeyException, InvalidMessageException, DuplicateMessageException {
ChainKey chainKey = getOrCreateChainKey(sessionState);
ECPublicKey theirEphemeral = sessionState.getLatestReceiverRatchetKey();
getOrCreateMessageKeys(sessionState, theirEphemeral, chainKey, 1);
}

private ChainKey getOrCreateChainKey(SessionState sessionState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ public void addReceiverChain(ECPublicKey senderRatchetKey, ChainKey chainKey) {
}
}

public void setReceiverRootKey(RootKey rootKey) {
this.sessionStructure = this.sessionStructure.toBuilder()
.setReceiverRootKey(ByteString.copyFrom(rootKey.getKeyBytes()))
.build();
}

public void setSenderChain(ECKeyPair senderRatchetKeyPair, ChainKey chainKey) {
Chain.ChainKey chainKeyStructure = Chain.ChainKey.newBuilder()
.setKey(ByteString.copyFrom(chainKey.getKey()))
Expand Down

0 comments on commit 3d2b789

Please sign in to comment.