示例#1
0
        public void Test_InitializeNonce_ExistingNonce_InitializesSuccessfully()
        {
            var nonceBytes = RandomBytesGenerator.NextBytes(NonceLength);
            var nonce      = new XChaChaNonce(nonceBytes);

            Assert.Equal(nonce.ToArray(), nonceBytes);
        }
        public void GlobalSetup()
        {
            this.data = new byte[this.DataLengthKb * 1024];
            new Random(31).NextBytes(data);
            this.key   = XChaChaKey.Generate();
            this.nonce = XChaChaNonce.Generate();
            var aeadCipher = new XChaChaAeadCipher();

            this.encryptedData       = new byte[aeadCipher.GetCipherTextLength(this.data.Length)];
            this.decryptOutputBuffer = new byte[aeadCipher.GetCipherTextLength(this.data.Length)];
            aeadCipher.Encrypt(data, this.encryptedData, this.key, this.nonce);
        }
示例#3
0
        public void Test_GenerateNonce_GeneratesNonceOfTheCorrectLength()
        {
            var nonce = XChaChaNonce.Generate();

            Assert.Equal(NonceLength, nonce.ReadOnlySpan.Length);
        }