2014-11-05 21:53:18 +01:00
|
|
|
---
|
|
|
|
src/Makefile.in | 2 +-
|
|
|
|
src/fips.c | 39 ++++++++++++++++++++++++++++++++-------
|
|
|
|
2 files changed, 33 insertions(+), 8 deletions(-)
|
|
|
|
|
2021-02-03 13:44:42 +01:00
|
|
|
Index: libgcrypt-1.9.0/src/fips.c
|
2014-03-31 09:35:35 +02:00
|
|
|
===================================================================
|
2021-02-03 13:44:42 +01:00
|
|
|
--- libgcrypt-1.9.0.orig/src/fips.c
|
|
|
|
+++ libgcrypt-1.9.0/src/fips.c
|
|
|
|
@@ -603,23 +603,49 @@ run_random_selftests (void)
|
2014-03-31 09:35:35 +02:00
|
|
|
return !!err;
|
|
|
|
}
|
|
|
|
|
2021-02-03 13:44:42 +01:00
|
|
|
+#ifdef ENABLE_HMAC_BINARY_CHECK
|
2014-03-31 09:35:35 +02:00
|
|
|
+static int
|
|
|
|
+get_library_path(const char *libname, const char *symbolname, char *path, size_t pathlen)
|
|
|
|
+{
|
|
|
|
+ Dl_info info;
|
|
|
|
+ void *dl, *sym;
|
|
|
|
+ int rv = -1;
|
|
|
|
+
|
2021-02-03 13:44:42 +01:00
|
|
|
+ dl = dlopen(libname, RTLD_LAZY);
|
|
|
|
+ if (dl == NULL)
|
|
|
|
+ return -1;
|
2014-03-31 09:35:35 +02:00
|
|
|
+
|
|
|
|
+ sym = dlsym(dl, symbolname);
|
2021-02-03 13:44:42 +01:00
|
|
|
+ if (sym != NULL && dladdr(sym, &info))
|
|
|
|
+ {
|
|
|
|
+ strncpy(path, info.dli_fname, pathlen-1);
|
|
|
|
+ path[pathlen-1] = '\0';
|
|
|
|
+ rv = 0;
|
|
|
|
+ }
|
2014-03-31 09:35:35 +02:00
|
|
|
+
|
2021-02-03 13:44:42 +01:00
|
|
|
+ dlclose(dl);
|
2014-03-31 09:35:35 +02:00
|
|
|
+
|
|
|
|
+ return rv;
|
|
|
|
+}
|
2021-02-03 13:44:42 +01:00
|
|
|
+#endif
|
2014-03-31 09:35:35 +02:00
|
|
|
+
|
|
|
|
/* Run an integrity check on the binary. Returns 0 on success. */
|
|
|
|
static int
|
|
|
|
check_binary_integrity (void)
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_HMAC_BINARY_CHECK
|
|
|
|
gpg_error_t err;
|
|
|
|
- Dl_info info;
|
|
|
|
+ char libpath[4096];
|
|
|
|
unsigned char digest[32];
|
|
|
|
int dlen;
|
|
|
|
char *fname = NULL;
|
|
|
|
- const char key[] = "What am I, a doctor or a moonshuttle conductor?";
|
|
|
|
+ const char key[] = "orboDeJITITejsirpADONivirpUkvarP";
|
2021-02-03 13:44:42 +01:00
|
|
|
|
|
|
|
- if (!dladdr ("gcry_check_version", &info))
|
2014-05-27 20:06:59 +02:00
|
|
|
+ if (get_library_path ("libgcrypt.so.20", "gcry_check_version", libpath, sizeof(libpath)))
|
2014-03-31 09:35:35 +02:00
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
- dlen = _gcry_hmac256_file (digest, sizeof digest, info.dli_fname,
|
|
|
|
+ dlen = _gcry_hmac256_file (digest, sizeof digest, libpath,
|
|
|
|
key, strlen (key));
|
|
|
|
if (dlen < 0)
|
|
|
|
err = gpg_error_from_syserror ();
|
2021-02-03 13:44:42 +01:00
|
|
|
@@ -627,7 +652,7 @@ check_binary_integrity (void)
|
2014-03-31 09:35:35 +02:00
|
|
|
err = gpg_error (GPG_ERR_INTERNAL);
|
|
|
|
else
|
|
|
|
{
|
2014-11-05 21:53:18 +01:00
|
|
|
- fname = xtrymalloc (strlen (info.dli_fname) + 1 + 5 + 1 );
|
|
|
|
+ fname = xtrymalloc (strlen (libpath) + 1 + 5 + 1 );
|
2014-03-31 09:35:35 +02:00
|
|
|
if (!fname)
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
else
|
2021-02-03 13:44:42 +01:00
|
|
|
@@ -636,7 +661,7 @@ check_binary_integrity (void)
|
2014-03-31 09:35:35 +02:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
/* Prefix the basename with a dot. */
|
|
|
|
- strcpy (fname, info.dli_fname);
|
|
|
|
+ strcpy (fname, libpath);
|
|
|
|
p = strrchr (fname, '/');
|
|
|
|
if (p)
|
|
|
|
p++;
|