#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#define NON_MAIN
-#include "apps.h"
-#undef NON_MAIN
+#include <ctype.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/pkcs12.h>
#include <openssl/ui.h>
#include <openssl/safestack.h>
+#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
+#endif
#ifdef OPENSSL_SYS_WINDOWS
#define strcasecmp _stricmp
# endif /* NO_STRINGS_H */
#endif
-#ifdef OPENSSL_SYS_WINDOWS
-# include "bss_file.c"
-#endif
+#define NON_MAIN
+#include "apps.h"
+#undef NON_MAIN
typedef struct {
char *name;
p++;
else
p=in;
- strncpy(out,p,size-1);
- out[size-1]='\0';
+ BUF_strlcpy(out,p,size);
}
#endif
#endif
#ifdef OPENSSL_SYS_WIN32
int WIN32_rename(char *from, char *to)
{
+#ifndef OPENSSL_SYS_WINCE
/* Windows rename gives an error if 'to' exists, so delete it
* first and ignore file not found errror
*/
return -1;
#undef rename
return rename(from, to);
+#else
+ /* convert strings to UNICODE */
+ {
+ BOOL result = FALSE;
+ WCHAR* wfrom;
+ WCHAR* wto;
+ int i;
+ wfrom = malloc((strlen(from)+1)*2);
+ wto = malloc((strlen(to)+1)*2);
+ if (wfrom != NULL && wto != NULL)
+ {
+ for (i=0; i<(int)strlen(from)+1; i++)
+ wfrom[i] = (short)from[i];
+ for (i=0; i<(int)strlen(to)+1; i++)
+ wto[i] = (short)to[i];
+ result = MoveFile(wfrom, wto);
+ }
+ if (wfrom != NULL)
+ free(wfrom);
+ if (wto != NULL)
+ free(wto);
+ return result;
+ }
+#endif
}
#endif
int dump_cert_text (BIO *out, X509 *x)
{
- char buf[256];
- X509_NAME_oneline(X509_get_subject_name(x),buf,256);
+ char *p;
+
+ p=X509_NAME_oneline(X509_get_subject_name(x),NULL,0);
BIO_puts(out,"subject=");
- BIO_puts(out,buf);
+ BIO_puts(out,p);
+ OPENSSL_free(p);
- X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
- BIO_puts(out,"\nissuer= ");
- BIO_puts(out,buf);
+ p=X509_NAME_oneline(X509_get_issuer_name(x),NULL,0);
+ BIO_puts(out,"\nissuer=");
+ BIO_puts(out,p);
BIO_puts(out,"\n");
- return 0;
+ OPENSSL_free(p);
+
+ return 0;
}
static int ui_open(UI *ui)
if (buff)
{
- memset(buff,0,(unsigned int)bufsiz);
+ OPENSSL_cleanse(buff,(unsigned int)bufsiz);
OPENSSL_free(buff);
}
{
BIO_printf(bio_err, "User interface error\n");
ERR_print_errors(bio_err);
- memset(buf,0,(unsigned int)bufsiz);
+ OPENSSL_cleanse(buf,(unsigned int)bufsiz);
res = 0;
}
if (ok == -2)
{
BIO_printf(bio_err,"aborted!\n");
- memset(buf,0,(unsigned int)bufsiz);
+ OPENSSL_cleanse(buf,(unsigned int)bufsiz);
res = 0;
}
UI_free(ui);
BIO_printf(err,"no keyfile specified\n");
goto end;
}
+#ifndef OPENSSL_NO_ENGINE
if (format == FORMAT_ENGINE)
{
if (!e)
ui_method, &cb_data);
goto end;
}
+#endif
key=BIO_new(BIO_s_file());
if (key == NULL)
{
BIO_printf(err,"no keyfile specified\n");
goto end;
}
+#ifndef OPENSSL_NO_ENGINE
if (format == FORMAT_ENGINE)
{
if (!e)
ui_method, &cb_data);
goto end;
}
+#endif
key=BIO_new(BIO_s_file());
if (key == NULL)
{
goto error;
for (;;)
{
- if (!BUF_MEM_grow(buf,size+1024*10))
+ if (!BUF_MEM_grow_clean(buf,size+1024*10))
goto error;
i = BIO_read(key, &(buf->data[size]), 1024*10);
size += i;
char *buf;
char mline = 0;
int indent = 0;
+
if(title) BIO_puts(out, title);
if((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
mline = 1;
return NULL;
}
+#ifndef OPENSSL_NO_ENGINE
/* Try to load an engine in a shareable library */
static ENGINE *try_load_engine(BIO *err, const char *engine, int debug)
{
}
return e;
}
+#endif
int load_config(BIO *err, CONF *cnf)
{
}
return 1;
}
+
+char *make_config_name()
+ {
+ const char *t=X509_get_default_cert_area();
+ char *p;
+
+ p=OPENSSL_malloc(strlen(t)+strlen(OPENSSL_CONF)+2);
+ strcpy(p,t);
+#ifndef OPENSSL_SYS_VMS
+ strcat(p,"/");
+#endif
+ strcat(p,OPENSSL_CONF);
+
+ return p;
+ }