Lines Matching refs:context

66 #define EVP_MD_CTX_new() &(context->_ctx)
72 isc_sha224_init(isc_sha224_t *context) {
73 if (context == (isc_sha224_t *)0) {
76 context->ctx = EVP_MD_CTX_new();
77 RUNTIME_CHECK(context->ctx != NULL);
78 if (EVP_DigestInit(context->ctx, EVP_sha224()) != 1) {
84 isc_sha224_invalidate(isc_sha224_t *context) {
85 EVP_MD_CTX_free(context->ctx);
86 context->ctx = NULL;
90 isc_sha224_update(isc_sha224_t *context, const isc_uint8_t* data, size_t len) {
97 REQUIRE(context != (isc_sha224_t *)0);
98 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
101 RUNTIME_CHECK(EVP_DigestUpdate(context->ctx,
106 isc_sha224_final(isc_uint8_t digest[], isc_sha224_t *context) {
108 REQUIRE(context != (isc_sha224_t *)0);
109 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
113 RUNTIME_CHECK(EVP_DigestFinal(context->ctx,
115 EVP_MD_CTX_free(context->ctx);
116 context->ctx = NULL;
120 isc_sha256_init(isc_sha256_t *context) {
121 if (context == (isc_sha256_t *)0) {
124 context->ctx = EVP_MD_CTX_new();
125 RUNTIME_CHECK(context->ctx != NULL);
126 if (EVP_DigestInit(context->ctx, EVP_sha256()) != 1) {
132 isc_sha256_invalidate(isc_sha256_t *context) {
133 EVP_MD_CTX_free(context->ctx);
134 context->ctx = NULL;
138 isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) {
145 REQUIRE(context != (isc_sha256_t *)0);
146 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
149 RUNTIME_CHECK(EVP_DigestUpdate(context->ctx,
154 isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) {
156 REQUIRE(context != (isc_sha256_t *)0);
157 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
161 RUNTIME_CHECK(EVP_DigestFinal(context->ctx,
163 EVP_MD_CTX_free(context->ctx);
164 context->ctx = NULL;
168 isc_sha512_init(isc_sha512_t *context) {
169 if (context == (isc_sha512_t *)0) {
172 context->ctx = EVP_MD_CTX_new();
173 RUNTIME_CHECK(context->ctx != NULL);
174 if (EVP_DigestInit(context->ctx, EVP_sha512()) != 1) {
180 isc_sha512_invalidate(isc_sha512_t *context) {
181 EVP_MD_CTX_free(context->ctx);
182 context->ctx = NULL;
185 void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t len) {
192 REQUIRE(context != (isc_sha512_t *)0);
193 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
196 RUNTIME_CHECK(EVP_DigestUpdate(context->ctx,
200 void isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) {
202 REQUIRE(context != (isc_sha512_t *)0);
203 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
207 RUNTIME_CHECK(EVP_DigestFinal(context->ctx,
209 EVP_MD_CTX_free(context->ctx);
210 context->ctx = NULL;
214 isc_sha384_init(isc_sha384_t *context) {
215 if (context == (isc_sha384_t *)0) {
218 context->ctx = EVP_MD_CTX_new();
219 RUNTIME_CHECK(context->ctx != NULL);
220 if (EVP_DigestInit(context->ctx, EVP_sha384()) != 1) {
226 isc_sha384_invalidate(isc_sha384_t *context) {
227 EVP_MD_CTX_free(context->ctx);
228 context->ctx = NULL;
232 isc_sha384_update(isc_sha384_t *context, const isc_uint8_t* data, size_t len) {
239 REQUIRE(context != (isc_sha512_t *)0);
240 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
243 RUNTIME_CHECK(EVP_DigestUpdate(context->ctx,
248 isc_sha384_final(isc_uint8_t digest[], isc_sha384_t *context) {
250 REQUIRE(context != (isc_sha384_t *)0);
251 REQUIRE(context->ctx != (EVP_MD_CTX *)0);
255 RUNTIME_CHECK(EVP_DigestFinal(context->ctx,
257 EVP_MD_CTX_free(context->ctx);
258 context->ctx = NULL;
264 isc_sha224_init(isc_sha224_t *context) {
268 if (context == (isc_sha224_t *)0) {
271 RUNTIME_CHECK(pk11_get_session(context, OP_DIGEST, ISC_TRUE, ISC_FALSE,
273 PK11_FATALCHECK(pkcs_C_DigestInit, (context->session, &mech));
277 isc_sha224_invalidate(isc_sha224_t *context) {
281 if (context->handle == NULL)
283 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
285 pk11_return_session(context);
289 isc_sha224_update(isc_sha224_t *context, const isc_uint8_t* data, size_t len) {
299 REQUIRE(context != (isc_sha224_t *)0 && data != (isc_uint8_t*)0);
303 (context->session, pPart, (CK_ULONG) len));
307 isc_sha224_final(isc_uint8_t digest[], isc_sha224_t *context) {
312 REQUIRE(context != (isc_sha224_t *)0);
317 (context->session,
323 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
326 pk11_return_session(context);
330 isc_sha256_init(isc_sha256_t *context) {
334 if (context == (isc_sha256_t *)0) {
337 RUNTIME_CHECK(pk11_get_session(context, OP_DIGEST, ISC_TRUE, ISC_FALSE,
339 PK11_FATALCHECK(pkcs_C_DigestInit, (context->session, &mech));
343 isc_sha256_invalidate(isc_sha256_t *context) {
347 if (context->handle == NULL)
349 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
351 pk11_return_session(context);
355 isc_sha256_update(isc_sha256_t *context, const isc_uint8_t* data, size_t len) {
365 REQUIRE(context != (isc_sha256_t *)0 && data != (isc_uint8_t*)0);
369 (context->session, pPart, (CK_ULONG) len));
373 isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) {
378 REQUIRE(context != (isc_sha256_t *)0);
383 (context->session,
389 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
392 pk11_return_session(context);
396 isc_sha512_init(isc_sha512_t *context) {
400 if (context == (isc_sha512_t *)0) {
403 RUNTIME_CHECK(pk11_get_session(context, OP_DIGEST, ISC_TRUE, ISC_FALSE,
405 PK11_FATALCHECK(pkcs_C_DigestInit, (context->session, &mech));
409 isc_sha512_invalidate(isc_sha512_t *context) {
413 if (context->handle == NULL)
415 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
417 pk11_return_session(context);
421 isc_sha512_update(isc_sha512_t *context, const isc_uint8_t* data, size_t len) {
431 REQUIRE(context != (isc_sha512_t *)0 && data != (isc_uint8_t*)0);
435 (context->session, pPart, (CK_ULONG) len));
439 isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) {
444 REQUIRE(context != (isc_sha512_t *)0);
449 (context->session,
455 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
458 pk11_return_session(context);
462 isc_sha384_init(isc_sha384_t *context) {
466 if (context == (isc_sha384_t *)0) {
469 RUNTIME_CHECK(pk11_get_session(context, OP_DIGEST, ISC_TRUE, ISC_FALSE,
471 PK11_FATALCHECK(pkcs_C_DigestInit, (context->session, &mech));
475 isc_sha384_invalidate(isc_sha384_t *context) {
479 if (context->handle == NULL)
481 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
483 pk11_return_session(context);
487 isc_sha384_update(isc_sha384_t *context, const isc_uint8_t* data, size_t len) {
497 REQUIRE(context != (isc_sha384_t *)0 && data != (isc_uint8_t*)0);
501 (context->session, pPart, (CK_ULONG) len));
505 isc_sha384_final(isc_uint8_t digest[], isc_sha384_t *context) {
510 REQUIRE(context != (isc_sha384_t *)0);
515 (context->session,
521 (void) pkcs_C_DigestFinal(context->session, garbage, &len);
524 pk11_return_session(context);
864 isc_sha224_init(isc_sha224_t *context) {
865 if (context == (isc_sha256_t *)0) {
868 memmove(context->state, sha224_initial_hash_value,
870 memset(context->buffer, 0, ISC_SHA256_BLOCK_LENGTH);
871 context->bitcount = 0;
875 isc_sha224_invalidate(isc_sha224_t *context) {
876 isc_safe_memwipe(context, sizeof(*context));
880 isc_sha224_update(isc_sha224_t *context, const isc_uint8_t* data, size_t len) {
881 isc_sha256_update((isc_sha256_t *)context, data, len);
885 isc_sha224_final(isc_uint8_t digest[], isc_sha224_t *context) {
887 isc_sha256_final(sha256_digest, (isc_sha256_t *)context);
894 isc_sha256_init(isc_sha256_t *context) {
895 if (context == (isc_sha256_t *)0) {
898 memmove(context->state, sha256_initial_hash_value,
900 memset(context->buffer, 0, ISC_SHA256_BLOCK_LENGTH);
901 context->bitcount = 0;
905 isc_sha256_invalidate(isc_sha256_t *context) {
906 isc_safe_memwipe(context, sizeof(*context));
946 void isc_sha256_transform(isc_sha256_t *context, const isc_uint32_t* data) {
951 W256 = (isc_uint32_t*)context->buffer;
954 a = context->state[0];
955 b = context->state[1];
956 c = context->state[2];
957 d = context->state[3];
958 e = context->state[4];
959 f = context->state[5];
960 g = context->state[6];
961 h = context->state[7];
989 context->state[0] += a;
990 context->state[1] += b;
991 context->state[2] += c;
992 context->state[3] += d;
993 context->state[4] += e;
994 context->state[5] += f;
995 context->state[6] += g;
996 context->state[7] += h;
1008 isc_sha256_transform(isc_sha256_t *context, const isc_uint32_t* data) {
1013 W256 = (isc_uint32_t*)context->buffer;
1016 a = context->state[0];
1017 b = context->state[1];
1018 c = context->state[2];
1019 d = context->state[3];
1020 e = context->state[4];
1021 f = context->state[5];
1022 g = context->state[6];
1023 h = context->state[7];
1073 context->state[0] += a;
1074 context->state[1] += b;
1075 context->state[2] += c;
1076 context->state[3] += d;
1077 context->state[4] += e;
1078 context->state[5] += f;
1079 context->state[6] += g;
1080 context->state[7] += h;
1092 isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) {
1101 REQUIRE(context != (isc_sha256_t *)0 && data != (isc_uint8_t*)0);
1103 usedspace = (unsigned int)((context->bitcount >> 3) %
1111 memmove(&context->buffer[usedspace], data, freespace);
1112 context->bitcount += freespace << 3;
1115 isc_sha256_transform(context,
1116 (isc_uint32_t*)context->buffer);
1119 memmove(&context->buffer[usedspace], data, len);
1120 context->bitcount += len << 3;
1130 memmove(context->buffer, data, ISC_SHA256_BLOCK_LENGTH);
1131 isc_sha256_transform(context, (isc_uint32_t*)context->buffer);
1132 context->bitcount += ISC_SHA256_BLOCK_LENGTH << 3;
1138 memmove(context->buffer, data, len);
1139 context->bitcount += len << 3;
1148 isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) {
1153 REQUIRE(context != (isc_sha256_t *)0);
1157 usedspace = (unsigned int)((context->bitcount >> 3) %
1161 REVERSE64(context->bitcount,context->bitcount);
1165 context->buffer[usedspace++] = 0x80;
1169 memset(&context->buffer[usedspace], 0,
1173 memset(&context->buffer[usedspace], 0,
1178 isc_sha256_transform(context,
1179 (isc_uint32_t*)context->buffer);
1182 memset(context->buffer, 0,
1187 memset(context->buffer, 0, ISC_SHA256_SHORT_BLOCK_LENGTH);
1190 *context->buffer = 0x80;
1193 *(isc_uint64_t*)&context->buffer[ISC_SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
1196 isc_sha256_transform(context, (isc_uint32_t*)context->buffer);
1203 REVERSE32(context->state[j],context->state[j]);
1204 *d++ = context->state[j];
1208 memmove(d, context->state, ISC_SHA256_DIGESTLENGTH);
1213 isc_safe_memwipe(context, sizeof(*context));
1220 isc_sha512_init(isc_sha512_t *context) {
1221 if (context == (isc_sha512_t *)0) {
1224 memmove(context->state, sha512_initial_hash_value,
1226 memset(context->buffer, 0, ISC_SHA512_BLOCK_LENGTH);
1227 context->bitcount[0] = context->bitcount[1] = 0;
1231 isc_sha512_invalidate(isc_sha512_t *context) {
1232 isc_safe_memwipe(context, sizeof(*context));
1271 void isc_sha512_transform(isc_sha512_t *context, const isc_uint64_t* data) {
1273 isc_uint64_t T1, *W512 = (isc_uint64_t*)context->buffer;
1277 a = context->state[0];
1278 b = context->state[1];
1279 c = context->state[2];
1280 d = context->state[3];
1281 e = context->state[4];
1282 f = context->state[5];
1283 g = context->state[6];
1284 h = context->state[7];
1311 context->state[0] += a;
1312 context->state[1] += b;
1313 context->state[2] += c;
1314 context->state[3] += d;
1315 context->state[4] += e;
1316 context->state[5] += f;
1317 context->state[6] += g;
1318 context->state[7] += h;
1330 isc_sha512_transform(isc_sha512_t *context, const isc_uint64_t* data) {
1332 isc_uint64_t T1, T2, *W512 = (isc_uint64_t*)context->buffer;
1336 a = context->state[0];
1337 b = context->state[1];
1338 c = context->state[2];
1339 d = context->state[3];
1340 e = context->state[4];
1341 f = context->state[5];
1342 g = context->state[6];
1343 h = context->state[7];
1393 context->state[0] += a;
1394 context->state[1] += b;
1395 context->state[2] += c;
1396 context->state[3] += d;
1397 context->state[4] += e;
1398 context->state[5] += f;
1399 context->state[6] += g;
1400 context->state[7] += h;
1411 void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t len) {
1420 REQUIRE(context != (isc_sha512_t *)0 && data != (isc_uint8_t*)0);
1422 usedspace = (unsigned int)((context->bitcount[0] >> 3) %
1430 memmove(&context->buffer[usedspace], data, freespace);
1431 ADDINC128(context->bitcount, freespace << 3);
1434 isc_sha512_transform(context,
1435 (isc_uint64_t*)context->buffer);
1438 memmove(&context->buffer[usedspace], data, len);
1439 ADDINC128(context->bitcount, len << 3);
1449 memmove(context->buffer, data, ISC_SHA512_BLOCK_LENGTH);
1450 isc_sha512_transform(context, (isc_uint64_t*)context->buffer);
1451 ADDINC128(context->bitcount, ISC_SHA512_BLOCK_LENGTH << 3);
1457 memmove(context->buffer, data, len);
1458 ADDINC128(context->bitcount, len << 3);
1466 void isc_sha512_last(isc_sha512_t *context) {
1469 usedspace = (unsigned int)((context->bitcount[0] >> 3) %
1473 REVERSE64(context->bitcount[0],context->bitcount[0]);
1474 REVERSE64(context->bitcount[1],context->bitcount[1]);
1478 context->buffer[usedspace++] = 0x80;
1482 memset(&context->buffer[usedspace], 0,
1486 memset(&context->buffer[usedspace], 0,
1490 isc_sha512_transform(context,
1491 (isc_uint64_t*)context->buffer);
1494 memset(context->buffer, 0, ISC_SHA512_BLOCK_LENGTH - 2);
1498 memset(context->buffer, 0, ISC_SHA512_SHORT_BLOCK_LENGTH);
1501 *context->buffer = 0x80;
1504 *(isc_uint64_t*)&context->buffer[ISC_SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
1505 *(isc_uint64_t*)&context->buffer[ISC_SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
1508 isc_sha512_transform(context, (isc_uint64_t*)context->buffer);
1511 void isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) {
1515 REQUIRE(context != (isc_sha512_t *)0);
1519 isc_sha512_last(context);
1527 REVERSE64(context->state[j],context->state[j]);
1528 *d++ = context->state[j];
1532 memmove(d, context->state, ISC_SHA512_DIGESTLENGTH);
1537 isc_safe_memwipe(context, sizeof(*context));
1543 isc_sha384_init(isc_sha384_t *context) {
1544 if (context == (isc_sha384_t *)0) {
1547 memmove(context->state, sha384_initial_hash_value,
1549 memset(context->buffer, 0, ISC_SHA384_BLOCK_LENGTH);
1550 context->bitcount[0] = context->bitcount[1] = 0;
1554 isc_sha384_invalidate(isc_sha384_t *context) {
1555 isc_safe_memwipe(context, sizeof(*context));
1559 isc_sha384_update(isc_sha384_t *context, const isc_uint8_t* data, size_t len) {
1560 isc_sha512_update((isc_sha512_t *)context, data, len);
1564 isc_sha384_final(isc_uint8_t digest[], isc_sha384_t *context) {
1568 REQUIRE(context != (isc_sha384_t *)0);
1572 isc_sha512_last((isc_sha512_t *)context);
1580 REVERSE64(context->state[j],context->state[j]);
1581 *d++ = context->state[j];
1585 memmove(d, context->state, ISC_SHA384_DIGESTLENGTH);
1590 isc_safe_memwipe(context, sizeof(*context));
1601 isc_sha224_end(isc_sha224_t *context, char buffer[]) {
1606 REQUIRE(context != (isc_sha224_t *)0);
1609 isc_sha224_final(digest, context);
1619 EVP_MD_CTX_reset(context->ctx);
1621 pk11_return_session(context);
1623 isc_safe_memwipe(context, sizeof(*context));
1634 isc_sha224_t context;
1636 isc_sha224_init(&context);
1637 isc_sha224_update(&context, data, len);
1638 return (isc_sha224_end(&context, digest));
1642 isc_sha256_end(isc_sha256_t *context, char buffer[]) {
1647 REQUIRE(context != (isc_sha256_t *)0);
1650 isc_sha256_final(digest, context);
1660 EVP_MD_CTX_reset(context->ctx);
1662 pk11_return_session(context);
1664 isc_safe_memwipe(context, sizeof(*context));
1675 isc_sha256_t context;
1677 isc_sha256_init(&context);
1678 isc_sha256_update(&context, data, len);
1679 return (isc_sha256_end(&context, digest));
1683 isc_sha512_end(isc_sha512_t *context, char buffer[]) {
1688 REQUIRE(context != (isc_sha512_t *)0);
1691 isc_sha512_final(digest, context);
1701 EVP_MD_CTX_reset(context->ctx);
1703 pk11_return_session(context);
1705 isc_safe_memwipe(context, sizeof(*context));
1716 isc_sha512_t context;
1718 isc_sha512_init(&context);
1719 isc_sha512_update(&context, data, len);
1720 return (isc_sha512_end(&context, digest));
1724 isc_sha384_end(isc_sha384_t *context, char buffer[]) {
1729 REQUIRE(context != (isc_sha384_t *)0);
1732 isc_sha384_final(digest, context);
1742 EVP_MD_CTX_reset(context->ctx);
1744 pk11_return_session(context);
1746 isc_safe_memwipe(context, sizeof(*context));
1757 isc_sha384_t context;
1759 isc_sha384_init(&context);
1760 isc_sha384_update(&context, data, len);
1761 return (isc_sha384_end(&context, digest));