summaryrefslogtreecommitdiffstats
path: root/src/rs1.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/rs1.c53
1 files changed, 9 insertions, 44 deletions
diff --git a/src/rs1.c b/src/rs1.c
index 03636b5..7db7f83 100644
--- a/src/rs1.c
+++ b/src/rs1.c
@@ -10,54 +10,20 @@
#include "fido.h"
-#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050200fL
-static EVP_MD *
-rs1_get_EVP_MD(void)
-{
- const EVP_MD *from;
- EVP_MD *to = NULL;
-
- if ((from = EVP_sha1()) != NULL && (to = malloc(sizeof(*to))) != NULL)
- memcpy(to, from, sizeof(*to));
-
- return (to);
-}
-
-static void
-rs1_free_EVP_MD(EVP_MD *md)
-{
- freezero(md, sizeof(*md));
-}
-#elif OPENSSL_VERSION_NUMBER >= 0x30000000
-static EVP_MD *
-rs1_get_EVP_MD(void)
-{
- return (EVP_MD_fetch(NULL, "SHA-1", NULL));
-}
-
-static void
-rs1_free_EVP_MD(EVP_MD *md)
-{
- EVP_MD_free(md);
-}
+#if defined(__GNUC__)
+#define PRAGMA(s) _Pragma(s)
#else
+#define PRAGMA(s)
+#endif
+
static EVP_MD *
rs1_get_EVP_MD(void)
{
- const EVP_MD *md;
-
- if ((md = EVP_sha1()) == NULL)
- return (NULL);
-
- return (EVP_MD_meth_dup(md));
-}
-
-static void
-rs1_free_EVP_MD(EVP_MD *md)
-{
- EVP_MD_meth_free(md);
+PRAGMA("GCC diagnostic push")
+PRAGMA("GCC diagnostic ignored \"-Wcast-qual\"")
+ return ((EVP_MD *)EVP_sha1());
+PRAGMA("GCC diagnostic pop")
}
-#endif /* LIBRESSL_VERSION_NUMBER */
int
rs1_verify_sig(const fido_blob_t *dgst, EVP_PKEY *pkey,
@@ -94,7 +60,6 @@ rs1_verify_sig(const fido_blob_t *dgst, EVP_PKEY *pkey,
ok = 0;
fail:
EVP_PKEY_CTX_free(pctx);
- rs1_free_EVP_MD(md);
return (ok);
}