나는 안드로이드 전화를 사용하여 펌웨어가 업데이트되는 제품을 만들고 있습니다. 안드로이드 응용 프로그램은 자동으로 펌웨어의 암호화 된 버전을 다운로드하고, 해독 한 다음 장치 부트 로더로 보냅니다. 동일한 비밀 키를 생성하기 위해 코드에서 암호와 salt를 지정합니다. 나는 apk가 디 컴파일 될 것이고 누군가가 우리의 펌웨어를 해독 할 수 있을지 걱정된다.APK에서 암호 해독 암호와 소금을 어떻게 보호합니까
파일을 해독/암호화하거나 코드를 보호하는 더 좋은 방법이 있습니까?
코드 :
private byte[] DecryptFile(byte[] encryptedFileBuffer) {
final int iterationCount = 10;
byte[] dataDecrypted = null;
SecretKey secKey = null;
try {
byte[] salt = "salt1234".getBytes();
String accessThingy = "Password";
KeySpec keySpec = new PBEKeySpec(accessThingy.toCharArray(), salt, iterationCount);
secKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
Cipher desCipher;
// Create the cipher
desCipher = Cipher.getInstance(secKey.getAlgorithm());
desCipher.init(Cipher.DECRYPT_MODE, secKey,paramSpec);
dataDecrypted = desCipher.doFinal(encrptedFileBuffer);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
return dataDecrypted;
}
이 답변에 누락 된 사항이 있습니까? 후속 조치를 잊지 마시고, 답변이 도움이 되었으면이를 수락하십시오. –