summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa/rsa_ssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_ssl.c')
-rw-r--r--src/lib/libcrypto/rsa/rsa_ssl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ssl.c b/src/lib/libcrypto/rsa/rsa_ssl.c
index 1050844f8d..81a857c813 100644
--- a/src/lib/libcrypto/rsa/rsa_ssl.c
+++ b/src/lib/libcrypto/rsa/rsa_ssl.c
@@ -82,12 +82,14 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, unsigned char *from,
82 /* pad out with non-zero random data */ 82 /* pad out with non-zero random data */
83 j=tlen-3-8-flen; 83 j=tlen-3-8-flen;
84 84
85 RAND_bytes(p,j); 85 if (RAND_bytes(p,j) <= 0)
86 return(0);
86 for (i=0; i<j; i++) 87 for (i=0; i<j; i++)
87 { 88 {
88 if (*p == '\0') 89 if (*p == '\0')
89 do { 90 do {
90 RAND_bytes(p,1); 91 if (RAND_bytes(p,1) <= 0)
92 return(0);
91 } while (*p == '\0'); 93 } while (*p == '\0');
92 p++; 94 p++;
93 } 95 }
@@ -140,6 +142,11 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,
140 142
141 i++; /* Skip over the '\0' */ 143 i++; /* Skip over the '\0' */
142 j-=i; 144 j-=i;
145 if (j > tlen)
146 {
147 RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_DATA_TOO_LARGE);
148 return(-1);
149 }
143 memcpy(to,p,(unsigned int)j); 150 memcpy(to,p,(unsigned int)j);
144 151
145 return(j); 152 return(j);