diff options
author | jbj <devnull@localhost> | 2003-05-05 16:02:02 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2003-05-05 16:02:02 +0000 |
commit | 5cd37687754d5ec15b8865d67ccad52de53a33a0 (patch) | |
tree | b9cade14c9e9578d0569d5a45d8c16eefb9d31f7 | |
parent | 4e1b7e82c001543adfa4ecbacccae61c93711f9a (diff) | |
download | librpm-tizen-5cd37687754d5ec15b8865d67ccad52de53a33a0.tar.gz librpm-tizen-5cd37687754d5ec15b8865d67ccad52de53a33a0.tar.bz2 librpm-tizen-5cd37687754d5ec15b8865d67ccad52de53a33a0.zip |
Merge in latest beecrypt-3.0.0 changes.
CVS patchset: 6813
CVS date: 2003/05/05 16:02:02
-rw-r--r-- | beecrypt/beecrypt.c | 41 | ||||
-rw-r--r-- | beecrypt/beecrypt.h | 16 | ||||
-rw-r--r-- | beecrypt/blockpad.c | 9 | ||||
-rw-r--r-- | beecrypt/blockpad.h | 4 | ||||
-rw-r--r-- | beecrypt/mp.c | 3 | ||||
-rw-r--r-- | beecrypt/mp.h | 188 | ||||
-rw-r--r-- | beecrypt/rsa.c | 7 |
7 files changed, 210 insertions, 58 deletions
diff --git a/beecrypt/beecrypt.c b/beecrypt/beecrypt.c index bc5a45b4c..fd3c3fb06 100644 --- a/beecrypt/beecrypt.c +++ b/beecrypt/beecrypt.c @@ -53,10 +53,6 @@ typedef struct #include "debug.h" -/*!\addtogroup ES_m - * \{ - */ - /*@observer@*/ /*@unchecked@*/ static entropySource entropySourceList[] = { @@ -90,12 +86,12 @@ int entropySourceCount() return ENTROPYSOURCES; } -const entropySource* entropySourceGet(int index) +const entropySource* entropySourceGet(int n) { - if ((index < 0) || (index >= ENTROPYSOURCES)) + if ((n < 0) || (n >= ENTROPYSOURCES)) return (const entropySource*) 0; - return entropySourceList+index; + return entropySourceList+n; } const entropySource* entropySourceFind(const char* name) @@ -146,11 +142,6 @@ int entropyGatherNext(byte* data, size_t size) return -1; } -/*!\} - * \addtogroup PRNG_m - * \{ - */ - /*@observer@*/ /*@unchecked@*/ static const randomGenerator* randomGeneratorList[] = { @@ -251,11 +242,6 @@ int randomGeneratorContextNext(randomGeneratorContext* ctxt, byte* data, size_t return ctxt->rng->next(ctxt->param, data, size); } -/*!\} - * \addtogroup HASH_m - * \{ - */ - /*@observer@*/ /*@unchecked@*/ static const hashFunction* hashFunctionList[] = { @@ -502,11 +488,6 @@ int hashFunctionContextDigestMatch(hashFunctionContext* ctxt, const mpnumber* d) /*@=mustfree@*/ } -/*!\} - * \addtogroup HMAC_m - * \{ - */ - /*@observer@*/ /*@unchecked@*/ static const keyedHashFunction* keyedHashFunctionList[] = { @@ -770,11 +751,6 @@ int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext* ctxt, const mp /*@=mustfree@*/ } -/*!\} - * \addtogroup BC_m - * \{ - */ - /*@observer@*/ /*@unchecked@*/ static const blockCipher* blockCipherList[] = { @@ -900,9 +876,7 @@ int blockCipherContextFree(blockCipherContext* ctxt) /*@=nullstate@*/ } -static /*@unused@*/ -int blockCipherContextECB(blockCipherContext* ctxt, void* dst, const void* src, int nblocks) - /*@modifies ctxt->param, dst @*/ +int blockCipherContextECB(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, size_t nblocks) { switch (ctxt->op) { @@ -923,9 +897,7 @@ int blockCipherContextECB(blockCipherContext* ctxt, void* dst, const void* src, return -1; } -static /*@unused@*/ -int blockCipherContextCBC(blockCipherContext* ctxt, void* dst, const void* src, int nblocks) - /*@modifies ctxt->param, dst @*/ +int blockCipherContextCBC(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, size_t nblocks) { switch (ctxt->op) { @@ -946,9 +918,6 @@ int blockCipherContextCBC(blockCipherContext* ctxt, void* dst, const void* src, return -1; } -/*!\} - */ - #if WIN32 __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved) diff --git a/beecrypt/beecrypt.h b/beecrypt/beecrypt.h index 28f8f33ce..92f0f52c9 100644 --- a/beecrypt/beecrypt.h +++ b/beecrypt/beecrypt.h @@ -76,11 +76,11 @@ int entropySourceCount(void) /** \ingroup ES_m * Retrieve a entropy source by index. - * @param index entropy source index + * @param n entropy source index * @return entropy source pointer (or NULL) */ BEECRYPTAPI /*@observer@*/ /*@null@*/ /*@unused@*/ -const entropySource* entropySourceGet(int index) +const entropySource* entropySourceGet(int n) /*@*/; /** \ingroup ES_m @@ -852,6 +852,18 @@ int blockCipherContextFree(/*@special@*/ blockCipherContext* ctxt) /*@releases ctxt->param @*/ /*@modifies ctxt->algo, ctxt->param @*/; +/** \ingroup BC_m + */ +BEECRYPTAPI /*@unused@*/ +int blockCipherContextECB(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, size_t nblocks) + /*@modifies ctxt->param, dst @*/; + +/** \ingroup BC_m + */ +BEECRYPTAPI /*@unused@*/ +int blockCipherContextCBC(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, size_t nblocks) + /*@modifies ctxt->param, dst @*/; + #ifdef __cplusplus } #endif diff --git a/beecrypt/blockpad.c b/beecrypt/blockpad.c index 29686820d..429de138c 100644 --- a/beecrypt/blockpad.c +++ b/beecrypt/blockpad.c @@ -19,7 +19,7 @@ /*!\file blockpad.c * \brief Blockcipher padding algorithms. - * \author Bob Deblier <bob@virtualunlimited.com> + * \author Bob Deblier <bob.deblier@pandora.be> * \ingroup BC_m */ @@ -27,10 +27,6 @@ #include "blockpad.h" #include "debug.h" -/*!\addtogroup BC_m - * \{ - */ - memchunk* pkcs5Pad(size_t blockbytes, memchunk* tmp) { if (tmp) @@ -121,6 +117,3 @@ memchunk* pkcs5UnpadCopy(/*@unused@*/ size_t blockbytes, const memchunk* src) return tmp; } - -/*!\} - */ diff --git a/beecrypt/blockpad.h b/beecrypt/blockpad.h index 9899b4485..c705d9e01 100644 --- a/beecrypt/blockpad.h +++ b/beecrypt/blockpad.h @@ -18,8 +18,8 @@ */ /*!\file blockpad.h - * \brief Blockcipher padding algorithms, headers. - * \author Bob Deblier <bob@virtualunlimited.com> + * \brief Blockcipher padding algorithms. + * \author Bob Deblier <bob.deblier@pandora.be> * \ingroup BC_m */ diff --git a/beecrypt/mp.c b/beecrypt/mp.c index 944944b0e..d3cb268b7 100644 --- a/beecrypt/mp.c +++ b/beecrypt/mp.c @@ -739,7 +739,7 @@ void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* #endif #ifndef ASM_MPADDSQRTRC -mpw mpaddsqrtrc(size_t size, mpw* result, const mpw* data) +void mpaddsqrtrc(size_t size, mpw* result, const mpw* data) { #if HAVE_MPDW register mpdw temp; @@ -797,7 +797,6 @@ mpw mpaddsqrtrc(size_t size, mpw* result, const mpw* data) carry += (load > rhi); } #endif - return carry; } #endif diff --git a/beecrypt/mp.h b/beecrypt/mp.h index b2b61363a..3136f23cb 100644 --- a/beecrypt/mp.h +++ b/beecrypt/mp.h @@ -81,36 +81,60 @@ void mpmove(size_t size, /*@out@*/ mpw* dst, const mpw* src) #endif /** + * This function zeroes a multi-precision integer of a given size. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. */ BEECRYPTAPI void mpzero(size_t size, /*@out@*/ mpw* data) /*@modifies data @*/; /** + * This function fills each word of a multi-precision integer with a + * given value. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @param fill The value fill the data with. */ BEECRYPTAPI /*@unused@*/ void mpfill(size_t size, /*@out@*/ mpw* data, mpw fill) /*@modifies data @*/; /** + * This function tests if a multi-precision integer is odd. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if odd, 0 if even */ BEECRYPTAPI int mpodd (size_t size, const mpw* data) /*@*/; /** + * This function tests if a multi-precision integer is even. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if even, 0 if odd */ BEECRYPTAPI int mpeven(size_t size, const mpw* data) /*@*/; /** + * This function tests if a multi-precision integer is zero. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if zero, 0 if not zero */ BEECRYPTAPI int mpz (size_t size, const mpw* data) /*@*/; /** + * This function tests if a multi-precision integer is not zero. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if not zero, 0 if zero */ /*@-exportlocal@*/ BEECRYPTAPI @@ -119,12 +143,24 @@ int mpnz (size_t size, const mpw* data) /*@=exportlocal@*/ /** + * This function tests if two multi-precision integers of the same size + * are equal. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if equal, 0 if not equal */ BEECRYPTAPI int mpeq (size_t size, const mpw* xdata, const mpw* ydata) /*@*/; /** + * This function tests if two multi-precision integers of the same size + * differ. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if not equal, 0 if equal */ /*@-exportlocal@*/ BEECRYPTAPI @@ -133,6 +169,13 @@ int mpne (size_t size, const mpw* xdata, const mpw* ydata) /*@=exportlocal@*/ /** + * This function tests if the first of two multi-precision integers + * of the same size is greater than the second. + * @note The comparison treats the arguments as unsigned. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if greater, 0 if less or equal */ /*@-exportlocal@*/ BEECRYPTAPI @@ -141,6 +184,13 @@ int mpgt (size_t size, const mpw* xdata, const mpw* ydata) /*@=exportlocal@*/ /** + * This function tests if the first of two multi-precision integers + * of the same size is less than the second. + * @note The comparison treats the arguments as unsigned. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if less, 0 if greater or equal */ /*@-exportlocal@*/ BEECRYPTAPI @@ -149,108 +199,208 @@ int mplt (size_t size, const mpw* xdata, const mpw* ydata) /*@=exportlocal@*/ /** + * This function tests if the first of two multi-precision integers + * of the same size is greater than or equal to the second. + * @note The comparison treats the arguments as unsigned. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if greater or equal, 0 if less */ BEECRYPTAPI int mpge (size_t size, const mpw* xdata, const mpw* ydata) /*@*/; /** + * This function tests if the first of two multi-precision integers + * of the same size is less than or equal to the second. + * @note The comparison treats the arguments as unsigned. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if less or equal, 0 if greater */ BEECRYPTAPI int mple (size_t size, const mpw* xdata, const mpw* ydata) /*@*/; /** + * This function tests if two multi-precision integers of different + * size are equal. + * @param xsize The size of the first multi-precision integer. + * @param xdata The first multi-precision integer. + * @param ysize The size of the first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if equal, 0 if not equal */ BEECRYPTAPI int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@*/; /** + * This function tests if two multi-precision integers of different + * size differ. + * @param xsize The size of the first multi-precision integer. + * @param xdata The first multi-precision integer. + * @param ysize The size of the first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if not equal, 0 if equal */ BEECRYPTAPI /*@unused@*/ int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@*/; /** + * This function tests if the first of two multi-precision integers + * of different size is greater than the second. + * @note The comparison treats the arguments as unsigned. + * @param xsize The size of the first multi-precision integer. + * @param xdata The first multi-precision integer. + * @param ysize The size of the second multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if greater, 0 if less or equal */ BEECRYPTAPI /*@unused@*/ int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@*/; /** + * This function tests if the first of two multi-precision integers + * of different size is less than the second. + * @note The comparison treats the arguments as unsigned. + * @param xsize The size of the first multi-precision integer. + * @param xdata The first multi-precision integer. + * @param ysize The size of the second multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if less, 0 if greater or equal */ BEECRYPTAPI /*@unused@*/ int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@*/; /** + * This function tests if the first of two multi-precision integers + * of different size is greater than or equal to the second. + * @note The comparison treats the arguments as unsigned. + * @param xsize The size of the first multi-precision integer. + * @param xdata The first multi-precision integer. + * @param ysize The size of the second multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if greater or equal, 0 if less */ BEECRYPTAPI int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@*/; /** + * This function tests if the first of two multi-precision integers + * of different size is less than or equal to the second. + * @note The comparison treats the arguments as unsigned. + * @param xsize The size of the first multi-precision integer. + * @param xdata The first multi-precision integer. + * @param ysize The size of the second multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if less or equal, 0 if greater */ BEECRYPTAPI int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@*/; /** + * This function tests if the value of a multi-precision integer is + * equal to one. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if equal to one, 0 otherwise. */ BEECRYPTAPI int mpisone(size_t size, const mpw* data) /*@*/; /** + * This function tests if the value of a multi-precision integer is + * equal to two. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if equal to two, 0 otherwise. */ BEECRYPTAPI int mpistwo(size_t size, const mpw* data) /*@*/; /** + * This function tests if the value of a multi-precision integer is + * less than or equal to one. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if less than or equal to one, 0 otherwise. */ BEECRYPTAPI int mpleone(size_t size, const mpw* data) /*@*/; /** + * This function tests if multi-precision integer x is equal to y minus one. + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return 1 if less than or equal to (y-1), 0 otherwise. */ BEECRYPTAPI /*@unused@*/ int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata) /*@*/; /** + * This function tests the most significant bit of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if set, 0 if not set */ BEECRYPTAPI int mpmsbset(size_t size, const mpw* data) /*@*/; /** + * This function tests the least significant bit of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. + * @return 1 if set, 0 if not set */ BEECRYPTAPI /*@unused@*/ int mplsbset(size_t size, const mpw* data) /*@*/; /** + * This function sets the most significant bit of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. */ BEECRYPTAPI /*@unused@*/ void mpsetmsb(size_t size, mpw* data) /*@modifies data @*/; /** + * This function sets the least significant bit of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. */ BEECRYPTAPI void mpsetlsb(size_t size, mpw* data) /*@modifies data @*/; /** + * This function clears the most significant bit of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. */ BEECRYPTAPI /*@unused@*/ void mpclrmsb(size_t size, mpw* data) /*@modifies data @*/; /** + * This function clears the least significant bit of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. */ BEECRYPTAPI /*@unused@*/ void mpclrlsb(size_t size, mpw* data) @@ -275,6 +425,9 @@ void mpor(size_t size, mpw* xdata, const mpw* ydata) /*@modifies xdata @*/; /** + * This function flips all bits of a multi-precision integer. + * @param size The size of the multi-precision integer. + * @param data The multi-precision integer data. */ /*@-exportlocal@*/ BEECRYPTAPI @@ -301,6 +454,12 @@ int mpaddw(size_t size, mpw* xdata, mpw y) /*@modifies xdata @*/; /** + * This function adds two multi-precision integers of equal size. + * The performed operation is in pseudocode: x += y + * @param size The size of the multi-precision integers. + * @param xdata The first multi-precision integer. + * @param ydata The second multi-precision integer. + * @return The carry-over value of the operation (either 0 or 1). */ BEECRYPTAPI int mpadd (size_t size, mpw* xdata, const mpw* ydata) @@ -411,32 +570,59 @@ void mpsdivtwo(size_t size, mpw* data) /*@modifies data @*/; /** + * This function performs a multi-precision multiply-setup. + * + * This function is used in the computation of a full multi-precision + * multiplication. By using it we can shave off a few cycles; otherwise we'd + * have to zero the least significant half of the result first and use + * another call to the slightly slower mpaddmul function. + * + * @param size The size of multi-precision integer multiplier. + * @param result The place where result will be accumulated. + * @param data The multi-precision integer multiplier. + * @param y The multiplicand. + * @return The carry-over multi-precision word. */ BEECRYPTAPI mpw mpsetmul (size_t size, /*@out@*/ mpw* result, const mpw* data, mpw y) /*@modifies result @*/; /** + * This function performs a mult-precision multiply-accumulate. + * + * This function is used in the computation of a full multi-precision + * multiplication. It computes the product-by-one-word and accumulates it with + * the previous result. + * + * @param size The size of multi-precision integer multiplier. + * @param result The place where result will be accumulated. + * @param data The multi-precision integer multiplier. + * @param y The multiplicand. + * @return The carry-over multi-precision word. */ BEECRYPTAPI mpw mpaddmul (size_t size, /*@out@*/ mpw* result, const mpw* data, mpw y) /*@modifies result @*/; /** + * This function is used in the calculation of a multi-precision + * squaring. */ /*@-exportlocal@*/ BEECRYPTAPI -mpw mpaddsqrtrc(size_t size, /*@out@*/ mpw* result, const mpw* data) +void mpaddsqrtrc(size_t size, /*@out@*/ mpw* result, const mpw* data) /*@modifies result @*/; /*@=exportlocal@*/ /** + * This function computes a full multi-precision product. */ BEECRYPTAPI void mpmul(/*@out@*/ mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) /*@modifies result @*/; /** + * This function computes a full multi-precision square. */ BEECRYPTAPI void mpsqr(/*@out@*/ mpw* result, size_t size, const mpw* data) diff --git a/beecrypt/rsa.c b/beecrypt/rsa.c index 4a2bfc53c..d1a6cf92e 100644 --- a/beecrypt/rsa.c +++ b/beecrypt/rsa.c @@ -28,10 +28,6 @@ #include "mp.h" #include "debug.h" -/*!\addtogroup IF_rsa_m - * \{ - */ - int rsapub(const rsapk* pk, const mpnumber* m, mpnumber* c) { register size_t size = pk->n.size; @@ -162,6 +158,3 @@ int rsavrfy(const rsapk* pk, const mpnumber* m, const mpnumber* c) } return 0; } - -/*!\} - */ |