如何实现 CryptoSystem 、 PublicKey 接口

发布于 2024-11-02 20:24:11 字数 197 浏览 2 评论 0原文

我必须提供一种编码、解码 RSA 公钥的方法,该方法不是通过 Certicom 的 API 获得的,但 RIM 有一个 publicKeyEncoder 类来抽象整个过程。

然而,它需要一个实现 PublicKey 接口以及 CryptoSystem 接口的对象 - 但我在任何地方都没有找到任何示例。

有人知道该往哪个方向走吗?加密系统如何工作?

I have to provide a means for encoding, decoding an RSA public key which 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

GRAY°灰色天空 2024-11-09 20:24:11

它的工作原理如下:

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文