|
Lines 21-26
Link Here
|
| 21 |
#ifdef WITH_OPENSSL |
21 |
#ifdef WITH_OPENSSL |
| 22 |
#include <openssl/evp.h> |
22 |
#include <openssl/evp.h> |
| 23 |
#include <openssl/pem.h> |
23 |
#include <openssl/pem.h> |
|
|
24 |
#include <openssl/rand.h> |
| 24 |
#include "openbsd-compat/openssl-compat.h" |
25 |
#include "openbsd-compat/openssl-compat.h" |
| 25 |
#endif |
26 |
#endif |
| 26 |
|
27 |
|
|
Lines 63-68
Link Here
|
| 63 |
#include "utf8.h" |
64 |
#include "utf8.h" |
| 64 |
#include "authfd.h" |
65 |
#include "authfd.h" |
| 65 |
#include "sshsig.h" |
66 |
#include "sshsig.h" |
|
|
67 |
#include "crypto_api.h" |
| 66 |
|
68 |
|
| 67 |
#ifdef WITH_OPENSSL |
69 |
#ifdef WITH_OPENSSL |
| 68 |
# define DEFAULT_KEY_TYPE_NAME "rsa" |
70 |
# define DEFAULT_KEY_TYPE_NAME "rsa" |
|
Lines 172-177
static char hostname[NI_MAXHOST];
Link Here
|
| 172 |
int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *); |
174 |
int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *); |
| 173 |
int prime_test(FILE *, FILE *, u_int32_t, u_int32_t, char *, unsigned long, |
175 |
int prime_test(FILE *, FILE *, u_int32_t, u_int32_t, char *, unsigned long, |
| 174 |
unsigned long); |
176 |
unsigned long); |
|
|
177 |
|
| 178 |
static int ssl_arc4_seed(const void *buf, int n) |
| 179 |
{ |
| 180 |
arc4random_set((void *)buf, n); |
| 181 |
return 1; |
| 182 |
} |
| 183 |
static void ssl_arc4_cleanup(void) {} |
| 184 |
static int ssl_arc4_add(const void *buf, int n, double randomness) { return 1; } |
| 185 |
static int ssl_arc4_status(void) { return 1; } |
| 186 |
RAND_METHOD ssl_arc4_meth = { |
| 187 |
.seed = ssl_arc4_seed, |
| 188 |
.bytes = arc4random_buf_det, |
| 189 |
.cleanup = ssl_arc4_cleanup, |
| 190 |
.add = ssl_arc4_add, |
| 191 |
.pseudorand = arc4random_buf_det, |
| 192 |
.status = ssl_arc4_status |
| 193 |
}; |
| 194 |
RAND_METHOD *RAND_arc4() { return &ssl_arc4_meth; } |
| 175 |
#endif |
195 |
#endif |
| 176 |
|
196 |
|
| 177 |
static void |
197 |
static void |
|
Lines 2757-2762
main(int argc, char **argv)
Link Here
|
| 2757 |
{ |
2777 |
{ |
| 2758 |
char dotsshdir[PATH_MAX], comment[1024], *passphrase1, *passphrase2; |
2778 |
char dotsshdir[PATH_MAX], comment[1024], *passphrase1, *passphrase2; |
| 2759 |
char *rr_hostname = NULL, *ep, *fp, *ra; |
2779 |
char *rr_hostname = NULL, *ep, *fp, *ra; |
|
|
2780 |
char *derive_from = NULL; |
| 2760 |
struct sshkey *private, *public; |
2781 |
struct sshkey *private, *public; |
| 2761 |
struct passwd *pw; |
2782 |
struct passwd *pw; |
| 2762 |
struct stat st; |
2783 |
struct stat st; |
|
Lines 2790-2797
main(int argc, char **argv)
Link Here
|
| 2790 |
|
2811 |
|
| 2791 |
__progname = ssh_get_progname(argv[0]); |
2812 |
__progname = ssh_get_progname(argv[0]); |
| 2792 |
|
2813 |
|
| 2793 |
seed_rng(); |
|
|
| 2794 |
|
| 2795 |
log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1); |
2814 |
log_init(argv[0], SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_USER, 1); |
| 2796 |
|
2815 |
|
| 2797 |
msetlocale(); |
2816 |
msetlocale(); |
|
Lines 2803-2812
main(int argc, char **argv)
Link Here
|
| 2803 |
if (gethostname(hostname, sizeof(hostname)) == -1) |
2822 |
if (gethostname(hostname, sizeof(hostname)) == -1) |
| 2804 |
fatal("gethostname: %s", strerror(errno)); |
2823 |
fatal("gethostname: %s", strerror(errno)); |
| 2805 |
|
2824 |
|
| 2806 |
/* Remaining characters: dw */ |
2825 |
/* Remaining characters: w */ |
| 2807 |
while ((opt = getopt(argc, argv, "ABHLQUXceghiklopquvxy" |
2826 |
while ((opt = getopt(argc, argv, "ABHLQUXceghiklopquvxy" |
| 2808 |
"C:D:E:F:G:I:J:K:M:N:O:P:R:S:T:V:W:Y:Z:" |
2827 |
"C:D:E:F:G:I:J:K:M:N:O:P:R:S:T:V:W:Y:Z:" |
| 2809 |
"a:b:f:g:j:m:n:r:s:t:z:")) != -1) { |
2828 |
"a:b:d:f:g:j:m:n:r:s:t:z:")) != -1) { |
| 2810 |
switch (opt) { |
2829 |
switch (opt) { |
| 2811 |
case 'A': |
2830 |
case 'A': |
| 2812 |
gen_all_hostkeys = 1; |
2831 |
gen_all_hostkeys = 1; |
|
Lines 2818-2823
main(int argc, char **argv)
Link Here
|
| 2818 |
fatal("Bits has bad value %s (%s)", |
2837 |
fatal("Bits has bad value %s (%s)", |
| 2819 |
optarg, errstr); |
2838 |
optarg, errstr); |
| 2820 |
break; |
2839 |
break; |
|
|
2840 |
case 'd': |
| 2841 |
derive_from = optarg; |
| 2842 |
break; |
| 2821 |
case 'E': |
2843 |
case 'E': |
| 2822 |
fingerprint_hash = ssh_digest_alg_by_name(optarg); |
2844 |
fingerprint_hash = ssh_digest_alg_by_name(optarg); |
| 2823 |
if (fingerprint_hash == -1) |
2845 |
if (fingerprint_hash == -1) |
|
Lines 3075-3080
main(int argc, char **argv)
Link Here
|
| 3075 |
/* NOTREACHED */ |
3097 |
/* NOTREACHED */ |
| 3076 |
} |
3098 |
} |
| 3077 |
|
3099 |
|
|
|
3100 |
if (derive_from) { |
| 3101 |
unsigned char hbuf[64]; |
| 3102 |
crypto_hash_sha512(hbuf, derive_from, strlen(derive_from)); |
| 3103 |
#ifdef WITH_OPENSSL |
| 3104 |
RAND_set_rand_method(RAND_arc4()); |
| 3105 |
RAND_seed(hbuf, sizeof(hbuf)); |
| 3106 |
#else |
| 3107 |
arc4random_set(hbuf, sizeof(hbuf)); |
| 3108 |
#endif |
| 3109 |
} else { |
| 3110 |
seed_rng(); |
| 3111 |
} |
| 3112 |
|
| 3078 |
if (ca_key_path != NULL) { |
3113 |
if (ca_key_path != NULL) { |
| 3079 |
if (argc < 1 && !gen_krl) { |
3114 |
if (argc < 1 && !gen_krl) { |
| 3080 |
error("Too few arguments."); |
3115 |
error("Too few arguments."); |