early-access version 2698

This commit is contained in:
pineappleEA
2022-04-24 22:29:35 +02:00
parent c96f949832
commit caa0c2911b
486 changed files with 37806 additions and 14362 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: ts_lib.c,v 1.10 2015/09/10 14:29:22 jsing Exp $ */
/* $OpenBSD: ts_lib.c,v 1.12 2021/12/04 16:08:32 tb Exp $ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
* project 2002.
*/
@@ -64,6 +64,9 @@
#include <openssl/ts.h>
#include <openssl/x509v3.h>
#include "bn_lcl.h"
#include "x509_lcl.h"
/* Local function declarations. */
/* Function definitions. */

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: ts_rsp_sign.c,v 1.23 2019/07/03 03:24:04 deraadt Exp $ */
/* $OpenBSD: ts_rsp_sign.c,v 1.26 2021/12/12 21:30:14 tb Exp $ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
* project 2002.
*/
@@ -65,6 +65,9 @@
#include <openssl/pkcs7.h>
#include <openssl/ts.h>
#include "evp_locl.h"
#include "x509_lcl.h"
/* Private function declarations. */
static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *, void *);
@@ -847,14 +850,18 @@ ESS_CERT_ID_new_init(X509 *cert, int issuer_needed)
{
ESS_CERT_ID *cid = NULL;
GENERAL_NAME *name = NULL;
unsigned char cert_hash[TS_HASH_LEN];
/* Recompute SHA1 hash of certificate if necessary (side effect). */
X509_check_purpose(cert, -1, 0);
if (!(cid = ESS_CERT_ID_new()))
goto err;
if (!ASN1_OCTET_STRING_set(cid->hash, cert->sha1_hash,
sizeof(cert->sha1_hash)))
if (!X509_digest(cert, TS_HASH_EVP, cert_hash, NULL))
goto err;
if (!ASN1_OCTET_STRING_set(cid->hash, cert_hash, sizeof(cert_hash)))
goto err;
/* Setting the issuer/serial if requested. */

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: ts_rsp_verify.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */
/* $OpenBSD: ts_rsp_verify.c,v 1.24 2021/12/12 21:30:14 tb Exp $ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
* project 2002.
*/
@@ -64,6 +64,9 @@
#include <openssl/pkcs7.h>
#include <openssl/ts.h>
#include "evp_locl.h"
#include "x509_lcl.h"
/* Private function declarations. */
static int TS_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted,
@@ -323,10 +326,14 @@ static int
TS_find_cert(STACK_OF(ESS_CERT_ID) *cert_ids, X509 *cert)
{
int i;
unsigned char cert_hash[TS_HASH_LEN];
if (!cert_ids || !cert)
return -1;
if (!X509_digest(cert, TS_HASH_EVP, cert_hash, NULL))
return -1;
/* Recompute SHA1 hash of certificate if necessary (side effect). */
X509_check_purpose(cert, -1, 0);
@@ -335,9 +342,8 @@ TS_find_cert(STACK_OF(ESS_CERT_ID) *cert_ids, X509 *cert)
ESS_CERT_ID *cid = sk_ESS_CERT_ID_value(cert_ids, i);
/* Check the SHA-1 hash first. */
if (cid->hash->length == sizeof(cert->sha1_hash) &&
!memcmp(cid->hash->data, cert->sha1_hash,
sizeof(cert->sha1_hash))) {
if (cid->hash->length == TS_HASH_LEN && !memcmp(cid->hash->data,
cert_hash, TS_HASH_LEN)) {
/* Check the issuer/serial as well if specified. */
ESS_ISSUER_SERIAL *is = cid->issuer_serial;
if (!is || !TS_issuer_serial_cmp(is, cert->cert_info))
@@ -593,35 +599,40 @@ TS_check_policy(ASN1_OBJECT *req_oid, TS_TST_INFO *tst_info)
}
static int
TS_compute_imprint(BIO *data, TS_TST_INFO *tst_info, X509_ALGOR **md_alg,
unsigned char **imprint, unsigned *imprint_len)
TS_compute_imprint(BIO *data, TS_TST_INFO *tst_info, X509_ALGOR **out_md_alg,
unsigned char **out_imprint, unsigned int *out_imprint_len)
{
TS_MSG_IMPRINT *msg_imprint = TS_TST_INFO_get_msg_imprint(tst_info);
X509_ALGOR *md_alg_resp = TS_MSG_IMPRINT_get_algo(msg_imprint);
TS_MSG_IMPRINT *msg_imprint;
X509_ALGOR *md_alg_resp;
X509_ALGOR *md_alg = NULL;
unsigned char *imprint = NULL;
unsigned int imprint_len = 0;
const EVP_MD *md;
EVP_MD_CTX md_ctx;
unsigned char buffer[4096];
int length;
*md_alg = NULL;
*imprint = NULL;
*out_md_alg = NULL;
*out_imprint = NULL;
*out_imprint_len = 0;
/* Return the MD algorithm of the response. */
if (!(*md_alg = X509_ALGOR_dup(md_alg_resp)))
/* Retrieve the MD algorithm of the response. */
msg_imprint = TS_TST_INFO_get_msg_imprint(tst_info);
md_alg_resp = TS_MSG_IMPRINT_get_algo(msg_imprint);
if ((md_alg = X509_ALGOR_dup(md_alg_resp)) == NULL)
goto err;
/* Getting the MD object. */
if (!(md = EVP_get_digestbyobj((*md_alg)->algorithm))) {
if ((md = EVP_get_digestbyobj((md_alg)->algorithm)) == NULL) {
TSerror(TS_R_UNSUPPORTED_MD_ALGORITHM);
goto err;
}
/* Compute message digest. */
length = EVP_MD_size(md);
if (length < 0)
if ((length = EVP_MD_size(md)) < 0)
goto err;
*imprint_len = length;
if (!(*imprint = malloc(*imprint_len))) {
imprint_len = length;
if ((imprint = malloc(imprint_len)) == NULL) {
TSerror(ERR_R_MALLOC_FAILURE);
goto err;
}
@@ -632,16 +643,20 @@ TS_compute_imprint(BIO *data, TS_TST_INFO *tst_info, X509_ALGOR **md_alg,
if (!EVP_DigestUpdate(&md_ctx, buffer, length))
goto err;
}
if (!EVP_DigestFinal(&md_ctx, *imprint, NULL))
if (!EVP_DigestFinal(&md_ctx, imprint, NULL))
goto err;
*out_md_alg = md_alg;
md_alg = NULL;
*out_imprint = imprint;
imprint = NULL;
*out_imprint_len = imprint_len;
return 1;
err:
X509_ALGOR_free(*md_alg);
free(*imprint);
*imprint = NULL;
*imprint_len = 0;
X509_ALGOR_free(md_alg);
free(imprint);
return 0;
}
@@ -711,7 +726,7 @@ TS_check_signer_name(GENERAL_NAME *tsa_name, X509 *signer)
/* Check the subject name first. */
if (tsa_name->type == GEN_DIRNAME &&
X509_name_cmp(tsa_name->d.dirn, signer->cert_info->subject) == 0)
X509_NAME_cmp(tsa_name->d.dirn, signer->cert_info->subject) == 0)
return 1;
/* Check all the alternative names. */