summaryrefslogtreecommitdiff
path: root/verify.php
blob: 797dae3729ad3091e98597883fcded8fa17138d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

$fp = fopen("subdap-oberon.pem", "r");
$pubd = fread($fp, 262144);
fclose($fp);

$pub = openssl_get_publickey($pubd);

$args = array();
foreach (explode('&', $argv[1]) as $parm) {
	$s = split('=', $parm);
	$args[$s[0]] = $s[1];
}

$sig = $args['sig'];
$sig = str_replace('-', '+', $sig);
$sig = str_replace('_', '/', $sig);
$sig = base64_decode($sig, true);

$data = sprintf("%s:%d:%s", $args['site'], $args['ts'], $args['user']);
if (openssl_verify($data, $sig, $pub, "SHA256")) {
	printf("OK: site=%s ts=%s user=%s\n", $args['site'], $args['ts'], $args['user']);
} else {
	print "verify failed\n";
}