Skip to content

Test vector for AES packet number encryption

Christian Huitema edited this page Feb 2, 2018 · 5 revisions

Better test this early, so we don't have problems when doing interop tests.

Let's assume that the PN encryption key is:

    static const uint8_t key[] = {
        0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
        0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c };

And that the packet received from the network is:

    static const uint8_t packet_encrypted_pn[] = {
        0x5d,
        0x80, 0x6d, 0xbb, 0xb5,
        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
        0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
        0x20, 0x3f, 0xbe, 0x2e, 0x32, 0x17, 0xfc, 0x5b,
        0x88, 0x55
    };

The first byte indicates that the C_ID is absent, and that the PN number is 4 bytes long. The PN value in the packet is encrypted. From the packet, we can extract the sample:

    static const uint8_t sample[] = {
        0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
        0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a };

Using that sample to construct IV as specified, the PN should decrypt to:

   static const uint8_t clear_pn[] = {
        0xba, 0xba, 0xc0, 0x01
    };
Clone this wiki locally