/// <summary> /// Creates a /// <see cref="PrivateKeySignature"/> /// instance. /// </summary> /// <param name="pk"> /// A /// <see cref="Org.BouncyCastle.Crypto.ICipherParameters"/> /// object. /// </param> /// <param name="hashAlgorithm">A hash algorithm (e.g. "SHA-1", "SHA-256",...).</param> /// <param name="provider">A security provider (e.g. "BC").</param> public PrivateKeySignature(ICipherParameters pk, String hashAlgorithm) { this.pk = pk; this.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms.GetAllowedDigest(hashAlgorithm)); encryptionAlgorithm = pk.GetAlgorithm(); if (encryptionAlgorithm.StartsWith("EC")) { encryptionAlgorithm = "ECDSA"; } }
private AsymmetricAlgorithmSignature(AsymmetricAlgorithm algorithm, String hashAlgorithm) { this.algorithm = algorithm; this.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms.GetAllowedDigest(hashAlgorithm)); if (algorithm is RSACryptoServiceProvider) { encryptionAlgorithm = "RSA"; } #if !NETSTANDARD1_6 else if (algorithm is DSACryptoServiceProvider) { encryptionAlgorithm = "DSA"; } #endif else { throw new ArgumentException("Not supported encryption algorithm " + algorithm); } }
/// <summary> /// Creates a /// <see cref="PrivateKeySignature"/> /// instance. /// </summary> /// <param name="pk"> /// A /// <see cref="Org.BouncyCastle.Crypto.ICipherParameters"/> /// object. /// </param> /// <param name="hashAlgorithm">A hash algorithm (e.g. "SHA-1", "SHA-256",...).</param> /// <param name="provider">A security provider (e.g. "BC").</param> public PrivateKeySignature(ICipherParameters pk, String hashAlgorithm) { this.pk = pk; this.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms.GetAllowedDigest(hashAlgorithm)); this.encryptionAlgorithm = SignUtils.GetPrivateKeyAlgorithm(pk); }