#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