I've been hitting a few roadblocks in my attempt to generate an HS256 jwt using SQLRPGLE.
I wanted to make sure i'm not missing anything, and before I post any code, I wanted to make sure I am thinking about this correctly, from an RPG perspective. It is important to preface, by default, my jobs run in CCSID(37). If this needs to change, let me know.
Here's my flow:
build & store json header string in ebcdic format
convert json header string to ascii
build & store payload string in ebcdic format
convert json payload string to ascii
get & store secret key in ebcdic format
convert secret key string to ascii
build & store base64 encoded ascii header string and remove trailing = symbols (url encoded)
build & store base64 encoded ascii payload string and remove trailing = symbols (url encoded)
build & store a string as follows: base64_url_encoded_header_ascii + '.' + base64_url_encoded_payload_ascii
execute Qc3CalculateHMAC() using the ascii secret key as the salt and the base64_url_encoded string to be hashed
convert the response from binary to ascii <-- how do you do this??
build & store signature string in ascii using the HMAC ascii value
build & store base64 encoded ascii signature string using the HMAC ascii value
build & store jwt using: base64_encoded_header_ascii + '.' + base64_encoded_payload_ascii + '.' + base64_encoded_signature_ascii
If this looks correct, the part i'm struggling with is how to get the binary response from the HMAC() api into an ascii RPG variable so that i can base64 encode it?
I wanted to make sure i'm not missing anything, and before I post any code, I wanted to make sure I am thinking about this correctly, from an RPG perspective. It is important to preface, by default, my jobs run in CCSID(37). If this needs to change, let me know.
Here's my flow:
build & store json header string in ebcdic format
convert json header string to ascii
build & store payload string in ebcdic format
convert json payload string to ascii
get & store secret key in ebcdic format
convert secret key string to ascii
build & store base64 encoded ascii header string and remove trailing = symbols (url encoded)
build & store base64 encoded ascii payload string and remove trailing = symbols (url encoded)
build & store a string as follows: base64_url_encoded_header_ascii + '.' + base64_url_encoded_payload_ascii
execute Qc3CalculateHMAC() using the ascii secret key as the salt and the base64_url_encoded string to be hashed
convert the response from binary to ascii <-- how do you do this??
build & store signature string in ascii using the HMAC ascii value
build & store base64 encoded ascii signature string using the HMAC ascii value
build & store jwt using: base64_encoded_header_ascii + '.' + base64_encoded_payload_ascii + '.' + base64_encoded_signature_ascii
If this looks correct, the part i'm struggling with is how to get the binary response from the HMAC() api into an ascii RPG variable so that i can base64 encode it?
Comment