2017-03-09 5 views
0

私はちょうどデータセキュリティを明確にしたい、私はSecreteKeyFactoryオブジェクトを使用して秘密鍵を生成しています。これは、データの暗号化/復号化に使用されます。アルゴリズムを隠す必要がありますか?

はここ

private SecretKey getKey(String user_id, String salt) throws NoSuchAlgorithmException, 
     InvalidKeySpecException, UnsupportedEncodingException { 
    SecretKey secretKey = null; 

    String PBE_SHA256_256BitAES_CBC_BC     = "PBEWithSHA256And256BitAES-CBC-BC"; 
    String AES_ENCRYPTION        = "AES"; 

    SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(PBE_SHA256_256BitAES_CBC_BC); 
    KeySpec keySpec = new PBEKeySpec(user_id.toCharArray(), salt.getBytes(), Constants.ITERATION_COUNT, Constants.KEY_LENGTH); 

    secretKey = secretKeyFactory.generateSecret(keySpec); 
    secretKey = new SecretKeySpec(secretKey.getEncoded(), AES_ENCRYPTION); 

    return secretKey; 
} 

私の質問は以下のようになり、私のコードです。秘密鍵の取得に使用するアルゴリズムを隠す必要がありますか?そうでなければ、我々はセキュリティを高めることができるようにアルゴリズムをどこに格納すべきですか?

答えて

10

いいえ、アルゴリズムを非表示にする必要はありません。そうすることはsecurity through obscurityであり、セキュリティの誤った感覚を作り出します。うまく設計された暗号システムでは、鍵は秘密にする必要がある唯一のものです。

+0

ああ、あなたの答えに感謝します:)。 – shinta

+0

@shintaこの概念は[Kirchoffs 'Principle](https://en.wikipedia.org/wiki/Kerckhoffs's_principle)として知られています。 – TheGreatContini