summaryrefslogtreecommitdiffstats
path: root/crypto/dsa
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2006-04-12 11:14:11 +0000
committerDr. Stephen Henson <steve@openssl.org>2006-04-12 11:14:11 +0000
commit75ef718820c44d8eb5efd98425c64b584ce2f5d5 (patch)
tree4029c8caabc08cd7b68ae404eb5aac9fbb58bf4e /crypto/dsa
parentc927df3fa19a2afda7bbacefbb366f7382b5269b (diff)
Support for DSA keygen, fix for genpkey.
Diffstat (limited to 'crypto/dsa')
-rw-r--r--crypto/dsa/dsa.h2
-rw-r--r--crypto/dsa/dsa_err.c2
-rw-r--r--crypto/dsa/dsa_pmeth.c21
3 files changed, 24 insertions, 1 deletions
diff --git a/crypto/dsa/dsa.h b/crypto/dsa/dsa.h
index 97efb92bd9..c4d440d51c 100644
--- a/crypto/dsa/dsa.h
+++ b/crypto/dsa/dsa.h
@@ -279,6 +279,7 @@ void ERR_load_DSA_strings(void);
#define DSA_F_DSA_VERIFY 108
#define DSA_F_I2D_DSA_SIG 111
#define DSA_F_PKEY_DSA_CTRL 120
+#define DSA_F_PKEY_DSA_KEYGEN 121
#define DSA_F_SIG_CB 114
/* Reason codes. */
@@ -288,6 +289,7 @@ void ERR_load_DSA_strings(void);
#define DSA_R_DECODE_ERROR 104
#define DSA_R_INVALID_DIGEST_TYPE 106
#define DSA_R_MISSING_PARAMETERS 101
+#define DSA_R_NO_PARAMETERS_SET 107
#define DSA_R_PARAMETER_ENCODING_ERROR 105
#ifdef __cplusplus
diff --git a/crypto/dsa/dsa_err.c b/crypto/dsa/dsa_err.c
index 5365f614a4..8bd6968fa7 100644
--- a/crypto/dsa/dsa_err.c
+++ b/crypto/dsa/dsa_err.c
@@ -89,6 +89,7 @@ static ERR_STRING_DATA DSA_str_functs[]=
{ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"},
{ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"},
{ERR_FUNC(DSA_F_PKEY_DSA_CTRL), "PKEY_DSA_CTRL"},
+{ERR_FUNC(DSA_F_PKEY_DSA_KEYGEN), "PKEY_DSA_KEYGEN"},
{ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"},
{0,NULL}
};
@@ -101,6 +102,7 @@ static ERR_STRING_DATA DSA_str_reasons[]=
{ERR_REASON(DSA_R_DECODE_ERROR) ,"decode error"},
{ERR_REASON(DSA_R_INVALID_DIGEST_TYPE) ,"invalid digest type"},
{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"},
+{ERR_REASON(DSA_R_NO_PARAMETERS_SET) ,"no parameters set"},
{ERR_REASON(DSA_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"},
{0,NULL}
};
diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c
index f91d03c208..364ba15a12 100644
--- a/crypto/dsa/dsa_pmeth.c
+++ b/crypto/dsa/dsa_pmeth.c
@@ -200,6 +200,24 @@ static int pkey_dsa_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
return ret;
}
+static int pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
+ {
+ DSA *dsa = NULL;
+ if (ctx->pkey == NULL)
+ {
+ DSAerr(DSA_F_PKEY_DSA_KEYGEN, DSA_R_NO_PARAMETERS_SET);
+ return 0;
+ }
+ dsa = DSA_new();
+ if (!dsa)
+ return 0;
+ EVP_PKEY_assign_DSA(pkey, dsa);
+ /* Note: if error return, pkey is freed by parent routine */
+ if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey))
+ return 0;
+ return DSA_generate_key(pkey->pkey.dsa);
+ }
+
const EVP_PKEY_METHOD dsa_pkey_meth =
{
EVP_PKEY_DSA,
@@ -210,7 +228,8 @@ const EVP_PKEY_METHOD dsa_pkey_meth =
0,
pkey_dsa_paramgen,
- 0,0,
+ 0,
+ pkey_dsa_keygen,
0,
pkey_dsa_sign,