common: make rma_auth work with the server

A couple of bugs have crept in with the latest series of patches:

 - the board ID value endianness does not have to be changed
 - the test RMA server public key value is wrong

BRANCH=cr50
BUG=b:67007905
TEST=the generated challenge is now accepted by the server, and the
      generated auth code matches between the server and the Cr50.

Change-Id: I18f413ab0bcc14d9cc50b115ac3784fdfcd5851c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/700798
Reviewed-by: Michael Tang <ntang@chromium.org>
This commit is contained in:
Vadim Bendebury
2017-10-03 18:49:31 -07:00
committed by chrome-bot
parent 04db902fee
commit 12181aacde
3 changed files with 6 additions and 11 deletions

View File

@@ -350,11 +350,11 @@ enum nvmem_users {
#define CONFIG_RNG
/* Dummy values to be replaced with real ones. */
#define CONFIG_RMA_AUTH_SERVER_PUBLIC_KEY { \
0x47, 0x3b, 0xa5, 0xdb, 0xc4, 0xbb, 0xd6, 0x77, \
0x20, 0xbd, 0xd8, 0xbd, 0xc8, 0x7a, 0xbb, 0x07, \
0x03, 0x79, 0xba, 0x7b, 0x52, 0x8c, 0xec, 0xb3, \
0x4d, 0xaa, 0x69, 0xf5, 0x65, 0xb4, 0x31, 0xad}
#define CONFIG_RMA_AUTH_SERVER_PUBLIC_KEY { \
0x03, 0xae, 0x2d, 0x2c, 0x06, 0x23, 0xe0, 0x73, \
0x0d, 0xd3, 0xb7, 0x92, 0xac, 0x54, 0xc5, 0xfd, \
0x7e, 0x9c, 0xf0, 0xa8, 0xeb, 0x7e, 0x2a, 0xb5, \
0xdb, 0xf4, 0x79, 0x5f, 0x8a, 0x0f, 0x28, 0x3f}
#define CONFIG_RMA_AUTH_SERVER_KEY_ID 0x10
#endif /* __CROS_EC_BOARD_H */

View File

@@ -102,8 +102,6 @@ int rma_create_challenge(void)
if (read_board_id(&bid))
return EC_ERROR_UNKNOWN;
/* The server wants this as a string, not a number. */
bid.type = htobe32(bid.type);
memcpy(c.board_id, &bid.type, sizeof(c.board_id));
unique_device_id_size = system_get_chip_unique_id(&device_id);

View File

@@ -63,7 +63,6 @@ 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)) {
@@ -102,9 +101,7 @@ 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.
*/
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))) {
if (memcmp(c.board_id, dummy_board_id, sizeof(c.board_id))) {
printf("BoardID mismatch\n");
return -1;
}