xref: /freebsd/crypto/openssl/doc/man3/BUF_MEM_new.pod (revision a7148ab39c03abd4d1a84997c70bf96f15dd2a09)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimBUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow,
6e71b7053SJung-uk KimBUF_MEM_grow_clean, BUF_reverse
7e71b7053SJung-uk Kim- simple character array structure
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim=head1 SYNOPSIS
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim #include <openssl/buffer.h>
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim BUF_MEM *BUF_MEM_new(void);
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
16e71b7053SJung-uk Kim
17e71b7053SJung-uk Kim void BUF_MEM_free(BUF_MEM *a);
18e71b7053SJung-uk Kim
19e71b7053SJung-uk Kim int BUF_MEM_grow(BUF_MEM *str, int len);
20e71b7053SJung-uk Kim size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
21e71b7053SJung-uk Kim
22e71b7053SJung-uk Kim void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size);
23e71b7053SJung-uk Kim
24e71b7053SJung-uk Kim=head1 DESCRIPTION
25e71b7053SJung-uk Kim
26e71b7053SJung-uk KimThe buffer library handles simple character arrays. Buffers are used for
27e71b7053SJung-uk Kimvarious purposes in the library, most notably memory BIOs.
28e71b7053SJung-uk Kim
29e71b7053SJung-uk KimBUF_MEM_new() allocates a new buffer of zero size.
30e71b7053SJung-uk Kim
31e71b7053SJung-uk KimBUF_MEM_new_ex() allocates a buffer with the specified flags.
32e71b7053SJung-uk KimThe flag B<BUF_MEM_FLAG_SECURE> specifies that the B<data> pointer
33e71b7053SJung-uk Kimshould be allocated on the secure heap; see L<CRYPTO_secure_malloc(3)>.
34e71b7053SJung-uk Kim
35e71b7053SJung-uk KimBUF_MEM_free() frees up an already existing buffer. The data is zeroed
36e71b7053SJung-uk Kimbefore freeing up in case the buffer contains sensitive data.
37*a7148ab3SEnji CooperIf the argument is NULL, nothing is done.
38e71b7053SJung-uk Kim
39e71b7053SJung-uk KimBUF_MEM_grow() changes the size of an already existing buffer to
40e71b7053SJung-uk KimB<len>. Any data already in the buffer is preserved if it increases in
41e71b7053SJung-uk Kimsize.
42e71b7053SJung-uk Kim
43e71b7053SJung-uk KimBUF_MEM_grow_clean() is similar to BUF_MEM_grow() but it sets any free'd
44e71b7053SJung-uk Kimor additionally-allocated memory to zero.
45e71b7053SJung-uk Kim
46e71b7053SJung-uk KimBUF_reverse() reverses B<size> bytes at B<in> into B<out>.  If B<in>
47e71b7053SJung-uk Kimis NULL, the array is reversed in-place.
48e71b7053SJung-uk Kim
49e71b7053SJung-uk Kim=head1 RETURN VALUES
50e71b7053SJung-uk Kim
51e71b7053SJung-uk KimBUF_MEM_new() returns the buffer or NULL on error.
52e71b7053SJung-uk Kim
53e71b7053SJung-uk KimBUF_MEM_free() has no return value.
54e71b7053SJung-uk Kim
55e71b7053SJung-uk KimBUF_MEM_grow() and BUF_MEM_grow_clean() return
56e71b7053SJung-uk Kimzero on error or the new size (i.e., B<len>).
57e71b7053SJung-uk Kim
58e71b7053SJung-uk Kim=head1 SEE ALSO
59e71b7053SJung-uk Kim
60e71b7053SJung-uk KimL<bio(7)>,
61e71b7053SJung-uk KimL<CRYPTO_secure_malloc(3)>.
62e71b7053SJung-uk Kim
63e71b7053SJung-uk Kim=head1 HISTORY
64e71b7053SJung-uk Kim
656935a639SJung-uk KimThe BUF_MEM_new_ex() function was added in OpenSSL 1.1.0.
66e71b7053SJung-uk Kim
67e71b7053SJung-uk Kim=head1 COPYRIGHT
68e71b7053SJung-uk Kim
69*a7148ab3SEnji CooperCopyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
70e71b7053SJung-uk Kim
71b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
72e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
73e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
74e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
75e71b7053SJung-uk Kim
76e71b7053SJung-uk Kim=cut
77