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
751b4e85
Unverified
Commit
751b4e85
authored
Aug 30, 2019
by
a72d9e2bad9edfd58d6c0248c12c953b71d409d2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added gmp
parent
be7e54e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
4 deletions
+67
-4
secure_enclave.c
secure_enclave/secure_enclave.c
+67
-4
No files found.
secure_enclave/secure_enclave.c
View file @
751b4e85
...
@@ -39,9 +39,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -39,9 +39,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <math.h>
#include <math.h>
#include <string.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/ec.h>
#include <openssl/bn.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "tSgxSSL_api.h"
#define MAX_KEY_LENGTH 128
#define MAX_KEY_LENGTH 128
#define ADD_ENTROPY_SIZE 32
void
*
(
*
gmp_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
*
(
*
gmp_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
*
(
*
oc_realloc_func
)(
void
*
,
size_t
,
size_t
);
void
*
(
*
oc_realloc_func
)(
void
*
,
size_t
,
size_t
);
...
@@ -168,6 +177,9 @@ void decrypt_key(int *err_status, unsigned char *encrypted_key,
...
@@ -168,6 +177,9 @@ void decrypt_key(int *err_status, unsigned char *encrypted_key,
}
}
}
}
void
sign_message
(
int
*
err_status
,
unsigned
char
*
encrypted_key
,
void
sign_message
(
int
*
err_status
,
unsigned
char
*
encrypted_key
,
uint32_t
enc_len
,
unsigned
char
*
message
,
uint32_t
enc_len
,
unsigned
char
*
message
,
unsigned
char
*
signature
)
{
unsigned
char
*
signature
)
{
...
@@ -183,14 +195,65 @@ void sign_message(int *err_status, unsigned char *encrypted_key,
...
@@ -183,14 +195,65 @@ void sign_message(int *err_status, unsigned char *encrypted_key,
return
;
return
;
}
}
char
*
s
ig
=
sign
(
key
,
""
,
""
,
""
);
char
*
ecdsaS
ig
=
sign
(
key
,
""
,
""
,
""
);
if
(
s
ig
==
NULL
)
{
if
(
ecdsaS
ig
==
NULL
)
{
return
;
return
;
}
}
strcpy
(
signature
,
s
ig
);
strcpy
(
signature
,
ecdsaS
ig
);
*
err_status
=
0
;
*
err_status
=
0
;
unsigned
char
entropy_buf
[
ADD_ENTROPY_SIZE
]
=
{
0
};
RAND_add
(
entropy_buf
,
sizeof
(
entropy_buf
),
ADD_ENTROPY_SIZE
);
RAND_seed
(
entropy_buf
,
sizeof
(
entropy_buf
));
// Initialize SGXSSL crypto
OPENSSL_init_crypto
(
0
,
NULL
);
RAND_add
(
entropy_buf
,
sizeof
(
entropy_buf
),
ADD_ENTROPY_SIZE
);
RAND_seed
(
entropy_buf
,
sizeof
(
entropy_buf
));
EC_KEY
*
ec
=
NULL
;
int
eccgroup
;
eccgroup
=
OBJ_txt2nid
(
"secp384r1"
);
ec
=
EC_KEY_new_by_curve_name
(
eccgroup
);
if
(
ec
==
NULL
)
{
return
;
}
EC_KEY_set_asn1_flag
(
ec
,
OPENSSL_EC_NAMED_CURVE
);
int
ret
=
EC_KEY_generate_key
(
ec
);
if
(
!
ret
)
{
return
;
}
EVP_PKEY
*
ec_pkey
=
EVP_PKEY_new
();
if
(
ec_pkey
==
NULL
)
{
return
;
}
EVP_PKEY_assign_EC_KEY
(
ec_pkey
,
ec
);
// DONE
char
buffer
[
100
];
unsigned
char
sig
;
unsigned
int
siglen
;
int
i
;
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
// Add context
EVP_MD_CTX
*
context
=
EVP_MD_CTX_new
();
// Init, update, final
EVP_SignInit_ex
(
context
,
EVP_sha1
(),
NULL
);
EVP_SignUpdate
(
context
,
&
buffer
,
100
);
EVP_SignFinal
(
context
,
&
sig
,
&
siglen
,
ec_pkey
);
}
}
}
\ No newline at end of file
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