Beispiel #1
0
        public byte[] SignWithSHA1(byte[] data)
        {
            byte[] hash = new SHA1CryptoServiceProvider().ComputeHash(data);

            byte[] buf = new byte[hash.Length + PKIUtil.SHA1_ASN_ID.Length];
            Array.Copy(PKIUtil.SHA1_ASN_ID, 0, buf, 0, PKIUtil.SHA1_ASN_ID.Length);
            Array.Copy(hash, 0, buf, PKIUtil.SHA1_ASN_ID.Length, hash.Length);

            BigInteger x = new BigInteger(buf);
            //Debug.WriteLine(x.ToHexString());
            int padLen = (_publickey._n.bitCount() + 7) / 8;

            x = RSAUtil.PKCS1PadType1(x, padLen);
            byte[] result = Sign(x.getBytes());
            return(result);
        }