Skip to content

Commit 774f590

Browse files
committed
Added AnnotatedPrivateKey check (relates to github #2200).
1 parent 942d04a commit 774f590

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/rsa/DigestSignatureSpi.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.bouncycastle.crypto.engines.RSABlindedEngine;
3333
import org.bouncycastle.crypto.util.DigestFactory;
3434
import org.bouncycastle.internal.asn1.oiw.OIWObjectIdentifiers;
35+
import org.bouncycastle.jcajce.util.AnnotatedPrivateKey;
3536
import org.bouncycastle.util.Arrays;
3637

3738
public class DigestSignatureSpi
@@ -81,6 +82,11 @@ protected void engineInitSign(
8182
PrivateKey privateKey)
8283
throws InvalidKeyException
8384
{
85+
if (privateKey instanceof AnnotatedPrivateKey)
86+
{
87+
privateKey = ((AnnotatedPrivateKey)privateKey).getKey();
88+
}
89+
8490
if (!(privateKey instanceof RSAPrivateKey))
8591
{
8692
throw new InvalidKeyException("Supplied key (" + getType(privateKey) + ") is not a RSAPrivateKey instance");

0 commit comments

Comments
 (0)