diff options
author | Ron Yorston <rmy@pobox.com> | 2022-10-12 10:43:26 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-10-12 10:43:26 +0100 |
commit | 49c6f079acb4edae84b4496bd941cdbb5048ba01 (patch) | |
tree | ac54ecaad45050f7bfe274a11db29882aa32a9a8 /networking | |
parent | a55cf07365ec2ff51749a77e09ae9edac79a99fe (diff) | |
parent | c8c1fcdba163f264a503380bc63485aacd09214c (diff) | |
download | busybox-w32-49c6f079acb4edae84b4496bd941cdbb5048ba01.tar.gz busybox-w32-49c6f079acb4edae84b4496bd941cdbb5048ba01.tar.bz2 busybox-w32-49c6f079acb4edae84b4496bd941cdbb5048ba01.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ping.c | 4 | ||||
-rw-r--r-- | networking/tc.c | 2 | ||||
-rw-r--r-- | networking/tls.c | 113 | ||||
-rw-r--r-- | networking/tls_sp_c32.c | 35 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 7 | ||||
-rw-r--r-- | networking/udhcp/d6_socket.c | 2 |
6 files changed, 93 insertions, 70 deletions
diff --git a/networking/ping.c b/networking/ping.c index 86d8088de..9805695a1 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -74,7 +74,7 @@ | |||
74 | //usage: "\n -c CNT Send only CNT pings" | 74 | //usage: "\n -c CNT Send only CNT pings" |
75 | //usage: "\n -s SIZE Send SIZE data bytes in packets (default 56)" | 75 | //usage: "\n -s SIZE Send SIZE data bytes in packets (default 56)" |
76 | //usage: "\n -i SECS Interval" | 76 | //usage: "\n -i SECS Interval" |
77 | //usage: "\n -A Ping as soon as reply is recevied" | 77 | //usage: "\n -A Ping as soon as reply is received" |
78 | //usage: "\n -t TTL Set TTL" | 78 | //usage: "\n -t TTL Set TTL" |
79 | //usage: "\n -I IFACE/IP Source interface or IP address" | 79 | //usage: "\n -I IFACE/IP Source interface or IP address" |
80 | //usage: "\n -W SEC Seconds to wait for the first response (default 10)" | 80 | //usage: "\n -W SEC Seconds to wait for the first response (default 10)" |
@@ -91,7 +91,7 @@ | |||
91 | //usage: "\n -c CNT Send only CNT pings" | 91 | //usage: "\n -c CNT Send only CNT pings" |
92 | //usage: "\n -s SIZE Send SIZE data bytes in packets (default 56)" | 92 | //usage: "\n -s SIZE Send SIZE data bytes in packets (default 56)" |
93 | //usage: "\n -i SECS Interval" | 93 | //usage: "\n -i SECS Interval" |
94 | //usage: "\n -A Ping as soon as reply is recevied" | 94 | //usage: "\n -A Ping as soon as reply is received" |
95 | ///////: "\n -t TTL Set TTL" | 95 | ///////: "\n -t TTL Set TTL" |
96 | ///////^^^^^ -t not tested for IPv6, might be not working | 96 | ///////^^^^^ -t not tested for IPv6, might be not working |
97 | //usage: "\n -I IFACE/IP Source interface or IP address" | 97 | //usage: "\n -I IFACE/IP Source interface or IP address" |
diff --git a/networking/tc.c b/networking/tc.c index 46ad23d8b..43187f7ee 100644 --- a/networking/tc.c +++ b/networking/tc.c | |||
@@ -214,7 +214,7 @@ static int prio_print_opt(struct rtattr *opt) | |||
214 | return 0; | 214 | return 0; |
215 | parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt, sizeof(*qopt)); | 215 | parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt, sizeof(*qopt)); |
216 | printf("bands %u priomap ", qopt->bands); | 216 | printf("bands %u priomap ", qopt->bands); |
217 | for (i=0; i<=TC_PRIO_MAX; i++) | 217 | for (i = 0; i <= TC_PRIO_MAX; i++) |
218 | printf(" %d", qopt->priomap[i]); | 218 | printf(" %d", qopt->priomap[i]); |
219 | 219 | ||
220 | if (tb[TCA_PRIO_MQ]) | 220 | if (tb[TCA_PRIO_MQ]) |
diff --git a/networking/tls.c b/networking/tls.c index 5f40aec70..9f1dd67ec 100644 --- a/networking/tls.c +++ b/networking/tls.c | |||
@@ -948,11 +948,46 @@ static int tls_has_buffered_record(tls_state_t *tls) | |||
948 | 948 | ||
949 | static const char *alert_text(int code) | 949 | static const char *alert_text(int code) |
950 | { | 950 | { |
951 | //10 unexpected_message | ||
952 | //20 bad_record_mac | ||
953 | //21 decryption_failed | ||
954 | //22 record_overflow | ||
955 | //30 decompression_failure | ||
956 | //40 handshake_failure | ||
957 | //41 no_certificate | ||
958 | //42 bad_certificate | ||
959 | //43 unsupported_certificate | ||
960 | //44 certificate_revoked | ||
961 | //45 certificate_expired | ||
962 | //46 certificate_unknown | ||
963 | //47 illegal_parameter | ||
964 | //48 unknown_ca | ||
965 | //49 access_denied | ||
966 | //50 decode_error | ||
967 | //51 decrypt_error | ||
968 | //52 too_many_cids_requested | ||
969 | //60 export_restriction | ||
970 | //70 protocol_version | ||
971 | //71 insufficient_security | ||
972 | //80 internal_error | ||
973 | //86 inappropriate_fallback | ||
974 | //90 user_canceled | ||
975 | //100 no_renegotiation | ||
976 | //109 missing_extension | ||
977 | //110 unsupported_extension | ||
978 | //111 certificate_unobtainable | ||
979 | //112 unrecognized_name | ||
980 | //113 bad_certificate_status_response | ||
981 | //114 bad_certificate_hash_value | ||
982 | //115 unknown_psk_identity | ||
983 | //116 certificate_required | ||
984 | //120 no_application_protocol | ||
951 | switch (code) { | 985 | switch (code) { |
952 | case 20: return "bad MAC"; | 986 | case 20: return "bad MAC"; |
953 | case 50: return "decode error"; | 987 | case 50: return "decode error"; |
954 | case 51: return "decrypt error"; | ||
955 | case 40: return "handshake failure"; | 988 | case 40: return "handshake failure"; |
989 | case 51: return "decrypt error"; | ||
990 | case 80: return "internal error"; | ||
956 | case 112: return "unrecognized name"; | 991 | case 112: return "unrecognized name"; |
957 | } | 992 | } |
958 | return itoa(code); | 993 | return itoa(code); |
@@ -1531,27 +1566,6 @@ static void send_client_hello_and_alloc_hsd(tls_state_t *tls, const char *sni) | |||
1531 | #endif | 1566 | #endif |
1532 | 0x01,0x00, //not a cipher - comprtypes_len, comprtype | 1567 | 0x01,0x00, //not a cipher - comprtypes_len, comprtype |
1533 | }; | 1568 | }; |
1534 | static const uint8_t supported_groups[] = { | ||
1535 | 0x00,0x0a, //extension_type: "supported_groups" | ||
1536 | 0x00,2 * (1 + ALLOW_CURVE_P256 + ALLOW_CURVE_X25519), //ext len | ||
1537 | 0x00,2 * (0 + ALLOW_CURVE_P256 + ALLOW_CURVE_X25519), //list len | ||
1538 | #if ALLOW_CURVE_P256 | ||
1539 | 0x00,0x17, //curve_secp256r1 (aka P256, aka prime256v1) | ||
1540 | #endif | ||
1541 | //0x00,0x18, //curve_secp384r1 | ||
1542 | //0x00,0x19, //curve_secp521r1 | ||
1543 | #if ALLOW_CURVE_X25519 | ||
1544 | 0x00,0x1d, //curve_x25519 (RFC 7748) | ||
1545 | #endif | ||
1546 | //0x00,0x1e, //curve_x448 (RFC 7748) | ||
1547 | }; | ||
1548 | //static const uint8_t signature_algorithms[] = { | ||
1549 | // 000d | ||
1550 | // 0020 | ||
1551 | // 001e | ||
1552 | // 0601 0602 0603 0501 0502 0503 0401 0402 0403 0301 0302 0303 0201 0202 0203 | ||
1553 | //}; | ||
1554 | |||
1555 | struct client_hello { | 1569 | struct client_hello { |
1556 | uint8_t type; | 1570 | uint8_t type; |
1557 | uint8_t len24_hi, len24_mid, len24_lo; | 1571 | uint8_t len24_hi, len24_mid, len24_lo; |
@@ -1563,15 +1577,47 @@ static void send_client_hello_and_alloc_hsd(tls_state_t *tls, const char *sni) | |||
1563 | uint8_t cipherid[2 * (1 + NUM_CIPHERS)]; /* actually variable */ | 1577 | uint8_t cipherid[2 * (1 + NUM_CIPHERS)]; /* actually variable */ |
1564 | uint8_t comprtypes_len; | 1578 | uint8_t comprtypes_len; |
1565 | uint8_t comprtypes[1]; /* actually variable */ | 1579 | uint8_t comprtypes[1]; /* actually variable */ |
1566 | /* Extensions (SNI shown): | 1580 | }; |
1567 | * hi,lo // len of all extensions | 1581 | // https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml |
1568 | * 00,00 // extension_type: "Server Name" | 1582 | static const uint8_t extensions[] = { |
1569 | * 00,0e // list len (there can be more than one SNI) | 1583 | // is.gd responds with "handshake failure" to our hello if there's no supported_groups |
1570 | * 00,0c // len of 1st Server Name Indication | 1584 | 0x00,0x0a, //extension_type: "supported_groups" |
1571 | * 00 // name type: host_name | 1585 | 0x00,2 * (1 + ALLOW_CURVE_P256 + ALLOW_CURVE_X25519), //ext len |
1572 | * 00,09 // name len | 1586 | 0x00,2 * (0 + ALLOW_CURVE_P256 + ALLOW_CURVE_X25519), //list len |
1573 | * "localhost" // name | 1587 | #if ALLOW_CURVE_P256 |
1574 | */ | 1588 | 0x00,0x17, //curve_secp256r1 (aka P256, aka prime256v1) |
1589 | #endif | ||
1590 | //0x00,0x18, //curve_secp384r1 | ||
1591 | //0x00,0x19, //curve_secp521r1 | ||
1592 | #if ALLOW_CURVE_X25519 | ||
1593 | 0x00,0x1d, //curve_x25519 (RFC 7748) | ||
1594 | #endif | ||
1595 | //0x00,0x1e, //curve_x448 (RFC 7748) | ||
1596 | |||
1597 | //0x00,0x0b,0x00,0x04,0x03,0x00,0x01,0x02, //extension_type: "ec_point_formats" | ||
1598 | //0x00,0x16,0x00,0x00, //extension_type: "encrpypt-then-mac" | ||
1599 | //0x00,0x17,0x00,0x00, //extension_type: "extended_master" | ||
1600 | //0x00,0x23,0x00,0x00, //extension_type: "session_ticket" | ||
1601 | |||
1602 | // kojipkgs.fedoraproject.org responds with alert code 80 ("internal error") | ||
1603 | // to our hello without signature_algorithms. | ||
1604 | // It is satisfied with just 0x04,0x01. | ||
1605 | 0x00,0x0d, //extension_type: "signature_algorithms" (RFC5246 section 7.4.1.4.1): | ||
1606 | #define SIGALGS (3 + 3 * ENABLE_FEATURE_TLS_SHA1) | ||
1607 | 0x00,2 * (1 + SIGALGS), //ext len | ||
1608 | 0x00,2 * (0 + SIGALGS), //list len | ||
1609 | //Format: two bytes | ||
1610 | // byte 1: 0:none,1:md5,2:sha1,3:sha224,4:sha256,5:sha384,6:sha512 | ||
1611 | // byte 2: 1:rsa,2:dsa,3:ecdsa | ||
1612 | // (note that TLS 1.3 changes this, see RFC8446 section 4.2.3) | ||
1613 | #if ENABLE_FEATURE_TLS_SHA1 | ||
1614 | 0x02,0x01, //sha1 + rsa | ||
1615 | 0x02,0x02, //sha1 + dsa | ||
1616 | 0x02,0x03, //sha1 + ecdsa | ||
1617 | #endif | ||
1618 | 0x04,0x01, //sha256 + rsa - kojipkgs.fedoraproject.org wants this | ||
1619 | 0x04,0x02, //sha256 + dsa | ||
1620 | 0x04,0x03, //sha256 + ecdsa | ||
1575 | // GNU Wget 1.18 to cdn.kernel.org sends these extensions: | 1621 | // GNU Wget 1.18 to cdn.kernel.org sends these extensions: |
1576 | // 0055 | 1622 | // 0055 |
1577 | // 0005 0005 0100000000 - status_request | 1623 | // 0005 0005 0100000000 - status_request |
@@ -1591,8 +1637,7 @@ static void send_client_hello_and_alloc_hsd(tls_state_t *tls, const char *sni) | |||
1591 | int sni_len = sni ? strnlen(sni, 127 - 5) : 0; | 1637 | int sni_len = sni ? strnlen(sni, 127 - 5) : 0; |
1592 | 1638 | ||
1593 | ext_len = 0; | 1639 | ext_len = 0; |
1594 | /* is.gd responds with "handshake failure" to our hello if there's no supported_groups element */ | 1640 | ext_len += sizeof(extensions); |
1595 | ext_len += sizeof(supported_groups); | ||
1596 | if (sni_len) | 1641 | if (sni_len) |
1597 | ext_len += 9 + sni_len; | 1642 | ext_len += 9 + sni_len; |
1598 | 1643 | ||
@@ -1626,7 +1671,7 @@ static void send_client_hello_and_alloc_hsd(tls_state_t *tls, const char *sni) | |||
1626 | ptr[8] = sni_len; //name len | 1671 | ptr[8] = sni_len; //name len |
1627 | ptr = mempcpy(&ptr[9], sni, sni_len); | 1672 | ptr = mempcpy(&ptr[9], sni, sni_len); |
1628 | } | 1673 | } |
1629 | memcpy(ptr, supported_groups, sizeof(supported_groups)); | 1674 | memcpy(ptr, extensions, sizeof(extensions)); |
1630 | 1675 | ||
1631 | tls->hsd = xzalloc(sizeof(*tls->hsd)); | 1676 | tls->hsd = xzalloc(sizeof(*tls->hsd)); |
1632 | /* HANDSHAKE HASH: ^^^ + len if need to save saved_client_hello */ | 1677 | /* HANDSHAKE HASH: ^^^ + len if need to save saved_client_hello */ |
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c index 292dda24e..a593c5c40 100644 --- a/networking/tls_sp_c32.c +++ b/networking/tls_sp_c32.c | |||
@@ -68,9 +68,6 @@ static const sp_digit p256_mod[8] ALIGNED(8) = { | |||
68 | 68 | ||
69 | #define p256_mp_mod ((sp_digit)0x000001) | 69 | #define p256_mp_mod ((sp_digit)0x000001) |
70 | 70 | ||
71 | /* Normalize the values in each word to 32 bits - NOP */ | ||
72 | #define sp_256_norm_8(a) ((void)0) | ||
73 | |||
74 | /* Write r as big endian to byte array. | 71 | /* Write r as big endian to byte array. |
75 | * Fixed length number of bytes written: 32 | 72 | * Fixed length number of bytes written: 32 |
76 | * | 73 | * |
@@ -83,8 +80,6 @@ static void sp_256_to_bin_8(const sp_digit* rr, uint8_t* a) | |||
83 | int i; | 80 | int i; |
84 | const uint64_t* r = (void*)rr; | 81 | const uint64_t* r = (void*)rr; |
85 | 82 | ||
86 | sp_256_norm_8(rr); | ||
87 | |||
88 | r += 4; | 83 | r += 4; |
89 | for (i = 0; i < 4; i++) { | 84 | for (i = 0; i < 4; i++) { |
90 | r--; | 85 | r--; |
@@ -97,8 +92,6 @@ static void sp_256_to_bin_8(const sp_digit* r, uint8_t* a) | |||
97 | { | 92 | { |
98 | int i; | 93 | int i; |
99 | 94 | ||
100 | sp_256_norm_8(r); | ||
101 | |||
102 | r += 8; | 95 | r += 8; |
103 | for (i = 0; i < 8; i++) { | 96 | for (i = 0; i < 8; i++) { |
104 | r--; | 97 | r--; |
@@ -641,7 +634,6 @@ static void sp_256_div2_8(sp_digit* r /*, const sp_digit* m*/) | |||
641 | int carry = 0; | 634 | int carry = 0; |
642 | if (r[0] & 1) | 635 | if (r[0] & 1) |
643 | carry = sp_256_add_8(r, r, m); | 636 | carry = sp_256_add_8(r, r, m); |
644 | sp_256_norm_8(r); | ||
645 | sp_256_rshift1_8(r, carry); | 637 | sp_256_rshift1_8(r, carry); |
646 | } | 638 | } |
647 | 639 | ||
@@ -652,10 +644,8 @@ static void sp_256_mont_add_8(sp_digit* r, const sp_digit* a, const sp_digit* b | |||
652 | // const sp_digit* m = p256_mod; | 644 | // const sp_digit* m = p256_mod; |
653 | 645 | ||
654 | int carry = sp_256_add_8(r, a, b); | 646 | int carry = sp_256_add_8(r, a, b); |
655 | sp_256_norm_8(r); | ||
656 | if (carry) { | 647 | if (carry) { |
657 | sp_256_sub_8_p256_mod(r); | 648 | sp_256_sub_8_p256_mod(r); |
658 | sp_256_norm_8(r); | ||
659 | } | 649 | } |
660 | } | 650 | } |
661 | 651 | ||
@@ -667,10 +657,8 @@ static void sp_256_mont_sub_8(sp_digit* r, const sp_digit* a, const sp_digit* b | |||
667 | 657 | ||
668 | int borrow; | 658 | int borrow; |
669 | borrow = sp_256_sub_8(r, a, b); | 659 | borrow = sp_256_sub_8(r, a, b); |
670 | sp_256_norm_8(r); | ||
671 | if (borrow) { | 660 | if (borrow) { |
672 | sp_256_add_8(r, r, m); | 661 | sp_256_add_8(r, r, m); |
673 | sp_256_norm_8(r); | ||
674 | } | 662 | } |
675 | } | 663 | } |
676 | 664 | ||
@@ -680,10 +668,8 @@ static void sp_256_mont_dbl_8(sp_digit* r, const sp_digit* a /*, const sp_digit* | |||
680 | // const sp_digit* m = p256_mod; | 668 | // const sp_digit* m = p256_mod; |
681 | 669 | ||
682 | int carry = sp_256_add_8(r, a, a); | 670 | int carry = sp_256_add_8(r, a, a); |
683 | sp_256_norm_8(r); | ||
684 | if (carry) | 671 | if (carry) |
685 | sp_256_sub_8_p256_mod(r); | 672 | sp_256_sub_8_p256_mod(r); |
686 | sp_256_norm_8(r); | ||
687 | } | 673 | } |
688 | 674 | ||
689 | /* Triple a Montgomery form number (r = a + a + a % m) */ | 675 | /* Triple a Montgomery form number (r = a + a + a % m) */ |
@@ -692,16 +678,12 @@ static void sp_256_mont_tpl_8(sp_digit* r, const sp_digit* a /*, const sp_digit* | |||
692 | // const sp_digit* m = p256_mod; | 678 | // const sp_digit* m = p256_mod; |
693 | 679 | ||
694 | int carry = sp_256_add_8(r, a, a); | 680 | int carry = sp_256_add_8(r, a, a); |
695 | sp_256_norm_8(r); | ||
696 | if (carry) { | 681 | if (carry) { |
697 | sp_256_sub_8_p256_mod(r); | 682 | sp_256_sub_8_p256_mod(r); |
698 | sp_256_norm_8(r); | ||
699 | } | 683 | } |
700 | carry = sp_256_add_8(r, r, a); | 684 | carry = sp_256_add_8(r, r, a); |
701 | sp_256_norm_8(r); | ||
702 | if (carry) { | 685 | if (carry) { |
703 | sp_256_sub_8_p256_mod(r); | 686 | sp_256_sub_8_p256_mod(r); |
704 | sp_256_norm_8(r); | ||
705 | } | 687 | } |
706 | } | 688 | } |
707 | 689 | ||
@@ -844,7 +826,6 @@ static void sp_512to256_mont_reduce_8(sp_digit* r, sp_digit* aa/*, const sp_digi | |||
844 | sp_512to256_mont_shift_8(r, aa); | 826 | sp_512to256_mont_shift_8(r, aa); |
845 | if (carry != 0) | 827 | if (carry != 0) |
846 | sp_256_sub_8_p256_mod(r); | 828 | sp_256_sub_8_p256_mod(r); |
847 | sp_256_norm_8(r); | ||
848 | } | 829 | } |
849 | 830 | ||
850 | #else /* Generic 32-bit version */ | 831 | #else /* Generic 32-bit version */ |
@@ -1003,8 +984,6 @@ static int sp_256_mul_add_8(sp_digit* r /*, const sp_digit* a, sp_digit b*/) | |||
1003 | * [In our case, it is (p256_mp_mod * a[1]) << 32.] | 984 | * [In our case, it is (p256_mp_mod * a[1]) << 32.] |
1004 | * And so on. Eventually T is divisible by R, and after division by R | 985 | * And so on. Eventually T is divisible by R, and after division by R |
1005 | * the algorithm is in the same place as the usual Montgomery reduction. | 986 | * the algorithm is in the same place as the usual Montgomery reduction. |
1006 | * | ||
1007 | * TODO: Can conditionally use 64-bit (if bit-little-endian arch) logic? | ||
1008 | */ | 987 | */ |
1009 | static void sp_512to256_mont_reduce_8(sp_digit* r, sp_digit* a/*, const sp_digit* m, sp_digit mp*/) | 988 | static void sp_512to256_mont_reduce_8(sp_digit* r, sp_digit* a/*, const sp_digit* m, sp_digit mp*/) |
1010 | { | 989 | { |
@@ -1032,7 +1011,6 @@ static void sp_512to256_mont_reduce_8(sp_digit* r, sp_digit* a/*, const sp_digit | |||
1032 | sp_512to256_mont_shift_8(r, a); | 1011 | sp_512to256_mont_shift_8(r, a); |
1033 | if (word16th != 0) | 1012 | if (word16th != 0) |
1034 | sp_256_sub_8_p256_mod(r); | 1013 | sp_256_sub_8_p256_mod(r); |
1035 | sp_256_norm_8(r); | ||
1036 | } | 1014 | } |
1037 | else { /* Same code for explicit mp == 1 (which is always the case for P256) */ | 1015 | else { /* Same code for explicit mp == 1 (which is always the case for P256) */ |
1038 | sp_digit word16th = 0; | 1016 | sp_digit word16th = 0; |
@@ -1052,7 +1030,6 @@ static void sp_512to256_mont_reduce_8(sp_digit* r, sp_digit* a/*, const sp_digit | |||
1052 | sp_512to256_mont_shift_8(r, a); | 1030 | sp_512to256_mont_shift_8(r, a); |
1053 | if (word16th != 0) | 1031 | if (word16th != 0) |
1054 | sp_256_sub_8_p256_mod(r); | 1032 | sp_256_sub_8_p256_mod(r); |
1055 | sp_256_norm_8(r); | ||
1056 | } | 1033 | } |
1057 | } | 1034 | } |
1058 | #endif | 1035 | #endif |
@@ -1208,14 +1185,12 @@ static void sp_256_map_8(sp_point* r, sp_point* p) | |||
1208 | /* Reduce x to less than modulus */ | 1185 | /* Reduce x to less than modulus */ |
1209 | if (sp_256_cmp_8(r->x, p256_mod) >= 0) | 1186 | if (sp_256_cmp_8(r->x, p256_mod) >= 0) |
1210 | sp_256_sub_8_p256_mod(r->x); | 1187 | sp_256_sub_8_p256_mod(r->x); |
1211 | sp_256_norm_8(r->x); | ||
1212 | 1188 | ||
1213 | /* y /= z^3 */ | 1189 | /* y /= z^3 */ |
1214 | sp_256_mont_mul_and_reduce_8(r->y, p->y, t1 /*, p256_mod, p256_mp_mod*/); | 1190 | sp_256_mont_mul_and_reduce_8(r->y, p->y, t1 /*, p256_mod, p256_mp_mod*/); |
1215 | /* Reduce y to less than modulus */ | 1191 | /* Reduce y to less than modulus */ |
1216 | if (sp_256_cmp_8(r->y, p256_mod) >= 0) | 1192 | if (sp_256_cmp_8(r->y, p256_mod) >= 0) |
1217 | sp_256_sub_8_p256_mod(r->y); | 1193 | sp_256_sub_8_p256_mod(r->y); |
1218 | sp_256_norm_8(r->y); | ||
1219 | 1194 | ||
1220 | memset(r->z, 0, sizeof(r->z)); | 1195 | memset(r->z, 0, sizeof(r->z)); |
1221 | r->z[0] = 1; | 1196 | r->z[0] = 1; |
@@ -1300,7 +1275,6 @@ static NOINLINE void sp_256_proj_point_add_8(sp_point* r, sp_point* p, sp_point* | |||
1300 | 1275 | ||
1301 | /* Check double */ | 1276 | /* Check double */ |
1302 | sp_256_sub_8(t1, p256_mod, q->y); | 1277 | sp_256_sub_8(t1, p256_mod, q->y); |
1303 | sp_256_norm_8(t1); | ||
1304 | if (sp_256_cmp_equal_8(p->x, q->x) | 1278 | if (sp_256_cmp_equal_8(p->x, q->x) |
1305 | && sp_256_cmp_equal_8(p->z, q->z) | 1279 | && sp_256_cmp_equal_8(p->z, q->z) |
1306 | && (sp_256_cmp_equal_8(p->y, q->y) || sp_256_cmp_equal_8(p->y, t1)) | 1280 | && (sp_256_cmp_equal_8(p->y, q->y) || sp_256_cmp_equal_8(p->y, t1)) |
@@ -1422,14 +1396,15 @@ static void sp_256_ecc_mulmod_8(sp_point* r, const sp_point* g, const sp_digit* | |||
1422 | static void sp_256_ecc_mulmod_base_8(sp_point* r, sp_digit* k /*, int map*/) | 1396 | static void sp_256_ecc_mulmod_base_8(sp_point* r, sp_digit* k /*, int map*/) |
1423 | { | 1397 | { |
1424 | /* Since this function is called only once, save space: | 1398 | /* Since this function is called only once, save space: |
1425 | * don't have "static const sp_point p256_base = {...}", | 1399 | * don't have "static const sp_point p256_base = {...}". |
1426 | * it would have more zeros than data. | ||
1427 | */ | 1400 | */ |
1428 | static const uint8_t p256_base_bin[] = { | 1401 | static const uint8_t p256_base_bin[] = { |
1429 | /* x (big-endian) */ | 1402 | /* x (big-endian) */ |
1430 | 0x6b,0x17,0xd1,0xf2,0xe1,0x2c,0x42,0x47,0xf8,0xbc,0xe6,0xe5,0x63,0xa4,0x40,0xf2,0x77,0x03,0x7d,0x81,0x2d,0xeb,0x33,0xa0,0xf4,0xa1,0x39,0x45,0xd8,0x98,0xc2,0x96, | 1403 | 0x6b,0x17,0xd1,0xf2,0xe1,0x2c,0x42,0x47,0xf8,0xbc,0xe6,0xe5,0x63,0xa4,0x40,0xf2, |
1404 | 0x77,0x03,0x7d,0x81,0x2d,0xeb,0x33,0xa0,0xf4,0xa1,0x39,0x45,0xd8,0x98,0xc2,0x96, | ||
1431 | /* y */ | 1405 | /* y */ |
1432 | 0x4f,0xe3,0x42,0xe2,0xfe,0x1a,0x7f,0x9b,0x8e,0xe7,0xeb,0x4a,0x7c,0x0f,0x9e,0x16,0x2b,0xce,0x33,0x57,0x6b,0x31,0x5e,0xce,0xcb,0xb6,0x40,0x68,0x37,0xbf,0x51,0xf5, | 1406 | 0x4f,0xe3,0x42,0xe2,0xfe,0x1a,0x7f,0x9b,0x8e,0xe7,0xeb,0x4a,0x7c,0x0f,0x9e,0x16, |
1407 | 0x2b,0xce,0x33,0x57,0x6b,0x31,0x5e,0xce,0xcb,0xb6,0x40,0x68,0x37,0xbf,0x51,0xf5, | ||
1433 | /* z will be set to 1, infinity flag to "false" */ | 1408 | /* z will be set to 1, infinity flag to "false" */ |
1434 | }; | 1409 | }; |
1435 | sp_point p256_base; | 1410 | sp_point p256_base; |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 9fc690315..c7f130a70 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -295,6 +295,7 @@ static void option_to_env(const uint8_t *option, const uint8_t *option_end) | |||
295 | *new_env() = xasprintf("ipv6=%s", ipv6str); | 295 | *new_env() = xasprintf("ipv6=%s", ipv6str); |
296 | 296 | ||
297 | move_from_unaligned32(v32, option + 4 + 16 + 4); | 297 | move_from_unaligned32(v32, option + 4 + 16 + 4); |
298 | v32 = ntohl(v32); | ||
298 | *new_env() = xasprintf("lease=%u", (unsigned)v32); | 299 | *new_env() = xasprintf("lease=%u", (unsigned)v32); |
299 | break; | 300 | break; |
300 | 301 | ||
@@ -332,6 +333,7 @@ static void option_to_env(const uint8_t *option, const uint8_t *option_end) | |||
332 | * +-+-+-+-+-+-+-+-+ | 333 | * +-+-+-+-+-+-+-+-+ |
333 | */ | 334 | */ |
334 | move_from_unaligned32(v32, option + 4 + 4); | 335 | move_from_unaligned32(v32, option + 4 + 4); |
336 | v32 = ntohl(v32); | ||
335 | *new_env() = xasprintf("ipv6prefix_lease=%u", (unsigned)v32); | 337 | *new_env() = xasprintf("ipv6prefix_lease=%u", (unsigned)v32); |
336 | 338 | ||
337 | sprint_nip6(ipv6str, option + 4 + 4 + 4 + 1); | 339 | sprint_nip6(ipv6str, option + 4 + 4 + 4 + 1); |
@@ -842,7 +844,7 @@ static NOINLINE int send_d6_renew(struct in6_addr *server_ipv6, struct in6_addr | |||
842 | uint8_t *opt_ptr; | 844 | uint8_t *opt_ptr; |
843 | 845 | ||
844 | /* Fill in: msg type, xid, ELAPSED_TIME */ | 846 | /* Fill in: msg type, xid, ELAPSED_TIME */ |
845 | opt_ptr = init_d6_packet(&packet, DHCPREQUEST); | 847 | opt_ptr = init_d6_packet(&packet, D6_MSG_RENEW); |
846 | 848 | ||
847 | /* server id */ | 849 | /* server id */ |
848 | opt_ptr = mempcpy(opt_ptr, client6_data.server_id, client6_data.server_id->len + 2+2); | 850 | opt_ptr = mempcpy(opt_ptr, client6_data.server_id, client6_data.server_id->len + 2+2); |
@@ -1081,7 +1083,7 @@ static void change_listen_mode(int new_mode) | |||
1081 | client_data.sockfd = -1; | 1083 | client_data.sockfd = -1; |
1082 | } | 1084 | } |
1083 | if (new_mode == LISTEN_KERNEL) | 1085 | if (new_mode == LISTEN_KERNEL) |
1084 | client_data.sockfd = udhcp_listen_socket(/*INADDR_ANY,*/ CLIENT_PORT6, client_data.interface); | 1086 | client_data.sockfd = d6_listen_socket(CLIENT_PORT6, client_data.interface); |
1085 | else if (new_mode != LISTEN_NONE) | 1087 | else if (new_mode != LISTEN_NONE) |
1086 | client_data.sockfd = d6_raw_socket(client_data.ifindex); | 1088 | client_data.sockfd = d6_raw_socket(client_data.ifindex); |
1087 | /* else LISTEN_NONE: client_data.sockfd stays closed */ | 1089 | /* else LISTEN_NONE: client_data.sockfd stays closed */ |
@@ -1487,6 +1489,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1487 | if (opt & OPT_l) | 1489 | if (opt & OPT_l) |
1488 | send_d6_info_request(); | 1490 | send_d6_info_request(); |
1489 | else /* send a broadcast renew request */ | 1491 | else /* send a broadcast renew request */ |
1492 | //TODO: send_d6_renew uses D6_MSG_RENEW message, should we use D6_MSG_REBIND here instead? | ||
1490 | send_d6_renew(/*server_ipv6:*/ NULL, requested_ipv6); | 1493 | send_d6_renew(/*server_ipv6:*/ NULL, requested_ipv6); |
1491 | timeout = discover_timeout; | 1494 | timeout = discover_timeout; |
1492 | packet_num++; | 1495 | packet_num++; |
diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c index 8ddee5a8e..21cf61c6e 100644 --- a/networking/udhcp/d6_socket.c +++ b/networking/udhcp/d6_socket.c | |||
@@ -110,7 +110,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) | |||
110 | int fd; | 110 | int fd; |
111 | struct sockaddr_in6 addr; | 111 | struct sockaddr_in6 addr; |
112 | 112 | ||
113 | log1("opening listen socket on *:%d %s", port, inf); | 113 | log2("opening listen socket on *:%d %s", port, inf); |
114 | fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); | 114 | fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); |
115 | 115 | ||
116 | setsockopt_reuseaddr(fd); | 116 | setsockopt_reuseaddr(fd); |