Method: Sandal::Sig::ES.decode_jws_signature

Defined in:
lib/sandal/sig/es.rb

.decode_jws_signature(signature) ⇒ OpenSSL::BN

Decodes a JWS signature into a pair of BNs.

Parameters:

  • signature (String)

    The ASN.1 signature.

Returns:

  • (OpenSSL::BN, OpenSSL::BN)

    A pair of BNs.

[View source]

72
73
74
75
76
77
78
# File 'lib/sandal/sig/es.rb', line 72

def self.decode_jws_signature(signature)
  n_length = signature.length / 2
  s_to_n = -> s { OpenSSL::BN.new(s.unpack("H*")[0], 16) }
  r = s_to_n.call(signature[0..(n_length - 1)])
  s = s_to_n.call(signature[n_length..-1])
  return r, s
end