Java Code Examples for com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA#convertASN1toXMLDSIG()
The following examples show how to use
com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA#convertASN1toXMLDSIG() .
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[] 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 2
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 3
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 4
Source File: DOMSignatureMethod.java From jdk8u60 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 5
Source File: DOMSignatureMethod.java From openjdk-jdk8u 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 6
Source File: DOMSignatureMethod.java From openjdk-jdk8u-backup 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 7
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 8
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 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: 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 11
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 12
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 13
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); } }