def cl_scrypt_init(self, N_value=15): # Initialise the openCL context & compile, with both debugging settings off debug = 0 bufStructs = buffer_structs() sprg = self.opencl_ctx.compile( bufStructs, "sCrypt.cl", None, N=N_value, invMemoryDensity=self.inv_memory_density) return [sprg, bufStructs]
def cl_sha256_init(self, option="", max_in_bytes=128, max_salt_bytes=32, dklen=0, max_ct_bytes=0): bufStructs = buffer_structs() bufStructs.specifySHA2(256, max_in_bytes, max_salt_bytes, dklen, max_ct_bytes) assert bufStructs.wordSize == 4 # set when you specify sha256 prg = self.opencl_ctx.compile(bufStructs, 'sha256.cl', option) return [prg, bufStructs]
def cl_scrypt_init(self, N_value=15, forceAltKernel=None): # Initialise the openCL context & compile, with both debugging settings off debug = 0 bufStructs = buffer_structs() if forceAltKernel: print("Loading Alternative sCrypt Kernel:", forceAltKernel) sprg = self.opencl_ctx.compile( bufStructs, forceAltKernel, None, N=N_value, invMemoryDensity=self.inv_memory_density) else: sprg = self.opencl_ctx.compile( bufStructs, "sCrypt.cl", None, N=N_value, invMemoryDensity=self.inv_memory_density) return [sprg, bufStructs]
def cl_pbkdf2_init(self, type, saltlen, dklen): bufStructs = buffer_structs() if type == "md5": self.max_out_bytes = bufStructs.specifyMD5(128, saltlen, dklen) ## hmac is defined in with pbkdf2, as a kernel function prg = self.opencl_ctx.compile(bufStructs, "md5.cl", "pbkdf2.cl") elif type == "sha1": self.max_out_bytes = bufStructs.specifySHA1(128, saltlen, dklen) ## hmac is defined in with pbkdf2, as a kernel function prg = self.opencl_ctx.compile(bufStructs, "sha1.cl", "pbkdf2.cl") elif type == "sha256": self.max_out_bytes = bufStructs.specifySHA2( 256, 128, saltlen, dklen) prg = self.opencl_ctx.compile(bufStructs, "sha256.cl", "pbkdf2.cl") elif type == "sha512": self.max_out_bytes = bufStructs.specifySHA2( 512, 256, saltlen, dklen) prg = self.opencl_ctx.compile(bufStructs, "sha512.cl", "pbkdf2.cl") else: assert ("Error on hash type, unknown !!!") return [prg, bufStructs]
def cl_hash_iterations_init(self, type): bufStructs = buffer_structs() if type == "md5": self.max_out_bytes = bufStructs.specifyMD5() ## hmac is defined in with pbkdf2, as a kernel function prg = self.opencl_ctx.compile(bufStructs, "md5.cl", "hash_iterations.cl") elif type == "sha1": self.max_out_bytes = bufStructs.specifySHA1() ## hmac is defined in with pbkdf2, as a kernel function prg = self.opencl_ctx.compile(bufStructs, "sha1.cl", "hash_iterations.cl") elif type == "sha256": self.max_out_bytes = bufStructs.specifySHA2() prg = self.opencl_ctx.compile(bufStructs, "sha256.cl", "hash_iterations.cl") elif type == "sha512": self.max_out_bytes = bufStructs.specifySHA2(512, 256, 0, 64) prg = self.opencl_ctx.compile(bufStructs, "sha512.cl", "hash_iterations.cl") else: assert ("Error on hash type, unknown !!!") return [prg, bufStructs]
def cl_sha1_init(self, option=""): bufStructs = buffer_structs() bufStructs.specifySHA1() assert bufStructs.wordSize == 4 # set when you specify sha1 prg = self.opencl_ctx.compile(bufStructs, 'sha1.cl', option) return [prg, bufStructs]
def cl_md5_init(self, option=""): bufStructs = buffer_structs() bufStructs.specifyMD5() assert bufStructs.wordSize == 4 # set when you specify md5 prg = self.opencl_ctx.compile(bufStructs, 'md5.cl', option) return [prg, bufStructs]