Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SSE-IoT-Encryption
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Fuhrmann
SSE-IoT-Encryption
Commits
1426639b
Commit
1426639b
authored
6 months ago
by
Dominik Fuhrmann
Browse files
Options
Downloads
Patches
Plain Diff
added old server.c
parent
9f032323
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scripts/client.c
+10
-10
10 additions, 10 deletions
scripts/client.c
scripts/server.c
+147
-547
147 additions, 547 deletions
scripts/server.c
scripts/test.py
+0
-36
0 additions, 36 deletions
scripts/test.py
setup/python_configuration.sh
+0
-2
0 additions, 2 deletions
setup/python_configuration.sh
with
157 additions
and
595 deletions
scripts/client.c
+
10
−
10
View file @
1426639b
...
@@ -17,8 +17,8 @@ void err_sys(const char* msg) {
...
@@ -17,8 +17,8 @@ void err_sys(const char* msg) {
int
main
()
{
int
main
()
{
int
sockfd
;
int
sockfd
;
struct
sockaddr_in
server_addr
;
struct
sockaddr_in
server_addr
;
SSL_CTX
*
ctx
;
wolf
SSL_CTX
*
ctx
;
SSL
*
ssl
;
wolf
SSL
*
ssl
;
int
ret
;
int
ret
;
char
msg
[]
=
"Hello, secure server!"
;
char
msg
[]
=
"Hello, secure server!"
;
char
reply
[
1024
];
char
reply
[
1024
];
...
@@ -27,7 +27,7 @@ int main() {
...
@@ -27,7 +27,7 @@ int main() {
wolfSSL_Init
();
wolfSSL_Init
();
// SSL-Kontext erstellen
// SSL-Kontext erstellen
ctx
=
SSL_CTX_new
(
wolfSSLv23_client_method
());
ctx
=
wolf
SSL_CTX_new
(
wolfSSLv23_client_method
());
if
(
ctx
==
NULL
)
{
if
(
ctx
==
NULL
)
{
err_sys
(
"SSL_CTX_new failed"
);
err_sys
(
"SSL_CTX_new failed"
);
}
}
...
@@ -48,11 +48,11 @@ int main() {
...
@@ -48,11 +48,11 @@ int main() {
}
}
// SSL-Objekt erstellen
// SSL-Objekt erstellen
ssl
=
SSL_new
(
ctx
);
ssl
=
wolf
SSL_new
(
ctx
);
SSL_set_fd
(
ssl
,
sockfd
);
wolf
SSL_set_fd
(
ssl
,
sockfd
);
// TLS-Verbindung herstellen
// TLS-Verbindung herstellen
ret
=
SSL_connect
(
ssl
);
ret
=
wolf
SSL_connect
(
ssl
);
if
(
ret
!=
1
)
{
if
(
ret
!=
1
)
{
err_sys
(
"SSL_connect failed"
);
err_sys
(
"SSL_connect failed"
);
}
}
...
@@ -60,13 +60,13 @@ int main() {
...
@@ -60,13 +60,13 @@ int main() {
printf
(
"TLS connection established.
\n
"
);
printf
(
"TLS connection established.
\n
"
);
// Nachricht an den Server senden
// Nachricht an den Server senden
ret
=
SSL_write
(
ssl
,
msg
,
strlen
(
msg
));
ret
=
wolf
SSL_write
(
ssl
,
msg
,
strlen
(
msg
));
if
(
ret
<=
0
)
{
if
(
ret
<=
0
)
{
err_sys
(
"SSL_write failed"
);
err_sys
(
"SSL_write failed"
);
}
}
// Antwort vom Server empfangen
// Antwort vom Server empfangen
ret
=
SSL_read
(
ssl
,
reply
,
sizeof
(
reply
)
-
1
);
ret
=
wolf
SSL_read
(
ssl
,
reply
,
sizeof
(
reply
)
-
1
);
if
(
ret
<=
0
)
{
if
(
ret
<=
0
)
{
err_sys
(
"SSL_read failed"
);
err_sys
(
"SSL_read failed"
);
}
}
...
@@ -75,12 +75,12 @@ int main() {
...
@@ -75,12 +75,12 @@ int main() {
printf
(
"Server reply: %s
\n
"
,
reply
);
printf
(
"Server reply: %s
\n
"
,
reply
);
// SSL-Verbindung beenden
// SSL-Verbindung beenden
SSL_shutdown
(
ssl
);
wolf
SSL_shutdown
(
ssl
);
SSL_free
(
ssl
);
SSL_free
(
ssl
);
close
(
sockfd
);
close
(
sockfd
);
// SSL-Kontext freigeben
// SSL-Kontext freigeben
SSL_CTX_free
(
ctx
);
wolf
SSL_CTX_free
(
ctx
);
// WolfSSL bereinigen
// WolfSSL bereinigen
wolfSSL_Cleanup
();
wolfSSL_Cleanup
();
...
...
This diff is collapsed.
Click to expand it.
scripts/server.c
+
147
−
547
View file @
1426639b
This diff is collapsed.
Click to expand it.
scripts/test.py
deleted
100644 → 0
+
0
−
36
View file @
9f032323
import
sys
try
:
from
wolfssl
import
WolfSSLContext
,
SSL_METHOD_TLSv1_2
# Nur diese Imports!
print
(
"
wolfssl erfolgreich importiert!
"
)
print
(
f
"
Python Version:
{
sys
.
version
}
"
)
print
(
f
"
wolfssl Version:
{
wolfssl
.
__version__
if
hasattr
(
wolfssl
,
'
__version__
'
)
else
'
Version unbekannt
'
}
"
)
#Versuche die Version auszugeben
context
=
WolfSSLContext
(
SSL_METHOD_TLSv1_2
)
#Test ob die Initialisierung funktioniert
print
(
"
Context erfolgreich erstellt
"
)
except
ImportError
as
e
:
print
(
f
"
ImportError:
{
e
}
"
)
print
(
f
"
Python Version:
{
sys
.
version
}
"
)
import
pkg_resources
installed_packages
=
pkg_resources
.
working_set
installed_packages_list
=
sorted
([
"
%s==%s
"
%
(
i
.
key
,
i
.
version
)
for
i
in
installed_packages
])
print
(
"
Installierte Pakete:
"
)
for
package
in
installed_packages_list
:
print
(
package
)
except
AttributeError
as
e
:
print
(
f
"
AttributeError:
{
e
}
"
)
print
(
f
"
Python Version:
{
sys
.
version
}
"
)
import
pkg_resources
installed_packages
=
pkg_resources
.
working_set
installed_packages_list
=
sorted
([
"
%s==%s
"
%
(
i
.
key
,
i
.
version
)
for
i
in
installed_packages
])
print
(
"
Installierte Pakete:
"
)
for
package
in
installed_packages_list
:
print
(
package
)
except
Exception
as
e
:
#Fange alle anderen Exceptions
print
(
f
"
Sonstiger Fehler:
{
e
}
"
)
print
(
f
"
Python Version:
{
sys
.
version
}
"
)
import
pkg_resources
installed_packages
=
pkg_resources
.
working_set
installed_packages_list
=
sorted
([
"
%s==%s
"
%
(
i
.
key
,
i
.
version
)
for
i
in
installed_packages
])
print
(
"
Installierte Pakete:
"
)
for
package
in
installed_packages_list
:
print
(
package
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup/python_configuration.sh
deleted
100644 → 0
+
0
−
2
View file @
9f032323
# Install pip if neccessary
sudo
apt
install
python3-pip
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment