I can't comment on the potential OID mismatch. The best I can tell, it looks OK.
http://www.oid-info.com/cgi-bin/display?oid=1.2.840.10045.2.1&action=displayFrom my testing, I think some libraries expect a key with a named curve, rather than a key with the domain parameters enumerated as shown above. In the case of OpenSSL, it should read the key, but it will fail later when you try and use it in a web server with SSL_CTX_use_PrivateKey_file (cf.,
http://wiki.openssl.org/index.php/Elliptic_Curve_Cryptography#Named_Curves). So you should try with a named curve.
To write out the named curve, you have to SetEncodeAsOID(true) on the DL_GroupParameters_EC:
ECDSA<ECP, SHA1>::PrivateKey myPrivateKey;
...
myPrivateKey.AccessGroupParameters().SetEncodeAsOID(true);
The PEM Pack had similar problems (
http://www.cryptopp.com/wiki/PEM_Pack). The relevant code from the PEM Pack is below.
Jeff
**********
void PEM_Save(BufferedTransformation& bt, const DL_GroupParameters_EC<ECP>& params)
{
bool old = PEM_GetNamedCurve(params);
PEM_SetNamedCurve(params, true);
PEM_SaveParams(bt, params, SBB_EC_PARAMETERS_BEGIN, SBB_EC_PARAMETERS_END);
PEM_SetNamedCurve(params, old);
}
template <class EC>
bool PEM_GetNamedCurve(const DL_GroupParameters_EC<EC>& params)
{
return params.GetEncodeAsOID();
}
template <class EC>
void PEM_SetNamedCurve(const DL_GroupParameters_EC<EC>& params, bool flag)
{
DL_GroupParameters_EC<EC>& pp = const_cast<DL_GroupParameters_EC<EC>&>(params);
pp.SetEncodeAsOID(flag);
}