char buffer[200];
if (file == NULL)
- file = RAND_file_name(buffer, sizeof buffer);
+ file = RAND_file_name(buffer, sizeof(buffer));
#ifndef OPENSSL_NO_EGD
else if (RAND_egd(file) > 0) {
/*
return 0;
if (file == NULL)
- file = RAND_file_name(buffer, sizeof buffer);
+ file = RAND_file_name(buffer, sizeof(buffer));
if (file == NULL || !RAND_write_file(file)) {
BIO_printf(bio_err, "unable to write 'random state'\n");
return 0;
OPENSSL_strlcpy(buf[0], serialfile, BSIZE);
else {
#ifndef OPENSSL_SYS_VMS
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, suffix);
#else
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, suffix);
#endif
}
out = BIO_new_file(buf[0], "w");
goto err;
}
#ifndef OPENSSL_SYS_VMS
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, new_suffix);
- j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", serialfile, old_suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, new_suffix);
+ j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", serialfile, old_suffix);
#else
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, new_suffix);
- j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", serialfile, old_suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, new_suffix);
+ j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", serialfile, old_suffix);
#endif
if (rename(serialfile, buf[1]) < 0 && errno != ENOENT
#ifdef ENOTDIR
goto err;
#ifndef OPENSSL_SYS_VMS
- BIO_snprintf(buf, sizeof buf, "%s.attr", dbfile);
+ BIO_snprintf(buf, sizeof(buf), "%s.attr", dbfile);
#else
- BIO_snprintf(buf, sizeof buf, "%s-attr", dbfile);
+ BIO_snprintf(buf, sizeof(buf), "%s-attr", dbfile);
#endif
dbattr_conf = app_load_config(buf);
goto err;
}
#ifndef OPENSSL_SYS_VMS
- j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr", dbfile);
- j = BIO_snprintf(buf[1], sizeof buf[1], "%s.attr.%s", dbfile, suffix);
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, suffix);
+ j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr", dbfile);
+ j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.attr.%s", dbfile, suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, suffix);
#else
- j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr", dbfile);
- j = BIO_snprintf(buf[1], sizeof buf[1], "%s-attr-%s", dbfile, suffix);
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, suffix);
+ j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr", dbfile);
+ j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-attr-%s", dbfile, suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, suffix);
#endif
out = BIO_new_file(buf[0], "w");
if (out == NULL) {
goto err;
}
#ifndef OPENSSL_SYS_VMS
- j = BIO_snprintf(buf[4], sizeof buf[4], "%s.attr", dbfile);
- j = BIO_snprintf(buf[3], sizeof buf[3], "%s.attr.%s", dbfile, old_suffix);
- j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr.%s", dbfile, new_suffix);
- j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", dbfile, old_suffix);
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, new_suffix);
+ j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s.attr", dbfile);
+ j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s.attr.%s", dbfile, old_suffix);
+ j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr.%s", dbfile, new_suffix);
+ j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", dbfile, old_suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, new_suffix);
#else
- j = BIO_snprintf(buf[4], sizeof buf[4], "%s-attr", dbfile);
- j = BIO_snprintf(buf[3], sizeof buf[3], "%s-attr-%s", dbfile, old_suffix);
- j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr-%s", dbfile, new_suffix);
- j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", dbfile, old_suffix);
- j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, new_suffix);
+ j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s-attr", dbfile);
+ j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s-attr-%s", dbfile, old_suffix);
+ j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr-%s", dbfile, new_suffix);
+ j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", dbfile, old_suffix);
+ j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, new_suffix);
#endif
if (rename(dbfile, buf[1]) < 0 && errno != ENOENT
#ifdef ENOTDIR
BIO_printf(bio_out, "%s - ", nm);
}
#endif
- BIO_puts(bio_out, SSL_CIPHER_description(c, buf, sizeof buf));
+ BIO_puts(bio_out, SSL_CIPHER_description(c, buf, sizeof(buf)));
}
}
"\n"
" if (dh == NULL)\n"
" return NULL;\n");
- BIO_printf(out, " dhp_bn = BN_bin2bn(dhp_%d, sizeof (dhp_%d), NULL);\n",
+ BIO_printf(out, " dhp_bn = BN_bin2bn(dhp_%d, sizeof(dhp_%d), NULL);\n",
bits, bits);
- BIO_printf(out, " dhg_bn = BN_bin2bn(dhg_%d, sizeof (dhg_%d), NULL);\n",
+ BIO_printf(out, " dhg_bn = BN_bin2bn(dhg_%d, sizeof(dhg_%d), NULL);\n",
bits, bits);
BIO_printf(out, " if (dhp_bn == NULL || dhg_bn == NULL\n"
" || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn)) {\n"
"\n");
BIO_printf(bio_out, " if (dsa == NULL)\n"
" return NULL;\n");
- BIO_printf(bio_out, " dsa->p = BN_bin2bn(dsap_%d, sizeof (dsap_%d), NULL);\n",
+ BIO_printf(bio_out, " dsa->p = BN_bin2bn(dsap_%d, sizeof(dsap_%d), NULL);\n",
bits_p, bits_p);
- BIO_printf(bio_out, " dsa->q = BN_bin2bn(dsaq_%d, sizeof (dsaq_%d), NULL);\n",
+ BIO_printf(bio_out, " dsa->q = BN_bin2bn(dsaq_%d, sizeof(dsaq_%d), NULL);\n",
bits_p, bits_p);
- BIO_printf(bio_out, " dsa->g = BN_bin2bn(dsag_%d, sizeof (dsag_%d), NULL);\n",
+ BIO_printf(bio_out, " dsa->g = BN_bin2bn(dsag_%d, sizeof(dsag_%d), NULL);\n",
bits_p, bits_p);
BIO_printf(bio_out, " if (!dsa->p || !dsa->q || !dsa->g) {\n"
" DSA_free(dsa);\n"
" BIGNUM *tmp_3 = NULL;\n"
"\n");
- BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_p_%d, sizeof (ec_p_%d), NULL)) == NULL)\n"
+ BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_p_%d, sizeof(ec_p_%d), NULL)) == NULL)\n"
" goto err;\n", len, len);
- BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_a_%d, sizeof (ec_a_%d), NULL)) == NULL)\n"
+ BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_a_%d, sizeof(ec_a_%d), NULL)) == NULL)\n"
" goto err;\n", len, len);
- BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_b_%d, sizeof (ec_b_%d), NULL)) == NULL)\n"
+ BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_b_%d, sizeof(ec_b_%d), NULL)) == NULL)\n"
" goto err;\n", len, len);
BIO_printf(out, " if ((group = EC_GROUP_new_curve_GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)\n"
" goto err;\n"
"\n");
BIO_printf(out, " /* build generator */\n");
- BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_gen_%d, sizeof (ec_gen_%d), tmp_1)) == NULL)\n"
+ BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_gen_%d, sizeof(ec_gen_%d), tmp_1)) == NULL)\n"
" goto err;\n", len, len);
BIO_printf(out, " point = EC_POINT_bn2point(group, tmp_1, NULL, NULL);\n");
BIO_printf(out, " if (point == NULL)\n"
" goto err;\n");
- BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_order_%d, sizeof (ec_order_%d), tmp_2)) == NULL)\n"
+ BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_order_%d, sizeof(ec_order_%d), tmp_2)) == NULL)\n"
" goto err;\n", len, len);
- BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_cofactor_%d, sizeof (ec_cofactor_%d), tmp_3)) == NULL)\n"
+ BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_cofactor_%d, sizeof(ec_cofactor_%d), tmp_3)) == NULL)\n"
" goto err;\n", len, len);
BIO_printf(out, " if (!EC_GROUP_set_generator(group, point, tmp_2, tmp_3))\n"
" goto err;\n"
char *hkey = NULL, *hiv = NULL, *hsalt = NULL, *p;
char *infile = NULL, *outfile = NULL, *prog;
char *str = NULL, *passarg = NULL, *pass = NULL, *strbuf = NULL;
- char mbuf[sizeof magic - 1];
+ char mbuf[sizeof(magic) - 1];
OPTION_CHOICE o;
int bsize = BSIZE, verbose = 0, debug = 0, olb64 = 0, nosalt = 0;
int enc = 1, printkey = 0, i, k;
in = bio_open_default(opt_arg(), 'r', FORMAT_TEXT);
if (in == NULL)
goto opthelp;
- i = BIO_gets(in, buf, sizeof buf);
+ i = BIO_gets(in, buf, sizeof(buf));
BIO_free(in);
in = NULL;
if (i <= 0) {
for (;;) {
char prompt[200];
- BIO_snprintf(prompt, sizeof prompt, "enter %s %s password:",
+ BIO_snprintf(prompt, sizeof(prompt), "enter %s %s password:",
OBJ_nid2ln(EVP_CIPHER_nid(cipher)),
(enc) ? "encryption" : "decryption");
strbuf[0] = '\0';
else {
if (enc) {
if (hsalt) {
- if (!set_hex(hsalt, salt, sizeof salt)) {
+ if (!set_hex(hsalt, salt, sizeof(salt))) {
BIO_printf(bio_err, "invalid hex salt value\n");
goto end;
}
- } else if (RAND_bytes(salt, sizeof salt) <= 0)
+ } else if (RAND_bytes(salt, sizeof(salt)) <= 0)
goto end;
/*
* If -P option then don't bother writing
*/
if ((printkey != 2)
&& (BIO_write(wbio, magic,
- sizeof magic - 1) != sizeof magic - 1
+ sizeof(magic) - 1) != sizeof(magic) - 1
|| BIO_write(wbio,
(char *)salt,
- sizeof salt) != sizeof salt)) {
+ sizeof(salt)) != sizeof(salt))) {
BIO_printf(bio_err, "error writing output file\n");
goto end;
}
- } else if (BIO_read(rbio, mbuf, sizeof mbuf) != sizeof mbuf
+ } else if (BIO_read(rbio, mbuf, sizeof(mbuf)) != sizeof(mbuf)
|| BIO_read(rbio,
(unsigned char *)salt,
- sizeof salt) != sizeof salt) {
+ sizeof(salt)) != sizeof(salt)) {
BIO_printf(bio_err, "error reading input file\n");
goto end;
- } else if (memcmp(mbuf, magic, sizeof magic - 1)) {
+ } else if (memcmp(mbuf, magic, sizeof(magic) - 1)) {
BIO_printf(bio_err, "bad magic number\n");
goto end;
}
int siz = EVP_CIPHER_iv_length(cipher);
if (siz == 0) {
BIO_printf(bio_err, "warning: iv not use by this cipher\n");
- } else if (!set_hex(hiv, iv, sizeof iv)) {
+ } else if (!set_hex(hiv, iv, sizeof(iv))) {
BIO_printf(bio_err, "invalid hex iv value\n");
goto end;
}
*/
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
| OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
- ERR_error_string_n(l, buf, sizeof buf);
+ ERR_error_string_n(l, buf, sizeof(buf));
BIO_printf(bio_out, "%s\n", buf);
}
}
*pcbio = cbio;
/* Read the request line. */
- len = BIO_gets(cbio, reqbuf, sizeof reqbuf);
+ len = BIO_gets(cbio, reqbuf, sizeof(reqbuf));
if (len <= 0)
return 1;
if (strncmp(reqbuf, "GET ", 4) == 0) {
/* Read and skip past the headers. */
for (;;) {
- len = BIO_gets(cbio, inbuf, sizeof inbuf);
+ len = BIO_gets(cbio, inbuf, sizeof(inbuf));
if (len <= 0)
return 1;
if ((inbuf[0] == '\r') || (inbuf[0] == '\n'))
for (;;) {
ret = 0;
/* Read a line, continue reading if line ends with \ */
- for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) {
+ for (p = buf, n = sizeof(buf), i = 0, first = 1; n > 0; first = 0) {
prompt = first ? "OpenSSL> " : "> ";
p[0] = '\0';
#ifndef READLINE
n -= 4;
/* Copy over the name, in lowercase. */
- if (n > sizeof prog - 1)
- n = sizeof prog - 1;
+ if (n > sizeof(prog) - 1)
+ n = sizeof(prog) - 1;
for (q = prog, i = 0; i < n; i++, p++)
*q++ = tolower((unsigned char)*p);
*q = '\0';
}
q = strrchr(p, '.');
- strncpy(prog, p, sizeof prog - 1);
- prog[sizeof prog - 1] = '\0';
- if (q != NULL && q - p < sizeof prog)
+ strncpy(prog, p, sizeof(prog) - 1);
+ prog[sizeof(prog) - 1] = '\0';
+ if (q != NULL && q - p < sizeof(prog))
prog[q - p] = '\0';
return prog;
}
p++;
break;
}
- strncpy(prog, p, sizeof prog - 1);
- prog[sizeof prog - 1] = '\0';
+ strncpy(prog, p, sizeof(prog) - 1);
+ prog[sizeof(prog) - 1] = '\0';
return prog;
}
#endif
i += 1 + strlen(valtype2param(o));
if (i < MAX_OPT_HELP_WIDTH && i > width)
width = i;
- assert(i < (int)sizeof start);
+ assert(i < (int)sizeof(start));
}
if (standard_prolog)
/* Pad out prefix */
memset(start, ' ', sizeof(start) - 1);
- start[sizeof start - 1] = '\0';
+ start[sizeof(start) - 1] = '\0';
if (o->name == OPT_MORE_STR) {
/* Continuation of previous line; pad and print. */
/* ignore rest of line */
char trash[BUFSIZ];
do
- r = BIO_gets(in, trash, sizeof trash);
+ r = BIO_gets(in, trash, sizeof(trash));
while ((r > 0) && (!strchr(trash, '\n')));
}
if (magic_len > 4) /* assert it's "1" or "apr1" */
return NULL;
- OPENSSL_strlcat(out_buf, magic, sizeof out_buf);
- OPENSSL_strlcat(out_buf, "$", sizeof out_buf);
- OPENSSL_strlcat(out_buf, salt, sizeof out_buf);
+ OPENSSL_strlcat(out_buf, magic, sizeof(out_buf));
+ OPENSSL_strlcat(out_buf, "$", sizeof(out_buf));
+ OPENSSL_strlcat(out_buf, salt, sizeof(out_buf));
if (strlen(out_buf) > 6 + 8) /* assert "$apr1$..salt.." */
return NULL;
|| !EVP_DigestFinal_ex(md2, buf, NULL))
goto err;
- for (i = passwd_len; i > sizeof buf; i -= sizeof buf) {
- if (!EVP_DigestUpdate(md, buf, sizeof buf))
+ for (i = passwd_len; i > sizeof(buf); i -= sizeof(buf)) {
+ if (!EVP_DigestUpdate(md, buf, sizeof(buf)))
goto err;
}
if (!EVP_DigestUpdate(md, buf, i))
goto err;
if (!EVP_DigestUpdate(md2,
(i & 1) ? (unsigned const char *)passwd : buf,
- (i & 1) ? passwd_len : sizeof buf))
+ (i & 1) ? passwd_len : sizeof(buf)))
goto err;
if (i % 3) {
if (!EVP_DigestUpdate(md2, salt_out, salt_len))
}
if (!EVP_DigestUpdate(md2,
(i & 1) ? buf : (unsigned const char *)passwd,
- (i & 1) ? sizeof buf : passwd_len))
+ (i & 1) ? sizeof(buf) : passwd_len))
goto err;
if (!EVP_DigestFinal_ex(md2, buf, NULL))
goto err;
{
/* transform buf into output string */
- unsigned char buf_perm[sizeof buf];
+ unsigned char buf_perm[sizeof(buf)];
int dest, source;
char *output;
buf_perm[15] = buf[11];
# ifndef PEDANTIC /* Unfortunately, this generates a "no
* effect" warning */
- assert(16 == sizeof buf_perm);
+ assert(16 == sizeof(buf_perm));
# endif
output = salt_out + salt_len;
if (1) {
#ifndef OPENSSL_NO_UI
if (EVP_read_pw_string
- (macpass, sizeof macpass, "Enter MAC Password:", export_cert)) {
+ (macpass, sizeof(macpass), "Enter MAC Password:", export_cert)) {
BIO_printf(bio_err, "Can't read Password\n");
goto end;
}
if (!noprompt) {
if (1) {
#ifndef OPENSSL_NO_UI
- if (EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:",
+ if (EVP_read_pw_string(pass, sizeof(pass), "Enter Export Password:",
1)) {
BIO_printf(bio_err, "Can't read Password\n");
goto export_end;
}
if (!twopass)
- OPENSSL_strlcpy(macpass, pass, sizeof macpass);
+ OPENSSL_strlcpy(macpass, pass, sizeof(macpass));
p12 = PKCS12_create(cpass, name, key, ucert, certs,
key_pbe, cert_pbe, iter, -1, keytype);
if (!noprompt) {
if (1) {
#ifndef OPENSSL_NO_UI
- if (EVP_read_pw_string(pass, sizeof pass, "Enter Import Password:",
+ if (EVP_read_pw_string(pass, sizeof(pass), "Enter Import Password:",
0)) {
BIO_printf(bio_err, "Can't read Password\n");
goto end;
}
if (!twopass)
- OPENSSL_strlcpy(macpass, pass, sizeof macpass);
+ OPENSSL_strlcpy(macpass, pass, sizeof(macpass));
if ((options & INFO) && PKCS12_mac_present(p12)) {
const ASN1_INTEGER *tmaciter;
#ifndef OPENSSL_NO_UI
p8pass = pass;
if (EVP_read_pw_string
- (pass, sizeof pass, "Enter Encryption Password:", 1)) {
+ (pass, sizeof(pass), "Enter Encryption Password:", 1)) {
X509_ALGOR_free(pbe);
goto end;
}
else if (1) {
#ifndef OPENSSL_NO_UI
p8pass = pass;
- if (EVP_read_pw_string(pass, sizeof pass, "Enter Password:", 0)) {
+ if (EVP_read_pw_string(pass, sizeof(pass), "Enter Password:", 0)) {
BIO_printf(bio_err, "Can't read Password\n");
goto end;
}
chunk = num;
if (chunk > (int)sizeof(buf))
- chunk = sizeof buf;
+ chunk = sizeof(buf);
r = RAND_bytes(buf, chunk);
if (r <= 0)
goto end;
/* If OBJ not recognised ignore it */
if ((nid = OBJ_txt2nid(type)) == NID_undef)
goto start;
- if (BIO_snprintf(buf, sizeof buf, "%s_default", v->name)
+ if (BIO_snprintf(buf, sizeof(buf), "%s_default", v->name)
>= (int)sizeof(buf)) {
BIO_printf(bio_err, "Name '%s' too long\n", v->name);
return 0;
def = "";
}
- BIO_snprintf(buf, sizeof buf, "%s_value", v->name);
+ BIO_snprintf(buf, sizeof(buf), "%s_value", v->name);
if ((value = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) {
ERR_clear_error();
value = NULL;
}
- BIO_snprintf(buf, sizeof buf, "%s_min", v->name);
+ BIO_snprintf(buf, sizeof(buf), "%s_min", v->name);
if (!NCONF_get_number(req_conf, dn_sect, buf, &n_min)) {
ERR_clear_error();
n_min = -1;
}
- BIO_snprintf(buf, sizeof buf, "%s_max", v->name);
+ BIO_snprintf(buf, sizeof(buf), "%s_max", v->name);
if (!NCONF_get_number(req_conf, dn_sect, buf, &n_max)) {
ERR_clear_error();
n_max = -1;
if ((nid = OBJ_txt2nid(type)) == NID_undef)
goto start2;
- if (BIO_snprintf(buf, sizeof buf, "%s_default", type)
+ if (BIO_snprintf(buf, sizeof(buf), "%s_default", type)
>= (int)sizeof(buf)) {
BIO_printf(bio_err, "Name '%s' too long\n", v->name);
return 0;
def = "";
}
- BIO_snprintf(buf, sizeof buf, "%s_value", type);
+ BIO_snprintf(buf, sizeof(buf), "%s_value", type);
if ((value = NCONF_get_string(req_conf, attr_sect, buf))
== NULL) {
ERR_clear_error();
value = NULL;
}
- BIO_snprintf(buf, sizeof buf, "%s_min", type);
+ BIO_snprintf(buf, sizeof(buf), "%s_min", type);
if (!NCONF_get_number(req_conf, attr_sect, buf, &n_min)) {
ERR_clear_error();
n_min = -1;
}
- BIO_snprintf(buf, sizeof buf, "%s_max", type);
+ BIO_snprintf(buf, sizeof(buf), "%s_max", type);
if (!NCONF_get_number(req_conf, attr_sect, buf, &n_max)) {
ERR_clear_error();
n_max = -1;
BIO_printf(bio_err, "%s [%s]:", text, def);
(void)BIO_flush(bio_err);
if (value != NULL) {
- OPENSSL_strlcpy(buf, value, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, value, sizeof(buf));
+ OPENSSL_strlcat(buf, "\n", sizeof(buf));
BIO_printf(bio_err, "%s\n", value);
} else {
buf[0] = '\0';
if (!batch) {
- if (!fgets(buf, sizeof buf, stdin))
+ if (!fgets(buf, sizeof(buf), stdin))
return 0;
} else {
buf[0] = '\n';
else if (buf[0] == '\n') {
if ((def == NULL) || (def[0] == '\0'))
return (1);
- OPENSSL_strlcpy(buf, def, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, def, sizeof(buf));
+ OPENSSL_strlcat(buf, "\n", sizeof(buf));
} else if ((buf[0] == '.') && (buf[1] == '\n'))
return (1);
BIO_printf(bio_err, "%s [%s]:", text, def);
(void)BIO_flush(bio_err);
if (value != NULL) {
- OPENSSL_strlcpy(buf, value, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, value, sizeof(buf));
+ OPENSSL_strlcat(buf, "\n", sizeof(buf));
BIO_printf(bio_err, "%s\n", value);
} else {
buf[0] = '\0';
if (!batch) {
- if (!fgets(buf, sizeof buf, stdin))
+ if (!fgets(buf, sizeof(buf), stdin))
return 0;
} else {
buf[0] = '\n';
else if (buf[0] == '\n') {
if ((def == NULL) || (def[0] == '\0'))
return (1);
- OPENSSL_strlcpy(buf, def, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, def, sizeof(buf));
+ OPENSSL_strlcat(buf, "\n", sizeof(buf));
} else if ((buf[0] == '.') && (buf[1] == '\n'))
return (1);
BIO_printf(bio, "---\nCertificate chain\n");
for (i = 0; i < sk_X509_num(sk); i++) {
X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk, i)),
- buf, sizeof buf);
+ buf, sizeof(buf));
BIO_printf(bio, "%2d s:%s\n", i, buf);
X509_NAME_oneline(X509_get_issuer_name(sk_X509_value(sk, i)),
- buf, sizeof buf);
+ buf, sizeof(buf));
BIO_printf(bio, " i:%s\n", buf);
if (c_showcerts)
PEM_write_bio_X509(bio, sk_X509_value(sk, i));
/* Redundant if we showed the whole chain */
if (!(c_showcerts && got_a_chain))
PEM_write_bio_X509(bio, peer);
- X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf);
+ X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof(buf));
BIO_printf(bio, "subject=%s\n", buf);
- X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf);
+ X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof(buf));
BIO_printf(bio, "issuer=%s\n", buf);
} else
BIO_printf(bio, "no peer certificate available\n");
SSL_CTX_set_verify(ctx, s_server_verify, verify_callback);
if (!SSL_CTX_set_session_id_context(ctx,
(void *)&s_server_session_id_context,
- sizeof s_server_session_id_context)) {
+ sizeof(s_server_session_id_context))) {
BIO_printf(bio_err, "error setting session id context\n");
ERR_print_errors(bio_err);
goto end;
SSL_CTX_set_verify(ctx2, s_server_verify, verify_callback);
if (!SSL_CTX_set_session_id_context(ctx2,
(void *)&s_server_session_id_context,
- sizeof s_server_session_id_context)) {
+ sizeof(s_server_session_id_context))) {
BIO_printf(bio_err, "error setting session id context\n");
ERR_print_errors(bio_err);
goto end;
if (peer != NULL) {
BIO_printf(bio_s_out, "Client certificate\n");
PEM_write_bio_X509(bio_s_out, peer);
- X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf);
+ X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof(buf));
BIO_printf(bio_s_out, "subject=%s\n", buf);
- X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf);
+ X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof(buf));
BIO_printf(bio_s_out, "issuer=%s\n", buf);
X509_free(peer);
peer = NULL;
}
- if (SSL_get_shared_ciphers(con, buf, sizeof buf) != NULL)
+ if (SSL_get_shared_ciphers(con, buf, sizeof(buf)) != NULL)
BIO_printf(bio_s_out, "Shared ciphers:%s\n", buf);
str = SSL_CIPHER_get_name(SSL_get_current_cipher(con));
ssl_print_sigalgs(bio_s_out, con);
goto end;
if (www_path != NULL) {
- buf_len = BIO_snprintf(buf, sizeof buf,
+ buf_len = BIO_snprintf(buf, sizeof(buf),
fmt_http_get_cmd, www_path);
if (SSL_write(scon, buf, buf_len) <= 0)
goto end;
}
if (www_path != NULL) {
- buf_len = BIO_snprintf(buf, sizeof buf,
+ buf_len = BIO_snprintf(buf, sizeof(buf),
fmt_http_get_cmd, www_path);
if (SSL_write(scon, buf, buf_len) <= 0)
goto end;
goto end;
if (www_path) {
- BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n",
+ BIO_snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n",
www_path);
if (SSL_write(scon, buf, strlen(buf)) <= 0)
goto end;
#ifndef OPENSSL_NO_DSA
if (RAND_status() != 1) {
- RAND_seed(rnd_seed, sizeof rnd_seed);
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
}
for (testnum = 0; testnum < DSA_NUM; testnum++) {
int st = 0;
#ifndef OPENSSL_NO_EC
if (RAND_status() != 1) {
- RAND_seed(rnd_seed, sizeof rnd_seed);
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
}
for (testnum = 0; testnum < EC_NUM; testnum++) {
int st = 1;
}
if (RAND_status() != 1) {
- RAND_seed(rnd_seed, sizeof rnd_seed);
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
}
for (testnum = 0; testnum < EC_NUM; testnum++) {
int ecdh_checks = 1;
if (**string == 0)
return NULL;
- memset(isdelim, 0, sizeof isdelim);
+ memset(isdelim, 0, sizeof(isdelim));
isdelim[0] = 1;
while (*delim) {
char *p;
f = fdopen(fds[n], "r");
- while (fgets(buf, sizeof buf, f)) {
+ while (fgets(buf, sizeof(buf), f)) {
p = strchr(buf, '\n');
if (p)
*p = '\0';
** Process the terminal input
*/
LogMessage ("Waiting on terminal I/O ...\n");
- len = recv (TermSock, TermBuff, sizeof (TermBuff), 0) ;
+ len = recv (TermSock, TermBuff, sizeof(TermBuff), 0) ;
TermBuff[len] = '\0';
LogMessage ("Received terminal I/O [%s]", TermBuff);
TerminalDeviceAst,
0,
TerminalDeviceBuff,
- sizeof (TerminalDeviceBuff) - 2,
+ sizeof(TerminalDeviceBuff) - 2,
0, 0, 0, 0);
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$QIO () - %08X", status);
/*
** Initialize the socket information
*/
- slen = sizeof (sin);
+ slen = sizeof(sin);
memset ((char *) &sin, 0, slen);
sin.sin_family = SocketFamily;
sin.sin_addr.s_addr = inet_addr (LocalHostAddr);
/*
** Now issue the connect
*/
- memset ((char *) &sin, 0, sizeof (sin)) ;
+ memset ((char *) &sin, 0, sizeof(sin)) ;
sin.sin_family = SocketFamily;
sin.sin_addr.s_addr = inet_addr (LocalHostAddr) ;
sin.sin_port = LocalHostPort ;
- status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof (sin));
+ status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof(sin));
if (status < 0 ) {
LogMessage ("CreateSocketPair: connect () - %d", errno);
sys$cantim (&sptb, 0);
TerminalDeviceAst,
0,
TerminalDeviceBuff,
- sizeof (TerminalDeviceBuff) - 1,
+ sizeof(TerminalDeviceBuff) - 1,
0, 0, 0, 0);
/*
char *m;
int len;
- X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof buf);
+ X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof(buf));
BIO_printf(out, "/*\n"
" * Subject: %s\n", buf);
- X509_NAME_oneline(X509_get_issuer_name(x), buf, sizeof buf);
+ X509_NAME_oneline(X509_get_issuer_name(x), buf, sizeof(buf));
BIO_printf(out, " * Issuer: %s\n"
" */\n", buf);
if ((minsize > 0) && (nchar < minsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT);
- BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize);
+ BIO_snprintf(strbuf, sizeof(strbuf), "%ld", minsize);
ERR_add_error_data(2, "minsize=", strbuf);
return -1;
}
if ((maxsize > 0) && (nchar > maxsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG);
- BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
+ BIO_snprintf(strbuf, sizeof(strbuf), "%ld", maxsize);
ERR_add_error_data(2, "maxsize=", strbuf);
return -1;
}
{
int i, first, len = 0, c, use_bn;
char ftmp[24], *tmp = ftmp;
- int tmpsize = sizeof ftmp;
+ int tmpsize = sizeof(ftmp);
const char *p;
unsigned long l;
BIGNUM *bl = NULL;
if ((a == NULL) || (a->data == NULL))
return (BIO_write(bp, "NULL", 4));
- i = i2t_ASN1_OBJECT(buf, sizeof buf, a);
+ i = i2t_ASN1_OBJECT(buf, sizeof(buf), a);
if (i > (int)(sizeof(buf) - 1)) {
p = OPENSSL_malloc(i + 1);
if (p == NULL)
if (c > 0xffffffffL)
return -1;
if (c > 0xffff) {
- BIO_snprintf(tmphex, sizeof tmphex, "\\W%08lX", c);
+ BIO_snprintf(tmphex, sizeof(tmphex), "\\W%08lX", c);
if (!io_ch(arg, tmphex, 10))
return -1;
return 10;
}
if (c > 0xff) {
- BIO_snprintf(tmphex, sizeof tmphex, "\\U%04lX", c);
+ BIO_snprintf(tmphex, sizeof(tmphex), "\\U%04lX", c);
if (!io_ch(arg, tmphex, 6))
return -1;
return 6;
if (type & BUF_TYPE_CONVUTF8) {
unsigned char utfbuf[6];
int utflen;
- utflen = UTF8_putc(utfbuf, sizeof utfbuf, c);
+ utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c);
for (i = 0; i < utflen; i++) {
/*
* We don't need to worry about setting orflags correctly
if (fn_opt != XN_FLAG_FN_NONE) {
int objlen, fld_len;
if ((fn_opt == XN_FLAG_FN_OID) || (fn_nid == NID_undef)) {
- OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1);
+ OBJ_obj2txt(objtmp, sizeof(objtmp), fn, 1);
fld_len = 0; /* XXX: what should this be? */
objbuf = objtmp;
} else {
p = str;
if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
- BIO_snprintf(str, sizeof str, "priv [ %d ] ", tag);
+ BIO_snprintf(str, sizeof(str), "priv [ %d ] ", tag);
else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
- BIO_snprintf(str, sizeof str, "cont [ %d ]", tag);
+ BIO_snprintf(str, sizeof(str), "cont [ %d ]", tag);
else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
- BIO_snprintf(str, sizeof str, "appl [ %d ]", tag);
+ BIO_snprintf(str, sizeof(str), "appl [ %d ]", tag);
else if (tag > 30)
- BIO_snprintf(str, sizeof str, "<ASN1 %d>", tag);
+ BIO_snprintf(str, sizeof(str), "<ASN1 %d>", tag);
else
p = ASN1_tag2str(tag);
ln = OBJ_nid2ln(OBJ_obj2nid(oid));
if (!ln)
ln = "";
- OBJ_obj2txt(objbuf, sizeof objbuf, oid, 1);
+ OBJ_obj2txt(objbuf, sizeof(objbuf), oid, 1);
if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0)
return 0;
return 1;
{
async_ctx *nctx = NULL;
- nctx = OPENSSL_malloc(sizeof (async_ctx));
+ nctx = OPENSSL_malloc(sizeof(async_ctx));
if (nctx == NULL) {
ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);
goto err;
{
ASYNC_JOB *job = NULL;
- job = OPENSSL_zalloc(sizeof (ASYNC_JOB));
+ job = OPENSSL_zalloc(sizeof(ASYNC_JOB));
if (job == NULL) {
ASYNCerr(ASYNC_F_ASYNC_JOB_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
return 0;
}
- pool = OPENSSL_zalloc(sizeof *pool);
+ pool = OPENSSL_zalloc(sizeof(*pool));
if (pool == NULL) {
ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
return 0;
{
struct fd_lookup_st *fdlookup;
- fdlookup = OPENSSL_zalloc(sizeof *fdlookup);
+ fdlookup = OPENSSL_zalloc(sizeof(*fdlookup));
if (fdlookup == NULL)
return 0;
int gai_ret = 0;
struct addrinfo hints;
- memset(&hints, 0, sizeof hints);
+ memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = socktype;
if ((rows * dump_width) < len)
rows++;
for (i = 0; i < rows; i++) {
- OPENSSL_strlcpy(buf, str, sizeof buf);
- BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width);
- OPENSSL_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcpy(buf, str, sizeof(buf));
+ BIO_snprintf(tmp, sizeof(tmp), "%04x - ", i * dump_width);
+ OPENSSL_strlcat(buf, tmp, sizeof(buf));
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len) {
- OPENSSL_strlcat(buf, " ", sizeof buf);
+ OPENSSL_strlcat(buf, " ", sizeof(buf));
} else {
ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
- BIO_snprintf(tmp, sizeof tmp, "%02x%c", ch,
+ BIO_snprintf(tmp, sizeof(tmp), "%02x%c", ch,
j == 7 ? '-' : ' ');
- OPENSSL_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof(buf));
}
}
- OPENSSL_strlcat(buf, " ", sizeof buf);
+ OPENSSL_strlcat(buf, " ", sizeof(buf));
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len)
break;
ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
#ifndef CHARSET_EBCDIC
- BIO_snprintf(tmp, sizeof tmp, "%c",
+ BIO_snprintf(tmp, sizeof(tmp), "%c",
((ch >= ' ') && (ch <= '~')) ? ch : '.');
#else
- BIO_snprintf(tmp, sizeof tmp, "%c",
+ BIO_snprintf(tmp, sizeof(tmp), "%c",
((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
? os_toebcdic[ch]
: '.');
#endif
- OPENSSL_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof(buf));
}
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof(buf));
/*
* if this is the last call then update the ddt_dump thing so that we
* will move the selection point in the debug window
}
#ifdef TRUNCATE
if (trc > 0) {
- BIO_snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", str,
+ BIO_snprintf(buf, sizeof(buf), "%s%04x - <SPACES/NULS>\n", str,
len + trc);
ret += cb((void *)buf, strlen(buf), u);
}
iconvert[iplace++] = "0123456789"[intpart % 10];
intpart = (intpart / 10);
} while (intpart && (iplace < (int)sizeof(iconvert)));
- if (iplace == sizeof iconvert)
+ if (iplace == sizeof(iconvert))
iplace--;
iconvert[iplace] = 0;
fracpart = (fracpart / 10);
}
- if (fplace == sizeof fconvert)
+ if (fplace == sizeof(fconvert))
fplace--;
fconvert[fplace] = 0;
if (BIO_CB_RETURN & cmd)
r = ret;
- len = BIO_snprintf(buf, sizeof buf, "BIO[%p]: ", (void *)bio);
+ len = BIO_snprintf(buf, sizeof(buf), "BIO[%p]: ", (void *)bio);
/* Ignore errors and continue printing the other information. */
if (len < 0)
b->shutdown = (int)num & BIO_CLOSE;
if (num & BIO_FP_APPEND) {
if (num & BIO_FP_READ)
- OPENSSL_strlcpy(p, "a+", sizeof p);
+ OPENSSL_strlcpy(p, "a+", sizeof(p));
else
- OPENSSL_strlcpy(p, "a", sizeof p);
+ OPENSSL_strlcpy(p, "a", sizeof(p));
} else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
- OPENSSL_strlcpy(p, "r+", sizeof p);
+ OPENSSL_strlcpy(p, "r+", sizeof(p));
else if (num & BIO_FP_WRITE)
- OPENSSL_strlcpy(p, "w", sizeof p);
+ OPENSSL_strlcpy(p, "w", sizeof(p));
else if (num & BIO_FP_READ)
- OPENSSL_strlcpy(p, "r", sizeof p);
+ OPENSSL_strlcpy(p, "r", sizeof(p));
else {
BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE);
ret = 0;
if (!init) {
init++;
#ifdef BN_LLONG
- BIO_snprintf(data, sizeof data, "bn(%d,%d)",
+ BIO_snprintf(data, sizeof(data), "bn(%d,%d)",
(int)sizeof(BN_ULLONG) * 8, (int)sizeof(BN_ULONG) * 8);
#else
- BIO_snprintf(data, sizeof data, "bn(%d,%d)",
+ BIO_snprintf(data, sizeof(data), "bn(%d,%d)",
(int)sizeof(BN_ULONG) * 8, (int)sizeof(BN_ULONG) * 8);
#endif
}
OPENSSL_free(section);
if (line != NULL)
*line = eline;
- BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
+ BIO_snprintf(btmp, sizeof(btmp), "%ld", eline);
ERR_add_error_data(2, "line ", btmp);
if (h != conf->data) {
CONF_free(conf->data);
if (!(flags & CONF_MFLAGS_SILENT)) {
char rcode[DECIMAL_SIZE(ret) + 1];
CONFerr(CONF_F_MODULE_RUN, CONF_R_MODULE_INITIALIZATION_ERROR);
- BIO_snprintf(rcode, sizeof rcode, "%-8d", ret);
+ BIO_snprintf(rcode, sizeof(rcode), "%-8d", ret);
ERR_add_error_data(6, "module=", name, ", value=", value,
", retcode=", rcode);
}
size = "int";
else
size = "long";
- BIO_snprintf(buf, sizeof buf, "des(%s)", size);
+ BIO_snprintf(buf, sizeof(buf), "des(%s)", size);
init = 0;
}
return (buf);
/* Convert password to ASCII. */
OPENSSL_strlcpy(e_buf, buf, sizeof(e_buf));
- ebcdic2ascii(e_buf, e_buf, sizeof e_buf);
+ ebcdic2ascii(e_buf, e_buf, sizeof(e_buf));
/* Encrypt it (from/to ASCII); if it worked, convert back. */
ret = DES_fcrypt(e_buf, e_salt, buff);
register int i;
#ifdef OPENBSD_DEV_CRYPTO
- memcpy(schedule->key, key, sizeof schedule->key);
+ memcpy(schedule->key, key, sizeof(schedule->key));
schedule->session = NULL;
#endif
k = &schedule->ks->deslong[0];
totalnum = num + numblocks;
- wsize = OPENSSL_malloc(totalnum * sizeof wsize[0]);
- wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]);
- wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space
- * for pivot */
- val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]);
+ wsize = OPENSSL_malloc(totalnum * sizeof(wsize[0]));
+ wNAF_len = OPENSSL_malloc(totalnum * sizeof(wNAF_len[0]));
+ /* include space for pivot */
+ wNAF = OPENSSL_malloc((totalnum + 1) * sizeof(wNAF[0]));
+ val_sub = OPENSSL_malloc(totalnum * sizeof(val_sub[0]));
/* Ensure wNAF is initialised in case we end up going to err */
if (wNAF != NULL)
* 'val_sub[i]' is a pointer to the subarray for the i-th point, or to a
* subarray of 'pre_comp->points' if we already have precomputation.
*/
- val = OPENSSL_malloc((num_val + 1) * sizeof val[0]);
+ val = OPENSSL_malloc((num_val + 1) * sizeof(val[0]));
if (val == NULL) {
ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);
goto err;
/* BN_bn2bin eats leading zeroes */
memset(b_out, 0, sizeof(b_out));
num_bytes = BN_num_bytes(bn);
- if (num_bytes > sizeof b_out) {
+ if (num_bytes > sizeof(b_out)) {
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
return 0;
}
{
felem_bytearray b_in, b_out;
felem_to_bin28(b_in, in);
- flip_endian(b_out, b_in, sizeof b_out);
- return BN_bin2bn(b_out, sizeof b_out, out);
+ flip_endian(b_out, b_in, sizeof(b_out));
+ return BN_bin2bn(b_out, sizeof(b_out), out);
}
/******************************************************************************/
/* BN_bn2bin eats leading zeroes */
memset(b_out, 0, sizeof(b_out));
num_bytes = BN_num_bytes(bn);
- if (num_bytes > sizeof b_out) {
+ if (num_bytes > sizeof(b_out)) {
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
return 0;
}
{
felem_bytearray b_in, b_out;
smallfelem_to_bin32(b_in, in);
- flip_endian(b_out, b_in, sizeof b_out);
- return BN_bin2bn(b_out, sizeof b_out, out);
+ flip_endian(b_out, b_in, sizeof(b_out));
+ return BN_bin2bn(b_out, sizeof(b_out), out);
}
/*-
/* BN_bn2bin eats leading zeroes */
memset(b_out, 0, sizeof(b_out));
num_bytes = BN_num_bytes(bn);
- if (num_bytes > sizeof b_out) {
+ if (num_bytes > sizeof(b_out)) {
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
return 0;
}
{
felem_bytearray b_in, b_out;
felem_to_bin66(b_in, in);
- flip_endian(b_out, b_in, sizeof b_out);
- return BN_bin2bn(b_out, sizeof b_out, out);
+ flip_endian(b_out, b_in, sizeof(b_out));
+ return BN_bin2bn(b_out, sizeof(b_out), out);
}
/*-
if (tmp == NULL || tmp_Z == NULL)
goto err;
- prod_Z = OPENSSL_malloc(num * sizeof prod_Z[0]);
+ prod_Z = OPENSSL_malloc(num * sizeof(prod_Z[0]));
if (prod_Z == NULL)
goto err;
for (i = 0; i < num; i++) {
tid.tid = CRYPTO_THREAD_get_current_id();
while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
- ERR_error_string_n(l, buf, sizeof buf);
+ ERR_error_string_n(l, buf, sizeof(buf));
BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", tid.ltid, buf,
file, line, (flags & ERR_TXT_STRING) ? data : "");
if (cb(buf2, strlen(buf2), u) <= 0)
}
b = ctx->cipher->block_size;
- OPENSSL_assert(b <= sizeof ctx->buf);
+ OPENSSL_assert(b <= sizeof(ctx->buf));
if (b == 1) {
*outl = 0;
return 1;
if (ctx->flags & EVP_CIPH_NO_PADDING)
return EVP_EncryptUpdate(ctx, out, outl, in, inl);
- OPENSSL_assert(b <= sizeof ctx->final);
+ OPENSSL_assert(b <= sizeof(ctx->final));
if (ctx->final_used) {
/* see comment about PTRDIFF_T comparison above */
EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_WRONG_FINAL_BLOCK_LENGTH);
return (0);
}
- OPENSSL_assert(b <= sizeof ctx->final);
+ OPENSSL_assert(b <= sizeof(ctx->final));
/*
* The following assumes that the ciphertext has been authenticated.
char obj_tmp[80];
EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_PBE_ALGORITHM);
if (!pbe_obj)
- OPENSSL_strlcpy(obj_tmp, "NULL", sizeof obj_tmp);
+ OPENSSL_strlcpy(obj_tmp, "NULL", sizeof(obj_tmp));
else
- i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj);
+ i2t_ASN1_OBJECT(obj_tmp, sizeof(obj_tmp), pbe_obj);
ERR_add_error_data(2, "TYPE=", obj_tmp);
return 0;
}
goto err;
}
keylen = EVP_CIPHER_CTX_key_length(ctx);
- OPENSSL_assert(keylen <= sizeof key);
+ OPENSSL_assert(keylen <= sizeof(key));
/* Decode parameter */
CRYPTO_THREAD_get_local(&threadstopkey);
if (local == NULL && alloc) {
- local = OPENSSL_zalloc(sizeof *local);
+ local = OPENSSL_zalloc(sizeof(*local));
if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
OPENSSL_free(local);
return NULL;
} tid;
CRYPTO_THREAD_ID ti;
-#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
+#define BUF_REMAIN (sizeof(buf) - (size_t)(bufp - buf))
lcl = localtime(&m->time);
BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
memset(buf, '>', ami_cnt);
tid.ltid = 0;
tid.tid = amip->threadid;
- BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
+ BIO_snprintf(buf + ami_cnt, sizeof(buf) - ami_cnt,
" thread=%lu, file=%s, line=%d, info=\"",
tid.ltid, amip->file,
amip->line);
memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
buf_len = 128 - 3;
} else {
- OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
+ OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof(buf) - buf_len);
buf_len = strlen(buf);
}
- BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
+ BIO_snprintf(buf + buf_len, sizeof(buf) - buf_len, "\"\n");
BIO_puts(l->bio, buf);
size_t pgsize;
size_t aligned;
- memset(&sh, 0, sizeof sh);
+ memset(&sh, 0, sizeof(sh));
/* make sure size and minsize are powers of 2 */
OPENSSL_assert(size > 0);
for (i = sh.bittable_size; i; i >>= 1)
sh.freelist_size++;
- sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof (char *));
+ sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof(char *));
OPENSSL_assert(sh.freelist != NULL);
if (sh.freelist == NULL)
goto err;
OPENSSL_free(sh.bitmalloc);
if (sh.map_result != NULL && sh.map_size)
munmap(sh.map_result, sh.map_size);
- memset(&sh, 0, sizeof sh);
+ memset(&sh, 0, sizeof(sh));
}
static int sh_allocated(const char *ptr)
n += i;
OPENSSL_free(bndec);
} else {
- BIO_snprintf(tbuf, sizeof tbuf, ".%lu", l);
+ BIO_snprintf(tbuf, sizeof(tbuf), ".%lu", l);
i = strlen(tbuf);
if (buf && (buf_len > 0)) {
OPENSSL_strlcpy(buf, tbuf, buf_len);
/* create the right magic header stuff */
OPENSSL_assert(strlen(objstr) + 23
+ 2 * EVP_CIPHER_iv_length(enc) + 13 <=
- sizeof buf);
+ sizeof(buf));
buf[0] = '\0';
PEM_proc_type(buf, PEM_TYPE_ENCRYPTED);
PEM_dek_info(buf, objstr, EVP_CIPHER_iv_length(enc),
OPENSSL_cleanse(buf, PEM_BUFSIZE);
OPENSSL_assert(strlen(objstr) + 23 + 2 * EVP_CIPHER_iv_length(enc) + 13
- <= sizeof buf);
+ <= sizeof(buf));
buf[0] = '\0';
PEM_proc_type(buf, PEM_TYPE_ENCRYPTED);
md_c[0] = md_count[0];
md_c[1] = md_count[1];
- memcpy(local_md, md, sizeof md);
+ memcpy(local_md, md, sizeof(md));
/* state_index <= state_num <= STATE_SIZE */
state_index += num;
st_num = state_num;
md_c[0] = md_count[0];
md_c[1] = md_count[1];
- memcpy(local_md, md, sizeof md);
+ memcpy(local_md, md, sizeof(md));
state_index += num_ceil;
if (state_index > state_num)
goto err;
#ifndef GETPID_IS_MEANINGLESS
if (curr_pid) { /* just in the first iteration to save time */
- if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof curr_pid))
+ if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof(curr_pid)))
goto err;
curr_pid = 0;
}
#endif
if (curr_time) { /* just in the first iteration to save time */
- if (!MD_Update(m, (unsigned char *)&curr_time, sizeof curr_time))
+ if (!MD_Update(m, (unsigned char *)&curr_time, sizeof(curr_time)))
goto err;
- if (!MD_Update(m, (unsigned char *)&tv, sizeof tv))
+ if (!MD_Update(m, (unsigned char *)&tv, sizeof(tv)))
goto err;
curr_time = 0;
if (!rand_hw_seed(m))
addr.sun_family = AF_UNIX;
if (strlen(path) >= sizeof(addr.sun_path))
return (-1);
- OPENSSL_strlcpy(addr.sun_path, path, sizeof addr.sun_path);
+ OPENSSL_strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1)
*/
curr_gid = getgid();
- RAND_add(&curr_gid, sizeof curr_gid, 1);
+ RAND_add(&curr_gid, sizeof(curr_gid), 1);
curr_gid = 0;
curr_pid = getpid();
- RAND_add(&curr_pid, sizeof curr_pid, 1);
+ RAND_add(&curr_pid, sizeof(curr_pid), 1);
curr_pid = 0;
curr_uid = getuid();
- RAND_add(&curr_uid, sizeof curr_uid, 1);
+ RAND_add(&curr_uid, sizeof(curr_uid), 1);
curr_uid = 0;
for (i = 0; i < (ENTROPY_NEEDED * 4); i++) {
/* take 8 bits */
v = (unsigned char)(ts.tv_nsec % 256);
- RAND_add(&v, sizeof v, 1);
+ RAND_add(&v, sizeof(v), 1);
v = 0;
}
return 1;
# if defined(DEVRANDOM) || (!defined(OPENSSL_NO_EGD) && defined(DEVRANDOM_EGD))
if (n > 0) {
- RAND_add(tmpbuf, sizeof tmpbuf, (double)n);
+ RAND_add(tmpbuf, sizeof(tmpbuf), (double)n);
OPENSSL_cleanse(tmpbuf, n);
}
# endif
goto err;
}
if (!EVP_DigestInit_ex(ctx, Hash, NULL)
- || !EVP_DigestUpdate(ctx, zeroes, sizeof zeroes)
+ || !EVP_DigestUpdate(ctx, zeroes, sizeof(zeroes))
|| !EVP_DigestUpdate(ctx, mHash, hLen))
goto err;
if (maskedDBLen - i) {
if (ctx == NULL)
goto err;
if (!EVP_DigestInit_ex(ctx, Hash, NULL)
- || !EVP_DigestUpdate(ctx, zeroes, sizeof zeroes)
+ || !EVP_DigestUpdate(ctx, zeroes, sizeof(zeroes))
|| !EVP_DigestUpdate(ctx, mHash, hLen))
goto err;
if (sLen && !EVP_DigestUpdate(ctx, salt, sLen))
BIO_puts(out, ", ");
else
first = 0;
- OBJ_obj2txt(oidstr, sizeof oidstr,
+ OBJ_obj2txt(oidstr, sizeof(oidstr),
sk_ASN1_OBJECT_value(trust, i), 0);
BIO_puts(out, oidstr);
}
BIO_puts(out, ", ");
else
first = 0;
- OBJ_obj2txt(oidstr, sizeof oidstr,
+ OBJ_obj2txt(oidstr, sizeof(oidstr),
sk_ASN1_OBJECT_value(reject, i), 0);
BIO_puts(out, oidstr);
}
case GEN_IPADD:
p = gen->d.ip->data;
if (gen->d.ip->length == 4)
- BIO_snprintf(oline, sizeof oline,
+ BIO_snprintf(oline, sizeof(oline),
"%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
else if (gen->d.ip->length == 16) {
oline[0] = 0;
for (i = 0; i < 8; i++) {
- BIO_snprintf(htmp, sizeof htmp, "%X", p[0] << 8 | p[1]);
+ BIO_snprintf(htmp, sizeof(htmp), "%X", p[0] << 8 | p[1]);
p += 2;
strcat(oline, htmp);
if (i != 7)
goto err;
tret = tmp;
vtmp = sk_CONF_VALUE_value(tret, i);
- i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method);
+ i2t_ASN1_OBJECT(objtmp, sizeof(objtmp), desc->method);
nlen = strlen(objtmp) + strlen(vtmp->name) + 5;
ntmp = OPENSSL_malloc(nlen);
if (ntmp == NULL)
unsigned int *dest_len = NULL;
if (SSL3_RECORD_get_type(rr) == SSL3_RT_HANDSHAKE) {
- dest_maxlen = sizeof s->rlayer.d->handshake_fragment;
+ dest_maxlen = sizeof(s->rlayer.d->handshake_fragment);
dest = s->rlayer.d->handshake_fragment;
dest_len = &s->rlayer.d->handshake_fragment_len;
} else if (SSL3_RECORD_get_type(rr) == SSL3_RT_ALERT) {
s->rwstate = SSL_NOTHING;
s->s3->fatal_alert = alert_descr;
SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr);
- BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr);
+ BIO_snprintf(tmp, sizeof(tmp), "%d", alert_descr);
ERR_add_error_data(2, "SSL alert number ", tmp);
s->shutdown |= SSL_RECEIVED_SHUTDOWN;
SSL_CTX_remove_session(s->session_ctx, s->session);
totlen = 0;
/* Clear our SSL3_RECORD structures */
- memset(wr, 0, sizeof wr);
+ memset(wr, 0, sizeof(wr));
for (j = 0; j < numpipes; j++) {
/* write the header */
*(outbuf[j]++) = type & 0xff;
unsigned int *dest_len = NULL;
if (SSL3_RECORD_get_type(rr) == SSL3_RT_HANDSHAKE) {
- dest_maxlen = sizeof s->rlayer.handshake_fragment;
+ dest_maxlen = sizeof(s->rlayer.handshake_fragment);
dest = s->rlayer.handshake_fragment;
dest_len = &s->rlayer.handshake_fragment_len;
} else if (SSL3_RECORD_get_type(rr) == SSL3_RT_ALERT) {
- dest_maxlen = sizeof s->rlayer.alert_fragment;
+ dest_maxlen = sizeof(s->rlayer.alert_fragment);
dest = s->rlayer.alert_fragment;
dest_len = &s->rlayer.alert_fragment_len;
}
s->rwstate = SSL_NOTHING;
s->s3->fatal_alert = alert_descr;
SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr);
- BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr);
+ BIO_snprintf(tmp, sizeof(tmp), "%d", alert_descr);
ERR_add_error_data(2, "SSL alert number ", tmp);
s->shutdown |= SSL_RECEIVED_SHUTDOWN;
SSL3_RECORD_set_read(rr);
void ssl_sort_cipher_list(void)
{
- qsort(ssl3_ciphers, OSSL_NELEM(ssl3_ciphers), sizeof ssl3_ciphers[0],
+ qsort(ssl3_ciphers, OSSL_NELEM(ssl3_ciphers), sizeof(ssl3_ciphers[0]),
cipher_compare);
}
char buf[1024];
int r;
- if (strlen(dir) + strlen(filename) + 2 > sizeof buf) {
+ if (strlen(dir) + strlen(filename) + 2 > sizeof(buf)) {
SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,
SSL_R_PATH_TOO_LONG);
goto err;
}
#ifdef OPENSSL_SYS_VMS
- r = BIO_snprintf(buf, sizeof buf, "%s%s", dir, filename);
+ r = BIO_snprintf(buf, sizeof(buf), "%s%s", dir, filename);
#else
- r = BIO_snprintf(buf, sizeof buf, "%s/%s", dir, filename);
+ r = BIO_snprintf(buf, sizeof(buf), "%s/%s", dir, filename);
#endif
if (r <= 0 || r >= (int)sizeof(buf))
goto err;
s->verify_mode = ctx->verify_mode;
s->not_resumable_session_cb = ctx->not_resumable_session_cb;
s->sid_ctx_length = ctx->sid_ctx_length;
- OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx);
+ OPENSSL_assert(s->sid_ctx_length <= sizeof(s->sid_ctx));
memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx));
s->verify_callback = ctx->default_verify_callback;
s->generate_session_id = ctx->generate_session_id;
int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,
unsigned int sid_ctx_len)
{
- if (sid_ctx_len > sizeof ctx->sid_ctx) {
+ if (sid_ctx_len > sizeof(ctx->sid_ctx)) {
SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,
SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG);
return 0;
*/
SSL_SESSION r, *p;
- if (id_len > sizeof r.session_id)
+ if (id_len > sizeof(r.session_id))
return 0;
r.ssl_version = ssl->version;
ss->session_id_length = 0;
}
- if (s->sid_ctx_length > sizeof ss->sid_ctx) {
+ if (s->sid_ctx_length > sizeof(ss->sid_ctx)) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);
SSL_SESSION_free(ss);
return 0;
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
- OPENSSL_cleanse(ss->master_key, sizeof ss->master_key);
- OPENSSL_cleanse(ss->session_id, sizeof ss->session_id);
+ OPENSSL_cleanse(ss->master_key, sizeof(ss->master_key));
+ OPENSSL_cleanse(ss->session_id, sizeof(ss->session_id));
X509_free(ss->peer);
sk_X509_pop_free(ss->peer_chain, X509_free);
sk_SSL_CIPHER_free(ss->ciphers);
goto f_err;
}
session_id_len = PACKET_remaining(&session_id);
- if (session_id_len > sizeof s->session->session_id
+ if (session_id_len > sizeof(s->session->session_id)
|| session_id_len > SSL3_SESSION_ID_SIZE) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG);
BF_set_key(&key, 16, cbc_key);
memset(cbc_in, 0, sizeof(cbc_in));
memset(cbc_out, 0, sizeof(cbc_out));
- memcpy(iv, cbc_iv, sizeof iv);
+ memcpy(iv, cbc_iv, sizeof(iv));
BF_cbc_encrypt((unsigned char *)cbc_data, cbc_out, len,
&key, iv, BF_ENCRYPT);
if (memcmp(cbc_out, cbc_ok, 32) != 0) {
results = 0;
- RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */
+ RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or BN_generate_prime may fail */
argc--;
argv++;
* performs sanity checks on the input and can reject it before the
* decoder is called.
*/
- len = BIO_read(bio, buf, sizeof buf);
+ len = BIO_read(bio, buf, sizeof(buf));
if (len < 0)
goto err;
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- RAND_seed(rnd_seed, sizeof rnd_seed);
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
out = BIO_new(BIO_s_file());
if (out == NULL)
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- RAND_seed(rnd_seed, sizeof rnd_seed);
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
BIO_printf(bio_err, "test generation of DSA parameters\n");
len =
EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf,
- sizeof buf, ctx);
+ sizeof(buf), ctx);
if (len == 0)
ABORT;
if (!EC_POINT_oct2point(group, P, buf, len, ctx))
len =
EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf,
- sizeof buf, ctx);
+ sizeof(buf), ctx);
if (len == 0)
ABORT;
if (!EC_POINT_oct2point(group, P, buf, len, ctx))
fprintf(stdout, "%02X", buf[i]);
len =
- EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf,
+ EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof(buf),
ctx);
if (len == 0)
ABORT;
# ifdef OPENSSL_EC_BIN_PT_COMP
len =
EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf,
- sizeof buf, ctx);
+ sizeof(buf), ctx);
if (len == 0)
ABORT;
if (!EC_POINT_oct2point(group, P, buf, len, ctx))
len =
EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf,
- sizeof buf, ctx);
+ sizeof(buf), ctx);
if (len == 0)
ABORT;
if (!EC_POINT_oct2point(group, P, buf, len, ctx))
/* Change test based on whether binary point compression is enabled or not. */
# ifdef OPENSSL_EC_BIN_PT_COMP
len =
- EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf,
+ EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof(buf),
ctx);
if (len == 0)
ABORT;
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */
+ RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or BN_generate_prime may fail */
prime_field_tests();
puts("");
unsigned char c;
BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple, *a, *b, *m;
- RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we
- * don't even check its return
- * value (which we should) */
+ /*
+ * See or BN_rand may fail, and we don't even check its return
+ * value (which we should)
+ */
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
ctx = BN_CTX_new();
if (ctx == NULL)
assert(v->length <= MAX_VECTOR_SIZE);
if (v->encrypt == AES_ENCRYPT)
- AES_set_encrypt_key(v->key, 8 * sizeof v->key, &key);
+ AES_set_encrypt_key(v->key, 8 * sizeof(v->key), &key);
else
- AES_set_decrypt_key(v->key, 8 * sizeof v->key, &key);
- memcpy(iv, v->iv, sizeof iv);
+ AES_set_decrypt_key(v->key, 8 * sizeof(v->key), &key);
+ memcpy(iv, v->iv, sizeof(iv));
AES_ige_encrypt(v->in, buf, v->length, &key, iv, v->encrypt);
if (memcmp(v->out, buf, v->length)) {
printf("IGE test vector %d failed\n", n);
- hexdump(stdout, "key", v->key, sizeof v->key);
- hexdump(stdout, "iv", v->iv, sizeof v->iv);
+ hexdump(stdout, "key", v->key, sizeof(v->key));
+ hexdump(stdout, "iv", v->iv, sizeof(v->iv));
hexdump(stdout, "in", v->in, v->length);
hexdump(stdout, "expected", v->out, v->length);
hexdump(stdout, "got", buf, v->length);
}
/* try with in == out */
- memcpy(iv, v->iv, sizeof iv);
+ memcpy(iv, v->iv, sizeof(iv));
memcpy(buf, v->in, v->length);
AES_ige_encrypt(buf, buf, v->length, &key, iv, v->encrypt);
if (memcmp(v->out, buf, v->length)) {
printf("IGE test vector %d failed (with in == out)\n", n);
- hexdump(stdout, "key", v->key, sizeof v->key);
- hexdump(stdout, "iv", v->iv, sizeof v->iv);
+ hexdump(stdout, "key", v->key, sizeof(v->key));
+ hexdump(stdout, "iv", v->iv, sizeof(v->iv));
hexdump(stdout, "in", v->in, v->length);
hexdump(stdout, "expected", v->out, v->length);
hexdump(stdout, "got", buf, v->length);
if (memcmp(v->out, buf, v->length)) {
printf("Bidirectional IGE test vector %d failed\n", n);
- hexdump(stdout, "key 1", v->key1, sizeof v->key1);
- hexdump(stdout, "key 2", v->key2, sizeof v->key2);
- hexdump(stdout, "iv", v->iv, sizeof v->iv);
+ hexdump(stdout, "key 1", v->key1, sizeof(v->key1));
+ hexdump(stdout, "key 2", v->key2, sizeof(v->key2));
+ hexdump(stdout, "iv", v->iv, sizeof(v->iv));
hexdump(stdout, "in", v->in, v->length);
hexdump(stdout, "expected", v->out, v->length);
hexdump(stdout, "got", buf, v->length);
assert(BIG_TEST_SIZE >= TEST_SIZE);
- RAND_bytes(rkey, sizeof rkey);
- RAND_bytes(plaintext, sizeof plaintext);
- RAND_bytes(iv, sizeof iv);
- memcpy(saved_iv, iv, sizeof saved_iv);
+ RAND_bytes(rkey, sizeof(rkey));
+ RAND_bytes(plaintext, sizeof(plaintext));
+ RAND_bytes(iv, sizeof(iv));
+ memcpy(saved_iv, iv, sizeof(saved_iv));
/* Forward IGE only... */
/* Straight encrypt/decrypt */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, iv, AES_ENCRYPT);
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT);
if (memcmp(checktext, plaintext, TEST_SIZE)) {
}
/* Now check encrypt chaining works */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
+ memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE / 2, &key, iv,
AES_ENCRYPT);
AES_ige_encrypt(plaintext + TEST_SIZE / 2,
ciphertext + TEST_SIZE / 2, TEST_SIZE / 2,
&key, iv, AES_ENCRYPT);
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT);
if (memcmp(checktext, plaintext, TEST_SIZE)) {
}
/* And check decrypt chaining */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
+ memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE / 2, &key, iv,
AES_ENCRYPT);
AES_ige_encrypt(plaintext + TEST_SIZE / 2,
ciphertext + TEST_SIZE / 2, TEST_SIZE / 2,
&key, iv, AES_ENCRYPT);
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ memcpy(iv, saved_iv, sizeof(iv));
AES_ige_encrypt(ciphertext, checktext, TEST_SIZE / 2, &key, iv,
AES_DECRYPT);
AES_ige_encrypt(ciphertext + TEST_SIZE / 2,
}
/* make sure garble extends forwards only */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
- AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv,
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey),&key);
+ memcpy(iv, saved_iv, sizeof(iv));
+ AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt halfway through */
- ++ciphertext[sizeof ciphertext / 2];
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- memcpy(iv, saved_iv, sizeof iv);
- AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv,
+ ++ciphertext[sizeof(ciphertext) / 2];
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ memcpy(iv, saved_iv, sizeof(iv));
+ AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
- for (n = 0; n < sizeof checktext; ++n)
+ for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
- if (matches > sizeof checktext / 2 + sizeof checktext / 100) {
+ if (matches > sizeof(checktext) / 2 + sizeof(checktext) / 100) {
printf("More than 51%% matches after garbling\n");
++err;
}
- if (matches < sizeof checktext / 2) {
+ if (matches < sizeof(checktext) / 2) {
printf("Garble extends backwards!\n");
++err;
}
*/
/* possible with biIGE, so the IV is not updated. */
- RAND_bytes(rkey2, sizeof rkey2);
+ RAND_bytes(rkey2, sizeof(rkey2));
/* Straight encrypt/decrypt */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2);
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_bi_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, &key2, iv,
AES_ENCRYPT);
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2);
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
AES_bi_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, &key2, iv,
AES_DECRYPT);
}
/* make sure garble extends both ways */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2);
- AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv,
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
+ AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt halfway through */
- ++ciphertext[sizeof ciphertext / 2];
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2);
- AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv,
+ ++ciphertext[sizeof(ciphertext) / 2];
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
+ AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
- for (n = 0; n < sizeof checktext; ++n)
+ for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
- if (matches > sizeof checktext / 100) {
+ if (matches > sizeof(checktext) / 100) {
printf("More than 1%% matches after bidirectional garbling\n");
++err;
}
/* make sure garble extends both ways (2) */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2);
- AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv,
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
+ AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt right at the end */
- ++ciphertext[sizeof ciphertext - 1];
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2);
- AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv,
+ ++ciphertext[sizeof(ciphertext) - 1];
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
+ AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
- for (n = 0; n < sizeof checktext; ++n)
+ for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
- if (matches > sizeof checktext / 100) {
+ if (matches > sizeof(checktext) / 100) {
printf("More than 1%% matches after bidirectional garbling (2)\n");
++err;
}
/* make sure garble extends both ways (3) */
- AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2);
- AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv,
+ AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
+ AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
AES_ENCRYPT);
/* corrupt right at the start */
++ciphertext[0];
- AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key);
- AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2);
- AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv,
+ AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key);
+ AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2);
+ AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv,
AES_DECRYPT);
matches = 0;
- for (n = 0; n < sizeof checktext; ++n)
+ for (n = 0; n < sizeof(checktext); ++n)
if (checktext[n] == plaintext[n])
++matches;
- if (matches > sizeof checktext / 100) {
+ if (matches > sizeof(checktext) / 100) {
printf("More than 1%% matches after bidirectional garbling (3)\n");
++err;
}
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
+ RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or OAEP may fail */
plen = sizeof(ptext_ex) - 1;
/* Is NULL equivalent to all-bytes-zero? */
p = NULL;
- memset(bytes, 0, sizeof bytes);
+ memset(bytes, 0, sizeof(bytes));
TEST(memcmp(&p, bytes, sizeof(bytes)) == 0);
/* Enum size */
CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- RAND_seed(rnd_seed, sizeof rnd_seed);
+ RAND_seed(rnd_seed, sizeof(rnd_seed));
bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
{
int session_id_context = 0;
if (!SSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context,
- sizeof session_id_context) ||
+ sizeof(session_id_context)) ||
!SSL_CTX_set_session_id_context(s_ctx2, (void *)&session_id_context,
- sizeof session_id_context)) {
+ sizeof(session_id_context))) {
ERR_print_errors(bio_err);
goto end;
}
if (cw_num > 0) {
/* Write to server. */
- if (cw_num > (long)sizeof cbuf)
- i = sizeof cbuf;
+ if (cw_num > (long)sizeof(cbuf))
+ i = sizeof(cbuf);
else
i = (int)cw_num;
r = BIO_write(c_ssl_bio, cbuf, i);
if (sw_num > 0) {
/* Write to client. */
- if (sw_num > (long)sizeof sbuf)
- i = sizeof sbuf;
+ if (sw_num > (long)sizeof(sbuf))
+ i = sizeof(sbuf);
else
i = (int)sw_num;
r = BIO_write(s_ssl_bio, sbuf, i);
if (cw_num > 0) {
/* Write to server. */
- if (cw_num > (long)sizeof cbuf)
- i = sizeof cbuf;
+ if (cw_num > (long)sizeof(cbuf))
+ i = sizeof(cbuf);
else
i = (int)cw_num;
r = BIO_write(c_ssl_bio, cbuf, i);
if (sw_num > 0) {
/* Write to client. */
- if (sw_num > (long)sizeof sbuf)
- i = sizeof sbuf;
+ if (sw_num > (long)sizeof(sbuf))
+ i = sizeof(sbuf);
else
i = (int)sw_num;
r = BIO_write(s_ssl_bio, sbuf, i);
char *s, buf[256];
s = X509_NAME_oneline(X509_get_subject_name(X509_STORE_CTX_get_current_cert(ctx)),
- buf, sizeof buf);
+ buf, sizeof(buf));
if (s != NULL) {
if (ok)
printf("depth=%d %s\n", X509_STORE_CTX_get_error_depth(ctx), buf);