Commit b5a34152 authored by Matthew Braithwaite's avatar Matthew Braithwaite Committed by Commit Bot

Update cryptotoken to 0.9.71.

Most changes are cosmetic.

Bug: 780299
Change-Id: I346ec1b6bd11ef20ef8018989b51c9c5842c4dee
Reviewed-on: https://chromium-review.googlesource.com/701468
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: default avatarAdam Langley <agl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521217}
parent 0eb57d23
...@@ -44,6 +44,12 @@ DeviceStatusCodes.INVALID_DATA_STATUS = 0x6984; ...@@ -44,6 +44,12 @@ DeviceStatusCodes.INVALID_DATA_STATUS = 0x6984;
*/ */
DeviceStatusCodes.WRONG_DATA_STATUS = 0x6a80; DeviceStatusCodes.WRONG_DATA_STATUS = 0x6a80;
/**
* Device operation file not found status.
* @const
*/
DeviceStatusCodes.FILE_NOT_FOUND_STATUS = 0x6a82;
/** /**
* Device operation timeout status. * Device operation timeout status.
* @const * @const
......
...@@ -539,7 +539,7 @@ Enroller.prototype.notifyError_ = function(error) { ...@@ -539,7 +539,7 @@ Enroller.prototype.notifyError_ = function(error) {
* Notifies the caller of success with the provided response data. * Notifies the caller of success with the provided response data.
* @param {string} u2fVersion Protocol version * @param {string} u2fVersion Protocol version
* @param {string} info Response data * @param {string} info Response data
* @param {string|undefined} opt_browserData Browser data used * @param {string=} opt_browserData Browser data used
* @private * @private
*/ */
Enroller.prototype.notifySuccess_ = function( Enroller.prototype.notifySuccess_ = function(
...@@ -562,6 +562,12 @@ Enroller.prototype.helperComplete_ = function(reply) { ...@@ -562,6 +562,12 @@ Enroller.prototype.helperComplete_ = function(reply) {
console.log(UTIL_fmt( console.log(UTIL_fmt(
'helper reported ' + reply.code.toString(16) + ', returning ' + 'helper reported ' + reply.code.toString(16) + ', returning ' +
reportedError.errorCode)); reportedError.errorCode));
// Log non-expected reply codes if we have url to send them.
if (reportedError.errorCode == ErrorCodes.OTHER_ERROR) {
var logMsg = 'log=u2fenroll&rc=' + reply.code.toString(16);
if (this.logMsgUrl_)
logMessage(logMsg, this.logMsgUrl_);
}
this.notifyError_(reportedError); this.notifyError_(reportedError);
} else { } else {
console.log(UTIL_fmt('Gnubby enrollment succeeded!!!!!')); console.log(UTIL_fmt('Gnubby enrollment succeeded!!!!!'));
......
...@@ -170,7 +170,7 @@ Gnubbies.prototype.enumerate = function(cb, opt_type) { ...@@ -170,7 +170,7 @@ Gnubbies.prototype.enumerate = function(cb, opt_type) {
} }
console.log(UTIL_fmt('Enumerated ' + devs.length + ' gnubbies')); console.log(UTIL_fmt('Enumerated ' + devs.length + ' gnubbies'));
console.log(devs); console.log(UTIL_fmt(JSON.stringify(devs)));
var presentDevs = {}; var presentDevs = {};
var deviceIds = []; var deviceIds = [];
......
...@@ -66,10 +66,10 @@ Gnubby.prototype.cancelOpen = function() { ...@@ -66,10 +66,10 @@ Gnubby.prototype.cancelOpen = function() {
/** /**
* Opens the gnubby with the given index, or the first found gnubby if no * Opens the gnubby with the given index, or the first found gnubby if no
* index is specified. * index is specified.
* @param {GnubbyDeviceId} which The device to open. If null, the first * @param {?GnubbyDeviceId} which The device to open. If null, the first
* gnubby found is opened. * gnubby found is opened.
* @param {GnubbyEnumerationTypes=} opt_type Which type of device to enumerate. * @param {GnubbyEnumerationTypes=} opt_type Which type of device to enumerate.
* @param {function(number)|undefined} opt_cb Called with result of opening the * @param {function(number)=} opt_cb Called with result of opening the
* gnubby. * gnubby.
* @param {string=} opt_caller Identifier for the caller. * @param {string=} opt_caller Identifier for the caller.
*/ */
...@@ -113,22 +113,23 @@ Gnubby.prototype.open = function(which, opt_type, opt_cb, opt_caller) { ...@@ -113,22 +113,23 @@ Gnubby.prototype.open = function(which, opt_type, opt_cb, opt_caller) {
if (self.closeHook_) { if (self.closeHook_) {
self.dev.setDestroyHook(self.closeHook_); self.dev.setDestroyHook(self.closeHook_);
} }
cb(rc); cb.call(self, rc);
}); });
} }
if (which) { if (which) {
setCid(which); setCid(which);
self.which = which; self.which = which;
Gnubby.gnubbies_.addClient(which, self, function(rc, device) { Gnubby.gnubbies_.addClient(
if (!rc) { /** @type {GnubbyDeviceId} */ (which), self, function(rc, device) {
self.dev = device; if (!rc) {
if (self.closeHook_) { self.dev = device;
self.dev.setDestroyHook(self.closeHook_); if (self.closeHook_) {
} self.dev.setDestroyHook(self.closeHook_);
} }
cb(rc); }
}); cb.call(self, rc);
});
} else { } else {
Gnubby.gnubbies_.enumerate(enumerated, opt_type); Gnubby.gnubbies_.enumerate(enumerated, opt_type);
} }
...@@ -139,7 +140,7 @@ Gnubby.prototype.open = function(which, opt_type, opt_cb, opt_caller) { ...@@ -139,7 +140,7 @@ Gnubby.prototype.open = function(which, opt_type, opt_cb, opt_caller) {
* collide within this application, but may when others simultaneously access * collide within this application, but may when others simultaneously access
* the device. * the device.
* @param {number} gnubbyInstance An instance identifier for a gnubby. * @param {number} gnubbyInstance An instance identifier for a gnubby.
* @param {GnubbyDeviceId} which The device identifer for the gnubby device. * @param {GnubbyDeviceId} which The device identifier for the gnubby device.
* @return {number} The channel id. * @return {number} The channel id.
* @private * @private
*/ */
...@@ -497,9 +498,8 @@ Gnubby.prototype.write_ = function(cmd, data) { ...@@ -497,9 +498,8 @@ Gnubby.prototype.write_ = function(cmd, data) {
* @param {ArrayBuffer|Uint8Array} data Command data * @param {ArrayBuffer|Uint8Array} data Command data
* @param {number} timeout Timeout in seconds. * @param {number} timeout Timeout in seconds.
* @param {function(number, ArrayBuffer=)} cb Callback * @param {function(number, ArrayBuffer=)} cb Callback
* @private
*/ */
Gnubby.prototype.exchange_ = function(cmd, data, timeout, cb) { Gnubby.prototype.exchange = function(cmd, data, timeout, cb) {
var busyWait = new CountdownTimer(Gnubby.SYS_TIMER_, this.busyMillis); var busyWait = new CountdownTimer(Gnubby.SYS_TIMER_, this.busyMillis);
var self = this; var self = this;
...@@ -742,7 +742,7 @@ Gnubby.prototype.blink = function(data, cb) { ...@@ -742,7 +742,7 @@ Gnubby.prototype.blink = function(data, cb) {
var d = new Uint8Array([data]); var d = new Uint8Array([data]);
data = d.buffer; data = d.buffer;
} }
this.exchange_(GnubbyDevice.CMD_PROMPT, data, Gnubby.NORMAL_TIMEOUT, cb); this.exchange(GnubbyDevice.CMD_PROMPT, data, Gnubby.NORMAL_TIMEOUT, cb);
}; };
/** Lock the gnubby /** Lock the gnubby
...@@ -756,7 +756,7 @@ Gnubby.prototype.lock = function(data, cb) { ...@@ -756,7 +756,7 @@ Gnubby.prototype.lock = function(data, cb) {
var d = new Uint8Array([data]); var d = new Uint8Array([data]);
data = d.buffer; data = d.buffer;
} }
this.exchange_(GnubbyDevice.CMD_LOCK, data, Gnubby.NORMAL_TIMEOUT, cb); this.exchange(GnubbyDevice.CMD_LOCK, data, Gnubby.NORMAL_TIMEOUT, cb);
}; };
/** Unlock the gnubby /** Unlock the gnubby
...@@ -766,7 +766,7 @@ Gnubby.prototype.unlock = function(cb) { ...@@ -766,7 +766,7 @@ Gnubby.prototype.unlock = function(cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
var data = new Uint8Array([0]); var data = new Uint8Array([0]);
this.exchange_(GnubbyDevice.CMD_LOCK, data.buffer, Gnubby.NORMAL_TIMEOUT, cb); this.exchange(GnubbyDevice.CMD_LOCK, data.buffer, Gnubby.NORMAL_TIMEOUT, cb);
}; };
/** Request system information data. /** Request system information data.
...@@ -775,7 +775,7 @@ Gnubby.prototype.unlock = function(cb) { ...@@ -775,7 +775,7 @@ Gnubby.prototype.unlock = function(cb) {
Gnubby.prototype.sysinfo = function(cb) { Gnubby.prototype.sysinfo = function(cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
this.exchange_( this.exchange(
GnubbyDevice.CMD_SYSINFO, new ArrayBuffer(0), Gnubby.NORMAL_TIMEOUT, cb); GnubbyDevice.CMD_SYSINFO, new ArrayBuffer(0), Gnubby.NORMAL_TIMEOUT, cb);
}; };
...@@ -785,7 +785,7 @@ Gnubby.prototype.sysinfo = function(cb) { ...@@ -785,7 +785,7 @@ Gnubby.prototype.sysinfo = function(cb) {
Gnubby.prototype.wink = function(cb) { Gnubby.prototype.wink = function(cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
this.exchange_( this.exchange(
GnubbyDevice.CMD_WINK, new ArrayBuffer(0), Gnubby.NORMAL_TIMEOUT, cb); GnubbyDevice.CMD_WINK, new ArrayBuffer(0), Gnubby.NORMAL_TIMEOUT, cb);
}; };
...@@ -796,7 +796,7 @@ Gnubby.prototype.wink = function(cb) { ...@@ -796,7 +796,7 @@ Gnubby.prototype.wink = function(cb) {
Gnubby.prototype.dfu = function(data, cb) { Gnubby.prototype.dfu = function(data, cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
this.exchange_(GnubbyDevice.CMD_DFU, data, Gnubby.NORMAL_TIMEOUT, cb); this.exchange(GnubbyDevice.CMD_DFU, data, Gnubby.NORMAL_TIMEOUT, cb);
}; };
/** Ping the gnubby /** Ping the gnubby
...@@ -811,7 +811,7 @@ Gnubby.prototype.ping = function(data, cb) { ...@@ -811,7 +811,7 @@ Gnubby.prototype.ping = function(data, cb) {
window.crypto.getRandomValues(d); window.crypto.getRandomValues(d);
data = d.buffer; data = d.buffer;
} }
this.exchange_(GnubbyDevice.CMD_PING, data, Gnubby.NORMAL_TIMEOUT, cb); this.exchange(GnubbyDevice.CMD_PING, data, Gnubby.NORMAL_TIMEOUT, cb);
}; };
/** Send a raw APDU command /** Send a raw APDU command
...@@ -821,7 +821,7 @@ Gnubby.prototype.ping = function(data, cb) { ...@@ -821,7 +821,7 @@ Gnubby.prototype.ping = function(data, cb) {
Gnubby.prototype.apdu = function(data, cb) { Gnubby.prototype.apdu = function(data, cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
this.exchange_(GnubbyDevice.CMD_APDU, data, Gnubby.MAX_TIMEOUT, cb); this.exchange(GnubbyDevice.CMD_APDU, data, Gnubby.MAX_TIMEOUT, cb);
}; };
/** Reset gnubby /** Reset gnubby
...@@ -830,7 +830,7 @@ Gnubby.prototype.apdu = function(data, cb) { ...@@ -830,7 +830,7 @@ Gnubby.prototype.apdu = function(data, cb) {
Gnubby.prototype.reset = function(cb) { Gnubby.prototype.reset = function(cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
this.exchange_( this.exchange(
GnubbyDevice.CMD_ATR, new ArrayBuffer(0), Gnubby.MAX_TIMEOUT, cb); GnubbyDevice.CMD_ATR, new ArrayBuffer(0), Gnubby.MAX_TIMEOUT, cb);
}; };
...@@ -845,7 +845,7 @@ Gnubby.prototype.usb_test = function(args, cb) { ...@@ -845,7 +845,7 @@ Gnubby.prototype.usb_test = function(args, cb) {
if (!cb) if (!cb)
cb = Gnubby.defaultCallback; cb = Gnubby.defaultCallback;
var u8 = new Uint8Array(args); var u8 = new Uint8Array(args);
this.exchange_( this.exchange(
GnubbyDevice.CMD_USB_TEST, u8.buffer, Gnubby.NORMAL_TIMEOUT, cb); GnubbyDevice.CMD_USB_TEST, u8.buffer, Gnubby.NORMAL_TIMEOUT, cb);
}; };
......
...@@ -50,3 +50,13 @@ GnubbyFactory.prototype.openGnubby = function( ...@@ -50,3 +50,13 @@ GnubbyFactory.prototype.openGnubby = function(
*/ */
GnubbyFactory.prototype.notEnrolledPrerequisiteCheck = function( GnubbyFactory.prototype.notEnrolledPrerequisiteCheck = function(
gnubby, appIdHash, cb) {}; gnubby, appIdHash, cb) {};
/**
* Called immediately after enrolling the gnubby to perform necessary actions.
* @param {Gnubby} gnubby The just-enrolled gnubby.
* @param {string} appIdHash The base64-encoded hash of the app id for which
* the gnubby was enrolled.
* @param {FactoryOpenCallback} cb Called with the result of the action.
* (A non-zero status indicates failure.)
*/
GnubbyFactory.prototype.postEnrollAction = function(gnubby, appIdHash, cb) {};
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* @param {string=} opt_logMsgUrl the url to post log messages to. * @param {string=} opt_logMsgUrl the url to post log messages to.
*/ */
function logMessage(logMsg, opt_logMsgUrl) { function logMessage(logMsg, opt_logMsgUrl) {
console.log(UTIL_fmt('logMessage("' + logMsg + '")')); console.warn(UTIL_fmt('logMessage("' + logMsg + '")'));
if (!opt_logMsgUrl) { if (!opt_logMsgUrl) {
return; return;
......
{ {
"name": "CryptoTokenExtension", "name": "CryptoTokenExtension",
"description": "CryptoToken Component Extension", "description": "CryptoToken Component Extension",
"version": "0.9.46", "version": "0.9.71",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7zRobvA+AVlvNqkHSSVhh1sEWsHSqz4oR/XptkDe/Cz3+gW9ZGumZ20NCHjaac8j1iiesdigp8B1LJsd/2WWv2Dbnto4f8GrQ5MVphKyQ9WJHwejEHN2K4vzrTcwaXqv5BSTXwxlxS/mXCmXskTfryKTLuYrcHEWK8fCHb+0gvr8b/kvsi75A1aMmb6nUnFJvETmCkOCPNX5CHTdy634Ts/x0fLhRuPlahk63rdf7agxQv5viVjQFk+tbgv6aa9kdSd11Js/RZ9yZjrFgHOBWgP4jTBqud4+HUglrzu8qynFipyNRLCZsaxhm+NItTyNgesxLdxZcwOz56KD1Q4IQIDAQAB", "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7zRobvA+AVlvNqkHSSVhh1sEWsHSqz4oR/XptkDe/Cz3+gW9ZGumZ20NCHjaac8j1iiesdigp8B1LJsd/2WWv2Dbnto4f8GrQ5MVphKyQ9WJHwejEHN2K4vzrTcwaXqv5BSTXwxlxS/mXCmXskTfryKTLuYrcHEWK8fCHb+0gvr8b/kvsi75A1aMmb6nUnFJvETmCkOCPNX5CHTdy634Ts/x0fLhRuPlahk63rdf7agxQv5viVjQFk+tbgv6aa9kdSd11Js/RZ9yZjrFgHOBWgP4jTBqud4+HUglrzu8qynFipyNRLCZsaxhm+NItTyNgesxLdxZcwOz56KD1Q4IQIDAQAB",
"manifest_version": 2, "manifest_version": 2,
"permissions": [ "permissions": [
......
...@@ -52,7 +52,7 @@ function MultipleGnubbySigner( ...@@ -52,7 +52,7 @@ function MultipleGnubbySigner(
/** @private {string|undefined} */ /** @private {string|undefined} */
this.logMsgUrl_ = opt_logMsgUrl; this.logMsgUrl_ = opt_logMsgUrl;
/** @private {Array<SignHelperChallenge>} */ /** @private {Array<DecodedSignHelperChallenge>} */
this.challenges_ = []; this.challenges_ = [];
/** @private {boolean} */ /** @private {boolean} */
this.challengesSet_ = false; this.challengesSet_ = false;
...@@ -107,12 +107,12 @@ MultipleGnubbySigner.prototype.doSign = function(challenges) { ...@@ -107,12 +107,12 @@ MultipleGnubbySigner.prototype.doSign = function(challenges) {
if (challenges) { if (challenges) {
for (var i = 0; i < challenges.length; i++) { for (var i = 0; i < challenges.length; i++) {
var decodedChallenge = {};
var challenge = challenges[i]; var challenge = challenges[i];
decodedChallenge['challengeHash'] = var decodedChallenge = {
B64_decode(challenge['challengeHash']); challengeHash: B64_decode(challenge['challengeHash']),
decodedChallenge['appIdHash'] = B64_decode(challenge['appIdHash']); appIdHash: B64_decode(challenge['appIdHash']),
decodedChallenge['keyHandle'] = B64_decode(challenge['keyHandle']); keyHandle: B64_decode(challenge['keyHandle'])
};
if (challenge['version']) { if (challenge['version']) {
decodedChallenge['version'] = challenge['version']; decodedChallenge['version'] = challenge['version'];
} }
......
...@@ -33,8 +33,10 @@ function RequestToken(queue, id, beginCb, opt_prev, opt_next) { ...@@ -33,8 +33,10 @@ function RequestToken(queue, id, beginCb, opt_prev, opt_next) {
this.queue_ = queue; this.queue_ = queue;
/** @private {number} */ /** @private {number} */
this.id_ = id; this.id_ = id;
/** @type {function(QueuedRequestToken)} */ /** @private {boolean} */
this.beginCb = beginCb; this.begun_ = false;
/** @private {function(QueuedRequestToken)} */
this.beginCb_ = beginCb;
/** @type {RequestToken} */ /** @type {RequestToken} */
this.prev = null; this.prev = null;
/** @type {RequestToken} */ /** @type {RequestToken} */
...@@ -43,6 +45,17 @@ function RequestToken(queue, id, beginCb, opt_prev, opt_next) { ...@@ -43,6 +45,17 @@ function RequestToken(queue, id, beginCb, opt_prev, opt_next) {
this.completed_ = false; this.completed_ = false;
} }
/** Begins work on this queued request. */
RequestToken.prototype.begin = function() {
this.begun_ = true;
this.beginCb_(this);
};
/** @return {boolean} Whether this token has already begun. */
RequestToken.prototype.begun = function() {
return this.begun_;
};
/** Completes (or cancels) this queued request. */ /** Completes (or cancels) this queued request. */
RequestToken.prototype.complete = function() { RequestToken.prototype.complete = function() {
if (this.completed_) { if (this.completed_) {
...@@ -59,6 +72,12 @@ RequestToken.prototype.completed = function() { ...@@ -59,6 +72,12 @@ RequestToken.prototype.completed = function() {
return this.completed_; return this.completed_;
}; };
/** @return {number} This token's id. */
RequestToken.prototype.id = function() {
return this.id_;
};
/** /**
* @param {!SystemTimer} sysTimer A system timer implementation. * @param {!SystemTimer} sysTimer A system timer implementation.
* @constructor * @constructor
...@@ -96,15 +115,32 @@ RequestQueue.prototype.insertToken_ = function(token) { ...@@ -96,15 +115,32 @@ RequestQueue.prototype.insertToken_ = function(token) {
/** /**
* Removes this token from the queue. * Removes this token from the queue.
* @param {RequestToken} token Queue token * @param {RequestToken} token Queue token
* @return {RequestToken?} The next token in the queue to run, if any.
* @private * @private
*/ */
RequestQueue.prototype.removeToken_ = function(token) { RequestQueue.prototype.removeToken_ = function(token) {
var nextTokenToRun = null;
// If this token has been begun, find the next token to run.
if (token.begun()) {
// Find the first token in the queue which has not yet been begun, and which
// is not the token being removed.
for (var nextToken = this.head_; nextToken; nextToken = nextToken.next) {
if (nextToken !== token && !nextToken.begun()) {
nextTokenToRun = nextToken;
break;
}
}
}
// Remove this token from the queue
if (token.next) { if (token.next) {
token.next.prev = token.prev; token.next.prev = token.prev;
} }
if (token.prev) { if (token.prev) {
token.prev.next = token.next; token.prev.next = token.next;
} }
// Update head and tail of queue.
if (this.head_ === token && this.tail_ === token) { if (this.head_ === token && this.tail_ === token) {
this.head_ = this.tail_ = null; this.head_ = this.tail_ = null;
} else { } else {
...@@ -117,7 +153,12 @@ RequestQueue.prototype.removeToken_ = function(token) { ...@@ -117,7 +153,12 @@ RequestQueue.prototype.removeToken_ = function(token) {
this.tail_.next = null; this.tail_.next = null;
} }
} }
// Isolate this token to prevent it from manipulating the queue, e.g. if
// complete() is called a second time with it.
token.prev = token.next = null; token.prev = token.next = null;
return nextTokenToRun;
}; };
/** /**
...@@ -126,11 +167,16 @@ RequestQueue.prototype.removeToken_ = function(token) { ...@@ -126,11 +167,16 @@ RequestQueue.prototype.removeToken_ = function(token) {
* @param {RequestToken} token Queue token * @param {RequestToken} token Queue token
*/ */
RequestQueue.prototype.complete = function(token) { RequestQueue.prototype.complete = function(token) {
console.log(UTIL_fmt('token ' + this.id_ + ' completed')); var next = this.removeToken_(token);
var next = token.next;
this.removeToken_(token);
if (next) { if (next) {
next.beginCb(next); console.log(
UTIL_fmt('token ' + token.id() + ' completed, starting ' + next.id()));
next.begin();
} else if (this.empty()) {
console.log(UTIL_fmt('token ' + token.id() + ' completed, queue empty'));
} else {
console.log(UTIL_fmt(
'token ' + token.id() + ' completed (earlier token still running)'));
} }
}; };
...@@ -156,7 +202,7 @@ RequestQueue.prototype.queueRequest = function(beginCb, timer) { ...@@ -156,7 +202,7 @@ RequestQueue.prototype.queueRequest = function(beginCb, timer) {
if (startNow) { if (startNow) {
this.sysTimer_.setTimeout(function() { this.sysTimer_.setTimeout(function() {
if (!token.completed()) { if (!token.completed()) {
token.beginCb(token); token.begin();
} }
}, 0); }, 0);
} }
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
var gnubbySignRequestQueue; var gnubbySignRequestQueue;
/**
* Initialize request queue.
*/
function initRequestQueue() { function initRequestQueue() {
gnubbySignRequestQueue = gnubbySignRequestQueue =
new OriginKeyedRequestQueue(FACTORY_REGISTRY.getSystemTimer()); new OriginKeyedRequestQueue(FACTORY_REGISTRY.getSystemTimer());
...@@ -177,10 +180,10 @@ function isValidSignRequest(request) { ...@@ -177,10 +180,10 @@ function isValidSignRequest(request) {
* @param {WebRequestSender} sender Message sender. * @param {WebRequestSender} sender Message sender.
* @param {function(U2fError)} errorCb Error callback * @param {function(U2fError)} errorCb Error callback
* @param {function(SignChallenge, string, string)} successCb Success callback * @param {function(SignChallenge, string, string)} successCb Success callback
* @param {string|undefined} opt_defaultChallenge A default sign challenge * @param {string=} opt_defaultChallenge A default sign challenge
* value, if a request does not provide one. * value, if a request does not provide one.
* @param {string|undefined} opt_appId The app id for the entire request. * @param {string=} opt_appId The app id for the entire request.
* @param {string|undefined} opt_logMsgUrl Url to post log messages to * @param {string=} opt_logMsgUrl Url to post log messages to
* @constructor * @constructor
* @implements {Closeable} * @implements {Closeable}
*/ */
...@@ -538,6 +541,12 @@ Signer.prototype.helperComplete_ = function(helperReply, opt_source) { ...@@ -538,6 +541,12 @@ Signer.prototype.helperComplete_ = function(helperReply, opt_source) {
console.log(UTIL_fmt( console.log(UTIL_fmt(
'helper reported ' + reply.code.toString(16) + ', returning ' + 'helper reported ' + reply.code.toString(16) + ', returning ' +
reportedError.errorCode)); reportedError.errorCode));
// Log non-expected reply codes if we have an url to send them
if (reportedError.errorCode == ErrorCodes.OTHER_ERROR) {
var logMsg = 'log=u2fsign&rc=' + reply.code.toString(16);
if (this.logMsgUrl_)
logMessage(logMsg, this.logMsgUrl_);
}
this.notifyError_(reportedError); this.notifyError_(reportedError);
} else { } else {
if (this.logMsgUrl_ && opt_source) { if (this.logMsgUrl_ && opt_source) {
......
...@@ -11,11 +11,21 @@ ...@@ -11,11 +11,21 @@
'use strict'; 'use strict';
/**
* @typedef {{
* challengeHash: Array<number>,
* appIdHash: Array<number>,
* keyHandle: Array<number>,
* version: (string|undefined)
* }}
*/
var DecodedSignHelperChallenge;
/** /**
* @typedef {{ * @typedef {{
* code: number, * code: number,
* gnubby: (Gnubby|undefined), * gnubby: (Gnubby|undefined),
* challenge: (SignHelperChallenge|undefined), * challenge: (DecodedSignHelperChallenge|undefined),
* info: (ArrayBuffer|undefined) * info: (ArrayBuffer|undefined)
* }} * }}
*/ */
...@@ -65,14 +75,14 @@ function SingleGnubbySigner( ...@@ -65,14 +75,14 @@ function SingleGnubbySigner(
/** @private {string|undefined} */ /** @private {string|undefined} */
this.logMsgUrl_ = opt_logMsgUrl; this.logMsgUrl_ = opt_logMsgUrl;
/** @private {!Array<!SignHelperChallenge>} */ /** @private {!Array<!DecodedSignHelperChallenge>} */
this.challenges_ = []; this.challenges_ = [];
/** @private {number} */ /** @private {number} */
this.challengeIndex_ = 0; this.challengeIndex_ = 0;
/** @private {boolean} */ /** @private {boolean} */
this.challengesSet_ = false; this.challengesSet_ = false;
/** @private {!Object<string, number>} */ /** @private {!Object<Array<number>, number>} */
this.cachedError_ = []; this.cachedError_ = [];
/** @private {(function()|undefined)} */ /** @private {(function()|undefined)} */
...@@ -132,7 +142,7 @@ SingleGnubbySigner.prototype.closed_ = function() { ...@@ -132,7 +142,7 @@ SingleGnubbySigner.prototype.closed_ = function() {
/** /**
* Begins signing the given challenges. * Begins signing the given challenges.
* @param {Array<SignHelperChallenge>} challenges The challenges to sign. * @param {Array<DecodedSignHelperChallenge>} challenges The challenges to sign.
* @return {boolean} Whether the challenges were accepted. * @return {boolean} Whether the challenges were accepted.
*/ */
SingleGnubbySigner.prototype.doSign = function(challenges) { SingleGnubbySigner.prototype.doSign = function(challenges) {
...@@ -481,7 +491,7 @@ SingleGnubbySigner.prototype.goToError_ = function(code, opt_warn) { ...@@ -481,7 +491,7 @@ SingleGnubbySigner.prototype.goToError_ = function(code, opt_warn) {
/** /**
* Switches to the success state, and notifies caller. * Switches to the success state, and notifies caller.
* @param {number} code Status code * @param {number} code Status code
* @param {SignHelperChallenge=} opt_challenge The challenge signed * @param {DecodedSignHelperChallenge=} opt_challenge The challenge signed
* @param {ArrayBuffer=} opt_info Optional result data * @param {ArrayBuffer=} opt_info Optional result data
* @private * @private
*/ */
......
...@@ -284,8 +284,16 @@ UsbEnrollHandler.prototype.enrollCallback_ = function( ...@@ -284,8 +284,16 @@ UsbEnrollHandler.prototype.enrollCallback_ = function(
break; break;
case DeviceStatusCodes.OK_STATUS: case DeviceStatusCodes.OK_STATUS:
var info = B64_encode(new Uint8Array(infoArray || [])); var appIdHash = this.request_.enrollChallenges[0].appIdHash;
this.notifySuccess_(version, info); DEVICE_FACTORY_REGISTRY.getGnubbyFactory().postEnrollAction(
gnubby, appIdHash, (rc) => {
if (rc == DeviceStatusCodes.OK_STATUS) {
var info = B64_encode(new Uint8Array(infoArray || []));
this.notifySuccess_(version, info);
} else {
this.notifyError_(rc);
}
});
break; break;
default: default:
......
...@@ -198,7 +198,7 @@ UsbGnubbyDevice.prototype.readOneReply_ = function() { ...@@ -198,7 +198,7 @@ UsbGnubbyDevice.prototype.readOneReply_ = function() {
}, 0); }, 0);
} else { } else {
console.log(UTIL_fmt('no x.data!')); console.log(UTIL_fmt('no x.data!'));
console.log(x); console.log(UTIL_fmt(JSON.stringify(x)));
window.setTimeout(function() { window.setTimeout(function() {
self.destroy(); self.destroy();
}, 0); }, 0);
......
...@@ -65,3 +65,15 @@ UsbGnubbyFactory.prototype.notEnrolledPrerequisiteCheck = function( ...@@ -65,3 +65,15 @@ UsbGnubbyFactory.prototype.notEnrolledPrerequisiteCheck = function(
gnubby, appIdHash, cb) { gnubby, appIdHash, cb) {
cb(DeviceStatusCodes.OK_STATUS, gnubby); cb(DeviceStatusCodes.OK_STATUS, gnubby);
}; };
/**
* No-op post enroll action.
* @param {Gnubby} gnubby The just-enrolled gnubby.
* @param {string} appIdHash The base64-encoded hash of the app id for which
* the gnubby was enrolled.
* @param {FactoryOpenCallback} cb Called with the result of the action.
* (A non-zero status indicates failure.)
*/
UsbGnubbyFactory.prototype.postEnrollAction = function(gnubby, appIdHash, cb) {
cb(DeviceStatusCodes.OK_STATUS, gnubby);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment