unsigned long, const AES_KEY *,
unsigned char *, int);
-
#ifdef __cplusplus
}
#endif
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 */
memcpy(ctx->iv, &oiv[1], ctx->cipher->iv_len);
}
- return 1;
- }
-
+ return 1;
+}
static int
cc_cleanup(EVP_CIPHER_CTX *ctx)
return &c;
}
+/*
+ *
+ */
+
static int
cc_aes_cfb8_init(EVP_CIPHER_CTX *ctx,
const unsigned char * key,
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);
}
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,
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,
{
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,
#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
#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
#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
#define O_BINARY 0
#endif
+#ifdef _WIN32
+#include<shlobj.h>
+#endif
+
/**
* @page page_rand RAND - random number
*
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
*
* So at least return the unix /dev/random if we have one
*/
-#ifndef _WIN32
if (e == NULL) {
int fd;
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;
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 */
#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
#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