int main (int argc, char *argv[]) { int i; for (i = 0; i < DATA_SIZE; i++) data[i] = (guchar)i; test_full (DATA_SIZE); test_full (1); test_full (2); test_full (3); test_incremental (FALSE, DATA_SIZE); test_incremental (TRUE, DATA_SIZE); test_incremental (FALSE, DATA_SIZE - 1); test_incremental (TRUE, DATA_SIZE - 1); test_incremental (FALSE, DATA_SIZE - 2); test_incremental (TRUE, DATA_SIZE - 2); test_incremental (FALSE, 1); test_incremental (FALSE, 2); test_incremental (FALSE, 3); return 0; }
int main(int argc, char **argv) { size_t i, j; uint8_t md[SHA_DIGEST_LENGTH]; char md_hex[sizeof(md) * 2 + 1]; int ok = 1; CRYPTO_library_init(); for (i = 0; test[i] != NULL; i++) { EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_sha1(), NULL); for (j = 0; j < sizeof(md); j++) { sprintf(&md_hex[j * 2], "%02x", md[j]); } if (strcmp(md_hex, expected[i]) != 0) { fprintf(stderr, "#%u: got %s, wanted %s\n", (unsigned)i, md_hex, expected[i]); ok = 0; } } ok &= test_incremental(); if (ok) { printf("PASS\n"); } return ok ? 0 : 1; }