* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
- *
+ *
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
+ *
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
+ * 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
+ *
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
static int seeded = 0;
static int egdsocket = 0;
-int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
- {
+int
+app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
+{
int consider_randfile = (file == NULL);
char buffer[200];
-
+
if (file == NULL)
file = RAND_file_name(buffer, sizeof buffer);
- else if (RAND_egd(file) > 0)
- {
+ else if (RAND_egd(file) > 0) {
/* we try if the given filename is an EGD socket.
if it is, we don't write anything back to the file. */
egdsocket = 1;
return 1;
- }
- if (file == NULL || !RAND_load_file(file, -1))
- {
- if (RAND_status() == 0)
- {
- if (!dont_warn)
- {
- BIO_printf(bio_e,"unable to load 'random state'\n");
- BIO_printf(bio_e,"This means that the random number generator has not been seeded\n");
- BIO_printf(bio_e,"with much random data.\n");
+ }
+ if (file == NULL || !RAND_load_file(file, -1)) {
+ if (RAND_status() == 0) {
+ if (!dont_warn) {
+ BIO_printf(bio_e, "unable to load 'random state'\n");
+ BIO_printf(bio_e, "This means that the random number generator has not been seeded\n");
+ BIO_printf(bio_e, "with much random data.\n");
if (consider_randfile) /* explanation does not apply when a file is explicitly named */
- {
- BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n");
- BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n");
- }
+ {
+ BIO_printf(bio_e, "Consider setting the RANDFILE environment variable to point at a file that\n");
+ BIO_printf(bio_e, "'random' data can be kept in (the file will be overwritten).\n");
}
- return 0;
}
+ return 0;
}
+ }
seeded = 1;
return 1;
- }
+}
-long app_RAND_load_files(char *name)
- {
- char *p,*n;
+long
+app_RAND_load_files(char *name)
+{
+ char *p, *n;
int last;
- long tot=0;
+ long tot = 0;
int egd;
-
- for (;;)
- {
- last=0;
- for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
- if (*p == '\0') last=1;
- *p='\0';
- n=name;
- name=p+1;
- if (*n == '\0') break;
- egd=RAND_egd(n);
+ for (;;) {
+ last = 0;
+ for (p = name;
+ ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
+ if (*p == '\0')
+ last = 1;
+ *p = '\0';
+ n = name;
+ name = p + 1;
+ if (*n == '\0')
+ break;
+
+ egd = RAND_egd(n);
if (egd > 0)
- tot+=egd;
+ tot += egd;
else
- tot+=RAND_load_file(n,-1);
- if (last) break;
- }
+ tot += RAND_load_file(n, -1);
+ if (last)
+ break;
+ }
if (tot > 512)
app_RAND_allow_write_file();
- return(tot);
- }
+ return (tot);
+}
-int app_RAND_write_file(const char *file, BIO *bio_e)
- {
+int
+app_RAND_write_file(const char *file, BIO *bio_e)
+{
char buffer[200];
-
+
if (egdsocket || !seeded)
/* If we did not manage to read the seed file,
* we should not write a low-entropy seed file back --
if (file == NULL)
file = RAND_file_name(buffer, sizeof buffer);
- if (file == NULL || !RAND_write_file(file))
- {
- BIO_printf(bio_e,"unable to write 'random state'\n");
+ if (file == NULL || !RAND_write_file(file)) {
+ BIO_printf(bio_e, "unable to write 'random state'\n");
return 0;
- }
- return 1;
}
+ return 1;
+}
-void app_RAND_allow_write_file(void)
- {
+void
+app_RAND_allow_write_file(void)
+{
seeded = 1;
- }
+}
*argc = 0;
*argv = NULL;
- if (buf != NULL) OPENSSL_free(buf);
- buf = (char *)OPENSSL_malloc(len + 1);
+ if (buf != NULL)
+ OPENSSL_free(buf);
+ buf = (char *)OPENSSL_malloc(len + 1);
if (buf == NULL)
return (0);
len = fread(buf, 1, len, fp);
- if (len <= 1) return (0);
- buf[len] = '\0';
+ if (len <= 1)
+ return (0);
+ buf[len] = '\0';
i = 0;
for (p = buf; *p; p++)
if (*p == '\n')
i++;
- if (arg != NULL) OPENSSL_free(arg);
- arg = (char **)OPENSSL_malloc(sizeof(char *)*(i*2));
+ if (arg != NULL)
+ OPENSSL_free(arg);
+ arg = (char **)OPENSSL_malloc(sizeof(char *)*(i*2));
*argv = arg;
num = 0;
if ((*p == '\'') || (*p == '\"')) /* scan for closing quote */
{
i= *(p++);
- arg->data[num-1]++; /* jump over quote */
+ arg->data[num - 1]++; /* jump over quote */
while (*p && (*p != i))
p++;
*p = '\0';
case UIT_VERIFY:
{
const char *password =
- ((PW_CB_DATA *)UI_get0_user_data(ui))->password;
+ ((PW_CB_DATA *)UI_get0_user_data(ui))->password;
if (password && password[0] != '\0') {
UI_set_result(ui, uis, password);
return 1;
app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2)
{
int same;
- if (!arg2 || !arg1 || strcmp(arg1, arg2)) same = 0;
- else
+ if (!arg2 || !arg1 || strcmp(arg1, arg2))
+ same = 0;
+ else
same = 1;
if (arg1) {
*pass1 = app_get_pass(err, arg1, same);
- if (!*pass1) return 0;
- } else if (pass1) *pass1 = NULL;
- if (arg2) {
+ if (!*pass1)
+ return 0;
+ } else if (pass1)
+ *pass1 = NULL;
+ if (arg2) {
*pass2 = app_get_pass(err, arg2, same ? 2 : 0);
- if (!*pass2) return 0;
- } else if (pass2) *pass2 = NULL;
- return 1;
+ if (!*pass2)
+ return 0;
+ } else if (pass2)
+ *pass2 = NULL;
+ return 1;
}
static char *
} else if (!strncmp(arg, "fd:", 3)) {
BIO *btmp;
i = atoi(arg + 3);
- if (i >= 0) pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
+ if (i >= 0)
+ pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
if ((i < 0) || !pwdbio) {
BIO_printf(err, "Can't access file descriptor %s\n", arg + 3);
return NULL;
return NULL;
}
tmp = strchr(tpass, '\n');
- if (tmp) *tmp = 0;
- return BUF_strdup(tpass);
+ if (tmp)
+ *tmp = 0;
+ return BUF_strdup(tpass);
}
int
(pem_password_cb *)password_callback, NULL);
else if (format == FORMAT_PKCS12) {
if (!load_pkcs12(err, cert, cert_descrip, NULL, NULL,
- NULL, &x, NULL))
+ NULL, &x, NULL))
goto end;
} else {
BIO_printf(err, "bad input format specified for %s\n",
BIO_printf(err, "unable to load certificate\n");
ERR_print_errors(err);
}
- if (cert != NULL) BIO_free(cert);
- return (x);
+ if (cert != NULL)
+ BIO_free(cert);
+ return (x);
}
EVP_PKEY *
goto end;
}
end:
- if (key != NULL) BIO_free(key);
- if (pkey == NULL)
- BIO_printf(err, "unable to load %s\n", key_descrip);
+ if (key != NULL)
+ BIO_free(key);
+ if (pkey == NULL)
+ BIO_printf(err, "unable to load %s\n", key_descrip);
return (pkey);
}
STACK_OF(CONF_VALUE) *vals;
CONF_VALUE *val;
int i, ret = 1;
- if (!arg) return 0;
- vals = X509V3_parse_list(arg);
+ if (!arg)
+ return 0;
+ vals = X509V3_parse_list(arg);
for (i = 0; i < sk_CONF_VALUE_num(vals); i++) {
val = sk_CONF_VALUE_value(vals, i);
if (!set_table_opts(flags, val->name, in_tbl))
ai = NULL;
}
err:
- if (in != NULL) BIO_free(in);
- if (ai != NULL) ASN1_INTEGER_free(ai);
- return (ret);
+ if (in != NULL)
+ BIO_free(in);
+ if (ai != NULL)
+ ASN1_INTEGER_free(ai);
+ return (ret);
}
int
free_index(CA_DB *db)
{
if (db) {
- if (db->db) TXT_DB_free(db->db);
- OPENSSL_free(db);
+ if (db->db)
+ TXT_DB_free(db->db);
+ OPENSSL_free(db);
}
}
err:
ret = -1;
ok:
- if (tfrom != NULL && tfrom != (TCHAR *)from) free(tfrom);
- return ret;
+ if (tfrom != NULL && tfrom != (TCHAR *)from)
+ free(tfrom);
+ return ret;
}
#endif
if (check_winnt())
proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE,
GetCurrentProcessId());
- if (proc == NULL) proc = (HANDLE) - 1;
- }
+ if (proc == NULL)
+ proc = (HANDLE) - 1;
+ }
- if (usertime && proc != (HANDLE) - 1) {
+ if (usertime && proc != (HANDLE) - 1) {
FILETIME junk;
GetProcessTimes(proc, &junk, &junk, &junk, &now);
} else
if (stop == TM_START) {
tmstart.u.LowPart = now.dwLowDateTime;
tmstart.u.HighPart = now.dwHighDateTime;
- }
- else {
+ } else {
ULARGE_INTEGER tmstop;
tmstop.u.LowPart = now.dwLowDateTime;
tmstart = now;
else
ret = ((now.tv_sec + now.tv_usec * 1e-6) -
- (tmstart.tv_sec + tmstart.tv_usec * 1e-6) );
+ (tmstart.tv_sec + tmstart.tv_usec * 1e-6));
return ret;
}