Subversion Repositories vnag

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#!/usr/bin/php
2
<?php
3
 
4
$file = $argv[1];
5
 
6
$cont = file_get_contents($file);
7
 
8
if (!preg_match('@<\?php /\* <ViaThinkSoftSignature>(.+)</ViaThinkSoftSignature> \*/ \?>\n@ismU', $cont, $m)) {
9
	die("File $file not signed\n");
10
}
11
$signature = base64_decode($m[1]);
12
 
13
$naked = preg_replace('@<\?php /\* <ViaThinkSoftSignature>(.+)</ViaThinkSoftSignature> \*/ \?>\n@ismU', '', $cont);
14
$hash = hash("sha256", $naked.basename($file));
15
 
16
$public_key = file_get_contents(__DIR__.'/public.pem');
17
if (!openssl_verify($hash, $signature, $public_key, OPENSSL_ALGO_SHA256)) {
18
	die("Signature invalid\n");
19
}
20
 
21
echo "Signature valid\n";