List of usage examples for org.bouncycastle.asn1 DLSequence DLSequence
public DLSequence(ASN1Encodable[] elements)
From source file:eu.emi.security.authn.x509.helpers.proxy.ProxyCertInfoExtension.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); if (pathLen != Integer.MAX_VALUE) v.add(new ASN1Integer(pathLen)); if (policy != null) { v.add(policy.toASN1Primitive()); } else {/*from w w w. j a v a2 s . c o m*/ throw new IllegalArgumentException( "Can't generate " + "ProxyCertInfoExtension without mandatory policy"); } return new DLSequence(v); }
From source file:org.certificateservices.custom.c2x.its.crypto.DefaultCryptoManager.java
License:Open Source License
/** * @see org.certificateservices.custom.c2x.its.crypto.CryptoManager#verifySignature(byte[], Signature, PublicKey) *///w w w .j a va 2 s .c o m @Override public boolean verifySignature(byte[] message, Signature signature, PublicKey publicKey) throws IllegalArgumentException, SignatureException, IOException { PublicKeyAlgorithm alg = signature.getPublicKeyAlgorithm(); if (alg == PublicKeyAlgorithm.ecdsa_nistp256_with_sha256) { try { EcdsaSignature ecdsaSignature = signature.getSignatureValue(); // Create Signature Data ASN1Integer asn1R = new ASN1Integer(ecdsaSignature.getR().getX()); ASN1Integer asn1S = new ASN1Integer(SerializationHelper.readFixedFieldSizeKey(alg, new ByteArrayInputStream(ecdsaSignature.getSignatureValue()))); DLSequence dLSequence = new DLSequence(new ASN1Encodable[] { asn1R, asn1S }); byte[] dERSignature = dLSequence.getEncoded(); byte[] messageDigest = digest(message, alg); java.security.Signature sig = java.security.Signature.getInstance("NONEwithECDSA", provider); sig.initVerify(publicKey); sig.update(messageDigest); return sig.verify(dERSignature); } catch (Exception e) { if (e instanceof IllegalArgumentException) { throw (IllegalArgumentException) e; } if (e instanceof IOException) { throw (IOException) e; } if (e instanceof SignatureException) { throw (SignatureException) e; } throw new SignatureException("Internal error verifying signature " + e.getClass().getSimpleName() + ": " + e.getMessage(), e); } } else { throw new IllegalArgumentException( "Unsupported signature algoritm: " + signature.getPublicKeyAlgorithm()); } }
From source file:org.cryptoworkshop.ximix.common.asn1.message.KeyGenerationMessage.java
License:Apache License
private static ASN1Sequence toASN1Sequence(List<String> set) { ASN1EncodableVector v = new ASN1EncodableVector(); for (String name : set) { v.add(new DERUTF8String(name)); }// w ww . j av a 2 s . c o m return new DLSequence(v); }
From source file:org.cryptoworkshop.ximix.common.asn1.message.TranscriptBlock.java
License:Apache License
private TranscriptBlock(int stepNo, ASN1EncodableVector details) { this.stepNo = stepNo; this.details = new DLSequence(details); }
From source file:org.jmrtd.lds.ActiveAuthenticationInfo.java
License:Open Source License
@Deprecated public ASN1Primitive getDERObject() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1ObjectIdentifier(oid)); v.add(new ASN1Integer(version)); if (signatureAlgorithmOID != null) { v.add(new ASN1ObjectIdentifier(signatureAlgorithmOID)); }/*from w w w . jav a 2 s . co m*/ return new DLSequence(v); }
From source file:org.jmrtd.lds.ChipAuthenticationInfo.java
License:Open Source License
@Deprecated public ASN1Primitive getDERObject() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1ObjectIdentifier(oid)); v.add(new ASN1Integer(version)); if (keyId.compareTo(BigInteger.ZERO) >= 0) { v.add(new ASN1Integer(keyId)); }/* w ww. j av a2 s . c om*/ return new DLSequence(v); }
From source file:org.jmrtd.lds.ChipAuthenticationPublicKeyInfo.java
License:Open Source License
@Deprecated public ASN1Primitive getDERObject() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1ObjectIdentifier(oid)); vector.add((ASN1Sequence) subjectPublicKeyInfo.toASN1Primitive()); if (keyId.compareTo(BigInteger.ZERO) >= 0) { vector.add(new ASN1Integer(keyId)); }//from w w w . j ava 2 s. com return new DLSequence(vector); }
From source file:org.jmrtd.lds.PACEDomainParameterInfo.java
License:Open Source License
@Deprecated @Override//w w w . jav a 2 s. co m public ASN1Primitive getDERObject() { ASN1EncodableVector vector = new ASN1EncodableVector(); /* Protocol */ vector.add(new ASN1ObjectIdentifier(protocolOID)); /* Required data */ vector.add(domainParameter); /* Optional data */ if (parameterId >= 0) { vector.add(new ASN1Integer(parameterId)); } return new DLSequence(vector); }
From source file:org.jmrtd.lds.PACEInfo.java
License:Open Source License
@Deprecated @Override// ww w. j a v a 2s .c o m public ASN1Primitive getDERObject() { ASN1EncodableVector vector = new ASN1EncodableVector(); /* Protocol */ vector.add(new ASN1ObjectIdentifier(protocolOID)); /* Required data */ vector.add(new ASN1Integer(version)); /* Optional data */ if (parameterId >= 0) { vector.add(new ASN1Integer(parameterId)); } return new DLSequence(vector); }
From source file:org.jmrtd.lds.SignedDataUtil.java
License:Open Source License
public static void writeData(SignedData signedData, OutputStream outputStream) throws IOException { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1ObjectIdentifier(SignedDataUtil.RFC_3369_SIGNED_DATA_OID)); v.add(new DERTaggedObject(0, signedData)); ASN1Sequence fileContentsObject = new DLSequence(v); byte[] fileContentsBytes = fileContentsObject.getEncoded(ASN1Encoding.DER); outputStream.write(fileContentsBytes); }