Changeset 1269:bf8648506a58 in roaraudio


Ignore:
Timestamp:
02/27/09 12:53:53 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

introduced OpenPGP commands: store, encrypt sym, encrypt pub

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/vio_cmd.h

    r1266 r1269  
    4343 
    4444#define ROAR_VIO_CMD_BUFSIZE        1024 
     45 
     46 
     47// for OpenPGP interface: 
     48#define ROAR_VIO_PGP_OPTS_NONE      0x00 
     49#define ROAR_VIO_PGP_OPTS_ASCII     0x01 
     50#define ROAR_VIO_PGP_OPTS_SIGN      0x02 
     51#define ROAR_VIO_PGP_OPTS_TEXTMODE  0x04 
     52 
    4553 
    4654struct roar_vio_cmd_child { 
     
    8997int roar_vio_open_gzip(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int level); 
    9098 
    91 int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts); 
     99int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts, int options); 
    92100int roar_vio_open_pgp_decrypt(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw); 
     101int roar_vio_open_pgp_store(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int options); 
     102int roar_vio_open_pgp_encrypt_sym(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int options); 
     103int roar_vio_open_pgp_encrypt_pub(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int options, char * recipient); 
    93104 
    94105#endif 
  • libroar/vio_cmd.c

    r1266 r1269  
    374374} 
    375375 
    376 int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts) { 
     376int roar_vio_open_gpg(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int wronly, char * opts, int options) { 
    377377#ifdef ROAR_HAVE_BIN_GPG 
    378378 char command[1024]; 
     379 char para[1024] = {0}; 
    379380 int pwpipe[2]; 
    380381 int ret; 
    381382 
     383/* 
     384#define ROAR_VIO_PGP_OPTS_NONE      0x00 
     385#define ROAR_VIO_PGP_OPTS_ASCII     0x01 
     386#define ROAR_VIO_PGP_OPTS_SIGN      0x02 
     387#define ROAR_VIO_PGP_OPTS_TEXTMODE  0x04 
     388*/ 
     389 
     390 if ( options & ROAR_VIO_PGP_OPTS_ASCII ) 
     391  strncat(para, "--armor ", 16); 
     392 
     393 if ( options & ROAR_VIO_PGP_OPTS_SIGN ) 
     394  strncat(para, "--sign ", 16); 
     395 
     396 if ( options & ROAR_VIO_PGP_OPTS_TEXTMODE ) 
     397  strncat(para, "--textmode ", 16); 
     398 
    382399 if ( pw != NULL ) { 
    383400  if ( pipe(pwpipe) == -1 ) 
    384401   return -1; 
    385402 
    386   snprintf(command, 1024, "%s --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s", ROAR_HAVE_BIN_GPG, pwpipe[0], opts); 
     403  snprintf(command, 1024, "%s --batch --no-verbose --quiet --passphrase-repeat 0 --passphrase-fd %i %s %s", ROAR_HAVE_BIN_GPG, pwpipe[0], para, opts); 
    387404 
    388405  write(pwpipe[1], pw, strlen(pw)); 
     
    390407  close(pwpipe[1]); 
    391408 } else { 
    392   snprintf(command, 1024, "%s --no-verbose --quiet %s", ROAR_HAVE_BIN_GPG, opts); 
     409  snprintf(command, 1024, "%s --no-verbose --quiet --batch %s %s", ROAR_HAVE_BIN_GPG, para, opts); 
    393410 } 
    394411 
     
    409426 
    410427int roar_vio_open_pgp_decrypt(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw) { 
    411  return roar_vio_open_gpg(calls, dst, pw, 0, "-d"); 
    412 } 
    413  
     428 return roar_vio_open_gpg(calls, dst, pw, 0, "-d", ROAR_VIO_PGP_OPTS_NONE); 
     429} 
     430 
     431int roar_vio_open_pgp_store(struct roar_vio_calls * calls, struct roar_vio_calls * dst, int options) { 
     432 return roar_vio_open_gpg(calls, dst, NULL, 1, "--store", options); 
     433} 
     434 
     435int roar_vio_open_pgp_encrypt_sym(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int options) { 
     436 return roar_vio_open_gpg(calls, dst, pw, 1, "--symmetric", options); 
     437} 
     438int roar_vio_open_pgp_encrypt_pub(struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * pw, int options, char * recipient) { 
     439 char buf[1024]; 
     440 
     441 snprintf(buf, 1024, "-e -r %s", recipient); 
     442 return roar_vio_open_gpg(calls, dst, pw, 1, buf, options); 
     443} 
    414444 
    415445//ll 
Note: See TracChangeset for help on using the changeset viewer.