Skip to content

Commit

Permalink
TKSS-486: SM2KeyPairGenerator::initialize should not raise NullPointe…
Browse files Browse the repository at this point in the history
…rException
  • Loading branch information
johnshajiang committed Oct 21, 2023
1 parent 832def5 commit 3327592
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void initialize(int keySize, SecureRandom random) {

@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random) {
if (!(params instanceof SM2ParameterSpec)
if (params == null || !(params instanceof SM2ParameterSpec)
&& !KnownOIDs.curveSM2.value().equals(
((NamedCurve) params).getObjectId())) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testInitialize() throws Exception {
keyPairGen.initialize(SM2ParameterSpec.instance());
Assertions.assertThrows(IllegalArgumentException.class,
() -> keyPairGen.initialize(CurveDB.P_256));
Assertions.assertThrows(NullPointerException.class,
Assertions.assertThrows(IllegalArgumentException.class,
() -> keyPairGen.initialize(null));
}

Expand Down

0 comments on commit 3327592

Please sign in to comment.