Skip to content

Commit

Permalink
set len to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
toidiu committed Aug 25, 2022
1 parent 1ab1dab commit b4abd23
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions crypto/s2n_aead_cipher_aes_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static int s2n_aead_cipher_aes_gcm_encrypt(struct s2n_session_key *key, struct s
int in_len = in->size - S2N_TLS_GCM_TAG_LEN;
uint8_t *tag_data = out->data + out->size - S2N_TLS_GCM_TAG_LEN;

int out_len;
int out_len = 0;
/* Specify the AAD */
POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, NULL, &out_len, aad->data, aad->size), S2N_ERR_ENCRYPT);

Expand Down Expand Up @@ -260,7 +260,7 @@ static int s2n_aead_cipher_aes_gcm_decrypt(struct s2n_session_key *key, struct s
/* Set the TAG */
POSIX_GUARD_OSSL(EVP_CIPHER_CTX_ctrl(key->evp_cipher_ctx, EVP_CTRL_GCM_SET_TAG, S2N_TLS_GCM_TAG_LEN, tag_data), S2N_ERR_DECRYPT);

int out_len;
int out_len = 0;
/* Specify the AAD */
POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, NULL, &out_len, aad->data, aad->size), S2N_ERR_DECRYPT);

Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_aead_cipher_chacha20_poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int s2n_aead_chacha20_poly1305_encrypt(struct s2n_session_key *key, struc
int in_len = in->size - S2N_TLS_CHACHA20_POLY1305_TAG_LEN;
uint8_t *tag_data = out->data + out->size - S2N_TLS_CHACHA20_POLY1305_TAG_LEN;

int out_len;
int out_len = 0;
/* Specify the AAD */
POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, NULL, &out_len, aad->data, aad->size), S2N_ERR_ENCRYPT);

Expand Down Expand Up @@ -99,7 +99,7 @@ static int s2n_aead_chacha20_poly1305_decrypt(struct s2n_session_key *key, struc
/* Set the TAG */
POSIX_GUARD_OSSL(EVP_CIPHER_CTX_ctrl(key->evp_cipher_ctx, EVP_CTRL_GCM_SET_TAG, S2N_TLS_CHACHA20_POLY1305_TAG_LEN, tag_data), S2N_ERR_DECRYPT);

int out_len;
int out_len = 0;
/* Specify the AAD */
POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, NULL, &out_len, aad->data, aad->size), S2N_ERR_DECRYPT);

Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_cbc_cipher_3des.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int s2n_cbc_cipher_3des_encrypt(struct s2n_session_key *key, struct s2n_b

POSIX_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_ENCRYPT);
S2N_ERROR_IF(len != in->size, S2N_ERR_ENCRYPT);

Expand All @@ -47,7 +47,7 @@ static int s2n_cbc_cipher_3des_decrypt(struct s2n_session_key *key, struct s2n_b

POSIX_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_DECRYPT);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_cbc_cipher_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int s2n_cbc_cipher_aes_encrypt(struct s2n_session_key *key, struct s2n_bl

POSIX_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_ENCRYPT);
S2N_ERROR_IF(len != in->size, S2N_ERR_ENCRYPT);

Expand All @@ -51,7 +51,7 @@ int s2n_cbc_cipher_aes_decrypt(struct s2n_session_key *key, struct s2n_blob *iv,
POSIX_ENSURE_GTE(out->size, in->size);

POSIX_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);
int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_DECRYPT);

return 0;
Expand Down
5 changes: 3 additions & 2 deletions crypto/s2n_composite_cipher_aes_sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ static int s2n_composite_cipher_aes_sha_encrypt(struct s2n_session_key *key, str

POSIX_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_ENCRYPT);

S2N_ERROR_IF(len != in->size, S2N_ERR_ENCRYPT);

return 0;
Expand All @@ -180,7 +181,7 @@ static int s2n_composite_cipher_aes_sha_decrypt(struct s2n_session_key *key, str
POSIX_ENSURE_EQ(out->size, in->size);
POSIX_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_DECRYPT);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion crypto/s2n_drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static S2N_RESULT s2n_drbg_block_encrypt(EVP_CIPHER_CTX *ctx, uint8_t in[S2N_DRB
{
RESULT_ENSURE_REF(ctx);

int len = S2N_DRBG_BLOCK_SIZE;
int len = 0;
RESULT_GUARD_OSSL(EVP_EncryptUpdate(ctx, out, &len, in, S2N_DRBG_BLOCK_SIZE), S2N_ERR_DRBG);
RESULT_ENSURE_EQ(len, S2N_DRBG_BLOCK_SIZE);

Expand Down
4 changes: 2 additions & 2 deletions crypto/s2n_stream_cipher_rc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int s2n_stream_cipher_rc4_encrypt(struct s2n_session_key *key, struct s2n
{
POSIX_ENSURE_GTE(out->size, in->size);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_ENCRYPT);

S2N_ERROR_IF(len != in->size, S2N_ERR_ENCRYPT);
Expand All @@ -52,7 +52,7 @@ static int s2n_stream_cipher_rc4_decrypt(struct s2n_session_key *key, struct s2n
{
POSIX_ENSURE_GTE(out->size, in->size);

int len = out->size;
int len = 0;
POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_ENCRYPT);

S2N_ERROR_IF(len != in->size, S2N_ERR_ENCRYPT);
Expand Down

0 comments on commit b4abd23

Please sign in to comment.