X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Frsa%2Frsa_ssl.c;h=03096653381c653e9539a1be36f3ff5b095ebd90;hp=48731dfb90a3b7bc5dac38630e996e33bd6f9a6a;hb=0f2deef59d13e852a4bde0e853e9b49bab51a108;hpb=cb57f42528ea93c908aeff2d2f2a90c478528add diff --git a/crypto/rsa/rsa_ssl.c b/crypto/rsa/rsa_ssl.c index 48731dfb90..0309665338 100644 --- a/crypto/rsa/rsa_ssl.c +++ b/crypto/rsa/rsa_ssl.c @@ -19,16 +19,17 @@ #include #include #include "internal/constant_time.h" +#include "rsa_local.h" -int RSA_padding_add_SSLv23(unsigned char *to, int tlen, - const unsigned char *from, int flen) +int rsa_padding_add_SSLv23_with_libctx(OPENSSL_CTX *libctx, unsigned char *to, + int tlen, const unsigned char *from, + int flen) { int i, j; unsigned char *p; if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) { - RSAerr(RSA_F_RSA_PADDING_ADD_SSLV23, - RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); + RSAerr(0, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; } @@ -40,12 +41,12 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, /* pad out with non-zero random data */ j = tlen - 3 - 8 - flen; - if (RAND_bytes(p, j) <= 0) + if (RAND_bytes_ex(libctx, p, j) <= 0) return 0; for (i = 0; i < j; i++) { if (*p == '\0') do { - if (RAND_bytes(p, 1) <= 0) + if (RAND_bytes_ex(libctx, p, 1) <= 0) return 0; } while (*p == '\0'); p++; @@ -59,6 +60,12 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, return 1; } +int RSA_padding_add_SSLv23(unsigned char *to, int tlen, + const unsigned char *from, int flen) +{ + return rsa_padding_add_SSLv23_with_libctx(NULL, to, tlen, from, flen); +} + /* * Copy of RSA_padding_check_PKCS1_type_2 with a twist that rejects padding * if nul delimiter is not preceded by 8 consecutive 0x03 bytes. It also