{"action":"opened","issue":{"url":"https://api.github.com/repos/funcool/buddy-core/issues/24","repository_url":"https://api.github.com/repos/funcool/buddy-core","labels_url":"https://api.github.com/repos/funcool/buddy-core/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/funcool/buddy-core/issues/24/comments","events_url":"https://api.github.com/repos/funcool/buddy-core/issues/24/events","html_url":"https://github.com/funcool/buddy-core/issues/24","id":146784745,"number":24,"title":"jwe auth token not compatible with other java libraries","user":{"login":"himangshuj","id":391484,"avatar_url":"https://avatars.githubusercontent.com/u/391484?v=3","gravatar_id":"","url":"https://api.github.com/users/himangshuj","html_url":"https://github.com/himangshuj","followers_url":"https://api.github.com/users/himangshuj/followers","following_url":"https://api.github.com/users/himangshuj/following{/other_user}","gists_url":"https://api.github.com/users/himangshuj/gists{/gist_id}","starred_url":"https://api.github.com/users/himangshuj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himangshuj/subscriptions","organizations_url":"https://api.github.com/users/himangshuj/orgs","repos_url":"https://api.github.com/users/himangshuj/repos","events_url":"https://api.github.com/users/himangshuj/events{/privacy}","received_events_url":"https://api.github.com/users/himangshuj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-08T01:14:05Z","updated_at":"2016-04-08T01:14:05Z","closed_at":null,"body":"I am trying out jwe with ```{:alg :rsa-oaep-256 :enc :a256cbc-hs512}```. It works only if the client and server both use buddy to perform encryption. But if I am using some other library, it does not. I tried with \r\nhttps://bitbucket.org/connect2id/nimbus-jose-jwt/wiki/Home and https://bitbucket.org/b_c/jose4j/wiki/Home. In both the cases, the cipher is fine, but the auth tag is not compatible. On the other hand, the token generated by jose4j works with nimbus-jose-jwt.\r\n\r\nOn digging further, the auth token generator seems to be culprit\r\n\r\nbuddy code \r\n```\r\n(defn- generate-authtag\r\n  [{:keys [algorithm input authkey iv aad] :as params}]\r\n  (let [al (if aad\r\n             (aad->bytes aad)\r\n             (byte-array 0))\r\n        data (bytes/concat aad iv input al)\r\n        fulltag (mac/hash data {:key authkey :alg :hmac :digest algorithm})\r\n        truncatesize (quot (count fulltag) 2)]\r\n    (bytes/slice fulltag 0 truncatesize)))\r\n```\r\n\r\nnimbus code\r\n```\r\n\tbyte[] al = AAD.computeLength(aad);\r\n\r\n\t\t// Do MAC\r\n\t\tint hmacInputLength = aad.length + iv.length + cipherText.length + al.length;\r\n\t\tbyte[] hmacInput = ByteBuffer.allocate(hmacInputLength).put(aad).put(iv).put(cipherText).put(al).array();\r\n\t\tbyte[] hmac = HMAC.compute(compositeKey.getMACKey(), hmacInput, macProvider);\r\n\t\tbyte[] authTag = Arrays.copyOf(hmac, compositeKey.getTruncatedMACByteLength());\r\n```\r\n\r\njose4j code\r\n```\r\nMac mac = MacUtil.getInitializedMac(this.getHmacJavaAlgorithm(), hmacKey, macProvider);\r\n        byte[] al = this.getAdditionalAuthenticatedDataLengthBytes(aad);\r\n        byte[] authenticationTagInput = ByteUtil.concat(new byte[][]{aad, iv, cipherText, al});\r\n        byte[] authenticationTag = mac.doFinal(authenticationTagInput);\r\n        authenticationTag = ByteUtil.subArray(authenticationTag, 0, this.getTagTruncationLength());\r\n```\r\n\r\n"}}