Skip to content

Commit

Permalink
Replaced call to cipher_aes_encrypt_bytes with cipher_aes_encrypt whi…
Browse files Browse the repository at this point in the history
…ch internally generates random IV
  • Loading branch information
rui-rafael-lastpass committed Jul 1, 2024
1 parent d94825a commit 959dd8d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ char *cipher_encrypt_private_key(struct private_key *private_key,
unsigned char *key_ptext;
unsigned char *ctext = NULL;
char *key_hex_dst;
char *ctext_hex = NULL;
char *encrypted_base64 = NULL;
size_t len, ctext_len, hex_len;

if (!private_key->len)
Expand All @@ -495,12 +495,13 @@ char *cipher_encrypt_private_key(struct private_key *private_key,

memcpy(key_ptext + strlen(LP_PKEY_PREFIX) + hex_len,
LP_PKEY_SUFFIX, strlen(LP_PKEY_SUFFIX));

ctext_len = cipher_aes_encrypt(key_ptext, key, &ctext);

ctext_len = cipher_aes_encrypt_bytes(key_ptext, len, key, key, &ctext);
bytes_to_hex(ctext, &ctext_hex, ctext_len);
encrypted_base64 = cipher_base64(ctext, ctext_len);

free(ctext);
return ctext_hex;
return encrypted_base64;
}

/*
Expand Down

0 comments on commit 959dd8d

Please sign in to comment.