I think some of your dll signitures are incorrect. eg. byval
string should be *c and if you want to pass null pointer, you
can use <0

Also the vb code may not work for 64-bit, please the actual
size of each parameter.

Чт, 05 сен 2013, Pascal Jasmin писал(а):
> I'm trying to get sha256 from microsoft's library working.
> 
> MS documentation on the last call in my function: 
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa379947(v=vs.85).aspx
> 
> The problem is that the 3rd param to CryptGetHashParam is a pointer to a byte 
> array, and should hold the hash result, but I'm unable to see it change.  The 
> 2nd param in CryptHashData may also be called incorrectly here.
> 
> any help?
> 
> 
> ALG_SID_SHA_256 =: 12
> ALG_CLASS_HASH =: 32768
> PROV_RSA_FULL =:1
> PROV_RSA_AES =: 24
> HP_HASHVAL =: 2
> CRYPT_VERIFYCONTEXT =: 4026531840
> CryptAcquireContext =: ('advapi32.dll CryptAcquireContextA i *i c c i i') & cd
> NB.(ByRef phProv As Long, ByVal pszContainer As String, ByVal pszProvider As 
> String, ByVal dwProvType As Long, ByVal dwFlags As Long) 
> CryptReleaseContext =: 'advapi32.dll CryptReleaseContext i i i' & cd
> NB. (ByVal hProv As Long, ByVal dwFlags As Long) As Long
> CryptCreateHash =: 'advapi32.dll CryptCreateHash i *i i i i *i' & cd
> NB.(ByVal hProv As Long, ByVal Algid As Long, ByVal hKey As Long, ByVal 
> dwFlags As Long, ByRef phHash As Long) As Long
> CryptDestroyHash =: 'advapi32.dll CryptDestroyHash i i' & cd
> NB.(ByVal hHash As Long) As Long
> CryptHashData =: 'advapi32.dll CryptHashData i *i *c i i' & cd
> NB.(ByVal hHash As Long, pbData As Any, ByVal cbData As Long, ByVal dwFlags 
> As Long) As Long
> CryptGetHashParam =: 'advapi32.dll CryptGetHashParam i *i i *c *i i' & cd
> NB.(ByVal hHash As Long, ByVal dwParam As Long, pbData As Any, ByRef pcbData 
> As Long, ByVal dwFlags As Long) As Long
> 
> 
> 
> CreateHash =: 3 : 0
> a =. mema 8
> h =. mema 128
> o =. mema 32
> 
> err=. CryptAcquireContext (<a);' ';' ';PROV_RSA_FULL;CRYPT_VERIFYCONTEXT
> err =. CryptCreateHash (<a); ALG_SID_SHA_256 ; 0 ; 0 ; (<<h)
> y memw o, 0 , # y
> CryptHashData (<h) ; (y) ; (# y) ; 0
> CryptGetHashParam (<h); HP_HASHVAL ; (<o ); (,32) ; 0
> NB. memr o, 0, # y
> )
> 
> 
> vb code that i adapted this from: 
> http://khoiriyyah.blogspot.ca/2012/06/vb6-hash-class-md5-sha-1-sha-256-sha.html
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to