26
26
27
27
verify_measurements_cb_t g_verify_measurements_cb = NULL ;
28
28
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 );
31
31
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;
36
34
}
37
35
38
- if (value && strcmp (value , "any" ) == 0 ) {
36
+ if (strcmp (value , "any" ) == 0 ) {
39
37
value = NULL ;
40
38
}
41
39
42
- return value ;
40
+ * out_value = value ;
41
+ return true;
43
42
}
44
43
45
44
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
57
56
const char * isv_svn_dec ;
58
57
59
58
/* 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 ;
61
61
if (mrsigner_hex ) {
62
62
if (parse_hex (mrsigner_hex , mrsigner , sizeof (* mrsigner ), NULL ) != 0 )
63
63
return MBEDTLS_ERR_X509_BAD_INPUT_DATA ;
64
64
* validate_mrsigner = true;
65
65
}
66
66
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 ;
68
69
if (mrenclave_hex ) {
69
70
if (parse_hex (mrenclave_hex , mrenclave , sizeof (* mrenclave ), NULL ) != 0 )
70
71
return MBEDTLS_ERR_X509_BAD_INPUT_DATA ;
71
72
* validate_mrenclave = true;
72
73
}
73
74
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 ;
75
77
if (isv_prod_id_dec ) {
76
78
errno = 0 ;
77
79
* 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
80
82
* validate_isv_prod_id = true;
81
83
}
82
84
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 ;
84
87
if (isv_svn_dec ) {
85
88
errno = 0 ;
86
89
* 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_
295
298
& expected_isv_prod_id , & validate_isv_prod_id ,
296
299
& expected_isv_svn , & validate_isv_svn );
297
300
if (ret < 0 )
298
- return MBEDTLS_ERR_X509_BAD_INPUT_DATA ;
301
+ return ret ;
299
302
300
303
ret = verify_quote_body (quote_body , validate_mrsigner ? (char * )& expected_mrsigner : NULL ,
301
304
validate_mrenclave ? (char * )& expected_mrenclave : NULL ,
0 commit comments