bb, stat = t1.login(userpin) if (stat != ''): print('Ошибка при login') print(stat) quit() tobj = 'объект' type = 'all' #type = 'cert' #type = 'pubkey' #type = 'data' #type = 'privkey' if (type == 'cert'): tobj = 'сертификат' #Читаем объекты с токена lm, stat = t1.listobjects(type, 'value') if (stat != ''): print('Ошибка при listobjects') print(stat) quit() print('Работа с listobjects: ' + type) i = 0 for obj in lm: print(str(i) + '-ый ' + tobj) for key in obj.keys(): print('\t' + key + ': ' + obj[key]) i += 1 #lm, stat = t1.listobjects('cert', 'value') #print('Работа с listobjects cert value:') lm, stat = t1.listobjects('pubkey', 'value') if (stat != ''):
print('Проверка 2-ой подписи') verify, stat = t1.verify(digest_hex, sign1_hex1, pubkeyinfo) #verify, stat = t1.verify(digest_hex, pubkeyinfo, sign1_hex1) if (stat != ''): print('Прерывание при verify 2: ' + stat) if (verify == 1): print('Подпись верна') else: print('Подпись не верна') print(verify) #Rename key label = 'key_512_new' dd = dict(pkcs11_id=pkcs11_id, pkcs11_label=label) print("Список открытых ключей на токене (наш ключ с меткой key_512) ") #lobj = pyp11.listobjects(aa, 0, 'pubkey') lobj, stat = t1.listobjects('pubkey') for lo in lobj: for key in lo: print('\t' + key + ': ' + lo[key]) print('Переименовывакм ключи с меткой: ' + labkey + ' на ' + label) t1.rename('key', pkcs11_id, label) #t1.changeckaid('key', pkcs11_id, '1111111111') print("Список открытых ключей на токене после переименования") lobj, stat = t1.listobjects('pubkey') for lo in lobj: for key in lo.keys(): print('\t' + key + ': ' + lo[key]) #Delete keyPair: private key and public key #t1.delete('key', pkcs11_id) #Or