From 04d0b3e2c6624ef19176aba2537cca88e058c6b2 Mon Sep 17 00:00:00 2001 From: Heimdal Developers Date: Tue, 24 Aug 2010 17:40:51 +0100 Subject: [PATCH] Import of code from heimdal 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 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/external/heimdal/hcrypto/aes.h | 1 - src/external/heimdal/hcrypto/camellia.h | 2 +- src/external/heimdal/hcrypto/evp-cc.c | 18 +++++++++++------- src/external/heimdal/hcrypto/evp-cc.h | 6 +++--- src/external/heimdal/hcrypto/md4.c | 6 +++--- src/external/heimdal/hcrypto/md5.c | 6 +++--- src/external/heimdal/hcrypto/rand.c | 22 +++++++++++++++++++++- src/external/heimdal/hcrypto/rand.h | 1 + src/external/heimdal/hcrypto/sha.c | 6 +++--- src/external/heimdal/hcrypto/sha256.c | 6 +++--- 10 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/external/heimdal/hcrypto/aes.h b/src/external/heimdal/hcrypto/aes.h index 1afa922ac..4ba451651 100644 --- a/src/external/heimdal/hcrypto/aes.h +++ b/src/external/heimdal/hcrypto/aes.h @@ -76,7 +76,6 @@ void AES_cfb8_encrypt(const unsigned char *, unsigned char *, unsigned long, const AES_KEY *, unsigned char *, int); - #ifdef __cplusplus } #endif diff --git a/src/external/heimdal/hcrypto/camellia.h b/src/external/heimdal/hcrypto/camellia.h index feabae1aa..6661f3bf0 100644 --- a/src/external/heimdal/hcrypto/camellia.h +++ b/src/external/heimdal/hcrypto/camellia.h @@ -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 */ diff --git a/src/external/heimdal/hcrypto/evp-cc.c b/src/external/heimdal/hcrypto/evp-cc.c index 9bc84f30e..983d5210a 100644 --- a/src/external/heimdal/hcrypto/evp-cc.c +++ b/src/external/heimdal/hcrypto/evp-cc.c @@ -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, diff --git a/src/external/heimdal/hcrypto/evp-cc.h b/src/external/heimdal/hcrypto/evp-cc.h index 1ac3cfbf2..9249bb226 100644 --- a/src/external/heimdal/hcrypto/evp-cc.h +++ b/src/external/heimdal/hcrypto/evp-cc.h @@ -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 diff --git a/src/external/heimdal/hcrypto/md4.c b/src/external/heimdal/hcrypto/md4.c index 435e662a4..1a9f77fed 100644 --- a/src/external/heimdal/hcrypto/md4.c +++ b/src/external/heimdal/hcrypto/md4.c @@ -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 diff --git a/src/external/heimdal/hcrypto/md5.c b/src/external/heimdal/hcrypto/md5.c index f99078737..b35c76e29 100644 --- a/src/external/heimdal/hcrypto/md5.c +++ b/src/external/heimdal/hcrypto/md5.c @@ -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 diff --git a/src/external/heimdal/hcrypto/rand.c b/src/external/heimdal/hcrypto/rand.c index b02f938c5..d5c1f687b 100644 --- a/src/external/heimdal/hcrypto/rand.c +++ b/src/external/heimdal/hcrypto/rand.c @@ -46,6 +46,10 @@ #define O_BINARY 0 #endif +#ifdef _WIN32 +#include +#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; diff --git a/src/external/heimdal/hcrypto/rand.h b/src/external/heimdal/hcrypto/rand.h index 923d4adb7..590bd8cf1 100644 --- a/src/external/heimdal/hcrypto/rand.h +++ b/src/external/heimdal/hcrypto/rand.h @@ -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 */ diff --git a/src/external/heimdal/hcrypto/sha.c b/src/external/heimdal/hcrypto/sha.c index 062f70509..39c53b0a5 100644 --- a/src/external/heimdal/hcrypto/sha.c +++ b/src/external/heimdal/hcrypto/sha.c @@ -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 diff --git a/src/external/heimdal/hcrypto/sha256.c b/src/external/heimdal/hcrypto/sha256.c index 2723c9b1a..108afdccc 100644 --- a/src/external/heimdal/hcrypto/sha256.c +++ b/src/external/heimdal/hcrypto/sha256.c @@ -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 -- 2.39.5