[BACK]Return to apps.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / openssl

Diff for /src/usr.bin/openssl/apps.c between version 1.34 and 1.35

version 1.34, 2015/09/10 16:01:06 version 1.35, 2015/09/11 14:30:23
Line 146 
Line 146 
 #include <openssl/x509.h>  #include <openssl/x509.h>
 #include <openssl/x509v3.h>  #include <openssl/x509v3.h>
   
 #ifndef OPENSSL_NO_ENGINE  
 #include <openssl/engine.h>  
 #endif  
   
 #include <openssl/rsa.h>  #include <openssl/rsa.h>
   
 typedef struct {  typedef struct {
Line 190 
Line 186 
             (strcmp(s, "PKCS12") == 0) || (strcmp(s, "pkcs12") == 0) ||              (strcmp(s, "PKCS12") == 0) || (strcmp(s, "pkcs12") == 0) ||
             (strcmp(s, "P12") == 0) || (strcmp(s, "p12") == 0))              (strcmp(s, "P12") == 0) || (strcmp(s, "p12") == 0))
                 return (FORMAT_PKCS12);                  return (FORMAT_PKCS12);
         else if ((*s == 'E') || (*s == 'e'))  
                 return (FORMAT_ENGINE);  
         else if ((*s == 'P') || (*s == 'p')) {          else if ((*s == 'P') || (*s == 'p')) {
                 if (s[1] == 'V' || s[1] == 'v')                  if (s[1] == 'V' || s[1] == 'v')
                         return FORMAT_PVK;                          return FORMAT_PVK;
Line 626 
Line 620 
 }  }
   
 X509 *  X509 *
 load_cert(BIO *err, const char *file, int format, const char *pass, ENGINE *e,  load_cert(BIO *err, const char *file, int format, const char *pass,
     const char *cert_descrip)      const char *cert_descrip)
 {  {
         X509 *x = NULL;          X509 *x = NULL;
Line 690 
Line 684 
   
 EVP_PKEY *  EVP_PKEY *
 load_key(BIO *err, const char *file, int format, int maybe_stdin,  load_key(BIO *err, const char *file, int format, int maybe_stdin,
     const char *pass, ENGINE *e, const char *key_descrip)      const char *pass, const char *key_descrip)
 {  {
         BIO *key = NULL;          BIO *key = NULL;
         EVP_PKEY *pkey = NULL;          EVP_PKEY *pkey = NULL;
Line 699 
Line 693 
         cb_data.password = pass;          cb_data.password = pass;
         cb_data.prompt_info = file;          cb_data.prompt_info = file;
   
         if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) {          if (file == NULL && (!maybe_stdin)) {
                 BIO_printf(err, "no keyfile specified\n");                  BIO_printf(err, "no keyfile specified\n");
                 goto end;                  goto end;
         }          }
 #ifndef OPENSSL_NO_ENGINE  
         if (format == FORMAT_ENGINE) {  
                 if (!e)  
                         BIO_printf(err, "no engine specified\n");  
                 else {  
                         pkey = ENGINE_load_private_key(e, file,  
                             ui_method, &cb_data);  
                         if (!pkey) {  
                                 BIO_printf(err, "cannot load %s from engine\n",  
                                     key_descrip);  
                                 ERR_print_errors(err);  
                         }  
                 }  
                 goto end;  
         }  
 #endif  
         key = BIO_new(BIO_s_file());          key = BIO_new(BIO_s_file());
         if (key == NULL) {          if (key == NULL) {
                 ERR_print_errors(err);                  ERR_print_errors(err);
Line 769 
Line 747 
   
 EVP_PKEY *  EVP_PKEY *
 load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,  load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
     const char *pass, ENGINE *e, const char *key_descrip)      const char *pass, const char *key_descrip)
 {  {
         BIO *key = NULL;          BIO *key = NULL;
         EVP_PKEY *pkey = NULL;          EVP_PKEY *pkey = NULL;
Line 778 
Line 756 
         cb_data.password = pass;          cb_data.password = pass;
         cb_data.prompt_info = file;          cb_data.prompt_info = file;
   
         if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) {          if (file == NULL && !maybe_stdin) {
                 BIO_printf(err, "no keyfile specified\n");                  BIO_printf(err, "no keyfile specified\n");
                 goto end;                  goto end;
         }          }
 #ifndef OPENSSL_NO_ENGINE  
         if (format == FORMAT_ENGINE) {  
                 if (!e)  
                         BIO_printf(bio_err, "no engine specified\n");  
                 else  
                         pkey = ENGINE_load_public_key(e, file,  
                             ui_method, &cb_data);  
                 goto end;  
         }  
 #endif  
         key = BIO_new(BIO_s_file());          key = BIO_new(BIO_s_file());
         if (key == NULL) {          if (key == NULL) {
                 ERR_print_errors(err);                  ERR_print_errors(err);
Line 899 
Line 867 
   
 static int  static int
 load_certs_crls(BIO *err, const char *file, int format, const char *pass,  load_certs_crls(BIO *err, const char *file, int format, const char *pass,
     ENGINE *e, const char *desc, STACK_OF(X509) **pcerts,      const char *desc, STACK_OF(X509) **pcerts,
     STACK_OF(X509_CRL) **pcrls)      STACK_OF(X509_CRL) **pcrls)
 {  {
         int i;          int i;
Line 983 
Line 951 
   
 STACK_OF(X509) *  STACK_OF(X509) *
 load_certs(BIO *err, const char *file, int format, const char *pass,  load_certs(BIO *err, const char *file, int format, const char *pass,
     ENGINE *e, const char *desc)      const char *desc)
 {  {
         STACK_OF(X509) *certs;          STACK_OF(X509) *certs;
   
         if (!load_certs_crls(err, file, format, pass, e, desc, &certs, NULL))          if (!load_certs_crls(err, file, format, pass, desc, &certs, NULL))
                 return NULL;                  return NULL;
         return certs;          return certs;
 }  }
   
 STACK_OF(X509_CRL) *  STACK_OF(X509_CRL) *
 load_crls(BIO *err, const char *file, int format, const char *pass, ENGINE *e,  load_crls(BIO *err, const char *file, int format, const char *pass,
     const char *desc)      const char *desc)
 {  {
         STACK_OF(X509_CRL) *crls;          STACK_OF(X509_CRL) *crls;
   
         if (!load_certs_crls(err, file, format, pass, e, desc, NULL, &crls))          if (!load_certs_crls(err, file, format, pass, desc, NULL, &crls))
                 return NULL;                  return NULL;
         return crls;          return crls;
 }  }
Line 1247 
Line 1215 
         X509_STORE_free(store);          X509_STORE_free(store);
         return NULL;          return NULL;
 }  }
   
 #ifndef OPENSSL_NO_ENGINE  
   
 ENGINE *  
 setup_engine(BIO *err, const char *engine, int debug)  
 {  
         ENGINE *e = NULL;  
   
         if (engine) {  
                 if (strcmp(engine, "auto") == 0) {  
                         BIO_printf(err, "enabling auto ENGINE support\n");  
                         ENGINE_register_all_complete();  
                         return NULL;  
                 }  
                 if ((e = ENGINE_by_id(engine)) == NULL) {  
                         BIO_printf(err, "invalid engine \"%s\"\n", engine);  
                         ERR_print_errors(err);  
                         return NULL;  
                 }  
                 if (debug) {  
                         if (ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,  
                             0, err, 0) <= 0) {  
                                 BIO_printf(err, "Cannot set logstream for "  
                                     "engine \"%s\"\n", engine);  
                                 ERR_print_errors(err);  
                                 ENGINE_free(e);  
                                 return NULL;  
                         }  
                 }  
                 if (!ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, ui_method, 0, 1)) {  
                         BIO_printf(err, "can't set user interface\n");  
                         ERR_print_errors(err);  
                         ENGINE_free(e);  
                         return NULL;  
                 }  
                 if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {  
                         BIO_printf(err, "can't use that engine\n");  
                         ERR_print_errors(err);  
                         ENGINE_free(e);  
                         return NULL;  
                 }  
                 BIO_printf(err, "engine \"%s\" set.\n", ENGINE_get_id(e));  
   
                 /* Free our "structural" reference. */  
                 ENGINE_free(e);  
         }  
         return e;  
 }  
 #endif  
   
 int  int
 load_config(BIO *err, CONF *cnf)  load_config(BIO *err, CONF *cnf)

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35