Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb24dbb

Browse files
committed
fix
1 parent447d764 commitfb24dbb

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

‎src/backend/storage/file/cfs.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void cfs_rc4_encrypt_block(void* block, uint32 offs, uint32 block_size)
224224
}
225225
}
226226

227-
staticvoidcfs_rc4_init(void)
227+
staticvoidcfs_crypto_init(void)
228228
{
229229
intindex1=0;
230230
intindex2=0;
@@ -233,6 +233,7 @@ static void cfs_rc4_init(void)
233233
intkey_length;
234234
intx=0,y=0;
235235
char*cipher_key;
236+
uint8aes_key[32]= {0};/* at most 256 bits */
236237
uint8*rc4_init_state=cfs_state->rc4_init_state;
237238

238239
cipher_key=getenv("PG_CIPHER_KEY");
@@ -241,6 +242,8 @@ static void cfs_rc4_init(void)
241242
}
242243
unsetenv("PG_CIPHER_KEY");/* make it not possible to inspect this environment variable through plperl */
243244
key_length=strlen(cipher_key);
245+
246+
////// AALEKSEEV TODO GET RID OF THIS
244247
for (i=0;i<CFS_CIPHER_KEY_SIZE;++i) {
245248
rc4_init_state[i]= (uint8)i;
246249
}
@@ -258,6 +261,15 @@ static void cfs_rc4_init(void)
258261
rc4_init_state[x]=rc4_init_state[y];
259262
rc4_init_state[y]=temp;
260263
}
264+
//////
265+
266+
memcpy(&aes_key,cipher_key,key_length>sizeof(aes_key) ?sizeof(aes_key) :key_length);
267+
rijndael_set_key(
268+
&cfs_state->aes_context,/* context */
269+
(u4byte*)&aes_key,/* key */
270+
sizeof(aes_key)*8/* key size in bits */,
271+
1/* for CTR mode we need only encryption */
272+
);
261273
}
262274

263275
/*
@@ -346,7 +358,7 @@ void cfs_initialize()
346358
cfs_state->max_iterations=0;
347359

348360
if (cfs_encryption) {
349-
cfs_rc4_init();
361+
cfs_crypto_init();
350362
}
351363
elog(LOG,"Start CFS version %s compression algorithm %s encryption %s",
352364
CFS_VERSION,cfs_algorithm(),cfs_encryption ?"enabled" :"disabled");

‎src/include/storage/cfs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#defineCFS_COMPRESSOR ZLIB_COMPRESSOR
3030
#endif
3131

32-
#defineCFS_RC4_DROP_N 3072
33-
#defineCFS_CIPHER_KEY_SIZE 256
32+
#defineCFS_RC4_DROP_N 3072 // AALEKSEEV TODO GET RID OF THIS
33+
#defineCFS_CIPHER_KEY_SIZE 256 // AALEKSEEV TODO GET RID OF THIS
3434

3535
typedefuint64inode_t;
3636

@@ -64,6 +64,7 @@ typedef struct
6464
boolgc_enabled;
6565
CfsStatisticgc_stat;
6666
uint8rc4_init_state[CFS_CIPHER_KEY_SIZE];
67+
rijndael_ctxaes_context;
6768
}CfsState;
6869

6970
typedefstruct

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp