diff --git a/crypto/rsa/rsa.h b/crypto/rsa/rsa.h index 98b3bd7cc5282a863810d41d9ff68307c7013894..b2e25e4e7c714a73449f437a107a002ab983c941 100644 --- a/crypto/rsa/rsa.h +++ b/crypto/rsa/rsa.h @@ -175,6 +175,8 @@ struct rsa_st #define RSA_NO_PADDING 3 #define RSA_PKCS1_OAEP_PADDING 4 +#define RSA_PKCS1_PADDING_SIZE 11 + #define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) #define RSA_get_app_data(s) RSA_get_ex_data(s,0) diff --git a/crypto/rsa/rsa_pk1.c b/crypto/rsa/rsa_pk1.c index c1edd6764fc0e5d878819d91a7c525ac1fc9c302..8560755f1d12d8745f8272f2cd7441c225556677 100644 --- a/crypto/rsa/rsa_pk1.c +++ b/crypto/rsa/rsa_pk1.c @@ -68,7 +68,7 @@ int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, 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); diff --git a/crypto/rsa/rsa_saos.c b/crypto/rsa/rsa_saos.c index 85adacc08fdece5ae290e4cf626243fd4349cdf0..423cb50652235d3c2fa0687177f525e64dcfc1a6 100644 --- a/crypto/rsa/rsa_saos.c +++ b/crypto/rsa/rsa_saos.c @@ -77,7 +77,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type, i=i2d_ASN1_OCTET_STRING(&sig,NULL); j=RSA_size(rsa); - if ((i-RSA_PKCS1_PADDING) > j) + if (i > (j-RSA_PKCS1_PADDING_SIZE)) { RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); return(0); diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index 2a440901de3ee94f76b93ffe0e843a25a50fd222..c53ca739149b6b78f76f37f15d96bc53ae30945a 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -113,7 +113,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len, i=i2d_X509_SIG(&sig,NULL); } j=RSA_size(rsa); - if ((i-RSA_PKCS1_PADDING) > j) + if (i > (j-RSA_PKCS1_PADDING_SIZE)) { RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); return(0);