Bouncy Castle NTRU加密导出公钥

时间:2017-04-21 13:06:28

标签: java bouncycastle public-key-encryption

我得到了AsymmetricKeyParameter a = asymmetricCipherKeyPair.getPublic(); 我花了几个小时在这个上面,并且不知道如何将公钥变成一个字节序列。任何想法?

 NTRUEncryptionKeyPairGenerator ntruEncryptionKeyPairGenerator = new NTRUEncryptionKeyPairGenerator();
        long begin = System.currentTimeMillis();
        NTRUEncryptionKeyGenerationParameters ntruEncryptionKeyPairGeneratorParameters = NTRUEncryptionKeyGenerationParameters.EES1087EP2;


        ntruEncryptionKeyPairGenerator.init(ntruEncryptionKeyPairGeneratorParameters);


        AsymmetricCipherKeyPair asymmetricCipherKeyPair = ntruEncryptionKeyPairGenerator.generateKeyPair();

我试过

AsymmetricKeyParameter a = asymmetricCipherKeyPair.getPublic();
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(a);

但它会抛出“无法识别的关键参数。”

1 个答案:

答案 0 :(得分:0)

((NTRUEncryptionPublicKeyParameters)asymmetricCipherKeyPair.getPublic()).getEncoded();