| beecrypt.h | | beecrypt.h | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| * These API functions provide an abstract way for using most of | | * These API functions provide an abstract way for using most of | |
| * the various algorithms implemented by the library. | | * the various algorithms implemented by the library. | |
| * | | * | |
| * \author Bob Deblier <bob.deblier@pandora.be> | | * \author Bob Deblier <bob.deblier@pandora.be> | |
| * \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m | | * \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m | |
| */ | | */ | |
| | | | |
| #ifndef _BEECRYPT_H | | #ifndef _BEECRYPT_H | |
| #define _BEECRYPT_H | | #define _BEECRYPT_H | |
| | | | |
|
| #include "beecrypt.api.h" | | #include "beecrypt/api.h" | |
| | | | |
|
| #include "memchunk.h" | | #include "beecrypt/memchunk.h" | |
| #include "mpnumber.h" | | #include "beecrypt/mpnumber.h" | |
| | | | |
| /* | | /* | |
| * Entropy Sources | | * Entropy Sources | |
| */ | | */ | |
| | | | |
| /*!\typedef entropyNext | | /*!\typedef entropyNext | |
| * \brief Prototype definition for an entropy-generating function. | | * \brief Prototype definition for an entropy-generating function. | |
| * \ingroup ES_m | | * \ingroup ES_m | |
| */ | | */ | |
| typedef int (*entropyNext)(byte*, size_t); | | typedef int (*entropyNext)(byte*, size_t); | |
| | | | |
| /*!\brief This struct holds information and pointers to code specific to ea
ch | | /*!\brief This struct holds information and pointers to code specific to ea
ch | |
| * source of entropy. | | * source of entropy. | |
| * \ingroup ES_m | | * \ingroup ES_m | |
| */ | | */ | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI entropySource | |
| | | #else | |
| | | struct _entropySource | |
| | | #endif | |
| { | | { | |
| /*!\var name | | /*!\var name | |
| * \brief The entropy source's name. | | * \brief The entropy source's name. | |
| */ | | */ | |
| const char* name; | | const char* name; | |
| /*!\var next | | /*!\var next | |
| * \brief Points to the function which produces the entropy. | | * \brief Points to the function which produces the entropy. | |
| */ | | */ | |
| const entropyNext next; | | const entropyNext next; | |
|
| } entropySource; | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _entropySource entropySource; | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /*!\fn int entropySourceCount() | | /*!\fn int entropySourceCount() | |
| * \brief This function returns the number of entropy sources implemented b
y | | * \brief This function returns the number of entropy sources implemented b
y | |
| * the library. | | * the library. | |
| * \return The number of implemented entropy sources. | | * \return The number of implemented entropy sources. | |
| */ | | */ | |
| | | | |
| skipping to change at line 152 | | skipping to change at line 160 | |
| * provided they each use their own randomGeneratorParam parameters, a chun
k | | * provided they each use their own randomGeneratorParam parameters, a chun
k | |
| * of memory which must be at least as large as indicated by the paramsize | | * of memory which must be at least as large as indicated by the paramsize | |
| * field. | | * field. | |
| * | | * | |
| */ | | */ | |
| | | | |
| /*!\brief This struct holds information and pointers to code specific to ea
ch | | /*!\brief This struct holds information and pointers to code specific to ea
ch | |
| * pseudo-random number generator. | | * pseudo-random number generator. | |
| * \ingroup PRNG_m | | * \ingroup PRNG_m | |
| */ | | */ | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI randomGenerator | |
| | | #else | |
| | | struct _randomGenerator | |
| | | #endif | |
| { | | { | |
| /*!\var name | | /*!\var name | |
| * \brief The random generator's name. | | * \brief The random generator's name. | |
| */ | | */ | |
| const char* name; | | const char* name; | |
| /*!\var paramsize | | /*!\var paramsize | |
| * \brief The size of the random generator's parameters. | | * \brief The size of the random generator's parameters. | |
| * \note The implementor should set this by using sizeof(<struct hol
ding | | * \note The implementor should set this by using sizeof(<struct hol
ding | |
| * random generator's parameters>). | | * random generator's parameters>). | |
| */ | | */ | |
| | | | |
| skipping to change at line 180 | | skipping to change at line 192 | |
| */ | | */ | |
| const randomGeneratorSeed seed; | | const randomGeneratorSeed seed; | |
| /*!\var seed | | /*!\var seed | |
| * \brief Points to the function which generates the random data. | | * \brief Points to the function which generates the random data. | |
| */ | | */ | |
| const randomGeneratorNext next; | | const randomGeneratorNext next; | |
| /*!\var seed | | /*!\var seed | |
| * \brief Points to the cleanup function. | | * \brief Points to the cleanup function. | |
| */ | | */ | |
| const randomGeneratorCleanup cleanup; | | const randomGeneratorCleanup cleanup; | |
|
| } randomGenerator; | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _randomGenerator randomGenerator; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * You can use the following functions to find random generators implemente
d by | | * You can use the following functions to find random generators implemente
d by | |
| * the library: | | * the library: | |
| * | | * | |
| * randomGeneratorCount returns the number of generators available. | | * randomGeneratorCount returns the number of generators available. | |
| * | | * | |
| * randomGeneratorGet returns the random generator with a given index (star
ting | | * randomGeneratorGet returns the random generator with a given index (star
ting | |
| * at zero, up to randomGeneratorCount() - 1), or NULL if the index was out
of | | * at zero, up to randomGeneratorCount() - 1), or NULL if the index was out
of | |
| * bounds. | | * bounds. | |
| | | | |
| skipping to change at line 218 | | skipping to change at line 234 | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * The struct 'randomGeneratorContext' is used to contain both the function
al | | * The struct 'randomGeneratorContext' is used to contain both the function
al | |
| * part (the randomGenerator), and its parameters. | | * part (the randomGenerator), and its parameters. | |
| */ | | */ | |
| | | | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI randomGeneratorContext | |
| | | #else | |
| | | struct _randomGeneratorContext | |
| | | #endif | |
| { | | { | |
| const randomGenerator* rng; | | const randomGenerator* rng; | |
| randomGeneratorParam* param; | | randomGeneratorParam* param; | |
|
| } randomGeneratorContext; | | | |
| | | #ifdef __cplusplus | |
| | | randomGeneratorContext(); | |
| | | randomGeneratorContext(const randomGenerator*); | |
| | | ~randomGeneratorContext(); | |
| | | #endif | |
| | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _randomGeneratorContext randomGeneratorContext; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * The following functions can be used to initialize and free a | | * The following functions can be used to initialize and free a | |
| * randomGeneratorContext. Initializing will allocate a buffer of the size | | * randomGeneratorContext. Initializing will allocate a buffer of the size | |
| * required by the randomGenerator, freeing will deallocate that buffer. | | * required by the randomGenerator, freeing will deallocate that buffer. | |
| */ | | */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int randomGeneratorContextInit(randomGeneratorContext*, const randomGenerat
or*); | | int randomGeneratorContextInit(randomGeneratorContext*, const randomGenerat
or*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int randomGeneratorContextFree(randomGeneratorContext*); | | int randomGeneratorContextFree(randomGeneratorContext*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int randomGeneratorContextNext(randomGeneratorContext*, byte*, size_t); | | int randomGeneratorContextNext(randomGeneratorContext*, byte*, size_t); | |
|
| | | BEECRYPTAPI | |
| | | int randomGeneratorContextSeed(randomGeneratorContext*, const byte*, size_t | |
| | | ); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * Hash Functions | | * Hash Functions | |
| */ | | */ | |
| | | | |
| /*!typedef void hashFunctionParam | | /*!typedef void hashFunctionParam | |
| | | | |
| skipping to change at line 268 | | skipping to change at line 300 | |
| /* | | /* | |
| * The struct 'hashFunction' holds information and pointers to code specifi
c | | * The struct 'hashFunction' holds information and pointers to code specifi
c | |
| * to each hash function. Specific hash functions MAY be written to be | | * to each hash function. Specific hash functions MAY be written to be | |
| * multithread-safe. | | * multithread-safe. | |
| * | | * | |
| * NOTE: data MUST have a size (in bytes) of at least 'digestsize' as descr
ibed | | * NOTE: data MUST have a size (in bytes) of at least 'digestsize' as descr
ibed | |
| * in the hashFunction struct. | | * in the hashFunction struct. | |
| * NOTE: for safety reasons, after calling digest, each specific implementa
tion | | * NOTE: for safety reasons, after calling digest, each specific implementa
tion | |
| * MUST reset itself so that previous values in the parameters are erased. | | * MUST reset itself so that previous values in the parameters are erased. | |
| */ | | */ | |
|
| | | #ifdef __cplusplus | |
| typedef struct | | struct BEECRYPTAPI hashFunction | |
| | | #else | |
| | | struct _hashFunction | |
| | | #endif | |
| { | | { | |
| const char* name; | | const char* name; | |
| const size_t paramsize; /* in bytes
*/ | | const size_t paramsize; /* in bytes
*/ | |
| const size_t blocksize; /* in bytes
*/ | | const size_t blocksize; /* in bytes
*/ | |
| const size_t digestsize; /* in bytes
*/ | | const size_t digestsize; /* in bytes
*/ | |
| const hashFunctionReset reset; | | const hashFunctionReset reset; | |
| const hashFunctionUpdate update; | | const hashFunctionUpdate update; | |
| const hashFunctionDigest digest; | | const hashFunctionDigest digest; | |
|
| } hashFunction; | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _hashFunction hashFunction; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * You can use the following functions to find hash functions implemented b
y | | * You can use the following functions to find hash functions implemented b
y | |
| * the library: | | * the library: | |
| * | | * | |
| * hashFunctionCount returns the number of hash functions available. | | * hashFunctionCount returns the number of hash functions available. | |
| * | | * | |
| * hashFunctionGet returns the hash function with a given index (starting | | * hashFunctionGet returns the hash function with a given index (starting | |
| * at zero, up to hashFunctionCount() - 1), or NULL if the index was out of | | * at zero, up to hashFunctionCount() - 1), or NULL if the index was out of | |
| * bounds. | | * bounds. | |
| | | | |
| skipping to change at line 315 | | skipping to change at line 354 | |
| const hashFunction* hashFunctionDefault(void); | | const hashFunction* hashFunctionDefault(void); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * The struct 'hashFunctionContext' is used to contain both the functional | | * The struct 'hashFunctionContext' is used to contain both the functional | |
| * part (the hashFunction), and its parameters. | | * part (the hashFunction), and its parameters. | |
| */ | | */ | |
|
| | | #ifdef __cplusplus | |
| typedef struct | | struct BEECRYPTAPI hashFunctionContext | |
| | | #else | |
| | | struct _hashFunctionContext | |
| | | #endif | |
| { | | { | |
| const hashFunction* algo; | | const hashFunction* algo; | |
| hashFunctionParam* param; | | hashFunctionParam* param; | |
|
| } hashFunctionContext; | | | |
| | | #ifdef __cplusplus | |
| | | hashFunctionContext(); | |
| | | hashFunctionContext(const hashFunction*); | |
| | | ~hashFunctionContext(); | |
| | | #endif | |
| | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _hashFunctionContext hashFunctionContext; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * The following functions can be used to initialize and free a | | * The following functions can be used to initialize and free a | |
| * hashFunctionContext. Initializing will allocate a buffer of the size | | * hashFunctionContext. Initializing will allocate a buffer of the size | |
| * required by the hashFunction, freeing will deallocate that buffer. | | * required by the hashFunction, freeing will deallocate that buffer. | |
| */ | | */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| skipping to change at line 383 | | skipping to change at line 435 | |
| * | | * | |
| * The struct field 'keybitsmin' contains the minimum number of bits a key | | * The struct field 'keybitsmin' contains the minimum number of bits a key | |
| * must contains, 'keybitsmax' the maximum number of bits a key may contain
, | | * must contains, 'keybitsmax' the maximum number of bits a key may contain
, | |
| * 'keybitsinc', the increment in bits that may be used between min and max
. | | * 'keybitsinc', the increment in bits that may be used between min and max
. | |
| * | | * | |
| * NOTE: data must be at least have a bytesize of 'digestsize' as described | | * NOTE: data must be at least have a bytesize of 'digestsize' as described | |
| * in the keyedHashFunction struct. | | * in the keyedHashFunction struct. | |
| * NOTE: for safety reasons, after calling digest, each specific implementa
tion | | * NOTE: for safety reasons, after calling digest, each specific implementa
tion | |
| * MUST reset itself so that previous values in the parameters are erased. | | * MUST reset itself so that previous values in the parameters are erased. | |
| */ | | */ | |
|
| | | #ifdef __cplusplus | |
| typedef struct | | struct BEECRYPTAPI keyedHashFunction | |
| | | #else | |
| | | struct _keyedHashFunction | |
| | | #endif | |
| { | | { | |
| const char* name; | | const char* name; | |
| const size_t paramsize; /* i
n bytes */ | | const size_t paramsize; /* i
n bytes */ | |
| const size_t blocksize; /* i
n bytes */ | | const size_t blocksize; /* i
n bytes */ | |
| const size_t digestsize; /* i
n bytes */ | | const size_t digestsize; /* i
n bytes */ | |
| const size_t keybitsmin; /* i
n bits */ | | const size_t keybitsmin; /* i
n bits */ | |
| const size_t keybitsmax; /* i
n bits */ | | const size_t keybitsmax; /* i
n bits */ | |
| const size_t keybitsinc; /* i
n bits */ | | const size_t keybitsinc; /* i
n bits */ | |
| const keyedHashFunctionSetup setup; | | const keyedHashFunctionSetup setup; | |
| const keyedHashFunctionReset reset; | | const keyedHashFunctionReset reset; | |
| const keyedHashFunctionUpdate update; | | const keyedHashFunctionUpdate update; | |
| const keyedHashFunctionDigest digest; | | const keyedHashFunctionDigest digest; | |
|
| } keyedHashFunction; | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _keyedHashFunction keyedHashFunction; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * You can use the following functions to find keyed hash functions impleme
nted | | * You can use the following functions to find keyed hash functions impleme
nted | |
| * by the library: | | * by the library: | |
| * | | * | |
| * keyedHashFunctionCount returns the number of keyed hash functions availa
ble. | | * keyedHashFunctionCount returns the number of keyed hash functions availa
ble. | |
| * | | * | |
| * keyedHashFunctionGet returns the keyed hash function with a given index | | * keyedHashFunctionGet returns the keyed hash function with a given index | |
| * (starting at zero, up to keyedHashFunctionCount() - 1), or NULL if the i
ndex | | * (starting at zero, up to keyedHashFunctionCount() - 1), or NULL if the i
ndex | |
| * was out of bounds. | | * was out of bounds. | |
| | | | |
| skipping to change at line 434 | | skipping to change at line 493 | |
| const keyedHashFunction* keyedHashFunctionDefault(void); | | const keyedHashFunction* keyedHashFunctionDefault(void); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * The struct 'keyedHashFunctionContext' is used to contain both the functi
onal | | * The struct 'keyedHashFunctionContext' is used to contain both the functi
onal | |
| * part (the keyedHashFunction), and its parameters. | | * part (the keyedHashFunction), and its parameters. | |
| */ | | */ | |
|
| | | #ifdef __cplusplus | |
| typedef struct | | struct BEECRYPTAPI keyedHashFunctionContext | |
| | | #else | |
| | | struct _keyedHashFunctionContext | |
| | | #endif | |
| { | | { | |
| const keyedHashFunction* algo; | | const keyedHashFunction* algo; | |
| keyedHashFunctionParam* param; | | keyedHashFunctionParam* param; | |
|
| } keyedHashFunctionContext; | | | |
| | | #ifdef __cplusplus | |
| | | keyedHashFunctionContext(); | |
| | | keyedHashFunctionContext(const keyedHashFunction*); | |
| | | ~keyedHashFunctionContext(); | |
| | | #endif | |
| | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _keyedHashFunctionContext keyedHashFunctionContext; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * The following functions can be used to initialize and free a | | * The following functions can be used to initialize and free a | |
| * keyedHashFunctionContext. Initializing will allocate a buffer of the siz
e | | * keyedHashFunctionContext. Initializing will allocate a buffer of the siz
e | |
| * required by the keyedHashFunction, freeing will deallocate that buffer. | | * required by the keyedHashFunction, freeing will deallocate that buffer. | |
| */ | | */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| skipping to change at line 558 | | skipping to change at line 630 | |
| const blockCipherModcrypt encrypt; | | const blockCipherModcrypt encrypt; | |
| const blockCipherModcrypt decrypt; | | const blockCipherModcrypt decrypt; | |
| } blockCipherMode; | | } blockCipherMode; | |
| | | | |
| /*!\brief Holds information and pointers to code specific to each cipher. | | /*!\brief Holds information and pointers to code specific to each cipher. | |
| * | | * | |
| * Specific block ciphers \e may be written to be multithread-safe. | | * Specific block ciphers \e may be written to be multithread-safe. | |
| * | | * | |
| * \ingroup BC_m | | * \ingroup BC_m | |
| */ | | */ | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI blockCipher | |
| | | #else | |
| | | struct _blockCipher | |
| | | #endif | |
| { | | { | |
| /*!\var name | | /*!\var name | |
| * \brief The blockcipher's name. | | * \brief The blockcipher's name. | |
| */ | | */ | |
| const char* name; | | const char* name; | |
| /*!\var paramsize | | /*!\var paramsize | |
| * \brief The size of the parameters required by this cipher, in byt
es. | | * \brief The size of the parameters required by this cipher, in byt
es. | |
| */ | | */ | |
| const size_t paramsize; | | const size_t paramsize; | |
| /*!\var blocksize | | /*!\var blocksize | |
| | | | |
| skipping to change at line 606 | | skipping to change at line 682 | |
| const blockCipherRaw raw; | | const blockCipherRaw raw; | |
| /*!\var ecb | | /*!\var ecb | |
| * \brief The cipher's ECB functions. | | * \brief The cipher's ECB functions. | |
| */ | | */ | |
| const blockCipherMode ecb; | | const blockCipherMode ecb; | |
| const blockCipherMode cbc; | | const blockCipherMode cbc; | |
| /*!\var getfb | | /*!\var getfb | |
| * \brief Pointer to the cipher's feedback-returning function. | | * \brief Pointer to the cipher's feedback-returning function. | |
| */ | | */ | |
| const blockCipherFeedback getfb; | | const blockCipherFeedback getfb; | |
|
| } blockCipher; | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _blockCipher blockCipher; | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /*!\fn int blockCipherCount() | | /*!\fn int blockCipherCount() | |
| * \brief This function returns the number of blockciphers implemented | | * \brief This function returns the number of blockciphers implemented | |
| * by the library. | | * by the library. | |
| * \return The number of implemented blockciphers. | | * \return The number of implemented blockciphers. | |
| */ | | */ | |
| | | | |
| skipping to change at line 655 | | skipping to change at line 735 | |
| const blockCipher* blockCipherDefault(void); | | const blockCipher* blockCipherDefault(void); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| /*!\brief Holds a pointer to a blockcipher as well as its parameters. | | /*!\brief Holds a pointer to a blockcipher as well as its parameters. | |
| * \warning A context can be used by only one thread at the same time. | | * \warning A context can be used by only one thread at the same time. | |
| * \ingroup BC_m | | * \ingroup BC_m | |
| */ | | */ | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI blockCipherContext | |
| | | #else | |
| | | struct _blockCipherContext | |
| | | #endif | |
| { | | { | |
| /*!\var algo | | /*!\var algo | |
| * \brief Pointer to a blockCipher. | | * \brief Pointer to a blockCipher. | |
| */ | | */ | |
| const blockCipher* algo; | | const blockCipher* algo; | |
| /*!\var param | | /*!\var param | |
| * \brief Pointer to the parameters used by algo. | | * \brief Pointer to the parameters used by algo. | |
| */ | | */ | |
| blockCipherParam* param; | | blockCipherParam* param; | |
| /*!\var op | | /*!\var op | |
| */ | | */ | |
| cipherOperation op; | | cipherOperation op; | |
|
| } blockCipherContext; | | | |
| | | #ifdef __cplusplus | |
| | | blockCipherContext(); | |
| | | blockCipherContext(const blockCipher*); | |
| | | ~blockCipherContext(); | |
| | | #endif | |
| | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _blockCipherContext blockCipherContext; | |
| | | #endif | |
| | | | |
| /* | | /* | |
| * The following functions can be used to initialize and free a | | * The following functions can be used to initialize and free a | |
| * blockCipherContext. Initializing will allocate a buffer of the size | | * blockCipherContext. Initializing will allocate a buffer of the size | |
| * required by the blockCipher, freeing will deallocate that buffer. | | * required by the blockCipher, freeing will deallocate that buffer. | |
| */ | | */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
End of changes. 21 change blocks. |
| 25 lines changed or deleted | | 120 lines changed or added | |
|
| dldp.h | | dldp.h | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| | | | |
| /*!\file dldp.h | | /*!\file dldp.h | |
| * \brief Discrete Logarithm domain parameters, headers. | | * \brief Discrete Logarithm domain parameters, headers. | |
| * \author Bob Deblier <bob.deblier@pandora.be> | | * \author Bob Deblier <bob.deblier@pandora.be> | |
| * \ingroup DL_m | | * \ingroup DL_m | |
| */ | | */ | |
| | | | |
| #ifndef _DLDP_H | | #ifndef _DLDP_H | |
| #define _DLDP_H | | #define _DLDP_H | |
| | | | |
|
| #include "mpbarrett.h" | | #include "beecrypt/mpbarrett.h" | |
| | | | |
| /* | | /* | |
| * Discrete Logarithm Domain Parameters - Prime | | * Discrete Logarithm Domain Parameters - Prime | |
| * | | * | |
| * Standard definition where p = qr+1; in case where p=2q+1, r=2 | | * Standard definition where p = qr+1; in case where p=2q+1, r=2 | |
| * | | * | |
| * In IEEE P1363 naming is p = rk+1 | | * In IEEE P1363 naming is p = rk+1 | |
| * | | * | |
| * Hence, IEEE prime r = q and cofactor k = r | | * Hence, IEEE prime r = q and cofactor k = r | |
| * | | * | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 53 | |
| * g is either a generator of a subgroup of order q, or a generator of orde
r | | * g is either a generator of a subgroup of order q, or a generator of orde
r | |
| * n = (p-1) | | * n = (p-1) | |
| */ | | */ | |
| | | | |
| /*!\brief Discrete Logarithm Domain Parameters over a prime field. | | /*!\brief Discrete Logarithm Domain Parameters over a prime field. | |
| * | | * | |
| * For the variables in this structure /f$p=qr+1/f$; if /f$p=2q+1 then r=2/
f$. | | * For the variables in this structure /f$p=qr+1/f$; if /f$p=2q+1 then r=2/
f$. | |
| * | | * | |
| * \ingroup DL_m | | * \ingroup DL_m | |
| */ | | */ | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI dldp_p | |
| | | #else | |
| | | struct _dldp_p | |
| | | #endif | |
| { | | { | |
| /*!\var p | | /*!\var p | |
| * \brief The prime. | | * \brief The prime. | |
| * | | * | |
| */ | | */ | |
| mpbarrett p; | | mpbarrett p; | |
| /*!\var q | | /*!\var q | |
| * \brief The cofactor. | | * \brief The cofactor. | |
| * | | * | |
| * \f$q\f$ is a prime divisor of \f$p-1\f$. | | * \f$q\f$ is a prime divisor of \f$p-1\f$. | |
| | | | |
| skipping to change at line 83 | | skipping to change at line 87 | |
| * | | * | |
| * \f$g\f$ is either a generator of \f$\mathds{Z}^{*}_p\f$, or a gen
erator | | * \f$g\f$ is either a generator of \f$\mathds{Z}^{*}_p\f$, or a gen
erator | |
| * of a cyclic subgroup \f$G\f$ of \f$\mathds{Z}^{*}_p\f$ of order \
f$q\f$. | | * of a cyclic subgroup \f$G\f$ of \f$\mathds{Z}^{*}_p\f$ of order \
f$q\f$. | |
| */ | | */ | |
| mpnumber g; | | mpnumber g; | |
| /*!\var n | | /*!\var n | |
| * | | * | |
| * \f$n=p-1=qr\f$ | | * \f$n=p-1=qr\f$ | |
| */ | | */ | |
| mpbarrett n; | | mpbarrett n; | |
|
| } dldp_p; | | #ifdef __cplusplus | |
| | | dldp_p(); | |
| | | dldp_p(const dldp_p&); | |
| | | ~dldp_p(); | |
| | | #endif | |
| | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _dldp_p dldp_p; | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * Functions for setting up and copying | | * Functions for setting up and copying | |
| */ | | */ | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| | | | |
| skipping to change at line 105 | | skipping to change at line 118 | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int dldp_pFree(dldp_p*); | | int dldp_pFree(dldp_p*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int dldp_pCopy(dldp_p*, const dldp_p*); | | int dldp_pCopy(dldp_p*, const dldp_p*); | |
| | | | |
| /* | | /* | |
| * Functions for generating keys | | * Functions for generating keys | |
| */ | | */ | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int dldp_pPrivate(const dldp_p*, randomGeneratorContext*, mpnumber*); | | int dldp_pPrivate (const dldp_p*, randomGeneratorContext*, mpnumber*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int dldp_pPublic (const dldp_p*, const mpnumber*, mpnumber*); | | int dldp_pPrivate_s(const dldp_p*, randomGeneratorContext*, mpnumber*, size
_t); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int dldp_pPair (const dldp_p*, randomGeneratorContext*, mpnumber*, mpnumb | | int dldp_pPublic (const dldp_p*, const mpnumber*, mpnumber*); | |
| er*); | | BEECRYPTAPI | |
| | | int dldp_pPair (const dldp_p*, randomGeneratorContext*, mpnumber*, mpnu | |
| | | mber*); | |
| | | BEECRYPTAPI | |
| | | int dldp_pPair_s (const dldp_p*, randomGeneratorContext*, mpnumber*, mpnu | |
| | | mber*, size_t); | |
| | | | |
| /* | | /* | |
| * Function for comparing domain parameters | | * Function for comparing domain parameters | |
| */ | | */ | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int dldp_pEqual (const dldp_p*, const dldp_p*); | | int dldp_pEqual (const dldp_p*, const dldp_p*); | |
| | | | |
| /* | | /* | |
| * Functions for generating and validating dldp_pgoq variant domain paramet
ers | | * Functions for generating and validating dldp_pgoq variant domain paramet
ers | |
| */ | | */ | |
| | | | |
End of changes. 6 change blocks. |
| 7 lines changed or deleted | | 26 lines changed or added | |
|
| mp.h | | mp.h | |
| | | | |
| skipping to change at line 44 | | skipping to change at line 44 | |
| * With some smart use of available assembler instructions, it's possible | | * With some smart use of available assembler instructions, it's possible | |
| * to speed these routines up by a factor of 2 to 4. | | * to speed these routines up by a factor of 2 to 4. | |
| * | | * | |
| * \author Bob Deblier <bob.deblier@pandora.be> | | * \author Bob Deblier <bob.deblier@pandora.be> | |
| * \ingroup MP_m | | * \ingroup MP_m | |
| */ | | */ | |
| | | | |
| #ifndef _MP_H | | #ifndef _MP_H | |
| #define _MP_H | | #define _MP_H | |
| | | | |
|
| #include "beecrypt.api.h" | | #include "beecrypt/api.h" | |
| #include "mpopt.h" | | #include "beecrypt/mpopt.h" | |
| | | | |
| #define MP_HWBITS (MP_WBITS >> 1) | | #define MP_HWBITS (MP_WBITS >> 1) | |
| #define MP_WBYTES (MP_WBITS >> 3) | | #define MP_WBYTES (MP_WBITS >> 3) | |
| #define MP_WNIBBLES (MP_WBITS >> 2) | | #define MP_WNIBBLES (MP_WBITS >> 2) | |
| | | | |
| #if (MP_WBITS == 64) | | #if (MP_WBITS == 64) | |
| # define MP_WORDS_TO_BITS(x) ((x) << 6) | | # define MP_WORDS_TO_BITS(x) ((x) << 6) | |
| # define MP_WORDS_TO_NIBBLES(x) ((x) << 4) | | # define MP_WORDS_TO_NIBBLES(x) ((x) << 4) | |
| # define MP_WORDS_TO_BYTES(x) ((x) << 3) | | # define MP_WORDS_TO_BYTES(x) ((x) << 3) | |
| # define MP_BITS_TO_WORDS(x) ((x) >> 6) | | # define MP_BITS_TO_WORDS(x) ((x) >> 6) | |
| | | | |
| skipping to change at line 410 | | skipping to change at line 410 | |
| | | | |
| /*!\fn void mpclrlsb(size_t size, mpw* data) | | /*!\fn void mpclrlsb(size_t size, mpw* data) | |
| * \brief This function clears the least significant bit of a multi-precisi
on | | * \brief This function clears the least significant bit of a multi-precisi
on | |
| * integer. | | * integer. | |
| * \param size The size of the multi-precision integer. | | * \param size The size of the multi-precision integer. | |
| * \param data The multi-precision integer data. | | * \param data The multi-precision integer data. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpclrlsb(size_t size, mpw* data); | | void mpclrlsb(size_t size, mpw* data); | |
| | | | |
|
| | | /*!\fn mpand(size_t size, mpw* xdata, const mpw* ydata) | |
| | | * \brief This function computes the bit-wise AND of two multi-precision | |
| | | * integers. Modifies xdata. | |
| | | * \param size The size of the multi-precision integers. | |
| | | * \param xdata The multi-precision integer data. | |
| | | * \param ydata The multi-precision integer data. | |
| | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpand(size_t, mpw*, const mpw*); | | void mpand(size_t size, mpw* xdata, const mpw* ydata); | |
| | | | |
|
| | | /*!\fn void mpor(size_t size, mpw* xdata, const mpw* ydata) | |
| | | * \brief This function computes the bit-wise OR of two multi-precision | |
| | | * integers. Modifies xdata. | |
| | | * \param size The size of the multi-precision integer. | |
| | | * \param xdata The multi-precision integer data. | |
| | | * \param ydata The multi-precision integer data. | |
| | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpor(size_t, mpw*, const mpw*); | | void mpor(size_t size, mpw* xdata, const mpw* ydata); | |
| | | | |
|
| | | /*!\fn void mpxor(size_t size, mpw* xdata, const mpw* ydata) | |
| | | * \brief This function computes the bit-wise XOR of two multi-precision | |
| | | * integers. Modifies xdata. | |
| | | * \param size The size of the multi-precision integer. | |
| | | * \param xdata The multi-precision integer data. | |
| | | * \param ydata The multi-precision integer data. | |
| | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpxor(size_t, mpw*, const mpw*); | | void mpxor(size_t size, mpw* xdata, const mpw* ydata); | |
| | | | |
| /*!\fn mpnot(size_t size, mpw* data) | | /*!\fn mpnot(size_t size, mpw* data) | |
| * \brief This function flips all bits of a multi-precision integer. | | * \brief This function flips all bits of a multi-precision integer. | |
| * \param size The size of the multi-precision integer. | | * \param size The size of the multi-precision integer. | |
| * \param data The multi-precision integer data. | | * \param data The multi-precision integer data. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpnot(size_t size, mpw* data); | | void mpnot(size_t size, mpw* data); | |
| | | | |
| /*!\fn void mpsetw(size_t size, mpw* xdata, mpw y) | | /*!\fn void mpsetw(size_t size, mpw* xdata, mpw y) | |
| | | | |
| skipping to change at line 505 | | skipping to change at line 526 | |
| * \brief This function subtracts two multi-precision integers of equal siz
e. | | * \brief This function subtracts two multi-precision integers of equal siz
e. | |
| * The performed operation in pseudocode: x -= y | | * The performed operation in pseudocode: x -= y | |
| * \param size The size of the multi-precision integers. | | * \param size The size of the multi-precision integers. | |
| * \param xdata The first multi-precision integer. | | * \param xdata The first multi-precision integer. | |
| * \param ydata The second multi-precision integer. | | * \param ydata The second multi-precision integer. | |
| * \return The carry-over value of the operation; this value is either 0 or
1. | | * \return The carry-over value of the operation; this value is either 0 or
1. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int mpsub (size_t size, mpw* xdata, const mpw* ydata); | | int mpsub (size_t size, mpw* xdata, const mpw* ydata); | |
| | | | |
|
| /*!\fn int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) | | /*!\fn int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) | |
| * \brief This function subtracts two multi-precision integers of different | | * \brief This function subtracts two multi-precision integers of different | |
| * size. The performed operation in pseudocode: x -= y. | | * size. The performed operation in pseudocode: x -= y. | |
| * \param xsize The size of the first multi-precision integer. | | * \param xsize The size of the first multi-precision integer. | |
| * \param xdata The first multi-precision integer. | | * \param xdata The first multi-precision integer. | |
| * \param ysize The size of the second multi-precision integer. | | * \param ysize The size of the second multi-precision integer. | |
| * \param ydata The second multi-precision integer. | | * \param ydata The second multi-precision integer. | |
| * \return The carry-over value of the operation; this value is either 0 or
1. | | * \return The carry-over value of the operation; this value is either 0 or
1. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata); | | int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| int mpmultwo(size_t size, mpw* data); | | int mpmultwo(size_t size, mpw* data); | |
| | | | |
|
| | | /*!\fn void mpneg(size_t size, mpw* data) | |
| | | * \brief This function negates a multi-precision integer. | |
| | | * \param size The size of the multi-precision integer. | |
| | | * \param data The multi-precision integer data. | |
| | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpneg(size_t size, mpw* data); | | void mpneg(size_t size, mpw* data); | |
| | | | |
|
| | | /*!\fn size_t mpsize(size_t size, const mpw* data) | |
| | | * \brief This function returns the true size of a multi-precision | |
| | | * integer, after stripping leading zero words. | |
| | | * \param size The size of the multi-precision integer. | |
| | | * \param data The multi-precision integer data. | |
| | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| size_t mpsize(size_t size, const mpw* data); | | size_t mpsize(size_t size, const mpw* data); | |
| | | | |
|
| | | /*!\fn size_t mpbits(size_t size, const mpw* data) | |
| | | * \brief This function returns the number of significant bits | |
| | | * in a multi-precision integer. | |
| | | * \param size The size of the multi-precision integer. | |
| | | * \param data The multi-precision integer data. | |
| | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| size_t mpbits(size_t size, const mpw* data); | | size_t mpbits(size_t size, const mpw* data); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| size_t mpmszcnt(size_t size, const mpw* data); | | size_t mpmszcnt(size_t size, const mpw* data); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| size_t mplszcnt(size_t size, const mpw* data); | | size_t mplszcnt(size_t size, const mpw* data); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| | | | |
| skipping to change at line 591 | | skipping to change at line 629 | |
| * \retval The carry-over multi-precision word. | | * \retval The carry-over multi-precision word. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| mpw mpaddmul (size_t size, mpw* result, const mpw* data, mpw y); | | mpw mpaddmul (size_t size, mpw* result, const mpw* data, mpw y); | |
| | | | |
| /*!\fn void mpaddsqrtrc(size_t size, mpw* result, const mpw* data) | | /*!\fn void mpaddsqrtrc(size_t size, mpw* result, const mpw* data) | |
| * \brief This function is used in the calculation of a multi-precision | | * \brief This function is used in the calculation of a multi-precision | |
| * squaring. | | * squaring. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpaddsqrtrc(size_t, mpw*, const mpw*); | | void mpaddsqrtrc(size_t size, mpw* result, const mpw* data); | |
| | | | |
| /*!\fn void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize
, const mpw* ydata) | | /*!\fn void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize
, const mpw* ydata) | |
| * \brief This function computes a full multi-precision product. | | * \brief This function computes a full multi-precision product. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpmul(mpw*, size_t, const mpw*, size_t, const mpw*); | | void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const | |
| | | mpw* ydata); | |
| | | | |
| /*!\fn void mpsqr(mpw* result, size_t size, const mpw* data) | | /*!\fn void mpsqr(mpw* result, size_t size, const mpw* data) | |
| * \brief This function computes a full multi-precision square. | | * \brief This function computes a full multi-precision square. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpsqr(mpw*, size_t, const mpw*); | | void mpsqr(mpw* result, size_t size, const mpw* data); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpgcd_w(size_t, const mpw*, const mpw*, mpw*, mpw*); | | void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, | |
| BEECRYPTAPI | | mpw* wksp); | |
| int mpextgcd_w(size_t, const mpw*, const mpw*, mpw*, mpw*); | | | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| mpw mppndiv(mpw, mpw, mpw); | | int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* resul
t, mpw* wksp); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpnmod(mpw*, size_t, const mpw*, size_t, const mpw*, mpw*); | | mpw mppndiv(mpw xhi, mpw xlo, mpw y); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpmod (mpw*, size_t, const mpw*, size_t, const mpw*, mpw*); | | void mpmod (mpw* result, size_t xsize, const mpw* xdata, size_t ysize, cons
t mpw*ydata, mpw* wksp); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpndivmod(mpw*, size_t, const mpw*, size_t, const mpw*, mpw*); | | void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, c
onst mpw* ydata, mpw* wksp); | |
| | | | |
| /* | | /* | |
| * Output Routines | | * Output Routines | |
| */ | | */ | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpprint(size_t size, const mpw* data); | | void mpprint(size_t size, const mpw* data); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpprintln(size_t size, const mpw* data); | | void mpprintln(size_t size, const mpw* data); | |
| | | | |
| skipping to change at line 642 | | skipping to change at line 679 | |
| void mpfprint(FILE* f, size_t size, const mpw* data); | | void mpfprint(FILE* f, size_t size, const mpw* data); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpfprintln(FILE* f, size_t size, const mpw* data); | | void mpfprintln(FILE* f, size_t size, const mpw* data); | |
| | | | |
| /* | | /* | |
| * Conversion Routines | | * Conversion Routines | |
| */ | | */ | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int os2ip(mpw*, size_t, const byte*, size_t); | | int os2ip(mpw* idata, size_t isize, const byte* osdata, size_t ossize); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int i2osp(byte*, size_t, const mpw*, size_t); | | int i2osp(byte* osdata, size_t ossize, const mpw* idata, size_t isize); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int hs2ip(mpw*, size_t, const char*, size_t); | | int hs2ip(mpw* idata, size_t isize, const char* hsdata, size_t hssize); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 22 change blocks. |
| 19 lines changed or deleted | | 58 lines changed or added | |
|
| mpbarrett.h | | mpbarrett.h | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| | | | |
| /*!\file mpbarrett.h | | /*!\file mpbarrett.h | |
| * \brief Multi-precision integer routines using Barrett modular reduction,
headers. | | * \brief Multi-precision integer routines using Barrett modular reduction,
headers. | |
| * \author Bob Deblier <bob.deblier@pandora.be> | | * \author Bob Deblier <bob.deblier@pandora.be> | |
| * \ingroup MP_m | | * \ingroup MP_m | |
| */ | | */ | |
| | | | |
| #ifndef _MPBARRETT_H | | #ifndef _MPBARRETT_H | |
| #define _MPBARRETT_H | | #define _MPBARRETT_H | |
| | | | |
|
| #include "beecrypt.h" | | #include "beecrypt/beecrypt.h" | |
| #include "mpnumber.h" | | #include "beecrypt/mpnumber.h" | |
| | | | |
|
| typedef struct | | #ifdef __cplusplus | |
| | | # include <iostream> | |
| | | #endif | |
| | | | |
| | | #ifdef __cplusplus | |
| | | struct BEECRYPTAPI mpbarrett | |
| | | #else | |
| | | struct _mpbarrett | |
| | | #endif | |
| { | | { | |
| size_t size; | | size_t size; | |
| mpw* modl; /* (size) words */ | | mpw* modl; /* (size) words */ | |
| mpw* mu; /* (size+1) words */ | | mpw* mu; /* (size+1) words */ | |
|
| } mpbarrett; | | | |
| | | #ifdef __cplusplus | |
| | | mpbarrett(); | |
| | | mpbarrett(const mpbarrett&); | |
| | | ~mpbarrett(); | |
| | | | |
| | | const mpbarrett& operator=(const mpbarrett&); | |
| | | bool operator==(const mpbarrett&); | |
| | | bool operator!=(const mpbarrett&); | |
| | | | |
| | | void wipe(); | |
| | | size_t bitlength() const; | |
| | | #endif | |
| | | }; | |
| | | | |
| | | #ifndef __cplusplus | |
| | | typedef struct _mpbarrett mpbarrett; | |
| | | #else | |
| | | BEECRYPTAPI | |
| | | std::ostream& operator<<(std::ostream&, const mpbarrett&); | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbzero(mpbarrett*); | | void mpbzero(mpbarrett*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbinit(mpbarrett*, size_t); | | void mpbinit(mpbarrett*, size_t); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 84 | |
| void mpbinit(mpbarrett*, size_t); | | void mpbinit(mpbarrett*, size_t); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbfree(mpbarrett*); | | void mpbfree(mpbarrett*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbcopy(mpbarrett*, const mpbarrett*); | | void mpbcopy(mpbarrett*, const mpbarrett*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbwipe(mpbarrett*); | | void mpbwipe(mpbarrett*); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbset(mpbarrett*, size_t, const mpw*); | | void mpbset(mpbarrett*, size_t, const mpw*); | |
|
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| void mpbsethex(mpbarrett*, const char*); | | int mpbsetbin(mpbarrett*, const byte*, size_t); | |
| | | BEECRYPTAPI | |
| | | int mpbsethex(mpbarrett*, const char*); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbsubone(const mpbarrett*, mpw*); | | void mpbsubone(const mpbarrett*, mpw*); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbmu_w(mpbarrett*, mpw*); | | void mpbmu_w(mpbarrett*, mpw*); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbrnd_w (const mpbarrett*, randomGeneratorContext*, mpw*, mpw*); | | void mpbrnd_w (const mpbarrett*, randomGeneratorContext*, mpw*, mpw*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| | | | |
| skipping to change at line 118 | | skipping to change at line 149 | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbnmulmod(const mpbarrett*, const mpnumber*, const mpnumber*, mpnumbe
r*); | | void mpbnmulmod(const mpbarrett*, const mpnumber*, const mpnumber*, mpnumbe
r*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbnsqrmod(const mpbarrett*, const mpnumber*, mpnumber*); | | void mpbnsqrmod(const mpbarrett*, const mpnumber*, mpnumber*); | |
| | | | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbnpowmod (const mpbarrett*, const mpnumber*, const mpnumber*, mpnu
mber*); | | void mpbnpowmod (const mpbarrett*, const mpnumber*, const mpnumber*, mpnu
mber*); | |
| BEECRYPTAPI | | BEECRYPTAPI | |
| void mpbnpowmodsld(const mpbarrett*, const mpw*, const mpnumber*, mpnumber*
); | | void mpbnpowmodsld(const mpbarrett*, const mpw*, const mpnumber*, mpnumber*
); | |
| | | | |
|
| | | BEECRYPTAPI | |
| | | size_t mpbbits(const mpbarrett*); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 6 change blocks. |
| 5 lines changed or deleted | | 39 lines changed or added | |
|
| rsa.h | | rsa.h | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| | | | |
| /*!\file rsa.h | | /*!\file rsa.h | |
| * \brief RSA algorithm. | | * \brief RSA algorithm. | |
| * \author Bob Deblier <bob.deblier@pandora.be> | | * \author Bob Deblier <bob.deblier@pandora.be> | |
| * \ingroup IF_m IF_rsa_m | | * \ingroup IF_m IF_rsa_m | |
| */ | | */ | |
| | | | |
| #ifndef _RSA_H | | #ifndef _RSA_H | |
| #define _RSA_H | | #define _RSA_H | |
| | | | |
|
| #include "rsakp.h" | | #include "beecrypt/rsakp.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| /*!\fn int rsapub(const rsapk* pk, const mpnumber* m, mpnumber* c) | | /*!\fn int rsapub(const mpbarrett* n, const mpnumber* e, const mpnumber* m,
mpnumber* c) | |
| * \brief This function performs a raw RSA public key operation. | | * \brief This function performs a raw RSA public key operation. | |
| * | | * | |
| * This function can be used for encryption and verifying. | | * This function can be used for encryption and verifying. | |
| * | | * | |
| * It performs the following operation: | | * It performs the following operation: | |
| * \li \f$c=m^{e}\ \textrm{mod}\ n\f$ | | * \li \f$c=m^{e}\ \textrm{mod}\ n\f$ | |
| * | | * | |
|
| * \param pk The RSA public key. | | * \param n The RSA modulus. | |
| | | * \param e The RSA public exponent. | |
| * \param m The message. | | * \param m The message. | |
| * \param c The ciphertext. | | * \param c The ciphertext. | |
| * \retval 0 on success. | | * \retval 0 on success. | |
| * \retval -1 on failure. | | * \retval -1 on failure. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int rsapub (const rsapk* pk, const mpnumber* m, mpnumber* c); | | int rsapub(const mpbarrett* n, const mpnumber* e, | |
| | | const mpnumber* m, mpnumber* c); | |
| | | | |
|
| /*!\fn int rsapri(const rsakp* kp, const mpnumber* c, mpnumber* m) | | /*!\fn int rsapri(const mpbarrett* n, const mpnumber* d, const mpnumber* c,
mpnumber* m) | |
| * \brief This function performs a raw RSA private key operation. | | * \brief This function performs a raw RSA private key operation. | |
| * | | * | |
| * This function can be used for decryption and signing. | | * This function can be used for decryption and signing. | |
| * | | * | |
| * It performs the operation: | | * It performs the operation: | |
| * \li \f$m=c^{d}\ \textrm{mod}\ n\f$ | | * \li \f$m=c^{d}\ \textrm{mod}\ n\f$ | |
| * | | * | |
|
| * \param kp The RSA keypair. | | * \param n The RSA modulus. | |
| | | * \param d The RSA private exponent. | |
| * \param c The ciphertext. | | * \param c The ciphertext. | |
| * \param m The message. | | * \param m The message. | |
| * \retval 0 on success. | | * \retval 0 on success. | |
| * \retval -1 on failure. | | * \retval -1 on failure. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int rsapri (const rsakp* kp, const mpnumber* c, mpnumber* m); | | int rsapri(const mpbarrett* n, const mpnumber* d, | |
| | | const mpnumber* c, mpnumber* m); | |
| | | | |
|
| /*!\fn int rsapricrt(const rsakp* kp, const mpnumber* c, mpnumber* m) | | /*!\fn int rsapricrt(const mpbarrett* n, const mpbarrett* p, const mpbarret | |
| | | t* q, const mpnumber* dp, const mpnumber* dq, const mpnumber* qi, const mpn | |
| | | umber* c, mpnumber* m) | |
| | | * | |
| * \brief This function performs a raw RSA private key operation, with | | * \brief This function performs a raw RSA private key operation, with | |
| * application of the Chinese Remainder Theorem. | | * application of the Chinese Remainder Theorem. | |
| * | | * | |
| * It performs the operation: | | * It performs the operation: | |
|
| * \li \f$j_1=c^{d_1}\ \textrm{mod}\ p\f$ | | * \li \f$j_1=c^{dp}\ \textrm{mod}\ p\f$ | |
| * \li \f$j_2=c^{d_2}\ \textrm{mod}\ q\f$ | | * \li \f$j_2=c^{dq}\ \textrm{mod}\ q\f$ | |
| * \li \f$h=c \cdot (j_1-j_2)\ \textrm{mod}\ p\f$ | | * \li \f$h=qi \cdot (j_1-j_2)\ \textrm{mod}\ p\f$ | |
| * \li \f$m=j_2+hq\f$ | | * \li \f$m=j_2+hq\f$ | |
| * | | * | |
|
| * \param kp The RSA keypair. | | * \param n The RSA modulus. | |
| | | * \param p The first RSA prime factor. | |
| | | * \param q The second RSA prime factor. | |
| | | * \param dp | |
| | | * \param dq | |
| | | * \param qi | |
| * \param c The ciphertext. | | * \param c The ciphertext. | |
| * \param m The message. | | * \param m The message. | |
| * \retval 0 on success. | | * \retval 0 on success. | |
| * \retval -1 on failure. | | * \retval -1 on failure. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int rsapricrt(const rsakp* kp, const mpnumber* c, mpnumber* m); | | int rsapricrt(const mpbarrett* n, const mpbarrett* p, const mpbarrett* q, | |
| | | const mpnumber* dp, const mpnumber* dq, const mpnumber* qi, | |
| | | const mpnumber* c, mpnumber* m); | |
| | | | |
|
| /*!\fn int rsavrfy(const rsapk* pk, const mpnumber* m, const mpnumber* c) | | /*!\fn int rsavrfy(const mpbarrett* n, const mpnumber* e, const mpnumber* m
, const mpnumber* c) | |
| * \brief This function performs a raw RSA verification. | | * \brief This function performs a raw RSA verification. | |
| * | | * | |
| * It verifies if ciphertext \a c was encrypted from cleartext \a m | | * It verifies if ciphertext \a c was encrypted from cleartext \a m | |
|
| * with the private key matching the given public key \a pk. | | * with the private key matching the given public key \a (n, e). | |
| * | | * | |
|
| * \param pk The public key. | | * \param n The RSA modulus. | |
| | | * \param e The RSA public exponent. | |
| * \param m The cleartext message. | | * \param m The cleartext message. | |
| * \param c The ciphertext message. | | * \param c The ciphertext message. | |
| * \retval 1 on success. | | * \retval 1 on success. | |
| * \retval 0 on failure. | | * \retval 0 on failure. | |
| */ | | */ | |
| BEECRYPTAPI | | BEECRYPTAPI | |
|
| int rsavrfy (const rsapk* pk, const mpnumber* m, const mpnumber* c); | | int rsavrfy(const mpbarrett* n, const mpnumber* e, | |
| | | const mpnumber* m, const mpnumber* c); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 15 change blocks. |
| 17 lines changed or deleted | | 33 lines changed or added | |
|