def print_all_slots(slot_info, color, theme_map): """Print all slots and cards available""" ############################################################################## columns = int(shutil.get_terminal_size().columns) // 4 print(color_prepare("#" * columns, "debug", color, theme_map)) print(handle_python_strings(slot_info).decode("ASCII").strip()) print(color_prepare("#" * columns, "debug", color, theme_map))
def print_all_slots(slot_info, color, theme_map): """Print all slots and cards available""" ############################################################################## columns = int(get_terminal_size().columns) // 4 print(color_prepare("#" * columns, "debug", color, theme_map), handle_python_strings(slot_info).decode("UTF-8").strip(), color_prepare("#" * columns, "debug", color, theme_map), sep="\n")
def _print_identity(self, key): """Print off identity""" #################################################################### print("%s" % (color_prepare(self.identities.iddb[key]['uid'] + ":", "first_level", self.args['color'], self.args['theme_map']))) for info in [ 'verified', 'subject', 'subjecthash', 'issuer', 'issuerhash', 'fingerprint', 'enddate' ]: print("\t%s %s" % (color_prepare( info + ":", "second_level", self.args['color'], self.args['theme_map']), self.identities.iddb[key][info]))
def color_print(self, string, color_type): ################################################################## """Handle the color printing for objects""" ################################################################## return color_prepare( string, color_type, self.args["color"], self.args["theme_map"] )
def print_card_info(card_slot, identity, verbosity, color, theme_map): """Inform the user what card is selected""" ############################################################################## if 'key_path' not in identity: out_list, stdout = get_card_info() if verbosity > 1: print_all_slots(stdout, color, theme_map) for out in out_list[1:]: stripped = out.decode("UTF-8").strip() if int(stripped[0]) == int(card_slot): verbosity = verbosity + 1 if verbosity < 2 else 2 stripped = "Using Slot" + ("\n").join( stripped.split('\n')[:verbosity]) print("%s" % (color_prepare(stripped, "info", color, theme_map)))
def print_card_info(card_slot, identity, verbosity, color, theme_map): """Inform the user what card is selected""" ############################################################################## if 'key_path' not in identity: command = ['pkcs11-tool', '-L'] proc = Popen(command, stdout=PIPE, stdin=PIPE, stderr=STDOUT) stdout, _ = proc.communicate() out_list = handle_python_strings(stdout).split(b'Slot') if verbosity > 1: print_all_slots(stdout, color, theme_map) for out in out_list[1:]: stripped = out.decode("ASCII").strip() if int(stripped[0]) == int(card_slot): verbosity = verbosity + 1 if verbosity < 2 else 2 stripped = ("\n").join(stripped.split('\n')[:verbosity]) stripped = "Using Slot" + stripped print("%s" % (color_prepare(stripped, "info", color, theme_map)))
def _decrypt_password_entry(self, password, myidentity): """This decrypts a given password entry""" #################################################################### plaintext_pw = password.decrypt_entry(identity=myidentity, passphrase=self.passphrase, card_slot=self.args['card_slot']) if not self.args['noverify']: result = password.verify_entry(myidentity['uid'], self.identities) if not result['sigOK']: print( "warning: could not verify that '%s' correctly signed your password entry." % result['distributor']) if not result['certOK']: print( "Warning: could not verify the certificate authenticity of user '%s'." % result['distributor']) print(("%s: %s") % (color_prepare( password.metadata['name'], "first_level", self.args['color'], self.args['theme_map']), plaintext_pw))
def color_print(self, string, color_type): """Handle the color printing for objects""" ################################################################## return color_prepare(string, color_type, self.args['color'], self.args['theme_map'])