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

*** empty log message ***

Rev: lib/modules/Crypto/des3.pike:1.3
parent 58281cce
No related branches found
No related tags found
No related merge requests found
...@@ -16,21 +16,31 @@ int query_key_size() { return 16; } ...@@ -16,21 +16,31 @@ int query_key_size() { return 16; }
int query_block_size() { return 8; } int query_block_size() { return 8; }
private array(string) split_key(string key)
{
string k1 = key[..7];
string k2 = key[8..15];
string k3 = (strlen(key) > 16) ? key[16..] : k1;
return ({ k1, k2, k3 });
}
/* An exception will be raised if key is weak */ /* An exception will be raised if key is weak */
object set_encrypt_key(string key) object set_encrypt_key(string key)
{ {
pipe :: set_encrypt_key(key[..7], key[8..], key[..7]); array(string) keys = split_key(key);
pipe :: set_encrypt_key( @ keys);
/* Switch mode of middle crypto */ /* Switch mode of middle crypto */
d[1]->set_decrypt_key(key[8..]); d[1]->set_decrypt_key(keys[1]);
return this_object(); return this_object();
} }
/* An exception will be raised if key is weak */ /* An exception will be raised if key is weak */
object set_decrypt_key(string key) object set_decrypt_key(string key)
{ {
pipe :: set_decrypt_key(key[..7], key[8..], key[..7]); array(string) keys = split_key(key);
pipe :: set_decrypt_key( @ keys);
/* Switch mode of middle crypto */ /* Switch mode of middle crypto */
d[1]->set_encrypt_key(key[8..]); d[1]->set_encrypt_key(keys[1]);
return this_object(); return this_object();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment