@@ -2,17 +2,17 @@ use core::{mem, slice};
22
33use base64ct:: Encoding ;
44use enclave_crypto:: dcap:: verify_quote_any;
5+ use log:: * ;
6+ use rsa:: signature:: Verifier ;
57use serde_json:: Value ;
68use sha2:: { Digest , Sha256 } ;
79use std:: collections:: { HashMap , HashSet } ;
810use std:: convert:: TryFrom ;
911use std:: io:: Write ;
12+ use std:: sync:: SgxMutex ;
1013use std:: untrusted:: fs:: File ;
1114use std:: vec:: Vec ;
1215
13- use log:: * ;
14- use rsa:: signature:: Verifier ;
15-
1616#[ cfg( feature = "SGX_MODE_HW" ) ]
1717use sgx_tse:: rsgx_create_report;
1818
@@ -142,7 +142,7 @@ lazy_static::lazy_static! {
142142 keys
143143 } ;
144144
145- static ref PPID_WHITELIST : HashSet <[ u8 ; 20 ] > = {
145+ pub static ref PPID_WHITELIST : SgxMutex < HashSet <[ u8 ; 20 ] > > = {
146146 let mut set: HashSet <[ u8 ; 20 ] > = HashSet :: new( ) ;
147147
148148 set. insert( [ 0x01 , 0x50 , 0x7c , 0x95 , 0x77 , 0x89 , 0xb7 , 0xc1 , 0xaf , 0xde , 0x97 , 0x2d , 0x67 , 0xf1 , 0xfd , 0xd5 , 0x3a , 0xf1 , 0xa8 , 0xda ] ) ;
@@ -257,7 +257,7 @@ lazy_static::lazy_static! {
257257 set. insert( [ 0xfe , 0xc9 , 0x34 , 0x2e , 0x9e , 0xe4 , 0x18 , 0x64 , 0x53 , 0xf8 , 0xa7 , 0xe0 , 0x27 , 0xfa , 0xc8 , 0xc2 , 0x4e , 0x7c , 0x0c , 0x60 ] ) ;
258258
259259
260- set
260+ SgxMutex :: new ( set)
261261 } ;
262262
263263 static ref FMSPC_EOL : HashSet <& ' static str > = HashSet :: from( [
@@ -661,7 +661,7 @@ pub fn verify_quote_sgx(
661661 Some ( ppid) => {
662662 let ppid_addr = crate :: registration:: offchain:: calculate_truncated_hash ( & ppid) ;
663663
664- let wl = & PPID_WHITELIST ;
664+ let wl = PPID_WHITELIST . lock ( ) . unwrap ( ) ;
665665 if wl. contains ( & ppid_addr) {
666666 true
667667 } else {
0 commit comments