3 // you may want to override these after including this file
4 $d0_blind_id_keygen = "crypto-keygen-standalone";
5 $d0_blind_id_d0pk = "key_0.d0pk";
8 // list($status, $idfp) = get_d0_blind_id();
10 // null, null = signature failed
12 // idfp, 0 = signed, ID was not signed by CA
13 // idfp, 1 = signed, ID was signed by CA
14 function d0_blind_id_verify()
16 global $d0_blind_id_keygen;
17 global $d0_blind_id_d0pk;
19 if($_SERVER["REQUEST_METHOD"] == "POST")
20 $data = file_get_contents("php://input") . "\0" . $_SERVER["QUERY_STRING"];
22 $data = $_SERVER["QUERY_STRING"];
23 $sig = $_SERVER["HTTP_X_D0_BLIND_ID_DETACHED_SIGNATURE"];
27 putenv("KEYGEN=$d0_blind_id_keygen");
29 "\"\$KEYGEN\" -p /dev/fd/3 -d /dev/fd/4 -s /dev/fd/5",
31 1 => array("pipe", "w"),
32 3 => array("file", $d0_blind_id_d0pk, "r"),
33 4 => array("pipe", "r"),
34 5 => array("pipe", "r")
42 die("Cannot start process");
46 5 => base64_decode($sig)
52 foreach($rpipes as $p)
53 stream_set_blocking($p, 0);
54 while(!empty($rpipes))
59 $n = stream_select($readers, $writers, $errorers, 1, 0);
63 foreach($errorers as $e)
65 $i = array_search($e, $rpipes);
73 foreach($writers as $w)
75 $i = array_search($w, $rpipes);
78 $written = fwrite($w, $buffers[$i], strlen($buffers[$i]));
80 $buffers[$i] = substr($buffers[$i], $written);
81 if($buffers[$i] == "")
93 die("could not write data to process");
94 $status = stream_get_line($outfh, 8192, "\n");
95 $idfp = stream_get_line($outfh, 8192, "\n");
96 $ret = proc_close($checker);
98 return array(null, null);
99 return array($idfp, $status);