12#include "ct_keyinfo_p.h"
14#include <gwenhywfar/misc.h>
15#include <gwenhywfar/debug.h>
28 if (strcasecmp(p_s,
"free")==0)
30 else if (strcasecmp(p_s,
"new")==0)
32 else if (strcasecmp(p_s,
"active")==0)
57 p_struct->_refCount=1;
62 p_struct->keyDescr=
NULL;
65 p_struct->cryptAlgoId=0;
66 p_struct->modulus=
NULL;
67 p_struct->exponent=
NULL;
68 p_struct->keyNumber=0;
69 p_struct->keyVersion=0;
70 p_struct->signCounter=0;
71 p_struct->certificate=
NULL;
81 assert(p_struct->_refCount);
82 if (p_struct->_refCount==1) {
86 free(p_struct->keyDescr);
87 p_struct->keyDescr=
NULL;
89 p_struct->modulus=
NULL;
91 p_struct->exponent=
NULL;
93 p_struct->certificate=
NULL;
94 p_struct->_refCount=0;
98 p_struct->_refCount--;
105 assert(p_struct->_refCount);
106 p_struct->_refCount++;
116 p_struct->id=p_src->id;
119 if (p_struct->keyDescr) {
120 free(p_struct->keyDescr);
121 p_struct->keyDescr=
NULL;
122 p_struct->keyDescr=
NULL;
124 if (p_src->keyDescr) {
125 p_struct->keyDescr=strdup(p_src->keyDescr);
129 p_struct->flags=p_src->flags;
132 p_struct->keySize=p_src->keySize;
135 p_struct->cryptAlgoId=p_src->cryptAlgoId;
138 if (p_struct->modulus) {
140 p_struct->modulus=
NULL;
141 p_struct->modulus=
NULL;
143 if (p_src->modulus) {
148 if (p_struct->exponent) {
150 p_struct->exponent=
NULL;
151 p_struct->exponent=
NULL;
153 if (p_src->exponent) {
158 p_struct->keyNumber=p_src->keyNumber;
161 p_struct->keyVersion=p_src->keyVersion;
164 p_struct->signCounter=p_src->signCounter;
167 if (p_struct->certificate) {
169 p_struct->certificate=
NULL;
170 p_struct->certificate=
NULL;
172 if (p_src->certificate) {
177 p_struct->certType=p_src->certType;
188 p_struct->id=p_src->id;
191 if (p_struct->keyDescr) {
192 free(p_struct->keyDescr);
193 p_struct->keyDescr=
NULL;
194 p_struct->keyDescr=
NULL;
196 if (p_src->keyDescr) {
197 p_struct->keyDescr=strdup(p_src->keyDescr);
201 p_struct->flags=p_src->flags;
204 p_struct->keySize=p_src->keySize;
207 p_struct->cryptAlgoId=p_src->cryptAlgoId;
210 if (p_struct->modulus) {
212 p_struct->modulus=
NULL;
213 p_struct->modulus=
NULL;
215 if (p_src->modulus) {
220 if (p_struct->exponent) {
222 p_struct->exponent=
NULL;
223 p_struct->exponent=
NULL;
225 if (p_src->exponent) {
230 p_struct->keyNumber=p_src->keyNumber;
233 p_struct->keyVersion=p_src->keyVersion;
236 p_struct->signCounter=p_src->signCounter;
239 if (p_struct->certificate) {
241 p_struct->certificate=
NULL;
242 p_struct->certificate=
NULL;
244 if (p_src->certificate) {
249 p_struct->certType=p_src->certType;
263 return p_struct->keyDescr;
269 return p_struct->flags;
275 return p_struct->keySize;
281 return p_struct->cryptAlgoId;
287 return p_struct->keyNumber;
293 return p_struct->keyVersion;
299 return p_struct->signCounter;
305 return p_struct->certType;
317 if (p_struct->keyDescr) {
318 free(p_struct->keyDescr);
319 p_struct->keyDescr=
NULL;
322 p_struct->keyDescr=strdup(p_src);
325 p_struct->keyDescr=
NULL;
332 p_struct->flags=p_src;
338 p_struct->flags|=p_src;
344 p_struct->flags&=~p_src;
350 p_struct->keySize=p_src;
356 p_struct->cryptAlgoId=p_src;
362 p_struct->keyNumber=p_src;
368 p_struct->keyVersion=p_src;
374 p_struct->signCounter=p_src;
380 p_struct->certType=p_src;
410 if (p_struct->keyDescr) {
411 free(p_struct->keyDescr);
412 p_struct->keyDescr=
NULL;
418 p_struct->keyDescr=strdup(s);
420 if (p_struct->keyDescr==
NULL) {
421 p_struct->keyDescr=
NULL;
434 if (p_struct->modulus) {
436 p_struct->modulus=
NULL;
447 if (p_struct->modulus==
NULL) {
448 p_struct->modulus=
NULL;
452 if (p_struct->exponent) {
454 p_struct->exponent=
NULL;
465 if (p_struct->exponent==
NULL) {
466 p_struct->exponent=
NULL;
479 if (p_struct->certificate) {
481 p_struct->certificate=
NULL;
492 if (p_struct->certificate==
NULL) {
493 p_struct->certificate=
NULL;
514 if (p_struct->keyDescr)
547 if (p_struct->modulus)
560 if (p_struct->exponent)
594 if (p_struct->certificate)
636 if (p_struct->keyDescr) {
637 free(p_struct->keyDescr);
638 p_struct->keyDescr=
NULL;
644 p_struct->keyDescr=strdup(s);
646 if (p_struct->keyDescr==
NULL) {
647 p_struct->keyDescr=
NULL;
660 if (p_struct->modulus) {
662 p_struct->modulus=
NULL;
672 if (p_struct->modulus==
NULL) {
673 p_struct->modulus=
NULL;
677 if (p_struct->exponent) {
679 p_struct->exponent=
NULL;
689 if (p_struct->exponent==
NULL) {
690 p_struct->exponent=
NULL;
703 if (p_struct->certificate) {
705 p_struct->certificate=
NULL;
715 if (p_struct->certificate==
NULL) {
716 p_struct->certificate=
NULL;
743 if (p_struct->modulus) {
753 if (p_struct->exponent) {
772 if (p_struct->certificate) {
809 if (p_struct->id==p_cmp)
811 else if (p_cmp<p_struct->
id)
897 st->certificate=
NULL;
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
GWEN_BUFFER * GWEN_Buffer_dup(GWEN_BUFFER *bf)
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
void GWEN_Crypt_Token_KeyInfo_SetCertificate(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
int GWEN_Crypt_Token_KeyInfo_toDb(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct, GWEN_DB_NODE *p_db)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_dup(const GWEN_CRYPT_TOKEN_KEYINFO *p_src)
int GWEN_Crypt_Token_KeyInfo_WriteDb(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct, GWEN_DB_NODE *p_db)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_fromDb(GWEN_DB_NODE *p_db)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_fromXml(GWEN_XMLNODE *p_db)
uint32_t GWEN_Crypt_Token_KeyInfo_GetCertificateLen(const GWEN_CRYPT_TOKEN_KEYINFO *st)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_new(uint32_t kid, GWEN_CRYPT_CRYPTALGOID a, int keySize)
void GWEN_Crypt_Token_KeyInfo_toXml(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct, GWEN_XMLNODE *p_db)
const char * GWEN_Crypt_Token_KeyStatus_toString(GWEN_CRYPT_TOKEN_KEYSTATUS p_i)
GWEN_CRYPT_TOKEN_KEYINFO_LIST * GWEN_Crypt_Token_KeyInfo_List_dup(const GWEN_CRYPT_TOKEN_KEYINFO_LIST *p_src)
void GWEN_Crypt_Token_KeyInfo_SetKeyDescr(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, const char *p_src)
void GWEN_Crypt_Token_KeyInfo_free(GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_List_GetById(const GWEN_CRYPT_TOKEN_KEYINFO_LIST *p_list, uint32_t p_cmp)
uint32_t GWEN_Crypt_Token_KeyInfo_GetSignCounter(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
uint32_t GWEN_Crypt_Token_KeyInfo_GetId(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
const uint8_t * GWEN_Crypt_Token_KeyInfo_GetCertificateData(const GWEN_CRYPT_TOKEN_KEYINFO *st)
void GWEN_Crypt_Token_KeyInfo_SetId(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_SetKeySize(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, int p_src)
void GWEN_Crypt_Token_KeyInfo_Attach(GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_copy(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, const GWEN_CRYPT_TOKEN_KEYINFO *p_src)
void GWEN_Crypt_Token_KeyInfo_SetCryptAlgoId(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, int p_src)
uint32_t GWEN_Crypt_Token_KeyInfo_GetFlags(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
void GWEN_Crypt_Token_KeyInfo_SetFlags(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
uint32_t GWEN_Crypt_Token_KeyInfo_GetModulusLen(const GWEN_CRYPT_TOKEN_KEYINFO *st)
uint32_t GWEN_Crypt_Token_KeyInfo_GetKeyNumber(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
void GWEN_Crypt_Token_KeyInfo_WriteXml(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct, GWEN_XMLNODE *p_db)
void GWEN_Crypt_Token_KeyInfo_SetKeyVersion(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_SubFlags(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_SetSignCounter(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_SetExponent(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
const uint8_t * GWEN_Crypt_Token_KeyInfo_GetExponentData(const GWEN_CRYPT_TOKEN_KEYINFO *st)
int GWEN_Crypt_Token_KeyInfo_GetKeySize(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
const char * GWEN_Crypt_Token_KeyInfo_GetKeyDescr(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
void GWEN_Crypt_Token_KeyInfo_SetModulus(GWEN_CRYPT_TOKEN_KEYINFO *st, const uint8_t *p, uint32_t len)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo__new(void)
void GWEN_Crypt_Token_KeyInfo_ReadXml(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, GWEN_XMLNODE *p_db)
void GWEN_Crypt_Token_KeyInfo_SetKeyNumber(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
void GWEN_Crypt_Token_KeyInfo_ReadDb(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, GWEN_DB_NODE *p_db)
uint8_t GWEN_Crypt_Token_KeyInfo_GetCertType(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
void GWEN_Crypt_Token_KeyInfo_AddFlags(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint32_t p_src)
uint32_t GWEN_Crypt_Token_KeyInfo_GetKeyVersion(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
int GWEN_Crypt_Token_KeyInfo_GetCryptAlgoId(const GWEN_CRYPT_TOKEN_KEYINFO *p_struct)
GWEN_CRYPT_TOKEN_KEYSTATUS GWEN_Crypt_Token_KeyStatus_fromString(const char *p_s)
const uint8_t * GWEN_Crypt_Token_KeyInfo_GetModulusData(const GWEN_CRYPT_TOKEN_KEYINFO *st)
uint32_t GWEN_Crypt_Token_KeyInfo_GetExponentLen(const GWEN_CRYPT_TOKEN_KEYINFO *st)
void GWEN_Crypt_Token_KeyInfo_SetCertType(GWEN_CRYPT_TOKEN_KEYINFO *p_struct, uint8_t p_src)
struct GWEN_CRYPT_TOKEN_KEYINFO GWEN_CRYPT_TOKEN_KEYINFO
GWEN_CRYPT_TOKEN_KEYSTATUS
@ GWEN_Crypt_Token_KeyStatusNew
@ GWEN_Crypt_Token_KeyStatusUnknown
@ GWEN_Crypt_Token_KeyStatusFree
@ GWEN_Crypt_Token_KeyStatusActive
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
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,...)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
#define GWEN_INHERIT_FUNCTIONS(t)
#define GWEN_INHERIT_INIT(t, element)
#define GWEN_INHERIT_FINI(t, element)
#define GWEN_LIST_FINI(t, element)
#define GWEN_LIST_FUNCTIONS(t, pr)
#define GWEN_LIST_INIT(t, element)
#define GWEN_LIST2_FUNCTIONS(t, pr)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_List_Next(const GWEN_CRYPT_TOKEN_KEYINFO *element)
GWEN_CRYPT_TOKEN_KEYINFO * GWEN_Crypt_Token_KeyInfo_List_First(const GWEN_CRYPT_TOKEN_KEYINFO_LIST *l)
void GWEN_Crypt_Token_KeyInfo_List_Add(GWEN_CRYPT_TOKEN_KEYINFO *element, GWEN_CRYPT_TOKEN_KEYINFO_LIST *list)
GWEN_CRYPT_TOKEN_KEYINFO_LIST * GWEN_Crypt_Token_KeyInfo_List_new()
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)
int GWEN_Text_ToHexBuffer(const char *src, unsigned l, GWEN_BUFFER *buf, unsigned int groupsize, char delimiter, int skipLeadingZeroes)
int GWEN_Text_FromHexBuffer(const char *src, GWEN_BUFFER *buf)
void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n, const char *name, int value)
int GWEN_XMLNode_GetIntValue(const GWEN_XMLNODE *n, const char *name, int defValue)
const char * GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n, const char *name, const char *defValue)
void GWEN_XMLNode_SetCharValue(GWEN_XMLNODE *n, const char *name, const char *value)
struct GWEN__XMLNODE GWEN_XMLNODE