Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When picking winning sec, properly filter out the ones we didn't declare #13

Closed
phhusson opened this issue Jul 5, 2023 · 5 comments
Closed

Comments

@phhusson
Copy link
Owner

phhusson commented Jul 5, 2023

Jio has:

07-05 23:00:58.804  2284  2357 D PHH SipHandler: > Security-Server: ipsec-3gpp;q=0.6;alg=hmac-md5-96;ealg=aes-cbc;spi-c=889215030;spi-s=889215031;port-c=32920;port-s=5067, ipsec-3gpp;q=0.4;alg=hmac-md5-96;ealg=des-ede3-cbc;spi-c=889215030;spi-s=889215031;port-c=32920;port-s=5067, ipsec-3gpp;q=0.3;alg=hmac-md5-96;spi-c=889215030;spi-s=889215031;port-c=32920;port-s=5067, ipsec-3gpp;q=0.1;alg=hmac-sha-1-96;ealg=des-ede3-cbc;spi-c=889215030;spi-s=889215031;port-c=32920;port-s=5067, ipsec-3gpp;q=0.2;alg=hmac-sha-1-96;ealg=aes-cbc;spi-c=889215030;spi-s=889215031;port-c=32920;port-s=5067, ipsec-3gpp;q=0.5;alg=hmac-sha-1-96;spi-c=889215030;spi-s=889215031;port-c=32920;port-s=5067
```

We send sha1/aes + sha1/null. Current code sorts by q and takes whichever ealg wins. In this case it's AES, even though that's meant to be AES/MD5. If we take highest q with sha1, then it's sha1/null that wins.

So in this case we're supposed to pick sha1/null, but we wrongly chose sha1/aes
@martinetd
Copy link
Contributor

Eh, why'd they put sha1/aes at a lower q than sha1/null, especially when md5/aes is first :/

I guess that's enough motivation to support AUTH_HMAC_MD5 as well, that ought to be easy enough. I'll send a patch that supports md5 and picks the right pair

@martinetd
Copy link
Contributor

martinetd@383ce05 should work better for this particular case; but thinking back this really should have worked: the Security-Server you gave as an example does list sha1/aes-cbc, with all other values (spi/ports) being identical, so while sha1+aes was't the first choice it should be supported...
I guess ultimately we'll have to leave it up to some configuration option e.g. I sure would want to enable aes if there's a valid option that works with aes even if it's not the first choice (the option could be "disallow null encryption" or something simpler than actually selecting alg/ealg though)

I didn't open a PR because your main branch is quite a bit far behind mine (alarm, some cleanup); but patch should apply cleanly if you want to try, and it should select md5/fix key length as you did so that'll probably work

@phhusson
Copy link
Owner Author

phhusson commented Jul 7, 2023 via email

@martinetd
Copy link
Contributor

Nope it shouldn't. The IPSec tunnel that the server prepared is the highest
q that is listed in both Security-Server and Security-Client. The server
doesn't prepare all intersecting variants

Ah, I was about to say we don't send hmac-md5 in our security-client, but you've patched that as well in your branch -- I'll fix that to also offer md5.

Ok so that makes sense, we just need to make the option adjust what is sent in Security-Client when we add one.

martinetd added a commit to martinetd/android_ims that referenced this issue Jul 7, 2023
- filter out unsupported alg/ealg in Security-Server
- handle hmac-md5-96 alg
- also adjust test to make sure this isn't too far off

Fixes: phhusson#13
martinetd added a commit to martinetd/android_ims that referenced this issue Jul 7, 2023
If we don't tell the server we accept hmac-md5-96 the tunnel won't be
setup with it

Fixes: phhusson#13
@martinetd
Copy link
Contributor

@phhusson Sorry should have said I updated the commit, please also take martinetd@c862196 (tip of my securityserver branch) for the Security-Client value

phhusson pushed a commit that referenced this issue Jul 7, 2023
If we don't tell the server we accept hmac-md5-96 the tunnel won't be
setup with it

Fixes: #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants