use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
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;
}
DERObject derO = ((DEREncodable) obj).getDERObject();
if (this.getDERObject().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;
DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
String value = (String) values.elementAt(i);
for (int j = 0; j < orderingSize; j++) {
if (indexes[j]) {
continue;
}
DERObjectIdentifier oOid = (DERObjectIdentifier) 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;
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class X509Name method equals.
/**
* @param inOrder if true the order of both X509 names must be the same,
* as well as the values associated with each element.
*/
public boolean equals(Object obj, boolean inOrder) {
if (!inOrder) {
return this.equals(obj);
}
if (obj == this) {
return true;
}
if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
return false;
}
DERObject derO = ((DEREncodable) obj).getDERObject();
if (this.getDERObject().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;
}
for (int i = 0; i < orderingSize; i++) {
DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
DERObjectIdentifier oOid = (DERObjectIdentifier) other.ordering.elementAt(i);
if (oid.equals(oOid)) {
String value = (String) values.elementAt(i);
String oValue = (String) other.values.elementAt(i);
if (!equivalentStrings(value, oValue)) {
return false;
}
} else {
return false;
}
}
return true;
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class DHDomainParameters method toASN1Object.
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(this.p);
v.add(this.g);
v.add(this.q);
if (this.j != null) {
v.add(this.j);
}
if (this.validationParms != null) {
v.add(this.validationParms);
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class X9Curve method toASN1Object.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* Curve ::= SEQUENCE {
* a FieldElement,
* b FieldElement,
* seed BIT STRING OPTIONAL
* }
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
if (fieldIdentifier.equals(prime_field)) {
v.add(new X9FieldElement(curve.getA()).getDERObject());
v.add(new X9FieldElement(curve.getB()).getDERObject());
} else if (fieldIdentifier.equals(characteristic_two_field)) {
v.add(new X9FieldElement(curve.getA()).getDERObject());
v.add(new X9FieldElement(curve.getB()).getDERObject());
}
if (seed != null) {
v.add(new DERBitString(seed));
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class X9FieldID method toASN1Object.
/**
* Produce a DER encoding of the following structure.
* <pre>
* FieldID ::= SEQUENCE {
* fieldType FIELD-ID.&id({IOSet}),
* parameters FIELD-ID.&Type({IOSet}{@fieldType})
* }
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(this.id);
v.add(this.parameters);
return new DERSequence(v);
}
Aggregations