aboutsummaryrefslogtreecommitdiff
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-09-29 14:45:49 +0100
committerMatt Caswell <matt@openssl.org>2016-09-29 15:09:02 +0100
commit0023baffb8f648c22d397bfa5e1cc8749749bd29 (patch)
treedf7330e76ec84d8eb7a38b4a074ca28d7afb9a29 /ssl
parentff8194774ca2d8e30223c6f8e2583112514e9fb7 (diff)
downloadopenssl-0023baffb8f648c22d397bfa5e1cc8749749bd29.zip
openssl-0023baffb8f648c22d397bfa5e1cc8749749bd29.tar.gz
openssl-0023baffb8f648c22d397bfa5e1cc8749749bd29.tar.bz2
Add an example of usage to the WPACKET_reserve_bytes() documentation
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r--ssl/packet_locl.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h
index 0e50c7d..8d3fd37 100644
--- a/ssl/packet_locl.h
+++ b/ssl/packet_locl.h
@@ -707,6 +707,16 @@ int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len,
* maximum size will be. If this function is used, then it should be immediately
* followed by a WPACKET_allocate_bytes() call before any other WPACKET
* functions are called (unless the write to the allocated bytes is abandoned).
+ *
+ * For example: If we are generating a signature, then the size of that
+ * signature may not be known in advance. We can use WPACKET_reserve_bytes() to
+ * handle this:
+ *
+ * if (!WPACKET_sub_reserve_bytes_u16(&pkt, EVP_PKEY_size(pkey), &sigbytes1)
+ * || EVP_SignFinal(md_ctx, sigbytes1, &siglen, pkey) <= 0
+ * || !WPACKET_sub_allocate_bytes_u16(&pkt, siglen, &sigbytes2)
+ * || sigbytes1 != sigbytes2)
+ * goto err;
*/
int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes);