diff common/binverify.c @ 586:ecfd77751daf

Disambiguate enumerator values and add portable wrapper.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 27 May 2014 16:30:58 +0000
parents f4ce4eef3b38
children c93730ef2a3a
line wrap: on
line diff
--- a/common/binverify.c	Tue May 27 10:46:02 2014 +0000
+++ b/common/binverify.c	Tue May 27 16:30:58 2014 +0000
@@ -11,6 +11,16 @@
 #include "strhelp.h"
 #include "logging.h"
 
+bin_verify_result
+verify_binary(const char *filename, size_t name_len) {
+#ifdef WIN32
+  return verify_binary_win(filename, name_len);
+#else
+  /* TODO */
+  return VerifyValid;
+#endif
+}
+
 #ifdef WIN32
 
 #include <windows.h>
@@ -20,7 +30,7 @@
 
 bin_verify_result
 verify_binary_win(const char *filename, size_t name_len) {
-  bin_verify_result retval = UnknownError;
+  bin_verify_result retval = VerifyUnknownError;
   WCHAR *filenameW = NULL;
   BOOL result = FALSE;
   DWORD dwEncoding = 0,
@@ -35,7 +45,7 @@
   if (!filename || name_len > MAX_PATH || strlen(filename) != name_len)
     {
       ERRORPRINTF ("Invalid parameters\n");
-      return UnknownError;
+      return VerifyUnknownError;
     }
 
   filenameW = utf8_to_wchar(filename, strnlen(filename, MAX_PATH));
@@ -55,7 +65,7 @@
   if (!result || !hMsg)
     {
       PRINTLASTERROR ("Failed to query crypto object");
-      retval = ReadFailed;
+      retval = VerifyReadFailed;
       goto done;
     }
 
@@ -71,7 +81,7 @@
   else
     {
       ERRORPRINTF ("Failed to get signer cert size.");
-      retval = UnknownError;
+      retval = VerifyUnknownError;
       goto done;
     }
 
@@ -82,7 +92,7 @@
                          &dwSignerInfoSize)))
     {
       ERRORPRINTF ("Failed to get signer cert.");
-      retval = UnknownError;
+      retval = VerifyUnknownError;
       goto done;
     }
 
@@ -94,7 +104,7 @@
   if (!pSignerCertContext)
     {
       ERRORPRINTF ("Failed to find signer cert in store.");
-      retval = UnknownError;
+      retval = VerifyUnknownError;
       goto done;
     }
 
@@ -106,10 +116,10 @@
     {
       DEBUGPRINTF ("Verify signature succeeded. \n");
       /* TODO pinning*/
-      retval = Valid;
+      retval = VerifyValid;
     } else {
       ERRORPRINTF ("The signature was not verified. \n");
-      retval = InvalidSignature;
+      retval = VerifyInvalidSignature;
       goto done;
     }
 

http://wald.intevation.org/projects/trustbridge/