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

Commit1ba7cc9

Browse files
committed
fix
1 parenta5d7f9b commit1ba7cc9

File tree

2 files changed

+3
-65
lines changed

2 files changed

+3
-65
lines changed

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

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -194,47 +194,11 @@ char const* cfs_algorithm()
194194

195195
#endif
196196

197-
198-
staticvoidcfs_rc4_encrypt_block(void*block,uint32offs,uint32block_size)// AALEKSEEV TODO: DELETE THIS
199-
{
200-
uint32i;
201-
uint8temp;
202-
uint8*dst= (uint8*)block;
203-
intnext_state;
204-
uint8state[CFS_CIPHER_KEY_SIZE];
205-
intx=0,y=0;
206-
uint32skip= (offs /BLCKSZ+block_size) %CFS_CIPHER_KEY_SIZE;
207-
208-
memcpy(state,cfs_state->rc4_init_state,CFS_CIPHER_KEY_SIZE);
209-
for (i=0;i<skip;i++) {
210-
x= (x+1) %CFS_CIPHER_KEY_SIZE;
211-
y= (y+state[x]) %CFS_CIPHER_KEY_SIZE;
212-
temp=state[x];
213-
state[x]=state[y];
214-
state[y]=temp;
215-
}
216-
for (i=0;i<block_size;i++) {
217-
x= (x+1) %CFS_CIPHER_KEY_SIZE;
218-
y= (y+state[x]) %CFS_CIPHER_KEY_SIZE;
219-
temp=state[x];
220-
state[x]=state[y];
221-
state[y]=temp;
222-
next_state= (state[x]+state[y]) %CFS_CIPHER_KEY_SIZE;
223-
dst[i] ^=state[next_state];
224-
}
225-
}
226-
227197
staticvoidcfs_crypto_init(void)
228198
{
229-
intindex1=0;
230-
intindex2=0;
231-
inti;
232-
uint8temp;
233199
intkey_length;
234-
intx=0,y=0;
235200
char*cipher_key;
236201
uint8aes_key[32]= {0};/* at most 256 bits */
237-
uint8*rc4_init_state=cfs_state->rc4_init_state;
238202

239203
cipher_key=getenv("PG_CIPHER_KEY");
240204
if (cipher_key==NULL) {
@@ -243,26 +207,6 @@ static void cfs_crypto_init(void)
243207
unsetenv("PG_CIPHER_KEY");/* make it not possible to inspect this environment variable through plperl */
244208
key_length=strlen(cipher_key);
245209

246-
////// AALEKSEEV TODO GET RID OF THIS
247-
for (i=0;i<CFS_CIPHER_KEY_SIZE;++i) {
248-
rc4_init_state[i]= (uint8)i;
249-
}
250-
for (i=0;i<CFS_CIPHER_KEY_SIZE;++i) {
251-
index2= (cipher_key[index1]+rc4_init_state[i]+index2) %CFS_CIPHER_KEY_SIZE;
252-
temp=rc4_init_state[i];
253-
rc4_init_state[i]=rc4_init_state[index2];
254-
rc4_init_state[index2]=temp;
255-
index1= (index1+1) %key_length;
256-
}
257-
for (i=0;i<CFS_RC4_DROP_N;i++) {
258-
x= (x+1) %CFS_CIPHER_KEY_SIZE;
259-
y= (y+rc4_init_state[x]) %CFS_CIPHER_KEY_SIZE;
260-
temp=rc4_init_state[x];
261-
rc4_init_state[x]=rc4_init_state[y];
262-
rc4_init_state[y]=temp;
263-
}
264-
//////
265-
266210
memcpy(&aes_key,cipher_key,key_length>sizeof(aes_key) ?sizeof(aes_key) :key_length);
267211
rijndael_set_key(
268212
&cfs_state->aes_context,/* context */
@@ -321,11 +265,11 @@ static int extract_fname_parts(const char* fname, uint32* part1, uint32* part2,
321265
/* Encryption and decryption using AES in CTR mode */
322266
staticvoidcfs_aes_crypt_block(constchar*fname,void*block,uint32offs,uint32size)
323267
{
324-
#defineAES_DEBUG 1
268+
#defineAES_DEBUG 1 // AALEKSEEV TODO: 0
325269
uint32aes_in[4];/* 16 bytes, 128 bits */
326270
uint32aes_out[4];
327271
uint8*plaintext= (uint8*)block;
328-
uint8*pgamma= (uint8*)&aes_out;
272+
uint8*gamma= (uint8*)&aes_out;
329273
uint32i,fname_part1,fname_part2,fname_part3;
330274

331275
if(extract_fname_parts(fname,&fname_part1,&fname_part2,&fname_part3)<0)
@@ -350,7 +294,7 @@ static void cfs_aes_crypt_block(const char* fname, void* block, uint32 offs, uin
350294

351295
for(i=0;i<size;i++)
352296
{
353-
plaintext[i] ^=pgamma[offs&0xF];
297+
plaintext[i] ^=gamma[offs&0xF];
354298
offs++;
355299
if((offs&0xF)==0)
356300
{
@@ -371,7 +315,6 @@ void cfs_encrypt(const char* fname, void* block, uint32 offs, uint32 size)
371315
{
372316
if (cfs_encryption)
373317
{
374-
cfs_rc4_encrypt_block(block,offs,size);// AALEKSEEV TODO DELETE
375318
cfs_aes_crypt_block(fname,block,offs,size);
376319
}
377320
}
@@ -380,7 +323,6 @@ void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 size)
380323
{
381324
if (cfs_encryption)
382325
{
383-
cfs_rc4_encrypt_block(block,offs,size);// AALEKSEEV TODO DELETE
384326
cfs_aes_crypt_block(fname,block,offs,size);
385327
}
386328
}

‎src/include/storage/cfs.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
#defineCFS_COMPRESSOR ZLIB_COMPRESSOR
3030
#endif
3131

32-
#defineCFS_RC4_DROP_N 3072 // AALEKSEEV TODO GET RID OF THIS
33-
#defineCFS_CIPHER_KEY_SIZE 256 // AALEKSEEV TODO GET RID OF THIS
34-
3532
typedefuint64inode_t;
3633

3734
#defineCFS_INODE_SIZE(inode) ((uint32)((inode) >> 32))
@@ -63,7 +60,6 @@ typedef struct
6360
intmax_iterations;
6461
boolgc_enabled;
6562
CfsStatisticgc_stat;
66-
uint8rc4_init_state[CFS_CIPHER_KEY_SIZE];
6763
rijndael_ctxaes_context;
6864
}CfsState;
6965

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp