Handle inlines in ansi-compatible manner
authorSam Hartman <hartmans@mit.edu>
Tue, 23 Oct 2001 22:00:23 +0000 (22:00 +0000)
committerSam Hartman <hartmans@mit.edu>
Tue, 23 Oct 2001 22:00:23 +0000 (22:00 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13835 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/enc_provider/ChangeLog
src/lib/crypto/enc_provider/arcfour.c

index 035d41b9dbe920d97c7d7daf4986eb526f0cbf3b..4fe632c8667c7ff32b976663c69bc37f4c299d86 100644 (file)
@@ -1,5 +1,7 @@
 2001-10-23  Sam Hartman  <hartmans@mit.edu>
 
+       * arcfour.c (endif /* gcc inlines*/): handle inlines in an ansi-compatible manner
+
        * enc_provider.h: New encryption provider: rc4
 
 2001-10-19  Sam Hartman  <hartmans@mit.edu>
index 956b75e8c4d55fb486e3c9781d00c7eff197a244..43c71f17957edad3ac28efb9373e97abdcb7cc09 100644 (file)
 #include "arcfour-int.h"
 #include "enc_provider.h"
 /* gets the next byte from the PRNG */
-static inline unsigned int k5_arcfour_byte(ArcfourContext *);
+#if ((__GNUC__ >= 2) )
+static __inline__ unsigned int k5_arcfour_byte(ArcfourContext *);
+#else
+static unsigned int k5_arcfour_byte(ArcfourContext *);
+#endif /* gcc inlines*/
 
 /* Initializes the context and sets the key. */
 static krb5_error_code k5_arcfour_init(ArcfourContext *ctx, const unsigned char *key, 
@@ -36,16 +40,22 @@ static void k5_arcfour_keysize(size_t *, size_t *);
 static krb5_error_code
 k5_arcfour_make_key(krb5_const krb5_data *, krb5_keyblock *);
 
-static char arcfour_weakkey1[] = {0x00, 0x00, 0xfd};
-static char arcfour_weakkey2[] = {0x03, 0xfd, 0xfc};
+static unsigned char arcfour_weakkey1[] = {0x00, 0x00, 0xfd};
+static unsigned char arcfour_weakkey2[] = {0x03, 0xfd, 0xfc};
 static krb5_data arcfour_weakkeys[] = { {KV5M_DATA, sizeof (arcfour_weakkey1),
-                                        arcfour_weakkey1},
+                                        (char * ) arcfour_weakkey1},
                                        {KV5M_DATA, sizeof (arcfour_weakkey2),
-                                        arcfour_weakkey2},
+                                        (char * ) arcfour_weakkey2},
                                        {KV5M_DATA, 0, 0}
 };
 
-static inline unsigned int k5_arcfour_byte(ArcfourContext *ctx)
+/*xxx we really should check for c9x here and use inline on 
+ * more than just gcc. */
+#if ((__GNUC__ >= 2) )
+static __inline__ unsigned int k5_arcfour_byte(ArcfourContext * ctx)
+#else
+static unsigned int k5_arcfour_byte(ArcfourContext * ctx)
+#endif /* gcc inlines*/
 {
   unsigned int x;
   unsigned int y;
@@ -147,7 +157,7 @@ k5_arcfour_docrypt(krb5_const krb5_keyblock *key, krb5_const krb5_data *state,
 
   if (state) {
     arcfour_ctx=(ArcfourContext *)state->data;
-    k5_arcfour_crypt(arcfour_ctx, output->data, input->data, input->length);
+    k5_arcfour_crypt(arcfour_ctx, (unsigned char *) output->data, (const unsigned char *) input->data, input->length);
   }
   else {
     arcfour_ctx=malloc(sizeof (ArcfourContext));
@@ -157,7 +167,8 @@ k5_arcfour_docrypt(krb5_const krb5_keyblock *key, krb5_const krb5_data *state,
       free(arcfour_ctx);
       return (ret);
     }
-    k5_arcfour_crypt(arcfour_ctx, output->data, input->data, input->length);
+    k5_arcfour_crypt(arcfour_ctx, (unsigned char * ) output->data,
+                    (const unsigned char * ) input->data, input->length);
     memset(arcfour_ctx, 0, sizeof (ArcfourContext));
     free(arcfour_ctx);
   }