noinst_LIBRARIES = libcrypt.a
-libcrypt_a_SOURCES = crypt.h crypt-gpgme.h \
+libcrypt_a_SOURCES = crypt.h \
crypt.c crypt-gpgme.c cryptglue.c
-noinst_HEADERS = crypt.h crypt-gpgme.h
+noinst_HEADERS = crypt.h
-include $(top_builddir)/tools/cflags.mk
#include <gpgme.h>
#include <lib-mime/mime.h>
-
#include <lib-ui/curses.h>
#include <lib-ui/enter.h>
#include <lib-ui/menu.h>
+#include "crypt.h"
+
#include "lib.h"
#include "alias.h"
-#include <lib-crypt/crypt.h>
#include "handler.h"
#include "copy.h"
#include "pager.h"
#include "recvattach.h"
#include "sort.h"
-#include "crypt-gpgme.h"
-
-/*
- * Helper macros.
- */
-#define digitp(p) (*(p) >= '0' && *(p) <= '9')
-#define hexdigitp(a) (digitp (a) \
- || (*(a) >= 'A' && *(a) <= 'F') \
- || (*(a) >= 'a' && *(a) <= 'f'))
-#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
- *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
-#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
/* Values used for comparing addresses. */
#define CRYPT_KV_VALID 1
/* Encrypt the mail body A to all keys given as space separated
fingerprints in KEYLIST and return the S/MIME encrypted body. */
-BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist)
+BODY *crypt_smime_build_smime_entity (BODY * a, char *keylist)
{
char *outfile = NULL;
BODY *t;
return (err);
}
-/*
- * Implementation of `encrypted_handler'.
- */
+/* Implementation of `encrypted_handler'. */
/* MIME handler for pgp/mime encrypted messages. */
-int pgp_gpgme_encrypted_handler (BODY * a, STATE * s)
+int crypt_pgp_encrypted_handler (BODY * a, STATE * s)
{
char tempfile[_POSIX_PATH_MAX];
FILE *fpout;
if (*string == '#') { /* hexstring */
string++;
- for (s = string; hexdigitp (s); s++)
+ for (s = string; hexval(*s) >= 0; s++)
s++;
n = s - string;
if (!n || (n & 1))
p = p_new(unsigned char, n + 1);
array->value = (char *) p;
for (s1 = string; n; s1 += 2, n--)
- *p++ = xtoi_2 (s1);
+ *p++ = (hexval(*s1) << 8) | hexval(*s1);
*p = 0;
}
else { /* regular v3 quoted string */
|| *s == '<' || *s == '>' || *s == '#' || *s == ';'
|| *s == '\\' || *s == '\"' || *s == ' ')
n++;
- else if (hexdigitp (s) && hexdigitp (s + 1)) {
+ else if (hexval(*s) >= 0 && hexval(*s + 1) >= 0) {
s++;
n++;
}
for (s = string; n; s++, n--) {
if (*s == '\\') {
s++;
- if (hexdigitp (s)) {
- *p++ = xtoi_2 (s);
+ if (hexval(*s) >= 0) {
+ *p++ = (hexval(*s) << 8) | hexval(*s + 1);
s++;
}
else
+++ /dev/null
-/*
- * Copyright notice from original mutt:
- * Copyright (C) 2004 g10 Code 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.
- */
-
-#ifndef CRYPT_GPGME_H
-#define CRYPT_GPGME_H
-
-#include <lib-crypt/crypt.h>
-
-/* {{{ cruft */
-
-/* Type defintions for crypto module functions. */
-typedef int (*crypt_func_encrypted_handler_t) (BODY * m, STATE * s);
-
-typedef void (*crypt_func_pgp_invoke_getkeys_t) (address_t * addr);
-typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf);
-typedef int (*crypt_func_send_menu_t) (HEADER * msg, int *redraw);
-
- /* (SMIME) */
-typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE * env);
-typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY * a,
- char *certlist);
-
-typedef struct crypt_module_specs {
- /* Common/General functions. */
- crypt_func_encrypted_handler_t encrypted_handler;
-
- /* PGP specific functions. */
- crypt_func_pgp_make_key_attachment_t pgp_make_key_attachment;
- crypt_func_pgp_invoke_getkeys_t pgp_invoke_getkeys;
-
- /* S/MIME specific functions. */
- crypt_func_smime_getkeys_t smime_getkeys;
- crypt_func_smime_build_smime_entity_t smime_build_smime_entity;
-} crypt_module_specs_t;
-
-extern struct crypt_module_specs crypt_mod_SMIME_gpgme;
-extern struct crypt_module_specs crypt_mod_PGP_gpgme;
-
-/* }}} */
-
-BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign);
-BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist);
-
-int pgp_gpgme_check_traditional (FILE * fp, BODY * b, int tagged_only);
-int pgp_gpgme_encrypted_handler (BODY * a, STATE * s);
-BODY *pgp_gpgme_make_key_attachment (char *tempf);
-
-#endif
#include "mutt.h"
#include "crypt.h"
-#include "crypt-gpgme.h"
-
-#define CRYPT_MOD_CALL_CHECK(identifier, func) \
- ((crypt_mod_##identifier##_gpgme).func)
-
-#define CRYPT_MOD_CALL(identifier, func) \
- (*((crypt_mod_##identifier##_gpgme).func))
-
-
-struct crypt_module_specs crypt_mod_SMIME_gpgme = {
- NULL, /* encrypted_handler */
-
- NULL, /* pgp_make_key_attachment */
- NULL, /* pgp_invoke_getkeys */
-
- NULL, /* smime_getkeys */
- smime_gpgme_build_smime_entity,
-};
-
-struct crypt_module_specs crypt_mod_PGP_gpgme = {
- pgp_gpgme_encrypted_handler,
-
- /* PGP specific. */
- NULL, /* pgp_make_key_attachment, */
- NULL, /* pgp_invoke_getkeys */
-
- NULL, /* smime_getkeys */
- NULL, /* smime_build_smime_entity */
-};
-
/* PGP */
-/* MIME handler for an PGP/MIME encrypted message. */
-int crypt_pgp_encrypted_handler (BODY * a, STATE * s)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler))
- return (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s);
- return (-1);
-}
-
/* fixme: needs documentation. */
void crypt_pgp_invoke_getkeys (address_t * addr)
{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_getkeys))
- (CRYPT_MOD_CALL (PGP, pgp_invoke_getkeys)) (addr);
}
/* Generate a PGP public key attachment. */
BODY *crypt_pgp_make_key_attachment (char *tempf)
{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_make_key_attachment))
- return (CRYPT_MOD_CALL (PGP, pgp_make_key_attachment)) (tempf);
-
return NULL;
}
/* fixme: Needs documentation. */
void crypt_smime_getkeys (ENVELOPE * env)
{
- if (CRYPT_MOD_CALL_CHECK (SMIME, smime_getkeys))
- (CRYPT_MOD_CALL (SMIME, smime_getkeys)) (env);
}
-/* fixme: needs documentation. */
-BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, smime_build_smime_entity))
- return (CRYPT_MOD_CALL (SMIME, smime_build_smime_entity)) (a, certlist);
-
- return NULL;
-}