Assignment 7 #4
1 changed files with 8 additions and 3 deletions
|
@ -85,15 +85,20 @@ sgx_status_t sign_firmware(uint8_t *data, size_t data_size, uint8_t *signature,
|
|||
sgx_ec256_public_t public;
|
||||
|
||||
sgx_status_t status;
|
||||
if((status = sgx_ecc256_open_context(&ecc_handle)) != SGX_SUCCESS)
|
||||
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)
|
||||
if((status = sgx_ecc256_create_key_pair(&private, &public, ecc_handle)) != SGX_SUCCESS) {
|
||||
sgx_ecc256_close_context(ecc_handle);
|
||||
return status;
|
||||
}
|
||||
|
||||
sgx_ec256_signature_t ecc_signature;
|
||||
if((status = sgx_ecdsa_sign(data, data_size, &private, &ecc_signature, ecc_handle)) != SGX_SUCCESS)
|
||||
if((status = sgx_ecdsa_sign(data, data_size, &private, &ecc_signature, ecc_handle)) != SGX_SUCCESS) {
|
||||
sgx_ecc256_close_context(ecc_handle);
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy(signature, ecc_signature.x, SGX_ECP256_KEY_SIZE);
|
||||
memcpy(signature + SGX_ECP256_KEY_SIZE, ecc_signature.y, SGX_ECP256_KEY_SIZE);
|
||||
|
|
Loading…
Reference in a new issue