title: jose4j, decrypt JWE with symmetric key
body: <p>I'm trying to reproduce a decoding of a JWE starting from <a href="https://jwt.io" rel="nofollow noreferrer">jwt.io</a> as an example and translating into code by using library <a href="https://bitbucket.org/b_c/jose4j/wiki/Home" rel="nofollow noreferrer">jose4j</a></p>
  <p>From site jwt.io I have the following:</p>
  <p>HEADER:</p>
  <pre><code>{
     &quot;alg&quot;: &quot;HS256&quot;
  }
  </code></pre>
  <p>PAYLOAD:</p>
  <pre><code>{
      &quot;sub&quot;: &quot;1234567890&quot;,
      &quot;name&quot;: &quot;John Doe&quot;,
      &quot;iat&quot;: 1516239022
  }
  </code></pre>
  <p>VERIFY SIGNATURE:</p>
  <pre><code>HMACSHA256(
      base64UrlEncode(header) + &quot;.&quot; +
      base64UrlEncode(payload),
      Fdh9u8rINxfivbrianbbVT1u232VQBZYKx1HGAGPt2I
  ) 
  </code></pre>
  <p>the secret base64 is not encoded.</p>
  <p>Now I try to reproduce the situation with jose4j and then having as a result the same value on the encoded field, which is:</p>
  <pre><code>eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.jOJ7G4oijaDk9Tr4ntAXczd6PlI4oVvBU0_5cf7oaz4
  </code></pre>
  <p>Then:</p>
  <pre><code>    Key key = new HmacKey(&quot;Fdh9u8rINxfivbrianbbVT1u232VQBZYKx1HGAGPt2I&quot;.getBytes(StandardCharsets.UTF_8));  
      JsonWebEncryption jwe = new JsonWebEncryption();
      String payload = Json.createObjectBuilder()
              .add(&quot;sub&quot;, &quot;1234567890&quot;)
              .add(&quot;name&quot;, &quot;John Doe&quot;)
              .add(&quot;iat&quot;, &quot;1516239022&quot;)
              .build()
              .toString();
      jwe.setPayload(payload);
      jwe.setHeader(&quot;alg&quot;, &quot;HS256&quot;);
      jwe.setKey(key);
      String serializedJwe = jwe.getCompactSerialization();
      System.out.println(&quot;Serialized Encrypted JWE: &quot; + serializedJwe);
  </code></pre>
  <p>However I get this error:</p>
  <blockquote>
  <p>org.jose4j.lang.InvalidAlgorithmException: HS256 is an unknown, unsupported or unavailable alg algorithm (not one of [RSA1_5, RSA-OAEP, RSA-OAEP-256, dir, A128KW, A192KW, A256KW, ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW, PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW, A128GCMKW, A192GCMKW, A256GCMKW]).</p>
  </blockquote>