Implemented immutable ownership helpers for core ASL values and routed internal clone/free paths through them so stored artifacts/references are deep-copied and no longer depend on caller-owned buffers.
This commit is contained in:
parent
e391e55150
commit
dd429ed6f1
|
|
@ -35,16 +35,23 @@ typedef struct {
|
||||||
amduat_octets_t amduat_octets(const void *data, size_t len);
|
amduat_octets_t amduat_octets(const void *data, size_t len);
|
||||||
bool amduat_octets_eq(amduat_octets_t a, amduat_octets_t b);
|
bool amduat_octets_eq(amduat_octets_t a, amduat_octets_t b);
|
||||||
bool amduat_octets_is_empty(amduat_octets_t v);
|
bool amduat_octets_is_empty(amduat_octets_t v);
|
||||||
|
/* Clone helpers allocate fresh buffers; free with the matching *_free call. */
|
||||||
|
bool amduat_octets_clone(amduat_octets_t src, amduat_octets_t *out);
|
||||||
|
void amduat_octets_free(amduat_octets_t *v);
|
||||||
|
|
||||||
amduat_type_tag_t amduat_type_tag(uint32_t tag_id);
|
amduat_type_tag_t amduat_type_tag(uint32_t tag_id);
|
||||||
bool amduat_type_tag_eq(amduat_type_tag_t a, amduat_type_tag_t b);
|
bool amduat_type_tag_eq(amduat_type_tag_t a, amduat_type_tag_t b);
|
||||||
|
|
||||||
amduat_reference_t amduat_reference(amduat_hash_id_t hash_id, amduat_octets_t digest);
|
amduat_reference_t amduat_reference(amduat_hash_id_t hash_id, amduat_octets_t digest);
|
||||||
bool amduat_reference_eq(amduat_reference_t a, amduat_reference_t b);
|
bool amduat_reference_eq(amduat_reference_t a, amduat_reference_t b);
|
||||||
|
bool amduat_reference_clone(amduat_reference_t src, amduat_reference_t *out);
|
||||||
|
void amduat_reference_free(amduat_reference_t *ref);
|
||||||
|
|
||||||
amduat_artifact_t amduat_artifact(amduat_octets_t bytes);
|
amduat_artifact_t amduat_artifact(amduat_octets_t bytes);
|
||||||
amduat_artifact_t amduat_artifact_with_type(amduat_octets_t bytes, amduat_type_tag_t type_tag);
|
amduat_artifact_t amduat_artifact_with_type(amduat_octets_t bytes, amduat_type_tag_t type_tag);
|
||||||
bool amduat_artifact_eq(amduat_artifact_t a, amduat_artifact_t b);
|
bool amduat_artifact_eq(amduat_artifact_t a, amduat_artifact_t b);
|
||||||
|
bool amduat_artifact_clone(amduat_artifact_t src, amduat_artifact_t *out);
|
||||||
|
void amduat_artifact_free(amduat_artifact_t *artifact);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
|
||||||
|
|
@ -35,34 +35,11 @@ static bool amduat_tgk_store_fs_artifact_eq(amduat_artifact_t a,
|
||||||
|
|
||||||
static bool amduat_tgk_store_fs_reference_clone(amduat_reference_t src,
|
static bool amduat_tgk_store_fs_reference_clone(amduat_reference_t src,
|
||||||
amduat_reference_t *dst) {
|
amduat_reference_t *dst) {
|
||||||
uint8_t *digest_copy;
|
return amduat_reference_clone(src, dst);
|
||||||
|
|
||||||
if (dst == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*dst = amduat_reference(src.hash_id, amduat_octets(NULL, 0));
|
|
||||||
if (src.digest.len == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (src.digest.data == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
digest_copy = (uint8_t *)malloc(src.digest.len);
|
|
||||||
if (digest_copy == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(digest_copy, src.digest.data, src.digest.len);
|
|
||||||
dst->digest = amduat_octets(digest_copy, src.digest.len);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_tgk_store_fs_reference_free(amduat_reference_t *ref) {
|
static void amduat_tgk_store_fs_reference_free(amduat_reference_t *ref) {
|
||||||
if (ref == NULL) {
|
amduat_reference_free(ref);
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_tgk_store_fs_artifact_bytes_free(
|
static void amduat_tgk_store_fs_artifact_bytes_free(
|
||||||
|
|
@ -70,11 +47,7 @@ static void amduat_tgk_store_fs_artifact_bytes_free(
|
||||||
if (artifact == NULL) {
|
if (artifact == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free((void *)artifact->artifact.bytes.data);
|
amduat_artifact_free(&artifact->artifact);
|
||||||
artifact->artifact.bytes.data = NULL;
|
|
||||||
artifact->artifact.bytes.len = 0;
|
|
||||||
artifact->artifact.has_type_tag = false;
|
|
||||||
artifact->artifact.type_tag.tag_id = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_tgk_store_fs_artifact_full_free(
|
static void amduat_tgk_store_fs_artifact_full_free(
|
||||||
|
|
|
||||||
|
|
@ -226,64 +226,28 @@ static int amduat_tgk_store_mem_edge_cmp(const void *a, const void *b) {
|
||||||
|
|
||||||
static bool amduat_tgk_store_mem_reference_clone(amduat_reference_t src,
|
static bool amduat_tgk_store_mem_reference_clone(amduat_reference_t src,
|
||||||
amduat_reference_t *dst) {
|
amduat_reference_t *dst) {
|
||||||
uint8_t *digest_copy;
|
return amduat_reference_clone(src, dst);
|
||||||
|
|
||||||
if (dst == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*dst = amduat_reference(src.hash_id, amduat_octets(NULL, 0));
|
|
||||||
if (src.digest.len == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (src.digest.data == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
digest_copy = (uint8_t *)malloc(src.digest.len);
|
|
||||||
if (digest_copy == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(digest_copy, src.digest.data, src.digest.len);
|
|
||||||
dst->digest = amduat_octets(digest_copy, src.digest.len);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_tgk_store_mem_reference_free(amduat_reference_t *ref) {
|
static void amduat_tgk_store_mem_reference_free(amduat_reference_t *ref) {
|
||||||
if (ref == NULL) {
|
amduat_reference_free(ref);
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool amduat_tgk_store_mem_artifact_clone(
|
static bool amduat_tgk_store_mem_artifact_clone(
|
||||||
amduat_reference_t ref,
|
amduat_reference_t ref,
|
||||||
amduat_artifact_t artifact,
|
amduat_artifact_t artifact,
|
||||||
amduat_tgk_store_mem_artifact_t *out) {
|
amduat_tgk_store_mem_artifact_t *out) {
|
||||||
uint8_t *bytes_copy = NULL;
|
|
||||||
|
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memset(out, 0, sizeof(*out));
|
memset(out, 0, sizeof(*out));
|
||||||
if (!amduat_tgk_store_mem_reference_clone(ref, &out->ref)) {
|
if (!amduat_reference_clone(ref, &out->ref)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (artifact.bytes.len != 0) {
|
if (!amduat_artifact_clone(artifact, &out->artifact)) {
|
||||||
if (artifact.bytes.data == NULL) {
|
amduat_reference_free(&out->ref);
|
||||||
amduat_tgk_store_mem_reference_free(&out->ref);
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bytes_copy = (uint8_t *)malloc(artifact.bytes.len);
|
|
||||||
if (bytes_copy == NULL) {
|
|
||||||
amduat_tgk_store_mem_reference_free(&out->ref);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(bytes_copy, artifact.bytes.data, artifact.bytes.len);
|
|
||||||
}
|
}
|
||||||
out->artifact.bytes = amduat_octets(bytes_copy, artifact.bytes.len);
|
|
||||||
out->artifact.has_type_tag = artifact.has_type_tag;
|
|
||||||
out->artifact.type_tag = artifact.type_tag;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -292,12 +256,8 @@ static void amduat_tgk_store_mem_artifact_free(
|
||||||
if (artifact == NULL) {
|
if (artifact == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free((void *)artifact->artifact.bytes.data);
|
amduat_artifact_free(&artifact->artifact);
|
||||||
artifact->artifact.bytes.data = NULL;
|
amduat_reference_free(&artifact->ref);
|
||||||
artifact->artifact.bytes.len = 0;
|
|
||||||
artifact->artifact.has_type_tag = false;
|
|
||||||
artifact->artifact.type_tag.tag_id = 0;
|
|
||||||
amduat_tgk_store_mem_reference_free(&artifact->ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool amduat_tgk_store_mem_artifact_value_eq(
|
static bool amduat_tgk_store_mem_artifact_value_eq(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "amduat/asl/core.h"
|
#include "amduat/asl/core.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
amduat_octets_t amduat_octets(const void *data, size_t len) {
|
amduat_octets_t amduat_octets(const void *data, size_t len) {
|
||||||
|
|
@ -23,6 +24,37 @@ bool amduat_octets_is_empty(amduat_octets_t v) {
|
||||||
return v.len == 0;
|
return v.len == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool amduat_octets_clone(amduat_octets_t src, amduat_octets_t *out) {
|
||||||
|
uint8_t *copy;
|
||||||
|
|
||||||
|
if (out == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*out = amduat_octets(NULL, 0u);
|
||||||
|
if (src.len == 0u) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (src.data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
copy = (uint8_t *)malloc(src.len);
|
||||||
|
if (copy == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(copy, src.data, src.len);
|
||||||
|
*out = amduat_octets(copy, src.len);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void amduat_octets_free(amduat_octets_t *v) {
|
||||||
|
if (v == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
free((void *)v->data);
|
||||||
|
v->data = NULL;
|
||||||
|
v->len = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
amduat_type_tag_t amduat_type_tag(uint32_t tag_id) {
|
amduat_type_tag_t amduat_type_tag(uint32_t tag_id) {
|
||||||
amduat_type_tag_t t;
|
amduat_type_tag_t t;
|
||||||
t.tag_id = tag_id;
|
t.tag_id = tag_id;
|
||||||
|
|
@ -45,6 +77,25 @@ bool amduat_reference_eq(amduat_reference_t a, amduat_reference_t b) {
|
||||||
return (a.hash_id == b.hash_id) && amduat_octets_eq(a.digest, b.digest);
|
return (a.hash_id == b.hash_id) && amduat_octets_eq(a.digest, b.digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool amduat_reference_clone(amduat_reference_t src, amduat_reference_t *out) {
|
||||||
|
if (out == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*out = amduat_reference(src.hash_id, amduat_octets(NULL, 0u));
|
||||||
|
if (!amduat_octets_clone(src.digest, &out->digest)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void amduat_reference_free(amduat_reference_t *ref) {
|
||||||
|
if (ref == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
amduat_octets_free(&ref->digest);
|
||||||
|
ref->hash_id = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
amduat_artifact_t amduat_artifact(amduat_octets_t bytes) {
|
amduat_artifact_t amduat_artifact(amduat_octets_t bytes) {
|
||||||
amduat_artifact_t a;
|
amduat_artifact_t a;
|
||||||
a.bytes = bytes;
|
a.bytes = bytes;
|
||||||
|
|
@ -74,3 +125,25 @@ bool amduat_artifact_eq(amduat_artifact_t a, amduat_artifact_t b) {
|
||||||
}
|
}
|
||||||
return amduat_type_tag_eq(a.type_tag, b.type_tag);
|
return amduat_type_tag_eq(a.type_tag, b.type_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool amduat_artifact_clone(amduat_artifact_t src, amduat_artifact_t *out) {
|
||||||
|
if (out == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*out = amduat_artifact(amduat_octets(NULL, 0u));
|
||||||
|
if (!amduat_octets_clone(src.bytes, &out->bytes)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
out->has_type_tag = src.has_type_tag;
|
||||||
|
out->type_tag = src.type_tag;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void amduat_artifact_free(amduat_artifact_t *artifact) {
|
||||||
|
if (artifact == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
amduat_octets_free(&artifact->bytes);
|
||||||
|
artifact->has_type_tag = false;
|
||||||
|
artifact->type_tag = amduat_type_tag(0u);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void amduat_reference_free(amduat_reference_t *ref) {
|
|
||||||
if (ref == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool amduat_tgk_edge_body_has_endpoints(const amduat_tgk_edge_body_t *edge) {
|
bool amduat_tgk_edge_body_has_endpoints(const amduat_tgk_edge_body_t *edge) {
|
||||||
if (edge == NULL) {
|
if (edge == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,5 @@ bool amduat_asl_artifact_expect_type_tag(const amduat_artifact_t *artifact,
|
||||||
}
|
}
|
||||||
|
|
||||||
void amduat_asl_artifact_free(amduat_artifact_t *artifact) {
|
void amduat_asl_artifact_free(amduat_artifact_t *artifact) {
|
||||||
if (artifact == NULL) {
|
amduat_artifact_free(artifact);
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)artifact->bytes.data);
|
|
||||||
artifact->bytes.data = NULL;
|
|
||||||
artifact->bytes.len = 0u;
|
|
||||||
artifact->has_type_tag = false;
|
|
||||||
artifact->type_tag = amduat_type_tag(0u);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void amduat_asl_ref_free(amduat_reference_t *ref) {
|
static void amduat_asl_ref_free(amduat_reference_t *ref) {
|
||||||
if (ref == NULL) {
|
amduat_reference_free(ref);
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0u;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool amduat_asl_ref_decode_hex_bytes(const uint8_t *data,
|
static bool amduat_asl_ref_decode_hex_bytes(const uint8_t *data,
|
||||||
|
|
|
||||||
|
|
@ -148,15 +148,6 @@ static bool amduat_read_encoded_ref(amduat_cursor_t *cur,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_reference_free(amduat_reference_t *ref) {
|
|
||||||
if (ref == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void amduat_diagnostic_list_free(amduat_pel_diagnostic_entry_t *entries,
|
static void amduat_diagnostic_list_free(amduat_pel_diagnostic_entry_t *entries,
|
||||||
size_t count) {
|
size_t count) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
|
||||||
|
|
@ -214,15 +214,6 @@ static bool amduat_read_encoded_ref(amduat_cursor_t *cur,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_reference_free(amduat_reference_t *ref) {
|
|
||||||
if (ref == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void amduat_diagnostic_list_free(amduat_pel_diagnostic_entry_t *entries,
|
static void amduat_diagnostic_list_free(amduat_pel_diagnostic_entry_t *entries,
|
||||||
size_t count) {
|
size_t count) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
|
||||||
|
|
@ -139,15 +139,6 @@ static bool amduat_read_encoded_ref(amduat_cursor_t *cur,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_reference_free(amduat_reference_t *ref) {
|
|
||||||
if (ref == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void amduat_enc_tgk1_edge_free(amduat_tgk_edge_body_t *edge) {
|
void amduat_enc_tgk1_edge_free(amduat_tgk_edge_body_t *edge) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,15 +167,6 @@ static bool amduat_read_encoded_ref(amduat_cursor_t *cur,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_reference_free(amduat_reference_t *ref) {
|
|
||||||
if (ref == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool amduat_join_path(const char *base,
|
static bool amduat_join_path(const char *base,
|
||||||
const char *segment,
|
const char *segment,
|
||||||
char **out_path) {
|
char **out_path) {
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void amduat_reference_free(amduat_reference_t *ref) {
|
|
||||||
if (ref == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void amduat_pel_surf_free_refs(amduat_reference_t *refs, size_t refs_len) {
|
void amduat_pel_surf_free_refs(amduat_reference_t *refs, size_t refs_len) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
|
@ -37,15 +28,6 @@ void amduat_pel_surf_free_ref(amduat_reference_t *ref) {
|
||||||
amduat_reference_free(ref);
|
amduat_reference_free(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void amduat_artifact_free(amduat_artifact_t *artifact) {
|
|
||||||
if (artifact == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)artifact->bytes.data);
|
|
||||||
artifact->bytes.data = NULL;
|
|
||||||
artifact->bytes.len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void amduat_init_core_result(amduat_pel_execution_result_value_t *result,
|
static void amduat_init_core_result(amduat_pel_execution_result_value_t *result,
|
||||||
amduat_reference_t scheme_ref,
|
amduat_reference_t scheme_ref,
|
||||||
amduat_pel_execution_status_t status,
|
amduat_pel_execution_status_t status,
|
||||||
|
|
|
||||||
|
|
@ -17,35 +17,12 @@ typedef struct {
|
||||||
} amduat_tgk_prov_index_queue_t;
|
} amduat_tgk_prov_index_queue_t;
|
||||||
|
|
||||||
static void amduat_tgk_prov_reference_free(amduat_reference_t *ref) {
|
static void amduat_tgk_prov_reference_free(amduat_reference_t *ref) {
|
||||||
if (ref == NULL) {
|
amduat_reference_free(ref);
|
||||||
return;
|
|
||||||
}
|
|
||||||
free((void *)ref->digest.data);
|
|
||||||
ref->digest.data = NULL;
|
|
||||||
ref->digest.len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool amduat_tgk_prov_reference_clone(amduat_reference_t src,
|
static bool amduat_tgk_prov_reference_clone(amduat_reference_t src,
|
||||||
amduat_reference_t *dst) {
|
amduat_reference_t *dst) {
|
||||||
uint8_t *digest_copy;
|
return amduat_reference_clone(src, dst);
|
||||||
|
|
||||||
if (dst == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*dst = amduat_reference(src.hash_id, amduat_octets(NULL, 0));
|
|
||||||
if (src.digest.len == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (src.digest.data == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
digest_copy = (uint8_t *)malloc(src.digest.len);
|
|
||||||
if (digest_copy == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(digest_copy, src.digest.data, src.digest.len);
|
|
||||||
dst->digest = amduat_octets(digest_copy, src.digest.len);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int amduat_tgk_prov_octets_cmp(amduat_octets_t a, amduat_octets_t b) {
|
static int amduat_tgk_prov_octets_cmp(amduat_octets_t a, amduat_octets_t b) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue