Import of code from heimdal
authorHeimdal Developers <heimdal-discuss@sics.se>
Tue, 24 Aug 2010 16:40:51 +0000 (17:40 +0100)
committerDerrick Brashear <shadow@dementia.org>
Tue, 24 Aug 2010 16:56:42 +0000 (09:56 -0700)
This commit updates the code imported from the external
heimdal git repository to their revision
4f5390877a6cdb9615cf1f61f1884edc7b91522c
which is described as switch-from-svn-to-git-1447-g4f53908

Change-Id: I8a679232dfb25ba636600264b235667f06a5f62c
Reviewed-on: http://gerrit.openafs.org/2607
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/external/heimdal/hcrypto/aes.h
src/external/heimdal/hcrypto/camellia.h
src/external/heimdal/hcrypto/evp-cc.c
src/external/heimdal/hcrypto/evp-cc.h
src/external/heimdal/hcrypto/md4.c
src/external/heimdal/hcrypto/md5.c
src/external/heimdal/hcrypto/rand.c
src/external/heimdal/hcrypto/rand.h
src/external/heimdal/hcrypto/sha.c
src/external/heimdal/hcrypto/sha256.c

index 1afa922..4ba4516 100644 (file)
@@ -76,7 +76,6 @@ void AES_cfb8_encrypt(const unsigned char *, unsigned char *,
                      unsigned long, const AES_KEY *,
                      unsigned char *, int);
 
-
 #ifdef  __cplusplus
 }
 #endif
index feabae1..6661f3b 100644 (file)
@@ -66,7 +66,7 @@ void CAMELLIA_decrypt(const unsigned char *, unsigned char *,
                      const CAMELLIA_KEY *);
 
 void CAMELLIA_cbc_encrypt(const unsigned char *, unsigned char *,
-                         const unsigned long, const CAMELLIA_KEY *,
+                         unsigned long, const CAMELLIA_KEY *,
                          unsigned char *, int);
 
 #endif /* HEIM_CAMELLIA_H */
index 9bc84f3..983d521 100644 (file)
@@ -117,9 +117,8 @@ cc_do_cfb8_cipher(EVP_CIPHER_CTX *ctx,
         memcpy(ctx->iv, &oiv[1], ctx->cipher->iv_len);
     }
 
-     return 1;
- }
-
+    return 1;
+}
 
 static int
 cc_cleanup(EVP_CIPHER_CTX *ctx)
@@ -334,6 +333,10 @@ EVP_cc_aes_256_cbc(void)
     return &c;
 }
 
+/*
+ *
+ */
+
 static int
 cc_aes_cfb8_init(EVP_CIPHER_CTX *ctx,
                const unsigned char * key,
@@ -341,6 +344,7 @@ cc_aes_cfb8_init(EVP_CIPHER_CTX *ctx,
                int encp)
 {
     struct cc_key *cc = ctx->cipher_data;
+    memcpy(ctx->iv, iv, ctx->cipher->iv_len);
     return init_cc_key(1, kCCAlgorithmAES128, kCCOptionECBMode,
                       key, ctx->cipher->key_len, NULL, &cc->href);
 }
@@ -361,7 +365,7 @@ EVP_cc_aes_128_cfb8(void)
        1,
        kCCKeySizeAES128,
        kCCBlockSizeAES128,
-       EVP_CIPH_CFB8_MODE,
+       EVP_CIPH_CFB8_MODE|EVP_CIPH_ALWAYS_CALL_INIT,
        cc_aes_cfb8_init,
        cc_do_cfb8_cipher,
        cc_cleanup,
@@ -390,7 +394,7 @@ EVP_cc_aes_192_cfb8(void)
        1,
        kCCKeySizeAES192,
        kCCBlockSizeAES128,
-       EVP_CIPH_CFB8_MODE,
+       EVP_CIPH_CFB8_MODE|EVP_CIPH_ALWAYS_CALL_INIT,
        cc_aes_cfb8_init,
        cc_do_cfb8_cipher,
        cc_cleanup,
@@ -416,10 +420,10 @@ EVP_cc_aes_256_cfb8(void)
 {
     static const EVP_CIPHER c = {
        0,
-       1,
+       kCCBlockSizeAES128,
        kCCKeySizeAES256,
        kCCBlockSizeAES128,
-       EVP_CIPH_CFB8_MODE,
+       EVP_CIPH_CFB8_MODE|EVP_CIPH_ALWAYS_CALL_INIT,
        cc_aes_cfb8_init,
        cc_do_cfb8_cipher,
        cc_cleanup,
index 1ac3cfb..9249bb2 100644 (file)
@@ -47,9 +47,9 @@
 #define EVP_cc_aes_128_cbc hc_EVP_cc_aes_128_cbc
 #define EVP_cc_aes_192_cbc hc_EVP_cc_aes_192_cbc
 #define EVP_cc_aes_256_cbc hc_EVP_cc_aes_256_cbc
-#define EVP_cc_aes_cfb_128_cbc hc_EVP_cc_aes_128_cfb8
-#define EVP_cc_aes_cfb_192_cbc hc_EVP_cc_aes_192_cfb8
-#define EVP_cc_aes_cfb_256_cbc hc_EVP_cc_aes_256_cfb8
+#define EVP_cc_aes_128_cfb8 hc_EVP_cc_aes_128_cfb8
+#define EVP_cc_aes_192_cfb8 hc_EVP_cc_aes_192_cfb8
+#define EVP_cc_aes_256_cfb8 hc_EVP_cc_aes_256_cfb8
 #define EVP_cc_rc4 hc_EVP_cc_rc4
 #define EVP_cc_rc4_40 hc_EVP_cc_rc4_40
 #define EVP_cc_rc2_40_cbc hc_EVP_cc_rc2_40_cbc
index 435e662..1a9f77f 100644 (file)
@@ -191,10 +191,10 @@ MD4_Update (struct md4 *m, const void *v, size_t len)
 #if defined(WORDS_BIGENDIAN)
            int i;
            uint32_t current[16];
-           struct x32 *u = (struct x32*)m->save;
+           struct x32 *us = (struct x32*)m->save;
            for(i = 0; i < 8; i++){
-               current[2*i+0] = swap_uint32_t(u[i].a);
-               current[2*i+1] = swap_uint32_t(u[i].b);
+               current[2*i+0] = swap_uint32_t(us[i].a);
+               current[2*i+1] = swap_uint32_t(us[i].b);
            }
            calc(m, current);
 #else
index f990787..b35c76e 100644 (file)
@@ -215,10 +215,10 @@ MD5_Update (struct md5 *m, const void *v, size_t len)
 #if defined(WORDS_BIGENDIAN)
       int i;
       uint32_t current[16];
-      struct x32 *u = (struct x32*)m->save;
+      struct x32 *us = (struct x32*)m->save;
       for(i = 0; i < 8; i++){
-       current[2*i+0] = swap_uint32_t(u[i].a);
-       current[2*i+1] = swap_uint32_t(u[i].b);
+       current[2*i+0] = swap_uint32_t(us[i].a);
+       current[2*i+1] = swap_uint32_t(us[i].b);
       }
       calc(m, current);
 #else
index b02f938..d5c1f68 100644 (file)
 #define O_BINARY 0
 #endif
 
+#ifdef _WIN32
+#include<shlobj.h>
+#endif
+
 /**
  * @page page_rand RAND - random number
  *
@@ -352,6 +356,8 @@ RAND_file_name(char *filename, size_t size)
        if (e)
            pathp = 1;
     }
+
+#ifndef _WIN32
     /*
      * Here we really want to call getpwuid(getuid()) but this will
      * cause recursive lookups if the nss library uses
@@ -359,7 +365,6 @@ RAND_file_name(char *filename, size_t size)
      *
      * So at least return the unix /dev/random if we have one
      */
-#ifndef _WIN32
     if (e == NULL) {
        int fd;
 
@@ -367,7 +372,22 @@ RAND_file_name(char *filename, size_t size)
        if (fd >= 0)
            close(fd);
     }
+#else  /* Win32 */
+
+    if (e == NULL) {
+       char profile[MAX_PATH];
+
+       if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
+                           SHGFP_TYPE_CURRENT, profile) == S_OK) {
+           ret = snprintf(filename, size, "%s\\.rnd", profile);
+
+           if (ret > 0 && ret < size)
+               return filename;
+       }
+    }
+
 #endif
+
     if (e == NULL)
        return NULL;
 
index 923d4ad..590bd8c 100644 (file)
@@ -104,5 +104,6 @@ int RAND_egd_bytes(const char *, int);
 const RAND_METHOD *    RAND_fortuna_method(void);
 const RAND_METHOD *    RAND_unix_method(void);
 const RAND_METHOD *    RAND_egd_method(void);
+const RAND_METHOD *    RAND_w32crypto_method(void);
 
 #endif /* _HEIM_RAND_H */
index 062f705..39c53b0 100644 (file)
@@ -241,10 +241,10 @@ SHA1_Update (struct sha *m, const void *v, size_t len)
 #if !defined(WORDS_BIGENDIAN) || defined(_CRAY)
       int i;
       uint32_t current[16];
-      struct x32 *u = (struct x32*)m->save;
+      struct x32 *us = (struct x32*)m->save;
       for(i = 0; i < 8; i++){
-       current[2*i+0] = swap_uint32_t(u[i].a);
-       current[2*i+1] = swap_uint32_t(u[i].b);
+       current[2*i+0] = swap_uint32_t(us[i].a);
+       current[2*i+1] = swap_uint32_t(us[i].b);
       }
       calc(m, current);
 #else
index 2723c9b..108afdc 100644 (file)
@@ -183,10 +183,10 @@ SHA256_Update (SHA256_CTX *m, const void *v, size_t len)
 #if !defined(WORDS_BIGENDIAN) || defined(_CRAY)
            int i;
            uint32_t current[16];
-           struct x32 *u = (struct x32*)m->save;
+           struct x32 *us = (struct x32*)m->save;
            for(i = 0; i < 8; i++){
-               current[2*i+0] = swap_uint32_t(u[i].a);
-               current[2*i+1] = swap_uint32_t(u[i].b);
+               current[2*i+0] = swap_uint32_t(us[i].a);
+               current[2*i+1] = swap_uint32_t(us[i].b);
            }
            calc(m, current);
 #else