Obsolete golang-120
[oi-userland.git] / components / library / trousers / patches / trspi_crypto_openssl_hash.c.patch
blob65b4c2f94716b74f40bae129af34efb36a7fb684
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
3 @@ -56,45 +56,21 @@
4 TSS_RESULT
5 Trspi_Hash(UINT32 HashType, UINT32 BufSize, BYTE* Buf, BYTE* Digest)
7 - EVP_MD_CTX md_ctx;
8 - unsigned int result_size;
9 - int rv;
11 - switch (HashType) {
12 - case TSS_HASH_SHA1:
13 - rv = EVP_DigestInit(&md_ctx, EVP_sha1());
14 - break;
15 - default:
16 - rv = TSPERR(TSS_E_BAD_PARAMETER);
17 - goto out;
18 - break;
19 - }
20 + Trspi_HashCtx ctx;
21 + TSS_RESULT rv;
23 - if (rv != EVP_SUCCESS) {
24 - rv = TSPERR(TSS_E_INTERNAL_ERROR);
25 - goto err;
26 - }
27 + rv = Trspi_HashInit(&ctx, HashType);
28 + if (rv != TSS_SUCCESS)
29 + return rv;
31 - rv = EVP_DigestUpdate(&md_ctx, Buf, BufSize);
32 - if (rv != EVP_SUCCESS) {
33 - rv = TSPERR(TSS_E_INTERNAL_ERROR);
34 - goto err;
35 + rv = Trspi_HashUpdate(&ctx, BufSize, Buf);
36 + if (rv != TSS_SUCCESS) {
37 + EVP_MD_CTX_destroy(ctx.ctx);
38 + return rv;
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);
46 - goto err;
47 - } else
48 - rv = TSS_SUCCESS;
50 - goto out;
52 -err:
53 - DEBUG_print_openssl_errors();
54 -out:
55 - return rv;
56 + return (rv);
59 TSS_RESULT
60 @@ -112,7 +88,8 @@
61 break;
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);
70 @@ -142,7 +119,7 @@
71 rv = EVP_DigestUpdate(ctx->ctx, data, size);
72 if (rv != EVP_SUCCESS) {
73 DEBUG_print_openssl_errors();
74 - free(ctx->ctx);
75 + EVP_MD_CTX_destroy(ctx->ctx);
76 ctx->ctx = NULL;
77 return TSPERR(TSS_E_INTERNAL_ERROR);
79 @@ -164,7 +141,7 @@
80 if (rv != EVP_SUCCESS)
81 return TSPERR(TSS_E_INTERNAL_ERROR);
83 - free(ctx->ctx);
84 + EVP_MD_CTX_destroy(ctx->ctx);
85 ctx->ctx = NULL;
87 return TSS_SUCCESS;