Ejemplo n.º 1
0
 protected static function _decodeFromDER(Identifier $identifier, $data, &$offset)
 {
     $idx = $offset;
     if (!$identifier->isPrimitive()) {
         throw new DecodeException("Null value must be primitive.");
     }
     // null type has always zero length
     Length::expectFromDER($data, $idx, 0);
     $offset = $idx;
     return new self();
 }
Ejemplo n.º 2
0
 /**
  *
  * @see \ASN1\Element::_decodeFromDER()
  * @return self
  */
 protected static function _decodeFromDER(Identifier $identifier, $data, &$offset)
 {
     $idx = $offset;
     if (!$identifier->isPrimitive()) {
         throw new DecodeException("DER encoded string must be primitive.");
     }
     $length = Length::expectFromDER($data, $idx);
     $str = $length->length() ? substr($data, $idx, $length->length()) : "";
     // substr should never return false, since length is
     // checked by Length::expectFromDER.
     assert('is_string($str)', "substr");
     $offset = $idx + $length->length();
     try {
         return new static($str);
     } catch (\InvalidArgumentException $e) {
         throw new DecodeException($e->getMessage(), null, $e);
     }
 }