@@ -98,7 +98,7 @@ func (client *Client) GenerateECKeyPair(ctx context.Context, curve types.Curves,
98
98
return client .CreateImportServiceKey (ctx , nil , body )
99
99
}
100
100
101
- func (client * Client ) importJWK (ctx context.Context , jwk types.JsonWebKey , name , keyCtx string , ops ... types.CryptographicUsages ) (* types.GetServiceKeyResponse , error ) {
101
+ func (client * Client ) importJWK (ctx context.Context , jwk types.JsonWebKeyRequest , name , keyCtx string , ops ... types.CryptographicUsages ) (* types.GetServiceKeyResponse , error ) {
102
102
var keyContext * string
103
103
if keyCtx != "" {
104
104
keyContext = & keyCtx
@@ -107,7 +107,7 @@ func (client *Client) importJWK(ctx context.Context, jwk types.JsonWebKey, name,
107
107
Context : keyContext ,
108
108
Name : name ,
109
109
Operations : & ops ,
110
- Keys : & []types.JsonWebKey {jwk },
110
+ Keys : & []types.JsonWebKeyRequest {jwk },
111
111
}
112
112
format := types .Jwk
113
113
return client .CreateImportServiceKey (ctx , & format , req )
@@ -122,16 +122,33 @@ func (client *Client) importJWK(ctx context.Context, jwk types.JsonWebKey, name,
122
122
// - []byte for importing symmetric keys.
123
123
func (client * Client ) ImportKey (ctx context.Context , key any , name , keyCtx string , ops ... types.CryptographicUsages ) (* types.GetServiceKeyResponse , error ) {
124
124
switch k := key .(type ) {
125
- case types.JsonWebKey :
125
+ case types.JsonWebKeyRequest :
126
126
return client .importJWK (ctx , k , name , keyCtx , ops ... )
127
- case * types.JsonWebKey :
127
+ case * types.JsonWebKeyRequest :
128
128
return client .importJWK (ctx , * k , name , keyCtx , ops ... )
129
129
}
130
130
jwk , err := types .NewJsonWebKey (key , ops , name )
131
131
if err != nil {
132
132
return nil , err
133
133
}
134
- return client .importJWK (ctx , jwk , name , keyCtx , ops ... )
134
+ jwkRequest := types.JsonWebKeyRequest {
135
+ Kid : & jwk .Kid ,
136
+ KeyOps : jwk .KeyOps ,
137
+ Kty : jwk .Kty ,
138
+ D : jwk .D ,
139
+ E : jwk .E ,
140
+ N : jwk .N ,
141
+ P : jwk .P ,
142
+ Q : jwk .Q ,
143
+ Dp : jwk .Dp ,
144
+ Dq : jwk .Dq ,
145
+ Qi : jwk .Qi ,
146
+ X : jwk .X ,
147
+ Y : jwk .Y ,
148
+ Crv : jwk .Crv ,
149
+ K : jwk .K ,
150
+ }
151
+ return client .importJWK (ctx , jwkRequest , name , keyCtx , ops ... )
135
152
}
136
153
137
154
// ImportKeyPairPEM imports a PEM formated key into the KMS. keyCtx can be left empty if not needed.
@@ -166,8 +183,8 @@ func (client *Client) ImportKeyPairPEM(ctx context.Context, privateKeyPem []byte
166
183
return client .ImportKey (ctx , k , name , keyCtx , ops ... )
167
184
}
168
185
169
- // ExportJwkPublicKey returns the public part of a key pair ans a Json Web Key.
170
- func (client * Client ) ExportJwkPublicKey (ctx context.Context , keyID uuid.UUID ) (* types.JsonWebKey , error ) {
186
+ // ExportJwkPublicKey returns the public part of a key pair as a Json Web Key.
187
+ func (client * Client ) ExportJwkPublicKey (ctx context.Context , keyID uuid.UUID ) (* types.JsonWebKeyResponse , error ) {
171
188
format := types .Jwk
172
189
k , err := client .GetServiceKey (ctx , keyID , & format )
173
190
if err != nil {
@@ -460,13 +477,16 @@ func (client *apiClient) Encrypt(ctx context.Context, keyId uuid.UUID, keyCtx st
460
477
}
461
478
462
479
// Sign signs the given message with the remote private key having the ID `keyId`. The message can be pre-hashed or not.
463
- func (client * apiClient ) Sign (ctx context.Context , keyId uuid.UUID , alg types.DigitalSignatureAlgorithms , preHashed bool , msg []byte ) (string , error ) {
480
+ func (client * apiClient ) Sign (ctx context.Context , keyId uuid.UUID , format * types. SignatureFormats , alg types.DigitalSignatureAlgorithms , preHashed bool , msg []byte ) (string , error ) {
464
481
req := types.SignRequest {
465
482
Alg : alg ,
466
483
Isdigest : & preHashed ,
467
484
Message : msg ,
468
485
}
469
- r , err := mapRestErr (client .inner .SignWithResponse (ctx , keyId , nil , req )) // TODO: Make the format param customizable
486
+ param := & types.SignParams {
487
+ Format : format ,
488
+ }
489
+ r , err := mapRestErr (client .inner .SignWithResponse (ctx , keyId , param , req ))
470
490
if err != nil {
471
491
return "" , err
472
492
}
0 commit comments