> My first question is that why key files contents are as above,whereas > in the code defined 1024 bits(128 bytes) for modulus n? > Why does "key.pv" contain 633 bytes?! > And which part is n and wich part is d? > Because the key files are hex encoded and contain more than just the modulus. The public key is a DER-encoded subjectPublicKeyInfo structure. See RFC 5280 for the structure and RFC 3279 for the RSA-specific contents.
The private key file is a DER-encoded PKCS#8 PrivateKeyInfo structure. The format of the PrivateKey field in that structure is RSAPrivateKey, as defined in PKCS#1. The definition of both of those is available from RSA here: http://www.rsa.com/rsalabs/node.asp?id=2124 in the PKCS#8 and PKCS#1 ASN.1 modules, respectively. > > > My second question: > Because I want to generate key pair and locate them in two byte > arrays, I used of "ArraySink" instead of "FileSink" and changed the > above code as below: > > Look here: > byte* privatekey; > byte* publickey; and here: > CryptoPP::HexEncoder privArray(new > CryptoPP::ArraySink(privatekey,sizeof(privatekey)) > ); // Hex Encoder > sizeof(privatekey) is sizeof(byte *). That''s a problem when you then tell crypto++ to copy more than sizeof(byte *) into the array :-). Hope that helps, Geoff Ho --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
