ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Wed Apr 14, 2021 10:19 pm

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: pbkdf1
PostPosted: Tue Dec 29, 2020 3:04 am 

Joined: Thu Aug 07, 2014 10:28 pm
Posts: 363
python code

Code:
from passlib.utils.pbkdf2 import pbkdf1
key = 'Jr9DW9ksMRv1Lc796mrwv145fXC3L5VcpmKE5VfCuvbrpZGfYwXMpwo9sGkJ54zHse4G7zftpjkhqHHY60O7aQPj4M2ekKMSw094PmXRkN4ftTmDFlYMPmwK8QvhJ20H'.encode('utf-8', 'ignore')
salt = 'Jr9DW9ksMRv1Lc796mrwv145fXC3L5VcpmKE5VfCuvbrpZGfYwXMpwo9sGkJ54zHse4G7zftpjkhqHHY60O7aQPj4M2ekKMSw094PmXRkN4ftTmDFlYMPmwK8QvhJ20H'.encode('utf-8', 'ignore')
bk = pbkdf1(key, salt, 100, keylen=16, hash='sha1')
bk.hex()


produces
Code:
'8e2e1d5a5e3a4a1c7388f6b8d7779d7b'


How would i do this in quickbms?


openssl code
Code:
#include <string.h>
#include <stdlib.h>
#include <openssl/sha.h>

void pbkdf1(const char *password, const char *salt, long iter, unsigned char dk[SHA_DIGEST_LENGTH])
{
    size_t pwlen = strlen(password);
    size_t dlen = pwlen + 8;
    unsigned char *buf;

    if (dlen > SHA_DIGEST_LENGTH)
        buf = malloc(dlen);
    else
        buf = malloc(SHA_DIGEST_LENGTH);

    memcpy(buf, password, pwlen);
    strncpy((char *)buf + pwlen, salt, 8);

    while (iter-- > 0)
    {
        SHA1(buf, dlen, buf);
        dlen = SHA_DIGEST_LENGTH;
    }

    memcpy(dk, buf, SHA_DIGEST_LENGTH);
    free(buf);
}


or

https://github.com/RobertCNelson/bertos ... f/pbkdf1.c


Top
   
 Post subject: Re: pbkdf1
PostPosted: Fri Jan 01, 2021 5:11 pm 

Joined: Thu Aug 07, 2014 10:28 pm
Posts: 363
I see this in quickbms source tomcrypt_pkcs.h but no idea how to call it.

Code:
/* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */
#ifdef LTC_PKCS_5

/* Algorithm #1 (old) */
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
                const unsigned char *salt,
                int iteration_count,  int hash_idx,
                unsigned char *out,   unsigned long *outlen);

/* Algorithm #2 (new) */
int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
                const unsigned char *salt,     unsigned long salt_len,
                int iteration_count,           int hash_idx,
                unsigned char *out,            unsigned long *outlen);

#endif  /* LTC_PKCS_5 */


Top
   
 Post subject: Re: pbkdf1
PostPosted: Tue Feb 16, 2021 7:50 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 12088
It will be available in the beta.
I added some code in the local one (not on the website yet) but I didn't test it yet.

Other solutions like PKCS5_PBKDF2_HMAC, BytesToKey and Rfc2898DeriveBytes are available but it may be a bit messy to use them since the Encryption command is limited and meant for something different.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited