Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

#include <assert.h>

c_static_assert(PAL_OperationEncrypt == kCCEncrypt);
c_static_assert(PAL_OperationDecrypt == kCCDecrypt);
c_static_assert((uint32_t)PAL_OperationEncrypt == (uint32_t)kCCEncrypt);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the enum types are uint32_t.

c_static_assert((uint32_t)PAL_OperationDecrypt == (uint32_t)kCCDecrypt);

c_static_assert(PAL_AlgorithmAES == kCCAlgorithmAES128);
c_static_assert(PAL_AlgorithmDES == kCCAlgorithmDES);
c_static_assert(PAL_Algorithm3DES == kCCAlgorithm3DES);
c_static_assert(PAL_AlgorithmRC2 == kCCAlgorithmRC2);
c_static_assert((uint32_t)PAL_AlgorithmAES == (uint32_t)kCCAlgorithmAES128);
c_static_assert((uint32_t)PAL_AlgorithmDES == (uint32_t)kCCAlgorithmDES);
c_static_assert((uint32_t)PAL_Algorithm3DES == (uint32_t)kCCAlgorithm3DES);
c_static_assert((uint32_t)PAL_AlgorithmRC2 == (uint32_t)kCCAlgorithmRC2);

c_static_assert(PAL_ChainingModeECB == kCCModeECB);
c_static_assert(PAL_ChainingModeCBC == kCCModeCBC);
c_static_assert(PAL_ChainingModeCFB == kCCModeCFB);
c_static_assert(PAL_ChainingModeCFB8 == kCCModeCFB8);
c_static_assert((uint32_t)PAL_ChainingModeECB == (uint32_t)kCCModeECB);
c_static_assert((uint32_t)PAL_ChainingModeCBC == (uint32_t)kCCModeCBC);
c_static_assert((uint32_t)PAL_ChainingModeCFB == (uint32_t)kCCModeCFB);
c_static_assert((uint32_t)PAL_ChainingModeCFB8 == (uint32_t)kCCModeCFB8);

c_static_assert(PAL_PaddingModeNone == ccNoPadding);
c_static_assert(PAL_PaddingModePkcs7 == ccPKCS7Padding);
c_static_assert((uint32_t)PAL_PaddingModeNone == (uint32_t)ccNoPadding);
c_static_assert((uint32_t)PAL_PaddingModePkcs7 == (uint32_t)ccPKCS7Padding);

// No PAL_SymmetricOptions are currently mapped, so no asserts required.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int32_t AppleCryptoNative_X509GetRawData(SecCertificateRef cert, CFDataRef* ppDa
}

*ppDataOut = SecCertificateCopyData(cert);
*pOSStatus = *ppDataOut == NULL ? errSecParam : noErr;
*pOSStatus = *ppDataOut == NULL ? errSecParam : (OSStatus)noErr;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a weird one to me, or the Clang compiler being a little confused. We use noErr all over the place but only complained in this place.

The reason it complains here is it is the only place we don't assign it to some OSStatus as an intermediate, and use it in an expression directly mixing it with an OSStatus. noErr is an anonymous enum in MacTypes.h.

The alternative is to use errSecSuccess. This is functionally the same as noErr (both have a value of 0), but I opted for the smaller change here. It would be a tad weird to use errSecSuccess in this function, but keep using noErr everywhere else, and changing everything seemed unnecessary.

return (*pOSStatus == noErr);
}

Expand Down