diff options
author | Dr. Stephen Henson <steve@openssl.org> | 1999-02-21 17:39:07 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 1999-02-21 17:39:07 +0000 |
commit | 0c8a1281d09525924f0b9d96fa7674db258747e3 (patch) | |
tree | 05cb046163a8c87175d3aca9a2c56c08a64cc0f8 /crypto/rsa/rsa_none.c | |
parent | 189b6a6062232c7e893c72a3fe9be03905febc47 (diff) | |
download | openssl-new-0c8a1281d09525924f0b9d96fa7674db258747e3.tar.gz |
Make RSA_NO_PADDING really use no padding.
Submitted by: Ulf Moeller <ulf@fitug.de>
Diffstat (limited to 'crypto/rsa/rsa_none.c')
-rw-r--r-- | crypto/rsa/rsa_none.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/crypto/rsa/rsa_none.c b/crypto/rsa/rsa_none.c index 6385b556be..e944f84bec 100644 --- a/crypto/rsa/rsa_none.c +++ b/crypto/rsa/rsa_none.c @@ -68,13 +68,18 @@ int tlen; unsigned char *from; int flen; { - if (flen >= tlen) + if (flen > tlen) { RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return(0); } + + if (flen < tlen) + { + RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE); + return(0); + } - *(to++)=0; memcpy(to,from,(unsigned int)flen); return(1); } @@ -86,25 +91,15 @@ unsigned char *from; int flen; int num; { - int j; - from++; - if (flen+1 > tlen) + if (flen > tlen) { RSAerr(RSA_F_RSA_PADDING_CHECK_NONE,RSA_R_DATA_TOO_LARGE); return(-1); } - if (flen+1 >= num) - { - RSAerr(RSA_F_RSA_PADDING_CHECK_NONE,RSA_R_BAD_ZERO_BYTE); - return(-1); - } - /* scan over padding data */ - j=flen-1; /* one for type and one for the prepended 0. */ - memset(to,0,tlen-j); - to+=(tlen-j); - memcpy(to,from,j); - return(j); + memset(to,0,tlen-flen); + memcpy(to+tlen-flen,from,flen); + return(tlen); } |