in oss-20190517/src/main/java/com/aliyun/sdk/service/oss20190517/encryption/internal/CryptoModuleBase.java [223:261]
protected final Map<String, String> generateCryptoMetadata(ContentCryptoMaterial contentCryptoMaterial, Map<String, Object> headers) {
Map<String, String> metadata = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
//x-oss-meta-client-side-encryption-key
byte[] encryptedCEK = contentCryptoMaterial.getEncryptedCEK();
metadata.put(CryptoHeaders.CRYPTO_KEY, Base64Util.encodeToString(encryptedCEK));
//x-oss-meta-client-side-encryption-start //iv
// Put the iv into the object metadata
byte[] encryptedIV = contentCryptoMaterial.getEncryptedIV();
metadata.put(CryptoHeaders.CRYPTO_IV, Base64Util.encodeToString(encryptedIV));
//x-oss-meta-client-side-encryption-cek-alg
// Put the content encrypt key algorithm into the object metadata
String contentCryptoAlgo = contentCryptoMaterial.getContentCryptoAlgorithm();
metadata.put(CryptoHeaders.CRYPTO_CEK_ALG, contentCryptoAlgo);
//x-oss-meta-client-side-encryption-wrap-alg
// Put the key wrap algorithm into the object metadata
String keyWrapAlgo = contentCryptoMaterial.getKeyWrapAlgorithm();
metadata.put(CryptoHeaders.CRYPTO_WRAP_ALG, keyWrapAlgo);
//x-oss-meta-client-side-encryption-matdesc,json format
// Put the crypto description into the object metadata
Map<String, String> materialDesc = contentCryptoMaterial.getMaterialsDescription();
if (materialDesc != null && materialDesc.size() > 0) {
String descStr = ParseUtil.toJSONString(materialDesc);
metadata.put(CryptoHeaders.CRYPTO_MATDESC, descStr);
}
//x-oss-meta-client-side-encryption-magic-number-hmac
//x-oss-meta-client-side-encryption-unencrypted-content-md5
if (headers.containsKey("Content-MD5")) {
metadata.put(CryptoHeaders.CRYPTO_UNENCRYPTION_CONTENT_MD5, (String) headers.get("Content-MD5"));
}
return metadata;
}