Hi, the program execution leads to:

 "RSA_public_decrypt failed: error:04067076:rsa
routines:RSA_EAY_PUBLIC_DECRYPT:unknown padding type"



///////////////////////////////////////////////////////////////////////////////

#include <openssl/ssl.h>

#include <openssl/rsa.h>

#include <openssl/err.h>

#include <cstring>

#include <stdio.h>


 int main(void)

{

RSA * rsa;

unsigned char src[1000] = "Some text....Some text....Some text";

unsigned char enc[1000] = {0};

unsigned char dec[1000] = {0};

int result;


 SSL_library_init();

SSL_load_error_strings();

OpenSSL_add_all_algorithms();


 if (!(rsa = RSA_generate_key(1024, 0x10001, NULL, NULL)))

{

printf("RSA_generate_key failed: %s\n", ERR_error_string(ERR_get_error(),
NULL));

return 1;

}


 if ((result = RSA_public_encrypt(strlen((char*)src), src, enc, rsa,
RSA_PKCS1_OAEP_PADDING)) < 0)

{

printf("RSA_public_encrypt failed: %s\n", ERR_error_string(ERR_get_error(),
NULL));

return 1;

}


 if ((result = RSA_public_decrypt(result, enc, dec, rsa,
RSA_PKCS1_OAEP_PADDING)) < 0)

{

printf("RSA_public_decrypt failed: %s\n", ERR_error_string(ERR_get_error(),
NULL));

return 1;

}


 RSA_free(rsa);


 return 0;

}

///////////////////////////////////////////////////////////////////////////////


OS: openSUSE 11.2 (x86_64)

Lib: OpenSSL 0.9.8k-3.7.1


 What's wrong?


Thank you in advance!



Fedor

Hi, the program execution leads to:


"RSA_public_decrypt failed: error:04067076:rsa routines:RSA_EAY_PUBLIC_DECRYPT:unknown padding type"


///////////////////////////////////////////////////////////////////////////////

#include <openssl/ssl.h>

#include <openssl/rsa.h>

#include <openssl/err.h>

#include <cstring>

#include <stdio.h>


int main(void)

{

RSA * rsa;

unsigned char src[1000] = "Some text....Some text....Some text";

unsigned char enc[1000] = {0};

unsigned char dec[1000] = {0};

int result;


SSL_library_init();

SSL_load_error_strings();

OpenSSL_add_all_algorithms();


if (!(rsa = RSA_generate_key(1024, 0x10001, NULL, NULL)))

{

printf("RSA_generate_key failed: %s\n", ERR_error_string(ERR_get_error(), NULL));

return 1;

}


if ((result = RSA_public_encrypt(strlen((char*)src), src, enc, rsa, RSA_PKCS1_OAEP_PADDING)) < 0)

{

printf("RSA_public_encrypt failed: %s\n", ERR_error_string(ERR_get_error(), NULL));

return 1;

}


if ((result = RSA_public_decrypt(result, enc, dec, rsa, RSA_PKCS1_OAEP_PADDING)) < 0)

{

printf("RSA_public_decrypt failed: %s\n", ERR_error_string(ERR_get_error(), NULL));

return 1;

}


RSA_free(rsa);


return 0;

}

///////////////////////////////////////////////////////////////////////////////


OS: openSUSE 11.2 (x86_64)

Lib: OpenSSL 0.9.8k-3.7.1


What's wrong?


Thank you in advance!



Fedor

Reply via email to