use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class PrivateKeyInfo method toASN1Object.
/**
* write out an RSA private key with its associated information
* as described in PKCS8.
* <pre>
* PrivateKeyInfo ::= SEQUENCE {
* version Version,
* privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
* privateKey PrivateKey,
* attributes [0] IMPLICIT Attributes OPTIONAL
* }
* Version ::= INTEGER {v1(0)} (v1,...)
*
* PrivateKey ::= OCTET STRING
*
* Attributes ::= SET OF Attribute
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERInteger(0));
v.add(algId);
v.add(new DEROctetString(privKey));
if (attributes != null) {
v.add(new DERTaggedObject(false, 0, attributes));
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class RSAPrivateKeyStructure method toASN1Object.
/**
* This outputs the key in PKCS1v2 format.
* <pre>
* RSAPrivateKey ::= SEQUENCE {
* version Version,
* modulus INTEGER, -- n
* publicExponent INTEGER, -- e
* privateExponent INTEGER, -- d
* prime1 INTEGER, -- p
* prime2 INTEGER, -- q
* exponent1 INTEGER, -- d mod (p-1)
* exponent2 INTEGER, -- d mod (q-1)
* coefficient INTEGER, -- (inverse of q) mod p
* otherPrimeInfos OtherPrimeInfos OPTIONAL
* }
*
* Version ::= INTEGER { two-prime(0), multi(1) }
* (CONSTRAINED BY {-- version must be multi if otherPrimeInfos present --})
* </pre>
* <p>
* This routine is written to output PKCS1 version 2.1, private keys.
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
// version
v.add(new DERInteger(version));
v.add(new DERInteger(getModulus()));
v.add(new DERInteger(getPublicExponent()));
v.add(new DERInteger(getPrivateExponent()));
v.add(new DERInteger(getPrime1()));
v.add(new DERInteger(getPrime2()));
v.add(new DERInteger(getExponent1()));
v.add(new DERInteger(getExponent2()));
v.add(new DERInteger(getCoefficient()));
if (otherPrimeInfos != null) {
v.add(otherPrimeInfos);
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class SafeBag method toASN1Object.
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(bagId);
v.add(new DERTaggedObject(0, bagValue));
if (bagAttributes != null) {
v.add(bagAttributes);
}
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class ContentInfo method toASN1Object.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* ContentInfo ::= SEQUENCE {
* contentType ContentType,
* content
* [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
* </pre>
*/
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(contentType);
if (content != null) {
v.add(new BERTaggedObject(0, content));
}
return new BERSequence(v);
}
use of org.bouncycastle.asn1.DERObject in project XobotOS by xamarin.
the class CertificationRequestInfo method toASN1Object.
public DERObject toASN1Object() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(version);
v.add(subject);
v.add(subjectPKInfo);
if (attributes != null) {
v.add(new DERTaggedObject(false, 0, attributes));
}
return new DERSequence(v);
}
Aggregations