diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56b84f3d..0d7dcda5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,10 +22,10 @@ jobs: stable:: [true] include: - compiler: gcc - os: fedora:rawhide + os: quay.io/fedora/fedora:rawhide stable: false - compiler: clang - os: fedora:rawhide + os: quay.io/fedora/fedora:rawhide stable: false - compiler: gcc os: ubuntu:devel @@ -34,7 +34,7 @@ jobs: os: ubuntu:devel stable: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Show OS information run: | @@ -81,7 +81,7 @@ jobs: - gcc - clang steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Show OS information run: | diff --git a/.github/workflows/install-dependencies b/.github/workflows/install-dependencies index ee978acf..26b5b955 100755 --- a/.github/workflows/install-dependencies +++ b/.github/workflows/install-dependencies @@ -23,7 +23,7 @@ debian:*|ubuntu:*) done ;; -fedora:*) +*fedora:*) echo 'max_parallel_downloads=10' >> /etc/dnf/dnf.conf dnf -y clean all dnf -y --setopt=deltarpm=0 update diff --git a/lib/meson.build b/lib/meson.build index 3d2b9f08..e836e885 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -6,7 +6,7 @@ if not cc.links(code, args: flags, name: '-Wl,--version-script=...') flags = [ '-export-symbols-regex=^jose_.*' ] endif -libjose_lib = library('jose', +libjose_lib = shared_library('jose', 'misc.c', 'misc.h', 'cfg.c', 'io.c', diff --git a/lib/openssl/hmac.c b/lib/openssl/hmac.c index c5213656..376fea12 100644 --- a/lib/openssl/hmac.c +++ b/lib/openssl/hmac.c @@ -95,7 +95,7 @@ ver_done(jose_io_t *io) } static HMAC_CTX * -hmac(const jose_hook_alg_t *alg, jose_cfg_t *cfg, +jhmac(const jose_hook_alg_t *alg, jose_cfg_t *cfg, const json_t *sig, const json_t *jwk) { uint8_t key[KEYMAX] = {}; @@ -251,7 +251,7 @@ alg_sign_sig(const jose_hook_alg_t *alg, jose_cfg_t *cfg, json_t *jws, i->obj = json_incref(jws); i->sig = json_incref(sig); - i->hctx = hmac(alg, cfg, sig, jwk); + i->hctx = jhmac(alg, cfg, sig, jwk); if (!i->obj || !i->sig || !i->hctx) return NULL; @@ -275,7 +275,7 @@ alg_sign_ver(const jose_hook_alg_t *alg, jose_cfg_t *cfg, const json_t *jws, io->free = io_free; i->sig = json_incref((json_t *) sig); - i->hctx = hmac(alg, cfg, sig, jwk); + i->hctx = jhmac(alg, cfg, sig, jwk); if (!i->sig || !i->hctx) return NULL; diff --git a/tests/alg_comp.c b/tests/alg_comp.c index c9bef752..fcd305c1 100644 --- a/tests/alg_comp.c +++ b/tests/alg_comp.c @@ -41,22 +41,23 @@ const struct { {} }; -typedef typeof(((jose_hook_alg_t *) NULL)->comp.inf) comp_func_t; - static void -test(const jose_hook_alg_t *a, comp_func_t func, bool iter, - const uint8_t *i, size_t il, - const uint8_t *o, size_t ol) +test(const jose_hook_alg_t *a, bool iter, + const uint8_t *i, size_t il) { jose_io_auto_t *b = NULL; + jose_io_auto_t *c = NULL; jose_io_auto_t *z = NULL; - void *buf = NULL; - size_t len = 0; + void *buf1 = NULL; + void *buf2 = NULL; + size_t blen = 0; + size_t clen = 0; - b = jose_io_malloc(NULL, &buf, &len); + /* Test compression first. */ + b = jose_io_malloc(NULL, &buf1, &blen); assert(b); - z = func(a, NULL, b); + z = a->comp.def(a, NULL, b); assert(z); if (iter) { @@ -68,8 +69,26 @@ test(const jose_hook_alg_t *a, comp_func_t func, bool iter, assert(z->done(z)); - assert(len == ol); - assert(memcmp(buf, o, ol) == 0); + /* Test decompression now. */ + c = jose_io_malloc(NULL, &buf2, &clen); + assert(b); + + z = a->comp.inf(a, NULL, c); + assert(z); + + if (iter) { + uint8_t *m = buf1; + for (size_t j = 0; j < blen; j++) + assert(z->feed(z, &m[j], 1)); + } else { + assert(z->feed(z, buf1, blen)); + } + + assert(z->done(z)); + + /* Compare the final output with the original input. */ + assert(clen == il); + assert(memcmp(buf2, i, il) == 0); } int @@ -93,20 +112,10 @@ main(int argc, char *argv[]) assert(jose_b64_dec_buf(tests[i].def, strlen(tests[i].def), tst_def, sizeof(tst_def)) == sizeof(tst_def)); - test(a, a->comp.def, false, - tst_inf, sizeof(tst_inf), - tst_def, sizeof(tst_def)); - - test(a, a->comp.inf, false, - tst_def, sizeof(tst_def), + test(a, false, tst_inf, sizeof(tst_inf)); - test(a, a->comp.def, true, - tst_inf, sizeof(tst_inf), - tst_def, sizeof(tst_def)); - - test(a, a->comp.inf, true, - tst_def, sizeof(tst_def), + test(a, true, tst_inf, sizeof(tst_inf)); }