[Assignment-7] public_key: renamed to get_public_key; improved error handling
This commit is contained in:
parent
3ea3076945
commit
8da66bea12
3 changed files with 14 additions and 11 deletions
|
@ -127,24 +127,27 @@ sgx_status_t unseal_key_pair(const uint8_t *sealed, sgx_ec256_private_t *private
|
|||
return status;
|
||||
}
|
||||
|
||||
sgx_status_t public_key(const uint8_t *sealed, const size_t sealed_size, uint8_t *gx, uint8_t *gy) {
|
||||
// return if no sealed data provided
|
||||
if(sealed == NULL)
|
||||
return SGX_ERROR_UNEXPECTED;
|
||||
sgx_status_t get_public_key(const uint8_t *sealed, uint32_t sealed_size, uint8_t *gx, uint32_t gx_size, uint8_t *gy, uint32_t gy_size) {
|
||||
// invalid parameter handling
|
||||
if((sealed == NULL) || (sealed_size == 0)) {
|
||||
return SGX_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// unseal public key
|
||||
sgx_status_t status;
|
||||
sgx_ec256_public_t public;
|
||||
if(unseal_key_pair(sealed, sealed_size, NULL, &public) != SGX_SUCCESS) {
|
||||
return SGX_ERROR_UNEXPECTED;
|
||||
if((status = unseal_key_pair(sealed, NULL, &public)) != SGX_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// copy public key into return buffers
|
||||
if((gx != NULL) && (gy != NULL)) {
|
||||
memcpy(gx, public.gx, SGX_ECP256_KEY_SIZE);
|
||||
memcpy(gy, public.gy, SGX_ECP256_KEY_SIZE);
|
||||
memcpy(gx, public.gx, SK_SIZE);
|
||||
memcpy(gy, public.gy, SK_SIZE);
|
||||
}
|
||||
|
||||
return SGX_SUCCESS;
|
||||
// return success
|
||||
return status;
|
||||
}
|
||||
|
||||
sgx_status_t sign_firmware(const uint8_t *sealed, size_t sealed_size, uint8_t *data, size_t data_size, uint8_t *signature, size_t signature_size) {
|
||||
|
|
|
@ -44,7 +44,7 @@ enclave {
|
|||
public int get_signature_size();
|
||||
public int get_public_key_size();
|
||||
public int get_private_key_size();
|
||||
public sgx_status_t public_key([in, size=sealed_size]const uint8_t *sealed, size_t sealed_size, [out]uint8_t *gx, [out]uint8_t *gy);
|
||||
public sgx_status_t get_public_key([in, size=sealed_size]const uint8_t *sealed, uint32_t sealed_size, [out, size=gx_size]uint8_t *gx, uint32_t gx_size, [out, size=gx_size]uint8_t *gy, uint32_t gy_size);
|
||||
public sgx_status_t sign_firmware([in, size=data_size]const uint8_t *sealed, size_t sealed_size, [in, size=data_size]uint8_t *data, size_t data_size, [out, size=signature_size]uint8_t *signature, size_t signature_size);
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ int get_signature_size();
|
|||
int get_public_key_size();
|
||||
int get_private_key_size();
|
||||
|
||||
sgx_status_t public_key(const uint8_t *sealed, const size_t sealed_size, uint8_t *gx, uint8_t *gy);
|
||||
sgx_status_t get_public_key(const uint8_t *sealed, const uint32_t sealed_size, uint8_t *gx, uint32_t gx_size, uint8_t *gy, uint32_t gy_size);
|
||||
sgx_status_t sign_firmware(const uint8_t *sealed, size_t sealed_size, uint8_t *data, size_t data_size, uint8_t *signature, size_t signature_size);
|
||||
|
||||
#endif /* !_ENCLAVE_H_ */
|
Loading…
Reference in a new issue