Skip to content

Commit 051e976

Browse files
committed
fix
1 parent f3329a8 commit 051e976

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/backend/storage/file/cfs.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,34 +321,50 @@ static int extract_fname_parts(const char* fname, uint32* part1, uint32* part2,
321321
/* Encryption and decryption using AES in CTR mode */
322322
static void cfs_aes_crypt_block(const char* fname, void* block, uint32 offs, uint32 size)
323323
{
324+
#define AES_DEBUG 1
324325
uint32 aes_in[4]; /* 16 bytes, 128 bits */
325326
uint32 aes_out[4];
326327
uint8* plaintext = (uint8*)block;
327328
uint8* pgamma = (uint8*)&aes_out;
329+
rijndael_ctx temp_ctx = cfs_state->aes_context;
328330
uint32 i, fname_part1, fname_part2, fname_part3;
329331

330332
if(extract_fname_parts(fname, &fname_part1, &fname_part2, &fname_part3) < 0)
331333
fname_part1 = fname_part2 = fname_part3 = 0;
332334

333-
// AALEKSEEV TODO MAKE DEBUG4
335+
#ifdef AES_DEBUG
334336
elog(LOG, "cfs_aes_crypt_block, fname = %s, part1 = %d, part2 = %d, part3 = %d, offs = %d, size = %d",
335337
fname, fname_part1, fname_part2, fname_part3, offs, size);
338+
#endif
336339

337-
aes_in[0] = fname_part1;
338-
aes_in[1] = fname_part2;
339-
aes_in[2] = fname_part3;
340+
aes_in[0] = 0; // fname_part1;
341+
aes_in[1] = 0; // fname_part2;
342+
aes_in[2] = 0; // fname_part3;
340343
aes_in[3] = offs & 0xFFFFFFF0;
341-
rijndael_encrypt(&cfs_state->aes_context, (u4byte*)&aes_in, (u4byte*)&aes_out);
344+
rijndael_encrypt(&temp_ctx, (u4byte*)&aes_in, (u4byte*)&aes_out);
345+
346+
#ifdef AES_DEBUG
347+
elog(LOG, "cfs_aes_crypt_block, in = %08X %08X %08X %08X, out = %08X %08X %08X %08X",
348+
aes_in[0], aes_in[1], aes_in[2], aes_in[3],
349+
aes_out[0], aes_out[1], aes_out[2], aes_out[3]);
350+
#endif
342351

343352
for(i = 0; i < size; i++)
344353
{
345-
plaintext[i] ^= aes_out[offs & 0xF];
354+
plaintext[i] ^= pgamma[offs & 0xF];
346355
offs++;
347356
if((offs & 0xF) == 0)
348357
{
349358
/* Prepare next gamma part */
350359
aes_in[3] = offs;
351-
rijndael_encrypt(&cfs_state->aes_context, (u4byte*)&aes_in, (u4byte*)&aes_out);
360+
temp_ctx = cfs_state->aes_context;
361+
rijndael_encrypt(&temp_ctx, (u4byte*)&aes_in, (u4byte*)&aes_out);
362+
363+
#ifdef AES_DEBUG
364+
elog(LOG, "cfs_aes_crypt_block, in = %08X %08X %08X %08X, out = %08X %08X %08X %08X",
365+
aes_in[0], aes_in[1], aes_in[2], aes_in[3],
366+
aes_out[0], aes_out[1], aes_out[2], aes_out[3]);
367+
#endif
352368
}
353369
}
354370
}

src/include/storage/cfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "port/atomics.h"
77
#include "storage/rijndael.h"
88

9-
#define CFS_VERSION "0.22"
9+
#define CFS_VERSION "0.23"
1010

1111
#define CFS_GC_LOCK 0x10000000
1212

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy