diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-01-08 13:48:49 -0800 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-01-08 14:09:01 -0800 |
commit | 6445ea5f13850f42c3952bd06a2369317683ed88 (patch) | |
tree | f2bb37c8cf4710ff6a6a37a3e7e702c5a21ca504 /src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java | |
parent | a4d8f7f6a4c4e9e89db35f299e558dceee2362a1 (diff) |
Break project up into Java and Android build/test.
Diffstat (limited to 'src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java')
-rw-r--r-- | src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java b/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java deleted file mode 100644 index 71375923..00000000 --- a/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.whispersystems.libaxolotl.groups.ratchet; - -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -public class SenderChainKey { - - private static final byte[] MESSAGE_KEY_SEED = {0x01}; - private static final byte[] CHAIN_KEY_SEED = {0x02}; - - private final int iteration; - private final byte[] chainKey; - - public SenderChainKey(int iteration, byte[] chainKey) { - this.iteration = iteration; - this.chainKey = chainKey; - } - - public int getIteration() { - return iteration; - } - - public SenderMessageKey getSenderMessageKey() { - return new SenderMessageKey(iteration, getDerivative(MESSAGE_KEY_SEED, chainKey)); - } - - public SenderChainKey getNext() { - return new SenderChainKey(iteration + 1, getDerivative(CHAIN_KEY_SEED, chainKey)); - } - - public byte[] getSeed() { - return chainKey; - } - - private byte[] getDerivative(byte[] seed, byte[] key) { - try { - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(new SecretKeySpec(key, "HmacSHA256")); - - return mac.doFinal(seed); - } catch (NoSuchAlgorithmException | InvalidKeyException e) { - throw new AssertionError(e); - } - } - -} |