mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-16 00:03:40 -04:00
refactored if defined WINDOWS to if defined _WIN32
This commit is contained in:
parent
c2e7d637ef
commit
ab5185239e
@ -4,12 +4,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OQS_MEM_cleanse(void *ptr, size_t len) {
|
void OQS_MEM_cleanse(void *ptr, size_t len) {
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
SecureZeroMemory(ptr, len);
|
SecureZeroMemory(ptr, len);
|
||||||
#elif defined(HAVE_MEMSET_S)
|
#elif defined(HAVE_MEMSET_S)
|
||||||
if (0U < len && memset_s(ptr, (rsize_t) len, 0, (rsize_t) len) != 0) {
|
if (0U < len && memset_s(ptr, (rsize_t) len, 0, (rsize_t) len) != 0) {
|
||||||
|
@ -24,7 +24,7 @@ void OQS_MEM_secure_free(void *ptr, size_t len);
|
|||||||
#define eprintf(...) fprintf(stderr, __VA_ARGS__);
|
#define eprintf(...) fprintf(stderr, __VA_ARGS__);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define UNUSED
|
#define UNUSED
|
||||||
// __attribute__ not supported in VS
|
// __attribute__ not supported in VS
|
||||||
#else
|
#else
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <oqs/sha3.h>
|
#include <oqs/sha3.h>
|
||||||
#include <oqs/sig.h>
|
#include <oqs/sig.h>
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <oqs/config.h>
|
#include <oqs/config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Wincrypt.h>
|
#include <Wincrypt.h>
|
||||||
#else
|
#else
|
||||||
@ -50,7 +50,7 @@ void OQS_RAND_free(OQS_RAND *r) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
/* For some reason specifying inline results in a build error */
|
/* For some reason specifying inline results in a build error */
|
||||||
inline
|
inline
|
||||||
#endif
|
#endif
|
||||||
@ -147,7 +147,7 @@ void OQS_RAND_report_statistics(const unsigned long occurrences[256], const char
|
|||||||
OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
||||||
OQS_STATUS result = OQS_ERROR;
|
OQS_STATUS result = OQS_ERROR;
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
HCRYPTPROV hCryptProv;
|
HCRYPTPROV hCryptProv;
|
||||||
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) ||
|
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) ||
|
||||||
!CryptGenRandom(hCryptProv, (DWORD) n, buf)) {
|
!CryptGenRandom(hCryptProv, (DWORD) n, buf)) {
|
||||||
@ -174,7 +174,7 @@ OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
|||||||
result = OQS_SUCCESS;
|
result = OQS_SUCCESS;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
if (fd > 0) {
|
if (fd > 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Wincrypt.h>
|
#include <Wincrypt.h>
|
||||||
#else
|
#else
|
||||||
@ -18,7 +18,7 @@
|
|||||||
#include <oqs/rand.h>
|
#include <oqs/rand.h>
|
||||||
#include <oqs/rand_urandom_aesctr.h>
|
#include <oqs/rand_urandom_aesctr.h>
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#pragma warning(disable : 4267)
|
#pragma warning(disable : 4267)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Wincrypt.h>
|
#include <Wincrypt.h>
|
||||||
#else
|
#else
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "external/chacha20.c"
|
#include "external/chacha20.c"
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* from https://twitter.com/tweetfips202
|
* from https://twitter.com/tweetfips202
|
||||||
* by Gilles Van Assche, Daniel J. Bernstein, and Peter Schwabe */
|
* by Gilles Van Assche, Daniel J. Bernstein, and Peter Schwabe */
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#pragma warning(disable : 4244)
|
#pragma warning(disable : 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ PRINT_TIMER_FOOTER
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
int gettimeofday(struct timeval *tp, struct timezone *tzp) {
|
int gettimeofday(struct timeval *tp, struct timezone *tzp) {
|
||||||
@ -114,7 +114,7 @@ int gettimeofday(struct timeval *tp, struct timezone *tzp) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint64_t rdtsc(void) {
|
static uint64_t rdtsc(void) {
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
return __rdtsc();
|
return __rdtsc();
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
uint64_t x;
|
uint64_t x;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <oqs/common.h>
|
#include <oqs/common.h>
|
||||||
#include <oqs/rand.h>
|
#include <oqs/rand.h>
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <oqs/config.h>
|
#include <oqs/config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#pragma warning(disable : 4244 4293)
|
#pragma warning(disable : 4244 4293)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "kex_code_mcbits.h"
|
#include "kex_code_mcbits.h"
|
||||||
#include "mcbits.h"
|
#include "mcbits.h"
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#define RECOMMENDED_N_ARRAY_SIZE (752 * 8)
|
#define RECOMMENDED_N_ARRAY_SIZE (752 * 8)
|
||||||
#define RECOMMENDED_CDF_TABLE_LEN 6
|
#define RECOMMENDED_CDF_TABLE_LEN 6
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
// VS complains about arrays initialized with const param. On Windows,
|
// VS complains about arrays initialized with const param. On Windows,
|
||||||
// we use directly the recommended value passed down from calling functions.
|
// we use directly the recommended value passed down from calling functions.
|
||||||
// Currently there is only one set of params, so that works. Need to fix this
|
// Currently there is only one set of params, so that works. Need to fix this
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DISABLE_NTRU_ON_WINDOWS_BY_DEFAULT
|
#ifndef DISABLE_NTRU_ON_WINDOWS_BY_DEFAULT
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Wincrypt.h>
|
#include <Wincrypt.h>
|
||||||
#else
|
#else
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <ntru_crypto.h>
|
#include <ntru_crypto.h>
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "rlwe_a.h"
|
#include "rlwe_a.h"
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* See LICENSE for complete information.
|
* See LICENSE for complete information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#pragma warning(disable : 4146 4244 4267)
|
#pragma warning(disable : 4146 4244 4267)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -13,7 +13,7 @@
|
|||||||
#include "LatticeCrypto_priv.h"
|
#include "LatticeCrypto_priv.h"
|
||||||
#include "kex_rlwe_msrln16.h"
|
#include "kex_rlwe_msrln16.h"
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -13,7 +13,7 @@
|
|||||||
#include "newhope.c"
|
#include "newhope.c"
|
||||||
#include "params.h"
|
#include "params.h"
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ extern uint16_t omegas_inv_montgomery[];
|
|||||||
extern uint16_t psis_inv_montgomery[];
|
extern uint16_t psis_inv_montgomery[];
|
||||||
extern uint16_t psis_bitrev_montgomery[];
|
extern uint16_t psis_bitrev_montgomery[];
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
typedef unsigned __int16 uint16_t;
|
typedef unsigned __int16 uint16_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t coeffs[PARAM_N];
|
uint16_t coeffs[PARAM_N];
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
} poly;
|
} poly;
|
||||||
#else
|
#else
|
||||||
} poly __attribute__((aligned(32)));
|
} poly __attribute__((aligned(32)));
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <oqs/rand.h>
|
#include <oqs/rand.h>
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include "../windows_undef.h"
|
#include "../windows_undef.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <oqs/rand.h>
|
#include <oqs/rand.h>
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#include "../windows_undef.h"
|
#include "../windows_undef.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define OS_WIN 1
|
#define OS_WIN 1
|
||||||
#define OS_LINUX 2
|
#define OS_LINUX 2
|
||||||
/*
|
/*
|
||||||
#if defined(__WINDOWS__) // Microsoft Windows OS
|
#if defined(_WIN32) // Microsoft Windows OS
|
||||||
#define OS_TARGET OS_WIN
|
#define OS_TARGET OS_WIN
|
||||||
#elif defined(__LINUX__) // Linux OS
|
#elif defined(__LINUX__) // Linux OS
|
||||||
#define OS_TARGET OS_LINUX
|
#define OS_TARGET OS_LINUX
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#pragma warning(disable : 4047 4090)
|
#pragma warning(disable : 4047 4090)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define UNUSED
|
#define UNUSED
|
||||||
#else
|
#else
|
||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if !defined(WINDOWS)
|
#if !defined(_WIN32)
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#include "P751/P751_api.h"
|
#include "P751/P751_api.h"
|
||||||
#include "kex_sidh_msr.h"
|
#include "kex_sidh_msr.h"
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#define strdup _strdup // for strdup deprecation warning
|
#define strdup _strdup // for strdup deprecation warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* to avoid Visual Studio errors
|
* to avoid Visual Studio errors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#undef OQS_SIDH_MSR_CRYPTO_SECRETKEYBYTES
|
#undef OQS_SIDH_MSR_CRYPTO_SECRETKEYBYTES
|
||||||
#undef OQS_SIDH_MSR_CRYPTO_PUBLICKEYBYTES
|
#undef OQS_SIDH_MSR_CRYPTO_PUBLICKEYBYTES
|
||||||
#undef OQS_SIDH_MSR_CRYPTO_BYTES
|
#undef OQS_SIDH_MSR_CRYPTO_BYTES
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#if defined(WINDOWS)
|
#if defined(_WIN32)
|
||||||
#pragma warning(disable : 4244 4293)
|
#pragma warning(disable : 4244 4293)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user