aboutsummaryrefslogtreecommitdiff
path: root/ssl/packet_locl.h
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2015-10-06 17:20:32 +0200
committerEmilia Kasper <emilia@openssl.org>2015-10-09 15:32:35 +0200
commit310115448188415e270bb0bef958c7c130939838 (patch)
tree4acce2a2cb0626327668858b21dc9f7811e803c5 /ssl/packet_locl.h
parent0f0cfbe24c07376a67b12048686baa318db2cd95 (diff)
downloadopenssl-310115448188415e270bb0bef958c7c130939838.zip
openssl-310115448188415e270bb0bef958c7c130939838.tar.gz
openssl-310115448188415e270bb0bef958c7c130939838.tar.bz2
DTLS: remove unused cookie field
Note that this commit constifies a user callback parameter and therefore will break compilation for applications using this callback. But unless they are abusing write access to the buffer, the fix is trivial. Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'ssl/packet_locl.h')
-rw-r--r--ssl/packet_locl.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h
index 9354e6c..778ec77 100644
--- a/ssl/packet_locl.h
+++ b/ssl/packet_locl.h
@@ -62,6 +62,7 @@
# include <string.h>
# include <openssl/bn.h>
# include <openssl/buffer.h>
+# include <openssl/crypto.h>
# include "e_os.h"
# ifdef __cplusplus
@@ -125,6 +126,18 @@ static inline void PACKET_null_init(PACKET *pkt)
}
/*
+ * Returns 1 if the packet has length |num| and its contents equal the |num|
+ * bytes read from |ptr|. Returns 0 otherwise (lengths or contents not equal).
+ * If lengths are equal, performs the comparison in constant time.
+ */
+__owur static inline int PACKET_equal(const PACKET *pkt, const void *ptr,
+ size_t num) {
+ if (PACKET_remaining(pkt) != num)
+ return 0;
+ return CRYPTO_memcmp(pkt->curr, ptr, num) == 0;
+}
+
+/*
* Peek ahead and initialize |subpkt| with the next |len| bytes read from |pkt|.
* Data is not copied: the |subpkt| packet will share its underlying buffer with
* the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|.