-
Notifications
You must be signed in to change notification settings - Fork 35
out-of-tree attester/verifier instances support #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,9 @@ | |
#include <rats-tls/log.h> | ||
#include <rats-tls/crypto_wrapper.h> | ||
#include <rats-tls/oid.h> | ||
#include <rats-tls/attester.h> | ||
#include "openssl.h" | ||
#include "internal/attester.h" | ||
|
||
#define CERT_SERIAL_NUMBER 9527 | ||
|
||
|
@@ -145,26 +147,22 @@ crypto_wrapper_err_t openssl_gen_cert(crypto_wrapper_ctx_t *ctx, rats_tls_cert_a | |
if (!x509_extension_add(cert, ias_report_signature_oid, epid->ias_report_signature, | ||
epid->ias_report_signature_len)) | ||
goto err; | ||
} else if (!strcmp(cert_info->evidence.type, "sgx_ecdsa")) { | ||
ecdsa_attestation_evidence_t *ecdsa = &cert_info->evidence.ecdsa; | ||
|
||
if (!x509_extension_add(cert, ecdsa_quote_oid, ecdsa->quote, ecdsa->quote_len)) | ||
goto err; | ||
} else if (!strcmp(cert_info->evidence.type, "sgx_la")) { | ||
la_attestation_evidence_t *la = &cert_info->evidence.la; | ||
|
||
if (!x509_extension_add(cert, la_report_oid, la->report, la->report_len)) | ||
goto err; | ||
} else if (!strcmp(cert_info->evidence.type, "tdx_ecdsa")) { | ||
tdx_attestation_evidence_t *tdx = &cert_info->evidence.tdx; | ||
} | ||
|
||
if (!x509_extension_add(cert, tdx_quote_oid, tdx->quote, tdx->quote_len)) | ||
enclave_attester_opts_t *opts = NULL; | ||
for(int i = 0; i < registerd_enclave_attester_nums; ++i) { | ||
opts = enclave_attesters_opts[i]; | ||
if (!opts) { | ||
RTLS_DEBUG("registerd enclave_attesters_opts is null.\n"); | ||
goto err; | ||
} else if (!strcmp(cert_info->evidence.type, "sev_snp")) { | ||
snp_attestation_evidence_t *snp = &cert_info->evidence.snp; | ||
} | ||
|
||
if (!x509_extension_add(cert, snp_report_oid, snp->report, snp->report_len)) | ||
goto err; | ||
if (!strcmp(cert_info->evidence.type, opts->name)) { | ||
tee_attestation_evidence_t *evidence = &cert_info->evidence.evidence; | ||
if (!x509_extension_add(cert, opts->oid, evidence->report, evidence->report_len)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't any places where an OID is referred and then you replace such a loop to find the OID. Actually |
||
goto err; | ||
break; | ||
} | ||
} | ||
|
||
ret = -CRYPTO_WRAPPER_ERR_CERT; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
#ifndef _ENCLAVE_CERT_H | ||
#define _ENCLAVE_CERT_H | ||
|
||
#define OID_LENGTH 64 | ||
|
||
typedef struct { | ||
const unsigned char *organization; | ||
const unsigned char *organization_unit; | ||
|
@@ -24,34 +26,16 @@ typedef struct { | |
uint32_t ias_report_signature_len; | ||
} attestation_verification_report_t; | ||
|
||
typedef struct { | ||
uint8_t quote[8192]; | ||
uint32_t quote_len; | ||
} ecdsa_attestation_evidence_t; | ||
|
||
typedef struct { | ||
uint8_t report[8192]; | ||
uint32_t report_len; | ||
} la_attestation_evidence_t; | ||
|
||
typedef struct { | ||
uint8_t quote[8192]; | ||
uint32_t quote_len; | ||
} tdx_attestation_evidence_t; | ||
|
||
typedef struct { | ||
uint8_t report[8192]; | ||
uint32_t report_len; | ||
} snp_attestation_evidence_t; | ||
} tee_attestation_evidence_t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This structure can be removed. |
||
|
||
typedef struct { | ||
char type[ENCLAVE_ATTESTER_TYPE_NAME_SIZE]; | ||
union { | ||
attestation_verification_report_t epid; | ||
ecdsa_attestation_evidence_t ecdsa; | ||
la_attestation_evidence_t la; | ||
tdx_attestation_evidence_t tdx; | ||
snp_attestation_evidence_t snp; | ||
tee_attestation_evidence_t evidence; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change to typedef struct {
char type[ENCLAVE_ATTESTER_TYPE_NAME_SIZE];
union {
attestation_verification_report_t epid;
struct {
uint8_t report[8192];
uint32_t report_len;
};
};
} attestation_evidence_t; So we could avoid referring report with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good advice! |
||
}; | ||
} attestation_evidence_t; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ typedef struct { | |
uint8_t api_version; | ||
unsigned long flags; | ||
const char name[ENCLAVE_VERIFIER_TYPE_NAME_SIZE]; | ||
const char oid[OID_LENGTH]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a newline here. |
||
/* Different attester instances may generate the same format of verifier, | ||
* e.g, sgx_ecdsa and sgx_ecdsa_qve both generate the format "sgx_ecdsa". | ||
* By default, the value of type equals to name. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should move this check to the corresponding instances' pre_init(), instead of simply removing them. In addition, ENCLAVE_ATTESTER_OPTS_FLAGS_SNP_GUEST and ENCLAVE_ATTESTER_OPTS_FLAGS_TDX_GUEST looks useless. You can remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep tee self-detect function in registering phase will block some instance to register. Consider the condition, if an app need to use some key generation function in sev-snp.so, but the app run in intel cpu, user will never have the opportunity to load the sev-snp.so. That's why remove the self-detect function as a registering gate-keeper.
I think user can invoke self-detect function to check the HW environment, but don't use self-detect as forcing gate-keeper in rats-tls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get your point. Why an user uses hardware agnostic key generation function from sev-snp? sev-snp only provides the support for its attester role or verifier role. If key generation function is so common that other instance wants to reuse it, does it make sense to move such a general function to the common part? In addition, your scenario actually exists? Does sev-snp instance really show enough versatility on key generation (not just a limited usage for serving itself)?