This works on that machine:
OPENSSL=: '/lib/x86_64-linux-gnu/libssl.so.1.0.0'
sslSha256 =: (IFWIN {:: ' SHA256 > + x *c x *c';'SHA256 > x *c x
*c') ssl NB. SHA256 i *c l *c' ssl
s256=: 3 : 0
sslSha256 (y);(#y);md=. 32#' '
md
)
hexhash =: ( [: ,@:hfd a.i.])@:
s256 hexhash 'The quick brown fox jumps over the lazy dog'
d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
However, if I try
OPENSSL=:'libssl.so'
sslSha256 =: (IFWIN {:: ' SHA256 > + x *c x *c';'SHA256 > x *c x
*c') ssl NB. SHA256 i *c l *c' ssl
s256 hexhash 'The quick brown fox jumps over the lazy dog'
|domain error: cd
Similarly:
OPENSSL=:'/usr/lib/libssl.so'
sslSha256 =: (IFWIN {:: ' SHA256 > + x *c x *c';'SHA256 > x *c x
*c') ssl NB. SHA256 i *c l *c' ssl
s256 hexhash 'The quick brown fox jumps over the lazy dog'
|domain error: cd
Speaking more generally, the motivation behind having the very
specific /lib/x86_64-linux-gnu/libssl.so.1.0.0 is so that the 64 bit
code and the 32 bit code can coexist, and the reason for not
supporting the more generic /usr/lib/libssl.so is so that there's a
clean separation between these two mechanisms. It's a bit ugly, but so
is the underlying cpu architecture.
Thanks,
--
Raul
On Sat, Sep 6, 2014 at 12:49 PM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> sorry about domain error, fixed on wiki, changing line to:
>
> OPENSSL =: sslp , (IFIOS + (;: 'Win Linux Android Darwin') i. <UNAME_z_) pick
> 'libeay32.dll '; (2 $ <'libssl.so '), (2 $ <'libssl.dylib ')
>
> basically, OPENSSL should be set to: (based on your distribution)
>
> OPENSSL
> /lib/x86_64-linux-gnu/libssl.so.1.0.0
>
> my understanding of linux is that libssl.so will find the latest version.
> No idea how standard '/lib/x86_64-linux-gnu/' is, but that is what you want
> assigned in the sslp =: line. Perhaps you want to also add an IF64 line for
> your other system
>
>
> ----- Original Message -----
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Cc:
> Sent: Saturday, September 6, 2014 12:12 PM
> Subject: Re: [Jprogramming] md5 is not md5
>
> IFIOS
> 0
> UNAME_z_
> Linux
> sslp =: IFWIN pick '/usr/lib/';'D:\OpenSSL-Win64\bin\'
> sslp
> /usr/lib/
>
> Looking closer, I'm thinking you probably want
> /lib/x86_64-linux-gnu/libssl.so.1.0.0 rather than /usr/lib/libssl.so
> (which does not exist).
>
> That said, the domain error is because you are trying to compute this result:
>
> '/usr/lib/',2$<'libssl.so'
>
> Thanks,
>
> --
> Raul
>
> On Sat, Sep 6, 2014 at 12:02 PM, 'Pascal Jasmin' via Programming
> <[email protected]> wrote:
>> what is sslp defined as?
>>
>> Is it possible IFIOS is not defined? or less likely UNAME_z_?
>>
>>
>> ----- Original Message -----
>> From: Raul Miller <[email protected]>
>> To: Programming forum <[email protected]>
>> Cc:
>> Sent: Saturday, September 6, 2014 11:57 AM
>> Subject: Re: [Jprogramming] md5 is not md5
>>
>> Here's what happens if I use that code and only extract hexhash from
>> the top (instead of simply incorporating both blocks of code):
>>
>> s256 hexhash 'The quick brown fox jumps over the lazy dog'
>> |value error: sslSha256
>> | sslSha256(y);(#y);md=.32#' '
>>
>> So, ok, what's wrong with sslSha256?
>>
>> sslSha256
>> |value error: sslSha256
>> sslSha256 =: (IFWIN {:: ' SHA256 > + x *c x *c';'SHA256 > x *c x
>> *c') ssl NB. SHA256 i *c l *c' ssl
>> |value error: OPENSSL
>> | ( OPENSSL,m)&cd
>>
>> So, ok, what's wrong with OPENSSL?
>>
>> OPENSSL =: sslp , (IFIOS + (;: 'Win Linux Android Darwin') i.
>> <UNAME_z_) pick 'libeay32.dll '; (2 $ <'libssl.so '); (2 $
>> <'libssl.dylib ')
>> |domain error
>> | OPENSSL=:sslp ,(IFIOS+(;:'Win Linux Android
>> Darwin')i.<UNAME_z_)pick'libeay32.dll ';(2$<'libssl.so
>> ');(2$<'libssl.dylib ')
>>
>> In other words, I was just copying and pasting your code into
>> jconsole, rather than defining a script and attempting to debug it.
>>
>> I recall doing that earlier and finding an issue with libssl which I
>> was not prepared to deal with.
>>
>> Thanks,
>>
>> --
>> Raul
>>
>> On Sat, Sep 6, 2014 at 11:52 AM, 'Pascal Jasmin' via Programming
>> <[email protected]> wrote:
>>> You did not go far enough down the page :P CryptAcquireContext is only
>>> used in the MSFT binding not openssl binding
>>>
>>>
>>> ----- Original Message -----
>>> From: Raul Miller <[email protected]>
>>> To: Programming forum <[email protected]>
>>> Cc:
>>> Sent: Saturday, September 6, 2014 11:49 AM
>>> Subject: Re: [Jprogramming] md5 is not md5
>>>
>>> I used the code from the bottom of the page.
>>>
>>> Quite possibly I should have used it differently, but that's a different
>>> issue.
>>>
>>> Thanks,
>>>
>>> --
>>> Raul
>>>
>>>
>>> On Sat, Sep 6, 2014 at 11:46 AM, 'Pascal Jasmin' via Programming
>>> <[email protected]> wrote:
>>>> You are using the wrong code. That is indeed windows specific bindings.
>>>> The openssl bindings are at the bottom of the page. Though you may want
>>>> to pick up hexhash definition from the top section.
>>>>
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Raul Miller <[email protected]>
>>>> To: Programming forum <[email protected]>
>>>> Cc:
>>>> Sent: Saturday, September 6, 2014 11:41 AM
>>>> Subject: Re: [Jprogramming] md5 is not md5
>>>>
>>>> I tried your code at
>>>> http://www.jsoftware.com/jwiki/PascalJasmin/SHA%201%2C%202%20and%20MD5%20for%20windows
>>>>
>>>> sha256 hexhash 'The quick brown fox jumps over the lazy dog'
>>>> |domain error: cd
>>>> |
>>>> CryptAcquireContext(aProv=.,_1);(<0);(<0);PROV_RSA_AES;CRYPT_VERIFYCONTEXT
>>>>
>>>> Meanwhile, what I have works for me.
>>>>
>>>> Specifically, I built libmd5.so using
>>>> https://github.com/rdm/libmd5.so, copied it into the directory
>>>> /home/ubuntu/bin/ and then used, from in J:
>>>>
>>>> md5raw=: '/home/ubuntu/bin/libmd5-64.so MD5String > l *c l'&(15!:0)@(; #)
>>>> md5=: 3 :',tolower hfd a.i. 15!:1 (md5raw y),0 16 2'
>>>>
>>>> Now... since I need both 32 bit J (to parse xml using xml/sax -
>>>> apparently that only works on 32 bit j602) and 64 bit J (to deal with
>>>> more data than will fit in a 32 bit process), I'm having to have two
>>>> copies of libmd5.so - one for each instance of J. But I can live with
>>>> that.
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Raul
>>>>
>>>>
>>>> On Sat, Sep 6, 2014 at 11:23 AM, 'Pascal Jasmin' via Programming
>>>> <[email protected]> wrote:
>>>>> the code was tested at one point on mac. There is an attempt in the
>>>>> definitions (at bottom of page only) to link on linux. assumes
>>>>> /usr/lib/libssl.so . Should work? or few changes needed to work on linux?
>>>>>
>>>>>
>>>>> ----- Original Message -----
>>>>> From: Raul Miller <[email protected]>
>>>>> To: Programming forum <[email protected]>
>>>>> Cc:
>>>>> Sent: Saturday, September 6, 2014 11:11 AM
>>>>> Subject: Re: [Jprogramming] md5 is not md5
>>>>>
>>>>> I can't use your implementation, since I'm not running this on windows.
>>>>>
>>>>> That said, I've got a fix for my code.
>>>>>
>>>>> That said, I do not have a fix for the portable code in convert/misc/md5.
>>>>>
>>>>> The first thing which would need to be fixed there are the uses of 32
>>>>> b. and 33 b. (in the definitions of sh_pcrypt_ and rot_pcrypt_) but
>>>>> oddly enough that does not seem to be sufficient. It's not obvious to
>>>>> me what else needs to be fixed, and right now I am feeling too
>>>>> impatient to isolate the problem.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> --
>>>>> Raul
>>>>>
>>>>>
>>>>> On Sat, Sep 6, 2014 at 10:55 AM, 'Pascal Jasmin' via Programming
>>>>> <[email protected]> wrote:
>>>>>> It was written and tested for 32 bits. J7-64 also gives the wrong
>>>>>> answer.
>>>>>>
>>>>>> At the bottom of this page there are openssl bindings to similar hashes.
>>>>>>
>>>>>> http://www.jsoftware.com/jwiki/PascalJasmin/SHA%201%2C%202%20and%20MD5%20for%20windows
>>>>>>
>>>>>> all the bound hashes are the same speed when called, but I added an md5
>>>>>> implementation this morning. IIRC it is over 1000 times faster than the
>>>>>> J code.
>>>>>>
>>>>>> I possibly made the unpopular design decision to split out the
>>>>>> formatting of the hash and keep it raw binary. There is a 5x
>>>>>> performance benefit for doing so.
>>>>>>
>>>>>> the fastest conversion (but takes more space than binary) is
>>>>>>
>>>>>> listhash =: (a. i. ])@:
>>>>>>
>>>>>> or:
>>>>>> a. i. md5 'example'
>>>>>>
>>>>>> If you are having any problems with the library, the source is likely in
>>>>>> the first 3 lines. I didn't test with 32 bits, but any problems there
>>>>>> are likely solveable.
>>>>>>
>>>>>>
>>>>>> ----- Original Message -----
>>>>>> From: Raul Miller <[email protected]>
>>>>>> To: Programming forum <[email protected]>
>>>>>> Cc:
>>>>>> Sent: Saturday, September 6, 2014 9:10 AM
>>>>>> Subject: [Jprogramming] md5 is not md5
>>>>>>
>>>>>> j602:
>>>>>>
>>>>>> load'convert/misc/md5'
>>>>>> md5 'example'
>>>>>> 1a79a4d60de6718e8e5b326e338ae533
>>>>>>
>>>>>> j64-802:
>>>>>>
>>>>>> load'convert/misc/md5'
>>>>>> md5 'example'
>>>>>> 64a9df64d8defee229d86709a425ea7a
>>>>>>
>>>>>> This is a problem...
>>>>>>
>>>>>> ==
>>>>>> Raul
>>>>>> ----------------------------------------------------------------------
>>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>>
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> ----------------------------------------------------------------------
>>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
>>>
>>>
>>>
>>>>> ----------------------------------------------------------------------
>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>>
>>>>> ----------------------------------------------------------------------
>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm