From: Richard Russon Date: Fri, 20 Jul 2018 21:57:01 +0000 (+0100) Subject: rename crypto constants X-Git-Tag: 2019-10-25~743^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05e15d57478fd58a45e22610ca20748e6499c93a;p=neomutt rename crypto constants --- diff --git a/hdrline.c b/hdrline.c index f81315d14..34fc94035 100644 --- a/hdrline.c +++ b/hdrline.c @@ -1321,7 +1321,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co ch = "P"; else if ((WithCrypto != 0) && (hdr->security & SIGN)) ch = "s"; - else if (((WithCrypto & APPLICATION_PGP) != 0) && ((hdr->security & PGPKEY) == PGPKEY)) + else if (((WithCrypto & APPLICATION_PGP) != 0) && ((hdr->security & PGP_KEY) == PGP_KEY)) ch = "K"; else ch = " "; @@ -1385,7 +1385,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co second = "P"; else if ((WithCrypto != 0) && (hdr->security & SIGN)) second = "s"; - else if (((WithCrypto & APPLICATION_PGP) != 0) && (hdr->security & PGPKEY)) + else if (((WithCrypto & APPLICATION_PGP) != 0) && (hdr->security & PGP_KEY)) second = "K"; else second = " "; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 154765099..57bdac848 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -179,7 +179,7 @@ int mutt_protect(struct Header *msg, char *keylist) if ((msg->security & SIGN) && !crypt_valid_passphrase(msg->security)) return -1; - if (((WithCrypto & APPLICATION_PGP) != 0) && ((msg->security & PGPINLINE) == PGPINLINE)) + if (((WithCrypto & APPLICATION_PGP) != 0) && ((msg->security & PGP_INLINE) == PGP_INLINE)) { if ((msg->content->type != TYPE_TEXT) || (mutt_str_strcasecmp(msg->content->subtype, "plain") != 0)) @@ -350,7 +350,7 @@ int mutt_protect(struct Header *msg, char *keylist) /** * mutt_is_multipart_signed - Is a message signed? * @param b Body of email - * @retval >0 Message is signed, e.g. #PGPSIGN + * @retval >0 Message is signed, e.g. #PGP_SIGN * @retval 0 Message is not signed */ int mutt_is_multipart_signed(struct Body *b) @@ -373,18 +373,18 @@ int mutt_is_multipart_signed(struct Body *b) if (((WithCrypto & APPLICATION_PGP) != 0) && !(mutt_str_strcasecmp(p, "application/pgp-signature") != 0)) { - return PGPSIGN; + return PGP_SIGN; } if (((WithCrypto & APPLICATION_SMIME) != 0) && !(mutt_str_strcasecmp(p, "application/x-pkcs7-signature") != 0)) { - return SMIMESIGN; + return SMIME_SIGN; } if (((WithCrypto & APPLICATION_SMIME) != 0) && !(mutt_str_strcasecmp(p, "application/pkcs7-signature") != 0)) { - return SMIMESIGN; + return SMIME_SIGN; } return 0; @@ -393,7 +393,7 @@ int mutt_is_multipart_signed(struct Body *b) /** * mutt_is_multipart_encrypted - Does the message have encrypted parts? * @param b Body of email - * @retval >0 Message has got encrypted parts, e.g. #PGPENCRYPT + * @retval >0 Message has got encrypted parts, e.g. #PGP_ENCRYPT * @retval 0 Message hasn't got encrypted parts */ int mutt_is_multipart_encrypted(struct Body *b) @@ -411,13 +411,13 @@ int mutt_is_multipart_encrypted(struct Body *b) return 0; } - return PGPENCRYPT; + return PGP_ENCRYPT; } /** * mutt_is_valid_multipart_pgp_encrypted - Is this a valid multi-part encrypted message? * @param b Body of email - * @retval >0 Message is valid, with encrypted parts, e.g. #PGPENCRYPT + * @retval >0 Message is valid, with encrypted parts, e.g. #PGP_ENCRYPT * @retval 0 Message hasn't got encrypted parts */ int mutt_is_valid_multipart_pgp_encrypted(struct Body *b) @@ -439,13 +439,13 @@ int mutt_is_valid_multipart_pgp_encrypted(struct Body *b) return 0; } - return PGPENCRYPT; + return PGP_ENCRYPT; } /** * mutt_is_malformed_multipart_pgp_encrypted - Check for malformed layout * @param b Body of email - * @retval PGPENCRYPT Success + * @retval PGP_ENCRYPT Success * @retval 0 Error * * This checks for the malformed layout caused by MS Exchange in @@ -494,13 +494,13 @@ int mutt_is_malformed_multipart_pgp_encrypted(struct Body *b) if (b) return 0; - return PGPENCRYPT; + return PGP_ENCRYPT; } /** * mutt_is_application_pgp - Does the message use PGP? * @param m Body of email - * @retval >0 Message uses PGP, e.g. #PGPENCRYPT + * @retval >0 Message uses PGP, e.g. #PGP_ENCRYPT * @retval 0 Message doesn't use PGP */ int mutt_is_application_pgp(struct Body *m) @@ -517,24 +517,24 @@ int mutt_is_application_pgp(struct Body *m) if (p && ((mutt_str_strcasecmp(p, "sign") == 0) || (mutt_str_strcasecmp(p, "signclear") == 0))) { - t |= PGPSIGN; + t |= PGP_SIGN; } p = mutt_param_get(&m->parameter, "format"); if (p && (mutt_str_strcasecmp(p, "keys-only") == 0)) { - t |= PGPKEY; + t |= PGP_KEY; } if (!t) - t |= PGPENCRYPT; /* not necessarily correct, but... */ + t |= PGP_ENCRYPT; /* not necessarily correct, but... */ } if (mutt_str_strcasecmp(m->subtype, "pgp-signed") == 0) - t |= PGPSIGN; + t |= PGP_SIGN; if (mutt_str_strcasecmp(m->subtype, "pgp-keys") == 0) - t |= PGPKEY; + t |= PGP_KEY; } else if (m->type == TYPE_TEXT && (mutt_str_strcasecmp("plain", m->subtype) == 0)) { @@ -543,15 +543,15 @@ int mutt_is_application_pgp(struct Body *m) (p = mutt_param_get(&m->parameter, "action"))) && (mutt_str_strncasecmp("pgp-sign", p, 8) == 0)) { - t |= PGPSIGN; + t |= PGP_SIGN; } else if (p && (mutt_str_strncasecmp("pgp-encrypt", p, 11) == 0)) - t |= PGPENCRYPT; + t |= PGP_ENCRYPT; else if (p && (mutt_str_strncasecmp("pgp-keys", p, 7) == 0)) - t |= PGPKEY; + t |= PGP_KEY; } if (t) - t |= PGPINLINE; + t |= PGP_INLINE; return t; } @@ -559,7 +559,7 @@ int mutt_is_application_pgp(struct Body *m) /** * mutt_is_application_smime - Does the message use S/MIME? * @param m Body of email - * @retval >0 Message uses S/MIME, e.g. #SMIMEENCRYPT + * @retval >0 Message uses S/MIME, e.g. #SMIME_ENCRYPT * @retval 0 Message doesn't use S/MIME */ int mutt_is_application_smime(struct Body *m) @@ -580,9 +580,9 @@ int mutt_is_application_smime(struct Body *m) if (t) { if (mutt_str_strcasecmp(t, "enveloped-data") == 0) - return SMIMEENCRYPT; + return SMIME_ENCRYPT; else if (mutt_str_strcasecmp(t, "signed-data") == 0) - return SMIMESIGN | SMIMEOPAQUE; + return SMIME_SIGN | SMIME_OPAQUE; else return 0; } @@ -591,7 +591,7 @@ int mutt_is_application_smime(struct Body *m) * instead of Content-Type parameter */ if (mutt_str_strcasecmp(m->description, "S/MIME Encrypted Message") == 0) - return SMIMEENCRYPT; + return SMIME_ENCRYPT; complain = true; } else if (mutt_str_strcasecmp(m->subtype, "octet-stream") != 0) @@ -623,10 +623,10 @@ int mutt_is_application_smime(struct Body *m) { /* Not sure if this is the correct thing to do, but it's required for compatibility with Outlook */ - return SMIMESIGN | SMIMEOPAQUE; + return SMIME_SIGN | SMIME_OPAQUE; } else if (mutt_str_strcasecmp((t + len), "p7s") == 0) - return SMIMESIGN | SMIMEOPAQUE; + return SMIME_SIGN | SMIME_OPAQUE; } return 0; @@ -1104,14 +1104,14 @@ int mutt_signed_handler(struct Body *a, struct State *s) inconsistent = true; } break; - case PGPSIGN: + case PGP_SIGN: if (a->next->type != TYPE_APPLICATION || (mutt_str_strcasecmp(a->next->subtype, "pgp-signature") != 0)) { inconsistent = true; } break; - case SMIMESIGN: + case SMIME_SIGN: if (a->next->type != TYPE_APPLICATION || ((mutt_str_strcasecmp(a->next->subtype, "x-pkcs7-signature") != 0) && (mutt_str_strcasecmp(a->next->subtype, "pkcs7-signature") != 0))) diff --git a/ncrypt/ncrypt.h b/ncrypt/ncrypt.h index d5c4c527b..700450f43 100644 --- a/ncrypt/ncrypt.h +++ b/ncrypt/ncrypt.h @@ -131,17 +131,17 @@ extern char *SmimeVerifyOpaqueCommand; #define PGP_TRADITIONAL_CHECKED (1 << 11) -#define PGPENCRYPT (APPLICATION_PGP | ENCRYPT) -#define PGPSIGN (APPLICATION_PGP | SIGN) -#define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN) -#define PGPKEY (APPLICATION_PGP | KEYBLOCK) -#define PGPINLINE (APPLICATION_PGP | INLINE) - -#define SMIMEENCRYPT (APPLICATION_SMIME | ENCRYPT) -#define SMIMESIGN (APPLICATION_SMIME | SIGN) -#define SMIMEGOODSIGN (APPLICATION_SMIME | GOODSIGN) -#define SMIMEBADSIGN (APPLICATION_SMIME | BADSIGN) -#define SMIMEOPAQUE (APPLICATION_SMIME | SIGNOPAQUE) +#define PGP_ENCRYPT (APPLICATION_PGP | ENCRYPT) +#define PGP_SIGN (APPLICATION_PGP | SIGN) +#define PGP_GOODSIGN (APPLICATION_PGP | GOODSIGN) +#define PGP_KEY (APPLICATION_PGP | KEYBLOCK) +#define PGP_INLINE (APPLICATION_PGP | INLINE) + +#define SMIME_ENCRYPT (APPLICATION_SMIME | ENCRYPT) +#define SMIME_SIGN (APPLICATION_SMIME | SIGN) +#define SMIME_GOODSIGN (APPLICATION_SMIME | GOODSIGN) +#define SMIME_BADSIGN (APPLICATION_SMIME | BADSIGN) +#define SMIME_OPAQUE (APPLICATION_SMIME | SIGNOPAQUE) /* WITHCRYPTO actually replaces ifdefs so make the code more readable. * Because it is defined as a constant and known at compile time, the diff --git a/pattern.c b/pattern.c index 2498bb2e8..966d39478 100644 --- a/pattern.c +++ b/pattern.c @@ -2008,7 +2008,7 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, case MUTT_PGP_KEY: if (!(WithCrypto & APPLICATION_PGP)) break; - return pat->not ^ ((h->security & PGPKEY) == PGPKEY); + return pat->not ^ ((h->security & PGP_KEY) == PGP_KEY); case MUTT_XLABEL: if (!h->env) return 0; diff --git a/recvattach.c b/recvattach.c index 8430ef3d4..3bbe30eb1 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1161,7 +1161,7 @@ static void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Header secured = !crypt_smime_decrypt_mime(fp, &new_fp, m, &new_body); /* S/MIME nesting */ - if ((mutt_is_application_smime(new_body) & SMIMEOPAQUE) == SMIMEOPAQUE) + if ((mutt_is_application_smime(new_body) & SMIME_OPAQUE) == SMIME_OPAQUE) { struct Body *outer_new_body = new_body; FILE *outer_fp = new_fp; @@ -1176,7 +1176,7 @@ static void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Header } if (secured) - hdr->security |= SMIMEENCRYPT; + hdr->security |= SMIME_ENCRYPT; } if (((WithCrypto & APPLICATION_PGP) != 0) && @@ -1190,7 +1190,7 @@ static void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Header secured = !crypt_pgp_decrypt_mime(fp, &new_fp, m, &new_body); if (secured) - hdr->security |= PGPENCRYPT; + hdr->security |= PGP_ENCRYPT; } if (need_secured && secured) diff --git a/sendlib.c b/sendlib.c index 137b0626a..4951fd4f6 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1492,9 +1492,9 @@ struct Body *mutt_make_message_attach(struct Context *ctx, struct Header *hdr, b chflags |= CH_MIME | CH_TXTPLAIN; cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV; if (WithCrypto & APPLICATION_PGP) - pgp &= ~PGPENCRYPT; + pgp &= ~PGP_ENCRYPT; if (WithCrypto & APPLICATION_SMIME) - pgp &= ~SMIMEENCRYPT; + pgp &= ~SMIME_ENCRYPT; } else if ((WithCrypto != 0) && ForwardDecrypt && (hdr->security & ENCRYPT)) { @@ -1502,21 +1502,21 @@ struct Body *mutt_make_message_attach(struct Context *ctx, struct Header *hdr, b { chflags |= CH_MIME | CH_NONEWLINE; cmflags = MUTT_CM_DECODE_PGP; - pgp &= ~PGPENCRYPT; + pgp &= ~PGP_ENCRYPT; } else if (((WithCrypto & APPLICATION_PGP) != 0) && - ((mutt_is_application_pgp(hdr->content) & PGPENCRYPT) == PGPENCRYPT)) + ((mutt_is_application_pgp(hdr->content) & PGP_ENCRYPT) == PGP_ENCRYPT)) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV; - pgp &= ~PGPENCRYPT; + pgp &= ~PGP_ENCRYPT; } else if (((WithCrypto & APPLICATION_SMIME) != 0) && - ((mutt_is_application_smime(hdr->content) & SMIMEENCRYPT) == SMIMEENCRYPT)) + ((mutt_is_application_smime(hdr->content) & SMIME_ENCRYPT) == SMIME_ENCRYPT)) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV; - pgp &= ~SMIMEENCRYPT; + pgp &= ~SMIME_ENCRYPT; } }