Skip to content
Draft
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
8 changes: 4 additions & 4 deletions crypto/s2n_aead_cipher_aes_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ static S2N_RESULT s2n_tls12_aead_cipher_aes128_gcm_set_ktls_info(
RESULT_ENSURE_LTE(sizeof(crypto_info->iv), in->seq.size);
RESULT_CHECKED_MEMCPY(crypto_info->iv, in->seq.data, sizeof(crypto_info->iv));

RESULT_GUARD_POSIX(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
RESULT_GUARD(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
sizeof(s2n_ktls_crypto_info_tls12_aes_gcm_128)));
return S2N_RESULT_OK;
}
Expand All @@ -445,7 +445,7 @@ static S2N_RESULT s2n_tls12_aead_cipher_aes256_gcm_set_ktls_info(
RESULT_ENSURE_LTE(sizeof(crypto_info->iv), in->seq.size);
RESULT_CHECKED_MEMCPY(crypto_info->iv, in->seq.data, sizeof(crypto_info->iv));

RESULT_GUARD_POSIX(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
RESULT_GUARD(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
sizeof(s2n_ktls_crypto_info_tls12_aes_gcm_256)));
return S2N_RESULT_OK;
}
Expand Down Expand Up @@ -481,7 +481,7 @@ static S2N_RESULT s2n_tls13_aead_cipher_aes128_gcm_set_ktls_info(
RESULT_ENSURE_LTE(sizeof(crypto_info->iv), iv_remainder);
RESULT_CHECKED_MEMCPY(crypto_info->iv, in->iv.data + salt_size, sizeof(crypto_info->iv));

RESULT_GUARD_POSIX(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
RESULT_GUARD(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
sizeof(s2n_ktls_crypto_info_tls12_aes_gcm_128)));
return S2N_RESULT_OK;
}
Expand Down Expand Up @@ -511,7 +511,7 @@ static S2N_RESULT s2n_tls13_aead_cipher_aes256_gcm_set_ktls_info(
RESULT_ENSURE_LTE(sizeof(crypto_info->iv), iv_remainder);
RESULT_CHECKED_MEMCPY(crypto_info->iv, in->iv.data + salt_size, sizeof(crypto_info->iv));

RESULT_GUARD_POSIX(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
RESULT_GUARD(s2n_blob_init(&out->value, (uint8_t *) (void *) crypto_info,
sizeof(s2n_ktls_crypto_info_tls12_aes_gcm_256)));
return S2N_RESULT_OK;
}
Expand Down
12 changes: 6 additions & 6 deletions crypto/s2n_certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int s2n_create_cert_chain_from_stuffer(struct s2n_cert_chain *cert_chain_out, st

DEFER_CLEANUP(struct s2n_blob mem = { 0 }, s2n_free);
POSIX_GUARD(s2n_alloc(&mem, sizeof(struct s2n_cert)));
POSIX_GUARD(s2n_blob_zero(&mem));
POSIX_GUARD_RESULT(s2n_blob_zero(&mem));

struct s2n_cert *new_node = (struct s2n_cert *) (void *) mem.data;
POSIX_GUARD(s2n_alloc(&new_node->raw, s2n_stuffer_data_available(&cert_out_stuffer)));
Expand Down Expand Up @@ -173,15 +173,15 @@ struct s2n_cert_chain_and_key *s2n_cert_chain_and_key_new(void)
{
DEFER_CLEANUP(struct s2n_blob chain_and_key_mem = { 0 }, s2n_free);
PTR_GUARD_POSIX(s2n_alloc(&chain_and_key_mem, sizeof(struct s2n_cert_chain_and_key)));
PTR_GUARD_POSIX(s2n_blob_zero(&chain_and_key_mem));
PTR_GUARD_RESULT(s2n_blob_zero(&chain_and_key_mem));

DEFER_CLEANUP(struct s2n_blob cert_chain_mem = { 0 }, s2n_free);
PTR_GUARD_POSIX(s2n_alloc(&cert_chain_mem, sizeof(struct s2n_cert_chain)));
PTR_GUARD_POSIX(s2n_blob_zero(&cert_chain_mem));
PTR_GUARD_RESULT(s2n_blob_zero(&cert_chain_mem));

DEFER_CLEANUP(struct s2n_blob pkey_mem = { 0 }, s2n_free);
PTR_GUARD_POSIX(s2n_alloc(&pkey_mem, sizeof(s2n_cert_private_key)));
PTR_GUARD_POSIX(s2n_blob_zero(&pkey_mem));
PTR_GUARD_RESULT(s2n_blob_zero(&pkey_mem));

DEFER_CLEANUP(struct s2n_array *cn_names = NULL, s2n_array_free_p);
cn_names = s2n_array_new(sizeof(struct s2n_blob));
Expand Down Expand Up @@ -242,7 +242,7 @@ int s2n_cert_chain_and_key_load_sans(struct s2n_cert_chain_and_key *chain_and_ke
POSIX_CHECKED_MEMCPY(san_blob->data, san_str, san_str_len);
san_blob->size = san_str_len;
/* normalize san_blob to lowercase */
POSIX_GUARD(s2n_blob_char_to_lower(san_blob));
POSIX_GUARD_RESULT(s2n_blob_char_to_lower(san_blob));
}
}

Expand Down Expand Up @@ -315,7 +315,7 @@ int s2n_cert_chain_and_key_load_cns(struct s2n_cert_chain_and_key *chain_and_key
POSIX_CHECKED_MEMCPY(cn_name->data, utf8_str, utf8_out_len);
cn_name->size = utf8_out_len;
/* normalize cn_name to lowercase */
POSIX_GUARD(s2n_blob_char_to_lower(cn_name));
POSIX_GUARD_RESULT(s2n_blob_char_to_lower(cn_name));
}
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_composite_cipher_aes_sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static int s2n_composite_cipher_aes_sha_initial_hmac(struct s2n_session_key *key
#else
uint8_t ctrl_buf[S2N_TLS12_AAD_LEN];
struct s2n_blob ctrl_blob = { 0 };
POSIX_GUARD(s2n_blob_init(&ctrl_blob, ctrl_buf, S2N_TLS12_AAD_LEN));
POSIX_GUARD_RESULT(s2n_blob_init(&ctrl_blob, ctrl_buf, S2N_TLS12_AAD_LEN));
struct s2n_stuffer ctrl_stuffer = { 0 };
POSIX_GUARD(s2n_stuffer_init(&ctrl_stuffer, &ctrl_blob));

Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static S2N_RESULT s2n_drbg_bits(struct s2n_drbg *drbg, struct s2n_blob *out)
RESULT_ENSURE_REF(out);

struct s2n_blob value = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&value, drbg->v, sizeof(drbg->v)));
RESULT_GUARD(s2n_blob_init(&value, drbg->v, sizeof(drbg->v)));
uint32_t block_aligned_size = out->size - (out->size % S2N_DRBG_BLOCK_SIZE);

/* Per NIST SP800-90A 10.2.1.2: */
Expand Down Expand Up @@ -190,7 +190,7 @@ S2N_RESULT s2n_drbg_instantiate(struct s2n_drbg *drbg, struct s2n_blob *personal

/* Copy the personalization string */
RESULT_STACK_BLOB(ps, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
RESULT_GUARD_POSIX(s2n_blob_zero(&ps));
RESULT_GUARD(s2n_blob_zero(&ps));

RESULT_CHECKED_MEMCPY(ps.data, personalization_string->data, MIN(ps.size, personalization_string->size));

Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int s2n_custom_hkdf(struct s2n_hmac_state *hmac, s2n_hmac_algorithm alg,
{
uint8_t prk_pad[MAX_DIGEST_SIZE] = { 0 };
struct s2n_blob pseudo_rand_key = { 0 };
POSIX_GUARD(s2n_blob_init(&pseudo_rand_key, prk_pad, sizeof(prk_pad)));
POSIX_GUARD_RESULT(s2n_blob_init(&pseudo_rand_key, prk_pad, sizeof(prk_pad)));

POSIX_GUARD(s2n_custom_hkdf_extract(hmac, alg, salt, key, &pseudo_rand_key));
POSIX_GUARD(s2n_custom_hkdf_expand(hmac, alg, &pseudo_rand_key, info, output));
Expand Down Expand Up @@ -360,7 +360,7 @@ int s2n_hkdf_expand_label(struct s2n_hmac_state *hmac, s2n_hmac_algorithm alg, c

POSIX_ENSURE_LTE(label->size, S2N_MAX_HKDF_EXPAND_LABEL_LENGTH);

POSIX_GUARD(s2n_blob_init(&hkdf_label_blob, hkdf_label_buf, sizeof(hkdf_label_buf)));
POSIX_GUARD_RESULT(s2n_blob_init(&hkdf_label_blob, hkdf_label_buf, sizeof(hkdf_label_buf)));
POSIX_GUARD(s2n_stuffer_init(&hkdf_label, &hkdf_label_blob));
POSIX_GUARD(s2n_stuffer_write_uint16(&hkdf_label, output->size));
POSIX_GUARD(s2n_stuffer_write_uint8(&hkdf_label, label->size + sizeof("tls13 ") - 1));
Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_pkey_evp.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ int s2n_pkey_evp_decrypt(const struct s2n_pkey *key, struct s2n_blob *in, struct
/* RSA decryption requires more output memory than the size of the final decrypted message */
struct s2n_blob buffer = { 0 };
uint8_t buffer_bytes[4096] = { 0 };
POSIX_GUARD(s2n_blob_init(&buffer, buffer_bytes, sizeof(buffer_bytes)));
POSIX_GUARD_RESULT(s2n_blob_init(&buffer, buffer_bytes, sizeof(buffer_bytes)));
POSIX_ENSURE(out->size <= buffer.size, S2N_ERR_NOMEM);
POSIX_ENSURE(expected_size <= buffer.size, S2N_ERR_NOMEM);

Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_prf_libcrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ S2N_RESULT s2n_prf_libcrypto(struct s2n_connection *conn,

if (seed_b != NULL) {
struct s2n_blob seed_b_blob = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&seed_b_blob, seed_b->data, seed_b->size));
RESULT_GUARD(s2n_blob_init(&seed_b_blob, seed_b->data, seed_b->size));
RESULT_GUARD_POSIX(s2n_stuffer_init_written(&seed_b_stuffer, &seed_b_blob));

if (seed_c != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_tls13_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ int s2n_tls13_keys_init(struct s2n_tls13_keys *keys, s2n_hmac_algorithm alg)
keys->hmac_algorithm = alg;
POSIX_GUARD(s2n_hmac_hash_alg(alg, &keys->hash_algorithm));
POSIX_GUARD(s2n_hash_digest_size(keys->hash_algorithm, &keys->size));
POSIX_GUARD(s2n_blob_init(&keys->extract_secret, keys->extract_secret_bytes, keys->size));
POSIX_GUARD(s2n_blob_init(&keys->derive_secret, keys->derive_secret_bytes, keys->size));
POSIX_GUARD_RESULT(s2n_blob_init(&keys->extract_secret, keys->extract_secret_bytes, keys->size));
POSIX_GUARD_RESULT(s2n_blob_init(&keys->derive_secret, keys->derive_secret_bytes, keys->size));
POSIX_GUARD(s2n_hmac_new(&keys->hmac));

return 0;
Expand Down
2 changes: 1 addition & 1 deletion stuffer/s2n_stuffer_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int s2n_stuffer_alloc_ro_from_fd(struct s2n_stuffer *stuffer, int rfd)
POSIX_ENSURE(map != MAP_FAILED, S2N_ERR_MMAP);

struct s2n_blob b = { 0 };
POSIX_GUARD(s2n_blob_init(&b, map, (uint32_t) st.st_size));
POSIX_GUARD_RESULT(s2n_blob_init(&b, map, (uint32_t) st.st_size));
return s2n_stuffer_init(stuffer, &b);
}

Expand Down
4 changes: 2 additions & 2 deletions stuffer/s2n_stuffer_hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static S2N_RESULT s2n_stuffer_hex_read_n_bytes(struct s2n_stuffer *stuffer, uint

uint8_t hex_data[16] = { 0 };
struct s2n_blob b = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&b, hex_data, n * 2));
RESULT_GUARD(s2n_blob_init(&b, hex_data, n * 2));

RESULT_ENSURE_REF(stuffer);
RESULT_ENSURE(s2n_stuffer_read(stuffer, &b) == S2N_SUCCESS, S2N_ERR_BAD_HEX);
Expand Down Expand Up @@ -145,7 +145,7 @@ static S2N_RESULT s2n_stuffer_hex_write_n_bytes(struct s2n_stuffer *stuffer, uin

uint8_t hex_data[16] = { 0 };
struct s2n_blob b = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&b, hex_data, n * 2));
RESULT_GUARD(s2n_blob_init(&b, hex_data, n * 2));

for (size_t i = b.size; i > 0; i--) {
b.data[i - 1] = value_to_hex[u & 0x0f];
Expand Down
2 changes: 1 addition & 1 deletion stuffer/s2n_stuffer_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int s2n_stuffer_init_ro_from_string(struct s2n_stuffer *stuffer, uint8_t *data,
POSIX_ENSURE_REF(data);

struct s2n_blob data_blob = { 0 };
POSIX_GUARD(s2n_blob_init(&data_blob, data, length));
POSIX_GUARD_RESULT(s2n_blob_init(&data_blob, data, length));

POSIX_GUARD(s2n_stuffer_init(stuffer, &data_blob));
POSIX_GUARD(s2n_stuffer_skip_write(stuffer, length));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void s2n_blob_char_to_lower_harness()
save_byte_from_blob(blob, &old_byte_from_blob);

/* Operation under verification. */
if (s2n_blob_char_to_lower(blob) == S2N_SUCCESS) {
if (s2n_result_is_ok(s2n_blob_char_to_lower(blob))) {
if (blob->size != 0) {
if (old_byte_from_blob.byte >= 'A' && old_byte_from_blob.byte <= 'Z') {
assert(blob->data[ old_byte_from_blob.idx ] == (old_byte_from_blob.byte + ('a' - 'A')));
Expand Down
4 changes: 3 additions & 1 deletion tests/cbmc/proofs/s2n_blob_init/s2n_blob_init_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ void s2n_blob_init_harness()
__CPROVER_assume(S2N_IMPLIES(size != 0, data != NULL));

/* Operation under verification. */
if (s2n_blob_init(blob, data, size) == S2N_SUCCESS) { assert(s2n_result_is_ok(s2n_blob_validate(blob))); }
if (s2n_result_is_ok(s2n_blob_init(blob, data, size))) {
assert(s2n_result_is_ok(s2n_blob_validate(blob)));
}
}
2 changes: 1 addition & 1 deletion tests/cbmc/proofs/s2n_blob_slice/s2n_blob_slice_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void s2n_blob_slice_harness()
save_byte_from_blob(slice, &old_byte_from_slice);

/* Operation under verification. */
if (s2n_blob_slice(blob, slice, offset, size) == S2N_SUCCESS) {
if (s2n_result_is_ok(s2n_blob_slice(blob, slice, offset, size))) {
assert(blob->size >= offset + size);
assert(slice->size == size);
assert(slice->growable == 0);
Expand Down
4 changes: 3 additions & 1 deletion tests/cbmc/proofs/s2n_blob_zero/s2n_blob_zero_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void s2n_blob_zero_harness()
__CPROVER_assume(s2n_result_is_ok(s2n_blob_validate(blob)));

/* Operation under verification. */
if (s2n_blob_zero(blob) == S2N_SUCCESS && blob->size != 0) { assert_all_zeroes(blob->data, blob->size); }
if (s2n_result_is_ok(s2n_blob_zero(blob))) {
assert_all_zeroes(blob->data, blob->size);
}
assert(s2n_result_is_ok(s2n_blob_validate(blob)));
}
2 changes: 1 addition & 1 deletion tests/fuzz/s2n_deserialize_resumption_state_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int s2n_fuzz_test(const uint8_t *buf, size_t len)

uint8_t test_data[] = "test psk identity";
struct s2n_blob test_blob = { 0 };
POSIX_GUARD(s2n_blob_init(&test_blob, test_data, sizeof(test_data)));
POSIX_GUARD_RESULT(s2n_blob_init(&test_blob, test_data, sizeof(test_data)));

/* Ignore the result of this function */
s2n_result_ignore(s2n_deserialize_resumption_state(server_conn, &test_blob, &fuzzed_ticket));
Expand Down
4 changes: 2 additions & 2 deletions tests/testlib/s2n_connection_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ S2N_RESULT s2n_connection_set_secrets(struct s2n_connection *conn)

uint8_t client_key_bytes[S2N_TLS13_SECRET_MAX_LEN] = "client key";
struct s2n_blob client_key = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&client_key, client_key_bytes, cipher->key_material_size));
RESULT_GUARD(s2n_blob_init(&client_key, client_key_bytes, cipher->key_material_size));
RESULT_GUARD(cipher->init(&conn->secure->client_key));
RESULT_GUARD(cipher->set_encryption_key(&conn->secure->client_key, &client_key));

uint8_t server_key_bytes[S2N_TLS13_SECRET_MAX_LEN] = "server key";
struct s2n_blob server_key = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&server_key, server_key_bytes, cipher->key_material_size));
RESULT_GUARD(s2n_blob_init(&server_key, server_key_bytes, cipher->key_material_size));
RESULT_GUARD(cipher->init(&conn->secure->server_key));
RESULT_GUARD(cipher->set_encryption_key(&conn->secure->server_key, &server_key));

Expand Down
2 changes: 1 addition & 1 deletion tests/testlib/s2n_io_testlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ S2N_RESULT s2n_test_new_iovecs(struct s2n_test_iovecs *iovecs,

struct s2n_blob iovecs_mem = { 0 };
RESULT_GUARD_POSIX(s2n_alloc(&iovecs_mem, sizeof(struct iovec) * iovecs_count));
RESULT_GUARD_POSIX(s2n_blob_zero(&iovecs_mem));
RESULT_GUARD(s2n_blob_zero(&iovecs_mem));
iovecs->iovecs = (struct iovec *) (void *) iovecs_mem.data;
iovecs->iovecs_count = iovecs_count;

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/s2n_3des_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ int main(int argc, char **argv)
uint8_t mac_key[] = "sample mac key";
uint8_t des3_key[] = "12345678901234567890123";
struct s2n_blob des3 = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&des3, des3_key, sizeof(des3_key)));
EXPECT_OK(s2n_blob_init(&des3, des3_key, sizeof(des3_key)));
uint8_t random_data[S2N_DEFAULT_FRAGMENT_LENGTH + 1];
struct s2n_blob r = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&r, random_data, sizeof(random_data)));
EXPECT_OK(s2n_blob_init(&r, random_data, sizeof(random_data)));

BEGIN_TEST();
EXPECT_SUCCESS(s2n_disable_tls13_in_test());
Expand All @@ -61,7 +61,7 @@ int main(int argc, char **argv)

for (int i = 0; i <= S2N_DEFAULT_FRAGMENT_LENGTH + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

EXPECT_SUCCESS(s2n_stuffer_wipe(&conn->out));
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/s2n_aead_aes_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ int main(int argc, char **argv)
uint8_t aes128_key[] = "123456789012345";
uint8_t aes256_key[] = "1234567890123456789012345678901";
struct s2n_blob aes128 = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&aes128, aes128_key, sizeof(aes128_key)));
EXPECT_OK(s2n_blob_init(&aes128, aes128_key, sizeof(aes128_key)));
struct s2n_blob aes256 = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&aes256, aes256_key, sizeof(aes256_key)));
EXPECT_OK(s2n_blob_init(&aes256, aes256_key, sizeof(aes256_key)));
struct s2n_blob r = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&r, random_data, sizeof(random_data)));
EXPECT_OK(s2n_blob_init(&r, random_data, sizeof(random_data)));

BEGIN_TEST();
EXPECT_SUCCESS(s2n_disable_tls13_in_test());
Expand All @@ -75,7 +75,7 @@ int main(int argc, char **argv)
int max_fragment = S2N_SMALL_FRAGMENT_LENGTH;
for (size_t i = 0; i <= max_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

/* TLS packet on the wire using AES-GCM:
Expand Down Expand Up @@ -273,7 +273,7 @@ int main(int argc, char **argv)

for (size_t i = 0; i <= max_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

EXPECT_SUCCESS(s2n_connection_wipe(conn));
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/s2n_aead_chacha20_poly1305_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ int main(int argc, char **argv)
uint8_t random_data[S2N_SMALL_FRAGMENT_LENGTH + 1];
uint8_t chacha20_poly1305_key_data[] = "1234567890123456789012345678901";
struct s2n_blob chacha20_poly1305_key = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&chacha20_poly1305_key, chacha20_poly1305_key_data, sizeof(chacha20_poly1305_key_data)));
EXPECT_OK(s2n_blob_init(&chacha20_poly1305_key, chacha20_poly1305_key_data, sizeof(chacha20_poly1305_key_data)));
struct s2n_blob r = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&r, random_data, sizeof(random_data)));
EXPECT_OK(s2n_blob_init(&r, random_data, sizeof(random_data)));

BEGIN_TEST();
EXPECT_SUCCESS(s2n_disable_tls13_in_test());
Expand All @@ -78,7 +78,7 @@ int main(int argc, char **argv)
int max_fragment = S2N_SMALL_FRAGMENT_LENGTH;
for (size_t i = 0; i <= max_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

/* TLS packet on the wire using ChaCha20-Poly1305:
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/s2n_aes_sha_composite_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ int main(int argc, char **argv)
uint8_t aes128_key[] = "123456789012345";
uint8_t aes256_key[] = "1234567890123456789012345678901";
struct s2n_blob aes128 = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&aes128, aes128_key, sizeof(aes128_key)));
EXPECT_OK(s2n_blob_init(&aes128, aes128_key, sizeof(aes128_key)));
struct s2n_blob aes256 = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&aes256, aes256_key, sizeof(aes256_key)));
EXPECT_OK(s2n_blob_init(&aes256, aes256_key, sizeof(aes256_key)));
struct s2n_blob r = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&r, random_data, sizeof(random_data)));
EXPECT_OK(s2n_blob_init(&r, random_data, sizeof(random_data)));
/* Stores explicit IVs used in each test case to validate uniqueness. */
uint8_t existing_explicit_ivs[S2N_DEFAULT_FRAGMENT_LENGTH + 2][S2N_TLS_MAX_IV_LEN];

Expand Down Expand Up @@ -92,7 +92,7 @@ int main(int argc, char **argv)
for (int j = 0; j < 3; j++) {
for (size_t i = 0; i <= max_aligned_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

EXPECT_SUCCESS(s2n_connection_wipe(conn));
Expand Down Expand Up @@ -168,7 +168,7 @@ int main(int argc, char **argv)
for (int j = 0; j < 3; j++) {
for (int i = 0; i <= max_aligned_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

EXPECT_SUCCESS(s2n_connection_wipe(conn));
Expand Down Expand Up @@ -244,7 +244,7 @@ int main(int argc, char **argv)
for (int j = 0; j < 3; j++) {
for (int i = 0; i < max_aligned_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

EXPECT_SUCCESS(s2n_connection_wipe(conn));
Expand Down Expand Up @@ -320,7 +320,7 @@ int main(int argc, char **argv)
for (int j = 0; j < 3; j++) {
for (int i = 0; i <= max_aligned_fragment + 1; i++) {
struct s2n_blob in = { 0 };
EXPECT_SUCCESS(s2n_blob_init(&in, random_data, i));
EXPECT_OK(s2n_blob_init(&in, random_data, i));
int bytes_written = 0;

EXPECT_SUCCESS(s2n_connection_wipe(conn));
Expand Down
Loading
Loading