Browse Source

Make everything compile on MSVC

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 1 year ago
parent
commit
9db30dfdc5
3 changed files with 2 additions and 9 deletions
  1. 0 7
      src/headers/tomcrypt_custom.h
  2. 1 1
      src/headers/tomcrypt_private.h
  3. 1 1
      src/prngs/rng_get_bytes.c

+ 0 - 7
src/headers/tomcrypt_custom.h

@@ -777,11 +777,4 @@
 #undef LTC_ECC521
 #undef LTC_ECC521
 #endif
 #endif
 
 
-/* MSVC can't build PEM */
-#if defined(LTC_PEM) && defined(_MSC_VER)
-#undef LTC_PEM
-#undef LTC_PEM_DECODE_BUFSZ
-#undef LTC_PEM_READ_BUFSIZE
-#endif
-
 #endif /* TOMCRYPT_CUSTOM_H_ */
 #endif /* TOMCRYPT_CUSTOM_H_ */

+ 1 - 1
src/headers/tomcrypt_private.h

@@ -282,7 +282,7 @@ struct str {
 };
 };
 
 
 #define SET_STR(n, s) n.p = s, n.len = XSTRLEN(s)
 #define SET_STR(n, s) n.p = s, n.len = XSTRLEN(s)
-#define SET_CSTR(n, s) n.p = (char*)s, n.len = XSTRLEN(s)
+#define SET_CSTR(n, s) n.p = (char*)s, n.len = (sizeof s) - 1
 #define COPY_STR(n, s, l) do { XMEMCPY(n.p, s, l); n.len = l; } while(0)
 #define COPY_STR(n, s, l) do { XMEMCPY(n.p, s, l); n.len = l; } while(0)
 #define RESET_STR(n) do { n.p = NULL; n.len = 0; } while(0)
 #define RESET_STR(n) do { n.p = NULL; n.len = 0; } while(0)
 
 

+ 1 - 1
src/prngs/rng_get_bytes.c

@@ -112,9 +112,9 @@ static unsigned long s_rng_win32(unsigned char *buf, unsigned long len,
 static unsigned long s_rng_win32(unsigned char *buf, unsigned long len,
 static unsigned long s_rng_win32(unsigned char *buf, unsigned long len,
                                void (*callback)(void))
                                void (*callback)(void))
 {
 {
+   static HCRYPTPROV hProv = 0;
    LTC_UNUSED_PARAM(callback);
    LTC_UNUSED_PARAM(callback);
 
 
-   static HCRYPTPROV hProv = 0;
    if (hProv == 0) {
    if (hProv == 0) {
       HCRYPTPROV h = 0;
       HCRYPTPROV h = 0;
       if (!CryptAcquireContextW(&h, NULL, MS_DEF_PROV_W, PROV_RSA_FULL,
       if (!CryptAcquireContextW(&h, NULL, MS_DEF_PROV_W, PROV_RSA_FULL,