cryptography failure  
Author Message
AlexBB





PostPosted: Visual FoxPro General, cryptography failure Top

I use _cryptapi class of the _CRYPT class library to encrypt limited amount of information: ids and passwords. They are in a table and the table feeds treeview items on demand. Before appearing in treeview the field values are automatically decrypted.

Everything has been working fine until I noticed a problem yesterday. I have done most of development on C: drive but recently began moving the whole project to a G: drive since I set a new OS up on that partition. It is a bootable partition. If the encryption done on C: partition it can only be decrypted on that same partition. On partition G: everything is garbled. If I encrypted an item on G: partition I can decrypt it only here, it will be garbled if I run the application on C:

I checked the code. It seems there is no problem. I use LEFT (HOME(),2) statement to identify the partition. It is then assigned to a constant via #DEFINE CUR_DRIVE LEFT(HOME(),2)).

Everything seems to be working fine elsewhere since this CUR_DRIVE constant is employed in dozens of places.

What could be the problem

Thanks.




Visual FoxPro2  
 
 
Dave M.





PostPosted: Visual FoxPro General, cryptography failure Top

I tried the Following and have no problems..

CLOSE DATABASES
CLEAR
x=Newobject("_cryptapi","C:\FOX\crypt\_crypt.vcx")
CREATE TABLE c:\fox\crypt free (f1 c(5))

lcText='hello'
tcKey='dave1234'
lcCipher=''
lcreturn=''


lcCipher
SELECT crypt
APPEND BLANK
REPLACE f1 WITH lcCipher
BROWSE
CLOSE DATABASES

COPY FILE c:\fox\crypt.dbf TO m:\crypt.dbf
USE m:\crypt  && m is a Diffrent drive on this comp not a network map.
*USE c:\fox\crypt.dbf

lcreturn

CLOSE DATABASES
RELEASE ALL

Perhaps you are using a dynamic encyption Key that is dependant on the OS or Path
Dave M.


 
 
AlexBB





PostPosted: Visual FoxPro General, cryptography failure Top

Thank you, Dave. Iou've helped me many times in the past, I hope this post will eventually lead to a resolution but at this moment I do not see how.

I do not have FREE tables. They are all in databases. I know it is a long shot but still.....

Could it be a problem



 
 
Dave M.





PostPosted: Visual FoxPro General, cryptography failure Top

I Don’t thinks so, I’m far from an expert on this class, I think you have a logic error someplace, Try to replicate the error in a very controlled environment, similar to what I have done above. (You can copy the DBC and DBFs). It’s much easier to track it down like that.

 

This kind Encryption Is very important when transferring data though none secure places, (ie Email) to presumably another person or systems. It makes no scents that it should such major limitations as must be decrypted on the same OS/ Drive letter or DBC. This is why is think you have logic error somewhere.

 

Our Java Guy is currently writing a website for one of our clients that requires Encryption of certain data that is populated by the Jsp and Stored in the MYSql database and a Linux Box web server. I will have to access that data form FoxPro, Theoretically the Mysql Encryption methodologies and this Cryptapi should work exactly the same way as they are both based on that same published standard. So I should be able pass the data over the Internet in its encrypted form then decrypted with this class in FoxPro, rather than have Mysql Decrypt and pass the data over the Internet Decrypted. (That’s plan A, I don’t why but I am laughing as I type this. )              

 

Dave M.



 
 
AlexBB





PostPosted: Visual FoxPro General, cryptography failure Top

Yes, I checked the logic again. The encryption key is assigned to a variable like "form1.cccc" Thus it is global for this form. It is also used by a function in a prg file but the form object is passed as a parameter to it. As far as I can tell the drive letter is never used in the encryption at all. Thus all that description I gave of how I check for the location is not really relevant. I did it just in case.

"as must be decrypted on the same OS/ Drive " My two OSs are located on different drives: one is the DELL original and the other one I installed myself after buying it at Best Buy. Again I do not think it should be a problem.

I will run the test you suggested. It is very simple.

Thanks.



 
 
AlexBB





PostPosted: Visual FoxPro General, cryptography failure Top

BTW, the operating systems are also different. First one is Win2K, the other one is WinSer2003.

 
 
Alex Feldstein





PostPosted: Visual FoxPro General, cryptography failure Top

Unfortunately due to Microsoft default provider changes you cannot encrypt and decrypt in different OS without some work.

See my notes on this Wiki topic:
http://fox.wikis.com/wc.dll Wiki~CryptoAPI

 
 
Dave M.





PostPosted: Visual FoxPro General, cryptography failure Top

Alex F.

So what you are saying is this is worthless in a networked environment…

Dave M.



 
 
Alex Feldstein





PostPosted: Visual FoxPro General, cryptography failure Top

>So what you are saying is this is worthless in a networked environment…

You said it politely.

Actually with some work it can be used. MS has basically abandoned Windows CryptoAPI in favor of .NET Cryptography spaces. They are not updating or spending any time with CryptoAPI anymore.

Nowadays I prefer to use routines like the ones from Craig S. Boyd [MVP]

http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,db662a8f-d47c-46c8-b0d2-a591c20d024b.aspx

which is easier to use and more up to date.


 
 
AlexBB





PostPosted: Visual FoxPro General, cryptography failure Top

Yep, I checked - it is garbled in XP as well if coded in Win2K.

Thanks.