Skip to content

Commit 93dc29a

Browse files
authored
Merge pull request #623 from libtom/update-ci
Update base OS version of CI
2 parents fae62af + 9035949 commit 93dc29a

File tree

13 files changed

+54
-40
lines changed

13 files changed

+54
-40
lines changed

.ci/valgrind.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ make clean &>/dev/null
2121

2222
echo "Build for valgrind..."
2323

24-
make -j$MAKE_JOBS CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" test LTC_DEBUG=1 1>gcc_1.txt 2>gcc_2.txt
24+
# set DWARFv4 as debug format for clang, since it creates DWARFv5 as default which isn't support in old valgrind
25+
[ -z "$(echo $CC | grep "clang")" ] || GFLAG="-gdwarf-4"
26+
27+
make -j$MAKE_JOBS CFLAGS="$2 $CFLAGS $4 $GFLAG" EXTRALIBS="$5" test LTC_DEBUG=1 1>gcc_1.txt 2>gcc_2.txt
2528

2629
echo "Run tests with valgrind..."
2730

.github/workflows/main.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
matrix:
3434
cc: [ gcc, clang ]
35-
os: [ ubuntu-18.04 ]
35+
os: [ ubuntu-20.04, ubuntu-22.04 ]
3636
config:
3737
- { BUILDNAME: 'META_BUILDS', BUILDOPTIONS: '-DGMP_DESC', BUILDSCRIPT: '.ci/meta_builds.sh' }
3838
- { BUILDNAME: 'VALGRIND', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/valgrind.sh' }
@@ -56,10 +56,11 @@ jobs:
5656
- name: install dependencies
5757
run: |
5858
sudo apt-get update -qq
59-
sudo apt-get install -y libtommath-dev libgmp-dev libtfm-dev valgrind libtool-bin clang-tools lcov
59+
sudo apt-get install -y libgmp-dev valgrind libtool-bin clang-tools lcov ruby clang
60+
sudo apt-get remove -y libtommath1
6061
sudo gem install coveralls-lcov
6162
curl -s https://packagecloud.io/install/repositories/libtom/packages/script.deb.sh | sudo bash
62-
sudo apt-get install libtfm1=0.13-5ubuntu1
63+
sudo apt-get install libtfm-git-dev libtommath-git-dev
6364
- name: run tests
6465
env:
6566
CC: "${{ matrix.cc }}"
@@ -71,14 +72,16 @@ jobs:
7172
- name: regular logs
7273
if: ${{ !failure() }}
7374
run: |
74-
cat gcc_1.txt
75-
cat gcc_2.txt
75+
cat gcc_1.txt || true
76+
cat gcc_2.txt || true
7677
- name: error logs
7778
if: ${{ failure() }}
7879
run: |
79-
cat test_std.txt
80-
cat test_err.txt
81-
cat tv.txt
80+
cat gcc_1.txt || true
81+
cat gcc_2.txt || true
82+
cat test_std.txt || true
83+
cat test_err.txt || true
84+
cat tv.txt || true
8285
- name: pack build directory
8386
if: ${{ failure() }}
8487
run: |

makefile_include.mk

+8-2
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ endif
5555

5656
ifndef EXTRALIBS
5757
ifneq ($(shell echo $(CFLAGS) | grep USE_LTM),)
58-
EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs)
58+
EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs libtommath)
5959
else
6060
ifneq ($(shell echo $(CFLAGS) | grep USE_TFM),)
61-
EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config tomsfastmath --libs)
61+
EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs tomsfastmath)
6262
endif
6363
endif
6464
endif
@@ -76,6 +76,12 @@ endef
7676
# by giving them as a parameter to make:
7777
# make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
7878
#
79+
ifneq ($(shell echo $(CFLAGS) | grep LTM_DESC),)
80+
LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I libtommath)
81+
endif
82+
ifneq ($(shell echo $(CFLAGS) | grep TFM_DESC),)
83+
LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I tomsfastmath)
84+
endif
7985
LTC_CFLAGS += -I./src/headers/ -DLTC_SOURCE -Wall -Wsign-compare -Wshadow
8086

8187
ifdef OLD_GCC

src/encauth/ccm/ccm_test.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ int ccm_test(void)
215215
XMEMCPY(tag3, tests[x].tag, tests[x].taglen);
216216
tag3[0] ^= 0xff; /* set the tag to the wrong value */
217217
taglen = tests[x].taglen;
218-
if ((err = ccm_memory(idx,
219-
tests[x].key, 16,
220-
NULL,
221-
tests[x].nonce, tests[x].noncelen,
222-
tests[x].header, tests[x].headerlen,
223-
buf2, tests[x].ptlen,
224-
buf,
225-
tag3, &taglen, 1 )) != CRYPT_ERROR) {
218+
if (ccm_memory(idx,
219+
tests[x].key, 16,
220+
NULL,
221+
tests[x].nonce, tests[x].noncelen,
222+
tests[x].header, tests[x].headerlen,
223+
buf2, tests[x].ptlen,
224+
buf,
225+
tag3, &taglen, 1 ) != CRYPT_ERROR) {
226226
return CRYPT_FAIL_TESTVECTOR;
227227
}
228228
if (compare_testvector(buf2, tests[x].ptlen, zero, tests[x].ptlen, "CCM decrypt wrong tag", x)) {

src/misc/pkcs5/pkcs_5_test.c

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ int pkcs_5_test (void)
169169
(unsigned char*)cases_5_2[i].S, cases_5_2[i].S_len,
170170
cases_5_2[i].c, hash,
171171
DK, &dkLen)) != CRYPT_OK) {
172+
LTC_UNUSED_PARAM(err);
172173
#ifdef LTC_TEST_DBG
173174
printf("\npkcs_5_alg2() #%d: Failed/1 (%s)\n", i, error_to_string(err));
174175
#endif
@@ -186,6 +187,7 @@ int pkcs_5_test (void)
186187
(unsigned char*)cases_5_1[i].S,
187188
cases_5_1[i].c, hash,
188189
DK, &dkLen)) != CRYPT_OK) {
190+
LTC_UNUSED_PARAM(err);
189191
#ifdef LTC_TEST_DBG
190192
printf("\npkcs_5_alg1() #%d: Failed/1 (%s)\n", i, error_to_string(err));
191193
#endif
@@ -203,6 +205,7 @@ int pkcs_5_test (void)
203205
(unsigned char*)cases_5_1o[i].S,
204206
cases_5_1o[i].c, hash,
205207
DK, &dkLen)) != CRYPT_OK) {
208+
LTC_UNUSED_PARAM(err);
206209
#ifdef LTC_TEST_DBG
207210
printf("\npkcs_5_alg1_openssl() #%d: Failed/1 (%s)\n", i, error_to_string(err));
208211
#endif

src/misc/ssh/ssh_encode_sequence_multi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
134134
STORE32H(size, out);
135135
out += 4;
136136
}
137-
if ((err = mp_to_unsigned_bin(vdata, out)) != CRYPT_OK) {
137+
if (mp_to_unsigned_bin(vdata, out) != CRYPT_OK) {
138138
err = CRYPT_ERROR;
139139
goto error;
140140
}

src/pk/asn1/der/custom_type/der_encode_custom_type.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int der_encode_custom_type(const ltc_asn1_list *root,
3636

3737
/* get size of output that will be required */
3838
y = 0; z = 0;
39-
if ((err = der_length_custom_type(root, &y, &z)) != CRYPT_OK) return CRYPT_INVALID_ARG;
39+
if (der_length_custom_type(root, &y, &z) != CRYPT_OK) return CRYPT_INVALID_ARG;
4040

4141
/* too big ? */
4242
if (*outlen < y) {
@@ -46,7 +46,7 @@ int der_encode_custom_type(const ltc_asn1_list *root,
4646
}
4747

4848
/* get length of the identifier, so we know the offset where to start writing */
49-
if ((err = der_length_asn1_identifier(root, &id_len)) != CRYPT_OK) return CRYPT_INVALID_ARG;
49+
if (der_length_asn1_identifier(root, &id_len) != CRYPT_OK) return CRYPT_INVALID_ARG;
5050
x = id_len;
5151

5252

src/pk/asn1/der/sequence/der_encode_sequence_ex.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int der_encode_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,
3333

3434
/* get size of output that will be required */
3535
y = 0; z = 0;
36-
if ((err = der_length_sequence_ex(list, inlen, &y, &z)) != CRYPT_OK) return CRYPT_INVALID_ARG;
36+
if (der_length_sequence_ex(list, inlen, &y, &z) != CRYPT_OK) return CRYPT_INVALID_ARG;
3737

3838
/* too big ? */
3939
if (*outlen < y) {

src/pk/dsa/dsa_import.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
7272
}
7373
}
7474
/* get key type */
75-
if ((err = der_decode_sequence_multi(in, inlen,
76-
LTC_ASN1_SHORT_INTEGER, 1UL, &zero,
77-
LTC_ASN1_INTEGER, 1UL, key->p,
78-
LTC_ASN1_INTEGER, 1UL, key->q,
79-
LTC_ASN1_INTEGER, 1UL, key->g,
80-
LTC_ASN1_INTEGER, 1UL, key->y,
81-
LTC_ASN1_INTEGER, 1UL, key->x,
82-
LTC_ASN1_EOL, 0UL, NULL)) == CRYPT_OK) {
75+
if (der_decode_sequence_multi(in, inlen,
76+
LTC_ASN1_SHORT_INTEGER, 1UL, &zero,
77+
LTC_ASN1_INTEGER, 1UL, key->p,
78+
LTC_ASN1_INTEGER, 1UL, key->q,
79+
LTC_ASN1_INTEGER, 1UL, key->g,
80+
LTC_ASN1_INTEGER, 1UL, key->y,
81+
LTC_ASN1_INTEGER, 1UL, key->x,
82+
LTC_ASN1_EOL, 0UL, NULL) == CRYPT_OK) {
8383

8484
key->type = PK_PRIVATE;
8585
} else { /* public */

src/pk/ecc/ecc_import_pkcs8.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int ecc_import_pkcs8(const unsigned char *in, unsigned long inlen,
6464
if (err != CRYPT_OK) return err;
6565

6666

67-
if ((err = pkcs8_decode_flexi(in, inlen, pwd, pwdlen, &l)) == CRYPT_OK) {
67+
if (pkcs8_decode_flexi(in, inlen, pwd, pwdlen, &l) == CRYPT_OK) {
6868

6969
/* Setup for basic structure */
7070
n=0;
@@ -73,7 +73,7 @@ int ecc_import_pkcs8(const unsigned char *in, unsigned long inlen,
7373
LTC_SET_DER_FLEXI_CHECK(flexi_should, n++, LTC_ASN1_OCTET_STRING, &priv_key);
7474
LTC_SET_DER_FLEXI_CHECK(flexi_should, n, LTC_ASN1_EOL, NULL);
7575

76-
if (((err = s_der_flexi_sequence_cmp(l, flexi_should)) == CRYPT_OK) &&
76+
if ((s_der_flexi_sequence_cmp(l, flexi_should) == CRYPT_OK) &&
7777
(pk_oid_cmp_with_asn1(pka_ec_oid, seq->child) == CRYPT_OK)) {
7878
ltc_asn1_list *version, *field, *point, *point_g, *order, *p_cofactor;
7979

@@ -154,7 +154,7 @@ int ecc_import_pkcs8(const unsigned char *in, unsigned long inlen,
154154

155155
/* load private key value 'k' */
156156
len = priv_key->size;
157-
if ((err = der_decode_sequence_flexi(priv_key->data, &len, &p)) == CRYPT_OK) {
157+
if (der_decode_sequence_flexi(priv_key->data, &len, &p) == CRYPT_OK) {
158158
if (p->type == LTC_ASN1_SEQUENCE &&
159159
LTC_ASN1_IS_TYPE(p->child, LTC_ASN1_INTEGER) &&
160160
LTC_ASN1_IS_TYPE(p->child->next, LTC_ASN1_OCTET_STRING)) {

src/pk/rsa/rsa_verify_hash.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long sigle
136136
LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2);
137137
LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, tmpbuf, siglen);
138138

139-
if ((err = der_decode_sequence_strict(out, outlen, siginfo, 2)) != CRYPT_OK) {
139+
if (der_decode_sequence_strict(out, outlen, siginfo, 2) != CRYPT_OK) {
140140
/* fallback to Legacy:missing NULL */
141141
LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 1);
142142
if ((err = der_decode_sequence_strict(out, outlen, siginfo, 2)) != CRYPT_OK) {

tests/der_test.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1272,19 +1272,18 @@ static void der_Xcode_run(const der_Xcode_t* x)
12721272
{
12731273
unsigned long l1, l2, sz;
12741274
void *d1, *d2;
1275-
int err;
12761275

12771276
l1 = 1;
12781277
d1 = XMALLOC(l1 * x->type_sz);
12791278
sz = (x->in_sz * x->factor)/x->type_sz;
12801279

1281-
if ((err = x->encode(x->in, sz, d1, &l1)) == CRYPT_BUFFER_OVERFLOW) {
1280+
if (x->encode(x->in, sz, d1, &l1) == CRYPT_BUFFER_OVERFLOW) {
12821281
d1 = XREALLOC(d1, l1 * x->type_sz);
12831282
}
12841283
DO(x->encode(x->in, sz, d1, &l1));
12851284
l2 = 1;
12861285
d2 = XMALLOC(l2 * x->type_sz);
1287-
while ((err = x->decode(d1, l1, d2, &l2)) == CRYPT_BUFFER_OVERFLOW) {
1286+
while (x->decode(d1, l1, d2, &l2) == CRYPT_BUFFER_OVERFLOW) {
12881287
d2 = XREALLOC(d2, l2 * x->type_sz);
12891288
}
12901289
DO(x->decode(d1, l1, d2, &l2));

tests/pkcs_1_test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int pkcs_1_test(void)
1414
{
1515
unsigned char buf[3][128];
1616
int res1, res2, res3, prng_idx, hash_idx;
17-
unsigned long x, y, l1, l2, l3, i1, i2, lparamlen, saltlen, modlen;
17+
unsigned long x, y, l1, l2, l3, i1, lparamlen, saltlen, modlen;
1818
static const unsigned char lparam[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
1919

2020
/* get hash/prng */
@@ -75,7 +75,7 @@ int pkcs_1_test(void)
7575
DO(pkcs_1_pss_decode(buf[0], l3, buf[1], l1, saltlen, hash_idx, modlen, &res2));
7676

7777
buf[0][i1] ^= 1;
78-
buf[1][i2 = abs(rand()) % (l1 - 1)] ^= 1;
78+
buf[1][abs(rand()) % (l1 - 1)] ^= 1;
7979
pkcs_1_pss_decode(buf[0], l3, buf[1], l1, saltlen, hash_idx, modlen, &res3);
8080
if (!(res1 == 1 && res2 == 0 && res3 == 0)) {
8181
fprintf(stderr, "PSS failed: %d, %d, %d, %lu, %lu\n", res1, res2, res3, l3, saltlen);

0 commit comments

Comments
 (0)