static int aes_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
			 const unsigned char *in, unsigned int inl)
	{
	int n;
	unsigned char tmp[16];
	RIJNDAEL_KEY *k=ctx->cipher_data;
	while(inl > 0)
		{
		if(ctx->encrypt)
			{
			for(n=0 ; n < 16 ; n++)
				tmp[n] = in[n] ^ ctx->iv[n];
			rijndaelEncrypt(k->rd_key,k->rounds, tmp, out);
			memcpy(ctx->iv,out,16);
			}
		else
			{
			memcpy(tmp, in, 16);
			rijndaelDecrypt(k->rd_key,k->rounds, in, out);
			for(n=0 ; n < 16 ; n++)
				out[n] ^= ctx->iv[n];
			memcpy(ctx->iv,tmp,16);
			}
		inl-=16;
		in+=16;
		out+=16;
		}
	assert(inl == 0);
	return 1;
	}