-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
256 lines (244 loc) · 10.8 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Encryption example</title>
<script src="lib/bower_components/jquery/dist/jquery.min.js"></script>
<script src="lib/bower_components/js-jose/dist/jose.js"></script>
<script src="lib/bower_components/kjur-jsrsasign/ext/yahoo-min.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/jsbn.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/jsbn2.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/prng4.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/rng.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/base64.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/rsa.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/rsa2.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/ec.js"></script>
<script src="lib/bower_components/kjur-jsrsasign//ext/ec-patch.js"></script>
<script src="lib/bower_components/webcrypto-shim/webcrypto-shim.js"></script>
<script src="lib/bower_components/kjur-jsrsasign/min/asn1hex-1.1.min.js"></script>
<script src="lib/bower_components/kjur-jsrsasign/min/base64x-1.1.min.js"></script>
<script src="lib/bower_components/kjur-jsrsasign/min/ecdsa-modified-1.0.min.js"></script>
<script src="lib/bower_components/kjur-jsrsasign/min/keyutil-1.0.min.js"></script>
<!-- Bootstrap -->
<link href="lib/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<script>
function loadPresets() {
$('#public_key').val("-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1qB2hmObbCbAM+lc+ggDauoIZReejEimnvrmeqEs0opeTeZiiietoHT1FkB8HjlgCWrh6UimxrRvBwwvNn/4uiVEqxuPb37ozWRj87bp1R3iwhzIGHBMgkibfFf9v3FxEjtY6CgCvOJ/12+AiotL+4jBCwsUWcqui3phq4/C19bQTWaN8u1Q1ABB0SSExcfqH3Ahg6i4pJfDwY+/khb4rgvmqPpb7a0tHiWuWqAMUxfEO/GJVaDV+Bq4k5vfUNirIcazUtmnLhBVSTBcjw7OEDEIHGckwUHs6prKE0kkQD4Xjm06XupuZW8/H+/oPBdHJBr+Ugv5Kzlsst/81BEyoQIDAQAB-----END PUBLIC KEY-----");
$('#endpoint').val("https://api.figo.me");
}
function encrypt(tan) {
// use jsrsasign to read the public key and convert it to jwk
var keyObj = KEYUTIL.getKey($('#public_key').val())
var jwk = KEYUTIL.getJWKFromKey(keyObj);
// init jose-js and pass the jwk to encrypt given credentials
var cryptographer = new Jose.WebCryptographer();
var rsa_key = Jose.Utils.importRsaPublicKey(jwk, "RSA-OAEP");
cryptographer.setContentEncryptionAlgorithm($("#content_encryption option:selected").val());
var encrypter = new JoseJWE.Encrypter(cryptographer, rsa_key);
var creds = "";
if (tan == false) {
creds = JSON.stringify([$('#user').val(),$('#additional_pin').val(),$('#pin').val()]);
$('#to_be_encrypted').html(creds);
encrypter.encrypt(creds).then(function(result) {
document.getElementById("encrypted_token").innerHTML = result;
}).catch(function(err){
console.error(err);
});
}
else {
creds = JSON.stringify($('#tan').val());
$('#tan_to_be_encrypted').html(creds);
encrypter.encrypt(creds).then(function(result) {
document.getElementById("encrypted_tan").innerHTML = result;
}).catch(function(err){
console.error(err);
});
}
}
</script>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<a class="navbar-brand" href="#">JWE Example</a>
</div>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<p>
<h4>Please enter the following information:</h4>
<div class="row">
<div class="col-md-2">Public Key:</div>
<div class="col-md-8"><textarea rows="10" cols="80" id="public_key"></textarea></div>
<div class="col-md-2">
<button type="button" class="btn btn-primary" onclick="loadPresets(); return false;">load figo presets</button>
</div>
</div>
</p>
<div class="row">
<p>
<div class="col-md-2">Choose content encryption algorithm:</div>
<div class="col-md-3">
<select class="form-control" id="content_encryption">
<option>A128CBC-HS256</option>
<option selected="selected">A256CBC-HS512</option>
</select>
</div>
</p>
</div>
<hr>
<!--h4>If you want to test the generated JWE against a specific API, please enter the following information:</h4>
<p>
<div class="row">
<div class="col-md-2">Endpoint:</div>
<div class="col-md-10"><input type="text" size="50" id="endpoint"></input></div>
</div>
</p>
<p>
<div class="row">
<div class="col-md-2">Client ID:</div>
<div class="col-md-10"><input type="text" size="90"></input></div>
</div>
<div class="row">
<div class="col-md-2">Client Secret:</div>
<div class="col-md-10"><input type="password" size="90"></input></div>
</div>
</p -->
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Prepare bank credentials</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<form>
<div class="row">
<p>
<div class="col-md-4">Username:</div>
<div class="col-md-6"><input type="text" size="40" id="user"></input></div>
</p>
</div>
<div class="row">
<p>
<div class="col-md-4">Password:</div>
<div class="col-md-6"><input type="text" size="40" id="pin"></input></div>
</p>
</div>
<div class="row">
<p>
<div class="col-md-4">Additional Password:</div>
<div class="col-md-6"><input type="text" size="40" id="additional_pin"></input></div>
</p>
</div>
<p>
<div class="row">
<p>
<div class="col-md-4"></div>
<div class="col-md-6"><button type="button" class="btn btn-warning" onclick="encrypt(false); return false;">convert</button></input></div>
</p>
</div>
</p>
</form>
</div>
<div class="col-md-6">
<div class="row">
<p>
<div class="col-md-2">Data to encrypt:</div>
<div class="col-md-10" id="to_be_encrypted"></div>
</p>
</div>
<div class="row">
<p>
<div class="col-md-6">Example request:</div>
<div class="col-md-6"></div>
</p>
</div>
<div class="row">
<div class="col-md-12">
<pre style="white-space: pre-line;">
{
"bank_code" : "90090042",
"country" : "de",
"credentials" : {
"type" : "encrypted",
"value" : "<span id="encrypted_token" style="word-wrap:break-word;"></span>"
}
}
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Prepare challenge response (TAN)</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<form>
<div class="row">
<p>
<div class="col-md-4">TAN:</div>
<div class="col-md-6"><input type="text" size="40" id="tan"></input></div>
</p>
</div>
<p>
<div class="row">
<p>
<div class="col-md-4"></div>
<div class="col-md-6"><button type="button" class="btn btn-warning" onclick="encrypt(true); return false;">convert</button></input></div>
</p>
</div>
</p>
</form>
</div>
<div class="col-md-6">
<div class="row">
<p>
<div class="col-md-2">Data to encrypt:</div>
<div class="col-md-10" id="tan_to_be_encrypted"></div>
</p>
</div>
<div class="row">
<p>
<div class="col-md-6">Example request:</div>
<div class="col-md-6"></div>
</p>
</div>
<div class="row">
<div class="col-md-12">
<pre style="white-space: pre-line;">
{
"response" : {
"type" : "encrypted",
"value" : "<span id="encrypted_tan" style="word-wrap:break-word;"></span>"
}
}
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="lib/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>