Tcl Library Source Code

View Ticket
Login
2020-02-19
08:11 • Ticket [f8e09da9dc] pki::verify return always false if algo (hash algorithm) argument is provided status still Closed with 3 other changes artifact: e5b8d213aa user: RP.
08:09 • Ticket [f8e09da9dc]: 3 changes artifact: e54cc1a455 user: RP.
2020-02-18
20:33 • Ticket [bbdff172a3] ::pki::verify always returns false when "algo" argument is provided status still Open with 4 other changes artifact: 8c29e1a1dc user: rkeene
2019-06-27
18:08 • Closed ticket [f8e09da9dc]: pki::verify return always false if algo (hash algorithm) argument is provided plus 6 other changes artifact: aea4f76b18 user: aku
18:06
pki - Tkt [f8e09da9dc] - T, D - No version bump. - Moved all test asset files into a separate directory, and switched access to the `asset-get` helper command from the test utilities. Further moved large test results into asset files as well. - Added clarifications on the interaction between `sign` and `verify` with respect to the specification of the hash algorithm. Regenerated docs. check-in: 3f868874e7 user: andreask tags: trunk
2019-06-26
17:42 • Ticket [f8e09da9dc] pki::verify return always false if algo (hash algorithm) argument is provided status still Open with 4 other changes artifact: f74e9176c5 user: rkeene
17:08 • Ticket [f8e09da9dc]: 3 changes artifact: c083f98291 user: aku
13:10 • New ticket [f8e09da9dc]. artifact: 19c1cb8e86 user: anonymous

Ticket UUID: f8e09da9dc22e29ca64e7862c19b573f1d522d4c
Title: pki::verify return always false if algo (hash algorithm) argument is provided
Type: Bug Version: 0.10
Submitter: anonymous Created on: 2019-06-26 13:10:54
Subsystem: pki Assigned To: aku
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2020-02-19 08:11:08
Resolution: By Design Closed By: aku
    Closed on: 2019-06-27 18:08:25
Description:
e.g. the unit test of pki.test fail if $hash is provided to verify

This original code of the test works ok
set signed   [::pki::sign   $plain  $key   $hash]
set verified [::pki::verify $signed $plain $key]

but this fail (providing hash with the right hash algorithm used to sign)
set signed   [::pki::sign $plain $key $hash]
set verified [::pki::verify $signed $plain $key $hash]
User Comments: RP. added on 2020-02-19 08:11:08:
Sorry, wrong ticket.

RP. added on 2020-02-19 08:09:53:
Thank you for your response. In my case message isn't signed by me, so I wanted additional security to make sure that only specific algorithm was used (force signee to use it). But maybe in fact it was not that necessary.
Anyway I think that "algo" argument is misleading and as it works as you described it should be something like "is_raw" since any other option than "raw" makes no sense.

aku added on 2019-06-27 18:08:25:

Updated the documentation, see commit [3f868874e7]

See https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/pki/pki.md#3 for the updated documentation.

Restructured the testsuite a bit, moving the input assets into a separate directory, and large results into asset files as well, under the same directory.


rkeene added on 2019-06-26 17:42:30:
This is ultimately a documentation issue  the [::pki::sign] command returns
a PKCS#1 v1.5 signature which embeds the hashing algorithm as an ASN.1
header to the data    UNLESS "raw" is specified as the "algorithm" for
[::pki::sign] (in which case the data is only padded before being signed).

The [::pki::verify] command knows to expect this PKCS#1 v1.5 structure so that
the relevant hashing information can be obtained and stripped from the
input so you don't need to specify the algorithm *UNLESS* it does not contain
the PKCS#1 v1.5 header, in which case the hashing algorithm has to be specified.
Since the only case where you have to specify the hashing algorithm is in the
case where the prefix is missing, if you specify the hashing algorithm for the
[::pki::verify] function it won't strip the header that [::pki::sign] added
because it assumes you specified the algorithm because there wasn't a header, so
it doesn't even check for a header.

Summary:  Don't specify the "algorithm" parameter for [pki::verify] unless you
specified "raw" as the algorithm for [pki::sign].