Changeset 226862 in webkit


Ignore:
Timestamp:
Jan 11, 2018 9:29:01 PM (6 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthN] Import a CBOR coder from Chromium
https://bugs.webkit.org/show_bug.cgi?id=181522
<rdar://problem/36055729>

Reviewed by Brent Fulgham.

Source/WebCore:

This patch imports a CBOR coder including encoder and decoder from Chromium. CBOR encoder
is needed for WebAuthN to encode attestation object into binaries. When supporting extensions
in the future, CBOR encoder/decoder will be needed as well. Implementating and maintaining
a fully-fledged CBOR coder doesn't seem to align with WebKit's best interests. Therefore,
importing a most suitable third party implementation will be wise.

In this patch, it fully integrate the whole coder into our codebase. Those changes includes:

  1. Substitute data structures that enjoy a better WTF version.
  2. Replacing marcos.
  3. Implementating workarounds for some functionalities that we lack fundamental types' support.
  4. Changing the coding style to match ours.

This patch doesn't intend to improve the logic of the original codebase. Hence some of the
coding logic might not match what WebKit ususally has.

Here is a full list of Chromium changes that constructed this CBOR coder in chronological order:
6efcf495521d18d060027762f48bb292d6979136,
9eb43fd347890b4c6cf54c4bd7ec1bbb88e381e1,
31c85e74fd567772f18e0a41be468d04af721f21,
68672fdcad280a8ff69b91927d38d0eabf2c87f2,
0ca8667c0584fb21c0748ebd7468d32889759a07,
df763d790d7e45d70116bdefacbfd4f9faa8995e,
6d30c4a621c65314db63eb56e87c19ab75627b26,
50fe92953f4739f17a62303fedbf8db9234317c8,
47be22c3603424d1832d046a348ff3f982500288,
98a59e46948b2c71608926004fac8192b0ff2208,
07540c6d850ed6e0fa508d63c20a8ce96d751de6,
06ae32d640c8e4b86ea8914a80ee419ea16e56d8.

Covered by API tests.

  • Modules/webauthn/cbor/CBORBinary.h: Added.
  • Modules/webauthn/cbor/CBORReader.cpp: Added.

(cbor::CBORReader::CBORReader):
(cbor::CBORReader::~CBORReader):
(cbor::CBORReader::read):
(cbor::CBORReader::decodeCBOR):
(cbor::CBORReader::readVariadicLengthInteger):
(cbor::CBORReader::decodeValueToNegative):
(cbor::CBORReader::decodeValueToUnsigned):
(cbor::CBORReader::readSimpleValue):
(cbor::CBORReader::readString):
Workarounds applied.
(cbor::CBORReader::readBytes):
(cbor::CBORReader::readCBORArray):
(cbor::CBORReader::readCBORMap):
(cbor::CBORReader::canConsume):
(cbor::CBORReader::checkMinimalEncoding):
(cbor::CBORReader::checkExtraneousData):
(cbor::CBORReader::checkDuplicateKey):
(cbor::CBORReader::hasValidUTF8Format):
Workarounds applied.
(cbor::CBORReader::checkOutOfOrderKey):
(cbor::CBORReader::getErrorCode):
(cbor::CBORReader::errorCodeToString):

  • Modules/webauthn/cbor/CBORReader.h: Added.
  • Modules/webauthn/cbor/CBORValue.cpp: Added.

(cbor::CBORValue::CBORValue):
(cbor::CBORValue::operator=):
(cbor::CBORValue::~CBORValue):
(cbor::CBORValue::clone const):
(cbor::CBORValue::getInteger const):
(cbor::CBORValue::getUnsigned const):
(cbor::CBORValue::getNegative const):
(cbor::CBORValue::getString const):
(cbor::CBORValue::getByteString const):
(cbor::CBORValue::getArray const):
(cbor::CBORValue::getMap const):
(cbor::CBORValue::getSimpleValue const):
(cbor::CBORValue::internalMoveConstructFrom):
(cbor::CBORValue::internalCleanup):

  • Modules/webauthn/cbor/CBORValue.h: Added.
  • Modules/webauthn/cbor/CBORWriter.cpp: Added.

(cbor::CBORWriter::~CBORWriter):
(cbor::CBORWriter::write):
(cbor::CBORWriter::CBORWriter):
(cbor::CBORWriter::encodeCBOR):
Workarounds applied.
(cbor::CBORWriter::startItem):
(cbor::CBORWriter::setAdditionalInformation):
(cbor::CBORWriter::setUint):
(cbor::CBORWriter::getNumUintBytes):

  • Modules/webauthn/cbor/CBORWriter.h: Added.
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:

Tools:

This patch also imports all unit tests into our API tests to ensure all
workarounds and modification against the original codebase doesn't change
any original functionalities.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp: Added.

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebCore/CBORValueTest.cpp: Added.

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp: Added.

(TestWebKitAPI::eq):
Workarounds applied.
(TestWebKitAPI::TEST):

Location:
trunk
Files:
11 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r226842 r226862  
     12018-01-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Import a CBOR coder from Chromium
     4        https://bugs.webkit.org/show_bug.cgi?id=181522
     5        <rdar://problem/36055729>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        This patch imports a CBOR coder including encoder and decoder from Chromium. CBOR encoder
     10        is needed for WebAuthN to encode attestation object into binaries. When supporting extensions
     11        in the future, CBOR encoder/decoder will be needed as well. Implementating and maintaining
     12        a fully-fledged CBOR coder doesn't seem to align with WebKit's best interests. Therefore,
     13        importing a most suitable third party implementation will be wise.
     14
     15        In this patch, it fully integrate the whole coder into our codebase. Those changes includes:
     16            1. Substitute data structures that enjoy a better WTF version.
     17            2. Replacing marcos.
     18            3. Implementating workarounds for some functionalities that we lack fundamental types' support.
     19            4. Changing the coding style to match ours.
     20
     21        This patch doesn't intend to improve the logic of the original codebase. Hence some of the
     22        coding logic might not match what WebKit ususally has.
     23
     24        Here is a full list of Chromium changes that constructed this CBOR coder in chronological order:
     25        6efcf495521d18d060027762f48bb292d6979136,
     26        9eb43fd347890b4c6cf54c4bd7ec1bbb88e381e1,
     27        31c85e74fd567772f18e0a41be468d04af721f21,
     28        68672fdcad280a8ff69b91927d38d0eabf2c87f2,
     29        0ca8667c0584fb21c0748ebd7468d32889759a07,
     30        df763d790d7e45d70116bdefacbfd4f9faa8995e,
     31        6d30c4a621c65314db63eb56e87c19ab75627b26,
     32        50fe92953f4739f17a62303fedbf8db9234317c8,
     33        47be22c3603424d1832d046a348ff3f982500288,
     34        98a59e46948b2c71608926004fac8192b0ff2208,
     35        07540c6d850ed6e0fa508d63c20a8ce96d751de6,
     36        06ae32d640c8e4b86ea8914a80ee419ea16e56d8.
     37
     38        Covered by API tests.
     39
     40        * Modules/webauthn/cbor/CBORBinary.h: Added.
     41        * Modules/webauthn/cbor/CBORReader.cpp: Added.
     42        (cbor::CBORReader::CBORReader):
     43        (cbor::CBORReader::~CBORReader):
     44        (cbor::CBORReader::read):
     45        (cbor::CBORReader::decodeCBOR):
     46        (cbor::CBORReader::readVariadicLengthInteger):
     47        (cbor::CBORReader::decodeValueToNegative):
     48        (cbor::CBORReader::decodeValueToUnsigned):
     49        (cbor::CBORReader::readSimpleValue):
     50        (cbor::CBORReader::readString):
     51        Workarounds applied.
     52        (cbor::CBORReader::readBytes):
     53        (cbor::CBORReader::readCBORArray):
     54        (cbor::CBORReader::readCBORMap):
     55        (cbor::CBORReader::canConsume):
     56        (cbor::CBORReader::checkMinimalEncoding):
     57        (cbor::CBORReader::checkExtraneousData):
     58        (cbor::CBORReader::checkDuplicateKey):
     59        (cbor::CBORReader::hasValidUTF8Format):
     60        Workarounds applied.
     61        (cbor::CBORReader::checkOutOfOrderKey):
     62        (cbor::CBORReader::getErrorCode):
     63        (cbor::CBORReader::errorCodeToString):
     64        * Modules/webauthn/cbor/CBORReader.h: Added.
     65        * Modules/webauthn/cbor/CBORValue.cpp: Added.
     66        (cbor::CBORValue::CBORValue):
     67        (cbor::CBORValue::operator=):
     68        (cbor::CBORValue::~CBORValue):
     69        (cbor::CBORValue::clone const):
     70        (cbor::CBORValue::getInteger const):
     71        (cbor::CBORValue::getUnsigned const):
     72        (cbor::CBORValue::getNegative const):
     73        (cbor::CBORValue::getString const):
     74        (cbor::CBORValue::getByteString const):
     75        (cbor::CBORValue::getArray const):
     76        (cbor::CBORValue::getMap const):
     77        (cbor::CBORValue::getSimpleValue const):
     78        (cbor::CBORValue::internalMoveConstructFrom):
     79        (cbor::CBORValue::internalCleanup):
     80        * Modules/webauthn/cbor/CBORValue.h: Added.
     81        * Modules/webauthn/cbor/CBORWriter.cpp: Added.
     82        (cbor::CBORWriter::~CBORWriter):
     83        (cbor::CBORWriter::write):
     84        (cbor::CBORWriter::CBORWriter):
     85        (cbor::CBORWriter::encodeCBOR):
     86        Workarounds applied.
     87        (cbor::CBORWriter::startItem):
     88        (cbor::CBORWriter::setAdditionalInformation):
     89        (cbor::CBORWriter::setUint):
     90        (cbor::CBORWriter::getNumUintBytes):
     91        * Modules/webauthn/cbor/CBORWriter.h: Added.
     92        * Sources.txt:
     93        * WebCore.xcodeproj/project.pbxproj:
     94
    1952018-01-11  Chris Dumez  <cdumez@apple.com>
    296
  • trunk/Source/WebCore/Sources.txt

    r226778 r226862  
    246246
    247247Modules/webauthn/PublicKeyCredential.cpp
     248Modules/webauthn/cbor/CBORReader.cpp
     249Modules/webauthn/cbor/CBORValue.cpp
     250Modules/webauthn/cbor/CBORWriter.cpp
    248251
    249252Modules/webdatabase/ChangeVersionWrapper.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r226778 r226862  
    16421642                5721A98B1ECE57040081295A /* CryptoAlgorithmRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5721A9881ECE57040081295A /* CryptoAlgorithmRsaPssParams.h */; };
    16431643                572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
     1644                57303BB92006C6EE00355965 /* CBORValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BB42006C6ED00355965 /* CBORValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1645                57303BBA2006C6EE00355965 /* CBORWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BB52006C6ED00355965 /* CBORWriter.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1646                57303BBB2006C6EE00355965 /* CBORBinary.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BB62006C6ED00355965 /* CBORBinary.h */; };
     1647                57303BC12006E00C00355965 /* CBORReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BBF2006E00C00355965 /* CBORReader.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16441648                573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
    16451649                5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; };
     
    81708174                572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
    81718175                572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
     8176                57303BB42006C6ED00355965 /* CBORValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORValue.h; sourceTree = "<group>"; };
     8177                57303BB52006C6ED00355965 /* CBORWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORWriter.h; sourceTree = "<group>"; };
     8178                57303BB62006C6ED00355965 /* CBORBinary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORBinary.h; sourceTree = "<group>"; };
     8179                57303BB72006C6ED00355965 /* CBORValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORValue.cpp; sourceTree = "<group>"; };
     8180                57303BB82006C6ED00355965 /* CBORWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORWriter.cpp; sourceTree = "<group>"; };
     8181                57303BBE2006E00400355965 /* CBORReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORReader.cpp; sourceTree = "<group>"; };
     8182                57303BBF2006E00C00355965 /* CBORReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORReader.h; sourceTree = "<group>"; };
    81728183                573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; };
    81738184                5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmParameters.h; sourceTree = "<group>"; };
     
    1805918070                        sourceTree = "<group>";
    1806018071                };
     18072                57303BB32006C6ED00355965 /* cbor */ = {
     18073                        isa = PBXGroup;
     18074                        children = (
     18075                                57303BB62006C6ED00355965 /* CBORBinary.h */,
     18076                                57303BBE2006E00400355965 /* CBORReader.cpp */,
     18077                                57303BBF2006E00C00355965 /* CBORReader.h */,
     18078                                57303BB72006C6ED00355965 /* CBORValue.cpp */,
     18079                                57303BB42006C6ED00355965 /* CBORValue.h */,
     18080                                57303BB82006C6ED00355965 /* CBORWriter.cpp */,
     18081                                57303BB52006C6ED00355965 /* CBORWriter.h */,
     18082                        );
     18083                        path = cbor;
     18084                        sourceTree = "<group>";
     18085                };
    1806118086                57C7A6881E56946D00C67D71 /* credentialmanagement */ = {
    1806218087                        isa = PBXGroup;
     
    1809918124                        isa = PBXGroup;
    1810018125                        children = (
     18126                                57303BB32006C6ED00355965 /* cbor */,
    1810118127                                57D8462C1FEAF68F00CA3682 /* PublicKeyCredential.cpp */,
    1810218128                                57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */,
     
    2652526551                                07B7116F1D899E63009F0FFB /* CaptureDeviceManager.h in Headers */,
    2652626552                                CDC734151977896D0046BFC5 /* CARingBuffer.h in Headers */,
     26553                                57303BBB2006C6EE00355965 /* CBORBinary.h in Headers */,
     26554                                57303BC12006E00C00355965 /* CBORReader.h in Headers */,
     26555                                57303BB92006C6EE00355965 /* CBORValue.h in Headers */,
     26556                                57303BBA2006C6EE00355965 /* CBORWriter.h in Headers */,
    2652726557                                6550B69E099DF0270090D781 /* CDATASection.h in Headers */,
    2652826558                                CDF4B7161E00B7E500E235A2 /* CDM.h in Headers */,
  • trunk/Tools/ChangeLog

    r226841 r226862  
     12018-01-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Import a CBOR coder from Chromium
     4        https://bugs.webkit.org/show_bug.cgi?id=181522
     5        <rdar://problem/36055729>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        This patch also imports all unit tests into our API tests to ensure all
     10        workarounds and modification against the original codebase doesn't change
     11        any original functionalities.
     12
     13        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     14        * TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp: Added.
     15        (TestWebKitAPI::TEST):
     16        * TestWebKitAPI/Tests/WebCore/CBORValueTest.cpp: Added.
     17        (TestWebKitAPI::TEST):
     18        * TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp: Added.
     19        (TestWebKitAPI::eq):
     20        Workarounds applied.
     21        (TestWebKitAPI::TEST):
     22
    1232018-01-11  Jonathan Bedard  <jbedard@apple.com>
    224
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r226471 r226862  
    219219                5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */; };
    220220                571F7FD01F2961FB00946648 /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 571F7FCF1F2961E100946648 /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-wal */; };
     221                57303BC9200824D300355965 /* CBORValueTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BAC2006C56000355965 /* CBORValueTest.cpp */; };
     222                57303BCA20082C0100355965 /* CBORWriterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BAB2006C55400355965 /* CBORWriterTest.cpp */; };
     223                57303BCB2008376500355965 /* CBORReaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57303BC220071E2200355965 /* CBORReaderTest.cpp */; };
    221224                57599E211F07191900A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */; };
    222225                57599E271F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E241F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3 */; };
     
    13801383                5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL2.html; sourceTree = "<group>"; };
    13811384                571F7FCF1F2961E100946648 /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IndexedDBStructuredCloneBackwardCompatibility.sqlite3-wal"; sourceTree = "<group>"; };
     1385                57303BAB2006C55400355965 /* CBORWriterTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORWriterTest.cpp; sourceTree = "<group>"; };
     1386                57303BAC2006C56000355965 /* CBORValueTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORValueTest.cpp; sourceTree = "<group>"; };
     1387                57303BC220071E2200355965 /* CBORReaderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORReaderTest.cpp; sourceTree = "<group>"; };
    13821388                5735F0251F3A4EA6000EE801 /* TestWebKitAPI-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "TestWebKitAPI-iOS.entitlements"; sourceTree = "<group>"; };
    13831389                57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBStructuredCloneBackwardCompatibility.mm; sourceTree = "<group>"; };
     
    22042210                                93A720E518F1A0E800A848E1 /* CalculationValue.cpp */,
    22052211                                07C046C91E42573E007201E7 /* CARingBuffer.cpp */,
     2212                                57303BC220071E2200355965 /* CBORReaderTest.cpp */,
     2213                                57303BAC2006C56000355965 /* CBORValueTest.cpp */,
     2214                                57303BAB2006C55400355965 /* CBORWriterTest.cpp */,
    22062215                                7C3965051CDD74F90094DBB8 /* Color.cpp */,
    22072216                                1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */,
     
    33323341                                7CCE7EE71A411AE600447C4C /* CanHandleRequest.cpp in Sources */,
    33333342                                07C046CA1E4262A8007201E7 /* CARingBuffer.cpp in Sources */,
     3343                                57303BCB2008376500355965 /* CBORReaderTest.cpp in Sources */,
     3344                                57303BC9200824D300355965 /* CBORValueTest.cpp in Sources */,
     3345                                57303BCA20082C0100355965 /* CBORWriterTest.cpp in Sources */,
    33343346                                7CCE7EE61A411AE600447C4C /* CloseFromWithinCreatePage.cpp in Sources */,
    33353347                                7CCE7EB71A411A7E00447C4C /* CloseNewWindowInNavigationPolicyDelegate.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.