Skip to content

Add options to set op and amf for aka auth in pjsua cli tool#4354

Merged
sauwming merged 4 commits intopjsip:masterfrom
alexander-zerpa:master
Mar 24, 2025
Merged

Add options to set op and amf for aka auth in pjsua cli tool#4354
sauwming merged 4 commits intopjsip:masterfrom
alexander-zerpa:master

Conversation

@alexander-zerpa
Copy link
Contributor

The documentation specifies that if pjsip is compiled with Digest AKA Authentication support then:

Optionally application may set ext.aka.op and ext.aka.amf in the credential to specify AKA Operator variant key and AKA Authentication Management Field information.

This PR adds some options to pjsua cli interface in order to set them on app launch if needed.

Tip

As of #1728, manually linking of milenage third-party library is required. Easiest way I found of doing this was to simply run a git revert on 7a302f2

@CLAassistant
Copy link

CLAassistant commented Mar 13, 2025

CLA assistant check
All committers have signed the CLA.

@sauwming
Copy link
Member

You need to implement write_settings() for the new options.

@alexander-zerpa
Copy link
Contributor Author

alexander-zerpa commented Mar 17, 2025

This this options were quickly added to be able to test some thing on a project I'm working on, and as such I'm mainly coping the behavior demonstrated by the --password option when working with AKA AUTH.

However, in my experience all this parameters (including K) tent to be binary values, generally represented as hex to the user. Right now I manually convert to ASCII before passing the argument to pjsua, but in a future it would be interesting to support parsing the hex representation if provided.

@sauwming sauwming requested a review from nanangizz March 17, 2025 09:13
@sauwming sauwming added this to the release-2.16 milestone Mar 17, 2025
@nanangizz
Copy link
Member

However, in my experience all this parameters (including K) tent to be binary values, generally represented as hex to the user. Right now I manually convert to ASCII before passing the argument to pjsua, but in a future it would be interesting to support parsing the hex representation if provided.

Yes, I think it is better to have hex string for UI. Currently there are only these basic functions pj_hex_digit_to_val() & pj_val_to_hex_digit().

Sample usages:

  • hex string to octet array:
    /* Hexa string to octet array */
    int my_hex_string_to_octet_string(char *raw, char *hex, int len)
    {
    int i;
    for (i = 0; i < len; i+=2) {
    int tmp;
    if (i+1 >= len || !pj_isxdigit(hex[i]) || !pj_isxdigit(hex[i+1]))
    return i;
    tmp = pj_hex_digit_to_val((unsigned char)hex[i]) << 4;
    tmp |= pj_hex_digit_to_val((unsigned char)hex[i+1]);
    raw[i/2] = (char)(tmp & 0xFF);
    }
    return len;
    }
  • octet array to hex string:
    /* Transform digest to string.
    * output must be at least PJSIP_MD5STRLEN+1 bytes.
    *
    * NOTE: THE OUTPUT STRING IS NOT NULL TERMINATED!
    */
    static void digestNtoStr(const unsigned char digest[], int n, char *output)
    {
    int i;
    for (i = 0; i<n; ++i) {
    pj_val_to_hex_digit(digest[i], output);
    output += 2;
    }
    }

Btw, --op & --amf do not sound very intuitive, what about --aka-op & --aka-amf?

@nanangizz
Copy link
Member

Could you also integrate the hex representation for UI (using the samples above as ref perhaps)? Because having ASCII representation for binary/octet strings does not seem practical (e.g: not possible to have zero or some non-printable chars in the middle) and changing it in the future may require a new set of params (and perhaps deprecating the current params --aka-op & --aka-amf) to avoid backward compatibilities issues.

@alexander-zerpa
Copy link
Contributor Author

Could you also integrate the hex representation for UI

I'll look into that, I need to make the time tough so might take a wile before I can get to it

@nanangizz
Copy link
Member

Perhaps I can do it, if it is okay with you, please make sure this is enabled?

@alexander-zerpa
Copy link
Contributor Author

please make sure this is enabled?

It is

@nanangizz
Copy link
Member

Done & tested quickly, please check.

@alexander-zerpa
Copy link
Contributor Author

Works correctly on my setup.

@sauwming sauwming merged commit a6e13db into pjsip:master Mar 24, 2025
42 checks passed
BarryYin pushed a commit to BarryYin/pjproject that referenced this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments