List of usage examples for org.bouncycastle.asn1.x509 RSAPublicKeyStructure toASN1Object
public ASN1Primitive toASN1Object()
From source file:cf.monteux.silvertunnel.netlib.layer.tor.util.Encryption.java
License:Open Source License
/** * converts a RSAPublicKey into PKCS1-encoding (ASN.1). * * @param pubKeyStruct/* ww w. j ava 2 s . co m*/ * @return PKCS1-encoded RSA PUBLIC KEY * @see JCERSAPublicKey */ public static byte[] getPKCS1EncodingFromRSAPublicKey(final RSAPublicKey pubKeyStruct) { try { final RSAPublicKeyStructure myKey = new RSAPublicKeyStructure(pubKeyStruct.getModulus(), pubKeyStruct.getPublicExponent()); final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(myKey.toASN1Object()); aOut.close(); return bOut.toByteArray(); } catch (final Exception e) { return null; } }
From source file:org.silvertunnel.netlib.layer.tor.util.Encryption.java
License:Open Source License
/** * converts a RSAPublicKey into PKCS1-encoding (ASN.1) * /* ww w.java2 s . co m*/ * @param rsaPublicKey * @see JCERSAPublicKey * @return PKCS1-encoded RSA PUBLIC KEY */ public static byte[] getPKCS1EncodingFromRSAPublicKey(RSAPublicKey pubKeyStruct) { try { RSAPublicKeyStructure myKey = new RSAPublicKeyStructure(pubKeyStruct.getModulus(), pubKeyStruct.getPublicExponent()); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(myKey.toASN1Object()); return bOut.toByteArray(); } catch (Exception e) { return null; } }
From source file:TorJava.Common.Encryption.java
License:Open Source License
/** * converts a JCERSAPublicKey into PKCS1-encoding * //from w ww . ja v a 2 s.c o m * @param rsaPublicKey * @see JCERSAPublicKey * @return PKCS1-encoded RSA PUBLIC KEY */ public static byte[] getPKCS1EncodingFromRSAPublicKey(RSAPublicKeyStructure pubKeyStruct) { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(pubKeyStruct.toASN1Object()); return bOut.toByteArray(); } catch (Exception e) { return null; } }