ARMOR(3)

NAME
armor - routines to (de)armor

SYNOPSIS
#include <pgplib.h>
int
armor_buffer(u_char *ibuf, int ilen, int *used, char **obuf, int *olen);
int
armor_file(FILE *in, FILE *out);
int
dearmor_buffer(char *ibuf, long ilen, int *used, char **obuf, int *olen);
int
dearmor_file(FILE *in, FILE *out);
int
read_armored_package(FILE *in, char **obuf, int *olen);
int
pemDecode(char *in, u_char *out, int *outlen);
int
pemEncode(u_char *in, int inlen, char *out, int *outlen);
.

DESCRIPTION
These routines provides an interface to the "armored" format specified by RFC1991.

The routines armor_buffer() and dearmor_buffer() will armor (and dearmor, repsectively) the data in ibuf (which is ilen bytes long) and write the result in the memory pointed to by obuf. In all cases. the memory pointed to by obuf is (at least) olen bytesand has been allocated by means of malloc(). The caller must free it. Regarding the routines operating on files, in all cases the file in must be open for reading, while the file out must be opened for writing. .

pemEncode() will encode an arbritrary buffer stored in in ( lnlen bytes long) and store the result, outlen bytes worth of data) in out. pemDecode() will decode a zero terminated string stored in in and store the result ( outlen bytes worth of data) in out. All buffers must be allocated by the caller. Encoding stores three bytes of (binary) data into four characters, while decoding packs four characters into three bytes. It follows that pemDecode() must not be called to decode less than four characters (pluss a terminating zero). pemEncode(msu, not, be, called, to, encode, less, than, three, bytes;, if) less than thre bytes are available, the rest, up to the minimum of three, should be chould be set to 0 (zero). .

RETURN VALUES
If successful all routines return 0, upon error, -1 is returned. The routines dearmor_file() and dearmor_buffer() and read_armored_packag() will all return 1 if the input was not recognized. .

BUGS
armor_buffer() should only armor PGP compatible packets. In these cases used might be smaller than len. However, at present, it will armor anything and thus consume the entire buffer.

SEE ALSO
fopen(3) free(3) malloc(3) PGPlib(3) .

HISTORY
Written by Peter Gutmann, Tage Stabell-Kulø and Magne Rassmussen. First appeared in PGPlib 0.1.

STANDARDS
The resulting package is compatible with RFC1991. Encoding (and decoding) of binary data is according to RFC1113.