/*
 utils.h

 Copyright NTT MCL, 2000.

 Duncan S Wong   
 Security Group, NTT MCL
 July 2000
*/

/* read public key info from a file */
int get_pubKey(EPOC3_PUB_KEY *publicKey, FILE *fp);

/* read private key info from a file */
int get_privKey(EPOC3_PRIV_KEY *privateKey, FILE *fp);

/* read EPOC3 ciphertext info from a file */
int get_ciphertext(EPOC3_CIPHERTEXT *ciphertext, EPOC3_PUB_KEY *publicKey,
                   CIPHER_INFO *cipherInfo, FILE *fp);

/* open filename for read, return NULL if problem */
FILE *open_input(const char *filename);

/* open file for write, return NULL if problem */
FILE *open_output(const char *filename);

/* parse a line in the format "field_id = field_body" */
int parse_field(char *one_line, char *field_id, char *field_body);

/* copy len BYTEs from from to to */
void assignBYTE(BYTE *to, BYTE *from, WORD len);

/* convert xp to a sequence of bytes in big-endian called xp_raw */
void WORD2BYTE(BYTE *xp_raw, mp_srcptr xp, mp_size_t xsize);

mp_size_t BYTE2WORD(mpz_ptr x, BYTE *raw, mp_size_t size);

/* one-time pad */
WORD Vernam(BYTE *K, WORD kLen, BYTE *in, BYTE *out);
