merge crypt back into $top_builddir :)
[apps/madmutt.git] / crypt.h
diff --git a/crypt.h b/crypt.h
new file mode 100644 (file)
index 0000000..12acc61
--- /dev/null
+++ b/crypt.h
@@ -0,0 +1,140 @@
+/*
+ * Copyright notice from original mutt:
+ * Copyright (C) 2003 Werner Koch <wk@gnupg.org>
+ * Copyright (C) 2004 g10code GmbH
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+/*
+   Common definitions and prototypes for the crypt functions. They are
+   all defined in crypt.c and cryptglue.c
+*/
+
+#ifndef MUTT_CRYPT_H
+#define MUTT_CRYPT_H
+
+#include <lib-mime/mime.h>
+#include "state.h"
+
+#define ENCRYPT    (1 << 0)
+#define SIGN       (1 << 1)
+#define GOODSIGN   (1 << 2)
+#define BADSIGN    (1 << 3)
+#define PARTSIGN   (1 << 4)
+#define SIGNOPAQUE (1 << 5)
+#define KEYBLOCK   (1 << 6)     /* KEY too generic? */
+#define INLINE     (1 << 7)
+
+#define APPLICATION_PGP    (1 << 8)
+#define APPLICATION_SMIME  (1 << 9)
+
+#define PGP_TRADITIONAL_CHECKED (1 << 10)
+
+#define PGPENCRYPT  (APPLICATION_PGP | ENCRYPT)
+#define PGPSIGN     (APPLICATION_PGP | SIGN)
+#define PGPKEY      (APPLICATION_PGP | KEYBLOCK)
+#define PGPINLINE   (APPLICATION_PGP | INLINE)
+
+#define SMIMEENCRYPT  (APPLICATION_SMIME | ENCRYPT)
+#define SMIMESIGN     (APPLICATION_SMIME | SIGN)
+#define SMIMEOPAQUE   (APPLICATION_SMIME | SIGNOPAQUE)
+
+#define KEYFLAG_CANSIGN                (1 <<  0)
+#define KEYFLAG_CANENCRYPT             (1 <<  1)
+#define KEYFLAG_ISX509                  (1 <<  2)
+#define KEYFLAG_SECRET                 (1 <<  7)
+#define KEYFLAG_EXPIRED                (1 <<  8)
+#define KEYFLAG_REVOKED                (1 <<  9)
+#define KEYFLAG_DISABLED               (1 << 10)
+#define KEYFLAG_SUBKEY                         (1 << 11)
+#define KEYFLAG_CRITICAL               (1 << 12)
+#define KEYFLAG_PREFER_ENCRYPTION      (1 << 13)
+#define KEYFLAG_PREFER_SIGNING                 (1 << 14)
+
+#define KEYFLAG_CANTUSE (KEYFLAG_DISABLED|KEYFLAG_REVOKED|KEYFLAG_EXPIRED)
+#define KEYFLAG_RESTRICTIONS (KEYFLAG_CANTUSE|KEYFLAG_CRITICAL)
+
+#define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING)
+
+/*-- new API --*/
+
+void crypt_invoke_import(FILE *stream, int smime);
+int crypt_send_menu(HEADER *msg, int *redraw, int smime);
+int crypt_verify_one(BODY *, STATE *s, FILE *fp, int smime);
+
+
+/*-- crypt.c --*/
+
+int mutt_protect (HEADER *, char *);
+int mutt_signed_handler (BODY *, STATE *);
+int mutt_parse_crypt_hdr (char *, int);
+void convert_to_7bit (BODY *);
+
+/* Check out the type of encryption used and set the cached status
+   values if there are any. */
+int crypt_query (BODY * m);
+
+/* Fixme: To be documented. */
+void crypt_extract_keys_from_messages (HEADER * h);
+
+/* Do a quick check to make sure that we can find all of the
+   encryption keys if the user has requested this service. 
+   Return the list of keys in KEYLIST. */
+int crypt_get_keys (HEADER * msg, char **keylist);
+
+
+/* Show a message that a backend will be invoked. */
+void crypt_invoke_message (int type);
+
+/* Decrypt a PGP/MIME message. */
+int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
+
+/* MIME handler for the application/pgp content-type. */
+int crypt_pgp_application_pgp_handler (BODY * m, STATE * s);
+
+/* MIME handler for an PGP/MIME encrypted message. */
+int crypt_pgp_encrypted_handler (BODY * a, STATE * s);
+
+/* fixme: needs documentation. */
+void crypt_pgp_invoke_getkeys (address_t * addr);
+
+/* Check for a traditional PGP message in body B. */
+int crypt_pgp_check_traditional (FILE * fp, BODY * b, int tagged_only);
+
+/* Generate a PGP public key attachment. */
+BODY *crypt_pgp_make_key_attachment (char *tempf);
+
+/* Create a new body with a PGP signed message from A. */
+BODY *crypt_pgp_sign_message (BODY * a);
+
+/* Warning: A is no longer freed in this routine, you need to free it
+   later.  This is necessary for $fcc_attach. */
+BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign);
+
+/* fixme: needs documentation */
+void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag,
+                                                  BODY * top);
+
+
+/* Decrypt an S/MIME message. */
+int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
+
+/* MIME handler for the application/smime content-type. */
+int crypt_smime_application_smime_handler (BODY * m, STATE * s);
+
+/* fixme: Needs documentation. */
+void crypt_smime_getkeys (ENVELOPE * env);
+
+/* Check that the sender matches. */
+int crypt_smime_verify_sender (HEADER * h);
+
+/* fixme: Needs documentation. */
+BODY *crypt_smime_sign_message (BODY * a);
+
+/* fixme: needs documentation. */
+BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist);
+
+#endif /*MUTT_CRYPT_H */