forked from particle-iot/tinydtls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into ecdh-merge
- Loading branch information
Showing
6 changed files
with
200 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* dtls -- a very basic DTLS implementation | ||
* | ||
* Copyright (C) 2011--2012 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2011--2013 Olaf Bergmann <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
|
@@ -298,7 +298,7 @@ dtls_ccm_decrypt_message(rijndael_ctx *ctx, size_t M, size_t L, | |
memxor(msg, S, M); | ||
|
||
/* return length if MAC is valid, otherwise continue with error handling */ | ||
if (memcmp(X, msg, M) == 0) | ||
if (equals(X, msg, M)) | ||
return len - M; | ||
|
||
error: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- Autoconf -*- | ||
# Process this file with autoconf to produce a configure script. | ||
# | ||
# Copyright (C) 2011--2012 Olaf Bergmann <[email protected]> | ||
# Copyright (C) 2011--2013 Olaf Bergmann <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person | ||
# obtaining a copy of this software and associated documentation | ||
|
@@ -24,7 +24,7 @@ | |
# SOFTWARE. | ||
|
||
AC_PREREQ([2.65]) | ||
AC_INIT([tinydtls], [0.4.0]) | ||
AC_INIT([tinydtls], [0.5.0]) | ||
AC_CONFIG_SRCDIR([dtls.c]) | ||
dnl AC_CONFIG_HEADERS([config.h]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* dtls -- a very basic DTLS implementation | ||
* | ||
* Copyright (C) 2011--2012 Olaf Bergmann <[email protected]> | ||
* Copyright (C) 2011--2013 Olaf Bergmann <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
|
@@ -188,6 +188,25 @@ memxor(unsigned char *x, const unsigned char *y, size_t n) { | |
} | ||
} | ||
|
||
/** | ||
* Compares \p len bytes from @p a with @p b in constant time. This | ||
* functions always traverses the entire length to prevent timing | ||
* attacks. | ||
* | ||
* \param a Byte sequence to compare | ||
* \param b Byte sequence to compare | ||
* \param len Number of bytes to compare. | ||
* \return \c 1 if \p a and \p b are equal, \c 0 otherwise. | ||
*/ | ||
static inline int | ||
equals(unsigned char *a, unsigned char *b, size_t len) { | ||
int result = 1; | ||
while (len--) { | ||
result &= (*a++ == *b++); | ||
} | ||
return result; | ||
} | ||
|
||
#ifdef HAVE_FLS | ||
#define dtls_fls(i) fls(i) | ||
#else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.