From 33b53c7f5cef4cf19770a38baa4b627f234322cf Mon Sep 17 00:00:00 2001 From: Giovanni Conte Date: Wed, 16 Jan 2019 12:09:43 +0100 Subject: removed longbow dependency Change-Id: I0c224b26261c7b24699410fc5e41ed6f3fab9815 Signed-off-by: Giovanni Conte --- libparc/parc/security/parc_PublicKeySigner.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'libparc/parc/security/parc_PublicKeySigner.c') diff --git a/libparc/parc/security/parc_PublicKeySigner.c b/libparc/parc/security/parc_PublicKeySigner.c index 3c70a139..0a029cae 100644 --- a/libparc/parc/security/parc_PublicKeySigner.c +++ b/libparc/parc/security/parc_PublicKeySigner.c @@ -41,7 +41,7 @@ struct PARCPublicKeySigner { static bool _parcPublicKeySigner_Finalize(PARCPublicKeySigner **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPublicKeySigner pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPublicKeySigner pointer."); PARCPublicKeySigner *instance = *instancePtr; @@ -58,7 +58,7 @@ _parcPublicKeySigner_Finalize(PARCPublicKeySigner **instancePtr) void parcPublicKeySigner_AssertValid(const PARCPublicKeySigner *instance) { - assertTrue(parcPublicKeySigner_IsValid(instance), "PARCPublicKeySigner is not valid."); + parcAssertTrue(parcPublicKeySigner_IsValid(instance), "PARCPublicKeySigner is not valid."); } bool @@ -140,28 +140,28 @@ parcPublicKeySigner_Create(PARCKeyStore *keyStore, PARCCryptoSuite suite) static PARCSigningAlgorithm _GetSigningAlgorithm(PARCPublicKeySigner *signer) { - assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); + parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); return signer->signingAlgorithm; } static PARCCryptoHashType _GetCryptoHashType(PARCPublicKeySigner *signer) { - assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); + parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); return signer->hashType; } static PARCCryptoHasher * _GetCryptoHasher(PARCPublicKeySigner *signer) { - assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); + parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); return signer->hasher; } static PARCKeyStore * _GetKeyStore(PARCPublicKeySigner *signer) { - assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); + parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher"); return signer->keyStore; } @@ -175,7 +175,7 @@ static inline int _SignDigestRSA(const PARCCryptoHash *digestToSign, PARCBuffer RSA *rsa = EVP_PKEY_get1_RSA(privateKey); *sig = parcMemory_Allocate(RSA_size(rsa)); - assertNotNull(*sig, "parcMemory_Allocate(%u) returned NULL", RSA_size(rsa)); + parcAssertNotNull(*sig, "parcMemory_Allocate(%u) returned NULL", RSA_size(rsa)); *sigLength = 0; PARCBuffer *bb_digest = parcCryptoHash_GetDigest(digestToSign); @@ -185,7 +185,7 @@ static inline int _SignDigestRSA(const PARCCryptoHash *digestToSign, PARCBuffer *sig, sigLength, rsa); - assertTrue(result == 1, "Got error from RSA_sign: %d", result); + parcAssertTrue(result == 1, "Got error from RSA_sign: %d", result); EVP_PKEY_free(privateKey); RSA_free(rsa); return result; @@ -201,7 +201,7 @@ static inline int _SignDigestECDSA(const PARCCryptoHash *digestToSign, PARCBuffe EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(privateKey); *sig = parcMemory_Allocate(ECDSA_size(ec_key)); - assertNotNull(sig, "parcMemory_Allocate(%u) returned NULL", ECDSA_size(ec_key)); + parcAssertNotNull(sig, "parcMemory_Allocate(%u) returned NULL", ECDSA_size(ec_key)); *sigLength = 0; PARCBuffer *bb_digest = parcCryptoHash_GetDigest(digestToSign); @@ -211,7 +211,7 @@ static inline int _SignDigestECDSA(const PARCCryptoHash *digestToSign, PARCBuffe *sig, sigLength, ec_key); - assertTrue(result == 1, "Got error from ECDSA_sign: %d", result); + parcAssertTrue(result == 1, "Got error from ECDSA_sign: %d", result); EC_KEY_free(ec_key); } @@ -221,8 +221,8 @@ _SignDigest(PARCPublicKeySigner *signer, const PARCCryptoHash *digestToSign) { parcSecurity_AssertIsInitialized(); - assertNotNull(signer, "Parameter must be non-null CCNxFileKeystore"); - assertNotNull(digestToSign, "Buffer to sign must not be null"); + parcAssertNotNull(signer, "Parameter must be non-null CCNxFileKeystore"); + parcAssertNotNull(digestToSign, "Buffer to sign must not be null"); // TODO: what is the best way to expose this? PARCKeyStore *keyStore = signer->keyStore; @@ -240,7 +240,7 @@ _SignDigest(PARCPublicKeySigner *signer, const PARCCryptoHash *digestToSign) opensslDigestType = NID_sha512; break; default: - trapUnexpectedState("Unknown digest type: %s", + parcTrapUnexpectedState("Unknown digest type: %s", parcCryptoHashType_ToString(parcCryptoHash_GetDigestType(digestToSign))); } @@ -272,7 +272,7 @@ _SignDigest(PARCPublicKeySigner *signer, const PARCCryptoHash *digestToSign) static size_t _GetSignatureSize(PARCPublicKeySigner *signer) { - assertNotNull(signer, "Parameter must be non-null CCNxFileKeystore"); + parcAssertNotNull(signer, "Parameter must be non-null CCNxFileKeystore"); // TODO: what is the best way to expose this? PARCKeyStore *keyStore = signer->keyStore; -- cgit 1.2.3-korg From 82317aed7d4b6acd4fb65441a106f9de4d9c8926 Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Thu, 17 Jan 2019 10:57:04 +0100 Subject: add clang directives to avoid warnings Change-Id: I1ed298176ad1403ed089177a3cce4264f028bbbd Signed-off-by: Angelo Mantellini --- libparc/parc/algol/parc_Object.h | 27 +++++++++++++++++++++++++ libparc/parc/security/parc_CertificateFactory.c | 2 ++ libparc/parc/security/parc_PublicKeySigner.c | 4 +++- libparc/parc/security/parc_X509Certificate.c | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) (limited to 'libparc/parc/security/parc_PublicKeySigner.c') diff --git a/libparc/parc/algol/parc_Object.h b/libparc/parc/algol/parc_Object.h index b1a48558..ac7e9652 100644 --- a/libparc/parc/algol/parc_Object.h +++ b/libparc/parc/algol/parc_Object.h @@ -598,7 +598,33 @@ const PARCObjectDescriptor *parcObject_SetDescriptor(PARCObject *object, const P * The new `PARCObjectDescriptor` uses the existing `PARCObjectDescriptor` as the super-type of the new descriptor. */ +#ifdef __clang__ #define parcObject_Extends(_subtype, _superType, ...) \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Winitializer-overrides\"") \ + parcObjectDescriptor_Declaration(_subtype) = { \ + .super = &parcObject_DescriptorName(_superType), \ + .name = #_subtype, \ + .objectSize = 0, \ + .objectAlignment = 0, \ + .destroy = NULL, \ + .destructor = NULL, \ + .release = NULL, \ + .copy = NULL, \ + .toString = NULL, \ + .equals = NULL, \ + .compare = NULL, \ + .hashCode = NULL, \ + .toJSON = NULL, \ + .display = NULL, \ + .isLockable = true, \ + .typeState = NULL, \ + __VA_ARGS__ \ + }; \ + _Pragma("GCC diagnostic pop") \ + const PARCObjectDescriptor parcObject_DescriptorName(_subtype) +#else + #define parcObject_Extends(_subtype, _superType, ...) \ _Pragma("GCC diagnostic ignored \"-Woverride-init\"") \ parcObjectDescriptor_Declaration(_subtype) = { \ .super = &parcObject_DescriptorName(_superType), \ @@ -621,6 +647,7 @@ const PARCObjectDescriptor *parcObject_SetDescriptor(PARCObject *object, const P }; \ _Pragma("GCC diagnostic warning \"-Woverride-init\"") \ const PARCObjectDescriptor parcObject_DescriptorName(_subtype) +#endif /** * Define a new PARC Object implementation, by composing a new PARC Object Descriptor referencing an old one. diff --git a/libparc/parc/security/parc_CertificateFactory.c b/libparc/parc/security/parc_CertificateFactory.c index 52cef4af..c737e425 100644 --- a/libparc/parc/security/parc_CertificateFactory.c +++ b/libparc/parc/security/parc_CertificateFactory.c @@ -91,6 +91,8 @@ parcCertificateFactory_CreateSelfSignedCertificate(PARCCertificateFactory *facto case PARCSigningAlgorithm_ECDSA: certificate = parcX509Certificate_CreateSelfSignedCertificate(privateKey, subjectName, (int) keyLength, valdityDays, PARCKeyType_EC); break; + default: + break; } // This may fail. diff --git a/libparc/parc/security/parc_PublicKeySigner.c b/libparc/parc/security/parc_PublicKeySigner.c index 0a029cae..1297611e 100644 --- a/libparc/parc/security/parc_PublicKeySigner.c +++ b/libparc/parc/security/parc_PublicKeySigner.c @@ -213,7 +213,7 @@ static inline int _SignDigestECDSA(const PARCCryptoHash *digestToSign, PARCBuffe ec_key); parcAssertTrue(result == 1, "Got error from ECDSA_sign: %d", result); EC_KEY_free(ec_key); - + return result; } static PARCSignature * @@ -307,6 +307,8 @@ _GetSignatureSize(PARCPublicKeySigner *signer) EVP_PKEY_free(privateKey); break; } + default: + break; } parcBuffer_Release(&privateKeyBuffer); diff --git a/libparc/parc/security/parc_X509Certificate.c b/libparc/parc/security/parc_X509Certificate.c index 497cff99..2c964ae7 100644 --- a/libparc/parc/security/parc_X509Certificate.c +++ b/libparc/parc/security/parc_X509Certificate.c @@ -609,6 +609,8 @@ parcX509Certificate_CreateSelfSignedCertificate(PARCBuffer **privateKeyBuffer, c return _createSelfSignedCertificate_RSA(privateKeyBuffer, subjectName, keyLength, validityDays); case PARCKeyType_EC: return _createSelfSignedCertificate_EC(privateKeyBuffer, subjectName, keyLength, validityDays); + default: + break; } return NULL; -- cgit 1.2.3-korg