Skip to content

Commit

Permalink
added support for composite private keys nested in OCTET STRING
Browse files Browse the repository at this point in the history
minor refactor - removed use of toUpperCase() in BCMLDSAPrivateKey
  • Loading branch information
dghgit committed Dec 27, 2024
1 parent f9ab990 commit 6c5bcfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Map;

import org.bouncycastle.asn1.ASN1BitString;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
Expand Down Expand Up @@ -192,7 +193,15 @@ public PrivateKey generatePrivate(PrivateKeyInfo keyInfo)
// TODO: backwards compatibility code - should be deleted after 1.84.
try
{
seq = DERSequence.getInstance(keyInfo.parsePrivateKey());
ASN1Encodable obj = keyInfo.parsePrivateKey();
if (obj instanceof ASN1OctetString)
{
seq = DERSequence.getInstance(ASN1OctetString.getInstance(obj).getOctets());
}
else
{
seq = DERSequence.getInstance(obj);
}
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void init(MLDSAPrivateKeyParameters params, ASN1Set attributes)
{
this.attributes = attributes;
this.params = params;
algorithm = MLDSAParameterSpec.fromName(params.getParameters().getName()).getName().toUpperCase();
algorithm = Strings.toUpperCase(MLDSAParameterSpec.fromName(params.getParameters().getName()).getName());
}

/**
Expand Down

0 comments on commit 6c5bcfb

Please sign in to comment.