Module: Linzer::Common Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Shared functionality for signature base computation and validation.
This module contains the core logic for building the canonical signature base string that gets signed/verified, as defined in RFC 9421 Section 2.5.
Class Method Summary collapse
-
.signature_base(message, serialized_components, parameters, field_ids: nil) ⇒ String
private
Computes the signature base string for an HTTP message.
-
.signature_base_line(component, message) ⇒ String
private
Builds a single line of the signature base for a component.
- .signature_params_line(serialized_components, parameters) ⇒ Object private
Class Method Details
.signature_base(message, serialized_components, parameters, field_ids: nil) ⇒ String
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.
Computes the signature base string for an HTTP message.
The signature base is a canonical string representation of the covered components, formatted according to RFC 9421. This is the string that gets cryptographically signed.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/linzer/common.rb', line 29 def signature_base(, serialized_components, parameters, field_ids: nil) buf = +"" if field_ids i = 0 len = serialized_components.size while i < len buf << serialized_components[i] << ": " << String([field_ids[i]]) << "\n" i += 1 end else serialized_components.each do |component| buf << signature_base_line(component, ) << "\n" end end buf << signature_params_line(serialized_components, parameters) buf end |
.signature_base_line(component, message) ⇒ String
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.
Builds a single line of the signature base for a component.
56 57 58 59 |
# File 'lib/linzer/common.rb', line 56 def signature_base_line(component, ) field_id = FieldId.new(field_name: component) "%s: %s" % [field_id.serialize, [field_id]] end |
.signature_params_line(serialized_components, parameters) ⇒ 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.
73 74 75 76 77 78 |
# File 'lib/linzer/common.rb', line 73 def signature_params_line(serialized_components, parameters) params_str = HTTP::StructuredField.serialize_parameters(parameters) components_str = serialized_components.join(" ") "#{SERIALIZED_SIGNATURE_PARAMS}: (#{components_str})#{params_str}" end |