Class: Aws::Plugins::ChecksumAlgorithm Private
- Inherits:
-
Seahorse::Client::Plugin
- Object
- Seahorse::Client::Plugin
- Aws::Plugins::ChecksumAlgorithm
- Defined in:
- lib/aws-sdk-core/plugins/checksum_algorithm.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: AwsChunkedTrailerDigestIO, ChecksumHandler, Digest, OptionHandler
Constant Summary collapse
- CHUNK_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
one MB
1 * 1024 * 1024
- CLIENT_ALGORITHMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
determine the set of supported client side checksum algorithms CRC32c requires aws-crt (optional sdk dependency) for support
begin supported = %w[SHA256 SHA1 CRC32] begin require 'aws-crt' supported << 'CRC32C' supported << 'CRC64NVME' if Aws::Crt::GEM_VERSION >= '0.3.0' rescue LoadError # Ignored end supported end.freeze
- CRT_ALGORITHMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[CRC32C CRC64NVME].freeze
- CHECKSUM_ALGORITHM_PRIORITIES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Priority order of checksum algorithms to validate responses against. Remove any algorithms not supported by client (ie, depending on CRT availability). This list was chosen based on average performance.
%w[CRC32 CRC32C CRC64NVME SHA1 SHA256] & CLIENT_ALGORITHMS
- CHECKSUM_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
byte size of checksums, used in computing the trailer length
{ 'CRC32' => 9, 'CRC32C' => 9, 'CRC64NVME' => 13, # SHA functions need 1 byte padding because of how they are encoded 'SHA1' => 28 + 1, 'SHA256' => 44 + 1 }.freeze
- DEFAULT_CHECKSUM =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'CRC32'
Class Method Summary collapse
- .digest_for_algorithm(algorithm) ⇒ Object private
-
.trailer_length(algorithm, location_name) ⇒ Object
private
The trailer size (in bytes) is the overhead (0, r, n) + the trailer name + the bytesize of the base64 encoded checksum.
Instance Method Summary collapse
Methods inherited from Seahorse::Client::Plugin
#add_options, #after_initialize, after_initialize, after_initialize_hooks, #before_initialize, before_initialize, before_initialize_hooks, handlers, literal, option, options
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response, #handler_for, #new_handler
Class Method Details
.digest_for_algorithm(algorithm) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/aws-sdk-core/plugins/checksum_algorithm.rb', line 78 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 |
.trailer_length(algorithm, location_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The trailer size (in bytes) is the overhead (0, r, n) + the trailer name + the bytesize of the base64 encoded checksum.
98 99 100 |
# File 'lib/aws-sdk-core/plugins/checksum_algorithm.rb', line 98 def trailer_length(algorithm, location_name) 7 + location_name.size + CHECKSUM_SIZE[algorithm] end |
Instance Method Details
#add_handlers(handlers, _config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
153 154 155 156 157 158 |
# File 'lib/aws-sdk-core/plugins/checksum_algorithm.rb', line 153 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 |