static void rsa_sethash(struct rsacommon *c, struct hash_if *hash)
{
free(c->hashbuf);
- c->hashbuf=safe_malloc(hash->len, "generate_msg");
+ c->hashbuf=safe_malloc(hash->hlen, "generate_msg");
c->hashi=hash;
}
static void rsa_pub_sethash(void *sst, struct hash_if *hash)
}
static void rsa_hash(struct rsacommon *c, const uint8_t *buf, int32_t len)
{
- void *hst=c->hashi->init();
- c->hashi->update(hst,buf,len);
- c->hashi->final(hst,c->hashbuf);
+ hash_hash(c->hashi,buf,len,c->hashbuf);
}
static void emsa_pkcs1(MP_INT *n, MP_INT *m,
rsa_hash(&st->common,data,datalen);
/* Construct the message representative. */
- emsa_pkcs1(&st->n, &a, st->common.hashbuf, st->common.hashi->len);
+ emsa_pkcs1(&st->n, &a, st->common.hashbuf, st->common.hashi->hlen);
/*
* Produce an RSA signature (a^d mod n) using the Chinese
{
uint8_t *lp = buf_unprepend(msg, 2);
if (!lp) return False;
- sig->siglen = get_uint16(lp);
- sig->sigstart = buf_unprepend(msg, sig->siglen);
- if (!sig->sigstart) return False;
+ sig->len = get_uint16(lp);
+ sig->start = buf_unprepend(msg, sig->len);
+ if (!sig->start) return False;
/* In `rsa_sig_check' below, we assume that we can write a nul
* terminator following the signature. Make sure there's enough space.
mpz_init(&c);
rsa_hash(&st->common,data,datalen);
- emsa_pkcs1(&st->n, &a, st->common.hashbuf, st->common.hashi->len);
+ emsa_pkcs1(&st->n, &a, st->common.hashbuf, st->common.hashi->hlen);
/* Terminate signature with a '0' - already checked that this will fit */
- int save = sig->sigstart[sig->siglen];
- sig->sigstart[sig->siglen] = 0;
- mpz_set_str(&b, sig->sigstart, 16);
- sig->sigstart[sig->siglen] = save;
+ int save = sig->start[sig->len];
+ sig->start[sig->len] = 0;
+ mpz_set_str(&b, sig->start, 16);
+ sig->start[sig->len] = save;
mpz_powm(&c, &b, &st->e, &st->n);