1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #include "deriv.h"
- #include "sgx_tcrypto.h"
- static const uint8_t BASE_SEAL_KEY[] = {
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
- };
- static const uint8_t BASE_REPORT_KEY[] = {
- 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
- 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
- };
- static const uint8_t BASE_EINITTOKEN_KEY[] = {
- 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55,
- 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55,
- };
- static const uint8_t BASE_PROVISION_KEY[] = {
- 0xbb, 0xaa, 0xbb, 0xee, 0xff, 0x00, 0x00, 0xdd,
- 0xbb, 0xaa, 0xbb, 0xee, 0xff, 0x00, 0x00, 0xdd,
- };
- static const uint8_t BASE_PROV_SEAL_KEY[] = {
- 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f,
- 0x4e, 0x53, 0x45, 0x41, 0x4c, 0x4b, 0x45, 0x59,
- };
- const uint8_t* get_base_key(uint16_t key_name)
- {
- switch (key_name) {
- case SGX_KEYSELECT_SEAL:
- return BASE_SEAL_KEY;
- case SGX_KEYSELECT_REPORT:
- return BASE_REPORT_KEY;
- case SGX_KEYSELECT_EINITTOKEN:
- return BASE_EINITTOKEN_KEY;
- case SGX_KEYSELECT_PROVISION:
- return BASE_PROVISION_KEY;
- case SGX_KEYSELECT_PROVISION_SEAL:
- return BASE_PROV_SEAL_KEY;
- }
-
-
- return (uint8_t*)0;
- }
- void derive_key(const derivation_data_t* dd, sgx_key_128bit_t okey)
- {
- sgx_rijndael128_cmac_msg((const sgx_cmac_128bit_key_t*)(get_base_key(dd->key_name)),
- dd->ddbuf, dd->size, (sgx_cmac_128bit_tag_t*)okey);
- }
- void cmac(const sgx_key_128bit_t *key, const uint8_t* buf, int buf_len, sgx_mac_t* cmac)
- {
- sgx_rijndael128_cmac_msg((const sgx_cmac_128bit_key_t*)key, buf, buf_len, cmac);
- }
|