Beispiel #1
0
        public static byte[] GenerateOneTimeKey(ReadOnlySpan <byte> key, ReadOnlySpan <byte> nonce, uint numRounds)
        {
            var ivLow      = 0U;
            var ivHigh     = BinaryPrimitives.ReadUInt32LittleEndian(nonce);
            var oneTimeKey = new byte[ChaChaTransform.BlockLength];

            ChaChaTransform.WriteKeyStreamBlock(ChaCha.Initialize(key, nonce, ivLow), BitwiseHelpers.ConcatBits(ivHigh, ivLow), numRounds, oneTimeKey);

            return(oneTimeKey);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AeadChaChaPoly1305"/> class.
 /// </summary>
 protected AeadChaChaPoly1305(byte[] aad, ChaCha chaCha, Poly1305 poly1305)
 {
     m_aad      = aad;
     m_chaCha   = chaCha;
     m_poly1305 = poly1305;
 }
Beispiel #3
0
 private AeadChaCha20Poly1305(byte[] aad, ChaCha chaCha, Poly1305 poly1305) : base(aad, chaCha, poly1305)
 {
 }