List of usage examples for org.bouncycastle.asn1 DLSet DLSet
public DLSet(ASN1Encodable[] elements)
From source file:org.jmrtd.lds.CardAccessFile.java
License:Open Source License
protected void writeContent(OutputStream outputStream) throws IOException { ASN1EncodableVector vector = new ASN1EncodableVector(); for (SecurityInfo si : securityInfos) { vector.add(si.getDERObject());/* www. j a va 2s . c o m*/ } ASN1Set derSet = new DLSet(vector); outputStream.write(derSet.getEncoded(ASN1Encoding.DER)); }
From source file:org.jmrtd.lds.CardSecurityFile.java
License:Open Source License
private static ContentInfo toContentInfo(String contentTypeOID, Collection<SecurityInfo> securityInfos) { try {//from w w w. j a v a2s .co m ASN1EncodableVector vector = new ASN1EncodableVector(); for (SecurityInfo si : securityInfos) { vector.add(si.getDERObject()); } ASN1Set derSet = new DLSet(vector); return new ContentInfo(new ASN1ObjectIdentifier(contentTypeOID), new DEROctetString(derSet)); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "Error creating signedData: " + ioe.getMessage()); throw new IllegalArgumentException("Error DER encoding the security infos"); } }
From source file:org.jmrtd.lds.DG14File.java
License:Open Source License
protected void writeContent(OutputStream outputStream) throws IOException { ASN1EncodableVector vector = new ASN1EncodableVector(); for (SecurityInfo securityInfo : securityInfos) { ASN1Primitive derObject = securityInfo.getDERObject(); vector.add(derObject);/*from w w w . j a va 2 s .c o m*/ } ASN1Set derSet = new DLSet(vector); outputStream.write(derSet.getEncoded(ASN1Encoding.DER)); }
From source file:org.jmrtd.lds.SignedDataUtil.java
License:Open Source License
public static ASN1Set createAuthenticatedAttributes(String digestAlgorithm, String contentTypeOID, ContentInfo contentInfo) throws NoSuchAlgorithmException { /* Check bug found by Paulo Assumpco. */ if ("SHA256".equals(digestAlgorithm)) { digestAlgorithm = "SHA-256"; }/* w w w . j a va 2 s .co m*/ MessageDigest dig = MessageDigest.getInstance(digestAlgorithm); byte[] contentBytes = ((DEROctetString) contentInfo.getContent()).getOctets(); byte[] digestedContentBytes = dig.digest(contentBytes); ASN1OctetString digestedContent = new DEROctetString(digestedContentBytes); Attribute contentTypeAttribute = new Attribute( new ASN1ObjectIdentifier(SignedDataUtil.RFC_3369_CONTENT_TYPE_OID), createSingletonSet(new ASN1ObjectIdentifier(contentTypeOID))); Attribute messageDigestAttribute = new Attribute( new ASN1ObjectIdentifier(SignedDataUtil.RFC_3369_MESSAGE_DIGEST_OID), createSingletonSet(digestedContent)); ASN1Object[] result = { contentTypeAttribute.toASN1Primitive(), messageDigestAttribute.toASN1Primitive() }; return new DLSet(result); }
From source file:org.jmrtd.lds.SignedDataUtil.java
License:Open Source License
private static ASN1Set createSingletonSet(ASN1Object e) { return new DLSet(new ASN1Encodable[] { e }); }
From source file:org.jruby.ext.openssl.X509Name.java
License:LGPL
@JRubyMethod public IRubyObject to_der() { DLSequence seq = null;/* w ww.j a va2 s.c o m*/ if (oids.size() > 0) { ASN1EncodableVector vec = new ASN1EncodableVector(); ASN1EncodableVector sVec = new ASN1EncodableVector(); ASN1ObjectIdentifier lstOid = null; for (int i = 0; i != oids.size(); i++) { ASN1EncodableVector v = new ASN1EncodableVector(); ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) oids.get(i); v.add(oid); String str = (String) values.get(i); v.add(convert(oid, str, RubyNumeric.fix2int(((RubyFixnum) types.get(i))))); if (lstOid == null) { sVec.add(new DLSequence(v)); } else { vec.add(new DLSet(sVec)); sVec = new ASN1EncodableVector(); sVec.add(new DLSequence(v)); } lstOid = oid; } vec.add(new DLSet(sVec)); seq = new DLSequence(vec); } else { seq = new DLSequence(); } try { return RubyString.newString(getRuntime(), seq.getEncoded(ASN1Encoding.DER)); } catch (IOException ex) { throw newX509NameError(getRuntime(), ex.getMessage()); } }