Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a47eb7d

Browse filesBrowse files
committed
Use constant_time_eq instead of our bespoke implementation
1 parent a917da3 commit a47eb7d
Copy full SHA for a47eb7d

File tree

6 files changed

+11
-62
lines changed
Filter options

6 files changed

+11
-62
lines changed

‎Cargo.lock

Copy file name to clipboardExpand all lines: Cargo.lock
+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎common/Cargo.toml

Copy file name to clipboardExpand all lines: common/Cargo.toml
-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ unicode_names2 = { workspace = true }
3434
lock_api = "0.4"
3535
radium = "0.7"
3636
siphasher = "1"
37-
volatile = "0.3"
3837

3938
[target.'cfg(windows)'.dependencies]
4039
widestring = { workspace = true }

‎common/src/cmp.rs

Copy file name to clipboardExpand all lines: common/src/cmp.rs
-48
This file was deleted.

‎common/src/lib.rs

Copy file name to clipboardExpand all lines: common/src/lib.rs
-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub mod atomic;
1010
pub mod borrow;
1111
pub mod boxvec;
1212
pub mod cformat;
13-
pub mod cmp;
1413
#[cfg(any(unix, windows, target_os = "wasi"))]
1514
pub mod crt_fd;
1615
pub mod encodings;

‎vm/Cargo.toml

Copy file name to clipboardExpand all lines: vm/Cargo.toml
+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ bstr = { workspace = true }
5151
cfg-if = { workspace = true }
5252
crossbeam-utils = { workspace = true }
5353
chrono = { workspace = true, features = ["wasmbind"] }
54+
constant_time_eq = { workspace = true }
5455
flame = { workspace = true, optional = true }
5556
getrandom = { workspace = true }
5657
hex = { workspace = true }

‎vm/src/stdlib/operator.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/operator.rs
+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pub(crate) use _operator::make_module;
22

33
#[pymodule]
44
mod _operator {
5-
use crate::common::cmp;
65
use crate::{
76
AsObject, Py, PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine,
87
builtins::{PyInt, PyIntRef, PyStr, PyStrRef, PyTupleRef, PyTypeRef},
@@ -13,6 +12,7 @@ mod _operator {
1312
recursion::ReprGuard,
1413
types::{Callable, Constructor, PyComparisonOp, Representable},
1514
};
15+
use constant_time_eq::constant_time_eq;
1616

1717
#[pyfunction]
1818
fn lt(a: PyObjectRef, b: PyObjectRef, vm: &VirtualMachine) -> PyResult {
@@ -328,11 +328,9 @@ mod _operator {
328328
"comparing strings with non-ASCII characters is not supported".to_owned(),
329329
));
330330
}
331-
cmp::timing_safe_cmp(a.as_bytes(), b.as_bytes())
332-
}
333-
(Either::B(a), Either::B(b)) => {
334-
a.with_ref(|a| b.with_ref(|b| cmp::timing_safe_cmp(a, b)))
331+
constant_time_eq(a.as_bytes(), b.as_bytes())
335332
}
333+
(Either::B(a), Either::B(b)) => a.with_ref(|a| b.with_ref(|b| constant_time_eq(a, b))),
336334
_ => {
337335
return Err(vm.new_type_error(
338336
"unsupported operand types(s) or combination of types".to_owned(),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.