n2n icon indicating copy to clipboard operation
n2n copied to clipboard

Edge on OpenWRT with encryption

Open siskai opened this issue 3 years ago • 19 comments

I compiled last version of dev branch on Windows, Ubuntu (for OpenWRT and Android). Communication between Windows, Linux and Android works fine, but pinging to OpenWRT does not work. When I turn off encryption, then it works.

Log output:

...
04/Jan/2022 16:10:45 [edge_utils.c:1762] sending data of size 110 to TAP
04/Jan/2022 16:10:45 [edge_utils.c:2432] Rx N2N_UDP of size 172 from [<ip_address:port>]
04/Jan/2022 16:10:45 [edge_utils.c:2536] [pSp] from 00:FF:8D:8E:63:95 via [<ip_address:port>]
04/Jan/2022 16:10:45 [edge_utils.c:1646] handle_PACKET size 126 transform 4
04/Jan/2022 16:10:45 [transform_cc20.c:106] decode_cc20 126 bytes
04/Jan/2022 16:10:45 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0xC269
04/Jan/2022 16:10:45 [edge_utils.c:1762] sending data of size 110 to TAP
04/Jan/2022 16:10:45 [edge_utils.c:2432] Rx N2N_UDP of size 172 from [<ip_address:port>]
04/Jan/2022 16:10:45 [edge_utils.c:2536] [pSp] from 00:FF:8D:8E:63:95 via [<ip_address:port>]
04/Jan/2022 16:10:45 [edge_utils.c:1646] handle_PACKET size 126 transform 4
04/Jan/2022 16:10:45 [transform_cc20.c:106] decode_cc20 126 bytes
04/Jan/2022 16:10:45 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0xA7AC
04/Jan/2022 16:10:45 [edge_utils.c:1762] sending data of size 110 to TAP
04/Jan/2022 16:10:45 [edge_utils.c:2432] Rx N2N_UDP of size 172 from [<ip_address:port>]
04/Jan/2022 16:10:45 [edge_utils.c:2536] [pSp] from 00:FF:8D:8E:63:95 via [<ip_address:port>]
04/Jan/2022 16:10:45 [edge_utils.c:1646] handle_PACKET size 126 transform 4
04/Jan/2022 16:10:45 [transform_cc20.c:106] decode_cc20 126 bytes
04/Jan/2022 16:10:45 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0xF41B
04/Jan/2022 16:10:45 [edge_utils.c:1762] sending data of size 110 to TAP
04/Jan/2022 16:10:46 [edge_utils.c:2432] Rx N2N_UDP of size 172 from [<ip_address:port>]
04/Jan/2022 16:10:46 [edge_utils.c:2536] [pSp] from 00:FF:8D:8E:63:95 via [<ip_address:port>]
04/Jan/2022 16:10:46 [edge_utils.c:1646] handle_PACKET size 126 transform 4
04/Jan/2022 16:10:46 [transform_cc20.c:106] decode_cc20 126 bytes
04/Jan/2022 16:10:46 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0x9091
04/Jan/2022 16:10:46 [edge_utils.c:1762] sending data of size 110 to TAP
04/Jan/2022 16:10:46 [edge_utils.c:2432] Rx N2N_UDP of size 172 from [<ip_address:port>]
04/Jan/2022 16:10:46 [edge_utils.c:2536] [pSp] from 00:FF:8D:8E:63:95 via [<ip_address:port>]
04/Jan/2022 16:10:46 [edge_utils.c:1646] handle_PACKET size 126 transform 4
04/Jan/2022 16:10:46 [transform_cc20.c:106] decode_cc20 126 bytes
04/Jan/2022 16:10:46 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0xB0B1
04/Jan/2022 16:10:46 [edge_utils.c:1762] sending data of size 110 to TAP
04/Jan/2022 16:10:46 [edge_utils.c:2432] Rx N2N_UDP of size 172 from [<ip_address:port>]
04/Jan/2022 16:10:46 [edge_utils.c:2536] [pSp] from 00:FF:8D:8E:63:95 via [<ip_address:port>]
04/Jan/2022 16:10:46 [edge_utils.c:1646] handle_PACKET size 126 transform 4
04/Jan/2022 16:10:46 [transform_cc20.c:106] decode_cc20 126 bytes
04/Jan/2022 16:10:46 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0xBDAD
04/Jan/2022 16:10:46 [edge_utils.c:1762] sending data of size 110 to TAP
...

I think the problem is similar to #642.

siskai avatar Jan 04 '22 16:01 siskai

This reminds me of the byte-swap bug seen on Windows and as fixed with #830. For some reason, the 64-bit byte-swap (for endianess correction) did not work as expected on Windows.

It could be the same here on your platform. What is your CPU?

Logan007 avatar Jan 05 '22 07:01 Logan007

Core i7 4790S

Ubuntu is running on virtual machine. n2n on Ubuntu works fine, but n2n compiled for OpenWRT (MIPS 24Kc) does't work.

Version 2.8 works everywhere without problems.

siskai avatar Jan 05 '22 09:01 siskai

I do not have openWrt Platform / MIPS24Kc available here.

Anyone here who can verify if it is the same byte-swap issue in portable_endian.h as in seen with #830? Maybe running a short test progamm including the portable_endian.h from n2n's include/ folder – just checking the correct output of htobe64 and be64toh (and optionally htole64 as well as le64toh)?

Roughly speaking

include <stdint.h>
include <stdio.h>
include "portable_endian.h"

int main (void) {

    uint64_t x = 0x0102030405060708;


    printf("x = %016llx, htobe64(x) = %016llx, be64toh(x) = %016llx\n", 
           x, htobe64(x), be64toh(x));

    return 0;
}

Logan007 avatar Jan 05 '22 10:01 Logan007

Output: x = 0102030405060708, htobe64(x) = 0102030405060708, be64toh(x) = 0102030405060708

siskai avatar Jan 08 '22 23:01 siskai

This looks good for a big endian machine... unfortunately... as it means some tough debugging at other places.

I shall try to emulate it in QEMU then one day. Any hints?

Logan007 avatar Jan 09 '22 09:01 Logan007

On Windows the result is different. x = 0102030405060708, htobe64(x) = 0807060504030201, be64toh(x) = 0807060504030201

Is it normal?

siskai avatar Jan 09 '22 09:01 siskai

Yes, Windows on x86 is little endian. I was "hoping" for some result like "0x000000000005060708" clearly indicating a non-working 64-bit endianess conversion (which I suspected)... but well, I will have to take the deep-dive. :wink:

Logan007 avatar Jan 09 '22 09:01 Logan007

It is recommended to manually implement reliable endian conversions yourself to avoid unexpected behavior. The following code is what I once wrote, it can implement byte order conversion of any length, for reference.

static int is_little_endian() {
        int a = 1; // big_endian: 0x00 0x00 0x00 0x01,little_endian: 0x01 0x00 0x00 0x00
        int b = (int) (*(char *) &a);
        return b;
}

static void endian_swap(void *dest, void *source, int len) {
        memset(dest, 0, len);

        for (int i = 0; i < len; ++i) {
                ((char *) dest)[i] = ((char *) source)[len - 1 - i];
        }
        return;
}


fengdaolong avatar Jan 09 '22 12:01 fengdaolong

Thank you @fengdaolong. In this case, the endian-swaps do not seem to be the issue. At least not the one I was suspecting from an earlier issue.

@siskai, does any of the test output deviate?

Logan007 avatar Jan 09 '22 12:01 Logan007

b = 0

In second function I do not know what to put in the variables.

siskai avatar Jan 09 '22 15:01 siskai

@siskai oh, no, I was thinking of the scripts/test_harness.sh tests. Sorry that I misled you.

Logan007 avatar Jan 09 '22 15:01 Logan007

The build environment for OpenWRT makes running the test harness a little difficult. I think the individual tools are still built, but they probably need to be run individually. (TODO: this needs testing / documenting!)

hamishcoleman avatar Jan 09 '22 15:01 hamishcoleman

Well, I just tried to do an OpenWRT build to improve the documentation, but the upnp configuration and detection has broken the build.

hamishcoleman avatar Jan 09 '22 16:01 hamishcoleman

tests-auth.out

bin_to_ascii: input size = 0x10
000: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
bin_to_ascii: output: 00420mG51WS82GeB30qE3m

ascii_to_bin: input = 00420mG51WS82GeB30qE3m
ascii_to_bin: output:
000: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
010: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   |                |

generate_private_key: input = 00420mG51WS82GeB30qE3m
generate_private_key: output:
000: a4 f4 b5 1c 8a 0a 09 f9  7e 98 22 ca 8a cc b3 f9   |        ~ "     |
010: 4d 5a 0d 02 0b 9d 08 ea  03 9b 46 41 8e 3c 0d 49   |MZ        FA < I|

generate_public_key: input:
000: a4 f4 b5 1c 8a 0a 09 f9  7e 98 22 ca 8a cc b3 f9   |        ~ "     |
010: 4d 5a 0d 02 0b 9d 08 ea  03 9b 46 41 8e 3c 0d 49   |MZ        FA < I|
generate_public_key: output:
000: ca 58 61 6f f9 25 d0 cd  1d a5 62 48 a0 15 5e ad   | Xao %    bH  ^ |
010: a9 f3 5c 10 5f 20 b6 42  b0 a9 7c 1e 0e d7 e9 4b   |  \ _  B  |    K|

generate_shared_secret: input: prv
000: a4 f4 b5 1c 8a 0a 09 f9  7e 98 22 ca 8a cc b3 f9   |        ~ "     |
010: 4d 5a 0d 02 0b 9d 08 ea  03 9b 46 41 8e 3c 0d 49   |MZ        FA < I|
generate_shared_secret: input: pub
000: ca 58 61 6f f9 25 d0 cd  1d a5 62 48 a0 15 5e ad   | Xao %    bH  ^ |
010: a9 f3 5c 10 5f 20 b6 42  b0 a9 7c 1e 0e d7 e9 4b   |  \ _  B  |    K|
generate_shared_secret: output:
000: 5d 94 7b 0b db 54 e8 70  8a 09 b0 db 6f 0b 0d 31   |] {  T p    o  1|
010: 1b b8 5f ba 57 74 34 bd  3b c5 c4 6c d5 ae a4 84   |  _ Wt4 ;  l    |

tests-compress.out

original: input size = 0x20000000004
000: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
010: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
020: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
030: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
040: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
050: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
060: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
070: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
080: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
090: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0a0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0b0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0c0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0d0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0e0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0f0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
100: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
110: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
120: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
130: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
140: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
150: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
160: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
170: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
180: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
190: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1a0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1b0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1c0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1d0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1e0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1f0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |

lzo1x: output size = 0x2f7f90a6f4
000: 0d 00 01 02 03 04 05 06  07 08 09 0a 0b 0c 0d 0e   |                |
010: 0f 20 00 bc 3c 00 00 02  0c 0d 0e 0f 00 01 02 03   |    <           |
020: 04 05 06 07 08 09 0a 0b  0c 0d 0e 0f 11 00 00      |               |

zstd: output size = 0x21
000: 28 b5 2f fd 60 00 01 bd  00 00 80 00 01 02 03 04   |( / `           |
010: 05 06 07 08 09 0a 0b 0c  0d 0e 0f 01 00 da 47 9d   |              G |
020: 4b                                                 |K|

tests-elliptic.out

environment: input
000: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   |                |
010: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 09   |                |
environment: key
000: 55 55 55 55 55 55 55 55  55 55 55 55 55 55 55 55   |UUUUUUUUUUUUUUUU|
010: 55 55 55 55 55 55 55 55  55 55 55 55 55 55 55 55   |UUUUUUUUUUUUUUUU|

curve25519: output
000: 7f 42 1b f9 34 5a 59 84  4a 30 bc 53 64 74 fa 7c   | B  4ZY J0 Sdt ||
010: 15 81 77 a4 4d 34 6d 2f  8b c1 8c 05 d6 a9 44 54   |  w M4m/      DT|

tests-hashing.out

environment: input size = 0x20000000005
000: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
010: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
020: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
030: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
040: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
050: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
060: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
070: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
080: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
090: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0a0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0b0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0c0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0d0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0e0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0f0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
100: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
110: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
120: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
130: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
140: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
150: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
160: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
170: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
180: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
190: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1a0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1b0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1c0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1d0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1e0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1f0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |

pearson_hash_256: output:
000: 40 09 5c ca 28 6b fb 93  4c 4a f7 c0 79 a8 04 5a   |@ \ (k  LJ  y  Z|
010: b5 3d cf b3 a7 ed 18 56  b2 d9 8f a8 2e a1 08 be   | =     V    .   |

pearson_hash_128: output:
000: b5 3d cf b3 a7 ed 18 56  b2 d9 8f a8 2e a1 08 be   | =     V    .   |

pearson_hash_64: output = 0xb2d98fa82ea108be

pearson_hash_32: output = 0x2ea108be

pearson_hash_16: output = 0x8be

tests-transform.out

environment: community_name = "abc123def456"
environment: encrypt_key = "SoMEVer!S$cUREPassWORD"
environment: input size = 0x2000000000a
000: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
010: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
020: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
030: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
040: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
050: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
060: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
070: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
080: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
090: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0a0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0b0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0c0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0d0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0e0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
0f0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
100: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
110: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
120: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
130: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
140: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
150: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
160: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
170: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
180: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
190: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1a0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1b0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1c0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1d0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1e0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |
1f0: 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   |                |

null: output size = 0x2260000000e
000: 03 02 00 03 61 62 63 31  32 33 64 65 66 34 35 36   |    abc123def456|
010: 00 00 00 00 00 00 00 00  00 01 02 03 04 05 00 01   |                |
020: 02 03 04 05 00 00 00 01  02 03 04 05 06 07 08 09   |                |
030: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
040: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
050: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
060: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
070: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
080: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
090: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
0a0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
0b0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
0c0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
0d0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
0e0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
0f0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
100: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
110: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
120: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
130: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
140: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
150: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
160: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
170: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
180: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
190: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
1a0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
1b0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
1c0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
1d0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
1e0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
1f0: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
200: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
210: 0a 0b 0c 0d 0e 0f 00 01  02 03 04 05 06 07 08 09   |                |
220: 0a 0b 0c 0d 0e 0f                                  |      |

tf: output size = 0x236004612d0
000: 03 02 00 03 61 62 63 31  32 33 64 65 66 34 35 36   |    abc123def456|
010: 00 00 00 00 00 00 00 00  00 01 02 03 04 05 00 01   |                |
020: 02 03 04 05 00 00 69 54  ba b7 b9 00 7e 1f 4e 43   |      iT    ~ NC|
030: 6b 6e c0 b7 5a bb e1 6a  7d 8b f6 41 9e fb 7e c1   |kn  Z  j}  A  ~ |
040: a8 6c 67 6b c7 27 17 32  9b 89 f2 5d 1d 67 49 de   | lgk ' 2   ] gI |
050: ab 5c d4 b7 a1 97 99 76  7d 90 8d 2c 7c 0d 65 66   | \     v}  ,| ef|
060: d5 7f 1a 3b bf 0c 52 b3  42 0d c8 c8 0d 62 8e 4b   |   ;  R B    b K|
070: 98 7b bc 0d 9c db bf 61  dc 9d 9f 44 a4 fc 8d 1a   | {     a   D    |
080: 70 f0 14 87 89 0e 4a b8  7e 66 72 7a 04 6e 9b 17   |p     J ~frz n  |
090: e1 2c 06 ce 52 04 2a a0  0f 7f 76 f4 5c c5 e2 09   | ,  R *   v \   |
0a0: f6 35 ff ad 87 ab 72 5a  6f bc 61 78 f6 3c 48 e2   | 5    rZo ax <H |
0b0: b2 a4 27 ae 74 03 c7 83  f4 af 5a 1e da b4 7e 8a   |  ' t     Z   ~ |
0c0: 25 87 45 d2 8e 97 2b c0  69 8f f3 6d e5 8f a5 7f   |% E   + i  m    |
0d0: 91 72 94 49 bc d8 0e 20  d0 ed 16 28 df 78 37 53   | r I       ( x7S|
0e0: 97 63 f9 9e 0a c1 4c 3c  98 a9 c3 79 5a 76 a0 c9   | c    L<   yZv  |
0f0: 34 f1 26 6e 66 27 a9 68  9d d1 24 26 e8 64 a4 a0   |4 &nf' h  $& d  |
100: 71 e1 37 9a c9 b2 d6 7b  1c 56 b3 9d ac b0 47 5d   |q 7    { V    G]|
110: 81 2f 12 c4 56 a7 61 8f  58 20 1d 91 a0 ff fa 43   | /  V a X      C|
120: 4c 46 77 9f 20 66 7f a1  1d 98 b3 c5 b4 36 dd 41   |LFw  f       6 A|
130: 42 f3 4f b0 65 65 aa 94  f0 42 aa 31 2f e3 de c0   |B O ee   B 1/   |
140: a0 d2 02 c4 a8 6c d2 81  56 d7 00 eb c5 1b 3f 10   |     l  V     ? |
150: bc ea 09 c9 b7 f7 9f 08  c4 80 55 b6 04 02 50 f4   |          U   P |
160: 6c 76 bb 70 a0 04 14 da  fd 13 d1 b0 cd cb a6 b2   |lv p            |
170: d0 3f 37 09 47 62 94 bf  39 f4 6b d6 fa 22 0c 23   | ?7 Gb  9 k  " #|
180: a6 07 9b 1e ee b6 ae f7  58 b0 dc a9 db 60 ff a2   |        X    `  |
190: b7 03 a1 a3 26 1b 5b 37  c6 69 43 6b bb 6c 03 3e   |    & [7 iCk l >|
1a0: a7 fc d2 83 5b 61 b1 e0  fd 28 d1 ec 65 a2 cf 6c   |    [a   (  e  l|
1b0: ef 3b ad cc 75 e3 f9 71  0f 90 71 a6 bc 1a d5 17   | ;  u  q  q     |
1c0: 65 64 3e 0c d2 c8 de bd  1f d5 af 84 fc fe aa bd   |ed>             |
1d0: c5 88 13 af 09 ee 8c c0  38 49 79 09 a7 7a 01 48   |        8Iy  z H|
1e0: 2e 3e 9a 38 1b c6 b8 c0  a9 4e 61 0f 19 2a 95 84   |.> 8     Na  *  |
1f0: 3b 53 1c db 9a ec af 8f  2d af 73 d5 cc 71 bd 42   |;S      - s  q B|
200: 4f e2 70 ca 45 b6 44 18  54 fe 6b 23 31 ba f4 b1   |O p E D T k#1   |
210: 02 a1 26 4f f1 a9 c0 78  e6 3b 11 9e d6 3c 61 e5   |  &O   x ;   <a |
220: 3b 6f f3 42 43 9f 77 cf  9e 0d 39 85 eb e0 ad db   |;o BC w   9     |
230: d6 40 b7 94 99 ca                                  | @    |

tests-wire.out

environment: common.ttl = 2
environment: common.flags = 0
environment: common.community = "abc123def456z"

REGISTER: common.pc = 1
REGISTER: reg.cookie = 0
REGISTER: reg.srcMac[] = 0:1:2:3:4:5
REGISTER: reg.dstMac[] = 10:11:12:13:14:15
REGISTER: reg.dev_addr.net_addr = 0x20212223
REGISTER: reg.dev_addr.net_bitlen = 25
REGISTER: reg.dev_desc = "Dummy_Dev_Desc"

REGISTER: output retval = 0x2400000000
REGISTER: output idx = 0x3d0000000a
000: 03 02 00 01 61 62 63 31  32 33 64 65 66 34 35 36   |    abc123def456|
010: 7a 00 00 00 00 00 00 00  00 00 00 00 00 01 02 03   |z               |
020: 04 05 10 11 12 13 14 15  20 21 22 23 19 44 75 6d   |         !"# Dum|
030: 6d 79 5f 44 65 76 5f 44  65 73 63 00 00            |my_Dev_Desc  |

REGISTER_SUPER: common.pc = 5
REGISTER_SUPER: reg.cookie = 0
REGISTER_SUPER: reg.edgeMac[] = 20:21:22:23:24:25
REGISTER_SUPER: reg.dev_addr.net_addr = 0x20212223
REGISTER_SUPER: reg.dev_addr.net_bitlen = 25
REGISTER_SUPER: reg.dev_desc = "Dummy_Dev_Desc"
REGISTER_SUPER: reg.auth.scheme = 1
REGISTER_SUPER: reg.auth.token_size = 16
REGISTER_SUPER: reg.auth.token[0] = 0xfe
REGISTER_SUPER: reg.key_time = 600

REGISTER_SUPER: output retval = 0x3600000000
REGISTER_SUPER: output idx = 0x4f0000000a
000: 03 02 00 05 61 62 63 31  32 33 64 65 66 34 35 36   |    abc123def456|
010: 7a 00 00 00 00 00 00 00  00 00 00 00 20 21 22 23   |z            !"#|
020: 24 25 20 21 22 23 19 44  75 6d 6d 79 5f 44 65 76   |$% !"# Dummy_Dev|
030: 5f 44 65 73 63 00 00 00  01 00 10 fe 00 00 00 fd   |_Desc           |
040: 00 00 00 fc 00 00 00 00  00 00 fb 00 00 02 58      |              X|

UNREGISTER_SUPER: common.pc = 6
UNREGISTER_SUPER: unreg.auth.scheme = 1
UNREGISTER_SUPER: unreg.auth.token_size = 16
UNREGISTER_SUPER: unreg.auth.token[0] = 0xfe
UNREGISTER_SUPER: unreg.srcMac[] = 30:31:32:33:34:35

UNREGISTER_SUPER: output retval = 0x1900000006
UNREGISTER_SUPER: output idx = 0x320000000a
000: 03 02 00 06 61 62 63 31  32 33 64 65 66 34 35 36   |    abc123def456|
010: 7a 00 00 00 00 00 00 00  00 01 00 10 fe 00 00 00   |z               |
020: fd 00 00 00 fc 00 00 00  00 00 00 fb 30 31 32 33   |            0123|
030: 34 35                                              |45|

siskai avatar Jan 09 '22 16:01 siskai

Hmm... the test output all look good so far. Is there more output from the tests-transform.out, maybe the AES section?

Logan007 avatar Jan 09 '22 22:01 Logan007

When I run tests-transform, output in terminal constains

null: tested
tf: round-trip buffer mismatch

There are no other transform tests.

siskai avatar Jan 09 '22 23:01 siskai

Have you tried to use the Twofish cipher for communication (-A2 at the edges)? Does that one work?

As a guess in the dark, could it be an openSSL issue? Do you compile with openSSL support? And if so, could you try to compile without openSSL support?

Logan007 avatar Jan 10 '22 07:01 Logan007

Twofish: Same issue

10/Jan/2022 17:01:39 [edge_utils.c:2419] Rx N2N_UDP of size 104 from [<ip_address:port>]
10/Jan/2022 17:01:39 [edge_utils.c:2522] [pSp] from 4E:30:6A:13:8F:9A via [<ip_address:port>]
10/Jan/2022 17:01:39 [edge_utils.c:1633] handle_PACKET size 58 transform 2
10/Jan/2022 17:01:39 [transform_tf.c:139] transop_decode_tf 58 bytes ciphertext
10/Jan/2022 17:01:39 [transform_tf.c:163] WARNING: transop_decode_tf payload decryption failed with unexpected cipher text stealing padding
10/Jan/2022 17:01:39 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0x0000
10/Jan/2022 17:01:39 [edge_utils.c:1749] sending data of size 4294967295 to TAP
10/Jan/2022 17:01:40 [edge_utils.c:2419] Rx N2N_UDP of size 104 from [<ip_address:port>]
10/Jan/2022 17:01:40 [edge_utils.c:2522] [pSp] from 4E:30:6A:13:8F:9A via [<ip_address:port>]
10/Jan/2022 17:01:40 [edge_utils.c:1633] handle_PACKET size 58 transform 2
10/Jan/2022 17:01:40 [transform_tf.c:139] transop_decode_tf 58 bytes ciphertext
10/Jan/2022 17:01:40 [transform_tf.c:163] WARNING: transop_decode_tf payload decryption failed with unexpected cipher text stealing padding
10/Jan/2022 17:01:40 [network_traffic_filter.c:159] collect_packet_info stumbled across the unknown ether type 0x0000
10/Jan/2022 17:01:40 [edge_utils.c:1749] sending data of size 4294967295 to TAP

I compile with default settings, ie without OpenSSL support. Should I try to compile with OpenSSL support?

siskai avatar Jan 10 '22 16:01 siskai

Should I try to compile with OpenSSL support?

No, please don't. I was suspecting maybe an issue with openSSL because it is the first cipher (counting TF, AES, ChaCha, SPECK) optionally supported by openSSL. And it still is strange that you only get TF output from tests... so, I will try to setup a VM some day and try to re-produce.

Anyone else experiencing this on openWRT?

Logan007 avatar Jan 10 '22 17:01 Logan007