1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-23 03:33:59 +00:00

Android test project with Key Derivation Tests

This commit is contained in:
Kyle Spearrin
2016-08-01 20:49:04 -04:00
parent 6f800896c3
commit 23097072ef
13 changed files with 3526 additions and 3268 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Text;
using System.Linq;
using NUnit.Framework;
namespace Bit.Android.Test
{
[TestFixture]
public class KeyDerivationTests
{
[SetUp]
public void Setup() { }
[TearDown]
public void Tear() { }
[Test]
public void MakeKeyFromPasswordBase64()
{
var service = new CommonCryptoKeyDerivationService();
var key = service.DeriveKey(Encoding.UTF8.GetBytes("123456"), Encoding.UTF8.GetBytes("salt"), 5000);
Assert.True(key.SequenceEqual(GetKey()));
}
[Test]
public void HashPasswordBase64()
{
var service = new CommonCryptoKeyDerivationService();
var hash = service.DeriveKey(GetKey(), Encoding.UTF8.GetBytes("123456"), 1);
var hashBytes = Convert.FromBase64String("7Bsl4ponrsFu0jGl4yMeLZp5tKqx6g4tLrXhMszIsjQ=");
Assert.True(hash.SequenceEqual(hashBytes));
}
private byte[] GetKey()
{
return Convert.FromBase64String("QpSYI5k0bLQXEygUEHn4wMII3ERatuWDFBszk7JAhbQ=");
}
}
}