Merge pull request #2482 from Bilb/crypto-magic-swallow-exception

fix: swallow exception while doing tryMatchBlindWithStandardKey
pull/2470/merge
Audric Ackermann 3 years ago committed by GitHub
commit afe573fd06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -151,6 +151,10 @@ export function tryMatchBlindWithStandardKey(
if (!blindedSessionId.startsWith(KeyPrefixType.blinded)) { if (!blindedSessionId.startsWith(KeyPrefixType.blinded)) {
throw new Error('blindedKey must be a blinded key (starting with 15)'); throw new Error('blindedKey must be a blinded key (starting with 15)');
} }
// We don't want to stop iterating even if an error happens while looking for a blind/standard match.
// That's why we catch any errors and return false if it happens.
try {
// tslint:disable: no-bitwise // tslint:disable: no-bitwise
const sessionIdNoPrefix = PubKey.removePrefixIfNeeded(PubKey.cast(standardSessionId).key); const sessionIdNoPrefix = PubKey.removePrefixIfNeeded(PubKey.cast(standardSessionId).key);
@ -172,13 +176,18 @@ export function tryMatchBlindWithStandardKey(
const pk2 = cloneDeep(pk1); const pk2 = cloneDeep(pk1);
pk2[31] = pk1[31] ^ 0b1000_0000; pk2[31] = pk1[31] ^ 0b1000_0000;
const match = isEqual(blindedIdNoPrefix, to_hex(pk1)) || isEqual(blindedIdNoPrefix, to_hex(pk2)); const match =
isEqual(blindedIdNoPrefix, to_hex(pk1)) || isEqual(blindedIdNoPrefix, to_hex(pk2));
if (!match) { if (!match) {
return false; return false;
} }
return true; return true;
} catch (e) {
window.log.warn('Failed to do crypto tryMatchBlindWithStandardKey with ', e.message);
return false;
}
} }
/** /**

Loading…
Cancel
Save