Lines Matching +full:end +full:- +full:failure
48 // FALSE(0) failure
58 ctx->buffer = buffer; in ASN1UnmarshalContextInitialize()
59 ctx->size = size; in ASN1UnmarshalContextInitialize()
60 ctx->offset = 0; in ASN1UnmarshalContextInitialize()
61 ctx->tag = 0xFF; in ASN1UnmarshalContextInitialize()
80 VERIFY(ctx->offset < ctx->size); in ASN1DecodeLength()
111 ctx->size = -1; // Makes everything fail from now on. in ASN1DecodeLength()
112 return -1; in ASN1DecodeLength()
129 VERIFY(ctx->offset < ctx->size); in ASN1NextTag()
131 ctx->tag = NEXT_OCTET(ctx); in ASN1NextTag()
133 VERIFY((ctx->tag & 0x1F) != 0x1F); in ASN1NextTag()
138 // Attempt to read beyond the end of the context or an illegal tag in ASN1NextTag()
139 ctx->size = -1; // Persistent failure in ASN1NextTag()
140 ctx->tag = 0xFF; in ASN1NextTag()
141 return -1; in ASN1NextTag()
149 // If there is a general parsing error, the context->size is set to -1.
152 // FALSE(0) failure
166 VERIFY(ctx->tag == ASN1_BITSTRING); in ASN1GetBitStringValue()
167 // Get the shift value for the bit field (how many bits to lop off of the end) in ASN1GetBitStringValue()
169 length--; in ASN1GetBitStringValue()
171 inputBits = (8 * length) - shift; in ASN1GetBitStringValue()
175 for(; length > 1; length--) in ASN1GetBitStringValue()
188 VERIFY(((value & (0xFF000000 << (8 - shift)))) == 0); in ASN1GetBitStringValue()
189 value = (value << (8 - shift)) + (NEXT_OCTET(ctx) >> shift); in ASN1GetBitStringValue()
194 value <<= (32 - inputBits); in ASN1GetBitStringValue()
198 ctx->size = -1; in ASN1GetBitStringValue()
208 // the things that will be at the end of the structure are added last. To manage the
210 // there is one, and then placing items in from the bottom up. If the bottom-most
214 // The context control structure contains a 'buffer' pointer, an 'offset', an 'end'
219 // functions make sure that no data is written beyond the end of the buffer.
221 // When a new context is started, the current value of 'end' is pushed
222 // on the stack and 'end' is set to 'offset. As bytes are added, offset gets smaller.
223 // At any time, the count of bytes in the current context is simply 'end' - 'offset'.
225 // Since starting a new context involves setting 'end' = 'offset', the number of bytes
227 // 'end' - 'offset' to set the length value, and then a tag is added to the buffer.
228 // Then the previous 'end' value is popped meaning that the context just ended
233 // simple as the size of the move is the initial 'end' value minus the final 'offset'
242 // process executed again with the data going into the buffer. At the end, the data
255 ctx->buffer = buffer; in ASN1InitialializeMarshalContext()
257 ctx->offset = length; in ASN1InitialializeMarshalContext()
259 ctx->offset = INT16_MAX; in ASN1InitialializeMarshalContext()
260 ctx->end = ctx->offset; in ASN1InitialializeMarshalContext()
261 ctx->depth = -1; in ASN1InitialializeMarshalContext()
272 pAssert((ctx->depth + 1) < MAX_DEPTH); in ASN1StartMarshalContext()
273 ctx->depth++; in ASN1StartMarshalContext()
274 ctx->ends[ctx->depth] = ctx->end; in ASN1StartMarshalContext()
275 ctx->end = ctx->offset; in ASN1StartMarshalContext()
279 // This function restores the end pointer for an encapsulating structure.
289 pAssert(ctx->depth >= 0); in ASN1EndMarshalContext()
290 length = ctx->end - ctx->offset; in ASN1EndMarshalContext()
291 ctx->end = ctx->ends[ctx->depth--]; in ASN1EndMarshalContext()
292 if((ctx->depth == -1) && (ctx->buffer)) in ASN1EndMarshalContext()
294 MemoryCopy(ctx->buffer, ctx->buffer + ctx->offset, ctx->end - ctx->offset); in ASN1EndMarshalContext()
303 // are used, a byte of zero is prepended. If a raw bit-string is needed, a new
307 // == 0 failure
317 ASN1PushTagAndLength(ctx, tag, ctx->end - ctx->offset); in ASN1EndEncapsulation()
328 if(ctx->offset > 0) in ASN1PushByte()
330 ctx->offset -= 1; in ASN1PushByte()
331 if(ctx->buffer) in ASN1PushByte()
332 ctx->buffer[ctx->offset] = b; in ASN1PushByte()
335 ctx->offset = -1; in ASN1PushByte()
343 // == 0 failure unless count was zero
355 ctx->offset -= count; in ASN1PushBytes()
357 VERIFY(ctx->offset >= 0); in ASN1PushBytes()
360 if(count && buffer && ctx->buffer) in ASN1PushBytes()
361 MemoryCopy(&ctx->buffer[ctx->offset], buffer, count); in ASN1PushBytes()
364 ctx->offset = -1; in ASN1PushBytes()
371 // == 0 failure unless count was zero
379 return (ctx->offset >= 0) ? 2 : 0; in ASN1PushNull()
386 // == 0 failure
393 UINT16 start = ctx->offset; in ASN1PushLength()
411 ctx->offset = -1; in ASN1PushLength()
413 return (ctx->offset > 0) ? start - ctx->offset : 0; in ASN1PushLength()
419 // == 0 failure
430 return (ctx->offset < 0) ? 0 : bytes; in ASN1PushTagAndLength()
438 // == 0 failure
455 // This function pushes an native-endian integer value. This just changes a
456 // native-endian integer into a big-endian byte string and calls ASN1PushInteger().
460 // == 0 failure unless count was zero
473 // Push a big-endian integer on the end of the buffer
476 // == 0 failure
481 BYTE *integer // IN: big-endian integer in ASN1PushInteger()
485 while((*integer == 0) && (--iLen > 0)) in ASN1PushInteger()
504 // == 0 failure
515 ctx->offset = -1; in ASN1PushOID()