mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-20 12:02:18 +02:00
Hold enclave attestation as raw bytes
Raw bytes let us avoid one more instance of fallible conversion at runtime. Use the hex_literal crate to make this easier to write in source code.
This commit is contained in:
parent
a51aa5b055
commit
ff1b73b9eb
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1607,6 +1607,8 @@ dependencies = [
|
||||
"bytes",
|
||||
"displaydoc",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"http",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
|
@ -12,6 +12,8 @@ boring = { git = "https://github.com/signalapp/boring", branch = "libsignal" }
|
||||
bytes = "1.4.0"
|
||||
displaydoc = "0.2"
|
||||
futures-util = "0.3.7"
|
||||
hex = "0.4"
|
||||
hex-literal = "0.4.1"
|
||||
http = "0.2.9"
|
||||
http-body-util = "0.1.0-rc.3"
|
||||
hyper = { version = "1.0.0-rc.4", features = ["http1", "http2", "client"] }
|
||||
|
@ -3,14 +3,16 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use crate::utils::basic_authorization;
|
||||
use hex_literal::hex;
|
||||
use tungstenite::client::IntoClientRequest;
|
||||
use tungstenite::handshake::client::Request;
|
||||
|
||||
use crate::utils::basic_authorization;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct CdsiRequest<'a> {
|
||||
base_url: &'a str,
|
||||
mr_enclave: &'a str,
|
||||
mr_enclave: &'a [u8],
|
||||
username: &'a str,
|
||||
password: &'a str,
|
||||
}
|
||||
@ -19,7 +21,10 @@ impl IntoClientRequest for CdsiRequest<'_> {
|
||||
fn into_client_request(self) -> tungstenite::Result<Request> {
|
||||
let url = format!(
|
||||
"wss://{}/{}/{}/{}",
|
||||
&self.base_url, "v1", &self.mr_enclave, "discovery",
|
||||
&self.base_url,
|
||||
"v1",
|
||||
&hex::encode(self.mr_enclave),
|
||||
"discovery",
|
||||
);
|
||||
let auth = basic_authorization(self.username, self.password);
|
||||
let mut request = url.into_client_request()?;
|
||||
@ -33,7 +38,7 @@ impl IntoClientRequest for CdsiRequest<'_> {
|
||||
pub struct Env<'a> {
|
||||
pub chat_host: &'a str,
|
||||
pub cdsi_host: &'a str,
|
||||
pub cdsi_mr_enclave: &'a str,
|
||||
pub cdsi_mr_enclave: &'a [u8],
|
||||
}
|
||||
|
||||
impl<'a> Env<'a> {
|
||||
@ -50,13 +55,13 @@ impl<'a> Env<'a> {
|
||||
pub const STAGING: Env<'static> = Env {
|
||||
chat_host: "chat.staging.signal.org",
|
||||
cdsi_host: "cdsi.staging.signal.org",
|
||||
cdsi_mr_enclave: "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57",
|
||||
cdsi_mr_enclave: &hex!("0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57"),
|
||||
};
|
||||
|
||||
pub const PROD: Env<'static> = Env {
|
||||
chat_host: "chat.signal.org",
|
||||
cdsi_host: "cdsi.signal.org",
|
||||
cdsi_mr_enclave: "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57",
|
||||
cdsi_mr_enclave: &hex!("0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57"),
|
||||
};
|
||||
|
||||
pub mod constants {
|
||||
|
Loading…
Reference in New Issue
Block a user