[Assignment-7] security fix in sign_firmware
This commit is contained in:
parent
5e0d13b84e
commit
cb380685a8
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_ec256_public_t public;
|
||||||
|
|
||||||
sgx_status_t status;
|
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;
|
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;
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
sgx_ec256_signature_t ecc_signature;
|
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;
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(signature, ecc_signature.x, SGX_ECP256_KEY_SIZE);
|
memcpy(signature, ecc_signature.x, SGX_ECP256_KEY_SIZE);
|
||||||
memcpy(signature + SGX_ECP256_KEY_SIZE, ecc_signature.y, SGX_ECP256_KEY_SIZE);
|
memcpy(signature + SGX_ECP256_KEY_SIZE, ecc_signature.y, SGX_ECP256_KEY_SIZE);
|
||||||
|
|
Loading…
Reference in a new issue