//public string GetJavaSignatureAlgorithm(DigestAlgorithm algorithm) public string GetSignatureAlgorithm(DigestAlgorithm algorithm) { //jbonilla: cambio de enum a clase. if (this.Equals(SignatureAlgorithm.RSA)) { if (algorithm.Equals(DigestAlgorithm.SHA1)) { return "SHA1withRSA"; } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return "SHA256withRSA"; } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return "SHA512withRSA"; } } } } else { if (this.Equals(SignatureAlgorithm.ECDSA)) { if (algorithm.Equals(DigestAlgorithm.SHA1)) { return "SHA1withECDSA"; } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return "SHA256withECDSA"; } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return "SHA512withECDSA"; } } } } } throw new NotSupportedException(); }
//public string GetJavaSignatureAlgorithm(DigestAlgorithm algorithm) public string GetSignatureAlgorithm(DigestAlgorithm algorithm) { //jbonilla: cambio de enum a clase. if (this.Equals(SignatureAlgorithm.RSA)) { if (algorithm.Equals(DigestAlgorithm.SHA1)) { return("SHA1withRSA"); } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return("SHA256withRSA"); } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return("SHA512withRSA"); } } } } else { if (this.Equals(SignatureAlgorithm.ECDSA)) { if (algorithm.Equals(DigestAlgorithm.SHA1)) { return("SHA1withECDSA"); } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return("SHA256withECDSA"); } else { if (algorithm.Equals(DigestAlgorithm.SHA256)) { return("SHA512withECDSA"); } } } } } throw new NotSupportedException(); }
public string GetXMLSignatureAlgorithm(DigestAlgorithm digestAlgo) { if (this.Equals(EU.Europa.EC.Markt.Dss.SignatureAlgorithm.RSA)) { if (digestAlgo.Equals(DigestAlgorithm.SHA1)) { return("http://www.w3.org/2000/09/xmldsig#rsa-sha1"); } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"); } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"); } } } } else { if (this.Equals(EU.Europa.EC.Markt.Dss.SignatureAlgorithm.ECDSA)) { if (digestAlgo.Equals(DigestAlgorithm.SHA1)) { return("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"); } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"); } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512"); } } } } } throw new NotSupportedException(); }
public virtual TimeStampResponse GetTimeStampResponse(DigestAlgorithm algorithm, byte[] digest) { this.digestAlgorithm = algorithm.GetName(); byte[] respBytes = null; TimeStampRequestGenerator tsqGenerator = new TimeStampRequestGenerator(); tsqGenerator.SetCertReq(true); // tsqGenerator.setReqPolicy("1.3.6.1.4.1.601.10.3.1"); BigInteger nonce = BigInteger.ValueOf(DateTime.Now.Ticks + Environment.TickCount); TimeStampRequest request = tsqGenerator.Generate(DigestAlgorithms.GetAllowedDigests(digestAlgorithm), digest, nonce); byte[] requestBytes = request.GetEncoded(); // Call the communications layer respBytes = GetTSAResponse(requestBytes); // Handle the TSA response return new TimeStampResponse(respBytes); }
public byte[] Sign(Stream stream, DigestAlgorithm digestAlgo, IDssPrivateKeyEntry keyEntry) { byte[] signedBytes; if (keyEntry is KSX509Certificate2Entry) { var cert = ((KSX509Certificate2Entry)keyEntry).Cert2; X509Certificate2Signature signer = new X509Certificate2Signature(cert, digestAlgo.GetName()); signedBytes = signer.Sign(Streams.ReadAll(stream)); stream.Close(); return signedBytes; } throw new ArgumentException("Only allowed KSX509Certificate2Entry", "keyEntry"); }
public string GetXMLSignatureAlgorithm(DigestAlgorithm digestAlgo) { if (this.Equals(EU.Europa.EC.Markt.Dss.SignatureAlgorithm.RSA)) { if (digestAlgo.Equals(DigestAlgorithm.SHA1)) { return "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"; } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"; } } } } else { if (this.Equals(EU.Europa.EC.Markt.Dss.SignatureAlgorithm.ECDSA)) { if (digestAlgo.Equals(DigestAlgorithm.SHA1)) { return "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"; } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"; } else { if (digestAlgo.Equals(DigestAlgorithm.SHA256)) { return "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512"; } } } } } throw new NotSupportedException(); }
public ExternalDigestSigner(DigestSigner signer, SignatureParameters parameters) { m_stream = new MemoryStream(); this.signer = signer; m_digestAlgorithm = parameters.DigestAlgorithm; }