public void PRFn_WithValidInput_ShouldReturnByteArrayWithCorrectLength() { // Arrange and Act byte[] resultBytes = CryptographyWrapper.PRFn(_length, _prfKey, _prefix, _data); // Assert Assert.AreEqual((int)_length, resultBytes.Length); }
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); }
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); }
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); }
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); }