[Assignment-7] add first enclave part
This commit is contained in:
parent
4a5261f6ec
commit
76d8d4a2f4
4 changed files with 138 additions and 0 deletions
28
Assignment 7 - SGX Hands-on/src/enclave/enclave.c
Normal file
28
Assignment 7 - SGX Hands-on/src/enclave/enclave.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "Enclave.h"
|
||||
#include "Enclave_t.h"
|
||||
#include <sgx_error.h>
|
||||
#include <sgx_tcrypto.h>
|
||||
|
||||
sgx_status_t public_key(uint8_t *gx, uint8_t *gy) {
|
||||
// unseal key or from file system
|
||||
}
|
||||
|
||||
sgx_status_t sign_firmware(uint8_t *data, size_t data_size, uint8_t *signature, size_t signature_size) {
|
||||
sgx_ecc_state_handle_t ecc_handle;
|
||||
sgx_ec256_private_t private;
|
||||
sgx_ec256_public_t public;
|
||||
|
||||
sgx_status_t status;
|
||||
if((status = sgx_ecc256_open_context(&ecc_handle)) != SGX_SUCCESS)
|
||||
return status;
|
||||
|
||||
if((status = sgx_ecc256_create_key_pair(&private, &public, ecc_handle)) != SGX_SUCCESS)
|
||||
return status;
|
||||
|
||||
sgx_ec256_signature_t ecc_signature;
|
||||
if((status = sgx_ecdsa_sign(data, data_size, &private, &ecc_signature, ecc_handle)) != SGX_SUCCESS)
|
||||
return status;
|
||||
|
||||
sgx_ecc256_close_context(ecc_handle);
|
||||
return SGX_SUCCESS;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue