Hi, I am using CRSAKeypair class which returns the public key and private key which is in long format , i want it to convert to TBuf format how should i proceed . I have tried creation of pointers but still no luck .. is there any other way
You could perhaps use the TASN1DecRSAPublicKey and TASN1EncRSAPublicKey classes to perform something similar, but beyond that, I am sorry I cannot help.
To get helpful answers, please specify what you mean by "TBuf format".
If you're using CRSAKeypair, you probably downloaded the Symbian cryptography library and its documentation from http://developer.symbian.com/main/tools%5Fand%5Fsdks/developer%5Ftools/supported/crypto%5Fapi/index.jsp
Admitedly, the documentation isn't explicit but I would venture that you can just send the modulus and exponent components to any other RSA engine in order to reconstitute the public key. The methods you're looking for are probably:
CRSAParameters::N();
CRSAPublicKey::E();
TInteger::BufferLC();
Just remember that methods with a trailing "C" push what they return on the cleanup stack so you need to pop it yourself.
If you need to understand descriptors better to convert HBufC8* to TBuf, I suggest spending some time on http://descriptors.blogspot.com
Well firstly create your TBuf8 with the length of the data along the lines of:
TUint length = sizeof(myLong);
TBuf<length> myLongBuf;
Then perhaps looking for some of these descriptor functions to copy the data in to the descriptor?
TDes::Num(TInt64)
Converts the 64-bit signed integer into a decimal character representation and copies the conversion into this descriptor, replacing any existing data
TDes::Num(TReal,const TRealFormat &)
Converts the specified floating point number into a character representation and copies the conversion into this descriptor, replacing any existing data
TDes::Num(TUint64,TRadix)
Converts the specified 64 bit unsigned integer into a character representation based on the specified number system and copies the conversion into this descriptor, replacing any existing data
TDes::NumFixedWidth(TUint,TRadix,TInt)
Converts the specified unsigned integer into a fixed width character representation based on the specified number system and copies the conversion into this descriptor, replacing any existing data
TDes::NumFixedWidthUC(TUint,TRadix,TInt)
Converts the specified unsigned integer into a fixed width character representation based on the specified number system and copies the conversion into this descriptor, replacing any existing data
TDes::NumUC(TUint64,TRadix)
Converts the specified 64 bit unsigned integer into a character representation based on the specified number system and copies the conversion into this descriptor, replacing any existing data