class Aws::Plugins::ChecksumAlgorithm

@api private

def add_handlers(handlers, _config)

def add_handlers(handlers, _config)
  handlers.add(OptionHandler, step: :initialize)
  # Priority is set low to ensure the checksum is computed AFTER the
  # request is built but before it is signed.
  handlers.add(ChecksumHandler, priority: 15, step: :build)
end

def digest_for_algorithm(algorithm)

def digest_for_algorithm(algorithm)
  case algorithm
  when 'CRC32'
    Digest.new(Zlib.method(:crc32), 'N')
  when 'CRC32C'
    Digest.new(Aws::Crt::Checksums.method(:crc32c), 'N')
  when 'CRC64NVME'
    Digest.new(Aws::Crt::Checksums.method(:crc64nvme), 'Q>')
  when 'SHA1'
    ::Digest::SHA1.new
  when 'SHA256'
    ::Digest::SHA256.new
  else
    raise ArgumentError,
          "#{algorithm} is not a supported checksum algorithm."
  end
end

def resolve_request_checksum_calculation(cfg)

def resolve_request_checksum_calculation(cfg)
  mode = ENV['AWS_REQUEST_CHECKSUM_CALCULATION'] ||
         Aws.shared_config.request_checksum_calculation(profile: cfg.profile) ||
         'when_supported'
  mode = mode.downcase
  unless %w[when_supported when_required].include?(mode)
    raise ArgumentError,
          'expected :request_checksum_calculation or' \
          " ENV['AWS_REQUEST_CHECKSUM_CALCULATION'] to be " \
          '`when_supported` or `when_required`.'
  end
  mode
end

def resolve_response_checksum_validation(cfg)

def resolve_response_checksum_validation(cfg)
  mode = ENV['AWS_RESPONSE_CHECKSUM_VALIDATION'] ||
         Aws.shared_config.response_checksum_validation(profile: cfg.profile) ||
         'when_supported'
  mode = mode.downcase
  unless %w[when_supported when_required].include?(mode)
    raise ArgumentError,
          'expected :response_checksum_validation or' \
          " ENV['AWS_RESPONSE_CHECKSUM_VALIDATION'] to be " \
          '`when_supported` or `when_required`.'
  end
  mode
end

def trailer_length(algorithm, location_name)

name + the bytesize of the base64 encoded checksum.
The trailer size (in bytes) is the overhead (0, \r, \n) + the trailer
def trailer_length(algorithm, location_name)
  7 + location_name.size + CHECKSUM_SIZE[algorithm]
end