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

Deprecate the low level AES functions #10580

Closed
wants to merge 7 commits into from

Conversation

mattcaswell
Copy link
Member

Use of the low level AES functions has been informally discouraged for a
long time. We now formally deprecate them.

Applications should instead use the EVP APIs, e.g. EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_EncryptFinal_ex, and the equivalently named decrypt
functions.

@mattcaswell mattcaswell added branch: master Merge to master branch approval: review pending This pull request needs review by a committer labels Dec 5, 2019
levitte
levitte previously approved these changes Dec 5, 2019
@levitte levitte dismissed their stale review December 5, 2019 21:33

Need 'make update'

@mattcaswell mattcaswell mentioned this pull request Dec 11, 2019
2 tasks
@levitte
Copy link
Member

levitte commented Dec 11, 2019

make update needed

@mattcaswell
Copy link
Member Author

make update needed

Unfortunately much more than that is needed. This PR just doesn't work at all with "no-deprecated". I'm working on it.

@mattcaswell mattcaswell changed the title Deprecate the low level AES functions WIP: Deprecate the low level AES functions Dec 11, 2019
@mattcaswell
Copy link
Member Author

Temporarily I moved this into WIP because its currently broken. I've pushed a bunch of fixes for "no-deprecated" but there's still more to fix.

@levitte
Copy link
Member

levitte commented Dec 11, 2019

The last commit added OPENSSL_SUPRESS_DEPRECATION a little all over the place. Wouldn't the following be much simpler and easier to follow?

diff --git a/include/openssl/macros.h b/include/openssl/macros.h
index a38387f131..484d76c1e1 100644
--- a/include/openssl/macros.h
+++ b/include/openssl/macros.h
@@ -25,6 +25,9 @@
 
 /*
  * Generic deprecation macro
+ *
+ * If OPENSSL_SUPPRESS_DEPRECATED is defined, then DECLARE_DEPRECATED
+ * becomes a no-op
  */
 # ifndef DECLARE_DEPRECATED
 #  define DECLARE_DEPRECATED(f)   f;
@@ -43,6 +46,13 @@
 #  endif
 # endif
 
+/*
+ * If OPENSSL_SUPPRESS_DEPRECATED is defined, then turn off 'no-deprecated'
+ */
+#ifdef OPENSSL_SUPPRESS_DEPRECATED
+# undef OPENSSL_NO_DEPRECATED
+#endif
+
 /*
  * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
  * declarations of functions deprecated in or before <version>.  If this is

@mattcaswell
Copy link
Member Author

You mean instead of the other changes in macros.h? Yes that could work.

@levitte
Copy link
Member

levitte commented Dec 11, 2019

You mean instead of the other changes in macros.h? Yes that could work.

And elsewhere. Basically, you shouldn't need to check OPENSSL_SUPPRESS_DEPRECATE all over the place

@mattcaswell
Copy link
Member Author

mattcaswell commented Dec 11, 2019

Updated so that it should now work in both normal builds and no-deprecated builds. I've left this as WIP for now because it now incorporates the commits from #10606 and #10608. Once those are merged I will rebase this and take it out of WIP.

@levitte
Copy link
Member

levitte commented Dec 11, 2019

I wouldn't mind if #10608 got reviewed. 😉

@mattcaswell mattcaswell changed the title WIP: Deprecate the low level AES functions Deprecate the low level AES functions Dec 16, 2019
@mattcaswell
Copy link
Member Author

Now that #10606 and #10608 have been merged I've rebased this and taken it out of WIP.

Please review.

@slontis
Copy link
Member

slontis commented Dec 17, 2019

travis isnt looking very healthly,
since deprecated warnings results in errors

goto err;
}

wkey = OPENSSL_malloc(ec->keylen + 8);

Copy link
Member

Choose a reason for hiding this comment

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

The + 8 on the line above in the existing code looks a bit dangerous to me :)
Hopefully it equals wkeylen below.
A check might have been nice.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a comment about this, and later ossl_assert check

@levitte
Copy link
Member

levitte commented Dec 17, 2019

travis isnt looking very healthly,
since deprecated warnings results in errors

crypto/aes/aes_cbc.c needs to include "internsl/deprecated.h"

@mattcaswell
Copy link
Member Author

crypto/aes/aes_cbc.c needs to include "internsl/deprecated.h"

Yes, and a couple of other spots. Now fixed.

Please take a look.

@mattcaswell
Copy link
Member Author

Travis red cross is not relevant.

Ping?

@@ -12,7 +12,8 @@

# include "openssl/aes.h"

# ifdef VPAES_ASM
# ifndef OPENSSL_NO_DEPRECATED
Copy link
Member

@slontis slontis Dec 18, 2019

Choose a reason for hiding this comment

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

Not quite sure I understand why the NO_DEPRECATED is required in this internal file?
(This file is used also inside provider implementations).

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is included by e_camellia.c which does not include the "internal/deprecated.h" file, because it doesn't use any externally deprecated APIs. However this header file contains references to AES things that may not be defined in a no-deprecated build - and so the compiler complains loudly. Adding this guard means e_camellia.c compiles correctly. Another fix would be to instead include "internal/deprecated.h" in e_camellia.c - but I'd rather not do that.

Copy link
Member

Choose a reason for hiding this comment

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

cipher_platform.h should really be divided into algo specific headers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe. But I'd see that as outside of the scope of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that #10662 has gone in, this file no longer exists and these changes aren't necessary.

We should not be using the low level AES APIs in CMS. Instead we should
be using EVP. There was a small amount of use of the low level key
wrap APIs - so we convert that to EVP.
Use of the low level AES functions has been informally discouraged for a
long time. We now formally deprecate them.

Applications should instead use the EVP APIs, e.g. EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_EncryptFinal_ex, and the equivalently named decrypt
functions.
@mattcaswell
Copy link
Member Author

I've rebased this to pick up the changes from #10662. Please take another look.

@mattcaswell
Copy link
Member Author

Ping?

* This header *must* be the first OpenSSL header included by a source file.
*/

#ifndef OSSL_INTERNAL_DEPRECTATED_H
Copy link
Member

Choose a reason for hiding this comment

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

Typo: deprectated

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@mattcaswell
Copy link
Member Author

Fixup commit pushed addressing latest feedback comment.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

LGTM

@t8m t8m added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jan 3, 2020
@levitte levitte 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 Jan 4, 2020
@mattcaswell
Copy link
Member Author

Pushed. Thanks.

@mattcaswell mattcaswell closed this Jan 6, 2020
openssl-machine pushed a commit that referenced this pull request Jan 6, 2020
We should not be using the low level AES APIs in CMS. Instead we should
be using EVP. There was a small amount of use of the low level key
wrap APIs - so we convert that to EVP.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #10580)
openssl-machine pushed a commit that referenced this pull request Jan 6, 2020
Use of the low level AES functions has been informally discouraged for a
long time. We now formally deprecate them.

Applications should instead use the EVP APIs, e.g. EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_EncryptFinal_ex, and the equivalently named decrypt
functions.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #10580)
* This file uses the low level AES functions (which are deprecated for
* non-internal use) in order to implement the padlock engine AES ciphers.
*/
#define OPENSSL_SUPPRESS_DEPRECATED
Copy link
Contributor

Choose a reason for hiding this comment

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

@mattcaswell does this work for an engine?
Won't the low level calls be hidden and non-resolvable?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are two scenarios:

  1. Compilation when "no-deprecated" has been defined

  2. Compilation when "no-deprecated" has not been defined

In the first case this PR changed Configure so that padlock never gets compiled. In the second case the low level calls are resolvable and we are only concerned about the deprecation warnings that the compiler will emit. This line is to suppress those.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, I missed the Configure change somehow.

Is this how we want to deal with engines that use deprecated APIs? e.g. the e_dasync engine uses SHA-1 and I modified it to not over in #10791.

Copy link
Member Author

Choose a reason for hiding this comment

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

In general no. I think where possible we should convert usage to use EVP instead. I took the decision not to do that with padlock because the usage was so extensive.

kubo39 added a commit to kubo39/rust-openssl that referenced this pull request Jan 26, 2020
decrypt functions

Some functions including low level AES functions would be deprecated
in next OpenSSL version(3.0).
OpenSSL team says that application should use the high level EVP APIs,
so I added these functions.

See also:
openssl/openssl#10580
openssl/openssl#10740
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 Merge to master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants