Skip to content

Commit 65a4e0f

Browse files
committed
code review
1 parent ec2ca6c commit 65a4e0f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/rust/src/backend/kdf.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ impl ConcatKdfHmac {
17051705
struct KbkdfHmac {
17061706
algorithm: pyo3::Py<pyo3::PyAny>,
17071707
length: usize,
1708-
params: KbkdfValidatedParams,
1708+
params: KbkdfParams,
17091709
used: bool,
17101710
}
17111711

@@ -1717,7 +1717,7 @@ fn int_to_bytes(value: usize, length: usize) -> Vec<u8> {
17171717
bytes
17181718
}
17191719

1720-
struct KbkdfValidatedParams {
1720+
struct KbkdfParams {
17211721
rlen: usize,
17221722
llen: Option<usize>,
17231723
location: pyo3::Py<pyo3::PyAny>,
@@ -1738,7 +1738,7 @@ fn validate_kbkdf_parameters(
17381738
context: Option<pyo3::Py<pyo3::types::PyBytes>>,
17391739
fixed: Option<pyo3::Py<pyo3::types::PyBytes>>,
17401740
break_location: Option<usize>,
1741-
) -> CryptographyResult<KbkdfValidatedParams> {
1741+
) -> CryptographyResult<KbkdfParams> {
17421742
let mode_bound = mode.bind(py);
17431743
let mode_type = crate::types::KBKDF_MODE.get(py)?;
17441744
if !mode_bound.is_instance(&mode_type)? {
@@ -1792,15 +1792,13 @@ fn validate_kbkdf_parameters(
17921792
));
17931793
}
17941794

1795-
if let Some(l) = llen {
1796-
if l == 0 {
1797-
return Err(CryptographyError::from(
1798-
pyo3::exceptions::PyValueError::new_err("llen must be non-zero"),
1799-
));
1800-
}
1795+
if llen == Some(0) {
1796+
return Err(CryptographyError::from(
1797+
pyo3::exceptions::PyValueError::new_err("llen must be non-zero"),
1798+
));
18011799
}
18021800

1803-
Ok(KbkdfValidatedParams {
1801+
Ok(KbkdfParams {
18041802
rlen,
18051803
llen,
18061804
location,

0 commit comments

Comments
 (0)