| % STAMP regression tests for Scapy |
| |
| # More information at http://www.secdev.org/projects/UTscapy/ |
| |
| # Type the following command to launch start the tests: |
| # $ test/run_tests -t test/contrib/stamp.uts |
| |
| ############ |
| # STAMP |
| ############ |
| |
| + STAMP tests |
| |
| = Load module |
| |
| load_contrib("stamp") |
| |
| = Test STAMP Session-Sender Test (Unauthenticated) |
| ~ stamp-session-sender-test |
| |
| created = STAMPSessionSenderTestUnauthenticated( |
| seq=0x1234, |
| ts=1234.5678, |
| err_estimate=ErrorEstimate( |
| S=1, |
| Z=0, |
| scale=0x12, |
| multiplier=0x34 |
| ), |
| ssid=1357 |
| ) |
| assert raw(created) == b'\x00\x00\x12\x34\x00\x00\x04\xD2\x91\x5B\x57\x3E\x92\x34\x05\x4D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
| parsed = STAMPSessionSenderTestUnauthenticated(raw(created)) |
| assert parsed.seq == 0x1234 |
| assert parsed.ts == 1234.5678 |
| assert parsed.err_estimate.S == 1 |
| assert parsed.err_estimate.Z == 0 |
| assert parsed.err_estimate.scale == 0x12 |
| assert parsed.err_estimate.multiplier == 0x34 |
| assert parsed.ssid == 1357 |
| assert parsed.mbz == 0 |
| assert not parsed.tlv_objects |
| |
| = Test STAMP Session-Reflector Test (Unauthenticated) |
| ~ stamp-session-reflector-test |
| |
| created = STAMPSessionReflectorTestUnauthenticated( |
| seq=0x1234, |
| ts=1234.5678, |
| err_estimate=ErrorEstimate( |
| S=1, |
| Z=0, |
| scale=0x12, |
| multiplier=0x34 |
| ), |
| ssid=1357, |
| ts_rx=4321.8765, |
| seq_sender=0x4321, |
| ts_sender=2143.6587, |
| err_estimate_sender=ErrorEstimate( |
| S=0, |
| Z=0, |
| scale=0x21, |
| multiplier=0x43 |
| ), |
| ttl_sender=111 |
| ) |
| assert raw(created) == b'\x00\x00\x12\x34\x00\x00\x04\xD2\x91\x5B\x57\x3E\x92\x34\x05\x4D\x00\x00\x10\xE1\xE0\x62\x4D\xD2\x00\x00\x43\x21\x00\x00\x08\x5F\xA8\xA0\x90\x2D\x21\x43\x00\x00\x6F\x00\x00\x00' |
| parsed = STAMPSessionReflectorTestUnauthenticated(raw(created)) |
| assert parsed.seq == 0x1234 |
| assert parsed.ts == 1234.5678 |
| assert parsed.err_estimate.S == 1 |
| assert parsed.err_estimate.Z == 0 |
| assert parsed.err_estimate.scale == 0x12 |
| assert parsed.err_estimate.multiplier == 0x34 |
| assert parsed.ssid == 1357 |
| assert parsed.ts_rx == 4321.8765 |
| assert parsed.seq_sender == 0x4321 |
| assert parsed.ts_sender == 2143.6587 |
| assert parsed.err_estimate_sender.S == 0 |
| assert parsed.err_estimate_sender.Z == 0 |
| assert parsed.err_estimate_sender.scale == 0x21 |
| assert parsed.err_estimate_sender.multiplier == 0x43 |
| assert parsed.mbz1 == 0 |
| assert parsed.ttl_sender == 111 |
| assert parsed.mbz2 == 0 |
| assert not parsed.tlv_objects |
| |