[GH-ISSUE #849] Comprehensive base-x conversion function #457

Closed
opened 2026-10-14 03:08:55 +07:00 by bsakaguchi · 28 comments
Owner

Originally created by @jfoug on GitHub (Nov 9, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/849

I am working on some new code. I will list what it does here. I am about 75% done on a POC level.

The code has 1 function (2 actually, 1 returns int, the other returns char *)

int base64_convert(const void *from, b64_convert_type from_t, 
                 int from_len, void *to, b64_convert_type to_t, int to_len);

The char * version simply returns the *to value. The int version returns the number of bytes written into *to (minus the null byte). raw does not get \0, but all other string types do get null termination. Right now, the base-64 types do not output padding. I may make that an option (it;s trivial)

The b64_convert_type enum is:

typedef enum {
        e_b64_unk=-1,   /* invalid type seen from command line usage */
        e_b64_raw,      /* raw memory */
        e_b64_hex,      /* hex */
        e_b64_hexU,     /* hex, but if used for convertTO param, will uppercase the hex */
        e_b64_mime,     /* mime */
        e_b64_crypt,    /* crypt encoding */
        e_b64_cryptBS,  /* crypt encoding, network order (used by WPA, cisco9, etc) */
} b64_convert_type;

There is also a command line tool (../run/base64conv). It's usage() output is:

Usage: ../run/base64conv [-i input_type] [-o output_type] data [data ...]
        data must match input_type (if hex, then data should be in hex)
        input/output types:
                hex     hexidecimal string (for input, case does not matter)
                hexU    hexidecimal string uppercase (if used for output type)
                mime    base64 mime encoding
                crypt   base64 crypt character set encoding
                cryptBS base64 crypt encoding, byte swapped

This 'issue' is simply a heads up, and if people want to comment, FEEL FREE.

Originally created by @jfoug on GitHub (Nov 9, 2014). Original GitHub issue: https://github.com/openwall/john/issues/849 I am working on some new code. I will list what it does here. I am about 75% done on a POC level. The code has 1 function (2 actually, 1 returns int, the other returns char *) ``` C int base64_convert(const void *from, b64_convert_type from_t, int from_len, void *to, b64_convert_type to_t, int to_len); ``` The char \* version simply returns the *to value. The int version returns the number of bytes written into *to (minus the null byte). raw does not get \0, but all other string types do get null termination. Right now, the base-64 types do not output padding. I may make that an option (it;s trivial) The b64_convert_type enum is: ``` C typedef enum { e_b64_unk=-1, /* invalid type seen from command line usage */ e_b64_raw, /* raw memory */ e_b64_hex, /* hex */ e_b64_hexU, /* hex, but if used for convertTO param, will uppercase the hex */ e_b64_mime, /* mime */ e_b64_crypt, /* crypt encoding */ e_b64_cryptBS, /* crypt encoding, network order (used by WPA, cisco9, etc) */ } b64_convert_type; ``` There is also a command line tool (../run/base64conv). It's usage() output is: ``` Usage: ../run/base64conv [-i input_type] [-o output_type] data [data ...] data must match input_type (if hex, then data should be in hex) input/output types: hex hexidecimal string (for input, case does not matter) hexU hexidecimal string uppercase (if used for output type) mime base64 mime encoding crypt base64 crypt character set encoding cryptBS base64 crypt encoding, byte swapped ``` This 'issue' is simply a heads up, and if people want to comment, FEEL FREE.
Author
Owner

@jfoug commented on GitHub (Nov 9, 2014):

Here is an example circular run
$ ../run/base64conv -i raw -o hex 123456789abcdefgHHHu
123456789abcdefgHHHu --> 3132333435363738396162636465666748484875

$ ../run/base64conv -i hex -o mime 3132333435363738396162636465666748484875
3132333435363738396162636465666748484875 --> MTIzNDU2Nzg5YWJjZGVmZ0hISHU

$ ../run/base64conv -i mime -o crypt MTIzNDU2Nzg5YWJjZGVmZ0hISHU
MTIzNDU2Nzg5YWJjZGVmZ0hISHU --> AH6nB1IqBnUtMK7XN4JaNoV6G5I

$ ../run/base64conv -i crypt -o raw AH6nB1IqBnUtMK7XN4JaNoV6G5I
AH6nB1IqBnUtMK7XN4JaNoV6G5I --> 123456789abcdefgHHHu

$ ../run/base64conv -i raw -o mime 123456789abcdefgHHHu
123456789abcdefgHHHu --> MTIzNDU2Nzg5YWJjZGVmZ0hISHU

But here I see I still have some bugs in code! (it should be AH6nB....)

$ ../run/base64conv -i raw -o crypt 123456789abcdefgHHHu
123456789abcdefgHHHu --> l6nAoIXBrUHCV7qMYJaNbV2G6J5

<!-- gh-comment-id:62316597 --> @jfoug commented on GitHub (Nov 9, 2014): Here is an example circular run $ ../run/base64conv -i raw -o hex 123456789abcdefgHHHu 123456789abcdefgHHHu --> 3132333435363738396162636465666748484875 $ ../run/base64conv -i hex -o mime 3132333435363738396162636465666748484875 3132333435363738396162636465666748484875 --> MTIzNDU2Nzg5YWJjZGVmZ0hISHU $ ../run/base64conv -i mime -o crypt MTIzNDU2Nzg5YWJjZGVmZ0hISHU MTIzNDU2Nzg5YWJjZGVmZ0hISHU --> AH6nB1IqBnUtMK7XN4JaNoV6G5I $ ../run/base64conv -i crypt -o raw AH6nB1IqBnUtMK7XN4JaNoV6G5I AH6nB1IqBnUtMK7XN4JaNoV6G5I --> 123456789abcdefgHHHu $ ../run/base64conv -i raw -o mime 123456789abcdefgHHHu 123456789abcdefgHHHu --> MTIzNDU2Nzg5YWJjZGVmZ0hISHU But here I see I still have some bugs in code! (it should be AH6nB....) $ ../run/base64conv -i raw -o crypt 123456789abcdefgHHHu 123456789abcdefgHHHu --> l6nAoIXBrUHCV7qMYJaNbV2G6J5
Author
Owner

@magnumripper commented on GitHub (Nov 9, 2014):

BTW I think you have a bug in current base64.c:82

static const char *mi64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";

It should end in +/, not ./, yes?

<!-- gh-comment-id:62319815 --> @magnumripper commented on GitHub (Nov 9, 2014): BTW I think you have a bug in current base64.c:82 ``` static const char *mi64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"; ``` It should end in `+/`, not `./`, yes?
Author
Owner

@jfoug commented on GitHub (Nov 9, 2014):

You are probably correct. I was going by the abase64_decode() function, which swaps + and . I do think the core should use +

This might be something to add as a modification flag, To be able to handle + or . Also to add or trim the = or trailing . values. Those type things should be in a flag (probably output case of hex also).

The new code strips out many of the latest changes (to base64, scrypt/pbkdf2-hmac-sha256, etc), and unifies them into base64_convert.c

The only conversion function that will not be in base64_convert (at the start), is the base64_decode contained in base64.h

I have a little more testing to do, but am about ready to plug it in and go.

<!-- gh-comment-id:62321195 --> @jfoug commented on GitHub (Nov 9, 2014): You are probably correct. I was going by the abase64_decode() function, which swaps + and . I do think the core should use + This might be something to add as a modification flag, To be able to handle + or . Also to add or trim the = or trailing . values. Those type things should be in a flag (probably output case of hex also). The new code strips out many of the latest changes (to base64, scrypt/pbkdf2-hmac-sha256, etc), and unifies them into base64_convert.c The only conversion function that will not be in base64_convert (at the start), is the base64_decode contained in base64.h I have a little more testing to do, but am about ready to plug it in and go.
Author
Owner

@jfoug commented on GitHub (Nov 9, 2014):

After changing . to + for mime, I had to change prepare to 'undo that' for pbkdf2_hmac_sha256 (for the cisco9 stuff)

But I think you are right, the + is the right thing to do.

<!-- gh-comment-id:62322146 --> @jfoug commented on GitHub (Nov 9, 2014): After changing . to + for mime, I had to change prepare to 'undo that' for pbkdf2_hmac_sha256 (for the cisco9 stuff) But I think you are right, the + is the right thing to do.
Author
Owner

@magnumripper commented on GitHub (Nov 9, 2014):

This might be something to add as a modification flag, To be able to handle + or .

Actually I think we should pass the wanted Base64 alphabet(s) as a whole, as one parameter. The normal ones would be defined as macros.

#define MIME_BASE64_ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
#define CRYPT_BASE64_ALPHABET "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Then we could do things like

convert(src, MIME_BASE64_ALPHABET, dst, CRYPT_BASE64_ALPHABET);

or

decode_base64(src, dst, MIME_BASE64_ALPHABET);
<!-- gh-comment-id:62322382 --> @magnumripper commented on GitHub (Nov 9, 2014): > This might be something to add as a modification flag, To be able to handle + or . Actually I think we should pass the wanted Base64 alphabet(s) as a whole, as one parameter. The normal ones would be defined as macros. ``` #define MIME_BASE64_ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" #define CRYPT_BASE64_ALPHABET "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ``` Then we could do things like ``` convert(src, MIME_BASE64_ALPHABET, dst, CRYPT_BASE64_ALPHABET); ``` or ``` decode_base64(src, dst, MIME_BASE64_ALPHABET); ```
Author
Owner

@jfoug commented on GitHub (Nov 9, 2014):

It is not just alphabet. It is also bit selection order.

<!-- gh-comment-id:62322647 --> @jfoug commented on GitHub (Nov 9, 2014): It is not just alphabet. It is also bit selection order.
Author
Owner

@jfoug commented on GitHub (Nov 9, 2014):

Anyhow, I will be checking in a version shortly.

<!-- gh-comment-id:62322706 --> @jfoug commented on GitHub (Nov 9, 2014): Anyhow, I will be checking in a version shortly.
Author
Owner

@jfoug commented on GitHub (Nov 9, 2014):

This is a first version: 38218fe

Here is a real simple test script, that ran it through its paces. I will need to also add some 'known' correct conversions, to make sure that things are correct.

$ cat tst

#!/bin/sh

MEM=123456789aBCDefGHJ


V1=`../run/base64conv -i raw -q -o hex $MEM 2> /dev/null`
V2=`../run/base64conv -i hex -q -o mime $V1 2> /dev/null`
V3=`../run/base64conv -i mime -q -o crypt $V2 2> /dev/null`
V4=`../run/base64conv -i crypt -q -o cryptBS $V3 2> /dev/null`
V5=`../run/base64conv -i cryptBS -q -o mime $V4 2> /dev/null`
V6=`../run/base64conv -i mime -q -o cryptBS $V5 2> /dev/null`
V7=`../run/base64conv -i cryptBS -q -o crypt $V6 2> /dev/null`
V8=`../run/base64conv -i crypt -q -o hex $V7 2> /dev/null`
V9=`../run/base64conv -i hex -q -o raw $V8 2> /dev/null`
echo $MEM  $V9
<!-- gh-comment-id:62322882 --> @jfoug commented on GitHub (Nov 9, 2014): This is a first version: 38218fe Here is a real simple test script, that ran it through its paces. I will need to also add some 'known' correct conversions, to make sure that things are correct. $ cat tst ``` #!/bin/sh MEM=123456789aBCDefGHJ V1=`../run/base64conv -i raw -q -o hex $MEM 2> /dev/null` V2=`../run/base64conv -i hex -q -o mime $V1 2> /dev/null` V3=`../run/base64conv -i mime -q -o crypt $V2 2> /dev/null` V4=`../run/base64conv -i crypt -q -o cryptBS $V3 2> /dev/null` V5=`../run/base64conv -i cryptBS -q -o mime $V4 2> /dev/null` V6=`../run/base64conv -i mime -q -o cryptBS $V5 2> /dev/null` V7=`../run/base64conv -i cryptBS -q -o crypt $V6 2> /dev/null` V8=`../run/base64conv -i crypt -q -o hex $V7 2> /dev/null` V9=`../run/base64conv -i hex -q -o raw $V8 2> /dev/null` echo $MEM $V9 ```
Author
Owner

@jfoug commented on GitHub (Nov 10, 2014):

I have a much more in depth test case, and have added overwrite detection logic into the base64conv program. I have it where I know every 'extra' byte.

The current code has zero overwrite for many of the conversions. BUT for some, there is 1 and for some length 2 bytes that get overwritten (past the 1 extra \0 byte). I have run test of all base64 to other base64 tests. The overwrites come from having to convert into raw, then into the final base-64 type. This conversion is only needed for endianty different base-64s. If they are the same byte order, I can simply do direct conversions from 1 to the other, replacing chars of the alphabets from the same offset.

This is mostly a query to @magnumripper. Is having to have +3 bytes longer than a flat string (with no null), to big of a thing to ask. Now that I have the base64conv program working, it may be that I can find better ways to convert from 1 encoding to another, than doing a full decode/encode pair. It may be that I can work my way through the buffer 4 characters at a time, and deal with the last 1,2,3 byte bundle by itself. But at this time, I am not there yet.

<!-- gh-comment-id:62461359 --> @jfoug commented on GitHub (Nov 10, 2014): I have a much more in depth test case, and have added overwrite detection logic into the base64conv program. I have it where I know every 'extra' byte. The current code has zero overwrite for many of the conversions. BUT for some, there is 1 and for some length 2 bytes that get overwritten (past the 1 extra \0 byte). I have run test of all base64 to other base64 tests. The overwrites come from having to convert into raw, then into the final base-64 type. This conversion is only needed for endianty different base-64s. If they are the same byte order, I can simply do direct conversions from 1 to the other, replacing chars of the alphabets from the same offset. This is mostly a query to @magnumripper. Is having to have +3 bytes longer than a flat string (with no null), to big of a thing to ask. Now that I have the base64conv program working, it may be that I can find better ways to convert from 1 encoding to another, than doing a full decode/encode pair. It may be that I can work my way through the buffer 4 characters at a time, and deal with the last 1,2,3 byte bundle by itself. But at this time, I am not there yet.
Author
Owner

@magnumripper commented on GitHub (Nov 10, 2014):

This is mostly a query to @magnumripper. Is having to have +3 bytes longer than a flat string (with no null), to big of a thing to ask.

As long as we know it, it's not much of an issue. The real problem is when we are simply not aware that we need to alloc one or a few extra bytes, like a week ago before 804754ca4 and c4574d02.

<!-- gh-comment-id:62473276 --> @magnumripper commented on GitHub (Nov 10, 2014): > This is mostly a query to @magnumripper. Is having to have +3 bytes longer than a flat string (with no null), to big of a thing to ask. As long as we know it, it's not much of an issue. The real problem is when we are simply not **aware** that we need to alloc one or a few extra bytes, like a week ago before 804754ca4 and c4574d02.
Author
Owner

@jfoug commented on GitHub (Nov 11, 2014):

Added update that reworks some buffer size stuff for conversions and also adds -e to check for overflow errors (1 and 2 byte are ignored, as was discussed)

7926b5c

I have used this to add ScryptKDF format to scrypt. Again, I simply did a conversion into original escryp\crypto_scrypt format. the ScryptKDF has salt in mime format (I had to convert to raw), and hash in mime format, I had to convert to cryptBS. But other than that, it was pretty trivial, and I will get it checked in, and issue #368 closed.

<!-- gh-comment-id:62516214 --> @jfoug commented on GitHub (Nov 11, 2014): Added update that reworks some buffer size stuff for conversions and also adds -e to check for overflow errors (1 and 2 byte are ignored, as was discussed) 7926b5c I have used this to add ScryptKDF format to scrypt. Again, I simply did a conversion into original escryp\crypto_scrypt format. the ScryptKDF has salt in mime format (I had to convert to raw), and hash in mime format, I had to convert to cryptBS. But other than that, it was pretty trivial, and I will get it checked in, and issue #368 closed.
Author
Owner

@jfoug commented on GitHub (Nov 12, 2014):

65c0417 Big improvements. Have a better test suite now, and almost all passes. What does not pass (2 items in one run of the mixer), I have not tracked down, but it should be trivial, I hope). I still have to add code to USE most of the flags, and add more flags.

New code uses no allocs for base64-base64 converts. All base64 converts now take 4 chars, convert them into 3 memory bytes, then take those 3 memory bytes and convert into the other base64 format. Very trivial until you get to the last limb (which will be 2, 3 or 4 valid base-64 characters). The code also handles input with padding properly (= or . padding). For the . padding it is harder. Sometimes, the first . character IS required. Currently, we ONLY output in non-padded format. If that extra '.' is supposed to be there, it will be. BUT padding out to even 4, has not been done yet. It is a flag, and I will get code to handle it, I have just not got it done yet.

<!-- gh-comment-id:62805356 --> @jfoug commented on GitHub (Nov 12, 2014): 65c0417 Big improvements. Have a better test suite now, and almost all passes. What does not pass (2 items in one run of the mixer), I have not tracked down, but it should be trivial, I hope). I still have to add code to USE most of the flags, and add more flags. New code uses no allocs for base64-base64 converts. All base64 converts now take 4 chars, convert them into 3 memory bytes, then take those 3 memory bytes and convert into the other base64 format. Very trivial until you get to the last limb (which will be 2, 3 or 4 valid base-64 characters). The code also handles input with padding properly (= or . padding). For the . padding it is harder. Sometimes, the first . character IS required. Currently, we ONLY output in non-padded format. If that extra '.' is supposed to be there, it will be. BUT padding out to even 4, has not been done yet. It is a flag, and I will get code to handle it, I have just not got it done yet.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

I can't even build it...

$ make -s 
In file included from /usr/include/stdio.h:492:0,
                 from scrypt_fmt.c:11:
scrypt_fmt.c: In function 'prepare':
scrypt_fmt.c:133:94: error: 'flg_Base64_NO_FLAGS' undeclared (first use in this function)
    base64_convert_cp(&(fields[1][3+14+1]), e_b64_crypt, 43, tmp, e_b64_cryptBS, sizeof(tmp), flg_Base64_NO_FLAGS));
                                                                                              ^
scrypt_fmt.c:133:94: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [scrypt_fmt.o] Error 1
make: *** [default] Error 2

Neither can the bots: https://travis-ci.org/magnumripper/JohnTheRipper/builds/40827333

<!-- gh-comment-id:62806352 --> @magnumripper commented on GitHub (Nov 12, 2014): I can't even build it... ``` $ make -s In file included from /usr/include/stdio.h:492:0, from scrypt_fmt.c:11: scrypt_fmt.c: In function 'prepare': scrypt_fmt.c:133:94: error: 'flg_Base64_NO_FLAGS' undeclared (first use in this function) base64_convert_cp(&(fields[1][3+14+1]), e_b64_crypt, 43, tmp, e_b64_cryptBS, sizeof(tmp), flg_Base64_NO_FLAGS)); ^ scrypt_fmt.c:133:94: note: each undeclared identifier is reported only once for each function it appears in make[1]: *** [scrypt_fmt.o] Error 1 make: *** [default] Error 2 ``` Neither can the bots: https://travis-ci.org/magnumripper/JohnTheRipper/builds/40827333
Author
Owner

@jfoug commented on GitHub (Nov 12, 2014):

Try now, sorry.

<!-- gh-comment-id:62806660 --> @jfoug commented on GitHub (Nov 12, 2014): Try now, sorry.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

Using ab93c6f8

$ make -sj8
In file included from /usr/include/stdio.h:492:0,
                 from misc.h:20,
                 from opencl_pbkdf2_hmac_sha256_fmt_plug.c:18:
opencl_pbkdf2_hmac_sha256_fmt_plug.c: In function 'prepare':
opencl_pbkdf2_hmac_sha256_fmt_plug.c:270:3: error: too few arguments to function 'base64_convert_cp'
   base64_convert_cp(&(fields[1][3+14+1]), e_b64_crypt, 43, tmp, e_b64_mime, sizeof(tmp)));
   ^
In file included from opencl_pbkdf2_hmac_sha256_fmt_plug.c:20:0:
base64_convert.h:42:7: note: declared here
 char *base64_convert_cp(const void *from, b64_convert_type from_t, int from_len, void *to, b64_convert_type to_t, int to_len, unsigned flags);
       ^
opencl_pbkdf2_hmac_sha256_fmt_plug.c: In function 'abase64_decode':
opencl_pbkdf2_hmac_sha256_fmt_plug.c:344:2: error: too few arguments to function 'base64_convert'
  base64_convert(hash, e_b64_mime, length, out, e_b64_raw, outlen);
  ^
In file included from opencl_pbkdf2_hmac_sha256_fmt_plug.c:20:0:
base64_convert.h:41:5: note: declared here
 int base64_convert(const void *from, b64_convert_type from_t, int from_len, void *to, b64_convert_type to_t, int to_len, unsigned flags);
     ^
make[1]: *** [opencl_pbkdf2_hmac_sha256_fmt_plug.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [default] Error 2
<!-- gh-comment-id:62806801 --> @magnumripper commented on GitHub (Nov 12, 2014): Using ab93c6f8 ``` $ make -sj8 In file included from /usr/include/stdio.h:492:0, from misc.h:20, from opencl_pbkdf2_hmac_sha256_fmt_plug.c:18: opencl_pbkdf2_hmac_sha256_fmt_plug.c: In function 'prepare': opencl_pbkdf2_hmac_sha256_fmt_plug.c:270:3: error: too few arguments to function 'base64_convert_cp' base64_convert_cp(&(fields[1][3+14+1]), e_b64_crypt, 43, tmp, e_b64_mime, sizeof(tmp))); ^ In file included from opencl_pbkdf2_hmac_sha256_fmt_plug.c:20:0: base64_convert.h:42:7: note: declared here char *base64_convert_cp(const void *from, b64_convert_type from_t, int from_len, void *to, b64_convert_type to_t, int to_len, unsigned flags); ^ opencl_pbkdf2_hmac_sha256_fmt_plug.c: In function 'abase64_decode': opencl_pbkdf2_hmac_sha256_fmt_plug.c:344:2: error: too few arguments to function 'base64_convert' base64_convert(hash, e_b64_mime, length, out, e_b64_raw, outlen); ^ In file included from opencl_pbkdf2_hmac_sha256_fmt_plug.c:20:0: base64_convert.h:41:5: note: declared here int base64_convert(const void *from, b64_convert_type from_t, int from_len, void *to, b64_convert_type to_t, int to_len, unsigned flags); ^ make[1]: *** [opencl_pbkdf2_hmac_sha256_fmt_plug.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [default] Error 2 ```
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

I fixed OpenCL for you some day ago. You need to have them in mind even if you don't build them yourself. As soon as you change a function jtr_foo(), try git grep -l jtr_foo and you'll see a list of all files affected.

<!-- gh-comment-id:62807046 --> @magnumripper commented on GitHub (Nov 12, 2014): I fixed OpenCL for you some day ago. You need to have them in mind even if you don't build them yourself. As soon as you change a function jtr_foo(), try `git grep -l jtr_foo` and you'll see a list of all files affected.
Author
Owner

@jfoug commented on GitHub (Nov 12, 2014):

I am building now.

<!-- gh-comment-id:62807276 --> @jfoug commented on GitHub (Nov 12, 2014): I am building now.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

Actually it seems to be this easy this time:

$ git show 65c0417c pbkdf2_hmac_sha256_fmt_plug.c | patch opencl_pbkdf2_hmac_sha256_fmt_plug.c
patching file opencl_pbkdf2_hmac_sha256_fmt_plug.c
Hunk #1 succeeded at 267 (offset 111 lines).
Hunk #2 succeeded at 341 with fuzz 1 (offset 112 lines).

But I'll let you commit it so we don't clash mid air.

<!-- gh-comment-id:62807756 --> @magnumripper commented on GitHub (Nov 12, 2014): Actually it seems to be this easy this time: ``` $ git show 65c0417c pbkdf2_hmac_sha256_fmt_plug.c | patch opencl_pbkdf2_hmac_sha256_fmt_plug.c patching file opencl_pbkdf2_hmac_sha256_fmt_plug.c Hunk #1 succeeded at 267 (offset 111 lines). Hunk #2 succeeded at 341 with fuzz 1 (offset 112 lines). ``` But I'll let you commit it so we don't clash mid air.
Author
Owner

@jfoug commented on GitHub (Nov 12, 2014):

already fixed, no need for an unsure patch.

<!-- gh-comment-id:62808132 --> @jfoug commented on GitHub (Nov 12, 2014): already fixed, no need for an unsure patch.
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2014):

All fine now, including --test=0

<!-- gh-comment-id:62808589 --> @magnumripper commented on GitHub (Nov 12, 2014): All fine now, including --test=0
Author
Owner

@jfoug commented on GitHub (Nov 12, 2014):

I got a Travis all - OK for build 1841, even though openCL had errors. I see Travis does not build opencl. I will have to keep that in mind also. Build 1842 is correct for CPU and GPU

<!-- gh-comment-id:62809030 --> @jfoug commented on GitHub (Nov 12, 2014): I got a Travis all - OK for build 1841, even though openCL had errors. I see Travis does not build opencl. I will have to keep that in mind also. Build 1842 is correct for CPU and GPU
Author
Owner

@jfoug commented on GitHub (Nov 13, 2014):

3211c44 This patch passes my entire test suite (include here). Also there are no memory allocations required any more. All conversions are done in place, with minimal temp memory used.

Now, I need to handle the flags, AND get this tied into other areas were we do base-64 stuff in john (and possibly hex stuff also), and remove TONS of custom code. The only issue would be if there are speed differences. If so, then all I need to do is optimize this 'common' code some.

Here is my test script

#!/bin/bash

T=yes

# simple test cycling through the types.  $MEM and $9 should be same in the end
MEM=123456789aBCDefGHJ
V1=`../run/base64conv -i raw -q -e -o hex $MEM`
V2=`../run/base64conv -i hex -q -e -o mime $V1`
V3=`../run/base64conv -i mime -q -e -o crypt $V2`
V4=`../run/base64conv -i crypt -q -e -o cryptBS $V3`
V5=`../run/base64conv -i cryptBS -q -e -o mime $V4`
V6=`../run/base64conv -i mime -q -e -o cryptBS $V5`
V7=`../run/base64conv -i cryptBS -q -e -o crypt $V6`
V8=`../run/base64conv -i crypt -q -e -o hex $V7`
V9=`../run/base64conv -i hex -q -e -o raw $V8`
if [ x$MEM != x$V9 ];
then
    echo "Simple test failed.  '$MEM' not same as '$9'"
    echo "MEM='$MEM'"
    echo "V1 ='$V1'"
    echo "V2 ='$V2'"
    echo "V3 ='$V3'"
    echo "V4 ='$V4'"
    echo "V5 ='$V5'"
    echo "V6 ='$V6'"
    echo "V7 ='$V7'"
    echo "V8 ='$V8'"
    echo "V9 ='$V9'"
else
    echo "Simple test success"
fi


#####################################################
#  Known text checks  (data made with perl script)
#####################################################

function known {
    kC=$4
    kM=$3
    kB=$2
    B=`../run/base64conv -i raw -q -e -o cryptBS $1`
    C=`../run/base64conv -i raw -q -e -o crypt $1`
    M=`../run/base64conv -i raw -q -e -o mime $1`
    T=yes
    if [ x$B != x$kB ];
    then
        echo "Known test failed (cryptBS). '$1' should be '$kB' not '$B'"
        T=no
    fi
    if [ x$M != x$kM ];
    then
        echo "Known test failed (mime). '$1' should be '$kM' not '$M'"
        T=no
    fi
    if [ x$C != x$kC ];
    then
        echo "Known test failed (crypt). '$1' should be '$kC' not '$C'"
        T=no
    fi
    C2=`../run/base64conv -i cryptBS -q -e -o crypt $B`
    M2=`../run/base64conv -i cryptBS -q -e -o mime $B`
    if [ x$M2 != x$kM ];
    then
        echo "Known test failed (cryptBS->mime). '$1' should be '$kM' not '$M2'"
        T=no
    fi
    if [ x$C2 != x$kC ];
    then
        echo "Known test failed (cryptBS->crypt). '$1' should be '$kC' not '$C2'"
        T=no
    fi
    B2=`../run/base64conv -i crypt -q -e -o cryptBS $C`
    M2=`../run/base64conv -i crypt -q -e -o mime $C`
    if [ x$M2 != x$kM ];
    then
        echo "Known test failed (crypt->mime). '$1' should be '$kM' not '$M2'"
        T=no
    fi
    if [ x$B2 != x$kB ];
    then
        echo "Known test failed (crypt->cryptBS). '$1' should be '$kB' not '$B2'"
        T=no
    fi
    B2=`../run/base64conv -i mime -q -e -o cryptBS $M`
    C2=`../run/base64conv -i mime -q -e -o crypt $M`
    if [ x$C2 != x$kC ];
    then
        echo "Known test failed (mime->crypt). '$1' should be '$kC' not '$C2'"
        T=no
    fi
    if [ x$B2 != x$kB ];
    then
        echo "Known test failed (mime->cryptBS). '$1' should be '$kB' not '$B2'"
        T=no
    fi
    if [ x$T = "xyes" ];
    then
        echo "Success known test param = $1"
    else
        echo "Failure known test param = $1"
    fi
}

known abcdefghijklmnopqrstuvwxyz12345 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1Bp. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NQ MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBE
known abcdefghijklmnopqrstuvwxyz123456 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpM1 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHM
known abcdefghijklmnopqrstuvwxyz1234567 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnB YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3 MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMr
known abcdefghijklmnopqrstuvwxyz12345678 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBs. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3OA MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC.

known abcdefghijklmnopqrstuvwxyz123456789 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODk MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1Y
known abcdefghijklmnopqrstuvwxyz1234567890 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1A YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkw MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1Yk
known abcdefghijklmnopqrstuvwxyz12345678901 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMQ MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAE
known abcdefghijklmnopqrstuvwxyz123456789012 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al61 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTI MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6

known abcdefghijklmnopqrstuvwxyz1234567890123 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nA YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIz MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6n
known abcdefghijklmnopqrstuvwxyz12345678901234 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nAo. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIzNA MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6nB.
known abcdefghijklmnopqrstuvwxyz123456789012345 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nAoI1 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIzNDU MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6nB1I
known abcdefghijklmnopqrstuvwxyz1234567890123456 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nAoIXB YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIzNDU2 MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6nB1Iq

#########################################
# Conversion from all formats
# to others tests, for many
# lengths.
#########################################

function comp {
    if [ x$1 != x$2 ];
    then
        echo "$3: '$1' is not equal to '$2'"
        T=no
    fi
}

function tst {
    T=yes
    B=`../run/base64conv -i raw -q -e -o cryptBS $1`
    C=`../run/base64conv -i raw -q -e -o crypt $1`
    M=`../run/base64conv -i raw -q -e -o mime $1`

    R=`../run/base64conv -i crypt -q -e -o cryptBS $C`
    R=`../run/base64conv -i cryptBS -q -e -o raw $R`
    comp x$1 x$R "crypt_cryptBS (1)"

    R=`../run/base64conv -i mime -q -e -o cryptBS $M`
    R=`../run/base64conv -i cryptBS -q -e -o raw $R`
    comp x$1 x$R "mime_cryptBS (2)"

    R=`../run/base64conv -i cryptBS -q -e -o crypt $B`
    R=`../run/base64conv -i crypt -q -e -o raw $R`
    comp x$1 x$R "cryptBS_crypt (3)"

    R=`../run/base64conv -i mime -q -e -o crypt $M`
    R=`../run/base64conv -i crypt -q -e -o raw $R`
    comp x$1 x$R "mime_crypt (4)"

    R=`../run/base64conv -i cryptBS -q -e -o mime $B`
    R=`../run/base64conv -i mime -q -e -o raw $R`
    comp a$1 a$R "cryptBS_mime (5)"

    R=`../run/base64conv -i crypt -q -e -o mime $C`
    R=`../run/base64conv -i mime -q -e -o raw $R`
    comp b$1 b$R "crypt_mime (6)"

    if [ x$T = "xyes" ];
    then
        echo "Success multi-convert test param = $1"
    else
        echo "Failure multi-convert test param = $1"
    fi
}

P=fadsgragabsrgahseeEDTa
tst $P
P=fadsgragabsrgahseeEDTa0
tst $P
P=fadsgragabsrgahseeEDTa0~
tst $P
P=fadsgragabsrgahseeEDTa0~~
tst $P
P=fadsgragabsrgahseeEDTa06x~
tst $P
P=xyhadhWaeFgAcwbsex03dz
tst $P
P=xyhadhWaeFgAcwbsex03dzZ
tst $P
P=xyhadhWaeFgAcwbsex03dzZ~
tst $P
P=xyhadhWaeFgAcwbsex03dzZ~~
tst $P
P=xyhadhWaeFgAcwbsex03dzZ~Z!
tst $P
#############################  Total random data (79 character working set)
P=PoQC,jTymI=GAPzLqs#B1@T-
tst $P
P=kbHAP_E3YWQk0/DhFj,zwO_,y
tst $P
P=p#OzRPQmEbgA!s:@dZ9nY@0dM,
tst $P
P=VGS%nUC0!@.#n3vOEDylfwA-}Rm
tst $P
P=zn}O=GYzi=LmXREZ,yYGuMNCcmZd
tst $P
P=QC*9P*myY5bAmebFK!TU4GQcZBUTA
tst $P
P=}mbfdKKG4cAxiDFfOLmO0kV{6Hg:nB
tst $P
P=~AaQZgLQ2Gxw11V_^KMVsi1pz0eR=m{
tst $P
P=V#@*jGWk=hq_p~h7B%JpDa%y
tst $P
P=uKHo,ipa7zpAeP4^/3oslwrrQ
tst $P
P=g%Fz_MN,0z~{/WJdp5BYhfH_L5
tst $P
P=,60L4e?Q=sNgBjRMI7Msec~mmf=
tst $P
P=8yQDJ4TpZJS0EgUCisBHtLO?k:LU
tst $P
P=rn-p5!JD4FyS-e41C=B:G__SMt!7z
tst $P
P=LvCRbk9bv1EuOn0PeX7AioktY2Lo2f
tst $P
P=.UusOL3m-m?rJC,a73od--KHUFpFLV5
tst $P
P=U3CrvW7Sey!YVF8_}c5dv8,3
tst $P
P=vc#uqCCyQHG_H@iXYI!1Ekbew
tst $P
P=/AVO!,lcQDX=u}PaOU7iaWAyW}
tst $P
P=H7BX8}iLz95AETxC@MDO@l@lS^6
tst $P
P=F15off04-HvYwrpat#9}vhd6umLv
tst $P
P=vWwUr6WBw0eRq@hW~RAUwyu%AR/l2
tst $P
P=8{NI-Kf9Kz0A=Xsx1SDYc?yMG2@fyr
tst $P
P=a^Tbt51QvhiTK2#2S-!z7cP*dRNPB6A
tst $P
P=C.?OkU=62rb8ZW6DS8D5S6!G
tst $P
P=xe0_mbgdqClK1MDK4zdSo-zyH
tst $P
P=3=4xxAcCUJd:m0/DsO%bTeE^An
tst $P
P=7qu*9pIvL~x@BmKxry?kwNn%*?W
tst $P
P=ANnvk@?EkSOR-=^}GdYrmpl6DtTg
tst $P
P=w7gak0XC9sVsX7qf~_Dph,A0v2B99
tst $P
P=~{0zP7#1MgxbU8u^u?B1bZD#8TFg~{
tst $P
P=w:~oS_!pBqlhVC@4z5Uj04}r?8u*wo%
tst $P
P=?bNfxfP5Oogw85@cB4,5dt5Q
tst $P
P=9Dk:Vmw#*}Okprf2sLTtg1N89
tst $P
P=WD2K}e*dzm0i-84,}Ff2la}oeY
tst $P
P=RY:Zv:tNzY~6WcYO/6}jjm~.Rj}
tst $P
P=rW~GRuv_3W}Ro5YBym3QRx@g}ad?
tst $P
P=./e6/T%KpX.@xE{/UUESK4fHnF~NH
tst $P
P=a{P,r!tHVgeH=}-*-Lr9KQsFX6040u
tst $P
P=S7iyHD5d/?65xM6cSJ@malnCBgwJ%OB
tst $P
P=onKq6-4-TjJzE8A^r5C31W/n
tst $P
P=BvNYgH/:UO/*xHbVnTk}=/VQI
tst $P
P=h1phkGu~i_DManJj{R{i}B8t2J
tst $P
P=!JTaAdEh5J,CGGj5o6Rq*T?%S/C
tst $P
P=TjNcj6BKTp8dn^^PJy,pqUAarE-{
tst $P
P=nTV.f_*1~Fu5TbE2c#%eTa*rtP?hd
tst $P
P=rGxH6d2-il/EDhkoGg5Hu8Dt2Ag%{,
tst $P
P=g2x2pm@VwIe3gsS}j7oS^!2Gt89n:j!
tst $P
P=VfxMYgm1Fj4amecMxwG7aGZJ
tst $P
P=Bq%*3t_WQK-L!wjO0DHhB1zur
tst $P
P=x-%EfHz7K5gXMxoUfB5fy#rwJD
tst $P
P=@i3Ud53sWo5O}fbo5a/@tVSPiEO
tst $P
P=t=/j?jDh/w={,YKg5mI@lywrf#QT
tst $P
P=7,s~tDgk?lB5lxl6!pq5Xu/@s:RHE
tst $P
P=?vi2zpI3Tskh_D%6{3lX2gKpvlIWjN
tst $P
P=?zdcv4K:0G-a,vgn?oeI4YwoW%Aua68
tst $P
P=MA1=Zk,sax%SfX8Zsmctl{tA
tst $P
P=}RvIWwBMNWCG8sKy7:e{%0gph
tst $P
P=Yqvylp6J8VJiDIjD3}e}YIkhgj
tst $P
P=Je-.F7,uCyE.dOQ?EFXZlsGJ^An
tst $P
P=:80=Axv}Te,D%Jbm?kBYj0N!*^G:
tst $P
P=pk-AsxOFR6PjIf?5~@tTK2O*F0*jl
tst $P
P=YxafCV0Y6~hf*NejEIO}d_Y@YeO%#m
tst $P
P=?1FM^6Al=2j:A:rqXtj3Y/}F?4dc1op
tst $P
P=tCt6Zp1AU7lg3Odr/,FyK%6N
tst $P
P=qXcXV5l,WxyzL07gAD3ErWt8M
tst $P
P=N^US17db.UPyCFytM@Zi61Jw7H
tst $P
P=T7V=j_isiXTLhlcEFUvMD*a3Y38
tst $P
P=vYSTO~MTgv_858XO@@4wgxVZyxiZ
tst $P
P=n*Qf{DaPAn%9pPAn-O0}8D{wybx=H
tst $P
P=.4UB2waQQid#y20WEj{Pq-MC1-~Mf^
tst $P
P=9*,bFT@ZR%,NC9/L8L_0sDx#8dNzCPK
tst $P
P=:77Ewp}pAbvvgR@%PeP1QYd^
tst $P
P=_zvLTkP0_{ZscGIou:KM8LAM8
tst $P
P=h:UbNTGHm%D6ir~zvqL4us_X1d
tst $P
P=.UXe%~K3Qtizdj80*nc#Hj%C=to
tst $P
P=I!CRw1V:mN0L@^D0O?aMN%DBk?f-
tst $P
P=BmxKQkHMIt2j:C=?hUP.ZIRiyA7f{
tst $P
P={Sa,u/{d=.rWKc3{8ygV!cyIVA*=3H
tst $P
P=c5LZJcSu8HhpH%7=BdEIo}2#iMS4fwS
tst $P
<!-- gh-comment-id:62938894 --> @jfoug commented on GitHub (Nov 13, 2014): 3211c44 This patch passes my entire test suite (include here). Also there are no memory allocations required any more. All conversions are done in place, with minimal temp memory used. Now, I need to handle the flags, AND get this tied into other areas were we do base-64 stuff in john (and possibly hex stuff also), and remove TONS of custom code. The only issue would be if there are speed differences. If so, then all I need to do is optimize this 'common' code some. Here is my test script ``` SH #!/bin/bash T=yes # simple test cycling through the types. $MEM and $9 should be same in the end MEM=123456789aBCDefGHJ V1=`../run/base64conv -i raw -q -e -o hex $MEM` V2=`../run/base64conv -i hex -q -e -o mime $V1` V3=`../run/base64conv -i mime -q -e -o crypt $V2` V4=`../run/base64conv -i crypt -q -e -o cryptBS $V3` V5=`../run/base64conv -i cryptBS -q -e -o mime $V4` V6=`../run/base64conv -i mime -q -e -o cryptBS $V5` V7=`../run/base64conv -i cryptBS -q -e -o crypt $V6` V8=`../run/base64conv -i crypt -q -e -o hex $V7` V9=`../run/base64conv -i hex -q -e -o raw $V8` if [ x$MEM != x$V9 ]; then echo "Simple test failed. '$MEM' not same as '$9'" echo "MEM='$MEM'" echo "V1 ='$V1'" echo "V2 ='$V2'" echo "V3 ='$V3'" echo "V4 ='$V4'" echo "V5 ='$V5'" echo "V6 ='$V6'" echo "V7 ='$V7'" echo "V8 ='$V8'" echo "V9 ='$V9'" else echo "Simple test success" fi ##################################################### # Known text checks (data made with perl script) ##################################################### function known { kC=$4 kM=$3 kB=$2 B=`../run/base64conv -i raw -q -e -o cryptBS $1` C=`../run/base64conv -i raw -q -e -o crypt $1` M=`../run/base64conv -i raw -q -e -o mime $1` T=yes if [ x$B != x$kB ]; then echo "Known test failed (cryptBS). '$1' should be '$kB' not '$B'" T=no fi if [ x$M != x$kM ]; then echo "Known test failed (mime). '$1' should be '$kM' not '$M'" T=no fi if [ x$C != x$kC ]; then echo "Known test failed (crypt). '$1' should be '$kC' not '$C'" T=no fi C2=`../run/base64conv -i cryptBS -q -e -o crypt $B` M2=`../run/base64conv -i cryptBS -q -e -o mime $B` if [ x$M2 != x$kM ]; then echo "Known test failed (cryptBS->mime). '$1' should be '$kM' not '$M2'" T=no fi if [ x$C2 != x$kC ]; then echo "Known test failed (cryptBS->crypt). '$1' should be '$kC' not '$C2'" T=no fi B2=`../run/base64conv -i crypt -q -e -o cryptBS $C` M2=`../run/base64conv -i crypt -q -e -o mime $C` if [ x$M2 != x$kM ]; then echo "Known test failed (crypt->mime). '$1' should be '$kM' not '$M2'" T=no fi if [ x$B2 != x$kB ]; then echo "Known test failed (crypt->cryptBS). '$1' should be '$kB' not '$B2'" T=no fi B2=`../run/base64conv -i mime -q -e -o cryptBS $M` C2=`../run/base64conv -i mime -q -e -o crypt $M` if [ x$C2 != x$kC ]; then echo "Known test failed (mime->crypt). '$1' should be '$kC' not '$C2'" T=no fi if [ x$B2 != x$kB ]; then echo "Known test failed (mime->cryptBS). '$1' should be '$kB' not '$B2'" T=no fi if [ x$T = "xyes" ]; then echo "Success known test param = $1" else echo "Failure known test param = $1" fi } known abcdefghijklmnopqrstuvwxyz12345 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1Bp. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NQ MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBE known abcdefghijklmnopqrstuvwxyz123456 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpM1 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHM known abcdefghijklmnopqrstuvwxyz1234567 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnB YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3 MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMr known abcdefghijklmnopqrstuvwxyz12345678 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBs. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3OA MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC. known abcdefghijklmnopqrstuvwxyz123456789 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODk MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1Y known abcdefghijklmnopqrstuvwxyz1234567890 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1A YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkw MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1Yk known abcdefghijklmnopqrstuvwxyz12345678901 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMQ MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAE known abcdefghijklmnopqrstuvwxyz123456789012 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al61 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTI MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6 known abcdefghijklmnopqrstuvwxyz1234567890123 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nA YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIz MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6n known abcdefghijklmnopqrstuvwxyz12345678901234 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nAo. YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIzNA MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6nB. known abcdefghijklmnopqrstuvwxyz123456789012345 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nAoI1 YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIzNDU MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6nB1I known abcdefghijklmnopqrstuvwxyz1234567890123456 V7qMYJaNbVKOeh4PhtqPk3bQnFLRqR5StdLAmA1BpMnBsY1Al6nAoIXB YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwMTIzNDU2 MK7XN4JaNqVdOahgPKtjQ53mQrFpRbRsSLclAXAoBHMrC1YkAH6nB1Iq ######################################### # Conversion from all formats # to others tests, for many # lengths. ######################################### function comp { if [ x$1 != x$2 ]; then echo "$3: '$1' is not equal to '$2'" T=no fi } function tst { T=yes B=`../run/base64conv -i raw -q -e -o cryptBS $1` C=`../run/base64conv -i raw -q -e -o crypt $1` M=`../run/base64conv -i raw -q -e -o mime $1` R=`../run/base64conv -i crypt -q -e -o cryptBS $C` R=`../run/base64conv -i cryptBS -q -e -o raw $R` comp x$1 x$R "crypt_cryptBS (1)" R=`../run/base64conv -i mime -q -e -o cryptBS $M` R=`../run/base64conv -i cryptBS -q -e -o raw $R` comp x$1 x$R "mime_cryptBS (2)" R=`../run/base64conv -i cryptBS -q -e -o crypt $B` R=`../run/base64conv -i crypt -q -e -o raw $R` comp x$1 x$R "cryptBS_crypt (3)" R=`../run/base64conv -i mime -q -e -o crypt $M` R=`../run/base64conv -i crypt -q -e -o raw $R` comp x$1 x$R "mime_crypt (4)" R=`../run/base64conv -i cryptBS -q -e -o mime $B` R=`../run/base64conv -i mime -q -e -o raw $R` comp a$1 a$R "cryptBS_mime (5)" R=`../run/base64conv -i crypt -q -e -o mime $C` R=`../run/base64conv -i mime -q -e -o raw $R` comp b$1 b$R "crypt_mime (6)" if [ x$T = "xyes" ]; then echo "Success multi-convert test param = $1" else echo "Failure multi-convert test param = $1" fi } P=fadsgragabsrgahseeEDTa tst $P P=fadsgragabsrgahseeEDTa0 tst $P P=fadsgragabsrgahseeEDTa0~ tst $P P=fadsgragabsrgahseeEDTa0~~ tst $P P=fadsgragabsrgahseeEDTa06x~ tst $P P=xyhadhWaeFgAcwbsex03dz tst $P P=xyhadhWaeFgAcwbsex03dzZ tst $P P=xyhadhWaeFgAcwbsex03dzZ~ tst $P P=xyhadhWaeFgAcwbsex03dzZ~~ tst $P P=xyhadhWaeFgAcwbsex03dzZ~Z! tst $P ############################# Total random data (79 character working set) P=PoQC,jTymI=GAPzLqs#B1@T- tst $P P=kbHAP_E3YWQk0/DhFj,zwO_,y tst $P P=p#OzRPQmEbgA!s:@dZ9nY@0dM, tst $P P=VGS%nUC0!@.#n3vOEDylfwA-}Rm tst $P P=zn}O=GYzi=LmXREZ,yYGuMNCcmZd tst $P P=QC*9P*myY5bAmebFK!TU4GQcZBUTA tst $P P=}mbfdKKG4cAxiDFfOLmO0kV{6Hg:nB tst $P P=~AaQZgLQ2Gxw11V_^KMVsi1pz0eR=m{ tst $P P=V#@*jGWk=hq_p~h7B%JpDa%y tst $P P=uKHo,ipa7zpAeP4^/3oslwrrQ tst $P P=g%Fz_MN,0z~{/WJdp5BYhfH_L5 tst $P P=,60L4e?Q=sNgBjRMI7Msec~mmf= tst $P P=8yQDJ4TpZJS0EgUCisBHtLO?k:LU tst $P P=rn-p5!JD4FyS-e41C=B:G__SMt!7z tst $P P=LvCRbk9bv1EuOn0PeX7AioktY2Lo2f tst $P P=.UusOL3m-m?rJC,a73od--KHUFpFLV5 tst $P P=U3CrvW7Sey!YVF8_}c5dv8,3 tst $P P=vc#uqCCyQHG_H@iXYI!1Ekbew tst $P P=/AVO!,lcQDX=u}PaOU7iaWAyW} tst $P P=H7BX8}iLz95AETxC@MDO@l@lS^6 tst $P P=F15off04-HvYwrpat#9}vhd6umLv tst $P P=vWwUr6WBw0eRq@hW~RAUwyu%AR/l2 tst $P P=8{NI-Kf9Kz0A=Xsx1SDYc?yMG2@fyr tst $P P=a^Tbt51QvhiTK2#2S-!z7cP*dRNPB6A tst $P P=C.?OkU=62rb8ZW6DS8D5S6!G tst $P P=xe0_mbgdqClK1MDK4zdSo-zyH tst $P P=3=4xxAcCUJd:m0/DsO%bTeE^An tst $P P=7qu*9pIvL~x@BmKxry?kwNn%*?W tst $P P=ANnvk@?EkSOR-=^}GdYrmpl6DtTg tst $P P=w7gak0XC9sVsX7qf~_Dph,A0v2B99 tst $P P=~{0zP7#1MgxbU8u^u?B1bZD#8TFg~{ tst $P P=w:~oS_!pBqlhVC@4z5Uj04}r?8u*wo% tst $P P=?bNfxfP5Oogw85@cB4,5dt5Q tst $P P=9Dk:Vmw#*}Okprf2sLTtg1N89 tst $P P=WD2K}e*dzm0i-84,}Ff2la}oeY tst $P P=RY:Zv:tNzY~6WcYO/6}jjm~.Rj} tst $P P=rW~GRuv_3W}Ro5YBym3QRx@g}ad? tst $P P=./e6/T%KpX.@xE{/UUESK4fHnF~NH tst $P P=a{P,r!tHVgeH=}-*-Lr9KQsFX6040u tst $P P=S7iyHD5d/?65xM6cSJ@malnCBgwJ%OB tst $P P=onKq6-4-TjJzE8A^r5C31W/n tst $P P=BvNYgH/:UO/*xHbVnTk}=/VQI tst $P P=h1phkGu~i_DManJj{R{i}B8t2J tst $P P=!JTaAdEh5J,CGGj5o6Rq*T?%S/C tst $P P=TjNcj6BKTp8dn^^PJy,pqUAarE-{ tst $P P=nTV.f_*1~Fu5TbE2c#%eTa*rtP?hd tst $P P=rGxH6d2-il/EDhkoGg5Hu8Dt2Ag%{, tst $P P=g2x2pm@VwIe3gsS}j7oS^!2Gt89n:j! tst $P P=VfxMYgm1Fj4amecMxwG7aGZJ tst $P P=Bq%*3t_WQK-L!wjO0DHhB1zur tst $P P=x-%EfHz7K5gXMxoUfB5fy#rwJD tst $P P=@i3Ud53sWo5O}fbo5a/@tVSPiEO tst $P P=t=/j?jDh/w={,YKg5mI@lywrf#QT tst $P P=7,s~tDgk?lB5lxl6!pq5Xu/@s:RHE tst $P P=?vi2zpI3Tskh_D%6{3lX2gKpvlIWjN tst $P P=?zdcv4K:0G-a,vgn?oeI4YwoW%Aua68 tst $P P=MA1=Zk,sax%SfX8Zsmctl{tA tst $P P=}RvIWwBMNWCG8sKy7:e{%0gph tst $P P=Yqvylp6J8VJiDIjD3}e}YIkhgj tst $P P=Je-.F7,uCyE.dOQ?EFXZlsGJ^An tst $P P=:80=Axv}Te,D%Jbm?kBYj0N!*^G: tst $P P=pk-AsxOFR6PjIf?5~@tTK2O*F0*jl tst $P P=YxafCV0Y6~hf*NejEIO}d_Y@YeO%#m tst $P P=?1FM^6Al=2j:A:rqXtj3Y/}F?4dc1op tst $P P=tCt6Zp1AU7lg3Odr/,FyK%6N tst $P P=qXcXV5l,WxyzL07gAD3ErWt8M tst $P P=N^US17db.UPyCFytM@Zi61Jw7H tst $P P=T7V=j_isiXTLhlcEFUvMD*a3Y38 tst $P P=vYSTO~MTgv_858XO@@4wgxVZyxiZ tst $P P=n*Qf{DaPAn%9pPAn-O0}8D{wybx=H tst $P P=.4UB2waQQid#y20WEj{Pq-MC1-~Mf^ tst $P P=9*,bFT@ZR%,NC9/L8L_0sDx#8dNzCPK tst $P P=:77Ewp}pAbvvgR@%PeP1QYd^ tst $P P=_zvLTkP0_{ZscGIou:KM8LAM8 tst $P P=h:UbNTGHm%D6ir~zvqL4us_X1d tst $P P=.UXe%~K3Qtizdj80*nc#Hj%C=to tst $P P=I!CRw1V:mN0L@^D0O?aMN%DBk?f- tst $P P=BmxKQkHMIt2j:C=?hUP.ZIRiyA7f{ tst $P P={Sa,u/{d=.rWKc3{8ygV!cyIVA*=3H tst $P P=c5LZJcSu8HhpH%7=BdEIo}2#iMS4fwS tst $P ```
Author
Owner

@jfoug commented on GitHub (Nov 13, 2014):

I am going to make a post on john_users listing this change. The base64conv tool in of itself if useful enough for a post.

<!-- gh-comment-id:62939505 --> @jfoug commented on GitHub (Nov 13, 2014): I am going to make a post on john_users listing this change. The base64conv tool in of itself if useful enough for a post.
Author
Owner

@jfoug commented on GitHub (Nov 13, 2014):

I am adding this function (and also thinking about possible rename of these functions)

int base64_valid_length(const char *from, b64_convert_type from_t, unsigned flags);

This would return the number of bytes that were valid for this from_t type. NOTE, e_b64_raw type would not be a valid type to get length, it would have to be one of the encodings. But there are MANY MANY formats that have this as custom code in their valid formats. Simple common functions like this could save a lot of coding.

This would return the length of valid characters passed in

<!-- gh-comment-id:62967043 --> @jfoug commented on GitHub (Nov 13, 2014): I am adding this function (and also thinking about possible rename of these functions) int base64_valid_length(const char *from, b64_convert_type from_t, unsigned flags); This would return the number of bytes that were valid for this from_t type. NOTE, e_b64_raw type would not be a valid type to get length, it would have to be one of the encodings. But there are MANY MANY formats that have this as custom code in their valid formats. Simple common functions like this could save a lot of coding. This would return the length of valid characters passed in
Author
Owner

@jfoug commented on GitHub (Nov 18, 2014):

8029a11 Starts getting other flags working. I did see a bug and will have to work on it. (mime2crypt where mime has trailing == chars)

<!-- gh-comment-id:63493909 --> @jfoug commented on GitHub (Nov 18, 2014): 8029a11 Starts getting other flags working. I did see a bug and will have to work on it. (mime2crypt where mime has trailing == chars)
Author
Owner

@jfoug commented on GitHub (Nov 20, 2014):

e52d74c mime2hex length bugs, and added a new mime alphabet (ends with -_ vs +/)

<!-- gh-comment-id:63800535 --> @jfoug commented on GitHub (Nov 20, 2014): e52d74c mime2hex length bugs, and added a new mime alphabet (ends with -_ vs +/)
Author
Owner

@frank-dittrich commented on GitHub (Dec 15, 2014):

When no data is given, base64conv should just read from stdin.

<!-- gh-comment-id:66953812 --> @frank-dittrich commented on GitHub (Dec 15, 2014): When no data is given, base64conv should just read from stdin.
Author
Owner

@jfoug commented on GitHub (Dec 15, 2014):

529fcf4

<!-- gh-comment-id:66982313 --> @jfoug commented on GitHub (Dec 15, 2014): 529fcf4
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#457
No description provided.