Blame SOURCES/jss-SignatureAlgorithm.patch

a7067b
# HG changeset patch
a7067b
# User David Stutzman david.konrad.stutzman@us.army.mil
a7067b
# Date 1509062346 25200
a7067b
#      Thu Oct 26 16:59:06 2017 -0700
a7067b
# Node ID b1a3c3cc6b3584948d251d3bfcfe6630d8970db5
a7067b
# Parent  252c10f448971b7ae087bde259505abd5dc5a03a
a7067b
Bugzilla.mozilla 1409867 org.mozilla.jss.pkix.cms.SignerInfo incorrectly producing signatures (especially for EC)
a7067b
a7067b
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.
a7067b
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.
a7067b
a7067b
cfu checking in for dstutzman
a7067b
a7067b
diff --git a/org/mozilla/jss/pkix/cms/SignerInfo.java b/org/mozilla/jss/pkix/cms/SignerInfo.java
a7067b
--- a/org/mozilla/jss/pkix/cms/SignerInfo.java
a7067b
+++ b/org/mozilla/jss/pkix/cms/SignerInfo.java
a7067b
@@ -289,7 +289,7 @@
a7067b
         }
a7067b
 
a7067b
         digestEncryptionAlgorithm = new AlgorithmIdentifier(
a7067b
-            signingAlg.getRawAlg().toOID(),null );
a7067b
+            signingAlg.toOID(),null );
a7067b
 
a7067b
 
a7067b
         if( signedAttributes != null ) 
a7067b
@@ -332,7 +332,7 @@
a7067b
         // encrypt the DER-encoded DigestInfo with the private key
a7067b
         CryptoToken token = signingKey.getOwningToken();
a7067b
         Signature sig;
a7067b
-        sig = token.getSignatureContext( signingAlg.getRawAlg() );
a7067b
+        sig = token.getSignatureContext( signingAlg );
a7067b
         sig.initSign(signingKey);
a7067b
         sig.update(toBeSigned);
a7067b
         encryptedDigest = new OCTET_STRING(sig.sign());