のような JCA(JCE) を使用しない環境Java ME
では、キー (または iv) バイトを生成しても問題ありjava.util.Random
ませんか?
// MIDP
// MIDP
// MIDP
private static final Random RANDOM = new Random();
/**
* Generates a new encryption key. This method is not intended to be used in
* production stage.
*
* @return a new encryption key.
*/
protected static byte[] newKey() {
final Random random;
synchronized (RANDOM) {
random = new Random(RANDOM.nextLong());
}
final byte[] key = new byte[256]; // AES 256
for (int i = 0; i < key.length; i++) {
key[i] = (byte) random.nextInt(256);
}
return key;
}
暗号に関する懸念はありますか?
ソースコードやコメントなど、この質問にタイプミスはありますか? (私はウリッシュ語が苦手です。)