Beispiel #1
0
 /**
  * Parse the ASN data of a primitive type.
  * (Override this to parse specific types)
  * @param $data The ASN encoded data
  */
 protected function parse($data)
 {
     parent::parse($data);
     // 		$numarr = unpack("C*",$data);
     // 		$tempData =0;
     // 		foreach($numarr as $byte) {
     // 			$tempData =  ($tempData << 8 )+ $byte;
     // 		}
     //
     // 		$this->parsedData = $tempData;
 }
Beispiel #2
0
 /**
  * Parse an ASN.1 OID value.
  *
  * This takes the raw binary string that represents an OID value and parses it into its
  * dot notation form.  example - 1.2.840.113549.1.1.5
  * look up OID's here: http://www.oid-info.com/
  * (the multi-byte OID section can be done in a more efficient way, I will fix it later)
  *
  * @param	string	$data		The raw binary data string
  */
 protected function parse($string)
 {
     parent::parse($string);
     /* 	$ret = floor(ord($string[0])/40).".";
     		  $ret .= (ord($string[0]) % 40);
     		  $build = array();
     		  $cs = 0;
     
     		  for ($i=1; $i<strlen($string); $i++){
     		  $v = ord($string[$i]);
     		  if ($v>127){
     		  $build[] = ord($string[$i])-Asn_Markers::ASN_BIT;
     		  } elseif ($build){
     		  // do the build here for multibyte values
     		  $build[] = ord($string[$i])-Asn_Markers::ASN_BIT;
     		  // you know, it seems there should be a better way to do this...
     		  $build = array_reverse($build);
     		  $num = 0;
     		  for ($x=0; $x<count($build); $x++){
     		  $mult = $x==0?1:pow(256, $x);
     		  if ($x+1==count($build)){
     		  $value = ((($build[$x] & (Asn_Markers::ASN_BIT-1)) >> $x)) * $mult;
     		  } else {
     		  $value = ((($build[$x] & (Asn_Markers::ASN_BIT-1)) >> $x) ^ ($build[$x+1] << (7 - $x) & 255)) * $mult;
     		  }
     		  $num += $value;
     		  }
     		  $ret .= ".".$num;
     		  $build = array(); // start over
     		  } else {
     		  $ret .= ".".$v;
     		  $build = array();
     		  }
     		  }
     		  $this->parsedData = $ret;
     		 */
 }
Beispiel #3
0
 /**
  * Parse the ASN data of a primitive type.
  * (Override this to parse specific types)
  * @param $data The ASN encoded data
  */
 protected function parse($data)
 {
     //	$this->parsedData = (bool) $data;
     return parent::parse($data);
 }
Beispiel #4
0
 /**
  * Parse the ASN data of a primitive type.
  * (Override this to parse specific types)
  * @param $data The ASN encoded data
  */
 protected function parse($data)
 {
     //	$this->parsedData = unpack(($this->dataLength > 4 ? "d" : "f"),$data);;
     parent::parse($data);
 }
Beispiel #5
0
 /**
  * Parse the ASN data of a primitive type.
  * (Override this to parse specific types)
  * @param $data The ASN encoded data
  */
 protected function parse($data)
 {
     return parent::parse($data);
     //$this->parsedData = unpack("I*",$data);;
 }
Beispiel #6
0
 /**
  * convert the actual data we got from the ASN record to a readable information
  * @param $struct TODO
  * @param Asn_Object $asnData the parsed ASN.1 recrod.
  * @param $fields TODO
  * @return Array conatining the fields in the ASN record converted to readableformat and keyed by they're use.
  */
 protected function parseASNDataRecur($struct, $asnData, $fields)
 {
     $ret = false;
     if (isset($struct['type']) && $struct['type'] != 'array' || !($asnData instanceof Asn_Object && $asnData->isConstructed())) {
         if (!isset($struct['type']) || !isset($fields[$struct['type']])) {
             Billrun_Factory::log()->log(" couldn't digg into struct : " . print_r($struct, 1) . " data : " . $asnData->getData(), Zend_Log::DEBUG);
         } else {
             $ret = $this->parseField($fields[$struct['type']], $asnData->getData());
         }
     } else {
         foreach ($asnData->getData() as $parsedElem) {
             $key = $parsedElem->getType();
             if (isset($struct[$key])) {
                 $val = $this->parseASNDataRecur($struct[$key], $parsedElem, $fields);
                 if (isset($struct[$key]['type']) && $struct[$key]['type'] == 'array' || isset($ret[$struct[$key]['name']][0]) && is_array($ret[$struct[$key]['name']])) {
                     $ret[$struct[$key]['name']][] = $val;
                 } else {
                     if (isset($ret[$struct[$key]['name']])) {
                         $ret[$struct[$key]['name']] = array_merge(array($ret[$struct[$key]['name']]), array($val));
                     } else {
                         $ret[$struct[$key]['name']] = $val;
                     }
                 }
             }
         }
     }
     return $ret;
 }