Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: switch s2n_blob to use S2N_RESULT #4448

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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 @@ -422,7 +422,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 @@ -449,7 +449,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 @@ -485,7 +485,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 @@ -515,7 +515,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 @@ -58,7 +58,7 @@ int s2n_create_cert_chain_from_stuffer(struct s2n_cert_chain *cert_chain_out, st
}
struct s2n_blob mem = { 0 };
POSIX_GUARD(s2n_alloc(&mem, sizeof(struct s2n_cert)));
POSIX_GUARD(s2n_blob_zero(&mem));
POSIX_GUARD_RESULT(s2n_blob_zero(&mem));
new_node = (struct s2n_cert *) (void *) mem.data;

if (s2n_alloc(&new_node->raw, s2n_stuffer_data_available(&cert_out_stuffer)) != S2N_SUCCESS) {
Expand Down Expand Up @@ -188,15 +188,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 @@ -257,7 +257,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 @@ -330,7 +330,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 @@ -62,7 +62,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 @@ -189,7 +189,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
2 changes: 1 addition & 1 deletion crypto/s2n_ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int s2n_ecdsa_sign(const struct s2n_pkey *priv, s2n_signature_algorithm s
POSIX_GUARD(s2n_hash_digest(digest, digest_out, digest_length));

struct s2n_blob digest_blob = { 0 };
POSIX_GUARD(s2n_blob_init(&digest_blob, digest_out, digest_length));
POSIX_GUARD_RESULT(s2n_blob_init(&digest_blob, digest_out, digest_length));
POSIX_GUARD(s2n_ecdsa_sign_digest(priv, &digest_blob, signature));

POSIX_GUARD(s2n_hash_reset(digest));
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 @@ -259,7 +259,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
4 changes: 2 additions & 2 deletions crypto/s2n_rsa_signing.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int s2n_rsa_pkcs1v15_sign(const struct s2n_pkey *priv, struct s2n_hash_state *di
POSIX_GUARD(s2n_hash_digest(digest, digest_out, digest_length));

struct s2n_blob digest_blob = { 0 };
POSIX_GUARD(s2n_blob_init(&digest_blob, digest_out, digest_length));
POSIX_GUARD_RESULT(s2n_blob_init(&digest_blob, digest_out, digest_length));
POSIX_GUARD(s2n_rsa_pkcs1v15_sign_digest(priv, digest->alg, &digest_blob, signature));

return S2N_SUCCESS;
Expand Down Expand Up @@ -176,7 +176,7 @@ int s2n_rsa_pss_sign(const struct s2n_pkey *priv, struct s2n_hash_state *digest,
POSIX_GUARD(s2n_hash_digest(digest, digest_data, digest_length));

struct s2n_blob digest_blob = { 0 };
POSIX_GUARD(s2n_blob_init(&digest_blob, digest_data, digest_length));
POSIX_GUARD_RESULT(s2n_blob_init(&digest_blob, digest_data, digest_length));
POSIX_GUARD(s2n_rsa_pss_sign_digest(priv, digest->alg, &digest_blob, signature_out));

return S2N_SUCCESS;
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
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
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 @@ -56,7 +56,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 @@ -295,13 +295,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_POSIX(cipher->init(&conn->secure->client_key));
RESULT_GUARD_POSIX(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_POSIX(cipher->init(&conn->secure->server_key));
RESULT_GUARD_POSIX(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/testlib/s2n_pq_kat_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static S2N_RESULT s2n_drbg_generate_for_pq_kat_tests(struct s2n_drbg *drbg, stru
RESULT_ENSURE_REF(drbg->ctx);
uint8_t zeros_buffer[S2N_DRBG_MAX_SEED_SIZE] = { 0 };
struct s2n_blob zeros = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&zeros, zeros_buffer, s2n_drbg_seed_size(drbg)));
RESULT_GUARD(s2n_blob_init(&zeros, zeros_buffer, s2n_drbg_seed_size(drbg)));

RESULT_ENSURE(blob->size <= S2N_DRBG_GENERATE_LIMIT, S2N_ERR_DRBG_REQUEST_SIZE);

Expand All @@ -83,7 +83,7 @@ static S2N_RESULT s2n_get_random_data_for_pq_kat_tests(struct s2n_blob *blob)
while (remaining) {
struct s2n_blob slice = { 0 };

RESULT_GUARD_POSIX(s2n_blob_slice(blob, &slice, offset, MIN(remaining, S2N_DRBG_GENERATE_LIMIT)));
RESULT_GUARD(s2n_blob_slice(blob, &slice, offset, MIN(remaining, S2N_DRBG_GENERATE_LIMIT)));
RESULT_GUARD(s2n_drbg_generate_for_pq_kat_tests(&drbg_for_pq_kats, &slice));

remaining -= slice.size;
Expand All @@ -97,7 +97,7 @@ S2N_RESULT s2n_get_random_bytes_for_pq_kat_tests(uint8_t *buffer, uint32_t num_b
{
RESULT_ENSURE(s2n_in_unit_test(), S2N_ERR_NOT_IN_UNIT_TEST);
struct s2n_blob out = { 0 };
RESULT_GUARD_POSIX(s2n_blob_init(&out, buffer, num_bytes));
RESULT_GUARD(s2n_blob_init(&out, buffer, num_bytes));

RESULT_GUARD(s2n_get_random_data_for_pq_kat_tests(&out));

Expand Down
4 changes: 2 additions & 2 deletions tests/testlib/s2n_stuffer_hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int s2n_stuffer_read_n_bits_hex(struct s2n_stuffer *stuffer, uint8_t n, u
{
uint8_t hex_data[16] = { 0 };
struct s2n_blob b = { 0 };
POSIX_GUARD(s2n_blob_init(&b, hex_data, n / 4));
POSIX_GUARD_RESULT(s2n_blob_init(&b, hex_data, n / 4));

POSIX_GUARD(s2n_stuffer_read(stuffer, &b));

Expand Down Expand Up @@ -125,7 +125,7 @@ static int s2n_stuffer_write_n_bits_hex(struct s2n_stuffer *stuffer, uint8_t n,
{
uint8_t hex_data[16] = { 0 };
struct s2n_blob b = { 0 };
POSIX_GUARD(s2n_blob_init(&b, hex_data, n / 4));
POSIX_GUARD_RESULT(s2n_blob_init(&b, hex_data, n / 4));

POSIX_ENSURE_LTE(n, 64);

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 @@ -60,7 +60,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;

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;

/* 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;

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;

/* 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;

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;

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;

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;

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