Home | History | Annotate | Download | only in openssl

Lines Matching refs:cbb

33 // A "CBB" (CRYPTO ByteBuilder) is a memory buffer that grows as needed and
175 // bit. |CBS| and |CBB| APIs consider the constructed bit to be part of the
296 // |CBB| objects allow one to build length-prefixed serialisations. A |CBB|
298 // |CBB_init|. Several |CBB| objects can point at the same buffer when a
299 // length-prefix is pending, however only a single |CBB| can be 'current' at
301 // the new |CBB| points at the same buffer as the original. But if the original
302 // |CBB| is used then the length prefix is written out and the new |CBB| must
305 // If one needs to force a length prefix to be written out because a |CBB| is
306 // going out of scope, use |CBB_flush|. If an operation on a |CBB| fails, it is
315 char error; /* One iff there was an error writing to this CBB. All future
321 // child points to a child CBB if a length-prefix is pending.
322 CBB *child;
323 // offset is the number of bytes from the start of |base->buf| to this |CBB|'s
326 // pending_len_len contains the number of bytes in this |CBB|'s pending
330 // is_top_level is true iff this is a top-level |CBB| (as opposed to a child
331 // |CBB|). Top-level objects are valid arguments for |CBB_finish|.
335 // CBB_zero sets an uninitialised |cbb| to the zero state. It must be
338 // uniform cleanup of a |CBB|.
339 OPENSSL_EXPORT void CBB_zero(CBB *cbb);
341 // CBB_init initialises |cbb| with |initial_capacity|. Since a |CBB| grows as
344 OPENSSL_EXPORT int CBB_init(CBB *cbb, size_t initial_capacity);
346 // CBB_init_fixed initialises |cbb| to write to |len| bytes at |buf|. Since
347 // |buf| cannot grow, trying to write more than |len| bytes will cause CBB
349 OPENSSL_EXPORT int CBB_init_fixed(CBB *cbb, uint8_t *buf, size_t len);
351 // CBB_cleanup frees all resources owned by |cbb| and other |CBB| objects
355 // This function can only be called on a "top level" |CBB|, i.e. one initialised
356 // with |CBB_init| or |CBB_init_fixed|, or a |CBB| set to the zero state with
358 OPENSSL_EXPORT void CBB_cleanup(CBB *cbb);
365 // It can only be called on a "top level" |CBB|, i.e. one initialised with
368 OPENSSL_EXPORT int CBB_finish(CBB *cbb, uint8_t **out_data, size_t *out_len);
371 // |CBB| objects of |cbb| to be invalidated. This allows |cbb| to continue to be
372 // used after the children go out of scope, e.g. when local |CBB| objects are
373 // added as children to a |CBB| that persists after a function returns. This
375 OPENSSL_EXPORT int CBB_flush(CBB *cbb);
377 // CBB_data returns a pointer to the bytes written to |cbb|. It does not flush
378 // |cbb|. The pointer is valid until the next operation to |cbb|.
381 // CBB with any active children.
382 OPENSSL_EXPORT const uint8_t *CBB_data(const CBB *cbb);
384 // CBB_len returns the number of bytes written to |cbb|. It does not flush
385 // |cbb|.
388 // CBB with any active children.
389 OPENSSL_EXPORT size_t CBB_len(const CBB *cbb);
391 // CBB_add_u8_length_prefixed sets |*out_contents| to a new child of |cbb|. The
392 // data written to |*out_contents| will be prefixed in |cbb| with an 8-bit
394 OPENSSL_EXPORT int CBB_add_u8_length_prefixed(CBB *cbb, CBB *out_contents);
396 // CBB_add_u16_length_prefixed sets |*out_contents| to a new child of |cbb|.
397 // The data written to |*out_contents| will be prefixed in |cbb| with a 16-bit,
399 OPENSSL_EXPORT int CBB_add_u16_length_prefixed(CBB *cbb, CBB *out_contents);
401 // CBB_add_u24_length_prefixed sets |*out_contents| to a new child of |cbb|.
402 // The data written to |*out_contents| will be prefixed in |cbb| with a 24-bit,
404 OPENSSL_EXPORT int CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents);
406 // CBB_add_asn1 sets |*out_contents| to a |CBB| into which the contents of an
409 OPENSSL_EXPORT int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned tag);
411 // CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on
413 OPENSSL_EXPORT int CBB_add_bytes(CBB *cbb, const uint8_t *data, size_t len);
415 // CBB_add_space appends |len| bytes to |cbb| and sets |*out_data| to point to
419 OPENSSL_EXPORT int CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len);
421 // CBB_reserve ensures |cbb| has room for |len| additional bytes and sets
425 // valid until the next operation on |cbb| or an ancestor |CBB|.
426 OPENSSL_EXPORT int CBB_reserve(CBB *cbb, uint8_t **out_data, size_t len);
428 // CBB_did_write advances |cbb| by |len| bytes, assuming the space has been
430 OPENSSL_EXPORT int CBB_did_write(CBB *cbb, size_t len);
432 // CBB_add_u8 appends an 8-bit number from |value| to |cbb|. It returns one on
434 OPENSSL_EXPORT int CBB_add_u8(CBB *cbb, uint8_t value);
436 // CBB_add_u16 appends a 16-bit, big-endian number from |value| to |cbb|. It
438 OPENSSL_EXPORT int CBB_add_u16(CBB *cbb, uint16_t value);
440 // CBB_add_u24 appends a 24-bit, big-endian number from |value| to |cbb|. It
442 OPENSSL_EXPORT int CBB_add_u24(CBB *cbb, uint32_t value);
444 // CBB_add_u32 appends a 32-bit, big-endian number from |value| to |cbb|. It
446 OPENSSL_EXPORT int CBB_add_u32(CBB *cbb, uint32_t value);
448 // CBB_discard_child discards the current unflushed child of |cbb|. Neither the
450 OPENSSL_EXPORT void CBB_discard_child(CBB *cbb);
452 // CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1|
455 OPENSSL_EXPORT int CBB_add_asn1_uint64(CBB *cbb, uint64_t value);
457 // CBB_add_asn1_octet_string writes an ASN.1 OCTET STRING into |cbb| with the
459 OPENSSL_EXPORT int CBB_add_asn1_octet_string(CBB *cbb, const uint8_t *data,
462 // CBB_add_asn1_bool writes an ASN.1 BOOLEAN into |cbb| which is true iff
464 OPENSSL_EXPORT int CBB_add_asn1_bool(CBB *cbb, int value);
468 // contents to |cbb|. It returns one on success and zero on malloc failure or if
474 OPENSSL_EXPORT int CBB_add_asn1_oid_from_text(CBB *cbb, const char *text,
477 // CBB_flush_asn1_set_of calls |CBB_flush| on |cbb| and then reorders the
484 OPENSSL_EXPORT int CBB_flush_asn1_set_of(CBB *cbb);
496 using ScopedCBB = internal::StackAllocated<CBB, void, CBB_zero, CBB_cleanup>;