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

Cannot use JWK::parseKey for kty=='oct' #555

Open
juacala opened this issue Jan 12, 2024 · 4 comments
Open

Cannot use JWK::parseKey for kty=='oct' #555

juacala opened this issue Jan 12, 2024 · 4 comments

Comments

@juacala
Copy link

juacala commented Jan 12, 2024

The following code does not work:

$keyInfo = [ 
        "kty" => "oct",
        "kid" => "unitTestJWKHMAC",
        "alg" => "HS256",
        "k"   => "SecretKey",
    ]
$jwk = \Firebase\JWT\JWK::parseKey($keyInfo);

Is there an intention to support this?

@yash30201
Copy link
Collaborator

yash30201 commented Jan 17, 2024

Hi @juacala , thanks for opening this issue.
We are aware of this feature request of supporting octet sequence algorithm but it hasn't been on priority as of now and we cannot comment on when this will be supported. If you'd like to submit a feature PR for this, please do so, as that would be a huge help to us!

@juacala
Copy link
Author

juacala commented Jan 22, 2024

@yash30201 I'll circle back to this when I get some bandwidth. I didn't have a development branch checked out, but this addition to JWT::parseKey seemed to do the trick:

            case 'oct':
                    return new Key(JWT::urlsafeB64Decode($jwk['k']), $jwk['alg']);

@bshaffer
Copy link
Collaborator

bshaffer commented Jan 22, 2024

@juacala thank you for your suggestion. I'd like to do better than "seems to do the trick" if we add this to this library, however.

Can you provide us with more information about your use-case? a sample key that we could use for testing would also be great.

I've found some information on using the octet keys in the JWK IETF spec and this jwk generation guide

@juacala
Copy link
Author

juacala commented Jan 24, 2024

I understand. I should have been more direct in my language. Adding the above code will satisfy the appropriate spec. I tested it both encoding and decoding using your library, as well as using a Javascript library as another party. I'll do my best to find some time to get a PR to y'all for your testing.

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

No branches or pull requests

3 participants