Changeset e832a52 for zcrypt.c


Ignore:
Timestamp:
Mar 17, 2010, 11:30:31 PM (15 years ago)
Author:
Nelson Elhage <nelhage@ksplice.com>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
88f0dae
Parents:
6d7f2a8
git-author:
Nelson Elhage <nelhage@ksplice.com> (03/17/10 21:15:18)
git-committer:
Nelson Elhage <nelhage@ksplice.com> (03/17/10 23:30:31)
Message:
const-ify most of the strings in zcrypt.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zcrypt.c

    r6d7f2a8 re832a52  
    5252} ZWRITEOPTIONS;
    5353
    54 char *GetZephyrVarKeyFile(char *whoami, char *class, char *instance);
    55 int ParseCryptSpec(char *spec, char **keyfile);
     54char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
     55int ParseCryptSpec(const char *spec, const char **keyfile);
    5656char *BuildArgString(char **argv, int start, int end);
    57 char *read_keystring(char *keyfile);
    58 
    59 int do_encrypt(int zephyr, char *class, char *instance,
    60                ZWRITEOPTIONS *zoptions, char* keyfile, int cipher);
    61 int do_encrypt_des(char *keyfile, char *in, int len, FILE *out);
    62 int do_encrypt_aes(char *keyfile, char *in, int len, FILE *out);
    63 
    64 int do_decrypt(char *keyfile, int cipher);
    65 int do_decrypt_aes(char *keyfile);
    66 int do_decrypt_des(char *keyfile);
     57char *read_keystring(const char *keyfile);
     58
     59int do_encrypt(int zephyr, const char *class, const char *instance,
     60               ZWRITEOPTIONS *zoptions, const char* keyfile, int cipher);
     61int do_encrypt_des(const char *keyfile, const char *in, int len, FILE *out);
     62int do_encrypt_aes(const char *keyfile, const char *in, int len, FILE *out);
     63
     64int do_decrypt(const char *keyfile, int cipher);
     65int do_decrypt_aes(const char *keyfile);
     66int do_decrypt_des(const char *keyfile);
    6767
    6868
     
    8181
    8282typedef struct {
    83   int (*encrypt)(char *keyfile, char *in, int len, FILE *out);
    84   int (*decrypt)(char *keyfile);
     83  int (*encrypt)(const char *keyfile, const char *in, int len, FILE *out);
     84  int (*decrypt)(const char *keyfile);
    8585} cipher_pair;
    8686
     
    104104{
    105105  char *cryptspec = NULL;
    106   char *keyfile;
     106  const char *keyfile;
    107107  int cipher;
    108108  int error = FALSE;
     
    333333}
    334334
    335 int ParseCryptSpec(char *spec, char **keyfile) {
     335int ParseCryptSpec(const char *spec, const char **keyfile) {
    336336  int cipher = CIPHER_DES;
    337337  char *cipher_name = strdup(spec);
     
    402402#define MAX_SEARCH 3
    403403/* Find the class/instance in the .crypt-table */
    404 char *GetZephyrVarKeyFile(char *whoami, char *class, char *instance)
     404char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
    405405{
    406406  char *keyfile = NULL;
     
    491491
    492492/* Open a pipe to zwrite */
    493 FILE *GetZephyrPipe(char *class, char *instance, ZWRITEOPTIONS *zoptions)
     493FILE *GetZephyrPipe(const char *class, const char *instance, const ZWRITEOPTIONS *zoptions)
    494494{
    495495  int fildes[2];
    496496  pid_t pid;
    497497  FILE *result;
    498   char *argv[20];
     498  const char *argv[20];
    499499  int argc = 0;
    500500
     
    547547    }
    548548    close(fildes[0]);
    549     execvp(argv[0], argv);
     549    execvp(argv[0], (char **)argv);
    550550    fprintf(stderr, "Exec error: could not run zwrite\n");
    551551    exit(0);
     
    642642}
    643643
    644 char *read_keystring(char *keyfile) {
     644char *read_keystring(const char *keyfile) {
    645645  char *keystring;
    646646  FILE *fkey = fopen(keyfile, "r");
     
    661661/* Encrypt stdin, with prompt if isatty, and send to stdout, or to zwrite
    662662   if zephyr is set. */
    663 int do_encrypt(int zephyr, char *class, char *instance,
    664                ZWRITEOPTIONS *zoptions, char* keyfile, int cipher)
     663int do_encrypt(int zephyr, const char *class, const char *instance,
     664               ZWRITEOPTIONS *zoptions, const char *keyfile, int cipher)
    665665{
    666666  FILE *outfile = stdout;
     
    696696}
    697697
    698 int do_encrypt_des(char *keyfile, char *in, int length, FILE *outfile)
     698int do_encrypt_des(const char *keyfile, const char *in, int length, FILE *outfile)
    699699{
    700700  des_key_schedule schedule;
    701701  unsigned char input[8], output[8];
    702   char *inptr;
     702  const char *inptr;
    703703  int num_blocks, last_block_size;
    704704  char *keystring;
     
    756756}
    757757
    758 int do_encrypt_aes(char *keyfile, char *in, int length, FILE *outfile)
     758int do_encrypt_aes(const char *keyfile, const char *in, int length, FILE *outfile)
    759759{
    760760  char *out;
     
    832832
    833833/* Decrypt stdin */
    834 int do_decrypt(char *keyfile, int cipher)
     834int do_decrypt(const char *keyfile, int cipher)
    835835{
    836836  return ciphers[cipher].decrypt(keyfile);
    837837}
    838838
    839 int do_decrypt_aes(char *keyfile) {
     839int do_decrypt_aes(const char *keyfile) {
    840840  char *in, *out;
    841841  int length;
     
    865865}
    866866
    867 int do_decrypt_des(char *keyfile) {
     867int do_decrypt_des(const char *keyfile) {
    868868  des_key_schedule schedule;
    869869  unsigned char input[8], output[8];
Note: See TracChangeset for help on using the changeset viewer.