]>
Commit | Line | Data |
---|---|---|
0ad170df JB |
1 | --- open62541-1.3.2/tools/tpm_keystore/cert_encrypt_tpm.c.orig 2022-06-24 11:05:00.000000000 +0200 |
2 | +++ open62541-1.3.2/tools/tpm_keystore/cert_encrypt_tpm.c 2022-07-02 17:39:33.382785211 +0200 | |
3 | @@ -21,7 +21,7 @@ typedef enum { B_FALSE, B_TRUE } boolean | |
4 | ||
5 | typedef struct binary_data binary_data; | |
6 | struct binary_data { | |
7 | - long length; | |
8 | + size_t length; | |
9 | void *data; | |
10 | }; | |
11 | ||
12 | @@ -101,9 +101,9 @@ static CK_RV encrypt(int slotNum, unsign | |
13 | unsigned int expected_md_len = 32; | |
14 | binary_data *out_data = *encrypted_data; | |
15 | uint32_t i; | |
16 | - CK_RV rv; | |
17 | + CK_RV rv = 0; | |
18 | ||
19 | - CK_BYTE *data_encrypted; | |
20 | + CK_BYTE *data_encrypted = NULL; | |
21 | CK_ULONG clear_data_length; | |
22 | CK_ULONG encrypted_data_length = 0; | |
23 | CK_ULONG enclen = 16; | |
24 | @@ -212,7 +212,7 @@ static CK_RV encrypt(int slotNum, unsign | |
25 | /* Add 16 bytes because encrypt final does not accept the data bytes */ | |
26 | clear_data_length +=16; | |
27 | ||
28 | - CK_BYTE_PTR ptr_clear_data; | |
29 | + CK_BYTE_PTR ptr_clear_data = NULL; | |
30 | ptr_clear_data = (CK_BYTE *)(malloc(clear_data_length * sizeof(CK_BYTE))); | |
31 | memset(ptr_clear_data, 0, clear_data_length); | |
32 | /* Copy the data into the bytes that will be encrypted */ | |
33 | @@ -253,7 +253,7 @@ static CK_RV encrypt(int slotNum, unsign | |
34 | /* Add 56 more bytes. 16 bytes will hold the iv | |
35 | The next 8 bytes will be an unsigned long (uint64_t) that indicates the original data length | |
36 | The last 32 bytes are for the HMAC */ | |
37 | - long out_data_length = (long)(encrypted_data_length + (long unsigned int)iv_data->length + sizeof(uint64_t) + expected_md_len); | |
38 | + size_t out_data_length = (size_t)(encrypted_data_length + (long unsigned int)iv_data->length + sizeof(uint64_t) + expected_md_len); | |
39 | if (out_data->data) { | |
40 | free(out_data->data); | |
41 | out_data->length = 0; | |
42 | @@ -325,7 +325,7 @@ static binary_data* read_input_file(cons | |
43 | /* Read the whole file to buffer */ | |
44 | const long length = (const long)fread(buff, 1, (size_t)end_position, f_in); | |
45 | if (length == end_position) { | |
46 | - data->length = end_position; | |
47 | + data->length = (size_t)end_position; | |
48 | data->data = buff; | |
49 | ||
50 | fclose(f_in); | |
51 | --- open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes128ctr_tpm.c.orig 2022-07-02 17:51:35.142208438 +0200 | |
52 | +++ open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes128ctr_tpm.c 2022-07-02 17:51:38.458857136 +0200 | |
53 | @@ -351,8 +351,10 @@ sign_sp_pubsub_aes128ctr_tpm(PUBSUB_AES1 | |
54 | } | |
55 | ||
56 | /* Signs data in a single part, where the signature is an appendix to the data */ | |
57 | + unsigned long siglen = signature->length; | |
58 | rv = (UA_StatusCode)C_Sign(cc->policyContext->sessionHandle, data->data, data->length, | |
59 | - (CK_BYTE_PTR)signature->data, &signature->length); | |
60 | + (CK_BYTE_PTR)signature->data, &siglen); | |
61 | + signature->length = siglen; | |
62 | if (rv != UA_STATUSCODE_GOOD) { | |
63 | UA_LOG_ERROR(cc->policyContext->securityPolicy->logger, UA_LOGCATEGORY_SECURITYPOLICY, | |
64 | "Signing failed 0x%.8lX", (long unsigned int)rv); | |
65 | --- open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes256ctr_tpm.c.orig 2022-06-24 11:05:00.000000000 +0200 | |
66 | +++ open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes256ctr_tpm.c 2022-07-02 17:52:12.062008426 +0200 | |
67 | @@ -357,8 +357,10 @@ sign_sp_pubsub_aes256ctr_tpm(PUBSUB_AES2 | |
68 | } | |
69 | ||
70 | /* Signs data in a single part, where the signature is an appendix to the data */ | |
71 | + unsigned long siglen = signature->length; | |
72 | rv = (UA_StatusCode)C_Sign(cc->policyContext->sessionHandle, data->data, data->length, | |
73 | - (CK_BYTE_PTR)signature->data, &signature->length); | |
74 | + (CK_BYTE_PTR)signature->data, &siglen); | |
75 | + signature->length = siglen; | |
76 | if (rv != UA_STATUSCODE_GOOD) { | |
77 | UA_LOG_ERROR(cc->policyContext->securityPolicy->logger, UA_LOGCATEGORY_SECURITYPOLICY, | |
78 | "Signing failed 0x%.8lX", (long unsigned int)rv); |