-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from datachainlab/fix-gen-ek
Fix `generate-key` to create a report that contains the EK Signed-off-by: Jun Kimura <[email protected]>
- Loading branch information
Showing
32 changed files
with
476 additions
and
344 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
15 changes: 13 additions & 2 deletions
15
enclave-modules/ecall-handler/src/enclave_manage/enclave.rs
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,15 +1,26 @@ | ||
use crate::enclave_manage::Error; | ||
use crate::prelude::*; | ||
use attestation_report::ReportData; | ||
use crypto::{EnclaveKey, SealingKey}; | ||
use ecall_commands::{GenerateEnclaveKeyInput, GenerateEnclaveKeyResponse}; | ||
use sgx_tse::rsgx_create_report; | ||
|
||
pub(crate) fn generate_enclave_key( | ||
_: GenerateEnclaveKeyInput, | ||
input: GenerateEnclaveKeyInput, | ||
) -> Result<GenerateEnclaveKeyResponse, Error> { | ||
let ek = EnclaveKey::new()?; | ||
let sealed_ek = ek.seal()?; | ||
let ek_pub = ek.get_pubkey(); | ||
let report_data = ReportData::new(ek_pub.as_address(), input.operator); | ||
let report = match rsgx_create_report(&input.target_info, &report_data.into()) { | ||
Ok(r) => r, | ||
Err(e) => { | ||
return Err(Error::sgx_error(e, "Report creation => failed".to_string())); | ||
} | ||
}; | ||
Ok(GenerateEnclaveKeyResponse { | ||
pub_key: ek.get_pubkey(), | ||
pub_key: ek_pub, | ||
sealed_ek, | ||
report, | ||
}) | ||
} |
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 |
---|---|---|
|
@@ -3,5 +3,4 @@ pub use router::dispatch; | |
|
||
mod enclave; | ||
mod errors; | ||
mod report; | ||
mod router; |
23 changes: 0 additions & 23 deletions
23
enclave-modules/ecall-handler/src/enclave_manage/report.rs
This file was deleted.
Oops, something went wrong.
13 changes: 2 additions & 11 deletions
13
enclave-modules/ecall-handler/src/enclave_manage/router.rs
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,23 +1,14 @@ | ||
use crate::enclave_manage::report::create_report; | ||
use crate::enclave_manage::{enclave::generate_enclave_key, Error}; | ||
use crate::prelude::*; | ||
use ecall_commands::{ | ||
CommandContext, CommandResponse, EnclaveManageCommand, EnclaveManageResponse, | ||
}; | ||
use ecall_commands::{CommandResponse, EnclaveManageCommand, EnclaveManageResponse}; | ||
|
||
pub fn dispatch( | ||
cctx: CommandContext, | ||
command: EnclaveManageCommand, | ||
) -> Result<CommandResponse, Error> { | ||
pub fn dispatch(command: EnclaveManageCommand) -> Result<CommandResponse, Error> { | ||
use EnclaveManageCommand::*; | ||
|
||
let res = match command { | ||
GenerateEnclaveKey(input) => CommandResponse::EnclaveManage( | ||
EnclaveManageResponse::GenerateEnclaveKey(generate_enclave_key(input)?), | ||
), | ||
CreateReport(input) => CommandResponse::EnclaveManage(EnclaveManageResponse::CreateReport( | ||
create_report(cctx, input)?, | ||
)), | ||
}; | ||
Ok(res) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.