Skip to content

Remove Diffie-Hellman examples #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

yanesca
Copy link
Collaborator

@yanesca yanesca commented Mar 5, 2019

These examples rely on the NET module, which we want to remove. In
theory we could remove just the dependency, but we decided to remove the
whole example because:

  • They showcase some bad crypto: custom, undocumented protocol (not
    obviously broken though, apart from authenticating only one side);
    hard-coded limit of 512-bit size for the DH modulus (2048 is the
    recommended minimum these days); direct use of the shared secret as a
    key (instead of applying a KDF); encryption with ECB, custom
    parameters and the client not having the ability to verify them.
  • The programs use the DH API in the same way that TLS does, so they
    have limited demonstration value.
  • The programs only show finite-field DH, which is not used all that
    much these days. What people want to see is mostly ECDH.

@yanesca yanesca added the needs: review The pull request is ready for review. This generally means that it has no known issues. label Mar 5, 2019
@Patater
Copy link
Contributor

Patater commented Mar 5, 2019

Are there any CMakeLists or Makefile or visual studio files to update?

@gilles-peskine-arm gilles-peskine-arm added needs: work The pull request needs rework before it can be merged. and removed needs: review The pull request is ready for review. This generally means that it has no known issues. labels Mar 5, 2019
@gilles-peskine-arm
Copy link
Collaborator

gilles-peskine-arm commented Mar 5, 2019

All of these files need updating:

$ git grep -l dh_client
ChangeLog
programs/.gitignore
programs/Makefile
programs/README.md
programs/pkey/CMakeLists.txt
programs/pkey/dh_client.c
visualc/VS2010/dh_client.vcxproj
visualc/VS2010/mbedTLS.sln

@yanesca
Copy link
Collaborator Author

yanesca commented Mar 5, 2019

I remember talking about it, but I don't remember how we decided, do we want to keep updating ChangeLog in mbed-crypto?

@gilles-peskine-arm
Copy link
Collaborator

We've talked about it but not decided anything. In the meantime, I propose to keep updating ChangeLog with an “Mbed Crypto” entry for anything that impacts the non-PSA API (but not for PSA API stuff because we have a huge backlog and no strong promise of backward compatibility yet).

@yanesca yanesca force-pushed the iotcrypt-685-rewrite-dh-example branch 2 times, most recently from 6b8d597 to 0307707 Compare March 5, 2019 12:26
@Patater
Copy link
Contributor

Patater commented Mar 5, 2019

Please don't add any Mbed Crypto entries to the ChangeLog. Feel free to start a wiki page for the next version's release notes, though. Until we have a solution to ChangeLog maintenance and automatic merging, it's not worth the effort. We can bring it back later if it makes sense.

@yanesca yanesca added needs: review The pull request is ready for review. This generally means that it has no known issues. and removed needs: work The pull request needs rework before it can be merged. labels Mar 5, 2019
@yanesca
Copy link
Collaborator Author

yanesca commented Mar 6, 2019

The PR is ready for review again.

Copy link
Collaborator

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

Looks ok except for the ChangeLog entry. Also, Jaeden wanted to keep the changelog entry somewhere else (I have no strong feelings about that point).

ChangeLog Outdated
@@ -64,6 +64,9 @@ Features
* Add a new function mbedtls_asn1_write_named_bitstring() to write ASN.1
named bitstring in DER as required by RFC 5280 Appendix B.

Mbed Crypto
* Removed two Diffie-Hellman examples which were relying on the Net module.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changelog entries are primarily for users of the library. Most users of the library don't care much about module dependencies, but they might care about the example programs. So we should tell them what to look at instead. Proposal:

Remove the Diffie-Hellman examples which implemented a toy protocol inspired by TLS DH key exchange. For an example of how to use the DHM module, see the code that calls mbedtls_dhm_xxx in ssl_tls.c and ssl_cli.c in Mbed TLS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixing it. (I had removed it before the review, just forgot to push.)

@@ -49,8 +49,7 @@ endif

APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \
pkey/dh_client$(EXEXT) \
pkey/dh_genprime$(EXEXT) pkey/dh_server$(EXEXT) \
pkey/dh_genprime$(EXEXT) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Check alignment of \.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in ff43390.

ChangeLog Outdated
@@ -64,6 +64,9 @@ Features
* Add a new function mbedtls_asn1_write_named_bitstring() to write ASN.1
named bitstring in DER as required by RFC 5280 Appendix B.

Mbed Crypto
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add release note items to our upcoming release's release notes page. We can edit them and get them into shape before publishing separately from code changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added the text suggested by @gilles-peskine-arm to the page.

@yanesca yanesca force-pushed the iotcrypt-685-rewrite-dh-example branch from 0307707 to ce1e24b Compare March 6, 2019 14:27
@yanesca
Copy link
Collaborator Author

yanesca commented Mar 6, 2019

The PR is ready for review again.

pkey/rsa_sign$(EXEXT) pkey/rsa_verify$(EXEXT) \
pkey/rsa_sign_pss$(EXEXT) pkey/rsa_verify_pss$(EXEXT) \
psa/crypto_examples$(EXEXT) \
hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \
Copy link
Contributor

@Patater Patater Mar 6, 2019

Choose a reason for hiding this comment

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

Could you align with tab-width 8 please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

These examples rely on the NET module, which we want to remove. In
theory we could remove just the dependency, but we decided to remove the
whole example because:

 - They showcase some bad crypto: custom, undocumented protocol (not
   obviously broken though, apart from authenticating only one side);
   hard-coded limit of 512-bit size for the DH modulus (2048 is the
   recommended minimum these days); direct use of the shared secret as a
   key (instead of applying a KDF); encryption with ECB, custom
   parameters and the client not having the ability to verify them.
 - The programs use the DH API in the same way that TLS does, so they
   have limited demonstration value.
 - The programs only show finite-field DH, which is not used all that
   much these days. What people want to see is mostly ECDH.
@yanesca yanesca force-pushed the iotcrypt-685-rewrite-dh-example branch from ff43390 to bea98b4 Compare March 6, 2019 15:40
Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: review The pull request is ready for review. This generally means that it has no known issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants