简体   繁体   English

Android上是AES128还是AES256?

[英]Is AES128 or AES256 on Android?

Greetings, 问候,

On Android, we can't specify AES128 or AES256. 在Android上,我们无法指定AES128或AES256。 But is AES128, or AES256 actually run when using "AES/CBC/PKCS5Padding"? 但是,使用“ AES / CBC / PKCS5Padding”时,AES128或AES256是否实际运行?

I tried something like below 我尝试了如下

SecretKeyFactory sf = SecretKeyFactory.getInstance("PBEWITHSHAAND256BITAES-CBC-BC");
KeySpec ks = new PBEKeySpec(masterPassword.toCharArray(),k1,1320,256);
secKey = sf.generateSecret(ks);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, secKey, generateIV(cipher));

The SecretKeyFactory created has a keySize of 256, and the keyLength specified in PBEKeySpec seems doesn't matter. 创建的SecretKeyFactory的keySize为256,在PBEKeySpec中指定的keyLength似乎无关紧要。 No matter 256 or 128, or any other positive number, the secKey generated always has 256 keySize. 无论是256还是128,或任何其他正数,生成的secKey始终具有256 keySize。 Since we passed the secKey to initialize the cipher, so now, does the encryption will be run using AES128, or AES256? 由于我们传递了secKey来初始化密码,因此,现在是否将使用AES128或AES256运行加密?

Thanks! 谢谢!

This article should allow you to determine the strengths and ciphers you have available in the runtime image. 本文应该使您能够确定运行时映像中可用的强度和密码。 I don't know if it will kick you out at this point but by specifying PBEKeySpec with a length of 256 I think you might have it. 我不知道这是否会把你踢出去,但是通过指定长度为256的PBEKeySpec,我想你可能会知道。

On Android, we can't specify AES128 or AES256. 在Android上,我们无法指定AES128或AES256。 But is AES128, or AES256 actually run when using "AES/CBC/PKCS5Padding"? 但是,使用“ AES / CBC / PKCS5Padding”时,AES128或AES256是否实际运行?

Am I wrong suggesting that none is actually determined at getInstance()? 我是否错误地建议在getInstance()上实际上未确定任何错误? I suppose the length of the cipher's key will be determined only after call to init() where you set a key which is of certain length. 我想只有在调用init()之后才能确定密码密钥的长度,在init()中您设置了一定长度的密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM