Lines Matching defs:ctx

50 #define EVP_MD_CTX_new() &(ctx->_ctx)
55 isc_md5_init(isc_md5_t *ctx) {
56 ctx->ctx = EVP_MD_CTX_new();
57 RUNTIME_CHECK(ctx->ctx != NULL);
58 if (EVP_DigestInit(ctx->ctx, EVP_md5()) != 1) {
64 isc_md5_invalidate(isc_md5_t *ctx) {
65 EVP_MD_CTX_free(ctx->ctx);
66 ctx->ctx = NULL;
70 isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) {
73 RUNTIME_CHECK(EVP_DigestUpdate(ctx->ctx,
79 isc_md5_final(isc_md5_t *ctx, unsigned char *digest) {
80 RUNTIME_CHECK(EVP_DigestFinal(ctx->ctx, digest, NULL) == 1);
81 EVP_MD_CTX_free(ctx->ctx);
82 ctx->ctx = NULL;
88 isc_md5_init(isc_md5_t *ctx) {
92 RUNTIME_CHECK(pk11_get_session(ctx, OP_DIGEST, ISC_TRUE, ISC_FALSE,
94 PK11_FATALCHECK(pkcs_C_DigestInit, (ctx->session, &mech));
98 isc_md5_invalidate(isc_md5_t *ctx) {
102 if (ctx->handle == NULL)
104 (void) pkcs_C_DigestFinal(ctx->session, garbage, &len);
106 pk11_return_session(ctx);
110 isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) {
116 (ctx->session, pPart, (CK_ULONG) len));
120 isc_md5_final(isc_md5_t *ctx, unsigned char *digest) {
125 (ctx->session, (CK_BYTE_PTR) digest, &len));
126 pk11_return_session(ctx);
148 isc_md5_init(isc_md5_t *ctx) {
149 ctx->buf[0] = 0x67452301;
150 ctx->buf[1] = 0xefcdab89;
151 ctx->buf[2] = 0x98badcfe;
152 ctx->buf[3] = 0x10325476;
154 ctx->bytes[0] = 0;
155 ctx->bytes[1] = 0;
159 isc_md5_invalidate(isc_md5_t *ctx) {
160 isc_safe_memwipe(ctx, sizeof(*ctx));
270 isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) {
275 t = ctx->bytes[0];
276 if ((ctx->bytes[0] = t + len) < t)
277 ctx->bytes[1]++; /* Carry from low to high */
279 t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
281 memmove((unsigned char *)ctx->in + 64 - t, buf, len);
285 memmove((unsigned char *)ctx->in + 64 - t, buf, t);
286 byteSwap(ctx->in, 16);
287 transform(ctx->buf, ctx->in);
293 memmove(ctx->in, buf, 64);
294 byteSwap(ctx->in, 16);
295 transform(ctx->buf, ctx->in);
301 memmove(ctx->in, buf, len);
309 isc_md5_final(isc_md5_t *ctx, unsigned char *digest) {
310 int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
311 unsigned char *p = (unsigned char *)ctx->in + count;
321 byteSwap(ctx->in, 16);
322 transform(ctx->buf, ctx->in);
323 p = (unsigned char *)ctx->in;
327 byteSwap(ctx->in, 14);
330 ctx->in[14] = ctx->bytes[0] << 3;
331 ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
332 transform(ctx->buf, ctx->in);
334 byteSwap(ctx->buf, 4);
335 memmove(digest, ctx->buf, 16);
336 isc_safe_memwipe(ctx, sizeof(*ctx)); /* In case it's sensitive */
350 isc_md5_t ctx;
370 isc_md5_init(&ctx);
371 isc_md5_update(&ctx, &input, 1U);
372 isc_md5_final(&ctx, digest);