X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=library%2Fasn1.php;h=cda96b6c8a94e93a021ae5b7880840ceb7752c56;hb=528d175baa803035a8cc44ce7bda729911f1fd85;hp=5b1ad3b8fb842b1af72fac865ed4f205125b7d54;hpb=1b3501899289fc6cdbb04a0a0b918e151b4fe853;p=friendica.git diff --git a/library/asn1.php b/library/asn1.php index 5b1ad3b8fb..cda96b6c8a 100644 --- a/library/asn1.php +++ b/library/asn1.php @@ -4,6 +4,7 @@ // Attribution: http://www.krisbailey.com // license: unknown // modified: Mike Macgrivin mike@macgirvin.com 6-oct-2010 to support Salmon auto-discovery +// modified: Tobias Diekershoff 28-jul-2016 adding an intval in line 162 to make PHP7 happy // from openssl public keys @@ -155,11 +156,11 @@ class ASN_BASE { if (($length & ASN_LONG_LEN)==ASN_LONG_LEN){ $tempLength = 0; for ($x=0; $x<($length & (ASN_LONG_LEN-1)); $x++){ - $tempLength = ord($string[$p++]) + ($tempLength * 256); + $tempLength = @ord($string[$p++]) + ($tempLength * 256); } $length = $tempLength; } - $data = substr($string, $p, $length); + $data = substr($string, $p, intval($length)); $parsed[] = self::parseASNData($type, $data, $level, $maxLevels); $p = $p + $length; } @@ -186,8 +187,7 @@ class ASN_BASE { case ASN_BOOLEAN: return new ASN_BOOLEAN((bool)$data); case ASN_INTEGER: - return new ASN_INTEGER(accum($data)); -// return new ASN_INTEGER(ord($data)); + return new ASN_INTEGER(strtr(base64_encode($data),'+/','-_')); case ASN_BIT_STR: return new ASN_BIT_STR(self::parseASNString($data, $level+1, $maxLevels)); case ASN_OCTET_STR: @@ -290,14 +290,3 @@ class ASN_BASE { } - -function accum($s) { - $len = strlen($s); - $result = ''; - for ($i=0; $i < $len; $i++) { - $cur = substr($s,$i,1); - $result .= bin2hex($cur); - } - return $result; -} -