/* -*-c-*-
*
- * $Id: oaep.c,v 1.4 2002/01/13 13:50:21 mdw Exp $
+ * $Id: oaep.c,v 1.5 2002/01/13 20:20:39 mdw Exp $
*
* Optimal asymmetric encryption packing
*
/*----- Revision history --------------------------------------------------*
*
* $Log: oaep.c,v $
+ * Revision 1.5 2002/01/13 20:20:39 mdw
+ * Hack the @oaep_decode@ code some more, to make it work again.
+ *
* Revision 1.4 2002/01/13 13:50:21 mdw
* Allow only one error return, to frustrate Manger's attack against OAEP.
*
ghash *h;
octet *q, *mq, *qq;
octet *pp;
+ unsigned bad = 0;
size_t n;
size_t hsz = o->ch->hashsz;
int rc = -1;
/* --- Decrypt the message --- */
+ bad = *q;
q++; sz--;
mq = q + hsz;
qq = q + sz;
h->ops->hash(h, o->ep, o->epsz);
h->ops->done(h, q);
h->ops->destroy(h);
- if ((memcmp(q, mq, hsz) != 0) || (*q != 0))
- goto fail;
+ bad |= memcmp(q, mq, hsz);
/* --- Now find the start of the actual message --- */
pp = mq + hsz;
while (*pp == 0 && pp < qq)
pp++;
- if (pp >= qq || *pp++ != 1)
- return (-1);
+ bad |= (pp >= qq) | (*pp++ != 1);
n = qq - pp;
dstr_putm(d, pp, n);
- rc = n;
+ if (!bad)
+ rc = n;
-fail:
x_free(d->a, q);
return (rc);
}