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 / cfiler / readme.txt < prev    next >
Text File  |  1996-01-12  |  8KB  |  168 lines

  1. Cryptography Filer 
  2.  
  3. SUMMARY
  4. =======
  5.  
  6. The CFiler sample is a file encryptor that uses the Microsoft Cryptography 
  7. API (CAPI). Its interface is an adaptation of the FILER sample. CFiler 
  8. demonstrates a large part of the capabilities of CAPI, including encryption, 
  9. digital signature, and password-based key generation.
  10.  
  11. CFiler's interface contains two list boxes: the directory list box and the 
  12. file list box. Users navigate about their directory tree by double-clicking 
  13. on the directory list box, which is located on the left of CFiler's client 
  14. area. Double-clicking on an entry in the directory list box once causes the 
  15. directory to be expanded, with all its subdirectories displayed indented 
  16. below the entry. Double-clicking on the entry a second time causes the entry 
  17. to be collapsed. Users can perform cryptographic operations on files and 
  18. directories by selecting them in the file list box and selecting operations 
  19. from the menu. When a user double-clicks on an item in the file list box, 
  20. CFiler encrypts the file and displays its filename in gray text. Note: The 
  21. plaintext file is deleted. A second double-click causes CFiler to decrypt 
  22. the file and display its filename in its original color. Users sign files by 
  23. first selecting them in the file list box and then selecting Sign from the 
  24. File menu. Signed files appear in red text. Users can verify the signature 
  25. of a file by selecting the file in the file list box and choosing Verify from 
  26. the file menu. An encrypted file that has been signed appears in light red 
  27. text. When users encrypt and then sign files, they know that adversaries 
  28. have not encrypted the files. Users can select the algorithms they wish to 
  29. use for encryption and digital signature from the Options menu.
  30.  
  31. The first time a user runs CFiler, the application creates a key called fnKey 
  32. and stores the key in the registry. From then on, when the user starts 
  33. CFiler, the application access fnKey from the registry. CFiler uses fnKey to 
  34. encrypt file and directory names. When a user chooses to encrypt a file, 
  35. CFiler generates a session key with which to encrypt the file, exports the 
  36. key, generates a random filename with a .CRP extension, creates a hidden 
  37. file with this name, encrypts the name of the plaintext file with fnKey, 
  38. stores the encrypted filename to the .CRP file, stores the exported key to 
  39. the .CRP file, encrypts the data with the session key, stores the encrypted 
  40. content to the .CRP file, and deletes the plaintext file. When the user 
  41. chooses to encrypt a directory, CFiler encrypts the name of the directory
  42. with fnKey, stores the data in a file called dirinfo in the directory,
  43. generates a random name with a .CRP extension, renames the directory 
  44. using this name, hides the directory, encrypts all the files in the 
  45. directory, and recursively encrypts all subdirectories. If the fnKey is lost 
  46. or tampered with, CFiler displays the file in the file list box as RecoverMe 
  47. in gray text. Although the user can recover the original file, the original 
  48. filename is lost when fnKey is lost.
  49.  
  50. The Password item under the Options menu prompts the user for a password. 
  51. CFiler generates a session key with this password the next time the user 
  52. encrypts a file. When the user wishes to decrypt that file, the application 
  53. again prompts the user for the password.
  54.  
  55. CFiler never displays the random file and directory names it generates. 
  56. CFiler only displays the original names. CFiler accomplishes this by 
  57. maintaining two string tables: one for the directory list box and one for the 
  58. file list box. Each entry in the string table has a hidden and displayed 
  59. field. The hidden field holds the pathname as it appears on the disk. The 
  60. displayed field holds the pathname as it appeared on the disk before 
  61. encryption.
  62.  
  63. CFiler stores all signatures of files along with the ALG_ID's of the hashing 
  64. algorithms used to generate the signatures as separate, hidden files in the 
  65. hidden directory sig off the root on the same drive as the system directory. 
  66. This directory is hidden by default. Users may choose to hide or unhide this 
  67. directory and its contents. The filenames of these files are SHA hashes of 
  68. the full pathnames of the files. It is necessary to convert these 20-byte 
  69. hashes before using them as filenames since there are only 2^6 rather than 
  70. 2^8 legal characters for filenames. By choosing 64 (2^6) characters for 
  71. filenames (A-Z, a-z, 0-9, +, and _), it is possible to convert 3 bytes of 
  72. the hash, containing 24 = 8 * 3 bits of data, to 4 bytes of the filename, 
  73. also containing 24 = 6 * 4 bits of data. CFiler adds 4 null bytes to the hash 
  74. to have 24 bytes with which to perform the conversion. CFiler knows that a 
  75. file has a signature if the hash of its full pathname is one of the files in 
  76. the sig directory. To increase efficiency, CFiler creates in memory a table 
  77. of the signature files when filling the file list box.
  78.  
  79. The default encryption algorithm is RC2, which is not fixed. For password-
  80. based key generation, MD4 is the hashing algorithm, and it cannot be changed. 
  81. The default hashing algorithm for generating signature files (which the user 
  82. can change) is MD4. The algorithm used to generate fnKey is RC4. The 
  83. algorithm used to hash pathnames of files in order to generate signature 
  84. filenames is SHA, which is fixed. It is necessary to #define WIN95 when 
  85. compiling under Windows 95. Making CFiler a Unicode application simply 
  86. requires a #define UNICODE.
  87.  
  88. MORE INFORMATION
  89. ================
  90.  
  91. Encrypted files are structured  in the following way:
  92.  
  93.  1. Filename encrypted with fnKey (RC4). - 256 * sizeof(TCHAR) bytes.
  94.  2. Exported key blob length - sizeof(DWORD) bytes. This is zero if the user 
  95.     selected a password-based key generation algorithm.
  96.  3. Key blob - (key blob length bytes) (0 bytes if generated from password).
  97.  4. Encrypted content.
  98.  
  99. Menus
  100. -----
  101.  
  102.   - File: Contains items which perform cryptographic operations on files.
  103.   - View: Contains items which change the view of the file and directory 
  104.     list boxes.
  105.   - Drives: Contains a list of available drives.
  106.   - Options: Contains items which set options for the cryptography operations.
  107.   - Help: Contains information for the user to obtain help and version 
  108.     information.
  109.  
  110. File Menu
  111. ---------
  112.  
  113.   - Encrypt/Decrypt: If the selected file in the file list box is plaintext, 
  114.     this menu item causes the application to encrypt the file. If the 
  115.     selected item is encrypted, this menu item causes the application to 
  116.     decrypt the file. During encryption, the plaintext file is deleted. 
  117.     During decryption, the encrypted file is deleted.
  118.  
  119.   - Sign: Creates a separate digital signature of the selected file in the 
  120.     file list box. This file is stored in the directory sig off the root on 
  121.     the same drive as the system directory. If a signature file already 
  122.     exists, the application asks users if they want to delete the signature 
  123.     file and replace it with a new signature file.
  124.  
  125.   - Verify: Verifies the signature of the file selected in the file list box. 
  126.  
  127.   - Exit: Terminates the application. 
  128.  
  129. View Menu
  130. ---------
  131.  
  132.   - Refresh: Refreshes the view of the current drive to that of the root. 
  133.  
  134.   - Expand Tree: Recursively expands the directory tree in the directory 
  135.     list box.
  136.  
  137.   - Swap Sides: Swaps the file and directory list boxes.
  138.  
  139. Drives Menu
  140. -----------
  141.  
  142. Lists available drives. When a user selects one of the items in this menu, 
  143. the application switches to that drive.
  144.  
  145. Options Menu
  146. ------------
  147.  
  148.   - Choose Encryption Algorithm: Prompts the user with a dialog box with 
  149.     radio buttons for each algorithm for generating session keys.
  150.  
  151.   - Enter Password: Prompts the user with a dialog box with a field for a 
  152.     password with which to generate session keys.
  153.  
  154.   - Choose Signature Algorithm: Prompts the user with a dialog box containing 
  155.     radio buttons for various algorithms with which to create digital
  156.     signatures.
  157.  
  158.   - Hide Signatures (either checked or unchecked): Toggles the hidden or 
  159.     shown status of the directory containing digital signatures as well as 
  160.     the hidden or shown status of the signatures themselves.
  161.  
  162. Help Menu
  163. ---------
  164.  
  165.   - CFiler Help: Loads the CFiler help file.
  166.  
  167.   - About CFiler: Shows the CFiler version information.
  168.