6 #define _RPMBC_INTERNAL
7 #define _RPMPGP_INTERNAL
31 if (c >=
'0' && c <=
'9')
32 return (
unsigned char) (c -
'0');
33 if (c >=
'A' && c <=
'F')
34 return (
unsigned char)((int)(c -
'A') + 10);
35 if (c >=
'a' && c <=
'f')
36 return (
unsigned char)((int)(c -
'a') + 10);
37 return (
unsigned char)
'\0';
45 unsigned int nbits = (unsigned) MP_WORDS_TO_BITS(bc->c.size);
46 unsigned int nb = (nbits + 7) >> 3;
58 hexstr = tt =
xmalloc(2 * nb + 1);
59 memset(tt, (
int)
'f', (2 * nb));
60 tt[0] =
'0'; tt[1] =
'0';
61 tt[2] =
'0'; tt[3] =
'1';
62 tt += (2 * nb) - strlen(prefix) - strlen(dig->md5) - 2;
63 *tt++ =
'0'; *tt++ =
'0';
68 mpnzero(&bc->rsahm); (void) mpnsethex(&bc->rsahm, hexstr);
71 hexstr =
_free(hexstr);
74 {
const char *str = dig->md5;
79 rc = memcmp(s, t,
sizeof(sigp->signhash16));
82 fprintf(stderr,
"*** hash fails: digest(%02x%02x) != signhash(%02x%02x)\n",
83 s[0], s[1], t[0], t[1]);
97 #if defined(HAVE_BEECRYPT_API_H)
98 rc = rsavrfy(&bc->rsa_pk.n, &bc->rsa_pk.e, &bc->c, &bc->rsahm);
100 rc = rsavrfy(&bc->rsa_pk, &bc->rsahm, &bc->c);
111 rpmbc bc = dig->impl;
119 mpnzero(&bc->hm); (void) mpnsethex(&bc->hm, dig->sha1);
123 signhash16[0] = (
rpmuint8_t)((*bc->hm.data >> 24) & 0xff);
124 signhash16[1] = (
rpmuint8_t)((*bc->hm.data >> 16) & 0xff);
125 return memcmp(signhash16, sigp->signhash16,
sizeof(signhash16));
132 rpmbc bc = dig->impl;
136 rc = dsavrfy(&bc->p, &bc->q, &bc->g, &bc->hm, &bc->y, &bc->r, &bc->s);
172 static char prbuf[2048];
188 mpnumber * mpn = dest;
195 if (pend != NULL && (p + ((mbits+7) >> 3)) > pend)
201 nbits = (lbits > mbits ? lbits : mbits);
202 nbytes = ((nbits + 7) >> 3);
204 ix = 2 * ((nbits - mbits) >> 3);
207 fprintf(stderr,
"*** mbits %u nbits %u nbytes %u t %p[%d] ix %u\n", mbits, nbits, nbytes, t, (2*nbytes+1), ix);
208 if (ix > 0) memset(t, (
int)
'0', ix);
209 strcpy(t+ix, (
const char *)
pgpMpiHex(p));
211 fprintf(stderr,
"*** %s %s\n", pre, t);
212 (void) mpnsethex(mpn, t);
215 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data);
225 rpmbc bc = dig->impl;
235 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->c.size, bc->c.data);
238 rc =
pgpMpiSet(pre, 160, &bc->r, p, pend);
241 rc =
pgpMpiSet(pre, 160, &bc->s, p, pend);
244 (void) mpbsethex(&bc->rsa_pk.n,
pgpMpiHex(p));
246 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->rsa_pk.n.size, bc->rsa_pk.n.modl);
249 (void) mpnsethex(&bc->rsa_pk.e,
pgpMpiHex(p));
251 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->rsa_pk.e.size, bc->rsa_pk.e.data);
256 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->p.size, bc->p.modl);
261 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->q.size, bc->q.modl);
266 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->g.size, bc->g.data);
271 fprintf(stderr,
"\t %s ", pre), mpfprintln(stderr, bc->y.size, bc->y.data);
287 (void) rsapkFree(&bc->rsa_pk);
309 mpbfree(&bc->rsa_pk.n);
310 mpnfree(&bc->rsa_pk.e);