From vincent.torri at gmail.com Sat Nov 5 10:51:29 2011 From: vincent.torri at gmail.com (Vincent Torri) Date: Sat, 5 Nov 2011 10:51:29 +0100 Subject: native support of Windows mutex in libgcrypt planned ? Message-ID: Hey afaics in the libgcrypt code, only pthread or gnu pth is used for mutexes. Is it possible to add Windows functions for mutexes ? thank you Vincent Torri -------------- next part -------------- An HTML attachment was scrubbed... URL: From wk at gnupg.org Sun Nov 6 17:33:51 2011 From: wk at gnupg.org (Werner Koch) Date: Sun, 06 Nov 2011 17:33:51 +0100 Subject: native support of Windows mutex in libgcrypt planned ? In-Reply-To: (Vincent Torri's message of "Sat, 5 Nov 2011 10:51:29 +0100") References: Message-ID: <87sjm1b47k.fsf@vigenere.g10code.de> On Sat, 5 Nov 2011 10:51, vincent.torri at gmail.com said: > afaics in the libgcrypt code, only pthread or gnu pth is used for mutexes. > Is it possible to add Windows functions for mutexes ? You may provide your own callbacks. Take the GCRY_THREAD_OPTION_PTHREAD_IMPL has a template and use GCRY_THREAD_OPTION_USER. The forthcoming Libgcrypt 1.6. will use the system's native thread implementation by default. Shalom-Salam, Werner -- Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz. From vincent.torri at gmail.com Sun Nov 6 19:55:53 2011 From: vincent.torri at gmail.com (Vincent Torri) Date: Sun, 6 Nov 2011 19:55:53 +0100 Subject: native support of Windows mutex in libgcrypt planned ? In-Reply-To: <87sjm1b47k.fsf@vigenere.g10code.de> References: <87sjm1b47k.fsf@vigenere.g10code.de> Message-ID: On Sun, Nov 6, 2011 at 5:33 PM, Werner Koch wrote: > On Sat, 5 Nov 2011 10:51, vincent.torri at gmail.com said: > > > afaics in the libgcrypt code, only pthread or gnu pth is used for > mutexes. > > Is it possible to add Windows functions for mutexes ? > > You may provide your own callbacks. Take the > GCRY_THREAD_OPTION_PTHREAD_IMPL has a template and use > GCRY_THREAD_OPTION_USER. > > The forthcoming Libgcrypt 1.6. will use the system's native thread > implementation by default. > I searched in the latest source code without finding any Win32 calls (like CreateMutex). Or maybe i didn't understand your remark ? Vincent Torri -------------- next part -------------- An HTML attachment was scrubbed... URL: From wk at gnupg.org Sun Nov 6 20:51:48 2011 From: wk at gnupg.org (Werner Koch) Date: Sun, 06 Nov 2011 20:51:48 +0100 Subject: native support of Windows mutex in libgcrypt planned ? In-Reply-To: (Vincent Torri's message of "Sun, 6 Nov 2011 19:55:53 +0100") References: <87sjm1b47k.fsf@vigenere.g10code.de> Message-ID: <87hb2hav1n.fsf@vigenere.g10code.de> On Sun, 6 Nov 2011 19:55, vincent.torri at gmail.com said: > I searched in the latest source code without finding any Win32 calls (like > CreateMutex). Or maybe i didn't understand your remark ? The latest source is under development and has currently no support for Windows; I am talking about the stable version: Did you read the section on multi threading and the required thread callbacks in the manual? There you find this remark: Libgcrypt contains convenient macros, which define the necessary thread callbacks for PThread and for GNU Pth: If you now need a different threading system (i.e. for W32), you may write such a macro or simply init the the thread callbacks structure directly. Shalom-Salam, Werner -- Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz. From ben.guthro at virtualcomputer.com Wed Nov 30 22:59:36 2011 From: ben.guthro at virtualcomputer.com (Ben Guthro) Date: Wed, 30 Nov 2011 16:59:36 -0500 Subject: [PATCH] Add ability to save/load an md5 checkpoint file Message-ID: <4ED6A748.1030702@virtualcomputer.com> For large encryption streams - it can be convenient to write a checkpoint file, to be able to be able to resume later. This implements save/load of md5 checkpoints Signed-off-by: Ben Guthro diff --git a/cipher/md.c b/cipher/md.c index 5ae9aee..7f3115f 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -1315,6 +1315,46 @@ gcry_md_is_enabled (gcry_md_hd_t a, int algo) return value; } +int +gcry_save_md5_checkpoint(FILE *f, gcry_md_hd_t *hd) +{ + GcryDigestEntry *entry; + int n; + + n = (*hd)->ctx->actual_handle_size - sizeof (struct gcry_md_context); + if (fwrite(*hd, n, 1, f) != 1) + return (-1); + entry = (*hd)->ctx->list; + if (fwrite(entry->context.c, entry->digest->contextsize, 1, f) != 1) + return (-1); + + return (0); +} + +int +gcry_load_md5_checkpoint(FILE *f, gcry_md_hd_t *hd) +{ + GcryDigestEntry *entry; + void *ctx; + int n; + + gcry_md_open(hd, GCRY_MD_MD5, 0); + /* see comment above in md_open() for description of layout */ + ctx = (*hd)->ctx; + n = (*hd)->ctx->actual_handle_size - sizeof (struct gcry_md_context); + if (fread(*hd, n, 1, f) != 1) + goto fail; + (*hd)->ctx = ctx; + entry = (*hd)->ctx->list; + if (fread(entry->context.c, entry->digest->contextsize, 1, f) != 1) + goto fail; + + return (0); +fail: + gcry_md_close(*hd); + return (-1); +} + /* Run the selftests for digest algorithm ALGO with optional reporting function REPORT. */ diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index b34ff08..565b5d3 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -22,6 +22,7 @@ #ifndef _GCRYPT_H #define _GCRYPT_H +#include #include #include #include @@ -1444,6 +1445,8 @@ int gcry_is_secure (const void *a) _GCRY_GCC_ATTR_PURE; /* Return true if Libgcrypt is in FIPS mode. */ #define gcry_fips_mode_active() !!gcry_control (GCRYCTL_FIPS_MODE_P, 0) +int gcry_save_md5_checkpoint(FILE *f, gcry_md_hd_t *hd); +int gcry_load_md5_checkpoint(FILE *f, gcry_md_hd_t *hd); #if 0 /* (Keep Emacsens' auto-indent happy.) */ { diff --git a/src/libgcrypt.def b/src/libgcrypt.def index 9bf0167..93a3ba1 100644 --- a/src/libgcrypt.def +++ b/src/libgcrypt.def @@ -211,3 +211,6 @@ EXPORTS gcry_pk_get_param @193 gcry_kdf_derive @194 + + gcry_save_md5_checkpoint @195 + gcry_load_md5_checkpoint @196 diff --git a/src/libgcrypt.vers b/src/libgcrypt.vers index dcb3749..7f32a7d 100644 --- a/src/libgcrypt.vers +++ b/src/libgcrypt.vers @@ -88,6 +88,8 @@ GCRYPT_1.6 { gcry_mpi_subm; gcry_mpi_swap; gcry_mpi_test_bit; gcry_mpi_lshift; + gcry_save_md5_checkpoint; gcry_load_md5_checkpoint; + local: *; diff --git a/src/visibility.c b/src/visibility.c index 2d3edbc..3ec73c3 100644 --- a/src/visibility.c +++ b/src/visibility.c @@ -1144,3 +1144,15 @@ gcry_is_secure (const void *a) { return _gcry_is_secure (a); } + +int +gcry_save_md5_checkpoint(FILE *f, gcry_md_hd_t *hd) +{ + _gcry_save_md5_checkpoint(f, hd); +} + +int +gcry_load_md5_checkpoint(FILE *f, gcry_md_hd_t *hd) +{ + _gcry_load_md5_checkpoint(f, hd); +} diff --git a/src/visibility.h b/src/visibility.h index 4606a20..dc7ec77 100644 --- a/src/visibility.h +++ b/src/visibility.h @@ -185,6 +185,8 @@ #define gcry_mpi_swap _gcry_mpi_swap #define gcry_mpi_test_bit _gcry_mpi_test_bit +#define gcry_save_md5_checkpoint _gcry_save_md5_checkpoint +#define gcry_load_md5_checkpoint _gcry_load_md5_checkpoint /* Include the main header here so that public symbols are mapped to the internal underscored ones. */ @@ -390,7 +392,8 @@ gcry_err_code_t gcry_md_get (gcry_md_hd_t hd, int algo, #undef gcry_mpi_subm #undef gcry_mpi_swap #undef gcry_mpi_test_bit - +#undef gcry_save_md5_checkpoint +#undef gcry_load_md5_checkpoint /* Now mark all symbols. */ @@ -557,7 +560,8 @@ MARK_VISIBLE (gcry_mpi_subm) MARK_VISIBLE (gcry_mpi_swap) MARK_VISIBLE (gcry_mpi_test_bit) - +MARK_VISIBLE (gcry_save_md5_checkpoint) +MARK_VISIBLE (gcry_load_md5_checkpoint) #undef MARK_VISIBLE #endif /*_GCRY_INCLUDED_BY_VISIBILITY_C*/