use of org.bouncycastle.asn1.ASN1Primitive in project robovm by robovm.
the class SignedData method toASN1Primitive.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* SignedData ::= SEQUENCE {
* version CMSVersion,
* digestAlgorithms DigestAlgorithmIdentifiers,
* encapContentInfo EncapsulatedContentInfo,
* certificates [0] IMPLICIT CertificateSet OPTIONAL,
* crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
* signerInfos SignerInfos
* }
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(version);
v.add(digestAlgorithms);
v.add(contentInfo);
if (certificates != null) {
if (certsBer) {
v.add(new BERTaggedObject(false, 0, certificates));
} else {
v.add(new DERTaggedObject(false, 0, certificates));
}
}
if (crls != null) {
if (crlsBer) {
v.add(new BERTaggedObject(false, 1, crls));
} else {
v.add(new DERTaggedObject(false, 1, crls));
}
}
v.add(signerInfos);
return new BERSequence(v);
}
use of org.bouncycastle.asn1.ASN1Primitive in project robovm by robovm.
the class SignerInfo method toASN1Primitive.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* SignerInfo ::= SEQUENCE {
* version Version,
* SignerIdentifier sid,
* digestAlgorithm DigestAlgorithmIdentifier,
* authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,
* digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,
* encryptedDigest EncryptedDigest,
* unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
* }
*
* EncryptedDigest ::= OCTET STRING
*
* DigestAlgorithmIdentifier ::= AlgorithmIdentifier
*
* DigestEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(version);
v.add(sid);
v.add(digAlgorithm);
if (authenticatedAttributes != null) {
v.add(new DERTaggedObject(false, 0, authenticatedAttributes));
}
v.add(digEncryptionAlgorithm);
v.add(encryptedDigest);
if (unauthenticatedAttributes != null) {
v.add(new DERTaggedObject(false, 1, unauthenticatedAttributes));
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.ASN1Primitive in project robovm by robovm.
the class CRLBag method toASN1Primitive.
/**
* <pre>
CRLBag ::= SEQUENCE {
crlId BAG-TYPE.&id ({CRLTypes}),
crlValue [0] EXPLICIT BAG-TYPE.&Type ({CRLTypes}{@crlId})
}
x509CRL BAG-TYPE ::= {OCTET STRING IDENTIFIED BY {certTypes 1}
-- DER-encoded X.509 CRL stored in OCTET STRING
CRLTypes BAG-TYPE ::= {
x509CRL,
... -- For future extensions
}
</pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(crlId);
v.add(new DERTaggedObject(0, crlValue));
return new DERSequence(v);
}
use of org.bouncycastle.asn1.ASN1Primitive in project robovm by robovm.
the class X509Name method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
if (seq == null) {
ASN1EncodableVector vec = new ASN1EncodableVector();
ASN1EncodableVector sVec = new ASN1EncodableVector();
ASN1ObjectIdentifier lstOid = null;
for (int i = 0; i != ordering.size(); i++) {
ASN1EncodableVector v = new ASN1EncodableVector();
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) ordering.elementAt(i);
v.add(oid);
String str = (String) values.elementAt(i);
v.add(converter.getConvertedValue(oid, str));
if (lstOid == null || ((Boolean) this.added.elementAt(i)).booleanValue()) {
sVec.add(new DERSequence(v));
} else {
vec.add(new DERSet(sVec));
sVec = new ASN1EncodableVector();
sVec.add(new DERSequence(v));
}
lstOid = oid;
}
vec.add(new DERSet(sVec));
seq = new DERSequence(vec);
}
return seq;
}
use of org.bouncycastle.asn1.ASN1Primitive in project robovm by robovm.
the class X509Name method equals.
/**
* test for equality - note: case is ignored.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
return false;
}
ASN1Primitive derO = ((ASN1Encodable) obj).toASN1Primitive();
if (this.toASN1Primitive().equals(derO)) {
return true;
}
X509Name other;
try {
other = X509Name.getInstance(obj);
} catch (IllegalArgumentException e) {
return false;
}
int orderingSize = ordering.size();
if (orderingSize != other.ordering.size()) {
return false;
}
boolean[] indexes = new boolean[orderingSize];
int start, end, delta;
if (// guess forward
ordering.elementAt(0).equals(other.ordering.elementAt(0))) {
start = 0;
end = orderingSize;
delta = 1;
} else // guess reversed - most common problem
{
start = orderingSize - 1;
end = -1;
delta = -1;
}
for (int i = start; i != end; i += delta) {
boolean found = false;
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) ordering.elementAt(i);
String value = (String) values.elementAt(i);
for (int j = 0; j < orderingSize; j++) {
if (indexes[j]) {
continue;
}
ASN1ObjectIdentifier oOid = (ASN1ObjectIdentifier) other.ordering.elementAt(j);
if (oid.equals(oOid)) {
String oValue = (String) other.values.elementAt(j);
if (equivalentStrings(value, oValue)) {
indexes[j] = true;
found = true;
break;
}
}
}
if (!found) {
return false;
}
}
return true;
}
Aggregations