主密钥通过文件载入(16 字节明文),转 3 UKey 发行工具。
This commit is contained in:
parent
cf4bbf95b2
commit
191472d0d8
1
swa/.gitignore
vendored
Normal file
1
swa/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/.idea/
|
||||||
@ -30,6 +30,9 @@ function text(el, string) {
|
|||||||
el.innerText = string;
|
el.innerText = string;
|
||||||
}
|
}
|
||||||
function decode(der, offset) {
|
function decode(der, offset) {
|
||||||
|
|
||||||
|
console.log("der", der)
|
||||||
|
|
||||||
offset = offset || 0;
|
offset = offset || 0;
|
||||||
tree.innerHTML = '';
|
tree.innerHTML = '';
|
||||||
dump.innerHTML = '';
|
dump.innerHTML = '';
|
||||||
@ -74,12 +77,19 @@ function decodeText(val) {
|
|||||||
function decodeBinaryString(str) {
|
function decodeBinaryString(str) {
|
||||||
var der;
|
var der;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (reHex.test(str))
|
if (reHex.test(str))
|
||||||
der = Hex.decode(str);
|
der = Hex.decode(str);
|
||||||
else if (Base64.re.test(str))
|
else if (Base64.re.test(str))
|
||||||
der = Base64.unarmor(str);
|
der = Base64.unarmor(str);
|
||||||
else
|
else
|
||||||
|
try {
|
||||||
|
der = Base64.decode(str)
|
||||||
|
return decode(der);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
der = str;
|
der = str;
|
||||||
|
|
||||||
decode(der);
|
decode(der);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
text(tree, 'Cannot decode file.');
|
text(tree, 'Cannot decode file.');
|
||||||
|
|||||||
@ -11,6 +11,10 @@
|
|||||||
margin: 0 -15px 0 0;
|
margin: 0 -15px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tabs-content .tabs {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.tabs a {
|
.tabs a {
|
||||||
float: left;
|
float: left;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
122
swa/u/index.html
122
swa/u/index.html
@ -37,6 +37,12 @@
|
|||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#btn_write_group {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#mainkey_loaded {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<link rel="stylesheet" type="text/css" href="tabs.css">
|
<link rel="stylesheet" type="text/css" href="tabs.css">
|
||||||
<link rel="stylesheet" type="text/css" href="layx.min.css">
|
<link rel="stylesheet" type="text/css" href="layx.min.css">
|
||||||
@ -69,6 +75,10 @@
|
|||||||
<a href="#" name="tab_public">UKey 发行</a>
|
<a href="#" name="tab_public">UKey 发行</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="#" name="tab_main">主密钥分散</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" name="tab_file">文件操作</a>
|
<a href="#" name="tab_file">文件操作</a>
|
||||||
</li>
|
</li>
|
||||||
@ -81,6 +91,7 @@
|
|||||||
<a href="#" name="tab_pin">PIN 管理</a>
|
<a href="#" name="tab_pin">PIN 管理</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" name="tab_active">驱动程序</a>
|
<a href="#" name="tab_active">驱动程序</a>
|
||||||
</li>
|
</li>
|
||||||
@ -91,7 +102,7 @@
|
|||||||
<div class="tabs-content">
|
<div class="tabs-content">
|
||||||
|
|
||||||
|
|
||||||
<div class="tab tab_public">
|
<div class="tab tab_public" style="display: none">
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
|
|
||||||
@ -112,8 +123,23 @@
|
|||||||
<button id="btn_nameplate_release" style="margin-right: 1rem">发  行</button>
|
<button id="btn_nameplate_release" style="margin-right: 1rem">发  行</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab tab_main" style="display: none">
|
||||||
|
|
||||||
<div class="tab tab_file">
|
<div class="form">
|
||||||
|
<button id="select_file" onclick="read()">请先载入主密钥文件</button>
|
||||||
|
<span id="mainkey_loaded">主密钥已载入,请分别写入三个 UKey</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin: 3rem 0" id="btn_write_group">
|
||||||
|
<button id="btn_m1" style="margin-right: 1rem">写入分量1</button>
|
||||||
|
<button id="btn_m2" style="margin-right: 1rem">写入分量2</button>
|
||||||
|
<button id="btn_m3" style="margin-right: 1rem">写入分量3</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="tab tab_file" style="display: none">
|
||||||
|
|
||||||
|
|
||||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||||
@ -136,7 +162,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab tab_sign">
|
<div class="tab tab_sign" style="display: none">
|
||||||
|
|
||||||
|
|
||||||
<textarea id="inData" style="display: block; margin: 1rem 0; width: 375px; height: 100px;" placeholder="输入签名文本"></textarea>
|
<textarea id="inData" style="display: block; margin: 1rem 0; width: 375px; height: 100px;" placeholder="输入签名文本"></textarea>
|
||||||
@ -147,7 +173,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab tab_pin">
|
<div class="tab tab_pin" style="display: none">
|
||||||
<div class="group" style="width: 100%; ">
|
<div class="group" style="width: 100%; ">
|
||||||
<input id="pwd2" style="width: 300px;height: 1.06rem" type="password" maxlength="8"
|
<input id="pwd2" style="width: 300px;height: 1.06rem" type="password" maxlength="8"
|
||||||
placeholder="口令,8 个数字">
|
placeholder="口令,8 个数字">
|
||||||
@ -170,7 +196,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab tab_active" style="padding-top: 1rem">
|
<div class="tab tab_active" style="display:none; padding-top: 1rem">
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
@ -456,5 +482,91 @@
|
|||||||
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
function read() {
|
||||||
|
var input = document.createElement('input')
|
||||||
|
input.type = 'file'
|
||||||
|
|
||||||
|
input.click() // 开始选择文件
|
||||||
|
input.onchange = () => { // 监听选择文件的结果,获取选择到的文件
|
||||||
|
var file = input.files[0]
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function(e) {
|
||||||
|
console.log(this.result);
|
||||||
|
console.log(e.target.result)
|
||||||
|
console.log(e.target.result.byteLength)
|
||||||
|
|
||||||
|
if ( ! e.target.result || 16 !== e.target.result.byteLength ) {
|
||||||
|
alert("文件格式错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$("#btn_write_group").show();
|
||||||
|
$("#mainkey_loaded").show();
|
||||||
|
$("#select_file").hide();
|
||||||
|
|
||||||
|
|
||||||
|
window.mk = e.target.result
|
||||||
|
|
||||||
|
}
|
||||||
|
reader.readAsArrayBuffer(file);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$("#btn_m1").click(function (){
|
||||||
|
|
||||||
|
var d = gmhelper.decentralizedMainKey(window.mk)
|
||||||
|
publicWrite('\\root\\mana\\a20', { data: '31'})
|
||||||
|
publicWrite('\\root\\mana\\a30', { data: d.m.checkValue}) // 主密钥校验值
|
||||||
|
publicWrite('\\root\\mana\\a40', { data: d.m.keyCiphertext}) // 主密钥密文
|
||||||
|
publicWrite('\\root\\mana\\a50', { data: d.p.checkValue}) // 保护密钥校验值
|
||||||
|
publicWrite('\\root\\mana\\a60', { data: d.p1}) // 保护分量1
|
||||||
|
success("写入成功")
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#btn_m2").click(function (){
|
||||||
|
|
||||||
|
var d = gmhelper.decentralizedMainKey(window.mk)
|
||||||
|
publicWrite('\\root\\mana\\a20', { data: '32'})
|
||||||
|
publicWrite('\\root\\mana\\a30', { data: d.m.checkValue}) // 主密钥校验值
|
||||||
|
publicWrite('\\root\\mana\\a40', { data: d.m.keyCiphertext}) // 主密钥密文
|
||||||
|
publicWrite('\\root\\mana\\a50', { data: d.p.checkValue}) // 保护密钥校验值
|
||||||
|
publicWrite('\\root\\mana\\a60', { data: d.p2}) // 保护分量2
|
||||||
|
|
||||||
|
success("写入成功")
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#btn_m3").click(function (){
|
||||||
|
|
||||||
|
var d = gmhelper.decentralizedMainKey(window.mk)
|
||||||
|
publicWrite('\\root\\mana\\a20', { data: '33'})
|
||||||
|
publicWrite('\\root\\mana\\a30', { data: d.m.checkValue}) // 主密钥校验值
|
||||||
|
publicWrite('\\root\\mana\\a40', { data: d.m.keyCiphertext}) // 主密钥密文
|
||||||
|
publicWrite('\\root\\mana\\a50', { data: d.p.checkValue}) // 保护密钥校验值
|
||||||
|
publicWrite('\\root\\mana\\a60', { data: d.p3}) // 保护分量3
|
||||||
|
|
||||||
|
success("写入成功")
|
||||||
|
})
|
||||||
|
|
||||||
|
function publicWrite(filepath, txt) {
|
||||||
|
try {
|
||||||
|
const idx = filepath.lastIndexOf("\\")
|
||||||
|
const folder = filepath.substr(0, idx)
|
||||||
|
const file = filepath.substr(idx + 1)
|
||||||
|
window.UKey.writeFile(folder, file, JSON.stringify(txt));
|
||||||
|
} catch (e) {
|
||||||
|
alert("写入失败:" + e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -37,6 +37,10 @@
|
|||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tabs-content .tabs {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.tabs .current {
|
.tabs .current {
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
border-bottom-color: var(--mainColor);
|
border-bottom-color: var(--mainColor);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user