SHA1 Implementation avialable?

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

SHA1 Implementation avialable?

Postby jvdsandt » Sun Nov 23, 2008 8:51 am

Hello,

Does anybody know if VisualAge for Smalltalk contains an implementation of the SHA1 secure hash algorithm? I found the "internal" class SstShaEngine but this seems to be only a partial implementation.

Regards,
Jan van de Sandt.
jvdsandt
 
Posts: 15
Joined: Sun Nov 23, 2008 8:46 am

Re: SHA1 Implementation avialable?

Postby nchillo » Wed Dec 03, 2008 10:47 am

I am having the same problem.
I need to invoke a secure webservice (with SstWSUsernameToken) and need to encript the password using SHA1.

If you have any answer or find an alternative solution please let me know.
Thanks,
Nicolas
nchillo
 
Posts: 9
Joined: Mon Nov 03, 2008 4:37 am

Re: SHA1 Implementation avialable?

Postby wembley » Wed Dec 03, 2008 11:11 am

Jan and Nicolas -

What functionality that you need is missing from SstShaEngine?
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Re: SHA1 Implementation avialable?

Postby nchillo » Wed Dec 03, 2008 11:53 am

I think my problem is I am not understanding how to use the SstSHAEngine.
Could you please post an example.
Thanks.
nchillo
 
Posts: 9
Joined: Mon Nov 03, 2008 4:37 am

Re: SHA1 Implementation avialable?

Postby jkoepp » Thu Dec 04, 2008 6:55 am

Here are two wikipedia examples (http://en.wikipedia.org/wiki/SHA_hash_functions)
(SstShaEngine new digest: 'The quick brown fox jumps over the lazy dog' asByteArray) asByteArray abtMD5AsHexString

returns '2FD4E1C67A2D28FCED849EE1BB76E7391B93EB12'

(SstShaEngine new digest: 'The quick brown fox jumps over the lazy cog' asByteArray) asByteArray abtMD5AsHexString

returns 'DE9F2C7FD25E1B3AFAD3E85A0BD17D9B100DB4B3'
jkoepp
 
Posts: 9
Joined: Mon Mar 31, 2008 4:40 am

Re: SHA1 Implementation avialable?

Postby jvdsandt » Sat Dec 06, 2008 1:03 pm

Hello all,

I need the SHA1 implementation because I want to use the SimpleDB service from Amazon. You need to sign your requests to this service using SHA1 and HMAC, so I also need support for HMAC. See http://docs.amazonwebservices.com/Amazo ... ation.html

Somebody gave me a tip and told me that VAST uses the OpenSSL library. This library supports the functions I am looking for. The functions are not yet available through the Smalltalk wrapper in the SciSslOpenSSLInterface. So now I am trying to add this function to the Smalltalk wrapper class.

I have added the following line to SciSslOpenSSLInterface>>_PRAGMA_SciSslFunctions
(name: HMAC isConstant: true valueExpression: 'PlatformFunction fromArray: #(''C'' ''HMAC'' nil ''CRYPTO_LIB'' #(#pointer #pointer #int32 #pointer #int32 #pointer #pointer) #pointer)')

To wrap the C function (from http://www.openssl.org/docs/crypto/hmac.html):
unsigned char *HMAC(const EVP_MD *evp_md, const void *key,
int key_len, const unsigned char *d, int n,
unsigned char *md, unsigned int *md_len);

In the first argument I need to specify that SHA1 should be used as the hash function.

I haven't figured out yet how to set up the arguments correctly. I will need some advice from someone with experience integrating C libaries in VAST. When I have it working I will post the results here.
jvdsandt
 
Posts: 15
Joined: Sun Nov 23, 2008 8:46 am

Re: SHA1 Implementation avialable?

Postby jvdsandt » Tue Dec 30, 2008 12:28 pm

Hello all,

I figured out how to get the SHA1-HMAC functionality to work using the OpenSSL libraries. The script below shows how it works:

Code: Select all
| sha1Func hmacFunc key message digest digestLen |
sha1Func := PlatformFunction fromArray: #('C' 'EVP_sha1' nil 'CRYPTO_LIB' #() #pointer).
hmacFunc := PlatformFunction fromArray: #('C' 'HMAC' nil 'CRYPTO_LIB' #(#pointer #pointer #int32 #pointer #int32 #pointer #pointer) #pointer).
key := 'our-secret' asByteArray.
message := 'Smalltalk is Cool!' asByteArray.
digest := ByteArray new: 20.
digestLen := ByteArray new: 4.
hmacFunc callWith: sha1Func call
   with: key
   with: key size
   with: message
   with: message size
   with: digest
   with: digestLen.
digest


The CRYPTO_LIB constant is defined in the SciSslOpenSSLInterface application, so this application is required as a prerequisite.

Jan.
jvdsandt
 
Posts: 15
Joined: Sun Nov 23, 2008 8:46 am

Re: SHA1 Implementation avialable?

Postby Thomas Holzer » Wed Jan 28, 2009 9:24 am

wembley wrote:Jan and Nicolas -

What functionality that you need is missing from SstShaEngine?

Hello John,

I think, the SstShaEngine class should be in an own application. Like the AbtMD5Engine is. Because if someone wants to use only the SHA features without SST, he is forced to use all the SST RMI classes, which are not needed.

Regards Thomas
Thomas Holzer
 
Posts: 16
Joined: Fri Nov 21, 2008 2:14 am

Re: SHA1 Implementation avialable?

Postby marten » Wed Jan 28, 2009 10:54 am

Thomas Holzer wrote:
wembley wrote:Jan and Nicolas -

What functionality that you need is missing from SstShaEngine?

Hello John,

I think, the SstShaEngine class should be in an own application. Like the AbtMD5Engine is. Because if someone wants to use only the SHA features without SST, he is forced to use all the SST RMI classes, which are not needed.

Regards Thomas


Ok, but the only problem is, that one has to load all stuff, which is not actually needed - but on the other hand the packager should throw all unneeded classes away. I have a similiar problem: a class I really like is SstSharedQueue - even without using the whole SST framework.

Marten
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest