diff --git a/common/fko_util.c b/common/fko_util.c index a520ffb3..4da49b60 100644 --- a/common/fko_util.c +++ b/common/fko_util.c @@ -1006,13 +1006,24 @@ ipv4_resolve(const char *dns_str, char *ip_str) struct addrinfo hints; struct addrinfo *result; /* Result of getaddrinfo() */ struct addrinfo *rp; /* Element of the linked list returned by getaddrinfo() */ + #if WIN32 && WINVER <= 0x0600 - struct sockaddr_in *in; - char *win_ip; + struct sockaddr_in *in; + char *win_ip; #else struct sockaddr_in *sai_remote; /* Remote host information as a sockaddr_in structure */ #endif +#if WIN32 + WSADATA wsa_data; + error = WSAStartup( MAKEWORD(1,1), &wsa_data ); + if( error != 0 ) + { + fprintf(stderr, "Winsock initialization error %d", error); + return(error); + } +#endif + memset(&hints, 0 , sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; @@ -1054,6 +1065,9 @@ ipv4_resolve(const char *dns_str, char *ip_str) freeaddrinfo(result); } +#if WIN32 + WSACleanup(); +#endif return error; } diff --git a/lib/hmac.c b/lib/hmac.c index 61db395b..da14ed8c 100644 --- a/lib/hmac.c +++ b/lib/hmac.c @@ -71,12 +71,11 @@ hmac_md5(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[MD5_BLOCK_LEN + MD5_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - - int final_len = hmac_key_len; - + if(MD5_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key @@ -118,12 +117,11 @@ hmac_sha1(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[SHA1_BLOCK_LEN + SHA1_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - int final_len = hmac_key_len; - if(SHA1_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key @@ -165,12 +163,11 @@ hmac_sha256(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[SHA256_BLOCK_LEN + SHA256_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - int final_len = hmac_key_len; - if(SHA256_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key @@ -212,12 +209,11 @@ hmac_sha384(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[SHA384_BLOCK_LEN + SHA384_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - int final_len = hmac_key_len; - if(SHA384_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key @@ -259,12 +255,11 @@ hmac_sha512(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[SHA512_BLOCK_LEN + SHA512_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - int final_len = hmac_key_len; - if(SHA512_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key @@ -306,12 +301,11 @@ hmac_sha3_256(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[SHA3_256_BLOCK_LEN + SHA3_256_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - int final_len = hmac_key_len; - if(SHA3_256_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key @@ -353,12 +347,11 @@ hmac_sha3_512(const char *msg, const unsigned int msg_len, unsigned char final_key[MAX_DIGEST_BLOCK_LEN] = {0}; unsigned char padded_hash[SHA3_512_BLOCK_LEN + SHA3_512_DIGEST_LEN + 1] = {0}; unsigned char *padded_msg = calloc(1, msg_len + MAX_DIGEST_BLOCK_LEN + 1); + int final_len = hmac_key_len; if (padded_msg == NULL) return FKO_ERROR_MEMORY_ALLOCATION; - int final_len = hmac_key_len; - if(SHA3_512_BLOCK_LEN < hmac_key_len) { /* Calculate the digest of the key diff --git a/win32/libfko.sln b/win32/libfko.sln index 15b78bfc..685ba3a5 100644 --- a/win32/libfko.sln +++ b/win32/libfko.sln @@ -1,12 +1,9 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfko", "libfko.vcproj", "{133BC195-4877-481D-9F56-9F1BEBAD21F0}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfko", "libfko.vcxproj", "{133BC195-4877-481D-9F56-9F1BEBAD21F0}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fwknop-client", "fwknop-client.vcproj", "{D8AFA02D-14BF-42F4-97DE-EF4924D046D6}" - ProjectSection(ProjectDependencies) = postProject - {133BC195-4877-481D-9F56-9F1BEBAD21F0} = {133BC195-4877-481D-9F56-9F1BEBAD21F0} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fwknop-client", "fwknop-client.vcxproj", "{D8AFA02D-14BF-42F4-97DE-EF4924D046D6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution