On Fri, Sep 23, 2011 at 10:04, Earnol <[email protected]> wrote:
> template <typename T>
> void CryptoProviderImpl::keyToString(T const &key, std::string &str)
> {
>  CryptoPP::ByteQueue     bq;
>  key.DEREncode(bq);
>  CryptoPP::Base64Encoder bt;
>  bq.CopyTo(bt);
>  bt.MessageEnd();
>  CryptoPP::StringSink store(str);
>  bt.CopyTo(store);
>  store.MessageEnd();
> }
>
> This is how i convert key to base 64 encoded string.
>

What is T? OpenSSL's RSA utility expects a DER-encoded
SubjectPublicKeyInfo structure which is:

   SubjectPublicKeyInfo  ::=  SEQUENCE  {
        algorithm            AlgorithmIdentifier,
        subjectPublicKey     BIT STRING  }

The piece you're encoding is just the subjectPublicKey field. (For RSA
that's a sequence of 2 integers: the modulus and public exponent.)

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