Skip to content

BlazeWasHere/cCHello

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cCHello

A minimal TLS client hello parser.

Features

  • compatible with C99
  • no dependencies
  • ~100 LOC
  • simple API
  • extensive overflow checks

API

client_hello_t *cchello_client_hello_init(void);
int cchello_parse(client_hello_t *ch, uint8_t *data, size_t data_len);
void cchello_client_hello_free(client_hello_t *ch);

Usage

#include "cCHello.h"
...
client_hello_t *ch == cchello_client_hello_init();
if (ch == NULL)
    // handle alloc failure.

int ret = cchello_parse(ch, data, data_len);
if (ret < 0)
    // handle cchello error.
else
    // you may want to check if cchello read all of the data
    assert(data_len == ret);

// remember to free!
cchello_client_hello_free(ch);

Example

After running the example binary, visit the URL https://localhost:1337 in your browser.

$ make example
cc -O2 -Wall -Wextra -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wmissing-declarations -Wredundant-decls -Wshadow  -o test tests.c cCHello.c
$ ./example
[...]

Tests

$ make test
cc -O2 -Wall -Wextra -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wmissing-declarations -Wredundant-decls -Wshadow  -o test tests.c cCHello.c
$ ./test
[...]
ALL TESTS PASSED.

Thanks

Michael Driscoll for the illustrated TLS connection

License

BSL-1.0 License

Releases

No releases published

Packages

No packages published