Skip to content

Commit

Permalink
Introduced protections against predictable RNG abuse
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored Aug 10, 2024
1 parent 38a3f87 commit 5a38f95
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void encryptStringSymmetricRandom() throws Exception {
byte[] key = generateKey();

String encryptedString;
if (new Random().nextBoolean()) {
if (new SecureRandom().nextBoolean()) {
encryptedString = EncryptionUtils.encryptStringSymmetricAsString(privateKey, key);
} else {
encryptedString = EncryptionUtils.encryptStringSymmetricAsStringOld(privateKey, key);
Expand Down Expand Up @@ -262,7 +262,7 @@ public void encryptPrivateKey() throws Exception {
String privateKeyString = encodeBytesToBase64String(privateKeyBytes);

String encryptedString;
if (new Random().nextBoolean()) {
if (new SecureRandom().nextBoolean()) {
encryptedString = EncryptionUtils.encryptPrivateKey(privateKeyString, keyPhrase);
} else {
encryptedString = EncryptionUtils.encryptPrivateKeyOld(privateKeyString, keyPhrase);
Expand Down

0 comments on commit 5a38f95

Please sign in to comment.