pike.git / lib / modules / SSL.pmod / asn1.pmod.pike

version» Context lines:

pike.git/lib/modules/SSL.pmod/asn1.pmod.pike:1:   /* asn1.pmod.pike    *    * Rudimentary support for decoding ASN.1 encoded data.    * -  * $Id: asn1.pmod.pike,v 1.2 1997/03/15 07:10:53 nisse Exp $ +  * $Id: asn1.pmod.pike,v 1.3 1997/03/15 12:15:07 nisse Exp $    */      /* BER decoder    *    * Values are represented as arrays ({ tag, value }).    * Tag is either an integer tag number, or a string, in case    * the tag recognized.    *    * Values are strings, integers, or arrays */      class ber_decode {    inherit ADT.struct;       array get_asn1()    {    int|string tag = get_int(1);    int len;    string contents;    mixed value;    -  + #ifdef SSL3_DEBUG    werror(sprintf("decoding tag %x\n", tag)); -  + #endif    if ( (tag & 0x1f) == 0x1f)    throw( ({ "high tag numbers is not supported\n", backtrace() }) );    int len = get_int(1);    if (len & 0x80)    len = get_int(len & 0x7f);    -  + #ifdef SSL3_DEBUG    werror(sprintf("len : %d\n", len)); -  + #endif    contents = get_fix_string(len); -  + #ifdef SSL3_DEBUG    werror(sprintf("contents: %O\n", contents)); -  + #endif    if (tag & 0x20)    {    object seq = object_program(this_object())(contents);    value = ({ });    while(! seq->is_empty())    {    array elem = seq->get_asn1(); -  + #ifdef SSL3_DEBUG    // werror(sprintf("elem: %O\n", elem)); -  + #endif    value += ({ elem });    }    }    switch(tag & 0xdf)    {    case 1: /* Boolean */    if (strlen(contents) != 1)    throw( ({ "SSL.asn1: Invalid boolean value.\n", backtrace() }) );    tag = "BOOLEAN";    value = !!contents[0];