How to use the oscrypto._mac._core_foundation.CoreFoundation.CFRelease function in oscrypto

To help you get started, we’ve selected a few oscrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wbond / oscrypto / oscrypto / _mac / symmetric.py View on Github external
Security.SecTransformSetAttribute(
            sec_transform,
            Security.kSecTransformInputAttributeName,
            cf_data,
            error_pointer
        )
        handle_cf_error(error_pointer)

        ciphertext = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(ciphertext)

    finally:
        if cf_dict:
            CoreFoundation.CFRelease(cf_dict)
        if cf_key:
            CoreFoundation.CFRelease(cf_key)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_iv:
            CoreFoundation.CFRelease(cf_iv)
        if sec_key:
            CoreFoundation.CFRelease(sec_key)
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
github wbond / oscrypto / oscrypto / _mac / asymmetric.py View on Github external
error_pointer
        )
        handle_cf_error(error_pointer)

        cf_signature = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(cf_signature)

    finally:
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
        if cf_signature:
            CoreFoundation.CFRelease(cf_signature)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_hash_length:
            CoreFoundation.CFRelease(cf_hash_length)
github wbond / oscrypto / oscrypto / _mac / asymmetric.py View on Github external
return KeyExchangeAlgorithm.load(private_key_bytes)['parameters']

    finally:
        if public_key_ref:
            CoreFoundation.CFRelease(public_key_ref)
        if private_key_ref:
            CoreFoundation.CFRelease(private_key_ref)
        if cf_data_public:
            CoreFoundation.CFRelease(cf_data_public)
        if cf_data_private:
            CoreFoundation.CFRelease(cf_data_private)
        if cf_string:
            CoreFoundation.CFRelease(cf_string)
        if sec_keychain_ref:
            Security.SecKeychainDelete(sec_keychain_ref)
            CoreFoundation.CFRelease(sec_keychain_ref)
        if temp_dir:
            shutil.rmtree(temp_dir)
        if sec_access_ref:
            CoreFoundation.CFRelease(sec_access_ref)
github wbond / oscrypto / oscrypto / _mac / symmetric.py View on Github external
error_pointer
        )
        handle_cf_error(error_pointer)

        ciphertext = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(ciphertext)

    finally:
        if cf_dict:
            CoreFoundation.CFRelease(cf_dict)
        if cf_key:
            CoreFoundation.CFRelease(cf_key)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_iv:
            CoreFoundation.CFRelease(cf_iv)
        if sec_key:
            CoreFoundation.CFRelease(sec_key)
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
github wbond / oscrypto / oscrypto / _mac / asymmetric.py View on Github external
Security.SecTransformSetAttribute(
            sec_transform,
            Security.kSecTransformInputAttributeName,
            cf_data,
            error_pointer
        )
        handle_cf_error(error_pointer)

        cf_signature = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(cf_signature)

    finally:
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
        if cf_signature:
            CoreFoundation.CFRelease(cf_signature)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_hash_length:
            CoreFoundation.CFRelease(cf_hash_length)
github wbond / oscrypto / oscrypto / _mac / asymmetric.py View on Github external
error = unwrap(error_pointer)
            if not is_null(error):
                raise SignatureError('Signature is invalid')

        res = bool(CoreFoundation.CFBooleanGetValue(res))

        if not res:
            raise SignatureError('Signature is invalid')

    finally:
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
        if cf_signature:
            CoreFoundation.CFRelease(cf_signature)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_hash_length:
            CoreFoundation.CFRelease(cf_hash_length)
github wbond / oscrypto / oscrypto / _mac / asymmetric.py View on Github external
handle_cf_error(error_pointer)

        cf_signature = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(cf_signature)

    finally:
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
        if cf_signature:
            CoreFoundation.CFRelease(cf_signature)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_hash_length:
            CoreFoundation.CFRelease(cf_hash_length)
github wbond / oscrypto / oscrypto / _mac / symmetric.py View on Github external
handle_cf_error(error_pointer)

        plaintext = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(plaintext)

    finally:
        if cf_dict:
            CoreFoundation.CFRelease(cf_dict)
        if cf_key:
            CoreFoundation.CFRelease(cf_key)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_iv:
            CoreFoundation.CFRelease(cf_iv)
        if sec_key:
            CoreFoundation.CFRelease(sec_key)
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)
github wbond / oscrypto / oscrypto / _mac / asymmetric.py View on Github external
result = Security.SecKeychainItemDelete(private_key_ref)
        handle_sec_error(result)

    finally:
        if cf_dict:
            CoreFoundation.CFRelease(cf_dict)
        if public_key_ref:
            CoreFoundation.CFRelease(public_key_ref)
        if private_key_ref:
            CoreFoundation.CFRelease(private_key_ref)
        if cf_data_public:
            CoreFoundation.CFRelease(cf_data_public)
        if cf_data_private:
            CoreFoundation.CFRelease(cf_data_private)
        if cf_string:
            CoreFoundation.CFRelease(cf_string)
        if sec_keychain_ref:
            Security.SecKeychainDelete(sec_keychain_ref)
            CoreFoundation.CFRelease(sec_keychain_ref)
        if temp_dir:
            shutil.rmtree(temp_dir)
        if sec_access_ref:
            CoreFoundation.CFRelease(sec_access_ref)

    return (load_public_key(public_key_bytes), load_private_key(private_key_bytes))
github wbond / oscrypto / oscrypto / _mac / symmetric.py View on Github external
plaintext = Security.SecTransformExecute(sec_transform, error_pointer)
        handle_cf_error(error_pointer)

        return CFHelpers.cf_data_to_bytes(plaintext)

    finally:
        if cf_dict:
            CoreFoundation.CFRelease(cf_dict)
        if cf_key:
            CoreFoundation.CFRelease(cf_key)
        if cf_data:
            CoreFoundation.CFRelease(cf_data)
        if cf_iv:
            CoreFoundation.CFRelease(cf_iv)
        if sec_key:
            CoreFoundation.CFRelease(sec_key)
        if sec_transform:
            CoreFoundation.CFRelease(sec_transform)