Пример #1
0
 def cl_pbkdf2_init(self, rtype, saltlen, dklen):
     bufStructs = buffer_structs()
     if rtype == "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 rtype == "sha1":
         if saltlen < 32 and dklen < 32:
             dklen = 32
             self.max_out_bytes = bufStructs.specifySHA1(32, saltlen, dklen)
             prg = self.opencl_ctx.compile(bufStructs, "pbkdf2_sha1_32.cl",
                                           None)
         else:
             self.max_out_bytes = bufStructs.specifySHA1(
                 128, saltlen, dklen)
             prg = self.opencl_ctx.compile(bufStructs, "sha1.cl",
                                           "pbkdf2.cl")
     elif rtype == "sha256":
         if saltlen <= 64 and dklen <= 64:
             dklen = 64
         self.max_out_bytes = bufStructs.specifySHA2(
             256, 128, saltlen, dklen)
         if saltlen <= 64 and dklen <= 64:
             prg = self.opencl_ctx.compile(bufStructs,
                                           "pbkdf2_sha256_32.cl", None)
         else:
             prg = self.opencl_ctx.compile(bufStructs, "sha256.cl",
                                           "pbkdf2.cl")
     elif rtype == "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]
Пример #2
0
 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",
         N=N_value,
         invMemoryDensity=self.inv_memory_density)
     return [sprg, bufStructs]
Пример #3
0
 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)
     prg = self.opencl_ctx.compile(bufStructs, 'sha256.cl', option)
     return [prg, bufStructs]
Пример #4
0
 def cl_sha512_init(self,
                    option="",
                    max_in_bytes=128,
                    max_salt_bytes=32,
                    dklen=0,
                    max_ct_bytes=0):
     bufStructs = buffer_structs()
     bufStructs.specifySHA2(512, max_in_bytes, max_salt_bytes, dklen,
                            max_ct_bytes)
     assert bufStructs.wordSize == 8  # set when you specify sha512
     prg = self.opencl_ctx.compile(bufStructs, 'sha512.cl', option)
     return [prg, bufStructs]
Пример #5
0
 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")
     else:
         assert ("Error on hash type, unknown !!!")
     return [prg, bufStructs]
Пример #6
0
 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]
Пример #7
0
 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]
Пример #8
0
 def cl_pbkdf2_saltlist_init(self, type, pwdlen, dklen):
     bufStructs = buffer_structs()
     if type == "md5":
         self.max_out_bytes = bufStructs.specifyMD5(
             max_in_bytes=128,
             max_salt_bytes=128,
             dklen=dklen,
             max_password_bytes=pwdlen)
         ## 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(
             max_in_bytes=128,
             max_salt_bytes=128,
             dklen=dklen,
             max_password_bytes=pwdlen)
         ## 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(
             hashDigestSize_bits=256,
             max_in_bytes=128,
             max_salt_bytes=128,
             dklen=dklen,
             max_password_bytes=pwdlen)
         prg = self.opencl_ctx.compile(bufStructs, "sha256.cl", "pbkdf2.cl")
     elif type == "sha512":
         self.max_out_bytes = bufStructs.specifySHA2(
             hashDigestSize_bits=512,
             max_in_bytes=256,
             max_salt_bytes=128,
             dklen=dklen,
             max_password_bytes=pwdlen)
         prg = self.opencl_ctx.compile(bufStructs, "sha512.cl", "pbkdf2.cl")
     else:
         assert ("Error on hash type, unknown !!!")
     return [prg, bufStructs]
Пример #9
0
 def cl_sha1_init(self, option=""):
     bufStructs = buffer_structs()
     bufStructs.specifySHA1()
     prg = self.opencl_ctx.compile(bufStructs, 'sha1.cl', option)
     return [prg, bufStructs]
Пример #10
0
 def cl_md5_init(self, option=""):
     bufStructs = buffer_structs()
     bufStructs.specifyMD5()
     prg = self.opencl_ctx.compile(bufStructs, 'md5.cl', option)
     return [prg, bufStructs]
Пример #11
0
 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]
Пример #12
0
 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]