Update tutorial-tcp-psk.md
parent
b41a6b4dfc
commit
491cf2e26c
|
@ -258,7 +258,7 @@ Session resumption allows a client/server pair to re-use previously generated cr
|
|||
|
||||
2. Change all calls from read() or recv() to CyaSSL_read(), in the simple server
|
||||
``read(sockfd, recvline, MAXLINE)``
|
||||
becomes
|
||||
>becomes
|
||||
``CyaSSL_read(ssl, recvline, MAXLINE)``
|
||||
|
||||
>(CyaSSL_read on first use also calls CyaSSL_accept if not explicitly called earlier in code.)
|
||||
|
@ -280,7 +280,8 @@ becomes
|
|||
```
|
||||
|
||||
6. In the servers main loop for accepting clients create a CYASSL pointer. Once a new client is accepted create a CyaSSL object and associate that object with the socket that the client is on. After using the CyaSSL object it should be freed and also before closing the program the ctx pointer should be freed and a CyaSSL cleanup method called.
|
||||
```
|
||||
|
||||
```
|
||||
CYASSL* ssl;
|
||||
|
||||
CyaSSL_set_fd(ssl, “integer returned from accept”);
|
||||
|
@ -314,7 +315,7 @@ The following steps are on how to use PSK in a CyaSSL server
|
|||
|
||||
3. Add the my_psk_server_cb function as follows. This is a function needed that is passed in as an argument to the CyaSSL callback.
|
||||
|
||||
```
|
||||
```
|
||||
static inline unsigned int my_psk_client_cb(CYASSL* ssl, char* identity, unsigned
|
||||
char* key, unsigned int key_max_len) {
|
||||
(void)ssl;
|
||||
|
@ -332,37 +333,39 @@ The following steps are on how to use PSK in a CyaSSL server
|
|||
|
||||
return 4;
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
Example Makefile for Simple Cyass PSK Client:
|
||||
```
|
||||
CC=gcc
|
||||
OBJ = client-psk.o
|
||||
CFLAG=-Wall
|
||||
|
||||
```
|
||||
CC=gcc
|
||||
OBJ = client-psk.o
|
||||
CFLAG=-Wall
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
client-psk: client-psk.c
|
||||
client-psk: client-psk.c
|
||||
$(CC) -Wall -o client-psk client-psk.c -lcyassl
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f *.o client-psk
|
||||
```
|
||||
clean:
|
||||
rm -f *.o client-psk
|
||||
```
|
||||
|
||||
The -lcyassl will link the Cyassl Libraries to your program
|
||||
|
||||
|
||||
The makefile for the server is going to be similar to that of the client. If the user wants separate makefiles just make a use the same set up of the client makefile and replace every instance of client-psk with server-psk. To combine make files just add a server-psk with similar ending to each time client-psk is referenced and change the target. There will also need to be a target for when compiling all targets.
|
||||
```
|
||||
all: server-psk client-psk
|
||||
|
||||
```
|
||||
all: server-psk client-psk
|
||||
|
||||
server-psk: server-psk.c
|
||||
$(CC) -Wall -o server-psk server-psk.c -lcyassl
|
||||
```
|
||||
```
|
||||
|
||||
## Nonblocking psk
|
||||
###### What is nonblocking?
|
||||
|
|
Loading…
Reference in New Issue