X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gcrypt.c;h=052546dd60733d143e6c12bdcfcc92ce36ac5e50;hp=1fde479e1be97656bd01002a2071a3d6f1b4b026;hb=e0545fd978a9583f9583b9bb35e5c25cb78c78f4;hpb=8eb77a20423c3dcc44c4584a082e981391272cb2 diff --git a/gcrypt.c b/gcrypt.c index 1fde479e..052546dd 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2011 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2011 Andre Noll , see file COPYING. */ /** \file gcrypt.c Libgrcypt-based encryption/decryption routines. */ @@ -56,21 +52,22 @@ void get_random_bytes_or_die(unsigned char *buf, int num) } /* - * This is called at the beginning of every program that uses libgcrypt. We - * don't have to initialize any random seed here, but we must initialize the - * gcrypt library. This task is performed by gcry_check_version() which can - * also check that the gcrypt library version is at least the minimal required - * version. + * This is called at the beginning of every program that uses libgcrypt. The + * call to gcry_check_version() initializes the gcrypt library and checks that + * we have at least the minimal required version. */ void init_random_seed_or_die(void) { const char *req_ver = "1.5.0"; + int seed; - if (gcry_check_version(req_ver)) - return; - PARA_EMERG_LOG("fatal: need at least libgcrypt-%s, have: %s\n", - req_ver, gcry_check_version(NULL)); - exit(EXIT_FAILURE); + if (!gcry_check_version(req_ver)) { + PARA_EMERG_LOG("fatal: need at least libgcrypt-%s, have: %s\n", + req_ver, gcry_check_version(NULL)); + exit(EXIT_FAILURE); + } + get_random_bytes_or_die((unsigned char *)&seed, sizeof(seed)); + srandom(seed); } /** S-expression for the public part of an RSA key. */