Branch: Tag:

2013-11-19

2013-11-19 14:05:50 by Martin Nilsson <nilsson@opera.com>

Improved the _sprintf of TBSCertificate.

275:    optional Crypto.RSA rsa; // Ugly   }    - protected class rsa_verifier + protected class RSAVerifier   {    inherit Verifier;    Crypto.RSA rsa;
283:    constant type = "rsa";       //! -  this_program init(string key) { +  protected void create(string key) {    rsa = RSA.parse_public_key(key); -  return rsa && this; +     }       //!
347:    || (seq[1]->get_der() != Null()->get_der()) )    return 0;    -  return rsa_verifier()->init(str->value); +  return RSAVerifier(str->value);    }       if(seq[0]->get_der() == Identifiers.dsa_sha_id->get_der())
418:    }    }    +  protected string get_id(object asn) +  { +  foreach(.PKCS.Identifiers.name_ids; string name; object id) +  if( asn==id ) return name; +  return (array(string))asn->id*"."; +  } +  +  protected array fmt_asn1(object asn) +  { +  array i = ({}); +  mapping m = ([]); +  +  foreach(asn->elements;; object o) +  { +  o = o[0]; +  string id = get_id(o[0]); +  i += ({ ([ id : o[1]->value]) }); +  if( m ) +  { +  if(m[id]) +  { +  m = 0; +  continue; +  } +  m[id] = o[1]->value; +  } +  } +  +  return m || i; +  } +     protected string _sprintf(int t)    { -  return t=='O' && sprintf("%O(%O)", this_program, cast("mapping")); +  if( t!='O' ) return UNDEFINED; +  mapping m = cast("mapping"); +  catch { +  m->issuer = fmt_asn1(m->issuer); +  m->subject = fmt_asn1(m->subject); +  }; +  return sprintf("%O(%O)", this_program, m);    }       //! Populates the object from a certificate decoded into an ASN.1