goto end;
}
p = pp[DB_serial];
- j = strlen(p);
+ j = (int)strlen(p);
if (*p == '-') {
p++;
j--;
i = revtm->length + 1;
if (reason)
- i += strlen(reason) + 1;
+ i += (int)(strlen(reason) + 1);
if (other)
- i += strlen(other) + 1;
+ i += (int)(strlen(other) + 1);
str = app_malloc(i, "revocation reason");
OPENSSL_strlcpy(str, (char *)revtm->data, i);
}
} else {
if (!OSSL_CMP_CTX_set1_referenceValue(ctx, (unsigned char *)opt_srv_ref,
- strlen(opt_srv_ref)))
+ (int)strlen(opt_srv_ref)))
goto err;
}
if (pass_str != NULL) {
cleanse(opt_srv_secret);
res = OSSL_CMP_CTX_set1_secretValue(ctx, (unsigned char *)pass_str,
- strlen(pass_str));
+ (int)strlen(pass_str));
clear_free(pass_str);
if (res == 0)
goto err;
cleanse(opt_secret);
res = OSSL_CMP_CTX_set1_secretValue(ctx,
(unsigned char *)pass_string,
- strlen(pass_string));
+ (int)strlen(pass_string));
clear_free(pass_string);
if (res == 0)
return 0;
}
if (opt_ref != NULL
&& !OSSL_CMP_CTX_set1_referenceValue(ctx, (unsigned char *)opt_ref,
- strlen(opt_ref)))
+ (int)strlen(opt_ref)))
return 0;
if (opt_key != NULL) {
int i, backslash = 0;
if (binout) {
- BIO_write(out, buf, len);
+ BIO_write(out, buf, (int)len);
} else if (sep == 2) {
file = newline_escape_filename(file, &backslash);
/* not needed if HASH_UPDATE() is fixed : */
int islen = (sptr != NULL ? saltlen : 0);
- if (!PKCS5_PBKDF2_HMAC(str, str_len, sptr, islen,
+ if (!PKCS5_PBKDF2_HMAC(str, (int)str_len, sptr, islen,
iter, dgst, iklen+ivlen, tmpkeyiv)) {
BIO_printf(bio_err, "PKCS5_PBKDF2_HMAC failed\n");
goto end;
"deprecated key derivation used.\n"
"Using -iter or -pbkdf2 would be better.\n");
if (!EVP_BytesToKey(cipher, dgst, sptr,
- (unsigned char *)str, str_len,
+ (unsigned char *)str, (int)str_len,
1, key, iv)) {
BIO_printf(bio_err, "EVP_BytesToKey failed\n");
goto end;
unsigned char j;
i = size * 2;
- n = strlen(in);
+ n = (int)strlen(in);
if (n > i) {
BIO_printf(bio_err, "hex string is too long, ignoring excess\n");
n = i; /* ignore exceeding part */
static int append_buf(char **buf, int *size, const char *s)
{
const int expand = 256;
- int len = strlen(s) + 1;
+ int len = (int)(strlen(s) + 1);
char *p = *buf;
if (p == NULL) {
*size = ((len + expand - 1) / expand) * expand;
p = *buf = app_malloc(*size, "engine buffer");
} else {
- const int blen = strlen(p);
+ const int blen = (int)strlen(p);
if (blen > 0)
len += 2 + blen;
/* Calculate the MAC for the indicator status - it may not be used */
mem_bio = BIO_new_mem_buf((const void *)INSTALL_STATUS_VAL,
- strlen(INSTALL_STATUS_VAL));
+ (int)strlen(INSTALL_STATUS_VAL));
if (mem_bio == NULL) {
BIO_printf(bio_err, "Unable to create memory BIO\n");
goto end;
char *prog, *hexout = NULL;
const char *outfile = NULL;
unsigned char *dkm_bytes = NULL;
- size_t dkm_len = 0;
+ int dkm_len = 0;
BIO *out = NULL;
EVP_KDF *kdf = NULL;
EVP_KDF_CTX *ctx = NULL;
out_bin = 1;
break;
case OPT_KEYLEN:
- dkm_len = (size_t)atoi(opt_arg());
+ dkm_len = atoi(opt_arg());
break;
case OPT_OUT:
outfile = opt_arg();
{
SSL_CTX *ctx = NULL;
STACK_OF(OPENSSL_CSTRING) *groups;
- size_t i, num;
+ int i, num;
if ((groups = sk_OPENSSL_CSTRING_new_null()) == NULL) {
BIO_printf(bio_err, "ERROR: Memory allocation\n");
}
if (out_bin) {
- BIO_write(out, buf, len);
+ BIO_write(out, buf, (int)len);
} else {
for (i = 0; i < (int)len; ++i)
BIO_printf(out, "%02X", buf[i]);
BIO_printf(bio_err, "ERROR: writing when tracing not started\n");
return 0;
}
+ if (cnt > INT_MAX)
+ cnt = INT_MAX;
- ret = BIO_write(trace_data->bio, buf, cnt);
+ ret = BIO_write(trace_data->bio, buf, (int)cnt);
break;
case OSSL_TRACE_CTRL_END:
if (!trace_data->ingroup) {
passwds = passwds_static;
if (in == NULL) {
if (EVP_read_pw_string
- (passwd_malloc, passwd_malloc_size, "Password: ",
+ (passwd_malloc, (int)passwd_malloc_size, "Password: ",
!(passed_salt || in_noverify)) != 0)
goto end;
}
assert(passwd != NULL);
do {
- int r = BIO_gets(in, passwd, pw_maxlen + 1);
+ int r = BIO_gets(in, passwd, (int)(pw_maxlen + 1));
if (r > 0) {
char *c = (strchr(passwd, '\n'));
if (c != NULL) {
|| !EVP_DigestFinal_ex(md2, buf, NULL))
goto err;
- for (i = passwd_len; i > sizeof(buf); i -= sizeof(buf)) {
+ for (i = (unsigned int)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;
- n = passwd_len;
+ n = (int)passwd_len;
while (n) {
if (!EVP_DigestUpdate(md, (n & 1) ? "\0" : passwd, 1))
goto err;
if (*salt_malloc_p == NULL)
*salt_p = *salt_malloc_p = app_malloc(saltlen + 1, "salt buffer");
- if (RAND_bytes((unsigned char *)*salt_p, saltlen) <= 0)
+ if (RAND_bytes((unsigned char *)*salt_p, (int)saltlen) <= 0)
goto end;
for (i = 0; i < saltlen; i++)
BIO_printf(bio_err, "Password required\n");
goto end;
}
- p8 = PKCS8_set0_pbe(p8pass, strlen(p8pass), p8inf, pbe);
+ p8 = PKCS8_set0_pbe(p8pass, (int)strlen(p8pass), p8inf, pbe);
if (p8 == NULL) {
X509_ALGOR_free(pbe);
BIO_printf(bio_err, "Error encrypting key\n");
BIO_printf(bio_err, "Password required\n");
goto end;
}
- p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
+ p8inf = PKCS8_decrypt(p8, p8pass, (int)strlen(p8pass));
}
if (p8inf == NULL) {
if (rawin) {
/* rawin allocates the buffer in do_raw_keyop() */
rv = do_raw_keyop(pkey_op, mctx, pkey, in, filesize, NULL, 0,
- &buf_out, (size_t *)&buf_outlen);
+ &buf_out, &buf_outlen);
} else {
if (kdflen != 0) {
buf_outlen = kdflen;
rv = 1;
} else {
- rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
- buf_in, (size_t)buf_inlen, NULL, (size_t *)&secretlen);
+ rv = do_keyop(ctx, pkey_op, NULL, &buf_outlen,
+ buf_in, (size_t)buf_inlen, NULL, &secretlen);
}
if (rv > 0
&& (secretlen > 0 || (pkey_op != EVP_PKEY_OP_ENCAPSULATE
if (secretlen > 0)
secret = app_malloc(secretlen, "secret output");
rv = do_keyop(ctx, pkey_op,
- buf_out, (size_t *)&buf_outlen,
- buf_in, (size_t)buf_inlen, secret, (size_t *)&secretlen);
+ buf_out, &buf_outlen,
+ buf_in, (size_t)buf_inlen, secret, &secretlen);
}
}
if (rv <= 0) {
ret = 0;
if (asn1parse) {
- if (!ASN1_parse_dump(out, buf_out, buf_outlen, 1, -1))
+ if (!ASN1_parse_dump(out, buf_out, (long)buf_outlen, 1, -1))
ERR_print_errors(bio_err); /* but still return success */
} else if (hexdump) {
- BIO_dump(out, (char *)buf_out, buf_outlen);
+ BIO_dump(out, (char *)buf_out, (int)buf_outlen);
} else {
- BIO_write(out, buf_out, buf_outlen);
+ BIO_write(out, buf_out, (int)buf_outlen);
}
/* Backwards compatible decap output fallback */
if (secretlen > 0)
- BIO_write(secout ? secout : out, secret, secretlen);
+ BIO_write(secout ? secout : out, secret, (int)secretlen);
end:
if (ret != 0)
} else {
for ( ; *argv; argv++) {
int bytes_read = 0;
- int valid_digits_length = 0;
if (!in_file) {
process_num(argv[0], hex);
}
while ((bytes_read = BIO_get_line(in, file_read_buf, BUFSIZE)) > 0) {
+ size_t valid_digits_length;
+
/* Number is too long. Discard remainder of the line */
if (bytes_read == BUFSIZE - 1 && file_read_buf[BUFSIZE - 2] != '\n') {
BIO_printf(bio_err, "Value in %s is over the maximum size (%d digits)\n",
return 1;
}
- i = strlen(buf);
+ i = (int)strlen(buf);
if (buf[i - 1] != '\n') {
BIO_printf(bio_err, "Missing newline at end of input\n");
return 0;
int len;
if (p != NULL)
- len = p - gstr;
+ len = (int)(p - gstr);
else
- len = strlen(gstr);
+ len = (int)strlen(gstr);
if (strncmp(gstr, "param", len) == 0) {
expect_paramfile = 1;
}
ret = 0;
if (asn1parse) {
- if (!ASN1_parse_dump(out, rsa_out, rsa_outlen, 1, -1)) {
+ if (!ASN1_parse_dump(out, rsa_out, (long)rsa_outlen, 1, -1)) {
ERR_print_errors(bio_err);
}
} else if (hexdump) {
- BIO_dump(out, (char *)rsa_out, rsa_outlen);
+ BIO_dump(out, (char *)rsa_out, (int)rsa_outlen);
} else {
- BIO_write(out, rsa_out, rsa_outlen);
+ BIO_write(out, rsa_out, (int)rsa_outlen);
}
end:
EVP_PKEY_CTX_free(ctx);
}
ctx->status =
- SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len);
+ SSL_select_next_proto(out, outlen, in, inlen,
+ ctx->data, (unsigned int)ctx->len);
return SSL_TLSEXT_ERR_OK;
}
#endif /* ndef OPENSSL_NO_NEXTPROTONEG */
BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",
ext_type);
- PEM_write_bio(bio_c_out, pem_name, "", ext_buf, 4 + inlen);
+ PEM_write_bio(bio_c_out, pem_name, "", ext_buf, (long)(4 + inlen));
return 1;
}
break;
case OPT_SERVERINFO:
p = opt_arg();
- len = strlen(p);
+ len = (int)strlen(p);
for (start = 0, i = 0; i <= len; ++i) {
if (i == len || p[i] == ',') {
serverinfo_types[serverinfo_count] = atoi(p + start);
goto end;
}
/* Returns 0 on success! */
- if (SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len) != 0) {
+ if (SSL_CTX_set_alpn_protos(ctx, alpn, (unsigned int)alpn_len) != 0) {
BIO_printf(bio_err, "Error setting ALPN\n");
goto end;
}
/* pull SEQUENCE */
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_CONSTRUCTED || tag != V_ASN1_SEQUENCE ||
- (rem = end - cur, len > rem)) {
+ (rem = (long)(end - cur), len > rem)) {
BIO_printf(bio_err, "Unexpected LDAP response\n");
goto end;
}
/* pull MessageID */
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_UNIVERSAL || tag != V_ASN1_INTEGER ||
- (rem = end - cur, len > rem)) {
+ (rem = (long)(end - cur), len > rem)) {
BIO_printf(bio_err, "No MessageID\n");
goto end;
}
cur += len; /* shall we check for MessageId match or just skip? */
/* pull [APPLICATION 24] */
- rem = end - cur;
+ rem = (long)(end - cur);
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_CONSTRUCTED || xclass != V_ASN1_APPLICATION ||
tag != 24) {
}
/* pull resultCode */
- rem = end - cur;
+ rem = (long)(end - cur);
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_UNIVERSAL || tag != V_ASN1_ENUMERATED || len == 0 ||
- (rem = end - cur, len > rem)) {
+ (rem = (long)(end - cur), len > rem)) {
BIO_printf(bio_err, "Not LDAPResult\n");
goto end;
}
tlsextnextprotoctx *next_proto = arg;
*data = next_proto->data;
- *len = next_proto->len;
+ *len = (unsigned int)next_proto->len;
return SSL_TLSEXT_ERR_OK;
}
}
if (SSL_select_next_proto
- ((unsigned char **)out, outlen, alpn_ctx->data, alpn_ctx->len, in,
- inlen) != OPENSSL_NPN_NEGOTIATED) {
+ ((unsigned char **)out, outlen, alpn_ctx->data,
+ (unsigned int)alpn_ctx->len, in, inlen) != OPENSSL_NPN_NEGOTIATED) {
return SSL_TLSEXT_ERR_ALERT_FATAL;
}
if (context != NULL
&& !SSL_set_session_id_context(con, context,
- strlen((char *)context))) {
+ (unsigned int)strlen((char *)context))) {
BIO_printf(bio_err, "Error setting session id context\n");
ret = -1;
goto err;
if (context != NULL
&& !SSL_set_session_id_context(con, context,
- strlen((char *)context))) {
+ (unsigned int)strlen((char *)context))) {
SSL_free(con);
goto err;
}
BIO_printf(bio_err, "FILE:%s\n", p);
if (www == 2) {
- i = strlen(p);
+ i = (int)strlen(p);
if (((i > 5) && (strcmp(&(p[i - 5]), ".html") == 0)) ||
((i > 4) && (strcmp(&(p[i - 4]), ".php") == 0)) ||
((i > 4) && (strcmp(&(p[i - 4]), ".htm") == 0)))
}
if (context != NULL
&& !SSL_set_session_id_context(con, context,
- strlen((char *)context))) {
+ (unsigned int)strlen((char *)context))) {
SSL_free(con);
ERR_print_errors(bio_err);
goto err;
unsigned int *id_len)
{
unsigned int count = 0;
- unsigned int session_id_prefix_len = strlen(session_id_prefix);
+ unsigned int session_id_prefix_len = (unsigned int)strlen(session_id_prefix);
do {
if (RAND_bytes(id, *id_len) <= 0)
goto end;
}
if (!SSL_SESSION_set1_id_context(x, (unsigned char *)context,
- ctx_len)) {
+ (unsigned int)ctx_len)) {
BIO_printf(bio_err, "Error setting id context\n");
goto end;
}
if (doit[D_HMAC]) {
static const char hmac_key[] = "This is a key...";
- int len = strlen(hmac_key);
+ int len = (int)strlen(hmac_key);
size_t hmac_name_len = sizeof("hmac()") + strlen(evp_mac_mdname);
OSSL_PARAM params[3];
aad[12] = (unsigned char)(len);
pad = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_TLS1_AAD,
EVP_AEAD_TLS1_AAD_LEN, aad);
- ciph_success = EVP_Cipher(ctx, out, inp, len + pad);
+ ciph_success = EVP_Cipher(ctx, out, inp, (unsigned int)(len + pad));
}
}
d = Time_F(STOP);
int cnt = 0, len = 0;
p = q = names;
- len = strlen(names);
+ len = (int)strlen(names);
while (q - names <= len) {
if (*q != ',' && *q != '\0') {