Skip to content

Commit

Permalink
Improve code readability
Browse files Browse the repository at this point in the history
Co-authored-by: Arthur Gautier <[email protected]>
  • Loading branch information
bkstein and baloo authored Dec 4, 2023
1 parent a3a6708 commit ee851f5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cms/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,15 +783,11 @@ where
let cek_byte_count: u8 = content_encryption_key.len().try_into().map_err(|_| {
Error::Builder("Content encryption key length must not exceed 255".to_string())
})?;
let mut check_value = vec![
0xff ^ content_encryption_key[0],
0xff ^ content_encryption_key[1],
0xff ^ content_encryption_key[2],
];

let mut wrapped_cek: Vec<u8> = Vec::new();
let mut wrapped_cek: Vec<u8> = Vec::with_capacity(4 + padding_length);
wrapped_cek.insert(0, cek_byte_count);
wrapped_cek.append(&mut check_value);
wrapped_cek.insert(0xff ^ content_encryption_key[0]);
wrapped_cek.insert(0xff ^ content_encryption_key[1]);
wrapped_cek.insert(0xff ^ content_encryption_key[2]);
if padding_length > 0 {
let mut padding = vec![0_u8; padding_length];
self.rng.fill_bytes(padding.as_mut_slice());
Expand Down

0 comments on commit ee851f5

Please sign in to comment.