projects
/
mirror
/
userdir-ldap-cgi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
968a3c8
)
fixed padding to allow spaces
author
tausq
<>
Sun, 30 Apr 2000 13:17:41 +0000
(13:17 +0000)
committer
tausq
<>
Sun, 30 Apr 2000 13:17:41 +0000
(13:17 +0000)
Util.pm
patch
|
blob
|
history
diff --git
a/Util.pm
b/Util.pm
index
6117a4e
..
0ec02cd
100644
(file)
--- a/
Util.pm
+++ b/
Util.pm
@@
-51,7
+51,9
@@
sub Encrypt {
my $input = shift;
my ($pos, $output);
my $input = shift;
my ($pos, $output);
- $input .= " " x ($blocksize - (length($input) % $blocksize)) if (length($input % $blocksize));
+ # prepend a length byte */
+ $input = chr(length($input)).$input;
+ $input .= "\001" x ($blocksize - (length($input) % $blocksize)) if (length($input % $blocksize));
for ($pos = 0; $pos < length($input); $pos += $blocksize) {
$output .= unpack("H16", $cipher->encrypt(substr($input, $pos, $blocksize))) if ($hascryptix);
for ($pos = 0; $pos < length($input); $pos += $blocksize) {
$output .= unpack("H16", $cipher->encrypt(substr($input, $pos, $blocksize))) if ($hascryptix);
@@
-64,7
+66,7
@@
sub Decrypt {
# trailing spaces are unimportant.
my $cipher = shift;
my $input = shift;
# trailing spaces are unimportant.
my $cipher = shift;
my $input = shift;
- my ($pos, $portion, $output);
+ my ($pos, $portion, $output
, $len
);
((length($input) % $blocksize) == 0) || &HTMLError("Password corrupted"); # should always be true...
((length($input) % $blocksize) == 0) || &HTMLError("Password corrupted"); # should always be true...
@@
-72,8
+74,10
@@
sub Decrypt {
$portion = pack("H16", substr($input, $pos, $blocksize*2));
$output .= $cipher->decrypt($portion) if ($hascryptix);
}
$portion = pack("H16", substr($input, $pos, $blocksize*2));
$output .= $cipher->decrypt($portion) if ($hascryptix);
}
-
- $output =~ s/ +$//;
+
+ # check length byte, discard junk
+ $len = substr($output, 0, 1);
+ $output = substr($output, 1, ord($len));
return $output;
}
return $output;
}