Skip to content

Commit 6c5bcfb

Browse files
committed
added support for composite private keys nested in OCTET STRING
minor refactor - removed use of toUpperCase() in BCMLDSAPrivateKey
1 parent f9ab990 commit 6c5bcfb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/compositesignatures/KeyFactorySpi.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Map;
1919

2020
import org.bouncycastle.asn1.ASN1BitString;
21+
import org.bouncycastle.asn1.ASN1Encodable;
2122
import org.bouncycastle.asn1.ASN1EncodableVector;
2223
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
2324
import org.bouncycastle.asn1.ASN1OctetString;
@@ -192,7 +193,15 @@ public PrivateKey generatePrivate(PrivateKeyInfo keyInfo)
192193
// TODO: backwards compatibility code - should be deleted after 1.84.
193194
try
194195
{
195-
seq = DERSequence.getInstance(keyInfo.parsePrivateKey());
196+
ASN1Encodable obj = keyInfo.parsePrivateKey();
197+
if (obj instanceof ASN1OctetString)
198+
{
199+
seq = DERSequence.getInstance(ASN1OctetString.getInstance(obj).getOctets());
200+
}
201+
else
202+
{
203+
seq = DERSequence.getInstance(obj);
204+
}
196205
}
197206
catch (Exception e)
198207
{

prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/mldsa/BCMLDSAPrivateKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private void init(MLDSAPrivateKeyParameters params, ASN1Set attributes)
5151
{
5252
this.attributes = attributes;
5353
this.params = params;
54-
algorithm = MLDSAParameterSpec.fromName(params.getParameters().getName()).getName().toUpperCase();
54+
algorithm = Strings.toUpperCase(MLDSAParameterSpec.fromName(params.getParameters().getName()).getName());
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)