private static GetPadded ( |
||
n | ||
length | int | |
return | byte[] |
private static byte[] GetPadded(BigInteger n, int length)
{
byte[] bs = BigIntegers.AsUnsignedByteArray(n);
if (bs.Length < length)
{
byte[] tmp = new byte[length];
Array.Copy(bs, 0, tmp, length - bs.Length, bs.Length);
bs = tmp;
}
return bs;
}
/// <summary>
public static BigInteger CalculateKey(IDigest digest, BigInteger N, BigInteger S) { int length = (N.BitLength + 7) / 8; byte[] padded = Srp6Utilities.GetPadded(S, length); digest.BlockUpdate(padded, 0, padded.Length); byte[] array = new byte[digest.GetDigestSize()]; digest.DoFinal(array, 0); return(new BigInteger(1, array)); }