[Assignment-7] public_key: renamed to get_public_key; improved error handling
This commit is contained in:
parent
5aad77ef33
commit
cf82ac1794
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;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, uint32_t sealed_size, uint8_t *gx, uint32_t gx_size, uint8_t *gy, uint32_t gy_size) {
|
||||||
// return if no sealed data provided
|
// invalid parameter handling
|
||||||
if(sealed == NULL)
|
if((sealed == NULL) || (sealed_size == 0)) {
|
||||||
return SGX_ERROR_UNEXPECTED;
|
return SGX_ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
// unseal public key
|
// unseal public key
|
||||||
|
sgx_status_t status;
|
||||||
sgx_ec256_public_t public;
|
sgx_ec256_public_t public;
|
||||||
if(unseal_key_pair(sealed, sealed_size, NULL, &public) != SGX_SUCCESS) {
|
if((status = unseal_key_pair(sealed, NULL, &public)) != SGX_SUCCESS) {
|
||||||
return SGX_ERROR_UNEXPECTED;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy public key into return buffers
|
// copy public key into return buffers
|
||||||
if((gx != NULL) && (gy != NULL)) {
|
if((gx != NULL) && (gy != NULL)) {
|
||||||
memcpy(gx, public.gx, SGX_ECP256_KEY_SIZE);
|
memcpy(gx, public.gx, SK_SIZE);
|
||||||
memcpy(gy, public.gy, SGX_ECP256_KEY_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) {
|
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_signature_size();
|
||||||
public int get_public_key_size();
|
public int get_public_key_size();
|
||||||
public int get_private_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);
|
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_public_key_size();
|
||||||
int get_private_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);
|
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_ */
|
#endif /* !_ENCLAVE_H_ */
|
Loading…
Reference in a new issue