-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
99 lines (98 loc) · 4.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html><html lang="ja">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>E2EEメッセージングヘルパー Ed25519 version</title>
<script type="module">
import * as sec from "https://code4fukui.github.io/sec.js/sec.js";
import { Base16 } from "https://code4fukui.github.io/Base16/Base16.js";
onload = () => {
generatebutton.onclick = async () => {
const prikey = sec.prikey();
const pubkey = sec.pubkey(prikey);
publickey.value = Base16.encode(pubkey);
privatekey.value = Base16.encode(prikey);
};
generatebutton2.onclick = async () => {
const pubkey2 = Base16.decode(publickey2.value);
const prikey = Base16.decode(privatekey.value);
const shkey = sec.sharekey(prikey, pubkey2);
sharekey.value = Base16.encode(shkey);
};
encryptbutton.onclick = async () => {
const data = new TextEncoder().encode(messagetext.value);
const key = Base16.decode(sharekey.value);
const cipher = sec.encrypt(key, data);
ciphertext.value = Base16.encode(cipher);
};
decryptbutton.onclick = async () => {
const key = Base16.decode(sharekey.value);
const cipher = Base16.decode(ciphertext.value);
const data = sec.decrypt(key, cipher);
if (data) {
messagetext.value = new TextDecoder().decode(data);
} else {
messagetext.value = "復号失敗";
}
};
};
</script>
<style>
body {
font-family: sans-serif;
}
input[type="text"] {
width: 80vw;
}
.message {
width: 30vw;
height: 5em;
}
.description {
font-size: 85%;
}
</style>
</head>
<body>
<main>
<h1>E2EEメッセージングヘルパー</h1>
<section>
<div class=description>既存の信用できない通信路を使った信用できる通信を実現する補助ツールです。<br><a href=https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%89%E3%83%AF%E3%83%BC%E3%82%BA%E6%9B%B2%E7%B7%9A%E3%83%87%E3%82%B8%E3%82%BF%E3%83%AB%E7%BD%B2%E5%90%8D%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0>Ed25519</a>/<a href=https://ja.wikipedia.org/wiki/Curve25519>X25519</a>でキーペアの生成と受け取った公開鍵から共通鍵の生成をし、共通鍵暗号<a href=https://ja.wikipedia.org/wiki/Galois/Counter_Mode>AES-GCM</a>で暗号化復号化します。<br>本ページの読み込み後、サーバーとの通信はしません。<a href=https://github.com/code4sabae/e2ee/blob/main/ed25519.html>ソースファイル</a>でご確認ください。</div>
<br>
<input id="generatebutton" type="button" value="1. キーペア(公開鍵と秘密鍵)をつくる"><br>
<br>
秘密鍵(誰にも見せてはいけない鍵)<br>
<input type="text" id="privatekey"><br>
公開鍵(相手に渡す鍵、公開してもOK!)<br>
<input type="text" id="publickey"><br>
<br>
2. 相手の公開鍵(通信する相手から公開鍵をもらって書く、一人で試す場合→<a href=./ target=_blank>新ウィンドウ</a>)<br>
<input type="text" id="publickey2"><br>
<br>
<input id="generatebutton2" type="button" value="3. 通信用の共通鍵をつくる"><br>
<br>
共通鍵(ネットワークには流れていないけど、通信相手と同じ鍵)<br>
<input type="text" id="sharekey"><br>
<br>
<hr>
<table>
<tr><th>メッセージ</th><th></th><th>暗号</th></tr>
<tr>
<td><textarea class="message" id="messagetext"></textarea></td>
<td>
<input id="encryptbutton" type="button" value="暗号化→"><br>
<br>
<input id="decryptbutton" type="button" value="←復号化"><br>
</td>
<td><textarea class="message" id="ciphertext"></textarea></td>
</tr>
</table>
<br>
</section>
<hr>
<div id="credit">
App: <a href=https://github.com/code4fukui/e2ee/>src on GitHub</a><br>
Lib: <a href=https://github.com/code4fukui/sec.js>sec.js</a>(Ed25519, X25519, Ed25519-to-X25519, AES-256-GCM, <a href=https://developer.mozilla.org/ja/docs/Web/API/Web_Crypto_API>Web Crypto API</a>)<br>
Blog: <a href=https://fukuno.jig.jp/3908>E2EE サイバーセキュリティ at 神山まるごと高専</a><br>
</div>
</main>
</body>
</html>