-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
The Logic Behind the Problem When RNG (Random Number Generator) values are not received through a hardware TRNG, seed values apply a certain pattern. (It takes a seed value such as a mathematical formula or time.) In response to this situation, there are various secure random classes to increase security. Solution Changes have been made to get random values using safe randomness instead of mathematical randomness. This increases the complexity of the pattern, making it difficult to discover even if data is listened to for long periods of time. The changes that have been made; - In the certificate_utils.go file, the random value was taken from the math class (mrand math/rand) and used. By taking this random value from the secure random class, we obtain a more reliable random value. I added HmacGenerate and generateSecureRandomKey functions for readability and ease of use. If you want to generate a key again, the generateSecureRandomKey function, which uses secure random, can be used. - In HashFunctions.kt, kotlin.random.Random class has been replaced with the more reliable java.security.SecureRandom class. - The reason for the change in eciesCrypto.js is that the length of aes-128-ctr is not considered reliable by various standards. For this reason, I preferred the more reliable 256 length. Fixes #2765 Signed-off-by: Kağan Can Şit <kagancansit@hotmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,7 +161,7 @@ function eciesEncryptMessage(recipientPublicKey, msg, options) { | |
const hKm = bitsToBytes(hmacKeyHash.finalize()); | ||
|
||
const iv = crypto.randomBytes(IVLength); | ||
const cipher = crypto.createCipheriv("aes-128-ctr", Buffer.from(aesKey), iv); | ||
const cipher = crypto.createCipheriv("aes-256-ctr", Buffer.from(aesKey), iv); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
petermetz
Contributor
|
||
const encryptedBytes = cipher.update(msg); | ||
const EM = Buffer.concat([iv, encryptedBytes]); | ||
const D = hmac(hKm, EM, options); | ||
|
@petermetz This change by itself is incorrect and causing the unit test to fail.
@KaganCanSit Just changing the algorithm without updating other parts of this code is causing the entire function to fail.
Can you please work on upgrading the entire code in this file to be consistent with the above change? There's a unit test you need to run to verify that the code works. Use
npm run test
for that.