X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-crypt%2Fcrypt-gpgme.c;h=7c24186797eabb1b3dd68b8bdf6ca87c3d6ab1ac;hb=e4360f3016dc130069b68459ef3942a26347358c;hp=7b6787ecd6a765fccbbcc635850ec9b3cd5fe4c9;hpb=64a23f5574b096605383ef1886c7d0d6c42aeeee;p=apps%2Fmadmutt.git diff --git a/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index 7b6787e..7c24186 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -27,31 +27,19 @@ #include #include - #include #include #include +#include "crypt.h" + #include "lib.h" #include "alias.h" -#include #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 @@ -875,7 +863,7 @@ BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign) /* 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; @@ -1980,12 +1968,10 @@ int crypt_pgp_application_pgp_handler (BODY * m, STATE * s) 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; @@ -2525,7 +2511,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, 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)) @@ -2534,7 +2520,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, 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 */ @@ -2545,7 +2531,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, || *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++; } @@ -2566,8 +2552,8 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, 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