projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Since we're moving between directories, let's get an absolute path to
[oweals/openssl.git]
/
crypto
/
rsa
/
rsa_pk1.c
diff --git
a/crypto/rsa/rsa_pk1.c
b/crypto/rsa/rsa_pk1.c
index b35eb626824e2f7dc49af7e3a3e4e61698e23340..8560755f1d12d8745f8272f2cd7441c225556677 100644
(file)
--- a/
crypto/rsa/rsa_pk1.c
+++ b/
crypto/rsa/rsa_pk1.c
@@
-63,12
+63,12
@@
#include <openssl/rand.h>
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
#include <openssl/rand.h>
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
- unsigned char *from, int flen)
+
const
unsigned char *from, int flen)
{
int j;
unsigned char *p;
{
int j;
unsigned char *p;
- if (flen > (tlen-
11
))
+ if (flen > (tlen-
RSA_PKCS1_PADDING_SIZE
))
{
RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
return(0);
{
RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
return(0);
@@
-79,7
+79,7
@@
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
*(p++)=0;
*(p++)=1; /* Private Key BT (Block Type) */
*(p++)=0;
*(p++)=1; /* Private Key BT (Block Type) */
- /* pad
d
out with 0xff data */
+ /* pad out with 0xff data */
j=tlen-3-flen;
memset(p,0xff,j);
p+=j;
j=tlen-3-flen;
memset(p,0xff,j);
p+=j;
@@
-89,10
+89,10
@@
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
}
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
}
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
- unsigned char *from, int flen, int num)
+
const
unsigned char *from, int flen, int num)
{
int i,j;
{
int i,j;
- unsigned char *p;
+
const
unsigned char *p;
p=from;
if ((num != (flen+1)) || (*(p++) != 01))
p=from;
if ((num != (flen+1)) || (*(p++) != 01))
@@
-130,13
+130,18
@@
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
}
i++; /* Skip over the '\0' */
j-=i;
}
i++; /* Skip over the '\0' */
j-=i;
+ if (j > tlen)
+ {
+ RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE);
+ return(-1);
+ }
memcpy(to,p,(unsigned int)j);
return(j);
}
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
memcpy(to,p,(unsigned int)j);
return(j);
}
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
- unsigned char *from, int flen)
+
const
unsigned char *from, int flen)
{
int i,j;
unsigned char *p;
{
int i,j;
unsigned char *p;
@@
-174,10
+179,10
@@
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
}
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
}
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
- unsigned char *from, int flen, int num)
+
const
unsigned char *from, int flen, int num)
{
int i,j;
{
int i,j;
- unsigned char *p;
+
const
unsigned char *p;
p=from;
if ((num != (flen+1)) || (*(p++) != 02))
p=from;
if ((num != (flen+1)) || (*(p++) != 02))
@@
-207,6
+212,11
@@
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
}
i++; /* Skip over the '\0' */
j-=i;
}
i++; /* Skip over the '\0' */
j-=i;
+ if (j > tlen)
+ {
+ RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,RSA_R_DATA_TOO_LARGE);
+ return(-1);
+ }
memcpy(to,p,(unsigned int)j);
return(j);
memcpy(to,p,(unsigned int)j);
return(j);