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
0b4d1bc9
Unverified
Commit
0b4d1bc9
authored
Aug 11, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3067-cleanup-sgx
parent
13ade9be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
secure_enclave.c
secure_enclave/secure_enclave.c
+20
-11
No files found.
secure_enclave/secure_enclave.c
View file @
0b4d1bc9
...
@@ -1397,37 +1397,43 @@ void trustedEncryptKeyAES(int *errStatus, char *errString, const char *key,
...
@@ -1397,37 +1397,43 @@ void trustedEncryptKeyAES(int *errStatus, char *errString, const char *key,
if
(
stat
!=
0
)
{
if
(
stat
!=
0
)
{
*
errStatus
=
stat
;
*
errStatus
=
stat
;
snprintf
(
errString
,
BUF_LEN
,
"AES encrypt failed with status %d"
,
stat
);
snprintf
(
errString
,
BUF_LEN
,
"AES encrypt failed with status %d"
,
stat
);
return
;
LOG_ERROR
(
errString
);
goto
clean
;
}
}
*
enc_len
=
strlen
(
key
)
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
;
*
enc_len
=
strlen
(
key
)
+
SGX_AESGCM_MAC_SIZE
+
SGX_AESGCM_IV_SIZE
;
SAFE_CHAR_BUF
(
decryptedKey
,
BUF_LEN
);
SAFE_CHAR_BUF
(
decryptedKey
,
BUF_LEN
);
stat
=
AES_decrypt
(
encryptedPrivateKey
,
*
enc_len
,
decryptedKey
,
BUF_LEN
);
stat
=
AES_decrypt
(
encryptedPrivateKey
,
*
enc_len
,
decryptedKey
,
BUF_LEN
);
if
(
stat
!=
0
)
{
if
(
stat
!=
0
)
{
*
errStatus
=
stat
;
*
errStatus
=
stat
;
snprintf
(
errString
,
BUF_LEN
,
":trustedDecryptKey failed with status %d"
,
stat
);
snprintf
(
errString
,
BUF_LEN
,
"trustedDecryptKey failed with status %d"
,
stat
);
return
;
LOG_ERROR
(
errString
);
goto
clean
;
}
}
uint64_t
decryptedKeyLen
=
strnlen
(
decryptedKey
,
MAX_KEY_LENGTH
);
uint64_t
decryptedKeyLen
=
strnlen
(
decryptedKey
,
MAX_KEY_LENGTH
);
if
(
decryptedKeyLen
==
MAX_KEY_LENGTH
)
{
if
(
decryptedKeyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
errString
,
BUF_LEN
,
"Decrypted key is not null terminated"
);
snprintf
(
errString
,
BUF_LEN
,
"Decrypted key is not null terminated"
);
return
;
LOG_ERROR
(
errString
);
goto
clean
;
}
}
*
errStatus
=
-
8
;
*
errStatus
=
-
8
;
if
(
strncmp
(
key
,
decryptedKey
,
MAX_KEY_LENGTH
)
!=
0
)
{
if
(
strncmp
(
key
,
decryptedKey
,
MAX_KEY_LENGTH
)
!=
0
)
{
snprintf
(
errString
,
BUF_LEN
,
"Decrypted key does not match original key"
);
snprintf
(
errString
,
BUF_LEN
,
"Decrypted key does not match original key"
);
return
;
LOG_ERROR
(
errString
);
goto
clean
;
}
}
*
errStatus
=
0
;
*
errStatus
=
0
;
clean:
;
}
}
void
trustedDecryptKeyAES
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encryptedPrivateKey
,
void
trustedDecryptKeyAES
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encryptedPrivateKey
,
...
@@ -1441,7 +1447,6 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
...
@@ -1441,7 +1447,6 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
CHECK_STATE
(
encryptedPrivateKey
);
CHECK_STATE
(
encryptedPrivateKey
);
CHECK_STATE
(
key
);
CHECK_STATE
(
key
);
*
errStatus
=
-
9
;
*
errStatus
=
-
9
;
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
key
,
3072
);
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
key
,
3072
);
...
@@ -1449,7 +1454,8 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
...
@@ -1449,7 +1454,8 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
*
errStatus
=
status
;
*
errStatus
=
status
;
snprintf
(
errString
,
BUF_LEN
,
"aes decrypt failed with status %d"
,
status
);
snprintf
(
errString
,
BUF_LEN
,
"aes decrypt failed with status %d"
,
status
);
return
;
LOG_ERROR
(
errString
);
goto
clean
;
}
}
*
errStatus
=
-
10
;
*
errStatus
=
-
10
;
...
@@ -1458,12 +1464,15 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
...
@@ -1458,12 +1464,15 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
errString
,
BUF_LEN
,
"Key is not null terminated"
);
snprintf
(
errString
,
BUF_LEN
,
"Key is not null terminated"
);
return
;
LOG_ERROR
(
errString
);
goto
clean
;
}
}
memcpy
(
errString
,
AES_key
,
1024
);
*
errStatus
=
0
;
*
errStatus
=
0
;
clean:
;
}
}
void
trustedBlsSignMessageAES
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encryptedPrivateKey
,
void
trustedBlsSignMessageAES
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encryptedPrivateKey
,
...
...
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