diff options
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h index 7357d2907..1e345a3ee 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -2294,6 +2294,36 @@ char *decode_base64(char *dst, const char **pp_src) FAST_FUNC; | |||
2294 | char *decode_base32(char *dst, const char **pp_src) FAST_FUNC; | 2294 | char *decode_base32(char *dst, const char **pp_src) FAST_FUNC; |
2295 | void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; | 2295 | void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; |
2296 | 2296 | ||
2297 | #if defined CONFIG_FEATURE_USE_CNG_API | ||
2298 | struct bcrypt_hash_ctx_t { | ||
2299 | void *handle; | ||
2300 | void *hash_obj; | ||
2301 | unsigned int output_size; | ||
2302 | }; | ||
2303 | typedef struct bcrypt_hash_ctx_t md5_ctx_t; | ||
2304 | typedef struct bcrypt_hash_ctx_t sha1_ctx_t; | ||
2305 | typedef struct bcrypt_hash_ctx_t sha256_ctx_t; | ||
2306 | typedef struct bcrypt_hash_ctx_t sha512_ctx_t; | ||
2307 | typedef struct sha3_ctx_t { | ||
2308 | uint64_t state[25]; | ||
2309 | unsigned bytes_queued; | ||
2310 | unsigned input_block_bytes; | ||
2311 | } sha3_ctx_t; | ||
2312 | void md5_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | ||
2313 | void sha1_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | ||
2314 | void sha256_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | ||
2315 | void sha512_begin(struct bcrypt_hash_ctx_t *ctx) FAST_FUNC; | ||
2316 | void generic_hash(struct bcrypt_hash_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | ||
2317 | unsigned generic_end(struct bcrypt_hash_ctx_t *ctx, void *resbuf) FAST_FUNC; | ||
2318 | #define md5_hash generic_hash | ||
2319 | #define sha1_hash generic_hash | ||
2320 | #define sha256_hash generic_hash | ||
2321 | #define sha512_hash generic_hash | ||
2322 | #define md5_end generic_end | ||
2323 | #define sha1_end generic_end | ||
2324 | #define sha256_end generic_end | ||
2325 | #define sha512_end generic_end | ||
2326 | #else | ||
2297 | typedef struct md5_ctx_t { | 2327 | typedef struct md5_ctx_t { |
2298 | uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */ | 2328 | uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */ |
2299 | void (*process_block)(struct md5_ctx_t*) FAST_FUNC; | 2329 | void (*process_block)(struct md5_ctx_t*) FAST_FUNC; |
@@ -2324,13 +2354,20 @@ void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; | |||
2324 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; | 2354 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; |
2325 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | 2355 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; |
2326 | unsigned sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; | 2356 | unsigned sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; |
2357 | #endif | ||
2327 | void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC; | 2358 | void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC; |
2328 | void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | 2359 | void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; |
2329 | unsigned sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC; | 2360 | unsigned sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC; |
2330 | /* TLS benefits from knowing that sha1 and sha256 share these. Give them "agnostic" names too */ | 2361 | /* TLS benefits from knowing that sha1 and sha256 share these. Give them "agnostic" names too */ |
2362 | #if defined CONFIG_FEATURE_USE_CNG_API | ||
2363 | typedef struct bcrypt_hash_ctx_t md5sha_ctx_t; | ||
2364 | #define md5sha_hash generic_hash | ||
2365 | #define sha_end generic_end | ||
2366 | #else | ||
2331 | typedef struct md5_ctx_t md5sha_ctx_t; | 2367 | typedef struct md5_ctx_t md5sha_ctx_t; |
2332 | #define md5sha_hash md5_hash | 2368 | #define md5sha_hash md5_hash |
2333 | #define sha_end sha1_end | 2369 | #define sha_end sha1_end |
2370 | #endif | ||
2334 | enum { | 2371 | enum { |
2335 | MD5_OUTSIZE = 16, | 2372 | MD5_OUTSIZE = 16, |
2336 | SHA1_OUTSIZE = 20, | 2373 | SHA1_OUTSIZE = 20, |