0299eade3ab12ea9f2b527483ae8f33cf513d68e
[cacert-devel.git] / includes / account_stuff.php
1 <? /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 $id = 0; if(array_key_exists("id",$_REQUEST)) $id=intval($_REQUEST['id']);
20 $expand="";
21
22 function showheader($title = "CAcert.org", $title2 = "")
23 {
24 global $id, $PHP_SELF;
25 $expand="";
26 $tmpid = $id;
27 if($PHP_SELF == "/wot.php")
28 $tmpid = $id + 500;
29 if($PHP_SELF == "/gpg.php")
30 $tmpid = $id + 1000;
31 if($PHP_SELF == "/disputes.php")
32 $tmpid = $id + 1500;
33 if($PHP_SELF == "/advertising.php")
34 $tmpid = $id + 2000;
35
36 switch($tmpid)
37 {
38 case 1:
39 case 2: $expand = " explode('emailacc');"; break;
40 case 3:
41 case 4:
42 case 5:
43 case 6: $expand = " explode('clicerts');"; break;
44 case 7:
45 case 8:
46 case 9: $expand = " explode('domains');"; break;
47 case 10:
48 case 11:
49 case 12:
50 case 15: $expand = " explode('servercert');"; break;
51 case 13:
52 case 14:
53 case 36:
54 case 41:
55 case 507:
56 case 508:
57 case 513: $expand = " explode('mydetails');"; break;
58 case 16:
59 case 17:
60 case 18:
61 case 19: $expand = " explode('clientorg');"; break;
62 case 20:
63 case 21:
64 case 22:
65 case 23: $expand = " explode('serverorg');"; break;
66 case 24:
67 case 25:
68 case 26:
69 case 27:
70 case 28:
71 case 29:
72 case 30:
73 case 31:
74 case 32:
75 case 33:
76 case 34:
77 case 35: $expand = " explode('orgadmin');"; break;
78 case 42:
79 case 43:
80 case 44:
81 case 45:
82 case 46:
83 case 47:
84 case 48:
85 case 49:
86 case 50:
87 case 54:
88 case 53: $expand = " explode('sysadmin');"; break;
89 case 500:
90 case 501:
91 case 502:
92 case 503:
93 case 504:
94 case 505:
95 case 506:
96 case 509:
97 case 510:
98 case 511:
99 case 512: $expand = " explode('WoT');"; break;
100 case 1000:
101 case 1001:
102 case 1002:
103 case 1003:
104 case 1004:
105 case 1005:
106 case 1006:
107 case 1007:
108 case 1008:
109 case 1009:
110 case 1010: $expand = " explode('gpg');"; break;
111 case 1500:
112 case 1501:
113 case 1502:
114 case 1503:
115 case 1504:
116 case 1505:
117 case 1506:
118 case 1507:
119 case 1508:
120 case 1509:
121 case 1510: $expand = " explode('disputes');"; break;
122 case 2000:
123 case 2001:
124 case 2002:
125 case 2003:
126 case 2004:
127 case 2005:
128 case 2006:
129 case 2007:
130 case 2008:
131 case 2009: $expand = " explode('advertising');"; break;
132 }
133
134 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
135 <html>
136 <head>
137 <title><?=$title?></title>
138 <? if(array_key_exists('header',$_SESSION) && $_SESSION['_config']['header'] != "") { ?><?=$_SESSION['_config']['header']?><? } ?>
139 <link rel="stylesheet" href="/styles/default.css" type="text/css" />
140 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
141 <script language="JavaScript" type="text/javascript">
142 function explode(e) {
143 if (document.getElementById(e).style.display == 'none') {
144 document.getElementById(e).style.display = 'block';
145 } else {
146 document.getElementById(e).style.display = 'none';
147 }
148 }
149
150 function hideall() {
151 var Nodes = document.getElementsByTagName('ul')
152 var max = Nodes.length
153 for(var i = 0;i < max;i++) {
154 var nodeObj = Nodes.item(i)
155 if (nodeObj.className == "menu") {
156 nodeObj.style.display = 'none';
157 }
158 }
159 }
160 </script>
161 </head>
162 <body onload="hideall(); explode('home');<?=$expand?>">
163 <div id="pagecell1">
164 <div id="pageName"><br>
165 <div id="pageLogo"><a href="http://<?=$_SESSION['_config']['normalhostname']?>"><img src="/images/cacert4.png" border="0" alt="CAcert.org logo"></a></div>
166 <div id="googlead"><h2><?=_("Free digital certificates!")?></h2></div>
167 </div>
168 <div id="pageNav">
169 <div class="relatedLinks">
170 <h3>CAcert.org</h3>
171 <ul class="menu" id="home"><li><a href="/index.php"><?=_("Go Home")?></a></li><li><a href="account.php?id=logout"><?=_("Logout")?></a></li></ul>
172 </div>
173 <div class="relatedLinks">
174 <h3 class="pointer" onclick="explode('mydetails')">+ <?=_("My Details")?></h3>
175 <ul class="menu" id="mydetails"><li><a href="account.php?id=13"><?=_("Edit")?></a></li><li><a href="account.php?id=14"><?=_("Change Password")?></a></li><li><a href="account.php?id=41"><?=_("Default Language")?></a></li><li><a href="wot.php?id=8"><?=_("My Listing")?></a></li><li><a href="wot.php?id=13"><?=_("My Location")?></a></li><li><a href="account.php?id=36"><?=_("My Alert Settings")?></a></li><li><a href="wot.php?id=10"><?=_("My Points")?></a></li><?
176 if($_SESSION['profile']['id'] == 1 || $_SESSION['profile']['id'] == 5897)
177 echo "<li><a href='sqldump.php'>SQL Dump</a></li>";
178 ?></ul>
179 </div>
180 <div class="relatedLinks">
181 <h3 class="pointer" onclick="explode('emailacc')">+ <?=_("Email Accounts")?></h3>
182 <ul class="menu" id="emailacc"><li><a href="account.php?id=1"><?=_("Add")?></a></li><li><a href="account.php?id=2"><?=_("View")?></a></li></ul>
183 </div>
184 <div class="relatedLinks">
185 <h3 class="pointer" onclick="explode('clicerts')">+ <?=_("Client Certificates")?></h3>
186 <ul class="menu" id="clicerts"><li><a href="account.php?id=3"><?=_("New")?></a></li><li><a href="account.php?id=5"><?=_("View")?></a></li></ul>
187 </div>
188 <? if($_SESSION['profile']['points'] >= 50) { ?>
189 <div class="relatedLinks">
190 <h3 class="pointer" onclick="explode('gpg')">+ <?=_("GPG/PGP Keys")?></h3>
191 <ul class="menu" id="gpg"><li><a href="gpg.php?id=0"><?=_("New")?></a></li><li><a href="gpg.php?id=2"><?=_("View")?></a></li></ul>
192 </div>
193 <? } ?>
194 <div class="relatedLinks">
195 <h3 class="pointer" onclick="explode('domains')">+ <?=_("Domains")?></h3>
196 <ul class="menu" id="domains"><li><a href="account.php?id=7"><?=_("Add")?></a></li><li><a href="account.php?id=9"><?=_("View")?></a></li></ul>
197 </div>
198 <div class="relatedLinks">
199 <h3 class="pointer" onclick="explode('servercert')">+ <?=_("Server Certificates")?></h3>
200 <ul class="menu" id="servercert"><li><a href="account.php?id=10"><?=_("New")?></a></li><li><a href="account.php?id=12"><?=_("View")?></a></li></ul>
201 </div>
202 <? if(mysql_num_rows(mysql_query("select * from `org` where `memid`='".intval($_SESSION['profile']['id'])."'")) > 0 || $_SESSION['profile']['orgadmin'] == 1) { ?>
203 <div class="relatedLinks">
204 <h3 class="pointer" onclick="explode('clientorg')">+ <?=_("Org Client Certs")?></h3>
205 <ul class="menu" id="clientorg"><li><a href="account.php?id=16"><?=_("New")?></a></li><li><a href="account.php?id=18"><?=_("View")?></a></li></ul>
206 </div>
207 <div class="relatedLinks">
208 <h3 class="pointer" onclick="explode('serverorg')">+ <?=_("Org Server Certs")?></h3>
209 <ul class="menu" id="serverorg"><li><a href="account.php?id=20"><?=_("New")?></a></li><li><a href="account.php?id=22"><?=_("View")?></a></li></ul>
210 </div>
211 <? } ?>
212 <? if(mysql_num_rows(mysql_query("select * from `org` where `memid`='".intval($_SESSION['profile']['id'])."' and `masteracc`='1'")) > 0 || $_SESSION['profile']['orgadmin'] == 1) { ?>
213 <div class="relatedLinks">
214 <h3 class="pointer" onclick="explode('orgadmin')">+ <?=_("Org Admin")?></h3>
215 <ul class="menu" id="orgadmin"><? if($_SESSION['profile']['orgadmin'] == 1) { ?><li><a href="account.php?id=24"><?=_("New Organisation")?></a></li><li><a href="account.php?id=25"><?=_("View Organisations")?></a></li><? } ?><li><a href="account.php?id=35"><?=_("View")?></a></li></ul>
216 </div>
217 <? } ?>
218 <div class="relatedLinks">
219 <h3 class="pointer" onclick="explode('WoT')">+ <?=_("CAcert Web of Trust")?></h3>
220 <ul class="menu" id="WoT"><li><a href="wot.php?id=0"><?=_("About")?></a></li><li><a href="wot.php?id=12"><?=_("Find an Assurer")?></a></li><li><a href="wot.php?id=3"><?=_("Rules")?></a></li><li><? if($_SESSION['profile']['assurer'] != 1) { ?><a href="wot.php?id=2"><?=_("Becoming an Assurer")?></a><? } else { ?><a href="wot.php?id=5"><?=_("Assure Someone")?></a><? } ?></li><li><a href="wot.php?id=4"><?=_("Trusted ThirdParties")?></a></li><? if($_SESSION['profile']['points'] >= 500) { ?><li><a href="wot.php?id=11"><div style="white-space:nowrap"><?=_("Organisation Assurance")?></div></a></li><? } ?><li><a href="account.php?id=55"><?=_("Training")?></a></li></ul>
221 </div>
222 <div class="relatedLinks">
223 <h3 class="pointer" onclick="explode('WoTForms')">+ <?=_("CAP Forms")?></h3><?
224 $name = $_SESSION['profile']['fname']." ".$_SESSION['profile']['mname']." ".$_SESSION['profile']['lname']." ".$_SESSION['profile']['suffix'];
225 while(strstr($name, " "))
226 $name = str_replace(" ", " ", $name);
227 $extra = "?name=".urlencode($name);
228 $extra .= "&amp;dob=".urlencode($_SESSION['profile']['dob']);
229 $extra .= "&amp;email=".urlencode($_SESSION['profile']['email']);
230
231 $extra2 = "?assurer=".urlencode($name)."&amp;date=now&amp;maxpoints=".maxpoints();
232 ?>
233 <ul class="menu" id="WoTForms">
234 <li><a href="/cap.php<?=$extra?>">A4 - <?=_("WoT Form")?></a></li>
235 <li><a href="/cap.php<?=$extra?>&amp;format=letter">US - <?=_("WoT Form")?></a></li>
236 <? /* <li><div style="white-space:nowrap"><a href="/ttp.php<?=$extra?>">A4 - <?=_("TTP Form")?></a></div></li>
237 <li><div style="white-space:nowrap"><a href="/ttp.php<?=$extra?>&amp;format=letter">US - <?=_("TTP Form")?></a></div></li> */
238 ?>
239 <? if($_SESSION['profile']['points'] > 100) { ?><li><div style="white-space:nowrap"><a href="/cap.php<?=$extra2?>">A4 - <?=_("Assurance Form")?></a></div></li>
240 <li><div style="white-space:nowrap"><a href="/cap.php<?=$extra2?>&amp;format=letter">US - <?=_("Assurance Form")?></a></div></li>
241 <? } ?>
242 <? /*
243 <li><div style="white-space:nowrap"><a href="/ttp.php">A4 - <?=_("Blank TTP Form")?></a></div></li>
244 <li><div style="white-space:nowrap"><a href="/ttp.php?&amp;format=letter">US - <?=_("Blank TTP Form")?></a></div></li>
245 */ ?>
246 <li><div style="white-space:nowrap"><a href="/cap.php">A4 - <?=_("Blank CAP Form")?></a></div></li>
247 <li><div style="white-space:nowrap"><a href="/cap.php?&amp;format=letter">US - <?=_("Blank CAP Form")?></a></div></li></ul>
248 </div>
249 <? if($_SESSION['profile']['admin'] == 1 || $_SESSION['profile']['locadmin'] == 1) { ?>
250 <div class="relatedLinks">
251 <h3 class="pointer" onclick="explode('sysadmin')">+ <?=_("System Admin")?></h3>
252 <ul class="menu" id="sysadmin"><? if($_SESSION['profile']['admin'] == 1) { ?><li><a href="account.php?id=42"><?=_("Find User")?></a></li><li><a href="account.php?id=48"><?=_("Find Domain")?></a></li><? } if($_SESSION['profile']['locadmin'] == 1) { ?><li><a href="account.php?id=53"><?=_("Location DB")?></a></li><? } ?></ul>
253 </div>
254 <? } ?>
255 <div class="relatedLinks">
256 <h3 class="pointer" onclick="explode('disputes')">+ <?=_("Disputes/Abuses")?></h3>
257 <ul class="menu" id="disputes"><li><a href="disputes.php?id=0"><?=_("More Information")?></a></li><li><a href="disputes.php?id=1"><?=_("Email Dispute")?></a></li><li><a href="disputes.php?id=2"><?=_("Domain Dispute")?></a></li><? if($_SESSION['profile']['admin'] == 1) { ?><li><a href="disputes.php?id=3"><?=_("Abuses")?></a></li><? } ?></ul>
258 </div>
259 <? if($_SESSION['profile']['adadmin'] >= 1) { ?>
260 <div class="relatedLinks">
261 <h3 class="pointer" onclick="explode('advertising')">+ <?=_("Advertising")?></h3>
262 <ul class="menu" id="advertising"><li><a href="advertising.php?id=1"><?=_("New Ad")?></a></li><li><a href="advertising.php?id=0"><?=_("View Ads")?></a></li></ul>
263 </div>
264 <? } ?>
265 </div>
266 <div id="content">
267 <div class="story">
268 <h3><?=$title2?></h3>
269 <? if($_SESSION['_config']['errmsg'] != "") { ?>
270 <p><font color="#ff0000" size="+2"><? echo $_SESSION['_config']['errmsg']; $_SESSION['_config']['errmsg'] = ""; ?> </font></p>
271 <? } ?>
272 <?
273 }
274
275 function showfooter()
276 {
277 ?>
278 </div>
279 </div>
280 <div id="siteInfo"><a href="account.php?id=37"><?=_("About Us")?></a> | <a href="account.php?id=38"><?=_("Donations")?></a> | <a href="http://wiki.cacert.org/wiki/CAcertIncorporated"><?=_("Association Membership")?></a> |
281 <a href="account.php?id=39"><?=_("Privacy Policy")?></a> | <a href="account.php?id=40"><?=_("Contact Us")?></a>
282 | &copy;2002-<?=date("Y")?> <?=_("by CAcert")?></div>
283 </div>
284 </body>
285 </html><?
286 }
287
288 /**
289 * Produces a log entry with the error message with log level E_USER_WARN
290 * and a random ID an returns a message that can be displayed to the user
291 * including the generated ID
292 *
293 * @param $errormessage string
294 * The error message that should be logged
295 * @return string containing the generated ID that can be displayed to the
296 * user
297 */
298 function failWithId($errormessage) {
299 $errorId = rand();
300 trigger_error("$errormessage. ID: $errorId", E_USER_WARNING);
301 return sprintf(_("Something went wrong when processing your request. ".
302 "Please contact %s for help and provide them with the ".
303 "following ID: %d"),
304 "<a href='mailto:support@cacert.org?subject=System%20Error%20-%20".
305 "ID%3A%20$errorId'>support@cacert.org</a>",
306 $errorId);
307 }
308
309 /**
310 * Checks whether the given CSR contains a vulnerable key
311 *
312 * @param $csr string
313 * The CSR to be checked
314 * @param $encoding string [optional]
315 * The encoding the CSR is in (for the "-inform" parameter of OpenSSL,
316 * currently only "PEM" (default) or "DER" allowed)
317 * @return string containing the reason if the key is considered weak,
318 * empty string otherwise
319 */
320 function checkWeakKeyCSR($csr, $encoding = "PEM")
321 {
322 /* If another encoding is used: convert to PEM */
323 if ($encoding !== "PEM")
324 {
325 // other encodings may be binary so don't use echo
326 $descriptorspec = array(
327 0 => array("pipe", "r"), // STDIN for child
328 1 => array("pipe", "w"), // STDOUT for child
329 2 => array("file", "/dev/null", "w") // ignore STDERR
330 );
331 $encoding = escapeshellarg($encoding);
332 $proc = proc_open("openssl req -inform $encoding -outform PEM",
333 $descriptorspec, $pipes);
334
335 if (is_resource($proc))
336 {
337 fwrite($pipes[0], $csr);
338 fclose($pipes[0]);
339
340 $csr = stream_get_contents($pipes[1]);
341 fclose($pipes[1]);
342
343 proc_close($proc);
344 } else {
345 trigger_error("checkWeakKeyCSR(): Failed to start OpenSSL",
346 E_USER_ERROR);
347 return _("Something went wrong when parsing the certificate ".
348 "signing request!");
349 }
350 }
351
352
353 /* Check for the debian OpenSSL vulnerability */
354
355 $csr = escapeshellarg($csr);
356 exec("echo $csr | openssl-vulnkey -q -", $dummy, $debianVuln);
357 if ($debianVuln === -1)
358 {
359 return sprintf(_("The keys you use have very likely been ".
360 "generated with a vulnerable version of OpenSSL which was ".
361 "distributed by debian. Please generate new keys. More ".
362 "information about this issue can be found in %sthe ".
363 "wiki%s"),
364 "<a href='//wiki.cacert.org/WeakKeys#DebianVulnerability'>",
365 "</a>");
366 } elseif ($debianVuln !== 0) {
367 trigger_error("checkWeakKeyCSR(): Something went wrong in the ".
368 "openssl-vulnkey call", E_USER_ERROR);
369 }
370
371 // $csr already escaped
372 $csrText = `echo $csr | openssl req -text -noout`;
373 return checkWeakKeyText($csrText);
374 }
375
376 /**
377 * Checks whether the given SPKAC contains a vulnerable key
378 *
379 * @param $spkac string
380 * The SPKAC to be checked
381 * @param $spkacname string [optional]
382 * The name of the variable that contains the SPKAC. The default is
383 * "SPKAC"
384 * @return string containing the reason if the key is considered weak,
385 * empty string otherwise
386 */
387 function checkWeakKeySPKAC($spkac, $spkacname = "SPKAC")
388 {
389 /* Check for the debian OpenSSL vulnerability */
390
391 $spkac = escapeshellarg($spkac);
392 $spkacname = escapeshellarg($spkacname);
393
394 $spkacText = `echo $spkac | openssl spkac -spkac $spkacname`;
395
396 /* Which public key algorithm? */
397 if (!preg_match('/^\s*Public Key Algorithm: ([^\s]+)$/m', $spkacText,
398 $algorithm))
399 {
400 trigger_error("checkWeakKeySPKAC(): Couldn't extract the public ".
401 "key algorithm used", E_USER_WARNING);
402 return "";
403 } else {
404 $algorithm = $algorithm[1];
405 }
406
407 if ($algorithm === "rsaEncryption")
408 {
409 if (!preg_match('/^\s*RSA Public Key: \((\d+) bit\)$/m', $spkacText,
410 $keysize))
411 {
412 trigger_error("checkWeakKeySPKAC(): Couldn't parse the RSA ".
413 "key size", E_USER_WARNING);
414 } else {
415 $keysize = $keysize[1];
416
417 // $spkac and $spkacname already escaped
418 $modulus = `echo $spkac | openssl spkac -spkac $spkacname \
419 -pubkey -noout | openssl rsa -pubin -modulus -noout`;
420
421 if (!preg_match('/^Modulus=([0-9A-F]+)$/', $modulus, $modulus))
422 {
423 trigger_error("checkWeakKeySPKAC(): Couldn't parse the ".
424 "RSA modulus", E_USER_WARNING);
425 } else {
426 $modulus = $modulus[1];
427
428 $keysize = escapeshellarg($keysize);
429 $modulus = escapeshellarg($modulus);
430 exec("openssl-vulnkey -q -b $keysize -m $modulus", $dummy,
431 $debianVuln);
432 if ($debianVuln === -1)
433 {
434 return sprintf(_("The keys you use have very likely been ".
435 "generated with a vulnerable version of OpenSSL which was ".
436 "distributed by debian. Please generate new keys. More ".
437 "information about this issue can be found in %sthe ".
438 "wiki%s"),
439 "<a href='//wiki.cacert.org/WeakKeys#DebianVulnerability'>",
440 "</a>");
441 } elseif ($debianVuln !== 0) {
442 trigger_error("checkWeakKeySPKAC(): Something went ".
443 "wrong in the openssl-vulnkey call", E_USER_ERROR);
444 }
445 }
446 }
447 }
448
449 return checkWeakKeyText($spkacText);
450 }
451
452 /**
453 * Checks whether the given text representation of a CSR or a SPKAC contains
454 * a weak key.
455 * ONLY TO BE USED BY THE MORE SPECIAL METHODS checkWeakKeyCSR() AND
456 * checkWeakKeySPKAC()
457 *
458 * @param $text string
459 * The text representation of a key as output by the
460 * "openssl <foo> -text -noout" commands
461 * @return string containing the reason if the key is considered weak,
462 * empty string otherwise
463 */
464 function checkWeakKeyText($text)
465 {
466 /* Which public key algorithm? */
467 if (!preg_match('/^\s*Public Key Algorithm: ([^\s]+)$/m', $text,
468 $algorithm))
469 {
470 return failWithId("checkWeakKeyText(): Couldn't extract the ".
471 "public key algorithm used");
472 } else {
473 $algorithm = $algorithm[1];
474 }
475
476
477 if ($algorithm === "rsaEncryption")
478 {
479 if (!preg_match('/^\s*RSA Public Key: \((\d+) bit\)$/m', $text,
480 $keysize))
481 {
482 return failWithId("checkWeakKeyText(): Couldn't parse the RSA ".
483 "key size");
484 } else {
485 $keysize = intval($keysize[1]);
486 }
487
488 if ($keysize < 1024)
489 {
490 return sprintf(_("The keys that you use are very small ".
491 "and therefore insecure. Please generate stronger ".
492 "keys. More information about this issue can be ".
493 "found in %sthe wiki%s"),
494 "<a href='//wiki.cacert.org/WeakKeys#SmallKey'>",
495 "</a>");
496 } elseif ($keysize < 2048) {
497 // not critical but log so we have some statistics about
498 // affected users
499 trigger_error("checkWeakKeyText(): Certificate for small ".
500 "key (< 2048 bit) requested", E_USER_NOTICE);
501 }
502
503
504 if (!preg_match('/^\s*Exponent: (\d+) \(0x[0-9a-fA-F]+\)$/m', $text,
505 $exponent))
506 {
507 return failWithId("checkWeakKeyText(): Couldn't parse the RSA ".
508 "exponent");
509 } else {
510 $exponent = $exponent[1]; // exponent might be very big =>
511 //handle as string using bc*()
512
513 if (bccomp($exponent, "3") === 0)
514 {
515 return sprintf(_("The keys you use might be insecure. ".
516 "Although there is currently no known attack for ".
517 "reasonable encryption schemes, we're being ".
518 "cautious and don't allow certificates for such ".
519 "keys. Please generate stronger keys. More ".
520 "information about this issue can be found in ".
521 "%sthe wiki%s"),
522 "<a href='//wiki.cacert.org/WeakKeys#SmallExponent'>",
523 "</a>");
524 } elseif (!(bccomp($exponent, "65537") >= 0 &&
525 (bccomp($exponent, "100000") === -1 ||
526 // speed things up if way smaller than 2^256
527 bccomp($exponent, bcpow("2", "256")) === -1) )) {
528 // 65537 <= exponent < 2^256 recommended by NIST
529 // not critical but log so we have some statistics about
530 // affected users
531 trigger_error("checkWeakKeyText(): Certificate for ".
532 "unsuitable exponent '$exponent' requested",
533 E_USER_NOTICE);
534 }
535 }
536 }
537
538 /* No weakness found */
539 return "";
540 }
541 ?>