X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Frsa%2Frsa_sign.c;h=e1b1714210f122d2fc9d84a3daa00d2d80721cce;hp=7dae5c84157e12ab0633cad8021923187b2a1f96;hb=b79aa05e3babdbab92c6356f6e51f7bb43c41576;hpb=5c95c2ac23dd30f3c458e2738598383d2ca58181 diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index 7dae5c8415..e1b1714210 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -62,6 +62,7 @@ #include #include #include +#include "rsa_locl.h" /* Size of an SSL signature: MD5+SHA1 */ #define SSL_SIG_LENGTH 36 @@ -142,10 +143,11 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len, return(ret); } -int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, - unsigned char *rm, unsigned int *prm_len, - const unsigned char *sigbuf, unsigned int siglen, - RSA *rsa) +int int_rsa_verify(int dtype, const unsigned char *m, + unsigned int m_len, + unsigned char *rm, unsigned int *prm_len, + const unsigned char *sigbuf, unsigned int siglen, + RSA *rsa) { int i,ret=0,sigtype; unsigned char *s; @@ -191,6 +193,23 @@ int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, sig=d2i_X509_SIG(NULL,&p,(long)i); if (sig == NULL) goto err; + + /* Excess data can be used to create forgeries */ + if(p != s+i) + { + RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); + goto err; + } + + /* Parameters to the signature algorithm can also be used to + create forgeries */ + if(sig->algor->parameter + && ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL) + { + RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); + goto err; + } + sigtype=OBJ_obj2nid(sig->algor->algorithm);