class Acme::Client::JWK::HMAC

Public Class Methods

new(key) click to toggle source

Instantiate a new HMAC JWS.

key - A string.

Returns nothing.

# File lib/acme/client/jwk/hmac.rb, line 9
def initialize(key)
  @key = key
end

Public Instance Methods

jwa_alg() click to toggle source

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

Returns a String.

# 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) click to toggle source

Sign a message with the private key.

message - A String message to sign.

Returns a String signature.

# File lib/acme/client/jwk/hmac.rb, line 18
def sign(message)
  OpenSSL::HMAC.digest('SHA256', @key, message)
end