Granados.PKI.DSAKeyPair.Sign C# (CSharp) Method

Sign() public method

public Sign ( byte data ) : byte[]
data byte
return byte[]
        public byte[] Sign(byte[] data)
        {
            BigInteger r = _publickey._g.ModPow(_x, _publickey._p) % _publickey._q;
            BigInteger s = (_x.ModInverse(_publickey._q) * (new BigInteger(data) + _x * r)) % _publickey._q;

            byte[] result = new byte[data.Length * 2];
            byte[] br = r.GetBytes();
            byte[] bs = s.GetBytes();
            Array.Copy(br, 0, result, data.Length - br.Length, br.Length);
            Array.Copy(bs, 0, result, data.Length * 2 - bs.Length, bs.Length);

            return result;
        }