allow cancelling execution of commands which take long time

This commit is contained in:
NIIBE Yutaka
2015-09-09 19:12:50 +09:00
parent f505dea314
commit 645f42a890
5 changed files with 39 additions and 4 deletions

View File

@@ -25,6 +25,7 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <chopstx.h>
#include "config.h"
@@ -2059,7 +2060,10 @@ gpg_do_keygen (uint8_t kk_byte)
if (attr == ALGO_RSA2K || attr == ALGO_RSA4K)
{
int cs = chopstx_setcancelstate (0); /* Allow cancellation. */
/* XXX: We need to free up the allocated memory on cancellation. */
p_q_modulus = rsa_genkey (prvkey_len);
chopstx_setcancelstate (cs);
if (p_q_modulus == NULL)
{
GPG_MEMORY_FAILURE ();