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

version» Context lines:

pike.git/lib/modules/Standards.pmod/X509.pmod:1812:   }      //! DWIM-parse the ASN.1-sequence for a private key.   Crypto.Sign.State parse_private_key(Sequence seq)   {    switch(sizeof(seq)) {    case 5:    return Standards.PKCS.DSA.parse_private_key(seq);    case 9:    return Standards.PKCS.RSA.parse_private_key(seq); - #if constant(Nettle.ECC_Curve) +     case 2:    // ECDSA, implicit curve. Not supported yet.    return UNDEFINED;    case 3:    case 4: -  +  // Either PKCS#8 or ECDSA. +  Crypto.Sign res = Standards.PKCS.parse_private_key(seq); +  if (res) return res; + #if constant(Nettle.ECC_Curve) +  // EDCSA    return Standards.PKCS.ECDSA.parse_private_key(seq);   #endif    }    return UNDEFINED;   }      //! DWIM-parse the DER-sequence for a private key.   variant Crypto.Sign.State parse_private_key(string private_key)   {    Object seq = Standards.ASN1.Decode.secure_der_decode(private_key);    if (!seq || (seq->type_name != "SEQUENCE")) return UNDEFINED;    return parse_private_key([object(Sequence)]seq);   }