def _commoncrypto_pbkdf2(data, salt, iterations, digest, keylen):
    """Common Crypto compatibile wrapper
    """
    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, # hardcoded 2-> PBKDF2
                                           c_pass, c_passlen,
                                           c_salt, c_saltlen,
                                           c_hashfunc,
                                           c_iter,
                                           c_buff,
                                           c_keylen)

    return (ret - 1, c_buff)
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/contrib/pbkdf2_ctypes.py/_commoncrypto_pbkdf2/swapped operands of `-`