Is phpseclib ASN1 biginteger in MATH_BIGINTEGER_MODE_GMP incompatible with standard implementation?

107 views Asked by At

I'm using phpseclib to parse Apple application manifest (for in-app purchases). I can parse it in c# with ASN1 library of Liping Dai and everything as expected. Also I have two webhosts, "A" with php 5.4.45 and OpenSSL 1.0.1p 9 Jul 2015 and "B" with php 5.5.27 OpenSSL 1.0.1e-fips 11 Feb 2013.

Not sure what to blame, but on host "A" phpseclib/ASN1 parses manifest from byte string as expected, while on new "B" host I've faced strange problem. All BIGINT (type=integer) values were parsed to Math_Bigint with MATH_BIGINTEGER_MODE_GMP mode (phpseclib/Math/BigInteger.php). I debugged in c# and php simulateously and found that while structure is correct, int values are wrong - there were some resource values, which gave wrong int values.

I've solved it by commenting MATH_BIGINTEGER_MODE_GMP in phpseclib/Math/BigInteger.php::Math_BigInteger constructor, and thus switched it to MATH_BIGINTEGER_MODE_BCMATH mode. Now it works like on host "A". But that's looks like magic, and I hate magic in code. Did somebody bumped into this?

0

There are 0 answers