Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{"Illegal base64url string! (Parameter 'input')"} #196

Open
Jesterbester2 opened this issue Jul 25, 2022 · 5 comments
Open

{"Illegal base64url string! (Parameter 'input')"} #196

Jesterbester2 opened this issue Jul 25, 2022 · 5 comments

Comments

@Jesterbester2
Copy link

So I'm trying to decrypt a jwe token, with an algorithm of RSA-OAEP, and encryption of A128CBC-HS256

I'm RSA to make a JWK object.
then I trying the code below:
rsa.FromXmlString( // PRIVATE XML STRING KEY );
var jwk= new Jwk(rsa);
JwtSettings settings = new JwtSettings();
settings.Jws(JwsAlgorithm.HS256);
settings.Jwa(JweAlgorithm.RSA_OAEP);
settings.Jwe(JweEncryption.A128CBC_HS256);
var jwe = Jose.JWE.Decrypt(token, jwk, JweAlgorithm.RSA_OAEP, JweEncryption.A128CBC_HS256, settings);

And everytime I try get an exception: {"Illegal base64url string! (Parameter 'input')"}

Below is an example of my token string, is there something I should be doing differently?

eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhDQkMtSFMyNTYiLCJraWQiOiJwMTgifQ.JpnQn7b-XJ2E6aBbBI_uF4JBQR7CSZjE8a-xQBwhouM-jUCDP4IjDAM_TtOFqx1NF4etUTJ2aiZC-lB5XqI6Kbe2Alo8NXB16V5OmYj0kJrCL9x6yRFYI9LNsVxhPbV5a-AMdXPaeGaM0-_SRuvT8rtTR8AAsZP9f033jjR4g.ECocleCj4xSGc55bJ54fnw.1X9vLA7NQfOrOh6JZHAPjSSClsZx5kr22-bkcBp5WMzR_9oJesOoIQz7qDI5_75KVkpypbOrWcvFwUy9nQ23aSnPvhOcDNZEPyohOMf0A-28EQ87vNdXY4u5qbeLgMh5FHFkqFdKOoIFTkhnVaDg177thw5ZQ9iTJ0-Ar0j26ZCrerfgcA0OlSlBgWtEPD6QURCBgPMKWE4hAMGR2kyULg3k9FUueugp8BzJUnO2wDiTOpbXThRCFb5aOpjoXw4xf9OYlbuedHkZwYVdbdBC3w.4ZaZxKr-X4TA5ZKsmq2be7m7qCA6482VncSOL7LoVKw

@dvsekhvalnov
Copy link
Owner

Hi @Jesterbester2 ,

it doesn't look like your token is JWE? Jose.JWE.Decrypt() handles RFC 7516 json encoded tokens.

Can you try with Jose.JWT.Decode(token, jwk) instead?

@Jesterbester2
Copy link
Author

I have tried both of them and neither work, also from my understanding jwt & Jwe. Jwts are seperated by two periods and JWEs are seperated by 4 periods the token above has 4, and I know for a fact the it was encrypted when it was originally made using JWtauthprovider.
So any help would be great i know in the code it is failing here
https://github.com/dvsekhvalnov/jose-jwt/blob/master/jose-jwt/util/Base64Url.cs
What does this mean?

@Jesterbester2
Copy link
Author

@dvsekhvalnov dvsekhvalnov

By the way in case I didn't make it clear I'm trying to get the payload from the token?

@dvsekhvalnov
Copy link
Owner

Hi @Jesterbester2 , can you attach your key if possible, so i can run decoding myself?

Hard to guess without trying.

@dvsekhvalnov
Copy link
Owner

Hey, so i dig around, it seems 2nd part of token is incorrectly base64url encoded, it has wrong padding

JpnQn7b-XJ2E6aBbBI_uF4JBQR7CSZjE8a-xQBwhouM-jUCDP4IjDAM_TtOFqx1NF4etUTJ2aiZC-lB5XqI6Kbe2Alo8NXB16V5OmYj0kJrCL9x6yRFYI9LNsVxhPbV5a-AMdXPaeGaM0-_SRuvT8rtTR8AAsZP9f033jjR4g

you can check it yourself too at https://toolsaday.com/encode-decode/base64Url-decode for instance.

@Jesterbester2 where did you get this token from? What library generated it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants