我需要从NTRU AsymmetricCipherKeyPair(org.bouncycastle.crypto.AsymmetricCipherKeyPair)生成一个KeyPair(java.security.KeyPair)。我使用许多不同的方法(在代码中稍后),这些方法以KeyPair(或PublicKey / PrivateKey)作为输入,并且不想为AsymmetricCipherKeyPair(或NTRUEncryptionPrivateKeyParameters / NTRUEncryptionPublicKeyParameters)创建其他方法。有没有办法从此AsymmetricCipherKeyPair构建KeyPair?
这里有一些代码作为示例:
NTRUEncryptionKeyPairGenerator keygen = new NTRUEncryptionKeyPairGenerator();
keygen.init(NTRUEncryptionKeyGenerationParameters.APR2011_439);
AsymmetricCipherKeyPair asymmetricCipherKeyPair = keygen.generateKeyPair();
//NTRUEncryptionPrivateKeyParameters ntruEncryptionPrivateKeyParameters = (NTRUEncryptionPrivateKeyParameters) asymmetricCipherKeyPair.getPrivate();
//NTRUEncryptionPublicKeyParameters ntruEncryptionPublicKeyParameters = (NTRUEncryptionPublicKeyParameters) asymmetricCipherKeyPair.getPublic();
KeyPair keyPair = ??? //what to do here?
PublicKey pubKey = ???
...
我发现了问题convert Bouncy Castle's AsymmetricCipherKeyPair (RSA) to java.security.KeyPair。但这对NTRU键可能没有用。
谢谢您的帮助:-)