Hi dear Jeff and Geoff!
I read RFC5280 for subjectPublicKeyInfo structure and found it as
below:
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING }
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE {
extnID OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extnValue OCTET STRING
-- contains the DER encoding of an ASN.1 value
-- corresponding to the extension type identified
-- by extnID
}
And PrivateKeyInfo as below:
PrivateKeyInfo ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey,
attributes [0] IMPLICIT Attributes OPTIONAL }
Version ::= INTEGER
PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
PrivateKey ::= OCTET STRING
Attributes ::= SET OF Attribute
But I can't understand which part of public or private key is "n" and
which part of private key is "d" and which part of public key is "e"
yet!
What I want, is that generate 128 bytes(Hex bytes) for n(modulus) and
128 bytes for d(private exponent)
and store them into two byte array!
In the below command,default value for e(public exponent) is 17:
// Specify 1024 bit modulus, accept e = 17
CryptoPP::RSAES_OAEP_SHA_Decryptor Decryptor( rng, 1024 /*, e
*/ );
and I accepted it!
I want to use this code(generating keypair) in my project and store
them into two "just 256 length" byte array in Hex form(e.g 0x2d,
0x56,...) and need to know which part is exactly n(128 bytes) and
which part is exactly d(128 bytes) and which part is exactly e!
Could you help me about this?
Unfortunately,I don't have any time for complete studying.
How can I achieve this purpose?
I've spent much time on it ,I only should work with sample codes which
are built successfully!
One other request!
Have you any successfully built sample codes of hashing data with SHA1
algorithm?
Sample codes in "Crypto++ user's guide" don't match with "CryptoPP
5.5.2" version and couldn't help me at all ,so I need a sample code
of hashing data with SHA1 algorithm which stores the digest in a byte
array that will be compiled successfully such examples on this page:
http://www.cryptopp.com/wiki/RSA_Cryptography#Key_Encoding
Any help will be greatly appreciated!
I need so help, please help me!
Gary
On Feb 22, 1:58 am, Jeffrey Walton <[email protected]> wrote:
> Hi Geoff,
>
> This question seems to crop up every now and again, so it has been
> added to the wiki. I hope you don't
> mind.http://www.cryptopp.com/wiki/RSA_Cryptography#Key_Encoding
>
> Jeff
>
> On Feb 21, 2:23 pm, Geoff Beier <[email protected]> wrote:
>
> > > 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.
-~----------~----~----~----~------~----~------~--~---