2009/2/22 Gary <[email protected]>:
> Questions:
>
> My first question is that why does each byte is shown as "one
> Hexadecimal digit"?
> For example, in first byte of "PrivateKeyArray", I see only "3" digit
> instead of two Hex digit(one byte)?
>
Because you're hex-ascii encoding, then stepping through and printing
each character (which represents a nibble).

>
> Because I exactly don't know length of Generated Private and Public
> keys,I decided to define
> " byte* " instead of array for two key arrays and changed some lines
> of the above code as below:
>


I think I'd use a ByteQueue here instead. Encode each of your keys
into a ByteQueue, call MaxRetrievable() to find out how many bytes are
there, use that to allocate your array, then use the Get() method on
the ByteQueue to dump the bytes into your array. So it'd look
something like:

RSAES_OAEP_SHA_Encryptor Encryptor(Decryptor);
// encode into a ByteQueue instead of an ArraySink to find out the size
ByteQueue pubq;
Encryptor.DEREncode(pubq);
// allocate an array the size of the DER-encoded public key.
SecByteBlock publicKeyArray(pubq.MaxRetrievable());
// copy the bytes into the array.
pubq.Get(publicKeyArray,publicKeyArray.size());

(* Warning: the above was typed into my mail window; I didn't compile
it. Review the reference if there's any trouble compiling it!)

and pubArray would then contain the bytes of your DER-encoded key
material. If you then wanted to print those to screen, you'd need to
encode them first to be sure they're printable. The SHA example I
posted earlier shows one way to do that.

Good luck,

Geoff

--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to