Implemented the optional chain ID in the GET_ETH_PUBLIC_ADDRESS apdu
This commit is contained in:
@@ -87,6 +87,7 @@ The address can be optionally checked on the device before being returned.
|
||||
| First derivation index (big endian) | 4
|
||||
| ... | 4
|
||||
| Last derivation index (big endian) | 4
|
||||
| Chain ID (big endian) (optional) | 8
|
||||
|==============================================================================================================================
|
||||
|
||||
'Output data'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "shared_context.h"
|
||||
#include "apdu_constants.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "feature_getPublicKey.h"
|
||||
#include "ethUtils.h"
|
||||
#include "common_ui.h"
|
||||
@@ -21,16 +21,16 @@ void handleGetPublicKey(uint8_t p1,
|
||||
}
|
||||
|
||||
if ((p1 != P1_CONFIRM) && (p1 != P1_NON_CONFIRM)) {
|
||||
THROW(0x6B00);
|
||||
THROW(APDU_RESPONSE_INVALID_P1_P2);
|
||||
}
|
||||
if ((p2 != P2_CHAINCODE) && (p2 != P2_NO_CHAINCODE)) {
|
||||
THROW(0x6B00);
|
||||
THROW(APDU_RESPONSE_INVALID_P1_P2);
|
||||
}
|
||||
|
||||
dataBuffer = parseBip32(dataBuffer, &dataLength, &bip32);
|
||||
|
||||
if (dataBuffer == NULL) {
|
||||
THROW(0x6a80);
|
||||
THROW(APDU_RESPONSE_INVALID_DATA);
|
||||
}
|
||||
|
||||
tmpCtx.publicKeyContext.getChaincode = (p2 == P2_CHAINCODE);
|
||||
@@ -51,12 +51,25 @@ void handleGetPublicKey(uint8_t p1,
|
||||
tmpCtx.publicKeyContext.address,
|
||||
&global_sha3,
|
||||
chainConfig->chainId);
|
||||
|
||||
uint64_t chain_id = chainConfig->chainId;
|
||||
if (dataLength >= sizeof(chain_id)) {
|
||||
chain_id = u64_from_BE(dataBuffer, sizeof(chain_id));
|
||||
dataLength -= sizeof(chain_id);
|
||||
dataBuffer += sizeof(chain_id);
|
||||
}
|
||||
|
||||
(void) dataBuffer; // to prevent dead increment warning
|
||||
if (dataLength > 0) {
|
||||
THROW(APDU_RESPONSE_INVALID_DATA);
|
||||
}
|
||||
|
||||
#ifndef NO_CONSENT
|
||||
if (p1 == P1_NON_CONFIRM)
|
||||
#endif // NO_CONSENT
|
||||
{
|
||||
*tx = set_result_get_publicKey();
|
||||
THROW(0x9000);
|
||||
THROW(APDU_RESPONSE_OK);
|
||||
}
|
||||
#ifndef NO_CONSENT
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user