diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/gendsa.c | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/src/usr.bin/openssl/gendsa.c b/src/usr.bin/openssl/gendsa.c index 4eb0b1f44d..982676818a 100644 --- a/src/usr.bin/openssl/gendsa.c +++ b/src/usr.bin/openssl/gendsa.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: gendsa.c,v 1.12 2019/07/14 03:30:46 guenther Exp $ */ | 1 | /* $OpenBSD: gendsa.c,v 1.13 2019/07/16 12:36:50 inoguchi Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -74,15 +74,61 @@ | |||
| 74 | #include <openssl/pem.h> | 74 | #include <openssl/pem.h> |
| 75 | #include <openssl/x509.h> | 75 | #include <openssl/x509.h> |
| 76 | 76 | ||
| 77 | static int set_enc(int argc, char **argv, int *argsused); | ||
| 78 | static const EVP_CIPHER *get_cipher_by_name(char *name); | ||
| 79 | |||
| 80 | static struct { | 77 | static struct { |
| 81 | const EVP_CIPHER *enc; | 78 | const EVP_CIPHER *enc; |
| 82 | char *outfile; | 79 | char *outfile; |
| 83 | char *passargout; | 80 | char *passargout; |
| 84 | } gendsa_config; | 81 | } gendsa_config; |
| 85 | 82 | ||
| 83 | static const EVP_CIPHER *get_cipher_by_name(char *name) | ||
| 84 | { | ||
| 85 | if (name == NULL || strcmp(name, "") == 0) | ||
| 86 | return (NULL); | ||
| 87 | #ifndef OPENSSL_NO_AES | ||
| 88 | else if (strcmp(name, "aes128") == 0) | ||
| 89 | return EVP_aes_128_cbc(); | ||
| 90 | else if (strcmp(name, "aes192") == 0) | ||
| 91 | return EVP_aes_192_cbc(); | ||
| 92 | else if (strcmp(name, "aes256") == 0) | ||
| 93 | return EVP_aes_256_cbc(); | ||
| 94 | #endif | ||
| 95 | #ifndef OPENSSL_NO_CAMELLIA | ||
| 96 | else if (strcmp(name, "camellia128") == 0) | ||
| 97 | return EVP_camellia_128_cbc(); | ||
| 98 | else if (strcmp(name, "camellia192") == 0) | ||
| 99 | return EVP_camellia_192_cbc(); | ||
| 100 | else if (strcmp(name, "camellia256") == 0) | ||
| 101 | return EVP_camellia_256_cbc(); | ||
| 102 | #endif | ||
| 103 | #ifndef OPENSSL_NO_DES | ||
| 104 | else if (strcmp(name, "des") == 0) | ||
| 105 | return EVP_des_cbc(); | ||
| 106 | else if (strcmp(name, "des3") == 0) | ||
| 107 | return EVP_des_ede3_cbc(); | ||
| 108 | #endif | ||
| 109 | #ifndef OPENSSL_NO_IDEA | ||
| 110 | else if (strcmp(name, "idea") == 0) | ||
| 111 | return EVP_idea_cbc(); | ||
| 112 | #endif | ||
| 113 | else | ||
| 114 | return (NULL); | ||
| 115 | } | ||
| 116 | |||
| 117 | static int | ||
| 118 | set_enc(int argc, char **argv, int *argsused) | ||
| 119 | { | ||
| 120 | char *name = argv[0]; | ||
| 121 | |||
| 122 | if (*name++ != '-') | ||
| 123 | return (1); | ||
| 124 | |||
| 125 | if ((gendsa_config.enc = get_cipher_by_name(name)) == NULL) | ||
| 126 | return (1); | ||
| 127 | |||
| 128 | *argsused = 1; | ||
| 129 | return (0); | ||
| 130 | } | ||
| 131 | |||
| 86 | static const struct option gendsa_options[] = { | 132 | static const struct option gendsa_options[] = { |
| 87 | #ifndef OPENSSL_NO_AES | 133 | #ifndef OPENSSL_NO_AES |
| 88 | { | 134 | { |
| @@ -250,52 +296,3 @@ gendsa_main(int argc, char **argv) | |||
| 250 | 296 | ||
| 251 | return (ret); | 297 | return (ret); |
| 252 | } | 298 | } |
| 253 | |||
| 254 | static int | ||
| 255 | set_enc(int argc, char **argv, int *argsused) | ||
| 256 | { | ||
| 257 | char *name = argv[0]; | ||
| 258 | |||
| 259 | if (*name++ != '-') | ||
| 260 | return (1); | ||
| 261 | |||
| 262 | if ((gendsa_config.enc = get_cipher_by_name(name)) == NULL) | ||
| 263 | return (1); | ||
| 264 | |||
| 265 | *argsused = 1; | ||
| 266 | return (0); | ||
| 267 | } | ||
| 268 | |||
| 269 | static const EVP_CIPHER *get_cipher_by_name(char *name) | ||
| 270 | { | ||
| 271 | if (name == NULL || strcmp(name, "") == 0) | ||
| 272 | return (NULL); | ||
| 273 | #ifndef OPENSSL_NO_AES | ||
| 274 | else if (strcmp(name, "aes128") == 0) | ||
| 275 | return EVP_aes_128_cbc(); | ||
| 276 | else if (strcmp(name, "aes192") == 0) | ||
| 277 | return EVP_aes_192_cbc(); | ||
| 278 | else if (strcmp(name, "aes256") == 0) | ||
| 279 | return EVP_aes_256_cbc(); | ||
| 280 | #endif | ||
| 281 | #ifndef OPENSSL_NO_CAMELLIA | ||
| 282 | else if (strcmp(name, "camellia128") == 0) | ||
| 283 | return EVP_camellia_128_cbc(); | ||
| 284 | else if (strcmp(name, "camellia192") == 0) | ||
| 285 | return EVP_camellia_192_cbc(); | ||
| 286 | else if (strcmp(name, "camellia256") == 0) | ||
| 287 | return EVP_camellia_256_cbc(); | ||
| 288 | #endif | ||
| 289 | #ifndef OPENSSL_NO_DES | ||
| 290 | else if (strcmp(name, "des") == 0) | ||
| 291 | return EVP_des_cbc(); | ||
| 292 | else if (strcmp(name, "des3") == 0) | ||
| 293 | return EVP_des_ede3_cbc(); | ||
| 294 | #endif | ||
| 295 | #ifndef OPENSSL_NO_IDEA | ||
| 296 | else if (strcmp(name, "idea") == 0) | ||
| 297 | return EVP_idea_cbc(); | ||
| 298 | #endif | ||
| 299 | else | ||
| 300 | return (NULL); | ||
| 301 | } | ||
