Lines Matching refs:ctx

161 OSSL_CMP_MSG *ossl_cmp_msg_create(OSSL_CMP_CTX *ctx, int bodytype)
165 if (!ossl_assert(ctx != NULL))
168 if ((msg = OSSL_CMP_MSG_new(ctx->libctx, ctx->propq)) == NULL)
170 if (!ossl_cmp_hdr_init(ctx, msg->header)
173 if (ctx->geninfo_ITAVs != NULL
175 ctx->geninfo_ITAVs))
187 if (ctx->p10CSR == NULL) {
191 if ((msg->body->value.p10cr = X509_REQ_dup(ctx->p10CSR)) == NULL)
252 #define HAS_SAN(ctx) \
253 (sk_GENERAL_NAME_num((ctx)->subjectAltNames) > 0 \
254 || OSSL_CMP_CTX_reqExtensions_have_SAN(ctx) == 1)
256 static const X509_NAME *determine_subj(OSSL_CMP_CTX *ctx, int for_KUR,
259 if (ctx->subjectName != NULL)
260 return IS_NULL_DN(ctx->subjectName) ? NULL : ctx->subjectName;
261 if (ctx->p10CSR != NULL) /* first default is from any given CSR */
262 return X509_REQ_get_subject_name(ctx->p10CSR);
263 if (for_KUR || !HAS_SAN(ctx))
272 OSSL_CRMF_MSG *OSSL_CMP_CTX_setup_CRM(OSSL_CMP_CTX *ctx, int for_KUR, int rid)
275 X509 *refcert = ctx->oldCert != NULL ? ctx->oldCert : ctx->cert;
277 EVP_PKEY *rkey = ossl_cmp_ctx_get0_newPubkey(ctx);
281 const X509_NAME *subject = determine_subj(ctx, for_KUR, ref_subj);
282 const X509_NAME *issuer = ctx->issuer != NULL || refcert == NULL
283 ? (IS_NULL_DN(ctx->issuer) ? NULL : ctx->issuer)
285 int crit = ctx->setSubjectAltNameCritical || subject == NULL;
295 if (for_KUR && refcert == NULL && ctx->p10CSR == NULL) {
310 if (ctx->days != 0) {
313 ASN1_TIME *notAfter = ASN1_TIME_adj(NULL, now, ctx->days, 0);
325 if (ctx->p10CSR != NULL
326 && (exts = X509_REQ_get_extensions(ctx->p10CSR)) == NULL)
328 if (!ctx->SubjectAltName_nodefault && !HAS_SAN(ctx) && refcert != NULL
334 if (ctx->reqExtensions != NULL /* augment/override existing ones */
335 && !add_extensions(&exts, ctx->reqExtensions))
337 if (sk_GENERAL_NAME_num(ctx->subjectAltNames) > 0
339 crit, ctx->subjectAltNames))
341 if (ctx->policies != NULL
343 ctx->setPoliciesCritical, ctx->policies))
377 OSSL_CMP_MSG *ossl_cmp_certreq_new(OSSL_CMP_CTX *ctx, int type,
383 if (!ossl_assert(ctx != NULL))
396 if ((msg = ossl_cmp_msg_create(ctx, type)) == NULL)
400 if (ctx->implicitConfirm && !ossl_cmp_hdr_set_implicitConfirm(msg->header))
406 EVP_PKEY *privkey = OSSL_CMP_CTX_get0_newPkey(ctx, 1);
408 /* privkey is ctx->newPkey (if private, else NULL) or ctx->pkey */
409 if (ctx->popoMethod >= OSSL_CRMF_POPO_SIGNATURE && privkey == NULL) {
414 local_crm = OSSL_CMP_CTX_setup_CRM(ctx,
418 || !OSSL_CRMF_MSG_create_popo(ctx->popoMethod, local_crm,
419 privkey, ctx->digest,
420 ctx->libctx, ctx->propq))
433 if (!ossl_cmp_msg_protect(ctx, msg))
445 OSSL_CMP_MSG *ossl_cmp_certrep_new(OSSL_CMP_CTX *ctx, int bodytype,
456 if (!ossl_assert(ctx != NULL && si != NULL))
459 if ((msg = ossl_cmp_msg_create(ctx, bodytype)) == NULL)
464 if (ctx->implicitConfirm && !ossl_cmp_hdr_set_implicitConfirm(msg->header))
507 if (!ossl_cmp_msg_protect(ctx, msg))
519 OSSL_CMP_MSG *ossl_cmp_rr_new(OSSL_CMP_CTX *ctx)
525 if (!ossl_assert(ctx != NULL && (ctx->oldCert != NULL
526 || ctx->p10CSR != NULL)))
533 ret = ctx->oldCert != NULL
537 X509_get_issuer_name(ctx->oldCert),
538 X509_get0_serialNumber(ctx->oldCert))
540 X509_REQ_get0_pubkey(ctx->p10CSR),
541 X509_REQ_get_subject_name(ctx->p10CSR),
547 if (ctx->revocationReason != CRL_REASON_NONE
549 ctx->revocationReason))
552 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_RR)) == NULL)
560 if (!ossl_cmp_msg_protect(ctx, msg))
572 OSSL_CMP_MSG *ossl_cmp_rp_new(OSSL_CMP_CTX *ctx, const OSSL_CMP_PKISI *si,
580 if (!ossl_assert(ctx != NULL && si != NULL))
583 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_RP)) == NULL)
608 if (!ossl_cmp_msg_protect(ctx, msg))
619 OSSL_CMP_MSG *ossl_cmp_pkiconf_new(OSSL_CMP_CTX *ctx)
623 if (!ossl_assert(ctx != NULL))
626 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_PKICONF)) == NULL)
628 if (ossl_cmp_msg_protect(ctx, msg))
679 static OSSL_CMP_MSG *gen_new(OSSL_CMP_CTX *ctx,
685 if (!ossl_assert(ctx != NULL))
688 if ((msg = ossl_cmp_msg_create(ctx, body_type)) == NULL)
694 if (!ossl_cmp_msg_protect(ctx, msg))
705 OSSL_CMP_MSG *ossl_cmp_genm_new(OSSL_CMP_CTX *ctx)
707 return gen_new(ctx, ctx->genm_ITAVs,
711 OSSL_CMP_MSG *ossl_cmp_genp_new(OSSL_CMP_CTX *ctx,
714 return gen_new(ctx, itavs,
718 OSSL_CMP_MSG *ossl_cmp_error_new(OSSL_CMP_CTX *ctx, const OSSL_CMP_PKISI *si,
726 if (!ossl_assert(ctx != NULL && si != NULL))
729 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_ERROR)) == NULL)
760 if (!unprotected && !ossl_cmp_msg_protect(ctx, msg))
785 OSSL_CMP_MSG *ossl_cmp_certConf_new(OSSL_CMP_CTX *ctx, int certReqId,
793 if (!ossl_assert(ctx != NULL && ctx->newCert != NULL
803 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_CERTCONF)) == NULL)
822 if ((certHash = X509_digest_sig(ctx->newCert, NULL, NULL)) == NULL)
842 if (!ossl_cmp_msg_protect(ctx, msg))
854 OSSL_CMP_MSG *ossl_cmp_pollReq_new(OSSL_CMP_CTX *ctx, int crid)
859 if (!ossl_assert(ctx != NULL))
862 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_POLLREQ)) == NULL)
871 if (!ossl_cmp_msg_protect(ctx, msg))
883 OSSL_CMP_MSG *ossl_cmp_pollRep_new(OSSL_CMP_CTX *ctx, int crid,
889 if (!ossl_assert(ctx != NULL))
892 if ((msg = ossl_cmp_msg_create(ctx, OSSL_CMP_PKIBODY_POLLREP)) == NULL)
903 if (!ossl_cmp_msg_protect(ctx, msg))
1027 * Uses libctx and propq from ctx, in case of indirect POPO also private key.
1030 X509 *ossl_cmp_certresponse_get1_cert(const OSSL_CMP_CTX *ctx,
1037 if (!ossl_assert(crep != NULL && ctx != NULL))
1048 pkey = OSSL_CMP_CTX_get0_newPkey(ctx, 1);
1049 /* pkey is ctx->newPkey (if private, else NULL) or ctx->pkey */
1056 ctx->libctx, ctx->propq,
1067 (void)ossl_x509_set0_libctx(crt, ctx->libctx, ctx->propq);
1071 int OSSL_CMP_MSG_update_transactionID(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg)
1073 if (ctx == NULL || msg == NULL) {
1077 if (!ossl_cmp_hdr_set_transactionID(ctx, msg->header))
1080 || ossl_cmp_msg_protect(ctx, msg);
1083 int OSSL_CMP_MSG_update_recipNonce(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg)
1085 if (ctx == NULL || msg == NULL || msg->header == NULL) {
1089 if (ctx->recipNonce == NULL) /* nothing to do for 1st msg in transaction */
1092 ctx->recipNonce))
1094 return msg->header->protectionAlg == NULL || ossl_cmp_msg_protect(ctx, msg);