From b9c7e507d4946f08280873899cbeb87838d7c6b6 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 May 2017 05:27:31 +0900 Subject: add macro for vc-dll --- include/bls_if.h | 109 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 50 deletions(-) (limited to 'include/bls_if.h') diff --git a/include/bls_if.h b/include/bls_if.h index 313e78a..5b718f0 100644 --- a/include/bls_if.h +++ b/include/bls_if.h @@ -14,8 +14,17 @@ #include // for size_t #ifdef _MSC_VER +#ifdef BLS256_DLL_EXPORT +#define BLS256_DLL_API __declspec(dllexport) +#else +#define BLS256_DLL_API __declspec(dllimport) +#ifndef MCL_NO_AUTOLINK #pragma comment(lib, "bls_if.lib") #endif +#endif +#else +#define BLS256_DLL_API +#endif #ifdef __cplusplus extern "C" { @@ -56,94 +65,94 @@ typedef struct { call this once before using the other method @note init() is not thread safe */ -void blsInit(int curve, int maxUnitSize); -size_t blsGetOpUnitSize(void); +BLS256_DLL_API void blsInit(int curve, int maxUnitSize); +BLS256_DLL_API size_t blsGetOpUnitSize(void); // return strlen(buf) if success else 0 -int blsGetCurveOrder(char *buf, size_t maxBufSize); -int blsGetFieldOrder(char *buf, size_t maxBufSize); +BLS256_DLL_API int blsGetCurveOrder(char *buf, size_t maxBufSize); +BLS256_DLL_API int blsGetFieldOrder(char *buf, size_t maxBufSize); -blsId *blsIdCreate(void); -void blsIdDestroy(blsId *id); +BLS256_DLL_API blsId *blsIdCreate(void); +BLS256_DLL_API void blsIdDestroy(blsId *id); // return 1 if same else 0 -int blsIdIsSame(const blsId *lhs, const blsId *rhs); -void blsIdPut(const blsId *id); -void blsIdCopy(blsId *dst, const blsId *src); +BLS256_DLL_API int blsIdIsSame(const blsId *lhs, const blsId *rhs); +BLS256_DLL_API void blsIdPut(const blsId *id); +BLS256_DLL_API void blsIdCopy(blsId *dst, const blsId *src); // return 0 if success -int blsIdSetStr(blsId *id, const char *buf, size_t bufSize, int ioMode); +BLS256_DLL_API int blsIdSetStr(blsId *id, const char *buf, size_t bufSize, int ioMode); /* return written byte size if ioMode = BlsIoComp return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1 return 0 otherwise */ -size_t blsIdGetStr(const blsId *id, char *buf, size_t maxBufSize, int ioMode); +BLS256_DLL_API size_t blsIdGetStr(const blsId *id, char *buf, size_t maxBufSize, int ioMode); /* access p[0], ..., p[3] if 256-bit curve access p[0], ..., p[5] if 384-bit curve */ -void blsIdSet(blsId *id, const uint64_t *p); +BLS256_DLL_API void blsIdSet(blsId *id, const uint64_t *p); -blsSecretKey* blsSecretKeyCreate(void); -void blsSecretKeyDestroy(blsSecretKey *sec); +BLS256_DLL_API blsSecretKey* blsSecretKeyCreate(void); +BLS256_DLL_API void blsSecretKeyDestroy(blsSecretKey *sec); // return 1 if same else 0 -int blsSecretKeyIsSame(const blsSecretKey *lhs, const blsSecretKey *rhs); +BLS256_DLL_API int blsSecretKeyIsSame(const blsSecretKey *lhs, const blsSecretKey *rhs); -void blsSecretKeyPut(const blsSecretKey *sec); -void blsSecretKeyCopy(blsSecretKey *dst, const blsSecretKey *src); -void blsSecretKeySetArray(blsSecretKey *sec, const uint64_t *p); -int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize, int ioMode); +BLS256_DLL_API void blsSecretKeyPut(const blsSecretKey *sec); +BLS256_DLL_API void blsSecretKeyCopy(blsSecretKey *dst, const blsSecretKey *src); +BLS256_DLL_API void blsSecretKeySetArray(blsSecretKey *sec, const uint64_t *p); +BLS256_DLL_API int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize, int ioMode); /* return written byte size if ioMode = BlsIoComp return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1 return 0 otherwise */ -size_t blsSecretKeyGetStr(const blsSecretKey *sec, char *buf, size_t maxBufSize, int ioMode); -void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs); - -void blsSecretKeyInit(blsSecretKey *sec); -void blsSecretKeyGetPublicKey(const blsSecretKey *sec, blsPublicKey *pub); -void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, size_t size); -void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id); -void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n); -void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign); - -blsPublicKey *blsPublicKeyCreate(void); -void blsPublicKeyDestroy(blsPublicKey *pub); +BLS256_DLL_API size_t blsSecretKeyGetStr(const blsSecretKey *sec, char *buf, size_t maxBufSize, int ioMode); +BLS256_DLL_API void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs); + +BLS256_DLL_API void blsSecretKeyInit(blsSecretKey *sec); +BLS256_DLL_API void blsSecretKeyGetPublicKey(const blsSecretKey *sec, blsPublicKey *pub); +BLS256_DLL_API void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, size_t size); +BLS256_DLL_API void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id); +BLS256_DLL_API void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n); +BLS256_DLL_API void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign); + +BLS256_DLL_API blsPublicKey *blsPublicKeyCreate(void); +BLS256_DLL_API void blsPublicKeyDestroy(blsPublicKey *pub); // return 1 if same else 0 -int blsPublicKeyIsSame(const blsPublicKey *lhs, const blsPublicKey *rhs); -void blsPublicKeyPut(const blsPublicKey *pub); -void blsPublicKeyCopy(blsPublicKey *dst, const blsPublicKey *src); -int blsPublicKeySetStr(blsPublicKey *pub, const char *buf, size_t bufSize, int ioMode); +BLS256_DLL_API int blsPublicKeyIsSame(const blsPublicKey *lhs, const blsPublicKey *rhs); +BLS256_DLL_API void blsPublicKeyPut(const blsPublicKey *pub); +BLS256_DLL_API void blsPublicKeyCopy(blsPublicKey *dst, const blsPublicKey *src); +BLS256_DLL_API int blsPublicKeySetStr(blsPublicKey *pub, const char *buf, size_t bufSize, int ioMode); /* return written byte size if ioMode = BlsIoComp return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1 return 0 otherwise */ -size_t blsPublicKeyGetStr(const blsPublicKey *pub, char *buf, size_t maxBufSize, int ioMode); -void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs); -void blsPublicKeySet(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id); -void blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n); +BLS256_DLL_API size_t blsPublicKeyGetStr(const blsPublicKey *pub, char *buf, size_t maxBufSize, int ioMode); +BLS256_DLL_API void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs); +BLS256_DLL_API void blsPublicKeySet(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id); +BLS256_DLL_API void blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n); -blsSign *blsSignCreate(void); -void blsSignDestroy(blsSign *sign); +BLS256_DLL_API blsSign *blsSignCreate(void); +BLS256_DLL_API void blsSignDestroy(blsSign *sign); // return 1 if same else 0 -int blsSignIsSame(const blsSign *lhs, const blsSign *rhs); -void blsSignPut(const blsSign *sign); -void blsSignCopy(blsSign *dst, const blsSign *src); -int blsSignSetStr(blsSign *sign, const char *buf, size_t bufSize, int ioMode); +BLS256_DLL_API int blsSignIsSame(const blsSign *lhs, const blsSign *rhs); +BLS256_DLL_API void blsSignPut(const blsSign *sign); +BLS256_DLL_API void blsSignCopy(blsSign *dst, const blsSign *src); +BLS256_DLL_API int blsSignSetStr(blsSign *sign, const char *buf, size_t bufSize, int ioMode); /* return written byte size if ioMode = BlsIoComp return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1 return 0 otherwise */ -size_t blsSignGetStr(const blsSign *sign, char *buf, size_t maxBufSize, int ioMode); -void blsSignAdd(blsSign *sign, const blsSign *rhs); -void blsSignRecover(blsSign *sign, const blsSign *signVec, const blsId *idVec, size_t n); +BLS256_DLL_API size_t blsSignGetStr(const blsSign *sign, char *buf, size_t maxBufSize, int ioMode); +BLS256_DLL_API void blsSignAdd(blsSign *sign, const blsSign *rhs); +BLS256_DLL_API void blsSignRecover(blsSign *sign, const blsSign *signVec, const blsId *idVec, size_t n); -int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size); +BLS256_DLL_API int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size); -int blsSignVerifyPop(const blsSign *sign, const blsPublicKey *pub); +BLS256_DLL_API int blsSignVerifyPop(const blsSign *sign, const blsPublicKey *pub); #ifdef __cplusplus } -- cgit v1.2.3