mirror of
https://github.com/bitwarden/android.git
synced 2024-12-27 03:18:27 +03:00
cleanup
This commit is contained in:
parent
9613019d4d
commit
392aa18497
2 changed files with 10 additions and 5 deletions
|
@ -35,15 +35,20 @@ namespace Bit.Droid.Services
|
||||||
generator.Init(password, salt, iterations);
|
generator.Init(password, salt, iterations);
|
||||||
return ((KeyParameter)generator.GenerateDerivedMacParameters(keySize)).GetKey();
|
return ((KeyParameter)generator.GenerateDerivedMacParameters(keySize)).GetKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Argon2id(byte[] password, byte[] salt, int iterations, int memory, int parallelism)
|
public byte[] Argon2id(byte[] password, byte[] salt, int iterations, int memory, int parallelism)
|
||||||
{
|
{
|
||||||
JavaSystem.LoadLibrary("argon2");
|
JavaSystem.LoadLibrary("argon2");
|
||||||
var hash = new byte[32];
|
// TODO: Do we need to pass this in somehow like PBKDF2, based on an algorithm?
|
||||||
argon2id_hash_raw(iterations, memory, parallelism, password, password.Length, password, salt.Length, hash, 32);
|
int keySize = 32;
|
||||||
return hash.ToArray();
|
var key = new byte[keySize];
|
||||||
|
argon2id_hash_raw(iterations, memory, parallelism,
|
||||||
|
password, password.Length, password, salt.Length, key, key.Length);
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("argon2", EntryPoint = "argon2id_hash_raw")]
|
[DllImport("argon2", EntryPoint = "argon2id_hash_raw")]
|
||||||
internal static extern int argon2id_hash_raw(int timeCost, int memoryCost, int parallelism, byte[] pwd, int pwdlen, byte[] salt, int saltlen, ref byte hash, int hashlen);
|
private static extern int argon2id_hash_raw(int timeCost, int memoryCost, int parallelism,
|
||||||
|
byte[] pwd, int pwdlen, byte[] salt, int saltlen, byte[] hash, int hashlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Bit.iOS.Core.Services
|
||||||
IntPtr salt, nuint saltLen, uint prf, nuint rounds, IntPtr derivedKey, nuint derivedKeyLength);
|
IntPtr salt, nuint saltLen, uint prf, nuint rounds, IntPtr derivedKey, nuint derivedKeyLength);
|
||||||
|
|
||||||
[DllImport("__Internal", EntryPoint = "argon2id_hash_raw")]
|
[DllImport("__Internal", EntryPoint = "argon2id_hash_raw")]
|
||||||
internal static extern int argon2id_hash_raw(int timeCost, int memoryCost, int parallelism, IntPtr pwd,
|
private static extern int argon2id_hash_raw(int timeCost, int memoryCost, int parallelism, IntPtr pwd,
|
||||||
nuint pwdlen, IntPtr salt, nuint saltlen, IntPtr hash, nuint hashlen);
|
nuint pwdlen, IntPtr salt, nuint saltlen, IntPtr hash, nuint hashlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue