Пример #1
0
 public OOTransport(bool initiator, CipherState <CipherType> c1, CipherState <CipherType> c2)
 {
     Exceptions.ThrowIfNull(c1, nameof(c1));
     this.initiator = initiator;
     this.c1        = c1;
     this.c2        = c2;
     filter         = new ReplayFilterNoBitshift();
 }
Пример #2
0
        /// <summary>
        /// Returns a pair of CipherState objects for encrypting transport messages.
        /// </summary>
        public (CipherState <CipherType> c1, CipherState <CipherType> c2) Split()
        {
            Span <byte> output = stackalloc byte[2 * hash.HashLen];

            hkdf.ExtractAndExpand2(ck, null, output);

            var tempK1 = output.Slice(0, Aead.KeySize);
            var tempK2 = output.Slice(hash.HashLen, Aead.KeySize);

            var c1 = new CipherState <CipherType>();
            var c2 = new CipherState <CipherType>();

            c1.InitializeKey(tempK1);
            c2.InitializeKey(tempK2);

            return(c1, c2);
        }