From 667f0b68bfa233b422ee2a40b453309a9573ef3f Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:11:35 +0000 Subject: Basic mutable array bindings. --- src/_cffi_src/commoncrypto/cf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/_cffi_src/commoncrypto/cf.py b/src/_cffi_src/commoncrypto/cf.py index 9d4387e6..02e58d90 100644 --- a/src/_cffi_src/commoncrypto/cf.py +++ b/src/_cffi_src/commoncrypto/cf.py @@ -20,6 +20,7 @@ typedef ... *CFDataRef; typedef signed long long CFIndex; typedef ... *CFStringRef; typedef ... *CFArrayRef; +typedef ... *CFMutableArrayRef; typedef ... *CFBooleanRef; typedef ... *CFErrorRef; typedef ... *CFNumberRef; @@ -35,6 +36,9 @@ typedef struct { typedef struct { ...; } CFRange; +typedef struct { + ...; +} CFArrayCallBacks; typedef UInt32 CFStringEncoding; enum { @@ -65,6 +69,8 @@ typedef int CFNumberType; const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; +const CFArrayCallBacks kCFTypeArrayCallBacks; + const CFBooleanRef kCFBooleanTrue; const CFBooleanRef kCFBooleanFalse; """ @@ -94,6 +100,10 @@ Boolean CFBooleanGetValue(CFBooleanRef); CFNumberRef CFNumberCreate(CFAllocatorRef, CFNumberType, const void *); void CFRelease(CFTypeRef); CFTypeRef CFRetain(CFTypeRef); + +CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef, CFIndex, + const CFArrayCallBacks *); +void CFArrayAppendValue(CFMutableArrayRef, const void *); """ MACROS = """ -- cgit v1.2.3 From 0600adc1445b277f27dcb879666b7c52897db53e Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:12:13 +0000 Subject: SecTrust for evaluating certificates. --- src/_cffi_src/commoncrypto/sectrust.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/_cffi_src/commoncrypto/sectrust.py b/src/_cffi_src/commoncrypto/sectrust.py index b787afad..4c330d04 100644 --- a/src/_cffi_src/commoncrypto/sectrust.py +++ b/src/_cffi_src/commoncrypto/sectrust.py @@ -9,9 +9,24 @@ INCLUDES = """ """ TYPES = """ +typedef ... *SecTrustRef; +typedef uint32_t SecTrustResultType; + +enum { + kSecTrustResultInvalid, + kSecTrustResultProceed, + kSecTrustResultConfirm, + kSecTrustResultDeny, + kSecTrustResultUnspecified, + kSecTrustResultRecoverableTrustFailure, + kSecTrustResultFatalTrustFailure, + kSecTrustResultOtherError + }; """ FUNCTIONS = """ +OSStatus SecTrustCreateWithCertificates(CFTypeRef, CFTypeRef, SecTrustRef *); +OSStatus SecTrustEvaluate(SecTrustRef, SecTrustResultType *); OSStatus SecTrustCopyAnchorCertificates(CFArrayRef *); """ -- cgit v1.2.3 From cc72cb5fa2f055db780bf7138c7957c41ad5df07 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:12:26 +0000 Subject: New bindings for evaluating certificates. --- src/_cffi_src/build_commoncrypto.py | 2 ++ src/_cffi_src/commoncrypto/seccertificate.py | 23 +++++++++++++++++++++++ src/_cffi_src/commoncrypto/secpolicy.py | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/_cffi_src/commoncrypto/seccertificate.py create mode 100644 src/_cffi_src/commoncrypto/secpolicy.py (limited to 'src') diff --git a/src/_cffi_src/build_commoncrypto.py b/src/_cffi_src/build_commoncrypto.py index 4e69b6d1..09e020a2 100644 --- a/src/_cffi_src/build_commoncrypto.py +++ b/src/_cffi_src/build_commoncrypto.py @@ -17,10 +17,12 @@ ffi = build_ffi_for_binding( "common_key_derivation", "common_cryptor", "common_symmetric_key_wrap", + "seccertificate", "secimport", "secitem", "seckey", "seckeychain", + "secpolicy", "sectransform", "sectrust", ], diff --git a/src/_cffi_src/commoncrypto/seccertificate.py b/src/_cffi_src/commoncrypto/seccertificate.py new file mode 100644 index 00000000..2b54b0ee --- /dev/null +++ b/src/_cffi_src/commoncrypto/seccertificate.py @@ -0,0 +1,23 @@ +# This file is dual licensed under the terms of the Apache License, Version +# 2.0, and the BSD License. See the LICENSE file in the root of this repository +# for complete details. + +from __future__ import absolute_import, division, print_function + +INCLUDES = """ +#include +""" + +TYPES = """ +typedef ... *SecCertificateRef; +""" + +FUNCTIONS = """ +SecCertificateRef SecCertificateCreateWithData(CFAllocatorRef, CFDataRef); +""" + +MACROS = """ +""" + +CUSTOMIZATIONS = """ +""" diff --git a/src/_cffi_src/commoncrypto/secpolicy.py b/src/_cffi_src/commoncrypto/secpolicy.py new file mode 100644 index 00000000..e132cfae --- /dev/null +++ b/src/_cffi_src/commoncrypto/secpolicy.py @@ -0,0 +1,23 @@ +# This file is dual licensed under the terms of the Apache License, Version +# 2.0, and the BSD License. See the LICENSE file in the root of this repository +# for complete details. + +from __future__ import absolute_import, division, print_function + +INCLUDES = """ +#include +""" + +TYPES = """ +typedef ... *SecPolicyRef; +""" + +FUNCTIONS = """ +SecPolicyRef SecPolicyCreateSSL(Boolean, CFStringRef); +""" + +MACROS = """ +""" + +CUSTOMIZATIONS = """ +""" -- cgit v1.2.3 From 66bd747d955775881a784a84cf28ac77bde867d9 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:17:24 +0000 Subject: Dedent closing brace. --- src/_cffi_src/commoncrypto/sectrust.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/_cffi_src/commoncrypto/sectrust.py b/src/_cffi_src/commoncrypto/sectrust.py index 4c330d04..1bdeba3c 100644 --- a/src/_cffi_src/commoncrypto/sectrust.py +++ b/src/_cffi_src/commoncrypto/sectrust.py @@ -21,7 +21,7 @@ enum { kSecTrustResultRecoverableTrustFailure, kSecTrustResultFatalTrustFailure, kSecTrustResultOtherError - }; +}; """ FUNCTIONS = """ -- cgit v1.2.3 From 8abf96ef6cfda80f2c4be9f5e637cffb344e7fa5 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:21:41 +0000 Subject: Remove SecTrustCreateWithCertificates. It's not present on 10.8. --- src/_cffi_src/commoncrypto/sectrust.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/_cffi_src/commoncrypto/sectrust.py b/src/_cffi_src/commoncrypto/sectrust.py index 1bdeba3c..26e95460 100644 --- a/src/_cffi_src/commoncrypto/sectrust.py +++ b/src/_cffi_src/commoncrypto/sectrust.py @@ -25,7 +25,6 @@ enum { """ FUNCTIONS = """ -OSStatus SecTrustCreateWithCertificates(CFTypeRef, CFTypeRef, SecTrustRef *); OSStatus SecTrustEvaluate(SecTrustRef, SecTrustResultType *); OSStatus SecTrustCopyAnchorCertificates(CFArrayRef *); """ -- cgit v1.2.3 From 4755d5c59ee34c3689e50918fe628c39d63bf5da Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:30:55 +0000 Subject: Fix indentation. --- src/_cffi_src/commoncrypto/sectrust.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/_cffi_src/commoncrypto/sectrust.py b/src/_cffi_src/commoncrypto/sectrust.py index 26e95460..6b185790 100644 --- a/src/_cffi_src/commoncrypto/sectrust.py +++ b/src/_cffi_src/commoncrypto/sectrust.py @@ -13,14 +13,14 @@ typedef ... *SecTrustRef; typedef uint32_t SecTrustResultType; enum { - kSecTrustResultInvalid, - kSecTrustResultProceed, - kSecTrustResultConfirm, - kSecTrustResultDeny, - kSecTrustResultUnspecified, - kSecTrustResultRecoverableTrustFailure, - kSecTrustResultFatalTrustFailure, - kSecTrustResultOtherError + kSecTrustResultInvalid, + kSecTrustResultProceed, + kSecTrustResultConfirm, + kSecTrustResultDeny, + kSecTrustResultUnspecified, + kSecTrustResultRecoverableTrustFailure, + kSecTrustResultFatalTrustFailure, + kSecTrustResultOtherError }; """ -- cgit v1.2.3 From ef273ebbc19aa49acb1506a8dffdcc5d72d60c6f Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Fri, 22 Jan 2016 18:31:10 +0000 Subject: Move SecTrustCreateWithCertificates to MACROS. Annoyingly, the type of the first parameter changed across versions. --- src/_cffi_src/commoncrypto/sectrust.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/_cffi_src/commoncrypto/sectrust.py b/src/_cffi_src/commoncrypto/sectrust.py index 6b185790..8962f4f2 100644 --- a/src/_cffi_src/commoncrypto/sectrust.py +++ b/src/_cffi_src/commoncrypto/sectrust.py @@ -30,6 +30,10 @@ OSStatus SecTrustCopyAnchorCertificates(CFArrayRef *); """ MACROS = """ +/* The first argument changed from CFArrayRef to CFTypeRef in 10.8, so this + * has to go here for compatibility. + */ +OSStatus SecTrustCreateWithCertificates(CFTypeRef, CFTypeRef, SecTrustRef *); """ CUSTOMIZATIONS = """ -- cgit v1.2.3