Skip to content

Commit

Permalink
Be compatible with the updated botan's behaviour related to reworked …
Browse files Browse the repository at this point in the history
…botan_cipher_update() function.
  • Loading branch information
ni4 committed May 31, 2024
1 parent a8f2318 commit 0cb2663
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/crypto/symmetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ pgp_cipher_aead_update(pgp_crypt_t *crypt, uint8_t *out, const uint8_t *in, size
}

if ((outwr != len) || (inread != len)) {
RNP_LOG("wrong aead usage");
RNP_LOG("wrong aead usage: %zu vs %zu, %zu vs %zu", outwr, len, inread, len);

Check warning on line 296 in src/lib/crypto/symmetric.cpp

View check run for this annotation

Codecov / codecov/patch

src/lib/crypto/symmetric.cpp#L296

Added line #L296 was not covered by tests
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librepgp/stream-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define ST_FROM ("From")

/* Preallocated cache length for AEAD encryption/decryption */
#define PGP_AEAD_CACHE_LEN (PGP_INPUT_CACHE_SIZE + PGP_AEAD_MAX_TAG_LEN)
#define PGP_AEAD_CACHE_LEN (PGP_INPUT_CACHE_SIZE + 2 * PGP_AEAD_MAX_TAG_LEN)

/* Maximum OpenPGP packet nesting level */
#define MAXIMUM_NESTING_LEVEL 32
Expand Down
3 changes: 2 additions & 1 deletion src/librepgp/stream-write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ encrypted_dst_write_aead(pgp_dest_t *dst, const void *buf, size_t len)
}

while (len > 0) {
sz = std::min(sizeof(param->cache) - PGP_AEAD_MAX_TAG_LEN - param->cachelen, len);
/* 2 tags to align to the PGP_INPUT_CACHE_SIZE size */
sz = std::min(sizeof(param->cache) - 2 * PGP_AEAD_MAX_TAG_LEN - param->cachelen, len);
sz = std::min(sz, param->chunklen - param->chunkout - param->cachelen);
memcpy(param->cache + param->cachelen, buf, sz);
param->cachelen += sz;
Expand Down

0 comments on commit 0cb2663

Please sign in to comment.