Skip to content
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

Support for libgcrypt, and external OCB in OpenSSL and libgcrypt #924

Closed
wants to merge 5 commits into from

Conversation

cgull
Copy link
Member

@cgull cgull commented Aug 24, 2017

This supersedes #790.

It adds support for libgcrypt's AES implementation. It also supports the OCB implementations in libgcrypt and OpenSSL 1.1+, in place of the bundled Rogaway/Krovetz implementation. There's autoconf support for all these permutations. Unlike #790, the autoconf code defaults to the current behavior, and libgcrypt and/or external OCB must be manually selected.

The external-OCB support is done by adding shims that support the ae_encrypt/ae_decrypt API presented by the bundled code. The shims are incomplete and do not support the full range of possible OCB encryption/decryption actions available in that API, or the full range of OCB cipher configurations. However, they do support the straightforward OCB requests that Mosh makes, and likely many of the requests that other practical OCB-using programs will make. The code passes all of Mosh's OCB tests, but does not pass the Krovetz/Rogaway test code at the bottom of src/crypto/ocb.cc. I think this code might be useful for other projects even if Mosh never uses it.

The libgcrypt support has seen some testing on Linux, FreeBSD, and macOS. The OpenSSL OCB code has only been tested on FreeBSD and needs verification on other platforms, once they take up OpenSSL 1.1+ more seriously. So this is not yet really ready to pull into Mosh.

cgull added 5 commits August 24, 2017 02:13
This code passes all Mosh tests, but fails some of the more esoteric
cases in the test program at the bottom of ocb.cc (none of which Mosh
uses).  Includes autoconf support.

But this is somewhat inefficient, it inits/resets OCB on every
message.

Only tested on FreeBSD.

Adds --with-external-ocb configure option, default to off.
@cgull cgull force-pushed the libgcrypt-external-ocb branch from 06aa38f to 43347dd Compare August 24, 2017 07:55
waltarix added a commit to waltarix/mosh that referenced this pull request Jan 12, 2022
achernya added a commit to achernya/mosh that referenced this pull request Jun 7, 2022
OpenSSL 3.0 deprecated many of the functions that ocb.cc used to
implement OCB-AES, causing a build failure when -Wdeprecated collided
with -Werror. Debian temporarily fixed this by suppressing the error
in mobile-shell#1191.

Since mosh 1.4 will be the next stable release of mosh, it should not
depend on deprecated functions in OpenSSL. Since version 1.1.0,
OpenSSL natively supports OCB-AES through the EVP_CIPHER API. @cgull
started early support for this in mobile-shell#924.

This change extends upon the previous work by @cgull in a few ways

 * EVP_EncryptInit_ex is called in ae_init to set up the
   EVP_CIPHER_CTX. It is later called in ae_encrypt and ae_decrypt
   just to load the key and nonce (IV in OpenSSL EVP parlance), which
   reduces the amount of initialization done per-packet.

 * Adds missing support for an external tag, rather than just one
   appended to the ciphertext

 * Support for non-default-sized tags

as well as some improved error handling.

Note that this change raises the minimum OpenSSL version for Mosh to
1.1.0. OpenSSL does not provide security support for versions prior to
1.1 at this time, so this is in principle reasonable dependency. If we
want to continue to support distributions (such as RHEL7) which
continue to be supported by their vendor but use an unsupported
OpenSSL, then some future work will have to restore the ocb.cc
implementation that uses the deprecated functions.

Bugs: mobile-shell#1174
achernya added a commit to achernya/mosh that referenced this pull request Jun 7, 2022
OpenSSL 3.0 deprecated many of the functions that ocb.cc used to
implement OCB-AES, causing a build failure when -Wdeprecated collided
with -Werror. Debian temporarily fixed this by suppressing the error
in mobile-shell#1191.

Since mosh 1.4 will be the next stable release of mosh, it should not
depend on deprecated functions in OpenSSL. Since version 1.1.0,
OpenSSL natively supports OCB-AES through the EVP_CIPHER API. @cgull
started early support for this in mobile-shell#924.

This change extends upon the previous work by @cgull in a few ways

 * EVP_EncryptInit_ex is called in ae_init to set up the
   EVP_CIPHER_CTX. It is later called in ae_encrypt and ae_decrypt
   just to load the key and nonce (IV in OpenSSL EVP parlance), which
   reduces the amount of initialization done per-packet.

 * Adds missing support for an external tag, rather than just one
   appended to the ciphertext

 * Support for non-default-sized tags

as well as some improved error handling.

Note that this change raises the minimum OpenSSL version for Mosh to
1.1.0. OpenSSL does not provide security support for versions prior to
1.1 at this time, so this is in principle reasonable dependency. If we
want to continue to support distributions (such as RHEL7) which
continue to be supported by their vendor but use an unsupported
OpenSSL, then some future work will have to restore the ocb.cc
implementation that uses the deprecated functions.

Bugs: mobile-shell#1174
achernya added a commit to achernya/mosh that referenced this pull request Jun 14, 2022
OpenSSL 3.0 deprecated many of the functions that ocb.cc used to
implement OCB-AES, causing a build failure when -Wdeprecated collided
with -Werror. Debian temporarily fixed this by suppressing the error
in mobile-shell#1191.

Since mosh 1.4 will be the next stable release of mosh, it should not
depend on deprecated functions in OpenSSL. Since version 1.1.0,
OpenSSL natively supports OCB-AES through the EVP_CIPHER API. @cgull
started early support for this in mobile-shell#924.

This change extends upon the previous work by @cgull in a few ways

 * EVP_CipherInit_ex is called in ae_init to set up the
   EVP_CIPHER_CTX. It is later called in ae_encrypt and ae_decrypt
   just to load nonce (IV in OpenSSL EVP parlance), which reduces the
   amount of initialization done per-packet. However, due to OpenSSL
   API limitations, two copies of the EVP_CIPHER_CTX are kept: one for
   encryption, and one for decryption.

 * Adds missing support for an external tag, rather than just one
   appended to the ciphertext

 * Support for non-default-sized tags

as well as some improved error handling.

Note that this change raises the minimum OpenSSL version for Mosh to
1.1.0. OpenSSL does not provide security support for versions prior to
1.1 at this time, so this is in principle reasonable dependency. If we
want to continue to support distributions (such as RHEL7) which
continue to be supported by their vendor but use an unsupported
OpenSSL, then some future work will have to restore the ocb.cc
implementation that uses the deprecated functions.

Bugs: mobile-shell#1174
achernya added a commit that referenced this pull request Jun 14, 2022
OpenSSL 3.0 deprecated many of the functions that ocb.cc used to
implement OCB-AES, causing a build failure when -Wdeprecated collided
with -Werror. Debian temporarily fixed this by suppressing the error
in #1191.

Since mosh 1.4 will be the next stable release of mosh, it should not
depend on deprecated functions in OpenSSL. Since version 1.1.0,
OpenSSL natively supports OCB-AES through the EVP_CIPHER API. @cgull
started early support for this in #924.

This change extends upon the previous work by @cgull in a few ways

 * EVP_CipherInit_ex is called in ae_init to set up the
   EVP_CIPHER_CTX. It is later called in ae_encrypt and ae_decrypt
   just to load nonce (IV in OpenSSL EVP parlance), which reduces the
   amount of initialization done per-packet. However, due to OpenSSL
   API limitations, two copies of the EVP_CIPHER_CTX are kept: one for
   encryption, and one for decryption.

 * Adds missing support for an external tag, rather than just one
   appended to the ciphertext

 * Support for non-default-sized tags

as well as some improved error handling.

Note that this change raises the minimum OpenSSL version for Mosh to
1.1.0. OpenSSL does not provide security support for versions prior to
1.1 at this time, so this is in principle reasonable dependency. If we
want to continue to support distributions (such as RHEL7) which
continue to be supported by their vendor but use an unsupported
OpenSSL, then some future work will have to restore the ocb.cc
implementation that uses the deprecated functions.

Bugs: #1174
@cgull
Copy link
Member Author

cgull commented Nov 16, 2022

This work has been mostly superseded by newer, better OpenSSL OCB support in #1196 by @achernya, and later work, included (but not default) in Mosh 1.4.0. The libgcrypt support here might still be of interest to some, but given libgcrypt's unpopularity, isn't worth pulling into Mosh.

After the problems discovered with OpenSSL's OCB, I now better understand @keithw's conservative position on using outside crypto implementations, and mostly agree with it. I think alternate crypto implementations still have some value for development and testing.

@cgull cgull closed this Nov 16, 2022
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.

1 participant