summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'key.c')
-rw-r--r--key.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/key.c b/key.c
index c71bf5b0a..1defb1132 100644
--- a/key.c
+++ b/key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.c,v 1.94 2010/10/28 11:22:09 djm Exp $ */ 1/* $OpenBSD: key.c,v 1.95 2010/11/10 01:33:07 djm Exp $ */
2/* 2/*
3 * read_bignum(): 3 * read_bignum():
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1013,25 +1013,33 @@ key_size(const Key *k)
1013static RSA * 1013static RSA *
1014rsa_generate_private_key(u_int bits) 1014rsa_generate_private_key(u_int bits)
1015{ 1015{
1016 RSA *private; 1016 RSA *private = RSA_new();
1017 BIGNUM *f4 = BN_new();
1017 1018
1018 private = RSA_generate_key(bits, RSA_F4, NULL, NULL);
1019 if (private == NULL) 1019 if (private == NULL)
1020 fatal("rsa_generate_private_key: key generation failed."); 1020 fatal("%s: RSA_new failed", __func__);
1021 if (f4 == NULL)
1022 fatal("%s: BN_new failed", __func__);
1023 if (!BN_set_word(f4, RSA_F4))
1024 fatal("%s: BN_new failed", __func__);
1025 if (!RSA_generate_key_ex(private, bits, f4, NULL))
1026 fatal("%s: key generation failed.", __func__);
1027 BN_free(f4);
1021 return private; 1028 return private;
1022} 1029}
1023 1030
1024static DSA* 1031static DSA*
1025dsa_generate_private_key(u_int bits) 1032dsa_generate_private_key(u_int bits)
1026{ 1033{
1027 DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); 1034 DSA *private = DSA_new();
1028 1035
1029 if (private == NULL) 1036 if (private == NULL)
1030 fatal("dsa_generate_private_key: DSA_generate_parameters failed"); 1037 fatal("%s: DSA_new failed", __func__);
1038 if (!DSA_generate_parameters_ex(private, bits, NULL, 0, NULL,
1039 NULL, NULL))
1040 fatal("%s: DSA_generate_parameters failed", __func__);
1031 if (!DSA_generate_key(private)) 1041 if (!DSA_generate_key(private))
1032 fatal("dsa_generate_private_key: DSA_generate_key failed."); 1042 fatal("%s: DSA_generate_key failed.", __func__);
1033 if (private == NULL)
1034 fatal("dsa_generate_private_key: NULL.");
1035 return private; 1043 return private;
1036} 1044}
1037 1045