Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        private PrivateKeySigner([NotNull] string privateKey)
        {
            if (privateKey == null)
            {
                throw new ArgumentNullException("privateKey");
            }

            _key = OpenSslKey.DecodeOpenSSLPrivateKey(privateKey);
        }
Exemplo n.º 3
0
        PrivateKeySigner(string privateKey, SigningAlgorithm signingAlgorithm)
        {
            if (privateKey == null)
            {
                throw new ArgumentNullException("privateKey");
            }

            _key = OpenSslKey.DecodeOpenSSLPrivateKey(privateKey);

            _algorithmInfo = new AlgorithmInfo(signingAlgorithm);
        }
Exemplo n.º 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);
            }
        }