Rev 48 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 48 | Rev 49 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * ISO/IEC 7816 Application Identifier decoder for PHP |
4 | * ISO/IEC 7816 Application Identifier decoder for PHP |
5 | * Copyright 2022 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2022 Daniel Marschall, ViaThinkSoft |
6 | * Version 2022-09-19 |
6 | * Version 2022-09-20 |
7 | * |
7 | * |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | * you may not use this file except in compliance with the License. |
9 | * you may not use this file except in compliance with the License. |
10 | * You may obtain a copy of the License at |
10 | * You may obtain a copy of the License at |
11 | * |
11 | * |
Line 581... | Line 581... | ||
581 | $out[] = array('', c_literal_hexstr($aid)); |
581 | $out[] = array('', c_literal_hexstr($aid)); |
582 | 582 | ||
583 | if ((strlen($aid) == 32) && (substr($aid,-2) == 'FF')) { |
583 | if ((strlen($aid) == 32) && (substr($aid,-2) == 'FF')) { |
584 | // Sometimes you read that a 16-byte AID must not end with FF, because it is reserved by ISO. |
584 | // Sometimes you read that a 16-byte AID must not end with FF, because it is reserved by ISO. |
585 | // I have only found one official source: |
585 | // I have only found one official source: |
586 | // ISO/IEC 7816-5 : 1994 (E) |
586 | // ISO/IEC 7816-5 : 1994 |
587 | // Identification cards - Integrated circuit(s) cards with contacts - |
587 | // Identification cards - Integrated circuit(s) cards with contacts - |
588 | // Part 5 : Numbering system and registration procedure for application identifiers |
588 | // Part 5 : Numbering system and registration procedure for application identifiers |
589 | // https://cdn.standards.iteh.ai/samples/19980/8ff6c7ccc9254fe4b7a8a21c0bf59424/ISO-IEC-7816-5-1994.pdf |
589 | // https://cdn.standards.iteh.ai/samples/19980/8ff6c7ccc9254fe4b7a8a21c0bf59424/ISO-IEC-7816-5-1994.pdf |
590 | // Quote from clause 5.2: |
590 | // Quote from clause 5.2: |
591 | // "The PIX has a free coding. If the AID is 16 bytes long, |
591 | // "The PIX has a free coding. If the AID is 16 bytes long, |
592 | // then the value 'FF' for the least significant byte is reserved for future use." |
592 | // then the value 'FF' for the least significant byte is reserved for future use." |
593 | // In the revisions of ISO/IEC 7816, parts of ISO 7816-5 (e.g. the AID categories) |
593 | // In the revisions of ISO/IEC 7816, parts of ISO 7816-5 (e.g. the AID categories) |
594 | // have been moved to ISO 7816-4. |
594 | // have been moved to ISO 7816-4. |
595 | // The "FF" reservation cannot be found in modern versions of 7816-4 or 7816-5. |
595 | // The "FF" reservation cannot be found in modern versions of 7816-4 or 7816-5. |
596 | $out[] = array('',"INVALID: A 16-byte AID must not end with FF. (Reserved by ISO/IEC)"); |
596 | /*$out[] = array('',"INVALID: A 16-byte AID must not end with FF. (Reserved by ISO/IEC)");*/ |
- | 597 | $out[] = array('',"Note: A 16-byte AID ending with FF was reserved by ISO/IEC 7816-5:1994"); |
|
597 | } |
598 | } |
598 | 599 | ||
599 | if (strlen($aid) > 32) { |
600 | if (strlen($aid) > 32) { |
600 | $out[] = array('',"INVALID: An AID must not be longer than 16 bytes"); |
601 | $out[] = array('',"INVALID: An AID must not be longer than 16 bytes"); |
601 | } |
602 | } |
Line 640... | Line 641... | ||
640 | $out[] = array($iin, "ISO/IEC 7812 Issuer Identification Number (IIN)"); |
641 | $out[] = array($iin, "ISO/IEC 7812 Issuer Identification Number (IIN)"); |
641 | if ((strlen($iin) != 6) && (strlen($iin) != 8)) { |
642 | if ((strlen($iin) != 6) && (strlen($iin) != 8)) { |
642 | $out[] = array('',"Warning: IIN has an unusual length. 6 or 8 digits are expected!"); |
643 | $out[] = array('',"Warning: IIN has an unusual length. 6 or 8 digits are expected!"); |
643 | } |
644 | } |
644 | 645 | ||
645 | $out[] = array($category, "IIN Category $category = $check_cat_name"); |
646 | $out[] = array($category, "Major industry identifier $category = $check_cat_name"); |
646 | $pad .= str_repeat(' ', strlen("$category")); |
647 | $pad .= str_repeat(' ', strlen("$category")); |
647 | 648 | ||
648 | if ("$category" === "9") { |
649 | if ("$category" === "9") { |
649 | $country = substr($iin,1,3); |
650 | $country = substr($iin,1,3); |
650 | if ($country == '') { |
651 | if ($country == '') { |