-
Notifications
You must be signed in to change notification settings - Fork 7
/
register.html
45 lines (37 loc) · 2.26 KB
/
register.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
<html>
<head>
<!-- NOTE this script is at https://github.com/simbo1905/thinbus-srp-npm/blob/master/browser.js -->
<script src="browser.thinbus.js"></script>
</head>
<body>
<h1>Thinbus Secure Remote Password Register Demo</h1>
<form action="/save" method="post">
username <input type="text" name="username" id="username"></input><br/>
password <input type="password" name="verifier" id="verifier"></input><br/>
<input type="hidden" name="salt" id="salt"></input>
<input type="hidden" name="verifier" id="verifier"></input>
<button type="button" onclick="createVerifier(this.parentElement)">Register</button>
</form>
<script>
// RFC 5054 2048bit constants
var rfc5054 = {
N_base10: "21766174458617435773191008891802753781907668374255538511144643224689886235383840957210909013086056401571399717235807266581649606472148410291413364152197364477180887395655483738115072677402235101762521901569820740293149529620419333266262073471054548368736039519702486226506248861060256971802984953561121442680157668000761429988222457090413873973970171927093992114751765168063614761119615476233422096442783117971236371647333871414335895773474667308967050807005509320424799678417036867928316761272274230314067548291133582479583061439577559347101961771406173684378522703483495337037655006751328447510550299250924469288819",
g_base10: "2",
k_base16: "5b9e8ef059c6b32ea59fc1d322d37f04aa30bae5aa9003b8321e21ddb04e300"
}
function createVerifier(form) {
var password = document.getElementById('verifier').value;
var username = document.getElementById('username').value;
// here we are using a module generated using "browserify --standalone thinbus" that adds the exported thinbus
// client session factor function onto the window object
var SRP6JavascriptClientSessionSHA256 = window.thinbus(rfc5054.N_base10, rfc5054.g_base10, rfc5054.k_base16);
var srpClient = new SRP6JavascriptClientSessionSHA256();
var salt = srpClient.generateRandomSalt();
var verifier = srpClient.generateVerifier(salt, username, password);
document.getElementById('verifier').value = verifier;
document.getElementById('salt').value = salt;
form.submit();
}
</script>
</body>
</html>