Skip to content

Commit aeefd6f

Browse files
CORE-3695 (#340)
1 parent 925efbd commit aeefd6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+493
-271
lines changed

cipher-suite/src/main/kotlin/net/corda/v5/cipher/suite/CryptoService.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ interface CryptoService {
4848
* Generate and optionally store an asymmetric key pair.
4949
*
5050
* @param spec parameters to generate key pair.
51-
* @param context the optional key/value operation context.
51+
* @param context the optional key/value operation context. The context will have at least two variables defined -
52+
* 'tenantId' and 'category'.
5253
*
5354
* Returns information about the generated key, could be either [GeneratedPublicKey] or [GeneratedWrappedKey]
5455
*
@@ -66,7 +67,8 @@ interface CryptoService {
6667
*
6768
* @param spec (either [SigningAliasSpec] or [SigningWrappedSpec]) to be used for signing.
6869
* @param data the data to be signed.
69-
* @param context the optional key/value operation context.
70+
* @param context the optional key/value operation context. The context will have at least one variable defined -
71+
* 'tenantId'.
7072
*
7173
* @throws [CryptoServiceBadRequestException] if the private key does not exist as defined in the [key],
7274
* the key scheme is not supported, or the [data] is empty array.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@file:JvmName("CryptoServiceContext")
2+
3+
package net.corda.v5.cipher.suite
4+
5+
/**
6+
* Standard [CryptoService] context constants keys.
7+
*/
8+
9+
const val CRYPTO_TENANT_ID = "tenantId"
10+
const val CRYPTO_CATEGORY = "category"

cipher-suite/src/main/kotlin/net/corda/v5/cipher/suite/KeyGenerationSpec.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import net.corda.v5.cipher.suite.schemes.SignatureScheme
55
/**
66
* Defines parameters to generate a key pair.
77
*
8-
* @property tenantId The tenant id which the key pair is generated for.
98
* @property signatureScheme The spec defining properties of the key pair being generated.
109
* @property alias Optional, the key alias for the pair as defined by the tenant, as that value is not guarantied to be
1110
* unique, in case if the HSM is shared between several tenants, the implementation must translate it something unique,
@@ -21,8 +20,8 @@ import net.corda.v5.cipher.suite.schemes.SignatureScheme
2120
* aliases for public and private keys, in such cases their names have to be derived from the single key pair alias.
2221
* It could be suffixes or whatever internal naming scheme is used.
2322
*/
23+
@Suppress("LongParameterList")
2424
class KeyGenerationSpec(
25-
val tenantId: String,
2625
val signatureScheme: SignatureScheme,
2726
val alias: String?,
2827
val masterKeyAlias: String?,

cipher-suite/src/main/kotlin/net/corda/v5/cipher/suite/SigningAliasSpec.kt

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import net.corda.v5.cipher.suite.schemes.SignatureScheme
55
/**
66
* Holding class for the key pair which is persisted in HSM and referenced by its alias.
77
*
8-
* @property tenantId The tenant id which the key pair belongs to.
98
* @property hsmAlias The key pair alias assigned by the implementation when the key was generated.
109
* @property signatureScheme The scheme for the signing operation.
1110
*
@@ -14,7 +13,6 @@ import net.corda.v5.cipher.suite.schemes.SignatureScheme
1413
* It could be suffixes or whatever internal naming scheme is used.
1514
*/
1615
class SigningAliasSpec(
17-
override val tenantId: String,
1816
val hsmAlias: String,
1917
override val signatureScheme: SignatureScheme
2018
) : SigningSpec

cipher-suite/src/main/kotlin/net/corda/v5/cipher/suite/SigningSpec.kt

-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import net.corda.v5.cipher.suite.schemes.SignatureScheme
55
/**
66
* Marker interface denoting the signing parameters.
77
*
8-
* @property tenantId The tenant id which the key pair belongs to.
98
* @property signatureScheme The scheme for the signing operation.
109
*/
1110
interface SigningSpec {
12-
val tenantId: String
1311
val signatureScheme: SignatureScheme
1412
}

cipher-suite/src/main/kotlin/net/corda/v5/cipher/suite/SigningWrappedSpec.kt

-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import net.corda.v5.cipher.suite.schemes.SignatureScheme
55
/**
66
* Holding class for the private key material.
77
*
8-
* @property tenantId The tenant id which the key pair belongs to.
98
* @property keyMaterial The encoded and encrypted private key.
109
* @property masterKeyAlias The wrapping key's alias which was used for wrapping, the value
1110
* could be null for HSMs which use built-in wrapping keys.
1211
* @property encodingVersion The encoding version which was used to encode the private key.
1312
* @property signatureScheme The scheme for the signing operation.
1413
*/
1514
class SigningWrappedSpec(
16-
override val tenantId: String,
1715
val keyMaterial: ByteArray,
1816
val masterKeyAlias: String?,
1917
val encodingVersion: Int,

data/avro-schema/src/main/resources/avro/net/corda/data/crypto/config/HSMLabel.avsc

-28
This file was deleted.

data/avro-schema/src/main/resources/avro/net/corda/data/crypto/config/TenantHSMConfig.avsc

-38
This file was deleted.

data/avro-schema/src/main/resources/avro/net/corda/data/crypto/persistence/HSMKeyInfo.avsc

-81
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "record",
3+
"name": "CryptoStringResult",
4+
"namespace": "net.corda.data.crypto.wire",
5+
"doc": "Defines over-the-wire response for operation which return only single string value",
6+
"fields": [
7+
{
8+
"name": "value",
9+
"type": "string",
10+
"doc": "The result's value"
11+
}
12+
]
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"type": "record",
3+
"name": "HSMCategoryInfo",
4+
"namespace": "net.corda.data.crypto.wire.hsm",
5+
"doc": "Defines information about category and HSM configuration relation.",
6+
"fields": [
7+
{
8+
"name": "category",
9+
"type": "string",
10+
"doc": "Such as LEDGER, TLS, etc."
11+
},
12+
{
13+
"name": "keyPolicy",
14+
"type": "PrivateKeyPolicy",
15+
"doc": "Policy how a key is generated and persisted in an HSM."
16+
}
17+
]
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"type": "record",
3+
"name": "HSMCategoryInfos",
4+
"namespace": "net.corda.data.crypto.wire.hsm",
5+
"doc": "Defines information about category and HSM configuration relation.",
6+
"fields": [
7+
{
8+
"name": "links",
9+
"type": {
10+
"type": "array",
11+
"items": "HSMCategoryInfo"
12+
},
13+
"doc": "Collection of HSMCategoryInfo"
14+
}
15+
]
16+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"type": "record",
33
"name": "HSMInfo",
4-
"namespace": "net.corda.data.crypto.config",
5-
"doc": "Defines persistent record for the HSM common configuration parameters.",
4+
"namespace": "net.corda.data.crypto.wire.hsm",
5+
"doc": "Defines information for HSM common configuration parameters.",
66
"fields": [
77
{
88
"name": "id",
@@ -18,40 +18,30 @@
1818
"doc": "Time ([Instant]) in milliseconds when the record was updated or added."
1919
},
2020
{
21-
"name": "version",
22-
"type": "int",
23-
"doc": "Ever increasing on each update version of the record, the initial value is 1."
24-
},
25-
{
26-
"name": "hsmLabel",
27-
"type": "string",
28-
"doc": "Label associated with HSM worker to partition for HSMs which don't support more than one HSM per process/VM. The default value is 'default'."
21+
"name": "workerLabel",
22+
"type": [
23+
"null",
24+
"string"
25+
],
26+
"doc": "Label associated with HSM worker to partition for HSMs which don't support more than one HSM per process/VM."
2927
},
3028
{
3129
"name": "description",
3230
"type": "string",
3331
"doc": "The human readable description of the HSM instance, like 'HSM on the first floor' or anything which helps tp understand what HSM is allocated."
3432
},
3533
{
36-
"name": "serviceName",
37-
"type": "string",
38-
"doc": "Name of the CryptoServiceProvider which is sued to create interface to the HSM."
34+
"name": "masterKeyPolicy",
35+
"type": "MasterKeyPolicy",
36+
"doc": "How to generate wrapping key on the HSM registration."
3937
},
4038
{
41-
"name": "byoTenantId",
39+
"name": "masterKeyAlias",
4240
"type": [
4341
"null",
4442
"string"
4543
],
46-
"doc": "The tenant id which owns the HSM instance. That HSM can be made available only for that tenant."
47-
},
48-
{
49-
"name": "categories",
50-
"type": {
51-
"type": "array",
52-
"items": "string"
53-
},
54-
"doc": "Categories, like TLS, LEDGER, FRESH_KEYS, etc., the HSM can be used for."
44+
"doc": "If masterKeyPolicy=SHARED then this field must be specified with the wrapping key name."
5545
},
5646
{
5747
"name": "retries",
@@ -70,6 +60,16 @@
7060
"items": "string"
7161
},
7262
"doc": "List of supported signature scheme codes, must be a subset of schemes defined in the cipher suite."
63+
},
64+
{
65+
"name": "serviceName",
66+
"type": "string",
67+
"doc": "Name of the CryptoServiceProvider which is used to create interface to the HSM."
68+
},
69+
{
70+
"name": "capacity",
71+
"type": "int",
72+
"doc": "Maximum number of tenants that the instance can be assigned to (the actual allocations may exceed slightly that number). -1 means there is no limit"
7373
}
7474
]
7575
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"type": "record",
3+
"name": "HSMInfos",
4+
"namespace": "net.corda.data.crypto.wire.hsm",
5+
"doc": "Defines a collection of HSMInfo",
6+
"fields": [
7+
{
8+
"name": "items",
9+
"type": {
10+
"type": "array",
11+
"items": "HSMInfo"
12+
},
13+
"doc": "Collection of HSMInfo"
14+
}
15+
]
16+
}

0 commit comments

Comments
 (0)