RESOLVED FIXED 186967
[GCrypt] Zero-prefix (if necessary) output of RSA-based encryption and signing operations
https://bugs.webkit.org/show_bug.cgi?id=186967
Summary [GCrypt] Zero-prefix (if necessary) output of RSA-based encryption and signin...
Zan Dobersek
Reported 2018-06-23 05:26:59 PDT
[GCrypt] Zero-prefix (if necessary) RSA-OAEP encryption, RSA-PSS signing output
Attachments
Patch (18.79 KB, patch)
2018-06-23 05:56 PDT, Zan Dobersek
no flags
Patch (19.01 KB, patch)
2018-06-25 00:03 PDT, Zan Dobersek
no flags
Zan Dobersek
Comment 1 2018-06-23 05:56:02 PDT
Zan Dobersek
Comment 2 2018-06-23 05:57:04 PDT
*** Bug 176759 has been marked as a duplicate of this bug. ***
Zan Dobersek
Comment 3 2018-06-23 05:57:12 PDT
*** Bug 180095 has been marked as a duplicate of this bug. ***
Zan Dobersek
Comment 4 2018-06-23 05:57:18 PDT
*** Bug 181139 has been marked as a duplicate of this bug. ***
Zan Dobersek
Comment 5 2018-06-23 05:57:26 PDT
*** Bug 176358 has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 6 2018-06-23 07:25:15 PDT
*** Bug 177529 has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 7 2018-06-23 07:39:37 PDT
Comment on attachment 343431 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=343431&action=review Excellent > Source/WebCore/ChangeLog:11 > + length of the RSA key. The way we retrieve the MPI data means libgcrypt > + can ignore the high-bit zero values and leave us with a valid result > + that's shorter in length compared to the RSA key. For instance, if the Wow! > Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp:98 > + ASSERT(!(key.keySizeInBits() % 8)); I'd probably use ASSERT_WITH_SECURITY_IMPLICATION > Source/WebCore/crypto/gcrypt/GCryptUtilities.h:183 > +static inline std::optional<Vector<uint8_t>> mpiZeroPrefixedData(gcry_mpi_t paramMPI, size_t targetLength) Isn't it pretty long for an inline hint? How long does it have to get before you worry about cache locality? > Source/WebCore/crypto/gcrypt/GCryptUtilities.h:191 > + // Fill out the output buffer with zeros. Properly determine the zero prefix length, > + // and copy the MPI data into memory area following the prefix (if any). These are good comments. It's a difficult art, finding the right balance between too much information and not enough. OK, just felt you deserved a compliment here.
Zan Dobersek
Comment 8 2018-06-24 23:45:42 PDT
Comment on attachment 343431 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=343431&action=review >> Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp:98 >> + ASSERT(!(key.keySizeInBits() % 8)); > > I'd probably use ASSERT_WITH_SECURITY_IMPLICATION OK. >> Source/WebCore/crypto/gcrypt/GCryptUtilities.h:183 >> +static inline std::optional<Vector<uint8_t>> mpiZeroPrefixedData(gcry_mpi_t paramMPI, size_t targetLength) > > Isn't it pretty long for an inline hint? How long does it have to get before you worry about cache locality? I don't think this harms cache locality. `inline` specifier is primarily used to denote functions that are defined in headers and that should remain the same in definition between different source files. Nowadays it's completely up to the compiler whether it decides to inline the function or not. This I guess primarily depends on compilation options (optimization flags, debugging options, link-time optimizations). If the `inline` specifier is removed, the compiler already complains of the function being unused in whatever translation unit the header is included in. What I can do is move all the definitions into a standalone GCryptUtilities.cpp source file. >> Source/WebCore/crypto/gcrypt/GCryptUtilities.h:191 >> + // and copy the MPI data into memory area following the prefix (if any). > > These are good comments. It's a difficult art, finding the right balance between too much information and not enough. OK, just felt you deserved a compliment here. Thanks.
Zan Dobersek
Comment 9 2018-06-25 00:03:17 PDT
Zan Dobersek
Comment 10 2018-06-25 00:05:53 PDT
Comment on attachment 343488 [details] Patch Clearing flags on attachment: 343488 Committed r233138: <https://trac.webkit.org/changeset/233138>
Zan Dobersek
Comment 11 2018-06-25 00:05:57 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 12 2018-06-25 00:06:24 PDT
Zan Dobersek
Comment 13 2018-06-25 23:29:39 PDT
(In reply to Zan Dobersek from comment #8) > What I can do is move all the definitions into a standalone > GCryptUtilities.cpp source file. > Bug #187033.
Note You need to log in before you can comment on or make changes to this bug.