* aes_s2k.c (krb5int_aes_string_to_key): Widen bytes of iteration count before shifting
authorKen Raeburn <raeburn@mit.edu>
Wed, 13 Apr 2005 20:14:48 +0000 (20:14 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 13 Apr 2005 20:14:48 +0000 (20:14 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17181 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/aes/ChangeLog
src/lib/crypto/aes/aes_s2k.c

index 462e3589732a3e0b733127cd8ebbb977e7c535cc..047ab0baed380b543a9019cec8c03c812e4fac0f 100644 (file)
@@ -1,5 +1,8 @@
 2005-04-13  Ken Raeburn  <raeburn@mit.edu>
 
+       * aes_s2k.c (krb5int_aes_string_to_key): Widen bytes of iteration
+       count before shifting.
+
        * Makefile.in (all-unix): Don't build aes-gen by default, leave it
        for 'make check'.
 
index 9d48bd0cb18beffa48aa69078b41f508fb3f7304..68d3111bfd688999be55ba19efb33dd0babdb86a 100644 (file)
@@ -50,7 +50,11 @@ krb5int_aes_string_to_key(const struct krb5_enc_provider *enc,
        unsigned char *p = (unsigned char *) params->data;
        if (params->length != 4)
            return KRB5_ERR_BAD_S2K_PARAMS;
-       iter_count = ((p[0] << 24) | (p[1] << 16) | (p[2] <<  8) | (p[3]));
+       /* The first two need casts in case 'int' is 16 bits.  */
+       iter_count = (((unsigned long)p[0] << 24)
+                     | ((unsigned long)p[1] << 16)
+                     | (p[2] <<  8)
+                     | (p[3]));
        if (iter_count == 0) {
            iter_count = (1L << 16) << 16;
            if (((iter_count >> 16) >> 16) != 1)