summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h')
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h799
1 files changed, 799 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h
new file mode 100755
index 0000000000..a4c8780d03
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h
@@ -0,0 +1,799 @@
1/*
2 * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20/*!\file beecrypt.h
21 * \brief BeeCrypt API, headers.
22 *
23 * These API functions provide an abstract way for using most of
24 * the various algorithms implemented by the library.
25 *
26 * \author Bob Deblier <bob.deblier@pandora.be>
27 * \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m
28 */
29
30#ifndef _BEECRYPT_H
31#define _BEECRYPT_H
32
33#include "beecrypt/api.h"
34
35#include "beecrypt/memchunk.h"
36#include "beecrypt/mpnumber.h"
37
38/*
39 * Entropy Sources
40 */
41
42/*!\typedef entropyNext
43 * \brief Prototype definition for an entropy-generating function.
44 * \ingroup ES_m
45 */
46typedef int (*entropyNext)(byte*, size_t);
47
48/*!\brief This struct holds information and pointers to code specific to each
49 * source of entropy.
50 * \ingroup ES_m
51 */
52#ifdef __cplusplus
53struct BEECRYPTAPI entropySource
54#else
55struct _entropySource
56#endif
57{
58 /*!\var name
59 * \brief The entropy source's name.
60 */
61 const char* name;
62 /*!\var next
63 * \brief Points to the function which produces the entropy.
64 */
65 const entropyNext next;
66};
67
68#ifndef __cplusplus
69typedef struct _entropySource entropySource;
70#endif
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
76/*!\fn int entropySourceCount()
77 * \brief This function returns the number of entropy sources implemented by
78 * the library.
79 * \return The number of implemented entropy sources.
80 */
81BEECRYPTAPI
82int entropySourceCount(void);
83
84/*!\fn const entropySource* entropySourceGet(int n)
85 * \brief This function returns the \a n -th entropy source implemented by
86 * the library.
87 * \param n Index of the requested entropy source; legal values are 0
88 * through entropySourceCount() - 1.
89 * \return A pointer to an entropy source or null, if the index was out of
90 * range.
91 */
92BEECRYPTAPI
93const entropySource* entropySourceGet(int n);
94
95/*!\fn const entropySource* entropySourceFind(const char* name)
96 * \brief This function returns the entropy source specified by the given name.
97 * \param name Name of the requested entropy source.
98 * \return A pointer to an entropy source or null, if the name wasn't found.
99 */
100BEECRYPTAPI
101const entropySource* entropySourceFind(const char* name);
102
103/*!\fn const entropySource* entropySourceDefault()
104 * \brief This functions returns the default entropy source; the default value
105 * can be specified by setting environment variable BEECRYPT_ENTROPY.
106 * \return A pointer to an entropy source or null, in case an error occured.
107 */
108BEECRYPTAPI
109const entropySource* entropySourceDefault(void);
110
111/*!\fn int entropyGatherNext(byte* data, size_t size)
112 * \brief This function gathers \a size bytes of entropy into \a data.
113 *
114 * Unless environment variable BEECRYPT_ENTROPY is set, this function will
115 * try each successive entropy source to gather up the requested amount.
116 *
117 * \param data Points to where the entropy should be stored.
118 * \param size Indicates how many bytes of entropy should be gathered.
119 * \retval 0 On success.
120 * \retval -1 On failure.
121 */
122BEECRYPTAPI
123int entropyGatherNext(byte*, size_t);
124
125#ifdef __cplusplus
126}
127#endif
128
129/*
130 * Pseudo-random Number Generators
131 */
132
133typedef void randomGeneratorParam;
134
135typedef int (*randomGeneratorSetup )(randomGeneratorParam*);
136typedef int (*randomGeneratorSeed )(randomGeneratorParam*, const byte*, size_t);
137typedef int (*randomGeneratorNext )(randomGeneratorParam*, byte*, size_t);
138typedef int (*randomGeneratorCleanup)(randomGeneratorParam*);
139
140/*
141 * The struct 'randomGenerator' holds information and pointers to code specific
142 * to each random generator. Each specific random generator MUST be written to
143 * be multithread safe.
144 *
145 * WARNING: each randomGenerator, when used in cryptographic applications, MUST
146 * be guaranteed to be of suitable quality and strength (i.e. don't use the
147 * random() function found in most UN*X-es).
148 *
149 * Multiple instances of each randomGenerator can be used (even concurrently),
150 * provided they each use their own randomGeneratorParam parameters, a chunk
151 * of memory which must be at least as large as indicated by the paramsize
152 * field.
153 *
154 */
155
156/*!\brief This struct holds information and pointers to code specific to each
157 * pseudo-random number generator.
158 * \ingroup PRNG_m
159 */
160#ifdef __cplusplus
161struct BEECRYPTAPI randomGenerator
162#else
163struct _randomGenerator
164#endif
165{
166 /*!\var name
167 * \brief The random generator's name.
168 */
169 const char* name;
170 /*!\var paramsize
171 * \brief The size of the random generator's parameters.
172 * \note The implementor should set this by using sizeof(<struct holding
173 * random generator's parameters>).
174 */
175 const size_t paramsize;
176 /*!\var setup
177 * \brief Points to the setup function.
178 */
179 const randomGeneratorSetup setup;
180 /*!\var seed
181 * \brief Points to the seeding function.
182 */
183 const randomGeneratorSeed seed;
184 /*!\var seed
185 * \brief Points to the function which generates the random data.
186 */
187 const randomGeneratorNext next;
188 /*!\var seed
189 * \brief Points to the cleanup function.
190 */
191 const randomGeneratorCleanup cleanup;
192};
193
194#ifndef __cplusplus
195typedef struct _randomGenerator randomGenerator;
196#endif
197
198/*
199 * You can use the following functions to find random generators implemented by
200 * the library:
201 *
202 * randomGeneratorCount returns the number of generators available.
203 *
204 * randomGeneratorGet returns the random generator with a given index (starting
205 * at zero, up to randomGeneratorCount() - 1), or NULL if the index was out of
206 * bounds.
207 *
208 * randomGeneratorFind returns the random generator with the given name, or
209 * NULL if no random generator exists with that name.
210 */
211
212#ifdef __cplusplus
213extern "C" {
214#endif
215
216BEECRYPTAPI
217int randomGeneratorCount(void);
218BEECRYPTAPI
219const randomGenerator* randomGeneratorGet(int);
220BEECRYPTAPI
221const randomGenerator* randomGeneratorFind(const char*);
222BEECRYPTAPI
223const randomGenerator* randomGeneratorDefault(void);
224
225#ifdef __cplusplus
226}
227#endif
228
229/*
230 * The struct 'randomGeneratorContext' is used to contain both the functional
231 * part (the randomGenerator), and its parameters.
232 */
233
234#ifdef __cplusplus
235struct BEECRYPTAPI randomGeneratorContext
236#else
237struct _randomGeneratorContext
238#endif
239{
240 const randomGenerator* rng;
241 randomGeneratorParam* param;
242
243 #ifdef __cplusplus
244 randomGeneratorContext();
245 randomGeneratorContext(const randomGenerator*);
246 ~randomGeneratorContext();
247 #endif
248};
249
250#ifndef __cplusplus
251typedef struct _randomGeneratorContext randomGeneratorContext;
252#endif
253
254/*
255 * The following functions can be used to initialize and free a
256 * randomGeneratorContext. Initializing will allocate a buffer of the size
257 * required by the randomGenerator, freeing will deallocate that buffer.
258 */
259
260#ifdef __cplusplus
261extern "C" {
262#endif
263
264BEECRYPTAPI
265int randomGeneratorContextInit(randomGeneratorContext*, const randomGenerator*);
266BEECRYPTAPI
267int randomGeneratorContextFree(randomGeneratorContext*);
268BEECRYPTAPI
269int randomGeneratorContextNext(randomGeneratorContext*, byte*, size_t);
270BEECRYPTAPI
271int randomGeneratorContextSeed(randomGeneratorContext*, const byte*, size_t);
272
273#ifdef __cplusplus
274}
275#endif
276
277/*
278 * Hash Functions
279 */
280
281/*!typedef void hashFunctionParam
282 * \ingroup HASH_m
283 */
284typedef void hashFunctionParam;
285
286typedef int (*hashFunctionReset )(hashFunctionParam*);
287typedef int (*hashFunctionUpdate)(hashFunctionParam*, const byte*, size_t);
288typedef int (*hashFunctionDigest)(hashFunctionParam*, byte*);
289
290/*
291 * The struct 'hashFunction' holds information and pointers to code specific
292 * to each hash function. Specific hash functions MAY be written to be
293 * multithread-safe.
294 *
295 * NOTE: data MUST have a size (in bytes) of at least 'digestsize' as described
296 * in the hashFunction struct.
297 * NOTE: for safety reasons, after calling digest, each specific implementation
298 * MUST reset itself so that previous values in the parameters are erased.
299 */
300#ifdef __cplusplus
301struct BEECRYPTAPI hashFunction
302#else
303struct _hashFunction
304#endif
305{
306 const char* name;
307 const size_t paramsize; /* in bytes */
308 const size_t blocksize; /* in bytes */
309 const size_t digestsize; /* in bytes */
310 const hashFunctionReset reset;
311 const hashFunctionUpdate update;
312 const hashFunctionDigest digest;
313};
314
315#ifndef __cplusplus
316typedef struct _hashFunction hashFunction;
317#endif
318
319/*
320 * You can use the following functions to find hash functions implemented by
321 * the library:
322 *
323 * hashFunctionCount returns the number of hash functions available.
324 *
325 * hashFunctionGet returns the hash function with a given index (starting
326 * at zero, up to hashFunctionCount() - 1), or NULL if the index was out of
327 * bounds.
328 *
329 * hashFunctionFind returns the hash function with the given name, or
330 * NULL if no hash function exists with that name.
331 */
332
333#ifdef __cplusplus
334extern "C" {
335#endif
336
337BEECRYPTAPI
338int hashFunctionCount(void);
339BEECRYPTAPI
340const hashFunction* hashFunctionGet(int);
341BEECRYPTAPI
342const hashFunction* hashFunctionFind(const char*);
343BEECRYPTAPI
344const hashFunction* hashFunctionDefault(void);
345
346#ifdef __cplusplus
347}
348#endif
349
350/*
351 * The struct 'hashFunctionContext' is used to contain both the functional
352 * part (the hashFunction), and its parameters.
353 */
354#ifdef __cplusplus
355struct BEECRYPTAPI hashFunctionContext
356#else
357struct _hashFunctionContext
358#endif
359{
360 const hashFunction* algo;
361 hashFunctionParam* param;
362
363 #ifdef __cplusplus
364 hashFunctionContext();
365 hashFunctionContext(const hashFunction*);
366 ~hashFunctionContext();
367 #endif
368};
369
370#ifndef __cplusplus
371typedef struct _hashFunctionContext hashFunctionContext;
372#endif
373
374/*
375 * The following functions can be used to initialize and free a
376 * hashFunctionContext. Initializing will allocate a buffer of the size
377 * required by the hashFunction, freeing will deallocate that buffer.
378 */
379
380#ifdef __cplusplus
381extern "C" {
382#endif
383
384BEECRYPTAPI
385int hashFunctionContextInit(hashFunctionContext*, const hashFunction*);
386BEECRYPTAPI
387int hashFunctionContextFree(hashFunctionContext*);
388BEECRYPTAPI
389int hashFunctionContextReset(hashFunctionContext*);
390BEECRYPTAPI
391int hashFunctionContextUpdate(hashFunctionContext*, const byte*, size_t);
392BEECRYPTAPI
393int hashFunctionContextUpdateMC(hashFunctionContext*, const memchunk*);
394BEECRYPTAPI
395int hashFunctionContextUpdateMP(hashFunctionContext*, const mpnumber*);
396BEECRYPTAPI
397int hashFunctionContextDigest(hashFunctionContext*, byte*);
398BEECRYPTAPI
399int hashFunctionContextDigestMP(hashFunctionContext*, mpnumber*);
400BEECRYPTAPI
401int hashFunctionContextDigestMatch(hashFunctionContext*, const mpnumber*);
402
403#ifdef __cplusplus
404}
405#endif
406
407/*
408 * Keyed Hash Functions, a.k.a. Message Authentication Codes
409 */
410
411/*!\typedef void keyedHashFunctionParam
412 * \ingroup HMAC_m
413 */
414typedef void keyedHashFunctionParam;
415
416typedef int (*keyedHashFunctionSetup )(keyedHashFunctionParam*, const byte*, size_t);
417typedef int (*keyedHashFunctionReset )(keyedHashFunctionParam*);
418typedef int (*keyedHashFunctionUpdate )(keyedHashFunctionParam*, const byte*, size_t);
419typedef int (*keyedHashFunctionDigest )(keyedHashFunctionParam*, byte*);
420
421/*
422 * The struct 'keyedHashFunction' holds information and pointers to code
423 * specific to each keyed hash function. Specific keyed hash functions MAY be
424 * written to be multithread-safe.
425 *
426 * The struct field 'keybitsmin' contains the minimum number of bits a key
427 * must contains, 'keybitsmax' the maximum number of bits a key may contain,
428 * 'keybitsinc', the increment in bits that may be used between min and max.
429 *
430 * NOTE: data must be at least have a bytesize of 'digestsize' as described
431 * in the keyedHashFunction struct.
432 * NOTE: for safety reasons, after calling digest, each specific implementation
433 * MUST reset itself so that previous values in the parameters are erased.
434 */
435#ifdef __cplusplus
436struct BEECRYPTAPI keyedHashFunction
437#else
438struct _keyedHashFunction
439#endif
440{
441 const char* name;
442 const size_t paramsize; /* in bytes */
443 const size_t blocksize; /* in bytes */
444 const size_t digestsize; /* in bytes */
445 const size_t keybitsmin; /* in bits */
446 const size_t keybitsmax; /* in bits */
447 const size_t keybitsinc; /* in bits */
448 const keyedHashFunctionSetup setup;
449 const keyedHashFunctionReset reset;
450 const keyedHashFunctionUpdate update;
451 const keyedHashFunctionDigest digest;
452};
453
454#ifndef __cplusplus
455typedef struct _keyedHashFunction keyedHashFunction;
456#endif
457
458/*
459 * You can use the following functions to find keyed hash functions implemented
460 * by the library:
461 *
462 * keyedHashFunctionCount returns the number of keyed hash functions available.
463 *
464 * keyedHashFunctionGet returns the keyed hash function with a given index
465 * (starting at zero, up to keyedHashFunctionCount() - 1), or NULL if the index
466 * was out of bounds.
467 *
468 * keyedHashFunctionFind returns the keyed hash function with the given name,
469 * or NULL if no keyed hash function exists with that name.
470 */
471
472#ifdef __cplusplus
473extern "C" {
474#endif
475
476BEECRYPTAPI
477int keyedHashFunctionCount(void);
478BEECRYPTAPI
479const keyedHashFunction* keyedHashFunctionGet(int);
480BEECRYPTAPI
481const keyedHashFunction* keyedHashFunctionFind(const char*);
482BEECRYPTAPI
483const keyedHashFunction* keyedHashFunctionDefault(void);
484
485#ifdef __cplusplus
486}
487#endif
488
489/*
490 * The struct 'keyedHashFunctionContext' is used to contain both the functional
491 * part (the keyedHashFunction), and its parameters.
492 */
493#ifdef __cplusplus
494struct BEECRYPTAPI keyedHashFunctionContext
495#else
496struct _keyedHashFunctionContext
497#endif
498{
499 const keyedHashFunction* algo;
500 keyedHashFunctionParam* param;
501
502 #ifdef __cplusplus
503 keyedHashFunctionContext();
504 keyedHashFunctionContext(const keyedHashFunction*);
505 ~keyedHashFunctionContext();
506 #endif
507};
508
509#ifndef __cplusplus
510typedef struct _keyedHashFunctionContext keyedHashFunctionContext;
511#endif
512
513/*
514 * The following functions can be used to initialize and free a
515 * keyedHashFunctionContext. Initializing will allocate a buffer of the size
516 * required by the keyedHashFunction, freeing will deallocate that buffer.
517 */
518
519#ifdef __cplusplus
520extern "C" {
521#endif
522
523BEECRYPTAPI
524int keyedHashFunctionContextInit(keyedHashFunctionContext*, const keyedHashFunction*);
525BEECRYPTAPI
526int keyedHashFunctionContextFree(keyedHashFunctionContext*);
527BEECRYPTAPI
528int keyedHashFunctionContextSetup(keyedHashFunctionContext*, const byte*, size_t);
529BEECRYPTAPI
530int keyedHashFunctionContextReset(keyedHashFunctionContext*);
531BEECRYPTAPI
532int keyedHashFunctionContextUpdate(keyedHashFunctionContext*, const byte*, size_t);
533BEECRYPTAPI
534int keyedHashFunctionContextUpdateMC(keyedHashFunctionContext*, const memchunk*);
535BEECRYPTAPI
536int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext*, const mpnumber*);
537BEECRYPTAPI
538int keyedHashFunctionContextDigest(keyedHashFunctionContext*, byte*);
539BEECRYPTAPI
540int keyedHashFunctionContextDigestMP(keyedHashFunctionContext*, mpnumber*);
541BEECRYPTAPI
542int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext*, const mpnumber*);
543
544#ifdef __cplusplus
545}
546#endif
547
548/*
549 * Block ciphers
550 */
551
552/*!\enum cipherOperation
553 * \brief Specifies whether to perform encryption or decryption.
554 * \ingroup BC_m
555 */
556typedef enum
557{
558 NOCRYPT,
559 ENCRYPT,
560 DECRYPT
561} cipherOperation;
562
563/*!\typedef void blockCipherParam
564 * \brief Placeholder type definition for blockcipher parameters.
565 * \sa aesParam, blowfishParam.
566 * \ingroup BC_m
567 */
568typedef void blockCipherParam;
569
570/*!\brief Prototype definition for a setup function.
571 * \ingroup BC_m
572 */
573typedef int (*blockCipherSetup )(blockCipherParam*, const byte*, size_t, cipherOperation);
574
575/*!\typedef int (*blockCipherSetIV)(blockCipherParam* bp, const byte* iv)
576 * \brief Prototype definition for an initialization vector setup function.
577 * \param bp The blockcipher's parameters.
578 * \param iv The blockciphers' IV value.
579 * \note iv length must be equal to the cipher's block size.
580 * \retval 0 on success.
581 * \retval -1 on failure.
582 * \ingroup BC_m
583 */
584typedef int (*blockCipherSetIV )(blockCipherParam*, const byte*);
585
586/*!\typedef int (*blockCipherRawcrypt)(blockCipherParam* bp, uint32_t* dst, const uint32_t* src)
587 * \brief Prototype for a \e raw encryption or decryption function.
588 * \param bp The blockcipher's parameters.
589 * \param dst The ciphertext address; must be aligned on 32-bit boundary.
590 * \param src The cleartext address; must be aligned on 32-bit boundary.
591 * \retval 0 on success.
592 * \retval -1 on failure.
593 * \ingroup BC_m
594 */
595typedef int (*blockCipherRawcrypt)(blockCipherParam*, uint32_t*, const uint32_t*);
596
597/*!\typedef int (*blockCipherModcrypt)(blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
598 * \brief Prototype for a \e encryption or decryption function which operates
599 * on multiple blocks in a certain mode.
600 * \param bp The blockcipher's parameters.
601 * \param dst The ciphertext address; must be aligned on 32-bit boundary.
602 * \param src The cleartext address; must be aligned on 32-bit boundary.
603 * \param nblocks The number of blocks to process.
604 * \retval 0 on success.
605 * \retval -1 on failure.
606 * \ingroup BC_m
607 */
608typedef int (*blockCipherModcrypt)(blockCipherParam*, uint32_t*, const uint32_t*, unsigned int);
609
610typedef uint32_t* (*blockCipherFeedback)(blockCipherParam*);
611
612typedef struct
613{
614 const blockCipherRawcrypt encrypt;
615 const blockCipherRawcrypt decrypt;
616} blockCipherRaw;
617
618typedef struct
619{
620 const blockCipherModcrypt encrypt;
621 const blockCipherModcrypt decrypt;
622} blockCipherMode;
623
624/*!\brief Holds information and pointers to code specific to each cipher.
625 *
626 * Specific block ciphers \e may be written to be multithread-safe.
627 *
628 * \ingroup BC_m
629 */
630#ifdef __cplusplus
631struct BEECRYPTAPI blockCipher
632#else
633struct _blockCipher
634#endif
635{
636 /*!\var name
637 * \brief The blockcipher's name.
638 */
639 const char* name;
640 /*!\var paramsize
641 * \brief The size of the parameters required by this cipher, in bytes.
642 */
643 const size_t paramsize;
644 /*!\var blocksize
645 * \brief The size of one block of data, in bytes.
646 */
647 const size_t blocksize;
648 /*!\var keybitsmin
649 * \brief The minimum number of key bits.
650 */
651 const size_t keybitsmin;
652 /*!\var keybitsmax
653 * \brief The maximum number of key bits.
654 */
655 const size_t keybitsmax;
656 /*!\var keybitsinc
657 * \brief The allowed increment in key bits between min and max.
658 * \see keybitsmin and keybitsmax.
659 */
660 const size_t keybitsinc;
661 /*!\var setup
662 * \brief Pointer to the cipher's setup function.
663 */
664 const blockCipherSetup setup;
665 /*!\var setiv
666 * \brief Pointer to the cipher's initialization vector setup function.
667 */
668 const blockCipherSetIV setiv;
669 /*!\var raw
670 * \brief The cipher's raw functions.
671 */
672 const blockCipherRaw raw;
673 /*!\var ecb
674 * \brief The cipher's ECB functions.
675 */
676 const blockCipherMode ecb;
677 const blockCipherMode cbc;
678 /*!\var getfb
679 * \brief Pointer to the cipher's feedback-returning function.
680 */
681 const blockCipherFeedback getfb;
682};
683
684#ifndef __cplusplus
685typedef struct _blockCipher blockCipher;
686#endif
687
688#ifdef __cplusplus
689extern "C" {
690#endif
691
692/*!\fn int blockCipherCount()
693 * \brief This function returns the number of blockciphers implemented
694 * by the library.
695 * \return The number of implemented blockciphers.
696 */
697BEECRYPTAPI
698int blockCipherCount(void);
699
700/*!\fn const blockCipher* blockCipherGet(int n)
701 * \brief This function returns the \a n -th blockcipher implemented by
702 * the library.
703 * \param n Index of the requested blockcipher; legal values are 0
704 * through blockCipherCount() - 1.
705 * \return A pointer to a blockcipher or null, if the index was out of
706 * range.
707 */
708BEECRYPTAPI
709const blockCipher* blockCipherGet(int);
710
711/*!\fn const blockCipher* blockCipherFind(const char* name)
712 * \brief This function returns the blockcipher specified by the given name.
713 * \param name Name of the requested blockcipher.
714 * \return A pointer to a blockcipher or null, if the name wasn't found.
715 */
716BEECRYPTAPI
717const blockCipher* blockCipherFind(const char*);
718
719/*!\fn const blockCipher* blockCipherDefault()
720 * \brief This functions returns the default blockcipher; the default value
721 * can be specified by setting environment variable BEECRYPT_CIPHER.
722 * \return A pointer to a blockcipher or null, in case an error occured.
723 */
724BEECRYPTAPI
725const blockCipher* blockCipherDefault(void);
726
727#ifdef __cplusplus
728}
729#endif
730
731/*!\brief Holds a pointer to a blockcipher as well as its parameters.
732 * \warning A context can be used by only one thread at the same time.
733 * \ingroup BC_m
734 */
735#ifdef __cplusplus
736struct BEECRYPTAPI blockCipherContext
737#else
738struct _blockCipherContext
739#endif
740{
741 /*!\var algo
742 * \brief Pointer to a blockCipher.
743 */
744 const blockCipher* algo;
745 /*!\var param
746 * \brief Pointer to the parameters used by algo.
747 */
748 blockCipherParam* param;
749 /*!\var op
750 */
751 cipherOperation op;
752
753 #ifdef __cplusplus
754 blockCipherContext();
755 blockCipherContext(const blockCipher*);
756 ~blockCipherContext();
757 #endif
758};
759
760#ifndef __cplusplus
761typedef struct _blockCipherContext blockCipherContext;
762#endif
763
764/*
765 * The following functions can be used to initialize and free a
766 * blockCipherContext. Initializing will allocate a buffer of the size
767 * required by the blockCipher, freeing will deallocate that buffer.
768 */
769
770#ifdef __cplusplus
771extern "C" {
772#endif
773
774BEECRYPTAPI
775int blockCipherContextInit(blockCipherContext*, const blockCipher*);
776
777BEECRYPTAPI
778int blockCipherContextSetup(blockCipherContext*, const byte*, size_t, cipherOperation);
779
780BEECRYPTAPI
781int blockCipherContextSetIV(blockCipherContext*, const byte*);
782
783BEECRYPTAPI
784int blockCipherContextFree(blockCipherContext*);
785
786BEECRYPTAPI
787int blockCipherContextECB(blockCipherContext*, uint32_t*, const uint32_t*, int);
788
789BEECRYPTAPI
790int blockCipherContextCBC(blockCipherContext*, uint32_t*, const uint32_t*, int);
791
792BEECRYPTAPI
793int blockCipherContextValidKeylen(blockCipherContext*, size_t);
794
795#ifdef __cplusplus
796}
797#endif
798
799#endif