net: websocket: Use system provided base64 function
Instead of using mbedtls_base64, use system provided base64 encoding function. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
a5a29e4efc
commit
6170ae5e2e
|
@ -39,10 +39,9 @@ CONFIG_HTTP_SERVER=y
|
||||||
# How many URLs we are serving
|
# How many URLs we are serving
|
||||||
CONFIG_HTTP_SERVER_NUM_URLS=5
|
CONFIG_HTTP_SERVER_NUM_URLS=5
|
||||||
|
|
||||||
# base64 support needed by websocket
|
# sha1 support needed by websocket
|
||||||
CONFIG_MBEDTLS=y
|
CONFIG_MBEDTLS=y
|
||||||
CONFIG_MBEDTLS_BUILTIN=y
|
CONFIG_MBEDTLS_BUILTIN=y
|
||||||
CONFIG_MBEDTLS_CFG_FILE="config-mini-tls1_2.h"
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
CONFIG_NET_LOG=y
|
CONFIG_NET_LOG=y
|
||||||
|
|
|
@ -3,5 +3,5 @@ sample:
|
||||||
tests:
|
tests:
|
||||||
test:
|
test:
|
||||||
build_only: true
|
build_only: true
|
||||||
platform_whitelist: qemu_x86
|
platform_whitelist: qemu_x86 native_posix
|
||||||
tags: net websocket
|
tags: net websocket
|
||||||
|
|
|
@ -38,10 +38,9 @@ CONFIG_HTTP_SERVER=y
|
||||||
# How many URLs we are serving
|
# How many URLs we are serving
|
||||||
CONFIG_HTTP_SERVER_NUM_URLS=5
|
CONFIG_HTTP_SERVER_NUM_URLS=5
|
||||||
|
|
||||||
# base64 support needed by websocket
|
# sha1 support needed by websocket
|
||||||
CONFIG_MBEDTLS=y
|
CONFIG_MBEDTLS=y
|
||||||
CONFIG_MBEDTLS_BUILTIN=y
|
CONFIG_MBEDTLS_BUILTIN=y
|
||||||
CONFIG_MBEDTLS_CFG_FILE="config-mini-tls1_2.h"
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
CONFIG_NET_LOG=y
|
CONFIG_NET_LOG=y
|
||||||
|
|
|
@ -3,5 +3,5 @@ sample:
|
||||||
tests:
|
tests:
|
||||||
test:
|
test:
|
||||||
build_only: true
|
build_only: true
|
||||||
platform_whitelist: qemu_x86 qemu_cortex_m3
|
platform_whitelist: qemu_x86 qemu_cortex_m3 native_posix
|
||||||
tags: net websocket
|
tags: net websocket
|
||||||
|
|
|
@ -8,6 +8,7 @@ menuconfig WEBSOCKET
|
||||||
default n
|
default n
|
||||||
depends on HTTP
|
depends on HTTP
|
||||||
select NET_TCP
|
select NET_TCP
|
||||||
|
select BASE64
|
||||||
help
|
help
|
||||||
This option enables the websocket library.
|
This option enables the websocket library.
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <net/net_ip.h>
|
#include <net/net_ip.h>
|
||||||
#include <net/websocket.h>
|
#include <net/websocket.h>
|
||||||
|
|
||||||
#include <mbedtls/base64.h>
|
#include <base64.h>
|
||||||
#include <mbedtls/sha1.h>
|
#include <mbedtls/sha1.h>
|
||||||
|
|
||||||
#define BUF_ALLOC_TIMEOUT 100
|
#define BUF_ALLOC_TIMEOUT 100
|
||||||
|
@ -395,12 +395,12 @@ static struct net_pkt *prepare_reply(struct http_ctx *ctx,
|
||||||
|
|
||||||
snprintk(tmp, sizeof(tmp), "Sec-WebSocket-Accept: ");
|
snprintk(tmp, sizeof(tmp), "Sec-WebSocket-Accept: ");
|
||||||
|
|
||||||
ret = mbedtls_base64_encode(tmp + sizeof("Sec-WebSocket-Accept: ") - 1,
|
ret = base64_encode(tmp + sizeof("Sec-WebSocket-Accept: ") - 1,
|
||||||
sizeof(tmp) -
|
sizeof(tmp) -
|
||||||
(sizeof("Sec-WebSocket-Accept: ") - 1),
|
(sizeof("Sec-WebSocket-Accept: ") - 1),
|
||||||
&olen, accept, sizeof(accept));
|
&olen, accept, sizeof(accept));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) {
|
if (ret == -ENOMEM) {
|
||||||
NET_DBG("[%p] Too short buffer olen %zd", ctx, olen);
|
NET_DBG("[%p] Too short buffer olen %zd", ctx, olen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,9 @@ CONFIG_HTTP_SERVER=y
|
||||||
# How many URLs we are serving
|
# How many URLs we are serving
|
||||||
CONFIG_HTTP_SERVER_NUM_URLS=5
|
CONFIG_HTTP_SERVER_NUM_URLS=5
|
||||||
|
|
||||||
# base64 support needed by websocket
|
# sha1 support needed by websocket
|
||||||
CONFIG_MBEDTLS=y
|
CONFIG_MBEDTLS=y
|
||||||
CONFIG_MBEDTLS_BUILTIN=y
|
CONFIG_MBEDTLS_BUILTIN=y
|
||||||
CONFIG_MBEDTLS_CFG_FILE="config-mini-tls1_2.h"
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
CONFIG_NET_LOG=y
|
CONFIG_NET_LOG=y
|
||||||
|
|
Loading…
Reference in a new issue