|
|
Message-ID: <6d34e93f.14023249.51d58d7c.429a1@o2.pl>
Date: Thu, 04 Jul 2013 16:58:04 +0200
From: marcus.desto <marcus.desto@...pl>
To: john-dev@...ts.openwall.com
Subject: Re: OpenCL PBKDFv2 Kernel With Python
Hi volks,
ok, I fixed some stuff.
I still do not know how to handle the following:
>
> How to deal with that using python?
>
> * Pass this kernel -DKEYLEN=x -DOUTLEN=y -DSALTLEN=z for generic use.
> *
> * KEYLEN should be PLAINTEXT_LENGTH for passwords or 20 for hash
> * OUTLEN should be sizeof(outbuffer->v)
> * SALTLEN should be sizeof(currentsalt.salt)
>
I have made a workaround by defining all 3 in the .cl file
Another problem appeared:
Traceback (most recent call last):
File "opencl_PBKDFv2_compare6.py", line 124, in <module>
cl.enqueue_copy(queue, OUT_host_buffer, OUT_dev_buffer).wait()
File "/usr/lib/python2.7/dist-packages/pyopencl/__init__.py", line 790, in enqueue_copy
return _cl._enqueue_read_buffer(queue, src, dest, **kwargs)
TypeError: Cannot use string as modifiable buffer
Here is some code:
plaintexts = []
plaintexts.append(password)
#plaintexts.append("foobar")
import struct
mf = cl.mem_flags
password_host_buffer = "".join([ struct.pack("=I65s", len(plaintext),plaintext) for plaintext in plaintexts ])
password_dev_buffer = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=password_host_buffer)
plainsalts = []
plainsalts.append(passwordSalt)
salt_host_buffer = "".join([ struct.pack("=I52s", len(plainsalt),plainsalt) for plainsalt in plainsalts ])
salt_dev_buffer = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=salt_host_buffer)
pyKEYLEN=20 # for hash
OUT_host_buffer = "".join([ struct.pack("=I",100+i) for i in range(pyKEYLEN) ]) # for testing 100+i, should be 0
OUT_dev_buffer = cl.Buffer(ctx, mf.READ_WRITE, sys.getsizeof(OUT_host_buffer))
f = open("pbkdf2_hmac_sha1_unsplit_kernel.cl", 'r')
fstr = "".join(f.readlines())
prg = cl.Program(ctx, fstr).build()
cl.enqueue_copy(queue, password_dev_buffer, password_host_buffer, is_blocking=True)
cl.enqueue_copy(queue, salt_dev_buffer, salt_host_buffer, is_blocking=True)
from time import clock
clbegin = clock()
# __kernel void derive_key(__global const pbkdf2_password *inbuffer, __global pbkdf2_hash *outbuffer, __global const pbkdf2_salt *salt)
prg.derive_key(queue, (1,), None, password_dev_buffer, OUT_dev_buffer ,salt_dev_buffer).wait()
cl.enqueue_copy(queue, OUT_host_buffer, OUT_dev_buffer).wait() # <== ERROR here
What kind of type do I have to use?
Regards,
Marcus
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.