我必须提供一种编码,解码RSA公钥的方法,这种公钥不是由Certicom的API获得的,但是RIM有一个publicKeyEncoder类来抽象整个过程。
然而,它期望一个对象实现PublicKey接口,以及CryptoSystem接口 - 但我没有在任何地方找到任何示例。
任何人都知道要走哪条路? CryptoSystem如何工作?
答案 0 :(得分:1)
它的工作原理如下:
* cryptoSystem = new RSACryptoSystem(1024);
byte[] expo = Base64InputStream.decode(exponent, 0, exponent.length());
byte[] modul = Base64InputStream.decode(modulus, 0, modulus.length());
byte[] pArr = Base64InputStream.decode(p, 0, p.length());
byte[] qArr = Base64InputStream.decode(q, 0, q.length());
byte[] dpArr = Base64InputStream.decode(dp, 0, dp.length());
byte[] dqArr = Base64InputStream.decode(dq, 0, dq.length());
byte[] inverseQArr = Base64InputStream.decode(inverseQ, 0, inverseQ.length());
byte[] dArr = Base64InputStream.decode(d, 0, d.length());
// Public Key Setup
RSAPublicKey publicKey = new RSAPublicKey( cryptoSystem, expo, modul);
RSAEncryptorEngine eEngine = new RSAEncryptorEngine( publicKey );
fEngine = new PKCS1FormatterEngine(eEngine);
// Private Key Setup
RSAPrivateKey privateKey = new RSAPrivateKey(cryptoSystem, expo, pArr, qArr, dpArr, dqArr, inverseQArr);
dEngine = new RSADecryptorEngine(privateKey);
ufEngine = new PKCS1UnformatterEngine(dEngine);