@@ -379,6 +379,8 @@ func (c *Client) CreateKey(ctx context.Context, spireKeyID string, keyType Trans
379379 return err
380380}
381381
382+ // GetKey gets the transit engine key with the specified spire key id.
383+ // See: https://developer.hashicorp.com/vault/api-docs/secret/transit#read-key
382384func (c * Client ) GetKey (ctx context.Context , spireKeyID string ) (string , error ) {
383385 // TODO: Handle errors here
384386 res , err := c .vaultClient .Logical ().ReadWithContext (ctx , fmt .Sprintf ("/%s/keys/%s" , c .clientParams .TransitEnginePath , spireKeyID ))
@@ -420,6 +422,8 @@ func (c *Client) GetKey(ctx context.Context, spireKeyID string) (string, error)
420422 return pkStr , nil
421423}
422424
425+ // SignData signs the data using the transit engine key with the provided spire key id.
426+ // See: https://developer.hashicorp.com/vault/api-docs/secret/transit#sign-data
423427func (c * Client ) SignData (ctx context.Context , spireKeyID string , data []byte , hashAlgo TransitHashAlgorithm , signatureAlgo TransitSignatureAlgorithm ) ([]byte , error ) {
424428 encodedData := base64 .StdEncoding .EncodeToString (data )
425429
@@ -446,6 +450,7 @@ func (c *Client) SignData(ctx context.Context, spireKeyID string, data []byte, h
446450 return nil , status .Errorf (codes .Internal , "expected signature data type %T but got %T" , sigStr , sig )
447451 }
448452
453+ // Vault adds an application specific prefix that we need to remove
449454 cutSig , ok := strings .CutPrefix (sigStr , "vault:v1:" )
450455 if ! ok {
451456 return nil , status .Errorf (codes .Internal , "signature is missing vault prefix: %v" , err )
0 commit comments