Skip to content

Commit

Permalink
Enable "NONEwithRSA" signatures with this mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
oh2mqk committed Mar 29, 2019
1 parent 38fe11e commit 7d44668
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class RSADigestSigner
*/
static
{
// Null-digester is intentionally NOT on this mapping.

oidMap.put("RIPEMD128", TeleTrusTObjectIdentifiers.ripemd128);
oidMap.put("RIPEMD160", TeleTrusTObjectIdentifiers.ripemd160);
oidMap.put("RIPEMD256", TeleTrusTObjectIdentifiers.ripemd256);
Expand Down Expand Up @@ -72,7 +74,12 @@ public RSADigestSigner(
ASN1ObjectIdentifier digestOid)
{
this.digest = digest;
this.algId = new AlgorithmIdentifier(digestOid, DERNull.INSTANCE);
if (digestOid != null) {
this.algId = new AlgorithmIdentifier(digestOid, DERNull.INSTANCE);
} else {
// NULL digester, match behaviour with DigestSignatureSpi
this.algId = null;
}
}

/**
Expand All @@ -84,7 +91,7 @@ public String getAlgorithmName()
}

/**
* initialise the signer for signing or verification.
* Initialize the signer for signing or verification.
*
* @param forSigning
* true if for signing, false otherwise
Expand Down Expand Up @@ -240,6 +247,10 @@ private byte[] derEncode(
byte[] hash)
throws IOException
{
if (algId == null) {
return hash;
}

DigestInfo dInfo = new DigestInfo(algId, hash);

return dInfo.getEncoded(ASN1Encoding.DER);
Expand Down

0 comments on commit 7d44668

Please sign in to comment.