def _commoncrypto_pbkdf2(data, salt, iterations, digest, keylen):
 c_hashfunc = ctypes.c_uint32(_commoncrypto_hashlib_to_crypto_map_get(digest))
 c_pass = ctypes.c_char_p(data)
 c_passlen = ctypes.c_size_t(len(data))
 c_salt = ctypes.c_char_p(salt)
 c_saltlen = ctypes.c_size_t(len(salt))
 c_iter = ctypes.c_uint(iterations)
 c_keylen = ctypes.c_size_t(keylen)
 c_buff = ctypes.create_string_buffer(keylen)
 crypto.CCKeyDerivationPBKDF.restype = ctypes.c_int
 crypto.CCKeyDerivationPBKDF.argtypes = [ctypes.c_uint32, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_uint32, ctypes.c_uint, ctypes.c_char_p, ctypes.c_size_t]
 ret = crypto.CCKeyDerivationPBKDF(2, c_pass, c_passlen, c_salt, c_saltlen, c_hashfunc, c_iter, c_buff, c_keylen)
 return ((1 - ret), c_buff)

def _commoncrypto_pbkdf2 ( data , salt , iterations , digest , keylen ) : c_hashfunc = ctypes . c_uint32 ( _commoncrypto_hashlib_to_crypto_map_get ( digest ) ) c_pass = ctypes . c_char_p ( data ) c_passlen = ctypes . c_size_t ( len ( data ) ) c_salt = ctypes . c_char_p ( salt ) c_saltlen = ctypes . c_size_t ( len ( salt ) ) c_iter = ctypes . c_uint ( iterations ) c_keylen = ctypes . c_size_t ( keylen ) c_buff = ctypes . create_string_buffer ( keylen ) crypto . CCKeyDerivationPBKDF . restype = ctypes . c_int crypto . CCKeyDerivationPBKDF . argtypes = [ ctypes . c_uint32 , ctypes . c_char_p , ctypes . c_size_t , ctypes . c_char_p , ctypes . c_size_t , ctypes . c_uint32 , ctypes . c_uint , ctypes . c_char_p , ctypes . c_size_t ] ret = crypto . CCKeyDerivationPBKDF ( 2 , c_pass , c_passlen , c_salt , c_saltlen , c_hashfunc , c_iter , c_buff , c_keylen ) return ( ( 1 - ret ) , c_buff )
common crypto compatibile wrapper .