Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/resources/cryptotoken/gnubby.js

Issue 495033002: Tolerate that CMD_SYNC does not exist (per U2F spec). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Provides a client view of a gnubby, aka USB security key. 6 * @fileoverview Provides a client view of a gnubby, aka USB security key.
7 */ 7 */
8 'use strict'; 8 'use strict';
9 9
10 /** 10 /**
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 (f.length == 7 || /* fw pre-0.2.1 bug: does not echo sentinel */ 516 (f.length == 7 || /* fw pre-0.2.1 bug: does not echo sentinel */
517 f[7] == self.synccnt)); 517 f[7] == self.synccnt));
518 } 518 }
519 519
520 function syncCompletionAction(rc, opt_frame) { 520 function syncCompletionAction(rc, opt_frame) {
521 if (rc) console.warn(UTIL_fmt('sync failed: ' + rc)); 521 if (rc) console.warn(UTIL_fmt('sync failed: ' + rc));
522 returnValue(rc); 522 returnValue(rc);
523 } 523 }
524 524
525 function sendInitSentinel() { 525 function sendInitSentinel() {
526 var cid = Gnubby.BROADCAST_CID; 526 var cid = self.cid;
527 if (cid == Gnubby.defaultChannelId_(self.gnubbyInstance, self.which)) {
528 cid = Gnubby.BROADCAST_CID;
529 }
527 var cmd = GnubbyDevice.CMD_INIT; 530 var cmd = GnubbyDevice.CMD_INIT;
528 self.dev.queueCommand(cid, cmd, nonce); 531 self.dev.queueCommand(cid, cmd, nonce);
529 } 532 }
530 533
531 function initSentinelEquals(f) { 534 function initSentinelEquals(f) {
532 return (f[4] == GnubbyDevice.CMD_INIT && 535 return (f[4] == GnubbyDevice.CMD_INIT &&
533 f.length >= nonce.length + 7 && 536 f.length >= nonce.length + 7 &&
534 UTIL_equalArrays(f.subarray(7, nonce.length + 7), nonce)); 537 UTIL_equalArrays(f.subarray(7, nonce.length + 7), nonce));
535 } 538 }
536 539
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 sentinelEquals = initSentinelEquals; 624 sentinelEquals = initSentinelEquals;
622 completionAction = initCompletionAction; 625 completionAction = initCompletionAction;
623 } 626 }
624 627
625 function setSync() { 628 function setSync() {
626 sendSentinel = sendSyncSentinel; 629 sendSentinel = sendSyncSentinel;
627 sentinelEquals = syncSentinelEquals; 630 sentinelEquals = syncSentinelEquals;
628 completionAction = syncCompletionAction; 631 completionAction = syncCompletionAction;
629 } 632 }
630 633
631 if (Gnubby.gnubbies_.isSharedAccess(this.which) && 634 if (Gnubby.gnubbies_.isSharedAccess(this.which)) {
632 this.cid == Gnubby.defaultChannelId_(this.gnubbyInstance, this.which)) {
633 setInit(); 635 setInit();
634 } else { 636 } else {
635 setSync(); 637 setSync();
636 } 638 }
637 timeoutLoop(); 639 timeoutLoop();
638 }; 640 };
639 641
640 /** Short timeout value in seconds */ 642 /** Short timeout value in seconds */
641 Gnubby.SHORT_TIMEOUT = 1; 643 Gnubby.SHORT_TIMEOUT = 1;
642 /** Normal timeout value in seconds */ 644 /** Normal timeout value in seconds */
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } 786 }
785 } 787 }
786 // Warn on errors other than waiting for touch, wrong data, and 788 // Warn on errors other than waiting for touch, wrong data, and
787 // unrecognized command. 789 // unrecognized command.
788 if (rc != 0x6985 && rc != 0x6a80 && rc != 0x6d00) { 790 if (rc != 0x6985 && rc != 0x6a80 && rc != 0x6d00) {
789 console.warn(UTIL_fmt('apduReply_ fail: ' + rc.toString(16))); 791 console.warn(UTIL_fmt('apduReply_ fail: ' + rc.toString(16)));
790 } 792 }
791 cb(rc); 793 cb(rc);
792 }); 794 });
793 }; 795 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698