-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attesteer RPC additions #1201
Merged
OverOrion
merged 22 commits into
integritee-network:master
from
OverOrion:szp/attesteer-rpc
Apr 3, 2023
Merged
Attesteer RPC additions #1201
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
378652e
rpc: add attesteer_forward_dcap_quote call
OverOrion 5862ee0
rpc: add attesteer_forward_ias_attestation_report
OverOrion 3865f59
remove unused variables
OverOrion 296ce9c
enclave-runtime/attestation: remove duplicate code
OverOrion ad76638
enclave-runtime/attestation: extract extrinsic sending
OverOrion 3b21f0a
enclave-runtime/attestaion: refactor generate_dcap_ra_extrinsic_inter…
OverOrion 5f1c56f
attesteer: add attesteer RPC calls to the CLI
OverOrion 6e4a5c1
compiling
OverOrion 9a11f6b
cli: attesteer dcap quote verification takes a filename (to a hex enc…
OverOrion 3c184f4
cli: attesteer ias attestation report takes a filename (to a hex enco…
OverOrion 74c7597
clippy: fix needless borrow
OverOrion 376dc0b
rename: match substrate convention for RPC method names
OverOrion ac5fcc5
rename: SendDCAPQuoteCmd -> SendDcapQuoteCmd
OverOrion 43aa983
rename: SendIASAttestationReportCmd -> SendIasAttestationReportCmd
OverOrion 554eea9
rename: attesteer_callForwardIASAttestationReport -> attesteer_Forwar…
OverOrion a7e5f80
rename: attesteer_callForwardDCAPQuote -> attesteer_ForwardDcapQuote
OverOrion e6cdacc
cli: refactor attesteer comamnds to use a neat match expressions
OverOrion 6875baa
cli: attesteer commands use let-else pattern
OverOrion c920561
cli: attesteer commands send to chain
OverOrion 5b94a6c
rename: attesteer_Forward -> attesteer_forward
OverOrion 2cb4162
Merge branch 'master' into szp/attesteer-rpc
OverOrion 8d75580
Merge branch 'master' into szp/attesteer-rpc
OverOrion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
*/ | ||
|
||
mod send_dcap_quote; | ||
mod send_ias_attestation; | ||
|
||
pub use self::{ | ||
send_dcap_quote::SendDcapQuoteCmd, send_ias_attestation::SendIasAttestationReportCmd, | ||
}; |
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,61 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
*/ | ||
|
||
use crate::{command_utils::get_worker_api_direct, Cli}; | ||
use itc_rpc_client::direct_client::DirectApi; | ||
use itp_rpc::{RpcRequest, RpcResponse, RpcReturnValue}; | ||
use itp_types::DirectRequestStatus; | ||
use itp_utils::FromHexPrefixed; | ||
use log::*; | ||
use std::fs::read_to_string; | ||
|
||
/// Forward DCAP quote for verification. | ||
#[derive(Debug, Clone, Parser)] | ||
pub struct SendDcapQuoteCmd { | ||
/// Hex encoded DCAP quote filename. | ||
quote: String, | ||
} | ||
|
||
impl SendDcapQuoteCmd { | ||
pub fn run(&self, cli: &Cli) { | ||
let direct_api = get_worker_api_direct(cli); | ||
let hex_encoded_quote = match read_to_string(&self.quote) { | ||
Ok(hex_encoded_quote) => hex_encoded_quote, | ||
Err(e) => panic!("Opening hex encoded DCAP quote file failed: {:#?}", e), | ||
}; | ||
|
||
let rpc_method = "attesteer_ForwardDcapQuote".to_owned(); | ||
let jsonrpc_call: String = | ||
RpcRequest::compose_jsonrpc_call(rpc_method, vec![hex_encoded_quote]).unwrap(); | ||
|
||
let rpc_response_str = direct_api.get(&jsonrpc_call).unwrap(); | ||
|
||
// Decode RPC response. | ||
let Ok(rpc_response) = serde_json::from_str::<RpcResponse>(&rpc_response_str) else { | ||
panic!("Can't parse RPC response: '{rpc_response_str}'"); | ||
}; | ||
clangenb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let rpc_return_value = match RpcReturnValue::from_hex(&rpc_response.result) { | ||
Ok(rpc_return_value) => rpc_return_value, | ||
Err(e) => panic!("Failed to decode RpcReturnValue: {:?}", e), | ||
}; | ||
|
||
match rpc_return_value.status { | ||
DirectRequestStatus::Ok => println!("DCAP quote verification succeded."), | ||
_ => error!("DCAP quote verification failed"), | ||
} | ||
} | ||
} |
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,64 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
*/ | ||
|
||
use itc_rpc_client::direct_client::DirectApi; | ||
use itp_rpc::{RpcRequest, RpcResponse, RpcReturnValue}; | ||
use itp_types::DirectRequestStatus; | ||
use itp_utils::FromHexPrefixed; | ||
use log::*; | ||
use std::fs::read_to_string; | ||
|
||
use crate::{command_utils::get_worker_api_direct, Cli}; | ||
|
||
/// Forward IAS attestation report for verification. | ||
#[derive(Debug, Clone, Parser)] | ||
pub struct SendIasAttestationReportCmd { | ||
/// Hex encoded IAS attestation report filename. | ||
report: String, | ||
} | ||
|
||
impl SendIasAttestationReportCmd { | ||
pub fn run(&self, cli: &Cli) { | ||
let direct_api = get_worker_api_direct(cli); | ||
let hex_encoded_report = match read_to_string(&self.report) { | ||
Ok(hex_encoded_report) => hex_encoded_report, | ||
Err(e) => panic!("Opening hex encoded IAS attestation report file failed: {:#?}", e), | ||
}; | ||
|
||
//let request = Request { shard, cyphertext: hex_encoded_quote.to_vec() }; | ||
|
||
let rpc_method = "attesteer_ForwardIasAttestationReport".to_owned(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, small 'f' please :) |
||
let jsonrpc_call: String = | ||
RpcRequest::compose_jsonrpc_call(rpc_method, vec![hex_encoded_report]).unwrap(); | ||
|
||
let rpc_response_str = direct_api.get(&jsonrpc_call).unwrap(); | ||
|
||
// Decode RPC response. | ||
let Ok(rpc_response) = serde_json::from_str::<RpcResponse>(&rpc_response_str) else { | ||
panic!("Can't parse RPC response: '{rpc_response_str}'"); | ||
}; | ||
let rpc_return_value = match RpcReturnValue::from_hex(&rpc_response.result) { | ||
Ok(rpc_return_value) => rpc_return_value, | ||
Err(e) => panic!("Failed to decode RpcReturnValue: {:?}", e), | ||
}; | ||
|
||
match rpc_return_value.status { | ||
DirectRequestStatus::Ok => println!("IAS attestation report verification succeded."), | ||
_ => error!("IAS attestation report verification failed"), | ||
clangenb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
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,41 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
*/ | ||
|
||
use crate::Cli; | ||
|
||
use self::commands::{SendDcapQuoteCmd, SendIasAttestationReportCmd}; | ||
|
||
mod commands; | ||
|
||
/// Attesteer subcommands for the CLI. | ||
#[derive(Debug, clap::Subcommand)] | ||
pub enum AttesteerCommand { | ||
/// Forward DCAP quote for verification. | ||
SendDCAPQuote(SendDcapQuoteCmd), | ||
|
||
/// Forward IAS attestation report for verification. | ||
SendIASAttestationReport(SendIasAttestationReportCmd), | ||
} | ||
|
||
impl AttesteerCommand { | ||
pub fn run(&self, cli: &Cli) { | ||
match self { | ||
AttesteerCommand::SendDCAPQuote(cmd) => cmd.run(cli), | ||
AttesteerCommand::SendIASAttestationReport(cmd) => cmd.run(cli), | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small 'f' please :)