2016-04-09 7 views
2

を暗号を作成することはできませんCMSEnvelopedData envData = gen.generate (new CMSProcessableByteArray (buffer), outputEncryptor);は、私は次のコードでアルゴリズム<code>AES128_CBC</code>を使用してファイルを暗号化するために<code>BountyCastle</code>を使用している、そのようなアルゴリズム

Exception in thread "main" org.bouncycastle.cms.CMSException: exception wrapping content key: cannot create cipher: No such algorithm: 1.2.840.10040.4.1 
    at org.bouncycastle.cms.KeyTransRecipientInfoGenerator.generate(Unknown Source) 
    at org.bouncycastle.cms.CMSEnvelopedDataGenerator.doGenerate(Unknown Source) 
    at org.bouncycastle.cms.CMSEnvelopedDataGenerator.generate(Unknown Source) 
    at com.crypto.tests.EncryptDocument.main(EncryptDocument.java:74) 

Caused by: org.bouncycastle.operator.OperatorCreationException: cannot create cipher: No such algorithm: 1.2.840.10040.4.1 
    at org.bouncycastle.operator.jcajce.OperatorHelper.createAsymmetricWrapper(Unknown Source) 
    at org.bouncycastle.operator.jcajce.JceAsymmetricKeyWrapper.generateWrappedKey(Unknown Source) 
... 4 more 

Caused by: java.security.NoSuchAlgorithmException: No such algorithm: 1.2.840.10040.4.1 
    at javax.crypto.Cipher.getInstance(Cipher.java:688) 
    at javax.crypto.Cipher.getInstance(Cipher.java:596) 
    at org.bouncycastle.jcajce.util.NamedJcaJceHelper.createCipher(Unknown Source) 
    ... 6 more 

答えて

3

DSAアルゴリズムまたはDSA鍵(1.2.840.10040.4.1はDSA)で暗号化することはできません。 DSAはDigital Signatureアルゴリズムの略です。代わりにRSAを試してみてください。

+0

ありがとうございます。だから基本的には、私が使っている証明書はDSAによって生成されているということですか? – Copernic

+1

@コペルニクそれは*大丈夫でしょう。 RSAはもっと良い考えです。 –

+0

ああ..意味がある!ありがとう@マートン! – Copernic

関連する問題