diff options
author | mcgreer%netscape.com <devnull@localhost> | 2000-09-16 15:56:06 +0000 |
---|---|---|
committer | mcgreer%netscape.com <devnull@localhost> | 2000-09-16 15:56:06 +0000 |
commit | c4355b785d071dace0db28290d1014d231d7eb32 (patch) | |
tree | 723377fcbbe210eea3bf9308c5cb3f72d003a814 /security/nss/lib/freebl/pqg.c | |
parent | ae001c16af979e5e2c4e40736cdd9dd0b51310db (diff) | |
download | nss-hg-c4355b785d071dace0db28290d1014d231d7eb32.tar.gz |
just some general cleanup
Diffstat (limited to 'security/nss/lib/freebl/pqg.c')
-rw-r--r-- | security/nss/lib/freebl/pqg.c | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/security/nss/lib/freebl/pqg.c b/security/nss/lib/freebl/pqg.c index da942f620..70c0faf0f 100644 --- a/security/nss/lib/freebl/pqg.c +++ b/security/nss/lib/freebl/pqg.c @@ -40,40 +40,13 @@ #include "mpi.h" #include "mpprime.h" #include "mplogic.h" +#include "secmpi.h" #define MAX_ITERATIONS 5 /* Maximum number of iterations of primegen */ #define NUMITER 40 /* Number iterations for primality tests */ /* XXX to be replaced by define in blapit.h */ #define BITS_IN_Q 160 -#define NSS_FREEBL_DSA_DEFAULT_CHUNKSIZE 2048 - -/* XXX the following defines are common to all NSS code using MPI, but - not part of MPI itself. They should go in a private header in - lib/freebl. - */ -#define CHECK_SEC_OK(func) if (SECSuccess != (rv = func)) goto cleanup - -#define CHECK_MPI_OK(func) if (MP_OKAY > (err = func)) goto cleanup - -#define OCTETS_TO_MPINT(oc, mp, len) \ - CHECK_MPI_OK(mp_read_unsigned_octets((mp), oc, len)) - -#define SECITEM_TO_MPINT(it, mp) \ - CHECK_MPI_OK(mp_read_unsigned_octets((mp), (it).data, (it).len)) - -#define MPINT_TO_SECITEM(mp, it, arena) \ - SECITEM_AllocItem(arena, (it), mp_unsigned_octet_size(mp)); \ - err = mp_to_unsigned_octets(mp, (it)->data, (it)->len); \ - if (err < 0) goto cleanup; else err = MP_OKAY; - -#define MP_TO_SEC_ERROR(err) \ - switch (err) { \ - case MP_MEM: PORT_SetError(SEC_ERROR_NO_MEMORY); break; \ - case MP_RANGE: PORT_SetError(SEC_ERROR_BAD_DATA); break; \ - case MP_BADARG: PORT_SetError(SEC_ERROR_INVALID_ARGS); break; \ - default: PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); break; \ - } /* For FIPS-compliance testing. ** The following array holds the seed defined in FIPS 186-1 appendix 5. @@ -286,8 +259,6 @@ const mp_int * Q, /* input. */ CHECK_MPI_OK( mp_2expt(&shift, (mp_digit)k*160) ); /* 2**(k*160) */ CHECK_MPI_OK( mp_mul(&tmp, &shift, &tmp) ); /* V_k << shift */ CHECK_MPI_OK( mp_add(&W, &tmp, &W) ); /* W += tmp */ - mp_zero(&tmp); /* XXX needed? */ - mp_zero(&shift); /* XXX needed? */ } /* Step 8, continued. ** [W += ((V_n mod 2**b) * 2**(n*160))] @@ -412,7 +383,7 @@ PQG_ParamGenSeedLen(unsigned int j, unsigned int seedBytes, return SECFailure; } /* Initialize an arena for the params. */ - arena = PORT_NewArena(NSS_FREEBL_DSA_DEFAULT_CHUNKSIZE); + arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE); if (!arena) { PORT_SetError(SEC_ERROR_NO_MEMORY); return SECFailure; @@ -425,7 +396,7 @@ PQG_ParamGenSeedLen(unsigned int j, unsigned int seedBytes, } params->arena = arena; /* Initialize an arena for the verify. */ - arena = PORT_NewArena(NSS_FREEBL_DSA_DEFAULT_CHUNKSIZE); + arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE); if (!arena) { PORT_SetError(SEC_ERROR_NO_MEMORY); return SECFailure; |