home *** CD-ROM | disk | FTP | other *** search
/ Using the Internet / 21003.iso / email / PEGASUS / WINPM222.ZIP / WINPMAIL.ZIP / FORMS / CRYPTIF.TXT next >
Text File  |  1995-11-03  |  11KB  |  207 lines

  1.      --------------------------------------------------------------
  2.      Runtime-loadable encryptor/decryptor modules for Pegasus Mail.
  3.  
  4.                          Pegasus Mail System, 
  5.         Copyright (c) 1990-95, David Harris, All Rights Reserved
  6.      --------------------------------------------------------------
  7.  
  8. The hot topic on everyone's lips is "privacy". And, as usual, the
  9. computer industry is in the process of confusing and disrupting the issue
  10. beyond recognition... We have factions all over the place each arguing
  11. passionately for its own most beloved encryption scheme, and some of the
  12. rhetoric is getting pretty heated.
  13.  
  14. Add to the proliferation of interests the USA's ridiculous export laws on
  15. encryptors and the sum is trouble. As far as I can tell, encryption is
  16. going through what seems to be an industry-standard cycle of chaos:
  17. everyone suddenly realises there's a lack/opportunity/need and rushes to
  18. promote the idea they like best; a small war develops during which the
  19. users and peripheral developers are left bemused and bewildered amongst
  20. the welter of extravagant claims and counter-claims, then eventually
  21. (usually after two or three years of total pandemonium) the group with
  22. the most clout (although not necessarily the best product) will win out
  23. and become "the standard".
  24.  
  25. I've been through this rat race several times and have no desire whatever 
  26. to go through it again; on the other hand, my USERS have very legitimate 
  27. concerns about privacy. So what do I do? Easy - I pass the buck.
  28.  
  29. WinPMail v2.2 and later supports third-party, runtime loadable modules to
  30. handle encryption and decryption of mail. A special mechanism has been
  31. defined that allows Pegasus Mail to detect that a third party encryptor
  32. has been used and to determine whether the matching decryptor is
  33. available on the system. The built-in encryptor will remain available for
  34. those sites who only need moderate levels of message security.  WinPMail
  35. will define an open interface for third-party encryptors and it is then
  36. up to other people to write the code. What I envisage actually happening
  37. is people writing "shell interfaces" for WinPMail - i.e., modules that
  38. take the calls I make and translate them into calls to other programs,
  39. such as PGP or whatever, returning the result.
  40.  
  41. I have gone to considerable lengths to find a balance between simplicity
  42. and functionality in designing this interface: an encryptor module can be
  43. implemented with as few as three exported functions, yet has support for
  44. greater functionality as required. The primary features I wanted to be
  45. able to support were encryption/decryption and both the generation and
  46. validation of digital signatures.
  47.  
  48. The interface is a variant of WinPMail 2.0's Extension Manager Interface:
  49. each encryptor/decryptor is implemented as a DLL exporting the following
  50. functions by name:
  51.  
  52.    int FAR PASCAL encrypt_file (char *sourcefile, 
  53.       char *destfile, char *recipient, char *key, int textfile);
  54.       //  Encrypt the contents of a file: if "textfile" is non-zero,
  55.       //  then the file may contain 8-bit data, but will have normal
  56.       //  text file CR/LF line endings. If "textfile" is zero, the
  57.       //  encryptor routine should presume that the file has unknown
  58.       //  or explicitly binary contents. "recipient" contains the
  59.       //  address of the person to whom this message is being sent.
  60.       //  "key" contains whatever key the user entered, or may be
  61.       //  NULL if the encryptor's FFF flags indicate that it does
  62.       //  not require a key.
  63.       //
  64.       //  On entry, the source file will exist, the destination file
  65.       //  will not: the encryptor should create the destination file
  66.       //  file and place the ciphertext version of the plaintext file
  67.       //  file in it in a format ready for transmission. The module
  68.       //  should NOT delete the plaintext file.
  69.       //
  70.       //  Returns:  1 if the file was successfully encrypted.
  71.       //            2 if the file was successfully encrypted but
  72.       //              may contain 8-bit data and should be sent
  73.       //              encoded using BASE64.
  74.       //            0 on failure.
  75.  
  76.    int FAR PASCAL decrypt_file (char *sourcefile, char *destfile,
  77.       char *key);
  78.       //  Decrypt a message into a format suitable to be displayed in
  79.       //  a message reader. "sourcefile" contains an image of the message
  80.       //  (not the actual message itself) complete with all header
  81.       //  information intact. The destination file will not exist and
  82.       //  should be created by the decryptor.
  83.       //
  84.       //  This routine should return 2 if the message data cannot be
  85.       //  displayed as text (ie, is binary).
  86.       //       
  87.       //  Returns:  1 if the file was successfully decrypted
  88.       //            2 if the file was decrypted but is non-textual
  89.       //            0 on password or system failure
  90.       //
  91.       //  IMPORTANT NOTE: For encrypted components of MIME multipart
  92.       //  messages, only the encrypted component from the message will
  93.       //  be passed to the encryptor, along with the headers from the
  94.       //  message proper.
  95.  
  96.  
  97. Encryptor modules may also export the following optional functions:
  98.  
  99.    int FAR PASCAL sign_file (char *sourcefile, char *destfile,
  100.       char *recipient, char *key, int encrypt_as_well);
  101.       //  Compute and attach a digital signature to the message passed
  102.       //  in "sourcefile". The message should be rewritten with the 
  103.       //  signature attached in the proper place in "destfile", which
  104.       //  will not exist on entry. "Sourcefile" will contain the body
  105.       //  of the message to sign, but will NOT contain the message
  106.       //  headers. If "encrypt_as_well" is non-zero, the file should
  107.       //  be both encrypted and signed, using whatever method is
  108.       //  appropriate.
  109.       //
  110.       //  Returns:  1 if the message was successfully processed
  111.       //            2 if the file was successfully processed but
  112.       //              may contain 8-bit data and should be sent
  113.       //              encoded using BASE64.
  114.       //            0 if an error occurred during processing
  115.       //           -1 if the operation is not supported
  116.  
  117.    int FAR PASCAL verify_signature (char *sourcefile, char *text);
  118.       //  Attempt to verify the digital signature (if any) associated
  119.       //  with the message passed in "sourcefile", which contains a
  120.       //  complete image of the message including headers. This
  121.       //  routine should not assume that the message actually has
  122.       //  a digital signature, and should be ready to deal with the
  123.       //  situation where none is present.
  124.       //
  125.       //  The "text" parameter points to a string 80 characters long
  126.       //  into which the verify routine can write any descriptive
  127.       //  text about a valid signature that should be reported to 
  128.       //  the user.
  129.       //
  130.       //  Returns:  1 if the digital signature was valid
  131.       //            0 if the digital signature was invalid
  132.       //           -1 if no digital signature could be found
  133.       //           -2 if the operation is not supported
  134.  
  135.    int FAR PASCAL destroy_file (char *sourcefile);
  136.       //  If this function is exported, WinPMail will call it when it
  137.       //  has finished with a temporary files created in the process
  138.       //  of encryption or decryption. It is up to the module what it
  139.       //  does with the file, although the expectation is that it will
  140.       //  zero the contents and delete it.
  141.       //
  142.       //  Note that if this function is not exported, WinPMail will
  143.       //  destroy the file by writing 0s into every byte then
  144.       //  deleting it.
  145.       //
  146.       //  Returns:  1 if the file was destroyed
  147.       //            0 if the file was not destroyed (in which
  148.       //              case WinPMail will delete it as described).
  149.  
  150.    int FAR PASCAL key_management (char *sourcefile);
  151.       //  This is the only function in this API which actually
  152.       //  specifically requires that the encryptor module provide
  153.       //  a user interface. The expectation is that it will open a
  154.       //  modal dialog offering a few simple key management choices
  155.       //  for the user. If "sourcefile" is non-null, it will point
  156.       //  to a filename which contains the image of a message selected
  157.       //  by the user (possibly for extraction of a public key
  158.       //  fingerprint, or something similar).
  159.  
  160.  
  161. Important considerations:
  162.  
  163. * Blocking: If an encryptor module has to call another process to perform
  164. its function, then it is the encryptor's duty to ensure that control does
  165. not return to WinPMail before the process is complete - in other words,
  166. WinPMail regards encryptor actions as atomic.
  167.  
  168. * Line termination: Internet mail uses CR/LF line endings, and Pegasus
  169. Mail enforces this scheme. While in transit, line endings in a message may
  170. be disturbed, and if a message originally contained a line ending scheme
  171. that is illegal in Internet terms (such as the unix LF-only termination),
  172. then the line endings may be arbitrarily altered to conform with Internet
  173. standards in transit. If the position or nature of line termination is
  174. significant to an encryption module, it should ensure that the encrypted
  175. data is "armoured" for transit as part of the encryption process; some
  176. encryptors, such as PGP, support this idea already, but if this is not
  177. the case with your encryptor, you will have to return the value 2 to
  178. WinPMail to have it armour your data using MIME BASE64 encoding.
  179.  
  180.  
  181. Interface:
  182.  
  183. Runtime loadable encryptors are implemented as a variant of the WinPMail
  184. Extension model. They should be implemented as a standard extension that
  185. exports the extra functions described above. Encryptors have access to
  186. the full Extension Manager API set except for those functions specific to
  187. READER extensions. Just as with regular extensions, Pegasus Mail learns
  188. about encryptors via Form Fact Files (FFF files); it uses the "Form
  189. Triggers" keyword in the .FFF file as a regular expression describing
  190. some identifying characteristic of a message that the encryptor module
  191. can handle. The regular expression is applied to the headers, and to the
  192. message body for the number of lines specified in the "# of lines to
  193. probe for enclosures" setting of the Advanced Settings preferences
  194. dialog.
  195.  
  196. All Pegasus Mail Extensions support a "tagname" - an identifying mark
  197. that is written into an "X-Tagname:" field in messages generated by
  198. the extension. For encryptor extensions the tagname field is
  199. particularly important, since it will usually be the basis for
  200. detecting that a particular encryptor has been used to perturb the
  201. message. Developers of encryptor extensions are urged in the
  202. strongest possible terms to register their tagnames with the author
  203. following the guidelines in WPMFORMS.TXT, the Extension Manager
  204. reference found in the FORMS\ subdirectory of a standard WinPMail
  205. 2.x installation.
  206.  
  207.