So I'm currently working on a web service for Amazon Alexa. For their request authentication, I'm downloading and validating a certificate. Afterwards I shall decrypt a signature with the certificate's public key. Now I've tried some things with Poco and OpenSSL, never getting a fitting result.
One example as a try for OpenSSL:
void decryptWithPublicKey(const std::string & input, const std::shared_ptr<Poco::Crypto::X509Certificate> & cert, std::string & buffer)
{
     RSA * decryptor = Poco::Crypto::RSAKey(*key).impl()->getRSA();
     const unsigned char * from = (const unsigned char*) input.c_str();
     unsigned char* to = new unsigned char[ RSA_size(decryptor)-12 ];;
     int result = RSA_public_decrypt((int) input.length(), from, to, decryptor, RSA_PKCS1_PADDING);
     if(result == -1)
     {
         // print error
     }
     else
     {
         buffer.append((char*) to);
     }
     delete from;
     delete[] to;
}
Output is always sth like "0!0 +\n PuTTYPuTTY"
Anyone has any experience with that?
 
    