1 --- trousers-0.3.11.2/src/trspi/crypto/openssl/hash.c.orig
2 +++ trousers-0.3.11.2/src/trspi/crypto/openssl/hash.c
5 Trspi_Hash(UINT32 HashType, UINT32 BufSize, BYTE* Buf, BYTE* Digest)
8 - unsigned int result_size;
13 - rv = EVP_DigestInit(&md_ctx, EVP_sha1());
16 - rv = TSPERR(TSS_E_BAD_PARAMETER);
23 - if (rv != EVP_SUCCESS) {
24 - rv = TSPERR(TSS_E_INTERNAL_ERROR);
27 + rv = Trspi_HashInit(&ctx, HashType);
28 + if (rv != TSS_SUCCESS)
31 - rv = EVP_DigestUpdate(&md_ctx, Buf, BufSize);
32 - if (rv != EVP_SUCCESS) {
33 - rv = TSPERR(TSS_E_INTERNAL_ERROR);
35 + rv = Trspi_HashUpdate(&ctx, BufSize, Buf);
36 + if (rv != TSS_SUCCESS) {
37 + EVP_MD_CTX_destroy(ctx.ctx);
40 + rv = Trspi_HashFinal(&ctx, Digest);
42 - result_size = EVP_MD_CTX_size(&md_ctx);
43 - rv = EVP_DigestFinal(&md_ctx, Digest, &result_size);
44 - if (rv != EVP_SUCCESS) {
45 - rv = TSPERR(TSS_E_INTERNAL_ERROR);
53 - DEBUG_print_openssl_errors();
64 - if ((ctx->ctx = malloc(sizeof(EVP_MD_CTX))) == NULL)
65 + ctx->ctx = EVP_MD_CTX_create();
66 + if (ctx->ctx == NULL)
67 return TSPERR(TSS_E_OUTOFMEMORY);
69 rv = EVP_DigestInit((EVP_MD_CTX *)ctx->ctx, (const EVP_MD *)md);
71 rv = EVP_DigestUpdate(ctx->ctx, data, size);
72 if (rv != EVP_SUCCESS) {
73 DEBUG_print_openssl_errors();
75 + EVP_MD_CTX_destroy(ctx->ctx);
77 return TSPERR(TSS_E_INTERNAL_ERROR);
80 if (rv != EVP_SUCCESS)
81 return TSPERR(TSS_E_INTERNAL_ERROR);
84 + EVP_MD_CTX_destroy(ctx->ctx);