sysoptions.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /*******************************************************************
  2. * You shouldn't edit this file unless you know you need to.
  3. * This file is only included from options.h
  4. *******************************************************************/
  5. #ifndef DROPBEAR_VERSION
  6. #define DROPBEAR_VERSION "2022.82"
  7. #endif
  8. #define LOCAL_IDENT "SSH-2.0-dropbear_" DROPBEAR_VERSION
  9. #define PROGNAME "dropbear"
  10. /* Spec recommends after one hour or 1 gigabyte of data. One hour
  11. * is a bit too verbose, so we try 8 hours */
  12. #ifndef KEX_REKEY_TIMEOUT
  13. #define KEX_REKEY_TIMEOUT (3600 * 8)
  14. #endif
  15. #ifndef KEX_REKEY_DATA
  16. #define KEX_REKEY_DATA (1<<30) /* 2^30 == 1GB, this value must be < INT_MAX */
  17. #endif
  18. /* Close connections to clients which haven't authorised after AUTH_TIMEOUT */
  19. #ifndef AUTH_TIMEOUT
  20. #define AUTH_TIMEOUT 300 /* we choose 5 minutes */
  21. #endif
  22. #define DROPBEAR_SVR_PUBKEY_OPTIONS_BUILT ((DROPBEAR_SVR_PUBKEY_AUTH) && (DROPBEAR_SVR_PUBKEY_OPTIONS))
  23. #if !(NON_INETD_MODE || INETD_MODE)
  24. #error "NON_INETD_MODE or INETD_MODE (or both) must be enabled."
  25. #endif
  26. /* Would probably work on freebsd but hasn't been tested */
  27. #if defined(HAVE_FEXECVE) && DROPBEAR_REEXEC && defined(__linux__)
  28. #define DROPBEAR_DO_REEXEC 1
  29. #else
  30. #define DROPBEAR_DO_REEXEC 0
  31. #endif
  32. /* A client should try and send an initial key exchange packet guessing
  33. * the algorithm that will match - saves a round trip connecting, has little
  34. * overhead if the guess was "wrong". */
  35. #ifndef DROPBEAR_KEX_FIRST_FOLLOWS
  36. #define DROPBEAR_KEX_FIRST_FOLLOWS 1
  37. #endif
  38. /* Use protocol extension to allow "first follows" to succeed more frequently.
  39. * This is currently Dropbear-specific but will gracefully fallback when connecting
  40. * to other implementations. */
  41. #ifndef DROPBEAR_KEXGUESS2
  42. #define DROPBEAR_KEXGUESS2 1
  43. #endif
  44. /* Minimum key sizes for DSS and RSA */
  45. #ifndef MIN_DSS_KEYLEN
  46. #define MIN_DSS_KEYLEN 1024
  47. #endif
  48. #ifndef MIN_RSA_KEYLEN
  49. #define MIN_RSA_KEYLEN 1024
  50. #endif
  51. #define MAX_BANNER_SIZE 2050 /* this is 25*80 chars, any more is foolish */
  52. #define MAX_BANNER_LINES 20 /* How many lines the client will display */
  53. /* the number of NAME=VALUE pairs to malloc for environ, if we don't have
  54. * the clearenv() function */
  55. #define ENV_SIZE 100
  56. #define MAX_CMD_LEN 9000 /* max length of a command */
  57. #define MAX_TERM_LEN 200 /* max length of TERM name */
  58. #define MAX_HOST_LEN 254 /* max hostname len for tcp fwding */
  59. #define MAX_IP_LEN 15 /* strlen("255.255.255.255") == 15 */
  60. #define DROPBEAR_MAX_PORTS 10 /* max number of ports which can be specified,
  61. ipv4 and ipv6 don't count twice */
  62. /* Each port might have at least a v4 and a v6 address */
  63. #define MAX_LISTEN_ADDR (DROPBEAR_MAX_PORTS*3)
  64. #define _PATH_TTY "/dev/tty"
  65. #define _PATH_CP "/bin/cp"
  66. #define DROPBEAR_ESCAPE_CHAR '~'
  67. /* success/failure defines */
  68. #define DROPBEAR_SUCCESS 0
  69. #define DROPBEAR_FAILURE -1
  70. #define DROPBEAR_PASSWORD_ENV "DROPBEAR_PASSWORD"
  71. #define DROPBEAR_NGROUP_MAX 1024
  72. /* Required for pubkey auth */
  73. #define DROPBEAR_SIGNKEY_VERIFY ((DROPBEAR_SVR_PUBKEY_AUTH) || (DROPBEAR_CLIENT))
  74. /* crypt(password) must take less time than the auth failure delay
  75. (250ms set in svr-auth.c). On Linux the delay depends on
  76. password length, 100 characters here was empirically derived.
  77. If a longer password is allowed Dropbear cannot compensate
  78. for the crypt time which will expose which usernames exist */
  79. #define DROPBEAR_MAX_PASSWORD_LEN 100
  80. #define SHA1_HASH_SIZE 20
  81. #define SHA256_HASH_SIZE 32
  82. #define MD5_HASH_SIZE 16
  83. #define MAX_HASH_SIZE 64 /* sha512 */
  84. #if DROPBEAR_CHACHA20POLY1305
  85. #define MAX_KEY_LEN 64 /* 2 x 256 bits for chacha20 */
  86. #else
  87. #define MAX_KEY_LEN 32 /* 256 bits for aes256 etc */
  88. #endif
  89. #define MAX_IV_LEN 20 /* must be same as max blocksize, */
  90. #if DROPBEAR_SHA2_512_HMAC
  91. #define MAX_MAC_LEN 64
  92. #elif DROPBEAR_SHA2_256_HMAC
  93. #define MAX_MAC_LEN 32
  94. #else
  95. #define MAX_MAC_LEN 20
  96. #endif
  97. /* sha2-512 is not necessary unless unforseen problems arise with sha2-256 */
  98. #ifndef DROPBEAR_SHA2_512_HMAC
  99. #define DROPBEAR_SHA2_512_HMAC 0
  100. #endif
  101. /* might be needed for compatibility with very old implementations */
  102. #ifndef DROPBEAR_MD5_HMAC
  103. #define DROPBEAR_MD5_HMAC 0
  104. #endif
  105. #define DROPBEAR_ECC ((DROPBEAR_ECDH) || (DROPBEAR_ECDSA))
  106. /* Debian doesn't define this in system headers */
  107. #if !defined(LTM_DESC) && (DROPBEAR_ECC)
  108. #define LTM_DESC
  109. #endif
  110. #define DROPBEAR_ECC_256 (DROPBEAR_ECC)
  111. #define DROPBEAR_ECC_384 (DROPBEAR_ECC)
  112. #define DROPBEAR_ECC_521 (DROPBEAR_ECC)
  113. #define DROPBEAR_LTC_PRNG (DROPBEAR_ECC)
  114. /* RSA can be vulnerable to timing attacks which use the time required for
  115. * signing to guess the private key. Blinding avoids this attack, though makes
  116. * signing operations slightly slower. */
  117. #define DROPBEAR_RSA_BLINDING 1
  118. #ifndef DROPBEAR_RSA_SHA1
  119. #define DROPBEAR_RSA_SHA1 DROPBEAR_RSA
  120. #endif
  121. #ifndef DROPBEAR_RSA_SHA256
  122. #define DROPBEAR_RSA_SHA256 DROPBEAR_RSA
  123. #endif
  124. /* hashes which will be linked and registered */
  125. #define DROPBEAR_SHA1 (DROPBEAR_RSA_SHA1 || DROPBEAR_DSS \
  126. || DROPBEAR_SHA1_HMAC || DROPBEAR_SHA1_96_HMAC \
  127. || DROPBEAR_DH_GROUP1 || DROPBEAR_DH_GROUP14_SHA1 )
  128. /* sha256 is always used for fingerprints and dbrandom */
  129. #define DROPBEAR_SHA256 1
  130. #define DROPBEAR_SHA384 (DROPBEAR_ECC_384)
  131. /* LTC SHA384 depends on SHA512 */
  132. #define DROPBEAR_SHA512 ((DROPBEAR_SHA2_512_HMAC) || (DROPBEAR_ECC_521) \
  133. || (DROPBEAR_SHA384) || (DROPBEAR_DH_GROUP16) \
  134. || (DROPBEAR_ED25519))
  135. #define DROPBEAR_MD5 (DROPBEAR_MD5_HMAC)
  136. #define DROPBEAR_DH_GROUP14 ((DROPBEAR_DH_GROUP14_SHA256) || (DROPBEAR_DH_GROUP14_SHA1))
  137. #define DROPBEAR_NORMAL_DH ((DROPBEAR_DH_GROUP1) || (DROPBEAR_DH_GROUP14) || (DROPBEAR_DH_GROUP16))
  138. /* Dropbear only uses server-sig-algs, only needed if we have rsa-sha256 pubkey auth */
  139. #define DROPBEAR_EXT_INFO ((DROPBEAR_RSA_SHA256) \
  140. && ((DROPBEAR_CLI_PUBKEY_AUTH) || (DROPBEAR_SVR_PUBKEY_AUTH)))
  141. /* roughly 2x 521 bits */
  142. #define MAX_ECC_SIZE 140
  143. #define MAX_NAME_LEN 64 /* maximum length of a protocol name, isn't
  144. explicitly specified for all protocols (just
  145. for algos) but seems valid */
  146. #define MAX_PROPOSED_ALGO 50
  147. /* size/count limits */
  148. /* From transport rfc */
  149. #define MIN_PACKET_LEN 16
  150. #define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  151. /* for channel code */
  152. #define TRANS_MAX_WINDOW 500000000 /* 500MB is sufficient, stopping overflow */
  153. #define TRANS_MAX_WIN_INCR 500000000 /* overflow prevention */
  154. #define RECV_WINDOWEXTEND (opts.recv_window / 3) /* We send a "window extend" every
  155. RECV_WINDOWEXTEND bytes */
  156. #define MAX_RECV_WINDOW (10*1024*1024) /* 10 MB should be enough */
  157. #define MAX_CHANNELS 1000 /* simple mem restriction, includes each tcp/x11
  158. connection, so can't be _too_ small */
  159. #define MAX_STRING_LEN (MAX(MAX_CMD_LEN, 2400)) /* Sun SSH needs 2400 for algos,
  160. MAX_CMD_LEN is usually longer */
  161. /* For a 4096 bit DSS key, empirically determined */
  162. #define MAX_PUBKEY_SIZE 1700
  163. /* For a 4096 bit DSS key, empirically determined */
  164. #define MAX_PRIVKEY_SIZE 1700
  165. #define MAX_HOSTKEYS 4
  166. /* The maximum size of the bignum portion of the kexhash buffer */
  167. /* Sect. 8 of the transport rfc 4253, K_S + e + f + K */
  168. #define KEXHASHBUF_MAX_INTS (1700 + 130 + 130 + 130)
  169. #define DROPBEAR_MAX_SOCKS 2 /* IPv4, IPv6 are all we'll get for now. Revisit
  170. in a few years time.... */
  171. #define DROPBEAR_MAX_CLI_PASS 1024
  172. #define DROPBEAR_MAX_CLI_INTERACT_PROMPTS 80 /* The number of prompts we'll
  173. accept for keyb-interactive
  174. auth */
  175. #define DROPBEAR_AES ((DROPBEAR_AES256) || (DROPBEAR_AES128))
  176. #define DROPBEAR_AEAD_MODE ((DROPBEAR_CHACHA20POLY1305) || (DROPBEAR_ENABLE_GCM_MODE))
  177. #define DROPBEAR_CLI_ANYTCPFWD ((DROPBEAR_CLI_REMOTETCPFWD) || (DROPBEAR_CLI_LOCALTCPFWD))
  178. #define DROPBEAR_TCP_ACCEPT ((DROPBEAR_CLI_LOCALTCPFWD) || (DROPBEAR_SVR_REMOTETCPFWD))
  179. #define DROPBEAR_LISTENERS \
  180. ((DROPBEAR_CLI_REMOTETCPFWD) || (DROPBEAR_CLI_LOCALTCPFWD) || \
  181. (DROPBEAR_SVR_REMOTETCPFWD) || (DROPBEAR_SVR_LOCALTCPFWD) || \
  182. (DROPBEAR_SVR_AGENTFWD) || (DROPBEAR_X11FWD))
  183. #define DROPBEAR_CLI_MULTIHOP ((DROPBEAR_CLI_NETCAT) && (DROPBEAR_CLI_PROXYCMD))
  184. #define ENABLE_CONNECT_UNIX ((DROPBEAR_CLI_AGENTFWD) || (DROPBEAR_USE_PRNGD))
  185. /* if we're using authorized_keys or known_hosts */
  186. #define DROPBEAR_KEY_LINES ((DROPBEAR_CLIENT) || (DROPBEAR_SVR_PUBKEY_AUTH))
  187. /* Changing this is inadvisable, it appears to have problems
  188. * with flushing compressed data */
  189. #define DROPBEAR_ZLIB_MEM_LEVEL 8
  190. #if (DROPBEAR_SVR_PASSWORD_AUTH) && (DROPBEAR_SVR_PAM_AUTH)
  191. #error "You can't turn on PASSWORD and PAM auth both at once. Fix it in localoptions.h"
  192. #endif
  193. /* PAM requires ./configure --enable-pam */
  194. #if !defined(HAVE_LIBPAM) && DROPBEAR_SVR_PAM_AUTH
  195. #error "DROPBEAR_SVR_PATM_AUTH requires PAM headers. Perhaps ./configure --enable-pam ?"
  196. #endif
  197. #if DROPBEAR_SVR_PASSWORD_AUTH && !HAVE_CRYPT
  198. #error "DROPBEAR_SVR_PASSWORD_AUTH requires `crypt()'."
  199. #endif
  200. #if !(DROPBEAR_SVR_PASSWORD_AUTH || DROPBEAR_SVR_PAM_AUTH || DROPBEAR_SVR_PUBKEY_AUTH)
  201. #error "At least one server authentication type must be enabled. DROPBEAR_SVR_PUBKEY_AUTH and DROPBEAR_SVR_PASSWORD_AUTH are recommended."
  202. #endif
  203. #if (DROPBEAR_PLUGIN && !DROPBEAR_SVR_PUBKEY_AUTH)
  204. #error "You must define DROPBEAR_SVR_PUBKEY_AUTH in order to use plugins"
  205. #endif
  206. #if !(DROPBEAR_AES128 || DROPBEAR_3DES || DROPBEAR_AES256 || DROPBEAR_CHACHA20POLY1305)
  207. #error "At least one encryption algorithm must be enabled. AES128 is recommended."
  208. #endif
  209. #if !(DROPBEAR_RSA || DROPBEAR_DSS || DROPBEAR_ECDSA || DROPBEAR_ED25519)
  210. #error "At least one hostkey or public-key algorithm must be enabled; RSA is recommended."
  211. #endif
  212. /* Source for randomness. This must be able to provide hundreds of bytes per SSH
  213. * connection without blocking. */
  214. #ifndef DROPBEAR_URANDOM_DEV
  215. #define DROPBEAR_URANDOM_DEV "/dev/urandom"
  216. #endif
  217. /* client keyboard interactive authentication is often used for password auth.
  218. rfc4256 */
  219. #define DROPBEAR_CLI_INTERACT_AUTH (DROPBEAR_CLI_PASSWORD_AUTH)
  220. /* We use dropbear_client and dropbear_server as shortcuts to avoid redundant
  221. * code, if we're just compiling as client or server */
  222. #if (DROPBEAR_SERVER) && (DROPBEAR_CLIENT)
  223. #define IS_DROPBEAR_SERVER (ses.isserver == 1)
  224. #define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  225. #elif DROPBEAR_SERVER
  226. #define IS_DROPBEAR_SERVER 1
  227. #define IS_DROPBEAR_CLIENT 0
  228. #elif DROPBEAR_CLIENT
  229. #define IS_DROPBEAR_SERVER 0
  230. #define IS_DROPBEAR_CLIENT 1
  231. #else
  232. /* Just building key utils? */
  233. #define IS_DROPBEAR_SERVER 0
  234. #define IS_DROPBEAR_CLIENT 0
  235. #endif /* neither DROPBEAR_SERVER nor DROPBEAR_CLIENT */
  236. #ifdef HAVE_FORK
  237. #define DROPBEAR_VFORK 0
  238. #else
  239. #define DROPBEAR_VFORK 1
  240. #endif
  241. #ifndef DROPBEAR_LISTEN_BACKLOG
  242. #if MAX_UNAUTH_CLIENTS > MAX_CHANNELS
  243. #define DROPBEAR_LISTEN_BACKLOG MAX_UNAUTH_CLIENTS
  244. #else
  245. #define DROPBEAR_LISTEN_BACKLOG MAX_CHANNELS
  246. #endif
  247. #endif
  248. /* free memory before exiting */
  249. #define DROPBEAR_CLEANUP 1
  250. /* Use this string since some implementations might special-case it */
  251. #define DROPBEAR_KEEPALIVE_STRING "keepalive@openssh.com"
  252. /* Linux will attempt TCP fast open, falling back if not supported by the kernel.
  253. * Currently server is enabled but client is disabled by default until there
  254. * is further compatibility testing */
  255. #ifdef __linux__
  256. #define DROPBEAR_SERVER_TCP_FAST_OPEN 1
  257. #define DROPBEAR_CLIENT_TCP_FAST_OPEN 0
  258. #else
  259. #define DROPBEAR_SERVER_TCP_FAST_OPEN 0
  260. #define DROPBEAR_CLIENT_TCP_FAST_OPEN 0
  261. #endif
  262. #define DROPBEAR_TRACKING_MALLOC (DROPBEAR_FUZZ)
  263. /* Used to work around Memory Sanitizer false positives */
  264. #if defined(__has_feature)
  265. # if __has_feature(memory_sanitizer)
  266. # define DROPBEAR_MSAN 1
  267. # endif
  268. #endif
  269. #ifndef DROPBEAR_MSAN
  270. #define DROPBEAR_MSAN 0
  271. #endif
  272. /* no include guard for this file */