From 1fc2b7b6238da0875b3b67029d5d5d0bb54fbc87 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 9 Jul 2024 15:20:42 -0500 Subject: [PATCH] Add PK11RSAPrivateKey.getParams() The PK11RSAPrivateKey.getParams() has been added based on the same method in PK11ECPrivateKey to resolve build issue with Java 22. --- .../org/mozilla/jss/pkcs11/PK11RSAPrivateKey.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/base/src/main/java/org/mozilla/jss/pkcs11/PK11RSAPrivateKey.java b/base/src/main/java/org/mozilla/jss/pkcs11/PK11RSAPrivateKey.java index 3133e424d..bd01c6d39 100644 --- a/base/src/main/java/org/mozilla/jss/pkcs11/PK11RSAPrivateKey.java +++ b/base/src/main/java/org/mozilla/jss/pkcs11/PK11RSAPrivateKey.java @@ -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; @@ -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()");