www.pudn.com > cryptfs030905.rar > fist_getiv.c


/*
 * Copyright (c) 1997-2003 Erez Zadok
 * Copyright (c) 2001-2003 Stony Brook University
 *
 * For specific licensing information, see the COPYING file distributed with
 * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING.
 *
 * This Copyright notice must be kept intact and distributed with all
 * fistgen sources INCLUDING sources generated by fistgen.
 */
/*
 * fist_getkey: get the Initialization Vector (IV) from cryptfs.
 */
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 

int
main(int argc, char *argv[])
{
  int fd, ret, i;
  struct _fist_ioctl_GETIV val;

  if (argc != 2) {
    fprintf(stderr, "Usage: %s file\n", argv[0]);
    exit(1);
  }
  fd = open(argv[1], O_RDONLY);
  if (fd < 0) {
    perror(argv[1]);
    exit(1);
  }
  ret = ioctl(fd, FIST_IOCTL_GETIV, &(val.outiv));
  if (ret < 0) {
    perror("ioctl");
  }
  close(fd);
  for (i=0; i