Header is automatically included as AAD for JWE content encryption algorithm

Issue #127 closed
Lauris Liparts created an issue

I need to communicate with server which expects AAD to be empty. Library automatically uses header as AAD but afaik it should be possible to use empty AAD: https://bitbucket.org/b_c/jose4j/src/7f9624414a1baf752adbc61d4a1be16253eeec23/src/main/java/org/jose4j/jwe/JsonWebEncryption.java#lines-271 Also I didn't find any evidence in JWE specification that AAD is mandatory and you need to use header for that always.

Comments (4)

  1. Brian Campbell

    In the JWE Compact Serialization, which is all this library supports, the header is always protected and thus always included in the AAD.

    The JWE spec can be a little hard to follow but some relevant parts follow.

    from https://tools.ietf.org/html/rfc7516#section-2

       JWE Protected Header
          JSON object that contains the Header Parameters that are integrity
          protected by the authenticated encryption operation.  These
          parameters apply to all recipients of the JWE.  For the JWE
          Compact Serialization, this comprises the entire JOSE Header.
    

    from https://tools.ietf.org/html/rfc7516#section-5.1

       13.  Compute the Encoded Protected Header value BASE64URL(UTF8(JWE
            Protected Header)).  If the JWE Protected Header is not present
            (which can only happen when using the JWE JSON Serialization and
            no "protected" member is present), let this value be the empty
            string.
    
       14.  Let the Additional Authenticated Data encryption parameter be
            ASCII(Encoded Protected Header).  However, if a JWE AAD value is
            present (which can only be the case when using the JWE JSON
            Serialization), instead let the Additional Authenticated Data
            encryption parameter be ASCII(Encoded Protected Header || '.' ||
            BASE64URL(JWE AAD)).
    
  2. Log in to comment