mirror of
https://github.com/corda/corda.git
synced 2025-02-21 17:56:54 +00:00
secureRandomBytes should call getNextBytes, not generateSeed (#2587)
This commit is contained in:
parent
c3c3a859d5
commit
2e9027db1b
@ -168,7 +168,7 @@ fun KeyPair.verify(signatureData: ByteArray, clearData: ByteArray): Boolean = Cr
|
|||||||
* which should never happen and suggests an unusual JVM or non-standard Java library.
|
* which should never happen and suggests an unusual JVM or non-standard Java library.
|
||||||
*/
|
*/
|
||||||
@Throws(NoSuchAlgorithmException::class)
|
@Throws(NoSuchAlgorithmException::class)
|
||||||
fun secureRandomBytes(numOfBytes: Int): ByteArray = newSecureRandom().generateSeed(numOfBytes)
|
fun secureRandomBytes(numOfBytes: Int): ByteArray = ByteArray(numOfBytes).apply { newSecureRandom().nextBytes(this) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an instance of [SecureRandom] to avoid blocking, due to waiting for additional entropy, when possible.
|
* Get an instance of [SecureRandom] to avoid blocking, due to waiting for additional entropy, when possible.
|
||||||
|
@ -78,7 +78,7 @@ sealed class SecureHash(bytes: ByteArray) : OpaqueBytes(bytes) {
|
|||||||
* Generates a random SHA-256 value.
|
* Generates a random SHA-256 value.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun randomSHA256() = sha256(newSecureRandom().generateSeed(32))
|
fun randomSHA256() = sha256(secureRandomBytes(32))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SHA-256 hash value consisting of 32 0x00 bytes.
|
* A SHA-256 hash value consisting of 32 0x00 bytes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user