aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-08 13:45:40 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-08 13:45:40 +0200
commit264fb4b2bb5480a28646a8465013647b2e034cf4 (patch)
tree98f52c0da7b4a3acaae484dc8c252c65bcd93648
parent113f90b689af1d7169df9db5d7e84443972b5f68 (diff)
Fix envelope decryption bug when encrkeylen=255
-rw-r--r--envelope.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/envelope.cpp b/envelope.cpp
index a8cd793..9bb011e 100644
--- a/envelope.cpp
+++ b/envelope.cpp
@@ -57,7 +57,7 @@ namespace Envelope{
string decrypt(const string &data,const RSA::PrivateKey &privkey){
cerr<<"=== DECRYPT ==="<<endl;
if(data.size()<2)throw invalid_argument("Envelope data length invalid");
- int encrkeylen=((uint16_t)data[data.size()-2]<<8)+(uint16_t)data.back();
+ int encrkeylen=((uint16_t)(uint8_t)data[data.size()-2]<<8)+(uint8_t)data.back();
assert(encrkeylen<(1<<16));
cerr<<"encrkeylen="<<encrkeylen<<endl;
if((int)data.size()<encrkeylen+2)throw invalid_argument("Envelope key format invalid");