Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CNIOSHA1.h to support C++ interoperability #2523

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Sources/CNIOSHA1/include/CNIOSHA1.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

struct sha1_ctxt {
union {
uint8_t b8[20];
Expand All @@ -68,7 +72,12 @@ typedef struct sha1_ctxt SHA1_CTX;

#define SHA1_RESULTLEN (160/8)

#ifdef __cplusplus
#define __min_size(x) (x)
#else
#define __min_size(x) static (x)
#endif

extern void c_nio_sha1_init(struct sha1_ctxt *);
extern void c_nio_sha1_pad(struct sha1_ctxt *);
extern void c_nio_sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t);
Expand All @@ -79,5 +88,8 @@ extern void c_nio_sha1_result(struct sha1_ctxt *, char[__min_size(SHA1_RESULTLEN
#define SHA1Update(x, y, z) c_nio_sha1_loop((x), (y), (z))
#define SHA1Final(x, y) c_nio_sha1_result((y), (x))

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*_CRYPTO_SHA1_H_*/