mirror of
https://github.com/corda/corda.git
synced 2024-12-19 13:08:04 +00:00
Remove duplicated SecureRandom functions in crypto package.
This commit is contained in:
parent
eaf9dad7c9
commit
c5966a93e5
@ -14,14 +14,6 @@ import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec
|
||||
import java.math.BigInteger
|
||||
import java.security.*
|
||||
|
||||
fun newSecureRandom(): SecureRandom {
|
||||
if (System.getProperty("os.name") == "Linux") {
|
||||
return SecureRandom.getInstance("NativePRNGNonBlocking")
|
||||
} else {
|
||||
return SecureRandom.getInstanceStrong()
|
||||
}
|
||||
}
|
||||
|
||||
/** A wrapper around a digital signature. */
|
||||
@CordaSerializable
|
||||
open class DigitalSignature(bits: ByteArray) : OpaqueBytes(bits) {
|
||||
|
@ -86,7 +86,7 @@ fun KeyPair.verify(signatureData: ByteArray, clearData: ByteArray): Boolean = Cr
|
||||
*/
|
||||
@Throws(NoSuchAlgorithmException::class)
|
||||
fun safeRandomBytes(numOfBytes: Int): ByteArray {
|
||||
return safeRandom().generateSeed(numOfBytes)
|
||||
return newSecureRandom().generateSeed(numOfBytes)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ fun safeRandomBytes(numOfBytes: Int): ByteArray {
|
||||
* which should never happen and suggests an unusual JVM or non-standard Java library.
|
||||
*/
|
||||
@Throws(NoSuchAlgorithmException::class)
|
||||
fun safeRandom(): SecureRandom {
|
||||
fun newSecureRandom(): SecureRandom {
|
||||
if (System.getProperty("os.name") == "Linux") {
|
||||
return SecureRandom.getInstance("NativePRNGNonBlocking")
|
||||
} else {
|
||||
|
@ -35,8 +35,8 @@ data class SignatureScheme(
|
||||
*/
|
||||
init {
|
||||
if (algSpec != null)
|
||||
keyPairGenerator.initialize(algSpec, safeRandom())
|
||||
keyPairGenerator.initialize(algSpec, newSecureRandom())
|
||||
else
|
||||
keyPairGenerator.initialize(keySize, safeRandom())
|
||||
keyPairGenerator.initialize(keySize, newSecureRandom())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user