15#define DISABLE_DEBUGLOG
18#include "cryptalgo_p.h"
19#include <gwenhywfar/misc.h>
20#include <gwenhywfar/debug.h>
31 if (strcasecmp(s,
"none")==0)
32 return GWEN_Crypt_CryptAlgoId_None;
33 else if (strcasecmp(s,
"rsa")==0)
34 return GWEN_Crypt_CryptAlgoId_Rsa;
35 else if (strcasecmp(s,
"dsa")==0)
36 return GWEN_Crypt_CryptAlgoId_Dsa;
37 else if (strcasecmp(s,
"des")==0)
38 return GWEN_Crypt_CryptAlgoId_Des;
39 else if (strcasecmp(s,
"des_3k")==0 ||
40 strcasecmp(s,
"des3k")==0)
41 return GWEN_Crypt_CryptAlgoId_Des3K;
42 else if (strcasecmp(s,
"blowfish")==0)
43 return GWEN_Crypt_CryptAlgoId_BlowFish;
44 else if (strcasecmp(s,
"aes128")==0)
45 return GWEN_Crypt_CryptAlgoId_Aes128;
46 else if (strcasecmp(s,
"any")==0)
47 return GWEN_Crypt_CryptAlgoId_Any;
48 return GWEN_Crypt_CryptAlgoId_Unknown;
56 case GWEN_Crypt_CryptAlgoId_None:
58 case GWEN_Crypt_CryptAlgoId_Rsa:
60 case GWEN_Crypt_CryptAlgoId_Dsa:
62 case GWEN_Crypt_CryptAlgoId_Des:
64 case GWEN_Crypt_CryptAlgoId_Des3K:
66 case GWEN_Crypt_CryptAlgoId_BlowFish:
68 case GWEN_Crypt_CryptAlgoId_Aes128:
70 case GWEN_Crypt_CryptAlgoId_Any:
82 if (strcasecmp(s,
"none")==0)
84 else if (strcasecmp(s,
"ecb")==0)
86 else if (strcasecmp(s,
"cfb")==0)
88 else if (strcasecmp(s,
"cbc")==0)
152 if (
id==GWEN_Crypt_CryptAlgoId_Unknown) {
195 if (a->pInitVector && a->lInitVector)
198 a->pInitVector, a->lInitVector);
217 if (na->pInitVector && na->lInitVector) {
218 a->pInitVector=(uint8_t *) malloc(na->lInitVector);
219 if (a->pInitVector==
NULL) {
224 memmove(a->pInitVector, na->pInitVector, na->lInitVector);
225 a->lInitVector=na->lInitVector;
227 a->chunkSize=na->chunkSize;
228 a->keySizeInBits=na->keySizeInBits;
238 if (a->refCount==1) {
239 if (a->pInitVector) {
240 free(a->pInitVector);
276 return a->pInitVector;
285 return a->lInitVector;
300 nv=(uint8_t *) malloc(lv);
306 if (a->pInitVector && a->lInitVector)
307 free(a->pInitVector);
310 a->lInitVector=(nv!=
NULL)?lv:0;
342 return a->keySizeInBits;
int GWEN_Crypt_CryptAlgo_SetInitVector(GWEN_CRYPT_CRYPTALGO *a, const uint8_t *pv, uint32_t lv)
GWEN_CRYPT_CRYPTALGO * GWEN_Crypt_CryptAlgo_dup(const GWEN_CRYPT_CRYPTALGO *na)
const char * GWEN_Crypt_CryptAlgoId_toString(GWEN_CRYPT_CRYPTALGOID a)
void GWEN_Crypt_CryptAlgo_SetChunkSize(GWEN_CRYPT_CRYPTALGO *a, int s)
void GWEN_Crypt_CryptAlgo_SetKeySizeInBits(GWEN_CRYPT_CRYPTALGO *a, int s)
uint8_t * GWEN_Crypt_CryptAlgo_GetInitVectorPtr(const GWEN_CRYPT_CRYPTALGO *a)
int GWEN_Crypt_CryptAlgo_GetKeySizeInBits(const GWEN_CRYPT_CRYPTALGO *a)
uint32_t GWEN_Crypt_CryptAlgo_GetInitVectorLen(const GWEN_CRYPT_CRYPTALGO *a)
GWEN_CRYPT_CRYPTMODE GWEN_Crypt_CryptMode_fromString(const char *s)
void GWEN_Crypt_CryptAlgo_free(GWEN_CRYPT_CRYPTALGO *a)
int GWEN_Crypt_CryptAlgo_GetChunkSize(const GWEN_CRYPT_CRYPTALGO *a)
int GWEN_Crypt_CryptAlgo_toDb(const GWEN_CRYPT_CRYPTALGO *a, GWEN_DB_NODE *db)
GWEN_CRYPT_CRYPTALGO * GWEN_Crypt_CryptAlgo_fromDb(GWEN_DB_NODE *db)
void GWEN_Crypt_CryptAlgo_Attach(GWEN_CRYPT_CRYPTALGO *a)
const char * GWEN_Crypt_CryptMode_toString(GWEN_CRYPT_CRYPTMODE m)
GWEN_CRYPT_CRYPTALGO * GWEN_Crypt_CryptAlgo_new(GWEN_CRYPT_CRYPTALGOID id, GWEN_CRYPT_CRYPTMODE m)
GWEN_CRYPT_CRYPTALGOID GWEN_Crypt_CryptAlgoId_fromString(const char *s)
GWEN_CRYPT_CRYPTMODE GWEN_Crypt_CryptAlgo_GetMode(const GWEN_CRYPT_CRYPTALGO *a)
GWEN_CRYPT_CRYPTALGOID GWEN_Crypt_CryptAlgo_GetId(const GWEN_CRYPT_CRYPTALGO *a)
struct GWEN_CRYPT_CRYPTALGO GWEN_CRYPT_CRYPTALGO
@ GWEN_Crypt_CryptMode_Unknown
@ GWEN_Crypt_CryptMode_Ecb
@ GWEN_Crypt_CryptMode_Cbc
@ GWEN_Crypt_CryptMode_Cfb
@ GWEN_Crypt_CryptMode_None
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
int GWEN_DB_SetBinValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
const void * GWEN_DB_GetBinValue(GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
#define GWEN_DB_FLAGS_OVERWRITE_VARS
struct GWEN_DB_NODE GWEN_DB_NODE
#define DBG_INFO(dbg_logger, format,...)
#define GWEN_ERROR_MEMORY_FULL
#define GWEN_LIST2_FUNCTIONS(t, pr)
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)