Commit 9458e1e2 authored by berge's avatar berge
Browse files

Cleanup + T3Doc

parent 6e2444f0
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -122,11 +122,11 @@ module ePassport_Altsteps {
                } 
                
                // Fail verdicts
                log("**** Checking Failure verdicts... ****");
                log("**** f_establishVerdict: INFO: Checking Failure verdicts... ****");
                v_checkFailVerdicts := match(vc_simu.isFailVerdicts, p_expectedFailResults);
                
                // Pass verdicts
                log("**** Checking Pass verdicts... ****");
                log("**** f_establishVerdict: INFO: Checking Pass verdicts... ****");
                v_checkPassVerdicts := match(vc_simu.isPassVerdicts, p_expectedPassResults);
                
                v_generalVerdict := v_checkFailVerdicts and v_checkPassVerdicts;
@@ -134,11 +134,11 @@ module ePassport_Altsteps {
            
            // Take decision and assign testcase verdict
            if(v_generalVerdict) {
                log("**** ", p_testcaseId, ": Pass: Inspection System produced expected result ****");
                log("**** ", p_testcaseId, ": PASS: Inspection System produced expected result ****");
                setverdict(pass);
            }
            else {
                log("**** ", p_testcaseId, ": Error: Inspection Sytem did not produce expected result ****");
                log("**** ", p_testcaseId, ": FAIL: Inspection Sytem did not produce expected result ****");
                setverdict(fail);
            }  
        } // end f_establishVerdict
@@ -198,24 +198,24 @@ module ePassport_Altsteps {
         */
        altstep a_default() runs on MRTD {
            [] t_guard.timeout {
                log("**** a_default: Error: Lifetime of testcase has expired. Sopping TC now. ****");
                log("**** a_default: ERROR: Lifetime of testcase has expired. Sopping TC now. ****");
                setverdict(inconc);
                f_cleanUp();
                stop;
            }
            [] any timer.timeout {
                log("**** a_default: Error: Unexpected timeout occured. ****");
                log("**** a_default: ERROR: Unexpected timeout occured. ****");
                setverdict(inconc);
                f_cleanUp();
                stop;
            }
            [] mrtdport.receive(mw_genericCommand) {
                log("**** a_default: Error: Unexpected message received. ****");
                log("**** a_default: ERROR: Unexpected message received. ****");
                mrtdport.send(m_responseNOK(c_w1w2InstructionCodeNotSupportedOrInvalid)); 
                repeat;
            }
            [] mrtdport.receive {
                log("**** a_default: Error: Unexpected message received. ****");
                log("**** a_default: ERROR: Unexpected message received. ****");
                mrtdport.send(m_responseNOK(c_w1w2InstructionCodeNotSupportedOrInvalid));
                setverdict(inconc);
                f_cleanUp();
@@ -303,7 +303,7 @@ module ePassport_Altsteps {
                // set current file for logical channel
                v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
                vc_simu.currentFiles[v_logicalChannel] := getFileByShortId(c_fileDGCertData.shortFileId);
                log("**** Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                log("**** a_aisReadCertificateData: INFO: Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                
                v_offset := v_readCommand.params.fileIdAndOffset.offset;
                v_dataLength := v_readCommand.lengthE;
@@ -331,12 +331,12 @@ module ePassport_Altsteps {
            var CommandGeneric v_report;
            
            [] mgmtport.receive(mw_report(int2oct(enum2int(e_aisNoFailure), 2))) {
                log("**** Success reported ****");
                log("**** a_aisReports: INFO: Success reported ****");
                f_pushPassResult(e_aisNoFailure);
                mgmtport.send(m_responseOK);
            }
            [] mgmtport.receive(mw_report(?)) -> value v_report {
                log("**** Failure reported: ", f_aisOctResultToEnum(v_report.payload.genericData.data[0]), " ****");
                log("**** a_aisReports: INFO: Failure reported: ", f_aisOctResultToEnum(v_report.payload.genericData.data[0]), " ****");
                f_pushFailResult(f_aisOctResultToEnum(v_report.payload.genericData.data[0]));
                mgmtport.send(m_responseOK);
                if(v_report.params.p2 != c_aisLastCommand) {
@@ -464,7 +464,6 @@ module ePassport_Altsteps {
                
                if(f_isTrustedCertificate(oct2char(v_dstCAR))) {
                    f_setDst(oct2char(v_dstCAR));
                    log("Setting DST: ", v_dstCAR);
                    mrtdport.send(m_responseOK);
                }
                else {
@@ -488,7 +487,6 @@ module ePassport_Altsteps {
                    v_chr := oct2char(v_psoCommand.payload.performSecurityOperationData.psoVerifyCertificate
                            .psoVerifyCertificateOverFullTemplate.cvCertificateBody.tlvValue.cvCertificateHolderReference.tlvValue);
                    f_addTrustedCertificate(v_chr, v_publicKey);
                    log("Adding trusted certificate: ", v_chr);
                    mrtdport.send(m_responseOK);
                 }
                 else {
@@ -648,7 +646,7 @@ module ePassport_Altsteps {
                // set current file for logical channel
                v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
                vc_simu.currentFiles[v_logicalChannel] := getFileByShortId(p_file.shortFileId);
                log("**** Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                log("**** a_readFile: INFO: Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                
                v_offset := v_readCommand.params.fileIdAndOffset.offset;
                v_dataLength := v_readCommand.lengthE;
@@ -769,7 +767,7 @@ module ePassport_Altsteps {
                v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
                v_shortFileId := bit2oct(v_readCommand.params.fileIdAndOffset.fileId);
                vc_simu.currentFiles[v_logicalChannel] :=  getFileByShortId(v_shortFileId);
                log("**** Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                log("**** a_readAnyFile: INFO: Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                
                v_offset := v_readCommand.params.fileIdAndOffset.offset;
                
+26 −27
Original line number Diff line number Diff line
@@ -133,8 +133,8 @@
            /**
             * @desc    This method verifies a digitally signed message based on DSA or RSA cryptographic algorithms
             * @param   p_message   The original message to verify
             * @param   p_signedMessage The signed message to verify
             * @param   p_key           The Document Signer Public Key (KPuDS) in PEM format
             * @param   p_signature The signed message to verify
             * @param   p_publicKey The Document Signer Public Key (KPuDS) in PEM format
             * @return  true if the message is verified successfully, false otherwise
             */
            external function fx_verifySignature(in octetstring p_message, in octetstring p_signature, in octetstring p_publicKey) return boolean;
@@ -171,8 +171,8 @@

            /**
             * @desc    Extract the public key information from the provided DGxx file content
             * @param   dgfile  The DGxx file content
             * @param   key     The public key in byte format
             * @param   p_dgfile    The DGxx file content
             * @param   p_publicKey The public key in byte format
             * @return  The algorithm
             * @see     LDS 1.7 2004-05-18 document - Page 90 for DG14/DG15 ASN.1 structure (and use ASN.1 editor to vizualize the files content)
             */
@@ -181,9 +181,9 @@
            /**
             * @desc    Compute a Diffie-Hellman shared secret
             * @param   p_privateKeyPicc    Private key of peer A
             * @param   p_publicKeyPiccAndDomainInfo    Public key of peer A (not used) and DH domain info
             * @param   p_publicKeyPcd      Public key of peer B
             * @return  Diffie-Hellman shared secret
             * @param   p_keyAgreement      Computed shared secret
             * @return  Used key agreement algorithm 
             * @see     Technical Guideline - Extended Access Control - Appendix D - D.1. Data Group 14
             */
            external function fx_computeDhSharedSecret(in octetstring p_privateKeyPicc, in octetstring p_publicKeyPcd, out octetstring p_keyAgreement) return KeyAgreementAlgorithm;
@@ -199,7 +199,7 @@
            
            /**
             * @desc    Extract X-Coordinate from EC public key
             * @param   p_publicKey EC public key
             * @param   p_ecPublicKey   EC public key
             * @return  X-Coordinate of EC public key
             */
            external function fx_extractXcoordinateFromEcPublicKey(in octetstring p_ecPublicKey) return octetstring;
@@ -323,9 +323,9 @@
        
        /**
         * @desc    Derive Kenc (KencA+KencB) and Kmac (KmacA+KmacB) keys from key seed.
         * @param   p_kSeed Key seed
         * @param   p_kEnc  Calculated Kenc
         * @param   p_kMac  Calculated Kmac
         * @param   p_keySeed   Key seed
         * @param   p_keyEnc    Calculated Kenc
         * @param   p_keyMac    Calculated Kmac
         * @see     PKI for Machine Readable Travel Documents offering ICC Read-Only Access - Annex E Basic Access Control and Secure Messaging
         */
        function f_deriveKeys(
@@ -399,7 +399,7 @@
        /**
         * @desc    This method verifies a digitally signed message based on DSA or RSA cryptographic algorithms
         * @param   p_message   The original message to verify
         * @param   p_signedMessage The signed message to verify
         * @param   p_signature The signed message to verify
         * @param   p_publicKey The Document Signer Public Key (KPuDS) in PEM format
         * @return  true if the message is verified successfully, false otherwise
         */
@@ -567,7 +567,7 @@
            // a) Check the checksum M_IFD of the cryptogram E_IFD.
            v_computedMacIfd := f_cryptographicChecksum(vc_simu.kMac, v_encryptedIfd);
            if(not match(v_computedMacIfd, v_macIfd)) {
                log("CHECKSUM ERROR");
                log("**** f_basicAccessControl: ERROR: Checksum error ****");
                mrtdport.send(m_responseNOK(c_w1w2NoPreciseDiagnosis));
                return ''O;
            }
@@ -628,19 +628,19 @@
            
            // create trailer (SHA1)
            if(vc_simu.aaHashAlgorithm == e_sha1) {
                v_trailer := 'BC'O; 
                v_trailer := c_trailerSha1; 
            }
            else if (vc_simu.aaHashAlgorithm == e_sha224) {
                v_trailer := '38CC'O; 
                v_trailer := c_trailerSha224; 
            }
            else if (vc_simu.aaHashAlgorithm == e_sha256) {
                v_trailer := '34CC'O; 
                v_trailer := c_trailerSha256; 
            }
            else if (vc_simu.aaHashAlgorithm == e_sha384) {
                v_trailer := '36CC'O; 
                v_trailer := c_trailerSha384; 
            }
            else if (vc_simu.aaHashAlgorithm == e_sha512) {
                v_trailer := '35CC'O; 
                v_trailer := c_trailerSha512; 
            }
            
            // determine lengths
@@ -659,7 +659,7 @@
            v_h := f_digest(vc_simu.aaHashAlgorithm, v_m);
            
            // construct message representative
            v_f := '6A'O & v_m1 & v_h & v_trailer; 
            v_f := c_messageRepresentativeHeader & v_m1 & v_h & v_trailer; 
            
            // encrypt message representative
            f_readFileData(c_filePrAA, 0, -1, v_aaPrivateKey);
@@ -965,7 +965,7 @@
            if(not(PXT_AUTOMATIC_TEST_INTERFACE)) {
                if(p_specialOperatorMessage != "") {
                    action(p_specialOperatorMessage);
                    log("**** ", p_specialOperatorMessage, " ****");
                    log("**** f_initializeIS: INFO: ", p_specialOperatorMessage, " ****");
                    f_sleepIgnoreDef(10.0);
                }
                
@@ -976,8 +976,8 @@
                    & v_opticalMrzLine2 & c_CRLF
                );
                
                log("**** Optical MRZ Line 1: ", v_opticalMrzLine1, " ****");
                log("**** Optical MRZ Line 2: ", v_opticalMrzLine2, " ****");
                log("**** f_initializeIS: INFO: Optical MRZ Line 1: ", v_opticalMrzLine1, " ****");
                log("**** f_initializeIS: INFO: Optical MRZ Line 2: ", v_opticalMrzLine2, " ****");
            }
            
        } // end f_initializeIS
@@ -1081,7 +1081,6 @@
            // ECDSA domain parameters are only contained in CVCA certificates
            if(f_isTrustPoint(p_chr)) {
                f_setSignatureVerificationParameters(f_getDstPublickey());
                log("setting sigverifparams");
            }
        } // end f_setDst
        
+3 −3
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ module ePassport_Templates {
         */
        template CommandPutDataWith mw_report(template Oct2 v_failCode) := {
            class := mw_class_01,
            ins := e_putDataWithDataBytes, //'da'O,
            ins := e_putDataWithDataBytes,
            params := {
                p1 := '00000001'B, //'00001111'B YGA See Table 3.6 - Put Data PDU
                p2 := ?
@@ -139,7 +139,7 @@ module ePassport_Templates {
            lengthC := ?,
            payload := { 
                selectData := {
                    fileId := 'a0000002471001'O // FIXME
                    fileId := c_ePassportApplication
                }
            },
            lengthE :=  omit
@@ -192,7 +192,7 @@ module ePassport_Templates {

        /**
         * @desc    Receive template for file reading using short file ID
         * @param   v_fileID    Short file ID of the file to be read
         * @param   p_shortFileId   Short file ID of the file to be read
         */
        template CommandReadBinary mw_readShortEF (ShortFileId p_shortFileId) := {
            class := mw_class_00,
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ module ePassport_Testcases {
                    // set current file for logical channel
                    v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
                    vc_simu.currentFiles[v_logicalChannel] := getFileByShortId(c_fileDG1.shortFileId);
                    log("**** Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                    log("**** TC_ISO7816_B08: INFO: Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
                    
                    v_offset := v_readCommand.params.fileIdAndOffset.offset;
                    v_dataLength := v_readCommand.lengthE;
+11 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ module ePassport_Values {
    // ATS
    import from ePassport_Types all;

    const octetstring c_ePassportApplication := 'a0000002471001'O;

    /**
     * @desc    Constant definitions for Class field
     */
@@ -103,6 +105,15 @@ module ePassport_Values {
        const integer c_bacKeySize := 16;
        const integer c_atNonceSize := 8;
        
        const octetstring c_messageRepresentativeHeader := '6A'O;
        
        const octetstring c_trailerSha1 := 'BC'O; 
        const octetstring c_trailerSha224 := '38CC'O; 
        const octetstring c_trailerSha256 := '34CC'O; 
        const octetstring c_trailerSha384 := '36CC'O; 
        const octetstring c_trailerSha512 := '35CC'O; 
        
        
    } // end securityValues
        
    /**