Bug 171213

Summary: [GCrypt] CryptoKeyRSA: implement create(), keySizeInBits(), buildAlgorithm(), exportData()
Product: WebKit Reporter: Zan Dobersek <zan>
Component: New BugsAssignee: Zan Dobersek <zan>
Status: RESOLVED FIXED    
Severity: Normal CC: jiewen_tan, mcatanzaro
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 133122, 171219, 171220, 171222    
Attachments:
Description Flags
Patch
none
Patch for landing none

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.