Bug 171213 - [GCrypt] CryptoKeyRSA: implement create(), keySizeInBits(), buildAlgorithm(), exportData()
Summary: [GCrypt] CryptoKeyRSA: implement create(), keySizeInBits(), buildAlgorithm(),...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on:
Blocks: 133122 171219 171220 171222
  Show dependency treegraph
 
Reported: 2017-04-24 00:56 PDT by Zan Dobersek
Modified: 2017-04-26 00:40 PDT (History)
2 users (show)

See Also:


Attachments
Patch (12.72 KB, patch)
2017-04-24 01:19 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch for landing (12.72 KB, patch)
2017-04-25 22:54 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2017-04-24 00:56:22 PDT
[GCrypt] CryptoKeyRSA: implement create(), keySizeInBits(), buildAlgorithm(), exportData()
Comment 1 Zan Dobersek 2017-04-24 01:19:34 PDT
Created attachment 307961 [details]
Patch
Comment 2 Michael Catanzaro 2017-04-24 06:53:04 PDT
Comment on attachment 307961 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307961&action=review

Looks good. Please wait for Jiewen before committing, as usual.

> Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:337
> +        // dp -- d mod (p - 1)

Thank you for the comments. ;)

> Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:341
> +            gcry_mpi_sub_ui(pm1MPI, pm1MPI, 1);

Do you think it would be safer to use an extra local variable for the result here (i.e. have both pMPI and pm1MPI locals)? I'm sure this is fine now and probably will be forever, but it could be disastrous if future versions of GCrypt can't handle the first parameter being the same as a subsequent parameter. That's probably paranoid though.
Comment 3 Zan Dobersek 2017-04-24 07:37:02 PDT
Comment on attachment 307961 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307961&action=review

>> Source/WebCore/crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:341
>> +            gcry_mpi_sub_ui(pm1MPI, pm1MPI, 1);
> 
> Do you think it would be safer to use an extra local variable for the result here (i.e. have both pMPI and pm1MPI locals)? I'm sure this is fine now and probably will be forever, but it could be disastrous if future versions of GCrypt can't handle the first parameter being the same as a subsequent parameter. That's probably paranoid though.

This makes sense, I think. We could definitely avoid any bug that might manifest in libgcrypt due to aliased pointers being passed to gcry_mpi_*() functions.

In this case, all this can be simplified into plain-allocating pm1MPI and then calling gcry_mpi_sub_ui(pm1MPI, pMP1, 1). I'll switch to that.
Comment 4 Zan Dobersek 2017-04-25 22:54:27 PDT
Created attachment 308219 [details]
Patch for landing
Comment 5 Zan Dobersek 2017-04-26 00:40:30 PDT
Comment on attachment 308219 [details]
Patch for landing

Clearing flags on attachment: 308219

Committed r215796: <http://trac.webkit.org/changeset/215796>
Comment 6 Zan Dobersek 2017-04-26 00:40:34 PDT
All reviewed patches have been landed.  Closing bug.