public void LegacyPduMacCalcWith0x0IntStaticTest() { byte[] bytes = File.ReadAllBytes(Path.Combine(TestSetup.LocalPath, Resources.KsiService_LegacyAggregationResponsePdu_0x0_Int)); ImprintTag mac; using (TlvReader tlvReader = new TlvReader(new MemoryStream(bytes))) { mac = new LegacyAggregationPdu(tlvReader.ReadTag()).Mac; } Assert.IsTrue(LegacyPdu.ValidateMac(bytes, mac, Util.EncodeNullTerminatedUtf8String(TestConstants.ServicePass)), "MAC should be valid"); }
public void LegacyPduMacCalcWith0x0IntStaticInvalidTest() { byte[] bytes = File.ReadAllBytes(Path.Combine(TestSetup.LocalPath, Resources.KsiService_LegacyAggregationResponsePdu_0x0_Int)); LegacyAggregationPdu pdu; using (TlvReader tlvReader = new TlvReader(new MemoryStream(bytes))) { pdu = new LegacyAggregationPdu(tlvReader.ReadTag()); } // 0x0 value representing an integer is converted to an empty TLV, thus MAC check will fail. byte[] pduBytes = pdu.Encode(); Assert.IsFalse(LegacyPdu.ValidateMac(pduBytes, pdu.Mac, Util.EncodeNullTerminatedUtf8String(TestConstants.ServicePass)), "MAC should be invalid"); }