github.com/aavshr/aws-sdk-go@v1.41.3/service/s3/s3crypto/cipher_util.go (about)

     1  package s3crypto
     2  
     3  import (
     4  	"encoding/base64"
     5  	"strconv"
     6  )
     7  
     8  // AESGCMNoPadding is the constant value that is used to specify
     9  // the cek algorithm consiting of AES GCM with no padding.
    10  const AESGCMNoPadding = "AES/GCM/NoPadding"
    11  
    12  // AESCBC is the string constant that signifies the AES CBC algorithm cipher.
    13  const AESCBC = "AES/CBC"
    14  
    15  func encodeMeta(reader lengthReader, cd CipherData) (Envelope, error) {
    16  	iv := base64.StdEncoding.EncodeToString(cd.IV)
    17  	key := base64.StdEncoding.EncodeToString(cd.EncryptedKey)
    18  
    19  	contentLength := reader.GetContentLength()
    20  
    21  	matdesc, err := cd.MaterialDescription.encodeDescription()
    22  	if err != nil {
    23  		return Envelope{}, err
    24  	}
    25  
    26  	return Envelope{
    27  		CipherKey:             key,
    28  		IV:                    iv,
    29  		MatDesc:               string(matdesc),
    30  		WrapAlg:               cd.WrapAlgorithm,
    31  		CEKAlg:                cd.CEKAlgorithm,
    32  		TagLen:                cd.TagLength,
    33  		UnencryptedContentLen: strconv.FormatInt(contentLength, 10),
    34  	}, nil
    35  }