1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-08 03:23:23 +00:00

Removed BouncyCastle in favor of PCLCrypto. Created KeyDerivationService for Android using BouncyCastle. Applied key derivation service to CryptoService. Create iOS Test project.

This commit is contained in:
Kyle Spearrin
2016-08-01 20:23:46 -04:00
parent fc07844bb6
commit 6f800896c3
28 changed files with 3842 additions and 3060 deletions

View File

@@ -0,0 +1,20 @@
using System;
using Bit.App.Abstractions;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Parameters;
namespace Bit.Android.Services
{
public class BouncyCastleKeyDerivationService : IKeyDerivationService
{
private const int KeyLength = 256; // 32 bytes
public byte[] DeriveKey(byte[] password, byte[] salt, uint rounds)
{
var generator = new Pkcs5S2ParametersGenerator(new Sha256Digest());
generator.Init(password, salt, Convert.ToInt32(rounds));
return ((KeyParameter)generator.GenerateDerivedMacParameters(KeyLength)).GetKey();
}
}
}