14 #define DISABLE_DEBUGLOG
17 #include "hashalgo_p.h"
18 #include <gwenhywfar/misc.h>
19 #include <gwenhywfar/debug.h>
29 if (strcasecmp(s,
"none")==0)
30 return GWEN_Crypt_HashAlgoId_None;
31 else if (strcasecmp(s,
"sha1")==0)
32 return GWEN_Crypt_HashAlgoId_Sha1;
33 else if (strcasecmp(s,
"rmd160")==0)
34 return GWEN_Crypt_HashAlgoId_Rmd160;
35 else if (strcasecmp(s,
"md5")==0)
36 return GWEN_Crypt_HashAlgoId_Md5;
37 else if (strcasecmp(s,
"any")==0)
38 return GWEN_Crypt_HashAlgoId_Any;
39 else if (strcasecmp(s,
"sha256")==0)
40 return GWEN_Crypt_HashAlgoId_Sha256;
41 return GWEN_Crypt_HashAlgoId_Unknown;
48 case GWEN_Crypt_HashAlgoId_None:
50 case GWEN_Crypt_HashAlgoId_Sha1:
52 case GWEN_Crypt_HashAlgoId_Rmd160:
54 case GWEN_Crypt_HashAlgoId_Md5:
56 case GWEN_Crypt_HashAlgoId_Sha256:
58 case GWEN_Crypt_HashAlgoId_Any:
100 if (
id==GWEN_Crypt_HashAlgoId_Unknown) {
127 if (a->pInitVector && a->lInitVector)
130 a->pInitVector, a->lInitVector);
142 if (na->pInitVector && na->lInitVector) {
143 a->pInitVector=(uint8_t*) malloc(na->lInitVector);
144 if (a->pInitVector==
NULL) {
149 memmove(a->pInitVector, na->pInitVector, na->lInitVector);
150 a->lInitVector=na->lInitVector;
161 if (a->refCount==1) {
162 if (a->pInitVector) {
163 free(a->pInitVector);
188 return a->pInitVector;
196 return a->lInitVector;
210 nv=(uint8_t*) malloc(lv);
216 if (a->pInitVector && a->lInitVector)
217 free(a->pInitVector);
220 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
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_LIST2_FUNCTIONS(TYPEMAKER2_TYPE, Typemaker2_Type)
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)