mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	encryption key has now limited time to live if not used for 10 minutes
This commit is contained in:
		
							parent
							
								
									2c3df13424
								
							
						
					
					
						commit
						5a64eed1dd
					
				@ -290,7 +290,11 @@ function deriveEncryptionKey(password) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// currently not configurable
 | 
				
			||||||
 | 
					const globalEncryptionKeyTimeToLive = 10 * 60 * 1000; // in milliseconds
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let globalEncryptionKey = null;
 | 
					let globalEncryptionKey = null;
 | 
				
			||||||
 | 
					let globalLastEncryptionOperationDate = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#encryptionPasswordForm").submit(function() {
 | 
					$("#encryptionPasswordForm").submit(function() {
 | 
				
			||||||
    const password = $("#encryptionPassword").val();
 | 
					    const password = $("#encryptionPassword").val();
 | 
				
			||||||
@ -313,6 +317,18 @@ $("#encryptionPasswordForm").submit(function() {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getAes() {
 | 
					function getAes() {
 | 
				
			||||||
 | 
					    globalLastEncryptionOperationDate = new Date();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    setTimeout(function() {
 | 
				
			||||||
 | 
					        if (new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionKeyTimeToLive) {
 | 
				
			||||||
 | 
					            globalEncryptionKey = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (globalNote.detail.encryption > 0) {
 | 
				
			||||||
 | 
					                loadNote(globalNote.detail.note_id);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }, globalEncryptionKeyTimeToLive + 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return new aesjs.ModeOfOperation.ctr(globalEncryptionKey, new aesjs.Counter(5));
 | 
					    return new aesjs.ModeOfOperation.ctr(globalEncryptionKey, new aesjs.Counter(5));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user