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
a49e7767
Unverified
Commit
a49e7767
authored
Sep 03, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing BLS
parent
65e7bd3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
27 deletions
+22
-27
secure_enclave.c
secure_enclave/secure_enclave.c
+15
-15
secure_enclave.edl
secure_enclave/secure_enclave.edl
+5
-12
sgxd_common.h
sgxd_common.h
+2
-0
No files found.
secure_enclave/secure_enclave.c
View file @
a49e7767
...
...
@@ -122,7 +122,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
*
err_status
=
-
1
;
uint64_t
keyLen
=
strnlen
(
key
,
MAX_KEY_LENGTH
);
uint64_t
keyLen
=
strnlen
(
key
,
MAX_KEY_LENGTH
);
// check that key is zero terminated string
...
...
@@ -137,7 +137,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
for
(
int
i
=
keyLen
;
i
<
MAX_KEY_LENGTH
;
i
++
)
{
if
(
key
[
i
]
!=
0
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"Unpadded key"
);
snprintf
(
err_string
,
BUF
_LEN
,
"Unpadded key"
);
return
;
}
}
...
...
@@ -145,7 +145,7 @@ void encrypt_key(int *err_status, char *err_string, char *key,
*
err_status
=
-
3
;
if
(
!
check_key
(
key
))
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"check_key failed"
);
snprintf
(
err_string
,
BUF
_LEN
,
"check_key failed"
);
return
;
}
...
...
@@ -153,18 +153,18 @@ void encrypt_key(int *err_status, char *err_string, char *key,
*
err_status
=
-
4
;
if
(
sealedLen
>
MAX_ENCRYPTED_KEY_LENGTH
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"sealedLen > MAX_ENCRYPTED_KEY_LENGTH"
);
if
(
sealedLen
>
BUF_LEN
)
{
snprintf
(
err_string
,
BUF
_LEN
,
"sealedLen > MAX_ENCRYPTED_KEY_LENGTH"
);
return
;
}
*
err_status
=
-
5
;
memset
(
encrypted_key
,
0
,
MAX_ENCRYPTED_KEY_LENGTH
);
memset
(
encrypted_key
,
0
,
BUF_LEN
);
if
(
sgx_seal_data
(
0
,
NULL
,
MAX_KEY_LENGTH
,
(
uint8_t
*
)
key
,
sealedLen
,
(
sgx_sealed_data_t
*
)
encrypted_key
)
!=
SGX_SUCCESS
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"SGX seal data failed"
);
snprintf
(
err_string
,
BUF
_LEN
,
"SGX seal data failed"
);
return
;
}
...
...
@@ -172,14 +172,14 @@ void encrypt_key(int *err_status, char *err_string, char *key,
char
key2
[
MAX_KEY_LENGTH
];
char
key2
[
BUF_LEN
];
memset
(
key2
,
0
,
MAX_KEY_LENGTH
);
memset
(
key2
,
0
,
BUF_LEN
);
decrypt_key
(
err_status
,
err_string
,
encrypted_key
,
sealedLen
,
key2
);
if
(
*
err_status
!=
0
)
{
snprintf
(
err_string
+
strlen
(
err_string
),
MAX_ERR
_LEN
,
":decrypt_key failed"
);
snprintf
(
err_string
+
strlen
(
err_string
),
BUF
_LEN
,
":decrypt_key failed"
);
return
;
}
...
...
@@ -212,13 +212,13 @@ void decrypt_key(int *err_status, char *err_string, uint8_t *encrypted_key,
(
const
sgx_sealed_data_t
*
)
encrypted_key
,
NULL
,
0
,
(
uint8_t
*
)
key
,
&
decLen
);
if
(
status
!=
SGX_SUCCESS
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"sgx_unseal_data failed with status %d"
,
status
);
snprintf
(
err_string
,
BUF
_LEN
,
"sgx_unseal_data failed with status %d"
,
status
);
return
;
}
if
(
decLen
!=
MAX_KEY_LENGTH
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"decLen != MAX_KEY_LENGTH"
);
snprintf
(
err_string
,
BUF
_LEN
,
"decLen != MAX_KEY_LENGTH"
);
return
;
}
...
...
@@ -229,7 +229,7 @@ void decrypt_key(int *err_status, char *err_string, uint8_t *encrypted_key,
if
(
keyLen
==
MAX_KEY_LENGTH
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"Key is not null terminated"
);
snprintf
(
err_string
,
BUF
_LEN
,
"Key is not null terminated"
);
return
;
}
...
...
@@ -237,7 +237,7 @@ void decrypt_key(int *err_status, char *err_string, uint8_t *encrypted_key,
for
(
int
i
=
keyLen
;
i
<
MAX_KEY_LENGTH
;
i
++
)
{
if
(
key
[
i
]
!=
0
)
{
snprintf
(
err_string
,
MAX_ERR
_LEN
,
"Unpadded key"
);
snprintf
(
err_string
,
BUF
_LEN
,
"Unpadded key"
);
return
;
}
}
...
...
@@ -262,7 +262,7 @@ void ecdsa_sign_message(int *err_status, char *err_string, uint8_t *encrypted_k
*
err_status
=
-
1
;
char
key
[
MAX_KEY_LENGTH
];
char
key
[
BUF_LEN
];
decrypt_key
(
err_status
,
err_string
,
encrypted_key
,
enc_len
,
key
);
...
...
secure_enclave/secure_enclave.edl
View file @
a49e7767
...
...
@@ -30,7 +30,7 @@ enclave {
public void encrypt_key (
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[in, count = 1
28
] char* key,
[in, count = 1
024
] char* key,
[out, count = 1024] uint8_t* encrypted_key, [user_check] uint32_t *enc_len);
public void decrypt_key (
...
...
@@ -38,15 +38,15 @@ enclave {
[out, count = 1024] char* err_string,
[in, count = 1024] uint8_t* encrypted_key,
uint32_t enc_len,
[out, count = 1
28
] char* key );
[out, count = 1
024
] char* key );
public void bls_sign_message (
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[in, count = 1024] uint8_t* encrypted_key,
uint32_t enc_len,
[in, count = 1
28
] char* hashX ,
[in, count = 1
28
] char* hashY ,
[in, count = 1
024
] char* hashX ,
[in, count = 1
024
] char* hashY ,
[out, count = 1024] char* signature);
public void ecdsa_sign_message (
...
...
@@ -54,15 +54,8 @@ enclave {
[out, count = 1024] char* err_string,
[in, count = 1024] unsigned char* encrypted_key,
uint32_t enc_len,
[in, count = 1
6
] uint8_t* hash,
[in, count = 1
024
] uint8_t* hash,
[out, count = 1024] char* signature);
};
...
...
sgxd_common.h
View file @
a49e7767
...
...
@@ -5,6 +5,8 @@
#ifndef SGXD_SGXD_COMMON_H
#define SGXD_SGXD_COMMON_H
#define BUF_LEN 1024
#define MAX_KEY_LENGTH 128
#define MAX_COMPONENT_LENGTH 80
#define MAX_COMPONENT_HEX_LENGTH MAX_COMPONENT_LENGTH * 2
...
...
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