web_socket_auth.c File Reference

HTTP authentication for WebSockets. More...

#include <stdlib.h>
#include "core/net.h"
#include "web_socket/web_socket.h"
#include "web_socket/web_socket_auth.h"
#include "encoding/base64.h"
#include "hash/md5.h"
#include "str.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   WEB_SOCKET_TRACE_LEVEL
 

Functions

error_t webSocketParseAuthenticateField (WebSocket *webSocket, char_t *value)
 Parse WWW-Authenticate header field. More...
 
size_t webSocketAddAuthorizationField (WebSocket *webSocket, char_t *output)
 Format Authorization header field. More...
 
void webSocketConvertArrayToHexString (const uint8_t *input, size_t inputLen, char_t *output)
 Convert byte array to hex string. More...
 

Detailed Description

HTTP authentication for WebSockets.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file web_socket_auth.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   WEB_SOCKET_TRACE_LEVEL

Definition at line 32 of file web_socket_auth.c.

Function Documentation

◆ webSocketAddAuthorizationField()

size_t webSocketAddAuthorizationField ( WebSocket webSocket,
char_t output 
)

Format Authorization header field.

Parameters
[in]webSocketHandle to a WebSocket
[out]outputBuffer where to format the header field
Returns
Total length of the header field

Definition at line 171 of file web_socket_auth.c.

◆ webSocketConvertArrayToHexString()

void webSocketConvertArrayToHexString ( const uint8_t *  input,
size_t  inputLen,
char_t output 
)

Convert byte array to hex string.

Parameters
[in]inputPoint to the byte array
[in]inputLenLength of the byte array
[out]outputNULL-terminated string resulting from the conversion

Definition at line 314 of file web_socket_auth.c.

◆ webSocketParseAuthenticateField()

error_t webSocketParseAuthenticateField ( WebSocket webSocket,
char_t value 
)

Parse WWW-Authenticate header field.

Parameters
[in]webSocketHandle to a WebSocket
[in]valueNULL-terminated string that contains the value of header field
Returns
Error code

Definition at line 55 of file web_socket_auth.c.