forked from openenclave/openenclave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement TEE-supported RNG for oe_random_internal
Signed-off-by: Ming-Wei Shih <[email protected]> Add the missing file Signed-off-by: Ming-Wei Shih <[email protected]>
- Loading branch information
1 parent
c6f73e7
commit 237c7c8
Showing
13 changed files
with
48 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
#include <openenclave/enclave.h> | ||
|
||
oe_result_t oe_random_internal(void* data, size_t size) | ||
{ | ||
OE_UNUSED(data); | ||
OE_UNUSED(size); | ||
return OE_UNSUPPORTED; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
#include <openenclave/corelibc/string.h> | ||
#include <openenclave/enclave.h> | ||
#include <openenclave/internal/rdrand.h> | ||
|
||
// The RDRAND generats 8-byte random value. | ||
#define RDRAND_BYTES 8 | ||
|
||
oe_result_t oe_random_internal(void* data, size_t size) | ||
{ | ||
for (size_t i = 0; i < size; i += RDRAND_BYTES) | ||
{ | ||
size_t request_size = size - i; | ||
if (request_size > RDRAND_BYTES) | ||
{ | ||
request_size = RDRAND_BYTES; | ||
} | ||
uint64_t random_bytes = oe_rdrand(); | ||
memcpy((void*)((uint8_t*)data + i), (void*)&random_bytes, request_size); | ||
} | ||
|
||
return OE_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
#ifndef _CRYPTO_ENCLAVE_RANDOM_H | ||
#define _CRYPTO_ENCLAVE_RANDOM_H | ||
#ifndef _CRYPTO_ENCLAVE_CTR_DRBG_H | ||
#define _CRYPTO_ENCLAVE_CTR_DRBG_H | ||
|
||
#include <mbedtls/ctr_drbg.h> | ||
|
||
mbedtls_ctr_drbg_context* oe_mbedtls_get_drbg(); | ||
|
||
#endif /* _CRYPTO_ENCLAVE_RANDOM_H */ | ||
#endif /* _CRYPTO_ENCLAVE_CTR_DRBG_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters