Lines Matching refs:cx

26 HMAC_Destroy(HMACContext *cx, PRBool freeit)  in HMAC_Destroy()  argument
28 if (cx == NULL) in HMAC_Destroy()
31 PORT_Assert(!freeit == !cx->wasAllocated); in HMAC_Destroy()
32 if (cx->hash != NULL) { in HMAC_Destroy()
33 cx->hashobj->destroy(cx->hash, PR_TRUE); in HMAC_Destroy()
34 PORT_Memset(cx, 0, sizeof *cx); in HMAC_Destroy()
37 PORT_Free(cx); in HMAC_Destroy()
41 hmac_initKey(HMACContext *cx, const unsigned char *secret, in hmac_initKey() argument
48 if (isFIPS && secret_len < cx->hashobj->length / 2) { in hmac_initKey()
53 if (secret_len > cx->hashobj->blocklength) { in hmac_initKey()
54 cx->hashobj->begin(cx->hash); in hmac_initKey()
55 cx->hashobj->update(cx->hash, secret, secret_len); in hmac_initKey()
56 PORT_Assert(cx->hashobj->length <= sizeof hashed_secret); in hmac_initKey()
57 cx->hashobj->end(cx->hash, hashed_secret, &secret_len, in hmac_initKey()
59 if (secret_len != cx->hashobj->length) { in hmac_initKey()
66 PORT_Memset(cx->ipad, 0x36, cx->hashobj->blocklength); in hmac_initKey()
67 PORT_Memset(cx->opad, 0x5c, cx->hashobj->blocklength); in hmac_initKey()
71 cx->ipad[i] ^= secret[i]; in hmac_initKey()
72 cx->opad[i] ^= secret[i]; in hmac_initKey()
83 HMAC_Init(HMACContext *cx, const SECHashObject *hash_obj, in HMAC_Init() argument
88 if (cx == NULL) { in HMAC_Init()
92 cx->wasAllocated = PR_FALSE; in HMAC_Init()
93 cx->hashobj = hash_obj; in HMAC_Init()
94 cx->hash = cx->hashobj->create(); in HMAC_Init()
95 if (cx->hash == NULL) in HMAC_Init()
98 rv = hmac_initKey(cx, secret, secret_len, isFIPS); in HMAC_Init()
104 if (cx->hash != NULL) in HMAC_Init()
105 cx->hashobj->destroy(cx->hash, PR_TRUE); in HMAC_Init()
114 HMACContext *cx = PORT_ZNew(HMACContext); in HMAC_Create() local
115 if (cx == NULL) in HMAC_Create()
117 rv = HMAC_Init(cx, hash_obj, secret, secret_len, isFIPS); in HMAC_Create()
118 cx->wasAllocated = PR_TRUE; in HMAC_Create()
120 PORT_Free(cx); /* contains no secret info */ in HMAC_Create()
121 cx = NULL; in HMAC_Create()
123 return cx; in HMAC_Create()
129 HMAC_ReInit(HMACContext *cx, const SECHashObject *hash_obj, in HMAC_ReInit() argument
137 if ((cx->hashobj == hash_obj) && (cx->hash != NULL)) { in HMAC_ReInit()
138 return hmac_initKey(cx, secret, secret_len, isFIPS); in HMAC_ReInit()
143 wasAllocated = cx->wasAllocated; in HMAC_ReInit()
144 cx->wasAllocated = PR_FALSE; in HMAC_ReInit()
145 HMAC_Destroy(cx, PR_FALSE); in HMAC_ReInit()
146 rv = HMAC_Init(cx, hash_obj, secret, secret_len, isFIPS); in HMAC_ReInit()
150 cx->wasAllocated = wasAllocated; in HMAC_ReInit()
155 HMAC_Begin(HMACContext *cx) in HMAC_Begin() argument
158 cx->hashobj->begin(cx->hash); in HMAC_Begin()
159 cx->hashobj->update(cx->hash, cx->ipad, cx->hashobj->blocklength); in HMAC_Begin()
163 HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len) in HMAC_Update() argument
165 cx->hashobj->update(cx->hash, data, data_len); in HMAC_Update()
169 HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, in HMAC_Finish() argument
172 if (max_result_len < cx->hashobj->length) { in HMAC_Finish()
177 cx->hashobj->end(cx->hash, result, result_len, max_result_len); in HMAC_Finish()
178 if (*result_len != cx->hashobj->length) in HMAC_Finish()
181 cx->hashobj->begin(cx->hash); in HMAC_Finish()
182 cx->hashobj->update(cx->hash, cx->opad, cx->hashobj->blocklength); in HMAC_Finish()
183 cx->hashobj->update(cx->hash, result, *result_len); in HMAC_Finish()
184 cx->hashobj->end(cx->hash, result, result_len, max_result_len); in HMAC_Finish()
189 HMAC_Clone(HMACContext *cx) in HMAC_Clone() argument
198 newcx->hashobj = cx->hashobj; in HMAC_Clone()
199 newcx->hash = cx->hashobj->clone(cx->hash); in HMAC_Clone()
202 PORT_Memcpy(newcx->ipad, cx->ipad, cx->hashobj->blocklength); in HMAC_Clone()
203 PORT_Memcpy(newcx->opad, cx->opad, cx->hashobj->blocklength); in HMAC_Clone()