Make compile with both OpenSSL and heimdal libdes.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16483 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-01-08 21:58:13 +00:00
parent 434d46a8fa
commit 1a7317f812

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004 - 2005 Kungliga Tekniska H<>gskolan * Copyright (c) 2004 - 2006 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -34,19 +34,7 @@
#include "hx_locl.h" #include "hx_locl.h"
RCSID("$Id$"); RCSID("$Id$");
#include <openssl/rsa.h> #include "crypto_headers.h"
#include <openssl/dsa.h>
#include <openssl/err.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include <openssl/md2.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/ui.h>
#include <openssl/pkcs12.h>
#define pkcs1(name, number) \ #define pkcs1(name, number) \
@@ -142,7 +130,7 @@ heim_int2BN(const heim_integer *i)
BIGNUM *bn; BIGNUM *bn;
bn = BN_bin2bn(i->data, i->length, NULL); bn = BN_bin2bn(i->data, i->length, NULL);
bn->neg = i->negative; BN_set_negative(bn, i->negative);
return bn; return bn;
} }
@@ -947,8 +935,10 @@ _hx509_private_key_assign_key_file(hx509_private_key key,
const struct _hx509_password *pw; const struct _hx509_password *pw;
int i; int i;
#ifdef HAVE_OPENSSL
OpenSSL_add_all_algorithms(); OpenSSL_add_all_algorithms();
ERR_load_crypto_strings(); ERR_load_crypto_strings();
#endif
if (key->private_key.rsa) { if (key->private_key.rsa) {
RSA_free(key->private_key.rsa); RSA_free(key->private_key.rsa);
@@ -959,6 +949,7 @@ _hx509_private_key_assign_key_file(hx509_private_key key,
pw = _hx509_lock_get_passwords(lock); pw = _hx509_lock_get_passwords(lock);
for (i = 0; i < pw->len; i++) { for (i = 0; i < pw->len; i++) {
#if HAVE_OPENSSL
EVP_PKEY *private_key; EVP_PKEY *private_key;
FILE *f; FILE *f;
@@ -977,6 +968,7 @@ _hx509_private_key_assign_key_file(hx509_private_key key,
return EINVAL; return EINVAL;
return 0; return 0;
#endif
} }
return EINVAL; return EINVAL;
@@ -1175,7 +1167,9 @@ hx509_crypto_encrypt(hx509_crypto crypto,
goto out; goto out;
} }
if (EVP_CipherInit(&evp,crypto->c,crypto->key.data,ivec->data, 1) != 1) { ret = EVP_CipherInit_ex(&evp, crypto->c, NULL,
crypto->key.data, ivec->data, 1);
if (ret != 1) {
EVP_CIPHER_CTX_cleanup(&evp); EVP_CIPHER_CTX_cleanup(&evp);
ret = HX509_CRYPTO_INTERNAL_ERROR; ret = HX509_CRYPTO_INTERNAL_ERROR;
goto out; goto out;
@@ -1262,7 +1256,9 @@ hx509_crypto_decrypt(hx509_crypto crypto,
EVP_CIPHER_CTX_init(&evp); EVP_CIPHER_CTX_init(&evp);
if (EVP_CipherInit(&evp, crypto->c, crypto->key.data, idata, 0) != 1) { ret = EVP_CipherInit_ex(&evp, crypto->c, NULL,
crypto->key.data, idata, 0);
if (ret != 1) {
EVP_CIPHER_CTX_cleanup(&evp); EVP_CIPHER_CTX_cleanup(&evp);
return HX509_CRYPTO_INTERNAL_ERROR; return HX509_CRYPTO_INTERNAL_ERROR;
} }
@@ -1332,6 +1328,7 @@ PBE_string2key(hx509_context context,
const heim_oid *enc_oid, const heim_oid *enc_oid,
const EVP_MD *md) const EVP_MD *md)
{ {
#ifdef HAVE_OPENSSL
PKCS12_PBEParams p12params; PKCS12_PBEParams p12params;
int passwordlen = strlen(password); int passwordlen = strlen(password);
hx509_crypto c; hx509_crypto c;
@@ -1384,6 +1381,9 @@ PBE_string2key(hx509_context context,
out: out:
free_PKCS12_PBEParams(&p12params); free_PKCS12_PBEParams(&p12params);
return ret; return ret;
#else
return HX509_CRYPTO_INTERNAL_ERROR;
#endif
} }
static const heim_oid * static const heim_oid *