title: How to Wrap RSA Private Key using AES on Lightweight API of Bouncy Castle
body: <p>I have a <code>RSA</code> generate key using the <code>RSAKeyPairGenerator class</code>. It returns a <code>AsymmetricCipherKeyPair</code> with the keys in <code>AsymmetricKeyParameter</code> objects. <code>AsymmetricKeyParameter</code> don't have anyone encode function for get the key in a byte array. </p>
  
  <p>The wrap function only receive <code>byte[]</code> parameter. How do I serialize the key using the Lightweight?</p>
  
  <pre><code>RSAKeyPairGenerator keyGenerator = new RSAKeyPairGenerator();
  keyGenerator.init(new RSAKeyGenerationParameters(new BigInteger("10001" ,16), new SecureRandom(), 2048, 80));
  AsymmetricCipherKeyPair keys = keyGenerator.generateKeyPair();
  AsymmetricKeyParameter priv = keys.getPrivate();
  </code></pre>