function parseEncryptionXml(xml, log, cb) {
    return parseString(xml, (err, parsed) => {
        if (err) {
            log.trace('xml parsing failed', {
                error: err,
                method: 'parseEncryptionXml',
            });
            log.debug('invalid xml', { xml });
            return cb(errors.MalformedXML);
        }

        if (!parsed
            || !parsed.ServerSideEncryptionConfiguration
            || !parsed.ServerSideEncryptionConfiguration.Rule) {
            log.trace('error in sse config, invalid ServerSideEncryptionConfiguration section', {
                method: 'parseEncryptionXml',
            });
            return cb(errors.MalformedXML);
        }

        const { Rule } = parsed.ServerSideEncryptionConfiguration;

        if (!Array.isArray(Rule)
            || Rule.length > 1
            || !Rule[0]
            || !Rule[0].ApplyServerSideEncryptionByDefault
            || !Rule[0].ApplyServerSideEncryptionByDefault[0]) {
            log.trace('error in sse config, invalid ApplyServerSideEncryptionByDefault section', {
                method: 'parseEncryptionXml',
            });
            return cb(errors.MalformedXML);
        }

        const [encConfig] = Rule[0].ApplyServerSideEncryptionByDefault;

        if (!encConfig.SSEAlgorithm || !encConfig.SSEAlgorithm[0]) {
            log.trace('error in sse config, no SSEAlgorithm provided', {
                method: 'parseEncryptionXml',
            });
            return cb(errors.MalformedXML);
        }

        const [algorithm] = encConfig.SSEAlgorithm;

        if (algorithm !== 'AES256' && algorithm !== 'aws:kms') {
            log.trace('error in sse config, unknown SSEAlgorithm', {
                method: 'parseEncryptionXml',
            });
            return cb(errors.MalformedXML);
        }

        const result = { algorithm, mandatory: true };

        if (encConfig.KMSMasterKeyID) {
            if (algorithm === 'AES256') {
                log.trace('error in sse config, can not specify KMSMasterKeyID when using AES256', {
                    method: 'parseEncryptionXml',
                });
                return cb(errorInstances.InvalidArgument.customizeDescription(
                    'a KMSMasterKeyID is not applicable if the default sse algorithm is not aws:kms'));
            }

            if (!encConfig.KMSMasterKeyID[0] || typeof encConfig.KMSMasterKeyID[0] !== 'string') {
                log.trace('error in sse config, invalid KMSMasterKeyID', {
                    method: 'parseEncryptionXml',
                });
                return cb(errors.MalformedXML);
            }

            result.configuredMasterKeyId = encConfig.KMSMasterKeyID[0];
            // If key is not in a scality arn format include a scality arn prefix
            // of the currently selected KMS client.
            // To keep track of KMS type, protocol and provider used
            if (!isScalityKmsArn(result.configuredMasterKeyId)) {
                result.configuredMasterKeyId = `${kms.arnPrefix}${result.configuredMasterKeyId}`;
            }
        }
        return cb(null, result);
    });
}
parseEncryptionXml - Parses and validates a ServerSideEncryptionConfiguration xml document
@param {object} xml - ServerSideEncryptionConfiguration doc
@param {object} log - logger
@param {ServerSideEncryptionInfo~callback} cb - callback
@returns {undefined}