use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class NetscapeCertRequest method getKeySpec.
private DERObject getKeySpec() throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DERObject obj = null;
try {
baos.write(pubkey.getEncoded());
baos.close();
ASN1InputStream derin = new ASN1InputStream(new ByteArrayInputStream(baos.toByteArray()));
obj = derin.readObject();
} catch (IOException ioe) {
throw new InvalidKeySpecException(ioe.getMessage());
}
return obj;
}
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);
}
Aggregations