mirror of
https://github.com/minio/minio.git
synced 2025-02-28 05:49:16 -05:00
use jsoniter for json marshal/unmarshal in KMS (#12146)
Signed-off-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
parent
d501c5e38b
commit
2966823818
@ -1499,7 +1499,6 @@ func (er erasureObjects) restoreTransitionedObject(ctx context.Context, bucket s
|
||||
}
|
||||
|
||||
_, err = er.CompleteMultipartUpload(ctx, bucket, object, uploadID, uploadedParts, ObjectOptions{
|
||||
VersionID: oi.VersionID,
|
||||
MTime: oi.ModTime,
|
||||
Versioned: globalBucketVersioningSys.Enabled(bucket),
|
||||
VersionSuspended: globalBucketVersioningSys.Suspended(bucket),
|
||||
|
@ -20,6 +20,8 @@ package kms
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// KMS is the generic interface that abstracts over
|
||||
@ -106,6 +108,7 @@ func (d *DEK) UnmarshalText(text []byte) error {
|
||||
Ciphertext []byte `json:"ciphertext"`
|
||||
}
|
||||
var v JSON
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.Unmarshal(text, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/secure-io/sio-go/sioutil"
|
||||
"golang.org/x/crypto/chacha20"
|
||||
"golang.org/x/crypto/chacha20poly1305"
|
||||
@ -152,6 +152,7 @@ func (kms secretKey) GenerateKey(keyID string, context Context) (DEK, error) {
|
||||
associatedData, _ := context.MarshalText()
|
||||
ciphertext := aead.Seal(nil, nonce, plaintext, associatedData)
|
||||
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
ciphertext, err = json.Marshal(encryptedKey{
|
||||
Algorithm: algorithm,
|
||||
IV: iv,
|
||||
@ -174,9 +175,11 @@ func (kms secretKey) DecryptKey(keyID string, ciphertext []byte, context Context
|
||||
}
|
||||
|
||||
var encryptedKey encryptedKey
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.Unmarshal(ciphertext, &encryptedKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if n := len(encryptedKey.IV); n != 16 {
|
||||
return nil, fmt.Errorf("kms: invalid iv size")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user