tbbr: Use constant-time bcmp() to compare hashes
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Fri, 13 Jan 2017 13:53:32 +0000 (13:53 +0000)
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Tue, 24 Jan 2017 14:42:13 +0000 (14:42 +0000)
commitb621fb503c76f3bdf06ed5ed1d3a995df8da9c50
treee26cbe6607da8407709277b5d4808bb759e501cb
parentaa050a7bdb943ca94ab914f2a9dc508e09a57431
tbbr: Use constant-time bcmp() to compare hashes

To avoid timing side-channel attacks, it is needed to use a constant
time memory comparison function when comparing hashes. The affected
code only cheks for equality so it isn't needed to use any variant of
memcmp(), bcmp() is enough.

Also, timingsafe_bcmp() is as fast as memcmp() when the two compared
regions are equal, so this change incurrs no performance hit in said
case. In case they are unequal, the boot sequence wouldn't continue as
normal, so performance is not an issue.

Change-Id: I1c7c70ddfa4438e6031c8814411fef79fd3bb4df
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
drivers/auth/mbedtls/mbedtls_crypto.c
drivers/auth/mbedtls/mbedtls_x509_parser.c