void get_mac(byte *buffer,int nbits,byte *out)
	{
	int nbytes= nbits >> 3;
	int rembits = nbits & 7;
	int mask =rembits?((1<rembits)-1):0;
	int i;
	for (i=0;i<nbytes;i++) out[i]=buffer[i];
	if (rembits) out[i]=buffer[i]&mask;
	}