Skip to content

Commit

Permalink
Add PK11RSAPrivateKey.getParams()
Browse files Browse the repository at this point in the history
The PK11RSAPrivateKey.getParams() has been added based on the
same method in PK11ECPrivateKey to resolve build issue with
Java 22.
  • Loading branch information
edewata committed Jul 9, 2024
1 parent e3a059a commit f04ef49
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions base/src/main/java/org/mozilla/jss/pkcs11/PK11RSAPrivateKey.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mozilla.jss.pkcs11;

import java.math.BigInteger;
import java.security.spec.AlgorithmParameterSpec;

import org.mozilla.jss.crypto.PrivateKey;
import org.slf4j.Logger;
Expand All @@ -24,6 +25,17 @@ public PrivateKey.Type getType() {
return PrivateKey.Type.RSA;
}

@Override
public AlgorithmParameterSpec getParams() {
PK11PubKey publicKey = getPublicKey();
if (!(publicKey instanceof PK11RSAPublicKey)) {
throw new RuntimeException("Unknown key type: expected the public key of an RSA key to be an PK11RSAPublicKey; got: " + publicKey);
}

PK11RSAPublicKey rsaPublicKey = (PK11RSAPublicKey)publicKey;
return rsaPublicKey.getParams();
}

@Override
public BigInteger getModulus() {
logger.debug("PK11RSAPrivateKey: getModulus()");
Expand Down

0 comments on commit f04ef49

Please sign in to comment.