Exemplo n.º 1
0
        private static DerivedKeys CalculateDerivedKeys(uint sessionVersion, byte[] masterSecret)
        {
            HKDF kdf = HKDF.CreateFor(sessionVersion);

            byte[]   derivedSecretBytes = kdf.DeriveSecrets(masterSecret, Encoding.UTF8.GetBytes("WhisperText"), 64);
            byte[][] derivedSecrets     = ByteUtil.Split(derivedSecretBytes, 32, 32);

            return(new DerivedKeys(new RootKey(kdf, derivedSecrets[0]),
                                   new ChainKey(kdf, derivedSecrets[1], 0)));
        }
Exemplo n.º 2
0
        public ChainKey GetReceiverChainKey(ECPublicKey senderEphemeral)
        {
            Pair <Chain, uint> receiverChainAndIndex = GetReceiverChain(senderEphemeral);
            Chain receiverChain = receiverChainAndIndex.First();

            if (receiverChain == null)
            {
                return(null);
            }
            else
            {
                return(new ChainKey(HKDF.CreateFor(GetSessionVersion()),
                                    receiverChain.ChainKey.Key.ToByteArray(),
                                    receiverChain.ChainKey.Index));
            }
        }
Exemplo n.º 3
0
 public ChainKey GetSenderChainKey()
 {
     Chain.Types.ChainKey chainKeyStructure = sessionStructure.SenderChain.ChainKey;
     return(new ChainKey(HKDF.CreateFor(GetSessionVersion()),
                         chainKeyStructure.Key.ToByteArray(), chainKeyStructure.Index));
 }
Exemplo n.º 4
0
 public RootKey GetRootKey()
 {
     return(new RootKey(HKDF.CreateFor(GetSessionVersion()),
                        this.sessionStructure.RootKey.ToByteArray()));
 }