Esempio n. 1
0
        public void PRFn_WithValidInput_ShouldReturnByteArrayWithCorrectLength()
        {
            // Arrange and Act
            byte[] resultBytes =
                CryptographyWrapper.PRFn(_length, _prfKey, _prefix, _data);

            // Assert
            Assert.AreEqual((int)_length, resultBytes.Length);
        }
Esempio n. 2
0
        public void PRFn_WithValidInput_ShouldReturnCorrectBytes()
        {
            // Arrange and Act
            byte[] resultBytes =
                CryptographyWrapper.PRFn(_length, _prfKey, _prefix, _data);
            bool resultIsCorrect =
                HelperMethods.CompareBuffers(resultBytes, _prf512, (int)_length) == 0;

            // Assert
            Assert.IsTrue(resultIsCorrect);
        }
Esempio n. 3
0
        public void PBKDF2_WithValidInput_ShouldReturnCorrectKey()
        {
            // Arrange and Act
            byte[] derivedKey =
                CryptographyWrapper.PBKDF2(_password, _salt, _iterations, _dkLen);
            bool deriveKeyIsCorrect =
                HelperMethods.CompareBuffers(derivedKey, _derivedKey, _dkLen) == 0;

            // Assert
            Assert.IsTrue(deriveKeyIsCorrect);
        }
Esempio n. 4
0
        public void AESCCMEncryptBytes_WithValidCCMPInput_ShouldEncryptCorrectly()
        {
            // Arrange
            byte[] bytesToEncrypt = new byte[_plaintext.Length];
            _plaintext.CopyTo(bytesToEncrypt, 0);

            // Act
            CryptographyWrapper.AESCCMEncryptBytes(bytesToEncrypt, _nonce, _ctrKey, new byte[8]);
            bool encryptedCorrectly =
                HelperMethods.CompareBuffers(_ciphertext, bytesToEncrypt, _ciphertext.Length) == 0;

            // Assert
            Assert.IsTrue(encryptedCorrectly);
        }
Esempio n. 5
0
        public void AESCCMEncryptBytes_WithValidCCMPInput_ShouldProduceCorrectTag()
        {
            // Arrange
            byte[] bytesToEncrypt = new byte[_plaintext.Length];
            _plaintext.CopyTo(bytesToEncrypt, 0);
            byte[] tag = new byte[_tag.Length];

            // Act
            CryptographyWrapper.AESCCMEncryptBytes(bytesToEncrypt, _nonce, _ctrKey, tag);
            bool tagIsCorrect = HelperMethods.CompareBuffers(_tag, tag, _tag.Length) == 0;

            // Assert
            Assert.IsTrue(tagIsCorrect);
        }