开发者

How to implement the CryptoSystem , PublicKey Interface

I have to provide a means for encoding, decoding an RSA public key wh开发者_如何学Goich was not obtained by Certicom's API, but RIM has a publicKeyEncoder class that abstracts the entire process.

However it expects an object implementing the PublicKey Interface, and also the CryptoSystem Interface - but I have not found any examples anywhere.

Anybody have a clue about what direction to go? How does a CryptoSystem work?


It works like this:

     *  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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜