From a478b7486074b09337bcb774ad55249bcf7b315d Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 30 Mar 2014 01:11:47 -0500 Subject: [PATCH] ASN1: explicit application tags didn't work (although implicit ones did) --- phpseclib/File/ASN1.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 9c85083d..8627b814 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -1085,7 +1085,12 @@ class File_ASN1 } if (isset($mapping['cast'])) { - $tag = ($mapping['class'] << 6) | ($tag & 0x20) | $mapping['cast']; + if (isset($mapping['explicit']) || $mapping['type'] == FILE_ASN1_TYPE_CHOICE) { + $value = chr($tag) . $this->_encodeLength(strlen($value)) . $value; + $tag = ($mapping['class'] << 6) | 0x20 | $mapping['cast']; + } else { + $tag = ($mapping['class'] << 6) | (ord($temp[0]) & 0x20) | $mapping['cast']; + } } return chr($tag) . $this->_encodeLength(strlen($value)) . $value;