diff options
Diffstat (limited to 'crypto/ts/ts_rsp_sign.c')
-rw-r--r-- | crypto/ts/ts_rsp_sign.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c index 88be6fa7bc..79d3e67837 100644 --- a/crypto/ts/ts_rsp_sign.c +++ b/crypto/ts/ts_rsp_sign.c @@ -52,7 +52,7 @@ static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *ctx, void *data) return serial; err: - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Error during serial number generation."); ASN1_INTEGER_free(serial); @@ -95,16 +95,13 @@ TS_RESP_CTX *TS_RESP_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq) { TS_RESP_CTX *ctx; - if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) { - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) return NULL; - } if (propq != NULL) { ctx->propq = OPENSSL_strdup(propq); if (ctx->propq == NULL) { OPENSSL_free(ctx); - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); return NULL; } } @@ -173,7 +170,7 @@ int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy) goto err; return 1; err: - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_OBJ_LIB); return 0; } @@ -190,16 +187,21 @@ int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy) ASN1_OBJECT *copy = NULL; if (ctx->policies == NULL - && (ctx->policies = sk_ASN1_OBJECT_new_null()) == NULL) + && (ctx->policies = sk_ASN1_OBJECT_new_null()) == NULL) { + ERR_raise(ERR_LIB_TS, ERR_R_CRYPTO_LIB); goto err; - if ((copy = OBJ_dup(policy)) == NULL) + } + if ((copy = OBJ_dup(policy)) == NULL) { + ERR_raise(ERR_LIB_TS, ERR_R_OBJ_LIB); goto err; - if (!sk_ASN1_OBJECT_push(ctx->policies, copy)) + } + if (!sk_ASN1_OBJECT_push(ctx->policies, copy)) { + ERR_raise(ERR_LIB_TS, ERR_R_CRYPTO_LIB); goto err; + } return 1; err: - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); ASN1_OBJECT_free(copy); return 0; } @@ -214,7 +216,7 @@ int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md) return 1; err: - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_CRYPTO_LIB); return 0; } @@ -247,7 +249,7 @@ int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, return 1; err: TS_RESP_CTX_accuracy_free(ctx); - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB); return 0; } @@ -282,27 +284,37 @@ int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx, ASN1_UTF8STRING *utf8_text = NULL; int ret = 0; - if ((si = TS_STATUS_INFO_new()) == NULL) + if ((si = TS_STATUS_INFO_new()) == NULL) { + ERR_raise(ERR_LIB_TS, ERR_R_TS_LIB); goto err; - if (!ASN1_INTEGER_set(si->status, status)) + } + if (!ASN1_INTEGER_set(si->status, status)) { + ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB); goto err; + } if (text) { if ((utf8_text = ASN1_UTF8STRING_new()) == NULL - || !ASN1_STRING_set(utf8_text, text, strlen(text))) + || !ASN1_STRING_set(utf8_text, text, strlen(text))) { + ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB); goto err; + } if (si->text == NULL - && (si->text = sk_ASN1_UTF8STRING_new_null()) == NULL) + && (si->text = sk_ASN1_UTF8STRING_new_null()) == NULL) { + ERR_raise(ERR_LIB_TS, ERR_R_CRYPTO_LIB); goto err; - if (!sk_ASN1_UTF8STRING_push(si->text, utf8_text)) + } + if (!sk_ASN1_UTF8STRING_push(si->text, utf8_text)) { + ERR_raise(ERR_LIB_TS, ERR_R_CRYPTO_LIB); goto err; + } utf8_text = NULL; /* Ownership is lost. */ } - if (!TS_RESP_set_status_info(ctx->response, si)) + if (!TS_RESP_set_status_info(ctx->response, si)) { + ERR_raise(ERR_LIB_TS, ERR_R_TS_LIB); goto err; + } ret = 1; err: - if (!ret) - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); TS_STATUS_INFO_free(si); ASN1_UTF8STRING_free(utf8_text); return ret; @@ -330,7 +342,7 @@ int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure) goto err; return 1; err: - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB); return 0; } @@ -363,7 +375,7 @@ TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio) ts_RESP_CTX_init(ctx); if ((ctx->response = TS_RESP_new()) == NULL) { - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_TS_LIB); goto end; } if ((ctx->request = d2i_TS_REQ_bio(req_bio, NULL)) == NULL) { @@ -673,7 +685,7 @@ static int ts_RESP_sign(TS_RESP_CTX *ctx) } if ((p7 = PKCS7_new_ex(ctx->libctx, ctx->propq)) == NULL) { - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB); goto err; } if (!PKCS7_set_type(p7, NID_pkcs7_signed)) @@ -738,7 +750,7 @@ static int ts_RESP_sign(TS_RESP_CTX *ctx) if (!ts_TST_INFO_content_new(p7)) goto err; if ((p7bio = PKCS7_dataInit(p7, NULL)) == NULL) { - ERR_raise(ERR_LIB_TS, ERR_R_MALLOC_FAILURE); + ERR_raise(ERR_LIB_TS, ERR_R_PKCS7_LIB); goto err; } if (!i2d_TS_TST_INFO_bio(p7bio, ctx->tst_info)) { |