Skip to content
Snippets Groups Projects
Commit e106c71c authored by Niels Möller's avatar Niels Möller
Browse files

Fixed a few bugs

Rev: lib/modules/Crypto/randomness.pmod.pike:1.2
Rev: lib/modules/Crypto/rsa.pike:1.5
Rev: src/modules/_Crypto/cbc.c:1.8
Rev: src/modules/_Crypto/crypto.c:1.20
Rev: src/modules/_Crypto/test_crypto.pike:1.4
parent 87e9719b
No related branches found
No related tags found
No related merge requests found
...@@ -105,7 +105,7 @@ object reasonably_random() ...@@ -105,7 +105,7 @@ object reasonably_random()
object really_random(int|void may_block) object really_random(int|void may_block)
{ {
object res; object res = Stdio.File();
if (may_block && file_stat(RANDOM_DEVICE)) if (may_block && file_stat(RANDOM_DEVICE))
{ {
if (res->open(RANDOM_DEVICE, "r")) if (res->open(RANDOM_DEVICE, "r"))
......
...@@ -81,7 +81,7 @@ int sha_verify(string message, string signature) ...@@ -81,7 +81,7 @@ int sha_verify(string message, string signature)
string s; string s;
hash->update(message); hash->update(message);
s = hash->digest; s = hash->digest();
s = sprintf("%c%s%c%s", 4, "sha1", strlen(s), s); s = sprintf("%c%s%c%s", 4, "sha1", strlen(s), s);
return s == rsa_unpad(BIGNUM(signature, 256)->powm(e, n), 1); return s == rsa_unpad(BIGNUM(signature, 256)->powm(e, n), 1);
......
/* /*
* $Id: cbc.c,v 1.7 1997/03/17 03:11:14 hubbe Exp $ * $Id: cbc.c,v 1.8 1997/04/10 02:33:26 nisse Exp $
* *
* CBC (Cipher Block Chaining Mode) crypto module for Pike. * CBC (Cipher Block Chaining Mode) crypto module for Pike.
* *
...@@ -260,7 +260,7 @@ static void f_decrypt_block(INT32 args) ...@@ -260,7 +260,7 @@ static void f_decrypt_block(INT32 args)
if (sp[-1].type != T_STRING) { if (sp[-1].type != T_STRING) {
error("Bad argument 1 to cbc->decrypt_block()\n"); error("Bad argument 1 to cbc->decrypt_block()\n");
} }
if (sp[-1].u.string->len & THIS->block_size) { if (sp[-1].u.string->len % THIS->block_size) {
error("Bad length of argument 1 to cbc->decrypt_block()\n"); error("Bad length of argument 1 to cbc->decrypt_block()\n");
} }
if (!(result = alloca(sp[-1].u.string->len))) { if (!(result = alloca(sp[-1].u.string->len))) {
......
/* /*
* $Id: crypto.c,v 1.19 1997/03/23 18:18:55 nisse Exp $ * $Id: crypto.c,v 1.20 1997/04/10 02:33:27 nisse Exp $
* *
* A pike module for getting access to some common cryptos. * A pike module for getting access to some common cryptos.
* *
...@@ -397,11 +397,10 @@ static void f_pad(INT32 args) ...@@ -397,11 +397,10 @@ static void f_pad(INT32 args)
error("Too many arguments to crypto->pad()\n"); error("Too many arguments to crypto->pad()\n");
} }
len = THIS->block_size - 1 - THIS->backlog_len; for (i = THIS->backlog_len; i < THIS->block_size - 1; i++)
for (i=0; i < len; i++) THIS->backlog[i] = my_rand() & 0xff;
THIS->backlog[THIS->backlog_len + i] = my_rand() & 0xff;
THIS->backlog[i] = len; THIS->backlog[THIS->block_size - 1] = 7 - THIS->backlog_len;
push_string(make_shared_binary_string((const char *)THIS->backlog, push_string(make_shared_binary_string((const char *)THIS->backlog,
THIS->block_size)); THIS->block_size));
......
...@@ -7,7 +7,6 @@ import Crypto; ...@@ -7,7 +7,6 @@ import Crypto;
#define K(a) hex_to_string(a) #define K(a) hex_to_string(a)
#define H(a) string_to_hex(a) #define H(a) string_to_hex(a)
int test_des() int test_des()
{ {
string *keys = ({ K("0101010101010180"), string *keys = ({ K("0101010101010180"),
...@@ -60,7 +59,6 @@ int test_des() ...@@ -60,7 +59,6 @@ int test_des()
return err; return err;
} }
int test_idea() int test_idea()
{ {
string key = K("0123456789abcdef0123456789abcdef"); string key = K("0123456789abcdef0123456789abcdef");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment