Skip to content

Commit 6b93db7

Browse files
neverpanicbeldmit
authored andcommitted
x509: Accept 'contentCommitment' as alias
ITU-T X.509 (10/2019) section 9.2.2.3 [1] defines 'contentCommitment' as the current name for what had previously been called 'nonRepudiation', and deprecates the old name: > It is not incorrect to refer to this keyUsage bit using the identifier > nonRepudiation. However, the use of this identifier has been > deprecated. Allow 'contentCommitment' as an alias wherever 'nonRepudiation' has been accepted before, so that passing -addext keyUsage=critical,contentCommitment works as expected. Add a test that checks that contentCommitment sets the same keyUsage bit as nonRepudiation. Adjust the docs to mention the available alias name. [1]: https://www.itu.int/rec/T-REC-X.509-201910-I/en Signed-off-by: Clemens Lang <[email protected]> Reviewed-by: David von Oheimb <[email protected]> Reviewed-by: Dmitry Belyavskiy <[email protected]> (Merged from #28161)
1 parent c5ef06f commit 6b93db7

5 files changed

Lines changed: 39 additions & 5 deletions

File tree

‎crypto/asn1/t_bitst.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,19 @@ int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
1717
{
1818
BIT_STRING_BITNAME *bnam;
1919
char first = 1;
20+
int last_seen_bit = -1;
21+
2022
BIO_printf(out, "%*s", indent, "");
2123
for (bnam = tbl; bnam->lname; bnam++) {
24+
/*
25+
* Skip duplicate entries for the same bit in the BIT_STRING_BITNAME
26+
* table. Those are aliases, but we only want to print the first entry
27+
* when converting to a string.
28+
*/
29+
if (last_seen_bit == bnam->bitnum)
30+
continue;
31+
last_seen_bit = bnam->bitnum;
32+
2233
if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
2334
if (!first)
2435
BIO_puts(out, ", ");

‎crypto/x509/v3_bitst.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static BIT_STRING_BITNAME ns_cert_type_table[] = {
2828
static BIT_STRING_BITNAME key_usage_type_table[] = {
2929
{0, "Digital Signature", "digitalSignature"},
3030
{1, "Non Repudiation", "nonRepudiation"},
31+
{1, "Content Commitment", "contentCommitment"},
3132
{2, "Key Encipherment", "keyEncipherment"},
3233
{3, "Data Encipherment", "dataEncipherment"},
3334
{4, "Key Agreement", "keyAgreement"},
@@ -48,7 +49,17 @@ STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
4849
STACK_OF(CONF_VALUE) *ret)
4950
{
5051
BIT_STRING_BITNAME *bnam;
52+
int last_seen_bit = -1;
53+
5154
for (bnam = method->usr_data; bnam->lname; bnam++) {
55+
/*
56+
* If the bitnumber did not change from the last iteration, this entry
57+
* is an an alias for the previous bit; treat the first result as
58+
* canonical and ignore the rest.
59+
*/
60+
if (last_seen_bit == bnam->bitnum)
61+
continue;
62+
last_seen_bit = bnam->bitnum;
5263
if (ASN1_BIT_STRING_get_bit(bits, bnam->bitnum))
5364
X509V3_add_value(bnam->lname, NULL, &ret);
5465
}

‎doc/man1/openssl-verification-options.pod‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ This is used as a workaround if the basicConstraints extension is absent.
661661
=item B<S/MIME Signing> (C<smimesign>)
662662

663663
In addition to the common S/MIME checks, for target certificates
664-
the key usage must allow for C<digitalSignature> and/or B<nonRepudiation>.
664+
the key usage must allow for C<digitalSignature> and/or B<nonRepudiation> (or
665+
its alias name B<contentCommitment>).
665666

666667
=item B<S/MIME Encryption> (C<smimeencrypt>)
667668

@@ -685,7 +686,8 @@ For all other certificates the normal CA checks apply.
685686
=item B<Timestamp Signing> (C<timestampsign>)
686687

687688
For target certificates, if the key usage extension is present, it must include
688-
C<digitalSignature> and/or C<nonRepudiation> and must not include other bits.
689+
C<digitalSignature> and/or C<nonRepudiation> (or its alias name
690+
C<contentCommitment>) and must not include other bits.
689691
The EKU extension must be present and contain C<timeStamping> only.
690692
Moreover, it must be marked as critical.
691693

‎doc/man5/x509v3_config.pod‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ any sub-CA's, and can only sign end-entity certificates.
130130

131131
Key usage is a multi-valued extension consisting of a list of names of
132132
the permitted key usages. The defined values are: C<digitalSignature>,
133-
C<nonRepudiation>, C<keyEncipherment>, C<dataEncipherment>, C<keyAgreement>,
134-
C<keyCertSign>, C<cRLSign>, C<encipherOnly>, and C<decipherOnly>.
133+
C<nonRepudiation> (with an alternative name C<contentCommitment>),
134+
C<keyEncipherment>, C<dataEncipherment>, C<keyAgreement>, C<keyCertSign>,
135+
C<cRLSign>, C<encipherOnly>, and C<decipherOnly>.
135136

136137
Examples:
137138

138139
keyUsage = digitalSignature, nonRepudiation
139140

141+
keyUsage = digitalSignature, contentCommitment
142+
140143
keyUsage = critical, keyCertSign
141144

142145
=head2 Extended Key Usage

‎test/recipes/25-test_req.t‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
1515

1616
setup("test_req");
1717

18-
plan tests => 113;
18+
plan tests => 116;
1919

2020
require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
2121

@@ -748,6 +748,13 @@ generate_cert($cert, "-in", srctop_file(@certs, "ext-check.csr"),
748748
"-copy_extensions", "copy");
749749
has_keyUsage($cert, 1);
750750

751+
# keyUsage=contentCommitment is an alias for nonRepudiation
752+
$cert = "self-issued-v3_CA_keyUsage_contentCommitment.pem";
753+
generate_cert($cert, "-addext", "keyUsage = contentCommitment",
754+
"-in", srctop_file(@certs, "x509-check.csr"));
755+
cert_contains($cert, "Non Repudiation", 1);
756+
cert_contains($cert, "Content Commitment", 0);
757+
751758
# Generate cert using req with '-modulus'
752759
ok(run(app(["openssl", "req", "-x509", "-new", "-days", "365",
753760
"-key", srctop_file("test", "testrsa.pem"),

0 commit comments

Comments
 (0)