Added support for openssl 1.1.1 89/16189/1
authorAlberto Compagno <[email protected]>
Mon, 26 Nov 2018 15:13:10 +0000 (16:13 +0100)
committerAlberto Compagno <[email protected]>
Mon, 26 Nov 2018 15:13:10 +0000 (16:13 +0100)
Change-Id: I596fd56152c32106c5279fc3033d48164328a903
Signed-off-by: Alberto Compagno <[email protected]>
libparc/parc/security/parc_Pkcs12KeyStore.c
libparc/parc/security/parc_SymmetricKeySigner.c
libparc/parc/security/test/test_parc_SymmetricKeySigner.c

index 392c9d3..c0d673c 100644 (file)
@@ -127,7 +127,11 @@ _parcPkcs12KeyStore_ParseFile(PARCPkcs12KeyStore *keystore, const char *filename
 
     keystore->public_key = X509_get_pubkey(keystore->x509_cert);
     if (keystore->public_key) {
-        switch (keystore->public_key->type) {
+#if OPENSSL_VERSION_NUMBER >= 0X10100000L
+        switch (EVP_PKEY_id(keystore->public_key)) {
+#else
+            switch (keystore->public_key->type) {
+#endif
             case EVP_PKEY_RSA:
                 keystore->signAlgo = PARCSigningAlgorithm_RSA;
                 break;
index 5cde896..b06389d 100644 (file)
@@ -116,8 +116,8 @@ _hmacDestroy(void **ctxPtr)
     HMAC_CTX_free(*ctxPtr);
 #else
     HMAC_CTX_cleanup(*ctxPtr);
-#endif
     parcMemory_Deallocate((void **) ctxPtr);
+#endif
     *ctxPtr = NULL;
 }
 
index 01874e7..44b169e 100644 (file)
@@ -155,11 +155,12 @@ LONGBOW_TEST_CASE(Specialization, test_hmac_sha256)
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
     _hmacInit(ctx);
     _hmacUpdate(ctx, to_digest_buffer, to_digest_length);
+    PARCBuffer *output = _hmacFinalize(ctx);
 #else
     _hmacInit(&ctx);
     _hmacUpdate(&ctx, to_digest_buffer, to_digest_length);
-#endif
     PARCBuffer *output = _hmacFinalize(&ctx);
+#endif
 
     assertTrue(parcBuffer_Position(output) == true_hmac_length,
                "hmac wrong length, expected %zu got %zu",
@@ -168,6 +169,7 @@ LONGBOW_TEST_CASE(Specialization, test_hmac_sha256)
 
     assertTrue(memcmp(parcByteArray_Array(parcBuffer_Array(output)), true_hmac_buffer, true_hmac_length) == 0,
                "hmac values did not match");
+
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
     HMAC_CTX_free(ctx);
 #else
@@ -214,11 +216,12 @@ LONGBOW_TEST_CASE(Specialization, test_hmac_sha512)
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
     _hmacInit(ctx);
     _hmacUpdate(ctx, to_digest_buffer, to_digest_length);
+    PARCBuffer *output = _hmacFinalize(ctx);
 #else
     _hmacInit(&ctx);
     _hmacUpdate(&ctx, to_digest_buffer, to_digest_length);
-#endif
     PARCBuffer *output = _hmacFinalize(&ctx);
+#endif
 
     assertTrue(parcBuffer_Position(output) == true_hmac_length,
                "hmac wrong length, expected %zu got %zu",