forked from cardid/WebCard-IE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebCard.html
82 lines (77 loc) · 2.85 KB
/
WebCard.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
<!DOCTYPE html>
<!-- saved from url=(0013)about:internet -->
<!-- The above comment makes IE treat this as a web page -->
<html>
<head>
<title>WebCard Test Page</title>
<style type="text/css">
body {margin: 60px; font: 12pt helvetica, arial, sans-serif;}
</style>
</head>
<script type="text/javascript">
function addEvent(obj, name, func)
{
if (obj.attachEvent) {
obj.attachEvent("on" + name, func);
} else {
obj.addEventListener(name, func, false);
}
}
function log(data) {
document.getElementById("log").textContent += data + "\n";
}
function pluginLoaded() {
window.webcard = document.getElementById("webcard");
log("WebCard version " + webcard.version);
addEvent(webcard, "cardpresent", cardPresent);
addEvent(webcard, "cardremoved", cardRemoved);
for (var i = 0; i < webcard.readers.length; i++) {
var rdr = document.createElement("h3");
rdr.textContent = webcard.readers[i].name;
rdr.id = webcard.readers[i].name.replace(/\s/g, "").toLowerCase();
document.getElementById("readerList").appendChild(rdr);
}
}
function cardPresent(reader) {
document.getElementById(reader.name.replace(/\s/g, "").toLowerCase()).style.color = "green";
setTimeout(initCard(reader), 10);
}
function cardRemoved(reader) {
document.getElementById(reader.name.replace(/\s/g, "").toLowerCase()).style.color = "inherit";
}
function initCard(reader) {
reader.connect(2); // 1-Exclusive, 2-Shared
log("ATR : " + reader.atr);
var apdu = "FFCA000000";
var resp = reader.transcieve(apdu);
if (resp.substr(-4) == "9000") {
log("UID : " + resp.substr(0, resp.length - 4));
}
apdu = '00A404000BA000000308000010000100';
resp = reader.transcieve(apdu);
if (resp.substr(-4) == "9000") {
log("FIPS 201 SP800-73 (PIV)");
}
apdu = "00A404000E315041592E5359532E4444463031";
resp = reader.transcieve(apdu);
if (resp.substr(-4) == "9000") {
log("EMV Payment Card");
}
apdu = "00A4040007A0000002471001";
resp = reader.transcieve(apdu);
if (resp.substr(-4) == "9000") {
log("ICAO Machine Readable Travel Document");
}
reader.disconnect();
}
</script>
<body>
<h1>Smart Card Browser Plugin</h1>
<object id="webcard" type="application/x-webcard" width="0" height="0">
<param name="onload" value="pluginLoaded" />
</object>
<div id="readerList"></div>
<textarea id="log" rows="10" cols="100"></textarea>
<p>For this page to work you need to install Webcard <a href="http://plugin.cardid.org/webcard.msi">for Windows</a> or <a href="http://plugin.cardid.org/webcard.dmg"> for Mac OS X</a></p>
</body>
</html>