+strict # lclint level
# --- not-yet at strict level
--exportconst
--exportfcn
--exporttype
--exportvar
--warnmissingglobs
--internalglobs
+-exportconst # 4 occurences
+-exportfcn # 317 occurences
+-exporttype # 52 occurences
+-exportvar # 10 occurences
-protoparamname
-ansi-reserved-internal # goofy
--ptrarith
--bitwisesigned
--strictops
--sizeoftype
-
--mod-file-sys
+-ptrarith # 217 occurences
+-bitwisesigned # 69 occurences
+-strictops # 37 occurences
+-sizeoftype # 124 occurences
-impcheckedstrictglobs
-impcheckedstrictstatics
-strictbranchstate
--strictdestroy
+-strictdestroy # 18 occurences
--forblock
--ifblock
--whileblock
+-forblock # 10 occurences
+-ifblock # 406 occurences
+-whileblock # 23 occurences
-sys-dir-errors # 30 occurences
# --- not-yet at checks level
--predboolptr
-+enumint
--allglobs # painful
+-predboolptr # 121 occurences
+-allglobs # 219 occurences, painful
-ansi-reserved # goofy
--infloopsuncon # goofy
# don't-bother-me-yet parameters
-branchstate # 6 occurences
--mustfree # alloca is painful
# --- not-yet at standard level
--boolops
--predboolint
--type
+-boolops # 58 occurences
+-predboolint # 203 occurences
+-type # 844 occurences
# --- not-yet at weak level
-#+boolint
-#-boolops
-#+ignorequals
-#+ignoresigns
-#-mustfree
-#+longintegral
-#+matchanyintegral
-#-nullpass
-#-observertrans
-#-predboolint
-#-predboolothers
-#-retvalint
-#-retvalother
-#-shiftsigned
EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS Doxyfile.in Doxyheader README.DLL README.WIN32 beecrypt.def beecrypt.mcp beecrypt.rc beecrypt.spec config.h config.gas.h config.win.h javaglue.h
-lclintfiles = base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c elgamal.c endianness.c entropy.c fips180.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c javaglue.c md5.c memchunk.c mp32.c mp32barrett.c mp32number.c mp32prime.c mtprng.c rsa.c rsakp.c rsapk.c sha256.c timestamp.c
-
DOXYGEN = /usr/bin/doxygen
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
if (rng == (randomGenerator*) 0)
return -1;
- /*@-temptrans@*/
ctxt->rng = rng;
- /*@=temptrans@*/
+ if (ctxt->param) /* XXX error? */
+ free(ctxt->param);
ctxt->param = (randomGeneratorParam*) calloc(rng->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
{
register int rc;
+ /*@-mustfree@*/
if (ctxt == (randomGeneratorContext*) 0)
return -1;
if (ctxt->param == (randomGeneratorParam*) 0)
return -1;
+ /*@=mustfree@*/
rc = ctxt->rng->cleanup(ctxt->param);
if (hash == (hashFunction*) 0)
return -1;
- /*@-temptrans@*/
ctxt->algo = hash;
- /*@=temptrans@*/
+ if (ctxt->param) /* XXX error? */
+ free(ctxt->param);
ctxt->param = (hashFunctionParam*) calloc(hash->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
int hashFunctionContextFree(hashFunctionContext* ctxt)
{
+ /*@-mustfree@*/
if (ctxt == (hashFunctionContext*) 0)
return -1;
if (ctxt->param == (hashFunctionParam*) 0)
return -1;
+ /*@=mustfree@*/
free(ctxt->param);
mp32nfree(&dig);
+ /*@-mustfree@*/ /* dig.data is OK */
return rc;
+ /*@=mustfree@*/
}
/*@observer@*/ static const keyedHashFunction* keyedHashFunctionList[] =
if (mac == (keyedHashFunction*) 0)
return -1;
- /*@-temptrans@*/
ctxt->algo = mac;
- /*@=temptrans@*/
+ if (ctxt->param) /* XXX error? */
+ free(ctxt->param);
ctxt->param = (keyedHashFunctionParam*) calloc(mac->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
int keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt)
{
+ /*@-mustfree@*/
if (ctxt == (keyedHashFunctionContext*) 0)
return -1;
if (ctxt->param == (keyedHashFunctionParam*) 0)
return -1;
+ /*@=mustfree@*/
free(ctxt->param);
mp32nfree(&dig);
+ /*@-mustfree@*/ /* dig.data is OK */
return rc;
+ /*@=mustfree@*/
}
if (ciph == (blockCipher*) 0)
return -1;
- /*@-temptrans@*/
ctxt->algo = ciph;
- /*@=temptrans@*/
+ if (ctxt->param) /* XXX error? */
+ free(ctxt->param);
ctxt->param = (blockCipherParam*) calloc(ciph->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
int blockCipherContextFree(blockCipherContext* ctxt)
{
+ /*@-mustfree@*/
if (ctxt == (blockCipherContext*) 0)
return -1;
if (ctxt->param == (blockCipherParam*) 0)
return -1;
+ /*@=mustfree@*/
free(ctxt->param);
*/
typedef struct
{
- const randomGenerator* rng; /*!< global functions and parameters */
+/*@observer@*/ /*@dependent@*/ const randomGenerator* rng; /*!< global functions and parameters */
/*@only@*/ randomGeneratorParam* param; /*!< specific parameters */
} randomGeneratorContext;
* Initialize a randomGenerator instance.
*/
BEEDLLAPI
-int randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng)
+int randomGeneratorContextInit(randomGeneratorContext* ctxt, /*@observer@*/ /*@dependent@*/ const randomGenerator* rng)
/*@modifies ctxt->rng, ctxt->param @*/;
/** \ingroup PRNG_m
* Destroy a randomGenerator instance.
*/
BEEDLLAPI
-int randomGeneratorContextFree(randomGeneratorContext* ctxt)
+int randomGeneratorContextFree(/*@special@*/ randomGeneratorContext* ctxt)
+ /*@uses ctxt->rng @*/
+ /*@releases ctxt->param @*/
/*@modifies ctxt->rng, ctxt->param @*/;
#ifdef __cplusplus
*/
typedef struct
{
-/*@unused@*/ const hashFunction* algo; /*!< global functions and parameters */
-/*@unused@*/ hashFunctionParam* param; /*!< specific parameters */
+/*@observer@*/ /*@dependent@*/ const hashFunction* algo;/*!< global functions and parameters */
+/*@only@*/ hashFunctionParam* param; /*!< specific parameters */
} hashFunctionContext;
#ifdef __cplusplus
* Initialize a hashFunction instance.
*/
BEEDLLAPI
-int hashFunctionContextInit(hashFunctionContext* ctxt, const hashFunction* hash)
- /*@modifies ctxt */;
+int hashFunctionContextInit(hashFunctionContext* ctxt, /*@observer@*/ /*@dependent@*/ const hashFunction* hash)
+ /*@modifies ctxt->algo, ctxt->param */;
/** \ingroup HASH_m
* Destroy a hashFunction instance.
*/
BEEDLLAPI
-int hashFunctionContextFree(hashFunctionContext* ctxt)
- /*@modifies ctxt */;
+int hashFunctionContextFree(/*@special@*/ hashFunctionContext* ctxt)
+ /*@releases ctxt->param @*/
+ /*@modifies ctxt->algo, ctxt->param */;
/** \ingroup HASH_m
*/
*/
typedef struct
{
-/*@unused@*/ const keyedHashFunction* algo; /*!< global functions and parameters */
-/*@unused@*/ keyedHashFunctionParam* param; /*!< specific parameters */
+/*@observer@*/ /*@dependent@*/ const keyedHashFunction* algo; /*!< global functions and parameters */
+/*@only@*/ keyedHashFunctionParam* param; /*!< specific parameters */
} keyedHashFunctionContext;
#ifdef __cplusplus
* Initialize a keyedHashFunction instance.
*/
BEEDLLAPI
-int keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, const keyedHashFunction* mac)
- /*@modifies ctxt @*/;
+int keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, /*@observer@*/ /*@dependent@*/ const keyedHashFunction* mac)
+ /*@modifies ctxt->algo, ctxt->param @*/;
/** \ingroup HMAC_m
* Destroy a keyedHashFunction instance.
*/
BEEDLLAPI
-int keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt)
- /*@modifies ctxt @*/;
+int keyedHashFunctionContextFree(/*@special@*/ keyedHashFunctionContext* ctxt)
+ /*@uses ctxt->algo @*/
+ /*@releases ctxt->param @*/
+ /*@modifies ctxt->algo, ctxt->param @*/;
/** \ingroup HMAC_m
*/
*/
typedef enum
{
- /*@-enummemuse@*/
ECB,
- /*@=enummemuse@*/
CBC
} cipherMode;
*/
typedef struct
{
- const blockCipher* algo; /*!< global functions and parameters */
- blockCipherParam* param; /*!< specific parameters */
+/*@observer@*/ /*@dependent@*/ const blockCipher* algo; /*!< global functions and parameters */
+/*@only@*/ blockCipherParam* param; /*!< specific parameters */
} blockCipherContext;
#ifdef __cplusplus
* Initialize a blockCipher instance.
*/
BEEDLLAPI
-int blockCipherContextInit(blockCipherContext* ctxt, const blockCipher* ciph)
- /*@modifies ctxt @*/;
+int blockCipherContextInit(blockCipherContext* ctxt, /*@observer@*/ /*@dependent@*/ const blockCipher* ciph)
+ /*@modifies ctxt->algo, ctxt->param @*/;
/** \ingroup BC_m
*/
* Destroy a blockCipher instance.
*/
BEEDLLAPI
-int blockCipherContextFree(blockCipherContext* ctxt)
- /*@modifies ctxt @*/;
+int blockCipherContextFree(/*@special@*/ blockCipherContext* ctxt)
+ /*@releases ctxt->param @*/
+ /*@modifies ctxt->algo, ctxt->param @*/;
#ifdef __cplusplus
}
mp32nzero(&ctxt->pub);
mp32nzero(&ctxt->pri);
+ /*@-modobserver@*/
if (hashFunctionContextInit(&ctxt->hash, params->hash))
return -1;
if (keyedHashFunctionContextInit(&ctxt->mac, params->mac))
return -1;
+ /*@=modobserver@*/
ctxt->cipherkeybits = params->cipherkeybits;
ctxt->mackeybits = params->mackeybits;
mp32nfree(&ctxt->pub);
mp32nfree(&ctxt->pri);
+ /*@-mustfree -modobserver @*/ /* ctxt is OK */
if (hashFunctionContextFree(&ctxt->hash))
return -1;
return -1;
return 0;
+ /*@=mustfree =modobserver @*/
}
/**
/* compute the shared secret, Diffie-Hellman style */
mp32nzero(&secret);
if (dlsvdp_pDHSecret(&ctxt->param, privkey, pubkey, &secret))
+ /*@-mustfree@*/ /* FIX: secret.data leak? */
return -1;
+ /*@=mustfree@*/
/* compute the hash of the message (ephemeral public) key and the shared secret */
mp32nzero(&digest);
mp32nwipe(&digest);
mp32nfree(&digest);
+ /*@-mustfree@*/ /* {secret,digest}.data are OK */
return rc;
+ /*@=mustfree@*/
}
memchunk* dhaes_pContextEncrypt(dhaes_pContext* ctxt, mp32number* ephemeralPublicKey, mp32number* mac, const memchunk* cleartext, randomGeneratorContext* rng)
mp32nwipe(&ephemeralPrivateKey);
mp32nfree(&ephemeralPrivateKey);
+ /*@-mustfree@*/ /* ephemeralPrivateKey.data is OK */
return ciphertext;
+ /*@=mustfree@*/
}
memchunk* dhaes_pContextDecrypt(dhaes_pContext* ctxt, const mp32number* ephemeralPublicKey, const mp32number* mac, const memchunk* ciphertext)
goto decrypt_end;
paddedtext->size = ciphertext->size;
+ /*@-mustfree@*/ /* paddedtext->data is OK */
paddedtext->data = (byte*) malloc(ciphertext->size);
+ /*@=mustfree@*/
if (paddedtext->data == (byte*) 0)
{
/**
*/
static int dldp_pgoqGenerator_w(dldp_p* dp, randomGeneratorContext* rgc, /*@out@*/ uint32* wksp)
- /*@modifies dp, wksp @*/;
+ /*@modifies dp->g, wksp @*/;
/**
*/
static int dldp_pgonGenerator_w(dldp_p* dp, randomGeneratorContext* rgc, /*@out@*/ uint32* wksp)
- /*@modifies dp, wksp @*/;
+ /*@modifies dp->g, wksp @*/;
int dldp_pPrivate(const dldp_p* dp, randomGeneratorContext* rgc, mp32number* x)
{
int dldp_pFree(dldp_p* dp)
{
+ /*@-usedef -compdef@*/
mp32bfree(&dp->p);
mp32bfree(&dp->q);
mp32nfree(&dp->g);
mp32nfree(&dp->r);
mp32bfree(&dp->n);
+ /*@=usedef =compdef@*/
return 0;
}
*/
BEEDLLAPI
int dldp_pInit(dldp_p* dp)
- /*@modifies dp */;
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n @*/;
/**
*/
BEEDLLAPI
-int dldp_pFree(dldp_p* dp)
- /*@modifies dp */;
+int dldp_pFree(/*@special@*/ dldp_p* dp)
+ /*@releases dp->p.modl, dp->q.modl, dp->n.modl @*/
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n @*/;
/**
*/
BEEDLLAPI
int dldp_pCopy(dldp_p* dst, const dldp_p* src)
- /*@modifies dst */;
+ /*@modifies dst @*/;
/*
* Functions for generating keys
*/
BEEDLLAPI /*@unused@*/
int dldp_pPrivate(const dldp_p* dp, randomGeneratorContext* rgc, mp32number* x)
- /*@modifies rgc, x */;
+ /*@modifies rgc, x @*/;
/**
*/
BEEDLLAPI /*@unused@*/
-int dldp_pPublic (const dldp_p* dp, const mp32number* x, mp32number* y)
- /*@modifies y */;
+int dldp_pPublic(const dldp_p* dp, const mp32number* x, mp32number* y)
+ /*@modifies y @*/;
/**
*/
BEEDLLAPI
-int dldp_pPair (const dldp_p* dp, randomGeneratorContext* rgc, mp32number* x, mp32number* y)
- /*@modifies rgc, x, y */;
+int dldp_pPair(const dldp_p* dp, randomGeneratorContext* rgc, mp32number* x, mp32number* y)
+ /*@modifies rgc, x, y @*/;
/*
* Function for comparing domain parameters
/**
*/
BEEDLLAPI
-int dldp_pEqual (const dldp_p* a, const dldp_p* b)
+int dldp_pEqual(const dldp_p* a, const dldp_p* b)
/*@*/;
/*
/**
*/
BEEDLLAPI
-int dldp_pgoqMake (dldp_p* dp, randomGeneratorContext* rgc, uint32 psize, uint32 qsize, int cofactor)
- /*@modifies dp, rgc */;
+int dldp_pgoqMake(dldp_p* dp, randomGeneratorContext* rgc, uint32 psize, uint32 qsize, int cofactor)
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
/**
*/
BEEDLLAPI /*@unused@*/
-int dldp_pgoqMakeSafe (dldp_p* dp, randomGeneratorContext* rgc, uint32 psize)
- /*@modifies dp, rgc */;
+int dldp_pgoqMakeSafe(dldp_p* dp, randomGeneratorContext* rgc, uint32 psize)
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
/**
*/
BEEDLLAPI /*@unused@*/
int dldp_pgoqGenerator(dldp_p* dp, randomGeneratorContext* rgc)
- /*@modifies dp, rgc */;
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
/**
*/
BEEDLLAPI
-int dldp_pgoqValidate (const dldp_p*, randomGeneratorContext* rgc, int cofactor)
+int dldp_pgoqValidate(const dldp_p*, randomGeneratorContext* rgc, int cofactor)
/*@modifies rgc @*/;
/*
/**
*/
BEEDLLAPI
-int dldp_pgonMake (dldp_p* dp, randomGeneratorContext* rgc, uint32 psize, uint32 qsize)
- /*@modifies dp, rgc */;
+int dldp_pgonMake(dldp_p* dp, randomGeneratorContext* rgc, uint32 psize, uint32 qsize)
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
/**
*/
BEEDLLAPI /*@unused@*/
-int dldp_pgonMakeSafe (dldp_p* dp, randomGeneratorContext* rgc, uint32 psize)
- /*@modifies dp, rgc */;
+int dldp_pgonMakeSafe(dldp_p* dp, randomGeneratorContext* rgc, uint32 psize)
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
/**
*/
BEEDLLAPI /*@unused@*/
int dldp_pgonGenerator(dldp_p* dp, randomGeneratorContext* rgc)
- /*@modifies dp, rgc */;
+ /*@modifies dp->p, dp->q, dp->r, dp->g, dp->n, rgc @*/;
/**
*/
BEEDLLAPI
-int dldp_pgonValidate (const dldp_p* dp, randomGeneratorContext* rgc)
+int dldp_pgonValidate(const dldp_p* dp, randomGeneratorContext* rgc)
/*@modifies rgc @*/;
#ifdef __cplusplus
int dlkp_pFree(dlkp_p* kp)
{
+ /*@-usereleased -compdef @*/ /* kp->param.{p,q,n}.modl is OK */
if (dldp_pFree(&kp->param) < 0)
+ return -1;
mp32nfree(&kp->y);
mp32nfree(&kp->x);
return 0;
+ /*@=usereleased =compdef @*/
}
int dlkp_pCopy(dlkp_p* dst, const dlkp_p* src)
int dlpk_pFree(dlpk_p* pk)
{
+ /*@-usereleased -compdef @*/ /* pk->param.{p,q,n}.modl is OK */
if (dldp_pFree(&pk->param) < 0)
return -1;
mp32nfree(&pk->y);
return 0;
+ /*@=usereleased =compdef @*/
}
int dlpk_pCopy(dlpk_p* dst, const dlpk_p* src)
*/
BEEDLLAPI /*@unused@*/
int writeByte(javabyte b, FILE* ofp)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int writeShort(javashort s, FILE* ofp)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/**
/*@-exportlocal@*/
BEEDLLAPI
int writeInt(javaint i, FILE* ofp)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/*@=exportlocal@*/
*/
BEEDLLAPI /*@unused@*/
int writeLong(javalong l, FILE* ofp)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/**
/*@-exportlocal@*/
BEEDLLAPI
int writeChar(javachar c, FILE* ofp)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/*@=exportlocal@*/
*/
BEEDLLAPI /*@unused@*/
int writeInts(const javaint* i, FILE* ofp, int count)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int writeChars(const javachar* c, FILE* ofp, int count)
+ /*@globals fileSystem @*/
/*@modifies ofp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readByte(/*@out@*/ javabyte* b, FILE* ifp)
+ /*@globals fileSystem @*/
/*@modifies b, ifp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readShort(/*@out@*/ javashort* s, FILE* ifp)
+ /*@globals fileSystem @*/
/*@modifies s, ifp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readInt(/*@out@*/ javaint* i, FILE* ifp)
+ /*@globals fileSystem @*/
/*@modifies i, ifp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readLong(/*@out@*/ javalong* l, FILE* ifp)
+ /*@globals fileSystem @*/
/*@modifies l, ifp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readChar(/*@out@*/ javachar* c, FILE* ifp)
+ /*@globals fileSystem @*/
/*@modifies c, ifp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readInts(/*@out@*/ javaint* i, FILE* ifp, int count)
+ /*@globals fileSystem @*/
/*@modifies i, ifp, fileSystem */;
/**
*/
BEEDLLAPI /*@unused@*/
int readChars(/*@out@*/ javachar* c, FILE* ifp, int count)
+ /*@globals fileSystem @*/
/*@modifies c, ifp, fileSystem */;
#ifdef __cplusplus
* @return
*/
static int statdevice(const char *device)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
struct stat s;
* @return
*/
static int opendevice(const char *device)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
register int fd;
* @param size
* @return
*/
+/*@-globuse@*/ /* aio_foo annotations aren't correct */
static int entropy_randombits(int fd, int timeout, uint32* data, int size)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
+/*@=globuse@*/
{
register byte* bytedata = (byte*) data;
register int bytesize = (((unsigned)size) << 2);
while (bytesize)
{
#if ENABLE_AIO
+ /*@-mustfree@*/ /* my_aiocb.aio_buf is OK */
my_aiocb.aio_buf = bytedata;
+ /*@=mustfree@*/
my_aiocb.aio_nbytes = bytesize;
/*@-moduncon@*/
* @return
*/
static int entropy_ttybits(int fd, uint32* data, int size)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
uint32 randombits = ((uint32)size) << 5;
#if HAVE_DEV_RANDOM
int entropy_dev_random(uint32* data, int size)
+ /*@globals dev_random_fd @*/
/*@modifies dev_random_fd @*/
{
const char* timeout_env = getenv("BEECRYPT_ENTROPY_RANDOM_TIMEOUT");
#if HAVE_DEV_URANDOM
int entropy_dev_urandom(uint32* data, int size)
+ /*@globals dev_urandom_fd @*/
/*@modifies dev_urandom_fd @*/
{
const char* timeout_env = getenv("BEECRYPT_ENTROPY_URANDOM_TIMEOUT");
#if HAVE_DEV_TTY
int entropy_dev_tty(uint32* data, int size)
+ /*@globals dev_tty_fd @*/
/*@modifies dev_tty_fd @*/
{
register int rc;
/** \ingroup ES_audio_m ES_m
*/
int entropy_dev_audio (uint32* data, int size)
- /*@*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies data, fileSystem, internalState @*/;
#endif
#if HAVE_DEV_DSP
/** \ingroup ES_dsp_m ES_m
*/
int entropy_dev_dsp (uint32* data, int size)
- /*@modifies data, internalState @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies data, fileSystem, internalState @*/;
#endif
#if HAVE_DEV_RANDOM
/** \ingroup ES_random_m ES_m
*/
int entropy_dev_random(uint32* data, int size)
- /*@modifies data, internalState @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies data, fileSystem, internalState @*/;
#endif
#if HAVE_DEV_URANDOM
/** \ingroup ES_urandom_m ES_m
*/
int entropy_dev_urandom(uint32* data, int size)
- /*@modifies data, internalState @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies data, fileSystem, internalState @*/;
#endif
#if HAVE_DEV_TTY
/** \ingroup ES_tty_m ES_m
*/
int entropy_dev_tty (uint32* data, int size)
- /*@modifies data, internalState @*/;
+ /*@globals fileSystem, internalState @*/
+ /*@modifies data, fileSystem, internalState @*/;
#endif
#endif
/* For now, I'm lazy ... */
/*@-nullpass -nullret -shiftsigned -usedef -temptrans -freshtrans @*/
/*@-noeffectuncon -globs -globnoglobs -modunconnomods -modnomods @*/
+/*@-mustfree@*/
#ifndef WORDS_BIGENDIAN
# define WORDS_BIGENDIAN 0
(*env)->ReleaseByteArrayElements(env, outputArray, output, 0);
}
+/*@=mustfree@*/
/*@=noeffectuncon =globs =globnoglobs =modunconnomods =modnomods @*/
/*@=nullpass =nullret =shiftsigned =usedef =temptrans =freshtrans @*/
# include <malloc.h>
#endif
-/*@-compdef@*/ /* tmp-?data is undefined */
+/*@-compdef@*/ /* tmp->data is undefined */
memchunk* memchunkAlloc(int size)
{
memchunk* tmp = (memchunk*) calloc(1, sizeof(memchunk));
if (tmp)
{
tmp->size = size;
+ /*@-mustfree@*/ /* tmp->data is OK */
tmp->data = (byte*) malloc(size);
+ /*@=mustfree@*/
if (tmp->data == (byte*) 0)
{
*/
BEEDLLAPI /*@unused@*/
void mp32print(uint32 xsize, const uint32* xdata)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
BEEDLLAPI
void mp32println(uint32 xsize, const uint32* xdata)
+ /*@globals fileSystem @*/
/*@modifies fileSystem @*/;
#ifdef __cplusplus
#include <stdio.h>
-/*@-nullstate@*/ /* b->mu may be null @*/
/**
* mp32bzero
*/
b->modl = (uint32*) 0;
b->mu = (uint32*) 0;
}
-/*@=nullstate@*/
-/*@-nullstate@*/ /* b->mu may be null @*/
+/*@-nullstate@*/ /* b->modl may be null @*/
/**
- * mp32binit
- * allocates the data words for an mp32barrett structure
+ * Allocates the data words for an mp32barrett structure.
* will allocate 2*size+1 words
*/
void mp32binit(mp32barrett* b, uint32 size)
{
b->size = size;
+ if (b->modl)
+ free(b->modl);
b->modl = (uint32*) calloc(2*size+1, sizeof(uint32));
if (b->modl != (uint32*) 0)
}
/*@=nullstate@*/
-/*@-nullstate@*/ /* b->mu may be null @*/
/**
* mp32bfree
*/
}
b->size = 0;
}
-/*@=nullstate@*/
-/*@-nullstate -compdef @*/ /* b->mu may be null @*/
+/*@-nullstate -compdef @*/ /* b->modl may be null @*/
void mp32bcopy(mp32barrett* b, const mp32barrett* copy)
{
register uint32 size = copy->size;
}
/*@=nullstate =compdef @*/
-/*@-nullstate -compdef @*/ /* b->mu may be null @*/
+/*@-nullstate -compdef @*/ /* b->modl may be null @*/
/**
* mp32bset
*/
}
/*@=nullstate =compdef @*/
-/*@-nullstate -compdef @*/ /* b->mu may be null @*/
+/*@-nullstate -compdef @*/ /* b->modl may be null @*/
void mp32bsethex(mp32barrett* b, const char* hex)
{
uint32 length = strlen(hex);
*dividend = (uint32) (1 << shift);
mp32zero(size*2, dividend+1);
mp32ndivmod(divmod, size*2+1, dividend, size, b->modl, workspace);
+ /*@-nullpass@*/ /* b->mu may be NULL */
mp32copy(size+1, b->mu, divmod+1);
+ /*@=nullpass@*/
/* de-normalize */
mp32rshift(size, b->modl, shift);
}
register const uint32* src = xdata+b->size+1;
register uint32* dst = wksp +b->size+1;
+ /*@-nullpass@*/ /* b->mu may be NULL */
rc = mp32setmul(sp, dst, b->mu, *(--src));
*(--dst) = rc;
}
else
*(--dst) = 0;
+ /*@=nullpass@*/
/* q3 is one word larger than b->modl */
/* r2 is (2*size+1) words, of which we only needs the (size+1) lsw's */
/*@-nullpass@*/ /* slide may be NULL */
mp32bslide_w(b, xsize, xdata, slide, wksp);
+ /*@-internalglobs -mods@*/ /* noisy */
mp32bpowmodsld_w(b, slide, psize, pdata-1, result, wksp);
+ /*@=internalglobs =mods@*/
free(slide);
/*@=nullpass@*/
mp32nsize(y, size);
/*@-nullpass@*/ /* temp may be NULL */
+ /*@-internalglobs -mods@*/ /* noisy */
mp32bpowmodsld_w(b, slide, pow->size, pow->data, y->data, temp);
+ /*@=internalglobs =mods@*/
free(temp);
/*@=nullpass@*/
{
uint32 size;
/*@owned@*/ uint32* modl; /* (size) words */
-/*@dependent@*/ uint32* mu; /* (size+1) words */
+/*@dependent@*/ /*@null@*/ uint32* mu; /* (size+1) words */
} mp32barrett;
#ifdef __cplusplus
*/
BEEDLLAPI
void mp32bzero(/*@out@*/ mp32barrett* b)
- /*@modifies b @*/;
+ /*@modifies b->size, b->modl, b->mu @*/;
/**
*/
BEEDLLAPI
void mp32binit(mp32barrett* b, uint32 size)
- /*@modifies b @*/;
+ /*@modifies b->size, b->modl, b->mu @*/;
/**
*/
BEEDLLAPI
-void mp32bfree(mp32barrett* b)
- /*@modifies b @*/;
+void mp32bfree(/*@special@*/ mp32barrett* b)
+ /*@uses b->size, b->modl @*/
+ /*@releases b->modl @*/
+ /*@modifies b->size, b->modl, b->mu @*/;
/**
*/
BEEDLLAPI
void mp32bcopy(mp32barrett* b, const mp32barrett* copy)
- /*@modifies b @*/;
+ /*@modifies b->size, b->modl, b->mu @*/;
/**
*/
BEEDLLAPI
void mp32bset(mp32barrett* b, uint32 size, const uint32* data)
- /*@modifies b @*/;
+ /*@modifies b->size, b->modl, b->mu @*/;
/**
*/
BEEDLLAPI /*@unused@*/
void mp32bsethex(mp32barrett* b, const char* hex)
- /*@modifies b @*/;
+ /*@modifies b->size, b->modl, b->mu @*/;
/**
*/
*/
BEEDLLAPI
void mp32bmu_w(mp32barrett* b, /*@out@*/ uint32* wksp)
- /*@modifies b, wksp @*/;
+ /*@modifies b->size, b->modl, b->mu, wksp @*/;
/**
*/
/*@-exportlocal@*/
BEEDLLAPI
void mp32bpowmodsld_w(const mp32barrett* b, const uint32* slide, uint32 psize, const uint32* pdata, /*@out@*/ uint32* result, /*@out@*/ uint32* wksp)
+ /*@globals internalState @*/
/*@modifies result, wksp, internalState @*/;
/*@=exportlocal@*/
void mp32ninit(mp32number* n, uint32 size, const uint32* data)
{
n->size = size;
+ if (n->data)
+ {
+ free(n->data);
+ n->data = (uint32*) 0;
+ }
n->data = (uint32*) malloc(size * sizeof(uint32));
if (n->data && data)
typedef struct
{
uint32 size;
-/*@only@*/ uint32* data;
+/*@owned@*/ uint32* data;
} mp32number;
#ifdef __cplusplus
int rsakpFree(rsakp* kp)
{
+ /*@-usereleased -compdef @*/ /* kp->param.{n,p,q}.modl is OK */
mp32bfree(&kp->n);
mp32nfree(&kp->e);
mp32nfree(&kp->d);
mp32nfree(&kp->c);
return 0;
+ /*@=usereleased =compdef @*/
}
int rsakpCopy(rsakp* dst, const rsakp* src)
int rsapkFree(rsapk* pk)
{
+ /*@-usereleased -compdef @*/ /* pk->n.modl is OK */
mp32bfree(&pk->n);
mp32nfree(&pk->e);
return 0;
+ /*@=usereleased =compdef @*/
}
int rsapkCopy(rsapk* dst, const rsapk* src)
/**
*/
static void sha256Finish(register sha256Param *p)
- /*@modifies p @*/
+ /*@globals internalState @*/
+ /*@modifies p, internalState @*/
{
register byte *ptr = ((byte *) p->data) + p->offset++;
/*@-exportlocal@*/
BEEDLLAPI
void sha256Process(sha256Param* p)
+ /*@globals internalState @*/
/*@modifies p, internalState @*/;
/*@=exportlocal@*/
*/
BEEDLLAPI
int sha256Update (sha256Param* p, const byte* data, int size)
- /*@modifies p @*/;
+ /*@globals internalState @*/
+ /*@modifies p, internalState @*/;
/** \ingroup HASH_sha256_m
*/
BEEDLLAPI
int sha256Digest (sha256Param* p, /*@out@*/ uint32* data)
- /*@modifies p, data @*/;
+ /*@globals internalState @*/
+ /*@modifies p, data, internalState @*/;
#ifdef __cplusplus
}
memset(&rngc, 0, sizeof(randomGeneratorContext));
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
register int rc;
free(temp);
/*@=nullpass =nullptrarith @*/
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rngc);
+ /*@=modobserver@*/
return rc;
}
memset(&rngc, 0, sizeof(randomGeneratorContext));
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
mp32number digest, r, s;
mp32nfree(&r);
mp32nfree(&s);
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rngc);
+ /*@=modobserver@*/
}
return rc;
}
memset(&rngc, 0, sizeof(randomGeneratorContext));
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
mp32number digest, r, s;
mp32nfree(&r);
mp32nfree(&s);
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rngc);
+ /*@=modobserver@*/
}
return rc;
}
#endif
/*@unused@*/ static int testVectorRSA(void)
- /*@*/
+ /*@globals fileSystem @*/
+ /*@modifies fileSystem @*/
{
int rc = 0;
memset(&rngc, 0, sizeof(randomGeneratorContext));
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
rsakp kp;
mp32number digest, s;
(void) rsakpFree(&kp);
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rngc);
+ /*@=modobserver@*/
return rc;
}
memset(&rc, 0, sizeof(randomGeneratorContext));
memset(&dp, 0, sizeof(dldp_p));
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
register int result;
mp32number gq;
mp32nfree(&gq);
(void) dldp_pFree(&dp);
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rc);
+ /*@=modobserver@*/
return result;
}
memset(¶m, 0, sizeof(param));
(void) sha256Reset(¶m);
+ /*@-internalglobs -mods @*/ /* noisy */
(void) sha256Update(¶m, (const unsigned char*) "abc", 3);
(void) sha256Digest(¶m, digest);
+ /*@=internalglobs =mods @*/
return mp32eq(8, expect, digest);
}
}
static void testBlockCiphers(void)
- /*@globals keyValue @*/
- /*@modifies internalState @*/
+ /*@globals fileSystem, internalState, keyValue @*/
+ /*@modifies fileSystem, internalState @*/
{
int i, k;
}
static void testHashFunctions(void)
- /*@modifies internalState */
+ /*@globals fileSystem, internalState */
+ /*@modifies fileSystem, internalState */
{
int i, j;
printf(" %s:\n", tmp->name);
+ /*@-nullpass -modobserver @*/
if (hashFunctionContextInit(&hfc, tmp) == 0)
+ /*@=nullpass =modobserver @*/
{
for (j = 0; j < 4; j++)
{
#endif
}
+ /*@-modobserver@*/
(void) hashFunctionContextFree(&hfc);
+ /*@=modobserver@*/
}
mp32nfree(&digest);
}
}
+ free(data);
}
}
static void testExpMods(void)
- /*@modifies internalState */
+ /*@globals fileSystem, internalState */
+ /*@modifies fileSystem, internalState */
{
/*@observer@*/ static const char* p_512 = "ffcf0a0767f18f9b659d92b9550351430737c3633dc6ae7d52445d937d8336e07a7ccdb119e9ab3e011a8f938151230e91187f84ac05c3220f335193fc5e351b";
mp32nzero(&y);
mp32nzero(&tmp);
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
int i;
#if HAVE_TIME_H
mp32nfree(&y);
mp32nfree(&tmp);
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rngc);
+ /*@=modobserver@*/
}
else
printf("random generator setup problem\n");
}
static void testDLParams(void)
- /*@modifies internalState */
+ /*@globals fileSystem, internalState */
+ /*@modifies fileSystem, internalState */
{
randomGeneratorContext rc;
dldp_p dp;
memset(&rc, 0, sizeof(randomGeneratorContext));
memset(&dp, 0, sizeof(dldp_p));
- /*@-nullpass@*/
+ /*@-nullpass -modobserver @*/
if (randomGeneratorContextInit(&rc, randomGeneratorDefault()) == 0)
- /*@=nullpass@*/
+ /*@=nullpass =modobserver @*/
{
#if HAVE_TIME_H
double ttime;
#if HAVE_TIME_H
tstart = clock();
#endif
+
+ /*@-usereleased -compdef @*/ /* annotate dldp_pgonMake correctly */
(void) dldp_pgonMake(&dp, &rc, 768 >> 5, 512 >> 5);
#if HAVE_TIME_H
tstop = clock();
printf("G = "); (void) fflush(stdout); mp32println(dp.g.size, dp.g.data);
printf("N = "); (void) fflush(stdout); mp32println(dp.n.size, dp.n.modl);
(void) dldp_pFree(&dp);
+ /*@=usereleased =compdef @*/
+ /*@-modobserver@*/
(void) randomGeneratorContextFree(&rc);
+ /*@=modobserver@*/
}
}
}
#else
int main(/*@unused@*/int argc, /*@unused@*/char *argv[])
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/
{
int i, j;