Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE-15939: NOT FOR REVIEW - add 4 new avro schemas for key rotation, two new kafka messages #1232

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,28 @@ public interface SigningService {
@Suspendable
@NotNull
Map<PublicKey, PublicKey> findMySigningKeys(@NotNull Set<PublicKey> keys);

/**
* Sign with the subset of keys we own from a specified set of keys.
*
* @param bytes The data to sign over use the keys we own
* @param keys The set of keys to consider; we will sign with the subset of the keys which we own.
* @param signatureSpec The {@link SignatureSpec} to use when producing these signatures
* @return A set of {@link DigitalSignature.WithKeyId}, one per key we own.
*/
@Suspendable
@NotNull
Set<DigitalSignature.WithKeyId> signWithMyKeys(@NotNull byte bytes[], @NotNull Set<PublicKey> keys, @NotNull SignatureSpec signatureSpec);

/**
* Sign with all the keys we have in a specified category.
*
* @param bytes The data to sign over use the keys we own
* @param category The key categories we use.
* @param signatureSpec The {@link SignatureSpec} to use when producing these signatures
* @return A set of {@link DigitalSignature.WithKeyId}, one per key we own.
*/
@Suspendable
@NotNull
Set<DigitalSignature.WithKeyId> signWithMyCategoryKeys(@NotNull byte bytes[], @NotNull String category, @NotNull SignatureSpec signatureSpec);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"type": "record",
"name": "IndividualKeyRotationRequest",
"namespace": "net.corda.data.crypto.wire.ops.key.rotation",
"doc": "Internal over-the-wire individual crypto key rotation operation request envelope.",
"fields": [
{
"name": "requestId",
"type": "string",
"doc": "GUID allocated by client to control key rotation."
},
{
"name": "tenantId",
"type": "string",
"doc": "Specifies the specific tenant that owns the old key."
},
{
"name": "oldKeyAlias",
"type": "string",
"doc": "The key alias whose protected content will be re-wrapped with a new key."
},
{
"name": "newKeyAlias",
"type": "string",
"doc": "The new wrapping key which oldKeyAlias' content will be re-wrapped with."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"type": "record",
"name": "IndividualKeyRotationResponse",
"namespace": "net.corda.data.crypto.wire.ops.key.rotation",
"doc": "Response for crypto's rewrap operations envelope.",
"fields": [
{
"name": "requestId",
"type": "string",
"doc": "GUID allocated by client to control key rotation."
},
{
"name": "tenantId",
"type": "string",
"doc": "Specifies the specific tenant that owns the old key."
},
{
"name": "oldKeyAlias",
"type": "string",
"doc": "The key alias whose protected content has been re-wrapped with a new key."
},
{
"name": "newKeyAlias",
"type": "string",
"doc": "The new wrapping key which oldKeyAlias' content has been re-wrapped with."
},
{
"name": "endOperationTimestamp",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
},
"doc": "Time ([Instant]) in milliseconds when the individual key rotation has finished."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"type": "record",
"name": "KeyRotationRequest",
"namespace": "net.corda.data.crypto.wire.ops.key.rotation",
"doc": "Internal over-the-wire crypto key rotation operation request envelope.",
"fields": [
{
"name": "requestId",
"type": "string",
"doc": "GUID allocated by client to control key rotation."
},
{
"name": "managedKey",
"type": {
"type": "enum",
"name": "KeyType",
"symbols": ["MANAGED", "UNMANAGED"]
},
"doc": "Type of the key to be rotated."
},
{
"name": "oldKeyAlias",
"type": ["null", "string"],
"doc": "The key alias that should no longer be used, and all its protected content re-wrapped with a new key."
},
{
"name": "newKeyAlias",
"type": ["null", "string"],
"doc": "The unmanaged key alias that should be used for material currently wrapped with old key. Only specified when rotating unmanaged keys."
},
{
"name": "oldGeneration",
"type": ["null", "int"],
"doc": "Specifies the old generation number we should move away from. If absent, rotate all matching keys."
},
{
"name": "tenantId",
"type": ["null", "string"],
"doc": "Only specified when targeting managed keys. Specifies the specific tenant that owns the old and new key."
},
{
"name": "simulate",
"type": "boolean",
"doc": "If true, only work out the number of keys to rotate; defaults to false, which causes the key rotation to actually happen."
},
{
"name": "timeToLive",
"type": ["null", "int"],
"doc": "The maximum number of milliseconds which should pass, after which the key rotation loop will exit. The server can return before this time, and should do at least one key rotation."
},
{
"name": "limit",
"type": ["null", "int"],
"doc": "The maximum number of key rotations to do, after which the key rotation loop will exit. The server can return after doing at least one, but at the server discretion not all of these keys, and should do at least one."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"type": "record",
"name": "KeyRotationStatus",
"namespace": "net.corda.data.crypto.wire.ops.key.rotation",
"doc": "Response for crypto's key rotation operation envelope",
"fields": [
{
"name": "requestId",
"type": "string",
"doc": "GUID allocated by client and passed in StartRotation message."
},
{
"name": "managedKey",
"type": {
"type": "enum",
"name": "KeyType",
"symbols": ["MANAGED", "UNMANAGED"]
},
"doc": "Type of the key to be rotated."
},
{
"name": "oldKeyAlias",
"type": ["null", "string"],
"doc": "The key alias that should no longer be used, and all its protected content re-wrapped with a new key."
},
{
"name": "newKeyAlias",
"type": ["null", "string"],
"doc": "The unmanaged key alias that should be used for material currently wrapped with old key. Only specified when rotating unmanaged keys."
},
{
"name": "oldGeneration",
"type": ["null", "int"],
"doc": "Specifies the old generation number we should move away from. If absent, rotate all matching keys."
},
{
"name": "tenantId",
"type": ["null", "string"],
"doc": "Only specified when targeting managed keys. Specifies the specific tenant that owns the old and new key."
},
{
"name": "simulate",
"type": "boolean",
"doc": "True, if the invocation was a simulation."
},
{
"name": "newGeneration",
"type": ["null", "int"],
"doc": "Set to the new generation number when rotating a single managed key, otherwise null."
},
{
"name": "processedCount",
"type": "int",
"doc": "Number of wrapped keys rotated so far."
},
{
"name": "expectedTotal",
"type": "int",
"doc": "Number of wrapped keys in total to re-wrap as part of this operation."
},
{
"name": "createdTimestamp",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
},
"doc": "The date and time the key rotation request was created."
},
{
"name": "lastUpdateTimestamp",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
},
"doc": "The date and time when the last individual key rotation operation has finished."
}
]
}
7 changes: 7 additions & 0 deletions data/topic-schema/src/main/java/net/corda/schema/Schemas.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ private Crypto() {
public static final String FLOW_OPS_MESSAGE_TOPIC = "crypto.ops.flow";
public static final String RPC_OPS_MESSAGE_TOPIC = "crypto.ops.rpc";
public static final String RPC_OPS_MESSAGE_RESPONSE_TOPIC = getRPCResponseTopic(RPC_OPS_MESSAGE_TOPIC);
public static final String REKEY_MESSAGE_TOPIC = "crypto.key.rotation.ops";
public static final String REKEY_MESSAGE_RESPONSE_TOPIC = getRPCResponseTopic(REKEY_MESSAGE_TOPIC);
public static final String REKEY_MESSAGE_STATUS_TOPIC = "crypto.key.rotation.status";
public static final String REWRAP_MESSAGE_TOPIC = "crypto.key.rotation.individual";
public static final String REWRAP_MESSAGE_RESPONSE_TOPIC = getRPCResponseTopic(REWRAP_MESSAGE_TOPIC);


}

/**
Expand Down
24 changes: 24 additions & 0 deletions data/topic-schema/src/main/resources/net/corda/schema/Crypto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,27 @@ topics:
producers:
- crypto
config:
CryptoOpsRekeyTopic:
name: crypto.key.rotation.ops
consumers:
- crypto
producers:
- rest
CryptoOpsRekeyStatusTopic:
name: crypto.key.rotation.ops.resp
consumers:
- rest
producers:
- crypto
CryptoOpsRewrapTopic:
name: crypto.key.rotation.individual
consumers:
- crypto
producers:
- crypto
CryptoOpsRewrapResponseTopic:
name: crypto.key.rotation.individual.resp
consumers:
- crypto
producers:
- crypto
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cordaProductVersion = 5.1.0
# NOTE: update this each time this module contains a breaking change
## NOTE: currently this is a top level revision, so all API versions will line up, but this could be moved to
## a per module property in which case module versions can change independently.
cordaApiRevision = 37
cordaApiRevision = 38

# Main
kotlinVersion = 1.8.21
Expand Down