aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/security
diff options
context:
space:
mode:
Diffstat (limited to 'libparc/parc/security')
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/command-line/parcPublicKey_About.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Certificate.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Certificate.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CertificateFactory.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CertificateType.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CertificateType.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_ContainerEncoding.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_ContainerEncoding.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoCache.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoCache.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHash.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHash.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHashType.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHasher.c4
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHasher.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoSuite.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoSuite.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_DiffieHellmanGroup.h0
-rw-r--r--libparc/parc/security/parc_DiffieHellmanKeyShare.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Identity.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Identity.h0
-rw-r--r--libparc/parc/security/parc_IdentityFile.c13
-rw-r--r--libparc/parc/security/parc_InMemoryVerifier.c5
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_InMemoryVerifier.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Key.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Key.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyId.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyId.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyStore.h0
-rw-r--r--libparc/parc/security/parc_Pkcs12KeyStore.c42
-rw-r--r--libparc/parc/security/parc_PublicKeySigner.c8
-rw-r--r--libparc/parc/security/parc_SecureRandom.c12
-rw-r--r--libparc/parc/security/parc_Security.c8
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Security.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Signature.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Signature.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Signer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_SigningAlgorithm.c0
-rw-r--r--libparc/parc/security/parc_SymmetricKeyStore.c12
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Verifier.c0
-rw-r--r--libparc/parc/security/parc_X509Certificate.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_X509Certificate.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CertificateFactory.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CertificateType.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_ContainerEncoding.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoCache.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoHash.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoHasher.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoSuite.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_DiffieHellman.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_InMemoryVerifier.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Key.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_KeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Pkcs12KeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_SecureRandom.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Security.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Signature.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_SigningAlgorithm.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_SymmetricKeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Verifier.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_X509Certificate.c0
63 files changed, 64 insertions, 50 deletions
diff --git a/libparc/parc/security/command-line/parcPublicKey_About.h b/libparc/parc/security/command-line/parcPublicKey_About.h
index fccb7b7d..fccb7b7d 100755..100644
--- a/libparc/parc/security/command-line/parcPublicKey_About.h
+++ b/libparc/parc/security/command-line/parcPublicKey_About.h
diff --git a/libparc/parc/security/parc_Certificate.c b/libparc/parc/security/parc_Certificate.c
index aead0fb5..aead0fb5 100755..100644
--- a/libparc/parc/security/parc_Certificate.c
+++ b/libparc/parc/security/parc_Certificate.c
diff --git a/libparc/parc/security/parc_Certificate.h b/libparc/parc/security/parc_Certificate.h
index 43eb9416..43eb9416 100755..100644
--- a/libparc/parc/security/parc_Certificate.h
+++ b/libparc/parc/security/parc_Certificate.h
diff --git a/libparc/parc/security/parc_CertificateFactory.h b/libparc/parc/security/parc_CertificateFactory.h
index 74035232..74035232 100755..100644
--- a/libparc/parc/security/parc_CertificateFactory.h
+++ b/libparc/parc/security/parc_CertificateFactory.h
diff --git a/libparc/parc/security/parc_CertificateType.c b/libparc/parc/security/parc_CertificateType.c
index 86581675..86581675 100755..100644
--- a/libparc/parc/security/parc_CertificateType.c
+++ b/libparc/parc/security/parc_CertificateType.c
diff --git a/libparc/parc/security/parc_CertificateType.h b/libparc/parc/security/parc_CertificateType.h
index 596cd293..596cd293 100755..100644
--- a/libparc/parc/security/parc_CertificateType.h
+++ b/libparc/parc/security/parc_CertificateType.h
diff --git a/libparc/parc/security/parc_ContainerEncoding.c b/libparc/parc/security/parc_ContainerEncoding.c
index 3376e69a..3376e69a 100755..100644
--- a/libparc/parc/security/parc_ContainerEncoding.c
+++ b/libparc/parc/security/parc_ContainerEncoding.c
diff --git a/libparc/parc/security/parc_ContainerEncoding.h b/libparc/parc/security/parc_ContainerEncoding.h
index 7cac3fd1..7cac3fd1 100755..100644
--- a/libparc/parc/security/parc_ContainerEncoding.h
+++ b/libparc/parc/security/parc_ContainerEncoding.h
diff --git a/libparc/parc/security/parc_CryptoCache.c b/libparc/parc/security/parc_CryptoCache.c
index 07caaed7..07caaed7 100755..100644
--- a/libparc/parc/security/parc_CryptoCache.c
+++ b/libparc/parc/security/parc_CryptoCache.c
diff --git a/libparc/parc/security/parc_CryptoCache.h b/libparc/parc/security/parc_CryptoCache.h
index 497ee38d..497ee38d 100755..100644
--- a/libparc/parc/security/parc_CryptoCache.h
+++ b/libparc/parc/security/parc_CryptoCache.h
diff --git a/libparc/parc/security/parc_CryptoHash.c b/libparc/parc/security/parc_CryptoHash.c
index d0f82af3..d0f82af3 100755..100644
--- a/libparc/parc/security/parc_CryptoHash.c
+++ b/libparc/parc/security/parc_CryptoHash.c
diff --git a/libparc/parc/security/parc_CryptoHash.h b/libparc/parc/security/parc_CryptoHash.h
index d0312d9e..d0312d9e 100755..100644
--- a/libparc/parc/security/parc_CryptoHash.h
+++ b/libparc/parc/security/parc_CryptoHash.h
diff --git a/libparc/parc/security/parc_CryptoHashType.h b/libparc/parc/security/parc_CryptoHashType.h
index 3ab1d9c9..3ab1d9c9 100755..100644
--- a/libparc/parc/security/parc_CryptoHashType.h
+++ b/libparc/parc/security/parc_CryptoHashType.h
diff --git a/libparc/parc/security/parc_CryptoHasher.c b/libparc/parc/security/parc_CryptoHasher.c
index a4d492ff..b7226e46 100755..100644
--- a/libparc/parc/security/parc_CryptoHasher.c
+++ b/libparc/parc/security/parc_CryptoHasher.c
@@ -435,7 +435,7 @@ static const uint32_t _crc32c_table[] = {
*/
__attribute__((unused))
static uint32_t
-_crc32c_UpdateSoftware(uint32_t crc, size_t len, uint8_t p[len])
+_crc32c_UpdateSoftware(uint32_t crc, size_t len, uint8_t *p)
{
for (int i = 0; i < len; i++) {
crc = (crc >> 8) ^ _crc32c_table[((uint8_t) (crc & 0xFF)) ^ p[i]];
@@ -469,7 +469,7 @@ _crc32c_Finalize(uint32_t crc)
* the CRC table used by the software calculation.
*/
static uint32_t
-_crc32c_Update(uint32_t crc, size_t len, uint8_t p[len])
+_crc32c_Update(uint32_t crc, size_t len, uint8_t *p)
{
#ifdef __SSE4_2__
crc = _crc32c_UpdateIntel(crc, len, p);
diff --git a/libparc/parc/security/parc_CryptoHasher.h b/libparc/parc/security/parc_CryptoHasher.h
index 2c93c1f7..2c93c1f7 100755..100644
--- a/libparc/parc/security/parc_CryptoHasher.h
+++ b/libparc/parc/security/parc_CryptoHasher.h
diff --git a/libparc/parc/security/parc_CryptoSuite.c b/libparc/parc/security/parc_CryptoSuite.c
index b7e1938b..7d7920f5 100755..100644
--- a/libparc/parc/security/parc_CryptoSuite.c
+++ b/libparc/parc/security/parc_CryptoSuite.c
@@ -35,12 +35,11 @@ parcCryptoSuite_GetCryptoHash(PARCCryptoSuite suite)
case PARCCryptoSuite_HMAC_SHA512: // fallthrough
case PARCCryptoSuite_RSA_SHA512:
return PARCCryptoHashType_SHA512;
-
case PARCCryptoSuite_NULL_CRC32C:
return PARCCryptoHashType_CRC32C;
-
default:
parcTrapIllegalValue(suite, "Unknown crypto suite: %d", suite);
+ return PARCCryptoHashType_NULL;
}
}
@@ -66,6 +65,7 @@ parcCryptoSuite_GetSignatureSizeBytes(PARCCryptoSuite suite, int keyLengthBits)
default:
parcTrapIllegalValue(suite, "Unknown crypto suite: %d", suite);
+ return -1;
}
}
@@ -82,6 +82,7 @@ PARCCryptoSuite parcCryptoSuite_GetFromSigningHash(PARCSigningAlgorithm signAlgo
return PARCCryptoSuite_NULL_CRC32C;
default:
parcTrapIllegalValue(suite, "Unknown signing algorithm suite: %d", signAlgo);
+ return PARCSigningAlgorithm_UNKNOWN;
}
}
@@ -107,5 +108,6 @@ parcCryptoSuite_GetSigningAlgorithm(PARCCryptoSuite suite)
default:
parcTrapIllegalValue(suit, "Unknown crypto suite: %d", suite);
+ return PARCSigningAlgorithm_UNKNOWN;
}
}
diff --git a/libparc/parc/security/parc_CryptoSuite.h b/libparc/parc/security/parc_CryptoSuite.h
index 366bcb11..366bcb11 100755..100644
--- a/libparc/parc/security/parc_CryptoSuite.h
+++ b/libparc/parc/security/parc_CryptoSuite.h
diff --git a/libparc/parc/security/parc_DiffieHellmanGroup.h b/libparc/parc/security/parc_DiffieHellmanGroup.h
index 7402399e..7402399e 100755..100644
--- a/libparc/parc/security/parc_DiffieHellmanGroup.h
+++ b/libparc/parc/security/parc_DiffieHellmanGroup.h
diff --git a/libparc/parc/security/parc_DiffieHellmanKeyShare.c b/libparc/parc/security/parc_DiffieHellmanKeyShare.c
index 313af4a3..48c3ee26 100644
--- a/libparc/parc/security/parc_DiffieHellmanKeyShare.c
+++ b/libparc/parc/security/parc_DiffieHellmanKeyShare.c
@@ -148,7 +148,7 @@ parcDiffieHellmanKeyShare_SerializePublicKey(PARCDiffieHellmanKeyShare *keyShare
const EC_POINT *point = EC_KEY_get0_public_key(ecKey);
const EC_GROUP *group = EC_KEY_get0_group(ecKey);
char *keyBuffer = EC_POINT_point2hex(group, point, form, bnctx);
- int length = strlen(keyBuffer);
+ int length = (int)strlen(keyBuffer);
PARCBuffer *publicKey = parcBuffer_Allocate(length);
parcBuffer_PutArray(publicKey, length, (uint8_t *) keyBuffer);
diff --git a/libparc/parc/security/parc_Identity.c b/libparc/parc/security/parc_Identity.c
index daaf661d..daaf661d 100755..100644
--- a/libparc/parc/security/parc_Identity.c
+++ b/libparc/parc/security/parc_Identity.c
diff --git a/libparc/parc/security/parc_Identity.h b/libparc/parc/security/parc_Identity.h
index c00af8fa..c00af8fa 100755..100644
--- a/libparc/parc/security/parc_Identity.h
+++ b/libparc/parc/security/parc_Identity.h
diff --git a/libparc/parc/security/parc_IdentityFile.c b/libparc/parc/security/parc_IdentityFile.c
index 8372a111..395757b6 100644
--- a/libparc/parc/security/parc_IdentityFile.c
+++ b/libparc/parc/security/parc_IdentityFile.c
@@ -13,23 +13,20 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <config.h>
#include <sys/stat.h>
-#include <unistd.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_Identity.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
-
#include <parc/security/parc_Pkcs12KeyStore.h>
#include <parc/security/parc_PublicKeySigner.h>
-
#include <parc/security/parc_IdentityFile.h>
struct parc_identity_file {
diff --git a/libparc/parc/security/parc_InMemoryVerifier.c b/libparc/parc/security/parc_InMemoryVerifier.c
index 33f6fcfe..8955e1f1 100644
--- a/libparc/parc/security/parc_InMemoryVerifier.c
+++ b/libparc/parc/security/parc_InMemoryVerifier.c
@@ -99,6 +99,7 @@ _parcInMemoryVerifier_GetCryptoHasher(void *interfaceContext, PARCKeyId *keyid,
default:
parcTrapUnexpectedState("unsupported hash type: %d", hashType);
+ return NULL;
}
}
@@ -275,7 +276,7 @@ _parcInMemoryVerifier_RSAKey_Verify(PARCInMemoryVerifier *verifier, PARCCryptoHa
{
const uint8_t *der_bytes = parcByteArray_Array(parcBuffer_Array(derEncodedKey));
- long der_length = parcBuffer_Remaining(derEncodedKey);
+ long der_length = (long)parcBuffer_Remaining(derEncodedKey);
EVP_PKEY *unwrapped_key = d2i_PUBKEY(NULL, &der_bytes, der_length);
if (unwrapped_key != NULL) {
@@ -337,7 +338,7 @@ _parcInMemoryVerifier_ECDSAKey_Verify(PARCInMemoryVerifier *verifier, PARCCrypto
{
const uint8_t *der_bytes = parcByteArray_Array(parcBuffer_Array(derEncodedKey));
- long der_length = parcBuffer_Remaining(derEncodedKey);
+ long der_length = (long)parcBuffer_Remaining(derEncodedKey);
EVP_PKEY *unwrapped_key = d2i_PUBKEY(NULL, &der_bytes, der_length);
if (unwrapped_key != NULL) {
diff --git a/libparc/parc/security/parc_InMemoryVerifier.h b/libparc/parc/security/parc_InMemoryVerifier.h
index bbec8130..bbec8130 100755..100644
--- a/libparc/parc/security/parc_InMemoryVerifier.h
+++ b/libparc/parc/security/parc_InMemoryVerifier.h
diff --git a/libparc/parc/security/parc_Key.c b/libparc/parc/security/parc_Key.c
index 82d21244..82d21244 100755..100644
--- a/libparc/parc/security/parc_Key.c
+++ b/libparc/parc/security/parc_Key.c
diff --git a/libparc/parc/security/parc_Key.h b/libparc/parc/security/parc_Key.h
index 426405bb..426405bb 100755..100644
--- a/libparc/parc/security/parc_Key.h
+++ b/libparc/parc/security/parc_Key.h
diff --git a/libparc/parc/security/parc_KeyId.c b/libparc/parc/security/parc_KeyId.c
index 45e7454b..45e7454b 100755..100644
--- a/libparc/parc/security/parc_KeyId.c
+++ b/libparc/parc/security/parc_KeyId.c
diff --git a/libparc/parc/security/parc_KeyId.h b/libparc/parc/security/parc_KeyId.h
index daa2a2fe..daa2a2fe 100755..100644
--- a/libparc/parc/security/parc_KeyId.h
+++ b/libparc/parc/security/parc_KeyId.h
diff --git a/libparc/parc/security/parc_KeyStore.c b/libparc/parc/security/parc_KeyStore.c
index 6d4a724a..6d4a724a 100755..100644
--- a/libparc/parc/security/parc_KeyStore.c
+++ b/libparc/parc/security/parc_KeyStore.c
diff --git a/libparc/parc/security/parc_KeyStore.h b/libparc/parc/security/parc_KeyStore.h
index 253505d5..253505d5 100755..100644
--- a/libparc/parc/security/parc_KeyStore.h
+++ b/libparc/parc/security/parc_KeyStore.h
diff --git a/libparc/parc/security/parc_Pkcs12KeyStore.c b/libparc/parc/security/parc_Pkcs12KeyStore.c
index f6c65e4f..12246593 100644
--- a/libparc/parc/security/parc_Pkcs12KeyStore.c
+++ b/libparc/parc/security/parc_Pkcs12KeyStore.c
@@ -13,31 +13,27 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <unistd.h>
+#endif
#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_Object.h>
-
#include <parc/security/parc_Security.h>
#include <parc/security/parc_Signer.h>
#include <parc/security/parc_KeyStore.h>
#include <parc/algol/parc_Memory.h>
-
#include <parc/security/parc_Certificate.h>
#include <parc/security/parc_CertificateFactory.h>
#include <parc/security/parc_CertificateType.h>
#include <parc/security/parc_ContainerEncoding.h>
#include <parc/security/parc_KeyType.h>
-
#include <parc/security/parc_Pkcs12KeyStore.h>
#include <openssl/pkcs12.h>
@@ -102,12 +98,22 @@ _parcPkcs12KeyStore_ParseFile(PARCPkcs12KeyStore *keystore, const char *filename
{
parcSecurity_AssertIsInitialized();
+#ifndef _WIN32
FILE *fp = fopen(filename, "rb");
-
parcAssertNotNull(fp, "Error opening %s: %s", filename, strerror(errno));
if (fp == NULL) {
return -1;
}
+#else
+ FILE *fp;
+ errno_t err = fopen_s(&fp, filename, "rb");
+ char errmsg[1024];
+ strerror_s(errmsg, 1024, err);
+ parcAssertNotNull(fp, "Error opening %s: %s", filename, errmsg);
+ if (err != 0) {
+ return -1;
+ }
+#endif
PKCS12 *p12Keystore = NULL;
d2i_PKCS12_fp(fp, &p12Keystore);
@@ -156,17 +162,17 @@ PKCS12 *_createPkcs12KeyStore_RSA(
// Extract the private key
EVP_PKEY *privateKey = NULL;
uint8_t *privateKeyBytes = parcBuffer_Overlay(privateKeyBuffer, parcBuffer_Limit(privateKeyBuffer));
- d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &privateKeyBytes, parcBuffer_Limit(privateKeyBuffer));
+ d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &privateKeyBytes, (long)parcBuffer_Limit(privateKeyBuffer));
parcBuffer_Release(&privateKeyBuffer);
-
+
// Extract the certificate
PARCBuffer *certBuffer = parcCertificate_GetDEREncodedCertificate(certificate);
uint8_t *certBytes = parcBuffer_Overlay(certBuffer, parcBuffer_Limit(certBuffer));
X509 *cert = NULL;
- d2i_X509(&cert, (const unsigned char **) &certBytes, parcBuffer_Limit(certBuffer));
-
+ d2i_X509(&cert, (const unsigned char **) &certBytes, (long)parcBuffer_Limit(certBuffer));
+
parcCertificate_Release(&certificate);
-
+
PKCS12 *pkcs12 = PKCS12_create((char *) password,
"ccnxuser",
privateKey,
@@ -190,17 +196,17 @@ PKCS12 *_createPkcs12KeyStore_ECDSA(
// Extract the private key
EVP_PKEY *privateKey = NULL;
uint8_t *privateKeyBytes = parcBuffer_Overlay(privateKeyBuffer, parcBuffer_Limit(privateKeyBuffer));
- d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &privateKeyBytes, parcBuffer_Limit(privateKeyBuffer));
+ d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &privateKeyBytes, (long)parcBuffer_Limit(privateKeyBuffer));
parcBuffer_Release(&privateKeyBuffer);
-
+
// Extract the certificate
PARCBuffer *certBuffer = parcCertificate_GetDEREncodedCertificate(certificate);
uint8_t *certBytes = parcBuffer_Overlay(certBuffer, parcBuffer_Limit(certBuffer));
X509 *cert = NULL;
- d2i_X509(&cert, (const unsigned char **) &certBytes, parcBuffer_Limit(certBuffer));
-
+ d2i_X509(&cert, (const unsigned char **) &certBytes, (long)parcBuffer_Limit(certBuffer));
+
parcCertificate_Release(&certificate);
-
+
PKCS12 *pkcs12 = PKCS12_create((char *) password,
"ccnxuser",
privateKey,
diff --git a/libparc/parc/security/parc_PublicKeySigner.c b/libparc/parc/security/parc_PublicKeySigner.c
index 55404b9c..de048df8 100644
--- a/libparc/parc/security/parc_PublicKeySigner.c
+++ b/libparc/parc/security/parc_PublicKeySigner.c
@@ -170,7 +170,7 @@ static inline int _SignDigestRSA(const PARCCryptoHash *digestToSign, PARCBuffer
EVP_PKEY *privateKey = NULL;
size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
- privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, keySize);
+ privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, (long)keySize);
RSA *rsa = EVP_PKEY_get1_RSA(privateKey);
//*sig = parcMemory_Allocate(RSA_size(rsa));
@@ -196,7 +196,7 @@ static inline int _SignDigestECDSA(const PARCCryptoHash *digestToSign, PARCBuffe
EVP_PKEY *privateKey = NULL;
size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
- privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, keySize);
+ privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, (long)keySize);
EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(privateKey);
@@ -283,7 +283,7 @@ _GetSignatureSize(PARCPublicKeySigner *signer)
{
EVP_PKEY *privateKey = NULL;
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, parcBuffer_Limit(privateKeyBuffer));
- privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, parcBuffer_Limit(privateKeyBuffer));
+ privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, (long)parcBuffer_Limit(privateKeyBuffer));
RSA *rsa = EVP_PKEY_get1_RSA(privateKey);
@@ -297,7 +297,7 @@ _GetSignatureSize(PARCPublicKeySigner *signer)
EVP_PKEY *privateKey = NULL;
size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
- privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, keySize);
+ privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, (long)keySize);
EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(privateKey);
diff --git a/libparc/parc/security/parc_SecureRandom.c b/libparc/parc/security/parc_SecureRandom.c
index 92c308c1..80189cb9 100644
--- a/libparc/parc/security/parc_SecureRandom.c
+++ b/libparc/parc/security/parc_SecureRandom.c
@@ -13,19 +13,17 @@
* limitations under the License.
*/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
-/**
- */
#include <config.h>
-
#include <stdlib.h>
#include <fcntl.h>
-#include <unistd.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Memory.h>
-
#include <parc/security/parc_SecureRandom.h>
struct parc_securerandom {
@@ -77,7 +75,7 @@ static void
_parcSecureRandom_ReSeed(PARCSecureRandom *random, PARCBuffer *buffer)
{
size_t length = parcBuffer_Remaining(buffer);
- int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), length);
+ int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), (long)length);
}
PARCSecureRandom *
@@ -104,7 +102,7 @@ ssize_t
parcSecureRandom_NextBytes(PARCSecureRandom *random, PARCBuffer *buffer)
{
size_t length = parcBuffer_Remaining(buffer);
- ssize_t result = read(random->randomfd, parcBuffer_Overlay(buffer, 0), length);
+ ssize_t result = read(random->randomfd, parcBuffer_Overlay(buffer, 0), (unsigned int)length);
return result;
}
diff --git a/libparc/parc/security/parc_Security.c b/libparc/parc/security/parc_Security.c
index e5f7609d..999a41da 100644
--- a/libparc/parc/security/parc_Security.c
+++ b/libparc/parc/security/parc_Security.c
@@ -50,8 +50,10 @@
#error OpenSSL version must be at least 0.9.8 release
#endif
+#ifndef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -120,8 +122,10 @@ _getThreadId(CRYPTO_THREADID *id)
#elif defined(__linux__)
// linux (at least ubuntu and redhat) uses unsigned long int
CRYPTO_THREADID_set_numeric(id, threadid);
+#elif _WIN32
+ CRYPTO_THREADID_set_pointer(id, threadid.p);
#else
-#error Unsupported platform, only __APPLE__ and __linux__ supported
+#error Unsupported platform, only __APPLE__, __linux__ and MSVC supported
#endif
}
#endif
@@ -206,4 +210,6 @@ parcSecurity_Fini(void)
parcAssertTrue(unlockSuccessful, "Unable to unlock the PARC Security framework.");
}
+#ifndef _WIN32
#pragma GCC diagnostic pop
+#endif \ No newline at end of file
diff --git a/libparc/parc/security/parc_Security.h b/libparc/parc/security/parc_Security.h
index 2c20496b..2c20496b 100755..100644
--- a/libparc/parc/security/parc_Security.h
+++ b/libparc/parc/security/parc_Security.h
diff --git a/libparc/parc/security/parc_Signature.c b/libparc/parc/security/parc_Signature.c
index 4b1abc06..4b1abc06 100755..100644
--- a/libparc/parc/security/parc_Signature.c
+++ b/libparc/parc/security/parc_Signature.c
diff --git a/libparc/parc/security/parc_Signature.h b/libparc/parc/security/parc_Signature.h
index 3d28ac56..3d28ac56 100755..100644
--- a/libparc/parc/security/parc_Signature.h
+++ b/libparc/parc/security/parc_Signature.h
diff --git a/libparc/parc/security/parc_Signer.h b/libparc/parc/security/parc_Signer.h
index 9bb0c6a1..9bb0c6a1 100755..100644
--- a/libparc/parc/security/parc_Signer.h
+++ b/libparc/parc/security/parc_Signer.h
diff --git a/libparc/parc/security/parc_SigningAlgorithm.c b/libparc/parc/security/parc_SigningAlgorithm.c
index 4d1765d7..4d1765d7 100755..100644
--- a/libparc/parc/security/parc_SigningAlgorithm.c
+++ b/libparc/parc/security/parc_SigningAlgorithm.c
diff --git a/libparc/parc/security/parc_SymmetricKeyStore.c b/libparc/parc/security/parc_SymmetricKeyStore.c
index 49d5055e..0d5f53e0 100644
--- a/libparc/parc/security/parc_SymmetricKeyStore.c
+++ b/libparc/parc/security/parc_SymmetricKeyStore.c
@@ -26,13 +26,15 @@
* @endcode
*/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
#include <config.h>
#include <stdio.h>
#include <fcntl.h>
-#include <unistd.h>
#include <string.h>
#include <limits.h>
-#include <unistd.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
@@ -390,9 +392,11 @@ parcSymmetricKeyStore_CreateKey(unsigned bits)
parcAssertTrue((bits & 0x07) == 0, "bits must be a multiple of 8");
unsigned keylength = bits / 8;
- uint8_t buffer[keylength];
+ uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t) * keylength);
RAND_bytes(buffer, keylength);
- return parcBuffer_Flip(parcBuffer_PutArray(parcBuffer_Allocate(keylength), keylength, buffer));
+ PARCBuffer *parcBuffer = parcBuffer_Flip(parcBuffer_PutArray(parcBuffer_Allocate(keylength), keylength, buffer));
+ free(buffer);
+ return parcBuffer;
}
PARCBuffer *
diff --git a/libparc/parc/security/parc_Verifier.c b/libparc/parc/security/parc_Verifier.c
index 75f99555..75f99555 100755..100644
--- a/libparc/parc/security/parc_Verifier.c
+++ b/libparc/parc/security/parc_Verifier.c
diff --git a/libparc/parc/security/parc_X509Certificate.c b/libparc/parc/security/parc_X509Certificate.c
index 2c964ae7..ab29bfa6 100644
--- a/libparc/parc/security/parc_X509Certificate.c
+++ b/libparc/parc/security/parc_X509Certificate.c
@@ -389,7 +389,7 @@ parcX509Certificate_CreateFromDERBuffer(const PARCBuffer *buffer)
PARCByteArray *array = parcBuffer_Array(buffer);
uint8_t *arrayIn = parcByteArray_Array(array);
- cert->certificate = d2i_X509(&cert->certificate, (const unsigned char **) &arrayIn, parcBuffer_Remaining(buffer));
+ cert->certificate = d2i_X509(&cert->certificate, (const unsigned char **) &arrayIn, (long)parcBuffer_Remaining(buffer));
if (cert->certificate == NULL) {
parcX509Certificate_Release(&cert);
return NULL;
diff --git a/libparc/parc/security/parc_X509Certificate.h b/libparc/parc/security/parc_X509Certificate.h
index c6ca8247..c6ca8247 100755..100644
--- a/libparc/parc/security/parc_X509Certificate.h
+++ b/libparc/parc/security/parc_X509Certificate.h
diff --git a/libparc/parc/security/test/test_parc_CertificateFactory.c b/libparc/parc/security/test/test_parc_CertificateFactory.c
index 29675f94..29675f94 100755..100644
--- a/libparc/parc/security/test/test_parc_CertificateFactory.c
+++ b/libparc/parc/security/test/test_parc_CertificateFactory.c
diff --git a/libparc/parc/security/test/test_parc_CertificateType.c b/libparc/parc/security/test/test_parc_CertificateType.c
index 67ce5e87..67ce5e87 100755..100644
--- a/libparc/parc/security/test/test_parc_CertificateType.c
+++ b/libparc/parc/security/test/test_parc_CertificateType.c
diff --git a/libparc/parc/security/test/test_parc_ContainerEncoding.c b/libparc/parc/security/test/test_parc_ContainerEncoding.c
index 01cafa50..01cafa50 100755..100644
--- a/libparc/parc/security/test/test_parc_ContainerEncoding.c
+++ b/libparc/parc/security/test/test_parc_ContainerEncoding.c
diff --git a/libparc/parc/security/test/test_parc_CryptoCache.c b/libparc/parc/security/test/test_parc_CryptoCache.c
index 8613808d..8613808d 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoCache.c
+++ b/libparc/parc/security/test/test_parc_CryptoCache.c
diff --git a/libparc/parc/security/test/test_parc_CryptoHash.c b/libparc/parc/security/test/test_parc_CryptoHash.c
index df5409b2..df5409b2 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoHash.c
+++ b/libparc/parc/security/test/test_parc_CryptoHash.c
diff --git a/libparc/parc/security/test/test_parc_CryptoHasher.c b/libparc/parc/security/test/test_parc_CryptoHasher.c
index 33a3f6bc..33a3f6bc 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoHasher.c
+++ b/libparc/parc/security/test/test_parc_CryptoHasher.c
diff --git a/libparc/parc/security/test/test_parc_CryptoSuite.c b/libparc/parc/security/test/test_parc_CryptoSuite.c
index 42007617..42007617 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoSuite.c
+++ b/libparc/parc/security/test/test_parc_CryptoSuite.c
diff --git a/libparc/parc/security/test/test_parc_DiffieHellman.c b/libparc/parc/security/test/test_parc_DiffieHellman.c
index 69bc109b..69bc109b 100755..100644
--- a/libparc/parc/security/test/test_parc_DiffieHellman.c
+++ b/libparc/parc/security/test/test_parc_DiffieHellman.c
diff --git a/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c b/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c
index e8a2eeca..e8a2eeca 100755..100644
--- a/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c
+++ b/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c
diff --git a/libparc/parc/security/test/test_parc_InMemoryVerifier.c b/libparc/parc/security/test/test_parc_InMemoryVerifier.c
index 81baebc7..81baebc7 100755..100644
--- a/libparc/parc/security/test/test_parc_InMemoryVerifier.c
+++ b/libparc/parc/security/test/test_parc_InMemoryVerifier.c
diff --git a/libparc/parc/security/test/test_parc_Key.c b/libparc/parc/security/test/test_parc_Key.c
index d22362b0..d22362b0 100755..100644
--- a/libparc/parc/security/test/test_parc_Key.c
+++ b/libparc/parc/security/test/test_parc_Key.c
diff --git a/libparc/parc/security/test/test_parc_KeyStore.c b/libparc/parc/security/test/test_parc_KeyStore.c
index b48099cb..b48099cb 100755..100644
--- a/libparc/parc/security/test/test_parc_KeyStore.c
+++ b/libparc/parc/security/test/test_parc_KeyStore.c
diff --git a/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c b/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c
index 17a5b60f..17a5b60f 100755..100644
--- a/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c
+++ b/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c
diff --git a/libparc/parc/security/test/test_parc_SecureRandom.c b/libparc/parc/security/test/test_parc_SecureRandom.c
index 82359a70..82359a70 100755..100644
--- a/libparc/parc/security/test/test_parc_SecureRandom.c
+++ b/libparc/parc/security/test/test_parc_SecureRandom.c
diff --git a/libparc/parc/security/test/test_parc_Security.c b/libparc/parc/security/test/test_parc_Security.c
index c2f2f33e..c2f2f33e 100755..100644
--- a/libparc/parc/security/test/test_parc_Security.c
+++ b/libparc/parc/security/test/test_parc_Security.c
diff --git a/libparc/parc/security/test/test_parc_Signature.c b/libparc/parc/security/test/test_parc_Signature.c
index 4c57d5a9..4c57d5a9 100755..100644
--- a/libparc/parc/security/test/test_parc_Signature.c
+++ b/libparc/parc/security/test/test_parc_Signature.c
diff --git a/libparc/parc/security/test/test_parc_SigningAlgorithm.c b/libparc/parc/security/test/test_parc_SigningAlgorithm.c
index 12e50956..12e50956 100755..100644
--- a/libparc/parc/security/test/test_parc_SigningAlgorithm.c
+++ b/libparc/parc/security/test/test_parc_SigningAlgorithm.c
diff --git a/libparc/parc/security/test/test_parc_SymmetricKeyStore.c b/libparc/parc/security/test/test_parc_SymmetricKeyStore.c
index ab9dfddb..ab9dfddb 100755..100644
--- a/libparc/parc/security/test/test_parc_SymmetricKeyStore.c
+++ b/libparc/parc/security/test/test_parc_SymmetricKeyStore.c
diff --git a/libparc/parc/security/test/test_parc_Verifier.c b/libparc/parc/security/test/test_parc_Verifier.c
index fe382a9b..fe382a9b 100755..100644
--- a/libparc/parc/security/test/test_parc_Verifier.c
+++ b/libparc/parc/security/test/test_parc_Verifier.c
diff --git a/libparc/parc/security/test/test_parc_X509Certificate.c b/libparc/parc/security/test/test_parc_X509Certificate.c
index dda9a9ff..dda9a9ff 100755..100644
--- a/libparc/parc/security/test/test_parc_X509Certificate.c
+++ b/libparc/parc/security/test/test_parc_X509Certificate.c