#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define DIE() abort()
#define __CLIP_H__
#include "../clipdes.h"
#include "../clipdes.c"

/////////////////////////////////////////////////////////////////////////////

int
main()
{
	const char data[] = "12345678ABCDEFGH12345678";
	const char key[] = { '\xdb','\x9f','\xbf','\x24','\x83','\x6a','\x58','\x7d' };

	char buf[1024];
	int n;
	int i;

	printf("%d\n", strlen(data));
//	n = des_ecb_encrypt(buf, sizeof buf, data, strlen(data), key);
	n = des_cbc_encrypt(buf, sizeof buf, data, strlen(data), key);
	printf("%d\n", n);
	for(i = 0; i < n; i++) {
		printf("%02x", buf[i]&255);
		if((i & 7) == 7) printf(" ");
	}
	printf("\n");
//	n = des_ecb_decrypt(buf, sizeof buf, buf, n, key);
	n = des_cbc_decrypt(buf, sizeof buf, buf, n, key);
	printf("%d\n", n);
	printf("%.*s\n", n, buf);
	if((n != (int)strlen(data)) || memcmp(buf, data, n)) DIE();

	getchar();
}

