how to read Cyberflex e-gate cards SN with VB.net I'm trying to make my program work only if a e-gate cards SN like Cruiser, Smart clip, UST how to read the SN for cruiser for Ex. with vb.net and if any one have info about smart cards how it's security work to make aprotection for aprogram with my own Smart card thanks in advance br GakaxyMan |
Quote:
|
1 Attachment(s) thanks for your help I found this code and I think it's for deal with E-gate cards but it's C++ lang as I thinks and I dont know this programing lang and I think this part is to read the E-gate SN =========== /* read the card serial number from the EF_gdo system file */ 1195 static int flex_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) 1196 { 1197 int r; 1198 u8 buf[16]; 1199 size_t len; 1200 sc_path_t tpath; 1201 sc_file_t *tfile = NULL; 1202 1203 if (!serial) 1204 return SC_ERROR_INVALID_ARGUMENTS; 1205 /* see if we have cached serial number */ 1206 if (card->serialnr.len) { 1207 memcpy(serial, &card->serialnr, sizeof(*serial)); 1208 return SC_SUCCESS; 1209 } 1210 /* read EF_ICCSN */ 1211 sc_format_path("3F000002", &tpath); 1212 r = sc_select_file(card, &tpath, &tfile); 1213 if (r < 0) 1214 return r; 1215 len = tfile->size; 1216 sc_file_free(tfile); 1217 if (len != 8) { 1218 sc_debug(card->ctx, "unexpected file length of EF_ICCSN (%lu)\n", 1219 (unsigned long) len); 1220 return SC_ERROR_INTERNAL; 1221 } 1222 r = sc_read_binary(card, 0, buf, len, 0); 1223 if (r < 0) 1224 return r; 1225 card->serialnr.len = len; 1226 memcpy(card->serialnr.value, buf, len); 1227 1228 memcpy(serial, &card->serialnr, sizeof(*serial)); 1229 1230 return SC_SUCCESS; 1231 } 1232 1233 static int flex_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) 1234 { 1235 switch (cmd) { 1236 case SC_CARDCTL_GET_DEFAULT_KEY: 1237 return flex_get_default_key(card, 1238 (struct sc_cardctl_default_key *) ptr); 1239 case SC_CARDCTL_CRYPTOFLEX_GENERATE_KEY: 1240 return flex_generate_key(card, 1241 (struct sc_cardctl_cryptoflex_genkey_info *) ptr); 1242 case SC_CARDCTL_GET_SERIALNR: 1243 return flex_get_serialnr(card, (sc_serial_number_t *) ptr); 1244 } 1245 1246 return SC_ERROR_NOT_SUPPORTED; 1247 } 1248 1249 static int flex_build_verify_apdu(sc_card_t *card, sc_apdu_t *apdu, 1250 struct sc_pin_cmd_data *data) 1251 { 1252 static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; 1253 int r, len; 1254 int cla = card->cla, ins; 1255 1256 switch (data->pin_type) { 1257 case SC_AC_CHV: 1258 ins = 0x20; 1259 break; 1260 case SC_AC_AUT: 1261 /* AUT keys cannot be entered through terminal */ 1262 if (data->flags & SC_PIN_CMD_USE_PINPAD) 1263 return SC_ERROR_INVALID_ARGUMENTS; 1264 /* Override CLA byte */ 1265 if (!IS_CYBERFLEX(card)) 1266 cla = 0xF0; 1267 ins = 0x2A; 1268 break; 1269 default: 1270 return SC_ERROR_INVALID_ARGUMENTS; 1271 } 1272 /* Copy the PIN, with padding */ 1273 if ((r = sc_build_pin(sbuf, sizeof(sbuf), &data->pin1, 1)) < 0) 1274 return r; 1275 len = r; 1276 1277 sc_format_apdu(card, apdu, SC_APDU_CASE_3_SHORT, ins, 0, data->pin_reference); 1278 apdu->cla = cla; 1279 apdu->data = sbuf; 1280 apdu->datalen = len; 1281 apdu->lc = len; 1282 apdu->sensitive = 1; 1283 1284 return 0; 1285 } 1286 1287 static void flex_init_pin_info(struct sc_pin_cmd_pin *pin, unsigned int num) 1288 { 1289 pin->encoding = SC_PIN_ENCODING_ASCII; 1290 pin->max_length = 8; 1291 pin->pad_length = 8; 1292 pin->offset = 5 + num * 8; 1293 } 1294 1295 static int flex_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, 1296 int *tries_left) 1297 { 1298 sc_apdu_t apdu; 1299 int r; 1300 int old_cla = -1; 1301 1302 /* Fix pin data */ 1303 data->flags /= SC_PIN_CMD_NEED_PADDING; 1304 flex_init_pin_info(&data->pin1, 0); 1305 flex_init_pin_info(&data->pin2, 1); 1306 1307 if (data->cmd == SC_PIN_CMD_VERIFY) { 1308 r = flex_build_verify_apdu(card, &apdu, data); 1309 if (r < 0) 1310 return r; 1311 data->apdu = &apdu; 1312 } else if (data->cmd == SC_PIN_CMD_CHANGE // data->cmd == SC_PIN_CMD_UNBLOCK) { 1313 if (data->pin_type != SC_AC_CHV) 1314 return SC_ERROR_INVALID_ARGUMENTS; 1315 old_cla = card->cla; 1316 if (!IS_CYBERFLEX(card)) 1317 card->cla = 0xF0; ============ and I'll attache the full code but can any one try it or convert it to VB or VB.net thanks in advance |
No promises I will see what i can do, but i wont promis anythig. |
I found this file I think It will make it easy for us http://www2.cs.uh.edu/~shah/teaching...yberflexPG.pdf br GalaxyMan |
Quote:
|
Quote:
sorry but the linke is not working br GalaxyMan |
function of cardctl.h and internal.h, must be included |
All times are GMT +1. The time now is 08:04. |
vBulletin Optimisation provided by
vB Optimise (Pro) -
vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -