JWE decoding

80 views
Skip to first unread message

Jeffrey Ramsay

unread,
Nov 25, 2020, 12:12:52 PM11/25/20
to CAS Community
All -

I am hoping someone can point me in the right direction. I am trying to extract the claims from a CAS JWE token and I am not sure what I should pass to the  AESDecrypter for the key; "X" as shown below.  I tried using the json web key and that failed as well.

     final String jwkJson = "{\"kty\":\"oct\",\"k\":\"" + encryptionKey + "\"}";
     final JsonWebKey jwk = JsonWebKey.Factory.newJwk(jwkJson);

Decode.java:136: error: no suitable constructor found for AESDecrypter(Key)
JWEDecrypter decrypter = new AESDecrypter(jwk.getKey());
                         ^
    constructor AESDecrypter.AESDecrypter(SecretKey) is not applicable
      (argument mismatch; Key cannot be converted to SecretKey)
    constructor AESDecrypter.AESDecrypter(byte[]) is not applicable
      (argument mismatch; Key cannot be converted to byte[])
    constructor AESDecrypter.AESDecrypter(OctetSequenceKey) is not applicable
      (argument mismatch; Key cannot be converted to OctetSequenceKey)
    constructor AESDecrypter.AESDecrypter(SecretKey,Set<String>) is not applicable
      (actual and formal argument lists differ in length)

-----------------------


JsonWebEncryption{"zip":"DEF","alg":"dir","enc":"A256GCM","cty":"JWT","typ":"JWT"}->eyJ6aXAiOiJERUYiLCJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiY3R5IjoiSldUIiwidHlwIjoiSldUIn0..lnPt05aWOWOPxUqF.BbAS52yWx3M4PQ-a8RdMzwuVsZpHxb485XlmfvxeCfT-nw.CSkY_sNu9SQQcX_oJR32L
JWE encoded token: eyJ6aXAiOiJERUYiLCJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiY3R5IjoiSldUIiwidHlwIjoiSldUIn0..lnPt05aWOWOPxUqF.BbAS52yWx3M4PQ-a8RdMzwuVsZpHxb485XlmfvxeCfT-nw.CSkY_sNu9SQQcX_oJR32L
Header: {"zip":"DEF","cty":"JWT","typ":"JWT","enc":"A256GCM","alg":"dir"}
Algorithm: dir
Encryption: A256GCM
JWE initialization vector (BASE64URL) length: 11
ffffff96 73 ffffffed ffffffd3 ffffff96 ffffff96 39 63 ffffff8f ffffffc5 4a ffffff85
JWE Ciphertext (BASE64URL) length: 33
5 ffffffb0 12 ffffffe7 6c ffffff96 ffffffc7 73 38 3d 6 ffffffbc 45 ffffffd3 33 ffffffc2 ffffffe5 6c 66 ffffff91 fffffff1 6f ffffff8f 39 5e 59 ffffff9f ffffffbf 17 ffffff82 7d 39 fffffff0
JWE Authentication Tag (BASE64URL) length: 14
9 29 18 ffffffb0 ffffffdb ffffffbd 49 4 1c 5e ffffff82 51 0 0 0 
===========
What value is used for 'X' in: JWEDecrypter decrypter = new AESDecrypter(X)

-Jeff
Reply all
Reply to author
Forward
0 new messages