From c9c09d48ff546b15612aaac361ae93a6cee355f6 Mon Sep 17 00:00:00 2001 From: PIKACHUIM Date: Mon, 2 Dec 2024 17:41:04 +0800 Subject: [PATCH] Updated20241202174104 --- Config/button.json | 8 +- Config/frames.json | 16 ++-- Config/global.json | 20 ++--- Config/labels.json | 8 +- Config/tables.json | 14 ++-- Module/Certificates.py | 4 +- .../__pycache__/Certificates.cpython-311.pyc | Bin 6468 -> 6501 bytes SmartCardAPP.py | 69 +++++++++++++----- 8 files changed, 87 insertions(+), 52 deletions(-) diff --git a/Config/button.json b/Config/button.json index 1f70ea7..32b739b 100644 --- a/Config/button.json +++ b/Config/button.json @@ -2,7 +2,7 @@ "main_main": [ [ 28, - 440 + 445 ], { "name": "inf", @@ -50,7 +50,7 @@ "card_main": [ [ 28, - 230 + 232 ], { "name": "add", @@ -80,7 +80,7 @@ "card_opts": [ [ 28, - 385 + 390 ], { "name": "ssh", @@ -110,7 +110,7 @@ "cert_main": [ [ 428, - 230 + 232 ], { "name": "cer", diff --git a/Config/frames.json b/Config/frames.json index d163921..00e3351 100644 --- a/Config/frames.json +++ b/Config/frames.json @@ -7,13 +7,13 @@ ], "main_main": [ 390, - 105, + 100, 15, - 420 + 425 ], "card_main": [ 390, - 415, + 420, 15, 5 ], @@ -21,30 +21,30 @@ 365, 120, 28, - 260 + 265 ], "cert_main": [ 650, 520, - 415, + 420, 5 ], "cert_info": [ 625, 160, 428, - 260 + 265 ], "cert_user": [ 308, 95, 428, - 420 + 425 ], "cert_last": [ 308, 95, 745, - 420 + 425 ] } \ No newline at end of file diff --git a/Config/global.json b/Config/global.json index 4644576..67503ad 100644 --- a/Config/global.json +++ b/Config/global.json @@ -97,7 +97,7 @@ "msg_pass_next_same": "新旧密码不能相同", "msg_pass_change_ok": "修改重置密码结果", "msg_pass_change_tx": "PIN密码修改", - "msg_pass_resets_tx": "%重置PIN密码", + "msg_pass_resets_tx": "PIN重置密码", "msg_card": "卡片", "msg_info": "信息", "msg_open": "打开", @@ -112,7 +112,7 @@ "msg_confirm": "确认", "msg_cancel": "取消", "msg_disable": "禁用", - "msg_char": "字符", + "msg_char": "字", "msg_create": "创建", "msg_result": "结果", "msg_user": "用户", @@ -148,8 +148,8 @@ "msg_no_cert": "(未找到证书)", "msg_ou_full": "组织单元", "msg_ks_full": "密钥限制", - "msg_ml_lite": "邮件特性", - "msg_ml_full": "SMIME", + "msg_ml_lite": "其他特性", + "msg_ml_full": "邮件加密", "msg_ml_text": "需邮件特性", "msg_must_in": "必填", "msg_none_in": "选填", @@ -158,7 +158,7 @@ "msg_domain": "域名列表", "msg_emails": "邮箱列表", "msg_splits": "用分号分割", - "msg_create_csr": "创建证书请求", + "msg_create_csr": "创建请求", "DigitalSignature": "数字签名", "nonRepudiation": "认可签名", "Encipherment": "加密解密", @@ -195,7 +195,8 @@ "cer_text": "注意:只能导入当前虚拟智能卡已存在对应密钥的证书", "sc_title": "未安装OpenSC", "sc_datas": "您似乎还没有安装OpenSC\n是否立即安装?", - "csp_sets": "使用自定义CSP" + "csp_sets": "使用自定义CSP", + "csp_set_": "选择CSP" }, "en": { "main_text": "TPM Virtual Smart Card Manager", @@ -348,7 +349,7 @@ "msg_ou_full": "Organizational Unit", "msg_ks_full": "Key Restrictions", "msg_ml_lite": "Email Features", - "msg_ml_full": "SMIME", + "msg_ml_full": " SMIME", "msg_ml_text": "Email Features Required", "msg_must_in": "Required", "msg_none_in": "Optional", @@ -357,7 +358,7 @@ "msg_domain": "Domain List", "msg_emails": "Email List", "msg_splits": "Separated by semicolons", - "msg_create_csr": "Create Certificate Request", + "msg_create_csr": "Create CSR", "DigitalSignature": "Digital Signature", "nonRepudiation": "Acceptance Signature", "Encipherment": "Encryption and Decryption", @@ -394,6 +395,7 @@ "cer_text": "Note: Only the Cert with key on the card can import", "sc_title": "OpenSC not Install", "sc_datas": "It seems you have not installed OpenSC\nInstall now?", - "csp_sets": "Use custom CSP" + "csp_sets": "Use custom CSP", + "csp_set_": "Use CSP" } } \ No newline at end of file diff --git a/Config/labels.json b/Config/labels.json index 1cd2745..5b6e0fb 100644 --- a/Config/labels.json +++ b/Config/labels.json @@ -11,7 +11,7 @@ "card_info": { "conf": [ 35, - 275 + 280 ], "data": [ { @@ -34,7 +34,7 @@ "cert_info": { "conf": [ 432, - 278 + 283 ], "data": [ { @@ -71,7 +71,7 @@ "cert_user": { "conf": [ 432, - 435 + 440 ], "data": [ { @@ -93,7 +93,7 @@ "cert_last": { "conf": [ 750, - 435 + 440 ], "data": [ { diff --git a/Config/tables.json b/Config/tables.json index c4dbaa2..0da071d 100644 --- a/Config/tables.json +++ b/Config/tables.json @@ -9,35 +9,35 @@ } }, "card_main": { - "pack": [28, 30, 158], + "pack": [28, 23, 170], "data": { "ITEM": [ 30, "card_list" ], "NAME": [ - 175, + 200, "card_name" ], "UUID": [ - 135, + 110, "card_uuid" ] } }, "cert_main": { - "pack": [428, 30, 158], + "pack": [428, 23, 170], "data": { "ITEM": [ - 55, + 60, "cert_guid" ], "NAME": [ - 300, + 290, "cert_name" ], "LENS": [ - 65, + 70, "pub_length" ], "USED": [ diff --git a/Module/Certificates.py b/Module/Certificates.py index b6849b2..c3a7573 100644 --- a/Module/Certificates.py +++ b/Module/Certificates.py @@ -88,7 +88,7 @@ def parseCert(self): self.IssuedDate = self._certs_['start_time'] if 'start_time' in self._certs_ else "Unknown" self.ExpireDate = self._certs_['end_time'] if 'end_time' in self._certs_ else "Unknown" self.CertSHA160 = self._certs_['cert_sha1'] if 'cert_sha1' in self._certs_ else "Unknown" - + self.pub_length = str(self._certs_['pubkey_len']) if 'pubkey_len' in self._certs_ else "Unknown" self.pub_origin = str(self._certs_['pubkey']) if 'pubkey' in self._certs_ else "Unknown" self.pub_key_al = str(self._certs_['pubkey_type']) if 'pubkey_type' in self._certs_ else "Unknown" @@ -103,7 +103,7 @@ def parseCert(self): self.is_ca_cert = str(self.certExtend('basicConstraints')).split(":")[-1] self.CertPolicy = self.certExtend('certificatePolicies') - self.MainUsages = self.certExtend('keyUsage') if type(self.certExtend('keyUsage')) is str else "" + self.MainUsages = self.certExtend('keyUsage') if len(str(self.certExtend('keyUsage'))) > 0 else "" self.MainHashID = self.certExtend('authorityKeyIdentifier') self.SubsUsages = self.certExtend('extendedKeyUsage') self.SubsOwners = self.certExtend('subjectAltName') diff --git a/Module/__pycache__/Certificates.cpython-311.pyc b/Module/__pycache__/Certificates.cpython-311.pyc index 711457e5c32d6f840761edda538f432197b15d55..23dd03dc704dcd56fb5134d34d555513009a9966 100644 GIT binary patch delta 231 zcmX?N^wfxVIWI340}!Z{`lk18tpYP6E<9fb=vV z{RT*%5>#T8pZr!(o>5^luMj&UYY`LBw8a<`-0Cl$`umz0inrGf=ZJO1cfG-0qGPVy$VRr z0Mhq>^cg`RercFtDGb33n(~_!h1eM<>k2<(yTwvcS&%weLL`$>VRMs6A(N5qj+FiR zyYf$DU9^k5Vi$SQGU|$D)YZ7e3zi@>LuJ1HEd3Q)7o|+ENSR&$qV&wodg2!t8A~Sr Hmq-Hurh`Sq diff --git a/SmartCardAPP.py b/SmartCardAPP.py index 9657e37..fee8eeb 100644 --- a/SmartCardAPP.py +++ b/SmartCardAPP.py @@ -67,6 +67,14 @@ def __init__(self): "label_name": font.Font(family=FONT_NAME, size=-12, weight="bold") } + style_head = ttk.Style() + style_head.configure("Treeview.Heading", font=self.t_fonts['label_name']) + style_head.configure("Treeview", font=self.t_fonts['label_data']) + # style_head.configure("TButton", font=self.t_fonts['label_name']) + style_head.configure("TLabel", font=self.t_fonts['label_name']) + style_head.configure("TCheckbutton", font=self.t_fonts['label_name']) + style_head.configure("TCheckbutton", font=self.t_fonts['label_name']) + self.frames = { "card_main": self.view_frames("card_main"), "card_info": self.view_frames("card_info"), @@ -220,7 +228,8 @@ def view_tables(self, in_name, t_style='info'): inf = ttk.Treeview(self.root, bootstyle=t_style, show="headings", - columns=tb_name) + columns=tb_name, + ) bar = ttk.Scrollbar(self.root, bootstyle=t_style, orient='vertical', @@ -228,12 +237,12 @@ def view_tables(self, in_name, t_style='info'): inf.configure(yscrollcommand=bar.set) # 设置表格组件 ==================================================== inf.place(x=tb_pack[0], y=tb_pack[1], width=tb_lens + 25) - bar.place(x=tb_pack[0] + tb_lens + 10, - y=tb_pack[1] + 33, height=tb_pack[2]) + bar.place(x=tb_pack[0] + tb_lens + 13, + y=tb_pack[1] + 29, height=tb_pack[2]) # 设置表列信息 ==================================================== for th_name in tb_data: inf.heading(th_name, text=self.la(tb_data[th_name][1])) # 标题 - inf.column(th_name, anchor='center', width=tb_data[th_name][0]) + inf.column(th_name, anchor='w', width=tb_data[th_name][0]) return inf, bar return None, None @@ -817,7 +826,7 @@ def change(*args): if um_var.get(): um_txt.config(state=tk.NORMAL) um_txt.config(bootstyle="info") - um_tip.config(text="0-999%s" % self.la("msg_char")) + um_tip.config(text="0-65536%s" % self.la("msg_char")) else: um_txt.delete(0, tk.END) um_txt.config(state=tk.DISABLED) @@ -862,13 +871,16 @@ def submit(): emails = [i for i in emails if len(i) > 0] ken_len = kl_txt.get()[3:] ken_sha = kl_sha.get().lower() + csp_txt = "Microsoft Base Smart Card Crypto Provider" + if v_csp_ts.get() and len(csp_data.get()) > 0: + csp_txt = csp_data.get() full_text = ('[Version]\n' 'Signature="$Windows NT$"\n' '[NewRequest]\n' - 'ProviderName = "Microsoft Base Smart Card Crypto Provider"\n' + 'ProviderName = "%s"\n' 'ProviderType = 0\n' 'Exportable = FALSE\n' - 'MachineKeySet = TRUE\n') + 'MachineKeySet = TRUE\n' % csp_txt) full_text += 'Subject = "%s%s%s%s%s%s%s%s"\n' % ( "CN=%s," % cn if len(cn) > 0 else "Unknown,", @@ -956,8 +968,21 @@ def submit(): self.load_status() make.destroy() + def csp_ts(*args): + all_keys = list(locals().keys()) + list(globals().keys()) + if "v_csp_ts" in all_keys and "csp_data" in all_keys: + if v_csp_ts.get(): + csp_data.grid(column=2, row=10, pady=5, padx=15, sticky=W, columnspan=5) + csp_list = TPMSmartCard.CSPFetch() + csp_name = "Microsoft Base Smart Card Crypto Provider" + csp_data.config(values=csp_list) + if csp_name in csp_list: + csp_data.current(csp_list.index(csp_name)) + else: + csp_data.grid_forget() + make = ttk.Toplevel(self.root) - make.geometry("800x530") + make.geometry("800x540") make.geometry(f"+{self.size[0]}+{self.size[1]}") make.attributes('-topmost', True) make.title(self.la("msg_create") + self.la("msg_cert")) @@ -968,7 +993,7 @@ def submit(): cn_tag.grid(column=0, row=0, pady=10, padx=15) cn_txt = ttk.Entry(make, bootstyle="info", width=83, textvariable=cn_var) cn_txt.grid(column=1, row=0, pady=10, padx=5, columnspan=6) - cn_tip = ttk.Label(make, text="%s, 1-255%s" % (self.la("msg_must_in"), self.la("msg_char"))) + cn_tip = ttk.Label(make, text="%s1-64%s" % (self.la("msg_must_in"), self.la("msg_char"))) cn_tip.grid(column=7, row=0, pady=10, padx=5) st_tag = ttk.Label(make, text=self.la("user_area") + ": ") @@ -983,7 +1008,7 @@ def submit(): cc_tag = ttk.Label(make, text=self.la("user_code") + ": ") cc_tag.grid(column=6, row=1, pady=10, padx=15) - cc_txt = ttk.Combobox(make, bootstyle="info", width=8, values=list(self.conf['cncode'].keys())) + cc_txt = ttk.Combobox(make, bootstyle="info", width=7, values=list(self.conf['cncode'].keys())) cc_txt.grid(column=7, row=1, pady=10, padx=5, sticky=W, columnspan=2) cc_txt.set("N/A") @@ -994,7 +1019,7 @@ def submit(): ou_tag = ttk.Label(make, text=self.la("msg_ou_full") + ": ") ou_tag.grid(column=4, row=2, pady=10, padx=15, sticky=W) - ou_txt = ttk.Entry(make, bootstyle="info", width=39) + ou_txt = ttk.Entry(make, bootstyle="info", width=38) ou_txt.grid(column=5, row=2, pady=10, padx=5, sticky=W, columnspan=3) kl_tag = ttk.Label(make, text=self.la("pub_length") + ": ") @@ -1007,7 +1032,7 @@ def submit(): kl_sha.grid(column=2, row=3, pady=10, padx=5, sticky=W) kl_sha.set("SHA256") - ks_tag = ttk.Label(make, text=self.la("msg_ks_full") + ": ") + ks_tag = ttk.Label(make, text=self.la("msg_ks_full")) ks_tag.grid(column=3, row=3, pady=10, padx=15) v_sign = tk.IntVar() v_sign.set(1) @@ -1025,7 +1050,7 @@ def submit(): k_data.grid(column=5, row=3, pady=10, padx=5, sticky=W) k_data.state(['!alternate']) - ml_tag = ttk.Label(make, text=self.la("msg_ml_lite") + ": ") + ml_tag = ttk.Label(make, text=self.la("msg_ml_lite")) ml_tag.grid(column=6, row=3, pady=10, padx=15) um_var = tk.IntVar() um_var.trace('w', change) @@ -1049,7 +1074,7 @@ def submit(): ku_out[ku_inf] = tk.BooleanVar() ku_dat[ku_inf] = ttk.Checkbutton(make, bootstyle="primary", width=10, text=self.la(ku_inf), variable=ku_out[ku_inf]) - ku_dat[ku_inf].grid(column=ku_num, row=4, padx=5) + ku_dat[ku_inf].grid(column=ku_num, row=4, padx=8 if ku_inf == "DecipherOnly" else 5) ku_num += 1 ku_dat[ku_inf].state(['!alternate']) @@ -1058,22 +1083,22 @@ def submit(): dn_txt = ttk.Entry(make, bootstyle="info", width=83) dn_txt.grid(column=1, row=5, pady=10, padx=5, columnspan=6) dn_tip = ttk.Label(make, text="%s" % self.la("msg_splits")) - dn_tip.grid(column=7, row=5, pady=10, padx=5) + dn_tip.grid(column=7, row=5, pady=10, padx=0) um_tag = ttk.Label(make, text=self.la("msg_emails") + ": ") um_tag.grid(column=0, row=6, pady=10, padx=15) um_txt = ttk.Entry(make, bootstyle="default", width=83) um_txt.grid(column=1, row=6, pady=10, padx=5, columnspan=6) um_tip = ttk.Label(make, text=self.la("msg_ml_text")) - um_tip.grid(column=7, row=6, pady=10, padx=5) + um_tip.grid(column=7, row=6, pady=10, padx=0) um_txt.config(state=tk.DISABLED) dt_tag = ttk.Label(make, text=self.la("DESCRIPTION") + ": ") dt_tag.grid(column=0, row=7, pady=10, padx=15) dt_txt = ttk.Entry(make, bootstyle="info", width=83) dt_txt.grid(column=1, row=7, pady=10, padx=5, columnspan=6) - dt_tip = ttk.Label(make, text="0-999%s" % self.la("msg_char")) - dt_tip.grid(column=7, row=7, pady=10, padx=5) + dt_tip = ttk.Label(make, text="0-65536%s" % self.la("msg_char")) + dt_tip.grid(column=7, row=7, pady=10, padx=0) def resign(*args): if va_self.get(): @@ -1165,6 +1190,14 @@ def set_ca(*args): submit_button = ttk.Button(make, text=self.la("msg_create_csr"), command=submit, bootstyle="success") submit_button.grid(column=7, row=10, pady=5, padx=0) submit_button.config(state=tk.DISABLED) + v_csp_ts = tk.IntVar() + v_csp_ts.set(0) + v_csp_ts.trace('w', csp_ts) + csp_sets = ttk.Checkbutton(make, bootstyle="info-round-toggle", text=self.la('csp_set_'), + variable=v_csp_ts) + csp_data = ttk.Combobox(make, bootstyle="info", width=62, values=list()) + csp_sets.grid(column=1, row=10, pady=5, padx=15, sticky=W) + # csp_data.grid(column=2, row=10, pady=5, padx=15, sticky=W, columnspan=4) make.mainloop()