diff options
| author | djm <> | 2008-09-06 12:15:56 +0000 |
|---|---|---|
| committer | djm <> | 2008-09-06 12:15:56 +0000 |
| commit | 5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 (patch) | |
| tree | aba68249883aa9d2361d92eef69a81d0c4961732 /src/lib/libcrypto/rsa/rsa_sign.c | |
| parent | f6198d4d0ab97685dc56be2d48715ed39fcc74b9 (diff) | |
| download | openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.gz openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.bz2 openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.zip | |
import of OpenSSL 0.9.8h
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_sign.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_sign.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c index cee09eccb1..71aabeea1b 100644 --- a/src/lib/libcrypto/rsa/rsa_sign.c +++ b/src/lib/libcrypto/rsa/rsa_sign.c | |||
| @@ -146,7 +146,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len, | |||
| 146 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa) | 146 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa) |
| 147 | { | 147 | { |
| 148 | int i,ret=0,sigtype; | 148 | int i,ret=0,sigtype; |
| 149 | unsigned char *p,*s; | 149 | unsigned char *s; |
| 150 | X509_SIG *sig=NULL; | 150 | X509_SIG *sig=NULL; |
| 151 | 151 | ||
| 152 | if (siglen != (unsigned int)RSA_size(rsa)) | 152 | if (siglen != (unsigned int)RSA_size(rsa)) |
| @@ -181,10 +181,27 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len, | |||
| 181 | RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); | 181 | RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); |
| 182 | else ret = 1; | 182 | else ret = 1; |
| 183 | } else { | 183 | } else { |
| 184 | p=s; | 184 | const unsigned char *p=s; |
| 185 | sig=d2i_X509_SIG(NULL,&p,(long)i); | 185 | sig=d2i_X509_SIG(NULL,&p,(long)i); |
| 186 | 186 | ||
| 187 | if (sig == NULL) goto err; | 187 | if (sig == NULL) goto err; |
| 188 | |||
| 189 | /* Excess data can be used to create forgeries */ | ||
| 190 | if(p != s+i) | ||
| 191 | { | ||
| 192 | RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); | ||
| 193 | goto err; | ||
| 194 | } | ||
| 195 | |||
| 196 | /* Parameters to the signature algorithm can also be used to | ||
| 197 | create forgeries */ | ||
| 198 | if(sig->algor->parameter | ||
| 199 | && ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL) | ||
| 200 | { | ||
| 201 | RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE); | ||
| 202 | goto err; | ||
| 203 | } | ||
| 204 | |||
| 188 | sigtype=OBJ_obj2nid(sig->algor->algorithm); | 205 | sigtype=OBJ_obj2nid(sig->algor->algorithm); |
| 189 | 206 | ||
| 190 | 207 | ||
