Skip to content
Snippets Groups Projects
Commit cffd0299 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Decryption is now done in the reverse order of encryption.

Rev: src/modules/_Crypto/pipe.c:1.2
parent f3b4e2a1
Branches
Tags
No related merge requests found
/* /*
* $Id: pipe.c,v 1.1 1996/11/11 19:24:04 grubba Exp $ * $Id: pipe.c,v 1.2 1996/11/13 15:26:51 grubba Exp $
* *
* PIPE crypto module for Pike. * PIPE crypto module for Pike.
* *
...@@ -185,6 +185,7 @@ static void f_set_encrypt_key(INT32 args) ...@@ -185,6 +185,7 @@ static void f_set_encrypt_key(INT32 args)
if (args != PIKE_PIPE->num_objs) { if (args != PIKE_PIPE->num_objs) {
error("Wrong number of arguments to pipe->set_encrypt_key()\n"); error("Wrong number of arguments to pipe->set_encrypt_key()\n");
} }
PIKE_PIPE->mode = 0;
for (i=-args; i; i++) { for (i=-args; i; i++) {
int n_args; int n_args;
...@@ -211,6 +212,7 @@ static void f_set_decrypt_key(INT32 args) ...@@ -211,6 +212,7 @@ static void f_set_decrypt_key(INT32 args)
if (args != PIKE_PIPE->num_objs) { if (args != PIKE_PIPE->num_objs) {
error("Wrong number of arguments to pipe->set_decrypt_key()\n"); error("Wrong number of arguments to pipe->set_decrypt_key()\n");
} }
PIKE_PIPE->mode = 1;
for (i=-args; i; i++) { for (i=-args; i; i++) {
int n_args; int n_args;
...@@ -243,10 +245,17 @@ static void f_crypt_block(INT32 args) ...@@ -243,10 +245,17 @@ static void f_crypt_block(INT32 args)
if (sp[-1].u.string->len % PIKE_PIPE->block_size) { if (sp[-1].u.string->len % PIKE_PIPE->block_size) {
error("Bad length of argument 1 to pipe->crypt_block()\n"); error("Bad length of argument 1 to pipe->crypt_block()\n");
} }
if (PIKE_PIPE->mode) {
/* Decryption -- Reverse the order */
for (i=PIKE_PIPE->num_objs; i--;) {
safe_apply(PIKE_PIPE->objects[i], "crypt_block", 1);
}
} else {
for (i=0; i<PIKE_PIPE->num_objs; i++) { for (i=0; i<PIKE_PIPE->num_objs; i++) {
safe_apply(PIKE_PIPE->objects[i], "crypt_block", 1); safe_apply(PIKE_PIPE->objects[i], "crypt_block", 1);
} }
} }
}
/* /*
* Module linkage * Module linkage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment