ENT-3256 Small performance enhancement and OS preparation for ENT changes (#4857)

This commit is contained in:
Rick Parker
2019-03-07 14:47:51 +00:00
committed by GitHub
parent 96b23eea6f
commit 1c38ecee7b
7 changed files with 48 additions and 21 deletions

View File

@ -2,6 +2,7 @@ package net.corda.nodeapi.internal.crypto
import net.corda.core.crypto.Crypto.SPHINCS256_SHA256
import net.corda.core.crypto.SignatureScheme
import net.corda.core.crypto.internal.Instances
import org.bouncycastle.asn1.x509.AlgorithmIdentifier
import org.bouncycastle.operator.ContentSigner
import java.io.OutputStream
@ -17,7 +18,7 @@ import java.security.Signature
object ContentSignerBuilder {
fun build(signatureScheme: SignatureScheme, privateKey: PrivateKey, provider: Provider, random: SecureRandom? = null): ContentSigner {
val sigAlgId = signatureScheme.signatureOID
val sig = Signature.getInstance(signatureScheme.signatureName, provider).apply {
val sig = Instances.getSignatureInstance(signatureScheme.signatureName, provider).apply {
// TODO special handling for Sphincs due to a known BouncyCastle's Sphincs bug we reported.
// It is fixed in BC 161b12, so consider updating the below if-statement after updating BouncyCastle.
if (random != null && signatureScheme != SPHINCS256_SHA256) {