Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ell for openSUSE:Factory checked in at 2022-02-26 17:01:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ell (Old) and /work/SRC/openSUSE:Factory/.ell.new.1958 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ell" Sat Feb 26 17:01:43 2022 rev:27 rq:957524 version:0.49 Changes: -------- --- /work/SRC/openSUSE:Factory/ell/ell.changes 2022-01-27 23:16:15.215273853 +0100 +++ /work/SRC/openSUSE:Factory/.ell.new.1958/ell.changes 2022-02-26 17:01:44.343532628 +0100 @@ -1,0 +2,7 @@ +Fri Feb 25 07:33:24 UTC 2022 - Paolo Stivanin <[email protected]> + +- update to 0.49: + * Fix issue with multiple offers from the same DHCP server. + * Fix issue with Base64 decoding and bytes consumed validation. + +------------------------------------------------------------------- Old: ---- ell-0.48.tar.sign ell-0.48.tar.xz New: ---- ell-0.49.tar.sign ell-0.49.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ell.spec ++++++ --- /var/tmp/diff_new_pack.Gr4Wzq/_old 2022-02-26 17:01:45.135532754 +0100 +++ /var/tmp/diff_new_pack.Gr4Wzq/_new 2022-02-26 17:01:45.139532755 +0100 @@ -18,7 +18,7 @@ %define lname libell0 Name: ell -Version: 0.48 +Version: 0.49 Release: 0 Summary: Wireless setup and cryptography library License: LGPL-2.1-or-later ++++++ ell-0.48.tar.xz -> ell-0.49.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ChangeLog new/ell-0.49/ChangeLog --- old/ell-0.48/ChangeLog 2022-01-24 21:40:13.000000000 +0100 +++ new/ell-0.49/ChangeLog 2022-02-24 21:20:21.000000000 +0100 @@ -1,3 +1,7 @@ +ver 0.49: + Fix issue with multiple offers from the same DHCP server. + Fix issue with Base64 decoding and bytes consumed validation. + ver 0.48: Fix issue with memory leaking from ICMPv6 RA. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/configure new/ell-0.49/configure --- old/ell-0.48/configure 2022-01-24 21:41:40.000000000 +0100 +++ new/ell-0.49/configure 2022-02-24 21:21:56.000000000 +0100 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ell 0.48. +# Generated by GNU Autoconf 2.69 for ell 0.49. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ # Identity of this package. PACKAGE_NAME='ell' PACKAGE_TARNAME='ell' -PACKAGE_VERSION='0.48' -PACKAGE_STRING='ell 0.48' +PACKAGE_VERSION='0.49' +PACKAGE_STRING='ell 0.49' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1350,7 +1350,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ell 0.48 to adapt to many kinds of systems. +\`configure' configures ell 0.49 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1421,7 +1421,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ell 0.48:";; + short | recursive ) echo "Configuration of ell 0.49:";; esac cat <<\_ACEOF @@ -1548,7 +1548,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ell configure 0.48 +ell configure 0.49 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1913,7 +1913,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ell $as_me 0.48, which was +It was created by ell $as_me 0.49, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2776,7 +2776,7 @@ # Define the identity of the package. PACKAGE='ell' - VERSION='0.48' + VERSION='0.49' cat >>confdefs.h <<_ACEOF @@ -13646,7 +13646,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ell $as_me 0.48, which was +This file was extended by ell $as_me 0.49, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13712,7 +13712,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ell config.status 0.48 +ell config.status 0.49 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/configure.ac new/ell-0.49/configure.ac --- old/ell-0.48/configure.ac 2022-01-24 21:40:13.000000000 +0100 +++ new/ell-0.49/configure.ac 2022-02-24 21:20:21.000000000 +0100 @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(ell, 0.48) +AC_INIT(ell, 0.49) AC_CONFIG_HEADERS(config.h) AC_CONFIG_AUX_DIR(build-aux) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/acd.c new/ell-0.49/ell/acd.c --- old/ell-0.48/ell/acd.c 2021-08-01 21:49:37.000000000 +0200 +++ new/ell-0.49/ell/acd.c 2022-02-24 21:20:21.000000000 +0100 @@ -281,11 +281,8 @@ target_conflict = probe && !memcmp(arp.arp_tpa, &acd->ip, sizeof(uint32_t)); - if (!source_conflict && !target_conflict) { - ACD_DEBUG("No target or source conflict detected for "NIPQUAD_FMT, - NIPQUAD(acd->ip)); + if (!source_conflict && !target_conflict) return true; - } switch (acd->state) { case ACD_STATE_PROBE: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/base64.c new/ell-0.49/ell/base64.c --- old/ell-0.48/ell/base64.c 2022-01-05 22:10:31.000000000 +0100 +++ new/ell-0.49/ell/base64.c 2022-02-24 21:20:21.000000000 +0100 @@ -27,56 +27,59 @@ #include "utf8.h" #include "base64.h" #include "private.h" +#include "useful.h" + +#include <stdio.h> LIB_EXPORT uint8_t *l_base64_decode(const char *in, size_t in_len, size_t *n_written) { const char *ptr, *in_end = in + in_len; + const char *base64_end = NULL; uint8_t *out_buf, *out; - int base64_len = 0, pad_len; + int base64_len = 0, pad_len = 0; uint16_t reg = 0; - for (ptr = in; ptr < in_end; ptr++) + for (ptr = in; ptr < in_end; ptr++) { if (l_ascii_isspace(*ptr)) /* Whitespace */ continue; - else if (*ptr == '=') + else if (*ptr == '=') { /* Final padding */ - break; - else if (l_ascii_isalnum(*ptr) || *ptr == '+' || *ptr == '/') + if (!pad_len) + base64_end = ptr; + + pad_len++; + } else if (!pad_len && (l_ascii_isalnum(*ptr) || *ptr == '+' || + *ptr == '/')) /* Base64 character */ base64_len++; else /* Bad character */ return NULL; + } - in_end = ptr; + if (ptr != in_end) + return NULL; if ((base64_len & 3) == 1) /* Invalid length */ return NULL; - pad_len = (4 - base64_len) & 3; - for (; ptr < in + in_len && pad_len; ptr++) - if (l_ascii_isspace(*ptr)) - /* Whitespace */ - continue; - else if (*ptr == '=') - /* Final padding */ - pad_len--; - else - /* Bad character */ - return NULL; - if (pad_len) + if (pad_len != align_len(base64_len, 4) - base64_len) return NULL; + /* No padding */ + if (!base64_end) + base64_end = ptr; + *n_written = base64_len * 3 / 4; out_buf = l_malloc(*n_written); out = out_buf; base64_len = 0; - for (ptr = in; ptr < in_end; ptr++) { + for (ptr = in; ptr < base64_end; ptr++) { if (l_ascii_isspace(*ptr)) /* Whitespace */ continue; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/cert-crypto.c new/ell-0.49/ell/cert-crypto.c --- old/ell-0.48/ell/cert-crypto.c 2021-03-29 14:19:13.000000000 +0200 +++ new/ell-0.49/ell/cert-crypto.c 2022-02-24 21:20:21.000000000 +0100 @@ -216,7 +216,7 @@ * characters used. Recalculate p_len after we know it. * Important: The password must be valid UTF-8 here. */ - if (password) { + if (p_len) { if (!(bmpstring = l_utf8_to_ucs2be(password, &passwd_len))) { l_checksum_free(h); return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/dhcp.c new/ell-0.49/ell/dhcp.c --- old/ell-0.48/ell/dhcp.c 2021-11-02 15:41:45.000000000 +0100 +++ new/ell-0.49/ell/dhcp.c 2022-02-24 21:20:21.000000000 +0100 @@ -757,6 +757,7 @@ size_t len) { struct dhcp_message_iter iter; + struct l_dhcp_lease *lease; CLIENT_DEBUG(""); @@ -766,15 +767,55 @@ if (!_dhcp_message_iter_init(&iter, offer, len)) return -EINVAL; - client->lease = _dhcp_lease_parse_options(&iter); - if (!client->lease) + lease = _dhcp_lease_parse_options(&iter); + if (!lease) return -ENOMSG; + /* + * Received another offer. In the case of multiple DHCP servers we want + * to ignore it and continue using the first offer. If this is from the + * same server its likely a buggy DHCP implementation and we should + * use the last offer it sends. + */ + if (client->lease) { + if (client->lease->server_address != lease->server_address) { + _dhcp_lease_free(lease); + return -ENOMSG; + } + + CLIENT_DEBUG("Server sent another offer, using it instead"); + + _dhcp_lease_free(client->lease); + } + + client->lease = lease; + client->lease->address = offer->yiaddr; return 0; } +static bool dhcp_client_handle_offer(struct l_dhcp_client *client, + const struct dhcp_message *message, + size_t len) +{ + if (dhcp_client_receive_offer(client, message, len) < 0) + return false; + + CLIENT_ENTER_STATE(DHCP_STATE_REQUESTING); + client->attempt = 1; + + if (dhcp_client_send_request(client) < 0) { + l_dhcp_client_stop(client); + + return false; + } + + l_timeout_modify_ms(client->timeout_resend, dhcp_fuzz_secs(4)); + + return true; +} + static void dhcp_client_rx_message(const void *data, size_t len, void *userdata, const uint8_t *saddr) { @@ -832,21 +873,16 @@ if (msg_type != DHCP_MESSAGE_TYPE_OFFER) return; - if (dhcp_client_receive_offer(client, message, len) < 0) + if (!dhcp_client_handle_offer(client, message, len)) return; - CLIENT_ENTER_STATE(DHCP_STATE_REQUESTING); - client->attempt = 1; - - if (dhcp_client_send_request(client) < 0) { - l_dhcp_client_stop(client); - - return; - } - - l_timeout_modify_ms(client->timeout_resend, dhcp_fuzz_secs(4)); break; case DHCP_STATE_REQUESTING: + if (msg_type == DHCP_MESSAGE_TYPE_OFFER) { + dhcp_client_handle_offer(client, message, len); + return; + } + /* Fall through */ case DHCP_STATE_RENEWING: case DHCP_STATE_REBINDING: receive_rapid_commit: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/ecc.c new/ell-0.49/ell/ecc.c --- old/ell-0.48/ell/ecc.c 2022-01-24 21:40:13.000000000 +0100 +++ new/ell-0.49/ell/ecc.c 2022-02-24 21:20:21.000000000 +0100 @@ -534,6 +534,8 @@ { struct l_ecc_point *p; size_t bytes = curve->ndigits * 8; + uint64_t tmp[L_ECC_MAX_DIGITS]; + bool sub; if (!data) return NULL; @@ -556,20 +558,16 @@ break; case L_ECC_POINT_TYPE_COMPRESSED_BIT0: - if (!_ecc_compute_y(curve, p->y, p->x)) - goto failed; - - if (!(p->y[0] & 1)) - _vli_mod_sub(p->y, curve->p, p->y, curve->p, - curve->ndigits); - break; case L_ECC_POINT_TYPE_COMPRESSED_BIT1: if (!_ecc_compute_y(curve, p->y, p->x)) goto failed; - if (p->y[0] & 1) - _vli_mod_sub(p->y, curve->p, p->y, curve->p, - curve->ndigits); + sub = secure_select(type == L_ECC_POINT_TYPE_COMPRESSED_BIT0, + !(p->y[0] & 1), p->y[0] & 1); + + _vli_mod_sub(tmp, curve->p, p->y, curve->p, curve->ndigits); + + l_secure_select(sub, tmp, p->y, p->y, curve->ndigits * 8); break; case L_ECC_POINT_TYPE_FULL: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/ell.sym new/ell-0.49/ell/ell.sym --- old/ell-0.48/ell/ell.sym 2022-01-24 21:40:13.000000000 +0100 +++ new/ell-0.49/ell/ell.sym 2022-02-24 21:20:21.000000000 +0100 @@ -452,6 +452,7 @@ l_ringbuf_append; /* settings */ l_settings_new; + l_settings_clone; l_settings_free; l_settings_load_from_data; l_settings_to_data; @@ -489,6 +490,7 @@ l_settings_has_embedded_group; l_settings_get_embedded_groups; l_settings_get_embedded_value; + l_settings_remove_embedded_groups; /* signal */ l_signal_create; l_signal_remove; @@ -634,6 +636,7 @@ l_rtnl_route_free; l_rtnl_route_get_family; l_rtnl_route_get_gateway; + l_rtnl_route_get_dst; l_rtnl_route_get_lifetime; l_rtnl_route_set_lifetime; l_rtnl_route_get_mtu; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/rtnl.c new/ell-0.49/ell/rtnl.c --- old/ell-0.48/ell/rtnl.c 2021-09-14 21:48:51.000000000 +0200 +++ new/ell-0.49/ell/rtnl.c 2022-02-24 21:20:21.000000000 +0100 @@ -70,7 +70,7 @@ return -errno; break; default: - return false; + return -EAFNOSUPPORT; } return 0; @@ -403,6 +403,21 @@ out_buf); } +LIB_EXPORT bool l_rtnl_route_get_dst(const struct l_rtnl_route *rt, + char *out_buf, + uint8_t *out_prefix_len) +{ + if (unlikely(!rt)) + return false; + + if (address_to_string(rt->family, &rt->dst.in_addr, &rt->dst.in6_addr, + out_buf) != 0) + return false; + + *out_prefix_len = rt->dst_prefix_len; + return true; +} + LIB_EXPORT uint32_t l_rtnl_route_get_lifetime(const struct l_rtnl_route *rt) { if (unlikely(!rt)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/rtnl.h new/ell-0.49/ell/rtnl.h --- old/ell-0.48/ell/rtnl.h 2021-11-02 15:41:45.000000000 +0100 +++ new/ell-0.49/ell/rtnl.h 2022-02-24 21:20:21.000000000 +0100 @@ -71,6 +71,8 @@ bool l_rtnl_route_get_gateway(const struct l_rtnl_route *rt, char *out_buf); uint32_t l_rtnl_route_get_lifetime(const struct l_rtnl_route *rt); bool l_rtnl_route_set_lifetime(struct l_rtnl_route *rt, uint32_t lt); +bool l_rtnl_route_get_dst(const struct l_rtnl_route *rt, char *out_buf, + uint8_t *out_prefix_len); uint32_t l_rtnl_route_get_mtu(const struct l_rtnl_route *rt); bool l_rtnl_route_set_mtu(struct l_rtnl_route *rt, uint32_t mtu); uint8_t l_rtnl_route_get_preference(const struct l_rtnl_route *rt); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/settings.c new/ell-0.49/ell/settings.c --- old/ell-0.48/ell/settings.c 2022-01-24 21:40:13.000000000 +0100 +++ new/ell-0.49/ell/settings.c 2022-02-24 21:20:21.000000000 +0100 @@ -116,6 +116,63 @@ return settings; } +static void copy_key_value_foreach(void *data, void *user_data) +{ + struct setting_data *s = data; + struct l_queue *settings = user_data; + struct setting_data *copy = l_new(struct setting_data, 1); + + copy->key = l_strdup(s->key); + copy->value = l_strdup(s->value); + + l_queue_push_head(settings, copy); +} + +static void copy_group_foreach(void *data, void *user_data) +{ + struct group_data *group = data; + struct l_queue *groups = user_data; + struct group_data *copy = l_new(struct group_data, 1); + + copy->name = l_strdup(group->name); + copy->settings = l_queue_new(); + + l_queue_push_head(groups, copy); + + l_queue_foreach(group->settings, copy_key_value_foreach, + copy->settings); +} + +static void copy_embedded_foreach(void *data, void *user_data) +{ + struct embedded_group_data *embedded = data; + struct l_queue *groups = user_data; + struct embedded_group_data *copy; + + copy = l_memdup(embedded, sizeof(struct embedded_group_data) + + embedded->len + 1); + copy->name = l_strdup(embedded->name); + + l_queue_push_tail(groups, copy); +} + +LIB_EXPORT struct l_settings *l_settings_clone( + const struct l_settings *settings) +{ + struct l_settings *copy; + + if (unlikely(!settings)) + return NULL; + + copy = l_settings_new(); + + l_queue_foreach(settings->groups, copy_group_foreach, copy->groups); + l_queue_foreach(settings->embedded_groups, copy_embedded_foreach, + copy->embedded_groups); + + return copy; +} + LIB_EXPORT void l_settings_free(struct l_settings *settings) { if (unlikely(!settings)) @@ -1504,3 +1561,13 @@ return group->data; } + +LIB_EXPORT bool l_settings_remove_embedded_groups(struct l_settings *settings) +{ + if (unlikely(!settings)) + return false; + + l_queue_clear(settings->embedded_groups, embedded_group_destroy); + + return true; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/settings.h new/ell-0.49/ell/settings.h --- old/ell-0.48/ell/settings.h 2021-11-02 15:41:45.000000000 +0100 +++ new/ell-0.49/ell/settings.h 2022-02-24 21:20:21.000000000 +0100 @@ -37,6 +37,8 @@ typedef void (*l_settings_destroy_cb_t) (void *user_data); struct l_settings *l_settings_new(void); +struct l_settings *l_settings_clone(const struct l_settings *settings); + void l_settings_free(struct l_settings *settings); DEFINE_CLEANUP_FUNC(l_settings_free); @@ -135,6 +137,7 @@ bool l_settings_remove_group(struct l_settings *settings, const char *group_name); +bool l_settings_remove_embedded_groups(struct l_settings *settings); char **l_settings_get_embedded_groups(struct l_settings *settings); bool l_settings_has_embedded_group(struct l_settings *settings, const char *group); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/ell/utf8.c new/ell-0.49/ell/utf8.c --- old/ell-0.48/ell/utf8.c 2021-03-29 14:19:13.000000000 +0200 +++ new/ell-0.49/ell/utf8.c 2022-02-24 21:20:21.000000000 +0100 @@ -98,7 +98,7 @@ return 1; } - expect_bytes = __builtin_clz(~((unsigned char)str[0] << 24)); + expect_bytes = __builtin_clz(~((unsigned int)str[0] << 24)); if (expect_bytes < 2 || expect_bytes > 4) goto error; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/unit/test-base64.c new/ell-0.49/unit/test-base64.c --- old/ell-0.48/unit/test-base64.c 2022-01-05 22:10:31.000000000 +0100 +++ new/ell-0.49/unit/test-base64.c 2022-02-24 21:20:21.000000000 +0100 @@ -30,6 +30,7 @@ struct base64_decode_test { const char *input; + size_t input_size; const uint8_t *output; size_t output_size; }; @@ -81,6 +82,46 @@ l_free(decoded); } +/* Length != string length */ +static const struct base64_decode_test error_1 = { + .input = "cGxlYXN1cmUu", + .input_size = 11 +}; + +/* Length doesn't include pad */ +static const struct base64_decode_test error_2 = { + .input = "bGVhc3VyZS4=", + .input_size = 11, +}; + +/* Length doesn't include pad */ +static const struct base64_decode_test error_3 = { + .input = "ZWFzdXJlLg==", + .input_size = 10 +}; + +/* Length correct, but data after padding */ +static const struct base64_decode_test error_4 = { + .input = "ZWFzdXJlLg==bG", + .input_size = 14 +}; + +/* Only pad */ +static const struct base64_decode_test error_5 = { + .input = "==", + .input_size = 2 +}; + +static void test_base64_error(const void *data) +{ + const struct base64_decode_test *test = data; + uint8_t *decoded; + size_t decoded_size; + + decoded = l_base64_decode(test->input, test->input_size, &decoded_size); + assert(!decoded); +} + struct base64_encode_test { const char *input; const char *output; @@ -133,6 +174,11 @@ l_test_add("base64/decode/test2", test_base64_decode, &decode_2); l_test_add("base64/decode/test3", test_base64_decode, &decode_3); l_test_add("base64/decode/test4", test_base64_decode, &decode_4); + l_test_add("base64/decode/test5", test_base64_error, &error_1); + l_test_add("base64/decode/test6", test_base64_error, &error_2); + l_test_add("base64/decode/test7", test_base64_error, &error_3); + l_test_add("base64/decode/test8", test_base64_error, &error_4); + l_test_add("base64/decode/test9", test_base64_error, &error_5); l_test_add("base64/encode/test1", test_base64_encode, &encode_1); l_test_add("base64/encode/test2", test_base64_encode, &encode_2); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/unit/test-ecc.c new/ell-0.49/unit/test-ecc.c --- old/ell-0.48/unit/test-ecc.c 2021-08-01 21:49:37.000000000 +0200 +++ new/ell-0.49/unit/test-ecc.c 2022-02-24 21:20:21.000000000 +0100 @@ -366,6 +366,66 @@ assert(!_vli_is_zero_or_one(_2, L_ECC_MAX_DIGITS)); } +struct compressed_point_data { + char *x; + char *exp_y; + enum l_ecc_point_type type; +}; + +static struct compressed_point_data compressed_tests[] = { + { + /* BIT1, subtraction performed */ + .x = "19b3fec1c000a888ee9c44272e4d7317e6e36577fc9d53e1edfb4e296b0b7ce1", + .exp_y = "a8f9efd0ab526cd930870779621f4e9a53d4e78887ac9f4ed45ff75ded32b158", + .type = L_ECC_POINT_TYPE_COMPRESSED_BIT1, + }, + { + /* BIT1, no subtraction */ + .x = "958df5997362a9695ad73938c86be34a4730da877eccaaf8b189e73ff20e67c3", + .exp_y = "1042f37262ded34d8424c1728a1ed23a726645b71db30a38f2932001a2027f46", + .type = L_ECC_POINT_TYPE_COMPRESSED_BIT1, + }, + { + /* BIT0, subtraction performed */ + .x = "069bd56634454ca76e7ba434244137509141cbbf532586c6b36e9b5be8a2cc34", + .exp_y = "f4f34d46e4bdc1473fec4b4c8724f349375a8a602f5e83c260d6724e64ec7e99", + .type = L_ECC_POINT_TYPE_COMPRESSED_BIT0, + }, + { + /* BIT0, no subtraction */ + .x = "8cade296a68e0c40bcf45a049f1993263bdc8524825e2be44b14ce114e475df0", + .exp_y = "94ed7d09b2a0e95d8df993eaf81eb64d5ff734d01da57e53b2e0277199bc5897", + .type = L_ECC_POINT_TYPE_COMPRESSED_BIT0, + }, +}; + +static void run_test_compressed_points(const void *arg) +{ + unsigned int i; + + for (i = 0; i < L_ARRAY_SIZE(compressed_tests); i++) { + const struct l_ecc_curve *curve = l_ecc_curve_from_ike_group(19); + struct compressed_point_data *data = &compressed_tests[i]; + uint64_t x[L_ECC_MAX_DIGITS]; + uint64_t y[L_ECC_MAX_DIGITS]; + uint64_t exp_y[L_ECC_MAX_DIGITS]; + size_t bytes = l_ecc_curve_get_scalar_bytes(curve); + struct l_ecc_point *p; + + HEX2BUF(data->x, x); + HEX2BUF(data->exp_y, exp_y); + + p = l_ecc_point_from_data(curve, data->type, x, bytes); + assert(p); + + l_ecc_point_get_y(p, y, bytes); + + assert(!memcmp(exp_y, y, bytes)); + + l_ecc_point_free(p); + } +} + int main(int argc, char *argv[]) { l_test_init(&argc, &argv); @@ -387,6 +447,7 @@ l_test_add("ECC reduce test", run_test_reduce, NULL); l_test_add("ECC zero or one test", run_test_zero_or_one, NULL); + l_test_add("ECC compressed points", run_test_compressed_points, NULL); return l_test_run(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ell-0.48/unit/test-settings.c new/ell-0.49/unit/test-settings.c --- old/ell-0.48/unit/test-settings.c 2020-11-29 22:35:22.000000000 +0100 +++ new/ell-0.49/unit/test-settings.c 2022-02-24 21:20:21.000000000 +0100 @@ -559,6 +559,45 @@ l_settings_free(settings); } +static void check_clone_data(struct l_settings *settings) +{ + const char *value; + const char *type = NULL; + + assert(l_settings_has_group(settings, "normal")); + assert(l_settings_has_key(settings, "normal", "key")); + value = l_settings_get_value(settings, "normal", "key"); + assert(value); + assert(!strcmp(value, "value")); + + assert(l_settings_has_embedded_group(settings, "single_cert")); + value = l_settings_get_embedded_value(settings, "single_cert", + &type); + assert(value && type); + assert(!strcmp(type, "pem")); + assert(!strcmp(value, TEST_CERTIFICATE)); +} + +static void test_clone(const void *data) +{ + const char *raw_data = + "[normal]\n" + "key=value\n" + "[@pem@single_cert]\n" + TEST_CERTIFICATE; + + struct l_settings *settings = l_settings_new(); + struct l_settings *copy; + + assert(l_settings_load_from_data(settings, raw_data, strlen(raw_data))); + check_clone_data(settings); + + copy = l_settings_clone(settings); + check_clone_data(copy); + l_settings_free(copy); + l_settings_free(settings); +} + int main(int argc, char *argv[]) { l_test_init(&argc, &argv); @@ -571,7 +610,7 @@ l_test_add("Invalid Data 2", test_invalid_data, key_before_group_data); l_test_add("Test valid ext group", test_valid_extended_group, NULL); l_test_add("Test invalid ext group", test_invalid_extended_group, NULL); - + l_test_add("Test clone", test_clone, NULL); return l_test_run(); }
