com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA Java Examples
The following examples show how to use
com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DOMSignatureMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override byte[] preVerifyFormat(Key key, byte[] sig) throws IOException { // If signature needs to be in ASN.1 (i.e., if the fallback // algorithm will be used to verify the sig), convert the signature // to the ASN.1 format if (asn1) { return SignatureECDSA.convertXMLDSIGtoASN1(sig); } else { return sig; } }
Example #2
Source File: DOMSignatureMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override byte[] postSignFormat(Key key, byte[] sig) throws IOException { // If signature is in ASN.1 (i.e., if the fallback algorithm // was used), convert the signature to the P1363 format if (asn1) { return SignatureECDSA.convertASN1toXMLDSIG(sig); } else { return sig; } }
Example #3
Source File: DOMSignatureMethod.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return convertASN1toXMLDSIG(signature.sign()); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #4
Source File: SignatureAlgorithm.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #5
Source File: DOMSignatureMethod.java From hottub with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig, size/8)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #6
Source File: DOMSignatureMethod.java From hottub with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return JavaUtils.convertDsaASN1toXMLDSIG(signature.sign(), size/8); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #7
Source File: SignatureAlgorithm.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #8
Source File: DOMSignatureMethod.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return signature.verify(convertXMLDSIGtoASN1(sig)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #9
Source File: DOMSignatureMethod.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return convertASN1toXMLDSIG(signature.sign()); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #10
Source File: SignatureAlgorithm.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #11
Source File: DOMSignatureMethod.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return signature.verify(convertXMLDSIGtoASN1(sig)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #12
Source File: DOMSignatureMethod.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig, size/8)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #13
Source File: SignatureAlgorithm.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #14
Source File: DOMSignatureMethod.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig, size/8)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #15
Source File: DOMSignatureMethod.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return JavaUtils.convertDsaASN1toXMLDSIG(signature.sign(), size/8); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #16
Source File: SignatureAlgorithm.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #17
Source File: DOMSignatureMethod.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return signature.verify(convertXMLDSIGtoASN1(sig)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #18
Source File: DOMSignatureMethod.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return convertASN1toXMLDSIG(signature.sign()); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #19
Source File: SignatureAlgorithm.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #20
Source File: DOMSignatureMethod.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return signature.verify(convertXMLDSIGtoASN1(sig)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #21
Source File: DOMSignatureMethod.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return convertASN1toXMLDSIG(signature.sign()); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #22
Source File: SignatureAlgorithm.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #23
Source File: SignatureAlgorithm.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #24
Source File: DOMSignatureMethod.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig, size/8)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #25
Source File: DOMSignatureMethod.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return JavaUtils.convertDsaASN1toXMLDSIG(signature.sign(), size/8); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #26
Source File: SignatureAlgorithm.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #27
Source File: DOMSignatureMethod.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig, size/8)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #28
Source File: DOMSignatureMethod.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { throw new NullPointerException(); } if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } checkKeySize(context, key); if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initSign((PrivateKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "Signing with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { int size = ((DSAKey)key).getParams().getQ().bitLength(); return JavaUtils.convertDsaASN1toXMLDSIG(signature.sign(), size/8); } else if (type == Type.ECDSA) { return SignatureECDSA.convertASN1toXMLDSIG(signature.sign()); } else { return signature.sign(); } } catch (SignatureException se) { throw new XMLSignatureException(se); } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }
Example #29
Source File: SignatureAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #30
Source File: DOMSignatureMethod.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { if (key == null || si == null || sig == null) { throw new NullPointerException(); } if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } if (signature == null) { try { Provider p = (Provider)context.getProperty ("org.jcp.xml.dsig.internal.dom.SignatureProvider"); signature = (p == null) ? Signature.getInstance(getJCAAlgorithm()) : Signature.getInstance(getJCAAlgorithm(), p); } catch (NoSuchAlgorithmException nsae) { throw new XMLSignatureException(nsae); } } signature.initVerify((PublicKey)key); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Signature provider:" + signature.getProvider()); log.log(java.util.logging.Level.FINE, "verifying with key: " + key); } ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature)); try { Type type = getAlgorithmType(); if (type == Type.DSA) { return signature.verify(convertXMLDSIGtoASN1(sig)); } else if (type == Type.ECDSA) { return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig)); } else { return signature.verify(sig); } } catch (IOException ioe) { throw new XMLSignatureException(ioe); } }