Skip to content

Certificate Compression (RFC8879)#18186

Closed
tmshort wants to merge 19 commits into
openssl:masterfrom
tmshort:master-certcomp
Closed

Certificate Compression (RFC8879)#18186
tmshort wants to merge 19 commits into
openssl:masterfrom
tmshort:master-certcomp

Conversation

@tmshort

@tmshort tmshort commented Apr 26, 2022

Copy link
Copy Markdown
Contributor

Replacement of #9155 (github doesn't allow change of source repositories)

Add support for brotli compression
Add support for Zstandardi compression
Add support for RFC8879
Add support for callback API, which allows the user to handle either compression expansion or pre-compressed server certificates.

Checklist
  • documentation is added or updated
  • tests are added or updated

@tmshort tmshort added branch: master Applies to master branch approval: review pending This pull request needs review by a committer approval: otc review pending triaged: feature The issue/pr requests/adds a feature labels Apr 26, 2022
@tmshort tmshort mentioned this pull request Apr 26, 2022
2 tasks
@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 30 days ago

@tmshort
tmshort force-pushed the master-certcomp branch 2 times, most recently from 351cfbb to 3d2f81d Compare June 2, 2022 15:42
@tmshort
tmshort requested review from mattcaswell and t8m June 2, 2022 15:43
@tmshort

tmshort commented Jun 2, 2022

Copy link
Copy Markdown
Contributor Author

Not sure why address_ub_santitizer is failing. I tried running it locally (same options, etc), and it succeeds. The error seems to be in a file this PR does not touch?

@mattcaswell mattcaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I reviewed this commit by commit, so some of my comments may have been made irrelevant by later changes

Comment thread Configure Outdated
Comment thread Configure Outdated
Comment thread apps/enc.c Outdated
Comment thread apps/enc.c Outdated
Comment thread doc/man3/COMP_CTX_new.pod Outdated
Comment thread ssl/statem/statem_clnt.c Outdated
Comment thread ssl/statem/statem_srvr.c Outdated
Comment thread ssl/statem/statem_srvr.c Outdated
Comment thread test/sslapitest.c Outdated
Comment thread .github/workflows/ci.yml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we run some tests with this code and asan?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tmshort

tmshort commented Jun 9, 2022

Copy link
Copy Markdown
Contributor Author

Thank you @mattcaswell! I will be updating this shortly.

@tmshort
tmshort force-pushed the master-certcomp branch 3 times, most recently from 42bc295 to 32fc27b Compare June 11, 2022 16:27

@FdaSilvaYY FdaSilvaYY left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more nits ...

Comment thread doc/man3/COMP_CTX_new.pod Outdated
Comment thread Configure Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see zstd options description

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had meant to remove brotli since it was not longer considered "special" (like zlib). It's now just a regular option to be used with enable- or no-.

Comment thread crypto/objects/objects.pl Outdated
Comment thread doc/man3/COMP_CTX_new.pod Outdated
Comment thread doc/man3/SSL_CTX_set_cert_comp_cb.pod Outdated
Comment thread ssl/ssl_lib.c Outdated
Comment thread ssl/statem/extensions.c Outdated
Comment thread ssl/statem/statem_lib.c Outdated
Comment thread ssl/statem/statem_srvr.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allocation can failed.

@tmshort tmshort Jun 13, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it's checked in tls13_process_compressed_certificate(); which is called by both the client and server code. So, I put the check in there, rather than having two checks before the call of the function.

Comment thread test/recipes/07-test_bio_comp.t Outdated
@tmshort
tmshort requested a review from mattcaswell June 15, 2022 13:59
@tmshort

tmshort commented Jun 28, 2022

Copy link
Copy Markdown
Contributor Author

Ping @mattcaswell ?

@tmshort
tmshort force-pushed the master-certcomp branch from 369459c to 021c166 Compare July 6, 2022 14:56
@mattcaswell

Copy link
Copy Markdown
Member

Ping @mattcaswell ?

Sorry - been away on vacation for the last 2 weeks. Will try and pick this up when I am caught up.

@tmshort

tmshort commented Aug 1, 2022

Copy link
Copy Markdown
Contributor Author

I removed BUF_MEM from the APIs.

@tmshort
tmshort force-pushed the master-certcomp branch 2 times, most recently from 144a3a1 to bf94cb8 Compare August 3, 2022 17:08
@tmshort

tmshort commented Aug 3, 2022

Copy link
Copy Markdown
Contributor Author

Should we run some tests with this code and asan?

Done.

@tmshort

tmshort commented Aug 3, 2022

Copy link
Copy Markdown
Contributor Author

ping @mattcaswell ?

@tmshort

tmshort commented Oct 17, 2022

Copy link
Copy Markdown
Contributor Author

👍 I'm happy to resolve the conflicts when merging.

I just did it locally, but I'm also a committer.

@tmshort tmshort self-assigned this Oct 17, 2022
@openssl-machine

Copy link
Copy Markdown
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@tmshort tmshort added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Oct 18, 2022
@tmshort

tmshort commented Oct 18, 2022

Copy link
Copy Markdown
Contributor Author

Just comments... starting merge.

@tmshort

tmshort commented Oct 18, 2022

Copy link
Copy Markdown
Contributor Author

Merged to master. Thanks @mattcaswell @hlandau.

@tmshort tmshort closed this Oct 18, 2022
@tmshort
tmshort deleted the master-certcomp branch October 18, 2022 15:45
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
Use the normal OPENSSL_NO_ prefix to enable/disable ZLIB
Make `BIO_f_zlib()` always available.

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
* Compressed Certificate extension (server/client)
* Server certificates (send/receive)
* Client certificate (send/receive)

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
size_t-ify the COMP_METHOD structure and functions.
Get rid of the non-functional COMP_METHODS and return NULL instead.

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
openssl-machine pushed a commit that referenced this pull request Oct 18, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18186)
@slontis

slontis commented Oct 19, 2022

Copy link
Copy Markdown
Member

Coverity has picked up a few things/..

New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)

** CID 1516095: (DEADCODE)
/test/cert_comp_test.c: 163 in test_ssl_cert_comp()
/test/cert_comp_test.c: 206 in test_ssl_cert_comp()


*** CID 1516095: (DEADCODE)
/test/cert_comp_test.c: 163 in test_ssl_cert_comp()
157 if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
158 TLS_client_method(),
159 TLS1_3_VERSION, 0,
160 &sctx, &cctx, cert, privkey)))
161 goto end;
162 if (test == 3) {

CID 1516095:    (DEADCODE)
Execution cannot reach this statement: "server_pref[0] = expected_s...".

163 server_pref[0] = expected_server;
164 server_pref[1] = expected_client;
165 if (!TEST_true(SSL_CTX_set1_cert_comp_preference(sctx, server_pref, 2)))
166 goto end;
167 client_pref[0] = expected_client;
168 if (!TEST_true(SSL_CTX_set1_cert_comp_preference(cctx, client_pref, 1)))
/test/cert_comp_test.c: 206 in test_ssl_cert_comp()
200 goto end;
201 }
202
203 if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
204 goto end;
205 if (test == 3) {

CID 1516095:    (DEADCODE)
Execution cannot reach the expression "sc" inside this statement: "sc = ((serverssl == NULL) ?...".

206 SSL_CONNECTION sc = SSL_CONNECTION_FROM_SSL(serverssl);
207
208 /
expect that the pre-compressed cert won't be used */
209 if (!TEST_int_eq(sc->cert->key->cert_comp_used, 0))
210 goto end;
211

** CID 1516094: Memory - illegal accesses (UNINIT)


*** CID 1516094: Memory - illegal accesses (UNINIT)
/ssl/statem/statem_clnt.c: 3735 in tls_construct_client_compressed_certificate()
3729 ret = 1;
3730 goto out;
3731
3732 err:
3733 SSLfatal(sc, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
3734 out:

CID 1516094:  Memory - illegal accesses  (UNINIT)
Using uninitialized value "tmppkt.subs" when calling "WPACKET_cleanup".

3735 WPACKET_cleanup(&tmppkt);
3736 BUF_MEM_free(buf);
3737 COMP_CTX_free(comp);
3738 return ret;
3739 }
3740 #endif

** CID 1516093: (TAINTED_SCALAR)
/ssl/t1_trce.c: 1337 in ssl_print_compressed_certificates()
/ssl/t1_trce.c: 1345 in ssl_print_compressed_certificates()


*** CID 1516093: (TAINTED_SCALAR)
/ssl/t1_trce.c: 1337 in ssl_print_compressed_certificates()
1331 msg += 8;
1332 BIO_indent(bio, indent, 80);
1333 BIO_printf(bio, "Compression type=%s (0x%04x)\n", ssl_trace_str(alg, ssl_comp_cert_tbl), alg);
1334 BIO_indent(bio, indent, 80);
1335 BIO_printf(bio, "Uncompressed length=%d\n", (int)uclen);
1336 BIO_indent(bio, indent, 80);

CID 1516093:    (TAINTED_SCALAR)
Using tainted expression "clen" as the divisor in "(float)uclen / (float)clen".

1337 BIO_printf(bio, "Compressed length=%d, Ratio=%f:1\n", (int)clen, (float)uclen / (float)clen);
1338
1339 BIO_dump_indent(bio, (const char *)msg, clen, indent);
1340
1341 #ifndef OPENSSL_NO_COMP_ALG
1342 if (!ossl_comp_has_alg(alg))
/ssl/t1_trce.c: 1345 in ssl_print_compressed_certificates()
1339 BIO_dump_indent(bio, (const char *)msg, clen, indent);
1340
1341 #ifndef OPENSSL_NO_COMP_ALG
1342 if (!ossl_comp_has_alg(alg))
1343 return 0;
1344

CID 1516093:    (TAINTED_SCALAR)
Passing tainted expression "uclen" to "CRYPTO_malloc", which uses it as an allocation size. [Note: The source code implementation of the function has been overridden by a builtin model.]

1345 if ((ucdata = OPENSSL_malloc(uclen)) == NULL)
1346 return 0;
1347
1348 switch (alg) {
1349 case TLSEXT_comp_cert_zlib:
1350 method = COMP_zlib();

@tmshort

tmshort commented Oct 19, 2022

Copy link
Copy Markdown
Contributor Author

Thanks @slontis, I'll take a look at these.

@tmshort

tmshort commented Oct 19, 2022

Copy link
Copy Markdown
Contributor Author

** CID 1516095: (DEADCODE)
/test/cert_comp_test.c: 163 in test_ssl_cert_comp()
/test/cert_comp_test.c: 206 in test_ssl_cert_comp()

These will look like dead code if less than two compression algorithms are configured. If there are two compression algorithms configured, then this won't be dead code. This is due to a check on line 152 which skips the tests when trying this configuration, the expected values are initialized and set based on the configuration compression algorithms.
EDIT: How does one ignore these errors? @slontis

@tmshort

tmshort commented Oct 19, 2022

Copy link
Copy Markdown
Contributor Author

See #19440

@tmshort tmshort mentioned this pull request Nov 11, 2022
2 tasks
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Use the normal OPENSSL_NO_ prefix to enable/disable ZLIB
Make `BIO_f_zlib()` always available.

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
* Compressed Certificate extension (server/client)
* Server certificates (send/receive)
* Client certificate (send/receive)

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
size_t-ify the COMP_METHOD structure and functions.
Get rid of the non-functional COMP_METHODS and return NULL instead.

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18186)
@mattcaswell mattcaswell mentioned this pull request Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch severity: fips change The pull request changes FIPS provider sources triaged: feature The issue/pr requests/adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants