Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 04 Jul 2013 15:53:03 +0200
From: marcus.desto <marcus.desto@...pl>
To: john-dev@...ts.openwall.com
Subject: Re: OpenCL PBKDFv2 Kernel With Python

Hi Michael,

thanks!


Dnia 4 lipca 2013 12:46 Michael Samuel <mik@...net.net> napisaƂ(a):

> Hi Marcus,
> 
> On 4 July 2013 20:34, marcus.desto <marcus.desto@...pl> wrote:
> 
> > __kernel void pbkdf2_init(__global const pbkdf2_password *inbuffer,
> >                           __constant pbkdf2_salt *salt,
> >                           __global pbkdf2_state *state)
> >
> > Does anyone of you has any idea, how I can access inbuffer of type pbkdf2_password from pyopencl?
> 
> If you have a look in opencl_pbkdf2_hmac_sha1.h you'll see the 3
> structs.  You'll probably need to do struct.pack() to create one of
> each of those structures.
> 
> So for example, I'd construct it with something like this:
> 
> 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)
> 
> Regards,
>   Michael
> 

I have a problem with unpacking the OUT_buffer. I know this is not a python mailing list, but maybe someone knows python and can give me a hint. I'd really appreciate.

pyKEYLEN=20 # for hash
import sys
print " ~> "+str( sys.getsizeof(numpy.uint32()) )
OUT_host_buffer = "".join([ struct.pack("=I",100+i) for i in range(pyKEYLEN) ]) # for testing 100+i
print " ----> "+str(sys.getsizeof(OUT_host_buffer))
OUT_dev_buffer = cl.Buffer(ctx, mf.READ_WRITE, sys.getsizeof(OUT_host_buffer))
print "\n>> OUT_host_buffer  "+str(OUT_host_buffer)+"\n"
print "\n>> OUT_dev_buffer  "+str(sys.getsizeof(OUT_dev_buffer))+"\n"
import binascii
s = struct.Struct('=I')
dat = s.unpack(bytearray(OUT_host_buffer))
print "\n>> dat  "+str(dat)+"\n"

I get the following error:

Traceback (most recent call last):
  File "opencl_PBKDFv2_compare6.py", line 103, in <module>
    dat = s.unpack(bytearray(OUT_host_buffer))
struct.error: unpack requires a string argument of length 4

I think I stuck at the OUT_buffer part.

typedef struct {
	uint v[(OUTLEN+3)/4];
} pbkdf2_hash;

This brings me to another problem:

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)

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.