File tree Expand file tree Collapse file tree 5 files changed +25
-0
lines changed
features/mbedtls/targets/TARGET_NUVOTON Expand file tree Collapse file tree 5 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
63
63
void mbedtls_sha1_clone (mbedtls_sha1_context * dst ,
64
64
const mbedtls_sha1_context * src )
65
65
{
66
+ // Corner case: Destination/source contexts are the same
67
+ if (dst == src ) {
68
+ return ;
69
+ }
70
+
66
71
// If dst is H/W context, we need to change it to S/W context first before cloning to.
67
72
if (dst -> active_ctx == & dst -> hw_ctx ) {
68
73
mbedtls_sha1_free (dst );
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
63
63
void mbedtls_sha256_clone (mbedtls_sha256_context * dst ,
64
64
const mbedtls_sha256_context * src )
65
65
{
66
+ // Corner case: Destination/source contexts are the same
67
+ if (dst == src ) {
68
+ return ;
69
+ }
70
+
66
71
// If dst is H/W context, we need to change it to S/W context first before cloning to.
67
72
if (dst -> active_ctx == & dst -> hw_ctx ) {
68
73
mbedtls_sha256_free (dst );
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ void mbedtls_sha512_free(mbedtls_sha512_context *ctx)
63
63
void mbedtls_sha512_clone (mbedtls_sha512_context * dst ,
64
64
const mbedtls_sha512_context * src )
65
65
{
66
+ // Corner case: Destination/source contexts are the same
67
+ if (dst == src ) {
68
+ return ;
69
+ }
70
+
66
71
// If dst is H/W context, we need to change it to S/W context first before cloning to.
67
72
if (dst -> active_ctx == & dst -> hw_ctx ) {
68
73
mbedtls_sha512_free (dst );
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
63
63
void mbedtls_sha1_clone (mbedtls_sha1_context * dst ,
64
64
const mbedtls_sha1_context * src )
65
65
{
66
+ // Corner case: Destination/source contexts are the same
67
+ if (dst == src ) {
68
+ return ;
69
+ }
70
+
66
71
// If dst is H/W context, we need to change it to S/W context first before cloning to.
67
72
if (dst -> active_ctx == & dst -> hw_ctx ) {
68
73
mbedtls_sha1_free (dst );
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
63
63
void mbedtls_sha256_clone (mbedtls_sha256_context * dst ,
64
64
const mbedtls_sha256_context * src )
65
65
{
66
+ // Corner case: Destination/source contexts are the same
67
+ if (dst == src ) {
68
+ return ;
69
+ }
70
+
66
71
// If dst is H/W context, we need to change it to S/W context first before cloning to.
67
72
if (dst -> active_ctx == & dst -> hw_ctx ) {
68
73
mbedtls_sha256_free (dst );
You can’t perform that action at this time.
0 commit comments