add bad key handler
This commit is contained in:
parent
2b833b5141
commit
cae68947df
|
@ -135,6 +135,11 @@ export default new class E2EE extends BuiltinModule {
|
||||||
|
|
||||||
const cached = Cache.find('e2ee:images', item => item.src === src);
|
const cached = Cache.find('e2ee:images', item => item.src === src);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
|
if (cached.invalidKey) {
|
||||||
|
component.props.className = 'bd-encryptedImageBadKey';
|
||||||
|
component.props.readyState = 'READY';
|
||||||
|
return;
|
||||||
|
}
|
||||||
Logger.info('E2EE', 'Returning encrypted image from cache');
|
Logger.info('E2EE', 'Returning encrypted image from cache');
|
||||||
try {
|
try {
|
||||||
const decrypt = this.decrypt(this.decrypt(this.decrypt(seed, this.master), haveKey), cached.image);
|
const decrypt = this.decrypt(this.decrypt(this.decrypt(seed, this.master), haveKey), cached.image);
|
||||||
|
@ -159,6 +164,7 @@ export default new class E2EE extends BuiltinModule {
|
||||||
const data = image.slice(0, -64);
|
const data = image.slice(0, -64);
|
||||||
const validateHmac = await this.createHmac(data);
|
const validateHmac = await this.createHmac(data);
|
||||||
if (hmac !== validateHmac) {
|
if (hmac !== validateHmac) {
|
||||||
|
Cache.push('e2ee:images', { src, invalidKey: true });
|
||||||
console.log('INVALID HMAC!');
|
console.log('INVALID HMAC!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue