summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-09 20:45:15 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-09 20:45:15 -0400
commit9979474f1e623bc362eb00b4cb882457863c44b7 (patch)
treefdc2373c32b3616ee9957e2c538b371a107b2dde /node
parent6c53891b44d40caae136dcc22965a7a6fe5fca49 (diff)
downloadinfinitytier-9979474f1e623bc362eb00b4cb882457863c44b7.tar.gz
infinitytier-9979474f1e623bc362eb00b4cb882457863c44b7.zip
Add range safety check to EllipticCurveKey.
Diffstat (limited to 'node')
-rw-r--r--node/EllipticCurveKey.hpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/node/EllipticCurveKey.hpp b/node/EllipticCurveKey.hpp
index b32f702d..5a3a60c4 100644
--- a/node/EllipticCurveKey.hpp
+++ b/node/EllipticCurveKey.hpp
@@ -30,6 +30,7 @@
#include <string>
#include <algorithm>
+#include <stdexcept>
#include <string.h>
#include "Utils.hpp"
@@ -69,39 +70,24 @@ public:
}
EllipticCurveKey(const void *data,unsigned int len)
- throw()
+ throw(std::out_of_range)
{
set(data,len);
}
EllipticCurveKey(const std::string &data)
- throw()
+ throw(std::out_of_range)
{
set(data.data(),data.length());
}
- EllipticCurveKey(const EllipticCurveKey &k)
- throw()
- {
- _bytes = k._bytes;
- memcpy(_key,k._key,_bytes);
- }
-
- inline EllipticCurveKey &operator=(const EllipticCurveKey &k)
- throw()
- {
- _bytes = k._bytes;
- memcpy(_key,k._key,_bytes);
- return *this;
- }
-
inline void set(const void *data,unsigned int len)
- throw()
+ throw(std::out_of_range)
{
if (len <= ZT_EC_MAX_BYTES) {
_bytes = len;
memcpy(_key,data,len);
- } else _bytes = 0;
+ } else throw std::out_of_range("key too large");
}
inline const unsigned char *data() const throw() { return _key; }