summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-09-02 17:48:26 +0200
committerMatt Caswell <matt@openssl.org>2019-09-09 15:00:00 +0200
commit390acbebfa90500c79c5014e6659eacda861550c (patch)
tree359600e65c4416217e11444c0eb25f3460c732ef /providers
parentImplement DSA in the default provider (diff)
downloadopenssl-390acbebfa90500c79c5014e6659eacda861550c.tar.xz
openssl-390acbebfa90500c79c5014e6659eacda861550c.zip
Add support for verify/verify_recover functions to EVP_SIGNATURE
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9753)
Diffstat (limited to 'providers')
-rw-r--r--providers/common/signature/dsa.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/providers/common/signature/dsa.c b/providers/common/signature/dsa.c
index 69f4978729..c0cd29381c 100644
--- a/providers/common/signature/dsa.c
+++ b/providers/common/signature/dsa.c
@@ -15,7 +15,8 @@
#include "internal/provider_algs.h"
static OSSL_OP_signature_newctx_fn dsa_newctx;
-static OSSL_OP_signature_sign_init_fn dsa_sign_init;
+static OSSL_OP_signature_sign_init_fn dsa_signature_init;
+static OSSL_OP_signature_verify_init_fn dsa_signature_init;
static OSSL_OP_signature_sign_fn dsa_sign;
static OSSL_OP_signature_freectx_fn dsa_freectx;
static OSSL_OP_signature_dupctx_fn dsa_dupctx;
@@ -37,7 +38,7 @@ static void *dsa_newctx(void *provctx)
return OPENSSL_zalloc(sizeof(PROV_DSA_CTX));
}
-static int dsa_sign_init(void *vpdsactx, void *vdsa)
+static int dsa_signature_init(void *vpdsactx, void *vdsa)
{
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
@@ -67,7 +68,7 @@ static int dsa_sign(void *vpdsactx, unsigned char *sig, size_t *siglen,
if (pdsactx->mdsize != 0 && tbslen != pdsactx->mdsize)
return 0;
- ret = DSA_sign(0, tbs, tbslen, sig, &sltmp, pdsactx-> dsa);
+ ret = DSA_sign(0, tbs, tbslen, sig, &sltmp, pdsactx->dsa);
if (ret <= 0)
return 0;
@@ -76,6 +77,18 @@ static int dsa_sign(void *vpdsactx, unsigned char *sig, size_t *siglen,
return 1;
}
+static int dsa_verify(void *vpdsactx, const unsigned char *sig, size_t siglen,
+ const unsigned char *tbs, size_t tbslen)
+{
+ PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
+
+ if (pdsactx->mdsize != 0 && tbslen != pdsactx->mdsize)
+ return 0;
+
+ return DSA_verify(0, tbs, tbslen, sig, siglen, pdsactx->dsa);
+}
+
+
static void dsa_freectx(void *vpdsactx)
{
PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
@@ -123,8 +136,10 @@ static int dsa_set_params(void *vpdsactx, const OSSL_PARAM params[])
const OSSL_DISPATCH dsa_signature_functions[] = {
{ OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))dsa_newctx },
- { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))dsa_sign_init },
+ { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))dsa_signature_init },
{ OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))dsa_sign },
+ { OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))dsa_signature_init },
+ { OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))dsa_verify },
{ OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))dsa_freectx },
{ OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))dsa_dupctx },
{ OSSL_FUNC_SIGNATURE_SET_PARAMS, (void (*)(void))dsa_set_params },