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
afdddf48
Unverified
Commit
afdddf48
authored
Aug 15, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3070-clean-sgx-3
parent
85ad2d41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
secure_enclave.c
secure_enclave/secure_enclave.c
+39
-3
No files found.
secure_enclave/secure_enclave.c
View file @
afdddf48
...
...
@@ -171,8 +171,7 @@ void get_global_random(unsigned char *_randBuff, uint64_t _size) {
int
status
;
int
*
errStatus
=
&
status
;
*
errString
=
0
;
*
errStatus
=
UNKNOWN_ERROR
;
INIT_ERROR_STATE
CHECK_STATE
(
_size
<=
32
)
CHECK_STATE
(
_randBuff
);
...
...
@@ -214,7 +213,7 @@ void trustedGenerateSEK(int *errStatus, char *errString,
*
enc_len
=
sealedLen
;
*
errStatus
=
0
;
SET_SUCCESS
clean:
;
LOG_INFO
(
"SGX call completed"
);
...
...
@@ -490,6 +489,43 @@ void trustedEcdsaSignAES(int *errStatus, char *errString, uint8_t *encryptedPriv
LOG_DEBUG
(
"SGX call completed"
);
}
void
trustedDecryptKeyAES
(
int
*
errStatus
,
char
*
errString
,
uint8_t
*
encryptedPrivateKey
,
uint32_t
enc_len
,
char
*
key
)
{
LOG_DEBUG
(
__FUNCTION__
);
INIT_ERROR_STATE
CHECK_STATE
(
encryptedPrivateKey
);
CHECK_STATE
(
key
);
*
errStatus
=
-
9
;
int
status
=
AES_decrypt
(
encryptedPrivateKey
,
enc_len
,
key
,
3072
);
if
(
status
!=
0
)
{
*
errStatus
=
status
;
snprintf
(
errString
,
BUF_LEN
,
"aes decrypt failed with status %d"
,
status
);
LOG_ERROR
(
errString
);
goto
clean
;
}
*
errStatus
=
-
10
;
uint64_t
keyLen
=
strnlen
(
key
,
MAX_KEY_LENGTH
);
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
errString
,
BUF_LEN
,
"Key is not null terminated"
);
LOG_ERROR
(
errString
);
goto
clean
;
}
SET_SUCCESS
clean:
;
}
void
trustedEncryptKeyAES
(
int
*
errStatus
,
char
*
errString
,
const
char
*
key
,
uint8_t
*
encryptedPrivateKey
,
uint32_t
*
enc_len
)
{
LOG_INFO
(
__FUNCTION__
);
...
...
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