Пример #1
0
        public byte[] Sign(byte[] data)
        {
            using (var rsa = OpenSslKey.DecodeRSAPrivateKey(_key))
            {
                byte[] signature = rsa.SignData(data, _algorithmInfo.SigningAlgorithm == SigningAlgorithm.RSASha1 ? "SHA1" : "SHA256");

                return(signature);
            }
        }
Пример #2
0
        private PrivateKeySigner([NotNull] string privateKey)
        {
            if (privateKey == null)
            {
                throw new ArgumentNullException("privateKey");
            }

            _key = OpenSslKey.DecodeOpenSSLPrivateKey(privateKey);
        }
Пример #3
0
        PrivateKeySigner(string privateKey, SigningAlgorithm signingAlgorithm)
        {
            if (privateKey == null)
            {
                throw new ArgumentNullException("privateKey");
            }

            _key = OpenSslKey.DecodeOpenSSLPrivateKey(privateKey);

            _algorithmInfo = new AlgorithmInfo(signingAlgorithm);
        }
Пример #4
0
        public byte[] Sign(byte[] data, SigningAlgorithm algorithm)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            using (var rsa = OpenSslKey.DecodeRSAPrivateKey(_key))
            {
                byte[] signature = rsa.SignData(data, GetHashName(algorithm));

                return(signature);
            }
        }