Fix bug 191396. Don't generate SEC_ERROR_LIBRARY_FAILURE unnecessarily

while doing dsa signatures.
This commit is contained in:
nelsonb%netscape.com 2003-01-31 02:39:36 +00:00
Родитель e1734e35a3
Коммит 04c74fc4ac
1 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -31,7 +31,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: dsa.c,v 1.8 2002-09-05 20:44:09 ian.mcgreer%sun.com Exp $
* $Id: dsa.c,v 1.9 2003-01-31 02:39:36 nelsonb%netscape.com Exp $
*/
#include "secerr.h"
@ -180,6 +180,7 @@ dsa_SignDigest(DSAPrivateKey *key, SECItem *signature, const SECItem *digest,
mp_int x, k; /* private key & pseudo-random integer */
mp_int r, s; /* tuple (r, s) is signature) */
mp_err err;
SECStatus rv = SECSuccess;
/* FIPS-compliance dictates that digest is a SHA1 hash. */
/* Check args. */
@ -235,7 +236,7 @@ dsa_SignDigest(DSAPrivateKey *key, SECItem *signature, const SECItem *digest,
*/
if (mp_cmp_z(&r) == 0 || mp_cmp_z(&s) == 0) {
PORT_SetError(SEC_ERROR_NEED_RANDOM);
err = MP_UNDEF;
rv = SECFailure;
goto cleanup;
}
/*
@ -244,10 +245,11 @@ dsa_SignDigest(DSAPrivateKey *key, SECItem *signature, const SECItem *digest,
** Signature is tuple (r, s)
*/
err = mp_to_fixlen_octets(&r, signature->data, DSA_SUBPRIME_LEN);
if (err < 0) goto cleanup; else err = MP_OKAY;
if (err < 0) goto cleanup;
err = mp_to_fixlen_octets(&s, signature->data + DSA_SUBPRIME_LEN,
DSA_SUBPRIME_LEN);
if (err < 0) goto cleanup; else err = MP_OKAY;
if (err < 0) goto cleanup;
err = MP_OKAY;
cleanup:
mp_clear(&p);
mp_clear(&q);
@ -258,9 +260,9 @@ cleanup:
mp_clear(&s);
if (err) {
translate_mpi_error(err);
return SECFailure;
rv = SECFailure;
}
return SECSuccess;
return rv;
}
/* signature is caller-supplied buffer of at least 20 bytes.