Commit Graph

79 Commits

Author SHA1 Message Date
Chris Peterson
210c7f9690 Bug 870698 - Part 9: Replace Assign(NS_LITERAL_STRING("")) with AssignLiteral(u""). r=erahm
The NS_LITERAL_STRING macro creates a temporary nsLiteralString to encapsulate the char16_t string literal and its length, but AssignLiteral() can determine the char16_t string literal's length at compile-time without nsLiteralString.

MozReview-Commit-ID: 6vgQiU8zN3o

--HG--
extra : rebase_source : 1b536b92ef43f610db057ace6f108620e8d8b4d5
extra : source : 336e21386d5eeb16f1c9893c29377f23b67cc4b0
2017-09-06 01:43:13 -07:00
Tim Taubert
09acff8375 Bug 1400668 - Fix Android builds on a CLOSED TREE by adding the key_handles arg to the stub PlatformManager r=bustage 2017-09-21 16:24:44 +02:00
Tim Taubert
3d449e1af3 Bug 1400668 - Process key handle exclusion list when registering a token r=jcj 2017-09-21 16:09:53 +02:00
Tim Taubert
a7712cd24a Bug 1400940 - Fix WebAuthn deadlock when cancelling a request on tab switch r=jcj
This should be an easy solution. We can't stop the sign() or register()
runloop from calling the callback, so we need the callback to simply return
early when the U2FHIDTokenManager shuts down.

Bug #: 1400940

Differential Revision: https://phabricator.services.mozilla.com/D67
2017-09-19 18:00:39 +02:00
Tim Taubert
0ab9d21338 Bug 1400559 - [u2f-hid-rs] rustfmt followup r=me 2017-09-19 16:45:07 +02:00
Tim Taubert
076af4a6e0 Bug 1400559 - Move runloop code into its own crate r=jcj
The runloop seems like a good candidate for moving into its own crate.

I wasn't sure whether we want it under the Mozilla org on GitHub, so I pushed
it to ttaubert/rust-runloop for a start. Moving the repository to mozilla/*
is easy, and we'd just need to bump the crate version with the updated
repository, if you think we should.

Bug #: 1400559

Differential Revision: https://phabricator.services.mozilla.com/D62

--HG--
rename : dom/webauthn/u2f-hid-rs/src/runloop.rs => third_party/rust/runloop/src/lib.rs
2017-09-19 15:46:55 +02:00
Sebastian Hengst
18a3ca206d merge mozilla-central to mozilla-inbound. r=merge a=merge 2017-09-19 11:15:12 +02:00
Ralph Giles
d0ed1d24c4 Bug 1400927 - Fix u2f-hid-rs cross-compilation on macOS r=jcj
One cannot use #[cfg(target_os)] checks in build.rs.
Build scripts can be used to generate code so the target
is set to the host platform when they are compiled.

Having this setting exported an unconditional link
depencency whenever the host was macOS, which broke
cross-compiling, in particular for fennec builds
targetting Android.

Instead, declare the IOKit dependency on the `extern`
block which imports the symbol inside macOS-specific
code. That way final link still works, but the extra
dependency is only enabled when appropriate for the
final target, like the other platform-dependent code.
2017-09-18 17:29:24 -07:00
Tim Taubert
cd9cddcc94 Bug 1400513 - u2f-hid-rs: fuzzers should use a deterministic cmd byte r=jcj
Summary: We're currently using the thread_rng to derive a cmd byte for the U2F protocol fuzzers. That of course should rather be derived deterministically from the input handed to the fuzzing target.

Bug #: 1400513

Differential Revision: https://phabricator.services.mozilla.com/D61
2017-09-17 20:07:32 +02:00
Tim Taubert
efb7d369f2 Bug 1400662 - Prefer the USB token if the softtoken is enabled as well r=jcj
Bug #: 1400662

Differential Revision: https://phabricator.services.mozilla.com/D63
2017-09-17 20:14:54 +02:00
J.C. Jones
8b00bef83f Bug 1400019 - Don't assert on illegal WebAuthn algo names r=keeler
The algorithm names provided to the WebAuthn methods have to either be a
string, or (potentially) a WebCrypto object. Right now we only work with
strings, but there's no good reason to assert that, we can just let the
action fail.

This patch removes the assert to help out the fuzzing team.

MozReview-Commit-ID: 9dc8m0a2gZK

--HG--
extra : rebase_source : 649a7f4928679405fe445ac533eee2cfccaedd25
2017-09-14 18:37:34 -07:00
J.C. Jones
f699a8f77b Bug 1400066 - Gracefully handle unsupported platforms for U2F HID support r=ttaubert
FreeBSD isn't currently support for FIDO U2F support, similar to Android, so
this patch [1] from Jan Beich <jbeich@FreeBSD.org> treats Android and FreeBSD
the same. With luck, someone will add in the platform support for both, soon!

[1] https://github.com/jcjones/u2f-hid-rs/pull/44

MozReview-Commit-ID: DU7Rco2NLb3

--HG--
rename : dom/webauthn/u2f-hid-rs/src/android/mod.rs => dom/webauthn/u2f-hid-rs/src/stub/mod.rs
2017-09-14 18:11:47 -07:00
J.C. Jones
29d179c6cf Bug 1400080 - Remove impossible telemetry test from WebAuthn r=ttaubert
Now that there are actual hardware devices, this test can't be run: it
depended on there being a deliberately-erroring implementation of WebAuthn
which would instantly reject promises. Fortunately, this test was really more
a test that telemetry scalars work properly than really the functionality
of WebAuthn.

Sadly, I don't see any way to re-enable this test without adding a new test-
only pref to the tree, which doesn't seem worth it for the telemetry.

So this patch removes the offending test completely which was backed out in
https://hg.mozilla.org/integration/mozilla-inbound/rev/c115eec567a6 .

MozReview-Commit-ID: LiLuQHbPU1z
2017-09-14 19:17:52 -07:00
Tim Taubert
62ee484a0d Bug 1388851 - Follow-up to disable parts of browser_webauthn_telemetry.js r=bustage 2017-09-14 23:12:13 +02:00
Tim Taubert
e773e24ae5 Bug 1388851 - Implement U2FHIDTokenManager r=jcj,qdot,keeler 2017-08-09 21:24:50 +02:00
Tim Taubert
dd24dc77e0 Bug 1388843 - Part 1: Copy u2f-hid-rs into dom/webauthn/ r=gerv,qdot 2017-08-09 21:16:49 +02:00
J.C. Jones
554acaea86 Bug 1245527 - Remove NSS U2F SoftToken. r=ttaubert, r=jed
The nsIU2FToken and its implementors are no longer needed; the soft token was
re-implemented into dom/webauthn/U2FSoftTokenManager.cpp during the WebAuthn
implementation. When the dom/u2f/ code changed to the implementation from
WebAuthn, the old synchronous version became dead code.

This patch removes the dead code.

MozReview-Commit-ID: 2yDD0tccgZr

--HG--
extra : rebase_source : 0f14d8de8f62599a41c13aa4d8fc9cdbc1fd79c7
2017-09-05 12:32:42 -07:00
J.C. Jones
2afc1ad18b Bug 1245527 - Rewrite U2F.cpp to use U2FTokenManager. r=keeler, r=ttaubert
- This patch reworks the U2F module to asynchronously call U2FManager,
  which in turn handles constructing and managing the U2FTokenManager
  via IPC.
- Add U2FTransaction{Parent,Child} implementations to mirror similar ones for
  WebAuthn
- Rewrite all tests to compensate for U2F executing asynchronously now.
  - Used async tasks, used the manifest parameters for scheme, and generally
    made these cleaner.
- The mochitest "pref =" functionality from Bug 1328830 doesn't support Android
  yet, causing breakage on Android. Rework the tests to go back to the old way
  of using iframes to test U2F.


NOTE TO REVIEWERS:
 Since this is huge, I recommend the following:

 keeler - please review U2F.cpp/h, the tests, and the security-prefs.js. Most
          of the U2F logic is still in U2F.cpp like before, but there's been
          some reworking of how it is called.

 ttaubert - please review U2FManager, the Transaction classes, build changes,
            and the changes to nsGlobalWindow. All of these should be very
            similar to the WebAuthn code it's patterned off.


MozReview-Commit-ID: C1ZN2ch66Rm

--HG--
extra : rebase_source : 5a2c52b0340c13f471af5040b998eb7e661b1981
2017-09-11 12:56:59 -07:00
J.C. Jones
334836b1e7 Bug 1245527 - Use PWebAuthnTransactionParent superclass for U2FTokenManager. r=keeler
This is a change to permit interacting with the U2FTokenManager from
the dom/U2F context in addition to the dom/WebAuthn one.

MozReview-Commit-ID: BvP5BY2wVYi

--HG--
extra : rebase_source : 0ca9cb1e72cb688b901484ec6bf2602d15131478
2017-08-25 18:37:17 -07:00
J.C. Jones
7b1ab1a9a0 Bug 1381126: Resume requiring WebAuthn RP ID to be a Domain String r=keeler
In Bug 1380421 we reverted some behavior that required Web Authentication's
RP ID to be domain string to permit it to be an origin, too, for interop
testing. That is no longer needed, so this patch resumes enforcement that
RP ID be a domain string.

It also adds a needed test that the RP ID hash is calculated correctly.

MozReview-Commit-ID: 8dDjzo5kQKP

--HG--
extra : rebase_source : 65cd7b9f3a6ecfc58805daf102f33966c9b19b98
2017-09-11 09:06:28 -07:00
J.C. Jones
b3996e4339 Bug 1384623 - WebAuthn [SameObject] attributes must cache those objects r=qdot
Peter points out [1] that I made assumptions that [SameObject] would handle
caching at the JS-layer, but it does not. This bug is to cache those objects [2]
on the heap, and add tests that they are indeed the same.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1382888#c6
[2] https://hg.mozilla.org/mozilla-central/rev/811510fdb51a

MozReview-Commit-ID: KQySNAOnyeE

--HG--
extra : rebase_source : 8422e9e8eafacc1071191a00d49bc85797571ebe
2017-07-26 10:03:17 -07:00
Tim Taubert
dbe7586a18 Bug 1380270 - Add dlopen() version of libudev-sys r=qdot,ted 2017-08-31 19:11:27 +02:00
Andrew McCreight
78807d8776 Bug 1391005 - Eliminate NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED. r=peterv
Replace it with NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION, because it
has been the same for a while.

MozReview-Commit-ID: 5agRGFyUry1

--HG--
extra : rebase_source : 5388c56b2f6905c6ef969150f0c5b77bf247624d
2017-08-29 16:02:48 -07:00
J.C. Jones
e5ca3874f4 Bug 1392366 - WebAuthn must use the WebCrypto SHA-256 algorithm identifier r=keeler
WD-05 changed the "hashAlg" parameter of the CollectedClientData definition
from using an internally-defined "S256" string to identify the sha256 digest
to the definition in WebCrypto [1]. This only appears once, hard-coded in
WebAuthn (since U2F only supports SHA-256), so we need to change that one
instance.

[1] https://www.w3.org/TR/WebCryptoAPI/#sha-registration

MozReview-Commit-ID: 8de2CIGBBGA

--HG--
extra : rebase_source : e54c0d1f3f9551be48c3a72444edf62c45c647c4
2017-08-21 12:06:15 -07:00
J.C. Jones
95d83ac876 Bug 1387820 - WebAuthn WD-05 Get Assertion Data Fix r=keeler
The WebAuthn WD-05 specification's Get Assertion method defines the returned
AuthenticatorAssertionResponse as providing ClientData, AuthenticatorData, and
the Signature from the Authenticator. Our implementation is incorrectly setting
AuthenticatorData and Signature:

AuthenticatorData as a structure is intended to mirror the structure from
the AuthenticatorData [1] section of the Attestation CBOR Object [2] in the
MakeCredential method, which we weren't doing _at all_. This is clarified in
the editor's draft of the specification, soon to be WD-06.

Signature for U2F Authenticators is defined as the "attestation signature", [3]
which is under-specified and we assumed would be the raw output from the U2F
Authenticator [4]. This should instead be the raw ANSI X9.62 signature with no
additional bytes. [5]

[1] https://www.w3.org/TR/2017/WD-webauthn-20170505/#sec-authenticator-data
[2] https://www.w3.org/TR/2017/WD-webauthn-20170505/#sec-attestation-data
[3] https://www.w3.org/TR/2017/WD-webauthn-20170505/#fido-u2f-attestation
[4] https://lists.w3.org/Archives/Public/public-webauthn/2017Aug/0078.html
[5] https://bugzilla.mozilla.org/show_bug.cgi?id=1387820#c4

MozReview-Commit-ID: DTIOILfS4pK

--HG--
extra : rebase_source : 996c10b2f0359b34f45cf370bb8483c2dc9d3b6e
2017-08-09 20:05:23 -07:00
Wes Kocher
cff9e9b197 Merge m-c to autoland, a=merge
MozReview-Commit-ID: 2YvHbITn9w3
2017-08-10 18:25:34 -07:00
Tim Taubert
72cca79ea8 Bug 1388853 - Fix timeouts in WebAuthnManager::MakeCredential() r=jcj 2017-08-09 21:26:49 +02:00
J.C. Jones
b491193ac3 Bug 1383799 - Cancel WebAuthn operations on tab-switch r=ttaubert
WebAuthn operations that are in-flight with authenticators must be cancelled
when switching tabs.

There's an Issue [1] opened with the WebAuthn spec for this already, but the
language is _not_ in spec. Still, it's necessary for security, spec or not.

This also matches how Chromium handles U2F operations during a tab switch.

[1] https://github.com/w3c/webauthn/issues/316

MozReview-Commit-ID: 6Qh9oC4pqys

--HG--
extra : rebase_source : ad1665b8140f74b1291f17994285e6146c4ec468
2017-08-04 12:34:18 -07:00
J.C. Jones
28cc1969ee Bug 1265472 - Add Telemetry to Web Authentication r=francois,keeler datareview=francois
This patch intends to obtain a 1) rough sense of the percentage of telemetry
population using Web Authentication over time, and 2) whether or not the
Authentication request was successful or errored out as a scalar. It also tracks
3) how long it takes for requests to complete as a histogram.

It counts Register (enrollment) and Sign (login) separately as we would
anticipate there being far, far more Sign uses than Register.

MozReview-Commit-ID: 8DFyKAG8XJw

--HG--
extra : rebase_source : 0c168b32b995ffffda804538d2b92009d4dc38c5
2017-08-09 12:22:48 -07:00
Tim Taubert
9dfa878543 Bug 1385313 - Use MozPromiseRequestHolders in U2FTokenManager r=jcj 2017-07-28 17:11:03 +02:00
Tim Taubert
0aee684c17 Bug 1385274 - Don't try to resolve WebAuthnManager::mPBackgroundCreationPromise twice r=jcj 2017-07-28 15:53:42 +02:00
J.C. Jones
b24d631e4c Bug 1385008: WebAuthn CollectedClientData.Origin must be RP ID r=keeler
The WebAuthn WD-05 version of the specification defines the Origin field [1]
of the CollectedClientData as being set to the RP ID [2][3].

Note there is some ambiguity in the specification, as [1] says
CollectedClientData.Origin is the document's origin, while the
algorithms [2] and [3] set it to RP ID.

I'm going to stick with the algorithm's definition for this patch; it's
simple to revert when we move to WD-06 (Bug 1384776).

[1] https://www.w3.org/TR/webauthn/#dom-collectedclientdata-origin
[2] https://www.w3.org/TR/webauthn/#createCredential
[3] https://www.w3.org/TR/webauthn/#getAssertion

MozReview-Commit-ID: LW918sIg5wH

--HG--
extra : rebase_source : 799f5fa8878614c45d0def07d01d6c1c0c6e9824
2017-07-27 10:27:53 -07:00
Carsten "Tomcat" Book
cad2e55095 Backed out changeset 674770e65a4f (bug 1265472) for memory leaks in browser_webauthn_telemetry.js 2017-07-26 07:56:38 +02:00
J.C. Jones
1b29ab6da2 Bug 1265472 - Add Telemetry to Web Authentication r=francois,keeler datareview=francois
This patch intends to obtain a 1) rough sense of the percentage of telemetry
population using Web Authentication over time, and 2) whether or not the
Authentication request was successful or errored out as a scalar. It also tracks
3) how long it takes for requests to complete as a histogram.

It counts Register (enrollment) and Sign (login) separately as we would
anticipate there being far, far more Sign uses than Register.

MozReview-Commit-ID: 8DFyKAG8XJw

--HG--
extra : rebase_source : c93eeac7a978a1d1c4b08ff1e18e2548b1045ced
2017-07-21 15:23:09 -07:00
J.C. Jones
860e263cc7 Bug 1384307 - Set WebAuthn PublicKeyCredential's "id" and "type" fields r=keeler
The Web Authentication PublicKeyCredential object has two fields currently
unpopulated which, to be spec-compliant, must be set. These fields duplicate
available data.

  [PublicKeyCredential.id] must be set to the base64url encoding with omitted
  padding of whatever data is in "rawId".

  [PublicKeyCredential.type] must be the literal "public-key".

MozReview-Commit-ID: L6wPYpZdD8A

--HG--
extra : rebase_source : 3ca83598b70f99f4d60f303d113e875046268669
2017-07-25 15:03:59 -07:00
J.C. Jones
7a3ee03404 Bug 1380529 - Only permit "ES256" as pubkey type for WebAuthn (3/3) r=ttaubert
Web Authentication uses JWK algorithm names (ES256) instead of WebCrypto names
(such as P-256). There are other JWK algorithm names, but our current U2F-backed
implementation only can support ES256 anyway, as that's all that FIDO U2F
devices understand. This patch limits us to the name ES256 for the "alg"
parameter.

MozReview-Commit-ID: 3V5DMzVzPad

--HG--
extra : rebase_source : 4fcf797ca0edc49f143333cc24aa51071cf719f5
2017-07-14 09:57:52 -07:00
J.C. Jones
3987ef311b Bug 1380529 - Use CBOR for the Create Credential WebAuthn call (2/3) r=ttaubert
The WebAuthn Create Credential method should encode its results using CBOR;
this patch changes to that format.

The CBOR formats for the U2F data are specified in [1][2]

The attestation data format is in [3]

The high-level layout is in [4]

[1] https://w3c.github.io/webauthn/#generating-an-attestation-object
[2] https://w3c.github.io/webauthn/#fido-u2f-attestation
[3] https://w3c.github.io/webauthn/#sec-attestation-data
[4] https://w3c.github.io/webauthn/#sctn-attestation

MozReview-Commit-ID: BYoFCJSxlLt

--HG--
extra : rebase_source : 190cb5f128659c7a947645abbc172c8aa39e4d40
2017-07-13 18:12:50 -07:00
J.C. Jones
91d5522630 Bug 1380529 - Add a CBOR library for WebAuthn (1/3) r=ttaubert
Web Authentication's WD-05 specification moves to using (CBOR) Concise Binary
Object Representation to transmit the binary data... most of it. This lands a
subset of the Apache 2-licensed "CBOR C++" serialization library [1] into
webauthn's path.

It does not add any code to use this library; see patch 2/3.

[1] https://github.com/naphaso/cbor-cpp/

MozReview-Commit-ID: Ktj9TgdqElk

--HG--
extra : rebase_source : e36c956ef62be3ea1a3b6cbc8e3d6df2626c15b1
2017-07-13 18:12:57 -07:00
Wes Kocher
ee45f814bb Merge m-c to autoland, a=merge
MozReview-Commit-ID: GOb2bgdUd36
2017-07-14 17:27:36 -07:00
Tim Taubert
4d50b6bd73 Bug 1380954 - Forward WebAuthnTransactionInfo::TimeoutMS() to U2F*TokenManagers r=jcj
The U2FSoftTokenManager is a synchronous implementation and thus didn't need a
timeout so far. We need it for the U2FHIDTokenManager though to let user
interaction timeout properly.

Thus, add a timeout argument to the methods required by the U2FTokenTransport
interface and forward that to the token manager implementations.
2017-07-14 19:27:53 +02:00
J.C. Jones
de0d023921 Bug 1380421 - Update test to handle origin RP IDs, too (2/2) r=keeler
This adjusts tests to also check origin-based RP IDs, for interop
purposes. When we officially move up to WD-06, we'll want to remove these.


MozReview-Commit-ID: FJRg7vxZIcN

--HG--
extra : rebase_source : 6b89ef1ec5f8f6312bc00740b171540dd2a111cf
2017-07-14 13:49:45 -07:00
J.C. Jones
b7eeb68241 Bug 1380421 - Handle URIs for RP IDs (1/2) r=keeler
A recent fixup commit [1] changed "RP ID" fields in WebAuthn to be domain
strings rather than origins, which matches the current editor's draft of
Web Authentication. Unfortunately, this is contrary to the interop WD-05,
which requires they be origins.

We should be tolerant of origins for now, and in the follow-on Bug 1381126
we'll remove this tolerance once we get past initial WD-05 interop.

[1] https://hg.mozilla.org/mozilla-central/rev/e173fd86d931

MozReview-Commit-ID: Cz2KaHvOIHz

--HG--
extra : rebase_source : eafac0cbab324c566a7ae64004f85258ca3ba805
2017-07-14 13:44:00 -07:00
Tim Taubert
aac46d1b3e Bug 1379580 - U2FTokenTransport promises should resolve to U2F data buffers r=qDot 2017-07-11 11:09:08 +02:00
J.C. Jones
8440e22c50 Bug 1329764 - Call IsRegistrableDomainSuffixOfOrEqualTo for WebAuthn r=keeler
nsHTMLDocument included IsRegistrableDomainSuffixOfOrEqualTo() to facilitate
some use cases in Web Authentication, and this patch adds support to our
implementation. The general idea is to permit relaxing some of the same-origin
policy for single-sign-on type approaches, while restricting other uses. [1]

[1] https://w3c.github.io/webauthn/#rp-id

MozReview-Commit-ID: BP74OYvcwBJ

--HG--
extra : rebase_source : 94b62f9063de129dc30c4457578b50088a3c92e0
2017-07-07 13:32:31 -07:00
J.C. Jones
ce493e08c1 Bug 1329764 - WebAuthn's RP IDs must be domain strings r=keeler
The spec for WebAuthn defines "RP ID" as a "valid domain string" [1], whereas we
were using an origin string (with the scheme and whatnot). This patch corrects
the default rpId strings (when not overriden) to be domain strings.

[1] https://w3c.github.io/webauthn/#rp-id

MozReview-Commit-ID: 2p1cEQDa2FV

--HG--
extra : rebase_source : 8be13b8e88abb409e15c1bf9142f18d786699504
2017-07-07 13:30:57 -07:00
Tim Taubert
daf6324bec Bug 1378762 - Remove 'aSignature' argument from U2FTokenTransport::Register() r=qDot,jcj 2017-07-06 14:44:56 +02:00
Tim Taubert
c3833cf06b Bug 1375847 - Add skeleton U2FHIDTokenManager r=qDot
This patch adds a skeleton U2FHIDTokenManager that returns
NS_ERROR_NOT_IMPLEMENTED for ::Register() and ::Sign().

This will help test calling into the Rust library and make it easier to
implement the full USB HID transport.
2017-06-23 15:48:50 +02:00
Tim Taubert
fa3483fd1d Bug 1375828 - U2FTokenTransport::Register() and ::Sign() should return promises r=qDot 2017-06-23 12:36:32 +02:00
Bill McCloskey
f115503a0b Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-26 14:19:58 -07:00
Tim Taubert
907f818103 Bug 1375744 - Add U2FTokenTransport::Cancel() to abort requests on HW devices r=qDot
This patch adds a Cancel() method to the U2FTokenTransport interface so that
we can forward request cancellations to the actual token manager implementation.
The current softtoken doesn't need that as it processes API calls synchronously,
USB HID tokens however need a cancellation mechanism.

The SendRequestCancel() call has been removed from WebAuthnManager::Cancel() as
we're currently only calling this method either when the chrome process
cancels the request (and then we don't need to send it back again) or the
content process fails to process the data after a request was fulfilled and
thus there's nothing to cancel. We will touch this again later when the UI
cancels requests on tab switch and similar user actions.
2017-06-23 21:04:38 +02:00