Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crypto/constant_time_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void bssl_constant_time_test_conditional_memcpy(uint8_t dst[256], const uint8_t
}

// Exposes `constant_time_conditional_memxor` to Rust for tests only.
void bssl_constant_time_test_conditional_memxor(uint8_t dst[256],
const uint8_t src[256],
void bssl_constant_time_test_conditional_memxor(uint8_t dst[255],
const uint8_t src[255],
crypto_word_t b) {
constant_time_conditional_memxor(dst, src, 256, b);
constant_time_conditional_memxor(dst, src, 255, b);
}
1 change: 1 addition & 0 deletions crypto/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ static inline void constant_time_conditional_memxor(void *dst, const void *src,
*(v32u8*)&out[i] ^= masks & *(v32u8 const*)&in[i];
}
out += n_vec;
in += n_vec;
n -= n_vec;
#endif
for (size_t i = 0; i < n; i++) {
Expand Down
6 changes: 3 additions & 3 deletions src/tests/bb_bytes_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fn constant_time_conditional_memcpy() -> Result<(), error::Unspecified> {
fn constant_time_conditional_memxor() -> Result<(), error::Unspecified> {
let rng = rand::SystemRandom::new();
for _ in 0..256 {
let mut out = rand::generate::<[u8; 256]>(&rng)?.expose();
let input = rand::generate::<[u8; 256]>(&rng)?.expose();
let mut out = rand::generate::<[u8; 255]>(&rng)?.expose();
let input = rand::generate::<[u8; 255]>(&rng)?.expose();

// Mask to 16 bits to make zero more likely than it would otherwise be.
let b = (rand::generate::<[u8; 1]>(&rng)?.expose()[0] & 0x0f) != 0;
Expand All @@ -66,7 +66,7 @@ fn constant_time_conditional_memxor() -> Result<(), error::Unspecified> {
};

prefixed_extern! {
fn bssl_constant_time_test_conditional_memxor(dst: &mut [u8; 256], src: &[u8; 256], b: BoolMask);
fn bssl_constant_time_test_conditional_memxor(dst: &mut [u8; 255], src: &[u8; 255], b: BoolMask);
}
unsafe {
bssl_constant_time_test_conditional_memxor(
Expand Down
6 changes: 3 additions & 3 deletions src/tests/c_constant_time_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn constant_time_conditional_memcpy() -> Result<(), error::Unspecified> {
fn constant_time_conditional_memxor() -> Result<(), error::Unspecified> {
let rng = rand::SystemRandom::new();
for _ in 0..256 {
let mut out = rand::generate::<[u8; 256]>(&rng)?.expose();
let input = rand::generate::<[u8; 256]>(&rng)?.expose();
let mut out = rand::generate::<[u8; 255]>(&rng)?.expose();
let input = rand::generate::<[u8; 255]>(&rng)?.expose();

// Mask to 16 bits to make zero more likely than it would otherwise be.
let b = (rand::generate::<[u8; 1]>(&rng)?.expose()[0] & 0x0f) != 0;
Expand All @@ -78,7 +78,7 @@ fn constant_time_conditional_memxor() -> Result<(), error::Unspecified> {
};

prefixed_extern! {
fn bssl_constant_time_test_conditional_memxor(dst: &mut [u8; 256], src: &[u8; 256], b: BoolMask);
fn bssl_constant_time_test_conditional_memxor(dst: &mut [u8; 255], src: &[u8; 255], b: BoolMask);
}
unsafe {
bssl_constant_time_test_conditional_memxor(
Expand Down