From 7a9ea673ca1dc988269c870c63cbf17b13e836f4 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 5 May 2014 16:39:35 -0500 Subject: [PATCH 1/2] ASN1: make File_ASN1 accept int primitives and not just Math_BigInteger objects when an integer is expected The code to convert the regular integer type into the appropriate format could all just be in-line'd when an integer primitive is used but this approach is easier to read. --- phpseclib/File/ASN1.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index da70d415..11e48541 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -950,6 +950,9 @@ class File_ASN1 case FILE_ASN1_TYPE_INTEGER: case FILE_ASN1_TYPE_ENUMERATED: if (!isset($mapping['mapping'])) { + if (is_int($source)) { + $source = new Math_BigInteger($source); + } $value = $source->toBytes(true); } else { $value = array_search($source, $mapping['mapping']); From 1b9c59947665101420a8e696eaa280f37b61532f Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 5 May 2014 17:38:33 -0500 Subject: [PATCH 2/2] ASN1: let strings in as well --- phpseclib/File/ASN1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 11e48541..2774e7e8 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -950,7 +950,7 @@ class File_ASN1 case FILE_ASN1_TYPE_INTEGER: case FILE_ASN1_TYPE_ENUMERATED: if (!isset($mapping['mapping'])) { - if (is_int($source)) { + if (is_numeric($source)) { $source = new Math_BigInteger($source); } $value = $source->toBytes(true);