Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Razor2/Signature/Ephemeral.pm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ sub picksection {
sub encode_separator {

my ( $self, $separator ) = @_;
my $rv;
my $rv = '';

unless ( ref $self ) { $separator = $self }
my @chars = split /-/, $separator;
Expand Down
162 changes: 1 addition & 161 deletions lib/Razor2/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use Razor2::Preproc::enBase64;

use Digest::SHA qw(sha1_hex);

#use MIME::Parser;

use Exporter 'import';

our @EXPORT = qw( hmac_sha1 xor_key
Expand All @@ -18,8 +16,7 @@ our @EXPORT = qw( hmac_sha1 xor_key
makesis parsesis makesis_nue parsesis_nue
hextobase64 base64tohex
randstr round
hex_dump prep_mail
prehash printb64table
prep_mail
hexbits2hash hmac2_sha1
fisher_yates_shuffle
);
Expand All @@ -40,12 +37,6 @@ BEGIN {
$b64table{63} = "_";
}

sub printb64table {
foreach ( 0 .. 63 ) {
print "$_ = $b64table{$_}\n";
}
}

sub hmac_sha1 {
my $text = shift;
my $iv1 = shift;
Expand All @@ -71,20 +62,6 @@ sub hmac2_sha1 {
return ( hextobase64($digest), $digest );
}

sub hmac3_sha1 {
my $text = shift;
my $iv1 = shift;
my $iv2 = shift;

return unless $text && $iv1 && $iv2;
die "no ref's allowed" if ref($text);

my $digest = $text;
$digest = sha1_hex( $iv1 . $digest );
$digest = sha1_hex( $iv2 . $digest );
return ( hextobase64($digest), $digest );
}

# part of RFC 2104 - see hmac_sha1()

sub xor_key {
Expand Down Expand Up @@ -541,72 +518,6 @@ sub randstr {

}

sub escape_smtp_terminator {

my ($textref) = @_;
$$textref =~ s/\r\n\./\r\n\.\./gm;

}

sub unescape_smtp_terminator {

my ($textref) = @_;
$$textref =~ s/\r\n\.\./\r\n\./gm;

}

sub hex_dump {
my $string = shift;

for ( split //, $string ) {
print ord($_) . " ";
}
print "\n";
}

sub hash2str {

my $href = shift;
my %hash = %$href;
my ( $str, $key );

for $key ( keys %hash ) {
my $tstr;
if ( ref $hash{$key} eq 'ARRAY' ) {
for ( @{ $hash{$key} } ) { $tstr .= escape($_) . "," }
$str =~ s/,$//;
}
elsif ( !( ref $hash{$key} ) ) {
$tstr .= escape( $hash{$key} );
}
if ($tstr) { $str .= "$key:$tstr&" }
}

$str =~ s/&$//;
return $str;

}

sub str2hash {

my $str = shift;
my %hash;
my @pairs = split /(?<!\\)&/, $str;

for (@pairs) {
my ( $key, $data ) = split /(?<!\\):/, $_, 2;
if ( $data =~ /(?<!\\),/ ) {
my @list = split /(?<!\\),/, $data;
for (@list) { $_ = unescape($_) }
$hash{$key} = [@list];
}
else { $hash{$key} = unescape($data) }
}

return \%hash;

}

#
# If body of an email has mime attachments, the headers
# will indicate this. likewise, each mime attachment
Expand Down Expand Up @@ -971,23 +882,6 @@ sub prep_mail {
return ( \$orig_hdr, @mimeparts_prep );
}

# from MIME::Parser
#my $parser = new MIME::Parser;
#my $entity = $parser->parse($body);
# foreach (dump_entity($entity))
sub dump_entity {
my $ent = shift;
my @parts = $ent->parts;

if (@parts) { # multipart...
map { dump_entity($_) } @parts;
}
else { # single part...
return ( $ent->body ); # return text blob
print " Part: ", $ent->bodyhandle->path, " (", scalar( $ent->head->mime_type ), ")\n";
}
}

# input: hex string ("2D")
# output: hash ref or array containg bits that are set
# 2D == (1, 3, 4, 6)
Expand All @@ -1003,34 +897,6 @@ sub hexbits2hash {

}

# input: hash ref, array ref, or array containg bits that are set
# output: hex string ("2D")
# 2D == (4, 8, 32)

sub hash2hexbits {
my @bits = @_;

@bits = @{ $bits[0] } if ref( $bits[0] ) eq 'ARRAY';
@bits = ( sort keys %{ $bits[0] } ) if ref( $bits[0] ) eq 'HASH';

my @all;
my $i = 1;
foreach ( sort { $a <=> $b } @bits ) {
while (1) {
push @all, 1 if $_ == $i;
last if $_ == $i;
push @all, 0;
$i++;
}
}
my $bs = join '', reverse @all;

# fixme needs testing
my $hex = ( unpack "H*", pack "B*", join '', reverse @all );

return $hex;
}

# for debugging - dumps a obj to a string
sub debugobj {
my ( $obj, $prefix, $maxwidth ) = @_;
Expand Down Expand Up @@ -1079,32 +945,6 @@ sub debugobj {
return $line;
}

sub clean_body {

my ( $self, $bodyref ) = @_;

my $hasheaders = 1;

if ( $self->{preprocs}->{deBase64}->isit($bodyref) ) {
$self->{preprocs}->{deBase64}->doit($bodyref);
$hasheaders = 0;
}

if ( $self->{preprocs}->{deQP}->isit($bodyref) ) {
$self->{preprocs}->{deQP}->doit($bodyref);
$hasheaders = 0;
}

if ( $self->{preprocs}->{deHTML}->isit($bodyref) ) {
$self->{preprocs}->{deHTML}->doit($bodyref);
}

if ($hasheaders) {
$$bodyref =~ s/^.*?\n\n//s;
}

}

sub round {

my $float = shift;
Expand Down
Loading