mkj / dropbear

Dropbear SSH
https://matt.ucc.asn.au/dropbear/dropbear.html
Other
1.73k stars 405 forks source link

MacOS compilation error #161

Closed armwdev closed 2 years ago

armwdev commented 2 years ago

Just trying to compile this over MacOS 10.15. After ./configure and make, I received a compilation error as "Undefined symbols for architecture x86_64:"

I've also tried ./configure flags and some changes to the default_options.h but that didn't help.

The rest of the error message below:

ld: warning: ignoring file libtommath/libtommath.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file libtomcrypt/libtomcrypt.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture x86_64:
  "_aes_desc", referenced from:
      _crypto_init in crypto_desc.o
      _dropbear_aes256 in common-algo.o
  "_base64_decode", referenced from:
      _cmp_base64_key in signkey.o
  "_base64_encode", referenced from:
      _sign_key_fingerprint in signkey.o
  "_crypt_argchk", referenced from:
      _dropbear_prng_read in ltc_prng.o
      _dropbear_prng_export in ltc_prng.o
  "_ctr_decrypt", referenced from:
      _dropbear_mode_ctr in common-algo.o
  "_ctr_encrypt", referenced from:
      _dropbear_mode_ctr in common-algo.o
  "_ctr_start", referenced from:
      _dropbear_big_endian_ctr_start in common-algo.o
  "_ecc_ansi_x963_export", referenced from:
      _buf_put_ecc_raw_pubkey_string in ecc.o
  "_ecc_free", referenced from:
      _buf_get_pub_key in signkey.o
      _buf_get_priv_key in signkey.o
      _sign_key_free in signkey.o
      _buf_get_ecc_raw_pubkey in ecc.o
      _buf_get_ecdsa_priv_key in ecdsa.o
      _buf_put_ecdsa_sign in ecdsa.o
      _free_kexecdh_param in common-kex.o
      ...
  "_ecc_make_key_ex", referenced from:
      _gen_ecdsa_priv_key in ecdsa.o
      _buf_put_ecdsa_sign in ecdsa.o
      _gen_kexecdh_param in common-kex.o
  "_find_cipher", referenced from:
      _send_msg_newkeys in common-kex.o
  "_find_hash", referenced from:
      _send_msg_newkeys in common-kex.o
  "_hmac_done", referenced from:
      _make_mac in packet.o
  "_hmac_init", referenced from:
      _make_mac in packet.o
  "_hmac_process", referenced from:
      _make_mac in packet.o
  "_ltc_deinit_multi", referenced from:
      _buf_put_ecdsa_sign in ecdsa.o
      _buf_ecdsa_verify in ecdsa.o
  "_ltc_ecc_del_point", referenced from:
      _dropbear_ecc_shared_secret in ecc.o
      _buf_ecdsa_verify in ecdsa.o
  "_ltc_ecc_new_point", referenced from:
      _dropbear_ecc_shared_secret in ecc.o
      _buf_ecdsa_verify in ecdsa.o
  "_ltc_ecc_sets", referenced from:
      _dropbear_ecc_fill_dp in ecc.o
  "_ltc_init_multi", referenced from:
      _buf_put_ecdsa_sign in ecdsa.o
      _buf_ecdsa_verify in ecdsa.o
  "_ltc_mp", referenced from:
      _dropbear_ecc_shared_secret in ecc.o
      _buf_put_ecdsa_sign in ecdsa.o
      _buf_ecdsa_verify in ecdsa.o
      _crypto_init in crypto_desc.o
  "_ltm_desc", referenced from:
      _crypto_init in crypto_desc.o
  "_mp_add", referenced from:
      _buf_get_ecc_raw_pubkey in ecc.o
  "_mp_add_d", referenced from:
      _gen_dss_priv_key in gendss.o
  "_mp_addmod", referenced from:
      _buf_put_dss_sign in dss.o
  "_mp_clear", referenced from:
      _buf_put_dss_sign in dss.o
      _m_mp_free_multi in bignum.o
      _buf_put_rsa_sign in rsa.o
      _dropbear_ecc_shared_secret in ecc.o
      _getrsaprime in genrsa.o
      _session_cleanup in common-session.o
      _send_msg_newkeys in common-kex.o
      ...
  "_mp_clear_multi", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
      _buf_rsa_verify in rsa.o
      _buf_put_rsa_sign in rsa.o
      _buf_get_ecc_raw_pubkey in ecc.o
      _gen_dss_priv_key in gendss.o
      _gen_rsa_priv_key in genrsa.o
      ...
  "_mp_cmp", referenced from:
      _buf_get_dss_pub_key in dss.o
      _buf_dss_verify in dss.o
      _buf_rsa_verify in rsa.o
      _gen_random_mpint in dbrandom.o
      _buf_get_ecc_raw_pubkey in ecc.o
      _kexdh_comb_key in common-kex.o
  "_mp_cmp_d", referenced from:
      _buf_get_dss_pub_key in dss.o
      _buf_dss_verify in dss.o
      _gen_random_mpint in dbrandom.o
      _buf_get_ecc_raw_pubkey in ecc.o
      _gen_dss_priv_key in gendss.o
      _getrsaprime in genrsa.o
      _kexdh_comb_key in common-kex.o
      ...
  "_mp_copy", referenced from:
      _dropbear_ecc_shared_secret in ecc.o
  "_mp_count_bits", referenced from:
      _buf_putmpint in buffer.o
      _buf_get_dss_pub_key in dss.o
      _buf_get_rsa_pub_key in rsa.o
      _gen_random_mpint in dbrandom.o
      _gen_dss_priv_key in gendss.o
      _gen_rsa_priv_key in genrsa.o
      _getrsaprime in genrsa.o
      ...
  "_mp_div", referenced from:
      _gen_dss_priv_key in gendss.o
  "_mp_div_2", referenced from:
      _gen_kexdh_param in common-kex.o
  "_mp_exptmod", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
      _buf_rsa_verify in rsa.o
      _buf_put_rsa_sign in rsa.o
      _gen_dss_priv_key in gendss.o
      _gen_kexdh_param in common-kex.o
      _kexdh_comb_key in common-kex.o
      ...
  "_mp_from_ubin", referenced from:
      _buf_getmpint in buffer.o
      _bytes_to_mp in bignum.o
      _buf_rsa_verify in rsa.o
      _buf_get_ecc_raw_pubkey in ecc.o
  "_mp_gcd", referenced from:
      _getrsaprime in genrsa.o
  "_mp_init", referenced from:
      _m_mp_init in bignum.o
      _m_mp_init_multi in bignum.o
      _m_mp_alloc_init_multi in bignum.o
     (maybe you meant: _m_mp_init, _m_mp_init_multi )
  "_mp_invmod", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
      _buf_put_rsa_sign in rsa.o
      _gen_rsa_priv_key in genrsa.o
  "_mp_lcm", referenced from:
      _gen_rsa_priv_key in genrsa.o
  "_mp_mod", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
      _buf_get_ecc_raw_pubkey in ecc.o
      _gen_dss_priv_key in gendss.o
  "_mp_mul", referenced from:
      _buf_get_ecc_raw_pubkey in ecc.o
      _gen_rsa_priv_key in genrsa.o
  "_mp_mul_d", referenced from:
      _gen_dss_priv_key in gendss.o
  "_mp_mulmod", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
      _buf_put_rsa_sign in rsa.o
  "_mp_prime_is_prime", referenced from:
      _gen_dss_priv_key in gendss.o
  "_mp_prime_next_prime", referenced from:
      _gen_dss_priv_key in gendss.o
      _getrsaprime in genrsa.o
  "_mp_prime_rabin_miller_trials", referenced from:
      _gen_dss_priv_key in gendss.o
      _getrsaprime in genrsa.o
  "_mp_rand_source", referenced from:
      _crypto_init in crypto_desc.o
  "_mp_read_radix", referenced from:
      _buf_get_ecc_raw_pubkey in ecc.o
      _dropbear_ecc_shared_secret in ecc.o
  "_mp_set", referenced from:
      _buf_get_ecc_raw_pubkey in ecc.o
      _gen_dss_priv_key in gendss.o
  "_mp_set_ul", referenced from:
      _gen_rsa_priv_key in genrsa.o
      _gen_kexdh_param in common-kex.o
  "_mp_sqr", referenced from:
      _buf_get_ecc_raw_pubkey in ecc.o
  "_mp_sub", referenced from:
      _buf_get_ecc_raw_pubkey in ecc.o
      _gen_dss_priv_key in gendss.o
  "_mp_sub_d", referenced from:
      _gen_dss_priv_key in gendss.o
      _getrsaprime in genrsa.o
      _gen_kexdh_param in common-kex.o
      _kexdh_comb_key in common-kex.o
  "_mp_to_ubin", referenced from:
      _buf_putmpint in buffer.o
      _buf_put_dss_sign in dss.o
      _buf_put_rsa_sign in rsa.o
  "_mp_ubin_size", referenced from:
      _buf_put_dss_sign in dss.o
      _buf_rsa_verify in rsa.o
      _rsa_pad_em in rsa.o
      _buf_put_rsa_sign in rsa.o
  "_mp_zero", referenced from:
      _buf_getmpint in buffer.o
  "_register_cipher", referenced from:
      _crypto_init in crypto_desc.o
  "_register_hash", referenced from:
      _crypto_init in crypto_desc.o
  "_register_prng", referenced from:
      _crypto_init in crypto_desc.o
  "_sha1_desc", referenced from:
      _rsa_pad_em in rsa.o
      l___const.crypto_init.reghashes in crypto_desc.o
      _dropbear_sha1 in common-algo.o
      _kex_dh_group14_sha1 in common-algo.o
  "_sha1_done", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
  "_sha1_init", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
  "_sha1_process", referenced from:
      _buf_dss_verify in dss.o
      _buf_put_dss_sign in dss.o
  "_sha256_desc", referenced from:
      _rsa_pad_em in rsa.o
      _ecc_curve_nistp256 in ecc.o
      l___const.crypto_init.reghashes in crypto_desc.o
      _dropbear_sha2_256 in common-algo.o
      _kex_curve25519 in common-algo.o
      _kex_ecdh_nistp256 in common-algo.o
      _kex_dh_group14_sha256 in common-algo.o
      ...
  "_sha256_done", referenced from:
      _sign_key_fingerprint in signkey.o
      _addrandom in dbrandom.o
      _seedrandom in dbrandom.o
      _genrandom in dbrandom.o
      _buf_sk_ecdsa_verify in sk-ecdsa.o
      _buf_sk_ed25519_verify in sk-ed25519.o
  "_sha256_init", referenced from:
      _sign_key_fingerprint in signkey.o
      _addrandom in dbrandom.o
      _seedrandom in dbrandom.o
      _genrandom in dbrandom.o
      _buf_sk_ecdsa_verify in sk-ecdsa.o
      _buf_sk_ed25519_verify in sk-ed25519.o
  "_sha256_process", referenced from:
      _sign_key_fingerprint in signkey.o
      _addrandom in dbrandom.o
      _seedrandom in dbrandom.o
      _genrandom in dbrandom.o
      _buf_sk_ecdsa_verify in sk-ecdsa.o
      _buf_sk_ed25519_verify in sk-ed25519.o
  "_sha384_desc", referenced from:
      _ecc_curve_nistp384 in ecc.o
      l___const.crypto_init.reghashes in crypto_desc.o
      _kex_ecdh_nistp384 in common-algo.o
  "_sha512_desc", referenced from:
      _ecc_curve_nistp521 in ecc.o
      l___const.crypto_init.reghashes in crypto_desc.o
      _kex_ecdh_nistp521 in common-algo.o
  "_sha512_done", referenced from:
      _crypto_hash in curve25519.o
      _dropbear_ed25519_sign in curve25519.o
      _dropbear_ed25519_verify in curve25519.o
  "_sha512_init", referenced from:
      _crypto_hash in curve25519.o
      _dropbear_ed25519_sign in curve25519.o
      _dropbear_ed25519_verify in curve25519.o
  "_sha512_process", referenced from:
      _crypto_hash in curve25519.o
      _dropbear_ed25519_sign in curve25519.o
      _dropbear_ed25519_verify in curve25519.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [dropbear] Error 1

Thanks for the reply.

mkj commented 2 years ago

Can you check that the dev tools being used are all from xcode? I wonder if it's using ranlib/ar/gcc/clang from homebrew or similar which doesn't have the right support. If you can upload config.log that might have some details.

armwdev commented 2 years ago

Thanks, I appreciate the quick reply. Not sure but I think it uses the default xcode-select. I've also installed the homebrew so not sure if they somehow conflict. The config.log is attached below.

Thanks a lot.

config.log

mkj commented 2 years ago

These binaries here are coming from /usr/local/opt which might be homebrew. I guess /usr/bin should be first in path, or perhaps there's a way to update/configure homebrew.

configure:3974: checking for aarch64-apple-darwin-ar
configure:4004: result: no
configure:4014: checking for ar
configure:4030: found /usr/local/opt/binutils/bin/ar
configure:4041: result: ar
configure:4066: checking for aarch64-apple-darwin-ranlib
configure:4096: result: no
configure:4106: checking for ranlib
configure:4122: found /usr/local/opt/binutils/bin/ranlib
configure:4133: result: ranlib
configure:4158: checking for aarch64-apple-darwin-strip
configure:4188: result: no
configure:4198: checking for strip
configure:4214: found /usr/local/opt/binutils/bin/strip
configure:4225: result: strip
armwdev commented 2 years ago

Sorry for the late reply and thanks a lot for the help!

I was able to compile after uninstalling the homebrew and removing the /usr/local/opt/ path from the ~/.zshrc file.

mkj commented 2 years ago

I wonder if it's using a different compiler/linker to the normal ones from xcode commandline tools?

armwdev commented 2 years ago

As far as I remember, it was the default ones from the xcode commandline tools. I also installed zig toolchain for cross-compiling but not sure if that has any effect since zig uses it's own commands for cross-compiling.