Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
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
community
godot
Commits
f03b7f3d
Commit
f03b7f3d
authored
Jun 07, 2020
by
Fabio Alessandrelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better zeroizing in CryptoKey.
Small code clenup (after PoolByteArray change).
parent
4e0f31a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
15 deletions
+8
-15
crypto_mbedtls.cpp
modules/mbedtls/crypto_mbedtls.cpp
+8
-15
No files found.
modules/mbedtls/crypto_mbedtls.cpp
View file @
f03b7f3d
...
...
@@ -59,11 +59,8 @@ Error CryptoKeyMbedTLS::load(String p_path) {
int
flen
=
f
->
get_len
();
out
.
resize
(
flen
+
1
);
{
uint8_t
*
w
=
out
.
ptrw
();
f
->
get_buffer
(
w
,
flen
);
w
[
flen
]
=
0
;
//end f string
}
f
->
get_buffer
(
out
.
ptrw
(),
flen
);
out
.
write
[
flen
]
=
0
;
// string terminator
memdelete
(
f
);
int
ret
=
mbedtls_pk_parse_key
(
&
pkey
,
out
.
ptr
(),
out
.
size
(),
nullptr
,
0
);
...
...
@@ -84,14 +81,14 @@ Error CryptoKeyMbedTLS::save(String p_path) {
int
ret
=
mbedtls_pk_write_key_pem
(
&
pkey
,
w
,
sizeof
(
w
));
if
(
ret
!=
0
)
{
memdelete
(
f
);
m
emset
(
w
,
0
,
sizeof
(
w
));
// Zeroize anything we might have written.
m
bedtls_platform_zeroize
(
w
,
sizeof
(
w
));
// Zeroize anything we might have written.
ERR_FAIL_V_MSG
(
FAILED
,
"Error writing key '"
+
itos
(
ret
)
+
"'."
);
}
size_t
len
=
strlen
((
char
*
)
w
);
f
->
store_buffer
(
w
,
len
);
memdelete
(
f
);
m
emset
(
w
,
0
,
sizeof
(
w
));
// Zeroize temporary buffer.
m
bedtls_platform_zeroize
(
w
,
sizeof
(
w
));
// Zeroize temporary buffer.
return
OK
;
}
...
...
@@ -108,11 +105,8 @@ Error X509CertificateMbedTLS::load(String p_path) {
int
flen
=
f
->
get_len
();
out
.
resize
(
flen
+
1
);
{
uint8_t
*
w
=
out
.
ptrw
();
f
->
get_buffer
(
w
,
flen
);
w
[
flen
]
=
0
;
//end f string
}
f
->
get_buffer
(
out
.
ptrw
(),
flen
);
out
.
write
[
flen
]
=
0
;
// string terminator
memdelete
(
f
);
int
ret
=
mbedtls_x509_crt_parse
(
&
cert
,
out
.
ptr
(),
out
.
size
());
...
...
@@ -211,9 +205,8 @@ void CryptoMbedTLS::load_default_certificates(String p_path) {
// Use builtin certs only if user did not override it in project settings.
PackedByteArray
out
;
out
.
resize
(
_certs_uncompressed_size
+
1
);
uint8_t
*
w
=
out
.
ptrw
();
Compression
::
decompress
(
w
,
_certs_uncompressed_size
,
_certs_compressed
,
_certs_compressed_size
,
Compression
::
MODE_DEFLATE
);
w
[
_certs_uncompressed_size
]
=
0
;
// Make sure it ends with string terminator
Compression
::
decompress
(
out
.
ptrw
(),
_certs_uncompressed_size
,
_certs_compressed
,
_certs_compressed_size
,
Compression
::
MODE_DEFLATE
);
out
.
write
[
_certs_uncompressed_size
]
=
0
;
// Make sure it ends with string terminator
#ifdef DEBUG_ENABLED
print_verbose
(
"Loaded builtin certs"
);
#endif
...
...
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