mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
totp alg updates
This commit is contained in:
@@ -177,13 +177,13 @@ angular
|
|||||||
function totpTick() {
|
function totpTick() {
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
var epoch = Math.round(new Date().getTime() / 1000.0);
|
var epoch = Math.round(new Date().getTime() / 1000.0);
|
||||||
var mod = (epoch % 30);
|
var mod = epoch % 30;
|
||||||
var sec = 30 - mod;
|
var sec = 30 - mod;
|
||||||
|
|
||||||
$scope.totpSec = sec;
|
$scope.totpSec = sec;
|
||||||
$scope.totpDash = (2.62 * mod).toFixed(2);
|
$scope.totpDash = (2.62 * mod).toFixed(2);
|
||||||
$scope.totpLow = sec <= 7;
|
$scope.totpLow = sec <= 7;
|
||||||
if (epoch % 30 == 0) {
|
if (mod == 0) {
|
||||||
totpUpdateCode();
|
totpUpdateCode();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,11 +39,25 @@ function initTotpService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var b32tohex = function (s) {
|
var b32tohex = function (s) {
|
||||||
|
s = s.toUpperCase();
|
||||||
|
var cleanedInput = '';
|
||||||
|
for (var i = 0; i < s.length; i++) {
|
||||||
|
if (b32Chars.indexOf(s[i]) < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanedInput += s[i];
|
||||||
|
}
|
||||||
|
s = cleanedInput;
|
||||||
|
|
||||||
var bits = '';
|
var bits = '';
|
||||||
var hex = '';
|
var hex = '';
|
||||||
for (var i = 0; i < s.length; i++) {
|
for (var i = 0; i < s.length; i++) {
|
||||||
var val = b32Chars.indexOf(s.charAt(i).toUpperCase());
|
var byteIndex = b32Chars.indexOf(s.charAt(i));
|
||||||
bits += leftpad(val.toString(2), 5, '0');
|
if (byteIndex < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bits += leftpad(byteIndex.toString(2), 5, '0');
|
||||||
}
|
}
|
||||||
for (var i = 0; i + 4 <= bits.length; i += 4) {
|
for (var i = 0; i + 4 <= bits.length; i += 4) {
|
||||||
var chunk = bits.substr(i, 4);
|
var chunk = bits.substr(i, 4);
|
||||||
|
|||||||
Reference in New Issue
Block a user