summaryrefslogtreecommitdiff
path: root/beecrypt
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2003-05-01 23:28:46 +0000
committerjbj <devnull@localhost>2003-05-01 23:28:46 +0000
commit366f697b6690d245319eb856985e84625c25236d (patch)
tree585c243dc02aca0ed529266674e73bd1f6fa1c7c /beecrypt
parent0b64f73176d63b71b289b9946e3e77a135e79070 (diff)
downloadlibrpm-tizen-366f697b6690d245319eb856985e84625c25236d.tar.gz
librpm-tizen-366f697b6690d245319eb856985e84625c25236d.tar.bz2
librpm-tizen-366f697b6690d245319eb856985e84625c25236d.zip
Intergate beecrypt spliddles.
CVS patchset: 6802 CVS date: 2003/05/01 23:28:46
Diffstat (limited to 'beecrypt')
-rw-r--r--beecrypt/.splintrc5
-rw-r--r--beecrypt/aes.c2
-rw-r--r--beecrypt/beecrypt.c26
-rw-r--r--beecrypt/blockmode.c10
-rw-r--r--beecrypt/blowfish.c2
-rw-r--r--beecrypt/dhaes.c2
-rw-r--r--beecrypt/dldp.h5
-rw-r--r--beecrypt/hmac.c4
-rw-r--r--beecrypt/mp.c12
-rw-r--r--beecrypt/mp.h5
-rw-r--r--beecrypt/mpprime.c2
-rw-r--r--beecrypt/tests/beetest.c14
12 files changed, 65 insertions, 24 deletions
diff --git a/beecrypt/.splintrc b/beecrypt/.splintrc
index a35876258..a38e1300b 100644
--- a/beecrypt/.splintrc
+++ b/beecrypt/.splintrc
@@ -15,10 +15,7 @@
# --- in progress
+likelybounds
-bufferoverflowhigh
--aliasunique
--mayaliasunique
--compdef # 83
--noeffectuncon # 11
+#-compdef # 83
-elseifcomplete
-whileempty
diff --git a/beecrypt/aes.c b/beecrypt/aes.c
index 97b5e0a2e..74e660bf6 100644
--- a/beecrypt/aes.c
+++ b/beecrypt/aes.c
@@ -891,10 +891,12 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
#ifndef ASM_AESSETIV
int aesSetIV(aesParam* ap, const byte* iv)
{
+/*@-mayaliasunique@*/
if (iv)
memcpy(ap->fdback, iv, 16);
else
memset(ap->fdback, 0, 16);
+/*@=mayaliasunique@*/
return 0;
}
diff --git a/beecrypt/beecrypt.c b/beecrypt/beecrypt.c
index aaabf9660..b9cd83398 100644
--- a/beecrypt/beecrypt.c
+++ b/beecrypt/beecrypt.c
@@ -1,4 +1,4 @@
-/*@-sizeoftype@*/
+/*@-compdef -sizeoftype@*/
/*
* Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
@@ -66,18 +66,18 @@ static entropySource entropySourceList[] =
{ "console", entropy_console },
{ "wincrypt", entropy_wincrypt },
#else
+# if HAVE_DEV_URANDOM
+ { "urandom", entropy_dev_urandom },
+# endif
+# if HAVE_DEV_RANDOM
+ { "random", entropy_dev_random },
+# endif
# if HAVE_DEV_AUDIO
{ "audio", entropy_dev_audio },
# endif
# if HAVE_DEV_DSP
{ "dsp", entropy_dev_dsp },
# endif
-# if HAVE_DEV_RANDOM
- { "random", entropy_dev_random },
-# endif
-# if HAVE_DEV_URANDOM
- { "urandom", entropy_dev_urandom },
-# endif
# if HAVE_DEV_TTY
{ "tty", entropy_dev_tty },
# endif
@@ -917,12 +917,17 @@ int blockCipherContextECB(blockCipherContext* ctxt, void* dst, const void* src,
switch (ctxt->op)
{
case NOCRYPT:
+/*@-mayaliasunique@*/
memcpy(dst, src, nblocks * ctxt->algo->blocksize);
+/*@=mayaliasunique@*/
return 0;
+ /*@notreached@*/ break;
case ENCRYPT:
return blockEncryptECB(ctxt->algo, ctxt->param, dst, src, nblocks);
+ /*@notreached@*/ break;
case DECRYPT:
return blockDecryptECB(ctxt->algo, ctxt->param, dst, src, nblocks);
+ /*@notreached@*/ break;
}
/*@notreached@*/
return -1;
@@ -935,12 +940,17 @@ int blockCipherContextCBC(blockCipherContext* ctxt, void* dst, const void* src,
switch (ctxt->op)
{
case NOCRYPT:
+/*@-mayaliasunique@*/
memcpy(dst, src, nblocks * ctxt->algo->blocksize);
+/*@=mayaliasunique@*/
return 0;
+ /*@notreached@*/ break;
case ENCRYPT:
return blockEncryptCBC(ctxt->algo, ctxt->param, dst, src, nblocks);
+ /*@notreached@*/ break;
case DECRYPT:
return blockDecryptCBC(ctxt->algo, ctxt->param, dst, src, nblocks);
+ /*@notreached@*/ break;
}
/*@notreached@*/
return -1;
@@ -965,4 +975,4 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved)
return TRUE;
}
#endif
-/*@=sizeoftype@*/
+/*@=compdef =sizeoftype@*/
diff --git a/beecrypt/blockmode.c b/beecrypt/blockmode.c
index 66c19716a..2eda8391e 100644
--- a/beecrypt/blockmode.c
+++ b/beecrypt/blockmode.c
@@ -39,7 +39,9 @@ int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
while (nblocks > 0)
{
+/*@-noeffectuncon@*/
(void) bc->encrypt(bp, dst, src);
+/*@=noeffectuncon@*/
dst += blockwords;
src += blockwords;
@@ -55,7 +57,9 @@ int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
while (nblocks > 0)
{
+/*@-noeffectuncon@*/
(void) bc->decrypt(bp, dst, src);
+/*@=noeffectuncon@*/
dst += blockwords;
src += blockwords;
@@ -77,7 +81,9 @@ int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
for (i = 0; i < blockwords; i++)
dst[i] = src[i] ^ fdback[i];
+/*@-noeffectuncon@*/
(void) bc->encrypt(bp, dst, dst);
+/*@=noeffectuncon@*/
dst += blockwords;
src += blockwords;
@@ -90,7 +96,9 @@ int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
for (i = 0; i < blockwords; i++)
dst[i] = src[i] ^ dst[i-blockwords];
+/*@-noeffectuncon@*/
(void) bc->encrypt(bp, dst, dst);
+/*@=noeffectuncon@*/
dst += blockwords;
src += blockwords;
@@ -119,7 +127,9 @@ int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
register uint32_t tmp;
register int i;
+/*@-noeffectuncon@*/
(void) bc->decrypt(bp, buf, src);
+/*@=noeffectuncon@*/
for (i = 0; i < blockwords; i++)
{
diff --git a/beecrypt/blowfish.c b/beecrypt/blowfish.c
index 7056e122b..119a75a9d 100644
--- a/beecrypt/blowfish.c
+++ b/beecrypt/blowfish.c
@@ -385,10 +385,12 @@ int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, /*@unused@
#ifndef ASM_BLOWFISHSETIV
int blowfishSetIV(blowfishParam* bp, const byte* iv)
{
+/*@-mayaliasunique@*/
if (iv)
memcpy(bp->fdback, iv, sizeof(bp->fdback));
else
memset(bp->fdback, 0, sizeof(bp->fdback));
+/*@=mayaliasunique@*/
return 0;
}
diff --git a/beecrypt/dhaes.c b/beecrypt/dhaes.c
index ed1ec5e02..d4c10e7b7 100644
--- a/beecrypt/dhaes.c
+++ b/beecrypt/dhaes.c
@@ -1,3 +1,4 @@
+/*@-compdef@*/
/*
* Copyright (c) 2000, 2001, 2002 Virtual Unlimited, B.V.
*
@@ -360,3 +361,4 @@ decrypt_end:
return cleartext;
/*@=usereleased@*/
}
+/*@=compdef@*/
diff --git a/beecrypt/dldp.h b/beecrypt/dldp.h
index 71635a1fb..453de990f 100644
--- a/beecrypt/dldp.h
+++ b/beecrypt/dldp.h
@@ -117,9 +117,8 @@ int dldp_pEqual(const dldp_p* a, const dldp_p* b)
/**
*/
BEECRYPTAPI /*@unused@*/
-int dldp_pgoqMake(/*@special@*/ dldp_p* dp, randomGeneratorContext* rgc, size_t pbits, size_t qbits, int cofactor)
- /*@defines dp->p, dp->q, dp->n @*/
- /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
+int dldp_pgoqMake(dldp_p* dp, randomGeneratorContext* rgc, size_t pbits, size_t qbits, int cofactor)
+ /*@modifies dp, rgc @*/;
/**
*/
diff --git a/beecrypt/hmac.c b/beecrypt/hmac.c
index 8512a3791..b374643a8 100644
--- a/beecrypt/hmac.c
+++ b/beecrypt/hmac.c
@@ -61,12 +61,16 @@ int hmacSetup(byte* kxi, byte* kxo, const hashFunction* hash, hashFunctionParam*
if (hash->digest(param, kxi))
return -1;
+/*@-mayaliasunique@*/
memcpy(kxo, kxi, keybytes = hash->digestsize);
+/*@=mayaliasunique@*/
}
else if (keybytes > 0)
{
+/*@-mayaliasunique@*/
memcpy(kxi, key, keybytes);
memcpy(kxo, key, keybytes);
+/*@=mayaliasunique@*/
}
else
return -1;
diff --git a/beecrypt/mp.c b/beecrypt/mp.c
index d19cc812d..5a2f1355f 100644
--- a/beecrypt/mp.c
+++ b/beecrypt/mp.c
@@ -1268,14 +1268,10 @@ void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const
mpw msw = *ydata;
size_t qsize = xsize-ysize;
- mpcopy(xsize, result+1, xdata);
- if (mpge(ysize, result+1, ydata))
- {
- (void) mpsub(ysize, result+1, ydata);
- *result = 1;
- }
- else
- *result = 0;
+ *result = (mpge(ysize, xdata, ydata) ? 1 : 0);
+ mpcopy(xsize, result + 1, xdata);
+ if (*result)
+ (void) mpsub(ysize, result, ydata);
result++;
while (qsize--)
diff --git a/beecrypt/mp.h b/beecrypt/mp.h
index c54c70e02..660a49c38 100644
--- a/beecrypt/mp.h
+++ b/beecrypt/mp.h
@@ -71,7 +71,10 @@ BEECRYPTAPI /*@unused@*/
void mpcopy(size_t size, /*@out@*/ mpw* dst, const mpw* src)
/*@modifies dst @*/;
#ifndef ASM_MPCOPY
-# define mpcopy(size, dst, src) memcpy(dst, src, MP_WORDS_TO_BYTES((unsigned)size))
+# define mpcopy(size, dst, src) \
+ /*@-aliasunique -mayaliasunique @*/ \
+ memcpy(dst, src, MP_WORDS_TO_BYTES((unsigned)size)) \
+ /*@=aliasunique =mayaliasunique @*/
#endif
/**
diff --git a/beecrypt/mpprime.c b/beecrypt/mpprime.c
index a0f49a2e0..851b15828 100644
--- a/beecrypt/mpprime.c
+++ b/beecrypt/mpprime.c
@@ -906,7 +906,9 @@ static void mpprndbits(mpbarrett* p, size_t msbclr, size_t lsbset, randomGenerat
if (p == (mpbarrett*) 0 || p->modl == (mpw*) 0)
return;
+/*@-noeffectuncon@*/
(void) rc->rng->next(rc->param, (byte*) p->modl, MP_WORDS_TO_BYTES(size));
+/*@=noeffectuncon@*/
if (msbclr != 0)
p->modl[0] &= (MP_ALLMASK >> msbclr);
diff --git a/beecrypt/tests/beetest.c b/beecrypt/tests/beetest.c
index 6a43b3804..e1cb252c6 100644
--- a/beecrypt/tests/beetest.c
+++ b/beecrypt/tests/beetest.c
@@ -1,3 +1,4 @@
+/*@-compdef@*/
/*
* beetest.c
*
@@ -126,7 +127,9 @@ static int testVectorElGamalV1(const dlkp_p* keypair)
mpnsize(&digest, 5);
memset(digest.data, 0, digest.size * sizeof(*digest.data));
+/*@-noeffectuncon@*/
(void) rngc.rng->next(rngc.param, digest.data, digest.size);
+/*@=noeffectuncon@*/
(void) elgv1sign(&keypair->param.p, &keypair->param.n, &keypair->param.g, &rngc, &digest, &keypair->x, &r, &s);
@@ -166,7 +169,9 @@ static int testVectorElGamalV3(const dlkp_p* keypair)
mpnsize(&digest, 5);
memset(digest.data, 0, digest.size * sizeof(*digest.data));
+/*@-noeffectuncon@*/
(void) rngc.rng->next(rngc.param, digest.data, digest.size);
+/*@=noeffectuncon@*/
(void) elgv3sign(&keypair->param.p, &keypair->param.n, &keypair->param.g, &rngc, &digest, &keypair->x, &r, &s);
@@ -487,7 +492,9 @@ static void testExpMods(void)
#endif
/* now run a test with x having 160 bits */
mpnsize(&x, 5);
+/*@-noeffectuncon@*/
(void) rngc.rng->next(rngc.param, x.data, x.size);
+/*@=noeffectuncon@*/
printf(" (1024 bits ^ 160 bits) mod 1024 bits:");
#if HAVE_TIME_H
tstart = clock();
@@ -555,7 +562,9 @@ static void testRSA(void)
#endif
mpnsize(&hm, 4);
+/*@-noeffectuncon@*/
(void) rngc.rng->next(rngc.param, hm.data, hm.size);
+/*@=noeffectuncon@*/
printf(" RSA sign:");
#if HAVE_TIME_H
@@ -648,7 +657,9 @@ static void testDLAlgorithms(void)
#endif
mpnsize(&hm, 5);
+/*@-noeffectuncon@*/
(void) rngc.rng->next(rngc.param, hm.data, hm.size);
+/*@=noeffectuncon@*/
printf(" DSA sign:");
#if HAVE_TIME_H
@@ -678,7 +689,9 @@ static void testDLAlgorithms(void)
printf(" 100x in %.3f seconds\n", ttime);
#endif
(void) dlkp_pFree(&kp);
+/*@-usedef@*/
(void) dldp_pFree(&dp);
+/*@=usedef@*/
printf(" generating P (1024 bits) Q (768 bits) G with order (P-1)\n");
#if HAVE_TIME_H
@@ -775,3 +788,4 @@ int main(/*@unused@*/ int argc, /*@unused@*/ char *argv[])
return 0;
}
+/*@=compdef@*/