mirror of https://github.com/keeweb/keeweb
fixed challenge-response calculation with padding
parent
a4b22b6c88
commit
176553a674
|
@ -4,7 +4,7 @@ import { Logger } from 'util/logger';
|
|||
import { UsbListener } from 'comp/app/usb-listener';
|
||||
import { AppSettingsModel } from 'models/app-settings-model';
|
||||
import { Timeouts } from 'const/timeouts';
|
||||
import { YubiKeyProductIds } from 'const/hardware';
|
||||
import { YubiKeyProductIds, YubiKeyChallengeSize } from 'const/hardware';
|
||||
import { Locale } from 'util/locale';
|
||||
|
||||
const logger = new Logger('yubikey');
|
||||
|
@ -250,7 +250,18 @@ const YubiKey = {
|
|||
calculateChalResp(chalResp, challenge, callback) {
|
||||
const { vid, pid, serial, slot } = chalResp;
|
||||
const yubiKey = { vid, pid, serial };
|
||||
this.ykChalResp.challengeResponse(yubiKey, challenge, slot, (err, response) => {
|
||||
|
||||
challenge = Buffer.from(challenge);
|
||||
|
||||
// https://github.com/Yubico/yubikey-personalization-gui/issues/86
|
||||
// https://github.com/keepassxreboot/keepassxc/blob/develop/src/keys/drivers/YubiKey.cpp#L318
|
||||
|
||||
const padLen = YubiKeyChallengeSize - challenge.byteLength;
|
||||
|
||||
const paddedChallenge = Buffer.alloc(YubiKeyChallengeSize, padLen);
|
||||
challenge.copy(paddedChallenge);
|
||||
|
||||
this.ykChalResp.challengeResponse(yubiKey, paddedChallenge, slot, (err, response) => {
|
||||
if (err) {
|
||||
if (err.code === this.ykChalResp.YK_ENOKEY) {
|
||||
err.noKey = true;
|
||||
|
|
|
@ -9,4 +9,6 @@ const YubiKeyProductIds = {
|
|||
YK4: [0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407]
|
||||
};
|
||||
|
||||
export { YubiKeyVendorId, YubiKeyProductIds };
|
||||
const YubiKeyChallengeSize = 64;
|
||||
|
||||
export { YubiKeyVendorId, YubiKeyProductIds, YubiKeyChallengeSize };
|
||||
|
|
Loading…
Reference in New Issue