Fixing SGX

parent 67c016b0
...@@ -147,9 +147,12 @@ std::shared_ptr<BLSSigShare> BLSPrivateKeyShareSGX::signWithHelperSGX( ...@@ -147,9 +147,12 @@ std::shared_ptr<BLSSigShare> BLSPrivateKeyShareSGX::signWithHelperSGX(
size_t sz = 0; size_t sz = 0;
auto encryptedKey = hex2carray(encryptedKeyHex->c_str(), &sz);
if (encryptedKey == nullptr) { uint8_t encryptedKey[BUF_LEN];
bool result = hex2carray(encryptedKeyHex->c_str(), &sz, encryptedKey);
if (!result) {
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid hex encrypted key")); BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid hex encrypted key"));
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#define GMP_WITH_SGX #define GMP_WITH_SGX
#include <string.h> #include <string.h>
#include <cstdint>
#include "../sgxd_common.h" #include "../sgxd_common.h"
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef SGXD_SGXD_COMMON_H #ifndef SGXD_SGXD_COMMON_H
#define SGXD_SGXD_COMMON_H #define SGXD_SGXD_COMMON_H
#include <stdbool.h>
#define BUF_LEN 1024 #define BUF_LEN 1024
#define MAX_KEY_LENGTH 128 #define MAX_KEY_LENGTH 128
...@@ -42,14 +44,14 @@ void carray2Hex(const unsigned char *d, int _len, char* _hexArray) { ...@@ -42,14 +44,14 @@ void carray2Hex(const unsigned char *d, int _len, char* _hexArray) {
} }
int hex2carray(const char * _hex, unsigned long long *_bin_len, bool hex2carray(const char * _hex, uint64_t *_bin_len,
unsigned char* _bin ) { uint8_t* _bin ) {
int len = strnlen(_hex, BUF_LEN); int len = strnlen(_hex, BUF_LEN);
if (len == 0 && len % 2 == 1) if (len == 0 && len % 2 == 1)
return -1; return false;
*_bin_len = len / 2; *_bin_len = len / 2;
...@@ -58,12 +60,13 @@ int hex2carray(const char * _hex, unsigned long long *_bin_len, ...@@ -58,12 +60,13 @@ int hex2carray(const char * _hex, unsigned long long *_bin_len,
int low = char2int((char)_hex[i * 2 + 1]); int low = char2int((char)_hex[i * 2 + 1]);
if (high < 0 || low < 0) { if (high < 0 || low < 0) {
return -1; return false;
} }
_bin[i] = (unsigned char) (high * 16 + low); _bin[i] = (unsigned char) (high * 16 + low);
} }
return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment