00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _BEECRYPT_H
00027 #define _BEECRYPT_H
00028
00029 #include "types.h"
00030
00031 #include "memchunk.h"
00032 #include "mp32number.h"
00033
00036
00045 typedef int (*entropyNext) ( uint32* data, int size)
00046 ;
00047
00052 typedef struct
00053 {
00054
00055 const char* name;
00056
00057 const entropyNext next;
00058 } entropySource;
00059
00060 #ifdef __cplusplus
00061 extern "C" {
00062 #endif
00063
00068 BEECRYPTAPI
00069 int entropySourceCount(void)
00070 ;
00071
00077 BEECRYPTAPI
00078 const entropySource* entropySourceGet(int index)
00079 ;
00080
00086
00087 BEECRYPTAPI
00088 const entropySource* entropySourceFind(const char* name)
00089 ;
00090
00091
00098 BEECRYPTAPI
00099 const entropySource* entropySourceDefault(void)
00100 ;
00101
00109 BEECRYPTAPI
00110 int entropyGatherNext(uint32* data, int size)
00111 ;
00112
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116
00120
00123 typedef void randomGeneratorParam;
00124
00132 typedef int (*randomGeneratorSetup) (randomGeneratorParam* param)
00133 ;
00134
00143 typedef int (*randomGeneratorSeed) (randomGeneratorParam* param, const uint32* data, int size)
00144 ;
00145
00155 typedef int (*randomGeneratorNext) (randomGeneratorParam* param, uint32* data, int size)
00156 ;
00157
00164 typedef int (*randomGeneratorCleanup) (randomGeneratorParam* param)
00165 ;
00166
00181 typedef struct
00182 {
00183
00184 const char* name;
00185 const unsigned int paramsize;
00186 const randomGeneratorSetup setup;
00187 const randomGeneratorSeed seed;
00188 const randomGeneratorNext next;
00189 const randomGeneratorCleanup cleanup;
00190 } randomGenerator;
00191
00192 #ifdef __cplusplus
00193 extern "C" {
00194 #endif
00195
00200 BEECRYPTAPI
00201 int randomGeneratorCount(void)
00202 ;
00203
00209 BEECRYPTAPI
00210 const randomGenerator* randomGeneratorGet(int index)
00211 ;
00212
00218
00219 BEECRYPTAPI
00220 const randomGenerator* randomGeneratorFind(const char* name)
00221 ;
00222
00223
00230 BEECRYPTAPI
00231 const randomGenerator* randomGeneratorDefault(void)
00232 ;
00233
00234 #ifdef __cplusplus
00235 }
00236 #endif
00237
00241 typedef struct
00242 {
00243
00244 const randomGenerator* rng;
00245
00246 randomGeneratorParam* param;
00247 } randomGeneratorContext;
00248
00249 #ifdef __cplusplus
00250 extern "C" {
00251 #endif
00252
00256 BEECRYPTAPI
00257 int randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng)
00258 ;
00259
00263 BEECRYPTAPI
00264 int randomGeneratorContextFree( randomGeneratorContext* ctxt)
00265
00266
00267 ;
00268
00269 BEECRYPTAPI
00270 int randomGeneratorContextNext(randomGeneratorContext* ctxt, uint32* data, int size)
00271 ;
00272
00273 #ifdef __cplusplus
00274 }
00275 #endif
00276
00280
00283 BEECRYPTAPI
00284 typedef void hashFunctionParam;
00285
00292 typedef int (*hashFunctionReset) (hashFunctionParam* param)
00293 ;
00294
00303 typedef int (*hashFunctionUpdate) (hashFunctionParam* param, const byte* data, int size)
00304 ;
00305
00320 typedef int (*hashFunctionDigest) (hashFunctionParam* param, uint32* data)
00321 ;
00322
00327 typedef struct
00328 {
00329
00330 const char* name;
00331 const unsigned int paramsize;
00332 const unsigned int blocksize;
00333 const unsigned int digestsize;
00334 const hashFunctionReset reset;
00335 const hashFunctionUpdate update;
00336 const hashFunctionDigest digest;
00337 } hashFunction;
00338
00339 #ifdef __cplusplus
00340 extern "C" {
00341 #endif
00342
00347 BEECRYPTAPI
00348 int hashFunctionCount(void)
00349 ;
00350
00356 BEECRYPTAPI
00357 const hashFunction* hashFunctionGet(int index)
00358 ;
00359
00365
00366 BEECRYPTAPI
00367 const hashFunction* hashFunctionFind(const char* name)
00368 ;
00369
00370
00377 BEECRYPTAPI
00378 const hashFunction* hashFunctionDefault(void)
00379 ;
00380
00381 #ifdef __cplusplus
00382 }
00383 #endif
00384
00388 typedef struct
00389 {
00390
00391 const hashFunction* algo;
00392
00393 hashFunctionParam* param;
00394 } hashFunctionContext;
00395
00396 #ifdef __cplusplus
00397 extern "C" {
00398 #endif
00399
00403 BEECRYPTAPI
00404 int hashFunctionContextInit(hashFunctionContext* ctxt, const hashFunction* hash)
00405 ;
00406
00410 BEECRYPTAPI
00411 int hashFunctionContextFree( hashFunctionContext* ctxt)
00412
00413 ;
00414
00417 BEECRYPTAPI
00418 int hashFunctionContextReset(hashFunctionContext* ctxt)
00419 ;
00420
00423 BEECRYPTAPI
00424 int hashFunctionContextUpdate(hashFunctionContext* ctxt, const byte* data, int size)
00425 ;
00426
00429 BEECRYPTAPI
00430 int hashFunctionContextUpdateMC(hashFunctionContext* ctxt, const memchunk* m)
00431 ;
00432
00435 BEECRYPTAPI
00436 int hashFunctionContextUpdateMP32(hashFunctionContext* ctxt, const mp32number* n)
00437 ;
00438
00441 BEECRYPTAPI
00442 int hashFunctionContextDigest(hashFunctionContext* ctxt, mp32number* dig)
00443 ;
00444
00447 BEECRYPTAPI
00448 int hashFunctionContextDigestMatch(hashFunctionContext* ctxt, const mp32number* match)
00449 ;
00450
00451 #ifdef __cplusplus
00452 }
00453 #endif
00454
00458
00461 typedef void keyedHashFunctionParam;
00462
00475 typedef int (*keyedHashFunctionSetup) (keyedHashFunctionParam* param, const uint32* key, int keybits)
00476 ;
00477
00484 typedef int (*keyedHashFunctionReset) (keyedHashFunctionParam* param)
00485 ;
00486
00495 typedef int (*keyedHashFunctionUpdate) (keyedHashFunctionParam* param, const byte* data, int size)
00496 ;
00497
00512 typedef int (*keyedHashFunctionDigest) (keyedHashFunctionParam* param, uint32* data)
00513 ;
00514
00519 typedef struct
00520 {
00521
00522 const char* name;
00523 const unsigned int paramsize;
00524 const unsigned int blocksize;
00525 const unsigned int digestsize;
00526 const unsigned int keybitsmin;
00527 const unsigned int keybitsmax;
00528 const unsigned int keybitsinc;
00529 const keyedHashFunctionSetup setup;
00530 const keyedHashFunctionReset reset;
00531 const keyedHashFunctionUpdate update;
00532 const keyedHashFunctionDigest digest;
00533 } keyedHashFunction;
00534
00535 #ifdef __cplusplus
00536 extern "C" {
00537 #endif
00538
00543 BEECRYPTAPI
00544 int keyedHashFunctionCount(void)
00545 ;
00546
00552 BEECRYPTAPI
00553 const keyedHashFunction* keyedHashFunctionGet(int index)
00554 ;
00555
00561
00562 BEECRYPTAPI
00563 const keyedHashFunction* keyedHashFunctionFind(const char* name)
00564 ;
00565
00566
00573 BEECRYPTAPI
00574 const keyedHashFunction* keyedHashFunctionDefault(void)
00575 ;
00576
00577 #ifdef __cplusplus
00578 }
00579 #endif
00580
00584 typedef struct
00585 {
00586
00587 const keyedHashFunction* algo;
00588
00589 keyedHashFunctionParam* param;
00590 } keyedHashFunctionContext;
00591
00592 #ifdef __cplusplus
00593 extern "C" {
00594 #endif
00595
00599 BEECRYPTAPI
00600 int keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, const keyedHashFunction* mac)
00601 ;
00602
00606 BEECRYPTAPI
00607 int keyedHashFunctionContextFree( keyedHashFunctionContext* ctxt)
00608
00609
00610 ;
00611
00614 BEECRYPTAPI
00615 int keyedHashFunctionContextSetup(keyedHashFunctionContext* ctxt, const uint32* key, int keybits)
00616 ;
00617
00620 BEECRYPTAPI
00621 int keyedHashFunctionContextReset(keyedHashFunctionContext* ctxt)
00622 ;
00623
00626 BEECRYPTAPI
00627 int keyedHashFunctionContextUpdate(keyedHashFunctionContext* ctxt, const byte* data, int size)
00628 ;
00629
00632 BEECRYPTAPI
00633 int keyedHashFunctionContextUpdateMC(keyedHashFunctionContext* ctxt, const memchunk* m)
00634 ;
00635
00638 BEECRYPTAPI
00639 int keyedHashFunctionContextUpdateMP32(keyedHashFunctionContext* ctxt, const mp32number* n)
00640 ;
00641
00644 BEECRYPTAPI
00645 int keyedHashFunctionContextDigest(keyedHashFunctionContext* ctxt, mp32number* dig)
00646 ;
00647
00650 BEECRYPTAPI
00651 int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext* ctxt, const mp32number* match)
00652 ;
00653
00654 #ifdef __cplusplus
00655 }
00656 #endif
00657
00661
00664 typedef void blockCipherParam;
00665
00669 typedef enum
00670 {
00671 ENCRYPT,
00672 DECRYPT
00673 } cipherOperation;
00674
00678
00679 typedef enum
00680 {
00681 ECB,
00682 CBC
00683 } cipherMode;
00684
00685
00693 typedef int (*blockModeEncrypt) (blockCipherParam* param, int count, uint32* dst, const uint32* src)
00694 ;
00695
00703 typedef int (*blockModeDecrypt) (blockCipherParam* param, int count, uint32* dst, const uint32* src)
00704 ;
00705
00708 typedef struct
00709 {
00710 const blockModeEncrypt encrypt;
00711 const blockModeDecrypt decrypt;
00712 } blockMode;
00713
00727 typedef int (*blockCipherSetup) (blockCipherParam* param, const uint32* key, int keybits, cipherOperation cipherOperation)
00728 ;
00729
00736 typedef int (*blockCipherSetIV) (blockCipherParam* param, const uint32* data)
00737 ;
00738
00748 typedef int (*blockCipherEncrypt) (blockCipherParam* param, uint32* dst, const uint32* src)
00749 ;
00750
00760 typedef int (*blockCipherDecrypt) (blockCipherParam* param, uint32* dst, const uint32* src)
00761 ;
00762
00767 typedef struct
00768 {
00769
00770 const char* name;
00771 const unsigned int paramsize;
00772 const unsigned int blocksize;
00773 const unsigned int keybitsmin;
00774 const unsigned int keybitsmax;
00775 const unsigned int keybitsinc;
00776 const blockCipherSetup setup;
00777 const blockCipherSetIV setiv;
00778 const blockCipherEncrypt encrypt;
00779 const blockCipherDecrypt decrypt;
00780
00781 const blockMode* mode;
00782 } blockCipher;
00783
00784 #ifdef __cplusplus
00785 extern "C" {
00786 #endif
00787
00792 BEECRYPTAPI
00793 int blockCipherCount(void)
00794 ;
00795
00801 BEECRYPTAPI
00802 const blockCipher* blockCipherGet(int index)
00803 ;
00804
00810
00811 BEECRYPTAPI
00812 const blockCipher* blockCipherFind(const char* name)
00813 ;
00814
00815
00822 BEECRYPTAPI
00823 const blockCipher* blockCipherDefault(void)
00824 ;
00825
00826 #ifdef __cplusplus
00827 }
00828 #endif
00829
00833 typedef struct
00834 {
00835
00836 const blockCipher* algo;
00837
00838 blockCipherParam* param;
00839 } blockCipherContext;
00840
00841 #ifdef __cplusplus
00842 extern "C" {
00843 #endif
00844
00848 BEECRYPTAPI
00849 int blockCipherContextInit(blockCipherContext* ctxt, const blockCipher* ciph)
00850 ;
00851
00854 BEECRYPTAPI
00855 int blockCipherContextSetup(blockCipherContext* ctxt, const uint32* key, int keybits, cipherOperation op)
00856 ;
00857
00860 BEECRYPTAPI
00861 int blockCipherContextSetIV(blockCipherContext* ctxt, const uint32* iv)
00862 ;
00863
00867 BEECRYPTAPI
00868 int blockCipherContextFree( blockCipherContext* ctxt)
00869
00870 ;
00871
00872 #ifdef __cplusplus
00873 }
00874 #endif
00875
00877 #endif