Class: Acme::Client::JWK::HMAC

Inherits:
Base
  • Object
show all
Defined in:
lib/acme/client/jwk/hmac.rb

Constant Summary

Constants inherited from Base

Base::THUMBPRINT_DIGEST

Instance Method Summary collapse

Methods inherited from Base

#jws, #jws_header, #thumbprint, #to_h, #to_json

Constructor Details

#initialize(key) ⇒ HMAC

Instantiate a new HMAC JWS.

key - A string.

Returns nothing.



9
10
11
# File 'lib/acme/client/jwk/hmac.rb', line 9

def initialize(key)
  @key = key
end

Instance Method Details

#jwa_algObject

The name of the algorithm as needed for the ‘alg` member of a JWS object.

Returns a String.



25
26
27
28
29
# File 'lib/acme/client/jwk/hmac.rb', line 25

def jwa_alg
  # https://tools.ietf.org/html/rfc7518#section-3.1
  # HMAC using SHA-256
  'HS256'
end

#sign(message) ⇒ Object

Sign a message with the private key.

message - A String message to sign.

Returns a String signature.



18
19
20
# File 'lib/acme/client/jwk/hmac.rb', line 18

def sign(message)
  OpenSSL::HMAC.digest('SHA256', @key, message)
end