Browse Source

crypto.Crypto: add pwfile_used() method

The MMGen Project 1 year ago
parent
commit
01470726f2
1 changed files with 10 additions and 2 deletions
  1. 10 2
      mmgen/crypto.py

+ 10 - 2
mmgen/crypto.py

@@ -65,6 +65,14 @@ class Crypto:
 		def __init__(self,fn):
 		def __init__(self,fn):
 			oneshot_warning.__init__(self,div=fn,fmt_args=[fn],reverse=True)
 			oneshot_warning.__init__(self,div=fn,fmt_args=[fn],reverse=True)
 
 
+	def pwfile_used(self,passwd_file):
+		if hasattr(self,'_pwfile_used'):
+			self.pwfile_reuse_warning(passwd_file)
+			return True
+		else:
+			self._pwfile_used = True
+			return False
+
 	def __init__(self,cfg):
 	def __init__(self,cfg):
 		self.cfg = cfg
 		self.cfg = cfg
 		self.util = cfg._util
 		self.util = cfg._util
@@ -329,7 +337,7 @@ class Crypto:
 				cfg    = self.cfg,
 				cfg    = self.cfg,
 				infile = passwd_file,
 				infile = passwd_file,
 				desc   = f'{pw_desc} for {data_desc}',
 				desc   = f'{pw_desc} for {data_desc}',
-				quiet  = self.pwfile_reuse_warning(passwd_file).warning_shown ))
+				quiet  = self.pwfile_used(passwd_file) ))
 		else:
 		else:
 			self.util.qmsg('\n'+fmt(message,indent='  '))
 			self.util.qmsg('\n'+fmt(message,indent='  '))
 			from .ui import get_words_from_user
 			from .ui import get_words_from_user
@@ -360,7 +368,7 @@ class Crypto:
 				cfg    = self.cfg,
 				cfg    = self.cfg,
 				infile = passwd_file,
 				infile = passwd_file,
 				desc   = f'{pw_desc} for {data_desc}',
 				desc   = f'{pw_desc} for {data_desc}',
-				quiet  = self.pwfile_reuse_warning(passwd_file).warning_shown ))
+				quiet  = self.pwfile_used(passwd_file) ))
 		else:
 		else:
 			from .ui import get_words_from_user
 			from .ui import get_words_from_user
 			return ' '.join(get_words_from_user( self.cfg, f'Enter {pw_desc} for {data_desc}: ' ))
 			return ' '.join(get_words_from_user( self.cfg, f'Enter {pw_desc} for {data_desc}: ' ))