summaryrefslogtreecommitdiff
path: root/engines/e_dasync.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-07-24 08:15:31 +0100
committerMatt Caswell <matt@openssl.org>2015-11-20 23:33:46 +0000
commitf4da39d200a8c2068595b8d5bd5efb78af4224e1 (patch)
treeeb329d8d472063fc60ba93c76a83af7d3217b602 /engines/e_dasync.c
parent252d6d3aa62dccf0dc826644b7da0b6bafa3831b (diff)
downloadopenssl-new-f4da39d200a8c2068595b8d5bd5efb78af4224e1.tar.gz
Initial Async notify code changes
Initial API implemented for notifying applications that an ASYNC_JOB has completed. Currently only s_server is using this. The Dummy Async engine "cheats" in that it notifies that it has completed *before* it pauses the job. A normal async engine would not do that. Only the posix version of this has been implemented so far, so it will probably fail to compile on Windows at the moment. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'engines/e_dasync.c')
-rw-r--r--engines/e_dasync.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/engines/e_dasync.c b/engines/e_dasync.c
index 6c41f7522d..9e0ed1b492 100644
--- a/engines/e_dasync.c
+++ b/engines/e_dasync.c
@@ -82,6 +82,7 @@ static int dasync_digests(ENGINE *e, const EVP_MD **digest,
static int dasync_digest_nids[] = { NID_sha1, 0 };
+static void dummy_pause_job(void);
/* SHA1 */
static int digest_sha1_init(EVP_MD_CTX *ctx);
@@ -234,6 +235,25 @@ static int dasync_digests(ENGINE *e, const EVP_MD **digest,
return ok;
}
+static void dummy_pause_job(void) {
+ ASYNC_JOB *job;
+
+ if ((job = ASYNC_get_current_job()) == NULL)
+ return;
+
+ /*
+ * In the Dummy async engine we are cheating. We signal that the job
+ * is complete by waking it before the call to ASYNC_pause_job(). A real
+ * async engine would only wake when the job was actually complete
+ */
+ ASYNC_wake(job);
+
+ /* Ignore errors - we carry on anyway */
+ ASYNC_pause_job();
+
+ ASYNC_clear_wake(job);
+}
+
/*
* SHA1 implementation. At the moment we just defer to the standard
@@ -243,8 +263,7 @@ static int dasync_digests(ENGINE *e, const EVP_MD **digest,
#define data(ctx) ((SHA_CTX *)(ctx)->md_data)
static int digest_sha1_init(EVP_MD_CTX *ctx)
{
- /* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return SHA1_Init(data(ctx));
}
@@ -252,16 +271,14 @@ static int digest_sha1_init(EVP_MD_CTX *ctx)
static int digest_sha1_update(EVP_MD_CTX *ctx, const void *data,
unsigned long count)
{
- /* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return SHA1_Update(data(ctx), data, (size_t)count);
}
static int digest_sha1_final(EVP_MD_CTX *ctx, unsigned char *md)
{
- /* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return SHA1_Final(md, data(ctx));
}
@@ -273,14 +290,14 @@ static int digest_sha1_final(EVP_MD_CTX *ctx, unsigned char *md)
static int dasync_pub_enc(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding) {
/* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return RSA_PKCS1_OpenSSL()->rsa_pub_enc(flen, from, to, rsa, padding);
}
static int dasync_pub_dec(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding) {
/* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return RSA_PKCS1_OpenSSL()->rsa_pub_dec(flen, from, to, rsa, padding);
}
@@ -288,7 +305,7 @@ static int dasync_rsa_priv_enc(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
{
/* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return RSA_PKCS1_OpenSSL()->rsa_priv_enc(flen, from, to, rsa, padding);
}
@@ -296,14 +313,14 @@ static int dasync_rsa_priv_dec(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
{
/* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return RSA_PKCS1_OpenSSL()->rsa_priv_dec(flen, from, to, rsa, padding);
}
static int dasync_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
{
/* Ignore errors - we carry on anyway */
- ASYNC_pause_job();
+ dummy_pause_job();
return RSA_PKCS1_OpenSSL()->rsa_mod_exp(r0, I, rsa, ctx);
}