2012-01-10 11 views
2

JavaサーバーとAndroidクライアントの間で暗号化を実行しようとしています。いくつかの研究の後、ここでPBEWithMD5AndDESアルゴリズムを使用したJava暗号化

は、私の暗号化設定されている:

public static String encryptionAlgoirthm = "DES"; 
public static short encryptionBitCount = 128; 
public static String hashingAlgorithm = "PBEWithMD5AndDES"; 
public static short hashingCount = 512; 
public static String cipherTransformation = "DES/CBC/PKCS5Padding"; 

しかし、私のCentOSのVPS上でサーバを実行しようとしたとき、私は、次を得る:

Algorithm [PBEWithMD5AndDES] of type [SecretKeyFactory] from provider [gnu.javax.security.auth.callback.GnuCallbacks: name=GNU-CALLBACKS version=2.1] is not found.

ここにありますコード:

KeySpec keySpec = new PBEKeySpec(EncryptionSettings.password, EncryptionSettings.salt, EncryptionSettings.hashingCount, EncryptionSettings.encryptionBitCount); 
    SecretKey tmpKey = null; 

    try 
    { 
     tmpKey = SecretKeyFactory.getInstance(EncryptionSettings.hashingAlgorithm).generateSecret(keySpec); 
    } 
    catch (final InvalidKeySpecException e) 
    { 
     Console.writeFatalError("Unable to generate key: invalid key specification"); 
    } 
    catch (final NoSuchAlgorithmException e) 
    { 
     Console.writeFatalError("Unable to generate key: encryption algorithm not supported - " + e.getMessage()); 
    } 

これを修正するにはどうすればよいですか?

+0

コードを貼り付けた場合、 "encryptionAlgoirthm'のスペルが間違っています – rossum

答えて

1

あなたはGNU JREを使用していて、JCEを持っていないようです。これを解決するには、bouncy castle JCEをダウンロードしてプロバイダとして追加します。 DESは、56ビットの固定キーSICEを持っているよう

​​

も注意してください、あなたのencryptionBitCountは疑わしいということ。

DESとMD5は廃止されていると考えられますが、暗号化にはAESを、ハッシュにはSHAを試してみるとよいでしょう。バウンシーキャッスルAPIは、このトリックを行うかもしれないアルゴリズムPBEWITHSHAAND128BITAES-CBC-BCを提供します。

関連する問題