Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmxsrup committed Nov 18, 2024
1 parent a11af72 commit 16bf6ce
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
5 changes: 2 additions & 3 deletions core/pta/veraison_attestation/cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2024, Institute of Information Security (IISEC)
*/

#include <compiler.h>
#include <kernel/pseudo_ta.h>
#include <mempool.h>

Expand Down Expand Up @@ -130,10 +131,8 @@ static void encode_protected_header(QCBOREncodeContext *context)
}

static void encode_protected_header_wrapper(QCBOREncodeContext *context,
void *args)
void *__unused args)
{
(void)args; /* unused */

encode_protected_header(context);
}

Expand Down
1 change: 1 addition & 0 deletions core/pta/veraison_attestation/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stddef.h>
#include <stdint.h>
#include <tee_api.h>

TEE_Result get_hash_ta_memory(uint8_t out[TEE_SHA256_HASH_SIZE]);

Expand Down
15 changes: 8 additions & 7 deletions core/pta/veraison_attestation/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ static TEE_Result hash_sha256(const uint8_t *msg, size_t msg_len, uint8_t *hash)

static void free_keypair(void)
{
assert(key && key->d && key->x && key->y);
if(!key)
return;

crypto_bignum_free(&key->d);
crypto_bignum_free(&key->x);
Expand All @@ -95,7 +96,8 @@ static void free_keypair(void)

static void free_pubkey(void)
{
assert(pubkey && pubkey->x && pubkey->y);
if(!key)
return;

crypto_bignum_free(&pubkey->x);
crypto_bignum_free(&pubkey->y);
Expand All @@ -115,8 +117,7 @@ static TEE_Result generate_key(void)
assert(!key);
key = calloc(1, sizeof(*key));
if (!key) {
res = TEE_ERROR_OUT_OF_MEMORY;
goto err;
return TEE_ERROR_OUT_OF_MEMORY;
}
res = crypto_acipher_alloc_ecc_keypair(key, TEE_TYPE_ECDSA_KEYPAIR,
KEY_SIZE_BIT);
Expand Down Expand Up @@ -158,7 +159,7 @@ static TEE_Result generate_key(void)
free_pubkey();
free_keypair:
free_keypair();
err:

return res;
}

Expand All @@ -171,7 +172,7 @@ TEE_Result sign_ecdsa_sha256(const uint8_t *msg, size_t msg_len, uint8_t *sig,
/* Allocate the key pair*/
res = generate_key();
if (res != TEE_SUCCESS)
goto out;
return res;

/* Hash the msg */
res = hash_sha256(msg, msg_len, hash_msg);
Expand All @@ -197,6 +198,6 @@ TEE_Result sign_ecdsa_sha256(const uint8_t *msg, size_t msg_len, uint8_t *sig,
assert(!pubkey);
free_keypair();
assert(!key);
out:

return res;
}
2 changes: 0 additions & 2 deletions core/pta/veraison_attestation/sub.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ srcs-$(CFG_VERAISON_ATTESTATION_PTA) += sign.c

cflags-$(CFG_VERAISON_ATTESTATION_PTA) += -Wno-declaration-after-statement
cflags-$(CFG_VERAISON_ATTESTATION_PTA) += -Wno-redundant-decls

cppflags-$(CFG_VERAISON_ATTESTATION_PTA_TEST_KEY) += -DCFG_VERAISON_ATTESTATION_PTA_TEST_KEY
5 changes: 2 additions & 3 deletions core/pta/veraison_attestation/veraison_attestation.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,12 @@ static TEE_Result cmd_get_cbor_evidence(uint32_t param_types,
return status;

/* Encode measurement_value to base64 */
if (base64_enc(measurement_value, TEE_SHA256_HASH_SIZE,
if (!base64_enc(measurement_value, TEE_SHA256_HASH_SIZE,
b64_measurement_value,
&b64_measurement_value_len) != 1) {
&b64_measurement_value_len)) {
DMSG("Failed to encode measurement_value to base64");
return TEE_ERROR_GENERIC;
}
b64_measurement_value[b64_measurement_value_len] = '\0';
DMSG("b64_measurement_value: %s", b64_measurement_value);

/* Encode evidence to CBOR */
Expand Down
2 changes: 1 addition & 1 deletion lib/libutee/include/pta_veraison_attestation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* [out] memref[1] Output buffer
* [in] memref[2] Implementation ID
*
* Return codes:
* Main return codes:
* TEE_SUCCESS
* TEE_ERROR_ACCESS_DENIED - Caller is not a user space TA
* TEE_ERROR_BAD_PARAMETERS - Incorrect input param
Expand Down

0 comments on commit 16bf6ce

Please sign in to comment.