Lines Matching refs:ctx

100 static int MD4_Init(MD4_CTX *ctx)  in MD4_Init()  argument
102 md4_init(ctx); in MD4_Init()
106 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) in MD4_Update() argument
108 md4_update(ctx, size, data); in MD4_Update()
111 static void MD4_Final(unsigned char *result, MD4_CTX *ctx) in MD4_Final() argument
113 md4_digest(ctx, MD4_DIGEST_SIZE, result); in MD4_Final()
123 static int MD4_Init(MD4_CTX *ctx) in MD4_Init() argument
125 return CC_MD4_Init(ctx); in MD4_Init()
128 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) in MD4_Update() argument
130 (void)CC_MD4_Update(ctx, data, (CC_LONG)size); in MD4_Update()
133 static void MD4_Final(unsigned char *result, MD4_CTX *ctx) in MD4_Final() argument
135 (void)CC_MD4_Final(result, ctx); in MD4_Final()
146 static int MD4_Init(MD4_CTX *ctx) in MD4_Init() argument
148 ctx->hCryptProv = 0; in MD4_Init()
149 ctx->hHash = 0; in MD4_Init()
151 if(!CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_FULL, in MD4_Init()
155 if(!CryptCreateHash(ctx->hCryptProv, CALG_MD4, 0, 0, &ctx->hHash)) { in MD4_Init()
156 CryptReleaseContext(ctx->hCryptProv, 0); in MD4_Init()
157 ctx->hCryptProv = 0; in MD4_Init()
164 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) in MD4_Update() argument
166 CryptHashData(ctx->hHash, (BYTE *)data, (unsigned int) size, 0); in MD4_Update()
169 static void MD4_Final(unsigned char *result, MD4_CTX *ctx) in MD4_Final() argument
173 CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0); in MD4_Final()
175 CryptGetHashParam(ctx->hHash, HP_HASHVAL, result, &length, 0); in MD4_Final()
177 if(ctx->hHash) in MD4_Final()
178 CryptDestroyHash(ctx->hHash); in MD4_Final()
180 if(ctx->hCryptProv) in MD4_Final()
181 CryptReleaseContext(ctx->hCryptProv, 0); in MD4_Final()
192 static int MD4_Init(MD4_CTX *ctx) in MD4_Init() argument
194 ctx->data = NULL; in MD4_Init()
195 ctx->size = 0; in MD4_Init()
199 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) in MD4_Update() argument
201 if(!ctx->data) { in MD4_Update()
202 ctx->data = Curl_memdup(data, size); in MD4_Update()
203 if(ctx->data) in MD4_Update()
204 ctx->size = size; in MD4_Update()
208 static void MD4_Final(unsigned char *result, MD4_CTX *ctx) in MD4_Final() argument
210 if(ctx->data) { in MD4_Final()
212 mbedtls_md4(ctx->data, ctx->size, result); in MD4_Final()
214 (void) mbedtls_md4_ret(ctx->data, ctx->size, result); in MD4_Final()
217 Curl_safefree(ctx->data); in MD4_Final()
218 ctx->size = 0; in MD4_Final()
273 static int MD4_Init(MD4_CTX *ctx);
274 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size);
275 static void MD4_Final(unsigned char *result, MD4_CTX *ctx);
309 (ctx->block[(n)] = \
315 (ctx->block[(n)])
322 static const void *my_md4_body(MD4_CTX *ctx, in my_md4_body() argument
330 a = ctx->a; in my_md4_body()
331 b = ctx->b; in my_md4_body()
332 c = ctx->c; in my_md4_body()
333 d = ctx->d; in my_md4_body()
405 ctx->a = a; in my_md4_body()
406 ctx->b = b; in my_md4_body()
407 ctx->c = c; in my_md4_body()
408 ctx->d = d; in my_md4_body()
413 static int MD4_Init(MD4_CTX *ctx) in MD4_Init() argument
415 ctx->a = 0x67452301; in MD4_Init()
416 ctx->b = 0xefcdab89; in MD4_Init()
417 ctx->c = 0x98badcfe; in MD4_Init()
418 ctx->d = 0x10325476; in MD4_Init()
420 ctx->lo = 0; in MD4_Init()
421 ctx->hi = 0; in MD4_Init()
425 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) in MD4_Update() argument
430 saved_lo = ctx->lo; in MD4_Update()
431 ctx->lo = (saved_lo + size) & 0x1fffffff; in MD4_Update()
432 if(ctx->lo < saved_lo) in MD4_Update()
433 ctx->hi++; in MD4_Update()
434 ctx->hi += (MD4_u32plus)size >> 29; in MD4_Update()
442 memcpy(&ctx->buffer[used], data, size); in MD4_Update()
446 memcpy(&ctx->buffer[used], data, available); in MD4_Update()
449 my_md4_body(ctx, ctx->buffer, 64); in MD4_Update()
453 data = my_md4_body(ctx, data, size & ~(unsigned long)0x3f); in MD4_Update()
457 memcpy(ctx->buffer, data, size); in MD4_Update()
460 static void MD4_Final(unsigned char *result, MD4_CTX *ctx) in MD4_Final() argument
464 used = ctx->lo & 0x3f; in MD4_Final()
466 ctx->buffer[used++] = 0x80; in MD4_Final()
471 memset(&ctx->buffer[used], 0, available); in MD4_Final()
472 my_md4_body(ctx, ctx->buffer, 64); in MD4_Final()
477 memset(&ctx->buffer[used], 0, available - 8); in MD4_Final()
479 ctx->lo <<= 3; in MD4_Final()
480 ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff); in MD4_Final()
481 ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff); in MD4_Final()
482 ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff); in MD4_Final()
483 ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24)&0xff); in MD4_Final()
484 ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff); in MD4_Final()
485 ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff); in MD4_Final()
486 ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff); in MD4_Final()
487 ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24); in MD4_Final()
489 my_md4_body(ctx, ctx->buffer, 64); in MD4_Final()
491 result[0] = curlx_ultouc((ctx->a)&0xff); in MD4_Final()
492 result[1] = curlx_ultouc((ctx->a >> 8)&0xff); in MD4_Final()
493 result[2] = curlx_ultouc((ctx->a >> 16)&0xff); in MD4_Final()
494 result[3] = curlx_ultouc(ctx->a >> 24); in MD4_Final()
495 result[4] = curlx_ultouc((ctx->b)&0xff); in MD4_Final()
496 result[5] = curlx_ultouc((ctx->b >> 8)&0xff); in MD4_Final()
497 result[6] = curlx_ultouc((ctx->b >> 16)&0xff); in MD4_Final()
498 result[7] = curlx_ultouc(ctx->b >> 24); in MD4_Final()
499 result[8] = curlx_ultouc((ctx->c)&0xff); in MD4_Final()
500 result[9] = curlx_ultouc((ctx->c >> 8)&0xff); in MD4_Final()
501 result[10] = curlx_ultouc((ctx->c >> 16)&0xff); in MD4_Final()
502 result[11] = curlx_ultouc(ctx->c >> 24); in MD4_Final()
503 result[12] = curlx_ultouc((ctx->d)&0xff); in MD4_Final()
504 result[13] = curlx_ultouc((ctx->d >> 8)&0xff); in MD4_Final()
505 result[14] = curlx_ultouc((ctx->d >> 16)&0xff); in MD4_Final()
506 result[15] = curlx_ultouc(ctx->d >> 24); in MD4_Final()
508 memset(ctx, 0, sizeof(*ctx)); in MD4_Final()
516 MD4_CTX ctx; in Curl_md4it() local
519 MD4_Init(&ctx); in Curl_md4it()
521 if(!MD4_Init(&ctx)) in Curl_md4it()
525 MD4_Update(&ctx, input, curlx_uztoui(len)); in Curl_md4it()
526 MD4_Final(output, &ctx); in Curl_md4it()