Skip to content

Commit 48434f7

Browse files
Merge pull request #6653 from julek-wolfssl/kerberos-update
Updates for Kerberos 5 1.21.1
2 parents d87bb14 + 4a175ba commit 48434f7

12 files changed

Lines changed: 392 additions & 27 deletions

File tree

.github/workflows/curl.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: curl Test
22

33
on:
4-
push:
54
workflow_call:
65

76
jobs:

.github/workflows/krb5.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Kerberos 5 Tests
2+
3+
on:
4+
workflow_call:
5+
# TODO remove push when opening the PR
6+
push:
7+
8+
jobs:
9+
build_wolfssl:
10+
name: Build wolfSSL
11+
# Just to keep it the same as the testing target
12+
runs-on: ubuntu-latest
13+
# This should be a safe limit for the tests to run.
14+
timeout-minutes: 5
15+
steps:
16+
- name: Build wolfSSL
17+
uses: wolfSSL/actions-build-autotools-project@v1
18+
with:
19+
path: wolfssl
20+
configure: --enable-krb CFLAGS='-fsanitize=address'
21+
install: true
22+
23+
- name: Upload built lib
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: wolf-install-krb5
27+
path: build-dir
28+
retention-days: 1
29+
30+
krb5_check:
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
# List of releases to test
35+
ref: [ 1.21.1 ]
36+
name: ${{ matrix.ref }}
37+
runs-on: ubuntu-latest
38+
# This should be a safe limit for the tests to run.
39+
timeout-minutes: 8
40+
needs: build_wolfssl
41+
steps:
42+
- name: Download lib
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: wolf-install-krb5
46+
path: build-dir
47+
48+
- name: Checkout OSP
49+
uses: actions/checkout@v3
50+
with:
51+
# TODO revert repo to wolfssl on merge
52+
repository: julek-wolfssl/osp
53+
# TODO remove ref on merge
54+
ref: krb5-1.21.1
55+
path: osp
56+
57+
- name: Checkout krb5
58+
uses: actions/checkout@v3
59+
with:
60+
repository: krb5/krb5
61+
ref: krb5-${{ matrix.ref }}-final
62+
path: krb5
63+
64+
- name: Apply patch
65+
working-directory: ./krb5
66+
run: |
67+
patch -p1 < $GITHUB_WORKSPACE/osp/krb5/Patch-for-Kerberos-5-${{ matrix.ref }}.patch
68+
69+
- name: Build krb5
70+
working-directory: ./krb5/src
71+
run: |
72+
autoreconf -ivf
73+
# Using rpath because LD_LIBRARY_PATH is overwritten during testing
74+
export WOLFSSL_CFLAGS="-I$GITHUB_WORKSPACE/build-dir/include -I$GITHUB_WORKSPACE/build-dir/include/wolfssl -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib"
75+
export WOLFSSL_LIBS="-lwolfssl -L$GITHUB_WORKSPACE/build-dir/lib -Wl,-rpath=$GITHUB_WORKSPACE/build-dir/lib"
76+
./configure --with-crypto-impl=wolfssl --with-tls-impl=wolfssl --disable-pkinit \
77+
CFLAGS='-fsanitize=address' LDFLAGS='-fsanitize=address'
78+
CFLAGS='-fsanitize=address' LDFLAGS='-fsanitize=address' make -j
79+
80+
- name: Run tests
81+
working-directory: ./krb5/src
82+
run: |
83+
CFLAGS='-fsanitize=address' LDFLAGS='-fsanitize=address' make -j check
84+

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
uses: ./.github/workflows/hitch.yml
3535
curl:
3636
uses: ./.github/workflows/curl.yml
37+
krb5:
38+
uses: ./.github/workflows/krb5.yml
3739
# TODO: Currently this test fails. Enable it once it becomes passing.
3840
# haproxy:
3941
# uses: ./.github/workflows/haproxy.yml

.github/workflows/nginx.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: nginx Tests
22

33
on:
4-
push:
54
workflow_call:
65

76
jobs:

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ AC_ARG_ENABLE([compkey],
35263526
[ ENABLED_COMPKEY=no ]
35273527
)
35283528

3529-
if test "$ENABLED_WPAS" = "yes"
3529+
if test "$ENABLED_WPAS" = "yes" || test "$ENABLED_OPENSSLALL" = "yes"
35303530
then
35313531
ENABLED_COMPKEY=yes
35323532
fi

src/pk.c

Lines changed: 128 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9711,27 +9711,27 @@ void wolfSSL_EC_POINT_dump(const char *msg, const WOLFSSL_EC_POINT *point)
97119711

97129712
WOLFSSL_ENTER("wolfSSL_EC_POINT_dump");
97139713

9714-
/* Only print when debugging on and logging callback set. */
9715-
if (WOLFSSL_IS_DEBUG_ON() && (wolfSSL_GetLoggingCb() == NULL)) {
9714+
/* Only print when debugging on. */
9715+
if (WOLFSSL_IS_DEBUG_ON()) {
97169716
if (point == NULL) {
97179717
/* No point passed in so just put out "NULL". */
9718-
XFPRINTF(stderr, "%s = NULL\n", msg);
9718+
WOLFSSL_MSG_EX("%s = NULL\n", msg);
97199719
}
97209720
else {
97219721
/* Put out message and status of internal/external data set. */
9722-
XFPRINTF(stderr, "%s:\n\tinSet=%d, exSet=%d\n", msg, point->inSet,
9722+
WOLFSSL_MSG_EX("%s:\n\tinSet=%d, exSet=%d\n", msg, point->inSet,
97239723
point->exSet);
97249724
/* Get x-ordinate as a hex string and print. */
97259725
num = wolfSSL_BN_bn2hex(point->X);
9726-
XFPRINTF(stderr, "\tX = %s\n", num);
9726+
WOLFSSL_MSG_EX("\tX = %s\n", num);
97279727
XFREE(num, NULL, DYNAMIC_TYPE_OPENSSL);
97289728
/* Get x-ordinate as a hex string and print. */
97299729
num = wolfSSL_BN_bn2hex(point->Y);
9730-
XFPRINTF(stderr, "\tY = %s\n", num);
9730+
WOLFSSL_MSG_EX("\tY = %s\n", num);
97319731
XFREE(num, NULL, DYNAMIC_TYPE_OPENSSL);
97329732
/* Get z-ordinate as a hex string and print. */
97339733
num = wolfSSL_BN_bn2hex(point->Z);
9734-
XFPRINTF(stderr, "\tZ = %s\n", num);
9734+
WOLFSSL_MSG_EX("\tZ = %s\n", num);
97359735
XFREE(num, NULL, DYNAMIC_TYPE_OPENSSL);
97369736
}
97379737
}
@@ -9922,6 +9922,8 @@ int wolfSSL_ECPoint_d2i(const unsigned char *in, unsigned int len,
99229922
const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *point)
99239923
{
99249924
int ret = 1;
9925+
WOLFSSL_BIGNUM* x = NULL;
9926+
WOLFSSL_BIGNUM* y = NULL;
99259927

99269928
WOLFSSL_ENTER("wolfSSL_ECPoint_d2i");
99279929

@@ -9958,17 +9960,49 @@ int wolfSSL_ECPoint_d2i(const unsigned char *in, unsigned int len,
99589960
#endif
99599961
}
99609962

9963+
if (ret == 1)
9964+
point->inSet = 1;
9965+
99619966
/* Set new external point. */
9962-
if ((ret == 1) && (ec_point_external_set(point) != 1)) {
9967+
if (ret == 1 && ec_point_external_set(point) != 1) {
99639968
WOLFSSL_MSG("ec_point_external_set failed");
99649969
ret = 0;
99659970
}
99669971

9972+
if (ret == 1 && !wolfSSL_BN_is_one(point->Z)) {
9973+
#if !defined(WOLFSSL_SP_MATH) && !defined(WOLF_CRYPTO_CB_ONLY_ECC)
9974+
x = wolfSSL_BN_new();
9975+
y = wolfSSL_BN_new();
9976+
if (x == NULL || y == NULL)
9977+
ret = 0;
9978+
9979+
if (ret == 1 && wolfSSL_EC_POINT_get_affine_coordinates_GFp(group,
9980+
point, x, y, NULL) != 1) {
9981+
WOLFSSL_MSG("wolfSSL_EC_POINT_get_affine_coordinates_GFp failed");
9982+
ret = 0;
9983+
}
9984+
9985+
/* wolfSSL_EC_POINT_set_affine_coordinates_GFp check that the point is
9986+
* on the curve. */
9987+
if (ret == 1 && wolfSSL_EC_POINT_set_affine_coordinates_GFp(group,
9988+
point, x, y, NULL) != 1) {
9989+
WOLFSSL_MSG("wolfSSL_EC_POINT_set_affine_coordinates_GFp failed");
9990+
ret = 0;
9991+
}
9992+
#else
9993+
WOLFSSL_MSG("Importing non-affine point. This may cause issues in math "
9994+
"operations later on.");
9995+
#endif
9996+
}
9997+
99679998
if (ret == 1) {
99689999
/* Dump new point. */
996910000
wolfSSL_EC_POINT_dump("d2i p", point);
997010001
}
997110002

10003+
wolfSSL_BN_free(x);
10004+
wolfSSL_BN_free(y);
10005+
997210006
return ret;
997310007
}
997410008

@@ -10060,6 +10094,14 @@ size_t wolfSSL_EC_POINT_point2oct(const WOLFSSL_EC_GROUP *group,
1006010094
}
1006110095
}
1006210096

10097+
#if defined(DEBUG_WOLFSSL)
10098+
if (!err) {
10099+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_point2oct point", point);
10100+
WOLFSSL_MSG("\twolfSSL_EC_POINT_point2oct output:");
10101+
WOLFSSL_BUFFER(buf, enc_len);
10102+
}
10103+
#endif
10104+
1006310105
/* On error, return encoding length of 0. */
1006410106
if (err) {
1006510107
enc_len = 0;
@@ -10209,7 +10251,7 @@ int wolfSSL_EC_POINT_is_on_curve(const WOLFSSL_EC_GROUP *group,
1020910251
* @return 1 on success.
1021010252
* @return 0 on error.
1021110253
*/
10212-
static int ec_point_convert_to_affine(const WOLFSSL_EC_GROUP *group,
10254+
int ec_point_convert_to_affine(const WOLFSSL_EC_GROUP *group,
1021310255
WOLFSSL_EC_POINT *point)
1021410256
{
1021510257
int err = 0;
@@ -10606,6 +10648,20 @@ int wolfSSL_EC_POINT_add(const WOLFSSL_EC_GROUP* group, WOLFSSL_EC_POINT* r,
1060610648
ret = 0;
1060710649
}
1060810650

10651+
#ifdef DEBUG_WOLFSSL
10652+
if (ret == 1) {
10653+
int nid = wolfSSL_EC_GROUP_get_curve_name(group);
10654+
const char* curve = wolfSSL_OBJ_nid2ln(nid);
10655+
const char* nistName = wolfSSL_EC_curve_nid2nist(nid);
10656+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_add p1", p1);
10657+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_add p2", p2);
10658+
if (curve != NULL)
10659+
WOLFSSL_MSG_EX("curve name: %s", curve);
10660+
if (nistName != NULL)
10661+
WOLFSSL_MSG_EX("nist curve name: %s", nistName);
10662+
}
10663+
#endif
10664+
1060910665
if (ret == 1) {
1061010666
/* Add points using wolfCrypt objects. */
1061110667
ret = wolfssl_ec_point_add(group->curve_idx, (ecc_point*)r->internal,
@@ -10618,6 +10674,12 @@ int wolfSSL_EC_POINT_add(const WOLFSSL_EC_GROUP* group, WOLFSSL_EC_POINT* r,
1061810674
ret = 0;
1061910675
}
1062010676

10677+
#ifdef DEBUG_WOLFSSL
10678+
if (ret == 1) {
10679+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_add result", r);
10680+
}
10681+
#endif
10682+
1062110683
return ret;
1062210684
}
1062310685

@@ -10779,7 +10841,7 @@ static int wolfssl_ec_point_mul(int curveIdx, ecc_point* r, mp_int* n,
1077910841

1078010842
if ((ret == 1) && (n != NULL) && (q != NULL) && (m != NULL)) {
1078110843
/* r = base point * n + q * m */
10782-
ec_mul2add(r, r, m, q, n, a, prime);
10844+
ret = ec_mul2add(r, r, n, q, m, a, prime);
1078310845
}
1078410846
/* Not all values present, see if we are only doing base point * n. */
1078510847
else if ((ret == 1) && (n != NULL)) {
@@ -10852,6 +10914,26 @@ int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r,
1085210914
ret = 0;
1085310915
}
1085410916

10917+
#ifdef DEBUG_WOLFSSL
10918+
if (ret == 1) {
10919+
int nid = wolfSSL_EC_GROUP_get_curve_name(group);
10920+
const char* curve = wolfSSL_OBJ_nid2ln(nid);
10921+
const char* nistName = wolfSSL_EC_curve_nid2nist(nid);
10922+
char* num;
10923+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_mul input q", q);
10924+
num = wolfSSL_BN_bn2hex(n);
10925+
WOLFSSL_MSG_EX("\tn = %s", num);
10926+
XFREE(num, NULL, DYNAMIC_TYPE_OPENSSL);
10927+
num = wolfSSL_BN_bn2hex(m);
10928+
WOLFSSL_MSG_EX("\tm = %s", num);
10929+
XFREE(num, NULL, DYNAMIC_TYPE_OPENSSL);
10930+
if (curve != NULL)
10931+
WOLFSSL_MSG_EX("curve name: %s", curve);
10932+
if (nistName != NULL)
10933+
WOLFSSL_MSG_EX("nist curve name: %s", nistName);
10934+
}
10935+
#endif
10936+
1085510937
if (ret == 1) {
1085610938
mp_int* ni = (n != NULL) ? (mp_int*)n->internal : NULL;
1085710939
ecc_point* qi = (q != NULL) ? (ecc_point*)q->internal : NULL;
@@ -10872,6 +10954,12 @@ int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r,
1087210954
ret = 0;
1087310955
}
1087410956

10957+
#ifdef DEBUG_WOLFSSL
10958+
if (ret == 1) {
10959+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_mul result", r);
10960+
}
10961+
#endif
10962+
1087510963
return ret;
1087610964
}
1087710965
#endif /* !WOLFSSL_ATECC508A && !WOLFSSL_ATECC608A && !HAVE_SELFTEST &&
@@ -10960,6 +11048,30 @@ int wolfSSL_EC_POINT_invert(const WOLFSSL_EC_GROUP *group,
1096011048
ret = 0;
1096111049
}
1096211050

11051+
#ifdef DEBUG_WOLFSSL
11052+
if (ret == 1) {
11053+
int nid = wolfSSL_EC_GROUP_get_curve_name(group);
11054+
const char* curve = wolfSSL_OBJ_nid2ln(nid);
11055+
const char* nistName = wolfSSL_EC_curve_nid2nist(nid);
11056+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_invert input", point);
11057+
if (curve != NULL)
11058+
WOLFSSL_MSG_EX("curve name: %s", curve);
11059+
if (nistName != NULL)
11060+
WOLFSSL_MSG_EX("nist curve name: %s", nistName);
11061+
11062+
}
11063+
#endif
11064+
11065+
if (ret == 1 && !wolfSSL_BN_is_one(point->Z)) {
11066+
#if !defined(WOLFSSL_SP_MATH) && !defined(WOLF_CRYPTO_CB_ONLY_ECC)
11067+
if (ec_point_convert_to_affine(group, point) != 0)
11068+
ret = 0;
11069+
#else
11070+
WOLFSSL_MSG("wolfSSL_EC_POINT_invert called on non-affine point");
11071+
ret = 0;
11072+
#endif
11073+
}
11074+
1096311075
if (ret == 1) {
1096411076
/* Perform inversion using wolfCrypt objects. */
1096511077
ret = wolfssl_ec_point_invert(group->curve_idx,
@@ -10972,6 +11084,12 @@ int wolfSSL_EC_POINT_invert(const WOLFSSL_EC_GROUP *group,
1097211084
ret = 0;
1097311085
}
1097411086

11087+
#ifdef DEBUG_WOLFSSL
11088+
if (ret == 1) {
11089+
wolfSSL_EC_POINT_dump("wolfSSL_EC_POINT_invert result", point);
11090+
}
11091+
#endif
11092+
1097511093
return ret;
1097611094
}
1097711095

0 commit comments

Comments
 (0)