public byte[] Sign(byte[] data) { using (var rsa = OpenSslKey.DecodeRSAPrivateKey(_key)) { byte[] signature = rsa.SignData(data, _algorithmInfo.SigningAlgorithm == SigningAlgorithm.RSASha1 ? "SHA1" : "SHA256"); return(signature); } }
private PrivateKeySigner([NotNull] string privateKey) { if (privateKey == null) { throw new ArgumentNullException("privateKey"); } _key = OpenSslKey.DecodeOpenSSLPrivateKey(privateKey); }
PrivateKeySigner(string privateKey, SigningAlgorithm signingAlgorithm) { if (privateKey == null) { throw new ArgumentNullException("privateKey"); } _key = OpenSslKey.DecodeOpenSSLPrivateKey(privateKey); _algorithmInfo = new AlgorithmInfo(signingAlgorithm); }
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); } }