Hi All,
I tried to punt on Initialize. Since I am worried I may be confusing
variables (NIST: r = Crypto++: n, etc).Still no joy.
I know Curve ec is correct - it is p, a, and b.
I know G is correct - it is x, y.
That leave two big numbers. When I try to inialize as below, I still
fail??? Any help or would be greatly appreciated.
Jeff
// PrivateKey.Initialize( ec, CryptoPP::ECP::Point( x, y ), n, h );
// PrivateKey.Initialize( rng, ec, CryptoPP::ECP::Point( x, y ), h );
// PrivateKey.Initialize( rng, ec, CryptoPP::ECP::Point( x, y ), n );
On 11/16/06, Jeffrey Walton <[EMAIL PROTECTED]> wrote:
Hi All,
Below is the sample which demonstrates the failure. My one question is
in reference to cofactor S - it seems very large. If I interpreted the
document correctly, this may be an issue in the Library.
I attached Curve P192 Parameters from the NiIST document, "RECOMMENDED
ELLIPTIC CURVES FOR FEDERAL GOVERNMENT USE", July 1999.
Jeff
#include <iostream>
#include "cryptlib.h"
#include "osrng.h"
#include "eccrypto.h"
#include "ecp.h"
#include "integer.h"
int main(int argc, char* argv[]) {
try {
CryptoPP::AutoSeededRandomPool rng;
// User Defined Domain Parameters
// This is Curve P-192 from NIST
// (Recommended Elliptic Curves for Federal Government Use)
CryptoPP::Integer
p("6277101735386680763835789423207666416083908700390324961279");
CryptoPP::Integer a("-3");
CryptoPP::Integer
b("0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1");
CryptoPP::Integer
n("6277101735386680763835789423176059013767194773182842284081");
CryptoPP::Integer
h("0x3045ae6fc8422f64ed579528d38120eae12196d5");
CryptoPP::Integer
x("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff101207192b95");
CryptoPP::Integer
y("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811");
CryptoPP::ECP ec( p, a, b );
CryptoPP::ECIES< CryptoPP::ECP >::PrivateKey PrivateKey;
CryptoPP::ECIES< CryptoPP::ECP >::PublicKey PublicKey;
// Curve Initialization and Public Key Generation
PrivateKey.Initialize( ec, CryptoPP::ECP::Point( x, y ), n, h );
PrivateKey.MakePublicKey( PublicKey );
// Key Validation
//
// User Defined Domain Parameters always fail, even at level 0???
//
// From cryptlib.h, Validate(...):
//
// 0 - using this object won't cause a crash or exception (rng
is ignored)
// 1 - this object will probably function (encrypt, sign,
etc.) correctly
// (but may not check for weak keys and such)
// 2 - make sure this object will function correctly, and do
reasonable
// security checks
// 3 - do checks that may take a long time
//
if( false == PrivateKey.Validate( rng, 0 ) )
{ throw std::string( "Private Key Validation Failure" ); }
if( false == PublicKey.Validate( rng, 0 ) )
{ throw std::string( "Public Key Validation Failure" ); }
}
catch( CryptoPP::Exception& e )
{ std::cerr << "Crypto++ Error: " << e.what() << std::endl; }
catch( std::string& s )
{ std::cerr << "Error: " << s << std::endl; }
catch (...)
{ std::cerr << "Unknown Error" << std::endl; }
return 0;
}