def _findStatic(berTLVArray, bTLVOff, berTagArray, bTagOff): tlv = BERTLV.getInstance(berTLVArray, bTLVOff) firstOff = bTLVOff + tlv.getTag().size() + getLengthLen(tlv.getLength()) if berTagArray is None: if tlv.getLength() > 0: # return the first one return firstOff else: return -1 offset = tlv._find(BERTag.getInstance(berTagArray, bTagOff)) if offset == -1: return -1 return firstOff + offset
def getInstance(bArray, bOff, bLen = None): if bLen is None: # This is a trick of mine, the JC framework will anyway always # call it will three arguments bLen = BERTLV.getLength(bArray, bOff) tag = BERTag.getInstance(bArray, bOff) if tag.isConstructed(): tlv = ConstructedBERTLV(0) else: tlv = PrimitiveBERTLV(0) bOff += tag.size() l, length = _getLength(bArray[bOff:]) # this calls the init method of the child class, not BERTLV tlv.init(tag, bArray, bOff + l, bLen - tag.size() - l) return tlv
def _findNextStatic(berTLVArray, bTLVOff, startOffset, berTagArray, bTagOff): tlv = BERTLV.getInstance(berTLVArray, bTLVOff) firstOff = bTLVOff + tlv.getTag().size() + getLengthLen(tlv.getLength()) # startOffset dos not has to be right on it ... correctStartOff = 0 while firstOff + correctStartOff < startOffset: correctStartOff = tlv._find(None, correctStartOff) if correctStartOff == -1: return -1 startOffset = correctStartOff nextOff = tlv._find(None, startOff) if berTagArray is None: return firstOff + nextOff offset = tlv._find(BERTag.getInstance(berTagArray, bTagOff), nextOff) if offset == -1: return -1 return firstOff + offset
def _getLengthStatic(berTLVArray, bOff): tag = BERTag.getInstance(berTLVArray, bOff) lenOff = bOff + tag.size() (llen, length) = _getLength(berTLVArray[lenOff:]) return tag.size() + llen + length