Skip to content

Commit c71f93b

Browse files
committed
Update Rust deps, fix nested star panics + example
1 parent fbfacc4 commit c71f93b

9 files changed

Lines changed: 67 additions & 17 deletions

build/rust/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/nested_star/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
nested-sta-rs = { path = "../../../../../nested-sta-rs" }
7+
nested-sta-rs = { git = "https://github.com/brave-experiments/nested-sta-rs", rev = "ad9816d4e14964f23680362c65bba8358dbe895a" }
88
cxx = { path = "../../../third_party/rust/cxx/v1/crate" }
99
# Use following cxx dep if compiling example via Makefile
1010
# cxx = "1.0"
@@ -17,3 +17,5 @@ name = "nested_star_cxx"
1717
crate-type = ["rlib"]
1818
# Use following crate type setting if compiling example via Makefile
1919
# crate-type = ["staticlib"]
20+
21+
# Also, if compiling example, rename build.example.rs to build.rs

components/nested_star/example/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ int main(int argc, char** argv) {
3232
return 3;
3333
}
3434

35+
rand_resp.proofs.clear();
36+
3537
auto msg_res = construct_message(rand_resp.points, rand_resp.proofs,
3638
*rrs_res.state, *public_key, {}, 50);
3739
if (msg_res.error.size() > 0) {

components/nested_star/src/lib.rs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ pub fn prepare_measurement(
106106
}
107107

108108
pub fn construct_randomness_request(rrs: &RandomnessRequestStateWrapper) -> Vec<VecU8> {
109-
let res = client::construct_randomness_request(&rrs.0.as_ref().unwrap());
110-
res.into_iter().map(|v| VecU8 { data: v }).collect()
109+
match rrs.0.as_ref() {
110+
Some(rrs) => {
111+
let res = client::construct_randomness_request(rrs);
112+
res.into_iter().map(|v| VecU8 { data: v }).collect()
113+
}
114+
None => Vec::new(),
115+
}
111116
}
112117

113118
pub fn construct_message(
@@ -118,19 +123,29 @@ pub fn construct_message(
118123
aux_bytes: &CxxVector<u8>,
119124
threshold: u32,
120125
) -> ByteDataResult {
121-
let rand_points_vec: Vec<&[u8]> = rand_points.iter().map(|v| v.data.as_slice()).collect();
122-
let rand_proofs_vec: Vec<&[u8]> = rand_proofs.iter().map(|v| v.data.as_slice()).collect();
123-
let res = client::construct_message(
124-
&rand_points_vec,
125-
if !rand_proofs.is_empty() { Some(&rand_proofs_vec) } else { None },
126-
rrs.0.as_ref().unwrap(),
127-
&verification_key.0,
128-
aux_bytes.as_slice(),
129-
threshold,
130-
);
131-
match res {
132-
Ok(data) => ByteDataResult { data, error: String::new() },
133-
Err(e) => ByteDataResult { data: Vec::new(), error: e.to_string() },
126+
match rrs.0.as_ref() {
127+
Some(rrs) => {
128+
let rand_points_vec: Vec<&[u8]> =
129+
rand_points.iter().map(|v| v.data.as_slice()).collect();
130+
let rand_proofs_vec: Vec<&[u8]> =
131+
rand_proofs.iter().map(|v| v.data.as_slice()).collect();
132+
let res = client::construct_message(
133+
&rand_points_vec,
134+
if !rand_proofs.is_empty() { Some(&rand_proofs_vec) } else { None },
135+
rrs,
136+
&verification_key.0,
137+
aux_bytes.as_slice(),
138+
threshold,
139+
);
140+
match res {
141+
Ok(data) => ByteDataResult { data, error: String::new() },
142+
Err(e) => ByteDataResult { data: Vec::new(), error: e.to_string() },
143+
}
144+
}
145+
None => ByteDataResult {
146+
data: Vec::new(),
147+
error: "Randomness request state is not present".to_string(),
148+
},
134149
}
135150
}
136151

components/p3a/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ source_set("unit_tests") {
9393
"//brave/components/brave_referrals/browser",
9494
"//brave/components/nested_star:cxx",
9595
"//brave/components/p3a",
96+
"//brave/components/p3a:buildflags",
9697
"//components/prefs:test_support",
9798
"//content/test:test_support",
9899
"//net:net",

components/p3a/brave_p3a_message_manager_unittest.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class P3AMessageManagerTest : public testing::Test,
6161

6262
protected:
6363
void SetUp() override {
64+
base::Time future_mock_time;
65+
if (base::Time::FromString("2050-01-04", &future_mock_time)) {
66+
task_environment_.AdvanceClock(future_mock_time - base::Time::Now());
67+
}
68+
6469
p3a_config.disable_star_attestation = true;
6570
p3a_config.star_randomness_host = kTestHost;
6671
p3a_config.randomize_upload_interval = false;
@@ -120,7 +125,7 @@ class P3AMessageManagerTest : public testing::Test,
120125
}));
121126

122127
message_manager.reset(new BraveP3AMessageManager(
123-
&local_state, &p3a_config, this, "release", "2022-01-01"));
128+
&local_state, &p3a_config, this, "release", "2099-01-01"));
124129

125130
message_manager->Init(shared_url_loader_factory);
126131

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager_impl.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager_impl.cc
2+
index 9f7a67788141d9a2ddc8095826d0e51b631f6a58..a762b3136c655056a7461b542b1e3762b4db9922 100644
3+
--- a/chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager_impl.cc
4+
+++ b/chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager_impl.cc
5+
@@ -41,6 +41,7 @@ BPKUR::KeyType AlgorithmToType(
6+
case crypto::SignatureVerifier::RSA_PSS_SHA256:
7+
return BPKUR::RSA_KEY;
8+
case crypto::SignatureVerifier::ECDSA_SHA256:
9+
+ case crypto::SignatureVerifier::ECDSA_SHA384:
10+
return BPKUR::EC_KEY;
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/crypto/unexportable_key.cc b/crypto/unexportable_key.cc
2+
index c735638d0e168bb30773d92503e3b8dd5bac7c31..28d6e9c8d221ad863bbc3e1636d3f1721218bdb8 100644
3+
--- a/crypto/unexportable_key.cc
4+
+++ b/crypto/unexportable_key.cc
5+
@@ -75,6 +75,7 @@ void MeasureTPMAvailabilityWin() {
6+
if (algo) {
7+
switch (*algo) {
8+
case SignatureVerifier::SignatureAlgorithm::ECDSA_SHA256:
9+
+ case SignatureVerifier::SignatureAlgorithm::ECDSA_SHA384:
10+
result = TPMSupport::kECDSA;
11+
break;
12+
case SignatureVerifier::SignatureAlgorithm::RSA_PKCS1_SHA256:

0 commit comments

Comments
 (0)