corda / com.r3.corda.networkmanage.common.cryptoservice.bouncycastle / BCCryptoService

BCCryptoService

class BCCryptoService : CryptoService<BCKeyStoreCredentials, BCKeyConfig>

Basic implementation of a CryptoService that uses BouncyCastle for cryptographic operations and a local Java KeyStore in the form of KeyStore to store private keys.

Constructors

<init>

BCCryptoService(keyStore: <ERROR CLASS>)

Basic implementation of a CryptoService that uses BouncyCastle for cryptographic operations and a local Java KeyStore in the form of KeyStore to store private keys.

Functions

authenticate

fun authenticate(credentials: BCKeyStoreCredentials): Unit

Authenticate a user against the underlying crypto provider using given credentials.

containsKey

fun containsKey(alias: String): Boolean

Check if this CryptoService contains an entry for the given alias.

generateAndStoreKeyPair

fun generateAndStoreKeyPair(keyConfig: BCKeyConfig): PublicKey

Generate a key pair and a basic self-signed certificate and store within the underlying key store.

generateRandomLong

fun generateRandomLong(): Long

Generate a random Long using the underlying Provider.

getAuthenticatedUsers

fun getAuthenticatedUsers(): List<String>

Return the list of users currently authenticated against the underlying crypto provider.

getCertificate

fun getCertificate(alias: String): Certificate

Returns the Certificate of the entry for the given alias.

getKeyPairAndCertificateChain

fun getKeyPairAndCertificateChain(keyAlias: String, keyPassword: String): <ERROR CLASS><KeyPair, List<X509Certificate>>

Retrieve a key pair and accompanying certificate chain for a given alias.

getPublicKey

fun getPublicKey(alias: String): PublicKey

Returns the PublicKey of the entry for the given alias.

getSigner

fun getSigner(alias: String, password: String?): <ERROR CLASS>

Returns ContentSigner for the key identified by the input alias.

importKey

fun importKey(alias: String, keyPair: KeyPair, keyPassword: String? = null, certificateChain: List<X509Certificate>): Unit

Import an externally generated key pair and certificate chain into the key store.

isAuthenticated

fun isAuthenticated(): Boolean

Boolean flag indicating whether further authentication is needed to use stored keys.

logOut

fun logOut(): Unit

Reset the authentication state for the underlying crypto provider.

setCertificate

fun setCertificate(alias: String, certificate: X509Certificate): Unit

For the given alias, add an entry with X509 certificate.

sign

fun sign(alias: String, data: ByteArray, signAlgorithm: String?, password: String?): ByteArray

Sign a ByteArray using the private key identified by the input alias. Returns the signature bytes formatted according to the signature scheme. The signAlgorithm if specified determines the signature scheme used for signing, if not specified then the signature scheme is based on the private key scheme.

updateCertificate

fun updateCertificate(keyConfig: BCKeyConfig, certificateChain: List<X509Certificate>): Unit

Update the certificate chain within the underlying key store.