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

basic support for SIP SHA-256 digest #180

Closed
wants to merge 3 commits into from

Conversation

alberanid
Copy link

This PR introduces support for SHA-256 in SIP authentication.

What's missing:

Also notice that right now it only works if OpenSSL is available; sha1.c doesn't support sha2 algorithms
and I'm not sure which of the various implementations is better to be included in Baresip.

An example of SIP server that supports SHA-256 digests is FlexiSIP.

Any help to improve this PR is welcome.

@sreimers
Copy link
Member

Thanks, can you add a test case for sip_auth_encode() in retest (the PR title has to match)?

@alberanid
Copy link
Author

Thanks, can you add a test case for sip_auth_encode() in retest (the PR title has to match)?

I gave it a try, but I fear I don't know enough of the Baresip internals to do a proper test.

In the attachment, a draft of implementation:
test_sip_auth_encode.txt

but it fails with:

  CC      build-x86_64/src/sip.o
src/sip.c: In function ‘test_sip_auth_encode’:
src/sip.c:878:8: warning: implicit declaration of function ‘sip_auth_encode’; did you mean ‘sip_addr_encode’? [-Wimplicit-function-declaration]
  878 |  err = sip_auth_encode(mb, auth, met, uri);
      |        ^~~~~~~~~~~~~~~
      |        sip_addr_encode
src/sip.c:878:8: warning: nested extern declaration of ‘sip_auth_encode’ [-Wnested-externs]

Since sip_auth_encode is not directly accessible.

Also, isn't it already covered by the test_sip_drequestf test?

Thanks.

@@ -155,6 +193,10 @@ static bool auth_handler(const struct sip_hdr *hdr, const struct sip_msg *msg,
if (err)
goto out;

err = pl_strdup(&realm->algorithm, &ch.algorithm);
Copy link
Member

Choose a reason for hiding this comment

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

I have added a new test case baresip/retest@78ea4df
If algorithm is not specified, pl_strdup fails with EINVAL.

@sreimers
Copy link
Member

@alberanid could you take a closer look at the failed test?

@alberanid
Copy link
Author

@sreimers I hope to be able to do so in the next few weeks, but I can't guarantee any timeline at the moment.

@alberanid
Copy link
Author

@alberanid could you take a closer look at the failed test?

See baresip/retest#39 - let me know is something else is needed. Thanks.

};

void sha256(const uint8_t *d, size_t n, uint8_t *md);
int sha256_printf(uint8_t *md, const char *fmt, ...);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to make the sha256 code into a separate PR ?

this way it is easier to test and to review ...

@alfredh
Copy link
Contributor

alfredh commented Feb 26, 2022

hi @alberanid

it looks like your patch have some merge conflicts now.
is there any chance you could rebase on top of HEAD ?

@alberanid
Copy link
Author

is there any chance you could rebase on top of HEAD ?

Unfortunately for the next few weeks I'll be really busy, but I'll try to do it as soon as possible.

@alfredh
Copy link
Contributor

alfredh commented Apr 3, 2022

hi @alberanid

we have added wrappers for sha256:

#306 (comment)

so if you rebase your patch, the patch should be smaller :)

@alfredh
Copy link
Contributor

alfredh commented Apr 7, 2022

hi @alberanid

if there is no progress here, I suggest to close the PR and open a new one when you have time to work on it.

I am happy to help with this

@alberanid
Copy link
Author

hi @alfredh , yes, it's fine for me.

I'd like to merge our implementation, but right now I can't commit to any timeline. Feel free to use the code in this PR, in any case.

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

Successfully merging this pull request may close these issues.

3 participants