Enforced StoreConfig at the wrapper boundary by validating the configured encoding/hash and rejecting mismatched hash IDs before delegating to backend ops. This makes the amduat_asl_store_t wrapper actively use/validate its config instead of just storing it.

This commit is contained in:
Carl Niklas Rydberg 2025-12-21 23:09:44 +01:00
parent 3dda32b62c
commit 5443ad041c

View file

@ -1,4 +1,24 @@
#include "amduat/asl/store.h"
#include "amduat/enc/asl1_core.h"
#include "amduat/hash/asl1.h"
static bool amduat_asl_store_config_supported(
const amduat_asl_store_config_t *config) {
const amduat_hash_asl1_desc_t *hash_desc;
if (config == NULL) {
return false;
}
if (amduat_enc_asl1_core_desc_lookup(config->encoding_profile_id) == NULL) {
return false;
}
hash_desc = amduat_hash_asl1_desc_lookup(config->hash_id);
if (hash_desc == NULL || hash_desc->digest_len == 0 ||
hash_desc->impl.digest == NULL) {
return false;
}
return true;
}
void amduat_asl_store_init(amduat_asl_store_t *store,
amduat_asl_store_config_t config,
@ -18,6 +38,9 @@ amduat_asl_store_error_t amduat_asl_store_put(amduat_asl_store_t *store,
if (store == NULL || store->ops.put == NULL) {
return AMDUAT_ASL_STORE_ERR_UNSUPPORTED;
}
if (!amduat_asl_store_config_supported(&store->config)) {
return AMDUAT_ASL_STORE_ERR_UNSUPPORTED;
}
return store->ops.put(store->ctx, artifact, out_ref);
}
@ -27,5 +50,11 @@ amduat_asl_store_error_t amduat_asl_store_get(amduat_asl_store_t *store,
if (store == NULL || store->ops.get == NULL) {
return AMDUAT_ASL_STORE_ERR_UNSUPPORTED;
}
if (!amduat_asl_store_config_supported(&store->config)) {
return AMDUAT_ASL_STORE_ERR_UNSUPPORTED;
}
if (ref.hash_id != store->config.hash_id) {
return AMDUAT_ASL_STORE_ERR_UNSUPPORTED;
}
return store->ops.get(store->ctx, ref, out_artifact);
}