Download | Plain Text | No Line Numbers
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
- #include <assert.h>
- #include "cipher.h"
-
- #ifdef DEBUG
- # include "hexdump.h"
- #endif
-
- #define BLOCKSIZE 8192
- #define PERL_SHEBANG "#!/usr/bin/perl\n"
- #define PERL_MODULE "use Confixx::Filter;\n"
-
- static const char *me;
-
- void usage()
- {
- }
-
- int main(int argc, char *argv[])
- {
- short encode = 0, stripped = 0, hashkey = 1;
- char *filename = NULL;
- int opt;
-
- me = argv[0];
-
- while ((opt = getopt(argc, argv, "hked")) != -1)
- {
- switch(opt)
- {
- case 'e':
- encode = 1;
- hashkey = 0;
- break;
- case 'd':
- break;
- case 'k':
- hashkey = 0;
- break;
- case 'h':
- default:
- usage();
- break;
- }
- }
- argv += optind;
-
- if (argv)
- filename = *argv;
-
- if (!filename)
- usage();
-
- #ifdef DEBUG
- #endif
-
- FILE *fp = stdin;
- filename = NULL;
- {
- if (errno)
- }
-
- /* allocate buffer for decrypted stuff */
- char out[BLOCKSIZE];
-
- /* cipher */
- ctx_t cipher;
- int ret = CipherInit(&cipher);
- if (ret != 256)
- {
- }
- #ifdef DEBUG
- #endif
-
- /* set pointer to output buffer */
- cipher.out = out;
-
- /* some sanity checks */
-
- /* let CipherUpdate don't prepend a hashkey */
- cipher.prepend_hashkey = hashkey;
-
- /* allocate input buffer */
- char in[BLOCKSIZE];
-
- if (encode)
- {
- }
-
- {
- /* read at most BLOCKSIZE - 1 bytes:
- * - 1 char ("#"-char) will be prepended in decode mode during
- * first call of CipherUpdate()
- */
- {
- if (errno)
- if (filename != NULL)
- }
- in[in_len] = '\0';
-
- #ifdef DEBUG
- #endif
-
- char *inptr = in;
- if (!encode && !stripped)
- {
- inptr += sizeof(PERL_SHEBANG) - 1;
- inptr += sizeof(PERL_MODULE) - 1;
- in_len -= inptr - in;
- }
- stripped = 1;
-
- uint32_t out_len = CipherUpdate(&cipher, inptr, in_len);
- #ifdef DEBUG
- #endif
- /* we don't need one extra byte to terminate the buffer
- * as fwrite has a size parameter
- */
-
- #ifdef DEBUG
- #endif
- }
-
- if (filename != NULL)
- return 0;
- }
-