function getObjectSSEConfiguration(headers, bucket, log, cb) {
    const bucketSSE = bucket.getServerSideEncryption();
    const { error, objectSSE } = parseObjectEncryptionHeaders(headers);
    if (error) {
        return cb(error);
    }

    // If a per object sse algo has been passed through
    // x-amz-server-side-encryption
    if (objectSSE.algorithm) {
        // If aws:kms and a custom key id
        // pass it through without updating the bucket md
        if (objectSSE.algorithm === 'aws:kms' && objectSSE.configuredMasterKeyId) {
            return cb(null, objectSSE);
        }

        // If the client has not specified a key id,
        // and we have a default config, then we reuse
        // it and pass it through
        if (!objectSSE.configuredMasterKeyId && bucketSSE) {
            // The default configs algo is overridden with the one passed in the
            // request headers. Our implementations of AES256 and aws:kms are the
            // same underneath so this is only cosmetic change.
            const sseConfig = Object.assign({}, bucketSSE, { algorithm: objectSSE.algorithm });
            return cb(null, sseConfig);
        }

        // If the client has not specified a key id, and we
        // don't have a default config, generate it
        if (!objectSSE.configuredMasterKeyId && !bucketSSE) {
            return createDefaultBucketEncryptionMetadata(bucket, log, (error, sseConfig) => {
                if (error) {
                    return cb(error);
                }
                // Override the algorithm, for the same reasons as above.
                Object.assign(sseConfig, { algorithm: objectSSE.algorithm });
                return cb(null, sseConfig);
            });
        }
    }

    // If the bucket has a default encryption config, and it is mandatory
    // (created with putBucketEncryption or legacy headers)
    // pass it through.
    if (bucketSSE && bucketSSE.mandatory) {
        return cb(null, bucketSSE);
    }

    // No encryption config
    return cb(null, null);
}
@param {object} headers - request headers
@param {BucketInfo} bucket - BucketInfo model
@param {*} log - werelogs logger
@param {ServerSideEncryptionInfo~callback} cb - callback
@returns {undefined}