Branch: Tag:

2017-08-22

2017-08-22 14:03:07 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Standards.PKCS: Fixed decoding of PKCS#8 public keys.

The public key data is for some reason kept in a BIT STRING
(and not in an OCTET STRING)...

103:    if (!o || o->type_name != "SEQUENCE") return UNDEFINED;    return parse_private_key([object(Sequence)]o, c);   } +  + //! Create a DER-coded ECPublicKey structure + //! @param ecdsa + //! @[Crypto.ECC.Curve()->ECDSA] object. + //! @returns + //! ASN.1 coded ECPublicKey structure as specified in + //! @rfc{5480:2@}. + string(8bit) public_key(Crypto.ECC.SECP_521R1.ECDSA ecdsa) + { +  return ecdsa->pkcs_public_key()->get_der(); + } +  + //! Get an initialized ECDSA object from an ECC curve and an ec public key. + //! + //! See @rfc{5280:4.1.2.7@} and @rfc{5480:2.2@}. + Crypto.ECC.SECP_521R1.ECDSA parse_public_key(string(8bit) key, Crypto.ECC.Curve c) + { +  Crypto.ECC.SECP_521R1.ECDSA res = c->ECDSA(); +  res->set_public_key(key); +  return res; + }