summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-09-28 12:57:33 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-10-24 01:53:21 +0000
commit42f16aed53d6b7120f3772768f1eeac9e882c076 (patch)
treeab101bd41ad42c780453be89e9180f7f07253987 /test
parent3ebe813f872ca7e7ef695a43ef3538e0704e5498 (diff)
downloadchrome-ec-42f16aed53d6b7120f3772768f1eeac9e882c076.tar.gz
commom: generalize rma_auth to and make it match server expectations
Different devices could have different sized unique device IDs. Let's just use the IDs as is if they are no larger than the rma_challenge:device_id field, or the first 8 bytes of the HMAC_sha256 value of the unique device ID, where the unique device ID is used both as the key and the payload. The server expects the board ID field in big endian format, let's swap it before calculating the RMA auth challenge. The test's server side implementation needs to be also adjusted. BRANCH=cr50 BUG=b:37952913 TEST=make buildall -j passes. With the rest of the patches applied RMA authentication process generates sensible values. Change-Id: Ia1fbf9161e01de30a2da8214258008f6e5f7d915 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/690991 Reviewed-by: Michael Tang <ntang@chromium.org> (cherry picked from commit 34ce0a90a59979f7a82e7efdd41481370fb31498) Reviewed-on: https://chromium-review.googlesource.com/734636
Diffstat (limited to 'test')
-rw-r--r--test/rma_auth.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/rma_auth.c b/test/rma_auth.c
index d833a2c33b..1ff0c63ea5 100644
--- a/test/rma_auth.c
+++ b/test/rma_auth.c
@@ -5,6 +5,7 @@
* Test RMA auth challenge/response
*/
+#include <endian.h>
#include <stdio.h>
#include "common.h"
#include "chip/g/board_id.h"
@@ -62,6 +63,7 @@ int rma_server_side(char *out_auth_code, const char *challenge)
uint8_t hmac[32];
struct rma_challenge c;
uint8_t *cptr = (uint8_t *)&c;
+ uint32_t inverted_board_id;
/* Convert the challenge back into binary */
if (base32_decode(cptr, 8 * sizeof(c), challenge, 9) != 8 * sizeof(c)) {
@@ -100,7 +102,9 @@ int rma_server_side(char *out_auth_code, const char *challenge)
* Since this is just a test, here we'll just make sure the BoardID
* and DeviceID match what we expected.
*/
- if (memcmp(c.board_id, dummy_board_id, sizeof(c.board_id))) {
+ memcpy(&inverted_board_id, dummy_board_id, sizeof(inverted_board_id));
+ inverted_board_id = be32toh(inverted_board_id);
+ if (memcmp(c.board_id, &inverted_board_id, sizeof(c.board_id))) {
printf("BoardID mismatch\n");
return -1;
}