mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 18:36:02 -05:00
[airplay] Small update to pairing modules
This commit is contained in:
parent
1546a43585
commit
8f48179365
@ -102,6 +102,9 @@ pair_cipher_free(struct pair_cipher_context *cctx);
|
||||
const char *
|
||||
pair_cipher_errmsg(struct pair_cipher_context *cctx);
|
||||
|
||||
/* Return 0 is success, -1 is general error, -2 is ciphertext_len shorter than
|
||||
* blocklen in payload
|
||||
*/
|
||||
int
|
||||
pair_encrypt(uint8_t **ciphertext, size_t *ciphertext_len, uint8_t *plaintext, size_t plaintext_len, struct pair_cipher_context *cctx);
|
||||
int
|
||||
|
@ -1776,6 +1776,7 @@ pair_encrypt(uint8_t **ciphertext, size_t *ciphertext_len, uint8_t *plaintext, s
|
||||
if (ret < 0)
|
||||
{
|
||||
cctx->errmsg = "Encryption with chacha poly1305 failed";
|
||||
cctx->encryption_counter = cctx->encryption_counter_prev;
|
||||
free(*ciphertext);
|
||||
return -1;
|
||||
}
|
||||
@ -1820,9 +1821,10 @@ pair_decrypt(uint8_t **plaintext, size_t *plaintext_len, uint8_t *ciphertext, si
|
||||
memcpy(&block_len, cipher_block, sizeof(block_len)); // TODO BE or LE?
|
||||
if (cipher_block + block_len + sizeof(block_len) + AUTHTAG_LENGTH > ciphertext + ciphertext_len)
|
||||
{
|
||||
cctx->errmsg = "Corrupt block length in encrypted data";
|
||||
cctx->errmsg = "Insufficient encrypted data or corrupt block length";
|
||||
cctx->decryption_counter = cctx->decryption_counter_prev;
|
||||
free(*plaintext);
|
||||
return -1; // Corrupt block_len, stop before we read over the end
|
||||
return -2; // Corrupt block_len, stop before we read over the end
|
||||
}
|
||||
|
||||
memcpy(tag, cipher_block + sizeof(block_len) + block_len, sizeof(tag));
|
||||
@ -1832,6 +1834,7 @@ pair_decrypt(uint8_t **plaintext, size_t *plaintext_len, uint8_t *ciphertext, si
|
||||
if (ret < 0)
|
||||
{
|
||||
cctx->errmsg = "Decryption with chacha poly1305 failed";
|
||||
cctx->decryption_counter = cctx->decryption_counter_prev;
|
||||
free(*plaintext);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user