| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #ifndef _WIZARDSTOOLKIT_CIPHER_H |
|---|
| 19 | #define _WIZARDSTOOLKIT_CIPHER_H |
|---|
| 20 | |
|---|
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 22 | extern "C" { |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | #include "wizard/random_.h" |
|---|
| 26 | |
|---|
| 27 | #define MaxCipherBlocksize 128 |
|---|
| 28 | |
|---|
| 29 | typedef enum |
|---|
| 30 | { |
|---|
| 31 | UndefinedMode, |
|---|
| 32 | CBCMode, |
|---|
| 33 | CFBMode, |
|---|
| 34 | CTRMode, |
|---|
| 35 | ECBMode, |
|---|
| 36 | OFBMode |
|---|
| 37 | } CipherMode; |
|---|
| 38 | |
|---|
| 39 | typedef enum |
|---|
| 40 | { |
|---|
| 41 | UndefinedCipher, |
|---|
| 42 | NoCipher, |
|---|
| 43 | AESCipher, |
|---|
| 44 | SerpentCipher, |
|---|
| 45 | TwofishCipher |
|---|
| 46 | } CipherType; |
|---|
| 47 | |
|---|
| 48 | typedef struct _CipherInfo |
|---|
| 49 | CipherInfo; |
|---|
| 50 | |
|---|
| 51 | extern WizardExport CipherInfo |
|---|
| 52 | *AcquireCipherInfo(const CipherType,const CipherMode), |
|---|
| 53 | *DestroyCipherInfo(CipherInfo *); |
|---|
| 54 | |
|---|
| 55 | extern WizardExport const StringInfo |
|---|
| 56 | *GetCipherNonce(CipherInfo *); |
|---|
| 57 | |
|---|
| 58 | extern WizardExport StringInfo |
|---|
| 59 | *DecipherCipher(CipherInfo *,StringInfo *), |
|---|
| 60 | *EncipherCipher(CipherInfo *,StringInfo *), |
|---|
| 61 | *GenerateCipherNonce(CipherInfo *); |
|---|
| 62 | |
|---|
| 63 | extern WizardExport size_t |
|---|
| 64 | GetCipherBlocksize(const CipherInfo *); |
|---|
| 65 | |
|---|
| 66 | extern WizardExport void |
|---|
| 67 | ResetCipherNonce(CipherInfo *), |
|---|
| 68 | SetCipherNonce(CipherInfo *,const StringInfo *), |
|---|
| 69 | SetCipherKey(CipherInfo *,const StringInfo *); |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | extern WizardExport StringInfo |
|---|
| 75 | *DecryptCipher(CipherInfo *,StringInfo *), |
|---|
| 76 | *EncryptCipher(CipherInfo *,StringInfo *); |
|---|
| 77 | |
|---|
| 78 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 79 | } |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | #endif |
|---|