Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
08455829
Unverified
Commit
08455829
authored
Jul 29, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2977 clean up
parent
1e558175
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
15 deletions
+12
-15
ECDSACrypto.cpp
ECDSACrypto.cpp
+6
-4
ECDSACrypto.h
ECDSACrypto.h
+2
-2
LevelDB.cpp
LevelDB.cpp
+0
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+3
-3
common.h
common.h
+1
-5
No files found.
ECDSACrypto.cpp
View file @
08455829
...
...
@@ -85,7 +85,7 @@ vector <string> genECDSAKey() {
return
keys
;
}
string
getECDSAPubKey
(
const
char
*
_encryptedKeyHex
)
{
string
getECDSAPubKey
(
const
std
::
string
&
_encryptedKeyHex
)
{
vector
<
char
>
errMsg
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyX
(
BUF_LEN
,
0
);
vector
<
char
>
pubKeyY
(
BUF_LEN
,
0
);
...
...
@@ -94,7 +94,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
int
errStatus
=
0
;
uint64_t
enc_len
=
0
;
if
(
!
hex2carray
(
_encryptedKeyHex
,
&
enc_len
,
encrPrKey
.
data
()))
{
if
(
!
hex2carray
(
_encryptedKeyHex
.
c_str
()
,
&
enc_len
,
encrPrKey
.
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
...
...
@@ -159,7 +159,7 @@ bool verifyECDSASig(string& pubKeyStr, const char *hashHex, const char *signatur
return
true
;
}
vector
<
string
>
ecdsaSignHash
(
const
char
*
encryptedKeyHex
,
const
char
*
hashHex
,
int
base
)
{
vector
<
string
>
ecdsaSignHash
(
const
std
::
string
&
encryptedKeyHex
,
const
char
*
hashHex
,
int
base
)
{
vector
<
string
>
signatureVector
(
3
);
vector
<
char
>
errMsg
(
1024
,
0
);
...
...
@@ -174,9 +174,11 @@ vector <string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex,
shared_ptr
<
SGXException
>
exception
=
NULL
;
if
(
!
hex2carray
(
encryptedKeyHex
,
&
decLen
,
encryptedKey
.
data
()))
{
spdlog
::
debug
(
"BEFORE HEX2CARRAY"
);
if
(
!
hex2carray
(
encryptedKeyHex
.
c_str
(),
&
decLen
,
encryptedKey
.
data
()))
{
throw
SGXException
(
INVALID_HEX
,
"Invalid encryptedKeyHex"
);
}
spdlog
::
debug
(
"AFTER HEX2CARRAY"
);
status
=
trustedEcdsaSignAES
(
eid
,
&
errStatus
,
errMsg
.
data
(),
encryptedKey
.
data
(),
decLen
,
(
unsigned
char
*
)
hashHex
,
...
...
ECDSACrypto.h
View file @
08455829
...
...
@@ -31,9 +31,9 @@ using namespace std;
vector
<
string
>
genECDSAKey
();
string
getECDSAPubKey
(
const
char
*
_encryptedKeyHex
);
string
getECDSAPubKey
(
const
std
::
string
&
_encryptedKeyHex
);
vector
<
string
>
ecdsaSignHash
(
const
char
*
encryptedKeyHex
,
const
char
*
hashHex
,
int
base
);
vector
<
string
>
ecdsaSignHash
(
const
std
::
string
&
encryptedKeyHex
,
const
char
*
hashHex
,
int
base
);
#endif //SGXD_ECDSACRYPTO_H
LevelDB.cpp
View file @
08455829
...
...
@@ -54,7 +54,6 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
result
.
get
());
spdlog
::
debug
(
"SUCCESS READING"
);
throwExceptionOnError
(
status
);
...
...
SGXWalletServer.cpp
View file @
08455829
...
...
@@ -332,7 +332,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
result
[
"signature_r"
]
=
""
;
result
[
"signature_s"
]
=
""
;
vector
<
string
>
signatureVector
(
3
);
vector
<
string
>
signatureVector
(
3
);
try
{
string
hashTmp
=
_messageHash
;
...
...
@@ -353,9 +353,9 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
throw
SGXException
(
-
22
,
"Invalid base"
);
}
shared_ptr
<
string
>
encryptedKey
=
readFromDb
(
_keyName
);
shared_ptr
<
string
>
encryptedKey
=
readFromDb
(
_keyName
);
signatureVector
=
ecdsaSignHash
(
encryptedKey
->
c_str
()
,
hashTmp
.
c_str
(),
_base
);
signatureVector
=
ecdsaSignHash
(
*
encryptedKey
,
hashTmp
.
c_str
(),
_base
);
if
(
signatureVector
.
size
()
!=
3
)
{
throw
SGXException
(
INVALID_ECSDA_SIGNATURE
,
"Invalid ecdsa signature"
);
}
...
...
common.h
View file @
08455829
...
...
@@ -32,13 +32,10 @@ using namespace std;
#include <map>
#include <memory>
#include <gmp.h>
#include "secure_enclave/Verify.h"
#include "InvalidStateException.h"
#define SAFE_FREE(__POINTER__) {if (__POINTER__) {free(__POINTER__); __POINTER__ = NULL;}}
inline
std
::
string
className
(
const
std
::
string
&
prettyFunction
)
{
...
...
@@ -51,12 +48,11 @@ inline std::string className(const std::string &prettyFunction) {
return
prettyFunction
.
substr
(
begin
,
end
);
}
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
#define CHECK_STATE(_EXPRESSION_) \
if (!(_EXPRESSION_)) { \
auto __msg__ = st
ring("State check failed::") + #_EXPRESSION_ + " " + string(__FILE__) + ":" +
to_string(__LINE__); \
auto __msg__ = st
d::string("State check failed::") + #_EXPRESSION_ + " " + std::string(__FILE__) + ":" + std::
to_string(__LINE__); \
throw InvalidStateException(__msg__, __CLASS_NAME__);}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment