use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class X509NameEntryConverter method convertHexEncoded.
/**
* Convert an inline encoded hex string rendition of an ASN.1
* object back into its corresponding ASN.1 object.
*
* @param str the hex encoded object
* @param off the index at which the encoding starts
* @return the decoded object
*/
protected DERObject convertHexEncoded(String str, int off) throws IOException {
str = Strings.toLowerCase(str);
byte[] data = new byte[(str.length() - off) / 2];
for (int index = 0; index != data.length; index++) {
char left = str.charAt((index * 2) + off);
char right = str.charAt((index * 2) + off + 1);
if (left < 'a') {
data[index] = (byte) ((left - '0') << 4);
} else {
data[index] = (byte) ((left - 'a' + 10) << 4);
}
if (right < 'a') {
data[index] |= (byte) (right - '0');
} else {
data[index] |= (byte) (right - 'a' + 10);
}
}
ASN1InputStream aIn = new ASN1InputStream(data);
return aIn.readObject();
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class DHValidationParms method toASN1Object.
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(this.seed);
v.add(this.pgenCounter);
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class X9ECParameters method toASN1Object.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* ECParameters ::= SEQUENCE {
* version INTEGER { ecpVer1(1) } (ecpVer1),
* fieldID FieldID {{FieldTypes}},
* curve X9Curve,
* base X9ECPoint,
* order INTEGER,
* cofactor INTEGER OPTIONAL
* }
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERInteger(1));
v.add(fieldID);
v.add(new X9Curve(curve, seed));
v.add(new X9ECPoint(g));
v.add(new DERInteger(n));
if (h != null) {
v.add(new DERInteger(h));
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class IssuerSerial method toASN1Object.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* IssuerSerial ::= SEQUENCE {
* issuer GeneralNames,
* serial CertificateSerialNumber,
* issuerUID UniqueIdentifier OPTIONAL
* }
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(issuer);
v.add(serial);
if (issuerUID != null) {
v.add(issuerUID);
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class X509Extensions method toASN1Object.
/**
* <pre>
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
*
* Extension ::= SEQUENCE {
* extnId EXTENSION.&id ({ExtensionSet}),
* critical BOOLEAN DEFAULT FALSE,
* extnValue OCTET STRING }
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector vec = new ASN1EncodableVector();
Enumeration e = ordering.elements();
while (e.hasMoreElements()) {
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
X509Extension ext = (X509Extension) extensions.get(oid);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(oid);
if (ext.isCritical()) {
// BEGIN android-changed
v.add(DERBoolean.TRUE);
// END android-changed
}
v.add(ext.getValue());
vec.add(new DERSequence(v));
}
return new DERSequence(vec);
}
Aggregations