Skip to content

Commit

Permalink
use namespace from XEP and remove ability to set it at build time
Browse files Browse the repository at this point in the history
since the XEP was officially accepted, the "untraditional" namespace
became the official one.
  • Loading branch information
gkdr committed Jan 31, 2022
1 parent 8b147e5 commit 6f153c0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A function to check via the attribute whether a received key is a prekey.
- Mention in the README the exact version implemented. ([#26](https://github.com/gkdr/libomemo/issues/26))

## Removed
- It is not any longer possible to set the used XML namespace at build time. ([#21](https://github.com/gkdr/libomemo/issues/21))

### Fixed
- Added missing symlinks for the `.so` files. ([#34](https://github.com/gkdr/libomemo/pull/34)) (thanks, [@hartwork](https://github.com/hartwork)!)
- Fix crossbuild using wrong multiarch triplet. ([#36](https://github.com/gkdr/libomemo/pull/36)) (thanks, [@fortysixandtwo](https://github.com/fortysixandtwo)!)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CFLAGS += -std=c11 -Wall -Wextra -Wpedantic -Wstrict-overflow \
-fno-strict-aliasing -funsigned-char \
-fno-builtin-memset -g $(PKGCFG_C)
CPPFLAGS += -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE
CFLAGS_CONVERSATIONS=$(CFLAGS) -DOMEMO_XMLNS='"eu.siacs.conversations.axolotl"' -DOMEMO_NS_SEPARATOR='"."' -DOMEMO_NS_NOVERSION
CFLAGS_CONVERSATIONS=$(CFLAGS)
COVFLAGS = --coverage -O0 -g $(CFLAGS)
LDFLAGS += -pthread -ldl -lm $(PKGCFG_L)
TESTFLAGS = -lcmocka $(LDFLAGS)
Expand Down
18 changes: 2 additions & 16 deletions src/libomemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,9 @@

#define HINTS_XMLNS "urn:xmpp:hints"

#ifndef OMEMO_XMLNS
#define OMEMO_XMLNS "urn:xmpp:omemo"
#endif

#ifndef OMEMO_NS_SEPARATOR
#define OMEMO_NS_SEPARATOR ":"
#endif

#define OMEMO_NS_SEPARATOR "."
#define OMEMO_NS_SEPARATOR_FINAL ":"

#define OMEMO_VERSION "0"

#ifdef OMEMO_NS_NOVERSION
#define OMEMO_NS OMEMO_XMLNS
#else
#define OMEMO_NS OMEMO_XMLNS ":" OMEMO_VERSION
#endif
#define OMEMO_NS "eu.siacs.conversations.axolotl"

#define PEP_NODE_NAME "node"
#define DEVICELIST_PEP_NAME "devicelist"
Expand Down
62 changes: 31 additions & 31 deletions test/test_libomemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
#include "../src/libomemo.c"
#include "../src/libomemo_crypto.c"

char * devicelist = "<items node='urn:xmpp:omemo:0:devicelist'>"
char * devicelist = "<items node='eu.siacs.conversations.axolotl.devicelist'>"
"<item>"
"<list xmlns='urn:xmpp:omemo:0'>"
"<list xmlns='eu.siacs.conversations.axolotl'>"
"<device id='4223' />"
"<device id='1337' />"
"</list>"
"</item>"
"</items>";

char * bundle = "<items node='urn:xmpp:omemo:0:bundles:31415'>"
char * bundle = "<items node='eu.siacs.conversations.axolotl.bundles:31415'>"
"<item>"
"<bundle xmlns='urn:xmpp:omemo:0'>"
"<bundle xmlns='eu.siacs.conversations.axolotl'>"
"<signedPreKeyPublic signedPreKeyId='1'>sWsAtQ==</signedPreKeyPublic>"
"<signedPreKeySignature>sWsAtQ==</signedPreKeySignature>"
"<identityKey>sWsAtQ==</identityKey>"
Expand Down Expand Up @@ -60,7 +60,7 @@ void test_devicelist_create(void ** state) {
assert_int_equal(omemo_devicelist_create("alice", &dl_p), 0);
assert_string_equal(dl_p->from, "alice");
assert_string_equal(mxmlGetElement(dl_p->list_node_p), "list");
assert_string_equal(mxmlElementGetAttr(dl_p->list_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(dl_p->list_node_p, "xmlns"), "eu.siacs.conversations.axolotl");
assert_ptr_equal(mxmlGetFirstChild(dl_p->list_node_p), (void *) 0);

omemo_devicelist_destroy(dl_p);
Expand All @@ -73,7 +73,7 @@ void test_devicelist_import(void ** state) {
assert_int_equal(omemo_devicelist_import(devicelist, "bob", &dl_p), 0);
assert_string_equal(dl_p->from, "bob");
assert_string_equal(mxmlGetElement(dl_p->list_node_p), "list");
assert_string_equal(mxmlElementGetAttr(dl_p->list_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(dl_p->list_node_p, "xmlns"), "eu.siacs.conversations.axolotl");

mxml_node_t * device_node_p;
assert_int_equal(expect_next_node(dl_p->list_node_p, mxmlGetFirstChild, "device", &device_node_p), 0);
Expand All @@ -99,9 +99,9 @@ void test_devicelist_import(void ** state) {
void test_devicelist_import_empty(void ** state) {
(void) state;

char * devicelist_empty = "<items node='urn:xmpp:omemo:0:devicelist'>"
char * devicelist_empty = "<items node='eu.siacs.conversations.axolotl.devicelist'>"
"<item>"
"<list xmlns='urn:xmpp:omemo:0'>"
"<list xmlns='eu.siacs.conversations.axolotl'>"
"</list>"
"</item>"
"</items>";
Expand All @@ -117,7 +117,7 @@ void test_devicelist_import_empty(void ** state) {
void test_devicelist_import_empty_alt(void ** state) {
(void) state;

char * devicelist_empty = "<items node='urn:xmpp:omemo:0:devicelist' />";
char * devicelist_empty = "<items node='eu.siacs.conversations.axolotl.devicelist' />";

omemo_devicelist * dl_p;
assert_int_equal(omemo_devicelist_import(devicelist_empty, "alice", &dl_p), 0);
Expand Down Expand Up @@ -251,14 +251,14 @@ void test_devicelist_export(void ** state) {
mxml_node_t * publish_node_p = mxmlLoadString((void *) 0, xml, MXML_NO_CALLBACK);
assert_ptr_not_equal(publish_node_p, (void *) 0);
assert_string_equal(mxmlGetElement(publish_node_p), "publish");
assert_string_equal(mxmlElementGetAttr(publish_node_p, "node"), "urn:xmpp:omemo:0:devicelist");
assert_string_equal(mxmlElementGetAttr(publish_node_p, "node"), "eu.siacs.conversations.axolotl.devicelist");

mxml_node_t * item_node_p = mxmlGetFirstChild(publish_node_p);
assert_string_equal(mxmlGetElement(item_node_p), "item");

mxml_node_t * list_node_p = mxmlGetFirstChild(item_node_p);
assert_string_equal(mxmlGetElement(list_node_p), "list");
assert_string_equal(mxmlElementGetAttr(list_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(list_node_p, "xmlns"), "eu.siacs.conversations.axolotl");

mxml_node_t * device_node_p = mxmlGetFirstChild(list_node_p);
assert_string_equal(mxmlGetElement(device_node_p), "device");
Expand All @@ -278,7 +278,7 @@ void test_devicelist_get_pep_node_name(void ** state) {

char * node_name = (void *) 0;
assert_int_equal(omemo_devicelist_get_pep_node_name(&node_name), 0);
assert_string_equal(node_name, "urn:xmpp:omemo:0:devicelist");
assert_string_equal(node_name, "eu.siacs.conversations.axolotl.devicelist");

free(node_name);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ void test_bundle_export(void ** state) {
mxml_node_t * bundle_node_p = mxmlGetFirstChild(item_node_p);
assert_ptr_not_equal(bundle_node_p, (void *) 0);
assert_string_equal(mxmlGetElement(bundle_node_p), "bundle");
assert_string_equal(mxmlElementGetAttr(bundle_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(bundle_node_p, "xmlns"), "eu.siacs.conversations.axolotl");

mxml_node_t * signed_pk_node_p = mxmlGetFirstChild(bundle_node_p);
assert_ptr_not_equal(signed_pk_node_p, (void *) 0);
Expand Down Expand Up @@ -487,16 +487,16 @@ void test_bundle_get_pep_node_name(void ** state) {

char * node_name = (void *) 0;
assert_int_equal(omemo_bundle_get_pep_node_name(1337, &node_name), 0);
assert_string_equal(node_name, "urn:xmpp:omemo:0:bundles:1337");
assert_string_equal(node_name, "eu.siacs.conversations.axolotl.bundles:1337");

free(node_name);
}

void test_bundle_import_malformed(void ** state) {
(void) state;

char * bundle_malformed_1 = "<items node='urn:xmpp:omemo:0:bundles:31415'>"
"<bundle xmlns='urn:xmpp:omemo:0'>"
char * bundle_malformed_1 = "<items node='eu.siacs.conversations.axolotl.bundles:31415'>"
"<bundle xmlns='eu.siacs.conversations.axolotl'>"
"<signedPreKeyPublic signedPreKeyId='1'>sWsAtQ==</signedPreKeyPublic>"
"<signedPreKeySignature>sWsAtQ==</signedPreKeySignature>"
"<identityKey>sWsAtQ==</identityKey>"
Expand All @@ -510,9 +510,9 @@ void test_bundle_import_malformed(void ** state) {
"</item>"
"</items>";

char * bundle_malformed_2 = "<items node='urn:xmpp:omemo:0:bundles:31415'>"
char * bundle_malformed_2 = "<items node='eu.siacs.conversations.axolotl.bundles:31415'>"
"<item>"
"<bundle xmlns='urn:xmpp:omemo:0'>"
"<bundle xmlns='eu.siacs.conversations.axolotl'>"
"<signedPreKeySignature>sWsAtQ==</signedPreKeySignature>"
"<identityKey>sWsAtQ==</identityKey>"
"<prekeys>"
Expand All @@ -525,9 +525,9 @@ void test_bundle_import_malformed(void ** state) {
"</item>"
"</items>";

char * bundle_malformed_3 = "<items node='urn:xmpp:omemo:0:bundles:31415'>"
char * bundle_malformed_3 = "<items node='eu.siacs.conversations.axolotl.bundles:31415'>"
"<item>"
"<bundle xmlns='urn:xmpp:omemo:0'>"
"<bundle xmlns='eu.siacs.conversations.axolotl'>"
"<signedPreKeyPublic signedPreKeyId='1'>sWsAtQ==</signedPreKeyPublic>"
"<identityKey>sWsAtQ==</identityKey>"
"<prekeys>"
Expand All @@ -540,9 +540,9 @@ void test_bundle_import_malformed(void ** state) {
"</item>"
"</items>";

char * bundle_malformed_4 = "<items node='urn:xmpp:omemo:0:bundles:31415'>"
char * bundle_malformed_4 = "<items node='eu.siacs.conversations.axolotl.bundles:31415'>"
"<item>"
"<bundle xmlns='urn:xmpp:omemo:0'>"
"<bundle xmlns='eu.siacs.conversations.axolotl'>"
"<signedPreKeyPublic signedPreKeyId='1'>sWsAtQ==</signedPreKeyPublic>"
"<signedPreKeySignature>sWsAtQ==</signedPreKeySignature>"
"<prekeys>"
Expand All @@ -555,9 +555,9 @@ void test_bundle_import_malformed(void ** state) {
"</item>"
"</items>";

char * bundle_malformed_5 = "<items node='urn:xmpp:omemo:0:bundles:31415'>"
char * bundle_malformed_5 = "<items node='eu.siacs.conversations.axolotl.bundles:31415'>"
"<item>"
"<bundle xmlns='urn:xmpp:omemo:0'>"
"<bundle xmlns='eu.siacs.conversations.axolotl'>"
"<signedPreKeyPublic signedPreKeyId='1'>sWsAtQ==</signedPreKeyPublic>"
"<signedPreKeySignature>sWsAtQ==</signedPreKeySignature>"
"<identityKey>sWsAtQ==</identityKey>"
Expand Down Expand Up @@ -765,7 +765,7 @@ void test_message_get_encrypted_key(void ** state) {
(void) state;

char * msg = "<message to='bob@example.com' from='alice@example.com'>"
"<encrypted xmlns='urn:xmpp:omemo:0'>"
"<encrypted xmlns='eu.siacs.conversations.axolotl'>"
"<header sid='1111'>"
"<key rid='2222'>sWsAtQ==</key>"
"<iv>BASE64ENCODED</iv>"
Expand Down Expand Up @@ -795,7 +795,7 @@ void test_message_is_encrypted_key_prekey(void ** state) {
(void) state;

char * msg = "<message to='bob@example.com' from='alice@example.com'>"
"<encrypted xmlns='urn:xmpp:omemo:0'>"
"<encrypted xmlns='eu.siacs.conversations.axolotl'>"
"<header sid='1111'>"
"<key prekey='true' rid='2222'>sWsAtQ==</key>"
"<key rid='3333' prekey='true'>sWsAtQ==</key>"
Expand Down Expand Up @@ -846,7 +846,7 @@ void test_message_get_encrypted_key_after_iv(void ** state) {
(void) state;

char * msg = "<message to='bob@example.com' from='alice@example.com'>"
"<encrypted xmlns='urn:xmpp:omemo:0'>"
"<encrypted xmlns='eu.siacs.conversations.axolotl'>"
"<header sid='1111'>"
"<iv>BASE64ENCODED</iv>"
"<key rid='2222'>sWsAtQ==</key>"
Expand Down Expand Up @@ -875,7 +875,7 @@ void test_message_get_encrypted_key_no_keys(void ** state) {
(void) state;

char * msg = "<message to='bob@example.com' from='alice@example.com'>"
"<encrypted xmlns='urn:xmpp:omemo:0'>"
"<encrypted xmlns='eu.siacs.conversations.axolotl'>"
"<header sid='1111'>"
"<iv>BASE64ENCODED</iv>"
"</header>"
Expand Down Expand Up @@ -971,7 +971,7 @@ void test_message_export_encrypted(void ** state) {

mxml_node_t * encrypted_node_p;
assert_int_equal(expect_next_node(message_node_p, mxmlGetFirstChild, "encrypted", &encrypted_node_p), 0);
assert_string_equal(mxmlElementGetAttr(encrypted_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(encrypted_node_p, "xmlns"), "eu.siacs.conversations.axolotl");

mxml_node_t * header_node_p;
assert_int_equal(expect_next_node(encrypted_node_p, mxmlGetFirstChild, "header", &header_node_p), 0);
Expand Down Expand Up @@ -1014,7 +1014,7 @@ void test_message_export_encrypted_with_extra_tags_and_body(void ** state) {

mxml_node_t * encrypted_node_p;
assert_int_equal(expect_next_node(body_node_p, mxmlGetNextSibling, "encrypted", &encrypted_node_p), 0);
assert_string_equal(mxmlElementGetAttr(encrypted_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(encrypted_node_p, "xmlns"), "eu.siacs.conversations.axolotl");

mxml_node_t * header_node_p;
assert_int_equal(expect_next_node(encrypted_node_p, mxmlGetFirstChild, "header", &header_node_p), 0);
Expand Down Expand Up @@ -1164,7 +1164,7 @@ void test_message_export_encrypted_with_eme(void ** state) {

mxml_node_t * encrypted_node_p;
assert_int_equal(expect_next_node(message_node_p, mxmlGetFirstChild, "encrypted", &encrypted_node_p), 0);
assert_string_equal(mxmlElementGetAttr(encrypted_node_p, "xmlns"), "urn:xmpp:omemo:0");
assert_string_equal(mxmlElementGetAttr(encrypted_node_p, "xmlns"), "eu.siacs.conversations.axolotl");

mxml_node_t * header_node_p;
assert_int_equal(expect_next_node(encrypted_node_p, mxmlGetFirstChild, "header", &header_node_p), 0);
Expand Down

0 comments on commit 6f153c0

Please sign in to comment.