mirror of
https://github.com/corda/corda.git
synced 2025-01-31 08:25:50 +00:00
Revert "Merged in use-urandom-2 (pull request #159)"
This reverts commit 1a1ed3b9e6684131863e53b75b2c18ea785ca3ab, reversing changes made to 09e2e49d44cf9197dd00464656bee0f33d2201cd.
This commit is contained in:
parent
1a1ed3b9e6
commit
0c325c31a2
@ -3,7 +3,6 @@ package com.r3corda.contracts.cash
|
||||
import com.r3corda.core.contracts.*
|
||||
import com.r3corda.core.crypto.Party
|
||||
import com.r3corda.core.crypto.SecureHash
|
||||
import com.r3corda.core.crypto.newSecureRandom
|
||||
import com.r3corda.core.crypto.toStringShort
|
||||
import com.r3corda.core.utilities.Emoji
|
||||
import java.security.PublicKey
|
||||
@ -75,7 +74,7 @@ class Cash : FungibleAsset<Currency>() {
|
||||
* Allows new cash states to be issued into existence: the nonce ("number used once") ensures the transaction
|
||||
* has a unique ID even when there are no inputs.
|
||||
*/
|
||||
data class Issue(override val nonce: Long = newSecureRandom().nextLong()) : FungibleAsset.Commands.Issue
|
||||
data class Issue(override val nonce: Long = SecureRandom.getInstanceStrong().nextLong()) : FungibleAsset.Commands.Issue
|
||||
|
||||
/**
|
||||
* A command stating that money has been withdrawn from the shared ledger and is now accounted for
|
||||
|
@ -4,7 +4,6 @@ import com.google.common.io.ByteStreams
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import com.google.common.util.concurrent.MoreExecutors
|
||||
import com.google.common.util.concurrent.SettableFuture
|
||||
import com.r3corda.core.crypto.newSecureRandom
|
||||
import org.slf4j.Logger
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.InputStream
|
||||
@ -37,7 +36,7 @@ fun String.abbreviate(maxWidth: Int): String = if (length <= maxWidth) this else
|
||||
* Returns a random positive long generated using a secure RNG. This function sacrifies a bit of entropy in order to
|
||||
* avoid potential bugs where the value is used in a context where negative numbers are not expected.
|
||||
*/
|
||||
fun random63BitValue(): Long = Math.abs(newSecureRandom().nextLong())
|
||||
fun random63BitValue(): Long = Math.abs(SecureRandom.getInstanceStrong().nextLong())
|
||||
|
||||
// Some utilities for working with Guava listenable futures.
|
||||
fun <T> ListenableFuture<T>.then(executor: Executor, body: () -> Unit) = addListener(Runnable(body), executor)
|
||||
@ -201,4 +200,4 @@ fun extractZipFile(zipPath: Path, toPath: Path) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Generic csv printing utility for clases.
|
||||
// TODO: Generic csv printing utility for clases.
|
@ -10,8 +10,6 @@ import java.security.*
|
||||
import java.security.interfaces.ECPublicKey
|
||||
import net.i2p.crypto.eddsa.KeyPairGenerator as EddsaKeyPairGenerator
|
||||
|
||||
fun newSecureRandom() = SecureRandom.getInstance("NativePRNGNonBlocking")
|
||||
|
||||
// "sealed" here means there can't be any subclasses other than the ones defined here.
|
||||
sealed class SecureHash private constructor(bits: ByteArray) : OpaqueBytes(bits) {
|
||||
class SHA256(bits: ByteArray) : SecureHash(bits) {
|
||||
@ -40,7 +38,7 @@ sealed class SecureHash private constructor(bits: ByteArray) : OpaqueBytes(bits)
|
||||
@JvmStatic fun sha256Twice(bits: ByteArray) = sha256(sha256(bits).bits)
|
||||
@JvmStatic fun sha256(str: String) = sha256(str.toByteArray())
|
||||
|
||||
@JvmStatic fun randomSHA256() = sha256(newSecureRandom().generateSeed(32))
|
||||
@JvmStatic fun randomSHA256() = sha256(SecureRandom.getInstanceStrong().generateSeed(32))
|
||||
}
|
||||
|
||||
abstract val signatureAlgorithmName: String
|
||||
@ -163,4 +161,4 @@ operator fun KeyPair.component1() = this.private
|
||||
operator fun KeyPair.component2() = this.public
|
||||
|
||||
/** A simple wrapper that will make it easier to swap out the EC algorithm we use in future */
|
||||
fun generateKeyPair() = EddsaKeyPairGenerator().generateKeyPair()
|
||||
fun generateKeyPair() = EddsaKeyPairGenerator().generateKeyPair()
|
@ -1,6 +1,5 @@
|
||||
package com.r3corda.core.contracts
|
||||
|
||||
import com.r3corda.core.crypto.newSecureRandom
|
||||
import com.r3corda.core.node.services.testing.MockTransactionStorage
|
||||
import com.r3corda.core.testing.DUMMY_NOTARY
|
||||
import com.r3corda.core.testing.MEGA_CORP_KEY
|
||||
@ -17,7 +16,7 @@ class TransactionGraphSearchTests {
|
||||
}
|
||||
}
|
||||
|
||||
fun random31BitValue(): Int = Math.abs(newSecureRandom().nextInt())
|
||||
fun random31BitValue(): Int = Math.abs(SecureRandom.getInstanceStrong().nextInt())
|
||||
|
||||
/**
|
||||
* Build a pair of transactions. The first issues a dummy output state, and has a command applied, the second then
|
||||
@ -71,4 +70,4 @@ class TransactionGraphSearchTests {
|
||||
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package com.r3corda.core.contracts
|
||||
|
||||
import com.r3corda.core.crypto.Party
|
||||
import com.r3corda.core.crypto.SecureHash
|
||||
import com.r3corda.core.crypto.newSecureRandom
|
||||
import com.r3corda.core.node.services.testing.MockStorageService
|
||||
import com.r3corda.core.testing.*
|
||||
import org.junit.Test
|
||||
@ -34,7 +33,7 @@ class TransactionGroupTests {
|
||||
}
|
||||
interface Commands : CommandData {
|
||||
class Move() : TypeOnlyCommandData(), Commands
|
||||
data class Issue(val nonce: Long = newSecureRandom().nextLong()) : Commands
|
||||
data class Issue(val nonce: Long = SecureRandom.getInstanceStrong().nextLong()) : Commands
|
||||
data class Exit(val amount: Amount<Currency>) : Commands
|
||||
}
|
||||
}
|
||||
@ -179,4 +178,4 @@ class TransactionGroupTests {
|
||||
}.toSet()
|
||||
TransactionGroup(ltxns, emptySet()).verify()
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package com.r3corda.core.serialization
|
||||
import com.r3corda.core.contracts.*
|
||||
import com.r3corda.core.crypto.Party
|
||||
import com.r3corda.core.crypto.SecureHash
|
||||
import com.r3corda.core.crypto.newSecureRandom
|
||||
import com.r3corda.core.node.services.testing.MockStorageService
|
||||
import com.r3corda.core.seconds
|
||||
import com.r3corda.core.testing.*
|
||||
@ -35,7 +34,7 @@ class TransactionSerializationTests {
|
||||
}
|
||||
interface Commands : CommandData {
|
||||
class Move() : TypeOnlyCommandData(), Commands
|
||||
data class Issue(val nonce: Long = newSecureRandom().nextLong()) : Commands
|
||||
data class Issue(val nonce: Long = SecureRandom.getInstanceStrong().nextLong()) : Commands
|
||||
data class Exit(val amount: Amount<Currency>) : Commands
|
||||
}
|
||||
}
|
||||
@ -108,4 +107,4 @@ class TransactionSerializationTests {
|
||||
assertEquals(tx.outputStates(), ltx.outputs)
|
||||
assertEquals(TEST_TX_TIME, ltx.commands.getTimestampBy(DUMMY_NOTARY)!!.midpoint)
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,6 @@ import java.nio.file.FileAlreadyExistsException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.security.KeyPair
|
||||
import java.security.Security
|
||||
import java.time.Clock
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
|
@ -3,7 +3,6 @@ package com.r3corda.node.services.messaging
|
||||
import com.google.common.net.HostAndPort
|
||||
import com.r3corda.core.RunOnCallerThread
|
||||
import com.r3corda.core.ThreadBox
|
||||
import com.r3corda.core.crypto.newSecureRandom
|
||||
import com.r3corda.core.messaging.*
|
||||
import com.r3corda.core.serialization.SingletonSerializeAsToken
|
||||
import com.r3corda.core.utilities.loggerFor
|
||||
@ -116,7 +115,7 @@ class ArtemisMessagingService(val directory: Path, val myHostPort: HostAndPort,
|
||||
val config = createArtemisConfig(directory, myHostPort)
|
||||
mq.setConfiguration(config)
|
||||
val secConfig = SecurityConfiguration()
|
||||
val password = BigInteger(128, newSecureRandom()).toString(16)
|
||||
val password = BigInteger(128, SecureRandom.getInstanceStrong()).toString(16)
|
||||
secConfig.addUser("internal", password)
|
||||
secConfig.addRole("internal", "internal")
|
||||
secConfig.defaultUser = "internal"
|
||||
|
Loading…
x
Reference in New Issue
Block a user