summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-21 01:43:37 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-21 01:44:38 +0200
commit72fbdd3349ad30d8a5074ea9a650f0909f96c299 (patch)
tree4cdecbea453084ca8dda7e7ecbd35c8998d547b1
parent89fef99014662a5a63e7deaedd6292b7fb4ab2f8 (diff)
journal: initialize libgcrypt explicitly, before using HMAC
-rw-r--r--src/journal/journal-authenticate.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c
index fd81797cf9..fe5b6bd506 100644
--- a/src/journal/journal-authenticate.c
+++ b/src/journal/journal-authenticate.c
@@ -413,12 +413,26 @@ finish:
return r;
}
+static void initialize_libgcrypt(void) {
+ const char *p;
+
+ if (gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P))
+ return;
+
+ p = gcry_check_version("1.4.5");
+ assert(p);
+
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+}
+
int journal_file_hmac_setup(JournalFile *f) {
gcry_error_t e;
if (!f->seal)
return 0;
+ initialize_libgcrypt();
+
e = gcry_md_open(&f->hmac, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC);
if (e != 0)
return -ENOTSUP;