⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286078 in webkit


Ignore:
Timestamp:
Nov 19, 2021, 2:19:52 PM (5 years ago)
Author:
J Pascoe
Message:

[WebAuthn] Add headers for [_WKWebAuthenticationPanel makeCredentialWithClientDataHash] and [_WKWebAuthenticationPanel getAssertionWithClientDataHash]
https://bugs.webkit.org/show_bug.cgi?id=233371
<rdar://problem/85607248>
Source/WebKit:

Reviewed by Brent Fulgham.

These SPIs were added in https://bugs.webkit.org/show_bug.cgi?id=233216, but were not added to the header
file _WKWebAuthenticationPanel.h, this change adds them.

  • UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:

Tools:

Reviewed by Brent Fulgham.

Add tests for [_WKWebAuthenticationPanel makeCredentialWithClientDataHash] and
[_WKWebAuthenticationPanel getAssertionWithClientDataHash].

  • TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r286077 r286078  
     12021-11-19  J Pascoe  <j_pascoe@apple.com>
     2
     3        [WebAuthn] Add headers for [_WKWebAuthenticationPanel makeCredentialWithClientDataHash] and [_WKWebAuthenticationPanel getAssertionWithClientDataHash]
     4        https://bugs.webkit.org/show_bug.cgi?id=233371
     5        <rdar://problem/85607248>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        These SPIs were added in https://bugs.webkit.org/show_bug.cgi?id=233216, but were not added to the header
     10        file _WKWebAuthenticationPanel.h, this change adds them.
     11
     12        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
     13
    1142021-11-19  Myles C. Maxfield  <mmaxfield@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h

    r285763 r286078  
    127127// FIXME: <rdar://problem/71509485> Adds detailed NSError.
    128128- (void)makeCredentialWithChallenge:(NSData *)challenge origin:(NSString *)origin options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler WK_API_AVAILABLE(macos(12.0), ios(15.0));
     129- (void)makeCredentialWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    129130- (void)getAssertionWithChallenge:(NSData *)challenge origin:(NSString *)origin options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler WK_API_AVAILABLE(macos(12.0), ios(15.0));
     131- (void)getAssertionWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    130132- (void)cancel;
    131133
  • trunk/Tools/ChangeLog

    r286076 r286078  
     12021-11-19  J Pascoe  <j_pascoe@apple.com>
     2
     3        [WebAuthn] Add headers for [_WKWebAuthenticationPanel makeCredentialWithClientDataHash] and [_WKWebAuthenticationPanel getAssertionWithClientDataHash]
     4        https://bugs.webkit.org/show_bug.cgi?id=233371
     5        <rdar://problem/85607248>
     6       
     7        Reviewed by Brent Fulgham.
     8
     9        Add tests for [_WKWebAuthenticationPanel makeCredentialWithClientDataHash] and
     10        [_WKWebAuthenticationPanel getAssertionWithClientDataHash].
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152021-11-18  Jonathan Bedard  <jbedard@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

    r285698 r286078  
    18991899    Util::run(&webAuthenticationPanelRan);
    19001900}
     1901
     1902TEST(WebAuthenticationPanel, MakeCredentialLAClientDataHash)
     1903{
     1904    reset();
     1905
     1906    uint8_t identifier[] = { 0x01, 0x02, 0x03, 0x04 };
     1907    uint8_t hash[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
     1908    NSData *nsIdentifier = [NSData dataWithBytes:identifier length:sizeof(identifier)];
     1909    auto nsHash = adoptNS([[NSData alloc] initWithBytes:hash length:sizeof(hash)]);
     1910    auto parameters = adoptNS([[_WKPublicKeyCredentialParameters alloc] initWithAlgorithm:@-7]);
     1911
     1912    auto rp = adoptNS([[_WKPublicKeyCredentialRelyingPartyEntity alloc] initWithName:@"example.com"]);
     1913    [rp setIdentifier:@"example.com"];
     1914    auto user = adoptNS([[_WKPublicKeyCredentialUserEntity alloc] initWithName:@"jappleseed@example.com" identifier:nsIdentifier displayName:@"J Appleseed"]);
     1915    NSArray<_WKPublicKeyCredentialParameters *> *publicKeyCredentialParamaters = @[ parameters.get() ];
     1916    auto options = adoptNS([[_WKPublicKeyCredentialCreationOptions alloc] initWithRelyingParty:rp.get() user:user.get() publicKeyCredentialParamaters:publicKeyCredentialParamaters]);
     1917
     1918    auto panel = adoptNS([[_WKWebAuthenticationPanel alloc] init]);
     1919    [panel setMockConfiguration:@{ @"privateKeyBase64": testES256PrivateKeyBase64 }];
     1920    auto delegate = adoptNS([[TestWebAuthenticationPanelDelegate alloc] init]);
     1921    [panel setDelegate:delegate.get()];
     1922
     1923    [panel makeCredentialWithClientDataHash:nsHash.get() options:options.get() completionHandler:^(_WKAuthenticatorAttestationResponse *response, NSError *error) {
     1924        webAuthenticationPanelRan = true;
     1925        cleanUpKeychain("example.com");
     1926
     1927        EXPECT_TRUE(laContextRequested);
     1928        EXPECT_NULL(error);
     1929
     1930        EXPECT_NOT_NULL(response);
     1931        EXPECT_NULL(response.clientDataJSON);
     1932        // This is the sha1 hash of the public key of testES256PrivateKeyBase64.
     1933        EXPECT_WK_STREQ([response.rawId base64EncodedStringWithOptions:0], "SMSXHngF7hEOsElA73C3RY+8bR4=");
     1934        EXPECT_NULL(response.extensions);
     1935        EXPECT_WK_STREQ([response.attestationObject base64EncodedStringWithOptions:0], "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YViYo3mm9u6vuaVeN4wRgDTidR5oL6ufLTCrE9ISVYbOGUdFAAAAAAAAAAAAAAAAAAAAAAAAAAAAFEjElx54Be4RDrBJQO9wt0WPvG0epQECAyYgASFYIDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749IlggVBJPgqUIwfhWHJ91nb7UPH76c0+WFOzZKslPyyFse4g=");
     1936    }];
     1937    Util::run(&webAuthenticationPanelRan);
     1938}
    19011939#endif
    19021940
     
    20502088}
    20512089
     2090TEST(WebAuthenticationPanel, GetAssertionLAClientDataHash)
     2091{
     2092    reset();
     2093
     2094    ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "example.com", testUserEntityBundleBase64));
     2095
     2096    uint8_t hash[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
     2097    NSData *nsHash = [NSData dataWithBytes:hash length:sizeof(hash)];
     2098
     2099    auto options = adoptNS([[_WKPublicKeyCredentialRequestOptions alloc] init]);
     2100    [options setRelyingPartyIdentifier:@"example.com"];
     2101
     2102    auto panel = adoptNS([[_WKWebAuthenticationPanel alloc] init]);
     2103    [panel setMockConfiguration:@{ }];
     2104    auto delegate = adoptNS([[TestWebAuthenticationPanelDelegate alloc] init]);
     2105    [panel setDelegate:delegate.get()];
     2106
     2107    [panel getAssertionWithClientDataHash:nsHash options:options.get() completionHandler:^(_WKAuthenticatorAssertionResponse *response, NSError *error) {
     2108        webAuthenticationPanelRan = true;
     2109        cleanUpKeychain("example.com");
     2110
     2111        EXPECT_NULL(error);
     2112
     2113        EXPECT_NOT_NULL(response);
     2114        EXPECT_NULL(response.clientDataJSON);
     2115        // This is the sha1 hash of the public key of testES256PrivateKeyBase64.
     2116        EXPECT_WK_STREQ([response.rawId base64EncodedStringWithOptions:0], "SMSXHngF7hEOsElA73C3RY+8bR4=");
     2117        EXPECT_NULL(response.extensions);
     2118
     2119        // echo -n "example.com" | shasum -a 256 | xxd -r -p | base64
     2120        NSString *base64RPIDHash = @"o3mm9u6vuaVeN4wRgDTidR5oL6ufLTCrE9ISVYbOGUc=";
     2121        constexpr uint8_t additionalAuthenticatorData[] = {
     2122            0x05, // 'flags': UV=1, UP=1
     2123
     2124            // 32-bit 'signCount'
     2125            0x00,
     2126            0x00,
     2127            0x00,
     2128            0x00,
     2129        };
     2130        NSMutableData *expectedAuthenticatorData = [[NSMutableData alloc] initWithBase64EncodedString:base64RPIDHash options:0];
     2131        [expectedAuthenticatorData appendBytes:additionalAuthenticatorData length:sizeof(additionalAuthenticatorData)];
     2132
     2133        EXPECT_WK_STREQ([response.authenticatorData base64EncodedStringWithOptions:0], [expectedAuthenticatorData base64EncodedStringWithOptions:0]);
     2134        EXPECT_NOT_NULL(response.signature);
     2135        EXPECT_WK_STREQ([response.userHandle base64EncodedStringWithOptions:0], "AAECAwQFBgcICQ==");
     2136    }];
     2137    Util::run(&webAuthenticationPanelRan);
     2138}
     2139
    20522140TEST(WebAuthenticationPanel, GetAssertionCrossPlatform)
    20532141{
Note: See TracChangeset for help on using the changeset viewer.