pike.git / lib / modules / Tools.pmod / X509.pmod

version» Context lines:

pike.git/lib/modules/Tools.pmod/X509.pmod:1:   #pike __REAL_VERSION__      /* -  * $Id: X509.pmod,v 1.21 2004/01/11 00:40:49 nilsson Exp $ +  * $Id: X509.pmod,v 1.22 2004/01/24 23:29:58 nilsson Exp $    *    * Some random functions for creating RFC-2459 style X.509 certificates.    *    */      #if constant(Standards.ASN1.Types.Sequence)      import Standards.ASN1.Types;   import Standards.PKCS;   
pike.git/lib/modules/Tools.pmod/X509.pmod:204:    rsa_sha1_algorithm,    BitString(rsa_sign_digest(rsa, Identifiers.sha1_id,   #if constant(Crypto.SHA.name)    Crypto.SHA.hash(tbs->get_der())   #else    Crypto.sha()->update(tbs->get_der())->digest()   #endif    )) }) )->get_der();   }    + class Verifier { +  constant type = "none"; +  int(0..1) verify(object,string,string); +  this_program init(string key); +  +  optional Crypto.rsa rsa; // Ugly + } +    //!   class rsa_verifier   { -  object rsa; +  inherit Verifier; +  Crypto.rsa rsa;       constant type = "rsa";       //! -  object init(string key) -  { +  this_program init(string key) {    rsa = RSA.parse_public_key(key);    return rsa && this;    }       //! -  int verify(object algorithm, string msg, string signature) +  int(0..1) verify(object algorithm, string msg, string signature)    {    if (algorithm->get_der() == rsa_md5_algorithm->get_der())    return rsa_verify_digest(rsa, Identifiers.md5_id,   #if constant(Crypto.MD5.name)    Crypto.MD5.hash(msg),   #else    Crypto.md5()->update(msg)->digest(),   #endif    signature);    if (algorithm->get_der() == rsa_sha1_algorithm->get_der())
pike.git/lib/modules/Tools.pmod/X509.pmod:254:    signature);    return 0;    }   }      #if 0   /* FIXME: This is a little more difficult, as the dsa-parameters are    * sometimes taken from the CA, and not present in the keyinfo. */   class dsa_verifier   { +  inherit Verifier;    object dsa;       constant type = "dsa";       object init(string key)    {    }   }   #endif      //! - rsa_verifier make_verifier(object keyinfo) + Verifier make_verifier(object keyinfo)   {    if ( (keyinfo->type_name != "SEQUENCE")    || (sizeof(keyinfo->elements) != 2)    || (keyinfo->elements[0]->type_name != "SEQUENCE")    || !sizeof(keyinfo->elements[0]->elements)    || (keyinfo->elements[1]->type_name != "BIT STRING")    || keyinfo->elements[1]->unused)    return 0;       if (keyinfo->elements[0]->elements[0]->get_der()
pike.git/lib/modules/Tools.pmod/X509.pmod:307:    string der;       int version;    object serial;    object algorithm; /* Algorithm Identifier */    object issuer;    mapping not_after;    mapping not_before;       object subject; -  object public_key; +  Verifier public_key;       /* Optional */    object issuer_id;    object subject_id;    object extensions;       this_program init(Object asn1)    {    der = asn1->get_der();    if (asn1->type_name != "SEQUENCE")