#ifndef DECRYPTION_H
#define DECRYPTION_H
#include <vsos.h>

/* Change to 1 so the decryption programs stays in memory.
 * with zero LoadLib and DropLib are needed.
 */
#define DECRYPTION_STAYS_IN_MEMORY 0

/* Encrypted source and decrypted destination drives */
#define ENCRYPTED_DEV 'D'
#define DECRYPTED_DEV 'E'

/* Common with decplay and decrypt (device) */
/* Modify for your cipher needs. */
#define CRYPTO_BUF_SIZE 32 /* Don't touch or it breaks. */
struct CryptContext {
	u_int32 pos;
	FILE *fi;
	u_int32 key[8];
	u_int32 nonce[3];
	u_int16 bufIndex;
	u_int16 buf[CRYPTO_BUF_SIZE];
	u_int32 state[16];
	/* u_int16 someState; */ /* Crypt implemention dependent and size can grow */
};
/* CryptoStart() is called when this program is executed, it can get keys for
   the decryption system
*/
ioresult CryptoStart(char *parameters, struct CryptContext *ctx);
/* Function to initialize crypt context for file. Executed when file is opened */
void InitCrypt(struct CryptContext *ctx, const char *name);
/* Decrypting function */
void Decrypt( void *buf, u_int16 destinationIndex, u_int16 bytes, struct CryptContext *ctx, u_int32 pos);

/* Convert ASCII character to hexadecimal digit:
   0-9 -> 0-9, a-f or A-F -> 10-15, anything else 0xFFFF. */
u_int16 ToHex(register __c0 char c);

void XorVec(register __i0 u_int16 *d, register __i2 const u_int16 *s,
	    register __c0 s_int16 cnt);
#endif
