php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68366 Does not use certificate's signing algorithm
Submitted: 2014-11-06 16:24 UTC Modified: 2021-12-17 11:32 UTC
From: jean-luc dot cooke at trustificorp dot com Assigned: bukka (profile)
Status: Assigned Package: OpenSSL related
PHP Version: 5.4.34 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jean-luc dot cooke at trustificorp dot com
New email:
PHP Version: OS:

 

 [2014-11-06 16:24 UTC] jean-luc dot cooke at trustificorp dot com
Description:
------------
---
From manual page: http://www.php.net/function.openssl-pkcs7-sign
---

Most certs are being issued with sha256WithRSAEncryption but the php openssl_pkcs7_sign() function always uses sha1WithRSAEncryption.  At a minimum there should be a way to specify the signing algorithm with an optional parameter like openssl_sign() does.

Test script:
---------------
                $ret = openssl_pkcs7_sign(
                        $fileTmp,
                        $fileSigned,
                        $signInfo['cert'],
                        array($signInfo['key'], $signInfo['keypass']),
                        $signHeaders,
                        PKCS7_DETACHED,
                        $signInfo['extracerts']
                );

Expected result:
----------------
After extracting smime.p7s from "$fileSigned" in the Test Script, check to see how it was signed using the command-line:

 openssl asn1parse -inform pem -in smime.p7s -dump -i | less -S

Look for ":messageDigest".  You'll see it's 20 bytes long (160bits which is SHA-1).  Plus you'll see a few lines above ":messageDigest" mention of ":sha1".

Actual result:
--------------
After extracting smime.p7s from "$fileSigned" in the Test Script, check to see how it was signed using the command-line:

 openssl asn1parse -inform pem -in smime.p7s -dump -i | less -S

Look for ":messageDigest".  You SHOULD see it's 32 bytes long (160bits which is SHA-256).  Plus you SHOULD see a few lines above ":messageDigest" mention of ":sha256".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-30 22:04 UTC] stas@php.net
-Assigned To: +Assigned To: bukka
 [2021-12-16 21:27 UTC] bukka@php.net
-Type: Security +Type: Feature/Change Request
 [2021-12-16 21:27 UTC] bukka@php.net
This is not a bug as it is just using the same default as OpenSSL ( see notes in https://www.openssl.org/docs/man1.1.1/man3/PKCS7_sign.html ). We could however add a way to overwrite it.
 [2021-12-16 21:28 UTC] bukka@php.net
What I mean is basically to add a parameter that would make use of PKCS7_add_signature
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 11:01:31 2025 UTC