Sha256: 5282c6c3bd12a29b15feab4cf8831cd7aae900f881ceff01541bad855dcda70f
Contents?: true
Size: 934 Bytes
Versions: 9
Compression:
Stored size: 934 Bytes
Contents
# frozen_string_literal: true require "cbor" require "cose/error" require "cose/security_message" module COSE class Sign1 < SecurityMessage CONTEXT = "Signature1" attr_reader :payload, :signature def self.keyword_arguments_for_initialize(decoded) { payload: decoded[0], signature: decoded[1] } end def self.tag 18 end def initialize(payload:, signature:, **keyword_arguments) super(**keyword_arguments) @payload = payload @signature = signature end def verify(key, external_aad = nil) if key.kid == headers.kid algorithm.verify(key, signature, verification_data(external_aad)) else raise(COSE::Error, "Non matching kid") end end private def verification_data(external_aad = nil) CBOR.encode([CONTEXT, serialized_map(protected_headers), external_aad || ZERO_LENGTH_BIN_STRING, payload]) end end end
Version data entries
9 entries across 9 versions & 1 rubygems