image_verify: Add support for OpenSSL 1.1.0

With OpenSSL 1.1.0, some of the functions were renamed, for
example EVP_MD_CTX_create() and EVP_MD_CTX_destroy() were
renamed to EVP_MD_CTX_new() and EVP_MD_CTX_free().
Reference: https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes
Abstract them to support old and new APIs.

Resolves openbmc/openbmc#3137

Tested: Verified the signature verification was successful.

Change-Id: If8b3f185666c3db59567c4ee3bdfa168c501d3da
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/utils.cpp b/utils.cpp
new file mode 100644
index 0000000..95fc2e0
--- /dev/null
+++ b/utils.cpp
@@ -0,0 +1,29 @@
+#include "utils.hpp"
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+
+#include <string.h>
+
+static void* OPENSSL_zalloc(size_t num)
+{
+    void* ret = OPENSSL_malloc(num);
+
+    if (ret != NULL)
+    {
+        memset(ret, 0, num);
+    }
+    return ret;
+}
+
+EVP_MD_CTX* EVP_MD_CTX_new(void)
+{
+    return (EVP_MD_CTX*)OPENSSL_zalloc(sizeof(EVP_MD_CTX));
+}
+
+void EVP_MD_CTX_free(EVP_MD_CTX* ctx)
+{
+    EVP_MD_CTX_cleanup(ctx);
+    OPENSSL_free(ctx);
+}
+
+#endif // OPENSSL_VERSION_NUMBER < 0x10100000L