public static GetDigest ( String oid ) : String | ||
oid | String | |
return | String |
/** * Creates an ExternalSignature instance * @param pk a PrivateKey object * @param hashAlgorithm the hash algorithm (e.g. "SHA-1", "SHA-256",...) * @param provider the security provider (e.g. "BC") */ public PrivateKeySignature(ICipherParameters pk, String hashAlgorithm) { this.pk = pk; this.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms.GetAllowedDigests(hashAlgorithm)); if (pk is RsaKeyParameters) { encryptionAlgorithm = "RSA"; } else if (pk is DsaKeyParameters) { encryptionAlgorithm = "DSA"; } else { throw new ArgumentException(MessageLocalization.GetComposedMessage("unknown.key.algorithm.1", pk.ToString())); } }
private AsymmetricAlgorithmSignature(AsymmetricAlgorithm algorithm, String hashAlgorithm) { this.algorithm = algorithm; this.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms.GetAllowedDigests(hashAlgorithm)); if (algorithm is RSACryptoServiceProvider) { encryptionAlgorithm = "RSA"; } else if (algorithm is DSACryptoServiceProvider) { encryptionAlgorithm = "DSA"; } else { throw new ArgumentException("Not supported encryption algorithm " + algorithm); } }
/// <summary> /// Creates a signature using a X509Certificate2. It supports smartcards without /// exportable private keys. /// </summary> /// <param name="certificate">The certificate with the private key</param> /// <param name="hashAlgorithm">The hash algorithm for the signature. As the Windows CAPI is used /// to do the signature the only hash guaranteed to exist is SHA-1</param> public X509Certificate2Signature(X509Certificate2 certificate, String hashAlgorithm) { if (!certificate.HasPrivateKey) { throw new ArgumentException("No private key."); } this.certificate = certificate; this.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms.GetAllowedDigests(hashAlgorithm)); if (certificate.PrivateKey is RSACryptoServiceProvider) { encryptionAlgorithm = "RSA"; } else if (certificate.PrivateKey is DSACryptoServiceProvider) { encryptionAlgorithm = "DSA"; } else { throw new ArgumentException("Unknown encryption algorithm " + certificate.PrivateKey); } }
/** * Returns the name of the digest algorithm, e.g. "SHA256". * @return the digest algorithm name, e.g. "SHA256" */ public String GetHashAlgorithm() { return(DigestAlgorithms.GetDigest(digestAlgorithmOid)); }