Skip to content

Implement AES-GCM support for TLS1.2#37

Merged
colmmacc merged 8 commits intoaws:masterfrom
baldwinmatt:aead-cipher-suites
Feb 19, 2015
Merged

Implement AES-GCM support for TLS1.2#37
colmmacc merged 8 commits intoaws:masterfrom
baldwinmatt:aead-cipher-suites

Conversation

@baldwinmatt
Copy link
Copy Markdown
Contributor

This commit adds support for AES-GCM mode for AES128 and AES256.

The new cipher suites are added as version 20150214 and made the new default.

closes #5

This commit adds support for AES-GCM mode for AES128 and AES256.

The new cipher suites are added as version 20150214 and made the new default.

closes #5
@baldwinmatt
Copy link
Copy Markdown
Contributor Author

This has been tested with

./bin/s2nd localhost 8443
openssl s_client -cipher DHE-RSA-AES128-GCM-SHA256 -connect localhost:8443

and

./bin/s2nc www.amazon.com 443

and in both cases we are able to negotiate and transmit data in both directions

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.

Since s2n is a TLS implementation, should it be authoritative about these sizes, rather than relying on OpenSSL to get it right? I feel like it's ok for OpenSSL to be authoritative about the crypto, but we should probably define TLS basics ourselves.

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.

agreed - i was thinking about this, glad you agree ;)

@colmmacc
Copy link
Copy Markdown
Contributor

Awesome change! implementing this is not at all easy and it's a big deal to get AEAD in now. Using OpenSSL-1.0.2's libcrypto will get us some great performance benefits too. Its AES implementation is significantly faster than predecessors.

Define TLS constants in S2N so as not to rely on openssl
Refactored the AAD derivation into a single implementation
Added some extra checks on size
Reordered code to prefer AEAD mode
@baldwinmatt
Copy link
Copy Markdown
Contributor Author

Added a new commit which addresses most things - still working on the negative tests and fixing the AES256/SHA384 implementations.

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.

Thanks for the update! Sorry for not catching it earlier, but I think we need to use != 1 here. The docs say that these functions return 1 on success, so that's the most explicit thing that we can check. If they return say, 2, we should assume something weird is going on.

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.

good call - fixed

@baldwinmatt
Copy link
Copy Markdown
Contributor Author

Added data tampering tests

@baldwinmatt
Copy link
Copy Markdown
Contributor Author

Removed the AES256/SHA384 cipher squites as they require changes to the PRF

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.

It's a memory leak unless you call EVP_CIPHER_CTX_cleanup.

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.

you are right, but calling that destroys the key.
do we need a corresponding destroy_(en|de)cryption_key method? as we currently have this problem with the CBC mode ciphers leaking too.

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.

Destroy sounds useful - there's definitely times where things keep intermediate forms of keys, and cipher states and need allocation and deallocation. Even if it's a no-op for a bunch of the suites that's no problem.

@baldwinmatt
Copy link
Copy Markdown
Contributor Author

Added the destroy_key API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support AEAD cipher suites

3 participants