svn rev #21793: trunk/src/ include/ lib/crypto/arcfour/ lib/krb5/krb/

raeburn@MIT.EDU raeburn at MIT.EDU
Fri Jan 23 20:27:20 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=21793
Commit By: raeburn
Log Message:
Change 16/32/64-bit big-/little-endian/native unaligned load/store
routines to take void pointers, so they can operate on both plain and
unsigned char buffers, or other types.
Remove some now-unneeded casts.


Changed Files:
U   trunk/src/include/k5-platform.h
U   trunk/src/lib/crypto/arcfour/arcfour_aead.c
U   trunk/src/lib/krb5/krb/pac.c
Modified: trunk/src/include/k5-platform.h
===================================================================
--- trunk/src/include/k5-platform.h	2009-01-23 19:59:50 UTC (rev 21792)
+++ trunk/src/include/k5-platform.h	2009-01-24 01:27:16 UTC (rev 21793)
@@ -1,7 +1,7 @@
 /*
  * k5-platform.h
  *
- * Copyright 2003, 2004, 2005, 2007, 2008 Massachusetts Institute of Technology.
+ * Copyright 2003, 2004, 2005, 2007, 2008, 2009 Massachusetts Institute of Technology.
  * All Rights Reserved.
  *
  * Export of this software from the United States of America may
@@ -534,8 +534,9 @@
 #endif
 
 static inline void
-store_16_be (unsigned int val, unsigned char *p)
+store_16_be (unsigned int val, void *vp)
 {
+    unsigned char *p = vp;
 #if defined(__GNUC__) && defined(K5_BE)
     PUT(16,p,val);
 #elif defined(__GNUC__) && defined(K5_LE) && defined(SWAP16)
@@ -546,8 +547,9 @@
 #endif
 }
 static inline void
-store_32_be (unsigned int val, unsigned char *p)
+store_32_be (unsigned int val, void *vp)
 {
+    unsigned char *p = vp;
 #if defined(__GNUC__) && defined(K5_BE)
     PUT(32,p,val);
 #elif defined(__GNUC__) && defined(K5_LE) && defined(SWAP32)
@@ -560,8 +562,9 @@
 #endif
 }
 static inline void
-store_64_be (UINT64_TYPE val, unsigned char *p)
+store_64_be (UINT64_TYPE val, void *vp)
 {
+    unsigned char *p = vp;
 #if defined(__GNUC__) && defined(K5_BE)
     PUT(64,p,val);
 #elif defined(__GNUC__) && defined(K5_LE) && defined(SWAP64)
@@ -578,8 +581,9 @@
 #endif
 }
 static inline unsigned short
-load_16_be (const unsigned char *p)
+load_16_be (const void *cvp)
 {
+    const unsigned char *p = cvp;
 #if defined(__GNUC__) && defined(K5_BE)
     return GET(16,p);
 #elif defined(__GNUC__) && defined(K5_LE) && defined(SWAP16)
@@ -589,8 +593,9 @@
 #endif
 }
 static inline unsigned int
-load_32_be (const unsigned char *p)
+load_32_be (const void *cvp)
 {
+    const unsigned char *p = cvp;
 #if defined(__GNUC__) && defined(K5_BE)
     return GET(32,p);
 #elif defined(__GNUC__) && defined(K5_LE) && defined(SWAP32)
@@ -602,8 +607,9 @@
 #endif
 }
 static inline UINT64_TYPE
-load_64_be (const unsigned char *p)
+load_64_be (const void *cvp)
 {
+    const unsigned char *p = cvp;
 #if defined(__GNUC__) && defined(K5_BE)
     return GET(64,p);
 #elif defined(__GNUC__) && defined(K5_LE) && defined(SWAP64)
@@ -613,8 +619,9 @@
 #endif
 }
 static inline void
-store_16_le (unsigned int val, unsigned char *p)
+store_16_le (unsigned int val, void *vp)
 {
+    unsigned char *p = vp;
 #if defined(__GNUC__) && defined(K5_LE)
     PUT(16,p,val);
 #elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP16)
@@ -625,8 +632,9 @@
 #endif
 }
 static inline void
-store_32_le (unsigned int val, unsigned char *p)
+store_32_le (unsigned int val, void *vp)
 {
+    unsigned char *p = vp;
 #if defined(__GNUC__) && defined(K5_LE)
     PUT(32,p,val);
 #elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP32)
@@ -639,8 +647,9 @@
 #endif
 }
 static inline void
-store_64_le (UINT64_TYPE val, unsigned char *p)
+store_64_le (UINT64_TYPE val, void *vp)
 {
+    unsigned char *p = vp;
 #if defined(__GNUC__) && defined(K5_LE)
     PUT(64,p,val);
 #elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP64)
@@ -657,8 +666,9 @@
 #endif
 }
 static inline unsigned short
-load_16_le (const unsigned char *p)
+load_16_le (const void *cvp)
 {
+    const unsigned char *p = cvp;
 #if defined(__GNUC__) && defined(K5_LE)
     return GET(16,p);
 #elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP16)
@@ -668,8 +678,9 @@
 #endif
 }
 static inline unsigned int
-load_32_le (const unsigned char *p)
+load_32_le (const void *cvp)
 {
+    const unsigned char *p = cvp;
 #if defined(__GNUC__) && defined(K5_LE)
     return GET(32,p);
 #elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP32)
@@ -679,8 +690,9 @@
 #endif
 }
 static inline UINT64_TYPE
-load_64_le (const unsigned char *p)
+load_64_le (const void *cvp)
 {
+    const unsigned char *p = cvp;
 #if defined(__GNUC__) && defined(K5_LE)
     return GET(64,p);
 #elif defined(__GNUC__) && defined(K5_BE) && defined(SWAP64)
@@ -691,7 +703,7 @@
 }
 
 static inline unsigned short
-load_16_n (const unsigned char *p)
+load_16_n (const void *p)
 {
 #ifdef _WIN32
     unsigned __int16 n;
@@ -702,7 +714,7 @@
     return n;
 }
 static inline unsigned int
-load_32_n (const unsigned char *p)
+load_32_n (const void *p)
 {
 #ifdef _WIN32
     unsigned __int32 n;
@@ -713,7 +725,7 @@
     return n;
 }
 static inline UINT64_TYPE
-load_64_n (const unsigned char *p)
+load_64_n (const void *p)
 {
     UINT64_TYPE n;
     memcpy(&n, p, 8);

Modified: trunk/src/lib/crypto/arcfour/arcfour_aead.c
===================================================================
--- trunk/src/lib/crypto/arcfour/arcfour_aead.c	2009-01-23 19:59:50 UTC (rev 21792)
+++ trunk/src/lib/crypto/arcfour/arcfour_aead.c	2009-01-24 01:27:16 UTC (rev 21793)
@@ -146,10 +146,10 @@
 
     if (key->enctype == ENCTYPE_ARCFOUR_HMAC_EXP) {
 	strncpy(salt.data, krb5int_arcfour_l40, salt.length);
-	store_32_le(ms_usage, (unsigned char *)salt.data + 10);
+	store_32_le(ms_usage, salt.data + 10);
     } else {
 	salt.length = 4;
-	store_32_le(ms_usage, (unsigned char *)salt.data);
+	store_32_le(ms_usage, salt.data);
     }
     ret = krb5_hmac(hash, key, 1, &salt, &d1);
     if (ret != 0)

Modified: trunk/src/lib/krb5/krb/pac.c
===================================================================
--- trunk/src/lib/krb5/krb/pac.c	2009-01-23 19:59:50 UTC (rev 21792)
+++ trunk/src/lib/krb5/krb/pac.c	2009-01-24 01:27:16 UTC (rev 21793)
@@ -730,7 +730,7 @@
     }
 
     /* Encode checksum type into buffer */
-    store_32_le((krb5_ui_4)*cksumtype, (unsigned char *)cksumdata.data);
+    store_32_le((krb5_ui_4)*cksumtype, cksumdata.data);
 
     return 0;
 }




More information about the cvs-krb5 mailing list