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 $postdata = file_get_contents("php://input");
20 if($postdata === false)
21 die("Cannot read from input");
22 $sig = $_SERVER["HTTP_X_D0_BLIND_ID_DETACHED_SIGNATURE"];
26 putenv("KEYGEN=$d0_blind_id_keygen");
28 "\"\$KEYGEN\" -p /dev/fd/3 -d /dev/fd/4 -s /dev/fd/5",
30 1 => array("pipe", "w"),
31 3 => array("file", $d0_blind_id_d0pk, "r"),
32 4 => array("pipe", "r"),
33 5 => array("pipe", "r")
41 die("Cannot start process");
45 5 => base64_decode($sig)
51 foreach($rpipes as $p)
52 stream_set_blocking($p, 0);
53 while(!empty($rpipes))
58 $n = stream_select($readers, $writers, $errorers, 1, 0);
62 foreach($errorers as $e)
64 $i = array_search($e, $rpipes);
72 foreach($writers as $w)
74 $i = array_search($w, $rpipes);
77 $written = fwrite($w, $buffers[$i], strlen($buffers[$i]));
79 $buffers[$i] = substr($buffers[$i], $written);
80 if($buffers[$i] == "")
92 die("could not write data to process");
93 $status = stream_get_line($outfh, 8192, "\n");
94 $idfp = stream_get_line($outfh, 8192, "\n");
95 $ret = proc_close($checker);
97 return array(null, null);
98 return array($idfp, $status);