home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / security / crypto / encrypt / readme.txt < prev   
Text File  |  1996-01-18  |  3KB  |  63 lines

  1. File Encryption
  2.  
  3.  
  4. The ENCRYPT sample is a console application that encrypts files. Files
  5. encrypted with this sample can be later decrypted with the DECRYPT sample.
  6.  
  7. Note that the INITUSER sample (or equivalent) must be run prior to running
  8. these samples, to create a key container for the default user.
  9.  
  10. Usage
  11. -----
  12.  
  13. The ENCRYPT sample is run from the command line as follows:
  14.  
  15.     encrypt <source file> <dest file> [ <password> ]
  16.  
  17. The <source file> argument specifies the filename of the plaintext file
  18. to be encrypted, and the <dest file> argument specifies the filename of
  19. the ciphertext file to be created. The optional <password> argument specifies
  20. a password with which to encrypt the file.
  21.  
  22. If no password is specified, then a random session key is used to encrypt
  23. the file. This session key is then encrypted with the key exchange public
  24. key of the default user and stored with the encrypted file. In this case,
  25. the corresponding key exchange private key is later used (by DECRYPT) to
  26. decrypt the session key, which is used in turn to decrypt the file itself.
  27.  
  28. The DECRYPT sample is run from the command line as follows:
  29.  
  30.     decrypt <source file> <dest file> [ <password> ]
  31.  
  32. The <source file> argument specifies the filename of the ciphertext file
  33. to be decrypted, and the <dest file> argument specifies the filename of
  34. the plaintext file to be created. The optional <password> argument specifies
  35. a password with which to decrypt the file.
  36.  
  37. If a bogus password is supplied to DECRYPT, no error is typically generated.
  38. Of course, the file isn't decrypted properly either.
  39.  
  40. Exercises for the Reader
  41. ------------------------
  42.  
  43. 1. By default, these samples use the RC4 stream cipher to perform the
  44.    encryption and decryption operations. If the USE_BLOCK_CIPHER constant is
  45.    defined at the top of each file, however, the RC2 block cipher is used
  46.    instead.
  47.  
  48. 2. For the sake of simplicity, these samples do not use salt values or (in the
  49.    case of a block cipher) initialization vectors (IVs). This greatly
  50.    diminishes their effective security. It would be a small matter to modify
  51.    these programs such that salt values and IVs are used (see CryptSetKeyParam
  52.    in the documentation). These values should be generated using the
  53.    CryptGenRandom function, and need to be stored (in a non-encrypted form)
  54.    along with the ciphertext file.
  55.  
  56. 3. Another command line argument could be added, which would specify a file
  57.    containing the public key to use when encrypting the session key. This file
  58.    would ideally be in the form of a certificate. If this is done, then it
  59.    becomes possible to encrypt a file such that only the owner of the
  60.    corresponding private key would be able to decrypt the file. This is useful
  61.    if you want to send the file to someone else. Note that this is only
  62.    applicable in the case when a password is not specified.
  63.