URI: 
       tadd dsa x509 - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 74fc94d47e68684567f16d3d09b822cdad721e4a
   DIR parent 039b8c9af0866a5a6607cbdd992b586896d48cdc
  HTML Author: rsc <devnull@localhost>
       Date:   Sun, 13 Feb 2005 18:35:11 +0000
       
       add dsa x509
       
       Diffstat:
         M src/libsec/port/x509.c              |      74 +++++++++++++++++++++++++++++++
       
       1 file changed, 74 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/src/libsec/port/x509.c b/src/libsec/port/x509.c
       t@@ -1934,6 +1934,68 @@ errret:
                return nil;
        }
        
       +/*
       + *         DSAPrivateKey ::= SEQUENCE{
       + *                version Version,
       + *                p INTEGER,
       + *                q INTEGER,
       + *                g INTEGER, -- alpha
       + *                pub_key INTEGER, -- key
       + *                priv_key INTEGER, -- secret
       + *        }
       + */
       +static DSApriv*
       +decode_dsaprivkey(Bytes* a)
       +{
       +        int version;
       +        Elem e;
       +        Elist *el;
       +        mpint *mp;
       +        DSApriv* key;
       +
       +        key = dsaprivalloc();
       +        if(decode(a->data, a->len, &e) != ASN_OK)
       +                goto errret;
       +        if(!is_seq(&e, &el) || elistlen(el) != 6)
       +                goto errret;
       +version=-1;
       +        if(!is_int(&el->hd, &version) || version != 0)
       +{
       +fprint(2, "version %d\n", version);
       +                goto errret;
       +        }
       +
       +        el = el->tl;
       +        key->pub.p = mp = asn1mpint(&el->hd);
       +        if(mp == nil)
       +                goto errret;
       +
       +        el = el->tl;
       +        key->pub.q = mp = asn1mpint(&el->hd);
       +        if(mp == nil)
       +                goto errret;
       +
       +        el = el->tl;
       +        key->pub.alpha = mp = asn1mpint(&el->hd);
       +        if(mp == nil)
       +                goto errret;
       +
       +        el = el->tl;
       +        key->pub.key = mp = asn1mpint(&el->hd);
       +        if(mp == nil)
       +                goto errret;
       +
       +        el = el->tl;
       +        key->secret = mp = asn1mpint(&el->hd);
       +        if(mp == nil)
       +                goto errret;
       +
       +        return key;
       +errret:
       +        dsaprivfree(key);
       +        return nil;
       +}
       +
        static mpint*
        asn1mpint(Elem *e)
        {
       t@@ -1984,6 +2046,18 @@ asn1toRSApriv(uchar *kd, int kn)
                return key;
        }
        
       +DSApriv*
       +asn1toDSApriv(uchar *kd, int kn)
       +{
       +        Bytes *b;
       +        DSApriv *key;
       +
       +        b = makebytes(kd, kn);
       +        key = decode_dsaprivkey(b);
       +        freebytes(b);
       +        return key;
       +}
       +
        /*
         * digest(CertificateInfo)
         * Our ASN.1 library doesn't return pointers into the original