1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2025-06-14 18:53:35 +00:00

rebase: bump github.com/IBM/keyprotect-go-client from 0.9.1 to 0.9.2

Bumps [github.com/IBM/keyprotect-go-client](https://github.com/IBM/keyprotect-go-client) from 0.9.1 to 0.9.2.
- [Release notes](https://github.com/IBM/keyprotect-go-client/releases)
- [Changelog](https://github.com/IBM/keyprotect-go-client/blob/master/CHANGELOG.md)
- [Commits](https://github.com/IBM/keyprotect-go-client/compare/v0.9.1...v0.9.2)

---
updated-dependencies:
- dependency-name: github.com/IBM/keyprotect-go-client
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2022-12-19 20:02:34 +00:00
committed by mergify[bot]
parent 911bc6eabc
commit bbcb0eb83e
8 changed files with 109 additions and 20 deletions

@ -112,13 +112,20 @@ type KeyVersions struct {
// KeysActionRequest represents request parameters for a key action
// API call.
type KeysActionRequest struct {
PlainText string `json:"plaintext,omitempty"`
AAD []string `json:"aad,omitempty"`
CipherText string `json:"ciphertext,omitempty"`
Payload string `json:"payload,omitempty"`
EncryptedNonce string `json:"encryptedNonce,omitempty"`
IV string `json:"iv,omitempty"`
EncryptionAlgorithm string `json:"encryptionAlgorithm,omitempty"`
PlainText string `json:"plaintext,omitempty"`
AAD []string `json:"aad,omitempty"`
CipherText string `json:"ciphertext,omitempty"`
Payload string `json:"payload,omitempty"`
EncryptedNonce string `json:"encryptedNonce,omitempty"`
IV string `json:"iv,omitempty"`
EncryptionAlgorithm string `json:"encryptionAlgorithm,omitempty"`
KeyVersion *KeyVersion `json:"keyVersion,,omitempty"`
}
type KeyActionResponse struct {
PlainText string `json:"plaintext,omitempty"`
CipherText string `json:"ciphertext,omitempty"`
KeyVersion *KeyVersion `json:"keyVersion,,omitempty"`
}
type KeyVersion struct {
@ -548,6 +555,43 @@ func (c *Client) wrap(ctx context.Context, idOrAlias string, plainText []byte, a
return pt, ct, nil
}
// WrapWithKeyVersion function supports KeyVersion Details, PlainText and Cyphertext in response
func (c *Client) WrapV2(ctx context.Context, idOrAlias string, plainText []byte, additionalAuthData *[]string) (*KeyActionResponse, error) {
keysActionReq := &KeysActionRequest{}
keyActionRes := &KeyActionResponse{}
if plainText != nil {
_, err := base64.StdEncoding.DecodeString(string(plainText))
if err != nil {
return keyActionRes, err
}
keysActionReq.PlainText = string(plainText)
}
if additionalAuthData != nil {
keysActionReq.AAD = *additionalAuthData
}
keysAction, err := c.doKeysAction(ctx, idOrAlias, "wrap", keysActionReq)
if err != nil {
return keyActionRes, err
}
keyActionRes = &KeyActionResponse{
PlainText: keysAction.PlainText,
CipherText: keysAction.CipherText,
}
if keysAction.KeyVersion != nil {
keyActionRes.KeyVersion = &KeyVersion{
ID: keysAction.KeyVersion.ID,
}
if keysAction.KeyVersion.CreationDate != nil {
keyActionRes.KeyVersion.CreationDate = keysAction.KeyVersion.CreationDate
}
}
return keyActionRes, nil
}
// Unwrap is deprecated since it returns only plaintext and doesn't know how to handle rotation.
func (c *Client) Unwrap(ctx context.Context, idOrAlias string, cipherText []byte, additionalAuthData *[]string) ([]byte, error) {
plainText, _, err := c.UnwrapV2(ctx, idOrAlias, cipherText, additionalAuthData)