Changeset 286078 in webkit
- Timestamp:
- Nov 19, 2021, 2:19:52 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r286077 r286078 1 2021-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 1 14 2021-11-19 Myles C. Maxfield <mmaxfield@apple.com> 2 15 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h
r285763 r286078 127 127 // FIXME: <rdar://problem/71509485> Adds detailed NSError. 128 128 - (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)); 129 130 - (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)); 130 132 - (void)cancel; 131 133 -
trunk/Tools/ChangeLog
r286076 r286078 1 2021-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 1 15 2021-11-18 Jonathan Bedard <jbedard@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm
r285698 r286078 1899 1899 Util::run(&webAuthenticationPanelRan); 1900 1900 } 1901 1902 TEST(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 } 1901 1939 #endif 1902 1940 … … 2050 2088 } 2051 2089 2090 TEST(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 2052 2140 TEST(WebAuthenticationPanel, GetAssertionCrossPlatform) 2053 2141 {
Note:
See TracChangeset
for help on using the changeset viewer.