Commit 2bf377af authored by marcus's avatar marcus
Browse files

adapted to new interface on the server

parent d2f890c7
......@@ -287,49 +287,39 @@ my $assertion=$response_content;
# ENCRYPTION #
################
my $restrict='!@#$%^&*()_-=+/' ;
my $symmetric_passwd =chars(5,32,0,$restrict,0);
my $iv='';
my $symmetric_passwd = chars(5,16,0,$restrict,0);
my $iv = chars(5,16,0,$restrict,0);
print ("symkey: ". $symmetric_passwd."\n");
print ("iv: ". $iv."\n");
# encryption
#my $encryption_algorithm='Twofish';
#my $encryption_algorithm='Blowfish';
my $encryption_algorithm='Rijndael';
my $encryption_algorithm_name='AES'; # only for the post, so the server knows what to use
my $cipher = new Crypt::CBC ($symmetric_passwd, $encryption_algorithm, -iv=>$iv, -header=>'none');
my $encrypted_assertion_tmp= $cipher->encrypt($assertion);
# Remove the first 16 bytes => TODO REMOVE THIS!!!!!
my $encrypted_assertion=substr($encrypted_assertion_tmp, 16);
my $cipher = new Crypt::CBC ($symmetric_passwd, 'Rijndael', -keysize=>8, -iv=>$iv, -header=>'none');
my $buf = $cipher->encrypt($assertion);
undef $assertion;
# Remove the first 16 bytes => TODO CHECK
my $encrypted_assertion=substr($buf, 16);
# extract actual password and initialisation vector
my $perl_key = unpack('H*', $cipher->key());
#my $perl_key = $cipher->key();
my $perl_key = $cipher->key();
my $perl_iv = $cipher->iv();
## log to file
#open (FILE, ">", 'log.perl');
#print FILE "pass: ".$perl_key."\n";
#print FILE "iv: ".$perl_iv."\n";
#print FILE $encrypted_assertion."\n";
#close (FILE);
## decrypt
#my $de_cipher = new Crypt::CBC ($symmetric_passwd, $encryption_algorithm, -iv=>'asdlsdff', -header=>'asdf');
#$de_cipher->iv('asdfasdf');
##$cipher = new Crypt::ECB ($symmetric_passwd, $encryption_algorithm);
#my $plaintext = $de_cipher->decrypt($encrypted_assertion);
#print ("\n".$plaintext."\n");
my $package = $perl_iv.$encrypted_assertion;
print ("perl_key: ".encode_base64($perl_key)."\n");
print ("length of perl_key: ".length($perl_key),"\n");
print ("length of perl_iv: ".length($perl_iv),"\n");
print ("length of encypted assertion ".length($encrypted_assertion),"\n");
print ("length of encyption package: ".length($package),"\n");
# base64 encoding
my $b64_encrypted_assertion=encode_base64($encrypted_assertion);
undef $encrypted_assertion;
my $b64_encrypted_assertion_package=encode_base64($package);
# upload encrypted assertion
$response=$ua->post(CREDENTIAL_UPLOAD_URL,
[encrypted_assertion =>$b64_encrypted_assertion,
key => $perl_key,
iv => $perl_iv,
encryption_algorithm => $encryption_algorithm_name,
[encrypted_assertion =>$b64_encrypted_assertion_package,
key => encode_base64($perl_key),
client => "perl",
client_verion => VERSION]);
......@@ -342,7 +332,7 @@ print Dumper($response_content);
# Store the returned URL
(undef, $url_to_assertion) = split("url=", $response_content);
my $url_to_assertion_with_key = $url_to_assertion."&k=".$symmetric_passwd;
my $url_to_assertion_with_key = $url_to_assertion."&k=".encode_base64($perl_key);
open (FILE, ">", $urlfile) or die $!;
print FILE $url_to_assertion_with_key."\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment