Skip to content

Commit 156db7d

Browse files
Merge pull request #9831 from julek-wolfssl/pytho-3.13.4
Fixes to run python with --enable-all
2 parents 0792c67 + 341024e commit 156db7d

12 files changed

Lines changed: 344 additions & 92 deletions

File tree

.github/workflows/python.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Python Tests
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'master', 'main', 'release/**' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
# END OF COMMON SECTION
14+
15+
jobs:
16+
build_wolfssl:
17+
name: Build wolfSSL
18+
if: github.repository_owner == 'wolfssl'
19+
runs-on: ubuntu-24.04
20+
timeout-minutes: 10
21+
steps:
22+
- name: Build wolfSSL
23+
uses: wolfSSL/actions-build-autotools-project@v1
24+
with:
25+
path: wolfssl
26+
configure: >-
27+
--enable-all --enable-tlsv10
28+
'CPPFLAGS=-DHAVE_SECRET_CALLBACK -DWOLFSSL_PYTHON'
29+
check: false
30+
install: true
31+
32+
- name: tar build-dir
33+
run: tar -zcf build-dir.tgz build-dir
34+
35+
- name: Upload built lib
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: wolf-install-python
39+
path: build-dir.tgz
40+
retention-days: 5
41+
42+
python_check:
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- python_ver: 3.12.11
48+
tests: >-
49+
test_ssl
50+
test.test_asyncio.test_ssl
51+
test.test_asyncio.test_sslproto
52+
test_hashlib
53+
test_hmac
54+
test_secrets
55+
test_ftplib
56+
test_imaplib
57+
test_poplib
58+
test_smtplib
59+
test_httplib
60+
test_urllib2_localnet
61+
test_xmlrpc
62+
test_docxmlrpc
63+
- python_ver: 3.13.4
64+
tests: >-
65+
test_ssl
66+
test.test_asyncio.test_ssl
67+
test.test_asyncio.test_sslproto
68+
test_hashlib
69+
test_hmac
70+
test_secrets
71+
test_ftplib
72+
test_imaplib
73+
test_poplib
74+
test_smtplib
75+
test_httplib
76+
test_urllib2_localnet
77+
test_xmlrpc
78+
test_docxmlrpc
79+
- python_ver: 3.13.7
80+
tests: >-
81+
test_ssl
82+
test.test_asyncio.test_ssl
83+
test.test_asyncio.test_sslproto
84+
test_hashlib
85+
test_hmac
86+
test_secrets
87+
test_ftplib
88+
test_imaplib
89+
test_poplib
90+
test_smtplib
91+
test_httplib
92+
test_urllib2_localnet
93+
test_xmlrpc
94+
test_docxmlrpc
95+
name: Python ${{ matrix.python_ver }}
96+
if: github.repository_owner == 'wolfssl'
97+
runs-on: ubuntu-24.04
98+
timeout-minutes: 60
99+
needs: build_wolfssl
100+
steps:
101+
- name: Install dependencies
102+
run: |
103+
sudo apt-get update
104+
sudo apt-get install -y \
105+
build-essential autoconf automake autoconf-archive pkgconf \
106+
libffi-dev libbz2-dev libreadline-dev libsqlite3-dev \
107+
zlib1g-dev libncursesw5-dev libgdbm-dev libnss3-dev \
108+
liblzma-dev uuid-dev pkg-config
109+
110+
- name: Download wolfSSL
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: wolf-install-python
114+
115+
- name: Untar wolfSSL build
116+
run: tar -xf build-dir.tgz
117+
118+
- name: Checkout OSP
119+
uses: actions/checkout@v4
120+
with:
121+
repository: wolfssl/osp
122+
path: osp
123+
124+
- name: Checkout CPython
125+
uses: actions/checkout@v4
126+
with:
127+
repository: python/cpython
128+
ref: v${{ matrix.python_ver }}
129+
path: cpython
130+
131+
- name: Apply wolfSSL patch
132+
working-directory: cpython
133+
run: patch -p1 < $GITHUB_WORKSPACE/osp/Python/wolfssl-python-${{ matrix.python_ver }}.patch
134+
135+
- name: Build CPython and run SSL and crypto tests
136+
working-directory: cpython
137+
run: |
138+
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build-dir/lib:$LD_LIBRARY_PATH
139+
rm -f aclocal.m4
140+
autoreconf -if
141+
./configure --with-wolfssl=$GITHUB_WORKSPACE/build-dir
142+
make -j test TESTOPTS="-v ${{ matrix.tests }}"

.github/workflows/softhsm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: wolfSSL/actions-build-autotools-project@v1
2626
with:
2727
path: wolfssl
28-
configure: --enable-all CFLAGS=-DRSA_MIN_SIZE=1024
28+
configure: --enable-all --disable-oldnames CFLAGS=-DRSA_MIN_SIZE=1024
2929
install: true
3030
check: false
3131

configure.ac

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,9 +1307,6 @@ then
13071307
test "$enable_openvpn" = "" && enable_openvpn=yes
13081308
test "$enable_asio" = "" && enable_asio=yes
13091309
test "$enable_libwebsockets" = "" && enable_libwebsockets=yes
1310-
if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -le 5; then
1311-
test "$enable_qt" = "" && enable_qt=yes
1312-
fi
13131310
fi
13141311
fi
13151312

src/internal.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26306,15 +26306,20 @@ int SendData(WOLFSSL* ssl, const void* data, size_t sz)
2630626306

2630726307
if (sent == (word32)sz) break;
2630826308

26309-
buffSz = (word32)sz - sent;
26310-
outputSz = wolfssl_local_GetRecordSize(ssl, (word32)buffSz, 1);
26309+
buffSz = (int)((word32)sz - sent);
26310+
if (buffSz <= 0) {
26311+
WOLFSSL_MSG("error: sent size exceeds input size");
26312+
ssl->error = BAD_FUNC_ARG;
26313+
return WOLFSSL_FATAL_ERROR;
26314+
}
2631126315
#if defined(WOLFSSL_DTLS)
2631226316
if (ssl->options.dtls) {
2631326317
#if defined(WOLFSSL_DTLS_MTU)
2631426318
int mtu = ssl->dtlsMtuSz;
2631526319
#else
2631626320
int mtu = MAX_MTU;
2631726321
#endif
26322+
outputSz = wolfssl_local_GetRecordSize(ssl, (word32)buffSz, 1);
2631826323
if (outputSz > mtu) {
2631926324
#if defined(WOLFSSL_NO_DTLS_SIZE_CHECK)
2632026325
/* split instead of error out */
@@ -26328,7 +26333,14 @@ int SendData(WOLFSSL* ssl, const void* data, size_t sz)
2632826333
#endif /* WOLFSSL_NO_DTLS_SIZE_CHECK */
2632926334
}
2633026335
}
26336+
else
2633126337
#endif /* WOLFSSL_DTLS */
26338+
{
26339+
int maxFrag = wolfSSL_GetMaxFragSize(ssl);
26340+
if (maxFrag > 0)
26341+
buffSz = min((word32)buffSz, (word32)maxFrag);
26342+
outputSz = wolfssl_local_GetRecordSize(ssl, (word32)buffSz, 1);
26343+
}
2633226344

2633326345
/* check for available size, it does also DTLS MTU checks */
2633426346
if ((ret = CheckAvailableSize(ssl, outputSz)) != 0)
@@ -34111,7 +34123,15 @@ int SendClientKeyExchange(WOLFSSL* ssl)
3411134123
#endif
3411234124

3411334125
if (IsEncryptionOn(ssl, 1)) {
34114-
args->sendSz += MAX_MSG_EXTRA;
34126+
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_DTLS_MTU)
34127+
/* Use exact cipher overhead for the MTU pre-flight check.
34128+
* MAX_MSG_EXTRA is an upper bound that can exceed a small MTU,
34129+
* while the actual message fits within it. */
34130+
if (ssl->options.dtls)
34131+
args->sendSz += cipherExtraData(ssl);
34132+
else
34133+
#endif
34134+
args->sendSz += MAX_MSG_EXTRA;
3411534135
}
3411634136

3411734137
/* check for available size */

src/ssl.c

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10470,8 +10470,7 @@ const char* wolfSSL_CIPHER_get_name(const WOLFSSL_CIPHER* cipher)
1047010470
return NULL;
1047110471
}
1047210472

10473-
#if !defined(WOLFSSL_CIPHER_INTERNALNAME) && !defined(NO_ERROR_STRINGS) && \
10474-
!defined(WOLFSSL_QT)
10473+
#if !defined(WOLFSSL_CIPHER_INTERNALNAME) && !defined(NO_ERROR_STRINGS)
1047510474
return GetCipherNameIana(cipher->cipherSuite0, cipher->cipherSuite);
1047610475
#else
1047710476
return wolfSSL_get_cipher_name_from_suite(cipher->cipherSuite0,
@@ -16035,9 +16034,8 @@ static WC_INLINE int sslCipherMinMaxCheck(const WOLFSSL *ssl, byte suite0,
1603516034
*/
1603616035
WOLF_STACK_OF(WOLFSSL_CIPHER) *wolfSSL_get_ciphers_compat(const WOLFSSL *ssl)
1603716036
{
16038-
WOLF_STACK_OF(WOLFSSL_CIPHER)* ret = NULL;
1603916037
const Suites* suites;
16040-
#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
16038+
#if defined(OPENSSL_ALL)
1604116039
const CipherSuiteInfo* cipher_names = GetCipherNames();
1604216040
int cipherSz = GetCipherNamesSize();
1604316041
#endif
@@ -16053,15 +16051,20 @@ WOLF_STACK_OF(WOLFSSL_CIPHER) *wolfSSL_get_ciphers_compat(const WOLFSSL *ssl)
1605316051
/* check if stack needs populated */
1605416052
if (ssl->suitesStack == NULL) {
1605516053
int i;
16056-
#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
16057-
int j;
16054+
16055+
((WOLFSSL*)ssl)->suitesStack =
16056+
wolfssl_sk_new_type_ex(STACK_TYPE_CIPHER, ssl->heap);
16057+
if (ssl->suitesStack == NULL)
16058+
return NULL;
1605816059

1605916060
/* higher priority of cipher suite will be on top of stack */
16060-
for (i = suites->suiteSz - 2; i >=0; i-=2) {
16061+
#if defined(OPENSSL_ALL)
16062+
for (i = suites->suiteSz - 2; i >=0; i-=2)
1606116063
#else
16062-
for (i = 0; i < suites->suiteSz; i+=2) {
16064+
for (i = 0; i < suites->suiteSz; i+=2)
1606316065
#endif
16064-
WOLFSSL_STACK* add;
16066+
{
16067+
struct WOLFSSL_CIPHER cipher;
1606516068

1606616069
/* A couple of suites are placeholders for special options,
1606716070
* skip those. */
@@ -16071,39 +16074,30 @@ WOLF_STACK_OF(WOLFSSL_CIPHER) *wolfSSL_get_ciphers_compat(const WOLFSSL *ssl)
1607116074
continue;
1607216075
}
1607316076

16074-
add = wolfSSL_sk_new_node(ssl->heap);
16075-
if (add != NULL) {
16076-
add->type = STACK_TYPE_CIPHER;
16077-
add->data.cipher.cipherSuite0 = suites->suites[i];
16078-
add->data.cipher.cipherSuite = suites->suites[i+1];
16079-
add->data.cipher.ssl = ssl;
16080-
#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
16077+
XMEMSET(&cipher, 0, sizeof(cipher));
16078+
cipher.cipherSuite0 = suites->suites[i];
16079+
cipher.cipherSuite = suites->suites[i+1];
16080+
cipher.ssl = ssl;
16081+
#if defined(OPENSSL_ALL)
16082+
cipher.in_stack = 1;
16083+
{
16084+
int j;
1608116085
for (j = 0; j < cipherSz; j++) {
16082-
if (cipher_names[j].cipherSuite0 ==
16083-
add->data.cipher.cipherSuite0 &&
16084-
cipher_names[j].cipherSuite ==
16085-
add->data.cipher.cipherSuite) {
16086-
add->data.cipher.offset = (unsigned long)j;
16086+
if (cipher_names[j].cipherSuite0 == cipher.cipherSuite0 &&
16087+
cipher_names[j].cipherSuite == cipher.cipherSuite) {
16088+
cipher.offset = (unsigned long)j;
1608716089
break;
1608816090
}
1608916091
}
16092+
}
1609016093
#endif
16091-
#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL)
16092-
/* in_stack is checked in wolfSSL_CIPHER_description */
16093-
add->data.cipher.in_stack = 1;
16094-
#endif
16095-
16096-
add->next = ret;
16097-
if (ret != NULL) {
16098-
add->num = ret->num + 1;
16099-
}
16100-
else {
16101-
add->num = 1;
16102-
}
16103-
ret = add;
16094+
if (wolfSSL_sk_insert(ssl->suitesStack, &cipher, 0) <= 0) {
16095+
WOLFSSL_MSG("Error inserting cipher onto stack");
16096+
wolfSSL_sk_CIPHER_free(ssl->suitesStack);
16097+
((WOLFSSL*)ssl)->suitesStack = NULL;
16098+
break;
1610416099
}
1610516100
}
16106-
((WOLFSSL*)ssl)->suitesStack = ret;
1610716101
}
1610816102
return ssl->suitesStack;
1610916103
}

0 commit comments

Comments
 (0)