library: add SGP.32 and SGP.22 ASN.1 specification, encoder and templates

This patch adds the eUICC related SGP.32 and SGP.22 ASN.1 specification
along with templates and related encoder/decoders (_EncDec.cc).

The collection of templates is not comprehensive, which means that there
are only templates available for a subset needed to implement testcases
for an IPAd.

Related: SYS#6563
Change-Id: I9df8caa98aeb6953a738660a758c92249832d780
diff --git a/library/euicc/SGP32Definitions_Templates.ttcn b/library/euicc/SGP32Definitions_Templates.ttcn
new file mode 100644
index 0000000..f22778c
--- /dev/null
+++ b/library/euicc/SGP32Definitions_Templates.ttcn
@@ -0,0 +1,433 @@
+/* SGP32 Templates in TTCN-3
+ *
+ * Author: Philipp Maier <pmaier@sysmocom.de> / sysmocom - s.f.m.c. GmbH
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+module SGP32Definitions_Templates {
+
+import from SGP32Definitions all;
+import from SGP32Definitions_Types all;
+
+import from RSPDefinitions all;
+import from RSPDefinitions_Types all;
+import from RSPDefinitions_Templates all;
+
+import from PKIX1Explicit88 all;
+import from PKIX1Explicit88_Templates all;
+import from PKIX1Explicit88_Types all;
+
+/* GSMA SGP.32, section 6.3.2.1 */
+template (present) EsipaMessageFromEimToIpa
+tr_initiateAuthenticationResponseEsipa(template (present) octetstring euiccChallenge := ?,
+				       template (present) universal charstring serverAddress := ?) := {
+	initiateAuthenticationResponseEsipa := {
+		initiateAuthenticationOkEsipa := {
+			transactionId := *,
+			serverSigned1 := {
+				transactionId := ?,
+				euiccChallenge := euiccChallenge,
+				serverAddress := serverAddress,
+				serverChallenge := ?
+			},
+			serverSignature1 := ?,
+			euiccCiPKIdToBeUsed := ?,
+			serverCertificate := ?,
+			matchingId := *,
+			ctxParams1 := *
+		}
+	}
+}
+
+template (value) EsipaMessageFromEimToIpa
+ts_initiateAuthenticationResponseEsipa(template (value) octetstring euiccChallenge := '00112233445566778899AABBCCDDEEFF'O,
+				       template (value) universal charstring serverAddress := "smdp.example.com") := {
+	initiateAuthenticationResponseEsipa := {
+		initiateAuthenticationOkEsipa := {
+			transactionId := omit,
+			serverSigned1 := {
+				transactionId := 'ABCDEF'O,
+				euiccChallenge := euiccChallenge,
+				serverAddress := "smdp.example.com",
+				serverChallenge := '01020304050607080910111213141516'O
+			},
+			serverSignature1 := '01020304'O,
+			euiccCiPKIdToBeUsed := 'F54172BDF98A95D65CBEB88A38A1C11D800A85C3'O, /* NIST */
+			serverCertificate := ts_cert_s_sm_dpauth_nist,
+//			serverCertificate := ts_cert_s_sm_dpauth_brp,
+//			serverCertificate := ts_cert_s_sm_dp2auth_nist,
+//			serverCertificate := ts_cert_s_sm_dp2auth_brp,
+			matchingId := omit,
+			ctxParams1 := omit
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.1 */
+template (present) EsipaMessageFromIpaToEim
+tr_initiateAuthenticationRequestEsipa(template (present) octetstring euiccChallenge := ?) := {
+	initiateAuthenticationRequestEsipa := {
+		euiccChallenge := euiccChallenge,
+		smdpAddress := *,
+		euiccInfo1 := *
+	}
+}
+template (value) EsipaMessageFromIpaToEim
+ts_initiateAuthenticationRequestEsipa(template (value) octetstring euiccChallenge := '00112233445566778899aabbccddeeff'O) := {
+	initiateAuthenticationRequestEsipa := {
+		euiccChallenge := euiccChallenge,
+		smdpAddress := omit,
+		euiccInfo1 := omit
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.2 */
+template (present) EsipaMessageFromIpaToEim
+tr_authenticateClientRequestEsipa := {
+	authenticateClientRequestEsipa := {
+		transactionId := ?,
+		authenticateServerResponse := {
+			authenticateResponseOk := ?
+		}
+	}
+}
+/* TODO: create coresponding ts_ template */
+
+/* GSMA SGP.32, section 6.3.2.2 */
+template (present) EsipaMessageFromEimToIpa
+tr_authenticateClientResponseEsipa_dse(template (present) octetstring transactionId := ?,
+				       template (present) charstring activationCode := ?) := {
+	authenticateClientResponseEsipa := {
+		authenticateClientOkDSEsipa := {
+			transactionId := transactionId,
+				profileDownloadTrigger := {
+				profileDownloadData := {
+					activationCode := ?
+				},
+				eimTransactionId := *
+			}
+		}
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_authenticateClientResponseEsipa_dse(template (value) octetstring transactionId := 'ABCDEF'O,
+				       template (value) charstring activationCode := "1$SMDP.EXAMPLE.COM$$1.3.6.1.4.1.31746") := {
+	authenticateClientResponseEsipa := {
+		authenticateClientOkDSEsipa := {
+			transactionId := transactionId,
+			profileDownloadTrigger := {
+				profileDownloadData := {
+					activationCode := activationCode
+				},
+				eimTransactionId := omit
+			}
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.2 */
+template (present) EsipaMessageFromEimToIpa
+tr_authenticateClientResponseEsipa_dpe(template (present) octetstring transactionId := ?) := {
+	authenticateClientResponseEsipa := {
+		authenticateClientOkDPEsipa := {
+			transactionId := transactionId,
+			profileMetaData := *,
+			smdpSigned2 := {
+				transactionId := ?,
+				ccRequiredFlag := ?,
+				bppEuiccOtpk := *
+			},
+			smdpSignature2 := ?,
+			smdpCertificate := ?,
+			hashCc := *
+		}
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_authenticateClientResponseEsipa_dpe(template (value) octetstring transactionId := 'ABCDEF'O) := {
+	authenticateClientResponseEsipa := {
+		authenticateClientOkDPEsipa := {
+			transactionId := transactionId,
+			profileMetaData := omit,
+			smdpSigned2 := {
+				transactionId := transactionId,
+				ccRequiredFlag := false,
+				bppEuiccOtpk := omit
+			},
+			smdpSignature2 := 'AAAAAAAAAAAAAAAAAAAAAAAA'O,
+			smdpCertificate := ts_cert_s_sm_dpauth_nist,
+//			smdpCertificate := ts_cert_s_sm_dpauth_brp,
+//			smdpCertificate := ts_cert_s_sm_dp2auth_nist,
+//			smdpCertificate := ts_cert_s_sm_dp2auth_brp,
+			hashCc := omit
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.6 */
+template (present) EsipaMessageFromIpaToEim
+tr_getEimPackageRequest(template (present) octetstring eidValue := ?) := {
+	getEimPackageRequest := {
+		eidValue := eidValue,
+		notifyStateChange := *,
+		rPLMN := *
+	}
+}
+template (value) EsipaMessageFromIpaToEim
+ts_getEimPackageRequest(template (value) octetstring eidValue) := {
+	getEimPackageRequest := {
+		eidValue := eidValue,
+		notifyStateChange := omit,
+		rPLMN := omit
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.6 and 2.11.1.3 */
+template (present) EsipaMessageFromEimToIpa
+tr_getEimPackageResponse_dnlTrigReq(template (present) charstring activationCode := ?) := {
+	getEimPackageResponse := {
+		profileDownloadTriggerRequest := {
+			profileDownloadData := {
+				activationCode := activationCode
+			},
+			eimTransactionId := *
+		}
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_getEimPackageResponse_dnlTrigReq(template (value) charstring activationCode := "1$SMDP.EXAMPLE.COM$$1.3.6.1.4.1.31746") := {
+	getEimPackageResponse := {
+		profileDownloadTriggerRequest := {
+			profileDownloadData := {
+				activationCode := activationCode
+			},
+			eimTransactionId := omit
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.6 and 2.11.1.2 */
+template (present) EsipaMessageFromEimToIpa
+tr_getEimPackageResponse_euiccDataReq := {
+	getEimPackageResponse := {
+		ipaEuiccDataRequest := {
+			tagList := ?,
+			euiccCiPKId := *,
+			searchCriteria := *
+		}
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_getEimPackageResponse_euiccDataReq := {
+	getEimPackageResponse := {
+		ipaEuiccDataRequest := {
+			tagList := '80BF20BF228384A5A688A9BF2B'O,
+			euiccCiPKId := omit,
+			searchCriteria := omit
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.6 */
+template (present) EsipaMessageFromEimToIpa
+tr_getEimPackageResponse_eimPkgErrUndef := {
+	getEimPackageResponse := {
+		eimPackageError := ?
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_getEimPackageResponse_eimPkgErrUndef := {
+	getEimPackageResponse := {
+		eimPackageError := 127
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.6 */
+template (value) EsipaMessageFromEimToIpa
+ts_getEimPackageResponse_euiccPkgReq := {
+	getEimPackageResponse := {
+		euiccPackageRequest := {
+			euiccPackageSigned := {
+				eimId := "myEim",
+				eidValue := '00112233445566778899AABBCCDDEEFF'O,
+				counterValue := 123,
+				transactionId := omit,
+				euiccPackage := {
+					psmoList := {
+						{
+							configureAutoEnable := {
+								autoEnableFlag := NULL,
+								smdpOid := omit,
+								smdpAddress := omit
+							}
+						}
+					}
+				}
+			},
+			eimSignature := '1234567890'O
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.5 */
+template (present) EsipaMessageFromIpaToEim
+tr_cancelSessionRequestEsipa := {
+	cancelSessionRequestEsipa := {
+		transactionId := ?,
+		cancelSessionResponse := {
+			cancelSessionResponseOk := tr_cancelSessionResponseOk
+		}
+	}
+}
+template (value) EsipaMessageFromIpaToEim
+ts_cancelSessionRequestEsipa := {
+	cancelSessionRequestEsipa := {
+		transactionId := 'AABBCC'O,
+		cancelSessionResponse := {
+			cancelSessionResponseOk := ts_cancelSessionResponseOk
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.5 */
+template (present) EsipaMessageFromEimToIpa
+tr_cancelSessionResponseEsipa := {
+	cancelSessionResponseEsipa := {
+		cancelSessionOk := {
+			/* This function has no output data */
+		}
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_cancelSessionResponseEsipa := {
+	cancelSessionResponseEsipa := {
+		cancelSessionOk := {
+			/* This function has no output data */
+		}
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.3 */
+template (present) EsipaMessageFromEimToIpa
+tr_getBoundProfilePackageResponseEsipa := {
+	getBoundProfilePackageResponseEsipa := {
+		getBoundProfilePackageOkEsipa := {
+			transactionId := *,
+			boundProfilePackage := tr_boundProfilePackage
+		}
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_getBoundProfilePackageResponseEsipa := {
+	getBoundProfilePackageResponseEsipa := {
+		getBoundProfilePackageOkEsipa := {
+			transactionId := omit,
+			boundProfilePackage := ts_boundProfilePackage
+		}
+	}
+}
+
+/* GSMA SGP.32, section 5.9.1 */
+template (present) EuiccPackageResult
+tr_euiccPackageResult := {
+	euiccPackageResultSigned := {
+		euiccPackageResultDataSigned := {
+			eimId := ?,
+			counterValue := ?,
+			transactionId := *,
+			seqNumber := ?,
+			euiccResult := ?
+		},
+		euiccSignEPR := ?
+	}
+}
+template (value) EuiccPackageResult
+ts_euiccPackageResult := {
+	euiccPackageResultSigned := {
+		euiccPackageResultDataSigned := {
+			eimId := "myEim",
+			counterValue := 333,
+			transactionId := omit,
+			seqNumber := 1234,
+			euiccResult := {
+				{
+					configureAutoEnableResult := 0
+				}
+			}
+		},
+		euiccSignEPR := 'AABBCCDDEEFF'O
+	}
+}
+
+/* GSMA SGP.32, section 6.3.2.7 */
+/* TODO rename tr_provideEimPackageResultResponse to something like tr_provideEimPackageResultResponse_eimAck */
+template (present) EsipaMessageFromEimToIpa
+tr_provideEimPackageResultResponse := {
+	provideEimPackageResultResponse := {
+		eimAcknowledgements := *
+	}
+}
+template (value) EsipaMessageFromEimToIpa
+ts_provideEimPackageResultResponse(template (value) EimAcknowledgements eimAcknowledgements := {}) := {
+	provideEimPackageResultResponse := {
+		eimAcknowledgements := eimAcknowledgements
+	}
+}
+
+/* GSMA SGP.32, section 2.11.1.2 */
+template (present) GetCertsResponse
+tr_getCertsResponse := {
+	certs := {
+		eumCertificate := ?,
+		euiccCertificate := ?
+	}
+}
+template (value) GetCertsResponse
+ts_getCertsResponse := {
+	certs := {
+		eumCertificate := ts_cert_s_sm_dpauth_nist,
+		euiccCertificate := ts_cert_eum_nist
+	}
+}
+
+/* GSMA SGP.32, section 5.9.18 */
+template (present) GetEimConfigurationDataResponse
+tr_getEimConfigurationDataResponse := {
+	eimConfigurationDataList := ?
+}
+template (value) GetEimConfigurationDataResponse
+ts_getEimConfigurationDataResponse(template (value) charstring eimFqdn := "127.0.0.1") := {
+	eimConfigurationDataList := {
+		{
+			eimId := "myEIM",
+			eimFqdn := eimFqdn,
+			eimIdType := omit,
+			counterValue := omit,
+			associationToken := 123,
+			eimPublicKeyData := omit,
+			trustedPublicKeyDataTls := omit,
+			eimSupportedProtocol := omit,
+			euiccCiPKId := omit
+		}
+	}
+}
+
+/* GSMA SGP.32, section 5.9.4 */
+template (present) AddInitialEimResponse
+tr_addInitialEimResponse := {
+	addInitialEimOk := ?
+}
+template (value) AddInitialEimResponse
+ts_addInitialEimResponse(template (value) charstring eimFqdn := "127.0.0.1") := {
+	addInitialEimOk := {
+		{
+			addOk := NULL
+		}
+	}
+}
+
+}
\ No newline at end of file