Skip navigation

Access Denied: Safeguarding Web Users' Confidential Data

Get answers to your security-related Windows 2003, XP, and Win2K questions

What's an easy utility to use to encrypt a file by using a public/private key pair instead of a shared key? Our Web server accepts confidential information from browsers and needs to store it in a text file in a staging folder (we download all the submitted files periodically). If someone gains access to the Active Server Pages (ASP) code or files in the staging folder, we don't want them to be able to decrypt the files and access the files' confidential information.

You're right, the weakness of using shared-key encryption in such a situation is that if someone gains read access to your code, they can see the key and use it to decrypt whatever files are currently staged on your server. If you use public/private key encryption and someone succeeds in getting your public key, they can't use it to decrypt files—it's good only for encrypting new files.

I suggest using capicom.dll, a high-level interface to Windows cryptography functions that's easily accessible from scripts such as those in ASP pages, to encrypt and decrypt files. In fact, Capicom even provides a VBScript script that uses certificates to encrypt and decrypt files. Capicom is part of the Core Software Development Kit (SDK) component of the Windows SDK, which you can download from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm?p=/msdownload/platformsdk/sdkupdate/psdkredist.htm. After you install Capicom, look in its installation folder for the samples\vbs folder, and look in samples\vbs for cenvelop.vbs. When you use the Cenvelop command, you need to supply the file to encrypt or decrypt and the certificate to use for encryption or decryption.

Where does the certificate come from? Unless you have a Windows Certificate Services Certificate Authority (CA) from which you can obtain a certificate, you'll need to create your own self-signed certificate by using SelfSSL, which is part of the Microsoft IIS 6.0 Resource Kit Tools, which you can download at http://www.microsoft.com/downloads/details.aspx?familyid=56fc92ee-a71a-4c73-b628-ade629c89499&displaylang=en. You'll create a certificate and keep it and its private key on the computer on which you'll be decrypting files. Then you'll export a copy of the certificate without the private key and install the certificate on your Web server so that Cenvelop or your custom-written code can encrypt files using the public key. One warning though—encryption protects you if someone gains read access to your code but not if they can modify your code. If they can modify your code, they can replace the certificate or circumvent your encryption altogether.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish