c - cryptsetup backend safe with multithreading? -


is there crypto backend cryptsetup either thread safe, or can used (or modified, preferably minimal effort) in thread safe manner testing if key correct?

background , have tried:

i started testing if modify source of cryptsetup test multiple keys using pthreads. crashed, believe used gcrypt initially. tried of backends available in cryptsetup stable source , found openssl , nettle seems avoid crashing.

however, testing not thorough , though (nettle specifically) not crash, seems not work correctly when using threads. when using single thread works, increasing number of threads makes increasingly silently never find correct key.

this brute forcing luks devices. aware pbkdf slows down crawl. i'm aware key space of aes cannot exhausted if kdf not there. fun of making in network distributed , multithreaded manner.

i noticed in source of cryptsetup (libdevmapper.c):

/*  * libdevmapper not context friendly, switch context on every dm call.  * fixme: not safe if called in parallel neither dm lib.  */ 

however, possible i'm not using correctly.

    if(!luks_open_key_with_hdr(crypt_any_slot, key, strlen(key), &cd->u.luks1.hdr, &vk, cd)) {             return 0;     } 

each worker thread this. call crypt_init() , crypt_load() once before worker threads start , pass them own separate copy of struct crypt_device. vk created locally each attempt. keys fetched wordlist access control mutex. found if each thread calls these functions (crypt_init , crypt_load) every time, seems crash more easily.

is incorrect try start removing , rewriting code uses dmcrypt? in luks_endec_template() attaches loop device crypto device, , creates dm device gives open(), gives fd of read_blockwise(). idea skip of since don't need use device except verify key. however, opening crypto device directly (and give read_blockwise()) not work.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -