class JSON::JWE

def jwe_encrypted_key

def jwe_encrypted_key
  @jwe_encrypted_key ||= case alg&.to_sym
  when :RSA1_5
    public_key_or_secret.public_encrypt content_encryption_key
  when :'RSA-OAEP'
    public_key_or_secret.public_encrypt content_encryption_key, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING
  when :A128KW, :A256KW
    AESKeyWrap.wrap content_encryption_key, public_key_or_secret
  when :dir
    ''
  when :'ECDH-ES'
    raise NotImplementedError.new('ECDH-ES not supported yet')
  when :'ECDH-ES+A128KW'
    raise NotImplementedError.new('ECDH-ES+A128KW not supported yet')
  when :'ECDH-ES+A256KW'
    raise NotImplementedError.new('ECDH-ES+A256KW not supported yet')
  else
    raise UnexpectedAlgorithm.new('Unknown Encryption Algorithm')
  end
end