14 #define DISABLE_DEBUGLOG 17 #include "hashalgo_p.h" 18 #include <gwenhywfar/misc.h> 19 #include <gwenhywfar/debug.h> 30 if (strcasecmp(s,
"none")==0)
31 return GWEN_Crypt_HashAlgoId_None;
32 else if (strcasecmp(s,
"sha1")==0)
33 return GWEN_Crypt_HashAlgoId_Sha1;
34 else if (strcasecmp(s,
"rmd160")==0)
35 return GWEN_Crypt_HashAlgoId_Rmd160;
36 else if (strcasecmp(s,
"md5")==0)
37 return GWEN_Crypt_HashAlgoId_Md5;
38 else if (strcasecmp(s,
"any")==0)
39 return GWEN_Crypt_HashAlgoId_Any;
40 else if (strcasecmp(s,
"sha256")==0)
41 return GWEN_Crypt_HashAlgoId_Sha256;
42 return GWEN_Crypt_HashAlgoId_Unknown;
50 case GWEN_Crypt_HashAlgoId_None:
52 case GWEN_Crypt_HashAlgoId_Sha1:
54 case GWEN_Crypt_HashAlgoId_Rmd160:
56 case GWEN_Crypt_HashAlgoId_Md5:
58 case GWEN_Crypt_HashAlgoId_Sha256:
60 case GWEN_Crypt_HashAlgoId_Any:
105 if (
id==GWEN_Crypt_HashAlgoId_Unknown) {
133 if (a->pInitVector && a->lInitVector)
136 a->pInitVector, a->lInitVector);
149 if (na->pInitVector && na->lInitVector) {
150 a->pInitVector=(uint8_t *) malloc(na->lInitVector);
151 if (a->pInitVector==
NULL) {
156 memmove(a->pInitVector, na->pInitVector, na->lInitVector);
157 a->lInitVector=na->lInitVector;
169 if (a->refCount==1) {
170 if (a->pInitVector) {
171 free(a->pInitVector);
198 return a->pInitVector;
207 return a->lInitVector;
222 nv=(uint8_t *) malloc(lv);
228 if (a->pInitVector && a->lInitVector)
229 free(a->pInitVector);
232 a->lInitVector=(nv!=
NULL)?lv:0;
int GWEN_Crypt_HashAlgo_SetInitVector(GWEN_CRYPT_HASHALGO *a, const uint8_t *pv, uint32_t lv)
#define GWEN_DB_FLAGS_OVERWRITE_VARS
#define GWEN_LIST2_FUNCTIONS(t, pr)
struct GWEN_DB_NODE GWEN_DB_NODE
GWEN_CRYPT_HASHALGOID GWEN_Crypt_HashAlgo_GetId(const GWEN_CRYPT_HASHALGO *a)
#define GWEN_FREE_OBJECT(varname)
const char * GWEN_Crypt_HashAlgoId_toString(GWEN_CRYPT_HASHALGOID a)
int GWEN_Crypt_HashAlgo_toDb(const GWEN_CRYPT_HASHALGO *a, GWEN_DB_NODE *db)
GWEN_CRYPT_HASHALGO * GWEN_Crypt_HashAlgo_fromDb(GWEN_DB_NODE *db)
uint8_t * GWEN_Crypt_HashAlgo_GetInitVectorPtr(const GWEN_CRYPT_HASHALGO *a)
int GWEN_DB_SetBinValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
#define GWEN_NEW_OBJECT(typ, varname)
const void * GWEN_DB_GetBinValue(GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
void GWEN_Crypt_HashAlgo_free(GWEN_CRYPT_HASHALGO *a)
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
uint32_t GWEN_Crypt_HashAlgo_GetInitVectorLen(const GWEN_CRYPT_HASHALGO *a)
GWEN_CRYPT_HASHALGO * GWEN_Crypt_HashAlgo_dup(const GWEN_CRYPT_HASHALGO *na)
GWEN_CRYPT_HASHALGO * GWEN_Crypt_HashAlgo_new(GWEN_CRYPT_HASHALGOID id)
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
#define DBG_INFO(dbg_logger, format, args...)
void GWEN_Crypt_HashAlgo_Attach(GWEN_CRYPT_HASHALGO *a)
struct GWEN_CRYPT_HASHALGO GWEN_CRYPT_HASHALGO
#define GWEN_ERROR_MEMORY_FULL
GWEN_CRYPT_HASHALGOID GWEN_Crypt_HashAlgoId_fromString(const char *s)