Make RSA_NO_PADDING really use no padding.
authorDr. Stephen Henson <steve@openssl.org>
Sun, 21 Feb 1999 17:39:07 +0000 (17:39 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sun, 21 Feb 1999 17:39:07 +0000 (17:39 +0000)
Submitted by: Ulf Moeller <ulf@fitug.de>

CHANGES
crypto/rsa/rsa.err
crypto/rsa/rsa.h
crypto/rsa/rsa_err.c
crypto/rsa/rsa_none.c

diff --git a/CHANGES b/CHANGES
index 1891c530b4cfd56c2760cf6e428d480afb02fa64..cfa988429e6805de3e398cd1d1b346d0aa2f9b4b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@
 
  Changes between 0.9.1c and 0.9.2
 
+  *) Make RSA_NO_PADDING really use no padding.
+     [Ulf Moeller <ulf@fitug.de>]
+
   *) Generate errors when private/public key check is done.
      [Ben Laurie]
 
index 81554a0421779a37a493082ef22666372e3451d6..8ac095f427a7a81f279471927d02222386190954 100644 (file)
 #define RSA_R_BAD_FIXED_HEADER_DECRYPT                  102
 #define RSA_R_BAD_PAD_BYTE_COUNT                        103
 #define RSA_R_BAD_SIGNATURE                             104
-#define RSA_R_BAD_ZERO_BYTE                             105
 #define RSA_R_BLOCK_TYPE_IS_NOT_01                      106
 #define RSA_R_BLOCK_TYPE_IS_NOT_02                      107
 #define RSA_R_DATA_GREATER_THAN_MOD_LEN                         108
 #define RSA_R_DATA_TOO_LARGE                            109
 #define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE               110
 #define RSA_R_DATA_TOO_SMALL                            111
+#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE               122
 #define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                112
 #define RSA_R_KEY_SIZE_TOO_SMALL                        120
 #define RSA_R_NULL_BEFORE_BLOCK_MISSING                         113
index 5a8b1f86408d0b71fbd40a848273a404fe0952cf..9911579226a771d8ca53335fbb875858fad96319 100644 (file)
@@ -338,13 +338,13 @@ char *RSA_get_ex_data();
 #define RSA_R_BAD_FIXED_HEADER_DECRYPT                  102
 #define RSA_R_BAD_PAD_BYTE_COUNT                        103
 #define RSA_R_BAD_SIGNATURE                             104
-#define RSA_R_BAD_ZERO_BYTE                             105
 #define RSA_R_BLOCK_TYPE_IS_NOT_01                      106
 #define RSA_R_BLOCK_TYPE_IS_NOT_02                      107
 #define RSA_R_DATA_GREATER_THAN_MOD_LEN                         108
 #define RSA_R_DATA_TOO_LARGE                            109
 #define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE               110
 #define RSA_R_DATA_TOO_SMALL                            111
+#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE               122
 #define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                112
 #define RSA_R_KEY_SIZE_TOO_SMALL                        120
 #define RSA_R_NULL_BEFORE_BLOCK_MISSING                         113
index 22d52548debadfe09af49d9ff90fa1fcee1f1028..cdb8a3334d860e1197b02bbefe49d1a98b2a0e9d 100644 (file)
@@ -96,13 +96,13 @@ static ERR_STRING_DATA RSA_str_reasons[]=
 {RSA_R_BAD_FIXED_HEADER_DECRYPT          ,"bad fixed header decrypt"},
 {RSA_R_BAD_PAD_BYTE_COUNT                ,"bad pad byte count"},
 {RSA_R_BAD_SIGNATURE                     ,"bad signature"},
-{RSA_R_BAD_ZERO_BYTE                     ,"bad zero byte"},
 {RSA_R_BLOCK_TYPE_IS_NOT_01              ,"block type is not 01"},
 {RSA_R_BLOCK_TYPE_IS_NOT_02              ,"block type is not 02"},
 {RSA_R_DATA_GREATER_THAN_MOD_LEN         ,"data greater than mod len"},
 {RSA_R_DATA_TOO_LARGE                    ,"data too large"},
 {RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE       ,"data too large for key size"},
 {RSA_R_DATA_TOO_SMALL                    ,"data too small"},
+{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE       ,"data too small for key size"},
 {RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY        ,"digest too big for rsa key"},
 {RSA_R_KEY_SIZE_TOO_SMALL                ,"key size too small"},
 {RSA_R_NULL_BEFORE_BLOCK_MISSING         ,"null before block missing"},
index 6385b556be83ef3a678d202d610c430f909b2e9b..e944f84bec39c6b9146b539b27329314c3ac207f 100644 (file)
@@ -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);
        }