No change to generated assembly.
-/* $OpenBSD: tls_config.c,v 1.45 2017/12/09 16:46:08 jsing Exp $ */
+/* $OpenBSD: tls_config.c,v 1.46 2018/02/05 00:52:24 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
if ((fd = open(filename, O_RDONLY)) == -1) {
tls_error_set(error, "failed to open %s file '%s'",
filetype, filename);
- goto fail;
+ goto err;
}
if (fstat(fd, &st) != 0) {
tls_error_set(error, "failed to stat %s file '%s'",
filetype, filename);
- goto fail;
+ goto err;
}
if (st.st_size < 0)
- goto fail;
+ goto err;
*len = (size_t)st.st_size;
if ((*buf = malloc(*len)) == NULL) {
tls_error_set(error, "failed to allocate buffer for "
"%s file", filetype);
- goto fail;
+ goto err;
}
n = read(fd, *buf, *len);
if (n < 0 || (size_t)n != *len) {
tls_error_set(error, "failed to read %s file '%s'",
filetype, filename);
- goto fail;
+ goto err;
}
close(fd);
return 0;
- fail:
+ err:
if (fd != -1)
close(fd);
freezero(*buf, *len);
if ((ssl_ctx = SSL_CTX_new(SSLv23_method())) == NULL) {
tls_config_set_errorx(config, "out of memory");
- goto fail;
+ goto err;
}
if (SSL_CTX_set_cipher_list(ssl_ctx, ciphers) != 1) {
tls_config_set_errorx(config, "no ciphers for '%s'", ciphers);
- goto fail;
+ goto err;
}
SSL_CTX_free(ssl_ctx);
return set_string(&config->ciphers, ciphers);
- fail:
+ err:
SSL_CTX_free(ssl_ctx);
return -1;
}
tls_ocsp_asn1_parse_time(ctx, revtime, &info->revocation_time) != 0) {
tls_set_error(ctx,
"unable to parse revocation time in OCSP reply");
- goto error;
+ goto err;
}
if (thisupd != NULL &&
tls_ocsp_asn1_parse_time(ctx, thisupd, &info->this_update) != 0) {
tls_set_error(ctx,
"unable to parse this update time in OCSP reply");
- goto error;
+ goto err;
}
if (nextupd != NULL &&
tls_ocsp_asn1_parse_time(ctx, nextupd, &info->next_update) != 0) {
tls_set_error(ctx,
"unable to parse next update time in OCSP reply");
- goto error;
+ goto err;
}
ctx->ocsp->ocsp_result = info;
return 0;
- error:
+
+ err:
free(info);
return -1;
}
STACK_OF(OPENSSL_STRING) *ocsp_urls = NULL;
if ((ocsp = tls_ocsp_new()) == NULL)
- goto failed;
+ goto err;
/* steal state from ctx struct */
ocsp->main_cert = SSL_get_peer_certificate(ctx->ssl_conn);
ocsp->extra_certs = SSL_get_peer_cert_chain(ctx->ssl_conn);
if (ocsp->main_cert == NULL) {
tls_set_errorx(ctx, "no peer certificate for OCSP");
- goto failed;
+ goto err;
}
ocsp_urls = X509_get1_ocsp(ocsp->main_cert);
if (ocsp_urls == NULL) {
tls_set_errorx(ctx, "no OCSP URLs in peer certificate");
- goto failed;
+ goto err;
}
ocsp->ocsp_url = strdup(sk_OPENSSL_STRING_value(ocsp_urls, 0));
if (ocsp->ocsp_url == NULL) {
tls_set_errorx(ctx, "out of memory");
- goto failed;
+ goto err;
}
X509_email_free(ocsp_urls);
return ocsp;
- failed:
+ err:
tls_ocsp_free(ocsp);
X509_email_free(ocsp_urls);
return NULL;
if ((br = OCSP_response_get1_basic(resp)) == NULL) {
tls_set_errorx(ctx, "cannot load ocsp reply");
- goto error;
+ goto err;
}
/*
if (OCSP_basic_verify(br, ctx->ocsp->extra_certs,
SSL_CTX_get_cert_store(ctx->ssl_ctx), flags) != 1) {
tls_set_error(ctx, "ocsp verify failed");
- goto error;
+ goto err;
}
/* signature OK, look inside */
if (response_status != OCSP_RESPONSE_STATUS_SUCCESSFUL) {
tls_set_errorx(ctx, "ocsp verify failed: response - %s",
OCSP_response_status_str(response_status));
- goto error;
+ goto err;
}
cid = tls_ocsp_get_certid(ctx->ocsp->main_cert,
ctx->ocsp->extra_certs, ctx->ssl_ctx);
if (cid == NULL) {
tls_set_errorx(ctx, "ocsp verify failed: no issuer cert");
- goto error;
+ goto err;
}
if (OCSP_resp_find_status(br, cid, &cert_status, &crl_reason,
&revtime, &thisupd, &nextupd) != 1) {
tls_set_errorx(ctx, "ocsp verify failed: no result for cert");
- goto error;
+ goto err;
}
if (OCSP_check_validity(thisupd, nextupd, JITTER_SEC,
MAXAGE_SEC) != 1) {
tls_set_errorx(ctx,
"ocsp verify failed: ocsp response not current");
- goto error;
+ goto err;
}
if (tls_ocsp_fill_info(ctx, response_status, cert_status,
crl_reason, revtime, thisupd, nextupd) != 0)
- goto error;
+ goto err;
/* finally can look at status */
if (cert_status != V_OCSP_CERTSTATUS_GOOD && cert_status !=
V_OCSP_CERTSTATUS_UNKNOWN) {
tls_set_errorx(ctx, "ocsp verify failed: revoked cert - %s",
OCSP_crl_reason_str(crl_reason));
- goto error;
+ goto err;
}
ret = 0;
- error:
+ err:
sk_X509_free(combined);
OCSP_CERTID_free(cid);
OCSP_BASICRESP_free(br);
-/* $OpenBSD: tls_util.c,v 1.9 2017/06/22 18:03:57 jsing Exp $ */
+/* $OpenBSD: tls_util.c,v 1.10 2018/02/05 00:52:24 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
*port = NULL;
if ((s = strdup(hostport)) == NULL)
- goto fail;
+ goto err;
h = p = s;
*p++ = '\0';
if (asprintf(host, "%s", h) == -1)
- goto fail;
+ goto err;
if (asprintf(port, "%s", p) == -1)
- goto fail;
+ goto err;
rv = 0;
goto done;
- fail:
+ err:
free(*host);
*host = NULL;
free(*port);
/* Just load the file into memory without decryption */
if (password == NULL) {
if (fstat(fd, &st) != 0)
- goto fail;
+ goto err;
if (st.st_size < 0)
- goto fail;
+ goto err;
size = (size_t)st.st_size;
if ((buf = malloc(size)) == NULL)
- goto fail;
+ goto err;
n = read(fd, buf, size);
if (n < 0 || (size_t)n != size)
- goto fail;
+ goto err;
close(fd);
goto done;
}
/* Or read the (possibly) encrypted key from file */
if ((fp = fdopen(fd, "r")) == NULL)
- goto fail;
+ goto err;
fd = -1;
key = PEM_read_PrivateKey(fp, NULL, tls_password_cb, password);
fclose(fp);
if (key == NULL)
- goto fail;
+ goto err;
/* Write unencrypted key to memory buffer */
if ((bio = BIO_new(BIO_s_mem())) == NULL)
- goto fail;
+ goto err;
if (!PEM_write_bio_PrivateKey(bio, key, NULL, NULL, 0, NULL, NULL))
- goto fail;
+ goto err;
if ((size = BIO_get_mem_data(bio, &data)) <= 0)
- goto fail;
+ goto err;
if ((buf = malloc(size)) == NULL)
- goto fail;
+ goto err;
memcpy(buf, data, size);
BIO_free_all(bio);
*len = size;
return (buf);
- fail:
+ err:
if (fd != -1)
close(fd);
freezero(buf, size);
-/* $OpenBSD: tls_verify.c,v 1.19 2017/04/10 17:11:13 jsing Exp $ */
+/* $OpenBSD: tls_verify.c,v 1.20 2018/02/05 00:52:24 jsing Exp $ */
/*
* Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org>
*
subject_name = X509_get_subject_name(cert);
if (subject_name == NULL)
- goto out;
+ goto done;
common_name_len = X509_NAME_get_text_by_NID(subject_name,
NID_commonName, NULL, 0);
if (common_name_len < 0)
- goto out;
+ goto done;
common_name = calloc(common_name_len + 1, 1);
if (common_name == NULL)
- goto out;
+ goto done;
X509_NAME_get_text_by_NID(subject_name, NID_commonName, common_name,
common_name_len + 1);
"NUL byte in Common Name field, "
"probably a malicious certificate", name);
rv = -1;
- goto out;
+ goto done;
}
/*
inet_pton(AF_INET6, name, &addrbuf) == 1) {
if (strcmp(common_name, name) == 0)
*cn_match = 1;
- goto out;
+ goto done;
}
if (tls_match_name(common_name, name) == 0)
*cn_match = 1;
- out:
+ done:
free(common_name);
return rv;
}