Search in sources :

Example 6 with DERNull

use of org.gudy.bouncycastle.asn1.DERNull in project BiglyBT by BiglySoftware.

the class JCERSAPublicKey method getEncoded.

@Override
public byte[] getEncoded() {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);
    SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
    try {
        dOut.writeObject(info);
        dOut.close();
    } catch (IOException e) {
        throw new RuntimeException("Error encoding RSA public key");
    }
    return bOut.toByteArray();
}
Also used : RSAPublicKeyStructure(org.gudy.bouncycastle.asn1.x509.RSAPublicKeyStructure) DERNull(org.gudy.bouncycastle.asn1.DERNull) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) SubjectPublicKeyInfo(org.gudy.bouncycastle.asn1.x509.SubjectPublicKeyInfo) DEROutputStream(org.gudy.bouncycastle.asn1.DEROutputStream) AlgorithmIdentifier(org.gudy.bouncycastle.asn1.x509.AlgorithmIdentifier)

Aggregations

DERNull (org.bouncycastle.asn1.DERNull)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)3 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)2 ASN1Set (org.bouncycastle.asn1.ASN1Set)2 BERConstructedOctetString (org.bouncycastle.asn1.BERConstructedOctetString)2 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)2 DERSequence (org.bouncycastle.asn1.DERSequence)2 DERSet (org.bouncycastle.asn1.DERSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InvalidKeyException (java.security.InvalidKeyException)1 SignatureException (java.security.SignatureException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)1 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)1