diff options
Diffstat (limited to '')
-rw-r--r-- | include/libbb.h | 216 | ||||
-rw-r--r-- | include/platform.h | 2 | ||||
-rw-r--r-- | include/usage.src.h | 6 |
3 files changed, 150 insertions, 74 deletions
diff --git a/include/libbb.h b/include/libbb.h index 27c523cdf..60037ed3d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -281,12 +281,26 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
281 | # endif | 281 | # endif |
282 | #endif | 282 | #endif |
283 | 283 | ||
284 | #if ENABLE_FEATURE_TLS_SCHANNEL | 284 | #if ENABLE_FEATURE_TLS_SCHANNEL || ENABLE_FEATURE_USE_CNG_API |
285 | # define SECURITY_WIN32 | 285 | # define SECURITY_WIN32 |
286 | # include <windows.h> | 286 | # include <windows.h> |
287 | # include <security.h> | 287 | # include <security.h> |
288 | #endif | 288 | #endif |
289 | 289 | ||
290 | #if ENABLE_FEATURE_USE_CNG_API | ||
291 | # include <bcrypt.h> | ||
292 | |||
293 | // these work on Windows >= 10 | ||
294 | # define BCRYPT_HMAC_SHA1_ALG_HANDLE ((BCRYPT_ALG_HANDLE) 0x000000a1) | ||
295 | # define BCRYPT_HMAC_SHA256_ALG_HANDLE ((BCRYPT_ALG_HANDLE) 0x000000b1) | ||
296 | # define sha1_begin_hmac BCRYPT_HMAC_SHA1_ALG_HANDLE | ||
297 | # define sha256_begin_hmac BCRYPT_HMAC_SHA256_ALG_HANDLE | ||
298 | #else | ||
299 | # define sha1_begin_hmac sha1_begin | ||
300 | # define sha256_begin_hmac sha256_begin | ||
301 | # define hmac_uninit(...) ((void)0) | ||
302 | #endif | ||
303 | |||
290 | /* Tested to work correctly with all int types (IIRC :]) */ | 304 | /* Tested to work correctly with all int types (IIRC :]) */ |
291 | #define MAXINT(T) (T)( \ | 305 | #define MAXINT(T) (T)( \ |
292 | ((T)-1) > 0 \ | 306 | ((T)-1) > 0 \ |
@@ -1210,6 +1224,32 @@ char *bin2hex(char *dst, const char *src, int count) FAST_FUNC; | |||
1210 | /* Reverse */ | 1224 | /* Reverse */ |
1211 | char* hex2bin(char *dst, const char *src, int count) FAST_FUNC; | 1225 | char* hex2bin(char *dst, const char *src, int count) FAST_FUNC; |
1212 | 1226 | ||
1227 | /* Returns strlen as a bonus */ | ||
1228 | //size_t replace_char(char *s, char what, char with) FAST_FUNC; | ||
1229 | static inline size_t replace_char(char *str, char from, char to) | ||
1230 | { | ||
1231 | char *p = str; | ||
1232 | while (*p) { | ||
1233 | if (*p == from) | ||
1234 | *p = to; | ||
1235 | p++; | ||
1236 | } | ||
1237 | return p - str; | ||
1238 | } | ||
1239 | |||
1240 | extern const char c_escape_conv_str00[]; | ||
1241 | #define c_escape_conv_str07 (c_escape_conv_str00+3) | ||
1242 | |||
1243 | void FAST_FUNC xorbuf_3(void *dst, const void *src1, const void *src2, unsigned count); | ||
1244 | void FAST_FUNC xorbuf(void* buf, const void* mask, unsigned count); | ||
1245 | void FAST_FUNC xorbuf16_aligned_long(void* buf, const void* mask); | ||
1246 | void FAST_FUNC xorbuf64_3_aligned64(void *dst, const void *src1, const void *src2); | ||
1247 | #if BB_UNALIGNED_MEMACCESS_OK | ||
1248 | # define xorbuf16(buf,mask) xorbuf16_aligned_long(buf,mask) | ||
1249 | #else | ||
1250 | void FAST_FUNC xorbuf16(void* buf, const void* mask); | ||
1251 | #endif | ||
1252 | |||
1213 | /* Generate a UUID */ | 1253 | /* Generate a UUID */ |
1214 | void generate_uuid(uint8_t *buf) FAST_FUNC; | 1254 | void generate_uuid(uint8_t *buf) FAST_FUNC; |
1215 | 1255 | ||
@@ -1924,18 +1964,25 @@ extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_F | |||
1924 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC; | 1964 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC; |
1925 | /* | 1965 | /* |
1926 | * rnd is additional random input. New one is returned. | 1966 | * rnd is additional random input. New one is returned. |
1927 | * Useful if you call crypt_make_salt many times in a row: | 1967 | * Useful if you call crypt_make_rand64encoded many times in a row: |
1928 | * rnd = crypt_make_salt(buf1, 4, 0); | 1968 | * rnd = crypt_make_rand64encoded(buf1, 4, 0); |
1929 | * rnd = crypt_make_salt(buf2, 4, rnd); | 1969 | * rnd = crypt_make_rand64encoded(buf2, 4, rnd); |
1930 | * rnd = crypt_make_salt(buf3, 4, rnd); | 1970 | * rnd = crypt_make_rand64encoded(buf3, 4, rnd); |
1931 | * (otherwise we risk having same salt generated) | 1971 | * (otherwise we risk having same salt generated) |
1932 | */ | 1972 | */ |
1933 | extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC; | 1973 | extern int crypt_make_rand64encoded(char *p, int cnt /*, int rnd*/) FAST_FUNC; |
1934 | /* "$N$" + sha_salt_16_bytes + NUL */ | 1974 | /* Size of char salt[] to hold randomly-generated salt string |
1935 | #define MAX_PW_SALT_LEN (3 + 16 + 1) | 1975 | * sha256/512: |
1976 | * "$5$" ["rounds=999999999$"] "<sha_salt_16_chars><NUL>" | ||
1977 | * "$6$" ["rounds=999999999$"] "<sha_salt_16_chars><NUL>" | ||
1978 | * #define MAX_PW_SALT_LEN (3 + sizeof("rounds=999999999$")-1 + 16 + 1) | ||
1979 | * yescrypt: | ||
1980 | * "$y$" <up to 8 params of up to 6 chars each> "$" <up to 86 chars salt><NUL> | ||
1981 | * (86 chars are ascii64-encoded 64 binary bytes) | ||
1982 | */ | ||
1983 | #define MAX_PW_SALT_LEN (3 + 8*6 + 1 + 86 + 1) | ||
1936 | extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC; | 1984 | extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC; |
1937 | 1985 | ||
1938 | |||
1939 | /* Returns number of lines changed, or -1 on error */ | 1986 | /* Returns number of lines changed, or -1 on error */ |
1940 | #if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP) | 1987 | #if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP) |
1941 | #define update_passwd(filename, username, data, member) \ | 1988 | #define update_passwd(filename, username, data, member) \ |
@@ -2078,6 +2125,10 @@ int64_t windows_read_key(int fd, char *buffer, int timeout) FAST_FUNC; | |||
2078 | int64_t safe_read_key(int fd, char *buffer, int timeout) FAST_FUNC; | 2125 | int64_t safe_read_key(int fd, char *buffer, int timeout) FAST_FUNC; |
2079 | void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC; | 2126 | void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC; |
2080 | 2127 | ||
2128 | int check_got_signal_and_poll(struct pollfd pfd[1], int timeout) FAST_FUNC; | ||
2129 | #if ENABLE_PLATFORM_MINGW32 | ||
2130 | # define check_got_signal_and_poll(p, t) poll(p, 1, t) | ||
2131 | #endif | ||
2081 | 2132 | ||
2082 | #if ENABLE_FEATURE_EDITING | 2133 | #if ENABLE_FEATURE_EDITING |
2083 | /* It's NOT just ENABLEd or disabled. It's a number: */ | 2134 | /* It's NOT just ENABLEd or disabled. It's a number: */ |
@@ -2124,7 +2175,7 @@ typedef struct line_input_t { | |||
2124 | # if MAX_HISTORY | 2175 | # if MAX_HISTORY |
2125 | int cnt_history; | 2176 | int cnt_history; |
2126 | int cur_history; | 2177 | int cur_history; |
2127 | int max_history; /* must never be <= 0 */ | 2178 | int max_history; /* must never be < 0 */ |
2128 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY | 2179 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY |
2129 | /* meaning of this field depends on FEATURE_EDITING_SAVE_ON_EXIT: | 2180 | /* meaning of this field depends on FEATURE_EDITING_SAVE_ON_EXIT: |
2130 | * if !FEATURE_EDITING_SAVE_ON_EXIT: "how many lines are | 2181 | * if !FEATURE_EDITING_SAVE_ON_EXIT: "how many lines are |
@@ -2190,33 +2241,6 @@ enum { COMM_LEN = 16 }; | |||
2190 | # endif | 2241 | # endif |
2191 | #endif | 2242 | #endif |
2192 | 2243 | ||
2193 | struct smaprec { | ||
2194 | unsigned long mapped_rw; | ||
2195 | unsigned long mapped_ro; | ||
2196 | unsigned long shared_clean; | ||
2197 | unsigned long shared_dirty; | ||
2198 | unsigned long private_clean; | ||
2199 | unsigned long private_dirty; | ||
2200 | unsigned long stack; | ||
2201 | unsigned long smap_pss, smap_swap; | ||
2202 | unsigned long smap_size; | ||
2203 | // For mixed 32/64 userspace, 32-bit pmap still needs | ||
2204 | // 64-bit field here to correctly show 64-bit processes: | ||
2205 | unsigned long long smap_start; | ||
2206 | // (strictly speaking, other fields need to be wider too, | ||
2207 | // but they are in kbytes, not bytes, and they hold sizes, | ||
2208 | // not start addresses, sizes tend to be less than 4 terabytes) | ||
2209 | char smap_mode[5]; | ||
2210 | char *smap_name; | ||
2211 | }; | ||
2212 | |||
2213 | #if !ENABLE_PMAP | ||
2214 | #define procps_read_smaps(pid, total, cb, data) \ | ||
2215 | procps_read_smaps(pid, total) | ||
2216 | #endif | ||
2217 | int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, | ||
2218 | void (*cb)(struct smaprec *, void *), void *data); | ||
2219 | |||
2220 | typedef struct procps_status_t { | 2244 | typedef struct procps_status_t { |
2221 | #if !ENABLE_PLATFORM_MINGW32 | 2245 | #if !ENABLE_PLATFORM_MINGW32 |
2222 | DIR *dir; | 2246 | DIR *dir; |
@@ -2252,7 +2276,13 @@ typedef struct procps_status_t { | |||
2252 | #endif | 2276 | #endif |
2253 | unsigned tty_major,tty_minor; | 2277 | unsigned tty_major,tty_minor; |
2254 | #if ENABLE_FEATURE_TOPMEM | 2278 | #if ENABLE_FEATURE_TOPMEM |
2255 | struct smaprec smaps; | 2279 | unsigned long mapped_rw; |
2280 | unsigned long mapped_ro; | ||
2281 | unsigned long shared_clean; | ||
2282 | unsigned long shared_dirty; | ||
2283 | unsigned long private_clean; | ||
2284 | unsigned long private_dirty; | ||
2285 | unsigned long stack; | ||
2256 | #endif | 2286 | #endif |
2257 | char state[4]; | 2287 | char state[4]; |
2258 | /* basename of executable in exec(2), read from /proc/N/stat | 2288 | /* basename of executable in exec(2), read from /proc/N/stat |
@@ -2301,11 +2331,15 @@ void free_procps_scan(procps_status_t* sp) FAST_FUNC; | |||
2301 | procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; | 2331 | procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; |
2302 | /* Format cmdline (up to col chars) into char buf[size] */ | 2332 | /* Format cmdline (up to col chars) into char buf[size] */ |
2303 | /* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ | 2333 | /* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ |
2304 | void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; | 2334 | int read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; |
2305 | pid_t *find_pid_by_name(const char* procName) FAST_FUNC; | 2335 | pid_t *find_pid_by_name(const char* procName) FAST_FUNC; |
2306 | pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; | 2336 | pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; |
2307 | int starts_with_cpu(const char *str) FAST_FUNC; | 2337 | int starts_with_cpu(const char *str) FAST_FUNC; |
2308 | unsigned get_cpu_count(void) FAST_FUNC; | 2338 | unsigned get_cpu_count(void) FAST_FUNC; |
2339 | /* Some internals reused by pmap: */ | ||
2340 | unsigned long FAST_FUNC fast_strtoul_10(char **endptr); | ||
2341 | unsigned long long FAST_FUNC fast_strtoull_16(char **endptr); | ||
2342 | char* FAST_FUNC skip_fields(char *str, int count); | ||
2309 | 2343 | ||
2310 | 2344 | ||
2311 | /* Use strict=1 if you process input from untrusted source: | 2345 | /* Use strict=1 if you process input from untrusted source: |
@@ -2331,6 +2365,22 @@ char *decode_base64(char *dst, const char **pp_src) FAST_FUNC; | |||
2331 | char *decode_base32(char *dst, const char **pp_src) FAST_FUNC; | 2365 | char *decode_base32(char *dst, const char **pp_src) FAST_FUNC; |
2332 | void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; | 2366 | void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; |
2333 | 2367 | ||
2368 | int FAST_FUNC i2a64(int i); | ||
2369 | int FAST_FUNC a2i64(char c); | ||
2370 | char* FAST_FUNC num2str64_lsb_first(char *s, unsigned v, int n); | ||
2371 | |||
2372 | enum { | ||
2373 | /* how many bytes XYZ_end() fills */ | ||
2374 | MD5_OUTSIZE = 16, | ||
2375 | SHA1_OUTSIZE = 20, | ||
2376 | SHA256_OUTSIZE = 32, | ||
2377 | SHA384_OUTSIZE = 48, | ||
2378 | SHA512_OUTSIZE = 64, | ||
2379 | //SHA3-224_OUTSIZE = 28, | ||
2380 | /* size of input block */ | ||
2381 | SHA2_INSIZE = 64, | ||
2382 | }; | ||
2383 | |||
2334 | #if defined CONFIG_FEATURE_USE_CNG_API | 2384 | #if defined CONFIG_FEATURE_USE_CNG_API |
2335 | struct bcrypt_hash_ctx_t { | 2385 | struct bcrypt_hash_ctx_t { |
2336 | void *handle; | 2386 | void *handle; |
@@ -2340,6 +2390,7 @@ struct bcrypt_hash_ctx_t { | |||
2340 | typedef struct bcrypt_hash_ctx_t md5_ctx_t; | 2390 | typedef struct bcrypt_hash_ctx_t md5_ctx_t; |
2341 | typedef struct bcrypt_hash_ctx_t sha1_ctx_t; | 2391 | typedef struct bcrypt_hash_ctx_t sha1_ctx_t; |
2342 | typedef struct bcrypt_hash_ctx_t sha256_ctx_t; | 2392 | typedef struct bcrypt_hash_ctx_t sha256_ctx_t; |
2393 | typedef struct bcrypt_hash_ctx_t sha384_ctx_t; | ||
2343 | typedef struct bcrypt_hash_ctx_t sha512_ctx_t; | 2394 | typedef struct bcrypt_hash_ctx_t sha512_ctx_t; |
2344 | typedef struct sha3_ctx_t { | 2395 | typedef struct sha3_ctx_t { |
2345 | uint64_t state[25]; | 2396 | uint64_t state[25]; |
@@ -2349,16 +2400,19 @@ typedef struct sha3_ctx_t { | |||
2349 | void md5_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | 2400 | void md5_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; |
2350 | void sha1_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | 2401 | void sha1_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; |
2351 | void sha256_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | 2402 | void sha256_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; |
2403 | void sha384_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | ||
2352 | void sha512_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | 2404 | void sha512_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; |
2353 | void generic_hash(struct bcrypt_hash_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | 2405 | void generic_hash(struct bcrypt_hash_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; |
2354 | unsigned generic_end(struct bcrypt_hash_ctx_t *ctx, void *resbuf) FAST_FUNC; | 2406 | unsigned generic_end(struct bcrypt_hash_ctx_t *ctx, void *resbuf) FAST_FUNC; |
2355 | # define md5_hash generic_hash | 2407 | # define md5_hash generic_hash |
2356 | # define sha1_hash generic_hash | 2408 | # define sha1_hash generic_hash |
2357 | # define sha256_hash generic_hash | 2409 | # define sha256_hash generic_hash |
2410 | # define sha384_hash generic_hash | ||
2358 | # define sha512_hash generic_hash | 2411 | # define sha512_hash generic_hash |
2359 | # define md5_end generic_end | 2412 | # define md5_end generic_end |
2360 | # define sha1_end generic_end | 2413 | # define sha1_end generic_end |
2361 | # define sha256_end generic_end | 2414 | # define sha256_end generic_end |
2415 | # define sha384_end generic_end | ||
2362 | # define sha512_end generic_end | 2416 | # define sha512_end generic_end |
2363 | #else | 2417 | #else |
2364 | typedef struct md5_ctx_t { | 2418 | typedef struct md5_ctx_t { |
@@ -2374,6 +2428,7 @@ typedef struct sha512_ctx_t { | |||
2374 | uint64_t hash[8]; | 2428 | uint64_t hash[8]; |
2375 | uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */ | 2429 | uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */ |
2376 | } sha512_ctx_t; | 2430 | } sha512_ctx_t; |
2431 | typedef struct sha512_ctx_t sha384_ctx_t; | ||
2377 | typedef struct sha3_ctx_t { | 2432 | typedef struct sha3_ctx_t { |
2378 | uint64_t state[25]; | 2433 | uint64_t state[25]; |
2379 | unsigned bytes_queued; | 2434 | unsigned bytes_queued; |
@@ -2391,10 +2446,14 @@ void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; | |||
2391 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; | 2446 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; |
2392 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | 2447 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; |
2393 | unsigned sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; | 2448 | unsigned sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; |
2449 | void sha384_begin(sha384_ctx_t *ctx) FAST_FUNC; | ||
2450 | #define sha384_hash sha512_hash | ||
2451 | unsigned sha384_end(sha384_ctx_t *ctx, void *resbuf) FAST_FUNC; | ||
2394 | #endif | 2452 | #endif |
2395 | void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC; | 2453 | void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC; |
2396 | void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | 2454 | void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; |
2397 | unsigned sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC; | 2455 | unsigned sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC; |
2456 | void FAST_FUNC sha256_block(const void *in, size_t len, uint8_t hash[32]); | ||
2398 | /* TLS benefits from knowing that sha1 and sha256 share these. Give them "agnostic" names too */ | 2457 | /* TLS benefits from knowing that sha1 and sha256 share these. Give them "agnostic" names too */ |
2399 | #if defined CONFIG_FEATURE_USE_CNG_API | 2458 | #if defined CONFIG_FEATURE_USE_CNG_API |
2400 | typedef struct bcrypt_hash_ctx_t md5sha_ctx_t; | 2459 | typedef struct bcrypt_hash_ctx_t md5sha_ctx_t; |
@@ -2405,13 +2464,51 @@ typedef struct md5_ctx_t md5sha_ctx_t; | |||
2405 | #define md5sha_hash md5_hash | 2464 | #define md5sha_hash md5_hash |
2406 | #define sha_end sha1_end | 2465 | #define sha_end sha1_end |
2407 | #endif | 2466 | #endif |
2408 | enum { | 2467 | |
2409 | MD5_OUTSIZE = 16, | 2468 | /* RFC 2104 HMAC (hash-based message authentication code) */ |
2410 | SHA1_OUTSIZE = 20, | 2469 | #if !ENABLE_FEATURE_USE_CNG_API |
2411 | SHA256_OUTSIZE = 32, | 2470 | typedef struct hmac_ctx { |
2412 | SHA512_OUTSIZE = 64, | 2471 | md5sha_ctx_t hashed_key_xor_ipad; |
2413 | SHA3_OUTSIZE = 28, | 2472 | md5sha_ctx_t hashed_key_xor_opad; |
2414 | }; | 2473 | } hmac_ctx_t; |
2474 | #else | ||
2475 | typedef struct bcrypt_hash_ctx_t hmac_ctx_t; | ||
2476 | #endif | ||
2477 | #define HMAC_ONLY_SHA256 (!ENABLE_FEATURE_TLS_SHA1) | ||
2478 | typedef void md5sha_begin_func(md5sha_ctx_t *ctx) FAST_FUNC; | ||
2479 | #if !ENABLE_FEATURE_USE_CNG_API | ||
2480 | #if HMAC_ONLY_SHA256 | ||
2481 | #define hmac_begin(ctx,key,key_size,begin) \ | ||
2482 | hmac_begin(ctx,key,key_size) | ||
2483 | #endif | ||
2484 | void FAST_FUNC hmac_begin(hmac_ctx_t *ctx, const uint8_t *key, unsigned key_size, md5sha_begin_func *begin); | ||
2485 | static ALWAYS_INLINE void hmac_hash(hmac_ctx_t *ctx, const void *in, size_t len) | ||
2486 | { | ||
2487 | md5sha_hash(&ctx->hashed_key_xor_ipad, in, len); | ||
2488 | } | ||
2489 | #else | ||
2490 | # if HMAC_ONLY_SHA256 | ||
2491 | # define hmac_begin(pre,key,key_size,begin) \ | ||
2492 | _hmac_begin(pre, key, key_size, sha256_begin_hmac) | ||
2493 | # else | ||
2494 | # define hmac_begin _hmac_begin | ||
2495 | # endif | ||
2496 | void _hmac_begin(hmac_ctx_t *pre, uint8_t *key, unsigned key_size, | ||
2497 | BCRYPT_ALG_HANDLE alg_handle); | ||
2498 | void hmac_uninit(hmac_ctx_t *pre); | ||
2499 | #endif | ||
2500 | unsigned FAST_FUNC hmac_end(hmac_ctx_t *ctx, uint8_t *out); | ||
2501 | #if HMAC_ONLY_SHA256 | ||
2502 | #define hmac_block(key,key_size,begin,in,sz,out) \ | ||
2503 | hmac_block(key,key_size,in,sz,out) | ||
2504 | #endif | ||
2505 | unsigned FAST_FUNC hmac_block(const uint8_t *key, unsigned key_size, | ||
2506 | md5sha_begin_func *begin, | ||
2507 | const void *in, unsigned sz, | ||
2508 | uint8_t *out); | ||
2509 | /* HMAC helpers for TLS: */ | ||
2510 | void FAST_FUNC hmac_hash_v(hmac_ctx_t *ctx, va_list va); | ||
2511 | unsigned hmac_peek_hash(hmac_ctx_t *ctx, uint8_t *out, ...); | ||
2415 | 2512 | ||
2416 | extern uint32_t *global_crc32_table; | 2513 | extern uint32_t *global_crc32_table; |
2417 | uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; | 2514 | uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; |
@@ -2547,31 +2644,10 @@ extern struct globals *BB_GLOBAL_CONST ptr_to_globals; | |||
2547 | #define barrier() asm volatile ("":::"memory") | 2644 | #define barrier() asm volatile ("":::"memory") |
2548 | 2645 | ||
2549 | #if defined(__clang_major__) && __clang_major__ >= 9 | 2646 | #if defined(__clang_major__) && __clang_major__ >= 9 |
2550 | /* Clang/llvm drops assignment to "constant" storage. Silently. | 2647 | /* {ASSIGN,XZALLOC}_CONST_PTR() are out-of-line functions |
2551 | * Needs serious convincing to not eliminate the store. | 2648 | * to prevent clang from reading pointer before it is assigned. |
2552 | */ | ||
2553 | static ALWAYS_INLINE void* not_const_pp(const void *p) | ||
2554 | { | ||
2555 | void *pp; | ||
2556 | asm volatile ( | ||
2557 | "# forget that p points to const" | ||
2558 | : /*outputs*/ "=r" (pp) | ||
2559 | : /*inputs*/ "0" (p) | ||
2560 | ); | ||
2561 | return pp; | ||
2562 | } | ||
2563 | # if !ENABLE_PLATFORM_MINGW32 | ||
2564 | # define ASSIGN_CONST_PTR(pptr, v) do { \ | ||
2565 | *(void**)not_const_pp(pptr) = (void*)(v); \ | ||
2566 | barrier(); \ | ||
2567 | } while (0) | ||
2568 | #else | ||
2569 | /* On Windows it seems necessary for this to be a function too. */ | ||
2570 | void ASSIGN_CONST_PTR(const void *pptr, const void *ptr) FAST_FUNC; | ||
2571 | #endif | ||
2572 | /* XZALLOC_CONST_PTR() is an out-of-line function to prevent | ||
2573 | * clang from reading pointer before it is assigned. | ||
2574 | */ | 2649 | */ |
2650 | void ASSIGN_CONST_PTR(const void *pptr, void *v) FAST_FUNC; | ||
2575 | void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC; | 2651 | void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC; |
2576 | #else | 2652 | #else |
2577 | # define ASSIGN_CONST_PTR(pptr, v) do { \ | 2653 | # define ASSIGN_CONST_PTR(pptr, v) do { \ |
diff --git a/include/platform.h b/include/platform.h index 5795a0cf3..0b88f990b 100644 --- a/include/platform.h +++ b/include/platform.h | |||
@@ -208,7 +208,7 @@ | |||
208 | #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN | 208 | #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN |
209 | # define BB_BIG_ENDIAN 0 | 209 | # define BB_BIG_ENDIAN 0 |
210 | # define BB_LITTLE_ENDIAN 1 | 210 | # define BB_LITTLE_ENDIAN 1 |
211 | #elif defined(__386__) | 211 | #elif defined(__i386__) |
212 | # define BB_BIG_ENDIAN 0 | 212 | # define BB_BIG_ENDIAN 0 |
213 | # define BB_LITTLE_ENDIAN 1 | 213 | # define BB_LITTLE_ENDIAN 1 |
214 | #else | 214 | #else |
diff --git a/include/usage.src.h b/include/usage.src.h index 5d2038834..0881337f8 100644 --- a/include/usage.src.h +++ b/include/usage.src.h | |||
@@ -17,11 +17,11 @@ | |||
17 | #define scripted_trivial_usage NOUSAGE_STR | 17 | #define scripted_trivial_usage NOUSAGE_STR |
18 | #define scripted_full_usage "" | 18 | #define scripted_full_usage "" |
19 | 19 | ||
20 | #if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA | 20 | #if !ENABLE_USE_BB_CRYPT |
21 | # define CRYPT_METHODS_HELP_STR "des,md5,sha256/512" \ | 21 | # define CRYPT_METHODS_HELP_STR "des,md5,sha256/512,yescrypt" \ |
22 | " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" | 22 | " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" |
23 | #else | 23 | #else |
24 | # define CRYPT_METHODS_HELP_STR "des,md5" \ | 24 | # define CRYPT_METHODS_HELP_STR "des,md5"IF_USE_BB_CRYPT_SHA(",sha256/512")IF_USE_BB_CRYPT_YES(",yescrypt") \ |
25 | " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" | 25 | " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" |
26 | #endif | 26 | #endif |
27 | 27 | ||