Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
f4fccef3
Commit
f4fccef3
authored
28 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Support for weak encryption
Rev: lib/modules/SSL.pmod/session.pike:1.2
parent
83a8646c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/SSL.pmod/session.pike
+79
-42
79 additions, 42 deletions
lib/modules/SSL.pmod/session.pike
with
79 additions
and
42 deletions
lib/modules/SSL.pmod/session.pike
+
79
−
42
View file @
f4fccef3
...
@@ -13,7 +13,7 @@ object cipher_spec;
...
@@ -13,7 +13,7 @@ object cipher_spec;
int ke_method;
int ke_method;
string master_secret; /* 48 byte secret shared between client and server */
string master_secret; /* 48 byte secret shared between client and server */
constant Struct =
(program) "
struct
"
;
constant Struct =
ADT.
struct;
constant State = (program) "state";
constant State = (program) "state";
void set_cipher_suite(int suite)
void set_cipher_suite(int suite)
...
@@ -22,6 +22,8 @@ void set_cipher_suite(int suite)
...
@@ -22,6 +22,8 @@ void set_cipher_suite(int suite)
cipher_suite = suite;
cipher_suite = suite;
ke_method = res[0];
ke_method = res[0];
cipher_spec = res[1];
cipher_spec = res[1];
werror(sprintf("SSL.session: cipher_spec %O\n",
mkmapping(indices(cipher_spec), values(cipher_spec))));
}
}
void set_compression_method(int compr)
void set_compression_method(int compr)
...
@@ -34,9 +36,11 @@ void set_compression_method(int compr)
...
@@ -34,9 +36,11 @@ void set_compression_method(int compr)
string generate_key_block(string client_random, string server_random)
string generate_key_block(string client_random, string server_random)
{
{
int required = 2 * (cipher_spec->key_material +
int required = 2 * (cipher_spec->is_exportable
? (5 + cipher_spec->hash_size)
: ( cipher_spec->key_material +
cipher_spec->hash_size +
cipher_spec->hash_size +
cipher_spec->iv_size);
cipher_spec->iv_size)
)
;
object sha = mac_sha();
object sha = mac_sha();
object md5 = mac_md5();
object md5 = mac_md5();
int i = 0;
int i = 0;
...
@@ -54,61 +58,94 @@ string generate_key_block(string client_random, string server_random)
...
@@ -54,61 +58,94 @@ string generate_key_block(string client_random, string server_random)
return key;
return key;
}
}
array
new_server_state
s(string client_random, string server_random)
array
generate_key
s(string client_random, string server_random)
{
{
object key_data = Struct(generate_key_block(client_random, server_random));
object key_data = Struct(generate_key_block(client_random, server_random));
object write_state = State(this_object());
array keys = allocate(6);
object read_state = State(this_object());
write(sprintf("client_random: '%s'\nserver_random: '%s'\n",
write(sprintf("client_random: '%s'\nserver_random: '%s'\n",
client_random, server_random));
client_random, server_random));
read_state->mac = cipher_spec->
mac_algorithm(key_data->get_fix_string(cipher_spec->hash_size));
write_state->mac = cipher_spec->
mac_algorithm(key_data->get_fix_string(cipher_spec->hash_size));
read_state->crypt = cipher_spec->bulk_cipher_algorithm();
read_state->crypt->
set_decrypt_key(key_data->get_fix_string(cipher_spec->key_material));
write_state->crypt = cipher_spec->bulk_cipher_algorithm();
/* client_write_MAC_secret */
write_state->crypt->
keys[0] = key_data->get_fix_string(cipher_spec->hash_size);
set_encrypt_key(key_data->get_fix_string(cipher_spec->key_material));
/* server_write_MAC_secret */
keys[1] = key_data->get_fix_string(cipher_spec->hash_size);
if (cipher_spec->is_exportable)
{
object md5 = mac_md5()->hash_raw;
keys[2] = md5(key_data->get_fix_string(5) +
client_random + server_random)
[..cipher_spec->key_material-1];
keys[3] = md5(key_data->get_fix_string(5) +
server_random + client_random)
[..cipher_spec->key_material-1];
if (cipher_spec->iv_size)
if (cipher_spec->iv_size)
{
{
read_state->crypt->
keys[4] = md5(client_random + server_random)[..cipher_spec->iv_size-1];
set_iv(key_data->get_fix_string(cipher_spec->iv_size));
keys[5] = md5(server_random + client_random)[..cipher_spec->iv_size-1];
write_state->crypt->
set_iv(key_data->get_fix_string(cipher_spec->iv_size));
}
}
return ({ read_state, write_state });
} else {
keys[2] = key_data->get_fix_string(cipher_spec->key_material);
keys[3] = key_data->get_fix_string(cipher_spec->key_material);
if (cipher_spec->iv_size)
{
keys[4] = key_data->get_fix_string(cipher_spec->iv_size);
keys[5] = key_data->get_fix_string(cipher_spec->iv_size);
}
}
return keys;
}
}
array new_
client
_states(string client_random, string server_random)
array new_
server
_states(string client_random, string server_random)
{
{
object key_data = Struct(generate_key_block(client_random, server_random));
object write_state = State(this_object());
object write_state = State(this_object());
object read_state = State(this_object());
object read_state = State(this_object());
array keys = generate_keys(client_random, server_random);
write_state->mac = cipher_spec->
if (cipher_spec->mac_algorithm)
mac_algorithm(key_data->get_fix_string(cipher_spec->hash_size));
{
read_state->mac = cipher_spec->
read_state->mac = cipher_spec->mac_algorithm(keys[0]);
mac_algorithm(key_data->get_fix_string(cipher_spec->hash_size));
write_state->mac = cipher_spec->mac_algorithm(keys[1]);
}
if (cipher_spec->bulk_cipher_algorithm)
{
read_state->crypt = cipher_spec->bulk_cipher_algorithm();
read_state->crypt->set_decrypt_key(keys[2]);
write_state->crypt = cipher_spec->bulk_cipher_algorithm();
write_state->crypt = cipher_spec->bulk_cipher_algorithm();
write_state->crypt->
write_state->crypt->set_encrypt_key(keys[3]);
set_encrypt_key(key_data->get_fix_string(cipher_spec->key_material));
if (cipher_spec->iv_size)
{
read_state->crypt->set_iv(keys[4]);
write_state->crypt->set_iv(keys[5]);
}
}
return ({ read_state, write_state });
}
read_state->crypt = cipher_spec->bulk_cipher_algorithm();
array new_client_states(string client_random, string server_random)
read_state->crypt->
{
set_decrypt_key(key_data->get_fix_string(cipher_spec->key_material));
object write_state = State(this_object());
object read_state = State(this_object());
array keys = generate_keys(client_random, server_random);
if (cipher_spec->mac_algorithm)
{
read_state->mac = cipher_spec->mac_algorithm(keys[1]);
write_state->mac = cipher_spec->mac_algorithm(keys[0]);
}
if (cipher_spec->bulk_cipher_algorithm)
{
read_state->crypt = cipher_spec->bulk_cipher_algorithm();
read_state->crypt->set_decrypt_key(keys[3]);
write_state->crypt = cipher_spec->bulk_cipher_algorithm();
write_state->crypt->set_encrypt_key(keys[2]);
if (cipher_spec->iv_size)
if (cipher_spec->iv_size)
{
{
write_state->crypt->
read_state->crypt->set_iv(keys[5]);
set_iv(key_data->get_fix_string(cipher_spec->iv_size));
write_state->crypt->set_iv(keys[4]);
read_state->crypt->
}
set_iv(key_data->get_fix_string(cipher_spec->iv_size));
}
}
return ({ read_state, write_state });
return ({ read_state, write_state });
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment