-
Notifications
You must be signed in to change notification settings - Fork 20
Add Check for PQCPrivateKey in Decapsulator and add tests. #1042
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
base: main
Are you sure you want to change the base?
Conversation
jasonkatonica
left a comment
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.
Some tests are also failing with the following unused variables:
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/base/BaseTestKEM.java:190:16: Unused local variable 'encr'. [UnusedLocalVariable]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/base/BaseTestKEM.java:197:16: Unused local variable 'decr'. [UnusedLocalVariable]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/base/BaseTestKEM.java:208:16: Unused local variable 'encr'. [UnusedLocalVariable]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/base/BaseTestKEM.java:215:16: Unused local variable 'decr'. [UnusedLocalVariable]
src/test/java/ibm/jceplus/junit/base/BaseTestPQCKeyInterop.java
Outdated
Show resolved
Hide resolved
src/test/java/ibm/jceplus/junit/base/BaseTestPQCKeyInterop.java
Outdated
Show resolved
Hide resolved
e85ad9f to
990a310
Compare
jasonkatonica
left a comment
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.
LGTM
|
|
||
| PublicKey pubKey = publicKey; | ||
| if (pubKey == null) { | ||
| throw new InvalidKeyException("unsupported key"); |
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.
Should we change the exception message here, since in this case the key is missing rather than being unsupported?
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.
Updated
| PrivateKey privKey = privateKey; | ||
|
|
||
| if (privKey == null) { | ||
| throw new InvalidKeyException("unsupported key"); |
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.
Same comment as above.
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.
Updated
| // Test null keys | ||
| PublicKey pub = null; | ||
| PrivateKey priv = null; | ||
|
|
||
| try { | ||
| kem.newEncapsulator(pub); | ||
| fail("testKEMKeys failed - NULL Public key did not cause an Invalid Key Excepton."); | ||
| } catch (InvalidKeyException ike) { | ||
| assertTrue(ike.getMessage().equals("unsupported key")); | ||
| } | ||
|
|
||
| try { | ||
| kem.newDecapsulator(priv); | ||
| fail("testKEMKeys failed - NULL Private key did not cause an Invalid Key Excepton."); | ||
| } catch (InvalidKeyException ike) { | ||
| assertTrue(ike.getMessage().equals("unsupported key")); | ||
| } |
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.
Would it make sense to separate this into another test method?
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.
It is doing testing of the keys and we really expect the same Exception. So, I don't thing it needs to be broken up.
… keys. Signed-off-by: John Peck <[email protected]>
f455242 to
ccf3001
Compare
Add Check for PQCPrivateKey in Decapsulator and add tests for invalid keys.
Signed-off-by: John Peck [email protected]