aboutsummaryrefslogtreecommitdiffstats
path: root/libar2.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-18 17:54:49 +0100
committerMattias Andrée <maandree@kth.se>2022-01-18 17:54:49 +0100
commitedb70e343f3000dfef1f38583e88e74d1e71d804 (patch)
tree9c900264882428578bba81748c3a773faec6ebc0 /libar2.h
parentFix typo: libar2_earse -> libar2_erase (diff)
downloadlibar2-edb70e343f3000dfef1f38583e88e74d1e71d804.tar.gz
libar2-edb70e343f3000dfef1f38583e88e74d1e71d804.tar.bz2
libar2-edb70e343f3000dfef1f38583e88e74d1e71d804.tar.xz
Improve portability
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libar2.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/libar2.h b/libar2.h
index 835a02f..862723f 100644
--- a/libar2.h
+++ b/libar2.h
@@ -7,6 +7,22 @@
/* for internal use { */
+#ifndef LIBAR2_PUBLIC__
+# if defined(_MSC_VER)
+# define LIBAR2_PUBLIC__ __declspec(dllexport)
+# else
+# define LIBAR2_PUBLIC__
+# endif
+#endif
+
+#ifndef LIBAR2_PUBLIC_VARIABLE__
+# if defined(_MSC_VER)
+# define LIBAR2_PUBLIC_VARIABLE__ __declspec(dllexport)
+# else
+# define LIBAR2_PUBLIC_VARIABLE__
+# endif
+#endif
+
#if defined(UINT_LEAST32_C)
# define LIBAR2_UINT_LEAST32_C__(V) UINT_LEAST32_C(V)
#elif defined(UINT32_C)
@@ -446,6 +462,7 @@ extern enum libar2_argon2_version libar2_latest_argon2_version;
* @return String representing the type, `NULL` (with `errno`
* set to EINVAL) if either argument is invalid
*/
+LIBAR2_PUBLIC__
const char *libar2_type_to_string(enum libar2_argon2_type type, enum libar2_casing casing);
/**
@@ -455,6 +472,7 @@ const char *libar2_type_to_string(enum libar2_argon2_type type, enum libar2_casi
* @param typep Output parameter for the primitive type
* @return 0 on success, -1 (with `errno` set to EINVAL) if `str` is invalid
*/
+LIBAR2_PUBLIC__
int libar2_string_to_type(const char *str, enum libar2_argon2_type *typep);
/**
@@ -465,6 +483,7 @@ int libar2_string_to_type(const char *str, enum libar2_argon2_type *typep);
* @return String representing the version, `NULL` (with
* `errno` set to EINVAL) if `version` is invalid
*/
+LIBAR2_PUBLIC__
const char *libar2_version_to_string(enum libar2_argon2_version version);
/**
@@ -475,6 +494,7 @@ const char *libar2_version_to_string(enum libar2_argon2_version version);
* @return String representing the version, `NULL` (with
* `errno` set to EINVAL) if `version` is invalid
*/
+LIBAR2_PUBLIC__
const char *libar2_version_to_string_proper(enum libar2_argon2_version version);
/**
@@ -484,6 +504,7 @@ const char *libar2_version_to_string_proper(enum libar2_argon2_version version);
* @param versionp Output parameter for the version number value
* @return 0 on success, -1 (with `errno` set to EINVAL) if `str` is invalid
*/
+LIBAR2_PUBLIC__
int libar2_string_to_version(const char *str, enum libar2_argon2_version *versionp);
/**
@@ -501,6 +522,7 @@ int libar2_string_to_version(const char *str, enum libar2_argon2_version *versio
* @return The number of bytes required for `buf`,
* including the NUL byte added to the end
*/
+LIBAR2_PUBLIC__
size_t libar2_encode_params(char *buf, const struct libar2_argon2_parameters *params);
/**
@@ -515,6 +537,7 @@ size_t libar2_encode_params(char *buf, const struct libar2_argon2_parameters *pa
* @return The number of bytes required for `buf`,
* including the NUL byte added to the end
*/
+LIBAR2_PUBLIC__
size_t libar2_encode_base64(char *buf, const void *data, size_t len);
/**
@@ -550,6 +573,7 @@ size_t libar2_encode_base64(char *buf, const void *data, size_t len);
* a hash, and not just parameters, `&str[return]` will
* point to the hash
*/
+LIBAR2_PUBLIC__
size_t libar2_decode_params(const char *str, struct libar2_argon2_parameters *params, char **bufp, struct libar2_context *ctx);
/**
@@ -560,6 +584,7 @@ size_t libar2_decode_params(const char *str, struct libar2_argon2_parameters *pa
* @param lenp Output parameter for the length of the decoded data
* @return The number of bytes read
*/
+LIBAR2_PUBLIC__
size_t libar2_decode_base64(const char *str, void *data, size_t *lenp);
/**
@@ -569,6 +594,7 @@ size_t libar2_decode_base64(const char *str, void *data, size_t *lenp);
* @param errmsgp Output parameter for the error message, or `null`
* @return The first detected error, or LIBAR2_OK (0) if none
*/
+LIBAR2_PUBLIC__
enum libar2_parameter_error libar2_validate_params(const struct libar2_argon2_parameters *params, const char **errmsgp);
/**
@@ -577,6 +603,7 @@ enum libar2_parameter_error libar2_validate_params(const struct libar2_argon2_pa
* @param mem The memory to erase
* @param size The number of bytes to erase
*/
+LIBAR2_PUBLIC__
void libar2_erase(volatile void *mem, size_t size);
/**
@@ -613,6 +640,7 @@ void libar2_erase(volatile void *mem, size_t size);
* @param ctx Library settings
* @return 0 on success, -1 on failure
*/
+LIBAR2_PUBLIC__
int libar2_hash(void *hash, void *msg, size_t msglen, struct libar2_argon2_parameters *params, struct libar2_context *ctx);
#endif