--- pgp/src/armor.c 2018/04/24 16:43:51 1.1.1.7 +++ pgp/src/armor.c 2018/04/24 16:44:49 1.1.1.8 @@ -1,4 +1,5 @@ -/* armor.c - ASCII/binary encoding/decoding based partly on PEM RFC1113. +/* armor.c - ASCII/binary encoding/decoding based partly on + PEM RFC1113 and MIME standards. PGP: Pretty Good(tm) Privacy - public key cryptography for the masses. (c) Copyright 1990-1994 by Philip Zimmermann. All rights reserved. @@ -29,16 +30,15 @@ #include "crypto.h" #include "armor.h" -static int dpem_file(char *infile, char *outfile); +static int darmor_file(char *infile, char *outfile); static crcword crchware(byte ch, crcword poly, crcword accum); -static int pem_file(char *infilename, char *outfilename, char *clearfilename); -static int pemdecode(FILE * in, FILE * out); +static int armordecode(FILE * in, FILE * out, int *warned); static void mk_crctbl(crcword poly); -static boolean is_pemfile(char *infile); +static boolean is_armorfile(char *infile); -/* Begin PEM routines. +/* Begin ASCII armor routines. This converts a binary file into printable ASCII characters, in a - radix-64 form mostly compatible with the PEM RFC1113 format. + radix-64 form mostly compatible with the MIME format. This makes it easier to send encrypted files over a 7-bit channel. */ @@ -46,8 +46,8 @@ static boolean is_pemfile(char *infile); * to that value. */ static -unsigned char bintoasc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\ -abcdefghijklmnopqrstuvwxyz0123456789+/"; +unsigned char bintoasc[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* Index this array by a 7 bit value to get the 6-bit binary field * corresponding to that value. Any illegal characters return high bit set. @@ -111,15 +111,14 @@ static long infile_line; * * You can detect spurious leading zeros or framing errors in the * message by initializing the CRC accumulator to some agreed-upon - * nonzero "random-like" value, but this is a bit nonstandard. + * nonzero value, but the value used is a bit nonstandard. */ #define CCITTCRC 0x1021 /* CCITT's 16-bit CRC generator polynomial */ #define PRZCRC 0x864cfbL /* PRZ's 24-bit CRC generator polynomial */ #define CRCINIT 0xB704CEL /* Init value for CRC accumulator */ -static -crcword crctable[256]; /* Table for speeding up CRC's */ +static crcword crctable[256]; /* Table for speeding up CRC's */ /* * mk_crctbl derives a CRC lookup table from the CRC polynomial. @@ -131,8 +130,8 @@ crcword crctable[256]; /* Table for spe * so the CRC of i>>1 (pointed to by p) can be used to derive * the CRC of i (pointed to by q). */ -static -void mk_crctbl(crcword poly) +static void +mk_crctbl(crcword poly) { int i; crcword t, *p, *q; @@ -167,7 +166,8 @@ crcbytes(byte * buf, unsigned len, regis } /* crcbytes */ /* Initialize the CRC table using our codes */ -void init_crc(void) +void +init_crc(void) { mk_crctbl(PRZCRC); } @@ -184,7 +184,8 @@ void init_crc(void) * output one group of up to 3 bytes, pointed at by p, on file f. * if fewer than 3 are present, the 1 or two extras must be zeros. */ -static void outdec(char *p, FILE * f, int count) +static void +outdec(char *p, FILE *f, int count) { int c1, c2, c3, c4; @@ -208,7 +209,8 @@ static void outdec(char *p, FILE * f, in /* Output the CRC value, MSB first per normal CRC conventions */ -static void outcrc(word32 crc, FILE * outFile) +static void +outcrc(word32 crc, FILE *outFile) { char crcbuf[4]; crcbuf[0] = (crc >> 16) & 0xff; @@ -226,7 +228,8 @@ static void outcrc(word32 crc, FILE * ou * >= 1000, then we have other problems to worry about, and this might do * weird things. */ -static char *numFilename(char *fname, int num, int ofnum) +static char * +numFilename(char *fname, int num, int ofnum) { static char fnamenum[MAX_PATH]; int len; @@ -247,7 +250,8 @@ static char *numFilename(char *fname, in * Reads and discards a line from the given file. Returns -1 on error or * EOF, 0 if the line is blank, and 1 if the line is not blank. */ -static int skipline(FILE * f) +static int +skipline(FILE * f) { int state, flag, c; @@ -270,12 +274,14 @@ static int skipline(FILE * f) } } /* skipline */ + /* * Copies a line from the input file to the output. Does NOT copy the * trailing newline. Returns -1 on EOF or error, 0 if the line was terminated * by EOF, and 1 if the line was terminated with a newline sequence. */ -static int copyline(FILE * in, FILE * out) +static int +copyline(FILE * in, FILE * out) { int state, flag, c; @@ -307,7 +313,8 @@ static int copyline(FILE * in, FILE * ou * Passing in a buffer less than 2 characters long is not a terribly bright * idea. */ -static int getline(char *buf, int n, FILE * f) +static int +getline(char *buf, int n, FILE * f) { int state; char *p; @@ -342,16 +349,31 @@ static int getline(char *buf, int n, FIL } /* for (;;) */ } /* getline */ +#if 1 +/* This limit is advisory only; longer lines are handled properly. + * The only requirement is that this be at least as long as the longest + * delimiter string used by PGP + * (e.g. "-----BEGIN PGP MESSAGE, PART %02d/%02d-----\n") + */ +#define MAX_LINE_SIZE 80 +#else +#ifdef MSDOS /* limited stack space */ +#define MAX_LINE_SIZE 256 +#else +#define MAX_LINE_SIZE 1024 +#endif +#endif + /* - * Read a line from file f, buf must be able to hold at least 80 characters. - * Strips trailing spaces and line terminator, can read LF, CRLF and CR - * textfiles. Anything after 80 characters is ignored. It can't be ASCII + * Read a line from file f, buf must be able to hold at least MAX_LINE_SIZE + * characters. Anything after that is ignored. Strips trailing spaces and + * line terminator, can read LF, CRLF and CR textfiles. It can't be ASCII * armor anyway. */ static char * - get_armor_line(char *buf, FILE * f) +get_armor_line(char *buf, FILE * f) { - int c, n = 79; + int c, n = MAX_LINE_SIZE-1; char *p = buf; do { @@ -364,13 +386,23 @@ static char * *buf = '\0'; return NULL; } - /* skip to end of line */ - while (c != '\n' && c != '\r' && c != EOF) + /* + * Skip to end of line, setting n to non-zero if anything trailing is + * not a space (meaning that any trailing whitespace in the buffer is + * not trailing whitespace on the line and should not be stripped). + */ + n = 0; + while (c != '\n' && c != '\r' && c != EOF) { + n |= c ^ ' '; c = getc(f); + } if (c == '\r' && (c = getc(f)) != '\n') ungetc(c, f); - while (--p >= buf && *p == ' '); - *++p = '\0'; + if (!n) { /* Skip trailing whitespace, as described above */ + while (p >= buf && p[-1] == ' ') + --p; + } + *p = '\0'; return buf; } @@ -386,41 +418,27 @@ static char * int pem_lines = 720; #define BYTES_PER_SECTION (LINE_LEN * pem_lines) -#if 1 -/* This limit is advisory only; longer lines are handled properly. - * The only requirement is that this be at least as long as the longest - * delimiter string used by PGP - * (e.g. "-----BEGIN PGP MESSAGE, PART %02d/%02d-----\n") - */ -#define MAX_LINE_SIZE 80 -#else -#ifdef MSDOS /* limited stack space */ -#define MAX_LINE_SIZE 256 -#else -#define MAX_LINE_SIZE 1024 -#endif -#endif - #ifndef VMS /* armored files are opened in binary mode so that CRLF/LF/CR files can be handled by all systems */ -#define FOPRPEM FOPRBIN +#define FOPRARMOR FOPRBIN #else -#define FOPRPEM FOPRTXT +#define FOPRARMOR FOPRTXT #endif extern boolean verbose; /* Undocumented command mode in PGP.C */ extern boolean filter_mode; /* - * Copy from infilename to outfilename, PEM encoding as you go along, - * and with breaks every - * pem_lines lines. + * Copy from infilename to outfilename, ASCII armoring as you go along, + * and with breaks every pem_lines lines. * If clearfilename is non-NULL, first output that file preceded by a - * special header line. + * special delimiter line. filename is the original filename, used + * only for debugging. */ -static -int pem_file(char *infilename, char *outfilename, char *clearfilename) +int +armor_file(char *infilename, char *outfilename, char *filename, + char *clearfilename) { char buffer[MAX_LINE_SIZE]; int i, rc, bytesRead, lines = 0; @@ -430,6 +448,11 @@ int pem_file(char *infilename, char *out FILE *inFile, *outFile, *clearFile; char *blocktype = "MESSAGE"; + if (verbose) + fprintf(pgpout, +"armor_file: infile = %s, outfile = %s, filename = %s, clearname = %s\n", + infilename, outfilename, filename, clearfilename); + /* open input file as binary */ if ((inFile = fopen(infilename, FOPRBIN)) == NULL) return 1; @@ -583,16 +606,16 @@ int pem_file(char *infilename, char *out i == noSections ? "\n" : ", "); } return 0; -} /* pem_file */ +} /* armor_file */ -/* End PEM encode routines. */ +/* End ASCII armor encode routines. */ /* - * PEM decode routines. + * ASCII armor decode routines. */ -static -int dpem_buffer(char *inbuf, char *outbuf, int *outlength) +static int +darmor_buffer(char *inbuf, char *outbuf, int *outlength) { unsigned char *bp; int length; @@ -652,34 +675,34 @@ int dpem_buffer(char *inbuf, char *outbu *outlength = length; return 0; /* normal return */ -} /* dpem_buffer */ +} /* darmor_buffer */ -static char pemfilename[MAX_PATH]; +static char armorfilename[MAX_PATH]; /* * try to open the next file of a multi-part armored file * the sequence number is expected at the end of the file name */ static FILE * - open_next(void) +open_next(void) { char *p, *s, c; FILE *fp; - p = pemfilename + strlen(pemfilename); - while (--p >= pemfilename && isdigit(*p)) { + p = armorfilename + strlen(armorfilename); + while (--p >= armorfilename && isdigit(*p)) { if (*p != '9') { ++*p; - return fopen(pemfilename, FOPRPEM); + return fopen(armorfilename, FOPRARMOR); } *p = '0'; } /* need an extra digit */ - if (p >= pemfilename) { + if (p >= armorfilename) { /* try replacing character ( .as0 -> .a10 ) */ c = *p; *p = '1'; - if ((fp = fopen(pemfilename, FOPRPEM)) != NULL) + if ((fp = fopen(armorfilename, FOPRARMOR)) != NULL) return fp; *p = c; /* restore original character */ } @@ -688,18 +711,107 @@ static FILE * s[1] = *s; *p = '1'; /* insert digit ( fn0 -> fn10 ) */ - return fopen(pemfilename, FOPRPEM); + return fopen(armorfilename, FOPRARMOR); +} + +/* + * Returns -1 if the line given is does not begin as a valid ASCII + * armor header line (something of the form "Label: ", where "Label" + * must begin with a letter followed by letters, numbers, or hyphens, + * followed immediately by a colon and a space), 0 if it is a familiar + * label, and the length of the label if it is an unfamiliar label + * (E.g. not "Version" or "Comment"); + */ +static int +isheaderline(char const *buf) +{ + int i; + + if (!isalpha(*buf)) + return -1; /* Not a label */ + + for (i = 1; isalnum(buf[i]) || i == '-'; i++) + ; + if (buf[i] != ':' || buf[i+1] != ' ') + return -1; /* Not a label */ + + if (memcmp(buf, "Version", i) == 0 || + memcmp(buf, "Comment", i) == 0) + return 0; /* Familiar label */ + return i; /* Unfamiliar label */ +} + +/* + * Skips a bunch of headers, either returning 0, or printing + * an error message and returning -1. + * If it encounters an unfamiliar label and *warned is not set, + * prints a warning and sets *warned. + * NOTE that file read errors are NOT printed or reported in the + * return code. It is assumed that the following read will + * notice the error and do something appropriate. + */ +static int +skipheaders(FILE *in, char *buf, int *warned, int armorfollows) +{ + int label_seen = 0; + int i; +#ifndef STRICT_ARMOR /* Allow no space */ + long fpos; + char outbuf[(MAX_LINE_SIZE*3+3)/4]; + int n; +#endif + + for (;;) { + ++infile_line; +#ifndef STRICT_ARMOR + fpos = ftell(in); +#endif + if (get_armor_line(buf, in) == NULL) /* Error */ + return 0; /* See comment above */ + if (buf[0] == '\0') /* Blank line */ + return 0; /* Success */ + if (label_seen && (buf[0] == ' ' || buf[0] == '\t')) + continue; /* RFC-822-style continuation line */ + i = isheaderline(buf); + if (i < 0) { /* Not a legal header line */ +#ifndef STRICT_ARMOR /* If it's as ASCII armor line, accept it */ + if (armorfollows && darmor_buffer(buf, outbuf, &n) == 0 && n == 48) + { + fseek(in, fpos, SEEK_SET); + --infile_line; + return 0; /* Consider this acceptable */ + } +#else + (void)armorfollows; /* Stop compiler complaints */ +#endif + fprintf(pgpout, +LANG("Invalid ASCII armor header line: \"%.40s\"\n\ +ASCII armor corrupted.\n"), buf); + return -1; + } + if (i > 0 && !*warned) { + fprintf(pgpout, +LANG("Warning: Unrecognized ASCII armor header label \"%.*s:\" ignored.\n"), + i, buf); + *warned = 1; + } + label_seen = 1; /* Continuation lines are now legal */ + } } /* * Copy from in to out, decoding as you go, with handling for multiple - * 500-line blocks of encoded data. + * 500-line blocks of encoded data. This function also knows how to + * go past the end of one part to the beginning of the next in a multi-part + * file. (As you can see from some ugliness below, this is not the best + * place to do it, since the caller is responsible for closing the + * "original_in" file.) */ -static -int pemdecode(FILE * in, FILE * out) +static int +armordecode(FILE *original_in, FILE *out, int *warned) { - char inbuf[80]; - char outbuf[80]; + char inbuf[MAX_LINE_SIZE]; + char outbuf[MAX_LINE_SIZE]; int i, n, status; int line; @@ -710,6 +822,7 @@ int pemdecode(FILE * in, FILE * out) char crcbuf[4]; int ret_code = 0; int end_of_message; + FILE *in = original_in; init_crc(); @@ -739,12 +852,10 @@ int pemdecode(FILE * in, FILE * out) /* Try and find start of next section */ do { if (get_armor_line(inbuf, in) == NULL) { - FILE *nextf; - if ((nextf = open_next()) != NULL) { + if (in != original_in) fclose(in); - in = nextf; - continue; - } + if ((in = open_next()) != NULL) + continue; /* Keep working on new in */ fprintf(pgpout, LANG("Can't find section %d.\n"), currentSection + 1); return -1; @@ -758,9 +869,9 @@ int pemdecode(FILE * in, FILE * out) "-----BEGIN PGP MESSAGE, PART %d/%d", §ion, &noSections)) { fprintf(pgpout, - LANG("Badly formed section header, part %d.\n"), + LANG("Badly formed section delimiter, part %d.\n"), currentSection + 1); - return -1; + goto error; } if (section != ++currentSection) { fprintf(pgpout, @@ -770,22 +881,22 @@ LANG("Sections out of order, expected pa LANG(", got part %d\n"), section); else fputc('\n', pgpout); - return -1; + goto error; } /* Skip header after BEGIN line */ - do { - ++infile_line; - if (get_armor_line(inbuf, in) == NULL) { - fprintf(pgpout, - LANG("ERROR: Hit EOF in header of section %d.\n"), - currentSection); - return -1; - } - } while (inbuf[0] != '\0'); - + if (skipheaders(in, inbuf, warned, 1) < 0) + goto error; + if (feof(in)) { + fprintf(pgpout, + LANG("ERROR: Hit EOF in header of section %d.\n"), + currentSection); + goto error; + } + /* Continue decoding */ continue; } + /* Quit when hit the -----END PGP MESSAGE----- line or a blank, * or handle checksum */ @@ -798,13 +909,13 @@ LANG("Sections out of order, expected pa */ if (strlen(inbuf) == 7 && inbuf[1] == '3' && inbuf[2] == 'D') - status = dpem_buffer(inbuf + 3, crcbuf, &n); + status = darmor_buffer(inbuf + 3, crcbuf, &n); else - status = dpem_buffer(inbuf + 1, crcbuf, &n); + status = darmor_buffer(inbuf + 1, crcbuf, &n); if (status < 0 || n != 3) { fprintf(pgpout, LANG("ERROR: Badly formed ASCII armor checksum, line %d.\n"), line); - return -1; + goto error; } chkcrc = (((long) crcbuf[0] << 16) & 0xff0000L) + ((crcbuf[1] << 8) & 0xff00L) + (crcbuf[2] & 0xffL); @@ -819,7 +930,7 @@ LANG("ERROR: Badly formed ASCII armor ch if (strncmp(inbuf, "-----END PGP ", 13) == 0) break; - status = dpem_buffer(inbuf, outbuf, &n); + status = darmor_buffer(inbuf, outbuf, &n); if (status == -1) { fprintf(pgpout, @@ -832,7 +943,7 @@ LANG("ERROR: Badly formed ASCII armor ch fprintf(pgpout, LANG("ERROR: Bad ASCII armor line length %d on line %d.\n"), n, line); - return -1; + goto error; } crc = crcbytes((byte *) outbuf, n, crc); if (fwrite(outbuf, 1, n, out) != n) { @@ -849,29 +960,35 @@ LANG("ERROR: Badly formed ASCII armor ch fprintf(pgpout, LANG(" in section %d"), noSections); fputc('\n', pgpout); - return -1; + goto error; } } else { fprintf(pgpout, LANG("Warning: Transport armor lacks a checksum.\n")); } + if (in != original_in) + fclose(in); return ret_code; /* normal return */ -} /* pemdecode */ +error: + if (in != original_in) + fclose(in); + return -1; /* error return */ +} /* armordecode */ -static -boolean is_pemfile(char *infile) +static boolean +is_armorfile(char *infile) { FILE *in; - char inbuf[80]; - char outbuf[80]; - int n, status; + char inbuf[MAX_LINE_SIZE]; + char outbuf[MAX_LINE_SIZE]; + int n; long il; - if ((in = fopen(infile, FOPRPEM)) == NULL) { - /* can't open file */ - return FALSE; - } + in = fopen(infile, FOPRARMOR); + if (in == NULL) + return FALSE; /* can't open file */ + /* Read to infile_line before we begin looking */ for (il = 0; il < infile_line; ++il) { if (get_armor_line(inbuf, in) == NULL) { @@ -880,59 +997,46 @@ boolean is_pemfile(char *infile) } } - /* search file for header line */ + /* search file for delimiter line */ for (;;) { - if (get_armor_line(inbuf, in) == NULL) { + if (get_armor_line(inbuf, in) == NULL) break; - } else { - if (strncmp(inbuf, "-----BEGIN PGP ", 15) == 0) { - if (strncmp(inbuf, - "-----BEGIN PGP SIGNED MESSAGE-----", 34) == 0) { - fclose(in); - return TRUE; - } - do { - if (get_armor_line(inbuf, in) == NULL) - break; -#ifndef STRICT_PEM - if (dpem_buffer(inbuf, outbuf, &n) == 0 - && n == 48) { - fclose(in); - return TRUE; - } -#endif - } while (inbuf[0] != '\0'); - if (get_armor_line(inbuf, in) == NULL) - break; - status = dpem_buffer(inbuf, outbuf, &n); - if (status < 0) - break; + if (strncmp(inbuf, "-----BEGIN PGP ", 15) == 0) { + if (strncmp(inbuf, + "-----BEGIN PGP SIGNED MESSAGE-----", 34) == 0) { fclose(in); return TRUE; } + n = 1; /* Don't print warnings yet */ + if (skipheaders(in, inbuf, &n, 1) < 0 || + get_armor_line(inbuf, in) == NULL || + darmor_buffer(inbuf, outbuf, &n) < 0) + break; + fclose(in); + return TRUE; } } fclose(in); return FALSE; +} /* is_armorfile */ -} /* is_pemfile */ - -static -int dpem_file(char *infile, char *outfile) +static int +darmor_file(char *infile, char *outfile) { FILE *in, *out; char buf[MAX_LINE_SIZE]; - char outbuf[80]; + char outbuf[(MAX_LINE_SIZE*3+3)/4]; int status, n; long il, fpos; char *litfile = NULL; + int header_warned = 0; /* Complained about unknown header */ - if ((in = fopen(infile, FOPRPEM)) == NULL) { + if ((in = fopen(infile, FOPRARMOR)) == NULL) { fprintf(pgpout, LANG("ERROR: Can't find file %s\n"), infile); return 10; } - strcpy(pemfilename, infile); /* store filename for multi-parts */ + strcpy(armorfilename, infile); /* store filename for multi-parts */ /* Skip to infile_line */ for (il = 0; il < infile_line; ++il) { @@ -942,10 +1046,10 @@ int dpem_file(char *infile, char *outfil } } - /* Loop through file, searching for header. Decode anything with a - header, complain if there were no headers. */ + /* Loop through file, searching for delimiter. Decode anything with a + delimiter, complain if there were no delimiter. */ - /* search file for header line */ + /* search file for delimiter line */ for (;;) { ++infile_line; if (get_armor_line(buf, in) == NULL) { @@ -962,6 +1066,42 @@ int dpem_file(char *infile, char *outfil char *canonfile, *p; int nline; + /* + * It would be nice to allow headers here, as we could add + * additional information to PGP messages, but it appears to + * be too easy to spoof, given standard text viewers. So, + * forbid it outright until we sit down and figure out how to + * thwart all the ways of faking an end-of-headers. The + * possibilities are: + * - Enough trailing whitespace on a valid-looking line to force a + * line wrap. The 80 column case is tricky, as the classical + * Big Iron IBM mainframe pads to 80 columns, and some terminal + * and text viewer combinations cause a blank line, while others + * don't. A line that is exactly 80 columns wide but ends in + * a non-blank would do, too. + * - A big pile of whitespace within a line, enough to + * produce something that looks like a blank line between + * the brginning and end parts. + * - Various cursor-control sequences. + * Basically, it's a nasty problem. A very strong case can be made + * for the argument that it's the text viewer's problem, and outside + * PGP's jurisdiction, but that has a few conflicts with reality. + */ + if (get_armor_line(buf, in) == NULL) { + fprintf(pgpout, +LANG("ERROR: ASCII armor decode input ended unexpectedly!\n")); + fclose(in); + return 12; + } + if (buf[0] != '\0') { + fprintf(pgpout, +LANG("ERROR: Header line added to ASCII armor: \"%s\"\n\ +ASCII armor corrupted.\n"), buf); + fclose(in); + return -1; + + } + litfile = tempfile(TMP_WIPE | TMP_TMPDIR); if ((litout = fopen(litfile, FOPWTXT)) == NULL) { fprintf(pgpout, @@ -969,12 +1109,7 @@ LANG("\n\007Unable to write ciphertext o fclose(in); return -1; } - /* Skip header lines until a blank is hit */ - do { - ++infile_line; - status = skipline(in); - } while (status != 0); - /* Ignore error; getline will discover it again */ + status = 0; for (;;) { ++infile_line; @@ -1014,22 +1149,15 @@ LANG("ERROR: ASCII armor decode input en litfile = canonfile; } /* Skip header after BEGIN line */ - do { - ++infile_line; - fpos = ftell(in); - if (get_armor_line(buf, in) == NULL) { - fprintf(pgpout, LANG("ERROR: Hit EOF in header.\n")); - fclose(in); - return 13; - } -#ifndef STRICT_PEM - if (dpem_buffer(buf, outbuf, &n) == 0 && n == 48) { - fseek(in, fpos, SEEK_SET); - --infile_line; - break; - } -#endif - } while (buf[0] != '\0'); + if (skipheaders(in, buf, &header_warned, 1) < 0) { + fclose(in); + return -1; + } + if (feof(in)) { + fprintf(pgpout, LANG("ERROR: Hit EOF in header.\n")); + fclose(in); + return 13; + } if ((out = fopen(outfile, FOPWBIN)) == NULL) { fprintf(pgpout, @@ -1037,13 +1165,14 @@ LANG("\n\007Unable to write ciphertext o fclose(in); return -1; } - status = pemdecode(in, out); + status = armordecode(in, out, &header_warned); if (litfile) { /* Glue the literal file read above to the signature */ char lit_mode = MODE_TEXT; word32 dummystamp = 0; FILE *f = fopen(litfile, FOPRBIN); + write_ctb_len(out, CTB_LITERAL2_TYPE, fsize(f) + 6, FALSE); fwrite(&lit_mode, 1, 1, out); /* write lit_mode */ fputc('\0', out); /* No filename */ @@ -1058,17 +1187,9 @@ LANG("\n\007Unable to write ciphertext o fclose(out); fclose(in); return status; -} /* dpem_file */ +} /* darmor_file */ /* Entry points for generic interface names */ -int armor_file(char *infile, char *outfile, char *filename, char *clearname) -{ - if (verbose) - fprintf(pgpout, -"armor_file: infile = %s, outfile = %s, filename = %s, clearname = %s\n", - infile, outfile, filename, clearname); - return pem_file(infile, outfile, clearname); -} int de_armor_file(char *infile, char *outfile, long *curline) { @@ -1079,7 +1200,7 @@ int de_armor_file(char *infile, char *ou "de_armor_file: infile = %s, outfile = %s, curline = %ld\n", infile, outfile, *curline); infile_line = (curline ? *curline : 0); - status = dpem_file(infile, outfile); + status = darmor_file(infile, outfile); if (curline) *curline = infile_line; return status; @@ -1089,5 +1210,5 @@ boolean is_armor_file(char *infile, long startline) { infile_line = startline; - return is_pemfile(infile); + return is_armorfile(infile); }