src/securityPolicy.c
static security_policy_t _policyForDeriveAddress(const addressParams_t* addressParams, security_policy_t successPolicy)
{
	DENY_UNLESS(isValidAddressParams(addressParams));

	switch (addressParams->type) {

	case BASE_PAYMENT_KEY_STAKE_KEY:
		// unusual path
		WARN_UNLESS(bip44_isPathReasonable(&addressParams->spendingKeyPath));
		WARN_IF(
		        addressParams->stakingDataSource == STAKING_KEY_PATH &&
		        !bip44_isPathReasonable(&addressParams->stakingKeyPath)
		);
		break;

	case BASE_PAYMENT_KEY_STAKE_SCRIPT:
	case POINTER_KEY:
	case ENTERPRISE_KEY:
	case BYRON:
		// unusual path
		WARN_UNLESS(bip44_isPathReasonable(&addressParams->spendingKeyPath));
		break;

	case BASE_PAYMENT_SCRIPT_STAKE_KEY:
	case REWARD_KEY:
		// we only support derivation based on key path
		DENY_IF(addressParams->stakingDataSource != STAKING_KEY_PATH);

		// unusual path
		WARN_UNLESS(bip44_isPathReasonable(&addressParams->stakingKeyPath));
		break;

	case BASE_PAYMENT_SCRIPT_STAKE_SCRIPT:
	case POINTER_SCRIPT:
	case ENTERPRISE_SCRIPT:
	case REWARD_SCRIPT:
		// no paths in the address
		break;

	default:
		DENY();
		break;
	}

	return successPolicy;
}
// common policy for DENY and WARN cases in returnDeriveAddress and showDeriveAddress
// successPolicy is returned if no DENY or WARN applies
common policy for DENY and WARN cases in returnDeriveAddress and showDeriveAddress
successPolicy is returned if no DENY or WARN applies
common policy for DENY and WARN cases in returnDeriveAddress and showDeriveAddress successPolicy is returned if no DENY or WARN applies
static security_policy_t _policyForDeriveAddress(const addressParams_t* addressParams, security_policy_t successPolicy)
{
	DENY_UNLESS(isValidAddressParams(addressParams));
	switch (addressParams->type) {
	case BASE_PAYMENT_KEY_STAKE_KEY:
		WARN_UNLESS(bip44_isPathReasonable(&addressParams->spendingKeyPath));
		WARN_IF(
		        addressParams->stakingDataSource == STAKING_KEY_PATH &&
		        !bip44_isPathReasonable(&addressParams->stakingKeyPath)
		);
		break;
	case BASE_PAYMENT_KEY_STAKE_SCRIPT:
	case POINTER_KEY:
	case ENTERPRISE_KEY:
	case BYRON:
		WARN_UNLESS(bip44_isPathReasonable(&addressParams->spendingKeyPath));
		break;
	case BASE_PAYMENT_SCRIPT_STAKE_KEY:
	case REWARD_KEY:
		DENY_IF(addressParams->stakingDataSource != STAKING_KEY_PATH);
		WARN_UNLESS(bip44_isPathReasonable(&addressParams->stakingKeyPath));
		break;
	case BASE_PAYMENT_SCRIPT_STAKE_SCRIPT:
	case POINTER_SCRIPT:
	case ENTERPRISE_SCRIPT:
	case REWARD_SCRIPT:
		break;
	default:
		DENY();
		break;
	}
	return successPolicy;
}
static security_policy_t _policyForDeriveAddress ( const addressParams_t * addressParams , security_policy_t successPolicy ) { DENY_UNLESS ( isValidAddressParams ( addressParams ) ) ; switch ( addressParams -> type ) { case BASE_PAYMENT_KEY_STAKE_KEY : WARN_UNLESS ( bip44_isPathReasonable ( & addressParams -> spendingKeyPath ) ) ; WARN_IF ( addressParams -> stakingDataSource == STAKING_KEY_PATH && ! bip44_isPathReasonable ( & addressParams -> stakingKeyPath ) ) ; break ; case BASE_PAYMENT_KEY_STAKE_SCRIPT : case POINTER_KEY : case ENTERPRISE_KEY : case BYRON : WARN_UNLESS ( bip44_isPathReasonable ( & addressParams -> spendingKeyPath ) ) ; break ; case BASE_PAYMENT_SCRIPT_STAKE_KEY : case REWARD_KEY : DENY_IF ( addressParams -> stakingDataSource != STAKING_KEY_PATH ) ; WARN_UNLESS ( bip44_isPathReasonable ( & addressParams -> stakingKeyPath ) ) ; break ; case BASE_PAYMENT_SCRIPT_STAKE_SCRIPT : case POINTER_SCRIPT : case ENTERPRISE_SCRIPT : case REWARD_SCRIPT : break ; default : DENY ( ) ; break ; } return successPolicy ; }
common policy for DENY and WARN cases in returnDeriveAddress and showDeriveAddress
successPolicy is returned if no DENY or WARN applies
common policy for DENY and WARN cases in returnDeriveAddress and showDeriveAddress successPolicy is returned if no DENY or WARN applies
// unusual path // unusual path // we only support derivation based on key path // unusual path // no paths in the address