use of org.gudy.bouncycastle.asn1.ASN1EncodableVector in project BiglyBT by BiglySoftware.
the class EncryptionScheme method getDERObject.
@Override
public DERObject getDERObject() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(objectId);
v.add(obj);
return new DERSequence(v);
}
use of org.gudy.bouncycastle.asn1.ASN1EncodableVector in project BiglyBT by BiglySoftware.
the class PKCS7SignedData method getEncoded.
/**
* return the bytes for the PKCS7SignedData object.
*/
public byte[] getEncoded() {
try {
digest = sig.sign();
// Create the set of Hash algorithms. I've assumed this is the
// set of all hash agorithms used to created the digest in the
// "signerInfo" structure. I may be wrong.
//
ASN1EncodableVector v = new ASN1EncodableVector();
for (Iterator i = digestalgos.iterator(); i.hasNext(); ) {
AlgorithmIdentifier a = new AlgorithmIdentifier(new DERObjectIdentifier((String) i.next()), null);
v.add(a);
}
DERSet algos = new DERSet(v);
// Create the contentInfo. Empty, I didn't implement this bit
//
DERSequence contentinfo = new DERSequence(new DERObjectIdentifier(ID_PKCS7_DATA));
// Get all the certificates
//
v = new ASN1EncodableVector();
for (Iterator i = certs.iterator(); i.hasNext(); ) {
DERInputStream tempstream = new DERInputStream(new ByteArrayInputStream(((X509Certificate) i.next()).getEncoded()));
v.add(tempstream.readObject());
}
DERSet dercertificates = new DERSet(v);
// Create signerinfo structure.
//
ASN1EncodableVector signerinfo = new ASN1EncodableVector();
// Add the signerInfo version
//
signerinfo.add(new DERInteger(signerversion));
IssuerAndSerialNumber isAnds = new IssuerAndSerialNumber(new X509Name((ASN1Sequence) getIssuer(signCert.getTBSCertificate())), new DERInteger(signCert.getSerialNumber()));
signerinfo.add(isAnds);
// Add the digestAlgorithm
//
signerinfo.add(new AlgorithmIdentifier(new DERObjectIdentifier(digestAlgorithm), new DERNull()));
//
// Add the digestEncryptionAlgorithm
//
signerinfo.add(new AlgorithmIdentifier(new DERObjectIdentifier(digestEncryptionAlgorithm), new DERNull()));
//
// Add the digest
//
signerinfo.add(new DEROctetString(digest));
//
// Finally build the body out of all the components above
//
ASN1EncodableVector body = new ASN1EncodableVector();
body.add(new DERInteger(version));
body.add(algos);
body.add(contentinfo);
body.add(new DERTaggedObject(false, 0, dercertificates));
if (crls.size() > 0) {
v = new ASN1EncodableVector();
for (Iterator i = crls.iterator(); i.hasNext(); ) {
DERInputStream t = new DERInputStream(new ByteArrayInputStream((((X509CRL) i.next()).getEncoded())));
v.add(t.readObject());
}
DERSet dercrls = new DERSet(v);
body.add(new DERTaggedObject(false, 1, dercrls));
}
// Only allow one signerInfo
//
body.add(new DERSet(new DERSequence(signerinfo)));
// Now we have the body, wrap it in it's PKCS7Signed shell
// and return it
//
ASN1EncodableVector whole = new ASN1EncodableVector();
whole.add(new DERObjectIdentifier(ID_PKCS7_SIGNED_DATA));
whole.add(new DERTaggedObject(0, new DERSequence(body)));
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dout = new DEROutputStream(bOut);
dout.writeObject(new DERSequence(whole));
dout.close();
return bOut.toByteArray();
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
}
use of org.gudy.bouncycastle.asn1.ASN1EncodableVector in project keystore-explorer by kaikramer.
the class PolicyMapping method toASN1Primitive.
@Override
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector dv = new ASN1EncodableVector();
dv.add(issuerDomainPolicy);
dv.add(subjectDomainPolicy);
return new DERSequence(dv);
}
use of org.gudy.bouncycastle.asn1.ASN1EncodableVector in project keystore-explorer by kaikramer.
the class SubjectInfoAccess method toASN1Primitive.
@Override
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector vec = new ASN1EncodableVector();
Iterator<AccessDescription> it = accessDescriptions.iterator();
while (it.hasNext()) {
vec.add(it.next().toASN1Primitive());
}
return new DERSequence(vec);
}
use of org.gudy.bouncycastle.asn1.ASN1EncodableVector in project keystore-explorer by kaikramer.
the class DPolicyInformationChooser method okPressed.
private void okPressed() {
ASN1ObjectIdentifier policyIdentifer = joiPolicyIdentifier.getObjectId();
if (policyIdentifer == null) {
JOptionPane.showMessageDialog(this, res.getString("DPolicyInformationChooser.PolicyIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
List<PolicyQualifierInfo> policyQualifierInfo = jpqPolicyQualifiers.getPolicyQualifierInfo();
if (policyQualifierInfo.size() > 0) {
ASN1EncodableVector policyQualifiersVec = new ASN1EncodableVector();
for (PolicyQualifierInfo policyQualInfo : policyQualifierInfo) {
try {
policyQualifiersVec.add(policyQualInfo);
} catch (Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
}
DERSequence policyQualifiersSeq = new DERSequence(policyQualifiersVec);
policyInformation = new PolicyInformation(policyIdentifer, policyQualifiersSeq);
} else {
policyInformation = new PolicyInformation(policyIdentifer);
}
closeDialog();
}
Aggregations