apdu/bin/card.ml

141 lines
3.3 KiB
OCaml
Raw Permalink Normal View History

2024-08-12 10:19:36 +07:00
open SmartCard
(** This file contains the default card data *)
(* EF.CardAccess *)
let ef_cardacces =
Filesystem.ElementaryFile {
fid = Bytes.of_string "\x01\x1C";
sid = Bytes.of_string "\x1C";
data = Hex.to_bytes (Hex.of_string "3134300d060804007f0007020202020101300f060a04007f000702020302020201013012060a04007f0007020204020202010202010d");
}
(* EF.CardSecurity *)
let ef_cardsecurity =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x1D";
data = Hex.to_bytes (Hex.of_string "");
}
(* EF.DIR *)
let ef_dir =
Filesystem.ElementaryFile {
fid = Bytes.of_string "\x01\x1E";
sid = Bytes.of_string "\x1E";
data = Hex.to_bytes (Hex.of_string "");
}
(* EF.ATR
The EF.ATR/INFO may be called EF.ATR in contact card
standards or specifications, and may be called EF.INFO
in contactless card standards or specifications
The contents of the EF.ATR/INFO can be freely retrieved by using a GET DATA command with
P1-P2 = '2F 01' and a command data field of '5C 00' ('00 CB 2F 01 02 5C 00'). The response data field for
the GET DATA command is the concatenation of all Data Objects (DO) which are present in EF.ATR/INFO.
It contains the BER-TLV content of the EF.ATR/INFO
*)
let ef_atr =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x01";
data = Hex.to_bytes (Hex.of_string "");
}
(* EF.COM *)
let ef_com =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x1E";
data = Bytes.of_string (Base64.decode_exn "");
}
(* EF.DG1 *)
let ef_dg1 =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x01";
data = Bytes.of_string (Base64.decode_exn "");
}
(* EF.DG2 *)
let ef_dg2 =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x02";
data = Bytes.of_string (Base64.decode_exn "");
}
(* EF.DG13 *)
let ef_dg13 =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x0D";
data = Bytes.of_string (Base64.decode_exn "");
}
(* EF.DG14 *)
let ef_dg14 =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x0E";
data = Bytes.of_string (Base64.decode_exn "");
}
(* EF.DG15 *)
let ef_dg15 =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x0F";
data = Bytes.of_string (Base64.decode_exn "");
}
(* EF.SOD *)
let ef_sod =
Filesystem.ElementaryFile {
fid = Bytes.of_string "";
sid = Bytes.of_string "\x1D";
data = Bytes.of_string (Base64.decode_exn "");
}
(* LDS1 eMRTD Application *)
let emrtd_application =
Filesystem.DelicatedFile {
fid = Bytes.of_string "";
aid = Some (Bytes.of_string "\xA0\x00\x00\x02\x47\x10\x01");
files = [
ef_com;
ef_dg1;
ef_dg2;
ef_dg13;
ef_dg14;
ef_dg15;
ef_sod
];
}
(** The masterfile MF for the card *)
let masterfile = Filesystem.DelicatedFile {
fid = Bytes.of_string "\x3F\x00";
aid = None;
files = [
ef_cardacces;
emrtd_application
];
}
(** The card can have multiple files, MF included *)
let allfiles = [masterfile]
let custom : CardState.t = {
masterfile = Some masterfile;
allfiles = allfiles;
sm = None;
current_file = None;
}