Skip to content

Commit b7ffa83

Browse files
committed
[tools/RA-TLS] Drop deprecated RA_TLS_* env semantics
Omitting any of the measurement variables is now a hard error. Signed-off-by: Michał Kowalczyk <[email protected]>
1 parent 64cd864 commit b7ffa83

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

.ci/lib/stage-test-sgx.jenkinsfile

+12
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ stage('test-sgx') {
119119
timeout(time: 5, unit: 'MINUTES') {
120120
sh '''
121121
cd CI-Examples/ra-tls-mbedtls
122+
export RA_TLS_MRSIGNER=any
123+
export RA_TLS_MRENCLAVE=any
124+
export RA_TLS_ISV_PROD_ID=any
125+
export RA_TLS_ISV_SVN=any
122126
if [ "${RA_TYPE}" = "epid" ]; then \
123127
if [ "${ra_client_spid}" != "" ] && [ "${ra_client_key}" != "" ]; \
124128
then \
@@ -142,6 +146,10 @@ stage('test-sgx') {
142146
timeout(time: 5, unit: 'MINUTES') {
143147
sh '''
144148
cd CI-Examples/ra-tls-secret-prov
149+
export RA_TLS_MRSIGNER=any
150+
export RA_TLS_MRENCLAVE=any
151+
export RA_TLS_ISV_PROD_ID=any
152+
export RA_TLS_ISV_SVN=any
145153
if [ "${RA_TYPE}" = "epid" ]; then \
146154
if [ "${ra_client_spid}" != "" ] && [ "${ra_client_key}" != "" ]; \
147155
then \
@@ -162,6 +170,10 @@ stage('test-sgx') {
162170
timeout(time: 5, unit: 'MINUTES') {
163171
sh '''
164172
cd CI-Examples/ra-tls-nginx
173+
export RA_TLS_MRSIGNER=any
174+
export RA_TLS_MRENCLAVE=any
175+
export RA_TLS_ISV_PROD_ID=any
176+
export RA_TLS_ISV_SVN=any
165177
if [ "${RA_TYPE}" = "epid" ]; then \
166178
if [ "${ra_client_spid}" != "" ] && [ "${ra_client_key}" != "" ]; \
167179
then \

Documentation/attestation.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,8 @@ SGX measurements:
314314
- ``RA_TLS_ISV_SVN`` -- verify that the attesting enclave has this or higher
315315
``ISV_SVN``. This is a decimal string.
316316

317-
For each of these settings, you may specify the special value ``any`` to skip
318-
verifying a particular measurement. This used to be the default, which would
319-
be used if a particular environment variable wasn't present. This behavior
320-
has been deprecated and will become a hard error in the future.
317+
Each of these variables has to be explicitly set, but you may specify the
318+
special value ``any`` to skip verifying a particular measurement.
321319

322320
The four SGX measurements above may be also verified via a user-specified
323321
callback with the signature ``int (*callback)(char* mrenclave, char* mrsigner,

tools/sgx/ra-tls/ra_tls_verify_common.c

+16-13
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,19 @@
2626

2727
verify_measurements_cb_t g_verify_measurements_cb = NULL;
2828

29-
static char* getenv_critical(const char* name) {
30-
char* value = getenv(name);
29+
static bool getenv_critical(const char* name, const char** out_value) {
30+
const char* value = getenv(name);
3131
if (!value) {
32-
INFO("WARNING: The default enclave verification hook is being used, but %s is not set. "
33-
"This is deprecated and will become an error in the future. "
34-
"If you wish to accept any value, please specify %s=any explicitly.\n",
35-
name, name);
32+
ERROR("ERROR: A required environment variable %s is not set.\n", name);
33+
return false;
3634
}
3735

38-
if (value && strcmp(value, "any") == 0) {
36+
if (strcmp(value, "any") == 0) {
3937
value = NULL;
4038
}
4139

42-
return value;
40+
*out_value = value;
41+
return true;
4342
}
4443

4544
static int getenv_enclave_measurements(sgx_measurement_t* mrsigner, bool* validate_mrsigner,
@@ -57,21 +56,24 @@ static int getenv_enclave_measurements(sgx_measurement_t* mrsigner, bool* valida
5756
const char* isv_svn_dec;
5857

5958
/* any of the below variables may be NULL (and then not used in validation) */
60-
mrsigner_hex = getenv_critical(RA_TLS_MRSIGNER);
59+
if (!getenv_critical(RA_TLS_MRSIGNER, &mrsigner_hex))
60+
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
6161
if (mrsigner_hex) {
6262
if (parse_hex(mrsigner_hex, mrsigner, sizeof(*mrsigner), NULL) != 0)
6363
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
6464
*validate_mrsigner = true;
6565
}
6666

67-
mrenclave_hex = getenv_critical(RA_TLS_MRENCLAVE);
67+
if (!getenv_critical(RA_TLS_MRENCLAVE, &mrenclave_hex))
68+
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
6869
if (mrenclave_hex) {
6970
if (parse_hex(mrenclave_hex, mrenclave, sizeof(*mrenclave), NULL) != 0)
7071
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
7172
*validate_mrenclave = true;
7273
}
7374

74-
isv_prod_id_dec = getenv_critical(RA_TLS_ISV_PROD_ID);
75+
if (!getenv_critical(RA_TLS_ISV_PROD_ID, &isv_prod_id_dec))
76+
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
7577
if (isv_prod_id_dec) {
7678
errno = 0;
7779
*isv_prod_id = strtoul(isv_prod_id_dec, NULL, 10);
@@ -80,7 +82,8 @@ static int getenv_enclave_measurements(sgx_measurement_t* mrsigner, bool* valida
8082
*validate_isv_prod_id = true;
8183
}
8284

83-
isv_svn_dec = getenv_critical(RA_TLS_ISV_SVN);
85+
if (!getenv_critical(RA_TLS_ISV_SVN, &isv_svn_dec))
86+
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
8487
if (isv_svn_dec) {
8588
errno = 0;
8689
*isv_svn = strtoul(isv_svn_dec, NULL, 10);
@@ -295,7 +298,7 @@ int verify_quote_body_against_envvar_measurements(const sgx_quote_body_t* quote_
295298
&expected_isv_prod_id, &validate_isv_prod_id,
296299
&expected_isv_svn, &validate_isv_svn);
297300
if (ret < 0)
298-
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
301+
return ret;
299302

300303
ret = verify_quote_body(quote_body, validate_mrsigner ? (char*)&expected_mrsigner : NULL,
301304
validate_mrenclave ? (char*)&expected_mrenclave : NULL,

0 commit comments

Comments
 (0)