Skip to content

Commit

Permalink
fixup! CMP lib and app: add optional certProfile request message head…
Browse files Browse the repository at this point in the history
…er and respective -profile option
  • Loading branch information
DDvO committed Dec 15, 2023
1 parent a0b402b commit 3c7a3ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,8 @@ static int add_certProfile(OSSL_CMP_CTX *ctx, const char *name)
ASN1_STRING_free(utf8string);
goto err;
}
(void)sk_ASN1_UTF8STRING_push(sk, utf8string); /* must succeed */
/* Due to sk_ASN1_UTF8STRING_new_reserve(NULL, 1), this surely succeeds: */
(void)sk_ASN1_UTF8STRING_push(sk, utf8string);
if ((itav = OSSL_CMP_ITAV_new0_certProfile(sk)) == NULL)
goto err;
if (OSSL_CMP_CTX_push0_geninfo_ITAV(ctx, itav))
Expand Down
10 changes: 8 additions & 2 deletions apps/lib/cmp_mock_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
ASN1_OBJECT *obj = OSSL_CMP_ITAV_get0_type(itav);
STACK_OF(ASN1_UTF8STRING) *strs;
ASN1_UTF8STRING *str;
const char *data;

if (OBJ_obj2nid(obj) == NID_id_it_certProfile) {
if (!OSSL_CMP_ITAV_get0_certProfile(itav, &strs))
Expand All @@ -261,8 +262,13 @@ static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
return NULL;
}
str = sk_ASN1_UTF8STRING_value(strs, 0);
if (strcmp((const char *)ASN1_STRING_get0_data(str), "profile1")
!= 0) {
if (str == NULL
|| (data =
(const char *)ASN1_STRING_get0_data(str)) == NULL) {
ERR_raise(ERR_LIB_CMP, ERR_R_PASSED_INVALID_ARGUMENT);
return NULL;
}
if (strcmp(data, "profile1") != 0) {
ERR_raise(ERR_LIB_CMP, CMP_R_UNEXPECTED_CERTPROFILE);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion doc/man1/openssl-cmp.pod.in
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ The B<cmp> application was added in OpenSSL 3.0.

The B<-engine> option was deprecated in OpenSSL 3.0.

The B<-profile> option as was added in OpenSSL 3.3.
The B<-profile> option was added in OpenSSL 3.3.

=head1 COPYRIGHT

Expand Down
7 changes: 6 additions & 1 deletion doc/man3/OSSL_CMP_ITAV_set0.pod
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ It is an error if the infoType of I<itav> is not B<certProfile>.

=head1 NOTES

CMP is defined in RFC 4210 (and CRMF in RFC 4211).
CMP is defined in RFC 4210 and RFC 9480 (and CRMF in RFC 4211).

OIDs to use as types in B<OSSL_CMP_ITAV> can be found at
L<https://datatracker.ietf.org/doc/html/rfc9480#section-4.2.2>.
The respective OpenSSL NIDs, such as B<NID_id_it_certProfile>,
are defined in the F<< <openssl/obj_mac.h> >> header file.

=head1 RETURN VALUES

Expand Down

0 comments on commit 3c7a3ea

Please sign in to comment.