static int run_test_vectors(void)
	{
	int n;
	int errs = 0;

	for(n=0 ; n < sizeof(ige_test_vectors)/sizeof(ige_test_vectors[0]) ; ++n)
		{
		const struct ige_test * const v = &ige_test_vectors[n];
		AES_KEY key;
		unsigned char buf[MAX_VECTOR_SIZE];
		unsigned char iv[AES_BLOCK_SIZE*2];

		assert(v->length <= MAX_VECTOR_SIZE);

		if(v->encrypt == AES_ENCRYPT)
			AES_set_encrypt_key(v->key, 8*sizeof v->key, &key);
		else
			AES_set_decrypt_key(v->key, 8*sizeof v->key, &key);
		memcpy(iv, v->iv, sizeof iv);
		AES_ige_encrypt(v->in, buf, v->length, &key, iv, v->encrypt);

		if(memcmp(v->out, buf, v->length))
			{
			printf("IGE test vector %d failed\n", n);
			hexdump(stdout, "key", v->key, sizeof v->key);
			hexdump(stdout, "iv", v->iv, sizeof v->iv);
			hexdump(stdout, "in", v->in, v->length);
			hexdump(stdout, "expected", v->out, v->length);
			hexdump(stdout, "got", buf, v->length);

			++errs;
			}

                // try with in == out
		memcpy(iv, v->iv, sizeof iv);
                memcpy(buf, v->in, v->length);
		AES_ige_encrypt(buf, buf, v->length, &key, iv, v->encrypt);

		if(memcmp(v->out, buf, v->length))
			{
			printf("IGE test vector %d failed (with in == out)\n", n);
			hexdump(stdout, "key", v->key, sizeof v->key);
			hexdump(stdout, "iv", v->iv, sizeof v->iv);
			hexdump(stdout, "in", v->in, v->length);
			hexdump(stdout, "expected", v->out, v->length);
			hexdump(stdout, "got", buf, v->length);

			++errs;
			}
		}

	for(n=0 ; n < sizeof(bi_ige_test_vectors)/sizeof(bi_ige_test_vectors[0])
			; ++n)
		{
		const struct bi_ige_test * const v = &bi_ige_test_vectors[n];
		AES_KEY key1;
		AES_KEY key2;
		unsigned char buf[MAX_VECTOR_SIZE];

		assert(v->length <= MAX_VECTOR_SIZE);

		if(v->encrypt == AES_ENCRYPT)
			{
			AES_set_encrypt_key(v->key1, 8*v->keysize, &key1);
			AES_set_encrypt_key(v->key2, 8*v->keysize, &key2);
			}
		else
			{
			AES_set_decrypt_key(v->key1, 8*v->keysize, &key1);
			AES_set_decrypt_key(v->key2, 8*v->keysize, &key2);
			}

		AES_bi_ige_encrypt(v->in, buf, v->length, &key1, &key2, v->iv,
						   v->encrypt);

		if(memcmp(v->out, buf, v->length))
			{
			printf("Bidirectional IGE test vector %d failed\n", n);
			hexdump(stdout, "key 1", v->key1, sizeof v->key1);
			hexdump(stdout, "key 2", v->key2, sizeof v->key2);
			hexdump(stdout, "iv", v->iv, sizeof v->iv);
			hexdump(stdout, "in", v->in, v->length);
			hexdump(stdout, "expected", v->out, v->length);
			hexdump(stdout, "got", buf, v->length);

			++errs;
			}
		}

	return errs;
	}