Handle V4 signature trailer for RSA too (ticket #34)
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 4 Mar 2009 11:08:30 +0000 (13:08 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 6 Mar 2009 09:36:31 +0000 (11:36 +0200)
(cherry picked from commit d50db40ceed7083467f7b548da7b2fbe96aaec61)

lib/signature.c

index feafc5e..9ca8da5 100644 (file)
@@ -1194,17 +1194,16 @@ verifyRSASignature(rpmKeyring keyring, rpmtd sigtd, pgpDig dig, char ** msg,
        if (sigp->hash != NULL)
            xx = rpmDigestUpdate(ctx, sigp->hash, sigp->hashlen);
 
-#ifdef NOTYET  /* XXX not for binary/text signatures as in packages. */
-       if (!(sigp->sigtype == PGPSIGTYPE_BINARY || sigp->sigtype == PGP_SIGTYPE_TEXT)) {
-           size_t nb = dig->nbytes + sigp->hashlen;
+       if (sigp->version == 4) {
+           /* V4 trailer is six octets long (rfc4880) */
            uint8_t trailer[6];
+           uint32_t nb = sigp->hashlen;
            nb = htonl(nb);
-           trailer[0] = 0x4;
+           trailer[0] = sigp->version;
            trailer[1] = 0xff;
-           memcpy(trailer+2, &nb, sizeof(nb));
+           memcpy(trailer+2, &nb, 4);
            xx = rpmDigestUpdate(ctx, trailer, sizeof(trailer));
        }
-#endif
 
        xx = rpmDigestFinal(ctx, (void **)&dig->md5, &dig->md5len, 0);