void AsnBits::DecodeGeneral(AsnBufBits &b, AsnLen &bitsDecoded) { unsigned char* seg; unsigned long templen = 0; long offset = 0; clear(); bitsDecoded += b.OctetAlignRead(); seg = (unsigned char*)b.GetBits(8); bitsDecoded += 8; while((seg[0] & 0xC0) == 0xC0) { seg[0] &= 0x3F; templen = (unsigned long)seg[0]; templen *= l_16k; b.OctetAlignRead(); Allocate(templen); delete [] seg; seg = b.GetBits(templen); memcpy(&bits[offset / 8], seg, ((templen + 7) / 8)); bitsDecoded += templen; bitsDecoded += b.OctetAlignRead(); offset += templen; delete [] seg; seg = (unsigned char*)b.GetBits(8); bitsDecoded += 8; } if((seg[0] & 0xC0) == 0x80) { seg[0] &= 0x3F; templen = (unsigned long)seg[0]; templen <<= 8; delete [] seg; seg = (unsigned char*)b.GetBits(8); bitsDecoded += 8; templen |= (unsigned long)seg[0]; bitsDecoded += b.OctetAlignRead(); Allocate(templen); delete [] seg; seg = b.GetBits(templen); memcpy(&bits[offset / 8], seg, ((templen + 7) / 8)); bitsDecoded += templen; offset += templen; } else if((seg[0] & 0x80) == 0x00) { seg[0] &= 0x7F; templen = (unsigned long)seg[0]; bitsDecoded += b.OctetAlignRead(); Allocate(templen); delete [] seg; seg = b.GetBits(templen); memcpy(&bits[offset / 8], seg, ((templen + 7) / 8)); bitsDecoded += templen; offset += templen; } delete [] seg; }
void PERGeneral::DecodeGeneral(AsnBufBits &b, AsnLen &bitsDecoded) { unsigned char* seg; unsigned long templen = 0; long offset = 0; Clear(); bitsDecoded += b.OctetAlignRead(); seg = (unsigned char*)b.GetBits(8); bitsDecoded += 8; while((seg[0] & 0xC0) == 0xC0) { seg[0] &= 0x3F; templen = (unsigned long)seg[0]; templen *= l_16k; Allocate(templen); bitsDecoded += b.OctetAlignRead(); while(templen) { Deterpret(b, bitsDecoded, offset); offset++; templen--; } bitsDecoded += b.OctetAlignRead(); free(seg); seg = (unsigned char*)b.GetBits(8); bitsDecoded += 8; } if((seg[0] & 0xC0) == 0x80) { seg[0] &= 0x3F; templen = (unsigned long)seg[0]; templen <<= 8; free(seg); seg = (unsigned char*)b.GetBits(8); bitsDecoded += 8; templen |= (unsigned long)seg[0]; Allocate(templen); bitsDecoded += b.OctetAlignRead(); while(templen) { Deterpret(b, bitsDecoded, offset); offset++; templen--; } } else if((seg[0] & 0x80) == 0x00) { seg[0] &= 0x7F; templen = (unsigned long)seg[0]; Allocate(templen); bitsDecoded += b.OctetAlignRead(); while(templen) { Deterpret(b, bitsDecoded, offset); offset++; templen--; } } free(seg); }