Hi,
I'm trying to figure out how to send a public key in form of Byte* in
a header which then will be sent through a socket and broadcasted to
other nodes.
I managed to get a byte* array of the public key. I had to use an
Encoding scheme to finally get that byte stream from public key since
I couldn't find out how to directly get a byte array of the public key
without encoding since I'm completely restricted with sizes so a pure
byte stream would make more sense for me than encoded byte stream even
though it is not matching with standard (in this case X.509). By the
way I used DEREncodingPublicKey to get a byte array of PubKey.
But my problem is indeed in the receiver side. When I want to get the
DER encoded back to a pub key to be used as a verification key, it
throws me an error.
Here is the piece of code I used to create byte array of ECDSA public
key.
====sending side====
byte* pubToByte = new byte[57];
ByteQueue bt;
puKey.DEREncodePublicKey(bt);
bt.Peek (pubToByte,57);
secHeader->pubkey = pubToByte; //here the byte array is placed in the
header to be sent out from socket.
====receiving side====
ECDSA<ECP, SHA1>::PublicKey recPubKey;
using namespace CryptoPP;
ByteQueue qt;
qt.Put (secRHeader->pubkey, 57);
cout << qt.MaxRetrievable()<<endl;
recPubKey.BERDecodePublicKey(qt,false,57); // this line should decode
qt and fill the recPubKey to be used in verification. but it stuck
here.
I don't get any error while compiling. the problem shows up when I'm
running the sockets and the byte array is feeded to
BERDecodePublicKey. here is the error I see in debugging mode.
#0 CryptoPP::ECP::DecodePoint (this=0x0, P=..., bt=...,
encodedPointLen=57)
at ecp.cpp:471
#1 0x00338881 in
CryptoPP::DL_PublicKey_EC<CryptoPP::ECP>::BERDecodePublicKey(CryptoPP::BufferedTransformation&,
bool, unsigned int) ()
from /usr/lib/libcrypto++.so.8
.....
I find out that there is sth wrong in the way I want to encode and
decode the keys and I saw somewhere that I should use .save and .load
functions to make it easy going. but those functions works for RSA not
for ECDSA as far as I see. Correct me if I'm wrong.
Thanks in Advance.
/Amin
--
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.