version 1.12, 2019/07/14 03:30:46 |
version 1.13, 2019/07/16 12:36:50 |
|
|
#include <openssl/pem.h> |
#include <openssl/pem.h> |
#include <openssl/x509.h> |
#include <openssl/x509.h> |
|
|
static int set_enc(int argc, char **argv, int *argsused); |
|
static const EVP_CIPHER *get_cipher_by_name(char *name); |
|
|
|
static struct { |
static struct { |
const EVP_CIPHER *enc; |
const EVP_CIPHER *enc; |
char *outfile; |
char *outfile; |
char *passargout; |
char *passargout; |
} gendsa_config; |
} gendsa_config; |
|
|
|
static const EVP_CIPHER *get_cipher_by_name(char *name) |
|
{ |
|
if (name == NULL || strcmp(name, "") == 0) |
|
return (NULL); |
|
#ifndef OPENSSL_NO_AES |
|
else if (strcmp(name, "aes128") == 0) |
|
return EVP_aes_128_cbc(); |
|
else if (strcmp(name, "aes192") == 0) |
|
return EVP_aes_192_cbc(); |
|
else if (strcmp(name, "aes256") == 0) |
|
return EVP_aes_256_cbc(); |
|
#endif |
|
#ifndef OPENSSL_NO_CAMELLIA |
|
else if (strcmp(name, "camellia128") == 0) |
|
return EVP_camellia_128_cbc(); |
|
else if (strcmp(name, "camellia192") == 0) |
|
return EVP_camellia_192_cbc(); |
|
else if (strcmp(name, "camellia256") == 0) |
|
return EVP_camellia_256_cbc(); |
|
#endif |
|
#ifndef OPENSSL_NO_DES |
|
else if (strcmp(name, "des") == 0) |
|
return EVP_des_cbc(); |
|
else if (strcmp(name, "des3") == 0) |
|
return EVP_des_ede3_cbc(); |
|
#endif |
|
#ifndef OPENSSL_NO_IDEA |
|
else if (strcmp(name, "idea") == 0) |
|
return EVP_idea_cbc(); |
|
#endif |
|
else |
|
return (NULL); |
|
} |
|
|
|
static int |
|
set_enc(int argc, char **argv, int *argsused) |
|
{ |
|
char *name = argv[0]; |
|
|
|
if (*name++ != '-') |
|
return (1); |
|
|
|
if ((gendsa_config.enc = get_cipher_by_name(name)) == NULL) |
|
return (1); |
|
|
|
*argsused = 1; |
|
return (0); |
|
} |
|
|
static const struct option gendsa_options[] = { |
static const struct option gendsa_options[] = { |
#ifndef OPENSSL_NO_AES |
#ifndef OPENSSL_NO_AES |
{ |
{ |
|
|
free(passout); |
free(passout); |
|
|
return (ret); |
return (ret); |
} |
|
|
|
static int |
|
set_enc(int argc, char **argv, int *argsused) |
|
{ |
|
char *name = argv[0]; |
|
|
|
if (*name++ != '-') |
|
return (1); |
|
|
|
if ((gendsa_config.enc = get_cipher_by_name(name)) == NULL) |
|
return (1); |
|
|
|
*argsused = 1; |
|
return (0); |
|
} |
|
|
|
static const EVP_CIPHER *get_cipher_by_name(char *name) |
|
{ |
|
if (name == NULL || strcmp(name, "") == 0) |
|
return (NULL); |
|
#ifndef OPENSSL_NO_AES |
|
else if (strcmp(name, "aes128") == 0) |
|
return EVP_aes_128_cbc(); |
|
else if (strcmp(name, "aes192") == 0) |
|
return EVP_aes_192_cbc(); |
|
else if (strcmp(name, "aes256") == 0) |
|
return EVP_aes_256_cbc(); |
|
#endif |
|
#ifndef OPENSSL_NO_CAMELLIA |
|
else if (strcmp(name, "camellia128") == 0) |
|
return EVP_camellia_128_cbc(); |
|
else if (strcmp(name, "camellia192") == 0) |
|
return EVP_camellia_192_cbc(); |
|
else if (strcmp(name, "camellia256") == 0) |
|
return EVP_camellia_256_cbc(); |
|
#endif |
|
#ifndef OPENSSL_NO_DES |
|
else if (strcmp(name, "des") == 0) |
|
return EVP_des_cbc(); |
|
else if (strcmp(name, "des3") == 0) |
|
return EVP_des_ede3_cbc(); |
|
#endif |
|
#ifndef OPENSSL_NO_IDEA |
|
else if (strcmp(name, "idea") == 0) |
|
return EVP_idea_cbc(); |
|
#endif |
|
else |
|
return (NULL); |
|
} |
} |