Added a concrete recognition path for TYPE_TAG_PEL_SCHEME_DESC_1 Artifacts by exposing canonical checks and wiring them into amduat-pel validate.
This commit is contained in:
parent
f5e1ab8801
commit
db3eb98b83
|
|
@ -2,6 +2,7 @@
|
||||||
#define AMDUAT_PEL_PROGRAM_DAG_DESC_H
|
#define AMDUAT_PEL_PROGRAM_DAG_DESC_H
|
||||||
|
|
||||||
#include "amduat/asl/core.h"
|
#include "amduat/asl/core.h"
|
||||||
|
#include "amduat/enc/pel_program_dag_desc.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
@ -16,6 +17,12 @@ enum {
|
||||||
|
|
||||||
amduat_reference_t amduat_pel_program_dag_scheme_ref(void);
|
amduat_reference_t amduat_pel_program_dag_scheme_ref(void);
|
||||||
|
|
||||||
|
bool amduat_pel_program_dag_desc_is_canonical(
|
||||||
|
const amduat_pel_dag_scheme_descriptor_t *desc);
|
||||||
|
|
||||||
|
bool amduat_pel_program_dag_desc_is_canonical_artifact(
|
||||||
|
const amduat_artifact_t *artifact);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,31 @@
|
||||||
|
|
||||||
#include "amduat/asl/ref_derive.h"
|
#include "amduat/asl/ref_derive.h"
|
||||||
#include "amduat/enc/asl1_core.h"
|
#include "amduat/enc/asl1_core.h"
|
||||||
|
#include "amduat/enc/pel_program_dag.h"
|
||||||
#include "amduat/hash/asl1.h"
|
#include "amduat/hash/asl1.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
amduat_reference_t amduat_pel_program_dag_scheme_ref(void) {
|
static const char k_scheme_name[] = "PEL/PROGRAM-DAG/1";
|
||||||
static const uint8_t descriptor_bytes[] = {
|
static const uint8_t k_descriptor_bytes[] = {
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x50, 0x45,
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x50, 0x45,
|
||||||
0x4c, 0x2f, 0x50, 0x52, 0x4f, 0x47, 0x52, 0x41,
|
0x4c, 0x2f, 0x50, 0x52, 0x4f, 0x47, 0x52, 0x41,
|
||||||
0x4d, 0x2d, 0x44, 0x41, 0x47, 0x2f, 0x31, 0x00,
|
0x4d, 0x2d, 0x44, 0x41, 0x47, 0x2f, 0x31, 0x00,
|
||||||
0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00
|
0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00
|
||||||
};
|
};
|
||||||
static uint8_t digest[] = {
|
static uint8_t k_digest[] = {
|
||||||
0xc5, 0x0f, 0xb2, 0xa7, 0x34, 0xa5, 0xcc, 0x23,
|
0xc5, 0x0f, 0xb2, 0xa7, 0x34, 0xa5, 0xcc, 0x23,
|
||||||
0x3c, 0x38, 0x75, 0xb7, 0x0a, 0x7d, 0x96, 0xea,
|
0x3c, 0x38, 0x75, 0xb7, 0x0a, 0x7d, 0x96, 0xea,
|
||||||
0xad, 0x37, 0x4f, 0x00, 0x00, 0x29, 0x77, 0x1d,
|
0xad, 0x37, 0x4f, 0x00, 0x00, 0x29, 0x77, 0x1d,
|
||||||
0x8b, 0xef, 0x1a, 0xf2, 0xcd, 0x63, 0x84, 0xdd
|
0x8b, 0xef, 0x1a, 0xf2, 0xcd, 0x63, 0x84, 0xdd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
amduat_reference_t amduat_pel_program_dag_scheme_ref(void) {
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
amduat_artifact_t artifact = amduat_artifact_with_type(
|
amduat_artifact_t artifact = amduat_artifact_with_type(
|
||||||
amduat_octets(descriptor_bytes, sizeof(descriptor_bytes)),
|
amduat_octets(k_descriptor_bytes, sizeof(k_descriptor_bytes)),
|
||||||
amduat_type_tag(AMDUAT_PEL_TYPE_TAG_SCHEME_DESC_1));
|
amduat_type_tag(AMDUAT_PEL_TYPE_TAG_SCHEME_DESC_1));
|
||||||
amduat_reference_t derived = amduat_reference(0u, amduat_octets(NULL, 0u));
|
amduat_reference_t derived = amduat_reference(0u, amduat_octets(NULL, 0u));
|
||||||
|
|
||||||
|
|
@ -33,13 +36,62 @@ amduat_reference_t amduat_pel_program_dag_scheme_ref(void) {
|
||||||
&derived,
|
&derived,
|
||||||
NULL) &&
|
NULL) &&
|
||||||
derived.digest.data != NULL &&
|
derived.digest.data != NULL &&
|
||||||
derived.digest.len == sizeof(digest)) {
|
derived.digest.len == sizeof(k_digest)) {
|
||||||
memcpy(digest, derived.digest.data, sizeof(digest));
|
memcpy(k_digest, derived.digest.data, sizeof(k_digest));
|
||||||
}
|
}
|
||||||
amduat_reference_free(&derived);
|
amduat_reference_free(&derived);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return amduat_reference(AMDUAT_HASH_ASL1_ID_SHA256,
|
return amduat_reference(AMDUAT_HASH_ASL1_ID_SHA256,
|
||||||
amduat_octets(digest, sizeof(digest)));
|
amduat_octets(k_digest, sizeof(k_digest)));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool amduat_pel_program_dag_desc_is_canonical(
|
||||||
|
const amduat_pel_dag_scheme_descriptor_t *desc) {
|
||||||
|
if (desc == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (desc->pel1_version != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (desc->scheme_name.len != sizeof(k_scheme_name) - 1 ||
|
||||||
|
desc->scheme_name.data == NULL ||
|
||||||
|
memcmp(desc->scheme_name.data,
|
||||||
|
k_scheme_name,
|
||||||
|
sizeof(k_scheme_name) - 1) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (desc->program_type_tag.tag_id != AMDUAT_PEL_TYPE_TAG_PROGRAM_DAG_1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (desc->program_enc_profile != AMDUAT_PEL_ENC_PROGRAM_DAG_V1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (desc->has_trace_profile_ref || desc->has_opreg_ref) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool amduat_pel_program_dag_desc_is_canonical_artifact(
|
||||||
|
const amduat_artifact_t *artifact) {
|
||||||
|
amduat_pel_dag_scheme_descriptor_t desc;
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
if (artifact == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!artifact->has_type_tag ||
|
||||||
|
artifact->type_tag.tag_id != AMDUAT_PEL_TYPE_TAG_SCHEME_DESC_1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&desc, 0, sizeof(desc));
|
||||||
|
if (!amduat_enc_pel_program_dag_desc_decode_v1(artifact->bytes, &desc)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ok = amduat_pel_program_dag_desc_is_canonical(&desc);
|
||||||
|
amduat_enc_pel_program_dag_desc_free(&desc);
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1171,8 +1171,8 @@ static int amduat_pel_cli_cmd_validate(
|
||||||
amduat_asl_artifact_free(&artifact);
|
amduat_asl_artifact_free(&artifact);
|
||||||
return AMDUAT_PEL_CLI_EXIT_CODEC;
|
return AMDUAT_PEL_CLI_EXIT_CODEC;
|
||||||
}
|
}
|
||||||
|
valid = amduat_pel_program_dag_desc_is_canonical(&desc);
|
||||||
amduat_enc_pel_program_dag_desc_free(&desc);
|
amduat_enc_pel_program_dag_desc_free(&desc);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
if (artifact.has_type_tag &&
|
if (artifact.has_type_tag &&
|
||||||
artifact.type_tag.tag_id != AMDUAT_PEL_TYPE_TAG_PROGRAM_DAG_1) {
|
artifact.type_tag.tag_id != AMDUAT_PEL_TYPE_TAG_PROGRAM_DAG_1) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue