Convert from RSAPrivateCrtKeyParameters / RSAKeyParameters to PEM in J2ME
Asked Answered
D

1

17

I'm developing some cryptography on BlackBerry, and we're working with certificates. We use BouncyCastle Lightweight API instead of RIM api to apply the cryptography, but in the lightweight API PEMWriter doesn't work (Well, it isn't included because it needs some JCE).

public RSAPrivateCrtKeyParameters _RSAPrivateKey;
public RSAKeyParameters _RSAPublicKey;

I get this keys from the object

AsymmetricCipherKeyPair theKeyPair

So, i need a method to BASE64Encode the two keys, or how to transform this keys to other objects that can be directly transformed to base64/PEM format. I can generate the certificate manually, but i need the encoding of the keys.

I know there are methods to do this, but all require PEMWriter or APIs that are not enabled with j2ME and the bouncycastle lightweight API.

Diggins answered 7/2, 2013 at 11:31 Comment(1)
Did you look at the encoders and decoders provided with the org.bouncycalstle.util.encoders package (bouncycastle.org/docs/docs1.5on/org/bouncycastle/util/encoders/…)Baptiste
V
2

You could look into the PEMWriter/PEMReader code of bouncy castle and use their implementation as a reference:

PemWriter

PemReader

Virnelli answered 22/6, 2013 at 0:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.