Initial Intel TEE integration.

This commit is contained in:
Andy Phillipson 2016-12-05 17:33:46 -05:00
commit 0c69dfb061
24 changed files with 492 additions and 75 deletions

View file

@ -1,10 +1,16 @@
'use strict';
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) {
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, intelTEE, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) {
// `wallet` is a decorated version of client.
var root = {};
root.externalSource = {
ledger: ledger.description,
trezor: trezor.description,
intelTEE: intelTEE.description
}
root.WALLET_STATUS_MAX_TRIES = 7;
root.WALLET_STATUS_DELAY_BETWEEN_TRIES = 1.4 * 1000;
root.SOFT_CONFIRMATION_LIMIT = 12;
@ -40,6 +46,40 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
var _signWithIntelTEE = function(wallet, txp, cb) {
$log.info('Requesting Intel TEE to sign the transaction');
intelTEE.signTx(wallet.credentials.hwInfo.id, txp, function(err, result) {
if (err) return cb(err);
$log.debug('Intel TEE response', result);
txp.signatures = result.Signatures;
return wallet.signTxProposal(txp, cb);
});
};
root.showMneumonicFromHardware = function(wallet, cb) {
switch (wallet.getPrivKeyExternalSourceName()) {
case root.externalSource.intelTEE.id:
return intelTEE.showMneumonic(wallet.credentials.hwInfo.id, cb);
break;
default:
cb('Error: unrecognized external source');
break;
}
};
root.showReceiveAddressFromHardware = function(wallet, address, cb) {
switch (wallet.getPrivKeyExternalSourceName()) {
case root.externalSource.intelTEE.id:
return intelTEE.showReceiveAddress(wallet.credentials.hwInfo.id, address, cb);
break;
default:
cb('Error: unrecognized external source');
break;
}
};
root.invalidateCache = function(wallet) {
if (wallet.cachedStatus)
wallet.cachedStatus.isValid = false;
@ -629,10 +669,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
if (wallet.isPrivKeyExternal()) {
switch (wallet.getPrivKeyExternalSourceName()) {
case 'ledger':
case root.externalSource.ledger.id:
return _signWithLedger(wallet, txp, cb);
case 'trezor':
case root.externalSource.trezor.id:
return _signWithTrezor(wallet, txp, cb);
case root.externalSource.intelTEE.id:
return _signWithIntelTEE(wallet, txp, cb);
default:
var msg = 'Unsupported External Key:' + wallet.getPrivKeyExternalSourceName();
$log.error(msg);