Blame SOURCES/jss-SignatureAlgorithm.patch

c89ed9
# HG changeset patch
c89ed9
# User David Stutzman david.konrad.stutzman@us.army.mil
c89ed9
# Date 1509062346 25200
c89ed9
#      Thu Oct 26 16:59:06 2017 -0700
c89ed9
# Node ID b1a3c3cc6b3584948d251d3bfcfe6630d8970db5
c89ed9
# Parent  252c10f448971b7ae087bde259505abd5dc5a03a
c89ed9
Bugzilla.mozilla 1409867 org.mozilla.jss.pkix.cms.SignerInfo incorrectly producing signatures (especially for EC)
c89ed9
c89ed9
The patch fixes the OID that goes into the signatureAlgorithm field as well as passing the full signature algorithm to the Signature context to generate the signature using the proper algorithm.
c89ed9
With this patch, if one passes SignatureAlgorithm.RSASignatureWithSHA256Digest in the constructor one will now get sha256WithRSAEncryption (1 2 840 113549 1 1 11) in the signatureAlgorithm field.
c89ed9
c89ed9
cfu checking in for dstutzman
c89ed9
c89ed9
diff --git a/org/mozilla/jss/pkix/cms/SignerInfo.java b/org/mozilla/jss/pkix/cms/SignerInfo.java
c89ed9
--- a/org/mozilla/jss/pkix/cms/SignerInfo.java
c89ed9
+++ b/org/mozilla/jss/pkix/cms/SignerInfo.java
c89ed9
@@ -289,7 +289,7 @@
c89ed9
         }
c89ed9
 
c89ed9
         digestEncryptionAlgorithm = new AlgorithmIdentifier(
c89ed9
-            signingAlg.getRawAlg().toOID(),null );
c89ed9
+            signingAlg.toOID(),null );
c89ed9
 
c89ed9
 
c89ed9
         if( signedAttributes != null ) 
c89ed9
@@ -332,7 +332,7 @@
c89ed9
         // encrypt the DER-encoded DigestInfo with the private key
c89ed9
         CryptoToken token = signingKey.getOwningToken();
c89ed9
         Signature sig;
c89ed9
-        sig = token.getSignatureContext( signingAlg.getRawAlg() );
c89ed9
+        sig = token.getSignatureContext( signingAlg );
c89ed9
         sig.initSign(signingKey);
c89ed9
         sig.update(toBeSigned);
c89ed9
         encryptedDigest = new OCTET_STRING(sig.sign());