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

GetPadded() private static method

Pads a byte[] to the specified length, with zeroes at the start of the buffer.
private static GetPadded ( BigInteger n, int length ) : byte[]
n Org.BouncyCastle.Math.BigInteger
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>

Usage Example

Exemplo n.º 1
0
        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));
        }
All Usage Examples Of Org.BouncyCastle.Crypto.Agreement.Srp.Srp6Utilities::GetPadded