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

New Operations: JWK conversion from/to PEM #1277

Merged
merged 1 commit into from
Apr 13, 2024
Merged

Conversation

cplussharp
Copy link
Contributor

Transforms a key in PEM format to a JSON Web key or
a JWK back to its PEM format

@cplussharp
Copy link
Contributor Author

Updated to current sources, added some more tests and fixed some conversion problems

@cplussharp
Copy link
Contributor Author

cplussharp commented Oct 6, 2023

Rebased to the current sources. Looks like there is something wrong with the UI tests:

An error occurred while creating a new ChromeDriver session: [SessionNotCreatedError] session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 117.0.5938.132 with binary path /usr/bin/google-chrome

@cplussharp
Copy link
Contributor Author

Rebased to the current master sources. This fixes #1794

if (Array.isArray(inputJson)) {
// list of keys => transform all keys
keys = inputJson;
} else if (Array.isArray(inputJson.keys)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a variety of examples / documentation also uses jwk as a paramater to store an array of keys, e.g:

{"jwk":
  [
    {"alg":"EC",
     "crv":"P-256",
     "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
     "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
     "use":"enc",
     "kid":"1"},

    {"alg":"RSA",
     "mod": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx
4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMs
tn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2
QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbI
SD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqb
w0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw",
     "exp":"AQAB",
     "kid":"2011-04-29"}
  ]
}

Might be a nice addition. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the RFC ( https://datatracker.ietf.org/doc/html/rfc7517#section-5 ) it is "keys". So it should hopefully match most use cases.

@a3957273
Copy link
Member

Tried it out with a few JWKs and a few PEMs. This is a nice implementation! Thanks so much for the contribution, apologies it's taken three years to merge this in.

@a3957273 a3957273 merged commit 67195f6 into gchq:master Apr 13, 2024
4 checks passed
Copy link
Contributor Author

@cplussharp cplussharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the merge

if (Array.isArray(inputJson)) {
// list of keys => transform all keys
keys = inputJson;
} else if (Array.isArray(inputJson.keys)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the RFC ( https://datatracker.ietf.org/doc/html/rfc7517#section-5 ) it is "keys". So it should hopefully match most use cases.

@cplussharp cplussharp deleted the jwk branch April 14, 2024 09:05
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

Successfully merging this pull request may close these issues.

2 participants