Loading ePassport/ttcn/ePassport_Functions.ttcn +25 −5 Original line number Diff line number Diff line Loading @@ -134,14 +134,24 @@ */ external function fx_digest(in HashAlgorithm p_algorithm, in octetstring p_data) return octetstring; /** * @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 * @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) */ external function fx_extractPublicKey(in octetstring p_dgfile, out octetstring p_publicKey) return KeyAgreementAlgorithm; /** * @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 * @see Technical Guideline - Extended Access Control - Appendix D - D.1. Data Group 14 */ external function fx_computeDhSharedSecret(in octetstring p_privateKeyPicc, in octetstring p_publicKeyPiccAndDomainInfo, in octetstring p_publicKeyPcd) return octetstring; external function fx_computeDhSharedSecret(in octetstring p_privateKeyPicc, in KeyAgreementAlgorithm p_keyAgreementAlgorithm, in octetstring p_publicKeyPcd) return octetstring; /** * @desc Calculate the signature of a data block Loading Loading @@ -277,12 +287,19 @@ } } // end f_getHashLength function f_extractPublicKey( in octetstring p_dgfile, out octetstring p_publicKey) return KeyAgreementAlgorithm { return fx_extractPublicKey(p_dgfile, p_publicKey); } function f_computeSharedSecret( in octetstring p_privateKeyPicc, in octetstring p_publicKeyPiccAndDomainInfo, in KeyAgreementAlgorithm p_keyAgreementAlgorithm, in octetstring p_publicKeyPcd) return octetstring { return fx_computeDhSharedSecret(p_privateKeyPicc, p_publicKeyPiccAndDomainInfo, p_publicKeyPcd); return fx_computeDhSharedSecret(p_privateKeyPicc, p_keyAgreementAlgorithm, p_publicKeyPcd); } // end f_computeSharedSecret function f_build3DesKey(in octetstring p_keyPair) return octetstring { Loading Loading @@ -432,6 +449,8 @@ var octetstring v_k; var octetstring v_h; var octetstring v_dg14; var KeyAgreementAlgorithm algo; var octetstring v_dummy; var octetstring v_dg14PrivateKey; // a) The shared secret K = KA(SKPICC;^PKPCD;DPICC) = KA(^SKPCD;PKPICC;DPICC) Loading @@ -439,7 +458,8 @@ log("DG14: ", v_dg14); log("Read c_filePrCA: ", f_readFileData(c_filePrCA, 0, -1, v_dg14PrivateKey)); log("DG14.sk: ", v_dg14PrivateKey); v_k := f_computeSharedSecret(v_dg14PrivateKey, v_dg14, p_publicKeyPcd); algo := f_extractPublicKey(v_dg14, v_dummy); // Is it possible to set a function parameter optional? v_k := f_computeSharedSecret(v_dg14PrivateKey, algo, p_publicKeyPcd); // b) The session keys KMAC and KEnc derived from K for Secure Messaging. f_deriveKeys(v_k, vc_simu.kEnc, vc_simu.kMac); Loading ePassport/ttcn/ePassport_Types.ttcn +5 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ module ePassport_Types { e_ecdsaAndSha256 } type enumerated KeyAgreementAlgorithm { e_ecdh, e_dh } }//end enumeratedTypes group simuParamsGroup { Loading Loading
ePassport/ttcn/ePassport_Functions.ttcn +25 −5 Original line number Diff line number Diff line Loading @@ -134,14 +134,24 @@ */ external function fx_digest(in HashAlgorithm p_algorithm, in octetstring p_data) return octetstring; /** * @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 * @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) */ external function fx_extractPublicKey(in octetstring p_dgfile, out octetstring p_publicKey) return KeyAgreementAlgorithm; /** * @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 * @see Technical Guideline - Extended Access Control - Appendix D - D.1. Data Group 14 */ external function fx_computeDhSharedSecret(in octetstring p_privateKeyPicc, in octetstring p_publicKeyPiccAndDomainInfo, in octetstring p_publicKeyPcd) return octetstring; external function fx_computeDhSharedSecret(in octetstring p_privateKeyPicc, in KeyAgreementAlgorithm p_keyAgreementAlgorithm, in octetstring p_publicKeyPcd) return octetstring; /** * @desc Calculate the signature of a data block Loading Loading @@ -277,12 +287,19 @@ } } // end f_getHashLength function f_extractPublicKey( in octetstring p_dgfile, out octetstring p_publicKey) return KeyAgreementAlgorithm { return fx_extractPublicKey(p_dgfile, p_publicKey); } function f_computeSharedSecret( in octetstring p_privateKeyPicc, in octetstring p_publicKeyPiccAndDomainInfo, in KeyAgreementAlgorithm p_keyAgreementAlgorithm, in octetstring p_publicKeyPcd) return octetstring { return fx_computeDhSharedSecret(p_privateKeyPicc, p_publicKeyPiccAndDomainInfo, p_publicKeyPcd); return fx_computeDhSharedSecret(p_privateKeyPicc, p_keyAgreementAlgorithm, p_publicKeyPcd); } // end f_computeSharedSecret function f_build3DesKey(in octetstring p_keyPair) return octetstring { Loading Loading @@ -432,6 +449,8 @@ var octetstring v_k; var octetstring v_h; var octetstring v_dg14; var KeyAgreementAlgorithm algo; var octetstring v_dummy; var octetstring v_dg14PrivateKey; // a) The shared secret K = KA(SKPICC;^PKPCD;DPICC) = KA(^SKPCD;PKPICC;DPICC) Loading @@ -439,7 +458,8 @@ log("DG14: ", v_dg14); log("Read c_filePrCA: ", f_readFileData(c_filePrCA, 0, -1, v_dg14PrivateKey)); log("DG14.sk: ", v_dg14PrivateKey); v_k := f_computeSharedSecret(v_dg14PrivateKey, v_dg14, p_publicKeyPcd); algo := f_extractPublicKey(v_dg14, v_dummy); // Is it possible to set a function parameter optional? v_k := f_computeSharedSecret(v_dg14PrivateKey, algo, p_publicKeyPcd); // b) The session keys KMAC and KEnc derived from K for Secure Messaging. f_deriveKeys(v_k, vc_simu.kEnc, vc_simu.kMac); Loading
ePassport/ttcn/ePassport_Types.ttcn +5 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ module ePassport_Types { e_ecdsaAndSha256 } type enumerated KeyAgreementAlgorithm { e_ecdh, e_dh } }//end enumeratedTypes group simuParamsGroup { Loading