int decrypt_cryptocom_key(unsigned char *sess_key,int max_key_len,
	const unsigned char *crypted_key,int crypted_key_len, gost_ctx *ctx)
	{
	int i;
	int j;
	int blocks = crypted_key_len >>3;
	unsigned char gamma[8];
	if (max_key_len <crypted_key_len)
		{
		GOSTerr(GOST_F_DECRYPT_CRYPTOCOM_KEY,GOST_R_NOT_ENOUGH_SPACE_FOR_KEY);
		return 0;
		}	
	if ((crypted_key_len & 7) !=0) 
		{
		GOSTerr(GOST_F_DECRYPT_CRYPTOCOM_KEY,GOST_R_INVALID_ENCRYPTED_KEY_SIZE);
		return 0;
		}	
	for (i=blocks-1;i>0;i--) 
		{
		gostcrypt(ctx,crypted_key+(i-1)*8,gamma);
		for(j=0;j<8;j++) 
			{
			sess_key[i*8+j]=gamma[j]^crypted_key[i*8+j];
			}
		}	
	gostcrypt(ctx,sess_key+crypted_key_len-8,gamma);	
	for(j=0;j<8;j++) 
		{
		sess_key[j]=gamma[j]^crypted_key[j];
		}
	return 1;
	}