Hi @ all,

at the first, sorry for my bad english :(

I have a little trouble with the creation of private key's.

I have written 5 classes for map the cryptopp RSA PK Functions for my cases.
CCreateRSAKeyPair

CPublicKeyEncrypt
CPrivateKeyDecrypt

CPrivateKeyEncrypt
CPublicKeyDecrypt

All the classes works .. but ,

At this time, i need to create 2 variants of Key pairs.
The first pair for the CPublicKeyEncrypt / CPrivateKeyDecrypt
and the second for CPrivateKeyEncrypt / CPublicKeyDecrypt

The key creation looks like this :
            AutoSeededRandomPool rng;

           RSAES_OAEP_SHA_Decryptor priv(rng, KeySize);
           RSAES_OAEP_SHA_Encryptor shortPriv(priv);

           HexEncoder privFile(new FileSink("privFile.txt"));
           HexEncoder privFileShort(new FileSink("shortPrivFile.txt"));

           priv.DEREncode(privFile);
           shortPriv.DEREncode(privFileShort);

           privFile.MessageEnd();
           privFileShort.MessageEnd();

           RSAES_OAEP_SHA_Encryptor pub(priv);

           HexEncoder pubFile(new FileSink("pubFile.txt"));
           pub.DEREncode(pubFile);
           pubFile.MessageEnd();

The pair privFile.txt / pubFile.txt is for the CPublicKeyEncrypt / CPrivateKeyDecrypt and
the pair shortPrivFile.txt / pubFile.txt CPrivateKeyEncrypt / CPublicKeyDecrypt.


So it works fine. But i need 3 Files with key's ....
The short one of the key, i create from the normal priv key.
Now my question, How can i create the short one from the privKey.txt file ?
I have tested much , but i always the error 'BER Decode Error' occurs.

fSource = FileSource("privKey.txt", true, new HexDecoder( newStringSink(m_szPrivKey)));
error-> RSAES_OAEP_SHA_Decryptor priv(fSource);


Has anyone an idea, how can i create the short privKey from the long privKey.txt File ?
I hope someone can help me ... please


Best regards
Torsten



Reply via email to