diff options
author | equinox <equinox@diac24.net> | 2011-04-01 07:00:48 +0200 |
---|---|---|
committer | equinox <equinox@diac24.net> | 2011-04-01 07:04:25 +0200 |
commit | 944d2f7e1bf9870b3e6d544f24ecd443450a6fb7 (patch) | |
tree | 91c23c61698d60033388c44fe5a37f3fe3f58a21 | |
parent | a48c542228cfec15ad9023bc7fe9a9d9cd1aeb2c (diff) |
php verify script
-rw-r--r-- | ticket.py | 3 | ||||
-rw-r--r-- | verify.php | 25 |
2 files changed, 27 insertions, 1 deletions
@@ -18,8 +18,9 @@ def tgt_verify(site, user, ts, sig, maxage = None): return status if __name__ == '__main__': + import urllib sig = tgt_create('site', 'test') - print sig + print urllib.urlencode(sig) assert not tgt_verify(maxage = -9999, **sig) assert tgt_verify(maxage = 9999, **sig) diff --git a/verify.php b/verify.php new file mode 100644 index 0000000..797dae3 --- /dev/null +++ b/verify.php @@ -0,0 +1,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"; +} |