Well, I'm getting closer.
Add this:
DECLARE INTEGER CryptDeriveKey ;
IN WIN32API as CryptDeriveKey;
INTEGER hProv,;
INTEGER Algid,;
INTEGER hBaseData,;
LONG dwFlags,;
INTEGER @phKey
*- set up RC2 key
*-hKey = "jOsmwux8tIy1aN3Urq08"
*lnStatus = CryptDeriveKey(&hCryptProv, dnCALG_RC2, lhHashObject, 0x00800000,
&hKey )
lnStatus = CryptDeriveKey(hCryptProv, dnCALG_RC2, lhHashObject,
dnCRYPT_EXPORTABLE, &hKey )
realized I'm supposed to get a handle pointer - hKey. Not provide it. Now the
error message "...is missing operand"
I've requested the complete Dot Net module, in its entirety and natural state.
-they gave what they thought was pertinent.-
-----Original Message-----
From: ProFox [mailto:[email protected]] On Behalf Of Anthony Jennings
Sent: Monday, July 22, 2013 12:47 PM
To: ProFox Email List
Subject: cryptoapi
Hello,
Would anyone be able to point to a complete reference of the cryptoapi for
FoxPro 9.0?
What I have so far is working (I think)until the CryptDeriveKey.
Thanks in advance for any ideas...
#include wincrypt.h
*
* decrypting section
*
CLEAR ALL
CLOSE ALL
CLEAR
DECLARE INTEGER CryptDestroyHash IN advapi32;
INTEGER hHash
DECLARE INTEGER CryptReleaseContext IN advapi32;
INTEGER hProvHandle,;
INTEGER nReserved
tsFileName = GETFILE('enc')
= decrypt((tsFileName))
FUNCTION decrypt
LPARAMETERS tsFileName
hCryptProv = 0
lhHashObject = 0
lnDataSize = LEN(tsFileName)
lcHashValue = REPLICATE(CHR(0), 8)
lnHashSize = LEN(lcHashValue)
DECLARE INTEGER CryptAcquireContextA ;
IN WIN32API AS CryptAcquireContext ;
INTEGER @lhProvHandle, ;
STRING cContainer, ;
STRING cProvider, ;
INTEGER nProvType, ;
INTEGER nFlags
*-=CryptAcquireContext( &hCryptProv, username, 0, dnPROV_RSA_FULL,
dnCRYPT_NEWKEYSET )
lnStatus = CryptAcquireContext(@hCryptProv, 0, 0, dnPROV_RSA_FULL,
dnCRYPT_VERIFYCONTEXT)
*- hashing
DECLARE INTEGER CryptCreateHash ;
IN WIN32API AS CryptCreateHash ;
INTEGER hProviderHandle, ;
INTEGER nALG_ID, ;
INTEGER hKeyhandle, ;
INTEGER nFlags, ;
INTEGER @hCryptHashHandle
lnStatus = CryptCreateHash(hCryptProv, dnCALG_SHA, 0, 0, @lhHashObject )
DECLARE INTEGER CryptHashData ;
IN WIN32API AS CryptHashData ;
INTEGER hHashHandle, ;
STRING @cData, ;
INTEGER nDataLen, ;
INTEGER nFlags
lnStatus = CryptHashData( lhHashObject, tsFileName, lnDataSize, 0)
*//BYTE pbHash[1024];
//DWORD hashLen = 1024;
//CryptGetHashParam( hHash, HP_HASHVAL, pbHash, &hashLen, 0 );
*// set up RC2 key
hKey = "jOsmwux8tIy1aN3Urq08"
*lnStatus = CryptDeriveKey(&hCryptProv, dnCALG_RC2, lhHashObject, 0x00800000,
&hKey )
lnStatus = CryptDeriveKey(&hCryptProv, dnCALG_RC2, lhHashObject, 0, &hKey
)
iv = [8]
*iv[0] = iv[1] = iv[2] = iv[3] = iv[4] = iv[5] = iv[6] = iv[7] = 0
=CryptSetKeyParam( hKey, KP_IV, iv, 0 )
*// now encrypt
=CryptDecrypt( hKey, NULL, TRUE, 0, DATA, dataLen )
*// cleanup
DECLARE INTEGER CryptDestroyHash IN advapi32;
INTEGER hHash
DECLARE INTEGER CryptReleaseContext IN advapi32;
INTEGER hProvHandle,;
INTEGER nReserved
=CryptDestroyKey( hKey )
=CryptDestroyHash( hHash )
=CryptReleaseContext(hCryptProv,0)
ENDFUNC
--- StripMime Report -- processed MIME parts --- multipart/alternative
text/plain (text body -- kept)
text/html
---
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/B6AD520020ACAE4188914E5A0DCE8AC4F10B6E@MBX021-W3-CA-4.exch021.domain.local
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.