Skip to content

hostapd: add sae_password_file support - #14448

Closed
roshii wants to merge 1 commit into
openwrt:mainfrom
roshii:sae_password_file
Closed

roshii wants to merge 1 commit into
openwrt:mainfrom
roshii:sae_password_file

Conversation

@roshii

@roshii roshii commented Jan 21, 2024 •

Copy link
Copy Markdown

With sae or sae-mixed encryption it is currently not possible to assign multiple passwords to a single bss.

This PR adds multiple passwords support for the above mentioned encryption mode both via wifi-station config section and sae_password_file entry on wifi-iface section, therefore allowing VLAN ID assignment for WPA3 clients (using password identifiers).

@roshii
roshii force-pushed the sae_password_file branch from d15abc5 to 73e3922 Compare January 21, 2024 12:54
@github-actions github-actions Bot added the core packages pull request/issue for core (in-tree) packages label Jan 21, 2024

function bss_reload_psk(bss, config, old_config)
{
if (is_equal(old_config.hash.wpa_psk_file, config.hash.wpa_psk_file))

@rany2 rany2 Jan 21, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be here, it should instead regenerate the config if the sae_password_file changed. This won't do anything.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really not sure about this one but simply put: if it doesn't do anything here, why would it do something in case of change to wpa_psk_file ? Shouldn't the logic be the same for both sae_password_file and wpa_psk_file ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because RELOAD_WPA_PSK only reloads the wpa_psk_file and it's functionality handled by hostapd itself, sae_password_file is not handled by hostapd (as we're generating the sae_password line on the fly) and so we will need to regenerate the config and reload if it changed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit b78f011 is my best guess at solving this one. I never did touch UnrealScript before and so I cannot guarantee syntax is correct but the logic should work

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not UnrealScript, it's ucode: https://github.com/jow-/ucode

As you can imagine I did never used ucode either, thanks :)

@roshii
roshii marked this pull request as draft January 23, 2024 19:46
@@ -408,7 +409,7 @@ hostapd_set_psk_file() {
json_get_vars mac vid key
set_default mac "00:00:00:00:00:00"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With SAE, there can only be one default key because - unlike with PSK2 - the AP can't check a PMK on its own.
That means there can be only one definition for MAC 00:00:00:00:00:00.
Maybe it makes sense to make that more explicit?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that is unless we start using id?)
hmm

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means there can be only one definition for MAC 00:00:00:00:00:00.

I don't think we should restrain it (at the very least not in hostapd_set_psk_file). As a matter of facts, multiple PSK2 password set for MAC 00:00:00:00:00:00 are used to assign VLAN ID to clients based on their password.
But you are right, this ain't working with SAE, and while I did not know that when first working on this PR, hostapd_set_sae_password is now required since logic is different. With that in mind, it makes sense to implement support for id parameter.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Password ID support implemented via e05e0c3
Exiting function with a message to stdout if a password is already set for default MAC with no ID.

@rany2

rany2 commented Mar 18, 2024

Copy link
Copy Markdown
Contributor

Personally I think the approach in my PR is slightly better, #14515. I simply used the upstream patch

@yogo1212

Copy link
Copy Markdown
Contributor

@rany2 If there wasn't already the infrastructure for defining stations using UCI, I'd also favour your more direct approach.
Presumedly, there will be some of both. The sae_password_file and support for UCI-defined stations.

We should figure out how UCI and wpa_psk_file should work in @Ansuel 's PR. Likely, what applies to wpa_psk_file will apply to sae_password_file as well.

Just adding the option like you do here might make future work more difficult if people start using the file directly (going past the existing Openwrt infrastructure).

@rany2

rany2 commented Mar 18, 2024

Copy link
Copy Markdown
Contributor

Likely, what applies to wpa_psk_file will apply to sae_password_file as well.

No, it does not. WPS is only a WPA2 thing.

@yogo1212

yogo1212 commented Mar 18, 2024 •

Copy link
Copy Markdown
Contributor

@rany2 I agree that WPS has nothing to do with it.

The more important point is:
There are two principal ways to specify passwords. One being UCI and a file being the other.
How they function together - if they do at all - should be figured out before we put in place a solution that people start using now (the file) because it might narrow down the possibilities in the future.

For the UCI-based mechanism, the file is just an artifact. It seems to me that your PR intends to have people writing to the file directly. If they start doing that, it's going to be more difficult to start using the UCI-defined stations for SAE in the future.

@rany2

rany2 commented Mar 18, 2024

Copy link
Copy Markdown
Contributor

For the UCI-based mechanism, the file is just an artifact. It seems to me that your PR intends to have people writing to the file directly. If they start doing that, it's going to be more difficult to start using the UCI-defined stations for SAE in the future.

It doesn't matter, if someone wanted to use a UCI-based mechanism they could just specify sae_password manually and we would simply create a new UCI option called like list sae_password 'blah blah blah'. sae_password_file works in the same way as specifying sae_password manually one line at a time, there is no need for it to be an artifact. I think your concern is misplaced.

@yogo1212

yogo1212 commented Mar 18, 2024 •

Copy link
Copy Markdown
Contributor

I would like to respectfully disagree.
Adding options to specify the list file directly is something that can't be taken back easily.
If it conflicts with a solution that is preferable, it is going to be difficult to take back because there'll be users who's setups are going to break if it's changed.
I'm not saying there should be no such option but if there is, it should probably be merged with a list generated from UCI to maintain compatibility with the solution already present in Openwrt.

Also, I would strongly advise against a list sae_password option.
With SAE, both parties (AP and station) have to cooperate to make one attempt at testing a password.
If you want to test 10 passwords and the last one is correct, the end user will receive nine messages telling them the password they entered was wrong despite you expecting them to try the same password again.
And that's just in theory. In practice, hostapd doesn't support that.

There's only one attempt. No guesswork and no brute-force (like it was possible with PSK2). A list of passwords simply makes no sense. You need to know which 1 password to test. In effect, this means you get one dictionary lookup (MAC + opt. key id) and, in case of a miss, you could go with a default.

@rany2

rany2 commented Mar 19, 2024

Copy link
Copy Markdown
Contributor

@yogo1212 I really don't understand what you're arguing about. Hostapd already supports specifying sae_password multiple times. You could specify both sae_password and sae_password_file, it's not mutually exclusive. sae_password_file is just treated by hostapd as if each line is a new sae_password entry.

The only difference is that you could only have one wildcard entry with SAE (if you specify multiple wildcard entries, the last one takes effect) whereas PSK does a brute force matching for every matching entry.

@yogo1212

yogo1212 commented Mar 21, 2024 •

Copy link
Copy Markdown
Contributor

@rany2 In my last comment, I was mainly concerned that there was a misconception about SAE because your proposal of adding a list option to specify SAE passwords.
But that appears to be no issue.

My more general concern is that there is currently a dichotomy regarding wpa_psk_file that is replicated for sae_password_file in this PR.

  1. it is used in hostapd.sh and mac80211.sh to load passwords/VLAN IDs from UCI
  • /var/run/hostapd-${ifname}.psk 'belongs' to Openwrt
  1. users can manually specify wpa_psk_file and use their own
  • wpa_psk_file belongs to the user
  • the stations configured in UCI become ineffective
  1. hostapd writes to wpa_psk_file if WPS is enabled
  • wpa_psk_file 'belongs' to hostapd
  • doesn't apply directly to sae_password_file but the solution for wpa_psk_file might work well here too

It makes sense for Openwrt to provide an abstraction for PSK2/SAE and, in fact, it already does (in part).
A solution should be expected for wpa_psk_file - there's the added pressure of making WPS provisions persistent. Maybe that means introducing a breaking change in Openwrt 24.

I simply want to avoid having to do a breaking change here as well. Right now, there is no support for sae_password_file, which means there is no breakage - there is also no pressure to introduce a feature prone to 'breaking' in the future.
If a feature is out there, we have to assume there are people using it which likely makes "add a UCI config flag deeming the usage model for sae_password_file" a breaking change.

One way to deal with this could be to only use sae_password_file internally for UCI-based provisions rather than exposing it to users.
That way, support for user-supplied files can be enabled later according to the model that (hopefully) will be agreed upon.

Another way could be to agree now that the goal will be to always merge UCI stations and user-supplied file into one.
Even tacking that on later can be a breaking change if users have come to rely on the fact that UCI-based stations are separate from their self-maintained file.

It is not my intention to upset anyone now but to avoid greater upset (also affecting users) in the future.

@roshii
roshii force-pushed the sae_password_file branch from 73e3922 to 251bda3 Compare April 10, 2024 12:43
)
if (is_equal(type, "sae")) {
let file = "sae_password_file"
let cmd = "RELOAD_CONFIG"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, it doesn't reread the sae_password_file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rany2 if it doesn't reread the file; how can that work for psk?
bss_reload_psk is comparing file hashes which must be computed by reading the file and so if it works for wpa_psk_file there is no reason it does not for sae_password_file or am I missing something?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i'm not mistaking hashes are calculated only once, when loading config in iface_load_config which is called prior to iface_set_config and in which iface_reload_config is called and comparing file hashes. so afaik, file hash is updated at the time bss_reload_psk is called

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roshii I think it's just hostapd bug

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're reading the sae_password_file yourself and then setting the sae_password(s). I thought you were using the hostapd option by now as it is now available in OpenWRT's hostapd. I'm not sure if the bug is relevant if you're setting the sae_password in the hostapd config but maybe not. You need to test it.

However I know for sure that if you used hostapd sae_password_file option it does not work

@jow- jow- Apr 11, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code can't work since let xxx variables declared inside a block are scoped to that block, they`re not visible outside. Also semicolons are mandatory to terminate a statement (they're only optional for the last statement in a block).

It needs to be something like this:

let file, cmd, msg;

if (type == "sae") {
	file = "sae_password_file";
	cmd = "RELOAD_CONFIG";
	msg = "Reload config on sae_password_file change for bss";
}
else {
	file = "wpa_psk_file";
	cmd = "RELOAD_WPA_PSK";
	msg = "Reload WPA PSK file for bss";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't ucode complain about this not being valid? At any rate, I was actually referring to RELOAD_CONFIG and RELOAD_BSS_CONFIG not reloading for hostapd's sae_password_file option in specific; I hadn't confirmed that this issue is relevant for when sae_password is defined in hostapd config. I didn't know that this wasn't valid code in the first place. I didn't test this submission.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're reading the sae_password_file yourself and then setting the sae_password(s). I thought you were using the hostapd option by now as it is now available in OpenWRT's hostapd. I'm not sure if the bug is relevant if you're setting the sae_password in the hostapd config but maybe not. You need to test it.

Thanks, I will test implementation and report back.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rany2 I can now confirm wifi script needs to be called when sae_password_file is amended. hostapd.conf is then regenerated with sae_password_file content.

@roshii
roshii force-pushed the sae_password_file branch from 72ce735 to b04e331 Compare April 12, 2024 12:56
@roshii

roshii commented Apr 16, 2024 •

Copy link
Copy Markdown
Author

While functional, I realize the PR is far from perfect, I am discovering OpenWrt inner working with it.

One way to deal with this could be to only use sae_password_file internally for UCI-based provisions rather than exposing it to users. That way, support for user-supplied files can be enabled later according to the model that (hopefully) will be agreed upon.

Another way could be to agree now that the goal will be to always merge UCI stations and user-supplied file into one. Even tacking that on later can be a breaking change if users have come to rely on the fact that UCI-based stations are separate from their self-maintained file.

Both options make sense IMHO. We could proceed as follows

  1. Amend this PR to just parse UCI configuration into sae_password entries, or (ideally) using sae_password_file option with hostapd patch from hostapd: SAE passwords from a separate file #14515 which would allow users to use WPA3 just like WAP2
  2. Create a new PR that handles merging UCI stations and user-supplied file into one, and exposing sae_password_file to UCI

@roshii

roshii commented Apr 16, 2024 •

Copy link
Copy Markdown
Author

Latest two commits add support for password identifiers in wifi-station section and gives priority to UCI configured password over the ones supplied by file. All password will end-up merged into a single OpenWrt owned file.

Would anyone disagree with this approach, I can simply remove the sae_password_file option until we come to an agreement on how to handle merging and just keep the UCI defined station.

@roshii
roshii force-pushed the sae_password_file branch from 852f8c6 to d636ecc Compare April 16, 2024 14:07
@roshii

roshii commented Apr 16, 2024 •

Copy link
Copy Markdown
Author

I just squashed all commits and will make sure I do not pollute this PR with work-in-progress commits in the future - I clearly made it a mess, please accept my apologies for that.

I am really not sure about what to do with the changes to hostapd.uc, I guess it should just be removed and aligned with what @rany2 did in #14515. Please advice.

Any suggestions are welcomed.

@roshii
roshii marked this pull request as ready for review April 16, 2024 14:16
@roshii
roshii force-pushed the sae_password_file branch from d636ecc to fe8dd4d Compare April 16, 2024 15:12
- Adds SAE support to station defined using `wifi-section` configuration section
- Adds support for password identifiers using `pwid` option in `wifi-section` section
- Adds support for `sae_password_file` option in `wifi-iface` section, merging with UCI defined password

Signed-off-by: Simon Castano <[email protected]>
@roshii
roshii force-pushed the sae_password_file branch from fe8dd4d to feba237 Compare April 16, 2024 16:54
@rany2

rany2 commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

This PR should be closed, it's already been implemented with:

Shell:

Ucode:

@Neustradamus

Neustradamus commented Nov 10, 2025 •

Copy link
Copy Markdown

@rany2: Good job and thanks to @robimarko for recent merging! :)

@rany2: Other tickets/PRs that I have listed here can be closed?

@robimarko, like @rany2 has said, this ticket can be closed, maybe other ones too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core packages pull request/issue for core (in-tree) packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants