Org.BouncyCastle.Crypto.Agreement.Srp.Srp6Utilities.HashPaddedPair C# (CSharp) Method

HashPaddedPair() private static method

Pads n1 and n2 to the same number of bytes as N. Then hashes them.
private static HashPaddedPair ( IDigest digest, BigInteger N, BigInteger n1, BigInteger n2 ) : BigInteger
digest IDigest
N Org.BouncyCastle.Math.BigInteger
n1 Org.BouncyCastle.Math.BigInteger
n2 Org.BouncyCastle.Math.BigInteger
return Org.BouncyCastle.Math.BigInteger
        private static BigInteger HashPaddedPair(IDigest digest, BigInteger N, BigInteger n1, BigInteger n2)
        {
            int padLength = (N.BitLength + 7) / 8;

            byte[] n1_bytes = GetPadded(n1, padLength);
            byte[] n2_bytes = GetPadded(n2, padLength);

            digest.BlockUpdate(n1_bytes, 0, n1_bytes.Length);
            digest.BlockUpdate(n2_bytes, 0, n2_bytes.Length);

            byte[] output = new byte[digest.GetDigestSize()];
            digest.DoFinal(output, 0);

            return new BigInteger(1, output).Mod(N);
        }

Usage Example

Exemplo n.º 1
0
 public static BigInteger CalculateK(IDigest digest, BigInteger N, BigInteger g)
 {
     return(Srp6Utilities.HashPaddedPair(digest, N, N, g));
 }
All Usage Examples Of Org.BouncyCastle.Crypto.Agreement.Srp.Srp6Utilities::HashPaddedPair