-
Notifications
You must be signed in to change notification settings - Fork 1
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
PYIC-5099: Enable RSA signature validation #2001
Conversation
e7c6210
to
cda64b4
Compare
...uk/gov/di/ipv/core/library/verifiablecredential/validator/VerifiableCredentialValidator.java
Show resolved
Hide resolved
e5bd3db
to
b9d91d1
Compare
...uk/gov/di/ipv/core/library/verifiablecredential/validator/VerifiableCredentialValidator.java
Outdated
Show resolved
Hide resolved
...common-services/src/main/java/uk/gov/di/ipv/core/library/exceptions/EncryptionAlgorithm.java
Outdated
Show resolved
Hide resolved
libs/cimit-service/src/test/java/uk/gov/di/ipv/core/library/service/CiMitServiceTest.java
Show resolved
Hide resolved
throws ParseException, JOSEException { | ||
return switch (signingAlgorithm) { | ||
case EC -> new ECDSAVerifier(ECKey.parse(signingKey)); | ||
case RSA -> new RSASSAVerifier(RSAKey.parse(signingKey)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Digging a bit further into our libraries, it looks like you might be able to do this completely automatically.
Have a look at DefaultJWSVerifierFactory.createJWSVerifier()
and JWK.parse()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw JWK.parse, and am now updating to use the key to determine the algorithm. Will also look at createJWSVerifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to play around with createJWSVerifier but it feels like it may not be as much of a simplification as wanted compared to the new version of the getVerifier method.
var signingKeyJws = JWSObject.parse(signingKey);
var keyFactory = KeyFactory.getInstance(signingKeyJws.getHeader().getAlgorithm().toString());
keyFactory.generatePublic(new PKCS8EncodedKeySpec(signingKey.getBytes())
);
new DefaultJWSVerifierFactory().createJWSVerifier(signingKeyJws.getHeader(), Key);
var formattedVc = EC.equals(signingKeyJws.getHeader().getAlgorithm()) ? transcodeSignatureIfDerFormat(vc) : vc;
9a83c92
to
5e5446c
Compare
5e5446c
to
7d08f34
Compare
libs/common-services/src/test/java/uk/gov/di/ipv/core/library/fixtures/TestFixtures.java
Outdated
Show resolved
Hide resolved
...uk/gov/di/ipv/core/library/verifiablecredential/validator/VerifiableCredentialValidator.java
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
Proposed changes
What changed
Why did it change
Issue tracking
Remaining to do: