You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Define cipher magic size with sizeof() rather than using a constant.
This commit is contained in:
@ -146,6 +146,10 @@
|
|||||||
<release-item>
|
<release-item>
|
||||||
<p>Remove redundant lines from embedded Perl by combining blank lines.</p>
|
<p>Remove redundant lines from embedded Perl by combining blank lines.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
|
||||||
|
<release-item>
|
||||||
|
<p>Define cipher magic size with <code>sizeof()</code> rather than using a constant.</p>
|
||||||
|
</release-item>
|
||||||
</release-development-list>
|
</release-development-list>
|
||||||
</release-core-list>
|
</release-core-list>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ Header constants and sizes
|
|||||||
// Magic constant for salted encrypt. Only salted encrypt is done here, but this constant is required for compatibility with the
|
// Magic constant for salted encrypt. Only salted encrypt is done here, but this constant is required for compatibility with the
|
||||||
// openssl command-line tool.
|
// openssl command-line tool.
|
||||||
#define CIPHER_BLOCK_MAGIC "Salted__"
|
#define CIPHER_BLOCK_MAGIC "Salted__"
|
||||||
#define CIPHER_BLOCK_MAGIC_SIZE 8
|
#define CIPHER_BLOCK_MAGIC_SIZE (sizeof(CIPHER_BLOCK_MAGIC) - 1)
|
||||||
|
|
||||||
// Total length of cipher header
|
// Total length of cipher header
|
||||||
#define CIPHER_BLOCK_HEADER_SIZE (CIPHER_BLOCK_MAGIC_SIZE + PKCS5_SALT_LEN)
|
#define CIPHER_BLOCK_HEADER_SIZE (CIPHER_BLOCK_MAGIC_SIZE + PKCS5_SALT_LEN)
|
||||||
|
@ -81,12 +81,12 @@ testRun(void)
|
|||||||
encryptSize += cipherBlockProcess(
|
encryptSize += cipherBlockProcess(
|
||||||
blockEncrypt, (unsigned char *)TEST_PLAINTEXT, strlen(TEST_PLAINTEXT), encryptBuffer + encryptSize);
|
blockEncrypt, (unsigned char *)TEST_PLAINTEXT, strlen(TEST_PLAINTEXT), encryptBuffer + encryptSize);
|
||||||
TEST_RESULT_INT(
|
TEST_RESULT_INT(
|
||||||
encryptSize, CIPHER_BLOCK_HEADER_SIZE + EVP_CIPHER_block_size(blockEncrypt->cipher),
|
encryptSize, CIPHER_BLOCK_HEADER_SIZE + (size_t)EVP_CIPHER_block_size(blockEncrypt->cipher),
|
||||||
"cipher size increases by one block");
|
"cipher size increases by one block");
|
||||||
|
|
||||||
encryptSize += cipherBlockFlush(blockEncrypt, encryptBuffer + encryptSize);
|
encryptSize += cipherBlockFlush(blockEncrypt, encryptBuffer + encryptSize);
|
||||||
TEST_RESULT_INT(
|
TEST_RESULT_INT(
|
||||||
encryptSize, CIPHER_BLOCK_HEADER_SIZE + (EVP_CIPHER_block_size(blockEncrypt->cipher) * 2),
|
encryptSize, CIPHER_BLOCK_HEADER_SIZE + (size_t)(EVP_CIPHER_block_size(blockEncrypt->cipher) * 2),
|
||||||
"cipher size increases by one block on flush");
|
"cipher size increases by one block on flush");
|
||||||
|
|
||||||
cipherBlockFree(blockEncrypt);
|
cipherBlockFree(blockEncrypt);
|
||||||
|
Reference in New Issue
Block a user