Skip to content

Commit

Permalink
Fix Q1 hash generation
Browse files Browse the repository at this point in the history
The base64 method of the Digest modules do not add padding
  • Loading branch information
mlschroe committed Jan 16, 2025
1 parent d4287db commit e6ca02c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Build/Apk.pm
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ sub calcapkchksum {
$ctx->addfile($fd);
}
return $ctx if $type eq 'raw';
return $type.$ctx->b64digest() if $type eq 'Q1' || $type eq 'Q2';
return $type.$ctx->b64digest().($type eq 'Q1' ? '=' : '') if $type eq 'Q1' || $type eq 'Q2';
return $type.$ctx->hexdigest() if $type eq 'X1' || $type eq 'X2';
return $ctx->hexdigest();
}
Expand Down
2 changes: 1 addition & 1 deletion Build/Apkv3.pm
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ sub trunc_apkchksum {
sub calcapkchksum_adb {
my ($type) = $_[1];
die("unsupported apkchksum type $type\n") unless $type eq 'Q1' || $type eq 'Q2' || $type eq 'X1' || $type eq 'X2' || $type eq 'md5';
return 'Q1'.Digest::SHA::sha1_base64($_[0]) if $type eq 'Q1';
return 'Q1'.Digest::SHA::sha1_base64($_[0]).'=' if $type eq 'Q1';
return 'Q2'.Digest::SHA::sha256_base64($_[0]) if $type eq 'Q2';
return 'X1'.Digest::SHA::sha1_hex($_[0]) if $type eq 'X1';
return 'X2'.Digest::SHA::sha256_hex($_[0]) if $type eq 'X2';
Expand Down

0 comments on commit e6ca02c

Please sign in to comment.