Class AwsKeyManager
-
- All Implemented Interfaces:
-
web5.sdk.crypto.KeyManager
public final class AwsKeyManager implements KeyManagerA KeyManager that uses AWS KMS for remote storage of keys and signing operations. Caller is expected to provide connection details for AWSKMS client as per Configure the AWS CLI
Key aliases are generated from the key's Jwk thumbprint, and stored in AWS KMS. e.g. alias/6uNnyj7xZUgtKTEOFV2mz0f7Hd3cxIH1o5VXsOo4u1M
AWSKeyManager supports a limited set ECDSA curves for signing:
JWSAlgorithm.ES256K
-
-
Constructor Summary
Constructors Constructor Description AwsKeyManager(AWSKMS kmsClient)AwsKeyManager()
-
Method Summary
Modifier and Type Method Description StringgeneratePrivateKey(AlgorithmId algorithmId, KeyGenOptions options)Generates and securely stores a private key based on the provided algorithm and options, returning a unique alias that can be utilized to reference the generated key for future operations. JwkgetPublicKey(String keyAlias)Retrieves the public key associated with a previously stored private key, identified by the provided alias. ByteArraysign(String keyAlias, ByteArray signingInput)Signs the provided payload using the private key identified by the provided alias. StringgetDeterministicAlias(Jwk publicKey)Return the alias of publicKey, as was originally returned by generatePrivateKey. -
-
Method Detail
-
generatePrivateKey
String generatePrivateKey(AlgorithmId algorithmId, KeyGenOptions options)
Generates and securely stores a private key based on the provided algorithm and options, returning a unique alias that can be utilized to reference the generated key for future operations.
- Parameters:
algorithmId- The algorithmId to use for key generation.options- (Optional) Additional options to control key generation behavior.- Returns:
A unique alias (String) that can be used to reference the stored key.
-
getPublicKey
Jwk getPublicKey(String keyAlias)
Retrieves the public key associated with a previously stored private key, identified by the provided alias.
- Parameters:
keyAlias- The alias referencing the stored private key.- Returns:
The associated public key in Jwk (JSON Web Key) format.
-
sign
ByteArray sign(String keyAlias, ByteArray signingInput)
Signs the provided payload using the private key identified by the provided alias.
- Parameters:
keyAlias- The alias referencing the stored private key.signingInput- The data to be signed.- Returns:
The signature in JWS R+S format
-
getDeterministicAlias
String getDeterministicAlias(Jwk publicKey)
Return the alias of publicKey, as was originally returned by generatePrivateKey.
- Parameters:
publicKey- A public key in Jwk (JSON Web Key) format- Returns:
The alias belonging to publicKey
-
-
-
-