Closed Erik-ly closed 1 year ago
The docker image intelanalytics/bigdl-ppml-trusted-bigdata-gramine-noattest-32g:2.4.0-SNAPSHOT
is a reference image we have already built an enclave in it, which means if you want to make a SGX enclave by commands, you need to use intelanalytics/bigdl-ppml-trusted-bigdata-gramine-base:2.4.0-SNAPSHOT
, or execute bash ./clean.sh
in /ppml
dir. Otherwise, the make
command will show the mr_enclave
and mr_signer
of our built SGX enclave, and the enclave-key.pem
you provided will not effect.
And mr_signer
is the SHA-256 hash of the modulus of the enclave key. A method to check mr_signer
is provided here:
openssl rsa -in enclave-key.pem -noout -modulus
You can verify the modulus with the output of make
or gramine-sgx-get-token
. It needs endian conversion in our example.
import hashlib
hex_integer = "D1D2889EC4F695F93E74A868A5BFB1C390AA66C918F10178CB7F5D1BC4CE53F5BA2561E7E32E2D394587E3798209862CAE82A127E7FF9F6CA7B0B25E590D2863D6F6E86723C0B63B7E7EB7DBD539A0AB402F4078711C9ABEC5FC62745F337994EB53810260A92DEAF9BA8676CF2BDC209A58B665C285013948B14B56C2A40C807E28FDAC2CB7AE96ADE0AEBECB1A47E89A55E46C6CC9114C93EFCA67C4D5D2D7672FC1A6F6558ACA26539C982B6891A1CF53696A2E44F8641D77A83BABBD9CB104C69EFD5FFBBCB2DDDFF85D0D48AB3652B1B274D3DFF94E8045E39A1ECB1CE8FF6504FBE7C241A5BF735F13EC604B853E0A668746C7B0CDE2D7A050ADF2612BD090434F5D4D77B2615461FA5E87D3F1E3FCD80D7125B532A1F6238A0C44F8D15C1AD1E6759F5D2B536762ADF66D3227D312B41ACD64FA2EC0AF65B9014C30605C6A4FDDCBB23093605EC250C84418BFD959EEB76946C26F96C87D9A9AEEE44945F817AA905A96F5FBD92FF1E0202E434F8B77DD1C55DDD7B4E5926F12BEBADD" # the result you got from first step
byte_string = bytes.fromhex(hex_integer) hash_object = hashlib.sha256(byte_string[::-1]) # Endian conversion hash_value = hash_object.hexdigest()
print(hash_value)
You can check the value with `mr_signer` in Attributes.
<img width="410" alt="image" src="https://github.com/intel-analytics/BigDL/assets/109123695/fb9e164a-43f2-4695-8a82-16f32a195e5d">
Thanks. I use intelanalytics/bigdl-ppml-trusted-bigdata-gramine-base:2.4.0-SNAPSHOT
, and execute bash ./clean.sh
in /ppml
dir,then execute make
cmd,get the different mr_signer
.
when I execute openssl rsa -in enclave-key.pem -noout -modulus
, output rsa:Unrecognized flag moudlus.
can't get the modulus info.Do I need to execute other commands?
Thanks. I use
intelanalytics/bigdl-ppml-trusted-bigdata-gramine-base:2.4.0-SNAPSHOT
, and executebash ./clean.sh
in/ppml
dir,then executemake
cmd,get the differentmr_signer
.when I execute
openssl rsa -in enclave-key.pem -noout -modulus
, outputrsa:Unrecognized flag moudlus.
can't get the modulus info.Do I need to execute other commands?
The output you provided logs moudlus
, which might be a mistaken spell of modulus
. Could you check it in your commands?
If the openssl
command won't effect, you can try another python code below: (based on cryptography==3.3.2
)
from cryptography.hazmat.primitives import serialization
import hashlib
private_key_file = "/ppml/enclave-key.pem"
with open(private_key_file, "rb") as key_file:
private_key = serialization.load_pem_private_key(key_file.read(), password=None)
modulus = private_key.private_numbers().public_numbers.n
modulus_hex = hex(modulus)[2:]
print("Private Key Modulus:", modulus_hex)
byte_string = bytes.fromhex(modulus_hex)
hash_object = hashlib.sha256(byte_string[::-1]) # Endian conversion
hash_value = hash_object.hexdigest()
print(hash_value)
The output you provided logs moudlus, which might be a mistaken spell of modulus. Could you check it in your commands?
Sorry, it is indeed a misspelled command. I use the command openssl rsa -in /root/.config/gramine/enclave-key.pem -noout -modulus
to get the Modulus value.
Then,I use the method Calculate SHA-256 hash.
, and I can get the same value as mr_signer
.
Thank you.
hi, I want to test the PPML attestation on docker, but the result is not as expected. The following is my test environment and steps, hoping to get help,thanks.
Environment info:
SGX PRMRR Size is 64G.
Test Steps:
a. Generate private key 1
b. Deploy SGX enclave 1 docker by private key 1
c. sign SGX enclave 1 with make command
check the enclave-key.pem(private-key1.pem)
a. Generate private key 2
b. Deploy SGX enclave 2 docker by private key 2
c. sign SGX enclave 2 with make command
check the enclave-key.pem(private-key2.pem)
Observe the output, mr_signer in container sgx-enclave-1 and container sgx-enclave-2 is the same.
I have verified that pem is different, the output of using the command "openssl rsa -in /root/.config/gramine/enclave-key.pem" is also different.
Please check the test steps and tell me the cause of the problem, thank you.