ENT-3142: net-params signing tool: include certificate path in signature (#5165)

This commit is contained in:
James Brown
2019-06-21 16:39:33 +01:00
committed by Shams Asari
parent 0cd57c81bc
commit ae877f87ba
2 changed files with 40 additions and 23 deletions

View File

@ -493,6 +493,13 @@ fun <T : Any> T.signWithCert(privateKey: PrivateKey, certificate: X509Certificat
}
}
@DeleteForDJVM
fun <T : Any> T.signWithCertPath(privateKey: PrivateKey, certPath: List<X509Certificate>): SignedDataWithCert<T> {
return signWithCert {
val signature = Crypto.doSign(privateKey, it.bytes)
DigitalSignatureWithCert(certPath.first(), certPath.takeLast(certPath.size - 1), signature)
}
}
@DeleteForDJVM
inline fun <T : Any> SerializedBytes<T>.sign(signer: (SerializedBytes<T>) -> DigitalSignature.WithKey): SignedData<T> {
return SignedData(this, signer(this))