Commit 7ba63cf8 authored by fetke's avatar fetke
Browse files

codec work

parent f269061e
Loading
Loading
Loading
Loading
+70 −47
Original line number Diff line number Diff line
@@ -91,7 +91,9 @@ module ePassport_Types {
				LengthC lengthC optional, 
				GenericPayload payload,
				LengthE lengthE optional
			} with {variant "isPdu;"};
			} with {
				variant "isPdu"
			}

			type record CommandManageSecurityEnvironment {
				Class class,
@@ -101,7 +103,7 @@ module ePassport_Types {
				ManageSecurityEnvironmentPayload payload optional, // presence depends on crtTag (present if 0xa4, 0xa6, 0xaa, 0xb4, 0xb6, 0xb8)
				LengthE lengthE optional
			} with {
				variant "isPdu;present=bits(5,8,0x22);"
				variant "isPdu;present=bytes(1,1,0x22);"
				variant (payload)
				"fieldPresent="
				"getIntTag('crtTag')==0xa4||"
@@ -119,7 +121,9 @@ module ePassport_Types {
				LengthC lengthC optional, 
				ExternalOrMutualAuthenticatePayload payload,
				LengthE lengthE optional
			} with {variant "isPdu;present=bits(5,8,0x82);"};
			} with {
				variant "isPdu;present=bytes(1,1,0x82);"
			}

			type record CommandGetChallenge {
				Class class,
@@ -128,7 +132,9 @@ module ePassport_Types {
				LengthC lengthC optional, 
				GetChallengePayload payload,
				LengthE lengthE optional
			} with {variant "isPdu;present=bits(5,8,0x84);"};
			} with {
				variant "isPdu;present=bytes(1,1,0x84);"
			}

			type record CommandInternalAuthenticate {
				Class class,
@@ -137,7 +143,9 @@ module ePassport_Types {
				LengthC lengthC optional, 
				InternalAuthenticatePayload payload,
				LengthE lengthE optional
			} with {variant "isPdu;present=bits(5,8,0x88);"};
			} with {
				variant "isPdu;present=bytes(1,1,0x88);"
			};

			type record CommandSelect {
				Class class,
@@ -146,7 +154,9 @@ module ePassport_Types {
				LengthC lengthC optional, 
				SelectPayload payload,
				LengthE lengthE optional
			} with {variant "isPdu;present=bits(5,8,0xA4);"};
			} with {
				variant "isPdu;present=bytes(1,1,0xA4);"
			};

			type record CommandReadBinary {
				Class class,
@@ -155,7 +165,9 @@ module ePassport_Types {
				LengthC lengthC optional, 
				ReadBinaryPayload payload,
				LengthE lengthE optional
			} with {variant "isPdu;present=bits(5,8,0xB0);"};
			} with {
				variant "isPdu;present=bytes(1,1,0xB0);"
			};

			type record CommandReadBinaryWithOffsetDataObject {
				Class class,
@@ -165,74 +177,74 @@ module ePassport_Types {
				ReadBinaryWithOffsetDataObjectPayload payload,
				LengthE lengthE optional
			} with {
				variant "isPdu;present=bits(5,8,0xB1);"
				variant "isPdu;present=bytes(1,1,0xB1)"
				variant (lengthC) "intTag='lengthC'"
			}

			type CommandGeneric CommandDeactivateFile
				with {variant "isPdu;present=bits(5,8,0x04);"};
				with {variant "isPdu;present=bytes(1,1,0x04);"};
			type CommandGeneric CommandEraseRecords
				with {variant "isPdu;present=bits(5,8,0x0C);"};
				with {variant "isPdu;present=bytes(1,1,0x0C);"};
			type CommandGeneric CommandEraseBinary
				with {variant "isPdu;present=bits(5,8,0x0E)||bits(5,8,0x0F);"};
				with {variant "isPdu;present=bytes(1,1,0x0E)||bytes(1,1,0x0F);"};
			type CommandGeneric CommandPerformScqlOperation
				with {variant "isPdu;present=bits(5,8,0x10);"};
				with {variant "isPdu;present=bytes(1,1,0x10);"};
			type CommandGeneric CommandPerformTransactionOperation
				with {variant "isPdu;present=bits(5,8,0x12);"};
				with {variant "isPdu;present=bytes(1,1,0x12);"};
			type CommandGeneric CommandPerformUserOperation
				with {variant "isPdu;present=bits(5,8,0x14);"};
				with {variant "isPdu;present=bytes(1,1,0x14);"};
			type CommandGeneric CommandVerify
				with {variant "isPdu;present=bits(5,8,0x20)||bits(5,8,0x21);"};
				with {variant "isPdu;present=bytes(1,1,0x20)||bytes(1,1,0x21);"};
			type CommandGeneric CommandChangeReferenceData
				with {variant "isPdu;present=bits(5,8,0x24);"};
				with {variant "isPdu;present=bytes(1,1,0x24);"};
			type CommandGeneric CommandDisableVerificationRequirement
				with {variant "isPdu;present=bits(5,8,0x26);"};
				with {variant "isPdu;present=bytes(1,1,0x26);"};
			type CommandGeneric CommandEnableVerificationRequirement
				with {variant "isPdu;present=bits(5,8,0x28);"};
				with {variant "isPdu;present=bytes(1,1,0x28);"};
			type CommandGeneric CommandPerformSecurityOperation
				with {variant "isPdu;present=bits(5,8,0x2A);"};
				with {variant "isPdu;present=bytes(1,1,0x2A);"};
			type CommandGeneric CommandResetRetryCounter
				with {variant "isPdu;present=bits(5,8,0x2C);"};
				with {variant "isPdu;present=bytes(1,1,0x2C);"};
			type CommandGeneric CommandActivateFile
				with {variant "isPdu;present=bits(5,8,0x44);"};
				with {variant "isPdu;present=bytes(1,1,0x44);"};
			type CommandGeneric CommandGenerateAsymmetricKeyPair
				with {variant "isPdu;present=bits(5,8,0x46);"};
				with {variant "isPdu;present=bytes(1,1,0x46);"};
			type CommandGeneric CommandManageChannel
				with {variant "isPdu;present=bits(5,8,0x70);"};
				with {variant "isPdu;present=bytes(1,1,0x70);"};
			type CommandGeneric CommandGeneralAuthenticate
				with {variant "isPdu;present=bits(5,8,0x87);"};
				with {variant "isPdu;present=bytes(1,1,0x87);"};
			type CommandGeneric CommandSearchBinary
				with {variant "isPdu;present=bits(5,8,0xA0)||bits(5,8,0xA1);"};
				with {variant "isPdu;present=bytes(1,1,0xA0)||bytes(1,1,0xA1);"};
			type CommandGeneric CommandSearchRecord
				with {variant "isPdu;present=bits(5,8,0xA2);"};
				with {variant "isPdu;present=bytes(1,1,0xA2);"};
			type CommandGeneric CommandReadRecords
				with {variant "isPdu;present=bits(5,8,0xB2)||bits(5,8,0xB3);"};
				with {variant "isPdu;present=bytes(1,1,0xB2)||bytes(1,1,0xB3);"};
			type CommandGeneric CommandGetResponse
				with {variant "isPdu;present=bits(5,8,0xC0);"};
				with {variant "isPdu;present=bytes(1,1,0xC0);"};
			type CommandGeneric CommandEnvelope
				with {variant "isPdu;present=bits(5,8,0xC2)||bits(5,8,0xC3);"};
				with {variant "isPdu;present=bytes(1,1,0xC2)||bytes(1,1,0xC3);"};
			type CommandGeneric CommandGetData
				with {variant "isPdu;present=bits(5,8,0xCA);"};
				with {variant "isPdu;present=bytes(1,1,0xCA);"};
			type CommandGeneric CommandWriteBinary
				with {variant "isPdu;present=bits(5,8,0xD0)||bits(5,8,0xD1);"};
				with {variant "isPdu;present=bytes(1,1,0xD0)||bytes(1,1,0xD1);"};
			type CommandGeneric CommandWriteRecord
				with {variant "isPdu;present=bits(5,8,0xD2);"};
				with {variant "isPdu;present=bytes(1,1,0xD2);"};
			type CommandGeneric CommandUpdateBinary
				with {variant "isPdu;present=bits(5,8,0xD6)||bits(5,8,0xD7);"};
				with {variant "isPdu;present=bytes(1,1,0xD6)||bytes(1,1,0xD7);"};
			type CommandGeneric CommandPutDataWith
				with {variant "isPdu;present=bits(5,8,0xDA)||bits(5,8,0xDB);"};
				with {variant "isPdu;present=bytes(1,1,0xDA)||bytes(1,1,0xDB);"};
			type CommandGeneric CommandUpdateRecord
				with {variant "isPdu;present=bits(5,8,0xDC)||bits(5,8,0xDD);"};
				with {variant "isPdu;present=bytes(1,1,0xDC)||bytes(1,1,0xDD);"};
			type CommandGeneric CommandCreateFile
				with {variant "isPdu;present=bits(5,8,0xE0);"};
				with {variant "isPdu;present=bytes(1,1,0xE0);"};
			type CommandGeneric CommandAppendRecord
				with {variant "isPdu;present=bits(5,8,0xE2);"};
				with {variant "isPdu;present=bytes(1,1,0xE2);"};
			type CommandGeneric CommandDeleteFile
				with {variant "isPdu;present=bits(5,8,0xE4);"};
				with {variant "isPdu;present=bytes(1,1,0xE4);"};
			type CommandGeneric CommandTerminateDF
				with {variant "isPdu;present=bits(5,8,0xE6)||bits(5,8,0xE8);"};
				with {variant "isPdu;present=bytes(1,1,0xE6)||bytes(1,1,0xE8);"};
			type CommandGeneric CommandTerminateCardUsage
				with {variant "isPdu;present=bits(5,8,0xFE);"};
				with {variant "isPdu;present=bytes(1,1,0xFE);"};

			group Header {

@@ -241,23 +253,28 @@ module ePassport_Types {
					FurtherInterindustryClass	further
				} with {
					// ISO/IEC 7816-4:2005(E), tables 2 and 3:
					variant (first)		"fieldPresent=bits(0,2,0x0)";
					variant (first)		"fieldPresent=bits(0,3,0x0)";
                    variant (further)	"fieldPresent=bits(0,2,0x1)";
				};

				type record FirstInterindustryClass {
					Bit3						tag ('000'B),
					ChainingControl				chaining,
					FirstSM						sm,
					FirstLogicalChannelNumber	channelNumber
				};
				}

				type record FurtherInterindustryClass {
					Bit2						tag ('01'B),
					FurtherSM					sm,
					ChainingControl				chaining,
					FurtherLogicalChannelNumber	channelNumber
				};
				}

				type integer FirstLogicalChannelNumber (0..3) with {variant "length=2;unsigned;"};
				type integer FirstLogicalChannelNumber (0..3)
				with {
					variant "length=2;unsigned;"
				}
				type integer FurtherLogicalChannelNumber (4..19)
				with {
					variant
@@ -276,12 +293,18 @@ module ePassport_Types {
					e_proprietarySM(1),
					e_SmCommandHeaderNotProcessed(2),
					e_SmCommandHeaderAuthenticated(3)
				} with {variant "length=2;unsigned;"}
				} with {
					variant	"length=2;unsigned;"
							"tag='sm'"
				}

				type enumerated FurtherSM {
					e_noSM(0),
					e_SmCommandHeaderNotProcessed(1)
				} with {variant "length=1;unsigned;"}
				} with {
					variant "length=1;unsigned;"
							"tag='sm'"
				}

				type enumerated Instruction {
					e_deactivateFile(4), // 0x04