/*
#  This is version 0.3 of absent
#
#               Copyright (c) 1999 by AT&T.
#  Permission to use, copy, and modify this software without fee is
#  hereby granted, provided that this entire notice is included in all
#  copies of any software which is or includes a copy or modification
#  of this software and in all copies of the supporting documentation
#  for such software.
#
#  SOME PARTS OF ABSENT MAY BE RESTRICTED UNDER UNITED STATES EXPORT
#  REGULATIONS.
#
#  THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
#  IMPLIED WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE
#  ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
#  MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
#  PURPOSE.
*/
#ifndef _KEYS_H
#define KEYS_H
#include "absent.h"
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>
#include <syslog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

#define SLACK_TIME  60  /* allow 60 seconds */
#define NO_STRERROR 1

#ifndef MASTER_KEY
#define MASTER_KEY "/usr/local/pushweb/keys/master_key"
#endif /* !MASTER_KEY_DIR */

extern unsigned long trand32();

void gen_master_key( C_Block master_secret );
int gen_key(long counter,C_Block master_key,C_Block new_key);

int check_time(time_t candidate_time);

void store_key(long counter, C_Block key, char *filename);
int read_key(long *counter, C_Block key, char *filename);

#endif /* _KEYS_H */
