Skip to content

Commit

Permalink
Fix #324: Update type encoding for a number of CoreFoundation types i…
Browse files Browse the repository at this point in the history
…n the Security framework
ronaldoussoren committed May 13, 2021
1 parent 71f0844 commit c0c3b7b
Showing 5 changed files with 59 additions and 23 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -44,6 +44,8 @@ Version 7.3

Calling these crashed in previous versions.

* #324: Fix the type encoding for a number of CoreFoundation types in the Security bindings

* #336: Add core support for 'final' classes

It is now possible to mark Objective-C classes as final,
30 changes: 30 additions & 0 deletions pyobjc-framework-LocalAuthentication/PyObjCTest/test_lacontext.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

from PyObjCTools.TestSupport import TestCase, min_os_level, os_level_between
import LocalAuthentication
import Security
import Foundation


class TestLAContext(TestCase):
@@ -103,3 +105,31 @@ def testMethods10_11(self):
2,
b"v" + objc._C_NSBOOL + b"@",
)

def test_regr_security_types(self):
# Issue #324
auth_ctx = LocalAuthentication.LAContext.new()
access_control = Security.SecAccessControlCreateWithFlags(
None,
Security.kSecAttrAccessibleWhenUnlocked,
Security.kSecAccessControlUserPresence,
None,
)[0]

called = False

def callback(a, b):
nonlocal called
called = True

auth_ctx.evaluateAccessControl_operation_localizedReason_reply_(
access_control,
LocalAuthentication.LAAccessControlOperationCreateKey,
"test",
callback,
)

loop = Foundation.NSRunLoop.currentRunLoop()
loop.runUntilDate_(Foundation.NSDate.dateWithTimeIntervalSinceNow_(0.2))

self.assertTrue(called)
6 changes: 5 additions & 1 deletion pyobjc-framework-LocalAuthentication/setup.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@
min_os_level="10.10",
packages=["LocalAuthentication"],
version=VERSION,
install_requires=["pyobjc-core>=" + VERSION, "pyobjc-framework-Cocoa>=" + VERSION],
install_requires=[
"pyobjc-core>=" + VERSION,
"pyobjc-framework-Cocoa>=" + VERSION,
"pyobjc-framework-Security>=" + VERSION,
],
long_description=__doc__,
)
22 changes: 11 additions & 11 deletions pyobjc-framework-Security/Lib/Security/_metadata.py
Original file line number Diff line number Diff line change
@@ -1611,44 +1611,44 @@ def sel32or64(a, b):
"errSecCSSigDBDenied": "errSecCSDBDenied",
}
cftypes = [
("SecKeyRef", b"^{OpaqueSecKeyRef=}", "SecKeyGetTypeID", None),
("SecPasswordRef", b"^{OpaqueSecPasswordRef=}", "SecPasswordGetTypeID", None),
("SecKeyRef", b"^{__SecKey=}", "SecKeyGetTypeID", None),
("SecPasswordRef", b"^{__SecPassword=}", "SecPasswordGetTypeID", None),
(
"SecKeychainItemRef",
b"^{OpaqueSecKeychainItemRef=}",
b"^{__SecKeychainItem=}",
"SecKeyChainItemGetTypeID",
None,
),
("SecTaskRef", b"^{__SecTask=}", "SecTaskGetTypeID", None),
(
"SecCertificateRef",
b"^{OpaqueSecCertificateRef=}",
b"^{__SecCertificate=}",
"SecCertificateGetTypeID",
None,
),
(
"SecTrustedApplicationRef",
b"^{OpaqueSecTrustedApplicationRef=}",
b"^{__SecTrustedApplication=}",
"SecTrustedApplicationGetTypeID",
None,
),
("CMSEncoderRef", b"^{_CMSEncoder=}", "CMSEncoderGetTypeID", None),
(
"SecAccessControlRef",
b"^{OpaqueSecAccessControlRef=}",
b"^{__SecAccessControl=}",
"SecAccessControlGetTypeID",
None,
),
("SecCodeRef", b"^{__SecCode=}", "SecCodeGetTypeID", None),
("CMSDecoderRef", b"^{_CMSDecoder=}", "CMSDecoderGetTypeID", None),
("SecAccessRef", b"^{OpaqueSecAccessRef=}", "SecAccessGetTypeID", None),
("SecIdentityRef", b"^{OpaqueSecIdentityRef=}", "SecIdentityGetTypeID", None),
("SecAccessRef", b"^{__SecAccess=}", "SecAccessGetTypeID", None),
("SecIdentityRef", b"^{__SecIdentity=}", "SecIdentityGetTypeID", None),
("SSLContextRef", b"^{SSLContext=}", "SSLContextGetTypeID", None),
("SecRequirementRef", b"^{__SecRequirement=}", "SecRequirementGetTypeID", None),
("SecPolicyRef", b"^{OpaqueSecPolicyRef=}", "SecPolicyGetTypeID", None),
("SecPolicyRef", b"^{__SecPolicy=}", "SecPolicyGetTypeID", None),
("SecTrustRef", b"^{__SecTrust=}", "SecTrustGetTypeID", None),
("SecACLRef", b"^{OpaqueSecTrustRef=}", "SecACLGetTypeID", None),
("SecKeychainRef", b"^{OpaqueSecKeychainRef=}", "SecKeyChainGetTypeID", None),
("SecACLRef", b"^{__SecACL=}", "SecACLGetTypeID", None),
("SecKeychainRef", b"^{__SecKeychain=}", "SecKeyChainGetTypeID", None),
]
misc.update(
{
22 changes: 11 additions & 11 deletions pyobjc-framework-Security/metadata/Security.fwinfo
Original file line number Diff line number Diff line change
@@ -34,47 +34,47 @@
"gettypeid_func": "SecRequirementGetTypeID"
},
"SecCertificateRef": {
"typestr": "^{OpaqueSecCertificateRef=}",
"typestr": "^{__SecCertificate=}",
"gettypeid_func": "SecCertificateGetTypeID"
},
"SecIdentityRef": {
"typestr": "^{OpaqueSecIdentityRef=}",
"typestr": "^{__SecIdentity=}",
"gettypeid_func": "SecIdentityGetTypeID"
},
"SecKeyRef": {
"typestr": "^{OpaqueSecKeyRef=}",
"typestr": "^{__SecKey=}",
"gettypeid_func": "SecKeyGetTypeID"
},
"SecPolicyRef": {
"typestr": "^{OpaqueSecPolicyRef=}",
"typestr": "^{__SecPolicy=}",
"gettypeid_func": "SecPolicyGetTypeID"
},
"SecAccessControlRef": {
"typestr": "^{OpaqueSecAccessControlRef=}",
"typestr": "^{__SecAccessControl=}",
"gettypeid_func": "SecAccessControlGetTypeID"
},
"SecKeychainRef": {
"typestr": "^{OpaqueSecKeychainRef=}",
"typestr": "^{__SecKeychain=}",
"gettypeid_func": "SecKeyChainGetTypeID"
},
"SecKeychainItemRef": {
"typestr": "^{OpaqueSecKeychainItemRef=}",
"typestr": "^{__SecKeychainItem=}",
"gettypeid_func": "SecKeyChainItemGetTypeID"
},
"SecTrustedApplicationRef": {
"typestr": "^{OpaqueSecTrustedApplicationRef=}",
"typestr": "^{__SecTrustedApplication=}",
"gettypeid_func": "SecTrustedApplicationGetTypeID"
},
"SecAccessRef": {
"typestr": "^{OpaqueSecAccessRef=}",
"typestr": "^{__SecAccess=}",
"gettypeid_func": "SecAccessGetTypeID"
},
"SecACLRef": {
"typestr": "^{OpaqueSecTrustRef=}",
"typestr": "^{__SecACL=}",
"gettypeid_func": "SecACLGetTypeID"
},
"SecPasswordRef": {
"typestr": "^{OpaqueSecPasswordRef=}",
"typestr": "^{__SecPassword=}",
"gettypeid_func": "SecPasswordGetTypeID"
},
"SecTaskRef": {

0 comments on commit c0c3b7b

Please sign in to comment.