summaryrefslogtreecommitdiffstats
path: root/crypto_openssl.c
diff options
context:
space:
mode:
authorAdriaan de Jong <dejong@fox-it.com>2011-06-23 16:21:32 +0200
committerDavid Sommerseth <davids@redhat.com>2011-10-19 22:09:54 +0200
commit902f674ef4170fd10cf47f216632e51214db6966 (patch)
treef1a952b61f862c83df9f133c1c5ef2e87c17bc69 /crypto_openssl.c
parent4a5a6033f95369a2d94e2dafff1d702f82f118ba (diff)
downloadopenvpn-902f674ef4170fd10cf47f216632e51214db6966.tar.gz
openvpn-902f674ef4170fd10cf47f216632e51214db6966.tar.xz
openvpn-902f674ef4170fd10cf47f216632e51214db6966.zip
Refactored message digest type functions
Signed-off-by: Adriaan de Jong <dejong@fox-it.com> Acked-by: David Sommerseth <davids@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'crypto_openssl.c')
-rw-r--r--crypto_openssl.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/crypto_openssl.c b/crypto_openssl.c
index a3e3a62..9c65757 100644
--- a/crypto_openssl.c
+++ b/crypto_openssl.c
@@ -63,6 +63,13 @@
#define DES_check_key_parity des_check_key_parity
#define DES_set_odd_parity des_set_odd_parity
+#define HMAC_CTX_init(ctx) CLEAR (*ctx)
+#define HMAC_Init_ex(ctx,sec,len,md,impl) HMAC_Init(ctx, sec, len, md)
+#define HMAC_CTX_cleanup(ctx) HMAC_cleanup(ctx)
+#define EVP_MD_CTX_cleanup(md) CLEAR (*md)
+
+#define INFO_CALLBACK_SSL_CONST
+
#endif
#if SSLEAY_VERSION_NUMBER < 0x00906000
@@ -91,6 +98,10 @@ cipher_ok (const char* name)
#endif /* SSLEAY_VERSION_NUMBER < 0x0090581f */
+#ifndef EVP_MD_name
+#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_type(e))
+#endif
+
/*
*
* OpenSSL engine support. Allows loading/unloading of engines.
@@ -451,3 +462,40 @@ cipher_des_encrypt_ecb (const unsigned char key[8],
des_set_key_unchecked((des_cblock*)key, sched);
des_ecb_encrypt((des_cblock *)src, (des_cblock *)dst, sched, DES_ENCRYPT);
}
+
+/*
+ *
+ * Generic message digest information functions
+ *
+ */
+
+
+const EVP_MD *
+md_kt_get (const char *digest)
+{
+ const EVP_MD *md = NULL;
+ ASSERT (digest);
+ md = EVP_get_digestbyname (digest);
+ if (!md)
+ msg (M_SSLERR, "Message hash algorithm '%s' not found", digest);
+ if (EVP_MD_size (md) > MAX_HMAC_KEY_LENGTH)
+ msg (M_FATAL, "Message hash algorithm '%s' uses a default hash size (%d bytes) which is larger than " PACKAGE_NAME "'s current maximum hash size (%d bytes)",
+ digest,
+ EVP_MD_size (md),
+ MAX_HMAC_KEY_LENGTH);
+ return md;
+}
+
+const char *
+md_kt_name (const EVP_MD *kt)
+{
+ if (NULL == kt)
+ return "[null-digest]";
+ return EVP_MD_name (kt);
+}
+
+int
+md_kt_size (const EVP_MD *kt)
+{
+ return EVP_MD_size(kt);
+}