Copy disabled (too large)
Download .txt
Showing preview only (12,492K chars total). Download the full file to get everything.
Repository: Mixiaoxiao/Arduino-HomeKit-ESP32
Branch: master
Commit: 21d48d1e8e12
Files: 184
Total size: 11.9 MB
Directory structure:
gitextract_em4h46tl/
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── examples/
│ └── ESP32_homekit_wolfssl_4_3_0/
│ ├── ESP32_homekit.ino
│ ├── ESPButton.h
│ └── builtin_led_accessory.c
├── library.json
├── library.properties
└── src/
├── accessories.c
├── arduino_homekit_server.h
├── arduino_homekit_server_esp32.cpp
├── arduino_homekit_server_esp8266.cpp
├── base64.c
├── base64.h
├── cJSON.c
├── cJSON.h
├── cQueue.c
├── cQueue.h
├── constants.h
├── crypto.c
├── crypto.h
├── esp_xpgm.h
├── homekit/
│ ├── characteristics.h
│ ├── homekit.h
│ ├── tlv.h
│ └── types.h
├── homekit_debug.c
├── homekit_debug.h
├── http_parser.c
├── http_parser.h
├── json.c
├── json.h
├── pairing.h
├── port.c
├── port.h
├── query_params.c
├── query_params.h
├── storage.c
├── storage.h
├── tlv.c
├── types.c
├── user_settings.h
├── watchdog.c
├── watchdog.h
├── wolfcrypt/
│ └── src/
│ ├── aes.c
│ ├── arc4.c
│ ├── asm.c
│ ├── asn.c
│ ├── blake2b.c
│ ├── blake2s.c
│ ├── camellia.c
│ ├── chacha.c
│ ├── chacha20_poly1305.c
│ ├── cmac.c
│ ├── coding.c
│ ├── compress.c
│ ├── cpuid.c
│ ├── cryptocb.c
│ ├── curve25519.c
│ ├── des3.c
│ ├── dh.c
│ ├── dsa.c
│ ├── ecc.c
│ ├── ecc_fp.c
│ ├── ed25519.c
│ ├── error.c
│ ├── evp.c
│ ├── fe_low_mem.c
│ ├── fe_operations.c
│ ├── ge_low_mem.c
│ ├── ge_operations.c
│ ├── hash.c
│ ├── hc128.c
│ ├── hmac.c
│ ├── idea.c
│ ├── integer.c
│ ├── logging.c
│ ├── md2.c
│ ├── md4.c
│ ├── md5.c
│ ├── memory.c
│ ├── misc.c
│ ├── pkcs12.c
│ ├── pkcs7.c
│ ├── poly1305.c
│ ├── port/
│ │ └── Espressif/
│ │ ├── README.md
│ │ ├── esp32_aes.c
│ │ ├── esp32_mp.c
│ │ ├── esp32_sha.c
│ │ └── esp32_util.c
│ ├── pwdbased.c.unused
│ ├── rabbit.c
│ ├── random.c
│ ├── ripemd.c
│ ├── rsa.c
│ ├── sha.c
│ ├── sha256.c
│ ├── sha3.c
│ ├── sha512.c
│ ├── signature.c
│ ├── sp_arm32.c
│ ├── sp_arm64.c
│ ├── sp_armthumb.c
│ ├── sp_c32.c
│ ├── sp_c64.c
│ ├── sp_cortexm.c
│ ├── sp_int.c
│ ├── sp_x86_64.c
│ ├── srp.c
│ ├── tfm.c
│ ├── wc_encrypt.c
│ ├── wc_pkcs11.c
│ ├── wc_port.c
│ ├── wolfevent.c
│ └── wolfmath.c
└── wolfssl/
├── version.h
└── wolfcrypt/
├── aes.h
├── arc4.h
├── asn.h
├── asn_public.h
├── blake2-impl.h
├── blake2-int.h
├── blake2.h
├── camellia.h
├── chacha.h
├── chacha20_poly1305.h
├── cmac.h
├── coding.h
├── compress.h
├── cpuid.h
├── cryptocb.h
├── curve25519.h
├── des3.h
├── dh.h
├── dsa.h
├── ecc.h
├── ed25519.h
├── error-crypt.h
├── fe_operations.h
├── fips_test.h
├── ge_operations.h
├── hash.h
├── hc128.h
├── hmac.h
├── idea.h
├── integer.h
├── logging.h
├── md2.h
├── md4.h
├── md5.h
├── mem_track.h
├── memory.h
├── misc.h
├── mpi_class.h
├── mpi_superclass.h
├── pkcs11.h
├── pkcs12.h
├── pkcs7.h
├── poly1305.h
├── port/
│ └── Espressif/
│ └── esp32-crypt.h
├── pwdbased.h
├── rabbit.h
├── random.h
├── ripemd.h
├── rsa.h
├── selftest.h
├── settings.h
├── sha.h
├── sha256.h
├── sha3.h
├── sha512.h
├── signature.h
├── sp.h
├── sp_int.h
├── srp.h
├── tfm.h
├── types.h
├── visibility.h
├── wc_encrypt.h
├── wc_pkcs11.h
├── wc_port.h
├── wolfevent.h
└── wolfmath.h
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
================================================
FILE: .gitignore
================================================
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Others
.DS_STORE
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2020 Mixiaoxiao(谜小小)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Arduino-HomeKit-ESP32
**[Deprecated]** Native Apple HomeKit accessory implementation for the ESP32 Arduino core.
This Arduino library is a native Apple HomeKit accessory implementation for the [ESP32 Arduino core](https://github.com/espressif/arduino-esp32), and works without any additional bridges.
This library is the ESP32 version of [Arduino-HomeKit-ESP8266](https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP8266), and **will no longer be maintained**, since Espressif has published the official HomeKit library for ESP32, available on Espressif's GitHub repository [esp-apple-homekit-adk](https://github.com/espressif/esp-apple-homekit-adk).
## Notes
* This is a "only-can-work" version for ESP32, remains something to be optimized.
* The `WolfSSL` used for ESP32 is based on `4.3.0-stable` version with **Hardware Acceleration Support** (enabled by default).
* The HomeKit running on ESP32 has a **GREAT PERFORMANCE** which Pair-Setup can be done in ~1.2s and Pair-Verify in < 0.1s (10x faster than ESP8266).
* The HomeKit storage on ESP32 is based on `nvs`.
## Performance WITH Hardware Acceleration on ESP32
* Preinit: ~0.53s
* Pair Setup Step 1/3: ~0s (The heavy crypto computation is done in Preinit)
* Pair Setup Step 2/3: ~0.53s
* Pair Setup Step 3/3: ~0.20s
* Pair Verify Step 1/2: ~0.05s
* Pair Verify Step 2/2: ~0.02s
## Performance WITHOUT Hardware Acceleration on ESP32
* Preinit: ~2.2s
* Pair Setup Step 1/3: ~0s (The heavy crypto computation is done in Preinit)
* Pair Setup Step 2/3: ~2.5s
* Pair Setup Step 3/3: ~0.1s
* Pair Verify Step 1/2: ~0.06s
* Pair Verify Step 2/2: ~0.03s
## Setup code of the example sketch
``111-11-111``
## Manual Installation
Refer to the official guide: [Manual installation](https://www.arduino.cc/en/guide/libraries#toc5)
Note: this library will not publish the release version for Arduino IDE.
#### Manual Installation for Windows
1. Click on _"Clone or Download"_ button, then click _"[Download ZIP](https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP32/archive/master.zip)"_ on the page.
1. Extract the contents of the downloaded zip file.
1. Rename the extracted folder to _"Arduino-HomeKit-ESP32"_.
1. Move this folder to your libraries directory. (under windows: `C:\Users\<USERNAME>\Documents\Arduino\libraries\`)
1. Restart your Arduino IDE.
1. Check out the examples.
================================================
FILE: examples/ESP32_homekit_wolfssl_4_3_0/ESP32_homekit.ino
================================================
#include "Arduino.h"
#include "WiFi.h"
#include "arduino_homekit_server.h"
#include "ESPButton.h"
extern "C" homekit_server_config_t config;
extern "C" homekit_characteristic_t name;
extern "C" char ACCESSORY_NAME[32];
extern "C" void led_toggle();
extern "C" void accessory_init();
#define PIN_BTN 0
const char *ssid = "your-ssid";
const char *password = "your-password";
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.persistent(false);
WiFi.disconnect(false);
WiFi.setAutoReconnect(true);
WiFi.begin(ssid, password);
printf("\n");
printf("SketchSize: %d B\n", ESP.getSketchSize());
printf("FreeSketchSpace: %d B\n", ESP.getFreeSketchSpace());
printf("FlashChipSize: %d B\n", ESP.getFlashChipSize());
//printf("FlashChipRealSize: %d B\n", ESP.getFlashChipRealSize());
printf("FlashChipSpeed: %d\n", ESP.getFlashChipSpeed());
printf("SdkVersion: %s\n", ESP.getSdkVersion());
//printf("FullVersion: %s\n", ESP.getFullVersion().c_str());
//printf("CpuFreq: %dMHz\n", ESP.getCpuFreqMHz());
printf("FreeHeap: %d B\n", ESP.getFreeHeap());
//printf("ResetInfo: %s\n", ESP.getResetInfo().c_str());
//printf("ResetReason: %s\n", ESP.getResetReason().c_str());
DEBUG_HEAP();
//Init Button
pinMode(PIN_BTN, INPUT_PULLUP);
ESPButton.add(0, PIN_BTN, LOW, false, true);
ESPButton.setCallback([](uint8_t id, ESPButtonEvent event) {
printf("ButtonEvent: %s\n", ESPButton.getButtonEventDescription(event));
if (event == ESPBUTTONEVENT_SINGLECLICK) {
led_toggle();
} else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
} else if (event == ESPBUTTONEVENT_LONGCLICK) {
homekit_storage_reset();
esp_restart();
}
});
ESPButton.begin();
homekit_setup();
}
void loop() {
ESPButton.loop();
uint32_t time = millis();
static uint32_t next_heap_millis = 0;
if (time > next_heap_millis) {
INFO("heap: %u, sockets: %d", ESP.getFreeHeap(), arduino_homekit_connected_clients_count());
next_heap_millis = time + 5000;
}
delay(5);
}
void homekit_setup() {
accessory_init();
// We create one FreeRTOS-task for HomeKit
// No need to call arduino_homekit_loop
arduino_homekit_setup(&config);
}
================================================
FILE: examples/ESP32_homekit_wolfssl_4_3_0/ESPButton.h
================================================
/*
* ESPButton.h
* Ticker-scan based Button Handler with debounce.
* Default scan interval is 16ms (60FPS).
* All added Buttons are scanned by a global Ticker (by os timer).
* [!!!] All events are triggered in interrupt, so you can NOT use delay() in callback!
*
* Usage:
* in setup():
* pinMode(pin, INPUT_PULLUP / INPUT /... );
* ESPButton.add(id, pin, pin_down_digital);
* ESPButton.setCallback(...); // handle your ButtonEvent by id
* ESPButton.begin(); // call begin to start scan.
* in loop():
* ESPButton.loop(); // will notify the event in loop (not in interrupt timer)
*
* Created on: 2020-03-08
* Last update: 2020-04-14
* Author: Wang Bin
*/
#ifndef ESPBUTTON_H_
#define ESPBUTTON_H_
#include <Arduino.h>
#include <functional>
#include <Ticker.h>
#define ESPBUTTON_DEBUG(message, ...) //printf_P(PSTR("[%7d] ESPButton: " message "\n"), millis(), ##__VA_ARGS__)
typedef struct _ESPButtonEntry {
uint8_t id = -1;
uint8_t pin = -1;
uint8_t pin_down_digital = LOW; //按下状态时的digital值
bool stable_down = false; //稳定状态的下的按键状态 (true: down, false: up)
uint32_t stable_threshold = 40; //如果按键状态维持一段时间未变化就认为是stable
bool is_stable = false; //当前是否是稳定状态,只有稳定状态下才会进一步处理
bool raw_down = false; //未消抖的原始按键状态
uint32_t raw_changed_time = 0; //未消抖的原始按键状态的改变的时间
//void (*ext_digitalRead)(uint8_t pin);
//如果该pin不是ESP芯片的引脚,而是从其他的扩展芯片读取的,就需要传入ext_digitalRead
std::function<uint8_t(uint8_t pin)> ext_digitalRead = nullptr;
//======
bool longclicked = false; //用来保证一次按下只能触发一次长按
bool down_handled = false; //标志着是否已经处理了该次down按下事件(比如已经触发了长按)
//down->up,在规定时间内再次down就是双击,否则超时就是单击
bool wait_doubleclick = false; //标志着是否等待着双击事件
uint32_t down_time = 0; //ms
uint32_t up_time = 0;
uint32_t longclick_threshold = 5000;
uint32_t doubleclick_threshold = 150; //按下释放后在此时间间隔内又按下认为是双击
bool longclick_enable = true;
bool doubleclick_enable = true;
//======
struct _ESPButtonEntry *next;
} ESPButtonEntry;
enum ESPButtonEvent {
ESPBUTTONEVENT_NONE = 0,
ESPBUTTONEVENT_SINGLECLICK,
ESPBUTTONEVENT_DOUBLECLICK,
ESPBUTTONEVENT_LONGCLICK
};
class ESPButtonClass;
static void _esp32_ticker_cb(ESPButtonClass *esp_button);
class ESPButtonClass {
public:
typedef std::function<void(uint8_t id, ESPButtonEvent event)> espbutton_callback;
Ticker ticker;
ESPButtonEntry *entries = nullptr;
espbutton_callback callback;
ESPButtonEvent notify_event = ESPBUTTONEVENT_NONE;
uint8_t notify_id = 0;
ESPButtonClass() {
}
~ESPButtonClass() {
}
void begin() {
ticker.detach();
#if defined(ESP8266)
ticker.attach_ms(16, std::bind(&ESPButtonClass::tick, this));
#elif defined(ESP32)
ticker.attach_ms(16, _esp32_ticker_cb, this);
#endif
}
ESPButtonEntry* add(uint8_t _id, uint8_t _pin, uint8_t _pin_down_digital,
bool _doubleclick_enable = false, bool _longclick_enable = true) {
ESPButtonEntry *entry = new ESPButtonEntry();
entry->id = _id;
entry->pin = _pin;
entry->pin_down_digital = _pin_down_digital;
entry->doubleclick_enable = _doubleclick_enable;
entry->longclick_enable = _longclick_enable;
//初始化entry的状态??暂时不需要,我们就是认为按键默认就是未按下的
//entry->laststate_is_down = digitalReadEntryIsDown(entry);
//加入链表
entry->next = entries;
entries = entry;
return entry;
}
void setCallback(espbutton_callback _callback) {
callback = _callback;
}
PGM_P getButtonEventDescription(ESPButtonEvent e) {
switch (e) {
case ESPBUTTONEVENT_SINGLECLICK:
return PSTR("SingleClick");
case ESPBUTTONEVENT_DOUBLECLICK:
return PSTR("DoubleClick");
case ESPBUTTONEVENT_LONGCLICK:
return PSTR("LongClick");
default:
return PSTR("<unknown event>");
}
}
void tick() {
ESPButtonEntry *entry = entries;
while (entry) {
tickEntry(entry);
entry = entry->next;
}
}
void loop() {
if (callback && (notify_event != ESPBUTTONEVENT_NONE)) {
callback(notify_id, notify_event);
notify_id = 0;
notify_event = ESPBUTTONEVENT_NONE;
}
}
private:
bool digitalReadEntryIsDown(ESPButtonEntry *entry) {
if (entry->ext_digitalRead) {
return entry->ext_digitalRead(entry->pin) == entry->pin_down_digital;
}
return digitalRead(entry->pin) == entry->pin_down_digital;
}
void tickEntry(ESPButtonEntry *entry) {
const uint32_t t = millis();
const bool down = digitalReadEntryIsDown(entry);
if (down != entry->raw_down) {
entry->raw_down = down;
entry->is_stable = false;
entry->raw_changed_time = t;
ESPBUTTON_DEBUG("change (%s)", down ? PSTR("down") : PSTR("up"));
} else { // down == raw_down
// 在stable_threshold时间内一直没有变化,认为是stable
if (!entry->is_stable) {
if (t - entry->raw_changed_time > entry->stable_threshold) {
ESPBUTTON_DEBUG("t: %d, raw: %d", t, entry->raw_changed_time);ESPBUTTON_DEBUG("stable (%s)", down ? PSTR("down") : PSTR("up"));
entry->is_stable = true;
}
}
}
if (!entry->is_stable) {
//ESPBUTTON_DEBUG("not stable");
return;
}
//以上代码能检测出超过一定时间的稳定了的状态,等稳定了之后再做处理
if (entry->stable_down == down) {
handleEntryUnchanged(entry);
return;
} else {
entry->stable_down = down;
handleEntryChanged(entry);
}
}
void handleEntryChanged(ESPButtonEntry *entry) {
const bool down = entry->stable_down;
//仅有单击事件就在down的时候直接回调? 暂时不这么做,类比实体开关,按下不松手的时候,就是一直开着的状态
//逻辑如下:
//单击:按下->释放->且释放一段时间内没有第二次按下
//双击:按下->释放->且释放一段时间内执行第二次按下时触发
//长按:按下一段时间内未释放
if (down) { //down
if (entry->wait_doubleclick && entry->doubleclick_enable) {
//规定时间内第二次down了,认为是双击
//亲测,一般情况下我的双击up->第二次down的间隔是80~100左右
ESPBUTTON_DEBUG("doubleclick, wait %d", (millis() - entry->up_time));
entry->down_handled = true;
notifyEvent(entry, ESPBUTTONEVENT_DOUBLECLICK);
} else {
//第一次按下
entry->down_handled = false;
}
entry->down_time = millis();
entry->longclicked = false;
entry->wait_doubleclick = false;
} else { //up
if (!entry->down_handled) {
if (entry->doubleclick_enable) {
//在loop中延时等待第二次按下
entry->up_time = millis();
entry->wait_doubleclick = true;
} else {
entry->down_handled = true;
notifyEvent(entry, ESPBUTTONEVENT_SINGLECLICK);
}
}
}
}
void handleEntryUnchanged(ESPButtonEntry *entry) {
bool down = entry->stable_down;
if (down) { //down
if (entry->longclick_enable) {
if (!entry->longclicked && !entry->down_handled) {
if (millis() - entry->down_time > entry->longclick_threshold) {
entry->longclicked = true;
entry->down_handled = true;
notifyEvent(entry, ESPBUTTONEVENT_LONGCLICK);
}
}
}
} else { //up
entry->longclicked = false;
if (entry->wait_doubleclick && entry->doubleclick_enable) {
if (millis() - entry->up_time > entry->doubleclick_threshold) {
entry->wait_doubleclick = false;
entry->down_handled = true;
//key2DoClick();
notifyEvent(entry, ESPBUTTONEVENT_SINGLECLICK);
}
}
}
}
void notifyEvent(ESPButtonEntry *entry, ESPButtonEvent event) {
ESPBUTTON_DEBUG("Button(%d): %s", entry->id, getButtonEventDescription(event));
// Save the Event and notify it in loop
if (notify_event != ESPBUTTONEVENT_NONE) {
ESPBUTTON_DEBUG("Warnning! Previous Button Event is not handled in loop!");
}
notify_event = event;
notify_id = entry->id;
// if (callback) {
// callback(entry->id, event);
// }
}
};
ESPButtonClass ESPButton;
static void _esp32_ticker_cb(ESPButtonClass *esp_button) {
esp_button->tick();
}
#endif /* ESPBUTTON_H_ */
================================================
FILE: examples/ESP32_homekit_wolfssl_4_3_0/builtin_led_accessory.c
================================================
/*
* builtin_led_accessory.c
* Define the accessory in pure C language using the Macro in characteristics.h
*
* Created on: 2020-04-13
* Author: Mixiaoxiao (Wang Bin)
*/
#include <Arduino.h>
#include <homekit/types.h>
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
#include <stdio.h>
#include <port.h>
#include <esp_wifi_types.h>
#include <esp_wifi.h>
static char ACCESSORY_NAME[32] = "ESP32_LED";
#define ACCESSORY_SN ("SN_0123456") //SERIAL_NUMBER
#define ACCESSORY_MANUFACTURER ("Arduino HomeKit")
#define ACCESSORY_MODEL ("ESP32_DEVKIT")
#define PIN_LED 2
void led_set_power(bool on) {
digitalWrite(PIN_LED, on ? HIGH : LOW);
}
void led_setter(homekit_value_t value);
homekit_characteristic_t name = HOMEKIT_CHARACTERISTIC_(NAME, ACCESSORY_NAME);
homekit_characteristic_t serial_number = HOMEKIT_CHARACTERISTIC_(SERIAL_NUMBER, ACCESSORY_SN);
homekit_characteristic_t led_on = HOMEKIT_CHARACTERISTIC_(ON, false, .setter=led_setter);
void led_setter(homekit_value_t value) {
if (value.format != homekit_format_bool) {
printf("Invalid on-value format: %d\n", value.format);
return;
}
const bool power = value.bool_value;
led_on.value.bool_value = power; // Sync the value, and no getter needed.
led_set_power(power);
printf("Set Builtin-LED to %s\n", power ? "ON" : "OFF");
}
void led_toggle() {
bool power = !led_on.value.bool_value;
led_on.value.bool_value = power;
led_set_power(power);
homekit_characteristic_notify(&led_on, led_on.value);
}
void led_blink_task(void *_args) {
for (int i = 0; i < 3; i++) {
led_set_power(true);
vTaskDelay(100 / portTICK_PERIOD_MS);
led_set_power(false);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
led_set_power(false);
vTaskDelete(NULL);
}
void led_blink() {
xTaskCreate(led_blink_task, "led_blink_task", 2048, NULL, 1, NULL);
}
void accessory_identify(homekit_value_t _value) {
printf("accessory identify\n");
led_blink();
}
homekit_accessory_t *accessories[] = {
HOMEKIT_ACCESSORY(
.id = 1,
.category = homekit_accessory_category_lightbulb,
.services=(homekit_service_t*[]){
HOMEKIT_SERVICE(ACCESSORY_INFORMATION,
.characteristics=(homekit_characteristic_t*[]){
&name,
HOMEKIT_CHARACTERISTIC(MANUFACTURER, ACCESSORY_MANUFACTURER),
&serial_number,
HOMEKIT_CHARACTERISTIC(MODEL, ACCESSORY_MODEL),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0.1"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, accessory_identify),
NULL
}),
HOMEKIT_SERVICE(LIGHTBULB, .primary=true,
.characteristics=(homekit_characteristic_t*[]){
HOMEKIT_CHARACTERISTIC(NAME, "Led"),
&led_on,
NULL
}),
NULL
}),
NULL
};
homekit_server_config_t config = {
.accessories = accessories,
.password = "111-11-111",
//.on_event = on_homekit_event,
.setupId = "ABCD"
};
void accessory_init() {
pinMode(PIN_LED, OUTPUT);
led_set_power(false);
//Rename ACCESSORY_NAME base on MAC address.
uint8_t mac[6];
esp_wifi_get_mac(WIFI_IF_STA, mac);
sprintf(ACCESSORY_NAME, "ESP32_LED_%02X%02X%02X", mac[3], mac[4], mac[5]);
}
================================================
FILE: library.json
================================================
{
"name":"HomeKit-ESP32",
"description":"Apple HomeKit accessory server library for the ESP32 Arduino core.",
"keywords":"homekit,esp32,apple homekit",
"authors":
{
"name": "Mixiaoxiao (Wang Bin)",
"maintainer": true
},
"repository":
{
"type": "git",
"url": "https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP32.git"
},
"version": "1.0.0",
"license": "MIT",
"frameworks": "arduino",
"platforms": "espressif32",
"build": {
"libCompatMode": 2
}
}
================================================
FILE: library.properties
================================================
name=HomeKit-ESP32
version=1.0.0
author=Mixiaoxiao
maintainer=Mixiaoxiao
sentence=Native Apple HomeKit accessory implementation for the ESP32 Arduino core.
paragraph=Native Apple HomeKit Accessory Implementation for the ESP32 Arduino core.
category=Communication
url=https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP32.git
architectures=esp32
================================================
FILE: src/accessories.c
================================================
#include <stdlib.h>
#include <string.h>
#include <homekit/types.h>
bool homekit_value_equal(homekit_value_t *a, homekit_value_t *b) {
if (a->is_null != b->is_null)
return false;
if (a->format != b->format)
return false;
switch (a->format) {
case homekit_format_bool:
return a->bool_value == b->bool_value;
case homekit_format_uint8:
case homekit_format_uint16:
case homekit_format_uint32:
case homekit_format_uint64:
case homekit_format_int:
return a->int_value == b->int_value;
case homekit_format_float:
return a->float_value == b->float_value;
case homekit_format_string:
return !strcmp(a->string_value, b->string_value);
case homekit_format_tlv: {
if (!a->tlv_values && !b->tlv_values)
return true;
if (!a->tlv_values || !b->tlv_values)
return false;
// TODO: implement order independent comparison?
tlv_t *ta = a->tlv_values->head, *tb = b->tlv_values->head;
for (; ta && tb; ta=ta->next, tb=tb->next) {
if (ta->type != tb->type || ta->size != tb->size)
return false;
if (strncmp((char *)ta->value, (char *)tb->value, ta->size))
return false;
}
return (!ta && !tb);
}
case homekit_format_data:
if (!a->data_value && !b->data_value)
return true;
if (!a->data_value || !b->data_value)
return false;
if (a->data_size != b->data_size)
return false;
return !memcmp(a->data_value, b->data_value, a->data_size);
}
return false;
}
void homekit_value_copy(homekit_value_t *dst, homekit_value_t *src) {
memset(dst, 0, sizeof(*dst));
dst->format = src->format;
dst->is_null = src->is_null;
if (!src->is_null) {
switch (src->format) {
case homekit_format_bool:
dst->bool_value = src->bool_value;
break;
case homekit_format_uint8:
case homekit_format_uint16:
case homekit_format_uint32:
case homekit_format_uint64:
case homekit_format_int:
dst->int_value = src->int_value;
break;
case homekit_format_float:
dst->float_value = src->float_value;
break;
case homekit_format_string:
if (src->is_static) {
dst->string_value = src->string_value;
dst->is_static = true;
} else {
dst->string_value = strdup(src->string_value);
}
break;
case homekit_format_tlv: {
if (src->is_static) {
dst->tlv_values = src->tlv_values;
dst->is_static = true;
} else {
dst->tlv_values = tlv_new();
for (tlv_t *v=src->tlv_values->head; v; v=v->next) {
tlv_add_value(dst->tlv_values, v->type, v->value, v->size);
}
}
break;
}
case homekit_format_data:
if (src->is_static) {
dst->data_value = src->data_value;
dst->data_size = src->data_size;
dst->is_static = true;
} else {
dst->data_size = src->data_size;
dst->data_value = malloc(src->data_size);
memcpy(dst->data_value, src->data_value, src->data_size);
}
break;
default:
// unknown format
break;
}
}
}
homekit_value_t *homekit_value_clone(homekit_value_t *value) {
homekit_value_t *copy = malloc(sizeof(homekit_value_t));
homekit_value_copy(copy, value);
return copy;
}
void homekit_value_destruct(homekit_value_t *value) {
if (!value->is_null) {
switch (value->format) {
case homekit_format_string:
if (!value->is_static && value->string_value)
free(value->string_value);
break;
case homekit_format_tlv:
if (!value->is_static && value->tlv_values)
tlv_free(value->tlv_values);
break;
case homekit_format_data:
if (!value->is_static && value->data_value)
free(value->data_value);
break;
default:
// unknown format
break;
}
}
}
void homekit_value_free(homekit_value_t *value) {
homekit_value_destruct(value);
free(value);
}
size_t align_size(size_t size) {
if (size % sizeof(void*)) {
size += sizeof(void*) - size % sizeof(void*);
}
return size;
}
void *align_pointer(void *ptr) {
uintptr_t p = (uintptr_t) ptr;
if (p % sizeof(void*)) {
p += sizeof(void*) - p % sizeof(void*);
}
return (void*) p;
}
homekit_characteristic_t* homekit_characteristic_clone(homekit_characteristic_t* ch) {
size_t type_len = strlen(ch->type) + 1;
size_t description_len = ch->description ? strlen(ch->description) + 1 : 0;
size_t size = align_size(sizeof(homekit_characteristic_t) + type_len + description_len);
if (ch->min_value)
size += sizeof(float);
if (ch->max_value)
size += sizeof(float);
if (ch->min_step)
size += sizeof(float);
if (ch->max_len)
size += sizeof(int);
if (ch->max_data_len)
size += sizeof(int);
if (ch->valid_values.count)
size += align_size(sizeof(uint8_t) * ch->valid_values.count);
if (ch->valid_values_ranges.count)
size += align_size(sizeof(homekit_valid_values_range_t) * ch->valid_values_ranges.count);
if (ch->callback) {
homekit_characteristic_change_callback_t *c = ch->callback;
while (c) {
size += align_size(sizeof(homekit_characteristic_change_callback_t));
c = c->next;
}
}
uint8_t* p = calloc(1, size);
homekit_characteristic_t* clone = (homekit_characteristic_t*) p;
p += sizeof(homekit_characteristic_t);
clone->service = ch->service;
clone->id = ch->id;
clone->type = (char*) p;
strncpy((char*) p, ch->type, type_len);
p[type_len - 1] = 0;
p += type_len;
clone->description = (char*) p;
strncpy((char*) p, ch->description, description_len);
p[description_len - 1] = 0;
p += description_len;
p = align_pointer(p);
clone->format = ch->format;
clone->unit = ch->unit;
clone->permissions = ch->permissions;
homekit_value_copy(&clone->value, &ch->value);
if (ch->min_value) {
clone->min_value = (float*) p;
*clone->min_value = *ch->min_value;
p += sizeof(float);
}
if (ch->max_value) {
clone->max_value = (float*) p;
*clone->max_value = *ch->max_value;
p += sizeof(float);
}
if (ch->min_step) {
clone->min_step = (float*) p;
*clone->min_step = *ch->min_step;
p += sizeof(float);
}
if (ch->max_len) {
clone->max_len = (int*) p;
*clone->max_len = *ch->max_len;
p += sizeof(int);
}
if (ch->max_data_len) {
clone->max_data_len = (int*) p;
*clone->max_data_len = *ch->max_data_len;
p += sizeof(int);
}
if (ch->valid_values.count) {
clone->valid_values.count = ch->valid_values.count;
clone->valid_values.values = (uint8_t*) p;
memcpy(clone->valid_values.values, ch->valid_values.values,
sizeof(uint8_t) * ch->valid_values.count);
p += align_size(sizeof(uint8_t) * ch->valid_values.count);
}
if (ch->valid_values_ranges.count) {
int c = ch->valid_values_ranges.count;
clone->valid_values_ranges.count = c;
clone->valid_values_ranges.ranges = (homekit_valid_values_range_t*) p;
memcpy(clone->valid_values_ranges.ranges,
ch->valid_values_ranges.ranges,
sizeof(homekit_valid_values_range_t*) * c);
p += align_size(sizeof(homekit_valid_values_range_t*) * c);
}
if (ch->callback) {
int c = 1;
homekit_characteristic_change_callback_t *callback_in = ch->callback;
clone->callback = (homekit_characteristic_change_callback_t*)p;
homekit_characteristic_change_callback_t *callback_out = clone->callback;
memcpy(callback_out, callback_in, sizeof(*callback_out));
while (callback_in->next) {
callback_in = callback_in->next;
callback_out->next = callback_out + 1;
callback_out = callback_out->next;
memcpy(callback_out, callback_in, sizeof(*callback_out));
c++;
}
callback_out->next = NULL;
p += align_size(sizeof(homekit_characteristic_change_callback_t)) * c;
}
clone->getter = ch->getter;
clone->setter = ch->setter;
clone->getter_ex = ch->getter_ex;
clone->setter_ex = ch->setter_ex;
clone->context = ch->context;
return clone;
}
homekit_service_t* homekit_service_clone(homekit_service_t* service) {
size_t type_len = strlen(service->type) + 1;
size_t size = align_size(sizeof(homekit_service_t) + type_len);
if (service->linked) {
int i = 0;
while (service->linked[i])
i++;
size += sizeof(homekit_service_t*) * (i + 1);
}
if (service->characteristics) {
int i = 0;
while (service->characteristics[i])
i++;
size += sizeof(homekit_characteristic_t*) * (i + 1);
}
uint8_t *p = calloc(1, size);
homekit_service_t *clone = (homekit_service_t*) p;
p += sizeof(homekit_service_t);
clone->accessory = service->accessory;
clone->id = service->id;
clone->type = strncpy((char*) p, service->type, type_len);
p[type_len - 1] = 0;
p += align_size(type_len);
clone->hidden = service->hidden;
clone->primary = service->primary;
if (service->linked) {
clone->linked = (homekit_service_t**) p;
int i = 0;
while (service->linked[i]) {
clone->linked[i] = service->linked[i];
i++;
}
clone->linked[i] = NULL;
p += (i + 1) * sizeof(homekit_service_t*);
}
if (service->characteristics) {
clone->characteristics = (homekit_characteristic_t**) p;
int i = 0;
while (service->characteristics[i]) {
clone->characteristics[i] = service->characteristics[i];
i++;
}
clone->characteristics[i] = NULL;
p += (i + 1) * sizeof(homekit_characteristic_t*);
}
return clone;
}
homekit_accessory_t* homekit_accessory_clone(homekit_accessory_t* ac) {
size_t size = sizeof(homekit_accessory_t);
if (ac->services) {
for (int i=0; ac->services[i]; i++) {
size += sizeof(homekit_service_t*);
}
size += sizeof(homekit_service_t*);
}
uint8_t* p = calloc(1, size);
homekit_accessory_t* clone = (homekit_accessory_t*) p;
p += align_size(sizeof(homekit_accessory_t));
clone->id = ac->id;
clone->category = ac->category;
clone->config_number = ac->config_number;
if (ac->services) {
clone->services = (homekit_service_t**) p;
int i = 0;
while (ac->services[i]) {
clone->services[i] = ac->services[i];
i++;
}
clone->services[i] = NULL;
p += sizeof(homekit_service_t*) * (i + 1);
}
return clone;
}
homekit_value_t homekit_characteristic_ex_old_getter(const homekit_characteristic_t *ch) {
return ch->getter();
}
void homekit_characteristic_ex_old_setter(homekit_characteristic_t *ch, homekit_value_t value) {
ch->setter(value);
}
void homekit_accessories_init(homekit_accessory_t **accessories) {
//设置aid 和 iid (自增1)
uint32_t aid = 1;
for (homekit_accessory_t **accessory_it = accessories; *accessory_it; accessory_it++) {
homekit_accessory_t *accessory = *accessory_it;
if (accessory->id) {
if (accessory->id >= aid)
aid = accessory->id+1;
} else {
accessory->id = aid++;
}
uint32_t iid = 1;
for (homekit_service_t **service_it = accessory->services; *service_it; service_it++) {
homekit_service_t *service = *service_it;
service->accessory = accessory;
if (service->id) {
if (service->id >= iid)
iid = service->id+1;
} else {
service->id = iid++;
}
for (homekit_characteristic_t **ch_it = service->characteristics; *ch_it; ch_it++) {
homekit_characteristic_t *ch = *ch_it;
ch->service = service;
if (ch->id) {
if (ch->id >= iid)
iid = ch->id+1;
} else {
ch->id = iid++;
}
if (!ch->getter_ex && ch->getter) {
ch->getter_ex = homekit_characteristic_ex_old_getter;
}
if (!ch->setter_ex && ch->setter) {
ch->setter_ex = homekit_characteristic_ex_old_setter;
}
ch->value.format = ch->format;
}
}
}
}
homekit_accessory_t *homekit_accessory_by_id(homekit_accessory_t **accessories, uint32_t aid) {
for (homekit_accessory_t **accessory_it = accessories; *accessory_it; accessory_it++) {
homekit_accessory_t *accessory = *accessory_it;
if (accessory->id == aid)
return accessory;
}
return NULL;
}
homekit_service_t *homekit_service_by_type(homekit_accessory_t *accessory, const char *type) {
for (homekit_service_t **service_it = accessory->services; *service_it; service_it++) {
homekit_service_t *service = *service_it;
if (!strcmp(service->type, type))
return service;
}
return NULL;
}
homekit_characteristic_t *homekit_service_characteristic_by_type(homekit_service_t *service, const char *type) {
for (homekit_characteristic_t **ch_it = service->characteristics; *ch_it; ch_it++) {
homekit_characteristic_t *ch = *ch_it;
if (!strcmp(ch->type, type))
return ch;
}
return NULL;
}
homekit_characteristic_t *homekit_characteristic_by_aid_and_iid(homekit_accessory_t **accessories, uint32_t aid, uint32_t iid) {
for (homekit_accessory_t **accessory_it = accessories; *accessory_it; accessory_it++) {
homekit_accessory_t *accessory = *accessory_it;
if (accessory->id != aid)
continue;
for (homekit_service_t **service_it = accessory->services; *service_it; service_it++) {
homekit_service_t *service = *service_it;
for (homekit_characteristic_t **ch_it = service->characteristics; *ch_it; ch_it++) {
homekit_characteristic_t *ch = *ch_it;
if (ch->id == iid)
return ch;
}
}
}
return NULL;
}
homekit_characteristic_t *homekit_characteristic_find_by_type(homekit_accessory_t **accessories, uint32_t aid, const char *type) {
for (homekit_accessory_t **accessory_it = accessories; *accessory_it; accessory_it++) {
homekit_accessory_t *accessory = *accessory_it;
if (accessory->id != aid)
continue;
for (homekit_service_t **service_it = accessory->services; *service_it; service_it++) {
homekit_service_t *service = *service_it;
for (homekit_characteristic_t **ch_it = service->characteristics; *ch_it; ch_it++) {
homekit_characteristic_t *ch = *ch_it;
if (!strcmp(ch->type, type))
return ch;
}
}
}
return NULL;
}
void homekit_characteristic_notify(homekit_characteristic_t *ch, homekit_value_t value) {
homekit_characteristic_change_callback_t *callback = ch->callback;
while (callback) {
callback->function(ch, value, callback->context);
callback = callback->next;
}
}
void homekit_characteristic_add_notify_callback(
homekit_characteristic_t *ch,
homekit_characteristic_change_callback_fn function,
void *context
) {
homekit_characteristic_change_callback_t *new_callback = malloc(sizeof(homekit_characteristic_change_callback_t));
new_callback->function = function;
new_callback->context = context;
new_callback->next = NULL;
if (!ch->callback) {
ch->callback = new_callback;
} else {
homekit_characteristic_change_callback_t *callback = ch->callback;
if (callback->function == function && callback->context == context) {
free(new_callback);
return;
}
while (callback->next) {
if (callback->next->function == function && callback->next->context == context) {
free(new_callback);
return;
}
callback = callback->next;
}
callback->next = new_callback;
}
}
void homekit_characteristic_remove_notify_callback(
homekit_characteristic_t *ch,
homekit_characteristic_change_callback_fn function,
void *context
) {
while (ch->callback) {
if (ch->callback->function != function || ch->callback->context != context) {
break;
}
homekit_characteristic_change_callback_t *c = ch->callback;
ch->callback = ch->callback->next;
free(c);
}
if (!ch->callback)
return;
homekit_characteristic_change_callback_t *callback = ch->callback;
while (callback->next) {
if (callback->next->function == function && callback->next->context == context) {
homekit_characteristic_change_callback_t *c = callback->next;
callback->next = callback->next->next;
free(c);
} else {
callback = callback->next;
}
}
}
// Removes particular callback from all characteristics
void homekit_accessories_clear_notify_callbacks(
homekit_accessory_t **accessories,
homekit_characteristic_change_callback_fn function,
void *context
) {
for (homekit_accessory_t **accessory_it = accessories; *accessory_it; accessory_it++) {
homekit_accessory_t *accessory = *accessory_it;
for (homekit_service_t **service_it = accessory->services; *service_it; service_it++) {
homekit_service_t *service = *service_it;
for (homekit_characteristic_t **ch_it = service->characteristics; *ch_it; ch_it++) {
homekit_characteristic_t *ch = *ch_it;
homekit_characteristic_remove_notify_callback(ch, function, context);
}
}
}
}
bool homekit_characteristic_has_notify_callback(
const homekit_characteristic_t *ch,
homekit_characteristic_change_callback_fn function,
void *context
) {
homekit_characteristic_change_callback_t *callback = ch->callback;
while (callback) {
if (callback->function == function && callback->context == context)
return true;
callback = callback->next;
}
return false;
}
================================================
FILE: src/arduino_homekit_server.h
================================================
#ifndef ARDUINO_HOMEKIT_SERVER_H_
#define ARDUINO_HOMEKIT_SERVER_H_
#include <WiFiServer.h>
#include <WiFiClient.h>
#include <string.h> //size_t
#ifdef __cplusplus
extern "C" {
#endif
#include "constants.h"
#include "base64.h"
#include "crypto.h"
#include "pairing.h"
#include "storage.h"
#include "query_params.h"
#include "json.h"
#include "homekit_debug.h"
#include "port.h"
#include "cQueue.h"
#include "homekit/homekit.h"
#include "http_parser.h"
typedef enum {
HOMEKIT_CLIENT_STEP_NONE = 0,
HOMEKIT_CLIENT_STEP_PAIR_SETUP_1OF3,//1, need receive data
HOMEKIT_CLIENT_STEP_PAIR_SETUP_2OF3,//2, need receive data
HOMEKIT_CLIENT_STEP_PAIR_SETUP_3OF3,//3, need receive data
HOMEKIT_CLIENT_STEP_PAIR_VERIFY_1OF2,//4, need receive data
HOMEKIT_CLIENT_STEP_PAIR_VERIFY_2OF2,//5, secure session established
//HOMEKIT_CLIENT_STEP_IDLE,//
//HOMEKIT_CLIENT_STEP_PAIRINGS, // not used currently
HOMEKIT_CLIENT_STEP_END // disconnected
} homekit_client_step_t;
typedef enum {
HOMEKIT_ENDPOINT_UNKNOWN = 0,
HOMEKIT_ENDPOINT_PAIR_SETUP,
HOMEKIT_ENDPOINT_PAIR_VERIFY,
HOMEKIT_ENDPOINT_IDENTIFY,
HOMEKIT_ENDPOINT_GET_ACCESSORIES,
HOMEKIT_ENDPOINT_GET_CHARACTERISTICS,
HOMEKIT_ENDPOINT_UPDATE_CHARACTERISTICS,
HOMEKIT_ENDPOINT_PAIRINGS,
HOMEKIT_ENDPOINT_RESOURCE,
} homekit_endpoint_t;
struct _client_context_t;
typedef struct _client_context_t client_context_t;
typedef struct {
Srp *srp;
byte *public_key;
size_t public_key_size;
client_context_t *client;
} pairing_context_t;
typedef struct {
byte *secret;
size_t secret_size;
byte *session_key;
size_t session_key_size;
byte *device_public_key;
size_t device_public_key_size;
byte *accessory_public_key;
size_t accessory_public_key_size;
} pair_verify_context_t;
typedef struct {
WiFiServer *wifi_server;
char accessory_id[ACCESSORY_ID_SIZE + 1];
ed25519_key accessory_key;
homekit_server_config_t *config;
bool paired;
pairing_context_t *pairing_context;
//int listen_fd;
//fd_set fds;
//int max_fd;
int nfds;// arduino homekit uses this to record client count
client_context_t *clients;
} homekit_server_t;
typedef struct {
homekit_characteristic_t *characteristic;
homekit_value_t value;
} characteristic_event_t;
struct _client_context_t {
homekit_server_t *server;
//int socket;
WiFiClient *socket; //new and delete
homekit_endpoint_t endpoint;
query_param_t *endpoint_params;
byte data[1024 + 18];
size_t data_size;
size_t data_available;
char *body;
size_t body_length;
http_parser parser;
int pairing_id;
byte permissions;
bool disconnect;
homekit_characteristic_t *current_characteristic;
homekit_value_t *current_value;
bool encrypted;
byte read_key[32];
byte write_key[32];
int count_reads;
int count_writes;
//QueueHandle_t event_queue;
Queue_t *event_queue;
pair_verify_context_t *verify_context;
homekit_client_step_t step; // WangBin added
bool error_write; // WangBin added
struct _client_context_t *next;
};
typedef enum {
TLVType_Method = 0, // (integer) Method to use for pairing. See PairMethod
TLVType_Identifier = 1, // (UTF-8) Identifier for authentication
TLVType_Salt = 2, // (bytes) 16+ bytes of random salt
TLVType_PublicKey = 3, // (bytes) Curve25519, SRP public key or signed Ed25519 key
TLVType_Proof = 4, // (bytes) Ed25519 or SRP proof
TLVType_EncryptedData = 5, // (bytes) Encrypted data with auth tag at end
TLVType_State = 6, // (integer) State of the pairing process. 1=M1, 2=M2, etc.
TLVType_Error = 7, // (integer) Error code. Must only be present if error code is
// not 0. See TLVError
TLVType_RetryDelay = 8, // (integer) Seconds to delay until retrying a setup code
TLVType_Certificate = 9, // (bytes) X.509 Certificate
TLVType_Signature = 10, // (bytes) Ed25519
TLVType_Permissions = 11, // (integer) Bit value describing permissions of the controller
// being added.
// None (0x00): Regular user
// Bit 1 (0x01): Admin that is able to add and remove
// pairings against the accessory
TLVType_FragmentData = 13, // (bytes) Non-last fragment of data. If length is 0,
// it's an ACK.
TLVType_FragmentLast = 14, // (bytes) Last fragment of data
TLVType_Separator = 0xff,
} TLVType;
typedef enum {
TLVMethod_PairSetup = 1,
TLVMethod_PairVerify = 2,
TLVMethod_AddPairing = 3,
TLVMethod_RemovePairing = 4,
TLVMethod_ListPairings = 5,
} TLVMethod;
typedef enum {
TLVError_Unknown = 1, // Generic error to handle unexpected errors
TLVError_Authentication = 2, // Setup code or signature verification failed
TLVError_Backoff = 3, // Client must look at the retry delay TLV item and
// wait that many seconds before retrying
TLVError_MaxPeers = 4, // Server cannot accept any more pairings
TLVError_MaxTries = 5, // Server reached its maximum number of
// authentication attempts
TLVError_Unavailable = 6, // Server pairing method is unavailable
TLVError_Busy = 7, // Server is busy and cannot accept a pairing
// request at this time
} TLVError;
typedef enum {
// This specifies a success for the request
HAPStatus_Success = 0,
// Request denied due to insufficient privileges
HAPStatus_InsufficientPrivileges = -70401,
// Unable to communicate with requested services,
// e.g. the power to the accessory was turned off
HAPStatus_NoAccessoryConnection = -70402,
// Resource is busy, try again
HAPStatus_ResourceBusy = -70403,
// Connot write to read only characteristic
HAPStatus_ReadOnly = -70404,
// Cannot read from a write only characteristic
HAPStatus_WriteOnly = -70405,
// Notification is not supported for characteristic
HAPStatus_NotificationsUnsupported = -70406,
// Out of resources to process request
HAPStatus_OutOfResources = -70407,
// Operation timed out
HAPStatus_Timeout = -70408,
// Resource does not exist
HAPStatus_NoResource = -70409,
// Accessory received an invalid value in a write request
HAPStatus_InvalidValue = -70410,
// Insufficient Authorization
HAPStatus_InsufficientAuthorization = -70411,
} HAPStatus;
typedef enum {
characteristic_format_type = (1 << 1),
characteristic_format_meta = (1 << 2),
characteristic_format_perms = (1 << 3),
characteristic_format_events = (1 << 4),
} characteristic_format_t;
typedef struct _client_event {
const homekit_characteristic_t *characteristic;
homekit_value_t value;
struct _client_event *next;
} client_event_t;
#define ISDIGIT(x) isdigit((unsigned char)(x))
#define ISBASE36(x) (isdigit((unsigned char)(x)) || (x >= 'A' && x <= 'Z'))
void arduino_homekit_setup(homekit_server_config_t *config);
void arduino_homekit_loop();
homekit_server_t * arduino_homekit_get_running_server();
int arduino_homekit_connected_clients_count();
void homekit_update_config_number();
#ifdef __cplusplus
}
#endif
#endif /* ARDUINO_HOMEKIT_SERVER_H_ */
================================================
FILE: src/arduino_homekit_server_esp32.cpp
================================================
#if defined(ESP32)
#include <Arduino.h>
#include <esp_xpgm.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiServer.h>
#include <WiFiClient.h>
#include <lwip/sockets.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
#include <homekit/tlv.h>
#include <homekit/types.h>
#include <wolfssl/wolfcrypt/hash.h> //wc_sha512
#include "constants.h"
#include "base64.h"
#include "pairing.h"
#include "storage.h"
#include "query_params.h"
#include "json.h"
#include "homekit_debug.h"
#include "port.h"
#include "http_parser.h"
#include "query_params.h"
#include "cJSON.h"
#include "cQueue.h"
#include "crypto.h"
#include "watchdog.h"
#include "arduino_homekit_server.h"
#define HOMEKIT_SERVER_PORT 5556
#define HOMEKIT_MAX_CLIENTS 8
#define HOMEKIT_MDNS_SERVICE "_hap"
#define HOMEKIT_MDNS_PROTO "_tcp"
#define HOMEKIT_EVENT_QUEUE_SIZE 4 //original is 20
#define HOMEKIT_SOCKET_TIMEOUT 500 //milliseconds
//#define TCP_DEFAULT_KEEPALIVE_IDLE_SEC 7200 // 2 hours
//#define TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC 75 // 75 sec
//#define TCP_DEFAULT_KEEPALIVE_COUNT 9 // fault after 9 failures
//const int idle = 180; /* 180 sec idle before start sending probes */
#define HOMEKIT_SOCKET_KEEPALIVE_IDLE_SEC 180
//const int interval = 30; /* 30 sec between probes */
#define HOMEKIT_SOCKET_KEEPALIVE_INTERVAL_SEC 30
//const int maxpkt = 4; /* Drop connection after 4 probes without response */
#define HOMEKIT_SOCKET_KEEPALIVE_IDLE_COUNT 4
// if 180 + 30 * 4 = 300 sec without socket response, disconected it.
// WiFiClient can not write big buff once.
// TCP_SND_BUF = (2 * TCP_MSS) = 1072. See lwipopts.h
// max(encrypted_chunk) = 512 + 8(chunk_info) + 18(chacha_info). See client_send_encrypted
#define HOMEKIT_JSONBUFFER_SIZE 512
#ifdef HOMEKIT_DEBUG
#define TLV_DEBUG(values) //tlv_debug(values)
#else
#define TLV_DEBUG(values)
#endif
#define CLIENT_DEBUG(client, message, ...) DEBUG("[Client %d] " message, client->socket->fd(), ##__VA_ARGS__)
#define CLIENT_INFO(client, message, ...) INFO("[Client %d] " message, client->socket->fd(), ##__VA_ARGS__)
#define CLIENT_ERROR(client, message, ...) ERROR("[Client %d] " message, client->socket->fd(), ##__VA_ARGS__)
client_context_t *current_client_context = NULL;
homekit_server_t *running_server = nullptr;
//WiFiEventHandler arduino_homekit_gotiphandler;//ESP32
#define HOMEKIT_NOTIFY_EVENT(server, event) \
if ((server)->config->on_event) \
(server)->config->on_event(event);
void client_context_free(client_context_t *c);
void pairing_context_free(pairing_context_t *context);
void homekit_server_close_client(homekit_server_t *server, client_context_t *context);
bool arduino_homekit_preinit(homekit_server_t *server);
void homekit_on_paired_status_changed();
homekit_server_t* server_new() {
homekit_server_t *server = (homekit_server_t*) malloc(sizeof(homekit_server_t));
server->wifi_server = new WiFiServer(HOMEKIT_SERVER_PORT);
server->wifi_server->begin();
server->wifi_server->setNoDelay(true);
DEBUG("WiFiServer begin at port: %d", HOMEKIT_SERVER_PORT);
//FD_ZERO(&server->fds);
//server->max_fd = 0;
server->nfds = 0;
server->config = NULL;
server->paired = false;
server->pairing_context = NULL;
server->clients = NULL;
return server;
}
void server_free(homekit_server_t *server) {
if (server->pairing_context)
pairing_context_free(server->pairing_context);
if (server->clients) {
client_context_t *client = server->clients;
while (client) {
client_context_t *next = client->next;
client_context_free(client);
client = next;
}
}
if (server->wifi_server) {
server->wifi_server->stop();
server->wifi_server->close();
delete server->wifi_server;
server->wifi_server = nullptr;
} DEBUG("homekit_server_t delete WiFiServer at port: %d\n", HOMEKIT_SERVER_PORT);
if (server == running_server) {
running_server = NULL;
}
free(server);
}
void tlv_debug(const tlv_values_t *values) {
DEBUG("Got following TLV values:");
for (tlv_t *t = values->head; t; t = t->next) {
char *escaped_payload = binary_to_string(t->value, t->size);
DEBUG("Type %d value (%d bytes): %s", t->type, t->size, escaped_payload);
free(escaped_payload);
}
}
pair_verify_context_t* pair_verify_context_new() {
pair_verify_context_t *context = (pair_verify_context_t*) malloc(sizeof(pair_verify_context_t));
context->secret = NULL;
context->secret_size = 0;
context->session_key = NULL;
context->session_key_size = 0;
context->device_public_key = NULL;
context->device_public_key_size = 0;
context->accessory_public_key = NULL;
context->accessory_public_key_size = 0;
return context;
}
void pair_verify_context_free(pair_verify_context_t *context) {
if (context->secret)
free(context->secret);
if (context->session_key)
free(context->session_key);
if (context->device_public_key)
free(context->device_public_key);
if (context->accessory_public_key)
free(context->accessory_public_key);
free(context);
}
//==========================
// client_context new and free
//============================
client_context_t* client_context_new(WiFiClient *wifiClient) {
client_context_t *c = (client_context_t*) malloc(sizeof(client_context_t));
c->server = NULL;
c->endpoint_params = NULL;
c->data_size = sizeof(c->data);
c->data_available = 0;
c->body = NULL;
c->body_length = 0;
http_parser_init(&c->parser, HTTP_REQUEST);
c->parser.data = c;
c->pairing_id = -1;
c->encrypted = false;
c->count_reads = 0;
c->count_writes = 0;
c->disconnect = false;
//c->event_queue = xQueueCreate(20, sizeof(characteristic_event_t*));
c->event_queue = (Queue_t*) malloc(sizeof(Queue_t));
q_init(c->event_queue, sizeof(characteristic_event_t*),
HOMEKIT_EVENT_QUEUE_SIZE, LIFO, true);
c->verify_context = NULL;
c->next = NULL;
c->socket = wifiClient;
c->step = HOMEKIT_CLIENT_STEP_NONE;
c->error_write = false;
return c;
}
void client_context_free(client_context_t *c) {
if (c->verify_context)
pair_verify_context_free(c->verify_context);
if (c->event_queue) {
//c->event_queue->clear();
q_clean(c->event_queue);
q_kill(c->event_queue);
free(c->event_queue);
}
if (c->endpoint_params)
query_params_free(c->endpoint_params);
if (c->body)
free(c->body);
if (c->socket) {
c->socket->stop();
delete c->socket;
c->socket = nullptr;
}
free(c);
}
pairing_context_t *saved_preinit_pairing_context = nullptr;
pairing_context_t* pairing_context_new() {
pairing_context_t *context = (pairing_context_t*) malloc(sizeof(pairing_context_t));
context->srp = crypto_srp_new();
context->client = NULL;
context->public_key = NULL;
context->public_key_size = 0;
return context;
}
void pairing_context_free(pairing_context_t *context) {
if (context == saved_preinit_pairing_context) {
INFO("Free saved_preinit_pairing_context");
if (saved_preinit_pairing_context) {
saved_preinit_pairing_context = nullptr;
}
}
if (context->srp) {
crypto_srp_free(context->srp);
}
if (context->public_key) {
free(context->public_key);
}
free(context);
}
//=====================
//pairing context
//=====================
void client_notify_characteristic(homekit_characteristic_t *ch, homekit_value_t value,
void *client);
void write_characteristic_json(json_stream *json, client_context_t *client,
const homekit_characteristic_t *ch, characteristic_format_t format,
const homekit_value_t *value) {
json_string(json, "aid");
json_uint32(json, ch->service->accessory->id);
json_string(json, "iid");
json_uint32(json, ch->id);
if (format & characteristic_format_type) {
json_string(json, "type");
json_string(json, ch->type);
}
if (format & characteristic_format_perms) {
json_string(json, "perms");
json_array_start(json);
if (ch->permissions & homekit_permissions_paired_read)
json_string(json, "pr");
if (ch->permissions & homekit_permissions_paired_write)
json_string(json, "pw");
if (ch->permissions & homekit_permissions_notify)
json_string(json, "ev");
if (ch->permissions & homekit_permissions_additional_authorization)
json_string(json, "aa");
if (ch->permissions & homekit_permissions_timed_write)
json_string(json, "tw");
if (ch->permissions & homekit_permissions_hidden)
json_string(json, "hd");
json_array_end(json);
}
if ((format & characteristic_format_events) && (ch->permissions & homekit_permissions_notify)) {
bool events = homekit_characteristic_has_notify_callback(ch, client_notify_characteristic,
client);
json_string(json, "ev");
json_boolean(json, events);
}
if (format & characteristic_format_meta) {
if (ch->description) {
json_string(json, "description");
json_string(json, ch->description);
}
const char *format_str = NULL;
switch (ch->format) {
case homekit_format_bool:
format_str = "bool";
break;
case homekit_format_uint8:
format_str = "uint8";
break;
case homekit_format_uint16:
format_str = "uint16";
break;
case homekit_format_uint32:
format_str = "uint32";
break;
case homekit_format_uint64:
format_str = "uint64";
break;
case homekit_format_int:
format_str = "int";
break;
case homekit_format_float:
format_str = "float";
break;
case homekit_format_string:
format_str = "string";
break;
case homekit_format_tlv:
format_str = "tlv8";
break;
case homekit_format_data:
format_str = "data";
break;
}
if (format_str) {
json_string(json, "format");
json_string(json, format_str);
}
const char *unit_str = NULL;
switch (ch->unit) {
case homekit_unit_none:
break;
case homekit_unit_celsius:
unit_str = "celsius";
break;
case homekit_unit_percentage:
unit_str = "percentage";
break;
case homekit_unit_arcdegrees:
unit_str = "arcdegrees";
break;
case homekit_unit_lux:
unit_str = "lux";
break;
case homekit_unit_seconds:
unit_str = "seconds";
break;
}
if (unit_str) {
json_string(json, "unit");
json_string(json, unit_str);
}
if (ch->min_value) {
json_string(json, "minValue");
json_float(json, *ch->min_value);
}
if (ch->max_value) {
json_string(json, "maxValue");
json_float(json, *ch->max_value);
}
if (ch->min_step) {
json_string(json, "minStep");
json_float(json, *ch->min_step);
}
if (ch->max_len) {
json_string(json, "maxLen");
json_uint32(json, *ch->max_len);
}
if (ch->max_data_len) {
json_string(json, "maxDataLen");
json_uint32(json, *ch->max_data_len);
}
if (ch->valid_values.count) {
json_string(json, "valid-values");
json_array_start(json);
for (int i = 0; i < ch->valid_values.count; i++) {
json_uint16(json, ch->valid_values.values[i]);
}
json_array_end(json);
}
if (ch->valid_values_ranges.count) {
json_string(json, "valid-values-range");
json_array_start(json);
for (int i = 0; i < ch->valid_values_ranges.count; i++) {
json_array_start(json);
json_integer(json, ch->valid_values_ranges.ranges[i].start);
json_integer(json, ch->valid_values_ranges.ranges[i].end);
json_array_end(json);
}
json_array_end(json);
}
}
if (ch->permissions & homekit_permissions_paired_read) {
homekit_value_t v = value ? *value : ch->getter_ex ? ch->getter_ex(ch) : ch->value;
if (v.is_null) {
json_string(json, "value");
json_null(json);
} else if (v.format != ch->format) {
ERROR("Characteristic value format is different from characteristic format");
} else {
switch (v.format) {
case homekit_format_bool: {
json_string(json, "value");
json_boolean(json, v.bool_value);
break;
}
case homekit_format_uint8: {
json_string(json, "value");
json_uint8(json, v.uint8_value);
break;
}
case homekit_format_uint16: {
json_string(json, "value");
json_uint16(json, v.uint16_value);
break;
}
case homekit_format_uint32: {
json_string(json, "value");
json_uint32(json, v.uint32_value);
break;
}
case homekit_format_uint64: {
json_string(json, "value");
json_uint64(json, v.uint64_value);
break;
}
case homekit_format_int: {
json_string(json, "value");
json_integer(json, v.int_value);
break;
}
case homekit_format_float: {
json_string(json, "value");
json_float(json, v.float_value);
break;
}
case homekit_format_string: {
json_string(json, "value");
json_string(json, v.string_value);
break;
}
case homekit_format_tlv: {
json_string(json, "value");
if (!v.tlv_values) {
json_string(json, "");
} else {
size_t tlv_size = 0;
tlv_format(v.tlv_values, NULL, &tlv_size);
if (tlv_size == 0) {
json_string(json, "");
} else {
byte *tlv_data = (byte*) malloc(tlv_size);
tlv_format(v.tlv_values, tlv_data, &tlv_size);
size_t encoded_tlv_size = base64_encoded_size(tlv_data, tlv_size);
byte *encoded_tlv_data = (byte*) malloc(encoded_tlv_size + 1);
base64_encode_(tlv_data, tlv_size, encoded_tlv_data);
encoded_tlv_data[encoded_tlv_size] = 0;
json_string(json, (char*) encoded_tlv_data);
free(encoded_tlv_data);
free(tlv_data);
}
}
break;
}
case homekit_format_data: {
json_string(json, "value");
if (!v.data_value || v.data_size == 0) {
json_string(json, "");
} else {
size_t encoded_data_size = base64_encoded_size(v.data_value, v.data_size);
byte *encoded_data = (byte*) malloc(encoded_data_size + 1);
base64_encode_(v.data_value, v.data_size, encoded_data);
encoded_data[encoded_data_size] = 0;
json_string(json, (char*) encoded_data);
free(encoded_data);
}
break;
}
}
}
if (!value && ch->getter_ex) {
// called getter to get value, need to free it
homekit_value_destruct(&v);
}
}
}
void write(client_context_t *context, byte *data, int data_size) {
if ((!context) || (!context->socket) || (!context->socket->connected())) {
CLIENT_ERROR(context, "The socket is null! (or is closed)");
return;
}
if (context->error_write) {
CLIENT_ERROR(context, "Abort write data since error_write.");
return;
}
int write_size = context->socket->write(data, data_size);
CLIENT_DEBUG(context, "Sending data of size %d", data_size);
if (write_size != data_size) {
CLIENT_ERROR(context, "socket.write, data_size=%d, write_size=%d", data_size, write_size);
context->error_write = true;
// Error write when :
// 1. remote client is disconnected
// 2. data_size is larger than the tcp internal send buffer
// But We has limited the data_size to 538, and TCP_SND_BUF = 1072. (See the comments on HOMEKIT_JSONBUFFER_SIZE)
// So we believe here is disconnected.
context->disconnect = true;
homekit_server_close_client(context->server, context);
// We consider the socket is 'closed' when error in writing (eg. the remote client is disconnected, NO tcp ack receive).
// Closing the socket causes memory-leak if some data has not been sent (the write_buffer did not free)
// To fix this memory-leak, add tcp_abandon(_pcb, 0); in ClientContext.h of ESP8266WiFi-library.
}
}
int client_send_encrypted_(client_context_t *context, byte *payload, size_t size) {
CLIENT_DEBUG(context, "Send encrypted of size %d", size);
// max(size) = HOMEKIT_JSONBUFFER_SIZE + chunk_info(8) = 512 + 8 = 520
if (!context || !context->encrypted)
return -1;
/*
HAP doc:
Each HTTP message is split into frames no larger than 1024 bytes.
Each frame has the following format:
<2:AAD for little endian length of encrypted data (n) in bytes>
<n:encrypted data according to AEAD algorithm, up to 1024 bytes>
<16:authTag according to AEAD algorithm>
Note by Wang Bin. 2020-03-07
*/
byte nonce[12];
memset(nonce, 0, sizeof(nonce));
byte encrypted[1024 + 18];
int payload_offset = 0;
while (payload_offset < size) {
size_t chunk_size = size - payload_offset;
if (chunk_size > 1024)
chunk_size = 1024;
byte aead[2] = { (byte) (chunk_size % 256), (byte) (chunk_size / 256) };
memcpy(encrypted, aead, 2);
byte i = 4;
int x = context->count_reads++;
while (x) {
nonce[i++] = x % 256;
x /= 256;
}
size_t available = sizeof(encrypted) - 2;
int r = crypto_chacha20poly1305_encrypt(context->read_key, nonce, aead, 2,
payload + payload_offset, chunk_size, encrypted + 2, &available);
if (r) {
ERROR("Failed to chacha encrypt payload (code %d)", r);
return -1;
}
payload_offset += chunk_size;
write(context, encrypted, available + 2);
}
return 0;
}
int client_decrypt_(client_context_t *context, byte *payload, size_t payload_size, byte *decrypted,
size_t *decrypted_size) {
if (!context || !context->encrypted)
return -1;
const size_t block_size = 1024 + 16 + 2;
size_t required_decrypted_size = payload_size / block_size * 1024;
if (payload_size % block_size > 0)
required_decrypted_size += payload_size % block_size - 16 - 2;
if (*decrypted_size < required_decrypted_size) {
*decrypted_size = required_decrypted_size;
return -2;
}
*decrypted_size = required_decrypted_size;
byte nonce[12];
memset(nonce, 0, sizeof(nonce));
int payload_offset = 0;
int decrypted_offset = 0;
while (payload_offset < payload_size) {
size_t chunk_size = payload[payload_offset] + payload[payload_offset + 1] * 256;
if (chunk_size + 18 > payload_size - payload_offset) {
// Unfinished chunk
break;
}
byte i = 4;
int x = context->count_writes++;
while (x) {
nonce[i++] = x % 256;
x /= 256;
}
size_t decrypted_len = *decrypted_size - decrypted_offset;
int r = crypto_chacha20poly1305_decrypt(context->write_key, nonce, payload + payload_offset,
2, payload + payload_offset + 2, chunk_size + 16, decrypted, &decrypted_len);
if (r) {
ERROR("Failed to chacha decrypt payload (code %d)", r);
return -1;
}
decrypted_offset += decrypted_len;
payload_offset += chunk_size + 18;
}
return payload_offset;
}
void client_notify_characteristic(homekit_characteristic_t *ch, homekit_value_t value,
void *context) {
client_context_t *client = (client_context_t*) context;
if (client->current_characteristic == ch && client->current_value
&& homekit_value_equal(client->current_value, &value)) {
// This value is set by this client, no need to send notification
CLIENT_DEBUG(client, "This value is set by this client, no need to send notification");
return;
}
CLIENT_INFO(client, "Got characteristic %d.%d change event", ch->service->accessory->id, ch->id);
//DEBUG("Got characteristic %d.%d change event", ch->service->accessory->id, ch->id);
if (!client->event_queue) {
ERROR("Client has no event queue. Skipping notification");
return;
}
characteristic_event_t *event = (characteristic_event_t*) malloc(
sizeof(characteristic_event_t));
event->characteristic = ch;
homekit_value_copy(&event->value, &value);
DEBUG("Sending event to client %d", client->socket);
//xQueueSendToBack(client->event_queue, &event, 10);*/
//q_push第二个参数要传指针地址
q_push(client->event_queue, &event);
}
void client_send(client_context_t *context, byte *data, size_t data_size) {
CLIENT_DEBUG(context, "send data size=%d, encrypted=%s",
data_size, context->encrypted ? "true" : "false");
if (context->encrypted) {
int r = client_send_encrypted_(context, data, data_size);
if (r) {
CLIENT_ERROR(context, "Failed to encrypt response (code %d)", r);
return;
}
} else {
write(context, data, data_size);
}
}
void client_send_P(client_context_t *context, PGM_P pgm) {
XPGM_BUFFCPY_STRING(char, buff, pgm);
//client_send(context, (byte*)buff, sizeof(buff) - 1);
client_send(context, (byte*) buff, buff_size - 1);
}
void client_send_chunk(byte *data, size_t size, void *arg) {
client_context_t *context = (client_context_t*) arg;
size_t payload_size = size + 8;
byte *payload = (byte*) malloc(payload_size);
if (!payload) {
ERROR("Error malloc payload!! payload_size->%d", payload_size);
return;
}
int offset = snprintf((char*) payload, payload_size, "%x\r\n", size);
memcpy(payload + offset, data, size);
payload[offset + size] = '\r';
payload[offset + size + 1] = '\n';
CLIENT_DEBUG(context, "client_send_chunk, size=%d, offset=%d", size, offset);
client_send(context, payload, offset + size + 2);
free(payload);
}
void send_204_response(client_context_t *context) {
static const char PROGMEM response[] = "HTTP/1.1 204 No Content\r\n\r\n";
client_send_P(context, response);
}
void send_404_response(client_context_t *context) {
static const char PROGMEM response[] = "HTTP/1.1 404 Not Found\r\n\r\n";
client_send_P(context, response);
}
void send_client_events(client_context_t *context, client_event_t *events) {
CLIENT_DEBUG(context, "Sending EVENT");DEBUG_HEAP();
static const char PROGMEM http_headers[] = "EVENT/1.0 200 OK\r\n"
"Content-Type: application/hap+json\r\n"
"Transfer-Encoding: chunked\r\n\r\n";
client_send_P(context, http_headers);
// ~35 bytes per event JSON
// 256 should be enough for ~7 characteristic updates
json_stream *json = json_new(HOMEKIT_JSONBUFFER_SIZE, client_send_chunk, context);
json_object_start(json);
json_string(json, "characteristics");
json_array_start(json);
client_event_t *e = events;
while (e) {
json_object_start(json);
write_characteristic_json(json, context, e->characteristic, (characteristic_format_t) 0,
&e->value);
json_object_end(json);
e = e->next;
}
json_array_end(json);
json_object_end(json);
json_flush(json);
json_free(json);
client_send_chunk(NULL, 0, context);
}
void send_tlv_response(client_context_t *context, tlv_values_t *values);
void send_tlv_error_response(client_context_t *context, int state, TLVError error) {
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, state);
tlv_add_integer_value(response, TLVType_Error, 1, error);
send_tlv_response(context, response);
}
void send_tlv_response(client_context_t *context, tlv_values_t *values) {
CLIENT_DEBUG(context, "Sending TLV response");TLV_DEBUG(values);
size_t payload_size = 0;
tlv_format(values, NULL, &payload_size);
byte *payload = (byte*) malloc(payload_size);
int r = tlv_format(values, payload, &payload_size);
if (r) {
CLIENT_ERROR(context, "Failed to format TLV payload (code %d)", r);
free(payload);
return;
}
tlv_free(values);
static const char PROGMEM http_headers_pgm[] = "HTTP/1.1 200 OK\r\n"
"Content-Type: application/pairing+tlv8\r\n"
"Content-Length: %d\r\n"
"Connection: keep-alive\r\n\r\n";
XPGM_BUFFCPY_STRING(char, http_headers, http_headers_pgm);
int response_size = strlen(http_headers) + payload_size + 32;
char *response = (char*) malloc(response_size);
int response_len = snprintf(response, response_size, http_headers, payload_size);
if (response_size - response_len < payload_size + 1) {
CLIENT_ERROR(context, "Incorrect response buffer size %d: headers took %d, payload size %d",
response_size, response_len, payload_size);
free(response);
free(payload);
return;
}
memcpy(response + response_len, payload, payload_size);
response_len += payload_size;
free(payload);
client_send(context, (byte*) response, response_len);
free(response);
}
static const char PROGMEM json_200_response_headers_progmem[] = "HTTP/1.1 200 OK\r\n"
"Content-Type: application/hap+json\r\n"
"Transfer-Encoding: chunked\r\n"
"Connection: keep-alive\r\n\r\n";
static const char PROGMEM json_207_response_headers_progmem[] = "HTTP/1.1 207 Multi-Status\r\n"
"Content-Type: application/hap+json\r\n"
"Transfer-Encoding: chunked\r\n"
"Connection: keep-alive\r\n\r\n";
void send_json_response(client_context_t *context, int status_code, byte *payload,
size_t payload_size) {
CLIENT_DEBUG(context, "Sending JSON response");DEBUG_HEAP();
static const char PROGMEM http_headers_pgm[] = "HTTP/1.1 %d %s\r\n"
"Content-Type: application/hap+json\r\n"
"Content-Length: %d\r\n"
"Connection: keep-alive\r\n\r\n";
XPGM_BUFFCPY_STRING(char, http_headers, http_headers_pgm);
CLIENT_DEBUG(context, "Payload: %s", payload);
// Using PSTR and strcpy_P. Ref: ESP.getResetReason
//const char *status_text = "OK";
char status_text[32];
strcpy_P(status_text, PSTR("OK"));
switch (status_code) {
case 204:
strcpy_P(status_text, PSTR("No Content"));
break;
case 207:
strcpy_P(status_text, PSTR("Multi-Status"));
break;
case 400:
strcpy_P(status_text, PSTR("Bad Request"));
break;
case 404:
strcpy_P(status_text, PSTR("Not Found"));
break;
case 422:
strcpy_P(status_text, PSTR("Unprocessable Entity"));
break;
case 500:
strcpy_P(status_text, PSTR("Internal Server Error"));
break;
case 503:
strcpy_P(status_text, PSTR("Service Unavailable"));
break;
}
int response_size = strlen(http_headers) + payload_size + strlen(status_text) + 32;
char *response = (char*) malloc(response_size);
if (!response) {
CLIENT_ERROR(context, "Failed to allocate response buffer of size %d", response_size);
return;
}
int response_len = snprintf(response, response_size, http_headers, status_code, status_text,
payload_size);
if (response_size - response_len < payload_size + 1) {
CLIENT_ERROR(context, "Incorrect response buffer size %d: headers took %d, payload size %d",
response_size, response_len, payload_size);
free(response);
return;
}
memcpy(response + response_len, payload, payload_size);
response_len += payload_size;
response[response_len] = 0; // required for debug output
CLIENT_DEBUG(context, "Sending HTTP response: %s", response);
client_send(context, (byte*) response, response_len);
free(response);
}
void send_json_error_response(client_context_t *context, int status_code, HAPStatus status) {
byte buffer[32];
int size = snprintf((char*) buffer, sizeof(buffer), "{\"status\": %d}", status);
send_json_response(context, status_code, buffer, size);
}
homekit_client_id_t homekit_get_client_id() {
return (homekit_client_id_t) current_client_context;
}
bool homekit_client_is_admin() {
if (!current_client_context)
return false;
return current_client_context->permissions & pairing_permissions_admin;
}
int homekit_client_send(unsigned char *data, size_t size) {
if (!current_client_context)
return -1;
client_send(current_client_context, data, size);
return 0;
}
void homekit_server_on_identify(client_context_t *context) {
CLIENT_INFO(context, "Identify");DEBUG_HEAP();
if (context->server->paired) {
// Already paired
send_json_error_response(context, 400, HAPStatus_InsufficientPrivileges);
return;
}
send_204_response(context);
homekit_accessory_t *accessory = homekit_accessory_by_id(context->server->config->accessories,
1);
if (!accessory) {
return;
}
homekit_service_t *accessory_info = homekit_service_by_type(accessory,
HOMEKIT_SERVICE_ACCESSORY_INFORMATION);
if (!accessory_info) {
return;
}
homekit_characteristic_t *ch_identify = homekit_service_characteristic_by_type(accessory_info,
HOMEKIT_CHARACTERISTIC_IDENTIFY);
if (!ch_identify) {
return;
}
if (ch_identify->setter_ex) {
ch_identify->setter_ex(ch_identify, HOMEKIT_BOOL_CPP(true));
}
}
void homekit_server_on_pair_setup(client_context_t *context, const byte *data, size_t size) {
DEBUG("Pair Setup");DEBUG_HEAP();
DEBUG_TIME_BEGIN();
#ifdef HOMEKIT_OVERCLOCK_PAIR_SETUP
homekit_overclock_start();
#endif
// First set step=NONE, if pair-setup ok then set step=1or2or3
// (if pair-step error, the step is NONE)
context->step = HOMEKIT_CLIENT_STEP_NONE;
tlv_values_t *message = tlv_new();
tlv_parse(data, size, message);
TLV_DEBUG(message);
switch (tlv_get_integer_value(message, TLVType_State, -1)) {
case 1: {
CLIENT_INFO(context, "Pair Setup Step 1/3");DEBUG_HEAP();
if (context->server->paired) {
CLIENT_INFO(context, "Refusing to pair: already paired");
send_tlv_error_response(context, 2, TLVError_Unavailable);
break;
}
if (context->server->pairing_context) {
if (context->server->pairing_context->client != context) {
CLIENT_INFO(context, "Refusing to pair: another pairing in progress");
send_tlv_error_response(context, 2, TLVError_Busy);
break;
}
} else {
// arduino homekit preinit (create pairing_context)
if (!arduino_homekit_preinit(context->server)) {
CLIENT_ERROR(context, "Init pairing context error");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
if (saved_preinit_pairing_context == nullptr) {
CLIENT_ERROR(context, "The saved_preinit_pairing_context is NULL ?!");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
context->server->pairing_context = saved_preinit_pairing_context; ///pairing_context_new();
context->server->pairing_context->client = context;
}
int r = 0;
size_t salt_size = 0;
crypto_srp_get_salt(context->server->pairing_context->srp, NULL, &salt_size);
byte *salt = (byte*) malloc(salt_size);
r = crypto_srp_get_salt(context->server->pairing_context->srp, salt, &salt_size);
if (r) {
CLIENT_ERROR(context, "Failed to get salt (code %d)", r);
free(salt);
pairing_context_free(context->server->pairing_context);
context->server->pairing_context = NULL;
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
tlv_values_t *response = tlv_new();
tlv_add_value(response, TLVType_PublicKey, context->server->pairing_context->public_key,
context->server->pairing_context->public_key_size);
tlv_add_value(response, TLVType_Salt, salt, salt_size);
tlv_add_integer_value(response, TLVType_State, 1, 2);
free(salt);
send_tlv_response(context, response);
context->step = HOMEKIT_CLIENT_STEP_PAIR_SETUP_1OF3;
break;
}
case 3: {
CLIENT_INFO(context, "Pair Setup Step 2/3");DEBUG_HEAP();
tlv_t *device_public_key = tlv_get_value(message, TLVType_PublicKey);
if (!device_public_key) {
CLIENT_ERROR(context, "Invalid payload: no device public key");
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
tlv_t *proof = tlv_get_value(message, TLVType_Proof);
if (!proof) {
CLIENT_ERROR(context, "Invalid payload: no device proof");
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
} CLIENT_DEBUG(context, "Computing SRP shared secret");DEBUG_HEAP();
watchdog_disable_all();
watchdog_check_begin();
int r = crypto_srp_compute_key(context->server->pairing_context->srp,
device_public_key->value, device_public_key->size,
context->server->pairing_context->public_key,
context->server->pairing_context->public_key_size);
watchdog_check_end("crypto_srp_compute_key"); // 13479ms
watchdog_enable_all();
delay(10);
if (r) {
CLIENT_ERROR(context, "Failed to compute SRP shared secret (code %d)", r);
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
free(context->server->pairing_context->public_key);
context->server->pairing_context->public_key = NULL;
context->server->pairing_context->public_key_size = 0;
CLIENT_DEBUG(context, "Verifying peer's proof");
//watchdog_check_begin();
r = crypto_srp_verify(context->server->pairing_context->srp, proof->value, proof->size);
//watchdog_check_end("crypto_srp_verify");// 1ms
if (r) {
CLIENT_ERROR(context, "Failed to verify peer's proof (code %d)", r);
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
} CLIENT_DEBUG(context, "Generating own proof");
size_t server_proof_size = 0;
crypto_srp_get_proof(context->server->pairing_context->srp, NULL, &server_proof_size);
byte *server_proof = (byte*) malloc(server_proof_size);
//watchdog_check_begin();
r = crypto_srp_get_proof(context->server->pairing_context->srp, server_proof,
&server_proof_size);
//watchdog_check_end("crypto_srp_get_proof");// 1ms
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 4);
tlv_add_value(response, TLVType_Proof, server_proof, server_proof_size);
free(server_proof);
send_tlv_response(context, response);
context->step = HOMEKIT_CLIENT_STEP_PAIR_SETUP_2OF3;
break;
}
case 5: {
CLIENT_INFO(context, "Pair Setup Step 3/3");DEBUG_HEAP();
int r;
byte shared_secret[HKDF_HASH_SIZE];
size_t shared_secret_size = sizeof(shared_secret);
CLIENT_DEBUG(context, "Calculating shared secret");
const char salt1[] = "Pair-Setup-Encrypt-Salt";
const char info1[] = "Pair-Setup-Encrypt-Info";
r = crypto_srp_hkdf(context->server->pairing_context->srp, (byte*) salt1, sizeof(salt1) - 1,
(byte*) info1, sizeof(info1) - 1, shared_secret, &shared_secret_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate shared secret (code %d)", r);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
tlv_t *tlv_encrypted_data = tlv_get_value(message, TLVType_EncryptedData);
if (!tlv_encrypted_data) {
CLIENT_ERROR(context, "Invalid payload: no encrypted data");
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Decrypting payload");
size_t decrypted_data_size = 0;
crypto_chacha20poly1305_decrypt(shared_secret, (byte*) "\x0\x0\x0\x0PS-Msg05", NULL, 0,
tlv_encrypted_data->value, tlv_encrypted_data->size,
NULL, &decrypted_data_size);
byte *decrypted_data = (byte*) malloc(decrypted_data_size);
// TODO: check malloc result
r = crypto_chacha20poly1305_decrypt(shared_secret, (byte*) "\x0\x0\x0\x0PS-Msg05", NULL, 0,
tlv_encrypted_data->value, tlv_encrypted_data->size, decrypted_data,
&decrypted_data_size);
if (r) {
CLIENT_ERROR(context, "Failed to decrypt data (code %d)", r);
free(decrypted_data);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
tlv_values_t *decrypted_message = tlv_new();
r = tlv_parse(decrypted_data, decrypted_data_size, decrypted_message);
if (r) {
CLIENT_ERROR(context, "Failed to parse decrypted TLV (code %d)", r);
tlv_free(decrypted_message);
free(decrypted_data);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
free(decrypted_data);
tlv_t *tlv_device_id = tlv_get_value(decrypted_message, TLVType_Identifier);
if (!tlv_device_id) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device identifier");
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
// TODO: check that tlv_device_id->size == 36
tlv_t *tlv_device_public_key = tlv_get_value(decrypted_message, TLVType_PublicKey);
if (!tlv_device_public_key) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device public key");
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
tlv_t *tlv_device_signature = tlv_get_value(decrypted_message, TLVType_Signature);
if (!tlv_device_signature) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device signature");
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Importing device public key");
ed25519_key device_key;
crypto_ed25519_init(&device_key);
r = crypto_ed25519_import_public_key(&device_key, tlv_device_public_key->value,
tlv_device_public_key->size);
if (r) {
CLIENT_ERROR(context, "Failed to import device public Key (code %d)", r);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
byte device_x[HKDF_HASH_SIZE];
size_t device_x_size = sizeof(device_x);
CLIENT_DEBUG(context, "Calculating DeviceX");
const char salt2[] = "Pair-Setup-Controller-Sign-Salt";
const char info2[] = "Pair-Setup-Controller-Sign-Info";
r = crypto_srp_hkdf(context->server->pairing_context->srp, (byte*) salt2, sizeof(salt2) - 1,
(byte*) info2, sizeof(info2) - 1, device_x, &device_x_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate DeviceX (code %d)", r);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
size_t device_info_size = device_x_size + tlv_device_id->size + tlv_device_public_key->size;
byte *device_info = (byte*) malloc(device_info_size);
memcpy(device_info, device_x, device_x_size);
memcpy(device_info + device_x_size, tlv_device_id->value, tlv_device_id->size);
memcpy(device_info + device_x_size + tlv_device_id->size, tlv_device_public_key->value,
tlv_device_public_key->size);
CLIENT_DEBUG(context, "Verifying device signature");
r = crypto_ed25519_verify(&device_key, device_info, device_info_size,
tlv_device_signature->value, tlv_device_signature->size);
if (r) {
CLIENT_ERROR(context, "Failed to generate DeviceX (code %d)", r);
free(device_info);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
free(device_info);
r = homekit_storage_add_pairing((const char*) tlv_device_id->value, &device_key,
pairing_permissions_admin);
if (r) {
CLIENT_ERROR(context, "Failed to store pairing (code %d)", r);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
char *device_id = strndup((const char*) tlv_device_id->value, tlv_device_id->size);
INFO("Added pairing with %s", device_id);
free(device_id);
tlv_free(decrypted_message);
HOMEKIT_NOTIFY_EVENT(context->server, HOMEKIT_EVENT_PAIRING_ADDED);
CLIENT_DEBUG(context, "Exporting accessory public key");
size_t accessory_public_key_size = 0;
crypto_ed25519_export_public_key(&context->server->accessory_key, NULL,
&accessory_public_key_size);
byte *accessory_public_key = (byte*) malloc(accessory_public_key_size);
r = crypto_ed25519_export_public_key(&context->server->accessory_key, accessory_public_key,
&accessory_public_key_size);
if (r) {
CLIENT_ERROR(context, "Failed to export accessory public key (code %d)", r);
free(accessory_public_key);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
size_t accessory_id_size = sizeof(context->server->accessory_id) - 1;
size_t accessory_info_size = HKDF_HASH_SIZE + accessory_id_size + accessory_public_key_size;
byte *accessory_info = (byte*) malloc(accessory_info_size);
CLIENT_DEBUG(context, "Calculating AccessoryX");
size_t accessory_x_size = accessory_info_size;
const char salt3[] = "Pair-Setup-Accessory-Sign-Salt";
const char info3[] = "Pair-Setup-Accessory-Sign-Info";
r = crypto_srp_hkdf(context->server->pairing_context->srp, (byte*) salt3, sizeof(salt3) - 1,
(byte*) info3, sizeof(info3) - 1, accessory_info, &accessory_x_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate AccessoryX (code %d)", r);
free(accessory_info);
free(accessory_public_key);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
memcpy(accessory_info + accessory_x_size, context->server->accessory_id, accessory_id_size);
memcpy(accessory_info + accessory_x_size + accessory_id_size, accessory_public_key,
accessory_public_key_size);
CLIENT_DEBUG(context, "Generating accessory signature");DEBUG_HEAP();
size_t accessory_signature_size = 0;
crypto_ed25519_sign(&context->server->accessory_key, accessory_info, accessory_info_size,
NULL, &accessory_signature_size);
byte *accessory_signature = (byte*) malloc(accessory_signature_size);
r = crypto_ed25519_sign(&context->server->accessory_key, accessory_info,
accessory_info_size, accessory_signature, &accessory_signature_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate accessory signature (code %d)", r);
free(accessory_signature);
free(accessory_public_key);
free(accessory_info);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
free(accessory_info);
tlv_values_t *response_message = tlv_new();
tlv_add_value(response_message, TLVType_Identifier, (byte*) context->server->accessory_id,
accessory_id_size);
tlv_add_value(response_message, TLVType_PublicKey, accessory_public_key,
accessory_public_key_size);
tlv_add_value(response_message, TLVType_Signature, accessory_signature,
accessory_signature_size);
free(accessory_public_key);
free(accessory_signature);
size_t response_data_size = 0;
TLV_DEBUG(response_message);
tlv_format(response_message, NULL, &response_data_size);
byte *response_data = (byte*) malloc(response_data_size);
r = tlv_format(response_message, response_data, &response_data_size);
if (r) {
CLIENT_ERROR(context, "Failed to format TLV response (code %d)", r);
free(response_data);
tlv_free(response_message);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
tlv_free(response_message);
CLIENT_DEBUG(context, "Encrypting response");
size_t encrypted_response_data_size = 0;
crypto_chacha20poly1305_encrypt(shared_secret, (byte*) "\x0\x0\x0\x0PS-Msg06", NULL, 0,
response_data, response_data_size,
NULL, &encrypted_response_data_size);
byte *encrypted_response_data = (byte*) malloc(encrypted_response_data_size);
r = crypto_chacha20poly1305_encrypt(shared_secret, (byte*) "\x0\x0\x0\x0PS-Msg06", NULL, 0,
response_data, response_data_size, encrypted_response_data,
&encrypted_response_data_size);
free(response_data);
if (r) {
CLIENT_ERROR(context, "Failed to encrypt response data (code %d)", r);
free(encrypted_response_data);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 6);
tlv_add_value(response, TLVType_EncryptedData, encrypted_response_data,
encrypted_response_data_size);
free(encrypted_response_data);
send_tlv_response(context, response);
pairing_context_free(context->server->pairing_context);
context->server->pairing_context = NULL;
context->server->paired = true;
CLIENT_INFO(context, "Successfully paired");
//homekit_setup_mdns(context->server);
context->step = HOMEKIT_CLIENT_STEP_PAIR_SETUP_3OF3;
break;
}
default: {
CLIENT_ERROR(context, "Unknown state: %d",
tlv_get_integer_value(message, TLVType_State, -1));
}
}
tlv_free(message);
DEBUG_TIME_END("pair_setup");
#ifdef HOMEKIT_OVERCLOCK_PAIR_SETUP
homekit_overclock_end();
#endif
}
void homekit_server_on_pair_verify(client_context_t *context, const byte *data, size_t size) {
DEBUG("HomeKit Pair Verify");DEBUG_HEAP();
DEBUG_TIME_BEGIN();
context->step = HOMEKIT_CLIENT_STEP_NONE;
#ifdef HOMEKIT_OVERCLOCK_PAIR_VERIFY
homekit_overclock_start();
#endif
tlv_values_t *message = tlv_new();
tlv_parse(data, size, message);
TLV_DEBUG(message);
int r;
switch (tlv_get_integer_value(message, TLVType_State, -1)) {
case 1: {
CLIENT_INFO(context, "Pair Verify Step 1/2"); CLIENT_DEBUG(context, "Importing device Curve25519 public key");
tlv_t *tlv_device_public_key = tlv_get_value(message, TLVType_PublicKey);
if (!tlv_device_public_key) {
CLIENT_ERROR(context, "Device Curve25519 public key not found");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
curve25519_key device_key;
r = crypto_curve25519_init(&device_key);
if (r) {
CLIENT_ERROR(context, "Failed to initialize device Curve25519 public key (code %d)", r);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
r = crypto_curve25519_import_public(&device_key, tlv_device_public_key->value,
tlv_device_public_key->size);
if (r) {
CLIENT_ERROR(context, "Failed to import device Curve25519 public key (code %d)", r);
crypto_curve25519_done(&device_key);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
} CLIENT_DEBUG(context, "Generating accessory Curve25519 key");
curve25519_key my_key;
r = crypto_curve25519_generate(&my_key);
if (r) {
CLIENT_ERROR(context, "Failed to generate accessory Curve25519 key (code %d)", r);
crypto_curve25519_done(&device_key);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
} CLIENT_DEBUG(context, "Exporting accessory Curve25519 public key");
size_t my_key_public_size = 0;
crypto_curve25519_export_public(&my_key, NULL, &my_key_public_size);
byte *my_key_public = (byte*) malloc(my_key_public_size);
r = crypto_curve25519_export_public(&my_key, my_key_public, &my_key_public_size);
if (r) {
CLIENT_ERROR(context, "Failed to export accessory Curve25519 public key (code %d)", r);
free(my_key_public);
crypto_curve25519_done(&my_key);
crypto_curve25519_done(&device_key);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
CLIENT_DEBUG(context, "Generating Curve25519 shared secret");
size_t shared_secret_size = 0;
crypto_curve25519_shared_secret(&my_key, &device_key, NULL, &shared_secret_size);
byte *shared_secret = (byte*) malloc(shared_secret_size);
r = crypto_curve25519_shared_secret(&my_key, &device_key, shared_secret,
&shared_secret_size);
crypto_curve25519_done(&my_key);
crypto_curve25519_done(&device_key);
if (r) {
CLIENT_ERROR(context, "Failed to generate Curve25519 shared secret (code %d)", r);
free(shared_secret);
free(my_key_public);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
CLIENT_DEBUG(context, "Generating signature");
size_t accessory_id_size = sizeof(context->server->accessory_id) - 1;
size_t accessory_info_size = my_key_public_size + accessory_id_size
+ tlv_device_public_key->size;
byte *accessory_info = (byte*) malloc(accessory_info_size);
memcpy(accessory_info, my_key_public, my_key_public_size);
memcpy(accessory_info + my_key_public_size, context->server->accessory_id,
accessory_id_size);
memcpy(accessory_info + my_key_public_size + accessory_id_size,
tlv_device_public_key->value, tlv_device_public_key->size);
size_t accessory_signature_size = 0;
crypto_ed25519_sign(&context->server->accessory_key, accessory_info, accessory_info_size,
NULL, &accessory_signature_size);
byte *accessory_signature = (byte*) malloc(accessory_signature_size);
r = crypto_ed25519_sign(&context->server->accessory_key, accessory_info,
accessory_info_size, accessory_signature, &accessory_signature_size);
free(accessory_info);
if (r) {
CLIENT_ERROR(context, "Failed to generate signature (code %d)", r);
free(accessory_signature);
free(shared_secret);
free(my_key_public);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
tlv_values_t *sub_response = tlv_new();
tlv_add_value(sub_response, TLVType_Identifier, (const byte*) context->server->accessory_id,
accessory_id_size);
tlv_add_value(sub_response, TLVType_Signature, accessory_signature,
accessory_signature_size);
free(accessory_signature);
size_t sub_response_data_size = 0;
tlv_format(sub_response, NULL, &sub_response_data_size);
byte *sub_response_data = (byte*) malloc(sub_response_data_size);
r = tlv_format(sub_response, sub_response_data, &sub_response_data_size);
tlv_free(sub_response);
if (r) {
CLIENT_ERROR(context, "Failed to format sub-TLV message (code %d)", r);
free(sub_response_data);
free(shared_secret);
free(my_key_public);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
CLIENT_DEBUG(context, "Generating proof");
size_t session_key_size = 0;
const byte salt[] = "Pair-Verify-Encrypt-Salt";
const byte info[] = "Pair-Verify-Encrypt-Info";
crypto_hkdf(shared_secret, shared_secret_size, salt, sizeof(salt) - 1, info,
sizeof(info) - 1,
NULL, &session_key_size);
byte *session_key = (byte*) malloc(session_key_size);
r = crypto_hkdf(shared_secret, shared_secret_size, salt, sizeof(salt) - 1, info,
sizeof(info) - 1, session_key, &session_key_size);
if (r) {
CLIENT_ERROR(context, "Failed to derive session key (code %d)", r);
free(session_key);
free(sub_response_data);
free(shared_secret);
free(my_key_public);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
CLIENT_DEBUG(context, "Encrypting response");
size_t encrypted_response_data_size = 0;
crypto_chacha20poly1305_encrypt(session_key, (byte*) "\x0\x0\x0\x0PV-Msg02", NULL, 0,
sub_response_data, sub_response_data_size,
NULL, &encrypted_response_data_size);
byte *encrypted_response_data = (byte*) malloc(encrypted_response_data_size);
r = crypto_chacha20poly1305_encrypt(session_key, (byte*) "\x0\x0\x0\x0PV-Msg02", NULL, 0,
sub_response_data, sub_response_data_size, encrypted_response_data,
&encrypted_response_data_size);
free(sub_response_data);
if (r) {
CLIENT_ERROR(context, "Failed to encrypt sub response data (code %d)", r);
free(encrypted_response_data);
free(session_key);
free(shared_secret);
free(my_key_public);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 2);
tlv_add_value(response, TLVType_PublicKey, my_key_public, my_key_public_size);
tlv_add_value(response, TLVType_EncryptedData, encrypted_response_data,
encrypted_response_data_size);
free(encrypted_response_data);
send_tlv_response(context, response);
if (context->verify_context)
pair_verify_context_free(context->verify_context);
context->verify_context = pair_verify_context_new();
context->verify_context->secret = shared_secret;
context->verify_context->secret_size = shared_secret_size;
context->verify_context->session_key = session_key;
context->verify_context->session_key_size = session_key_size;
context->verify_context->accessory_public_key = my_key_public;
context->verify_context->accessory_public_key_size = my_key_public_size;
context->verify_context->device_public_key = (byte*) malloc(tlv_device_public_key->size);
memcpy(context->verify_context->device_public_key, tlv_device_public_key->value,
tlv_device_public_key->size);
context->verify_context->device_public_key_size = tlv_device_public_key->size;
context->step = HOMEKIT_CLIENT_STEP_PAIR_VERIFY_1OF2;
break;
}
case 3: {
CLIENT_INFO(context, "Pair Verify Step 2/2");
if (!context->verify_context) {
CLIENT_ERROR(context, "Failed to verify: no state 1 data");
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
tlv_t *tlv_encrypted_data = tlv_get_value(message, TLVType_EncryptedData);
if (!tlv_encrypted_data) {
CLIENT_ERROR(context, "Failed to verify: no encrypted data");
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Decrypting payload");
size_t decrypted_data_size = 0;
crypto_chacha20poly1305_decrypt(context->verify_context->session_key,
(byte*) "\x0\x0\x0\x0PV-Msg03", NULL, 0, tlv_encrypted_data->value,
tlv_encrypted_data->size,
NULL, &decrypted_data_size);
byte *decrypted_data = (byte*) malloc(decrypted_data_size);
r = crypto_chacha20poly1305_decrypt(context->verify_context->session_key,
(byte*) "\x0\x0\x0\x0PV-Msg03", NULL, 0, tlv_encrypted_data->value,
tlv_encrypted_data->size, decrypted_data, &decrypted_data_size);
if (r) {
CLIENT_ERROR(context, "Failed to decrypt data (code %d)", r);
free(decrypted_data);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
tlv_values_t *decrypted_message = tlv_new();
r = tlv_parse(decrypted_data, decrypted_data_size, decrypted_message);
free(decrypted_data);
if (r) {
CLIENT_ERROR(context, "Failed to parse decrypted TLV (code %d)", r);
tlv_free(decrypted_message);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
tlv_t *tlv_device_id = tlv_get_value(decrypted_message, TLVType_Identifier);
if (!tlv_device_id) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device identifier");
tlv_free(decrypted_message);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
tlv_t *tlv_device_signature = tlv_get_value(decrypted_message, TLVType_Signature);
if (!tlv_device_signature) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device identifier");
tlv_free(decrypted_message);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
char *device_id = strndup((const char*) tlv_device_id->value, tlv_device_id->size);
CLIENT_DEBUG(context, "Searching pairing with %s", device_id);
pairing_t pairing;
if (homekit_storage_find_pairing(device_id, &pairing)) {
CLIENT_ERROR(context, "No pairing for %s found", device_id);
free(device_id);
tlv_free(decrypted_message);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
CLIENT_INFO(context, "Found pairing with %s", device_id);
free(device_id);
byte permissions = pairing.permissions;
int pairing_id = pairing.id;
size_t device_info_size = context->verify_context->device_public_key_size
+ context->verify_context->accessory_public_key_size + tlv_device_id->size;
byte *device_info = (byte*) malloc(device_info_size);
memcpy(device_info, context->verify_context->device_public_key,
context->verify_context->device_public_key_size);
memcpy(device_info + context->verify_context->device_public_key_size, tlv_device_id->value,
tlv_device_id->size);
memcpy(device_info + context->verify_context->device_public_key_size + tlv_device_id->size,
context->verify_context->accessory_public_key,
context->verify_context->accessory_public_key_size);
CLIENT_DEBUG(context, "Verifying device signature");
r = crypto_ed25519_verify(&pairing.device_key, device_info, device_info_size,
tlv_device_signature->value, tlv_device_signature->size);
free(device_info);
tlv_free(decrypted_message);
if (r) {
CLIENT_ERROR(context, "Failed to verify device signature (code %d)", r);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
const byte salt[] = "Control-Salt";
size_t read_key_size = sizeof(context->read_key);
const byte read_info[] = "Control-Read-Encryption-Key";
r = crypto_hkdf(context->verify_context->secret, context->verify_context->secret_size, salt,
sizeof(salt) - 1, read_info, sizeof(read_info) - 1, context->read_key,
&read_key_size);
if (r) {
CLIENT_ERROR(context, "Failed to derive read encryption key (code %d)", r);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
send_tlv_error_response(context, 4, TLVError_Unknown);
break;
}
size_t write_key_size = sizeof(context->write_key);
const byte write_info[] = "Control-Write-Encryption-Key";
r = crypto_hkdf(context->verify_context->secret, context->verify_context->secret_size, salt,
sizeof(salt) - 1, write_info, sizeof(write_info) - 1, context->write_key,
&write_key_size);
pair_verify_context_free(context->verify_context);
context->verify_context = NULL;
if (r) {
CLIENT_ERROR(context, "Failed to derive write encryption key (code %d)", r);
send_tlv_error_response(context, 4, TLVError_Unknown);
break;
}
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 4);
send_tlv_response(context, response);
context->pairing_id = pairing_id;
context->permissions = permissions;
context->encrypted = true;
HOMEKIT_NOTIFY_EVENT(context->server, HOMEKIT_EVENT_CLIENT_VERIFIED);
CLIENT_INFO(context, "Verification successful, secure session established");
context->step = HOMEKIT_CLIENT_STEP_PAIR_VERIFY_2OF2;
break;
}
default: {
CLIENT_ERROR(context, "Unknown state: %d",
tlv_get_integer_value(message, TLVType_State, -1));
}
}
tlv_free(message);
DEBUG_TIME_END("pair_verify");
INFO_HEAP();
#ifdef HOMEKIT_OVERCLOCK_PAIR_VERIFY
homekit_overclock_end();
#endif
}
void homekit_client_process(client_context_t *context);
void homekit_server_on_get_accessories(client_context_t *context) {
DEBUG_TIME_BEGIN();
CLIENT_INFO(context, "Get Accessories");DEBUG_HEAP();
client_send_P(context, json_200_response_headers_progmem);
CLIENT_DEBUG(context, "Get Accessories, start send json body");
json_stream *json = json_new(HOMEKIT_JSONBUFFER_SIZE, client_send_chunk, context);
json_object_start(json);
json_string(json, "accessories");
json_array_start(json);
for (homekit_accessory_t **accessory_it = context->server->config->accessories; *accessory_it;
accessory_it++) {
homekit_accessory_t *accessory = *accessory_it;
json_object_start(json);
json_string(json, "aid");
json_uint32(json, accessory->id);
json_string(json, "services");
json_array_start(json);
for (homekit_service_t **service_it = accessory->services; *service_it; service_it++) {
homekit_service_t *service = *service_it;
json_object_start(json);
json_string(json, "iid");
json_uint32(json, service->id);
json_string(json, "type");
json_string(json, service->type);
json_string(json, "hidden");
json_boolean(json, service->hidden);
json_string(json, "primary");
json_boolean(json, service->primary);
if (service->linked) {
json_string(json, "linked");
json_array_start(json);
for (homekit_service_t **linked = service->linked; *linked; linked++) {
json_uint32(json, (*linked)->id);
}
json_array_end(json);
}
json_string(json, "characteristics");
json_array_start(json);
for (homekit_characteristic_t **ch_it = service->characteristics; *ch_it; ch_it++) {
homekit_characteristic_t *ch = *ch_it;
json_object_start(json);
write_characteristic_json(json, context, ch,
(characteristic_format_t) (characteristic_format_type
| characteristic_format_meta | characteristic_format_perms
| characteristic_format_events),
NULL);
json_object_end(json);
}
json_array_end(json);
json_object_end(json); // service
}
json_array_end(json);
json_object_end(json); // accessory
}
json_array_end(json);
json_object_end(json); // response
json_flush(json);
json_free(json);
client_send_chunk(NULL, 0, context);
DEBUG_TIME_END("get_accessories")
}
bool bool_endpoint_param(const char *name, client_context_t *context) {
query_param_t *param = query_params_find(context->endpoint_params, name);
return param && param->value && !strcmp(param->value, "1");
}
void write_characteristic_error(json_stream *json, uint32_t aid, uint32_t iid, int status) {
json_object_start(json);
json_string(json, "aid");
json_uint32(json, aid);
json_string(json, "iid");
json_uint32(json, iid);
json_string(json, "status");
json_uint8(json, status);
json_object_end(json);
}
void homekit_server_on_get_characteristics(client_context_t *context) {
CLIENT_INFO(context, "Get Characteristics");DEBUG_HEAP();
query_param_t *qp = context->endpoint_params;
while (qp) {
CLIENT_DEBUG(context, "Query paramter %s = %s", qp->name, qp->value);
qp = qp->next;
}
query_param_t *id_param = query_params_find(context->endpoint_params, "id");
if (!id_param) {
CLIENT_ERROR(context, "Invalid get characteristics request: missing ID parameter");
send_json_error_response(context, 400, HAPStatus_InvalidValue);
return;
}
characteristic_format_t format = (characteristic_format_t) 0;
if (bool_endpoint_param("meta", context))
format = (characteristic_format_t) (format | characteristic_format_meta);
if (bool_endpoint_param("perms", context))
format = (characteristic_format_t) (format | characteristic_format_perms);
if (bool_endpoint_param("type", context))
format = (characteristic_format_t) (format | characteristic_format_type);
if (bool_endpoint_param("ev", context))
format = (characteristic_format_t) (format | characteristic_format_events);
bool success = true;
char *id = strdup(id_param->value);
char *ch_id;
char *_id = id;
while ((ch_id = strsep(&_id, ","))) {
char *dot = strstr(ch_id, ".");
if (!dot) {
send_json_error_response(context, 400, HAPStatus_InvalidValue);
free(id);
return;
}
*dot = 0;
uint32_t aid = atoi(ch_id);
uint32_t iid = atoi(dot + 1);
CLIENT_DEBUG(context, "Requested characteristic info for %u.%u", aid, iid);
homekit_characteristic_t *ch = homekit_characteristic_by_aid_and_iid(
context->server->config->accessories, aid, iid);
if (!ch) {
success = false;
continue;
}
if (!(ch->permissions & homekit_permissions_paired_read)) {
success = false;
continue;
}
}
free(id);
id = strdup(id_param->value);
if (success) {
client_send_P(context, json_200_response_headers_progmem);
} else {
client_send_P(context, json_207_response_headers_progmem);
}
json_stream *json = json_new(HOMEKIT_JSONBUFFER_SIZE, client_send_chunk, context);
json_object_start(json);
json_string(json, "characteristics");
json_array_start(json);
_id = id;
while ((ch_id = strsep(&_id, ","))) {
char *dot = strstr(ch_id, ".");
*dot = 0;
uint32_t aid = atoi(ch_id);
uint32_t iid = atoi(dot + 1);
CLIENT_DEBUG(context, "Requested characteristic info for %d.%d", aid, iid);
homekit_characteristic_t *ch = homekit_characteristic_by_aid_and_iid(
context->server->config->accessories, aid, iid);
if (!ch) {
write_characteristic_error(json, aid, iid, HAPStatus_NoResource);
continue;
}
if (!(ch->permissions & homekit_permissions_paired_read)) {
write_characteristic_error(json, aid, iid, HAPStatus_WriteOnly);
continue;
}
json_object_start(json);
write_characteristic_json(json, context, ch, format, NULL);
if (!success) {
json_string(json, "status");
json_uint8(json, HAPStatus_Success);
}
json_object_end(json);
}
json_array_end(json);
json_object_end(json); // response
json_flush(json);
json_free(json);
client_send_chunk(NULL, 0, context);
free(id);
}
HAPStatus process_characteristics_update(const cJSON *j_ch, client_context_t *context) {
cJSON *j_aid = cJSON_GetObjectItem(j_ch, "aid");
if (!j_aid) {
CLIENT_ERROR(context, "Failed to process request: no \"aid\" field");
return HAPStatus_NoResource;
}
if (j_aid->type != cJSON_Number) {
CLIENT_ERROR(context, "Failed to process request: \"aid\" field is not a number");
return HAPStatus_NoResource;
}
cJSON *j_iid = cJSON_GetObjectItem(j_ch, "iid");
if (!j_iid) {
CLIENT_ERROR(context, "Failed to process request: no \"iid\" field");
return HAPStatus_NoResource;
}
if (j_iid->type != cJSON_Number) {
CLIENT_ERROR(context, "Failed to process request: \"iid\" field is not a number");
return HAPStatus_NoResource;
}
uint32_t aid = (uint32_t) j_aid->valuedouble; //j_aid->valueint;
uint32_t iid = (uint32_t) j_iid->valuedouble; //j_iid->valueint;
homekit_characteristic_t *ch = homekit_characteristic_by_aid_and_iid(
context->server->config->accessories, aid, iid);
if (!ch) {
CLIENT_ERROR(context,
"Failed to process request to update %u.%u: " "no such characteristic", aid, iid);
return HAPStatus_NoResource;
}
cJSON *j_value = cJSON_GetObjectItem(j_ch, "value");
if (j_value) {
homekit_value_t h_value = HOMEKIT_NULL_CPP();
if (!(ch->permissions & homekit_permissions_paired_write)) {
CLIENT_ERROR(context, "Failed to update %d.%d: no write permission", aid, iid);
return HAPStatus_ReadOnly;
}
switch (ch->format) {
case homekit_format_bool: {
bool value = false;
if (j_value->type == cJSON_True) {
value = true;
} else if (j_value->type == cJSON_False) {
value = false;
} else if (j_value->type == cJSON_Number
&& (j_value->valueint == 0 || j_value->valueint == 1)) {
value = j_value->valueint == 1;
} else {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not a boolean or 0/1", aid,
iid);
return HAPStatus_InvalidValue;
}
CLIENT_DEBUG(context, "Updating characteristic %d.%d with boolean %s", aid, iid, value ? "true" : "false");
h_value = HOMEKIT_BOOL_CPP(value);
if (ch->setter_ex) {
ch->setter_ex(ch, h_value);
} else {
ch->value = h_value;
}
break;
}
case homekit_format_uint8:
case homekit_format_uint16:
case homekit_format_uint32:
case homekit_format_uint64:
case homekit_format_int: {
// We accept boolean values here in order to fix a bug in HomeKit. HomeKit sometimes sends a boolean instead of an integer of value 0 or 1.
if (j_value->type != cJSON_Number && j_value->type != cJSON_False
&& j_value->type != cJSON_True) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not a number", aid, iid);
return HAPStatus_InvalidValue;
}
double min_value = 0;
double max_value = 0;
switch (ch->format) {
case homekit_format_uint8: {
min_value = 0;
max_value = 255;
break;
}
case homekit_format_uint16: {
min_value = 0;
max_value = 65535;
break;
}
case homekit_format_uint32: {
min_value = 0;
max_value = 4294967295;
break;
}
case homekit_format_uint64: {
min_value = 0;
max_value = 18446744073709551615ULL;
break;
}
case homekit_format_int: {
min_value = -2147483648;
max_value = 2147483647;
break;
}
default: {
// Impossible, keeping to make compiler happy
break;
}
}
if (ch->min_value)
min_value = *ch->min_value;
if (ch->max_value)
max_value = *ch->max_value;
double value = j_value->valuedouble;
if (value < min_value || value > max_value) {
CLIENT_ERROR(context, "Failed to update %d.%d: value %g is not in range %g..%g",
aid, iid, value, min_value, max_value);
return HAPStatus_InvalidValue;
}
if (ch->valid_values.count) {
bool matches = false;
int v = (int) value;
for (int i = 0; i < ch->valid_values.count; i++) {
if (v == ch->valid_values.values[i]) {
matches = true;
break;
}
}
if (!matches) {
CLIENT_ERROR(context,
"Failed to update %d.%d: value is not one of valid values", aid, iid);
return HAPStatus_InvalidValue;
}
}
if (ch->valid_values_ranges.count) {
bool matches = false;
for (int i = 0; i < ch->valid_values_ranges.count; i++) {
if (value >= ch->valid_values_ranges.ranges[i].start
&& value <= ch->valid_values_ranges.ranges[i].end) {
matches = true;
break;
}
}
if (!matches) {
CLIENT_ERROR(context,
"Failed to update %d.%d: value is not in valid values range", aid, iid);
return HAPStatus_InvalidValue;
}
}
CLIENT_DEBUG(context, "Updating characteristic %d.%d with integer %g", aid, iid, value);
switch (ch->format) {
case homekit_format_uint8:
h_value = HOMEKIT_UINT8_CPP(value);
break;
case homekit_format_uint16:
h_value = HOMEKIT_UINT16_CPP(value);
break;
case homekit_format_uint32:
h_value = HOMEKIT_UINT32_CPP(value);
break;
case homekit_format_uint64:
h_value = HOMEKIT_UINT64_CPP(value);
break;
case homekit_format_int:
h_value = HOMEKIT_INT_CPP(value);
break;
default:
CLIENT_ERROR(context, "Unexpected format when updating numeric value: %d",
ch->format)
;
return HAPStatus_InvalidValue;
}
if (ch->setter_ex) {
ch->setter_ex(ch, h_value);
} else {
ch->value = h_value;
}
break;
}
case homekit_format_float: {
if (j_value->type != cJSON_Number) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not a number", aid, iid);
return HAPStatus_InvalidValue;
}
float value = j_value->valuedouble;
if ((ch->min_value && value < *ch->min_value)
|| (ch->max_value && value > *ch->max_value)) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not in range", aid, iid);
return HAPStatus_InvalidValue;
}
CLIENT_DEBUG(context, "Updating characteristic %d.%d with %g", aid, iid, value);
h_value = HOMEKIT_FLOAT_CPP(value);
if (ch->setter_ex) {
ch->setter_ex(ch, h_value);
} else {
ch->value = h_value;
}
break;
}
case homekit_format_string: {
if (j_value->type != cJSON_String) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not a string", aid, iid);
return HAPStatus_InvalidValue;
}
int max_len = (ch->max_len) ? *ch->max_len : 64;
char *value = j_value->valuestring;
if (strlen(value) > max_len) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is too long", aid, iid);
return HAPStatus_InvalidValue;
}
CLIENT_DEBUG(context, "Updating characteristic %d.%d with \"%s\"", aid, iid, value);
h_value = HOMEKIT_STRING_CPP(value);
if (ch->setter_ex) {
ch->setter_ex(ch, h_value);
} else {
homekit_value_destruct(&ch->value);
homekit_value_copy(&ch->value, &h_value);
}
break;
}
case homekit_format_tlv: {
if (j_value->type != cJSON_String) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not a string", aid, iid);
return HAPStatus_InvalidValue;
}
int max_len = (ch->max_len) ? *ch->max_len : 256;
char *value = j_value->valuestring;
size_t value_len = strlen(value);
if (value_len > max_len) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is too long", aid, iid);
return HAPStatus_InvalidValue;
}
size_t tlv_size = base64_decoded_size((unsigned char*) value, value_len);
byte *tlv_data = (byte*) malloc(tlv_size);
if (base64_decode_((byte*) value, value_len, tlv_data) < 0) {
free(tlv_data);
CLIENT_ERROR(context, "Failed to update %d.%d: error Base64 decoding", aid, iid);
return HAPStatus_InvalidValue;
}
tlv_values_t *tlv_values = tlv_new();
int r = tlv_parse(tlv_data, tlv_size, tlv_values);
free(tlv_data);
if (r) {
CLIENT_ERROR(context, "Failed to update %d.%d: error parsing TLV", aid, iid);
return HAPStatus_InvalidValue;
}
CLIENT_DEBUG(context, "Updating characteristic %d.%d with TLV:", aid, iid);
for (tlv_t *t = tlv_values->head; t; t = t->next) {
char *escaped_payload = binary_to_string(t->value, t->size);
CLIENT_DEBUG(context, " Type %d value (%d bytes): %s", t->type, t->size, escaped_payload);
free(escaped_payload);
}
h_value = HOMEKIT_TLV_CPP(tlv_values);
if (ch->setter_ex) {
ch->setter_ex(ch, h_value);
} else {
homekit_value_destruct(&ch->value);
homekit_value_copy(&ch->value, &h_value);
}
tlv_free(tlv_values);
break;
}
case homekit_format_data: {
if (j_value->type != cJSON_String) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is not a string", aid, iid);
return HAPStatus_InvalidValue;
}
// Default max data len = 2,097,152 but that does not make sense
// for this accessory
int max_len = (ch->max_data_len) ? *ch->max_data_len : 4096;
char *value = j_value->valuestring;
size_t value_len = strlen(value);
if (value_len > max_len) {
CLIENT_ERROR(context, "Failed to update %d.%d: value is too long", aid, iid);
return HAPStatus_InvalidValue;
}
size_t data_size = base64_decoded_size((unsigned char*) value, value_len);
byte *data = (byte*) malloc(data_size);
if (base64_decode_((byte*) value, value_len, data) < 0) {
free(data);
CLIENT_ERROR(context, "Failed to update %d.%d: error Base64 decoding", aid, iid);
return HAPStatus_InvalidValue;
}
CLIENT_DEBUG(context, "Updating characteristic %d.%d with Data:", aid, iid);
h_value = HOMEKIT_DATA_CPP(data, data_size);
if (ch->setter_ex) {
ch->setter_ex(ch, h_value);
} else {
homekit_value_destruct(&ch->value);
homekit_value_copy(&ch->value, &h_value);
}
break;
}
}
if (!h_value.is_null) {
context->current_characteristic = ch;
context->current_value = &h_value;
homekit_characteristic_notify(ch, h_value);
context->current_characteristic = NULL;
context->current_value = NULL;
}
}
cJSON *j_events = cJSON_GetObjectItem(j_ch, "ev");
if (j_events) {
if (!(ch->permissions && homekit_permissions_notify)) {
CLIENT_ERROR(context,
"Failed to set notification state for %d.%d: " "notifications are not supported",
aid, iid);
return HAPStatus_NotificationsUnsupported;
}
if ((j_events->type != cJSON_True) && (j_events->type != cJSON_False)) {
CLIENT_ERROR(context,
"Failed to set notification state for %d.%d: " "invalid state value", aid, iid);
}
if (j_events->type == cJSON_True) {
homekit_characteristic_add_notify_callback(ch, client_notify_characteristic, context);
} else {
homekit_characteristic_remove_notify_callback(ch, client_notify_characteristic,
context);
}
}
return HAPStatus_Success;
}
void homekit_server_on_update_characteristics(client_context_t *context, const byte *data,
size_t size) {
DEBUG_TIME_BEGIN();
CLIENT_INFO(context, "Update Characteristics");DEBUG_HEAP();
char *data1 = strndup((char*) data, size);
cJSON *json = cJSON_Parse(data1);
free(data1);
if (!json) {
CLIENT_ERROR(context, "Failed to parse request JSON");
send_json_error_response(context, 400, HAPStatus_InvalidValue);
return;
}
cJSON *characteristics = cJSON_GetObjectItem(json, "characteristics");
if (!characteristics) {
CLIENT_ERROR(context, "Failed to parse request: no \"characteristics\" field");
cJSON_Delete(json);
send_json_error_response(context, 400, HAPStatus_InvalidValue);
return;
}
if (characteristics->type != cJSON_Array) {
CLIENT_ERROR(context, "Failed to parse request: \"characteristics\" field is not an list");
cJSON_Delete(json);
send_json_error_response(context, 400, HAPStatus_InvalidValue);
return;
}
HAPStatus *statuses = (HAPStatus*) malloc(
sizeof(HAPStatus) * cJSON_GetArraySize(characteristics));
bool has_errors = false;
for (int i = 0; i < cJSON_GetArraySize(characteristics); i++) {
cJSON *j_ch = cJSON_GetArrayItem(characteristics, i);
char *s = cJSON_Print(j_ch);
CLIENT_DEBUG(context, "Processing element %s", s);
free(s);
statuses[i] = process_characteristics_update(j_ch, context);
if (statuses[i] != HAPStatus_Success)
has_errors = true;
}
if (!has_errors) {
CLIENT_DEBUG(context, "There were no processing errors, sending No Content response");
send_204_response(context);
} else {
CLIENT_DEBUG(context, "There were processing errors, sending Multi-Status response");
client_send_P(context, json_207_response_headers_progmem);
json_stream *json1 = json_new(HOMEKIT_JSONBUFFER_SIZE, client_send_chunk, context);
json_object_start(json1);
json_string(json1, "characteristics");
json_array_start(json1);
for (int i = 0; i < cJSON_GetArraySize(characteristics); i++) {
cJSON *j_ch = cJSON_GetArrayItem(characteristics, i);
json_object_start(json1);
json_string(json1, "aid");
json_uint32(json1, cJSON_GetObjectItem(j_ch, "aid")->valuedouble); //->valueint);
json_string(json1, "iid");
json_uint32(json1, cJSON_GetObjectItem(j_ch, "iid")->valuedouble); //->valueint);
json_string(json1, "status");
json_uint8(json1, statuses[i]);
json_object_end(json1);
}
json_array_end(json1);
json_object_end(json1); // response
json_flush(json1);
json_free(json1);
client_send_chunk(NULL, 0, context);
}
free(statuses);
cJSON_Delete(json);
DEBUG_TIME_END("update_characteristics");
}
void homekit_server_on_pairings(client_context_t *context, const byte *data, size_t size) {
DEBUG("HomeKit Pairings");DEBUG_HEAP();
//context->step = HOMEKIT_CLIENT_STEP_PAIRINGS;
tlv_values_t *message = tlv_new();
tlv_parse(data, size, message);
TLV_DEBUG(message);
int r;
if (tlv_get_integer_value(message, TLVType_State, -1) != 1) {
send_tlv_error_response(context, 2, TLVError_Unknown);
tlv_free(message);
return;
}
switch (tlv_get_integer_value(message, TLVType_Method, -1)) {
case TLVMethod_AddPairing: {
CLIENT_INFO(context, "Add Pairing");
if (!(context->permissions & pairing_permissions_admin)) {
CLIENT_ERROR(context, "Refusing to add pairing to non-admin controller");
send_tlv_error_response(context, 2, TLVError_Authentication);
break;
}
tlv_t *tlv_device_identifier = tlv_get_value(message, TLVType_Identifier);
if (!tlv_device_identifier) {
CLIENT_ERROR(context, "Invalid add pairing request: no device identifier");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
tlv_t *tlv_device_public_key = tlv_get_value(message, TLVType_PublicKey);
if (!tlv_device_public_key) {
CLIENT_ERROR(context, "Invalid add pairing request: no device public key");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
int device_permissions = tlv_get_integer_value(message, TLVType_Permissions, -1);
if (device_permissions == -1) {
CLIENT_ERROR(context, "Invalid add pairing request: no device permissions");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
ed25519_key device_key;
crypto_ed25519_init(&device_key);
r = crypto_ed25519_import_public_key(&device_key, tlv_device_public_key->value,
tlv_device_public_key->size);
if (r) {
CLIENT_ERROR(context, "Failed to import device public key");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
char *device_identifier = strndup((const char*) tlv_device_identifier->value,
tlv_device_identifier->size);
pairing_t pairing;
if (!homekit_storage_find_pairing(device_identifier, &pairing)) {
size_t pairing_public_key_size = 0;
crypto_ed25519_export_public_key(&pairing.device_key, NULL, &pairing_public_key_size);
byte *pairing_public_key = (byte*) malloc(pairing_public_key_size);
r = crypto_ed25519_export_public_key(&pairing.device_key, pairing_public_key,
&pairing_public_key_size);
if (r) {
CLIENT_ERROR(context,
"Failed to add pairing: error exporting pairing public key (code %d)", r);
free(pairing_public_key);
free(device_identifier);
send_tlv_error_response(context, 2, TLVError_Unknown);
}
if (pairing_public_key_size != tlv_device_public_key->size
|| memcmp(tlv_device_public_key->value, pairing_public_key,
pairing_public_key_size)) {
CLIENT_ERROR(context,
"Failed to add pairing: pairing public key differs from given one");
free(pairing_public_key);
free(device_identifier);
send_tlv_error_response(context, 2, TLVError_Unknown);
}
free(pairing_public_key);
r = homekit_storage_update_pairing(device_identifier, device_permissions);
if (r) {
CLIENT_ERROR(context, "Failed to add pairing: storage error (code %d)", r);
free(device_identifier);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
INFO("Updated pairing with %s", device_identifier);
} else {
if (!homekit_storage_can_add_pairing()) {
CLIENT_ERROR(context, "Failed to add pairing: max peers");
free(device_identifier);
send_tlv_error_response(context, 2, TLVError_MaxPeers);
break;
}
r = homekit_storage_add_pairing(device_identifier, &device_key, device_permissions);
if (r) {
CLIENT_ERROR(context, "Failed to add pairing: storage error (code %d)", r);
free(device_identifier);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
INFO("Added pairing with %s", device_identifier);
HOMEKIT_NOTIFY_EVENT(context->server, HOMEKIT_EVENT_PAIRING_ADDED);
}
free(device_identifier);
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 2);
send_tlv_response(context, response);
break;
}
case TLVMethod_RemovePairing: {
CLIENT_INFO(context, "Remove Pairing");
if (!(context->permissions & pairing_permissions_admin)) {
CLIENT_ERROR(context, "Refusing to remove pairing to non-admin controller");
send_tlv_error_response(context, 2, TLVError_Authentication);
break;
}
tlv_t *tlv_device_identifier = tlv_get_value(message, TLVType_Identifier);
if (!tlv_device_identifier) {
CLIENT_ERROR(context, "Invalid remove pairing request: no device identifier");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
char *device_identifier = strndup((const char*) tlv_device_identifier->value,
tlv_device_identifier->size);
pairing_t pairing;
if (!homekit_storage_find_pairing(device_identifier, &pairing)) {
bool is_admin = pairing.permissions & pairing_permissions_admin;
r = homekit_storage_remove_pairing(device_identifier);
if (r) {
CLIENT_ERROR(context, "Failed to remove pairing: storage error (code %d)", r);
free(device_identifier);
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
INFO("Removed pairing with %s", device_identifier);
HOMEKIT_NOTIFY_EVENT(context->server, HOMEKIT_EVENT_PAIRING_REMOVED);
client_context_t *c = context->server->clients;
while (c) {
if (c->pairing_id == pairing.id)
c->disconnect = true;
c = c->next;
}
if (is_admin) {
// Removed pairing was admin,
// check if there any other admins left.
// If no admins left, enable pairing again
bool admin_found = false;
pairing_iterator_t pairing_it;
homekit_storage_pairing_iterator_init(&pairing_it);
while ((!homekit_storage_next_pairing(&pairing_it, &pairing))) {
if (pairing.permissions & pairing_permissions_admin) {
admin_found = true;
break;
}
};
homekit_storage_pairing_iterator_done(&pairing_it);
if (!admin_found) {
// No admins left, enable pairing again
INFO("Last admin pairing was removed, enabling pair setup");
context->server->paired = false;
homekit_on_paired_status_changed();
//homekit_setup_mdns(context->server);
}
}
}
free(device_identifier);
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 2);
send_tlv_response(context, response);
break;
}
case TLVMethod_ListPairings: {
CLIENT_INFO(context, "List Pairings");
if (!(context->permissions & pairing_permissions_admin)) {
CLIENT_INFO(context, "Refusing to list pairings to non-admin controller");
send_tlv_error_response(context, 2, TLVError_Authentication);
break;
}
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 2);
bool first = true;
pairing_iterator_t it;
homekit_storage_pairing_iterator_init(&it);
pairing_t pairing;
byte public_key[32];
while (!homekit_storage_next_pairing(&it, &pairing)) {
if (!first) {
tlv_add_value(response, TLVType_Separator, NULL, 0);
}
size_t public_key_size = sizeof(public_key);
r = crypto_ed25519_export_public_key(&pairing.device_key, public_key, &public_key_size);
tlv_add_string_value(response, TLVType_Identifier, pairing.device_id);
tlv_add_value(response, TLVType_PublicKey, public_key, public_key_size);
tlv_add_integer_value(response, TLVType_Permissions, 1, pairing.permissions);
first = false;
}
homekit_storage_pairing_iterator_done(&it);
send_tlv_response(context, response);
break;
}
default: {
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
}
tlv_free(message);
}
void homekit_server_on_reset(client_context_t *context) {
INFO("Reset");
homekit_server_reset();
send_204_response(context);
//vTaskDelay(3000 / portTICK_PERIOD_MS);
homekit_system_restart();
}
void homekit_server_on_resource(client_context_t *context) {
CLIENT_INFO(context, "Resource");DEBUG_HEAP();
if (!context->server->config->on_resource) {
send_404_response(context);
return;
}
context->server->config->on_resource(context->body, context->body_length);
}
//=============================================
// parse data
//=============================================
int homekit_server_on_url(http_parser *parser, const char *data, size_t length) {
client_context_t *context = (client_context_t*) parser->data;
context->endpoint = HOMEKIT_ENDPOINT_UNKNOWN;
if (parser->method == HTTP_PARSER_METHOD_GET) {
if (!strncmp(data, "/accessories", length)) {
context->endpoint = HOMEKIT_ENDPOINT_GET_ACCESSORIES;
} else {
static const char url[] = "/characteristics";
size_t url_len = sizeof(url) - 1;
if (length >= url_len && !strncmp(data, url, url_len)
&& (data[url_len] == 0 || data[url_len] == '?')) {
context->endpoint = HOMEKIT_ENDPOINT_GET_CHARACTERISTICS;
if (data[url_len] == '?') {
char *query = strndup(data + url_len + 1, length - url_len - 1);
context->endpoint_params = query_params_parse(query);
free(query);
}
}
}
} else if (parser->method == HTTP_PARSER_METHOD_POST) {
if (!strncmp(data, "/identify", length)) {
context->endpoint = HOMEKIT_ENDPOINT_IDENTIFY;
} else if (!strncmp(data, "/pair-setup", length)) {
context->endpoint = HOMEKIT_ENDPOINT_PAIR_SETUP;
} else if (!strncmp(data, "/pair-verify", length)) {
context->endpoint = HOMEKIT_ENDPOINT_PAIR_VERIFY;
} else if (!strncmp(data, "/pairings", length)) {
context->endpoint = HOMEKIT_ENDPOINT_PAIRINGS;
} else if (!strncmp(data, "/resource", length)) {
context->endpoint = HOMEKIT_ENDPOINT_RESOURCE;
}
} else if (parser->method == HTTP_PARSER_METHOD_PUT) {
if (!strncmp(data, "/characteristics", length)) {
context->endpoint = HOMEKIT_ENDPOINT_UPDATE_CHARACTERISTICS;
}
}
if (context->endpoint == HOMEKIT_ENDPOINT_UNKNOWN) {
char *url = strndup(data, length);
//TODO fix
//ERROR("Unknown endpoint: %s %s", http_method_str(parser->method), url);
free(url);
}
return 0;
}
int homekit_server_on_body(http_parser *parser, const char *data, size_t length) {
DEBUG("http_parser lenght=%d", length);
client_context_t *context = (client_context_t*) parser->data;
context->body = (char*) realloc(context->body, context->body_length + length + 1);
memcpy(context->body + context->body_length, data, length);
context->body_length += length;
context->body[context->body_length] = 0;
return 0;
}
int homekit_server_on_message_complete(http_parser *parser) {
DEBUG("http_parser message_complete");
client_context_t *context = (client_context_t*) parser->data;
if (!context->encrypted) {
switch (context->endpoint) {
case HOMEKIT_ENDPOINT_PAIR_SETUP: {
homekit_server_on_pair_setup(context, (const byte*) context->body,
context->body_length);
break;
}
case HOMEKIT_ENDPOINT_PAIR_VERIFY: {
homekit_server_on_pair_verify(context, (const byte*) context->body,
context->body_length);
break;
}
default: {
DEBUG("Unknown endpoint");
send_404_response(context);
break;
}
}
} else {
switch (context->endpoint) {
case HOMEKIT_ENDPOINT_IDENTIFY: {
homekit_server_on_identify(context);
break;
}
case HOMEKIT_ENDPOINT_GET_ACCESSORIES: {
homekit_server_on_get_accessories(context);
break;
}
case HOMEKIT_ENDPOINT_GET_CHARACTERISTICS: {
homekit_server_on_get_characteristics(context);
break;
}
case HOMEKIT_ENDPOINT_UPDATE_CHARACTERISTICS: {
homekit_server_on_update_characteristics(context, (const byte*) context->body,
context->body_length);
break;
}
case HOMEKIT_ENDPOINT_PAIRINGS: {
homekit_server_on_pairings(context, (const byte*) context->body, context->body_length);
break;
}
case HOMEKIT_ENDPOINT_RESOURCE: {
homekit_server_on_resource(context);
break;
}
default: {
DEBUG("Unknown endpoint");
send_404_response(context);
break;
}
}
}
if (context->endpoint_params) {
query_params_free(context->endpoint_params);
context->endpoint_params = NULL;
}
if (context->body) {
free(context->body);
context->body = NULL;
context->body_length = 0;
}
return 0;
}
http_parser_settings make_http_parser_settings() {
http_parser_settings settings;
settings.on_url = homekit_server_on_url;
settings.on_body = homekit_server_on_body;
settings.on_message_complete = homekit_server_on_message_complete;
return settings;
}
//sorry, unimplemented: non-trivial designated initializers not supported
//static http_parser_settings homekit_http_parser_settings = {
// .on_url = homekit_server_on_url,
// .on_body = homekit_server_on_body,
// .on_message_complete = homekit_server_on_message_complete,
//};
//点号+赋值符号
//struct A a={.b = 1,.c = 2}; //c++ compiler dose not support
//冒号
//struct A a={b:1,c:2};
static http_parser_settings homekit_http_parser_settings = make_http_parser_settings();
void homekit_client_process(client_context_t *context) {
// int data_len = read(
// context->socket,
// context->data+context->data_available,
// context->data_size-context->data_available
// );
if (context->socket == nullptr) {
CLIENT_ERROR(context, "The socket is null");
return;
}
int data_len = 0;
int available_len = context->socket->available(); // optimistic_yield(100);
if (available_len > 0) {
int size = context->data_size - context->data_available;
if (size > available_len) {
size = available_len;
}
// read or readBytes
data_len = context->socket->read(context->data + context->data_available, size);
}
if (data_len == 0) {
if (!context->socket->connected()) {
CLIENT_INFO(context, "Disconnected!");
context->disconnect = true;
homekit_server_close_client(context->server, context);
}
return;
} CLIENT_DEBUG(context, "Got %d incomming data, encrypted is %s",
data_len, context->encrypted ? "true" : "false");
byte *payload = (byte*) context->data;
size_t payload_size = (size_t) data_len;
byte *decrypted = NULL;
size_t decrypted_size = 0;
if (context->encrypted) {
CLIENT_DEBUG(context, "Decrypting data");
client_decrypt_(context, context->data, data_len, NULL, &decrypted_size);
decrypted = (byte*) malloc(decrypted_size);
int r = client_decrypt_(context, context->data, data_len, decrypted, &decrypted_size);
if (r < 0) {
CLIENT_ERROR(context, "Invalid client data");
free(decrypted);
return;
}
context->data_available = data_len - r;
if (r && context->data_available) {
memmove(context->data, &context->data[r], context->data_available);
} CLIENT_DEBUG(context, "Decrypted %d bytes, available %d", decrypted_size, context->data_available);
payload = decrypted;
payload_size = decrypted_size;
if (payload_size)
print_binary("Decrypted data", payload, payload_size);
} else {
context->data_available = 0;
}
current_client_context = context;
http_parser_execute(&context->parser, &homekit_http_parser_settings, (char*) payload,
payload_size);
current_client_context = NULL;
CLIENT_DEBUG(context, "Finished processing");
if (decrypted) {
free(decrypted);
}
}
void homekit_server_close_client(homekit_server_t *server, client_context_t *context) {
CLIENT_INFO(context, "Closing client connection");
context->step = HOMEKIT_CLIENT_STEP_END;
server->nfds--;
if (context->socket) {
context->socket->stop();
CLIENT_DEBUG(context, "The sockect is stopped");
delete context->socket;
context->socket = nullptr;
}
if (context->server->pairing_context && context->server->pairing_context->client == context) {
pairing_context_free(context->server->pairing_context);
context->server->pairing_context = NULL;
CLIENT_INFO(context, "Clear the pairing context");
}
if (context->server->clients == context) {
context->server->clients = context->next;
} else {
client_context_t *c = context->server->clients;
while (c->next && c->next != context)
c = c->next;
if (c->next)
c->next = c->next->next;
}
homekit_accessories_clear_notify_callbacks(context->server->config->accessories,
client_notify_characteristic, context);
HOMEKIT_NOTIFY_EVENT(server, HOMEKIT_EVENT_CLIENT_DISCONNECTED);
client_context_free(context);
}
client_context_t* homekit_server_accept_client(homekit_server_t *server) {
if (!server->wifi_server) {
ERROR("The server's WiFiServer is NULL!");
return NULL;
}
WiFiClient *wifiClient = nullptr;
if (server->wifi_server->hasClient()) {
wifiClient = new WiFiClient(server->wifi_server->available());
if (server->nfds >= HOMEKIT_MAX_CLIENTS) {
INFO("No more room for client connections (max %d)", HOMEKIT_MAX_CLIENTS);
wifiClient->stop();
delete wifiClient;
return NULL;
}
} else {
return NULL;
}
INFO("Got new client: local %s:%d, remote %s:%d", wifiClient->localIP().toString().c_str(),
wifiClient->localPort(), wifiClient->remoteIP().toString().c_str(),
wifiClient->remotePort());
//wifiClient->keepAlive(HOMEKIT_SOCKET_KEEPALIVE_IDLE_SEC,
//HOMEKIT_SOCKET_KEEPALIVE_INTERVAL_SEC, HOMEKIT_SOCKET_KEEPALIVE_IDLE_COUNT);
int s = wifiClient->fd();
const struct timeval rcvtimeout = { 10, 0 }; /* 10 second timeout */
setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &rcvtimeout, sizeof(rcvtimeout));
const int yes = 1; /* enable sending keepalive probes for socket */
setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));
const int idle = HOMEKIT_SOCKET_KEEPALIVE_IDLE_SEC; /* 180 sec idle before start sending probes */
setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
const int interval = HOMEKIT_SOCKET_KEEPALIVE_INTERVAL_SEC; /* 30 sec between probes */
setsockopt(s, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
const int maxpkt = HOMEKIT_SOCKET_KEEPALIVE_IDLE_COUNT; /* Drop connection after 4 probes without response */
setsockopt(s, IPPROTO_TCP, TCP_KEEPCNT, &maxpkt, sizeof(maxpkt));
wifiClient->setNoDelay(true);
//wifiClient->setSync(false);
wifiClient->setTimeout(HOMEKIT_SOCKET_TIMEOUT);
client_context_t *context = client_context_new(wifiClient);
context->server = server;
context->socket = wifiClient;
context->next = server->clients;
server->clients = context;
server->nfds++;
HOMEKIT_NOTIFY_EVENT(server, HOMEKIT_EVENT_CLIENT_CONNECTED);
return context;
}
//设备向iPhone传递characteristic的消息
void homekit_server_process_notifications(homekit_server_t *server) {
client_context_t *context = server->clients;
// 把characteristic_event_t拼接成client_event_t链表
// 按照Apple的规定,Nofiy消息需合并发送
while (context) {
if (context->step != HOMEKIT_CLIENT_STEP_PAIR_VERIFY_2OF2) {
// Do not send event when the client is not verify over.
context = context->next;
continue;
}
characteristic_event_t *event = NULL;
if (context->event_queue && q_pop(context->event_queue, &event)) {
// Get and coalesce all client events
client_event_t *events_head = (client_event_t*) malloc(sizeof(client_event_t));
events_head->characteristic = event->characteristic;
homekit_value_copy(&events_head->value, &event->value);
events_head->next = NULL;
homekit_value_destruct(&event->value);
free(event);
client_event_t *events_tail = events_head;
while (q_pop(context->event_queue, &event)) {
//q_pop第二个参数必须传指针的地址
//event = context->event_queue->shift();
client_event_t *e = events_head;
while (e) {
if (e->characteristic == event->characteristic) {
break;
}
e = e->next;
}
if (e) {
homekit_value_destruct(&e->value);
} else {
e = (client_event_t*) malloc(sizeof(client_event_t));
e->characteristic = event->characteristic;
e->next = NULL;
events_tail->next = e;
events_tail = e;
}
homekit_value_copy(&e->value, &event->value);
homekit_value_destruct(&event->value);
free(event);
}
send_client_events(context, events_head);
client_event_t *e = events_head;
while (e) {
client_event_t *next = e->next;
homekit_value_destruct(&e->value);
free(e);
e = next;
}
}
context = context->next;
}
}
bool homekit_client_need_process_data(client_context_t *context) {
if (context) {
return (context->step >= HOMEKIT_CLIENT_STEP_PAIR_SETUP_1OF3
&& context->step < HOMEKIT_CLIENT_STEP_PAIR_VERIFY_2OF2);
}
return false;
}
//run in loop, include {accept_client, client_process, notifications}
void homekit_server_process(homekit_server_t *server) {
homekit_server_accept_client(server);
client_context_t *context = server->clients;
while (context) {
//homekit_client_process includes {handle data and stop disconnected client}
// do{
// if(homekit_client_need_process_data(context)){
// CLIENT_INFO(context, "Step is %d", context->step);
// }
// delay(10);
homekit_client_process(context);
// } while(homekit_client_need_process_data(context));
context = context->next;
}
homekit_server_process_notifications(server);
}
//=====================================================
// Arduino ESP8266 MDNS: call this funciton only once when WiFi STA is connected!
//=====================================================
bool homekit_mdns_started = false;
void homekit_on_config_number_changed() {
if (!running_server) {
return;
}
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "c#",
String(running_server->config->config_number).c_str());
}
void homekit_on_paired_status_changed() {
if (!running_server) {
return;
}
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "sf",
(running_server->paired) ? "0" : "1");
}
void homekit_mdns_init(homekit_server_t *server) {
INFO("Configuring MDNS");
//ESP32
/*
if (!WiFi.isConnected()) {
return;
}
IPAddress staIP = WiFi.localIP();
if (!staIP.isSet()) {
return;
}*/
homekit_accessory_t *accessory = server->config->accessories[0];
homekit_service_t *accessory_info = homekit_service_by_type(accessory,
HOMEKIT_SERVICE_ACCESSORY_INFORMATION);
if (!accessory_info) {
ERROR("Invalid accessory declaration: no Accessory Information service");
return;
}
homekit_characteristic_t *name = homekit_service_characteristic_by_type(accessory_info,
HOMEKIT_CHARACTERISTIC_NAME);
if (!name) {
ERROR("Invalid accessory declaration: " "no Name characteristic in AccessoryInfo service");
return;
}
homekit_characteristic_t *model = homekit_service_characteristic_by_type(accessory_info,
HOMEKIT_CHARACTERISTIC_MODEL);
if (!model) {
ERROR("Invalid accessory declaration: " "no Model characteristic in AccessoryInfo service");
return;
}
if (homekit_mdns_started) {
//MDNS.close();
//MDNS.begin(name->value.string_value, staIP);
//INFO("MDNS restart: %s, IP: %s", name->value.string_value, staIP.toString().c_str());
//MDNS.announce();
return;
}
//homekit_mdns_configure_init(name->value.string_value, PORT);
//WiFi.hostname(name->value.string_value);
WiFi.setHostname(name->value.string_value); //ESP32
// Must specify the MDNS runs on the IP of STA
//MDNS.begin(name->value.string_value, staIP);//ESP32
MDNS.begin(name->value.string_value);
mdns_instance_name_set(name->value.string_value);
//INFO("MDNS begin: %s, IP: %s", name->value.string_value, staIP.toString().c_str());
INFO("MDNS begin: %s", name->value.string_value);
MDNS.addService(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, HOMEKIT_SERVER_PORT);
//MDNSResponder::hMDNSService mdns_service = MDNS.addService(name->value.string_value,
//HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_SERVICE, HOMEKIT_SERVER_PORT);
// Set a service specific callback for dynamic service TXT items.
// The callback is called, whenever service TXT items are needed for the given service.
// MDNS.setDynamicServiceTxtCallback(mdns_service,
// [](const MDNSResponder::hMDNSService p_hService) {
// DEBUG("MDNS call DynamicServiceTxtCallback");
// if (running_server) {
// MDNS.addDynamicServiceTxt(p_hService, "sf",
// (running_server->paired) ? "0" : "1");
// MDNS.addDynamicServiceTxt(p_hService, "c#",
// running_server->config->config_number);
// }
//
// }
// );
//DynamicServiceTxt for ESP32
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "sf",
(server->paired) ? "0" : "1");
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "c#",
String(server->config->config_number).c_str());
//Static Service Txt
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "md",
(const char*) model->value.string_value);
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "pv", "1.0");
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "id",
(const char*) server->accessory_id);
//"c#" is a DynamicServiceTxt
//Current configuration number. Required.
//Must update when an accessory, service, or characteristic is added or removed on the accessory server.
//Accessories must increment the config number after a firmware update.
//This must have a range of 1-65535 and wrap to 1 when it overflows.
//This value must persist across reboots, power cycles, etc.
//MDNS.addServiceTxt(mdns_service, "c#", String(server->config->config_number).c_str());
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "s#", "1");
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "ff", "0");
//"sf" is a DynamicServiceTxt
//MDNS.addServiceTxt(HAP_SERVICE, HOMEKIT_MDNS_PROTO, "sf", (server->paired) ? "0" : "1");
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "ci",
String(server->config->category).c_str());
/*
// accessory model name (required)
homekit_mdns_add_txt("md", "%s", model->value.string_value);
// protocol version (required)
homekit_mdns_add_txt("pv", "1.0");
// device ID (required)
// should be in format XX:XX:XX:XX:XX:XX, otherwise devices will ignore it
homekit_mdns_add_txt("id", "%s", server->accessory_id);
// current configuration number (required)
homekit_mdns_add_txt("c#", "%d", server->config->config_number);
// current state number (required)
homekit_mdns_add_txt("s#", "1");
// feature flags (required if non-zero)
// bit 0 - supports HAP pairing. required for all HomeKit accessories
// bits 1-7 - reserved
homekit_mdns_add_txt("ff", "0");
// status flags
// bit 0 - not paired
// bit 1 - not configured to join WiFi
// bit 2 - problem detected on accessory
// bits 3-7 - reserved
homekit_mdns_add_txt("sf", "%d", (server->paired) ? 0 : 1);
// accessory category identifier
homekit_mdns_add_txt("ci", "%d", server->config->category);*/
if (server->config->setupId) {
DEBUG("Accessory Setup ID = %s", server->config->setupId);
size_t data_size = strlen(server->config->setupId) + strlen(server->accessory_id) + 1;
char *data = (char*) malloc(data_size);
snprintf(data, data_size, "%s%s", server->config->setupId, server->accessory_id);
data[data_size - 1] = 0;
unsigned char shaHash[SHA512_DIGEST_SIZE];
wc_Sha512Hash((const unsigned char*) data, data_size - 1, shaHash);
free(data);
unsigned char encodedHash[9];
memset(encodedHash, 0, sizeof(encodedHash));
word32 len = sizeof(encodedHash);
base64_encode_((const unsigned char*) shaHash, 4, encodedHash);
MDNS.addServiceTxt(HOMEKIT_MDNS_SERVICE, HOMEKIT_MDNS_PROTO, "sh",
(const char*) encodedHash);
}
//MDNS.announce();
//MDNS.update();
homekit_mdns_started = true;
//INFO("MDNS ok! Open your \"Home\" app, click \"Add or Scan Accessory\""
// " and \"I Don't Have a Code\". \nThis Accessory will show on your iOS device.");
}
// Used to update the config_number ("c#" value of Bonjour)
// Call this function when an accessory, service, or characteristic is added or removed on the accessory server.
// See the official HAP specification for more information.
void homekit_update_config_number() {
if (!homekit_mdns_started) {
return;
}
if (!running_server) {
return;
}
// range of 1-65535
uint16_t c = running_server->config->config_number;
c = (c > 0 && c < 65535) ? (c + 1) : 1;
running_server->config->config_number = c;
//MDNS.announce();
//MDNS.update();
homekit_on_config_number_changed();
INFO("Update config_number to %u", c);
}
int homekit_accessory_id_generate(char *accessory_id) {
byte buf[6];
homekit_random_fill(buf, sizeof(buf));
snprintf(accessory_id, ACCESSORY_ID_SIZE + 1, "%02X:%02X:%02X:%02X:%02X:%02X", buf[0], buf[1],
buf[2], buf[3], buf[4], buf[5]);
INFO("Generated new accessory ID: %s", accessory_id);
return 0;
}
int homekit_accessory_key_generate(ed25519_key *key) {
int r = crypto_ed25519_generate(key);
if (r) {
ERROR("Failed to generate accessory key");
return r;
}
INFO("Generated new accessory key");
return 0;
}
void homekit_server_init(homekit_server_config_t *config) {
if (!config->accessories) {
ERROR("Error initializing HomeKit accessory server: " "accessories are not specified");
return;
}
if (!config->password && !config->password_callback) {
ERROR(
"Error initializing HomeKit accessory server: " "neither password nor password callback is specified");
return;
}
if (config->password) {
const char *p = config->password;
if (strlen(p) != 10
|| !(ISDIGIT(p[0]) && ISDIGIT(p[1]) && ISDIGIT(p[2]) && p[3] == '-' && ISDIGIT(p[4])
&& ISDIGIT(p[5]) && p[6] == '-' && ISDIGIT(p[7]) && ISDIGIT(p[8])
&& ISDIGIT(p[9]))) {
ERROR("Error initializing HomeKit accessory server: " "invalid password format");
return;
}
}
if (config->setupId) {
const char *p = config->setupId;
if (strlen(p) != 4
|| !(ISBASE36(p[0]) && ISBASE36(p[1]) && ISBASE36(p[2]) && ISBASE36(p[3]))) {
ERROR("Error initializing HomeKit accessory server: " "invalid setup ID format");
return;
}
}
homekit_accessories_init(config->accessories);
if (!config->config_number) {
config->config_number = config->accessories[0]->config_number;
if (!config->config_number) {
config->config_number = 1;
}
}
if (!config->category) {
config->category = config->accessories[0]->category;
}
homekit_server_t *server = server_new();
running_server = server;
server->config = config;
//homekit_server_task(server);
INFO("Starting server");
int r = homekit_storage_init();
if (r == 0) {
r = homekit_storage_load_accessory_id(server->accessory_id);
if (!r)
r = homekit_storage_load_accessory_key(&server->accessory_key);
}
if (r) {
if (r < 0) {
INFO("Resetting HomeKit storage");
homekit_storage_reset();
}
homekit_accessory_id_generate(server->accessory_id);
homekit_storage_save_accessory_id(server->accessory_id);
homekit_accessory_key_generate(&server->accessory_key);
homekit_storage_save_accessory_key(&server->accessory_key);
} else {
INFO("Using existing accessory ID: %s", server->accessory_id);
}
pairing_iterator_t pairing_it;
homekit_storage_pairing_iterator_init(&pairing_it);
pairing_t pairing;
while (!homekit_storage_next_pairing(&pairing_it, &pairing)) {
if (pairing.permissions & pairing_permissions_admin) {
INFO("Found admin pairing with %s, disabling pair setup", pairing.device_id);
server->paired = true;
break;
}
}
homekit_storage_pairing_iterator_done(&pairing_it);
if (!server->paired) {
if (!arduino_homekit_preinit(server)) {
ERROR("Error in arduino_homekit_preinit, please check and retry");
system_restart();
return;
}
}
homekit_mdns_init(server);
HOMEKIT_NOTIFY_EVENT(server, HOMEKIT_EVENT_SERVER_INITIALIZED);
homekit_server_process(server);
INFO("Init server over");
}
void homekit_server_reset() {
homekit_storage_reset();
}
bool homekit_is_paired() {
bool paired = false;
pairing_iterator_t pairing_it;
homekit_storage_pairing_iterator_init(&pairing_it);
pairing_t pairing;
while (!homekit_storage_next_pairing(&pairing_it, &pairing)) {
if (pairing.permissions & pairing_permissions_admin) {
paired = true;
break;
}
};
homekit_storage_pairing_iterator_done(&pairing_it);
return paired;
}
int homekit_get_accessory_id(char *buffer, size_t size) {
if (size < ACCESSORY_ID_SIZE + 1)
return -1;
int r = homekit_storage_load_accessory_id(buffer);
if (r)
return r;
return 0;
}
int homekit_get_setup_uri(const homekit_server_config_t *config, char *buffer, size_t buffer_size) {
static const char base36Table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (buffer_size < 20)
return -1;
if (!config->password)
return -1;
// TODO: validate password in case it is run beffore server is started
if (!config->setupId)
return -1;
// TODO: validate setupID in case it is run beffore server is started
homekit_accessory_t *accessory = homekit_accessory_by_id(config->accessories, 1);
if (!accessory)
return -1;
uint32_t setup_code = 0;
for (const char *s = config->password; *s; s++) {
if (ISDIGIT(*s)) {
setup_code = setup_code * 10 + *s - '0';
}
}
uint64_t payload = 0;
payload <<= 4; // reserved 4 bits
payload <<= 8;
payload |= accessory->category & 0xff;
payload <<= 4;
payload |= 2; // flags (2=IP, 4=BLE, 8=IP_WAC)
payload <<= 27;
payload |= setup_code & 0x7fffffff;
strcpy(buffer, "X-HM://");
buffer += 7;
for (int i = 8; i >= 0; i--) {
buffer[i] = base36Table[payload % 36];
payload /= 36;
}
buffer += 9;
strcpy(buffer, config->setupId);
buffer += 4;
buffer[0] = 0;
return 0;
}
// Pre-initialize the pairing_context used in Pair-Setep 1/3
// For avoiding timeout caused sockect disconnection from iOS device.
bool arduino_homekit_preinit(homekit_server_t *server) {
if (saved_preinit_pairing_context != nullptr) {
return true;
}
INFO("Preiniting pairing context");
DEBUG_TIME_BEGIN();
pairing_context_t *preinit_pairing_context = pairing_context_new();
DEBUG_HEAP();
char password[11];
if (server->config->password) {
strncpy(password, server->config->password, sizeof(password));
//CLIENT_DEBUG(context, "Using user-specified password: %s", password);
INFO("Using user-specified password: %s", password);
} else {
for (int i = 0; i < 10; i++) {
password[i] = homekit_random() % 10 + '0';
}
password[3] = password[6] = '-';
password[10] = 0;
//CLIENT_DEBUG(context, "Using random password: %s", password);
INFO("Using random password: %s", password);
}
if (server->config->password_callback) {
server->config->password_callback(password);
}
watchdog_disable_all();
watchdog_check_begin();
crypto_srp_init(preinit_pairing_context->srp, "Pair-Setup", password);
watchdog_check_end("crypto_srp_init"); // 6585ms
watchdog_enable_all();
delay(10);
if (preinit_pairing_context->public_key) {
free(preinit_pairing_context->public_key);
preinit_pairing_context->public_key = NULL;
}
preinit_pairing_context->public_key_size = 0;
crypto_srp_get_public_key(preinit_pairing_context->srp, NULL,
&preinit_pairing_context->public_key_size);
preinit_pairing_context->public_key = (byte*) malloc(preinit_pairing_context->public_key_size);
watchdog_disable_all();
watchdog_check_begin();
int r = crypto_srp_get_public_key(preinit_pairing_context->srp,
preinit_pairing_context->public_key, &preinit_pairing_context->public_key_size);
watchdog_check_end("crypto_srp_get_public_key"); // 3310ms
watchdog_enable_all();
delay(10);
if (r) {
//CLIENT_ERROR(context, "Failed to dump SPR public key (code %d)", r);
ERROR("Failed to dump SPR public key (code %d)", r);
pairing_context_free(preinit_pairing_context);
preinit_pairing_context = NULL;
// In preinit, we should not send response
// send_tlv_error_response(context, 2, TLVError_Unknown);
return false;
}
saved_preinit_pairing_context = preinit_pairing_context;
DEBUG_TIME_END("preinit");
INFO("Preinit pairing context success");
//MDNS.announce(); // update "paired" state
homekit_on_paired_status_changed();
return true;
}
void esp32_homekit_task(void *args) {
homekit_server_config_t *config = (homekit_server_config_t*) args;
homekit_server_init(config);
for (;;) {
if (running_server != nullptr) {
if (!running_server->paired) {
//If not paired or pairing was removed, preinit paring context.
arduino_homekit_preinit(running_server);
}
homekit_server_process(running_server);
}
vTaskDelay(10 / portTICK_PERIOD_MS);
}
}
void arduino_homekit_setup(homekit_server_config_t *config) {
//ESP32 use FreeRTOS-task
xTaskCreate(esp32_homekit_task, "HomeKit Server",
SERVER_TASK_STACK, config, 1, NULL);
/*
if (system_get_cpu_freq() != SYS_CPU_160MHZ) {
system_update_cpu_freq(SYS_CPU_160MHZ);
INFO("Update the CPU to run at 160MHz");
}*/
//homekit_server_init(config);
// The MDNS needs to be restarted when WiFi is connected to confirm the
// MDNS runs at the IPAddress of STA
// otherwise the iOS will not show the Accessory
/*
arduino_homekit_gotiphandler = WiFi.onStationModeGotIP([](WiFiEventStationModeGotIP gotip) {
INFO("WiFi connected, ip: %s, mask: %s, gw: %s",
gotip.ip.toString().c_str(), gotip.mask.toString().c_str(),
gotip.gw.toString().c_str());
if (running_server) {
homekit_mdns_init(running_server);
} else {
ERROR("running_server is NULL!");
}
});*/
}
void arduino_homekit_loop() {
DEBUG("No need to call arduino_homekit_loop in ESP32");
// if (homekit_mdns_started) {
// MDNS.update();
// }
// if (running_server != nullptr) {
// if (!running_server->paired) {
// //If not paired or pairing was removed, preinit paring context.
// arduino_homekit_preinit(running_server);
// }
// homekit_server_process(running_server);
// }
}
int arduino_homekit_connected_clients_count() {
if (running_server) {
return running_server->nfds;
}
return -1;
}
homekit_server_t* arduino_homekit_get_running_server() {
return running_server;
}
#endif
================================================
FILE: src/arduino_homekit_server_esp8266.cpp
================================================
#if defined(ESP8266)
#include <Arduino.h>
#include <esp_xpgm.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <LEAmDNS.h>
#include <WiFiServer.h>
#include <WiFiClient.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
#include <homekit/tlv.h>
#include <homekit/types.h>
#include <wolfssl/wolfcrypt/hash.h> //wc_sha512
#include "constants.h"
#include "base64.h"
#include "pairing.h"
#include "storage.h"
#include "query_params.h"
#include "json.h"
#include "homekit_debug.h"
#include "port.h"
#include "http_parser.h"
#include "query_params.h"
#include "cJSON.h"
#include "cQueue.h"
#include "crypto.h"
#include "watchdog.h"
#include "arduino_homekit_server.h"
#define HOMEKIT_SERVER_PORT 5556
#define HOMEKIT_MAX_CLIENTS 8
#define HOMEKIT_MDNS_SERVICE "hap"//"_hap"
#define HOMEKIT_MDNS_PROTO "tcp"//"_tcp"
#define HOMEKIT_EVENT_QUEUE_SIZE 4 //original is 20
#define HOMEKIT_SOCKET_TIMEOUT 500 //milliseconds
//#define TCP_DEFAULT_KEEPALIVE_IDLE_SEC 7200 // 2 hours
//#define TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC 75 // 75 sec
//#define TCP_DEFAULT_KEEPALIVE_COUNT 9 // fault after 9 failures
//const int idle = 180; /* 180 sec idle before start sending probes */
#define HOMEKIT_SOCKET_KEEPALIVE_IDLE_SEC 180
//const int interval = 30; /* 30 sec between probes */
#define HOMEKIT_SOCKET_KEEPALIVE_INTERVAL_SEC 30
//const int maxpkt = 4; /* Drop connection after 4 probes without response */
#define HOMEKIT_SOCKET_KEEPALIVE_IDLE_COUNT 4
// if 180 + 30 * 4 = 300 sec without socket response, disconected it.
// WiFiClient can not write big buff once.
// TCP_SND_BUF = (2 * TCP_MSS) = 1072. See lwipopts.h
// max(encrypted_chunk) = 512 + 8(chunk_info) + 18(chacha_info). See client_send_encrypted
#define HOMEKIT_JSONBUFFER_SIZE 512
#ifdef HOMEKIT_DEBUG
#define TLV_DEBUG(values) //tlv_debug(values)
#else
#define TLV_DEBUG(values)
#endif
#define CLIENT_DEBUG(client, message, ...) DEBUG("[Client %d] " message, client->socket, ##__VA_ARGS__)
#define CLIENT_INFO(client, message, ...) INFO("[Client %d] " message, client->socket, ##__VA_ARGS__)
#define CLIENT_ERROR(client, message, ...) ERROR("[Client %d] " message, client->socket, ##__VA_ARGS__)
client_context_t *current_client_context = NULL;
homekit_server_t *running_server = nullptr;
WiFiEventHandler arduino_homekit_gotiphandler;
#define HOMEKIT_NOTIFY_EVENT(server, event) \
if ((server)->config->on_event) \
(server)->config->on_event(event);
void client_context_free(client_context_t *c);
void pairing_context_free(pairing_context_t *context);
void homekit_server_close_client(homekit_server_t *server, client_context_t *context);
bool arduino_homekit_preinit(homekit_server_t *server);
homekit_server_t* server_new() {
homekit_server_t *server = (homekit_server_t*) malloc(sizeof(homekit_server_t));
server->wifi_server = new WiFiServer(HOMEKIT_SERVER_PORT);
server->wifi_server->begin();
server->wifi_server->setNoDelay(true);
DEBUG("WiFiServer begin at port: %d", HOMEKIT_SERVER_PORT);
//FD_ZERO(&server->fds);
//server->max_fd = 0;
server->nfds = 0;
server->config = NULL;
server->paired = false;
server->pairing_context = NULL;
server->clients = NULL;
return server;
}
void server_free(homekit_server_t *server) {
if (server->pairing_context)
pairing_context_free(server->pairing_context);
if (server->clients) {
client_context_t *client = server->clients;
while (client) {
client_context_t *next = client->next;
client_context_free(client);
client = next;
}
}
if (server->wifi_server) {
server->wifi_server->stop();
server->wifi_server->close();
delete server->wifi_server;
server->wifi_server = nullptr;
}
DEBUG("homekit_server_t delete WiFiServer at port: %d\n", HOMEKIT_SERVER_PORT);
if (server == running_server) {
running_server = NULL;
}
free(server);
}
void tlv_debug(const tlv_values_t *values) {
DEBUG("Got following TLV values:");
for (tlv_t *t = values->head; t; t = t->next) {
char *escaped_payload = binary_to_string(t->value, t->size);
DEBUG("Type %d value (%d bytes): %s", t->type, t->size, escaped_payload);
free(escaped_payload);
}
}
pair_verify_context_t* pair_verify_context_new() {
pair_verify_context_t *context = (pair_verify_context_t*) malloc(sizeof(pair_verify_context_t));
context->secret = NULL;
context->secret_size = 0;
context->session_key = NULL;
context->session_key_size = 0;
context->device_public_key = NULL;
context->device_public_key_size = 0;
context->accessory_public_key = NULL;
context->accessory_public_key_size = 0;
return context;
}
void pair_verify_context_free(pair_verify_context_t *context) {
if (context->secret)
free(context->secret);
if (context->session_key)
free(context->session_key);
if (context->device_public_key)
free(context->device_public_key);
if (context->accessory_public_key)
free(context->accessory_public_key);
free(context);
}
//==========================
// client_context new and free
//============================
client_context_t* client_context_new(WiFiClient *wifiClient) {
client_context_t *c = (client_context_t*) malloc(sizeof(client_context_t));
c->server = NULL;
c->endpoint_params = NULL;
c->data_size = sizeof(c->data);
c->data_available = 0;
c->body = NULL;
c->body_length = 0;
http_parser_init(&c->parser, HTTP_REQUEST);
c->parser.data = c;
c->pairing_id = -1;
c->encrypted = false;
c->count_reads = 0;
c->count_writes = 0;
c->disconnect = false;
//c->event_queue = xQueueCreate(20, sizeof(characteristic_event_t*));
c->event_queue = (Queue_t*) malloc(sizeof(Queue_t));
q_init(c->event_queue, sizeof(characteristic_event_t*),
HOMEKIT_EVENT_QUEUE_SIZE, LIFO, true);
c->verify_context = NULL;
c->next = NULL;
c->socket = wifiClient;
c->step = HOMEKIT_CLIENT_STEP_NONE;
c->error_write = false;
return c;
}
void client_context_free(client_context_t *c) {
if (c->verify_context)
pair_verify_context_free(c->verify_context);
if (c->event_queue) {
//c->event_queue->clear();
q_clean(c->event_queue);
q_kill(c->event_queue);
free(c->event_queue);
}
if (c->endpoint_params)
query_params_free(c->endpoint_params);
if (c->body)
free(c->body);
if (c->socket) {
c->socket->stop();
delete c->socket;
c->socket = nullptr;
}
free(c);
}
pairing_context_t *saved_preinit_pairing_context = nullptr;
pairing_context_t* pairing_context_new() {
pairing_context_t *context = (pairing_context_t*) malloc(sizeof(pairing_context_t));
context->srp = crypto_srp_new();
context->client = NULL;
context->public_key = NULL;
context->public_key_size = 0;
return context;
}
void pairing_context_free(pairing_context_t *context) {
if (context == saved_preinit_pairing_context) {
INFO("Free saved_preinit_pairing_context");
if (saved_preinit_pairing_context) {
saved_preinit_pairing_context = nullptr;
}
}
if (context->srp) {
crypto_srp_free(context->srp);
}
if (context->public_key) {
free(context->public_key);
}
free(context);
}
//=====================
//pairing context
//=====================
void client_notify_characteristic(homekit_characteristic_t *ch, homekit_value_t value,
void *client);
void write_characteristic_json(json_stream *json, client_context_t *client,
const homekit_characteristic_t *ch, characteristic_format_t format,
const homekit_value_t *value) {
json_string(json, "aid");
json_uint32(json, ch->service->accessory->id);
json_string(json, "iid");
json_uint32(json, ch->id);
if (format & characteristic_format_type) {
json_string(json, "type");
json_string(json, ch->type);
}
if (format & characteristic_format_perms) {
json_string(json, "perms");
json_array_start(json);
if (ch->permissions & homekit_permissions_paired_read)
json_string(json, "pr");
if (ch->permissions & homekit_permissions_paired_write)
json_string(json, "pw");
if (ch->permissions & homekit_permissions_notify)
json_string(json, "ev");
if (ch->permissions & homekit_permissions_additional_authorization)
json_string(json, "aa");
if (ch->permissions & homekit_permissions_timed_write)
json_string(json, "tw");
if (ch->permissions & homekit_permissions_hidden)
json_string(json, "hd");
json_array_end(json);
}
if ((format & characteristic_format_events) && (ch->permissions & homekit_permissions_notify)) {
bool events = homekit_characteristic_has_notify_callback(ch, client_notify_characteristic,
client);
json_string(json, "ev");
json_boolean(json, events);
}
if (format & characteristic_format_meta) {
if (ch->description) {
json_string(json, "description");
json_string(json, ch->description);
}
const char *format_str = NULL;
switch (ch->format) {
case homekit_format_bool:
format_str = "bool";
break;
case homekit_format_uint8:
format_str = "uint8";
break;
case homekit_format_uint16:
format_str = "uint16";
break;
case homekit_format_uint32:
format_str = "uint32";
break;
case homekit_format_uint64:
format_str = "uint64";
break;
case homekit_format_int:
format_str = "int";
break;
case homekit_format_float:
format_str = "float";
break;
case homekit_format_string:
format_str = "string";
break;
case homekit_format_tlv:
format_str = "tlv8";
break;
case homekit_format_data:
format_str = "data";
break;
}
if (format_str) {
json_string(json, "format");
json_string(json, format_str);
}
const char *unit_str = NULL;
switch (ch->unit) {
case homekit_unit_none:
break;
case homekit_unit_celsius:
unit_str = "celsius";
break;
case homekit_unit_percentage:
unit_str = "percentage";
break;
case homekit_unit_arcdegrees:
unit_str = "arcdegrees";
break;
case homekit_unit_lux:
unit_str = "lux";
break;
case homekit_unit_seconds:
unit_str = "seconds";
break;
}
if (unit_str) {
json_string(json, "unit");
json_string(json, unit_str);
}
if (ch->min_value) {
json_string(json, "minValue");
json_float(json, *ch->min_value);
}
if (ch->max_value) {
json_string(json, "maxValue");
json_float(json, *ch->max_value);
}
if (ch->min_step) {
json_string(json, "minStep");
json_float(json, *ch->min_step);
}
if (ch->max_len) {
json_string(json, "maxLen");
json_uint32(json, *ch->max_len);
}
if (ch->max_data_len) {
json_string(json, "maxDataLen");
json_uint32(json, *ch->max_data_len);
}
if (ch->valid_values.count) {
json_string(json, "valid-values");
json_array_start(json);
for (int i = 0; i < ch->valid_values.count; i++) {
json_uint16(json, ch->valid_values.values[i]);
}
json_array_end(json);
}
if (ch->valid_values_ranges.count) {
json_string(json, "valid-values-range");
json_array_start(json);
for (int i = 0; i < ch->valid_values_ranges.count; i++) {
json_array_start(json);
json_integer(json, ch->valid_values_ranges.ranges[i].start);
json_integer(json, ch->valid_values_ranges.ranges[i].end);
json_array_end(json);
}
json_array_end(json);
}
}
if (ch->permissions & homekit_permissions_paired_read) {
homekit_value_t v = value ? *value : ch->getter_ex ? ch->getter_ex(ch) : ch->value;
if (v.is_null) {
json_string(json, "value"); json_null(json);
} else if (v.format != ch->format) {
ERROR("Characteristic value format is different from characteristic format");
} else {
switch (v.format) {
case homekit_format_bool: {
json_string(json, "value");
json_boolean(json, v.bool_value);
break;
}
case homekit_format_uint8: {
json_string(json, "value");
json_uint8(json, v.uint8_value);
break;
}
case homekit_format_uint16: {
json_string(json, "value");
json_uint16(json, v.uint16_value);
break;
}
case homekit_format_uint32: {
json_string(json, "value");
json_uint32(json, v.uint32_value);
break;
}
case homekit_format_uint64: {
json_string(json, "value");
json_uint64(json, v.uint64_value);
break;
}
case homekit_format_int: {
json_string(json, "value");
json_integer(json, v.int_value);
break;
}
case homekit_format_float: {
json_string(json, "value");
json_float(json, v.float_value);
break;
}
case homekit_format_string: {
json_string(json, "value");
json_string(json, v.string_value);
break;
}
case homekit_format_tlv: {
json_string(json, "value");
if (!v.tlv_values) {
json_string(json, "");
} else {
size_t tlv_size = 0;
tlv_format(v.tlv_values, NULL, &tlv_size);
if (tlv_size == 0) {
json_string(json, "");
} else {
byte *tlv_data = (byte*) malloc(tlv_size);
tlv_format(v.tlv_values, tlv_data, &tlv_size);
size_t encoded_tlv_size = base64_encoded_size(tlv_data, tlv_size);
byte *encoded_tlv_data = (byte*) malloc(encoded_tlv_size + 1);
base64_encode_(tlv_data, tlv_size, encoded_tlv_data);
encoded_tlv_data[encoded_tlv_size] = 0;
json_string(json, (char*) encoded_tlv_data);
free(encoded_tlv_data);
free(tlv_data);
}
}
break;
}
case homekit_format_data: {
json_string(json, "value");
if (!v.data_value || v.data_size == 0) {
json_string(json, "");
} else {
size_t encoded_data_size = base64_encoded_size(v.data_value, v.data_size);
byte *encoded_data = (byte*) malloc(encoded_data_size + 1);
base64_encode_(v.data_value, v.data_size, encoded_data);
encoded_data[encoded_data_size] = 0;
json_string(json, (char*) encoded_data);
free(encoded_data);
}
break;
}
}
}
if (!value && ch->getter_ex) {
// called getter to get value, need to free it
homekit_value_destruct(&v);
}
}
}
void write(client_context_t *context, byte *data, int data_size) {
if ((!context) || (!context->socket) || (!context->socket->connected())) {
CLIENT_ERROR(context, "The socket is null! (or is closed)");
return;
}
if (context->error_write) {
CLIENT_ERROR(context, "Abort write data since error_write.");
return;
}
int write_size = context->socket->write(data, data_size);
CLIENT_DEBUG(context, "Sending data of size %d", data_size);
if (write_size != data_size) {
CLIENT_ERROR(context, "socket.write, data_size=%d, write_size=%d", data_size, write_size);
context->error_write = true;
// Error write when :
// 1. remote client is disconnected
// 2. data_size is larger than the tcp internal send buffer
// But We has limited the data_size to 538, and TCP_SND_BUF = 1072. (See the comments on HOMEKIT_JSONBUFFER_SIZE)
// So we believe here is disconnected.
context->disconnect = true;
homekit_server_close_client(context->server, context);
// We consider the socket is 'closed' when error in writing (eg. the remote client is disconnected, NO tcp ack receive).
// Closing the socket causes memory-leak if some data has not been sent (the write_buffer did not free)
// To fix this memory-leak, add tcp_abandon(_pcb, 0); in ClientContext.h of ESP8266WiFi-library.
}
}
int client_send_encrypted_(client_context_t *context,
byte *payload, size_t size) {
CLIENT_DEBUG(context, "Send encrypted of size %d", size);
// max(size) = HOMEKIT_JSONBUFFER_SIZE + chunk_info(8) = 512 + 8 = 520
if (!context || !context->encrypted)
return -1;
/*
HAP doc:
Each HTTP message is split into frames no larger than 1024 bytes.
Each frame has the following format:
<2:AAD for little endian length of encrypted data (n) in bytes>
<n:encrypted data according to AEAD algorithm, up to 1024 bytes>
<16:authTag according to AEAD algorithm>
Note by Wang Bin. 2020-03-07
*/
byte nonce[12];
memset(nonce, 0, sizeof(nonce));
byte encrypted[1024 + 18];
int payload_offset = 0;
while (payload_offset < size) {
size_t chunk_size = size - payload_offset;
if (chunk_size > 1024)
chunk_size = 1024;
byte aead[2] = { chunk_size % 256, chunk_size / 256 };
memcpy(encrypted, aead, 2);
byte i = 4;
int x = context->count_reads++;
while (x) {
nonce[i++] = x % 256;
x /= 256;
}
size_t available = sizeof(encrypted) - 2;
int r = crypto_chacha20poly1305_encrypt(context->read_key, nonce, aead, 2,
payload + payload_offset, chunk_size, encrypted + 2, &available);
if (r) {
ERROR("Failed to chacha encrypt payload (code %d)", r);
return -1;
}
payload_offset += chunk_size;
write(context, encrypted, available + 2);
}
return 0;
}
int client_decrypt_(client_context_t *context,
byte *payload, size_t payload_size, byte *decrypted, size_t *decrypted_size) {
if (!context || !context->encrypted)
return -1;
const size_t block_size = 1024 + 16 + 2;
size_t required_decrypted_size = payload_size / block_size * 1024;
if (payload_size % block_size > 0)
required_decrypted_size += payload_size % block_size - 16 - 2;
if (*decrypted_size < required_decrypted_size) {
*decrypted_size = required_decrypted_size;
return -2;
}
*decrypted_size = required_decrypted_size;
byte nonce[12];
memset(nonce, 0, sizeof(nonce));
int payload_offset = 0;
int decrypted_offset = 0;
while (payload_offset < payload_size) {
size_t chunk_size = payload[payload_offset] + payload[payload_offset + 1] * 256;
if (chunk_size + 18 > payload_size - payload_offset) {
// Unfinished chunk
break;
}
byte i = 4;
int x = context->count_writes++;
while (x) {
nonce[i++] = x % 256;
x /= 256;
}
size_t decrypted_len = *decrypted_size - decrypted_offset;
int r = crypto_chacha20poly1305_decrypt(context->write_key, nonce, payload + payload_offset,
2, payload + payload_offset + 2, chunk_size + 16, decrypted, &decrypted_len);
if (r) {
ERROR("Failed to chacha decrypt payload (code %d)", r);
return -1;
}
decrypted_offset += decrypted_len;
payload_offset += chunk_size + 18;
}
return payload_offset;
}
void client_notify_characteristic(homekit_characteristic_t *ch, homekit_value_t value,
void *context) {
client_context_t *client = (client_context_t*) context;
if (client->current_characteristic == ch && client->current_value
&& homekit_value_equal(client->current_value, &value)) {
// This value is set by this client, no need to send notification
CLIENT_DEBUG(client, "This value is set by this client, no need to send notification");
return;
}
CLIENT_INFO(client, "Got characteristic %d.%d change event",
ch->service->accessory->id, ch->id);
//DEBUG("Got characteristic %d.%d change event", ch->service->accessory->id, ch->id);
if (!client->event_queue) {
ERROR("Client has no event queue. Skipping notification");
return;
}
characteristic_event_t *event = (characteristic_event_t*) malloc(
sizeof(characteristic_event_t));
event->characteristic = ch;
homekit_value_copy(&event->value, &value);
DEBUG("Sending event to client %d", client->socket);
//xQueueSendToBack(client->event_queue, &event, 10);*/
//q_push第二个参数要传指针地址
q_push(client->event_queue, &event);
}
void client_send(client_context_t *context, byte *data, size_t data_size) {
CLIENT_DEBUG(context, "send data size=%d, encrypted=%s",
data_size, context->encrypted ? "true" : "false");
if (context->encrypted) {
int r = client_send_encrypted_(context, data, data_size);
if (r) {
CLIENT_ERROR(context, "Failed to encrypt response (code %d)", r);
return;
}
} else {
write(context, data, data_size);
}
}
void client_send_P(client_context_t *context, PGM_P pgm) {
XPGM_BUFFCPY_STRING(char, buff, pgm);
client_send(context, (byte*)buff, sizeof(buff) - 1);
}
void client_send_chunk(byte *data, size_t size, void *arg) {
client_context_t *context = (client_context_t*) arg;
size_t payload_size = size + 8;
byte *payload = (byte*) malloc(payload_size);
if (!payload) {
ERROR("Error malloc payload!! payload_size->%d", payload_size);
return;
}
int offset = snprintf((char*) payload, payload_size, "%x\r\n", size);
memcpy(payload + offset, data, size);
payload[offset + size] = '\r';
payload[offset + size + 1] = '\n';
CLIENT_DEBUG(context, "client_send_chunk, size=%d, offset=%d", size, offset);
client_send(context, payload, offset + size + 2);
free(payload);
}
void send_204_response(client_context_t *context) {
static const char PROGMEM response[] = "HTTP/1.1 204 No Content\r\n\r\n";
client_send_P(context, response);
}
void send_404_response(client_context_t *context) {
static const char PROGMEM response[] = "HTTP/1.1 404 Not Found\r\n\r\n";
client_send_P(context, response);
}
void send_client_events(client_context_t *context, client_event_t *events) {
CLIENT_DEBUG(context, "Sending EVENT");DEBUG_HEAP();
static const char PROGMEM http_headers[] = "EVENT/1.0 200 OK\r\n"
"Content-Type: application/hap+json\r\n"
"Transfer-Encoding: chunked\r\n\r\n";
client_send_P(context, http_headers);
// ~35 bytes per event JSON
// 256 should be enough for ~7 characteristic updates
json_stream *json = json_new(HOMEKIT_JSONBUFFER_SIZE, client_send_chunk, context);
json_object_start(json);
json_string(json, "characteristics");
json_array_start(json);
client_event_t *e = events;
while (e) {
json_object_start(json);
write_characteristic_json(json, context, e->characteristic, (characteristic_format_t) 0,
&e->value);
json_object_end(json);
e = e->next;
}
json_array_end(json);
json_object_end(json);
json_flush(json);
json_free(json);
client_send_chunk(NULL, 0, context);
}
void send_tlv_response(client_context_t *context, tlv_values_t *values);
void send_tlv_error_response(client_context_t *context, int state, TLVError error) {
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, state);
tlv_add_integer_value(response, TLVType_Error, 1, error);
send_tlv_response(context, response);
}
void send_tlv_response(client_context_t *context, tlv_values_t *values) {
CLIENT_DEBUG(context, "Sending TLV response");TLV_DEBUG(values);
size_t payload_size = 0;
tlv_format(values, NULL, &payload_size);
byte *payload = (byte*) malloc(payload_size);
int r = tlv_format(values, payload, &payload_size);
if (r) {
CLIENT_ERROR(context, "Failed to format TLV payload (code %d)", r);
free(payload);
return;
}
tlv_free(values);
static const char PROGMEM http_headers_pgm[] = "HTTP/1.1 200 OK\r\n"
"Content-Type: application/pairing+tlv8\r\n"
"Content-Length: %d\r\n"
"Connection: keep-alive\r\n\r\n";
XPGM_BUFFCPY_STRING(char, http_headers, http_headers_pgm);
int response_size = strlen(http_headers) + payload_size + 32;
char *response = (char*) malloc(response_size);
int response_len = snprintf(response, response_size, http_headers, payload_size);
if (response_size - response_len < payload_size + 1) {
CLIENT_ERROR(context, "Incorrect response buffer size %d: headers took %d, payload size %d",
response_size, response_len, payload_size);
free(response);
free(payload);
return;
}
memcpy(response + response_len, payload, payload_size);
response_len += payload_size;
free(payload);
client_send(context, (byte*) response, response_len);
free(response);
}
static const char PROGMEM json_200_response_headers_progmem[] = "HTTP/1.1 200 OK\r\n"
"Content-Type: application/hap+json\r\n"
"Transfer-Encoding: chunked\r\n"
"Connection: keep-alive\r\n\r\n";
static const char PROGMEM json_207_response_headers_progmem[] = "HTTP/1.1 207 Multi-Status\r\n"
"Content-Type: application/hap+json\r\n"
"Transfer-Encoding: chunked\r\n"
"Connection: keep-alive\r\n\r\n";
void send_json_response(client_context_t *context, int status_code, byte *payload,
size_t payload_size) {
CLIENT_DEBUG(context, "Sending JSON response");DEBUG_HEAP();
static const char PROGMEM http_headers_pgm[] = "HTTP/1.1 %d %s\r\n"
"Content-Type: application/hap+json\r\n"
"Content-Length: %d\r\n"
"Connection: keep-alive\r\n\r\n";
XPGM_BUFFCPY_STRING(char, http_headers, http_headers_pgm);
CLIENT_DEBUG(context, "Payload: %s", payload);
// Using PSTR and strcpy_P. Ref: ESP.getResetReason
//const char *status_text = "OK";
char status_text[32];
strcpy_P(status_text, PSTR("OK"));
switch (status_code) {
case 204:
strcpy_P(status_text, PSTR("No Content"));
break;
case 207:
strcpy_P(status_text, PSTR("Multi-Status"));
break;
case 400:
strcpy_P(status_text, PSTR("Bad Request"));
break;
case 404:
strcpy_P(status_text, PSTR("Not Found"));
break;
case 422:
strcpy_P(status_text, PSTR("Unprocessable Entity"));
break;
case 500:
strcpy_P(status_text, PSTR("Internal Server Error"));
break;
case 503:
strcpy_P(status_text, PSTR("Service Unavailable"));
break;
}
int response_size = strlen(http_headers) + payload_size + strlen(status_text) + 32;
char *response = (char*) malloc(response_size);
if (!response) {
CLIENT_ERROR(context, "Failed to allocate response buffer of size %d", response_size);
return;
}
int response_len = snprintf(response, response_size, http_headers, status_code, status_text,
payload_size);
if (response_size - response_len < payload_size + 1) {
CLIENT_ERROR(context, "Incorrect response buffer size %d: headers took %d, payload size %d",
response_size, response_len, payload_size);
free(response);
return;
}
memcpy(response + response_len, payload, payload_size);
response_len += payload_size;
response[response_len] = 0; // required for debug output
CLIENT_DEBUG(context, "Sending HTTP response: %s", response);
client_send(context, (byte*) response, response_len);
free(response);
}
void send_json_error_response(client_context_t *context, int status_code, HAPStatus status) {
byte buffer[32];
int size = snprintf((char*) buffer, sizeof(buffer), "{\"status\": %d}", status);
send_json_response(context, status_code, buffer, size);
}
homekit_client_id_t homekit_get_client_id() {
return (homekit_client_id_t) current_client_context;
}
bool homekit_client_is_admin() {
if (!current_client_context)
return false;
return current_client_context->permissions & pairing_permissions_admin;
}
int homekit_client_send(unsigned char *data, size_t size) {
if (!current_client_context)
return -1;
client_send(current_client_context, data, size);
return 0;
}
void homekit_server_on_identify(client_context_t *context) {
CLIENT_INFO(context, "Identify");DEBUG_HEAP();
if (context->server->paired) {
// Already paired
send_json_error_response(context, 400, HAPStatus_InsufficientPrivileges);
return;
}
send_204_response(context);
homekit_accessory_t *accessory = homekit_accessory_by_id(context->server->config->accessories,
1);
if (!accessory) {
return;
}
homekit_service_t *accessory_info = homekit_service_by_type(accessory,
HOMEKIT_SERVICE_ACCESSORY_INFORMATION);
if (!accessory_info) {
return;
}
homekit_characteristic_t *ch_identify = homekit_service_characteristic_by_type(accessory_info,
HOMEKIT_CHARACTERISTIC_IDENTIFY);
if (!ch_identify) {
return;
}
if (ch_identify->setter_ex) {
ch_identify->setter_ex(ch_identify, HOMEKIT_BOOL_CPP(true));
}
}
void homekit_server_on_pair_setup(client_context_t *context, const byte *data, size_t size) {
DEBUG("Pair Setup");DEBUG_HEAP();
DEBUG_TIME_BEGIN();
#ifdef HOMEKIT_OVERCLOCK_PAIR_SETUP
homekit_overclock_start();
#endif
// First set step=NONE, if pair-setup ok then set step=1or2or3
// (if pair-step error, the step is NONE)
context->step = HOMEKIT_CLIENT_STEP_NONE;
tlv_values_t *message = tlv_new();
tlv_parse(data, size, message);
TLV_DEBUG(message);
switch (tlv_get_integer_value(message, TLVType_State, -1)) {
case 1: {
CLIENT_INFO(context, "Pair Setup Step 1/3");DEBUG_HEAP();
if (context->server->paired) {
CLIENT_INFO(context, "Refusing to pair: already paired");
send_tlv_error_response(context, 2, TLVError_Unavailable);
break;
}
if (context->server->pairing_context) {
if (context->server->pairing_context->client != context) {
CLIENT_INFO(context, "Refusing to pair: another pairing in progress");
send_tlv_error_response(context, 2, TLVError_Busy);
break;
}
} else {
// arduino homekit preinit (create pairing_context)
if (!arduino_homekit_preinit(context->server)) {
CLIENT_ERROR(context, "Init pairing context error");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
if (saved_preinit_pairing_context == nullptr) {
CLIENT_ERROR(context, "The saved_preinit_pairing_context is NULL ?!");
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
context->server->pairing_context = saved_preinit_pairing_context; ///pairing_context_new();
context->server->pairing_context->client = context;
}
int r = 0;
size_t salt_size = 0;
crypto_srp_get_salt(context->server->pairing_context->srp, NULL, &salt_size);
byte *salt = (byte*) malloc(salt_size);
r = crypto_srp_get_salt(context->server->pairing_context->srp, salt, &salt_size);
if (r) {
CLIENT_ERROR(context, "Failed to get salt (code %d)", r);
free(salt);
pairing_context_free(context->server->pairing_context);
context->server->pairing_context = NULL;
send_tlv_error_response(context, 2, TLVError_Unknown);
break;
}
tlv_values_t *response = tlv_new();
tlv_add_value(response, TLVType_PublicKey, context->server->pairing_context->public_key,
context->server->pairing_context->public_key_size);
tlv_add_value(response, TLVType_Salt, salt, salt_size);
tlv_add_integer_value(response, TLVType_State, 1, 2);
free(salt);
send_tlv_response(context, response);
context->step = HOMEKIT_CLIENT_STEP_PAIR_SETUP_1OF3;
break;
}
case 3: {
CLIENT_INFO(context, "Pair Setup Step 2/3");DEBUG_HEAP();
tlv_t *device_public_key = tlv_get_value(message, TLVType_PublicKey);
if (!device_public_key) {
CLIENT_ERROR(context, "Invalid payload: no device public key");
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
tlv_t *proof = tlv_get_value(message, TLVType_Proof);
if (!proof) {
CLIENT_ERROR(context, "Invalid payload: no device proof");
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Computing SRP shared secret");
DEBUG_HEAP();
watchdog_disable_all();
watchdog_check_begin();
int r = crypto_srp_compute_key(context->server->pairing_context->srp,
device_public_key->value, device_public_key->size,
context->server->pairing_context->public_key,
context->server->pairing_context->public_key_size);
watchdog_check_end("crypto_srp_compute_key"); // 13479ms
watchdog_enable_all();
delay(10);
if (r) {
CLIENT_ERROR(context, "Failed to compute SRP shared secret (code %d)", r);
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
free(context->server->pairing_context->public_key);
context->server->pairing_context->public_key = NULL;
context->server->pairing_context->public_key_size = 0;
CLIENT_DEBUG(context, "Verifying peer's proof");
//watchdog_check_begin();
r = crypto_srp_verify(context->server->pairing_context->srp, proof->value, proof->size);
//watchdog_check_end("crypto_srp_verify");// 1ms
if (r) {
CLIENT_ERROR(context, "Failed to verify peer's proof (code %d)", r);
send_tlv_error_response(context, 4, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Generating own proof");
size_t server_proof_size = 0;
crypto_srp_get_proof(context->server->pairing_context->srp, NULL, &server_proof_size);
byte *server_proof = (byte*) malloc(server_proof_size);
//watchdog_check_begin();
r = crypto_srp_get_proof(context->server->pairing_context->srp, server_proof,
&server_proof_size);
//watchdog_check_end("crypto_srp_get_proof");// 1ms
tlv_values_t *response = tlv_new();
tlv_add_integer_value(response, TLVType_State, 1, 4);
tlv_add_value(response, TLVType_Proof, server_proof, server_proof_size);
free(server_proof);
send_tlv_response(context, response);
context->step = HOMEKIT_CLIENT_STEP_PAIR_SETUP_2OF3;
break;
}
case 5: {
CLIENT_INFO(context, "Pair Setup Step 3/3");DEBUG_HEAP();
int r;
byte shared_secret[HKDF_HASH_SIZE];
size_t shared_secret_size = sizeof(shared_secret);
CLIENT_DEBUG(context, "Calculating shared secret");
const char salt1[] = "Pair-Setup-Encrypt-Salt";
const char info1[] = "Pair-Setup-Encrypt-Info";
r = crypto_srp_hkdf(context->server->pairing_context->srp, (byte*) salt1, sizeof(salt1) - 1,
(byte*) info1, sizeof(info1) - 1, shared_secret, &shared_secret_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate shared secret (code %d)", r);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
tlv_t *tlv_encrypted_data = tlv_get_value(message, TLVType_EncryptedData);
if (!tlv_encrypted_data) {
CLIENT_ERROR(context, "Invalid payload: no encrypted data");
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Decrypting payload");
size_t decrypted_data_size = 0;
crypto_chacha20poly1305_decrypt(shared_secret, (byte*) "\x0\x0\x0\x0PS-Msg05", NULL, 0,
tlv_encrypted_data->value, tlv_encrypted_data->size,
NULL, &decrypted_data_size);
byte *decrypted_data = (byte*) malloc(decrypted_data_size);
// TODO: check malloc result
r = crypto_chacha20poly1305_decrypt(shared_secret, (byte*) "\x0\x0\x0\x0PS-Msg05", NULL, 0,
tlv_encrypted_data->value, tlv_encrypted_data->size, decrypted_data,
&decrypted_data_size);
if (r) {
CLIENT_ERROR(context, "Failed to decrypt data (code %d)", r);
free(decrypted_data);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
tlv_values_t *decrypted_message = tlv_new();
r = tlv_parse(decrypted_data, decrypted_data_size, decrypted_message);
if (r) {
CLIENT_ERROR(context, "Failed to parse decrypted TLV (code %d)", r);
tlv_free(decrypted_message);
free(decrypted_data);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
free(decrypted_data);
tlv_t *tlv_device_id = tlv_get_value(decrypted_message, TLVType_Identifier);
if (!tlv_device_id) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device identifier");
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
// TODO: check that tlv_device_id->size == 36
tlv_t *tlv_device_public_key = tlv_get_value(decrypted_message, TLVType_PublicKey);
if (!tlv_device_public_key) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device public key");
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
tlv_t *tlv_device_signature = tlv_get_value(decrypted_message, TLVType_Signature);
if (!tlv_device_signature) {
CLIENT_ERROR(context, "Invalid encrypted payload: no device signature");
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
CLIENT_DEBUG(context, "Importing device public key");
ed25519_key device_key;
crypto_ed25519_init(&device_key);
r = crypto_ed25519_import_public_key(&device_key, tlv_device_public_key->value,
tlv_device_public_key->size);
if (r) {
CLIENT_ERROR(context, "Failed to import device public Key (code %d)", r);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
byte device_x[HKDF_HASH_SIZE];
size_t device_x_size = sizeof(device_x);
CLIENT_DEBUG(context, "Calculating DeviceX");
const char salt2[] = "Pair-Setup-Controller-Sign-Salt";
const char info2[] = "Pair-Setup-Controller-Sign-Info";
r = crypto_srp_hkdf(context->server->pairing_context->srp, (byte*) salt2, sizeof(salt2) - 1,
(byte*) info2, sizeof(info2) - 1, device_x, &device_x_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate DeviceX (code %d)", r);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
size_t device_info_size = device_x_size + tlv_device_id->size + tlv_device_public_key->size;
byte *device_info = (byte*) malloc(device_info_size);
memcpy(device_info, device_x, device_x_size);
memcpy(device_info + device_x_size, tlv_device_id->value, tlv_device_id->size);
memcpy(device_info + device_x_size + tlv_device_id->size, tlv_device_public_key->value,
tlv_device_public_key->size);
CLIENT_DEBUG(context, "Verifying device signature");
r = crypto_ed25519_verify(&device_key, device_info, device_info_size,
tlv_device_signature->value, tlv_device_signature->size);
if (r) {
CLIENT_ERROR(context, "Failed to generate DeviceX (code %d)", r);
free(device_info);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
free(device_info);
r = homekit_storage_add_pairing((const char*) tlv_device_id->value, &device_key,
pairing_permissions_admin);
if (r) {
CLIENT_ERROR(context, "Failed to store pairing (code %d)", r);
tlv_free(decrypted_message);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
char *device_id = strndup((const char*) tlv_device_id->value, tlv_device_id->size);
INFO("Added pairing with %s", device_id);
free(device_id);
tlv_free(decrypted_message);
HOMEKIT_NOTIFY_EVENT(context->server, HOMEKIT_EVENT_PAIRING_ADDED);
CLIENT_DEBUG(context, "Exporting accessory public key");
size_t accessory_public_key_size = 0;
crypto_ed25519_export_public_key(&context->server->accessory_key, NULL,
&accessory_public_key_size);
byte *accessory_public_key = (byte*) malloc(accessory_public_key_size);
r = crypto_ed25519_export_public_key(&context->server->accessory_key, accessory_public_key,
&accessory_public_key_size);
if (r) {
CLIENT_ERROR(context, "Failed to export accessory public key (code %d)", r);
free(accessory_public_key);
send_tlv_error_response(context, 6, TLVError_Authentication);
break;
}
size_t accessory_id_size = sizeof(context->server->accessory_id) - 1;
size_t accessory_info_size = HKDF_HASH_SIZE + accessory_id_size + accessory_public_key_size;
byte *accessory_info = (byte*) malloc(accessory_info_size);
CLIENT_DEBUG(context, "Calculating AccessoryX");
size_t accessory_x_size = accessory_info_size;
const char salt3[] = "Pair-Setup-Accessory-Sign-Salt";
const char info3[] = "Pair-Setup-Accessory-Sign-Info";
r = crypto_srp_hkdf(context->server->pairing_context->srp, (byte*) salt3, sizeof(salt3) - 1,
(byte*) info3, sizeof(info3) - 1, accessory_info, &accessory_x_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate AccessoryX (code %d)", r);
free(accessory_info);
free(accessory_public_key);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
memcpy(accessory_info + accessory_x_size, context->server->accessory_id, accessory_id_size);
memcpy(accessory_info + accessory_x_size + accessory_id_size, accessory_public_key,
accessory_public_key_size);
CLIENT_DEBUG(context, "Generating accessory signature");DEBUG_HEAP();
size_t accessory_signature_size = 0;
crypto_ed25519_sign(&context->server->accessory_key, accessory_info, accessory_info_size,
NULL, &accessory_signature_size);
byte *accessory_signature = (byte*) malloc(accessory_signature_size);
r = crypto_ed25519_sign(&context->server->accessory_key, accessory_info,
accessory_info_size, accessory_signature, &accessory_signature_size);
if (r) {
CLIENT_ERROR(context, "Failed to generate accessory signature (code %d)", r);
free(accessory_signature);
free(accessory_public_key);
free(accessory_info);
send_tlv_error_response(context, 6, TLVError_Unknown);
break;
}
free(accessory_info);
tlv_values_t *response_message = tlv_new();
tlv_add_value(response_message, TLVType_Identifier, (byte*) context->server->accessory_id,
accessory_id_size);
tlv_add_value(response_message, TLVType_PublicKey, accessory_public_key,
accessory_public_key_size);
tlv_add_value(response_message, TLVType_Signature, accessory_signature,
accessory_signature_size);
free(accessory_public_key);
free(accessory_signature);
size_t response_data_size = 0;
TLV_DEBUG(response_message);
tlv_format(response_message, NULL, &response_data_size);
byte *response_data = (byte*) malloc(response_data_size);
r = tlv_format(response_message, response_data, &response_data_si
gitextract_em4h46tl/
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── examples/
│ └── ESP32_homekit_wolfssl_4_3_0/
│ ├── ESP32_homekit.ino
│ ├── ESPButton.h
│ └── builtin_led_accessory.c
├── library.json
├── library.properties
└── src/
├── accessories.c
├── arduino_homekit_server.h
├── arduino_homekit_server_esp32.cpp
├── arduino_homekit_server_esp8266.cpp
├── base64.c
├── base64.h
├── cJSON.c
├── cJSON.h
├── cQueue.c
├── cQueue.h
├── constants.h
├── crypto.c
├── crypto.h
├── esp_xpgm.h
├── homekit/
│ ├── characteristics.h
│ ├── homekit.h
│ ├── tlv.h
│ └── types.h
├── homekit_debug.c
├── homekit_debug.h
├── http_parser.c
├── http_parser.h
├── json.c
├── json.h
├── pairing.h
├── port.c
├── port.h
├── query_params.c
├── query_params.h
├── storage.c
├── storage.h
├── tlv.c
├── types.c
├── user_settings.h
├── watchdog.c
├── watchdog.h
├── wolfcrypt/
│ └── src/
│ ├── aes.c
│ ├── arc4.c
│ ├── asm.c
│ ├── asn.c
│ ├── blake2b.c
│ ├── blake2s.c
│ ├── camellia.c
│ ├── chacha.c
│ ├── chacha20_poly1305.c
│ ├── cmac.c
│ ├── coding.c
│ ├── compress.c
│ ├── cpuid.c
│ ├── cryptocb.c
│ ├── curve25519.c
│ ├── des3.c
│ ├── dh.c
│ ├── dsa.c
│ ├── ecc.c
│ ├── ecc_fp.c
│ ├── ed25519.c
│ ├── error.c
│ ├── evp.c
│ ├── fe_low_mem.c
│ ├── fe_operations.c
│ ├── ge_low_mem.c
│ ├── ge_operations.c
│ ├── hash.c
│ ├── hc128.c
│ ├── hmac.c
│ ├── idea.c
│ ├── integer.c
│ ├── logging.c
│ ├── md2.c
│ ├── md4.c
│ ├── md5.c
│ ├── memory.c
│ ├── misc.c
│ ├── pkcs12.c
│ ├── pkcs7.c
│ ├── poly1305.c
│ ├── port/
│ │ └── Espressif/
│ │ ├── README.md
│ │ ├── esp32_aes.c
│ │ ├── esp32_mp.c
│ │ ├── esp32_sha.c
│ │ └── esp32_util.c
│ ├── pwdbased.c.unused
│ ├── rabbit.c
│ ├── random.c
│ ├── ripemd.c
│ ├── rsa.c
│ ├── sha.c
│ ├── sha256.c
│ ├── sha3.c
│ ├── sha512.c
│ ├── signature.c
│ ├── sp_arm32.c
│ ├── sp_arm64.c
│ ├── sp_armthumb.c
│ ├── sp_c32.c
│ ├── sp_c64.c
│ ├── sp_cortexm.c
│ ├── sp_int.c
│ ├── sp_x86_64.c
│ ├── srp.c
│ ├── tfm.c
│ ├── wc_encrypt.c
│ ├── wc_pkcs11.c
│ ├── wc_port.c
│ ├── wolfevent.c
│ └── wolfmath.c
└── wolfssl/
├── version.h
└── wolfcrypt/
├── aes.h
├── arc4.h
├── asn.h
├── asn_public.h
├── blake2-impl.h
├── blake2-int.h
├── blake2.h
├── camellia.h
├── chacha.h
├── chacha20_poly1305.h
├── cmac.h
├── coding.h
├── compress.h
├── cpuid.h
├── cryptocb.h
├── curve25519.h
├── des3.h
├── dh.h
├── dsa.h
├── ecc.h
├── ed25519.h
├── error-crypt.h
├── fe_operations.h
├── fips_test.h
├── ge_operations.h
├── hash.h
├── hc128.h
├── hmac.h
├── idea.h
├── integer.h
├── logging.h
├── md2.h
├── md4.h
├── md5.h
├── mem_track.h
├── memory.h
├── misc.h
├── mpi_class.h
├── mpi_superclass.h
├── pkcs11.h
├── pkcs12.h
├── pkcs7.h
├── poly1305.h
├── port/
│ └── Espressif/
│ └── esp32-crypt.h
├── pwdbased.h
├── rabbit.h
├── random.h
├── ripemd.h
├── rsa.h
├── selftest.h
├── settings.h
├── sha.h
├── sha256.h
├── sha3.h
├── sha512.h
├── signature.h
├── sp.h
├── sp_int.h
├── srp.h
├── tfm.h
├── types.h
├── visibility.h
├── wc_encrypt.h
├── wc_pkcs11.h
├── wc_port.h
├── wolfevent.h
└── wolfmath.h
Showing preview only (484K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (4914 symbols across 154 files)
FILE: examples/ESP32_homekit_wolfssl_4_3_0/ESPButton.h
type ESPButtonEntry (line 31) | typedef struct _ESPButtonEntry {
type ESPButtonEvent (line 62) | enum ESPButtonEvent {
function class (line 72) | class ESPButtonClass {
function setCallback (line 115) | void setCallback(espbutton_callback _callback) {
function PGM_P (line 119) | PGM_P getButtonEventDescription(ESPButtonEvent e) {
function tick (line 132) | void tick() {
function loop (line 140) | void loop() {
function tickEntry (line 157) | void tickEntry(ESPButtonEntry *entry) {
function handleEntryChanged (line 190) | void handleEntryChanged(ESPButtonEntry *entry) {
function handleEntryUnchanged (line 226) | void handleEntryUnchanged(ESPButtonEntry *entry) {
function notifyEvent (line 252) | void notifyEvent(ESPButtonEntry *entry, ESPButtonEvent event) {
function _esp32_ticker_cb (line 269) | static void _esp32_ticker_cb(ESPButtonClass *esp_button) {
FILE: examples/ESP32_homekit_wolfssl_4_3_0/builtin_led_accessory.c
function led_set_power (line 25) | void led_set_power(bool on) {
function led_setter (line 35) | void led_setter(homekit_value_t value) {
function led_toggle (line 46) | void led_toggle() {
function led_blink_task (line 53) | void led_blink_task(void *_args) {
function led_blink (line 64) | void led_blink() {
function accessory_identify (line 68) | void accessory_identify(homekit_value_t _value) {
function accessory_init (line 106) | void accessory_init() {
FILE: src/accessories.c
function homekit_value_equal (line 5) | bool homekit_value_equal(homekit_value_t *a, homekit_value_t *b) {
function homekit_value_copy (line 58) | void homekit_value_copy(homekit_value_t *dst, homekit_value_t *src) {
function homekit_value_t (line 118) | homekit_value_t *homekit_value_clone(homekit_value_t *value) {
function homekit_value_destruct (line 124) | void homekit_value_destruct(homekit_value_t *value) {
function homekit_value_free (line 146) | void homekit_value_free(homekit_value_t *value) {
function align_size (line 152) | size_t align_size(size_t size) {
function homekit_characteristic_t (line 168) | homekit_characteristic_t* homekit_characteristic_clone(homekit_character...
function homekit_service_t (line 299) | homekit_service_t* homekit_service_clone(homekit_service_t* service) {
function homekit_accessory_t (line 355) | homekit_accessory_t* homekit_accessory_clone(homekit_accessory_t* ac) {
function homekit_value_t (line 388) | homekit_value_t homekit_characteristic_ex_old_getter(const homekit_chara...
function homekit_characteristic_ex_old_setter (line 393) | void homekit_characteristic_ex_old_setter(homekit_characteristic_t *ch, ...
function homekit_accessories_init (line 397) | void homekit_accessories_init(homekit_accessory_t **accessories) {
function homekit_accessory_t (line 442) | homekit_accessory_t *homekit_accessory_by_id(homekit_accessory_t **acces...
function homekit_service_t (line 453) | homekit_service_t *homekit_service_by_type(homekit_accessory_t *accessor...
function homekit_characteristic_t (line 464) | homekit_characteristic_t *homekit_service_characteristic_by_type(homekit...
function homekit_characteristic_t (line 475) | homekit_characteristic_t *homekit_characteristic_by_aid_and_iid(homekit_...
function homekit_characteristic_t (line 498) | homekit_characteristic_t *homekit_characteristic_find_by_type(homekit_ac...
function homekit_characteristic_notify (line 521) | void homekit_characteristic_notify(homekit_characteristic_t *ch, homekit...
function homekit_characteristic_add_notify_callback (line 530) | void homekit_characteristic_add_notify_callback(
function homekit_characteristic_remove_notify_callback (line 562) | void homekit_characteristic_remove_notify_callback(
function homekit_accessories_clear_notify_callbacks (line 594) | void homekit_accessories_clear_notify_callbacks(
function homekit_characteristic_has_notify_callback (line 615) | bool homekit_characteristic_has_notify_callback(
FILE: src/arduino_homekit_server.h
type homekit_client_step_t (line 26) | typedef enum {
type homekit_endpoint_t (line 38) | typedef enum {
type _client_context_t (line 50) | struct _client_context_t
type client_context_t (line 51) | typedef struct _client_context_t client_context_t;
type pairing_context_t (line 53) | typedef struct {
type pair_verify_context_t (line 61) | typedef struct {
type homekit_server_t (line 72) | typedef struct {
type characteristic_event_t (line 90) | typedef struct {
type _client_context_t (line 95) | struct _client_context_t {
type TLVType (line 137) | typedef enum {
type TLVMethod (line 161) | typedef enum {
type TLVError (line 169) | typedef enum {
type HAPStatus (line 182) | typedef enum {
type characteristic_format_t (line 210) | typedef enum {
type client_event_t (line 217) | typedef struct _client_event {
FILE: src/arduino_homekit_server_esp32.cpp
function homekit_server_t (line 80) | homekit_server_t* server_new() {
function server_free (line 96) | void server_free(homekit_server_t *server) {
function tlv_debug (line 121) | void tlv_debug(const tlv_values_t *values) {
function pair_verify_context_t (line 130) | pair_verify_context_t* pair_verify_context_new() {
function pair_verify_context_free (line 146) | void pair_verify_context_free(pair_verify_context_t *context) {
function client_context_t (line 165) | client_context_t* client_context_new(WiFiClient *wifiClient) {
function client_context_free (line 201) | void client_context_free(client_context_t *c) {
function pairing_context_t (line 229) | pairing_context_t* pairing_context_new() {
function pairing_context_free (line 238) | void pairing_context_free(pairing_context_t *context) {
function write_characteristic_json (line 261) | void write_characteristic_json(json_stream *json, client_context_t *client,
function write (line 524) | void write(client_context_t *context, byte *data, int data_size) {
function client_send_encrypted_ (line 552) | int client_send_encrypted_(client_context_t *context, byte *payload, siz...
function client_decrypt_ (line 606) | int client_decrypt_(client_context_t *context, byte *payload, size_t pay...
function client_notify_characteristic (line 658) | void client_notify_characteristic(homekit_characteristic_t *ch, homekit_...
function client_send (line 688) | void client_send(client_context_t *context, byte *data, size_t data_size) {
function client_send_P (line 704) | void client_send_P(client_context_t *context, PGM_P pgm) {
function client_send_chunk (line 710) | void client_send_chunk(byte *data, size_t size, void *arg) {
function send_204_response (line 729) | void send_204_response(client_context_t *context) {
function send_404_response (line 734) | void send_404_response(client_context_t *context) {
function send_client_events (line 739) | void send_client_events(client_context_t *context, client_event_t *event...
function send_tlv_error_response (line 775) | void send_tlv_error_response(client_context_t *context, int state, TLVEr...
function send_tlv_response (line 783) | void send_tlv_response(client_context_t *context, tlv_values_t *values) {
function send_json_response (line 837) | void send_json_response(client_context_t *context, int status_code, byte...
function send_json_error_response (line 904) | void send_json_error_response(client_context_t *context, int status_code...
function homekit_client_id_t (line 911) | homekit_client_id_t homekit_get_client_id() {
function homekit_client_is_admin (line 915) | bool homekit_client_is_admin() {
function homekit_client_send (line 922) | int homekit_client_send(unsigned char *data, size_t size) {
function homekit_server_on_identify (line 929) | void homekit_server_on_identify(client_context_t *context) {
function homekit_server_on_pair_setup (line 959) | void homekit_server_on_pair_setup(client_context_t *context, const byte ...
function homekit_server_on_pair_verify (line 1403) | void homekit_server_on_pair_verify(client_context_t *context, const byte...
function homekit_server_on_get_accessories (line 1783) | void homekit_server_on_get_accessories(client_context_t *context) {
function bool_endpoint_param (line 1862) | bool bool_endpoint_param(const char *name, client_context_t *context) {
function write_characteristic_error (line 1867) | void write_characteristic_error(json_stream *json, uint32_t aid, uint32_...
function homekit_server_on_get_characteristics (line 1878) | void homekit_server_on_get_characteristics(client_context_t *context) {
function HAPStatus (line 1992) | HAPStatus process_characteristics_update(const cJSON *j_ch, client_conte...
function homekit_server_on_update_characteristics (line 2357) | void homekit_server_on_update_characteristics(client_context_t *context,...
function homekit_server_on_pairings (line 2445) | void homekit_server_on_pairings(client_context_t *context, const byte *d...
function homekit_server_on_reset (line 2694) | void homekit_server_on_reset(client_context_t *context) {
function homekit_server_on_resource (line 2705) | void homekit_server_on_resource(client_context_t *context) {
function homekit_server_on_url (line 2719) | int homekit_server_on_url(http_parser *parser, const char *data, size_t ...
function homekit_server_on_body (line 2768) | int homekit_server_on_body(http_parser *parser, const char *data, size_t...
function homekit_server_on_message_complete (line 2779) | int homekit_server_on_message_complete(http_parser *parser) {
function http_parser_settings (line 2849) | http_parser_settings make_http_parser_settings() {
function homekit_client_process (line 2869) | void homekit_client_process(client_context_t *context) {
function homekit_server_close_client (line 2942) | void homekit_server_close_client(homekit_server_t *server, client_contex...
function client_context_t (line 2977) | client_context_t* homekit_server_accept_client(homekit_server_t *server) {
function homekit_server_process_notifications (line 3038) | void homekit_server_process_notifications(homekit_server_t *server) {
function homekit_client_need_process_data (line 3107) | bool homekit_client_need_process_data(client_context_t *context) {
function homekit_server_process (line 3116) | void homekit_server_process(homekit_server_t *server) {
function homekit_on_config_number_changed (line 3141) | void homekit_on_config_number_changed() {
function homekit_on_paired_status_changed (line 3149) | void homekit_on_paired_status_changed() {
function homekit_mdns_init (line 3157) | void homekit_mdns_init(homekit_server_t *server) {
function homekit_update_config_number (line 3311) | void homekit_update_config_number() {
function homekit_accessory_id_generate (line 3328) | int homekit_accessory_id_generate(char *accessory_id) {
function homekit_accessory_key_generate (line 3339) | int homekit_accessory_key_generate(ed25519_key *key) {
function homekit_server_init (line 3351) | void homekit_server_init(homekit_server_config_t *config) {
function homekit_server_reset (line 3451) | void homekit_server_reset() {
function homekit_is_paired (line 3455) | bool homekit_is_paired() {
function homekit_get_accessory_id (line 3473) | int homekit_get_accessory_id(char *buffer, size_t size) {
function homekit_get_setup_uri (line 3484) | int homekit_get_setup_uri(const homekit_server_config_t *config, char *b...
function arduino_homekit_preinit (line 3540) | bool arduino_homekit_preinit(homekit_server_t *server) {
function esp32_homekit_task (line 3614) | void esp32_homekit_task(void *args) {
function arduino_homekit_setup (line 3629) | void arduino_homekit_setup(homekit_server_config_t *config) {
function arduino_homekit_loop (line 3656) | void arduino_homekit_loop() {
function arduino_homekit_connected_clients_count (line 3670) | int arduino_homekit_connected_clients_count() {
function homekit_server_t (line 3677) | homekit_server_t* arduino_homekit_get_running_server() {
FILE: src/arduino_homekit_server_esp8266.cpp
function homekit_server_t (line 80) | homekit_server_t* server_new() {
function server_free (line 96) | void server_free(homekit_server_t *server) {
function tlv_debug (line 122) | void tlv_debug(const tlv_values_t *values) {
function pair_verify_context_t (line 131) | pair_verify_context_t* pair_verify_context_new() {
function pair_verify_context_free (line 147) | void pair_verify_context_free(pair_verify_context_t *context) {
function client_context_t (line 166) | client_context_t* client_context_new(WiFiClient *wifiClient) {
function client_context_free (line 202) | void client_context_free(client_context_t *c) {
function pairing_context_t (line 230) | pairing_context_t* pairing_context_new() {
function pairing_context_free (line 239) | void pairing_context_free(pairing_context_t *context) {
function write_characteristic_json (line 262) | void write_characteristic_json(json_stream *json, client_context_t *client,
function write (line 524) | void write(client_context_t *context, byte *data, int data_size) {
function client_send_encrypted_ (line 552) | int client_send_encrypted_(client_context_t *context,
function client_decrypt_ (line 607) | int client_decrypt_(client_context_t *context,
function client_notify_characteristic (line 659) | void client_notify_characteristic(homekit_characteristic_t *ch, homekit_...
function client_send (line 690) | void client_send(client_context_t *context, byte *data, size_t data_size) {
function client_send_P (line 706) | void client_send_P(client_context_t *context, PGM_P pgm) {
function client_send_chunk (line 711) | void client_send_chunk(byte *data, size_t size, void *arg) {
function send_204_response (line 730) | void send_204_response(client_context_t *context) {
function send_404_response (line 735) | void send_404_response(client_context_t *context) {
function send_client_events (line 740) | void send_client_events(client_context_t *context, client_event_t *event...
function send_tlv_error_response (line 776) | void send_tlv_error_response(client_context_t *context, int state, TLVEr...
function send_tlv_response (line 784) | void send_tlv_response(client_context_t *context, tlv_values_t *values) {
function send_json_response (line 838) | void send_json_response(client_context_t *context, int status_code, byte...
function send_json_error_response (line 905) | void send_json_error_response(client_context_t *context, int status_code...
function homekit_client_id_t (line 912) | homekit_client_id_t homekit_get_client_id() {
function homekit_client_is_admin (line 916) | bool homekit_client_is_admin() {
function homekit_client_send (line 923) | int homekit_client_send(unsigned char *data, size_t size) {
function homekit_server_on_identify (line 930) | void homekit_server_on_identify(client_context_t *context) {
function homekit_server_on_pair_setup (line 960) | void homekit_server_on_pair_setup(client_context_t *context, const byte ...
function homekit_server_on_pair_verify (line 1407) | void homekit_server_on_pair_verify(client_context_t *context, const byte...
function homekit_server_on_get_accessories (line 1790) | void homekit_server_on_get_accessories(client_context_t *context) {
function bool_endpoint_param (line 1869) | bool bool_endpoint_param(const char *name, client_context_t *context) {
function write_characteristic_error (line 1874) | void write_characteristic_error(json_stream *json, uint32_t aid, uint32_...
function homekit_server_on_get_characteristics (line 1885) | void homekit_server_on_get_characteristics(client_context_t *context) {
function HAPStatus (line 1999) | HAPStatus process_characteristics_update(const cJSON *j_ch, client_conte...
function homekit_server_on_update_characteristics (line 2363) | void homekit_server_on_update_characteristics(client_context_t *context,...
function homekit_server_on_pairings (line 2451) | void homekit_server_on_pairings(client_context_t *context, const byte *d...
function homekit_server_on_reset (line 2699) | void homekit_server_on_reset(client_context_t *context) {
function homekit_server_on_resource (line 2710) | void homekit_server_on_resource(client_context_t *context) {
function homekit_server_on_url (line 2724) | int homekit_server_on_url(http_parser *parser, const char *data, size_t ...
function homekit_server_on_body (line 2773) | int homekit_server_on_body(http_parser *parser, const char *data, size_t...
function homekit_server_on_message_complete (line 2784) | int homekit_server_on_message_complete(http_parser *parser) {
function http_parser_settings (line 2854) | http_parser_settings make_http_parser_settings() {
function homekit_client_process (line 2874) | void homekit_client_process(client_context_t *context) {
function homekit_server_close_client (line 2949) | void homekit_server_close_client(homekit_server_t *server, client_contex...
function client_context_t (line 2984) | client_context_t* homekit_server_accept_client(homekit_server_t *server) {
function homekit_server_process_notifications (line 3029) | void homekit_server_process_notifications(homekit_server_t *server) {
function homekit_client_need_process_data (line 3098) | bool homekit_client_need_process_data(client_context_t *context) {
function homekit_server_process (line 3107) | void homekit_server_process(homekit_server_t *server) {
function homekit_mdns_init (line 3132) | void homekit_mdns_init(homekit_server_t *server) {
function homekit_update_config_number (line 3267) | void homekit_update_config_number() {
function homekit_accessory_id_generate (line 3283) | int homekit_accessory_id_generate(char *accessory_id) {
function homekit_accessory_key_generate (line 3294) | int homekit_accessory_key_generate(ed25519_key *key) {
function homekit_server_init (line 3306) | void homekit_server_init(homekit_server_config_t *config) {
function homekit_server_reset (line 3407) | void homekit_server_reset() {
function homekit_is_paired (line 3411) | bool homekit_is_paired() {
function homekit_get_accessory_id (line 3429) | int homekit_get_accessory_id(char *buffer, size_t size) {
function homekit_get_setup_uri (line 3440) | int homekit_get_setup_uri(const homekit_server_config_t *config, char *b...
function arduino_homekit_preinit (line 3496) | bool arduino_homekit_preinit(homekit_server_t *server) {
function arduino_homekit_setup (line 3565) | void arduino_homekit_setup(homekit_server_config_t *config) {
function arduino_homekit_loop (line 3587) | void arduino_homekit_loop() {
function arduino_homekit_connected_clients_count (line 3600) | int arduino_homekit_connected_clients_count() {
function homekit_server_t (line 3607) | homekit_server_t* arduino_homekit_get_running_server() {
FILE: src/base64.c
function base64_encode_char (line 5) | unsigned char base64_encode_char(unsigned char c) {
function base64_decode_char (line 9) | unsigned char base64_decode_char(unsigned char c) {
function base64_encoded_size (line 26) | size_t base64_encoded_size(const unsigned char *data, size_t size) {
function base64_decoded_size (line 30) | size_t base64_decoded_size(const unsigned char *encoded_data, size_t enc...
function base64_encode_ (line 39) | int base64_encode_(const unsigned char* data, size_t size, unsigned char...
function base64_decode_ (line 64) | int base64_decode_(const unsigned char* encoded_data, size_t encoded_siz...
FILE: src/cJSON.c
type error (line 71) | typedef struct {
function cJSON_GetErrorPtr (line 77) | CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
function cJSON_GetStringValue (line 82) | CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item) {
function cJSON_Version (line 95) | CJSON_PUBLIC(const char*) cJSON_Version(void)
function case_insensitive_strcmp (line 104) | static int case_insensitive_strcmp(const unsigned char *string1, const u...
type internal_hooks (line 127) | typedef struct internal_hooks
function internal_free (line 140) | static void CJSON_CDECL internal_free(void *pointer)
function cJSON_InitHooks (line 180) | CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
function cJSON (line 212) | static cJSON *cJSON_New_Item(const internal_hooks * const hooks)
function cJSON_Delete (line 224) | CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
function get_decimal_point (line 248) | static unsigned char get_decimal_point(void)
type parse_buffer (line 258) | typedef struct
function cJSON_bool (line 276) | static cJSON_bool parse_number(cJSON * const item, parse_buffer * const ...
function cJSON_SetNumberHelper (line 353) | CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number)
type printbuffer (line 371) | typedef struct
function update_offset (line 471) | static void update_offset(printbuffer * const buffer)
function cJSON_bool (line 484) | static cJSON_bool compare_double(double a, double b)
function cJSON_bool (line 490) | static cJSON_bool print_number(const cJSON * const item, printbuffer * c...
function parse_hex4 (line 556) | static unsigned parse_hex4(const unsigned char * const input)
function utf16_literal_to_utf8 (line 593) | static unsigned char utf16_literal_to_utf8(const unsigned char * const i...
function cJSON_bool (line 714) | static cJSON_bool parse_string(cJSON * const item, parse_buffer * const ...
function cJSON_bool (line 843) | static cJSON_bool print_string_ptr(const unsigned char * const input, pr...
function cJSON_bool (line 965) | static cJSON_bool print_string(const cJSON * const item, printbuffer * c...
function parse_buffer (line 979) | static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer)
function parse_buffer (line 1000) | static parse_buffer *skip_utf8_bom(parse_buffer * const buffer)
function cJSON_ParseWithOpts (line 1016) | CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char ...
function cJSON_Parse (line 1096) | CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
function cJSON_Print (line 1168) | CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item)
function cJSON_PrintUnformatted (line 1173) | CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
function cJSON_PrintBuffered (line 1178) | CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffe...
function cJSON_PrintPreallocated (line 1208) | CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buff...
function cJSON_bool (line 1228) | static cJSON_bool parse_value(cJSON * const item, parse_buffer * const i...
function cJSON_bool (line 1283) | static cJSON_bool print_value(const cJSON * const item, printbuffer * co...
function cJSON_bool (line 1357) | static cJSON_bool parse_array(cJSON * const item, parse_buffer * const i...
function cJSON_bool (line 1451) | static cJSON_bool print_array(const cJSON * const item, printbuffer * co...
function cJSON_bool (line 1513) | static cJSON_bool parse_object(cJSON * const item, parse_buffer * const ...
function cJSON_bool (line 1622) | static cJSON_bool print_object(const cJSON * const item, printbuffer * c...
function cJSON_GetArraySize (line 1736) | CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
function cJSON (line 1759) | static cJSON* get_array_item(const cJSON *array, size_t index)
function cJSON_GetArrayItem (line 1778) | CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index)
function cJSON (line 1788) | static cJSON *get_object_item(const cJSON * const object, const char * c...
function cJSON_GetObjectItem (line 1820) | CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, co...
function cJSON_GetObjectItemCaseSensitive (line 1825) | CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * con...
function cJSON_HasObjectItem (line 1830) | CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const ...
function suffix_object (line 1836) | static void suffix_object(cJSON *prev, cJSON *item)
function cJSON (line 1843) | static cJSON *create_reference(const cJSON *item, const internal_hooks *...
function cJSON_bool (line 1864) | static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
function cJSON_AddItemToArray (line 1894) | CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item)
function cJSON_bool (line 1915) | static cJSON_bool add_item_to_object(cJSON * const object, const char * ...
function cJSON_AddItemToObject (line 1952) | CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *stri...
function cJSON_AddItemToObjectCS (line 1958) | CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *st...
function cJSON_AddItemReferenceToArray (line 1963) | CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
function cJSON_AddItemReferenceToObject (line 1973) | CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const c...
function cJSON_AddNullToObject (line 1983) | CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const c...
function cJSON_AddTrueToObject (line 1995) | CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const c...
function cJSON_AddFalseToObject (line 2007) | CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const ...
function cJSON_AddBoolToObject (line 2019) | CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const c...
function cJSON_AddNumberToObject (line 2031) | CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const...
function cJSON_AddStringToObject (line 2043) | CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const...
function cJSON_AddRawToObject (line 2055) | CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const ch...
function cJSON_AddObjectToObject (line 2067) | CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const...
function cJSON_AddArrayToObject (line 2079) | CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const ...
function cJSON_DetachItemViaPointer (line 2091) | CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * ...
function cJSON_DetachItemFromArray (line 2121) | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
function cJSON_DeleteItemFromArray (line 2131) | CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which)
function cJSON_DetachItemFromObject (line 2136) | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const ch...
function cJSON_DetachItemFromObjectCaseSensitive (line 2143) | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *obj...
function cJSON_DeleteItemFromObject (line 2150) | CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char ...
function cJSON_DeleteItemFromObjectCaseSensitive (line 2155) | CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object...
function cJSON_InsertItemInArray (line 2161) | CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSO...
function cJSON_ReplaceItemViaPointer (line 2190) | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const paren...
function cJSON_ReplaceItemInArray (line 2225) | CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJS...
function cJSON_bool (line 2235) | static cJSON_bool replace_item_in_object(cJSON *object, const char *stri...
function cJSON_ReplaceItemInObject (line 2255) | CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *...
function cJSON_ReplaceItemInObjectCaseSensitive (line 2260) | CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,...
function cJSON_CreateNull (line 2266) | CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
function cJSON_CreateTrue (line 2277) | CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
function cJSON_CreateFalse (line 2288) | CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
function cJSON_CreateBool (line 2299) | CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
function cJSON_CreateNumber (line 2310) | CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
function cJSON_CreateString (line 2336) | CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
function cJSON_CreateStringReference (line 2353) | CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
function cJSON_CreateObjectReference (line 2365) | CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
function cJSON_CreateArrayReference (line 2376) | CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
function cJSON_CreateRaw (line 2386) | CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
function cJSON_CreateArray (line 2403) | CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
function cJSON_CreateObject (line 2414) | CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void)
function cJSON_CreateIntArray (line 2426) | CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
function cJSON_CreateFloatArray (line 2461) | CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int c...
function cJSON_CreateDoubleArray (line 2497) | CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int...
function cJSON_CreateStringArray (line 2533) | CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings...
function cJSON_Duplicate (line 2570) | CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recu...
function skip_oneline_comment (line 2649) | static void skip_oneline_comment(char **input)
function skip_multiline_comment (line 2662) | static void skip_multiline_comment(char **input)
function minify_string (line 2676) | static void minify_string(char **input, char **output) {
function cJSON_Minify (line 2698) | CJSON_PUBLIC(void) cJSON_Minify(char *json)
function cJSON_IsInvalid (line 2746) | CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item)
function cJSON_IsFalse (line 2756) | CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item)
function cJSON_IsTrue (line 2766) | CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item)
function cJSON_IsBool (line 2777) | CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item)
function cJSON_IsNull (line 2786) | CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item)
function cJSON_IsNumber (line 2796) | CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item)
function cJSON_IsString (line 2806) | CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item)
function cJSON_IsArray (line 2816) | CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item)
function cJSON_IsObject (line 2826) | CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item)
function cJSON_IsRaw (line 2836) | CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item)
function cJSON_Compare (line 2846) | CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSO...
function cJSON_malloc (line 2971) | CJSON_PUBLIC(void *) cJSON_malloc(size_t size)
function cJSON_free (line 2976) | CJSON_PUBLIC(void) cJSON_free(void *object)
FILE: src/cJSON.h
type cJSON (line 103) | typedef struct cJSON
type cJSON_Hooks (line 125) | typedef struct cJSON_Hooks
type cJSON_bool (line 132) | typedef int cJSON_bool;
FILE: src/cQueue.c
function inc_idx (line 21) | static inline void __attribute__((nonnull, always_inline)) inc_idx(uint1...
function dec_idx (line 35) | static inline void __attribute__((nonnull, always_inline)) dec_idx(uint1...
function q_kill (line 63) | void __attribute__((nonnull)) q_kill(Queue_t * const q)
function q_flush (line 70) | void __attribute__((nonnull)) q_flush(Queue_t * const q)
function q_push (line 78) | bool __attribute__((nonnull)) q_push(Queue_t * const q, const void * con...
function q_pop (line 97) | bool __attribute__((nonnull)) q_pop(Queue_t * const q, void * const record)
function q_peek (line 120) | bool __attribute__((nonnull)) q_peek(const Queue_t * const q, void * con...
function q_drop (line 143) | bool __attribute__((nonnull)) q_drop(Queue_t * const q)
function q_peekIdx (line 155) | bool __attribute__((nonnull)) q_peekIdx(const Queue_t * const q, void * ...
FILE: src/cQueue.h
type QueueType (line 32) | typedef enum enumQueueType {
type Queue_t (line 41) | typedef struct Queue_t {
function q_isInitialized (line 82) | inline bool __attribute__((nonnull, always_inline)) q_isInitialized(cons...
function q_isEmpty (line 91) | inline bool __attribute__((nonnull, always_inline)) q_isEmpty(const Queu...
function q_isFull (line 100) | inline bool __attribute__((nonnull, always_inline)) q_isFull(const Queue...
function q_sizeof (line 108) | inline uint32_t __attribute__((nonnull, always_inline)) q_sizeof(const Q...
function q_getCount (line 115) | inline uint16_t __attribute__((nonnull, always_inline)) q_getCount(const...
function q_getRemainingCount (line 122) | inline uint16_t __attribute__((nonnull, always_inline)) q_getRemainingCo...
function q_peekPrevious (line 193) | inline bool __attribute__((nonnull, always_inline)) q_peekPrevious(const...
FILE: src/crypto.c
function wc_SrpSetKeyH (line 59) | int wc_SrpSetKeyH(Srp *srp, byte *secret, word32 size) {
function Srp (line 80) | Srp *crypto_srp_new() {
function crypto_srp_free (line 95) | void crypto_srp_free(Srp *srp) {
function crypto_srp_init (line 101) | int crypto_srp_init(Srp *srp, const char *username, const char *password) {
function crypto_srp_get_salt (line 156) | int crypto_srp_get_salt(Srp *srp, byte *buffer, size_t *buffer_size) {
function crypto_srp_get_public_key (line 171) | int crypto_srp_get_public_key(Srp *srp, byte *buffer, size_t *buffer_siz...
function crypto_srp_compute_key (line 189) | int crypto_srp_compute_key(
function crypto_srp_verify (line 208) | int crypto_srp_verify(Srp *srp, const byte *proof, size_t proof_size) {
function crypto_srp_get_proof (line 219) | int crypto_srp_get_proof(Srp *srp, byte *proof, size_t *proof_size) {
function crypto_hkdf (line 236) | int crypto_hkdf(
function crypto_srp_hkdf (line 265) | int crypto_srp_hkdf(
function crypto_chacha20poly1305_decrypt (line 280) | int crypto_chacha20poly1305_decrypt(
function crypto_chacha20poly1305_encrypt (line 310) | int crypto_chacha20poly1305_encrypt(
function crypto_ed25519_init (line 336) | int crypto_ed25519_init(ed25519_key *key) {
function ed25519_key (line 345) | ed25519_key *crypto_ed25519_new() {
function crypto_ed25519_free (line 356) | void crypto_ed25519_free(ed25519_key *key) {
function crypto_ed25519_generate (line 361) | int crypto_ed25519_generate(ed25519_key *key) {
function crypto_ed25519_import_key (line 377) | int crypto_ed25519_import_key(ed25519_key *key, const byte *data, size_t...
function crypto_ed25519_export_key (line 385) | int crypto_ed25519_export_key(const ed25519_key *key, byte *buffer, size...
function crypto_ed25519_import_public_key (line 400) | int crypto_ed25519_import_public_key(ed25519_key *key, const byte *data,...
function crypto_ed25519_export_public_key (line 404) | int crypto_ed25519_export_public_key(const ed25519_key *key, byte *buffe...
function crypto_ed25519_sign (line 421) | int crypto_ed25519_sign(
function crypto_ed25519_verify (line 447) | int crypto_ed25519_verify(
function crypto_curve25519_init (line 467) | int crypto_curve25519_init(curve25519_key *key) {
function crypto_curve25519_done (line 476) | void crypto_curve25519_done(curve25519_key *key) {
function crypto_curve25519_generate (line 484) | int crypto_curve25519_generate(curve25519_key *key) {
function crypto_curve25519_import_public (line 502) | int crypto_curve25519_import_public(curve25519_key *key, const byte *dat...
function crypto_curve25519_export_public (line 507) | int crypto_curve25519_export_public(const curve25519_key *key, byte *buf...
function crypto_curve25519_shared_secret (line 530) | int crypto_curve25519_shared_secret(const curve25519_key *private_key, c...
FILE: src/crypto.h
type byte (line 24) | typedef unsigned char byte;
type _Srp (line 36) | struct _Srp
type Srp (line 37) | typedef struct _Srp Srp;
FILE: src/homekit/homekit.h
type homekit_event_t (line 13) | typedef enum {
type homekit_server_config_t (line 25) | typedef struct {
FILE: src/homekit/tlv.h
type byte (line 14) | typedef unsigned char byte;
type tlv_t (line 16) | typedef struct _tlv {
type tlv_values_t (line 24) | typedef struct {
FILE: src/homekit/types.h
type homekit_format_t (line 13) | typedef enum {
type homekit_unit_t (line 26) | typedef enum {
type homekit_permissions_t (line 35) | typedef enum {
type homekit_accessory_category_t (line 44) | typedef enum {
type _homekit_accessory (line 78) | struct _homekit_accessory
type _homekit_service (line 79) | struct _homekit_service
type _homekit_characteristic (line 80) | struct _homekit_characteristic
type homekit_accessory_t (line 81) | typedef struct _homekit_accessory homekit_accessory_t;
type homekit_service_t (line 82) | typedef struct _homekit_service homekit_service_t;
type homekit_characteristic_t (line 83) | typedef struct _homekit_characteristic homekit_characteristic_t;
type homekit_value_t (line 86) | typedef struct {
type homekit_valid_values_t (line 160) | typedef struct {
type homekit_valid_values_range_t (line 166) | typedef struct {
type homekit_valid_values_ranges_t (line 172) | typedef struct {
type homekit_characteristic_change_callback_t (line 180) | typedef struct _homekit_characteristic_change_callback {
type _homekit_characteristic (line 190) | struct _homekit_characteristic {
type _homekit_service (line 220) | struct _homekit_service {
type _homekit_accessory (line 232) | struct _homekit_accessory {
FILE: src/homekit_debug.c
function print_binary (line 36) | void print_binary(const char *prompt, const byte *data, size_t size) {
FILE: src/homekit_debug.h
type byte (line 14) | typedef unsigned char byte;
FILE: src/http_parser.c
type state (line 279) | enum state
type header_states (line 363) | enum header_states
type http_host_state (line 393) | enum http_host_state
function parse_url_char (line 487) | static enum state
function http_parser_execute (line 635) | size_t http_parser_execute (http_parser *parser,
function http_message_needs_eof (line 2096) | int
function http_should_keep_alive (line 2119) | int
type http_method (line 2139) | enum http_method
function http_parser_init (line 2145) | void
function http_parser_settings_init (line 2156) | void
function http_parse_host_char (line 2176) | static enum http_host_state
function http_parse_host (line 2258) | static int
function http_parser_url_init (line 2340) | void
function http_parser_parse_url (line 2345) | int
function http_parser_pause (line 2449) | void
function http_body_is_final (line 2463) | int
function http_parser_version (line 2468) | unsigned long
FILE: src/http_parser.h
type __int8 (line 42) | typedef __int8 int8_t;
type __int16 (line 44) | typedef __int16 int16_t;
type __int32 (line 46) | typedef __int32 int32_t;
type __int64 (line 48) | typedef __int64 int64_t;
type http_parser (line 72) | typedef struct http_parser http_parser;
type http_parser_settings (line 73) | typedef struct http_parser_settings http_parser_settings;
type http_status (line 160) | enum http_status
type http_method (line 211) | enum http_method
type http_parser_type (line 223) | enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH }
type flags (line 227) | enum flags
type http_errno (line 291) | enum http_errno {
type http_parser (line 301) | struct http_parser {
type http_parser_settings (line 332) | struct http_parser_settings {
type http_parser_url_fields (line 349) | enum http_parser_url_fields
type http_parser_url (line 368) | struct http_parser_url {
type http_parser_type (line 391) | enum http_parser_type
type http_method (line 416) | enum http_method
type http_parser_url (line 425) | struct http_parser_url
type http_parser_url (line 430) | struct http_parser_url
FILE: src/json.c
type json_state (line 16) | typedef enum {
type json_nesting (line 27) | typedef enum {
type json_stream (line 32) | struct json_stream {
function json_stream (line 47) | json_stream *json_new(size_t buffer_size, json_flush_callback on_flush, ...
function json_free (line 60) | void json_free(json_stream *json) {
function json_flush (line 65) | void json_flush(json_stream *json) {
function json_write (line 74) | void json_write(json_stream *json, const char *format, ...) {
function json_object_start (line 99) | void json_object_start(json_stream *json) {
function json_object_end (line 121) | void json_object_end(json_stream *json) {
function json_array_start (line 151) | void json_array_start(json_stream *json) {
function json_array_end (line 173) | void json_array_end(json_stream *json) {
function _json_number (line 203) | void _json_number(json_stream *json, char *value) {
function json_uint8 (line 234) | void json_uint8(json_stream *json, uint8_t x) {
function json_uint16 (line 241) | void json_uint16(json_stream *json, uint16_t x) {
function json_uint32 (line 248) | void json_uint32(json_stream *json, uint32_t x) {
function json_uint64 (line 255) | void json_uint64(json_stream *json, uint64_t x) {
function json_integer (line 267) | void json_integer(json_stream *json, int x) {
function json_float (line 274) | void json_float(json_stream *json, float x) {
function json_string (line 281) | void json_string(json_stream *json, const char *x) {
function json_boolean (line 319) | void json_boolean(json_stream *json, bool x) {
function json_null (line 349) | void json_null(json_stream *json) {
FILE: src/json.h
type json_stream (line 9) | struct json_stream
type json_stream (line 10) | typedef struct json_stream json_stream;
FILE: src/pairing.h
type pairing_permissions_t (line 8) | typedef enum {
type pairing_t (line 12) | typedef struct {
FILE: src/port.c
function homekit_random (line 16) | uint32_t homekit_random() {
function homekit_random_fill (line 20) | void homekit_random_fill(uint8_t *data, size_t size) {
function homekit_system_restart (line 24) | void homekit_system_restart() {
function homekit_overclock_start (line 28) | void homekit_overclock_start() {
function homekit_overclock_end (line 32) | void homekit_overclock_end() {
function homekit_mdns_init (line 40) | void homekit_mdns_init() {
function homekit_mdns_configure_init (line 44) | void homekit_mdns_configure_init(const char *instance_name, int port) {
function homekit_mdns_add_txt (line 50) | void homekit_mdns_add_txt(const char *key, const char *format, ...) {
function homekit_mdns_configure_finalize (line 68) | void homekit_mdns_configure_finalize() {
function homekit_random (line 85) | uint32_t homekit_random() {
function homekit_random_fill (line 90) | void homekit_random_fill(uint8_t *data, size_t size) {
function homekit_system_restart (line 99) | void homekit_system_restart() {
function homekit_overclock_start (line 103) | void homekit_overclock_start() {
function homekit_overclock_end (line 107) | void homekit_overclock_end() {
function homekit_random (line 150) | uint32_t homekit_random() {
function homekit_random_fill (line 154) | void homekit_random_fill(uint8_t *data, size_t size) {
function homekit_system_restart (line 163) | void homekit_system_restart() {
function homekit_overclock_start (line 167) | void homekit_overclock_start() {
function homekit_overclock_end (line 171) | void homekit_overclock_end() {
function spiflash_init (line 178) | bool spiflash_init() {
function spiflash_erase_sector (line 226) | bool spiflash_erase_sector(size_t sector) {
function spiflash_write (line 231) | bool spiflash_write(size_t dest_addr, const void *src, size_t size) {
function spiflash_read (line 239) | bool spiflash_read(size_t src_addr, void *dest, size_t size) {
FILE: src/query_params.c
function query_param_t (line 6) | query_param_t *query_params_parse(const char *s) {
function query_param_t (line 41) | query_param_t *query_params_find(query_param_t *params, const char *name) {
function query_params_free (line 52) | void query_params_free(query_param_t *params) {
FILE: src/query_params.h
type query_param_t (line 8) | typedef struct _query_param {
FILE: src/storage.c
type pairing_data_t (line 90) | typedef struct {
function homekit_storage_init (line 100) | int homekit_storage_init() {
function homekit_storage_reset (line 141) | int homekit_storage_reset() {
function homekit_storage_save_accessory_id (line 154) | void homekit_storage_save_accessory_id(const char *accessory_id) {
function ishex (line 161) | static char ishex(unsigned char c) {
function homekit_storage_load_accessory_id (line 166) | int homekit_storage_load_accessory_id(char *data) {
function homekit_storage_save_accessory_key (line 186) | void homekit_storage_save_accessory_key(const ed25519_key *key) {
function homekit_storage_load_accessory_key (line 201) | int homekit_storage_load_accessory_key(ed25519_key *key) {
function homekit_storage_can_add_pairing (line 218) | bool homekit_storage_can_add_pairing() {
function compact_data (line 228) | static int compact_data() {
function find_empty_block (line 270) | static int find_empty_block() {
function homekit_storage_add_pairing (line 290) | int homekit_storage_add_pairing(const char *device_id, const ed25519_key...
function homekit_storage_update_pairing (line 326) | int homekit_storage_update_pairing(const char *device_id, byte permissio...
function homekit_storage_remove_pairing (line 365) | int homekit_storage_remove_pairing(const char *device_id) {
function homekit_storage_find_pairing (line 386) | int homekit_storage_find_pairing(const char *device_id, pairing_t *pairi...
function homekit_storage_pairing_iterator_init (line 414) | void homekit_storage_pairing_iterator_init(pairing_iterator_t *it) {
function homekit_storage_pairing_iterator_done (line 419) | void homekit_storage_pairing_iterator_done(pairing_iterator_t *iterator) {
function homekit_storage_next_pairing (line 423) | int homekit_storage_next_pairing(pairing_iterator_t *it, pairing_t *pair...
FILE: src/storage.h
type pairing_iterator_t (line 28) | typedef struct {
FILE: src/tlv.c
function tlv_values_t (line 7) | tlv_values_t *tlv_new() {
function tlv_free (line 14) | void tlv_free(tlv_values_t *values) {
function tlv_add_value_ (line 27) | int tlv_add_value_(tlv_values_t *values, byte type, byte *value, size_t ...
function tlv_add_value (line 47) | int tlv_add_value(tlv_values_t *values, byte type, const byte *value, si...
function tlv_add_string_value (line 56) | int tlv_add_string_value(tlv_values_t *values, byte type, const char *va...
function tlv_add_integer_value (line 60) | int tlv_add_integer_value(tlv_values_t *values, byte type, size_t size, ...
function tlv_add_tlv_value (line 71) | int tlv_add_tlv_value(tlv_values_t *values, byte type, tlv_values_t *val...
function tlv_t (line 87) | tlv_t *tlv_get_value(const tlv_values_t *values, byte type) {
function tlv_get_integer_value (line 98) | int tlv_get_integer_value(const tlv_values_t *values, byte type, int def) {
function tlv_values_t (line 122) | tlv_values_t *tlv_get_tlv_value(const tlv_values_t *values, byte type) {
function tlv_format (line 139) | int tlv_format(const tlv_values_t *values, byte *buffer, size_t *size) {
function tlv_parse (line 184) | int tlv_parse(const byte *buffer, size_t length, tlv_values_t *values) {
FILE: src/types.c
function homekit_value_t (line 7) | homekit_value_t HOMEKIT_DEFAULT_CPP() {
function homekit_value_t (line 13) | homekit_value_t HOMEKIT_NULL_CPP() {
function homekit_value_t (line 19) | homekit_value_t HOMEKIT_BOOL_CPP(bool value) {
function homekit_value_t (line 26) | homekit_value_t HOMEKIT_INT_CPP(uint8_t value) {
function homekit_value_t (line 33) | homekit_value_t HOMEKIT_UINT8_CPP(uint8_t value) {
function homekit_value_t (line 40) | homekit_value_t HOMEKIT_UINT16_CPP(uint16_t value) {
function homekit_value_t (line 47) | homekit_value_t HOMEKIT_UINT32_CPP(uint32_t value) {
function homekit_value_t (line 54) | homekit_value_t HOMEKIT_UINT64_CPP(uint64_t value) {
function homekit_value_t (line 61) | homekit_value_t HOMEKIT_FLOAT_CPP(float value) {
function homekit_value_t (line 68) | homekit_value_t HOMEKIT_STRING_CPP(char *value) {
function homekit_value_t (line 75) | homekit_value_t HOMEKIT_TLV_CPP(tlv_values_t *value) {
function homekit_value_t (line 82) | homekit_value_t HOMEKIT_DATA_CPP(uint8_t *value, size_t size) {
FILE: src/user_settings.h
function hwrand_generate_block (line 24) | static inline int hwrand_generate_block(uint8_t *buf, size_t len) {
function hwrand_generate_block (line 31) | static inline int hwrand_generate_block(uint8_t *buf, size_t len) {
FILE: src/watchdog.c
function esp_hw_wdt_enable (line 21) | void esp_hw_wdt_enable() {
function esp_hw_wdt_disable (line 25) | void esp_hw_wdt_disable() {
function esp_hw_wdt_feed (line 29) | void esp_hw_wdt_feed() {
function watchdog_disable_all (line 35) | void watchdog_disable_all() {
function watchdog_enable_all (line 40) | void watchdog_enable_all() {
function watchdog_check_begin (line 53) | void watchdog_check_begin() {
function watchdog_check_end (line 57) | void watchdog_check_end(const char *message) {
function watchdog_disable_all (line 63) | void watchdog_disable_all() {
function watchdog_enable_all (line 66) | void watchdog_enable_all() {
function watchdog_check_begin (line 69) | void watchdog_check_begin() {
function watchdog_check_end (line 72) | void watchdog_check_end(const char *message) {
FILE: src/wolfcrypt/src/aes.c
function wc_AesSetKey (line 58) | int wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
function wc_AesSetIV (line 67) | int wc_AesSetIV(Aes* aes, const byte* iv)
function wc_AesCbcEncrypt (line 76) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 85) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCtrEncrypt (line 99) | int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesEncryptDirect (line 111) | void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesDecryptDirect (line 117) | void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesSetKeyDirect (line 123) | int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
function wc_AesGcmSetKey (line 132) | int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
function wc_AesGcmEncrypt (line 140) | int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_AesGcmDecrypt (line 156) | int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_GmacSetKey (line 172) | int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
function wc_GmacUpdate (line 181) | int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
function wc_AesCcmSetKey (line 198) | int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
function wc_AesCcmEncrypt (line 202) | int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
function wc_AesCcmDecrypt (line 218) | int wc_AesCcmDecrypt(Aes* aes, byte* out,
function wc_AesInit (line 236) | int wc_AesInit(Aes* aes, void* h, int i)
function wc_AesFree (line 248) | void wc_AesFree(Aes* aes)
function wc_AesEncrypt (line 295) | static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesDecrypt (line 379) | static int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesEncrypt (line 485) | static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesDecrypt (line 490) | static int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesEncrypt (line 508) | static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesDecrypt (line 532) | static int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesEncrypt (line 562) | static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesDecrypt (line 571) | static int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesEncrypt (line 583) | static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesEncrypt (line 598) | static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function wc_AesDecrypt (line 605) | static int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
function Check_CPU_support_AES (line 635) | static int Check_CPU_support_AES(void)
function AES_CBC_encrypt (line 646) | void AES_CBC_encrypt(const unsigned char* in, unsigned char* out,
function wc_AesSetKey (line 1987) | int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetKeyDirect (line 2009) | int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetKey (line 2017) | int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetKeyDirect (line 2035) | int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetKey (line 2042) | int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byt...
function wc_AesSetKeyDirect (line 2109) | int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetKeyLocal (line 2128) | static int wc_AesSetKeyLocal(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetKeyDirect (line 2372) | int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
function wc_AesSetIV (line 2407) | int wc_AesSetIV(Aes* aes, const byte* iv)
function wc_AesEncryptDirect (line 2427) | void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesDecryptDirect (line 2440) | void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesEncryptDirect (line 2463) | void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesDecryptDirect (line 2472) | void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesEncryptDirect (line 2483) | void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesDecryptDirect (line 2489) | void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
function wc_AesCbcEncrypt (line 2503) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 2560) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcEncrypt (line 2621) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 2696) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcCrypt (line 2784) | static int wc_AesCbcCrypt(Aes* aes, byte* po, const byte* pi, word32 sz,
function wc_AesCbcEncrypt (line 2877) | int wc_AesCbcEncrypt(Aes* aes, byte* po, const byte* pi, word32 sz)
function wc_AesCbcDecrypt (line 2883) | int wc_AesCbcDecrypt(Aes* aes, byte* po, const byte* pi, word32 sz)
function wc_AesCbcEncrypt (line 2890) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 2917) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcEncrypt (line 2949) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 2977) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcEncrypt (line 3008) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 3030) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcEncrypt (line 3057) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 3061) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcEncrypt (line 3066) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 3070) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcEncrypt (line 3086) | int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCbcDecrypt (line 3184) | int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCtrEncryptBlock (line 3280) | int wc_AesCtrEncryptBlock(Aes* aes, byte* out, const byte* in)
function wc_AesCtrEncryptBlock (line 3397) | int wc_AesCtrEncryptBlock(Aes* aes, byte* out, const byte* in)
function wc_AesCtrEncrypt (line 3411) | int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function WC_INLINE (line 3460) | static WC_INLINE void IncrementAesCounter(byte* inOutCtr)
function wc_AesCtrEncrypt (line 3471) | int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function WC_INLINE (line 3542) | static WC_INLINE void IncCtr(byte* ctr, word32 ctrSz)
function WC_INLINE (line 3575) | static WC_INLINE void IncrementGcmCounter(byte* inOutCtr)
function WC_INLINE (line 3586) | static WC_INLINE void DecrementGcmCounter(byte* inOutCtr)
function WC_INLINE (line 3601) | static WC_INLINE void FlattenSzInBits(byte* buf, word32 sz)
function WC_INLINE (line 3619) | static WC_INLINE void RIGHTSHIFTX(byte* x)
function GenerateM0 (line 3639) | static void GenerateM0(Aes* aes)
function wc_AesGcmSetKey (line 3664) | int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
function __m128i (line 3994) | static __m128i gfmul_sw(__m128i a, __m128i b)
function gfmul_only (line 4044) | static void gfmul_only(__m128i a, __m128i b, __m128i* r0, __m128i* r1)
function __m128i (line 4066) | static __m128i gfmul_shl1(__m128i a)
function __m128i (line 4081) | static __m128i ghash_red(__m128i r0, __m128i r1)
function __m128i (line 4106) | static __m128i gfmul_shifted(__m128i a, __m128i b)
function __m128i (line 4114) | static __m128i gfmul8(__m128i a1, __m128i a2, __m128i a3, __m128i a4,
function AES_GCM_encrypt (line 4133) | static void AES_GCM_encrypt(const unsigned char *in,
function AES_GCM_decrypt (line 4573) | static void AES_GCM_decrypt(const unsigned char *in,
function GMULT (line 4907) | static void GMULT(byte* X, byte* Y)
function GHASH (line 4932) | void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
function GMULT (line 5056) | static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
function GHASH (line 5081) | void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
function GMULT (line 5138) | static void GMULT(word64* X, word64* Y)
function GHASH (line 5176) | void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
function GMULT (line 5282) | static void GMULT(word32* X, word32* Y)
function GHASH (line 5330) | void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
function wc_AesGcmEncrypt (line 5431) | int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_AesGcmEncrypt_STM32 (line 5464) | static int wc_AesGcmEncrypt_STM32(Aes* aes, byte* out, const byte* in, w...
function AES_GCM_encrypt_C (line 5654) | int AES_GCM_encrypt_C(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_AesGcmDecrypt (line 5865) | int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_AesGcmDecrypt_STM32 (line 5898) | static int wc_AesGcmDecrypt_STM32(Aes* aes, byte* out,
function AES_GCM_decrypt_C (line 6089) | int AES_GCM_decrypt_C(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_AesGcmSetExtIV (line 6318) | int wc_AesGcmSetExtIV(Aes* aes, const byte* iv, word32 ivSz)
function wc_AesGcmSetIV (line 6344) | int wc_AesGcmSetIV(Aes* aes, word32 ivSz,
function wc_AesGcmEncrypt_ex (line 6381) | int wc_AesGcmEncrypt_ex(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_Gmac (line 6417) | int wc_Gmac(const byte* key, word32 keySz, byte* iv, word32 ivSz,
function wc_GmacVerify (line 6445) | int wc_GmacVerify(const byte* key, word32 keySz,
function WOLFSSL_API (line 6486) | WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
function WOLFSSL_API (line 6495) | WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
function wc_AesCcmSetKey (line 6508) | int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
function wc_AesCcmEncrypt (line 6528) | int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
function wc_AesCcmDecrypt (line 6556) | int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
function roll_x (line 6593) | static void roll_x(Aes* aes, const byte* in, word32 inSz, byte* out)
function roll_auth (line 6611) | static void roll_auth(Aes* aes, const byte* in, word32 inSz, byte* out)
function WC_INLINE (line 6656) | static WC_INLINE void AesCcmCtrInc(byte* B, word32 lenSz)
function wc_AesCcmEncrypt (line 6667) | int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
function wc_AesCcmDecrypt (line 6736) | int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
function wc_AesCcmSetNonce (line 6832) | int wc_AesCcmSetNonce(Aes* aes, const byte* nonce, word32 nonceSz)
function wc_AesCcmEncrypt_ex (line 6855) | int wc_AesCcmEncrypt_ex(Aes* aes, byte* out, const byte* in, word32 sz,
function wc_AesInit (line 6900) | int wc_AesInit(Aes* aes, void* heap, int devId)
function wc_AesInit_Id (line 6941) | int wc_AesInit_Id(Aes* aes, unsigned char* id, int len, void* heap, int...
function wc_AesFree (line 6962) | void wc_AesFree(Aes* aes)
function wc_AesGetKeySize (line 6990) | int wc_AesGetKeySize(Aes* aes, word32* keySize)
function wc_AesEcbEncrypt (line 7040) | int wc_AesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesEcbDecrypt (line 7057) | int wc_AesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCfbEncrypt (line 7087) | int wc_AesCfbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_AesCfbDecrypt (line 7147) | int wc_AesCfbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function WC_INLINE (line 7201) | static WC_INLINE void InitKeyWrapCounter(byte* inOutCtr, word32 value)
function WC_INLINE (line 7214) | static WC_INLINE void IncrementKeyWrapCounter(byte* inOutCtr)
function WC_INLINE (line 7226) | static WC_INLINE void DecrementKeyWrapCounter(byte* inOutCtr)
function wc_AesKeyWrap (line 7237) | int wc_AesKeyWrap(const byte* key, word32 keySz, const byte* in, word32 ...
function wc_AesKeyUnWrap (line 7303) | int wc_AesKeyUnWrap(const byte* key, word32 keySz, const byte* in, word3...
function wc_AesXtsSetKey (line 7401) | int wc_AesXtsSetKey(XtsAes* aes, const byte* key, word32 len, int dir,
function wc_AesXtsFree (line 7442) | int wc_AesXtsFree(XtsAes* aes)
function wc_AesXtsEncryptSector (line 7465) | int wc_AesXtsEncryptSector(XtsAes* aes, byte* out, const byte* in,
function wc_AesXtsDecryptSector (line 7493) | int wc_AesXtsDecryptSector(XtsAes* aes, byte* out, const byte* in, word3...
function _AesXtsHelper (line 7511) | static int _AesXtsHelper(Aes* aes, byte* out, const byte* in, word32 sz,...
FILE: src/wolfcrypt/src/arc4.c
function wc_Arc4SetKey (line 35) | int wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
function WC_INLINE (line 73) | static WC_INLINE byte MakeByte(word32* x, word32* y, byte* s)
function wc_Arc4Process (line 87) | int wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
function wc_Arc4Init (line 117) | int wc_Arc4Init(Arc4* arc4, void* heap, int devId)
function wc_Arc4Free (line 138) | void wc_Arc4Free(Arc4* arc4)
FILE: src/wolfcrypt/src/asm.c
function word32 (line 83) | static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit) {
function WC_INLINE (line 111) | WC_INLINE static int set_cpuid_flags(void) {
FILE: src/wolfcrypt/src/asn.c
type Asn_Misc (line 128) | enum Asn_Misc {
function WOLFSSL_LOCAL (line 146) | WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len,
function WOLFSSL_LOCAL (line 154) | WOLFSSL_LOCAL int GetLength_ex(const byte* input, word32* inOutIdx, int*...
function GetASNTag (line 211) | int GetASNTag(const byte* input, word32* inOutIdx, byte* tag, word32 max...
function GetASNHeader_ex (line 231) | static int GetASNHeader_ex(const byte* input, byte tag, word32* inOutIdx...
function GetASNHeader (line 264) | static int GetASNHeader(const byte* input, byte tag, word32* inOutIdx, i...
function GetHeader (line 270) | static int GetHeader(const byte* input, byte* tag, word32* inOutIdx, int...
function WOLFSSL_LOCAL (line 289) | WOLFSSL_LOCAL int GetSequence(const byte* input, word32* inOutIdx, int* ...
function WOLFSSL_LOCAL (line 297) | WOLFSSL_LOCAL int GetSequence_ex(const byte* input, word32* inOutIdx, in...
function WOLFSSL_LOCAL (line 305) | WOLFSSL_LOCAL int GetSet(const byte* input, word32* inOutIdx, int* len,
function WOLFSSL_LOCAL (line 313) | WOLFSSL_LOCAL int GetSet_ex(const byte* input, word32* inOutIdx, int* len,
function GetASNNull (line 331) | static int GetASNNull(const byte* input, word32* inOutIdx, word32 maxIdx)
function SetASNNull (line 355) | static int SetASNNull(byte* output)
function GetBoolean (line 372) | static int GetBoolean(const byte* input, word32* inOutIdx, word32 maxIdx)
function SetBoolean (line 401) | static int SetBoolean(int val, byte* output)
function GetOctetString (line 422) | static int GetOctetString(const byte* input, word32* inOutIdx, int* len,
function GetASNInt (line 440) | static int GetASNInt(const byte* input, word32* inOutIdx, int* len,
function GetInteger7Bit (line 473) | static int GetInteger7Bit(const byte* input, word32* inOutIdx, word32 ma...
function SetASNInt (line 619) | static int SetASNInt(int len, byte firstByte, byte* output)
function SetASNIntMP (line 652) | static int SetASNIntMP(mp_int* n, int maxSz, byte* output)
function SetASNIntRSA (line 688) | static int SetASNIntRSA(void* n, byte* output)
function WOLFSSL_LOCAL (line 713) | WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx,
function WOLFSSL_LOCAL (line 740) | WOLFSSL_LOCAL int GetShortInt(const byte* input, word32* inOutIdx, int* ...
function WOLFSSL_LOCAL (line 777) | WOLFSSL_LOCAL int SetShortInt(byte* input, word32* inOutIdx, word32 numb...
function GetExplicitVersion (line 821) | static int GetExplicitVersion(const byte* input, word32* inOutIdx, int* ...
function GetInt (line 843) | int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx, word32 maxIdx)
function SkipInt (line 876) | static int SkipInt(const byte* input, word32* inOutIdx, word32 maxIdx)
function CheckBitString (line 893) | static int CheckBitString(const byte* input, word32* inOutIdx, int* len,
function word32 (line 959) | static word32 SetBitString(word32 len, byte unusedBits, byte* output)
function GetBerHeader (line 978) | static int GetBerHeader(const byte* data, word32* idx, word32 maxIdx,
type Indef (line 1020) | typedef struct Indef {
type IndefItems (line 1028) | typedef struct IndefItems
function IndefItems_HeaderLen (line 1038) | static int IndefItems_HeaderLen(IndefItems* items)
function word32 (line 1044) | static word32 IndefItems_Len(IndefItems* items)
function IndefItems_AddItem (line 1050) | static int IndefItems_AddItem(IndefItems* items, word32 start)
function IndefItems_AddData (line 1071) | static void IndefItems_AddData(IndefItems* items, word32 length)
function IndefItems_UpdateHeaderLen (line 1077) | static void IndefItems_UpdateHeaderLen(IndefItems* items)
function IndefItems_Up (line 1084) | static void IndefItems_Up(IndefItems* items)
function IndefItems_CalcLength (line 1099) | static void IndefItems_CalcLength(IndefItems* items)
function IndefItems_MoreData (line 1114) | static void IndefItems_MoreData(IndefItems* items, word32 length)
function wc_BerToDer (line 1133) | int wc_BerToDer(const byte* ber, word32 berSz, byte* der, word32* derSz)
function word32 (line 1361) | static word32 SetBitString16Bit(word16 val, byte* output)
function byte (line 1647) | const byte* OidFromId(word32 id, word32 type, word32* oidSz)
function EncodeObjectId (line 2229) | int EncodeObjectId(const word16* in, word32 inSz, byte* out, word32* outSz)
function DecodeObjectId (line 2305) | int DecodeObjectId(const byte* in, word32 inSz, word16* out, word32* outSz)
function GetASNObjectId (line 2353) | int GetASNObjectId(const byte* input, word32* inOutIdx, int* len,
function SetObjectId (line 2383) | int SetObjectId(int len, byte* output)
function GetObjectId (line 2393) | int GetObjectId(const byte* input, word32* inOutIdx, word32* oid,
function SkipObjectId (line 2476) | static int SkipObjectId(const byte* input, word32* inOutIdx, word32 maxIdx)
function WOLFSSL_LOCAL (line 2492) | WOLFSSL_LOCAL int GetAlgoId(const byte* input, word32* inOutIdx, word32*...
function wc_RsaPrivateKeyDecode (line 2530) | int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey* ...
function ToTraditionalInline_ex (line 2585) | int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz,
function ToTraditionalInline (line 2625) | int ToTraditionalInline(const byte* input, word32* inOutIdx, word32 sz)
function ToTraditional_ex (line 2633) | int ToTraditional_ex(byte* input, word32 sz, word32* algId)
function ToTraditional (line 2650) | int ToTraditional(byte* input, word32 sz)
function wc_GetPkcs8TraditionalOffset (line 2665) | int wc_GetPkcs8TraditionalOffset(byte* input, word32* inOutIdx, word32 sz)
function wc_CreatePKCS8Key (line 2705) | int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
function wc_CheckPrivateKey (line 2799) | int wc_CheckPrivateKey(byte* key, word32 keySz, DecodedCert* der)
function CheckAlgo (line 3001) | static int CheckAlgo(int first, int second, int* id, int* version, int* ...
function CheckAlgoV2 (line 3060) | static int CheckAlgoV2(int oid, int* id, int* blockSz)
function wc_GetKeyOID (line 3091) | int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32*...
function Pkcs8Pad (line 3179) | static int Pkcs8Pad(byte* buf, int sz, int blockSz)
function UnTraditionalEnc (line 3210) | int UnTraditionalEnc(byte* key, word32 keySz, byte* out, word32* outSz,
function GetAlgoV2 (line 3420) | static int GetAlgoV2(int encAlgId, const byte** oid, int *len, int* id,
function TraditionalEnc (line 3462) | int TraditionalEnc(byte* key, word32 keySz, byte* out, word32* outSz,
function ToTraditionalEnc (line 3647) | int ToTraditionalEnc(byte* input, word32 sz,const char* password,
function EncryptContent (line 3821) | int EncryptContent(byte* input, word32 inputSz, byte* out, word32* outSz,
function DecryptContent (line 4018) | int DecryptContent(byte* input, word32 sz,const char* password, int pass...
function RsaPublicKeyDecodeRawIndex (line 4176) | static int RsaPublicKeyDecodeRawIndex(const byte* input, word32* inOutIdx,
function wc_RsaPublicKeyDecode_ex (line 4250) | int wc_RsaPublicKeyDecode_ex(const byte* input, word32* inOutIdx, word32...
function wc_RsaPublicKeyDecode (line 4329) | int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
function wc_RsaPublicKeyDecodeRaw (line 4348) | int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
function wc_DhKeyDecode (line 4401) | int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, word...
function wc_DhParamsLoad (line 4417) | int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p, word32* pIn...
function DsaPublicKeyDecode (line 4459) | int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
function DsaPrivateKeyDecode (line 4482) | int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key,
function mp_int (line 4509) | static mp_int* GetDsaInt(DsaKey* key, int idx)
function WC_INLINE (line 4526) | static WC_INLINE void FreeTmpDsas(byte** tmps, void* heap)
function wc_DsaKeyToDer (line 4538) | int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen)
function InitDecodedCert (line 4609) | void InitDecodedCert(DecodedCert* cert,
function FreeAltNames (line 4638) | void FreeAltNames(DNS_entry* altNames, void* heap)
function FreeNameSubtrees (line 4653) | void FreeNameSubtrees(Base_entry* names, void* heap)
function FreeDecodedCert (line 4668) | void FreeDecodedCert(DecodedCert* cert)
function GetCertHeader (line 4706) | static int GetCertHeader(DecodedCert* cert)
function StoreRsaKey (line 4737) | static int StoreRsaKey(DecodedCert* cert, word32 bitStringEnd)
function CheckCurve (line 4764) | static int CheckCurve(word32 oid)
function GetKey (line 4780) | static int GetKey(DecodedCert* cert)
function WOLFSSL_LOCAL (line 4971) | WOLFSSL_LOCAL int wc_OBJ_sn2nid(const char *sn)
function CalcHashId (line 5013) | int CalcHashId(const byte* data, word32 len, byte* hash)
function GetName (line 5035) | static int GetName(DecodedCert* cert, int nameType, int maxIdx)
function WC_INLINE (line 5627) | static WC_INLINE int GetTime(int* value, const byte* date, int* idx)
function ExtractDate (line 5644) | int ExtractDate(const unsigned char* date, unsigned char format,
function GetTimeString (line 5676) | int GetTimeString(byte* date, int format, char* buf, int len)
function GetAsnTimeString (line 5725) | int GetAsnTimeString(void* currTime, byte* buf, word32 len)
function WOLFSSL_LOCAL (line 5813) | WOLFSSL_LOCAL int DateGreaterThan(const struct tm* a, const struct tm* b)
function WC_INLINE (line 5843) | static WC_INLINE int DateLessThan(const struct tm* a, const struct tm* b)
function ValidateDate (line 5850) | int ValidateDate(const byte* date, byte format, int dateType)
function wc_GetTime (line 5927) | int wc_GetTime(void* timePtr, word32 timeSize)
function GetDateInfo (line 5948) | static int GetDateInfo(const byte* source, word32* idx, const byte** pDate,
function GetDate (line 5984) | static int GetDate(DecodedCert* cert, int dateType, int verify, int maxIdx)
function GetValidity (line 6026) | static int GetValidity(DecodedCert* cert, int verify, int maxIdx)
function wc_GetDateInfo (line 6049) | int wc_GetDateInfo(const byte* certDate, int certDateSz, const byte** date,
function wc_GetDateAsCalendarTime (line 6063) | int wc_GetDateAsCalendarTime(const byte* date, int length, byte format,
function wc_GetCertDates (line 6074) | int wc_GetCertDates(Cert* cert, struct tm* before, struct tm* after)
function wc_GetPubX509 (line 6108) | int wc_GetPubX509(DecodedCert* cert, int verify, int* badDate)
function DecodeToKey (line 6142) | int DecodeToKey(DecodedCert* cert, int verify)
function GetSignature (line 6166) | static int GetSignature(DecodedCert* cert)
function word32 (line 6182) | static word32 SetOctetString8Bit(word32 len, byte* output)
function word32 (line 6189) | static word32 SetDigest(const byte* digest, word32 digSz, byte* output)
function word32 (line 6198) | static word32 BytePrecision(word32 value)
function WOLFSSL_LOCAL (line 6209) | WOLFSSL_LOCAL word32 SetLength(word32 length, byte* output)
function WOLFSSL_LOCAL (line 6234) | WOLFSSL_LOCAL word32 SetSequence(word32 len, byte* output)
function WOLFSSL_LOCAL (line 6241) | WOLFSSL_LOCAL word32 SetOctetString(word32 len, byte* output)
function WOLFSSL_LOCAL (line 6248) | WOLFSSL_LOCAL word32 SetSet(word32 len, byte* output)
function WOLFSSL_LOCAL (line 6254) | WOLFSSL_LOCAL word32 SetImplicit(byte tag, byte number, word32 len, byte...
function WOLFSSL_LOCAL (line 6262) | WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output)
function SetCurve (line 6271) | static int SetCurve(ecc_key* key, byte* output)
function WC_INLINE (line 6312) | static WC_INLINE int IsSigAlgoECDSA(int algoOID)
function WOLFSSL_LOCAL (line 6324) | WOLFSSL_LOCAL word32 SetAlgoID(int algoOID, byte* output, int type, int ...
function word32 (line 6365) | word32 wc_EncodeSignature(byte* out, const byte* digest, word32 digSz,
function wc_GetCTC_HashOID (line 6387) | int wc_GetCTC_HashOID(int type)
function InitSignatureCtx (line 6400) | void InitSignatureCtx(SignatureCtx* sigCtx, void* heap, int devId)
function FreeSignatureCtx (line 6409) | void FreeSignatureCtx(SignatureCtx* sigCtx)
function HashForSignature (line 6457) | static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
function ConfirmSignature (line 6546) | static int ConfirmSignature(SignatureCtx* sigCtx,
function MatchBaseName (line 6893) | static int MatchBaseName(int type, const char* name, int nameSz,
function ConfirmNameConstraints (line 6956) | static int ConfirmNameConstraints(Signer* signer, DecodedCert* cert)
function DecodeAltNames (line 7078) | static int DecodeAltNames(const byte* input, int sz, DecodedCert* cert)
function DecodeBasicCaConstraint (line 7340) | static int DecodeBasicCaConstraint(const byte* input, int sz, DecodedCer...
function DecodeCrlDist (line 7398) | static int DecodeCrlDist(const byte* input, int sz, DecodedCert* cert)
function DecodeAuthInfo (line 7490) | static int DecodeAuthInfo(const byte* input, int sz, DecodedCert* cert)
function DecodeAuthKeyId (line 7538) | static int DecodeAuthKeyId(const byte* input, int sz, DecodedCert* cert)
function DecodeSubjKeyId (line 7580) | static int DecodeSubjKeyId(const byte* input, int sz, DecodedCert* cert)
function DecodeKeyUsage (line 7609) | static int DecodeKeyUsage(const byte* input, int sz, DecodedCert* cert)
function DecodeExtKeyUsage (line 7628) | static int DecodeExtKeyUsage(const byte* input, int sz, DecodedCert* cert)
function DecodeSubtree (line 7687) | static int DecodeSubtree(const byte* input, int sz,
function DecodeNameConstraints (line 7755) | static int DecodeNameConstraints(const byte* input, int sz, DecodedCert*...
function DecodePolicyOID (line 7798) | int DecodePolicyOID(char *out, word32 outSz, const byte *in, word32 inSz)
function DecodeCertPolicy (line 7846) | static int DecodeCertPolicy(const byte* input, int sz, DecodedCert* cert)
function DecodeCertExtensions (line 7960) | static int DecodeCertExtensions(DecodedCert* cert)
function ParseCert (line 8197) | int ParseCert(DecodedCert* cert, int type, int verify, void* cm)
function Signer (line 8248) | Signer* GetCA(void* signers, byte* hash)
function Signer (line 8256) | Signer* GetCAByName(void* signers, byte* hash)
function Signer (line 8267) | static Signer* GetCABySubjectAndPubKey(DecodedCert* cert, void* cm)
function CheckCertSignature_ex (line 8294) | static int CheckCertSignature_ex(const byte* cert, word32 certSz, void* ...
function CheckCertSignaturePubKey (line 8589) | int CheckCertSignaturePubKey(const byte* cert, word32 certSz, void* heap,
function CheckCertSignature (line 8599) | int CheckCertSignature(const byte* cert, word32 certSz, void* heap, void...
function ParseCertRelative (line 8606) | int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm)
function Signer (line 8915) | Signer* MakeSigner(void* heap)
function FreeSigner (line 8929) | void FreeSigner(Signer* signer, void* heap)
function FreeSignerTable (line 8949) | void FreeSignerTable(Signer** table, int rows, void* heap)
function FreeTrustedPeer (line 8966) | void FreeTrustedPeer(TrustedPeerCert* tp, void* heap)
function FreeTrustedPeerTable (line 8991) | void FreeTrustedPeerTable(TrustedPeerCert** table, int rows, void* heap)
function WOLFSSL_LOCAL (line 9007) | WOLFSSL_LOCAL int SetMyVersion(word32 version, byte* output, int header)
function WOLFSSL_LOCAL (line 9026) | WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* out...
function WOLFSSL_LOCAL (line 9072) | WOLFSSL_LOCAL int GetSerialNumber(const byte* input, word32* inOutIdx,
function AllocDer (line 9108) | int AllocDer(DerBuffer** pDer, word32 length, int type, void* heap)
function FreeDer (line 9144) | void FreeDer(DerBuffer** pDer)
function wc_AllocDer (line 9162) | int wc_AllocDer(DerBuffer** pDer, word32 length, int type, void* heap)
function wc_FreeDer (line 9166) | void wc_FreeDer(DerBuffer** pDer)
function WC_INLINE (line 9219) | static WC_INLINE char* SkipEndOfLineChars(char* line, const char* endOfL...
function wc_PemGetHeaderFooter (line 9229) | int wc_PemGetHeaderFooter(int type, const char** header, const char** fo...
function wc_EncryptedInfoGet (line 9340) | int wc_EncryptedInfoGet(EncryptedInfo* info, const char* cipherInfo)
function wc_EncryptedInfoParse (line 9391) | int wc_EncryptedInfoParse(EncryptedInfo* info, char** pBuffer, size_t bu...
function wc_EncryptedInfoAppend (line 9495) | static int wc_EncryptedInfoAppend(char* dest, int destSz, char* cipherInfo)
function wc_DerToPem (line 9521) | int wc_DerToPem(const byte* der, word32 derSz,
function wc_DerToPemEx (line 9529) | int wc_DerToPemEx(const byte* der, word32 derSz, byte* output, word32 ou...
function PemToDer (line 9663) | int PemToDer(const unsigned char* buff, long longSz, int type,
function wc_PemToDer (line 9879) | int wc_PemToDer(const unsigned char* buff, long longSz, int type,
function WC_INLINE (line 9887) | static WC_INLINE int OurPasswordCb(char* passwd, int sz, int rw, void* u...
function wc_KeyPemToDer (line 9899) | int wc_KeyPemToDer(const unsigned char* pem, int pemSz,
function wc_CertPemToDer (line 9955) | int wc_CertPemToDer(const unsigned char* pem, int pemSz,
function wc_PubKeyPemToDer (line 10001) | int wc_PubKeyPemToDer(const unsigned char* pem, int pemSz,
function wc_PemCertToDer (line 10039) | int wc_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz)
function wc_PemPubKeyToDer (line 10119) | int wc_PemPubKeyToDer(const char* fileName,
function SetRsaPublicKey (line 10206) | static int SetRsaPublicKey(byte* output, RsaKey* key,
function wc_RsaPublicKeyDerSize (line 10347) | int wc_RsaPublicKeyDerSize(RsaKey* key, int with_header)
function mp_int (line 10405) | static mp_int* GetRsaInt(RsaKey* key, int idx)
function WC_INLINE (line 10429) | static WC_INLINE void FreeTmpRsas(byte** tmps, void* heap)
function wc_RsaKeyToDer (line 10442) | int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen)
function wc_RsaKeyToPublicDer (line 10515) | int wc_RsaKeyToPublicDer(RsaKey* key, byte* output, word32 inLen)
function wc_InitCert (line 10534) | int wc_InitCert(Cert* cert)
type DerCert (line 10589) | typedef struct DerCert {
function word32 (line 10643) | static word32 SetPrintableString(word32 len, byte* output)
function word32 (line 10649) | static word32 SetUTF8String(word32 len, byte* output)
function wc_SetCert_Free (line 10660) | static
function wc_SetCert_LoadDer (line 10679) | static int wc_SetCert_LoadDer(Cert* cert, const byte* der, word32 derSz)
function SetEccPublicKey (line 10719) | static int SetEccPublicKey(byte* output, ecc_key* key, int with_header)
function wc_EccPublicKeyToDer (line 10830) | int wc_EccPublicKeyToDer(ecc_key* key, byte* output, word32 inLen,
function wc_EccPublicKeyDerSize (line 10880) | int wc_EccPublicKeyDerSize(ecc_key* key, int with_AlgCurve)
function SetEd25519PublicKey (line 10891) | static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_...
function wc_Ed25519PublicKeyToDer (line 10958) | int wc_Ed25519PublicKeyToDer(ed25519_key* key, byte* output, word32 inLen,
function WC_INLINE (line 10995) | static WC_INLINE byte itob(int number)
function SetTime (line 11002) | static void SetTime(struct tm* date, byte* output)
function CopyValidity (line 11033) | static int CopyValidity(byte* output, Cert* cert)
function SetValidity (line 11054) | static int SetValidity(byte* output, int daysValid)
type EncodedName (line 11128) | typedef struct EncodedName {
function GetNameType (line 11182) | static char GetNameType(CertName* name, int idx)
function byte (line 11227) | static byte GetNameId(int idx)
function SetExtensions (line 11279) | static int SetExtensions(byte* out, word32 outSz, int *IdxInOut,
function SetExtensionsHeader (line 11295) | static int SetExtensionsHeader(byte* out, word32 outSz, int extSz)
function SetCa (line 11327) | static int SetCa(byte* out, word32 outSz)
function SetOidValue (line 11346) | static int SetOidValue(byte* out, word32 outSz, const byte *oid, word32 ...
function SetSKID (line 11373) | static int SetSKID(byte* output, word32 outSz, const byte *input, word32...
function SetAKID (line 11419) | static int SetAKID(byte* output, word32 outSz,
function SetKeyUsage (line 11453) | static int SetKeyUsage(byte* output, word32 outSz, word16 input)
function SetOjectIdValue (line 11467) | static int SetOjectIdValue(byte* output, word32 outSz, int* idx,
function SetExtKeyUsage (line 11482) | static int SetExtKeyUsage(Cert* cert, byte* output, word32 outSz, byte i...
function SetCertificatePolicies (line 11564) | static int SetCertificatePolicies(byte *output,
function SetAltNames (line 11619) | static int SetAltNames(byte *out, word32 outSz, byte *input, word32 length)
function wc_EncodeName (line 11643) | static int wc_EncodeName(EncodedName* name, const char* nameStr, char na...
function SetName (line 11764) | int SetName(byte* output, word32 outputSz, CertName* name)
function EncodeCert (line 11896) | static int EncodeCert(Cert* cert, DerCert* der, RsaKey* rsaKey, ecc_key*...
function WriteCertBody (line 12253) | static int WriteCertBody(DerCert* der, byte* buffer)
function MakeSignature (line 12292) | static int MakeSignature(CertSignCtx* certSignCtx, const byte* buffer, i...
function AddSignature (line 12407) | static int AddSignature(byte* buffer, int bodySz, const byte* sig, int s...
function MakeAnyCert (line 12434) | static int MakeAnyCert(Cert* cert, byte* derBuffer, word32 derSz,
function wc_MakeCert_ex (line 12477) | int wc_MakeCert_ex(Cert* cert, byte* derBuffer, word32 derSz, int keyType,
function wc_MakeCert (line 12495) | int wc_MakeCert(Cert* cert, byte* derBuffer, word32 derSz, RsaKey* rsaKey,
function wc_MakeNtruCert (line 12505) | int wc_MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz,
function SetReqAttrib (line 12516) | static int SetReqAttrib(byte* output, char* pw, int pwPrintableString,
function EncodeCertReq (line 12593) | static int EncodeCertReq(Cert* cert, DerCert* der, RsaKey* rsaKey,
function WriteCertReqBody (line 12772) | static int WriteCertReqBody(DerCert* der, byte* buffer)
function MakeCertReq (line 12806) | static int MakeCertReq(Cert* cert, byte* derBuffer, word32 derSz,
function wc_MakeCertReq_ex (line 12841) | int wc_MakeCertReq_ex(Cert* cert, byte* derBuffer, word32 derSz, int key...
function wc_MakeCertReq (line 12858) | int wc_MakeCertReq(Cert* cert, byte* derBuffer, word32 derSz,
function SignCert (line 12866) | static int SignCert(int requestSz, int sType, byte* buffer, word32 buffSz,
function wc_SignCert_ex (line 12941) | int wc_SignCert_ex(int requestSz, int sType, byte* buffer, word32 buffSz,
function wc_SignCert (line 12959) | int wc_SignCert(int requestSz, int sType, byte* buffer, word32 buffSz,
function wc_MakeSelfCert (line 12966) | int wc_MakeSelfCert(Cert* cert, byte* buffer, word32 buffSz,
function wc_GetSubjectRaw (line 12984) | int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert)
function SetKeyIdFromPublicKey (line 12995) | static int SetKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *ec...
function wc_SetSubjectKeyIdFromPublicKey_ex (line 13064) | int wc_SetSubjectKeyIdFromPublicKey_ex(Cert *cert, int keyType, void* key)
function wc_SetSubjectKeyIdFromPublicKey (line 13082) | int wc_SetSubjectKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key ...
function wc_SetSubjectKeyIdFromNtruPublicKey (line 13089) | int wc_SetSubjectKeyIdFromNtruPublicKey(Cert *cert,
function wc_SetAuthKeyIdFromPublicKey_ex (line 13097) | int wc_SetAuthKeyIdFromPublicKey_ex(Cert *cert, int keyType, void* key)
function wc_SetAuthKeyIdFromPublicKey (line 13115) | int wc_SetAuthKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *ec...
function wc_SetSubjectKeyId (line 13124) | int wc_SetSubjectKeyId(Cert *cert, const char* file)
function SetAuthKeyIdFromDcert (line 13224) | static int SetAuthKeyIdFromDcert(Cert* cert, DecodedCert* decoded)
function wc_SetAuthKeyIdFromCert (line 13248) | int wc_SetAuthKeyIdFromCert(Cert *cert, const byte *der, int derSz)
function wc_SetAuthKeyId (line 13277) | int wc_SetAuthKeyId(Cert *cert, const char* file)
function wc_SetKeyUsage (line 13308) | int wc_SetKeyUsage(Cert *cert, const char *value)
function wc_SetExtKeyUsage (line 13367) | int wc_SetExtKeyUsage(Cert *cert, const char *value)
function wc_SetExtKeyUsageOID (line 13430) | int wc_SetExtKeyUsageOID(Cert *cert, const char *in, word32 sz, byte idx,
function SetAltNamesFromDcert (line 13457) | static int SetAltNamesFromDcert(Cert* cert, DecodedCert* decoded)
function SetAltNamesFromCert (line 13530) | static int SetAltNamesFromCert(Cert* cert, const byte* der, int derSz)
function SetDatesFromDcert (line 13569) | static int SetDatesFromDcert(Cert* cert, DecodedCert* decoded)
function SetNameFromDcert (line 13595) | static void SetNameFromDcert(CertName* cn, DecodedCert* decoded)
function SetNameFromCert (line 13689) | static int SetNameFromCert(CertName* cn, const byte* der, int derSz)
function wc_SetIssuer (line 13728) | int wc_SetIssuer(Cert* cert, const char* issuerFile)
function wc_SetSubject (line 13753) | int wc_SetSubject(Cert* cert, const char* subjectFile)
function wc_SetAltNames (line 13779) | int wc_SetAltNames(Cert* cert, const char* file)
function wc_SetIssuerBuffer (line 13806) | int wc_SetIssuerBuffer(Cert* cert, const byte* der, int derSz)
function wc_SetSubjectBuffer (line 13834) | int wc_SetSubjectBuffer(Cert* cert, const byte* der, int derSz)
function wc_SetSubjectRaw (line 13860) | int wc_SetSubjectRaw(Cert* cert, const byte* der, int derSz)
function wc_SetIssuerRaw (line 13892) | int wc_SetIssuerRaw(Cert* cert, const byte* der, int derSz)
function wc_SetAltNamesBuffer (line 13926) | int wc_SetAltNamesBuffer(Cert* cert, const byte* der, int derSz)
function wc_SetDatesBuffer (line 13952) | int wc_SetDatesBuffer(Cert* cert, const byte* der, int derSz)
function EncodePolicyOID (line 13984) | int EncodePolicyOID(byte *out, word32 *outSz, const char *in, void* heap)
function StoreECC_DSA_Sig (line 14070) | int StoreECC_DSA_Sig(byte* out, word32* outLen, mp_int* r, mp_int* s)
function DecodeECC_DSA_Sig (line 14108) | int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s)
function wc_EccPrivateKeyDecode (line 14141) | int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key*...
function ByteToHex (line 14267) | static void ByteToHex(byte n, char* str)
function ASNToHexString (line 14277) | static int ASNToHexString(const byte* input, word32* inOutIdx, char** out,
function wc_EccPublicKeyDecode (line 14315) | int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
function wc_BuildEccKeyDer (line 14501) | static int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 inLen,
function wc_EccKeyToDer (line 14618) | int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen)
function wc_EccPrivateKeyToDer (line 14626) | int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, word32 inLen)
function wc_EccPrivateKeyToPKCS8 (line 14638) | int wc_EccPrivateKeyToPKCS8(ecc_key* key, byte* output, word32* outLen)
function wc_Ed25519PrivateKeyDecode (line 14707) | int wc_Ed25519PrivateKeyDecode(const byte* input, word32* inOutIdx,
function wc_Ed25519PublicKeyDecode (line 14773) | int wc_Ed25519PublicKeyDecode(const byte* input, word32* inOutIdx,
function wc_BuildEd25519KeyDer (line 14809) | static int wc_BuildEd25519KeyDer(ed25519_key* key, byte* output, word32 ...
function wc_Ed25519KeyToDer (line 14863) | int wc_Ed25519KeyToDer(ed25519_key* key, byte* output, word32 inLen)
function wc_Ed25519PrivateKeyToDer (line 14872) | int wc_Ed25519PrivateKeyToDer(ed25519_key* key, byte* output, word32 inLen)
function GetBasicDate (line 14885) | static int GetBasicDate(const byte* source, word32* idx, byte* date,
function GetEnumerated (line 14907) | static int GetEnumerated(const byte* input, word32* inOutIdx, int *value,
function DecodeSingleResponse (line 14941) | static int DecodeSingleResponse(byte* source,
function DecodeOcspRespExtensions (line 15084) | static int DecodeOcspRespExtensions(byte* source,
function DecodeResponseData (line 15163) | static int DecodeResponseData(byte* source,
function DecodeCerts (line 15230) | static int DecodeCerts(byte* source,
function DecodeBasicOcspResponse (line 15263) | static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,
function InitOcspResponse (line 15385) | void InitOcspResponse(OcspResponse* resp, CertStatus* status,
function OcspResponseDecode (line 15400) | int OcspResponseDecode(OcspResponse* resp, void* cm, void* heap, int noV...
function word32 (line 15454) | word32 EncodeOcspRequestExtensions(OcspRequest* req, byte* output, word3...
function EncodeOcspRequest (line 15503) | int EncodeOcspRequest(OcspRequest* req, byte* output, word32 size)
function InitOcspRequest (line 15580) | int InitOcspRequest(OcspRequest* req, DecodedCert* cert, byte useNonce,
function FreeOcspRequest (line 15642) | void FreeOcspRequest(OcspRequest* req)
function CompareOcspReqResp (line 15668) | int CompareOcspReqResp(OcspRequest* req, OcspResponse* resp)
function WOLFSSL_LOCAL (line 15743) | WOLFSSL_LOCAL int GetNameHash(const byte* source, word32* idx, byte* hash,
function InitDecodedCRL (line 15782) | void InitDecodedCRL(DecodedCRL* dcrl, void* heap)
function FreeDecodedCRL (line 15795) | void FreeDecodedCRL(DecodedCRL* dcrl)
function GetRevoked (line 15810) | static int GetRevoked(const byte* buff, word32* idx, DecodedCRL* dcrl,
function GetCRL_Signature (line 15858) | static int GetCRL_Signature(const byte* source, word32* idx, DecodedCRL*...
function VerifyCRL_Signature (line 15877) | int VerifyCRL_Signature(SignatureCtx* sigCtx, const byte* toBeSigned,
function ParseCRL_CertList (line 15901) | static int ParseCRL_CertList(DecodedCRL* dcrl, const byte* buf,
function ParseCRL_AuthKeyIdExt (line 15976) | static int ParseCRL_AuthKeyIdExt(const byte* input, int sz, DecodedCRL* ...
function ParseCRL_Extensions (line 16016) | static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf,
function ParseCRL (line 16103) | int ParseCRL(DecodedCRL* dcrl, const byte* buff, word32 sz, void* cm)
function wc_ParseCertPIV (line 16186) | int wc_ParseCertPIV(wc_CertPIV* piv, const byte* buf, word32 totalSz)
FILE: src/wolfcrypt/src/blake2b.c
function WC_INLINE (line 73) | static WC_INLINE int blake2b_set_lastnode( blake2b_state *S )
function WC_INLINE (line 80) | static WC_INLINE int blake2b_set_lastblock( blake2b_state *S )
function WC_INLINE (line 88) | static WC_INLINE int blake2b_increment_counter( blake2b_state *S, const ...
function WC_INLINE (line 96) | static WC_INLINE int blake2b_init0( blake2b_state *S )
function blake2b_init_param (line 107) | int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
function blake2b_init (line 123) | int blake2b_init( blake2b_state *S, const byte outlen )
function blake2b_init_key (line 151) | int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key,
function blake2b_compress (line 206) | static int blake2b_compress( blake2b_state *S,
function blake2b_update (line 295) | int blake2b_update( blake2b_state *S, const byte *in, word64 inlen )
function blake2b_final (line 329) | int blake2b_final( blake2b_state *S, byte *out, byte outlen )
function blake2b (line 358) | int blake2b( byte *out, const void *in, const void *key, const byte outlen,
function main (line 387) | int main( int argc, char **argv )
function wc_InitBlake2b (line 423) | int wc_InitBlake2b(Blake2b* b2b, word32 digestSz)
function wc_Blake2bUpdate (line 435) | int wc_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz)
function wc_Blake2bFinal (line 442) | int wc_Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz)
FILE: src/wolfcrypt/src/blake2s.c
function WC_INLINE (line 69) | static WC_INLINE int blake2s_set_lastnode( blake2s_state *S )
function WC_INLINE (line 76) | static WC_INLINE int blake2s_set_lastblock( blake2s_state *S )
function WC_INLINE (line 84) | static WC_INLINE int blake2s_increment_counter( blake2s_state *S, const ...
function WC_INLINE (line 92) | static WC_INLINE int blake2s_init0( blake2s_state *S )
function blake2s_init_param (line 103) | int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
function blake2s_init (line 119) | int blake2s_init( blake2s_state *S, const byte outlen )
function blake2s_init_key (line 147) | int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key,
function blake2s_compress (line 202) | static int blake2s_compress( blake2s_state *S,
function blake2s_update (line 289) | int blake2s_update( blake2s_state *S, const byte *in, word32 inlen )
function blake2s_final (line 323) | int blake2s_final( blake2s_state *S, byte *out, byte outlen )
function blake2s (line 352) | int blake2s( byte *out, const void *in, const void *key, const byte outlen,
function main (line 381) | int main( int argc, char **argv )
function wc_InitBlake2s (line 417) | int wc_InitBlake2s(Blake2s* b2s, word32 digestSz)
function wc_Blake2sUpdate (line 429) | int wc_Blake2sUpdate(Blake2s* b2s, const byte* data, word32 sz)
function wc_Blake2sFinal (line 436) | int wc_Blake2sFinal(Blake2s* b2s, byte* final, word32 requestSz)
FILE: src/wolfcrypt/src/camellia.c
type u32 (line 75) | typedef unsigned int u32;
type u8 (line 76) | typedef unsigned char u8;
function camellia_setup128 (line 490) | static int camellia_setup128(const unsigned char *key, u32 *subkey)
function camellia_setup256 (line 722) | static int camellia_setup256(const unsigned char *key, u32 *subkey)
function camellia_setup192 (line 1029) | static int camellia_setup192(const unsigned char *key, u32 *subkey)
function camellia_encrypt128 (line 1051) | static void camellia_encrypt128(const u32 *subkey, u32 *io)
function camellia_decrypt128 (line 1141) | static void camellia_decrypt128(const u32 *subkey, u32 *io)
function camellia_encrypt256 (line 1234) | static void camellia_encrypt256(const u32 *subkey, u32 *io)
function camellia_decrypt256 (line 1348) | static void camellia_decrypt256(const u32 *subkey, u32 *io)
function Camellia_EncryptBlock (line 1467) | static void Camellia_EncryptBlock(const int keyBitLength,
function Camellia_DecryptBlock (line 1498) | static void Camellia_DecryptBlock(const int keyBitLength,
function wc_CamelliaSetKey (line 1532) | int wc_CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const ...
function wc_CamelliaSetIV (line 1563) | int wc_CamelliaSetIV(Camellia* cam, const byte* iv)
function wc_CamelliaEncryptDirect (line 1577) | int wc_CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in)
function wc_CamelliaDecryptDirect (line 1588) | int wc_CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in)
function wc_CamelliaCbcEncrypt (line 1599) | int wc_CamelliaCbcEncrypt(Camellia* cam, byte* out, const byte* in, word...
function wc_CamelliaCbcDecrypt (line 1621) | int wc_CamelliaCbcDecrypt(Camellia* cam, byte* out, const byte* in, word...
FILE: src/wolfcrypt/src/chacha.c
function wc_Chacha_SetIV (line 111) | int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter)
function wc_Chacha_SetKey (line 145) | int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz)
function WC_INLINE (line 210) | static WC_INLINE void wc_Chacha_wordtobyte(word32 output[CHACHA_CHUNK_WO...
function wc_Chacha_encrypt_bytes (line 259) | static void wc_Chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c,
function wc_Chacha_Process (line 289) | int wc_Chacha_Process(ChaCha* ctx, byte* output, const byte* input,
FILE: src/wolfcrypt/src/chacha20_poly1305.c
function wc_ChaCha20Poly1305_Encrypt (line 59) | int wc_ChaCha20Poly1305_Encrypt(
function wc_ChaCha20Poly1305_Decrypt (line 110) | int wc_ChaCha20Poly1305_Decrypt(
function calculateAuthTag (line 171) | static int calculateAuthTag(
function word32ToLittle64 (line 236) | static void word32ToLittle64(const word32 inLittle32, byte outLittle64[8])
FILE: src/wolfcrypt/src/cmac.c
function ShiftAndXorRb (line 55) | static void ShiftAndXorRb(byte* out, byte* in)
function wc_InitCmac (line 75) | int wc_InitCmac(Cmac* cmac, const byte* key, word32 keySz,
function wc_CmacUpdate (line 100) | int wc_CmacUpdate(Cmac* cmac, const byte* in, word32 inSz)
function wc_CmacFinal (line 128) | int wc_CmacFinal(Cmac* cmac, byte* out, word32* outSz)
function wc_AesCmacGenerate (line 164) | int wc_AesCmacGenerate(byte* out, word32* outSz,
function wc_AesCmacVerify (line 190) | int wc_AesCmacVerify(const byte* check, word32 checkSz,
FILE: src/wolfcrypt/src/coding.c
function Base64_Decode (line 59) | int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
function CEscape (line 164) | static int CEscape(int escaped, byte e, byte* out, word32* i, word32 max,
function DoBase64_Encode (line 246) | static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
function Base64_Encode (line 346) | int Base64_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
function Base64_EncodeEsc (line 353) | int Base64_EncodeEsc(const byte* in, word32 inLen, byte* out, word32* ou...
function Base64_Encode_NoNl (line 358) | int Base64_Encode_NoNl(const byte* in, word32 inLen, byte* out, word32* ...
function Base16_Decode (line 379) | int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
function Base16_Encode (line 435) | int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
FILE: src/wolfcrypt/src/compress.c
function myFree (line 54) | static void myFree(void* opaque, void* memory)
function wc_Compress_ex (line 86) | int wc_Compress_ex(byte* out, word32 outSz, const byte* in, word32 inSz,
function wc_Compress (line 125) | int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, wo...
function wc_DeCompress_ex (line 143) | int wc_DeCompress_ex(byte* out, word32 outSz, const byte* in, word32 inSz,
function wc_DeCompress (line 191) | int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
FILE: src/wolfcrypt/src/cpuid.c
function word32 (line 60) | static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit)
function cpuid_set_flags (line 90) | void cpuid_set_flags(void)
function word32 (line 104) | word32 cpuid_get_flags(void)
FILE: src/wolfcrypt/src/cryptocb.c
type CryptoCb (line 42) | typedef struct CryptoCb {
function CryptoCb (line 49) | static CryptoCb* wc_CryptoCb_FindDevice(int devId)
function CryptoCb (line 58) | static CryptoCb* wc_CryptoCb_FindDeviceByIndex(int startIdx)
function WC_INLINE (line 68) | static WC_INLINE int wc_CryptoCb_TranslateErrorCode(int ret)
function wc_CryptoCb_Init (line 77) | void wc_CryptoCb_Init(void)
function wc_CryptoCb_RegisterDevice (line 85) | int wc_CryptoCb_RegisterDevice(int devId, CryptoDevCallbackFunc cb, void...
function wc_CryptoCb_UnRegisterDevice (line 102) | void wc_CryptoCb_UnRegisterDevice(int devId)
function wc_CryptoCb_Rsa (line 112) | int wc_CryptoCb_Rsa(const byte* in, word32 inLen, byte* out,
function wc_CryptoCb_MakeRsaKey (line 143) | int wc_CryptoCb_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng)
function wc_CryptoCb_MakeEccKey (line 172) | int wc_CryptoCb_MakeEccKey(WC_RNG* rng, int keySize, ecc_key* key, int c...
function wc_CryptoCb_Ecdh (line 198) | int wc_CryptoCb_Ecdh(ecc_key* private_key, ecc_key* public_key,
function wc_CryptoCb_EccSign (line 225) | int wc_CryptoCb_EccSign(const byte* in, word32 inlen, byte* out,
function wc_CryptoCb_EccVerify (line 254) | int wc_CryptoCb_EccVerify(const byte* sig, word32 siglen,
function wc_CryptoCb_AesGcmEncrypt (line 286) | int wc_CryptoCb_AesGcmEncrypt(Aes* aes, byte* out,
function wc_CryptoCb_AesGcmDecrypt (line 327) | int wc_CryptoCb_AesGcmDecrypt(Aes* aes, byte* out,
function wc_CryptoCb_AesCbcEncrypt (line 370) | int wc_CryptoCb_AesCbcEncrypt(Aes* aes, byte* out,
function wc_CryptoCb_AesCbcDecrypt (line 402) | int wc_CryptoCb_AesCbcDecrypt(Aes* aes, byte* out,
function wc_CryptoCb_Des3Encrypt (line 437) | int wc_CryptoCb_Des3Encrypt(Des3* des3, byte* out,
function wc_CryptoCb_Des3Decrypt (line 469) | int wc_CryptoCb_Des3Decrypt(Des3* des3, byte* out,
function wc_CryptoCb_ShaHash (line 503) | int wc_CryptoCb_ShaHash(wc_Sha* sha, const byte* in,
function wc_CryptoCb_Sha256Hash (line 536) | int wc_CryptoCb_Sha256Hash(wc_Sha256* sha256, const byte* in,
function wc_CryptoCb_Hmac (line 569) | int wc_CryptoCb_Hmac(Hmac* hmac, int macType, const byte* in, word32 inSz,
function wc_CryptoCb_RandomBlock (line 598) | int wc_CryptoCb_RandomBlock(WC_RNG* rng, byte* out, word32 sz)
function wc_CryptoCb_RandomSeed (line 626) | int wc_CryptoCb_RandomSeed(OS_Seed* os, byte* seed, word32 sz)
FILE: src/wolfcrypt/src/curve25519.c
function wc_curve25519_make_key (line 54) | int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
function wc_curve25519_shared_secret (line 101) | int wc_curve25519_shared_secret(curve25519_key* private_key,
function wc_curve25519_shared_secret_ex (line 109) | int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
function wc_curve25519_export_public (line 179) | int wc_curve25519_export_public(curve25519_key* key, byte* out, word32* ...
function wc_curve25519_export_public_ex (line 186) | int wc_curve25519_export_public_ex(curve25519_key* key, byte* out,
function wc_curve25519_import_public (line 218) | int wc_curve25519_import_public(const byte* in, word32 inLen,
function wc_curve25519_import_public_ex (line 226) | int wc_curve25519_import_public_ex(const byte* in, word32 inLen,
function wc_curve25519_check_public (line 272) | int wc_curve25519_check_public(const byte* pub, word32 pubSz, int endian)
function wc_curve25519_export_private_raw (line 326) | int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
function wc_curve25519_export_private_raw_ex (line 336) | int wc_curve25519_export_private_raw_ex(curve25519_key* key, byte* out,
function wc_curve25519_export_key_raw (line 365) | int wc_curve25519_export_key_raw(curve25519_key* key,
function wc_curve25519_export_key_raw_ex (line 375) | int wc_curve25519_export_key_raw_ex(curve25519_key* key,
function wc_curve25519_import_private_raw (line 398) | int wc_curve25519_import_private_raw(const byte* priv, word32 privSz,
function wc_curve25519_import_private_raw_ex (line 409) | int wc_curve25519_import_private_raw_ex(const byte* priv, word32 privSz,
function wc_curve25519_import_private (line 426) | int wc_curve25519_import_private(const byte* priv, word32 privSz,
function wc_curve25519_import_private_ex (line 435) | int wc_curve25519_import_private_ex(const byte* priv, word32 privSz,
function wc_curve25519_init (line 469) | int wc_curve25519_init(curve25519_key* key)
function wc_curve25519_free (line 488) | void wc_curve25519_free(curve25519_key* key)
function wc_curve25519_size (line 504) | int wc_curve25519_size(curve25519_key* key)
FILE: src/wolfcrypt/src/des3.c
function wc_Des_SetKey (line 56) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 60) | int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
function wc_Des_CbcEncrypt (line 68) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 72) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcEncrypt (line 76) | int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 83) | int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_EcbEncrypt (line 93) | int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_EcbEncrypt (line 97) | int wc_Des3_EcbEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_SetIV (line 103) | void wc_Des_SetIV(Des* des, const byte* iv)
function wc_Des3_SetIV (line 107) | int wc_Des3_SetIV(Des3* des, const byte* iv)
function wc_Des3Init (line 112) | int wc_Des3Init(Des3* des3, void* heap, int devId)
function wc_Des3Free (line 121) | void wc_Des3Free(Des3* des3)
function wc_Des_SetKey (line 152) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 168) | int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
function DesCrypt (line 192) | static void DesCrypt(Des* des, byte* out, const byte* in, word32 sz,
function wc_Des_CbcEncrypt (line 326) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 332) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_EcbEncrypt (line 338) | int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function Des3Crypt (line 344) | static void Des3Crypt(Des3* des, byte* out, const byte* in, word32 sz,
function wc_Des3_CbcEncrypt (line 454) | int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 460) | int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_Cbc (line 500) | static void wc_Des_Cbc(byte* out, const byte* in, word32 sz,
function wc_Des_CbcEncrypt (line 582) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 588) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcEncrypt (line 594) | int wc_Des3_CbcEncrypt(Des3* des3, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 601) | int wc_Des3_CbcDecrypt(Des3* des3, byte* out, const byte* in, word32 sz)
function setParity (line 607) | static void setParity(byte *buf, int len)
function wc_Des_SetKey (line 626) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 656) | int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
function wc_Des_SetKey (line 689) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 700) | int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
function wc_Des_CbcEncrypt (line 718) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 728) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcEncrypt (line 738) | int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 755) | int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_SetKey (line 792) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 809) | int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
function wc_Des_CbcEncrypt (line 837) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 884) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcEncrypt (line 932) | int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 984) | int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_SetKey (line 1042) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 1053) | int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
function wc_Des_CbcEncrypt (line 1064) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 1076) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcEncrypt (line 1088) | int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 1100) | int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_EcbEncrypt (line 1113) | int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_EcbEncrypt (line 1125) | int wc_Des3_EcbEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function WC_INLINE (line 1314) | static WC_INLINE void IPERM(word32* left, word32* right)
function WC_INLINE (line 1340) | static WC_INLINE void FPERM(word32* left, word32* right)
function DesSetKey (line 1367) | static int DesSetKey(const byte* key, int dir, word32* out)
function wc_Des_SetKey (line 1442) | int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
function wc_Des3_SetKey (line 1449) | int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
function DesRawProcessBlock (line 1482) | static void DesRawProcessBlock(word32* lIn, word32* rIn, const word32* k...
function DesProcessBlock (line 1514) | static void DesProcessBlock(Des* des, const byte* in, byte* out)
function Des3ProcessBlock (line 1537) | static void Des3ProcessBlock(Des3* des, const byte* in, byte* out)
function wc_Des_CbcEncrypt (line 1562) | int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des_CbcDecrypt (line 1577) | int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcEncrypt (line 1593) | int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des3_CbcDecrypt (line 1644) | int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_EcbEncrypt (line 1697) | int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
function wc_Des3_EcbEncrypt (line 1714) | int wc_Des3_EcbEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
function wc_Des_SetIV (line 1735) | void wc_Des_SetIV(Des* des, const byte* iv)
function wc_Des3_SetIV (line 1743) | int wc_Des3_SetIV(Des3* des, const byte* iv)
function wc_Des3Init (line 1758) | int wc_Des3Init(Des3* des3, void* heap, int devId)
function wc_Des3Free (line 1782) | void wc_Des3Free(Des3* des3)
FILE: src/wolfcrypt/src/dh.c
function DhParams (line 151) | const DhParams* wc_Dh_ffdhe2048_Get(void)
function DhParams (line 269) | const DhParams* wc_Dh_ffdhe3072_Get(void)
function DhParams (line 419) | const DhParams* wc_Dh_ffdhe4096_Get(void)
function DhParams (line 633) | const DhParams* wc_Dh_ffdhe6144_Get(void)
function DhParams (line 911) | const DhParams* wc_Dh_ffdhe8192_Get(void)
function wc_InitDhKey_ex (line 924) | int wc_InitDhKey_ex(DhKey* key, void* heap, int devId)
function wc_InitDhKey (line 947) | int wc_InitDhKey(DhKey* key)
function wc_FreeDhKey (line 953) | int wc_FreeDhKey(DhKey* key)
function word32 (line 971) | static word32 DiscreteLogWorkFactor(word32 n)
function CheckDhLN (line 1004) | static int CheckDhLN(int modLen, int divLen)
function GeneratePrivateDh186 (line 1038) | static int GeneratePrivateDh186(DhKey* key, WC_RNG* rng, byte* priv,
function GeneratePrivateDh (line 1159) | static int GeneratePrivateDh(DhKey* key, WC_RNG* rng, byte* priv,
function GeneratePublicDh (line 1224) | static int GeneratePublicDh(DhKey* key, byte* priv, word32 privSz,
function wc_DhGenerateKeyPair_Sync (line 1297) | static int wc_DhGenerateKeyPair_Sync(DhKey* key, WC_RNG* rng,
function wc_DhGenerateKeyPair_Async (line 1313) | static int wc_DhGenerateKeyPair_Async(DhKey* key, WC_RNG* rng,
function wc_DhCheckPubKey_ex (line 1384) | int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
function wc_DhCheckPubKey (line 1531) | int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz)
function wc_DhCheckPubValue (line 1549) | int wc_DhCheckPubValue(const byte* prime, word32 primeSz, const byte* pub,
function wc_DhCheckPrivKey_ex (line 1589) | int wc_DhCheckPrivKey_ex(DhKey* key, const byte* priv, word32 privSz,
function wc_DhCheckPrivKey (line 1683) | int wc_DhCheckPrivKey(DhKey* key, const byte* priv, word32 privSz)
function wc_DhCheckKeyPair (line 1700) | int wc_DhCheckKeyPair(DhKey* key, const byte* pub, word32 pubSz,
function wc_DhGenerateKeyPair (line 1810) | int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng,
function wc_DhAgree_Sync (line 1834) | static int wc_DhAgree_Sync(DhKey* key, byte* agree, word32* agreeSz,
function wc_DhAgree_Async (line 1998) | static int wc_DhAgree_Async(DhKey* key, byte* agree, word32* agreeSz,
function wc_DhAgree (line 2041) | int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
function _DhSetKey (line 2065) | static int _DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
function wc_DhSetCheckKey (line 2149) | int wc_DhSetCheckKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
function wc_DhSetKey_ex (line 2157) | int wc_DhSetKey_ex(DhKey* key, const byte* p, word32 pSz, const byte* g,
function wc_DhSetKey (line 2165) | int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
function wc_DhGenerateParams (line 2175) | int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh)
function wc_DhExportParamsRaw (line 2340) | int wc_DhExportParamsRaw(DhKey* dh, byte* p, word32* pSz,
FILE: src/wolfcrypt/src/dsa.c
function wc_InitDsaKey (line 53) | int wc_InitDsaKey(DsaKey* key)
function wc_InitDsaKey_h (line 75) | int wc_InitDsaKey_h(DsaKey* key, void* h)
function wc_FreeDsaKey (line 85) | void wc_FreeDsaKey(DsaKey* key)
function CheckDsaLN (line 105) | static int CheckDsaLN(int modLen, int divLen)
function wc_MakeDsaKey (line 141) | int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa)
function wc_MakeDsaParameters (line 228) | int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa)
function _DsaImportParamsRaw (line 428) | static int _DsaImportParamsRaw(DsaKey* dsa, const char* p, const char* q,
function wc_DsaImportParamsRaw (line 492) | int wc_DsaImportParamsRaw(DsaKey* dsa, const char* p, const char* q,
function wc_DsaImportParamsRawCheck (line 515) | int wc_DsaImportParamsRawCheck(DsaKey* dsa, const char* p, const char* q,
function wc_DsaExportParamsRaw (line 538) | int wc_DsaExportParamsRaw(DsaKey* dsa, byte* p, word32* pSz,
function wc_DsaExportKeyRaw (line 615) | int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y, word3...
function wc_DsaVerify (line 856) | int wc_DsaVerify(const byte* digest, const byte* sig, DsaKey* key, int* ...
FILE: src/wolfcrypt/src/ecc.c
type oid_cache_t (line 1145) | typedef struct {
type ecc_curve_spec (line 1169) | typedef struct ecc_curve_spec {
type ecc_curve_load_mask (line 1199) | enum ecc_curve_load_mask {
function _wc_ecc_curve_free (line 1256) | static void _wc_ecc_curve_free(ecc_curve_spec* curve)
function wc_ecc_curve_free (line 1280) | static void wc_ecc_curve_free(ecc_curve_spec* curve)
function wc_ecc_curve_load_item (line 1289) | static int wc_ecc_curve_load_item(const char* src, mp_int** dst,
function wc_ecc_curve_load (line 1317) | static int wc_ecc_curve_load(const ecc_set_type* dp, ecc_curve_spec** pC...
function wc_ecc_curve_cache_init (line 1416) | int wc_ecc_curve_cache_init(void)
function wc_ecc_curve_cache_free (line 1425) | void wc_ecc_curve_cache_free(void)
function wc_ecc_set_curve (line 1458) | int wc_ecc_set_curve(ecc_key* key, int keysize, int curve_id)
function alt_fp_init (line 1500) | static void alt_fp_init(mp_int* a)
function ecc_projective_add_point (line 1522) | int ecc_projective_add_point(ecc_point* P, ecc_point* Q, ecc_point* R,
function ecc_projective_dbl_point (line 1917) | int ecc_projective_dbl_point(ecc_point *P, ecc_point *R, mp_int* a,
function wc_ecc_mulmod_ex (line 2474) | int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
function wc_ecc_mulmod (line 2950) | int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
function ecc_point (line 2962) | ecc_point* wc_ecc_new_point_h(void* heap)
function ecc_point (line 2996) | ecc_point* wc_ecc_new_point(void)
function wc_ecc_del_point_h (line 3002) | void wc_ecc_del_point_h(ecc_point* p, void* heap)
function wc_ecc_del_point (line 3018) | void wc_ecc_del_point(ecc_point* p)
function wc_ecc_copy_point (line 3028) | int wc_ecc_copy_point(ecc_point* p, ecc_point *r)
function wc_ecc_cmp_point (line 3055) | int wc_ecc_cmp_point(ecc_point* a, ecc_point *b)
function wc_ecc_is_valid_idx (line 3081) | int wc_ecc_is_valid_idx(int n)
function wc_ecc_get_curve_idx (line 3096) | int wc_ecc_get_curve_idx(int curve_id)
function wc_ecc_get_curve_id (line 3109) | int wc_ecc_get_curve_id(int curve_idx)
function wc_ecc_get_curve_size_from_id (line 3122) | int wc_ecc_get_curve_size_from_id(int curve_id)
function wc_ecc_get_curve_idx_from_name (line 3136) | int wc_ecc_get_curve_idx_from_name(const char* curveName)
function wc_ecc_get_curve_size_from_name (line 3165) | int wc_ecc_get_curve_size_from_name(const char* curveName)
function wc_ecc_get_curve_id_from_name (line 3185) | int wc_ecc_get_curve_id_from_name(const char* curveName)
function wc_ecc_cmp_param (line 3203) | static int wc_ecc_cmp_param(const char* curveParam,
function wc_ecc_get_curve_id_from_params (line 3283) | int wc_ecc_get_curve_id_from_params(int fieldSize,
function wc_ecc_get_curve_id_from_dp_params (line 3330) | int wc_ecc_get_curve_id_from_dp_params(const ecc_set_type* dp)
function wc_ecc_get_curve_id_from_oid (line 3371) | int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len)
function ecc_set_type (line 3393) | const ecc_set_type* wc_ecc_get_curve_params(int curve_idx)
function WC_INLINE (line 3405) | static WC_INLINE int wc_ecc_alloc_mpint(ecc_key* key, mp_int** mp)
function WC_INLINE (line 3418) | static WC_INLINE void wc_ecc_free_mpint(ecc_key* key, mp_int** mp)
function wc_ecc_alloc_async (line 3427) | static int wc_ecc_alloc_async(ecc_key* key)
function wc_ecc_free_async (line 3435) | static void wc_ecc_free_async(ecc_key* key)
function wc_ecc_shared_secret (line 3457) | int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte...
function wc_ecc_shared_secret_gen_sync (line 3528) | static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point...
function wc_ecc_shared_secret_gen (line 3675) | int wc_ecc_shared_secret_gen(ecc_key* private_key, ecc_point* point,
function wc_ecc_shared_secret_ex (line 3723) | int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
function wc_ecc_point_is_at_infinity (line 3795) | int wc_ecc_point_is_at_infinity(ecc_point* p)
function wc_ecc_gen_k (line 3807) | int wc_ecc_gen_k(WC_RNG* rng, int size, mp_int* k, mp_int* order)
function WC_INLINE (line 3850) | static WC_INLINE void wc_ecc_reset(ecc_key* key)
function wc_ecc_make_pub_ex (line 3870) | static int wc_ecc_make_pub_ex(ecc_key* key, ecc_curve_spec* curveIn,
function wc_ecc_make_pub (line 4009) | int wc_ecc_make_pub(ecc_key* key, ecc_point* pubOut)
function WOLFSSL_ABI (line 4017) | WOLFSSL_ABI
function wc_ecc_dump_oids (line 4213) | static void wc_ecc_dump_oids(void)
function WOLFSSL_ABI (line 4268) | WOLFSSL_ABI
function WOLFSSL_ABI (line 4285) | WOLFSSL_ABI
function wc_ecc_make_key (line 4307) | int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key)
function WOLFSSL_ABI (line 4313) | WOLFSSL_ABI
function wc_ecc_init (line 4373) | int wc_ecc_init(ecc_key* key)
function wc_ecc_init_id (line 4379) | int wc_ecc_init_id(ecc_key* key, unsigned char* id, int len, void* heap,
function wc_ecc_set_flags (line 4401) | int wc_ecc_set_flags(ecc_key* key, word32 flags)
function wc_ecc_get_curve_order_bit_count (line 4411) | static int wc_ecc_get_curve_order_bit_count(const ecc_set_type* dp)
function wc_ecc_sign_hash_hw (line 4436) | static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,
function wc_ecc_sign_hash_async (line 4541) | static int wc_ecc_sign_hash_async(const byte* in, word32 inlen, byte* out,
function WOLFSSL_ABI (line 4626) | WOLFSSL_ABI
function wc_ecc_sign_hash_ex (line 4711) | int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
function wc_ecc_sign_set_k (line 5095) | int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key)
function wc_ecc_free_curve (line 5125) | void wc_ecc_free_curve(const ecc_set_type* curve, void* heap)
function WOLFSSL_ABI (line 5150) | WOLFSSL_ABI
function ecc_mul2add (line 5211) | int ecc_mul2add(ecc_point* A, mp_int* kA,
function wc_ecc_verify_hash (line 5544) | int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
function wc_ecc_import_point_der (line 6100) | int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx,
function wc_ecc_export_point_der (line 6238) | int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte*...
function wc_ecc_export_x963 (line 6306) | int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen)
function wc_ecc_export_x963_ex (line 6386) | int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen,
function wc_ecc_is_point (line 6404) | int wc_ecc_is_point(ecc_point* ecp, mp_int* a, mp_int* b, mp_int* prime)
function ecc_check_privkey_gen (line 6518) | static int ecc_check_privkey_gen(ecc_key* key, mp_int* a, mp_int* prime)
function ecc_check_privkey_gen_helper (line 6588) | static int ecc_check_privkey_gen_helper(ecc_key* key)
function ecc_check_pubkey_order (line 6625) | static int ecc_check_pubkey_order(ecc_key* key, ecc_point* pubkey, mp_in...
function wc_ecc_check_key (line 6668) | int wc_ecc_check_key(ecc_key* key)
function wc_ecc_import_x963_ex (line 6796) | int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
function wc_ecc_import_x963 (line 6961) | int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key)
function wc_ecc_export_ex (line 6972) | int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen,
function wc_ecc_export_private_only (line 7029) | int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen)
function wc_ecc_export_public_raw (line 7041) | int wc_ecc_export_public_raw(ecc_key* key, byte* qx, word32* qxLen,
function wc_ecc_export_private_raw (line 7055) | int wc_ecc_export_private_raw(ecc_key* key, byte* qx, word32* qxLen,
function wc_ecc_import_private_key_ex (line 7067) | int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
function wc_ecc_import_private_key (line 7159) | int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byt...
function wc_ecc_rs_to_sig (line 7175) | int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* ou...
function wc_ecc_rs_raw_to_sig (line 7242) | int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word3...
function wc_ecc_sig_to_rs (line 7310) | int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen,
function wc_ecc_import_raw_private (line 7383) | static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
function wc_ecc_import_raw_ex (line 7553) | int wc_ecc_import_raw_ex(ecc_key* key, const char* qx, const char* qy,
function wc_ecc_import_unsigned (line 7562) | int wc_ecc_import_unsigned(ecc_key* key, byte* qx, byte* qy,
function wc_ecc_import_raw (line 7579) | int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
function wc_ecc_size (line 7610) | int wc_ecc_size(ecc_key* key)
function wc_ecc_sig_size_calc (line 7619) | int wc_ecc_sig_size_calc(int sz)
function wc_ecc_sig_size (line 7636) | int wc_ecc_sig_size(ecc_key* key)
type fp_cache_t (line 7695) | typedef struct {
function find_hole (line 8244) | static int find_hole(void)
function find_base (line 8277) | static int find_base(ecc_point* g)
function add_entry (line 8295) | static int add_entry(int idx, ecc_point *g)
function build_lut (line 8340) | static int build_lut(int idx, mp_int* a, mp_int* modulus, mp_digit mp,
function accel_fp_mul (line 8476) | static int accel_fp_mul(int idx, mp_int* k, ecc_point *R, mp_int* a,
function ecc_mul2add (line 8980) | int ecc_mul2add(ecc_point* A, mp_int* kA,
function wc_ecc_mulmod_ex (line 9104) | int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
function wc_ecc_fp_free_cache (line 9196) | static void wc_ecc_fp_free_cache(void)
type ecCliState (line 9245) | enum ecCliState {
type ecSrvState (line 9254) | enum ecSrvState {
type ecEncCtx (line 9264) | struct ecEncCtx {
function byte (line 9283) | const byte* wc_ecc_ctx_get_own_salt(ecEncCtx* ctx)
function wc_ecc_ctx_set_info (line 9314) | int wc_ecc_ctx_set_info(ecEncCtx* ctx, const byte* info, int sz)
function wc_ecc_ctx_set_peer_salt (line 9328) | int wc_ecc_ctx_set_peer_salt(ecEncCtx* ctx, const byte* salt)
function ecc_ctx_set_salt (line 9377) | static int ecc_ctx_set_salt(ecEncCtx* ctx, int flags, WC_RNG* rng)
function ecc_ctx_init (line 9390) | static void ecc_ctx_init(ecEncCtx* ctx, int flags)
function wc_ecc_ctx_reset (line 9409) | int wc_ecc_ctx_reset(ecEncCtx* ctx, WC_RNG* rng)
function ecEncCtx (line 9419) | ecEncCtx* wc_ecc_ctx_new_ex(int flags, WC_RNG* rng, void* heap)
function ecEncCtx (line 9441) | ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng)
function wc_ecc_ctx_free (line 9448) | void wc_ecc_ctx_free(ecEncCtx* ctx)
function ecc_get_key_sizes (line 9457) | static int ecc_get_key_sizes(ecEncCtx* ctx, int* encKeySz, int* ivSz,
function wc_ecc_encrypt (line 9491) | int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
function wc_ecc_decrypt (line 9660) | int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
function do_mp_jacobi (line 9836) | int do_mp_jacobi(mp_int* a, mp_int* n, int* c)
function mp_jacobi (line 9921) | int mp_jacobi(mp_int* a, mp_int* n, int* c)
function mp_sqrtmod_prime (line 9955) | int mp_sqrtmod_prime(mp_int* n, mp_int* prime, mp_int* ret)
function wc_ecc_export_x963_compressed (line 10159) | static int wc_ecc_export_x963_compressed(ecc_key* key, byte* out, word32...
function wc_ecc_get_oid (line 10192) | int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz)
function wc_ecc_set_custom_curve (line 10238) | int wc_ecc_set_custom_curve(ecc_key* key, const ecc_set_type* dp)
function WC_INLINE (line 10253) | static WC_INLINE void IncrementX963KdfCounter(byte* inOutCtr)
function wc_X963_KDF (line 10265) | int wc_X963_KDF(enum wc_HashType type, const byte* secret, word32 secretSz,
FILE: src/wolfcrypt/src/ed25519.c
function wc_ed25519_make_public (line 55) | int wc_ed25519_make_public(ed25519_key* key, unsigned char* pubKey,
function wc_ed25519_make_key (line 94) | int wc_ed25519_make_key(WC_RNG* rng, int keySz, ed25519_key* key)
function ed25519_sign_msg (line 137) | static int ed25519_sign_msg(const byte* in, word32 inLen, byte* out,
function wc_ed25519_sign_msg (line 263) | int wc_ed25519_sign_msg(const byte* in, word32 inLen, byte* out,
function wc_ed25519ctx_sign_msg (line 280) | int wc_ed25519ctx_sign_msg(const byte* in, word32 inLen, byte* out,
function wc_ed25519ph_sign_hash (line 299) | int wc_ed25519ph_sign_hash(const byte* hash, word32 hashLen, byte* out,
function wc_ed25519ph_sign_msg (line 318) | int wc_ed25519ph_sign_msg(const byte* in, word32 inLen, byte* out,
function ed25519_verify_msg (line 345) | static int ed25519_verify_msg(const byte* sig, word32 sigLen, const byte...
function wc_ed25519_verify_msg (line 439) | int wc_ed25519_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
function wc_ed25519ctx_verify_msg (line 457) | int wc_ed25519ctx_verify_msg(const byte* sig, word32 sigLen, const byte*...
function wc_ed25519ph_verify_hash (line 476) | int wc_ed25519ph_verify_hash(const byte* sig, word32 sigLen, const byte*...
function wc_ed25519ph_verify_msg (line 495) | int wc_ed25519ph_verify_msg(const byte* sig, word32 sigLen, const byte* ...
function wc_ed25519_init (line 513) | int wc_ed25519_init(ed25519_key* key)
function wc_ed25519_free (line 529) | void wc_ed25519_free(ed25519_key* key)
function wc_ed25519_export_public (line 545) | int wc_ed25519_export_public(ed25519_key* key, byte* out, word32* outLen)
function wc_ed25519_import_public (line 572) | int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* ...
function wc_ed25519_import_private_only (line 643) | int wc_ed25519_import_private_only(const byte* priv, word32 privSz,
function wc_ed25519_import_private_key (line 662) | int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
function wc_ed25519_export_private_only (line 698) | int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* ...
function wc_ed25519_export_private (line 721) | int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen)
function wc_ed25519_export_key (line 741) | int wc_ed25519_export_key(ed25519_key* key,
function wc_ed25519_check_key (line 761) | int wc_ed25519_check_key(ed25519_key* key)
function wc_ed25519_size (line 777) | int wc_ed25519_size(ed25519_key* key)
function wc_ed25519_priv_size (line 786) | int wc_ed25519_priv_size(ed25519_key* key)
function wc_ed25519_pub_size (line 795) | int wc_ed25519_pub_size(ed25519_key* key)
function wc_ed25519_sig_size (line 804) | int wc_ed25519_sig_size(ed25519_key* key)
FILE: src/wolfcrypt/src/error.c
function wc_ErrorString (line 521) | void wc_ErrorString(int error, char* buffer)
FILE: src/wolfcrypt/src/evp.c
function wolfSSL_EVP_Cipher_key_length (line 42) | int wolfSSL_EVP_Cipher_key_length(const WOLFSSL_EVP_CIPHER* c)
function wolfSSL_EVP_EncryptInit (line 85) | int wolfSSL_EVP_EncryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
function wolfSSL_EVP_EncryptInit_ex (line 93) | int wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
function wolfSSL_EVP_DecryptInit (line 103) | int wolfSSL_EVP_DecryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
function wolfSSL_EVP_DecryptInit_ex (line 112) | int wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
function WOLFSSL_EVP_CIPHER_CTX (line 124) | WOLFSSL_EVP_CIPHER_CTX *wolfSSL_EVP_CIPHER_CTX_new(void)
function wolfSSL_EVP_CIPHER_CTX_free (line 135) | void wolfSSL_EVP_CIPHER_CTX_free(WOLFSSL_EVP_CIPHER_CTX *ctx)
function wolfSSL_EVP_CIPHER_CTX_mode (line 144) | unsigned long wolfSSL_EVP_CIPHER_CTX_mode(const WOLFSSL_EVP_CIPHER_CTX *...
function wolfSSL_EVP_EncryptFinal (line 150) | int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
function wolfSSL_EVP_CipherInit_ex (line 162) | int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
function wolfSSL_EVP_EncryptFinal_ex (line 173) | int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
function wolfSSL_EVP_DecryptFinal (line 184) | int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
function wolfSSL_EVP_DecryptFinal_ex (line 196) | int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
function wolfSSL_EVP_DigestInit_ex (line 209) | int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
function fillBuff (line 225) | static int fillBuff(WOLFSSL_EVP_CIPHER_CTX *ctx, const unsigned char *in...
function evpCipherBlock (line 241) | static int evpCipherBlock(WOLFSSL_EVP_CIPHER_CTX *ctx,
function wolfSSL_EVP_CipherUpdate_GCM (line 360) | static int wolfSSL_EVP_CipherUpdate_GCM(WOLFSSL_EVP_CIPHER_CTX *ctx,
function WOLFSSL_API (line 373) | WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx,
function padBlock (line 499) | static void padBlock(WOLFSSL_EVP_CIPHER_CTX *ctx)
function checkPad (line 506) | static int checkPad(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *buff)
function wolfSSL_EVP_CipherFinal (line 519) | int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
function WOLFSSL_API (line 607) | WOLFSSL_API int wolfSSL_EVP_DecryptFinal_legacy(WOLFSSL_EVP_CIPHER_CTX ...
function wolfSSL_EVP_CIPHER_CTX_block_size (line 650) | int wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX *ctx)
function cipherType (line 689) | static unsigned int cipherType(const WOLFSSL_EVP_CIPHER *cipher)
function wolfSSL_EVP_CIPHER_block_size (line 765) | int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
function WOLFSSL_CIPHER_mode (line 806) | unsigned long WOLFSSL_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher)
function WOLFSSL_EVP_CIPHER_mode (line 850) | unsigned long WOLFSSL_EVP_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher)
function wolfSSL_EVP_CIPHER_CTX_set_flags (line 856) | void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int f...
function wolfSSL_EVP_CIPHER_CTX_clear_flags (line 863) | void wolfSSL_EVP_CIPHER_CTX_clear_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int...
function wolfSSL_EVP_CIPHER_flags (line 870) | unsigned long wolfSSL_EVP_CIPHER_flags(const WOLFSSL_EVP_CIPHER *cipher)
function wolfSSL_EVP_CIPHER_CTX_set_padding (line 876) | int wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX *ctx, int...
function wolfSSL_EVP_add_digest (line 888) | int wolfSSL_EVP_add_digest(const WOLFSSL_EVP_MD *digest)
function wolfSSL_EVP_PKEY_CTX_free (line 900) | int wolfSSL_EVP_PKEY_CTX_free(WOLFSSL_EVP_PKEY_CTX *ctx)
function WOLFSSL_EVP_PKEY_CTX (line 916) | WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new(WOLFSSL_EVP_PKEY *pkey, W...
function wolfSSL_EVP_PKEY_CTX_set_rsa_padding (line 944) | int wolfSSL_EVP_PKEY_CTX_set_rsa_padding(WOLFSSL_EVP_PKEY_CTX *ctx, int ...
function WOLFSSL_EVP_PKEY_CTX (line 953) | WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new_id(int id, WOLFSSL_ENGINE...
function wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits (line 972) | int wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits(WOLFSSL_EVP_PKEY_CTX *ctx, ...
function wolfSSL_EVP_PKEY_decrypt (line 990) | int wolfSSL_EVP_PKEY_decrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
function wolfSSL_EVP_PKEY_decrypt_init (line 1033) | int wolfSSL_EVP_PKEY_decrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx)
function wolfSSL_EVP_PKEY_encrypt (line 1061) | int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
function wolfSSL_EVP_PKEY_encrypt_init (line 1104) | int wolfSSL_EVP_PKEY_encrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx)
function WOLFSSL_API (line 1128) | WOLFSSL_API int wolfSSL_EVP_PKEY_sign_init(WOLFSSL_EVP_PKEY_CTX *ctx)
function WOLFSSL_API (line 1157) | WOLFSSL_API int wolfSSL_EVP_PKEY_sign(WOLFSSL_EVP_PKEY_CTX *ctx, unsigne...
function wolfSSL_EVP_PKEY_bits (line 1201) | int wolfSSL_EVP_PKEY_bits(const WOLFSSL_EVP_PKEY *pkey)
function wolfSSL_EVP_PKEY_keygen_init (line 1212) | int wolfSSL_EVP_PKEY_keygen_init(WOLFSSL_EVP_PKEY_CTX *ctx)
function wolfSSL_EVP_PKEY_keygen (line 1218) | int wolfSSL_EVP_PKEY_keygen(WOLFSSL_EVP_PKEY_CTX *ctx,
function wolfSSL_EVP_PKEY_size (line 1279) | int wolfSSL_EVP_PKEY_size(WOLFSSL_EVP_PKEY *pkey)
function WOLFSSL_API (line 1306) | WOLFSSL_API int wolfSSL_EVP_PKEY_missing_parameters(WOLFSSL_EVP_PKEY *pkey)
function WOLFSSL_API (line 1314) | WOLFSSL_API int wolfSSL_EVP_PKEY_cmp(const WOLFSSL_EVP_PKEY *a, const WO...
function wolfSSL_EVP_SignInit (line 1377) | int wolfSSL_EVP_SignInit(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD *...
function WOLFSSL_API (line 1384) | WOLFSSL_API int wolfSSL_EVP_SignInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
function wolfSSL_EVP_SignUpdate (line 1402) | int wolfSSL_EVP_SignUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *data, si...
function md2nid (line 1414) | static int md2nid(const unsigned char md)
function wolfSSL_EVP_SignFinal (line 1451) | int wolfSSL_EVP_SignFinal(WOLFSSL_EVP_MD_CTX *ctx, unsigned char *sigret,
function wolfSSL_EVP_VerifyInit (line 1494) | int wolfSSL_EVP_VerifyInit(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD...
function wolfSSL_EVP_VerifyUpdate (line 1510) | int wolfSSL_EVP_VerifyUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *data, ...
function wolfSSL_EVP_VerifyFinal (line 1527) | int wolfSSL_EVP_VerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
function wolfSSL_EVP_add_cipher (line 1562) | int wolfSSL_EVP_add_cipher(const WOLFSSL_EVP_CIPHER *cipher)
function WOLFSSL_EVP_PKEY (line 1570) | WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_mac_key(int type, ENGINE* e,
function wolfSSL_evp_digest_pk_init (line 1613) | static int wolfSSL_evp_digest_pk_init(WOLFSSL_EVP_MD_CTX *ctx,
function wolfssl_evp_digest_pk_final (line 1706) | static int wolfssl_evp_digest_pk_final(WOLFSSL_EVP_MD_CTX *ctx,
function wolfssl_mac_len (line 1736) | static int wolfssl_mac_len(unsigned char macType)
function wolfSSL_EVP_DigestSignInit (line 1789) | int wolfSSL_EVP_DigestSignInit(WOLFSSL_EVP_MD_CTX *ctx,
function wolfSSL_EVP_DigestSignUpdate (line 1804) | int wolfSSL_EVP_DigestSignUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *d,
function wolfSSL_EVP_DigestSignFinal (line 1815) | int wolfSSL_EVP_DigestSignFinal(WOLFSSL_EVP_MD_CTX *ctx, unsigned char *...
function wolfSSL_EVP_DigestVerifyInit (line 1909) | int wolfSSL_EVP_DigestVerifyInit(WOLFSSL_EVP_MD_CTX *ctx,
function wolfSSL_EVP_DigestVerifyUpdate (line 1924) | int wolfSSL_EVP_DigestVerifyUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *d,
function wolfSSL_EVP_DigestVerifyFinal (line 1936) | int wolfSSL_EVP_DigestVerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
function XGETPASSWD (line 2008) | static int XGETPASSWD(char* buf, int bufSz) {
function wolfSSL_EVP_read_pw_string (line 2065) | int wolfSSL_EVP_read_pw_string(char* buf, int bufSz, const char* banner,...
function wolfSSL_PKCS5_PBKDF2_HMAC_SHA1 (line 2078) | int wolfSSL_PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
function WOLFSSL_API (line 2104) | WOLFSSL_API int wolfSSL_PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
FILE: src/wolfcrypt/src/fe_low_mem.c
function fprime_copy (line 43) | void fprime_copy(byte *x, const byte *a)
function lm_copy (line 51) | void lm_copy(byte* x, const byte* a)
function fe_init (line 63) | void fe_init(void)
function xc_double (line 71) | static void xc_double(byte *x3, byte *z3,
function xc_diffadd (line 102) | static void xc_diffadd(byte *x5, byte *z5,
function curve25519 (line 144) | int curve25519(byte *result, byte *e, byte *q)
function raw_add (line 191) | static void raw_add(byte *x, const byte *p)
function raw_try_sub (line 204) | static void raw_try_sub(byte *x, const byte *p)
function prime_msb (line 220) | static int prime_msb(const byte *p)
function fprime_select (line 247) | void fprime_select(byte *dst, const byte *zero, const byte *one, byte co...
function fprime_add (line 257) | void fprime_add(byte *r, const byte *a, const byte *modulus)
function fprime_sub (line 264) | void fprime_sub(byte *r, const byte *a, const byte *modulus)
function fprime_mul (line 272) | void fprime_mul(byte *r, const byte *a, const byte *b,
function fe_load (line 299) | void fe_load(byte *x, word32 c)
function fe_normalize (line 313) | void fe_normalize(byte *x)
function fe_select (line 349) | void fe_select(byte *dst,
function lm_add (line 361) | void lm_add(byte* r, const byte* a, const byte* b)
function lm_sub (line 385) | void lm_sub(byte* r, const byte* a, const byte* b)
function lm_neg (line 410) | void lm_neg(byte* r, const byte* a)
function fe_mul__distinct (line 435) | void fe_mul__distinct(byte *r, const byte *a, const byte *b)
function lm_mul (line 465) | void lm_mul(byte *r, const byte* a, const byte *b)
function fe_mul_c (line 474) | void fe_mul_c(byte *r, const byte *a, word32 b)
function fe_inv__distinct (line 497) | void fe_inv__distinct(byte *r, const byte *x)
function lm_invert (line 548) | void lm_invert(byte *r, const byte *x)
function exp2523 (line 560) | static void exp2523(byte *r, const byte *x, byte *s)
function fe_sqrt (line 588) | void fe_sqrt(byte *r, const byte *a)
FILE: src/wolfcrypt/src/fe_operations.c
function load_3 (line 62) | uint64_t load_3(const unsigned char *in)
function load_4 (line 72) | uint64_t load_4(const unsigned char *in)
function fe_1 (line 87) | void fe_1(fe h)
function fe_0 (line 106) | void fe_0(fe h)
function fe_init (line 125) | void fe_init(void)
function curve25519 (line 132) | int curve25519(byte* q, byte* n, byte* p)
function fe_sq (line 225) | void fe_sq(fe h,const fe f)
function fe_add (line 370) | void fe_add(fe h,const fe f,const fe g)
function fe_tobytes (line 440) | void fe_tobytes(unsigned char *s,const fe h)
function fe_sub (line 546) | void fe_sub(fe h,const fe f,const fe g)
function fe_frombytes (line 597) | void fe_frombytes(fe h,const unsigned char *s)
function fe_invert (line 646) | void fe_invert(fe out,const fe z)
function fe_copy (line 686) | void fe_copy(fe h,const fe f)
function fe_mul (line 743) | void fe_mul(fe h,const fe f,const fe g)
function fe_cswap (line 970) | void fe_cswap(fe f, fe g, int b)
function fe_mul121666 (line 1047) | void fe_mul121666(fe h,fe f)
function fe_sq2 (line 1120) | void fe_sq2(fe h,const fe f)
function fe_pow22523 (line 1264) | void fe_pow22523(fe out,const fe z)
function fe_neg (line 1308) | void fe_neg(fe h,const fe f)
function fe_isnonzero (line 1350) | int fe_isnonzero(const fe f)
function fe_isnegative (line 1366) | int fe_isnegative(const fe f)
function fe_cmov (line 1381) | void fe_cmov(fe f, const fe g, int b)
FILE: src/wolfcrypt/src/ge_low_mem.c
function ge_compress_key (line 72) | int ge_compress_key(byte* out, const byte* xIn, const byte* yIn,
function word32 (line 94) | static word32 lt(word32 a,word32 b) /* 16-bit inputs */
function reduce_add_sub (line 104) | static void reduce_add_sub(word32 *r)
function barrett_reduce (line 126) | static void barrett_reduce(word32* r, word32 x[64])
function sc_reduce (line 179) | void sc_reduce(unsigned char x[64])
function sc_muladd (line 190) | void sc_muladd(byte* out, const byte* a, const byte* b, const byte* c)
function ed25519_add (line 271) | void ed25519_add(ge_p3 *r,
function ed25519_double (line 347) | void ed25519_double(ge_p3 *r, const ge_p3 *p)
function ed25519_smult (line 415) | void ed25519_smult(ge_p3 *r_out, const ge_p3 *p, const byte *e)
function ge_scalarmult_base (line 438) | void ge_scalarmult_base(ge_p3 *R,const unsigned char *nonce)
function ge_p3_tobytes (line 445) | void ge_p3_tobytes(unsigned char *s,const ge_p3 *h)
function ge_tobytes (line 467) | void ge_tobytes(unsigned char *s,const ge_p2 *h)
function ge_frombytes_negate_vartime (line 492) | int ge_frombytes_negate_vartime(ge_p3 *p,const unsigned char *s)
function ge_double_scalarmult_vartime (line 538) | int ge_double_scalarmult_vartime(ge_p2* R, const unsigned char *h,
FILE: src/wolfcrypt/src/ge_operations.c
function load_3 (line 99) | uint64_t load_3(const unsigned char *in)
function load_4 (line 109) | uint64_t load_4(const unsigned char *in)
function sc_reduce (line 129) | void sc_reduce(byte* s)
function sc_muladd (line 332) | void sc_muladd(byte* s, const byte* a, const byte* b, const byte* c)
function load_6 (line 642) | static uint64_t load_6(const byte* a)
function load_7 (line 654) | static uint64_t load_7(const byte* a)
function sc_reduce (line 681) | void sc_reduce(byte* s)
function sc_muladd (line 791) | void sc_muladd(byte* s, const byte* a, const byte* b, const byte* c)
function ge_compress_key (line 934) | int ge_compress_key(byte* out, const byte* xIn, const byte* yIn, word32 ...
function WC_INLINE (line 964) | static WC_INLINE void ge_add(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
function equal (line 988) | static unsigned char equal(signed char b,signed char c)
function negative (line 1000) | static unsigned char negative(signed char b)
function WC_INLINE (line 1006) | static WC_INLINE void cmov(ge_precomp *t,const ge_precomp *u,unsigned ch...
function ge_select (line 9096) | static void ge_select(ge_precomp *t,int pos,signed char b)
function ge_scalarmult_base (line 9128) | void ge_scalarmult_base(ge_p3 *h,const unsigned char *a)
function slide (line 9196) | static void slide(signed char *r,const unsigned char *a)
function ge_double_scalarmult_vartime (line 9408) | int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a,
function ge_frombytes_negate_vartime (line 9505) | int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s)
function WC_INLINE (line 9553) | static WC_INLINE void ge_madd(ge_p1p1 *r,const ge_p3 *p,const ge_precomp...
function WC_INLINE (line 9580) | static WC_INLINE void ge_msub(ge_p1p1 *r,const ge_p3 *p,const ge_precomp...
function ge_p1p1_to_p2 (line 9606) | static void ge_p1p1_to_p2(ge_p2 *r,const ge_p1p1 *p)
function WC_INLINE (line 9624) | static WC_INLINE void ge_p1p1_to_p3(ge_p3 *r,const ge_p1p1 *p)
function ge_p2_0 (line 9639) | static void ge_p2_0(ge_p2 *h)
function WC_INLINE (line 9653) | static WC_INLINE void ge_p2_dbl(ge_p1p1 *r,const ge_p2 *p)
function ge_p3_dbl (line 9678) | static void ge_p3_dbl(ge_p1p1 *r,const ge_p3 *p)
function WC_INLINE (line 9713) | static WC_INLINE void ge_p3_to_cached(ge_cached *r,const ge_p3 *p)
function ge_p3_to_p2 (line 9727) | static void ge_p3_to_p2(ge_p2 *r,const ge_p3 *p)
function ge_p3_tobytes (line 9736) | void ge_p3_tobytes(unsigned char *s,const ge_p3 *h)
function ge_precomp_0 (line 9752) | static void ge_precomp_0(ge_precomp *h)
function WC_INLINE (line 9766) | static WC_INLINE void ge_sub(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
function ge_tobytes (line 9789) | void ge_tobytes(unsigned char *s,const ge_p2 *h)
FILE: src/wolfcrypt/src/hash.c
type Hash_Sum (line 46) | enum Hash_Sum {
function wc_HashTypeConvert (line 62) | enum wc_HashType wc_HashTypeConvert(int hashType)
function wc_HashGetOID (line 132) | int wc_HashGetOID(enum wc_HashType hash_type)
function wc_OidGetHash (line 206) | enum wc_HashType wc_OidGetHash(int oid)
function wc_HashGetDigestSize (line 270) | int wc_HashGetDigestSize(enum wc_HashType hash_type)
function wc_HashGetBlockSize (line 359) | int wc_HashGetBlockSize(enum wc_HashType hash_type)
function wc_Hash (line 447) | int wc_Hash(enum wc_HashType hash_type, const byte* data,
function wc_HashInit_ex (line 540) | int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
function wc_HashInit (line 615) | int wc_HashInit(wc_HashAlg* hash, enum wc_HashType type)
function wc_HashUpdate (line 620) | int wc_HashUpdate(wc_HashAlg* hash, enum wc_HashType type, const byte* d...
function wc_HashFinal (line 695) | int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type, byte* out)
function wc_HashFree (line 769) | int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
function wc_HashSetFlags (line 854) | int wc_HashSetFlags(wc_HashAlg* hash, enum wc_HashType type, word32 flags)
function wc_HashGetFlags (line 915) | int wc_HashGetFlags(wc_HashAlg* hash, enum wc_HashType type, word32* flags)
function wc_Md5Hash (line 982) | int wc_Md5Hash(const byte* data, word32 len, byte* hash)
function wc_ShaHash (line 1019) | int wc_ShaHash(const byte* data, word32 len, byte* hash)
function wc_Sha224Hash (line 1056) | int wc_Sha224Hash(const byte* data, word32 len, byte* hash)
function wc_Sha256Hash (line 1094) | int wc_Sha256Hash(const byte* data, word32 len, byte* hash)
function wc_Sha512Hash (line 1136) | int wc_Sha512Hash(const byte* data, word32 len, byte* hash)
function wc_Sha384Hash (line 1174) | int wc_Sha384Hash(const byte* data, word32 len, byte* hash)
function wc_Sha3_224Hash (line 1213) | int wc_Sha3_224Hash(const byte* data, word32 len, byte* hash)
function wc_Sha3_256Hash (line 1251) | int wc_Sha3_256Hash(const byte* data, word32 len, byte* hash)
function wc_Sha3_384Hash (line 1289) | int wc_Sha3_384Hash(const byte* data, word32 len, byte* hash)
function wc_Sha3_512Hash (line 1327) | int wc_Sha3_512Hash(const byte* data, word32 len, byte* hash)
function wc_PRF (line 1374) | int wc_PRF(byte* result, word32 resLen, const byte* secret,
function wc_PRF_TLSv1 (line 1500) | int wc_PRF_TLSv1(byte* digest, word32 digLen, const byte* secret,
function wc_PRF_TLS (line 1591) | int wc_PRF_TLS(byte* digest, word32 digLen, const byte* secret, word32 s...
FILE: src/wolfcrypt/src/hc128.c
function generate_keystream (line 91) | static void generate_keystream(HC128* ctx, word32* keystream)
function setup_update (line 168) | static void setup_update(HC128* ctx) /*each time 16 steps*/
function Hc128_SetIV (line 234) | static void Hc128_SetIV(HC128* ctx, const byte* inIv)
function WC_INLINE (line 275) | static WC_INLINE int DoKey(HC128* ctx, const byte* key, const byte* iv)
function wc_Hc128_SetHeap (line 291) | int wc_Hc128_SetHeap(HC128* ctx, void* heap)
function wc_Hc128_SetKey (line 306) | int wc_Hc128_SetKey(HC128* ctx, const byte* key, const byte* iv)
function WC_INLINE (line 338) | static WC_INLINE int DoProcess(HC128* ctx, byte* output, const byte* input,
function wc_Hc128_Process (line 389) | int wc_Hc128_Process(HC128* ctx, byte* output, const byte* input, word32...
FILE: src/wolfcrypt/src/hmac.c
function wc_HmacSetKey (line 64) | int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 keySz)
function wc_HmacUpdate (line 74) | int wc_HmacUpdate(Hmac* hmac, const byte* in, word32 sz)
function wc_HmacFinal (line 82) | int wc_HmacFinal(Hmac* hmac, byte* out)
function wolfSSL_GetHmacMaxSize (line 90) | int wolfSSL_GetHmacMaxSize(void)
function wc_HmacInit (line 95) | int wc_HmacInit(Hmac* hmac, void* heap, int devId)
function wc_HmacFree (line 104) | void wc_HmacFree(Hmac* hmac)
function wc_HKDF (line 112) | int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
function wc_HmacSizeByType (line 125) | int wc_HmacSizeByType(int type)
function _InitHmac (line 200) | int _InitHmac(Hmac* hmac, int type, void* heap)
function wc_HmacSetKey (line 279) | int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
function HmacKeyInnerHash (line 565) | static int HmacKeyInnerHash(Hmac* hmac)
function wc_HmacUpdate (line 648) | int wc_HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
function wc_HmacFinal (line 751) | int wc_HmacFinal(Hmac* hmac, byte* hash)
function wc_HmacInit (line 974) | int wc_HmacInit(Hmac* hmac, void* heap, int devId)
function wc_HmacInit_Id (line 999) | int wc_HmacInit_Id(Hmac* hmac, unsigned char* id, int len, void* heap,
function wc_HmacFree (line 1021) | void wc_HmacFree(Hmac* hmac)
function wolfSSL_GetHmacMaxSize (line 1140) | int wolfSSL_GetHmacMaxSize(void)
function wc_HKDF_Extract (line 1157) | int wc_HKDF_Extract(int type, const byte* salt, word32 saltSz,
function wc_HKDF_Expand (line 1202) | int wc_HKDF_Expand(int type, const byte* inKey, word32 inKeySz,
function wc_HKDF (line 1261) | int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
FILE: src/wolfcrypt/src/idea.c
function WC_INLINE (line 47) | static WC_INLINE word16 idea_mult(word16 x, word16 y)
function WC_INLINE (line 69) | static WC_INLINE word16 idea_invmod(word16 x)
function wc_IdeaSetKey (line 118) | int wc_IdeaSetKey(Idea *idea, const byte* key, word16 keySz,
function wc_IdeaSetIV (line 182) | int wc_IdeaSetIV(Idea *idea, const byte* iv)
function wc_IdeaCipher (line 197) | int wc_IdeaCipher(Idea *idea, byte* out, const byte* in)
function wc_IdeaCbcEncrypt (line 252) | int wc_IdeaCbcEncrypt(Idea *idea, byte* out, const byte* in, word32 len)
function wc_IdeaCbcDecrypt (line 277) | int wc_IdeaCbcDecrypt(Idea *idea, byte* out, const byte* in, word32 len)
FILE: src/wolfcrypt/src/integer.c
function bn_reverse (line 91) | static void
function word32 (line 109) | word32 CheckRunTimeSettings(void)
function mp_init_multi (line 116) | int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
function mp_init (line 161) | int mp_init (mp_int * a)
function mp_clear (line 184) | void mp_clear (mp_int * a)
function mp_free (line 207) | void mp_free (mp_int * a)
function mp_forcezero (line 221) | void mp_forcezero(mp_int * a)
function mp_unsigned_bin_size (line 247) | int mp_unsigned_bin_size (mp_int * a)
function mp_count_bits (line 255) | int mp_count_bits (mp_int * a)
function mp_leading_bit (line 278) | int mp_leading_bit (mp_int * a)
function mp_to_unsigned_bin_at_pos (line 299) | int mp_to_unsigned_bin_at_pos(int x, mp_int *t, unsigned char *b)
function mp_to_unsigned_bin (line 317) | int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
function mp_to_unsigned_bin_len (line 337) | int mp_to_unsigned_bin_len(mp_int * a, unsigned char *b, int c)
function mp_init_copy (line 350) | int mp_init_copy (mp_int * a, mp_int * b)
function mp_copy (line 367) | int mp_copy (mp_int * a, mp_int * b)
function mp_grow (line 418) | int mp_grow (mp_int * a, int size)
function mp_div_2d (line 457) | int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
function mp_zero (line 510) | void mp_zero (mp_int * a)
function mp_clamp (line 535) | void mp_clamp (mp_int * a)
function mp_exch (line 554) | void mp_exch (mp_int * a, mp_int * b)
function mp_rshb (line 565) | void mp_rshb (mp_int *c, int x)
function mp_rshd (line 600) | void mp_rshd (mp_int * a, int b)
function mp_mod_2d (line 652) | int mp_mod_2d (mp_int * a, int b, mp_int * c)
function mp_read_unsigned_bin (line 686) | int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
function mp_mul_2d (line 721) | int mp_mul_2d (mp_int * a, int b, mp_int * c)
function mp_lshd (line 786) | int mp_lshd (mp_int * a, int b)
function mp_exptmod_ex (line 946) | int mp_exptmod_ex (mp_int * G, mp_int * X, int digits, mp_int * P, mp_in...
function mp_abs (line 956) | int mp_abs (mp_int * a, mp_int * b)
function mp_invmod (line 978) | int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
function fast_mp_invmod (line 1007) | int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
function mp_invmod_slow (line 1147) | int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
function mp_cmp_mag (line 1329) | int mp_cmp_mag (mp_int * a, mp_int * b)
function mp_cmp (line 1364) | int mp_cmp (mp_int * a, mp_int * b)
function mp_cmp_d (line 1386) | int mp_cmp_d(mp_int * a, mp_digit b)
function mp_set (line 1414) | int mp_set (mp_int * a, mp_digit b)
function mp_is_bit_set (line 1427) | int mp_is_bit_set (mp_int *a, mp_digit b)
function mp_mod (line 1439) | int mp_mod (mp_int * a, mp_int * b, mp_int * c)
function mp_div (line 1467) | int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
function mp_div_2 (line 1540) | int mp_div_2(mp_int * a, mp_int * b)
function mp_add (line 1588) | int mp_add (mp_int * a, mp_int * b, mp_int * c)
function s_mp_add (line 1620) | int s_mp_add (mp_int * a, mp_int * b, mp_int * c)
function s_mp_sub (line 1708) | int s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
function mp_sub (line 1780) | int mp_sub (mp_int * a, mp_int * b, mp_int * c)
function mp_reduce_is_2k_l (line 1817) | int mp_reduce_is_2k_l(mp_int *a)
function mp_reduce_is_2k (line 1840) | int mp_reduce_is_2k(mp_int *a)
function mp_dr_is_modulus (line 1871) | int mp_dr_is_modulus(mp_int *a)
function mp_exptmod_fast (line 1907) | int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y,
function mp_exptmod_base_2 (line 2232) | int mp_exptmod_base_2(mp_int * X, mp_int * P, mp_int * Y)
function mp_montgomery_setup (line 2388) | int mp_montgomery_setup (mp_int * n, mp_digit * rho)
function fast_mp_montgomery_reduce (line 2434) | int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
function mp_montgomery_reduce (line 2593) | int mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
function mp_dr_setup (line 2690) | void mp_dr_setup(mp_int *a, mp_digit *d)
function mp_dr_reduce (line 2714) | int mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k)
function mp_reduce_2k (line 2776) | int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d)
function mp_reduce_2k_setup (line 2818) | int mp_reduce_2k_setup(mp_int *a, mp_digit *d)
function mp_set_bit (line 2845) | int mp_set_bit (mp_int * a, int b)
function mp_2expt (line 2869) | int mp_2expt (mp_int * a, int b)
function mp_mul_d (line 2878) | int mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
function mp_mulmod (line 2939) | int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
function mp_submod (line 2960) | int mp_submod(mp_int* a, mp_int* b, mp_int* c, mp_int* d)
function mp_addmod (line 2980) | int mp_addmod(mp_int* a, mp_int* b, mp_int* c, mp_int* d)
function mp_sqr (line 3000) | int mp_sqr (mp_int * a, mp_int * b)
function mp_mul (line 3028) | int mp_mul (mp_int * a, mp_int * b, mp_int * c)
function mp_mul_2 (line 3063) | int mp_mul_2(mp_int * a, mp_int * b)
function mp_div_3 (line 3125) | int mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
function mp_init_size (line 3182) | int mp_init_size (mp_int * a, int size)
function fast_s_mp_sqr (line 3223) | int fast_s_mp_sqr (mp_int * a, mp_int * b)
function fast_s_mp_mul_digs (line 3342) | int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
function s_mp_sqr (line 3431) | int s_mp_sqr (mp_int * a, mp_int * b)
function s_mp_mul_digs (line 3498) | int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
function mp_montgomery_calc_normalization (line 3570) | int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
function s_mp_exptmod (line 3611) | int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int re...
function mp_reduce_setup (line 3843) | int mp_reduce_setup (mp_int * a, mp_int * b)
function mp_reduce (line 3858) | int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
function mp_reduce_2k_l (line 3939) | int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d)
function mp_reduce_2k_setup_l (line 3979) | int mp_reduce_2k_setup_l(mp_int *a, mp_int *d)
function s_mp_mul_high_digs (line 4005) | int s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
function fast_s_mp_mul_high_digs (line 4072) | int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
function mp_set_int (line 4166) | int mp_set_int (mp_int * a, unsigned long b)
function mp_sqrmod (line 4203) | int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
function mp_add_d (line 4230) | int mp_add_d (mp_int* a, mp_digit b, mp_int* c)
function mp_sub_d (line 4322) | int mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
function mp_cnt_lsb (line 4403) | int mp_cnt_lsb(mp_int *a)
function s_is_power_of_two (line 4433) | static int s_is_power_of_two(mp_digit b, int *p)
function mp_div_d (line 4452) | static int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
function mp_mod_d (line 4537) | int mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
function mp_prime_miller_rabin (line 4595) | static int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
function mp_prime_is_divisible (line 4697) | static int mp_prime_is_divisible (mp_int * a, int *result)
function mp_prime_is_prime (line 4724) | int mp_prime_is_prime (mp_int * a, int t, int *result)
function mp_prime_is_prime_ex (line 4790) | int mp_prime_is_prime_ex (mp_int * a, int t, int *result, WC_RNG *rng)
function mp_rand_prime (line 4890) | int mp_rand_prime(mp_int* N, int len, WC_RNG* rng, void* heap)
function mp_lcm (line 4959) | int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
function mp_gcd (line 5001) | int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
function mp_read_radix (line 5098) | int mp_read_radix (mp_int * a, const char *str, int radix)
function mp_radix_size (line 5171) | int mp_radix_size (mp_int *a, int radix, int *size)
function mp_toradix (line 5227) | int mp_toradix (mp_int *a, char *str, int radix)
function mp_dump (line 5286) | void mp_dump(const char* desc, mp_int* a, byte verbose)
FILE: src/wolfcrypt/src/logging.c
type wc_error_queue (line 42) | struct wc_error_queue {
type wc_error_queue (line 51) | struct wc_error_queue
type wc_error_queue (line 52) | struct wc_error_queue
type wc_error_queue (line 53) | struct wc_error_queue
function WC_INLINE (line 104) | static WC_INLINE double current_time(int reset)
type log (line 122) | struct log
function wolfSSL_SetLoggingCb (line 129) | int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
function wolfSSL_Debugging_ON (line 141) | int wolfSSL_Debugging_ON(void)
function wolfSSL_Debugging_OFF (line 155) | void wolfSSL_Debugging_OFF(void)
function WOLFSSL_START (line 167) | void WOLFSSL_START(int funcNum)
function WOLFSSL_END (line 176) | void WOLFSSL_END(int funcNum)
function WOLFSSL_TIME (line 185) | void WOLFSSL_TIME(int count)
function wolfssl_log (line 229) | static void wolfssl_log(const int logLevel, const char *const logMessage)
function WOLFSSL_MSG (line 270) | void WOLFSSL_MSG(const char* msg)
function WOLFSSL_BUFFER (line 279) | void WOLFSSL_BUFFER(const byte* buffer, word32 length)
function WOLFSSL_ENTER (line 326) | void WOLFSSL_ENTER(const char* msg)
function WOLFSSL_LEAVE (line 336) | void WOLFSSL_LEAVE(const char* msg, int ret)
function WOLFSSL_ERROR_MSG (line 420) | void WOLFSSL_ERROR_MSG(const char* msg)
function wc_LoggingInit (line 434) | int wc_LoggingInit(void)
function wc_LoggingCleanup (line 449) | int wc_LoggingCleanup(void)
function wc_PeekErrorNode (line 474) | int wc_PeekErrorNode(int idx, const char **file, const char **reason,
function wc_PullErrorNode (line 535) | int wc_PullErrorNode(const char **file, const char **reason, int *line)
function wc_AddErrorNode (line 575) | int wc_AddErrorNode(int error, int line, char* buf, char* file)
function wc_RemoveErrorNode (line 658) | void wc_RemoveErrorNode(int idx)
function wc_ClearErrorNodes (line 694) | void wc_ClearErrorNodes(void)
function wc_SetLoggingHeap (line 724) | int wc_SetLoggingHeap(void* h)
function wc_ERR_remove_state (line 740) | int wc_ERR_remove_state(void)
function wc_ERR_print_errors_fp (line 769) | void wc_ERR_print_errors_fp(XFILE fp)
FILE: src/wolfcrypt/src/md2.c
function wc_InitMd2 (line 43) | void wc_InitMd2(Md2* md2)
function wc_Md2Update (line 52) | void wc_Md2Update(Md2* md2, const byte* data, word32 len)
function wc_Md2Final (line 117) | void wc_Md2Final(Md2* md2, byte* hash)
function wc_Md2Hash (line 135) | int wc_Md2Hash(const byte* data, word32 len, byte* hash)
FILE: src/wolfcrypt/src/md4.c
function wc_InitMd4 (line 40) | void wc_InitMd4(Md4* md4)
function Transform (line 53) | static void Transform(Md4* md4)
function WC_INLINE (line 133) | static WC_INLINE void AddLength(Md4* md4, word32 len)
function wc_Md4Update (line 141) | void wc_Md4Update(Md4* md4, const byte* data, word32 len)
function wc_Md4Final (line 166) | void wc_Md4Final(Md4* md4, byte* hash)
FILE: src/wolfcrypt/src/md5.c
function wc_InitMd5_ex (line 56) | int wc_InitMd5_ex(wc_Md5* md5, void* heap, int devId)
function wc_Md5Update (line 70) | int wc_Md5Update(wc_Md5* md5, const byte* data, word32 len)
function wc_Md5Final (line 87) | int wc_Md5Final(wc_Md5* md5, byte* hash)
function Transform (line 123) | static int Transform(wc_Md5* md5, const byte* data)
function Transform_Len (line 137) | static int Transform_Len(wc_Md5* md5, const byte* data, word32 len)
function Transform (line 196) | static int Transform(wc_Md5* md5, const byte* data)
function WC_INLINE (line 285) | static WC_INLINE void AddLength(wc_Md5* md5, word32 len)
function _InitMd5 (line 293) | static int _InitMd5(wc_Md5* md5)
function wc_InitMd5_ex (line 312) | int wc_InitMd5_ex(wc_Md5* md5, void* heap, int devId)
function wc_Md5Update (line 335) | int wc_Md5Update(wc_Md5* md5, const byte* data, word32 len)
function wc_Md5Final (line 436) | int wc_Md5Final(wc_Md5* md5, byte* hash)
function wc_InitMd5 (line 495) | int wc_InitMd5(wc_Md5* md5)
function wc_Md5Free (line 503) | void wc_Md5Free(wc_Md5* md5)
function wc_Md5GetHash (line 516) | int wc_Md5GetHash(wc_Md5* md5, byte* hash)
function wc_Md5Copy (line 532) | int wc_Md5Copy(wc_Md5* src, wc_Md5* dst)
function wc_Md5SetFlags (line 555) | int wc_Md5SetFlags(wc_Md5* md5, word32 flags)
function wc_Md5GetFlags (line 562) | int wc_Md5GetFlags(wc_Md5* md5, word32* flags)
FILE: src/wolfcrypt/src/memory.c
function wolfSSL_SetMemFailCount (line 83) | void wolfSSL_SetMemFailCount(int memFailCount)
function wolfSSL_SetAllocators (line 102) | int wolfSSL_SetAllocators(wolfSSL_Malloc_cb mf,
function wolfSSL_GetAllocators (line 112) | int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf,
function wolfSSL_Free (line 184) | void wolfSSL_Free(void *ptr)
type wc_Memory (line 241) | struct wc_Memory {
function create_memory_buckets (line 251) | static int create_memory_buckets(byte* buffer, word32 bufSz,
function wolfSSL_init_memory_heap (line 292) | int wolfSSL_init_memory_heap(WOLFSSL_HEAP* heap)
function wc_LoadStaticMemory (line 314) | int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
function wolfSSL_load_static_memory (line 379) | int wolfSSL_load_static_memory(byte* buffer, word32 sz, int flag,
function wolfSSL_MemoryPaddingSz (line 451) | int wolfSSL_MemoryPaddingSz(void)
function wolfSSL_StaticBufferSz (line 461) | int wolfSSL_StaticBufferSz(byte* buffer, word32 sz, int flag)
function FreeFixedIO (line 514) | int FreeFixedIO(WOLFSSL_HEAP* heap, wc_Memory** io)
function SetFixedIO (line 537) | int SetFixedIO(WOLFSSL_HEAP* heap, wc_Memory** io)
function wolfSSL_GetMemStats (line 558) | int wolfSSL_GetMemStats(WOLFSSL_HEAP* heap, WOLFSSL_MEM_STATS* stats)
function wolfSSL_Free (line 737) | void wolfSSL_Free(void *ptr, void* heap, int type)
function XFREE (line 1015) | void XFREE(void *p, void* heap, int type)
function xfree (line 1087) | void xfree(void *p, void* heap, int type, const char* func, const char* ...
function __cyg_profile_func_enter (line 1110) | void __attribute__((no_instrument_function))
function __cyg_profile_func_exit (line 1118) | void __attribute__((no_instrument_function))
FILE: src/wolfcrypt/src/misc.c
function word32 (line 69) | word32 rotlFixed(word32 x, word32 y)
function word32 (line 74) | word32 rotrFixed(word32 x, word32 y)
function word32 (line 81) | word32 rotlFixed(word32 x, word32 y)
function word32 (line 87) | word32 rotrFixed(word32 x, word32 y)
function word32 (line 95) | word32 ByteReverseWord32(word32 value)
function ByteReverseWords (line 119) | void ByteReverseWords(word32* out, const word32* in,
function word64 (line 133) | word64 rotlFixed64(word64 x, word64 y)
function word64 (line 139) | word64 rotrFixed64(word64 x, word64 y)
function word64 (line 145) | word64 ByteReverseWord64(word64 value)
function ByteReverseWords64 (line 162) | void ByteReverseWords64(word64* out, const word64* in,
function XorWords (line 175) | void XorWords(wolfssl_word* r, const wolfssl_word* a, word32 n)
function xorbuf (line 183) | void xorbuf(void* buf, const void* mask, word32 count)
function ForceZero (line 200) | void ForceZero(const void* mem, word32 len)
function ConstantCompare (line 226) | int ConstantCompare(const byte* a, const byte* b, int length)
function word32 (line 245) | word32 min(word32 a, word32 b)
function word32 (line 256) | word32 max(word32 a, word32 b)
function c32to24 (line 264) | void c32to24(word32 in, word24 out)
function c16toa (line 272) | void c16toa(word16 wc_u16, byte* c)
function c32toa (line 279) | void c32toa(word32 wc_u32, byte* c)
function c24to32 (line 290) | void c24to32(const word24 wc_u24, word32* wc_u32)
function ato24 (line 297) | void ato24(const byte* c, word32* wc_u24)
function ato16 (line 303) | void ato16(const byte* c, word16* wc_u16)
function ato32 (line 309) | void ato32(const byte* c, word32* wc_u32)
function word32 (line 315) | word32 btoi(byte b)
function byte (line 324) | byte ctMaskGT(int a, int b)
function byte (line 330) | byte ctMaskGTE(int a, int b)
function ctMaskIntGTE (line 336) | int ctMaskIntGTE(int a, int b)
function byte (line 342) | byte ctMaskLT(int a, int b)
function byte (line 348) | byte ctMaskLTE(int a, int b)
function byte (line 354) | byte ctMaskEq(int a, int b)
function word16 (line 359) | word16 ctMask16Eq(int a, int b)
function byte (line 365) | byte ctMaskNotEq(int a, int b)
function byte (line 371) | byte ctMaskSel(byte m, byte a, byte b)
function ctMaskSelInt (line 377) | int ctMaskSelInt(byte m, int a, int b)
function byte (line 384) | byte ctSetLTE(int a, int b)
FILE: src/wolfcrypt/src/pkcs12.c
type ContentInfo (line 77) | typedef struct ContentInfo {
type AuthenticatedSafe (line 86) | typedef struct AuthenticatedSafe {
type MacData (line 95) | typedef struct MacData {
type WC_PKCS12 (line 105) | struct WC_PKCS12 {
type WC_PKCS12_ATTRIBUTE (line 114) | typedef struct WC_PKCS12_ATTRIBUTE {
function WC_PKCS12 (line 121) | WC_PKCS12* wc_PKCS12_new(void)
function freeSafe (line 136) | static void freeSafe(AuthenticatedSafe* safe, void* heap)
function wc_PKCS12_free (line 159) | void wc_PKCS12_free(WC_PKCS12* pkcs12)
function GetSafeContent (line 193) | static int GetSafeContent(WC_PKCS12* pkcs12, const byte* input,
function GetSignData (line 354) | static int GetSignData(WC_PKCS12* pkcs12, const byte* mem, word32* idx,
function wc_PKCS12_create_mac (line 500) | static int wc_PKCS12_create_mac(WC_PKCS12* pkcs12, byte* data, word32 da...
function wc_PKCS12_verify (line 573) | static int wc_PKCS12_verify(WC_PKCS12* pkcs12, byte* data, word32 dataSz,
function wc_d2i_PKCS12 (line 623) | int wc_d2i_PKCS12(const byte* der, word32 derSz, WC_PKCS12* pkcs12)
function wc_i2d_PKCS12 (line 703) | int wc_i2d_PKCS12(WC_PKCS12* pkcs12, byte** der, int* derSz)
function wc_FreeCertList (line 886) | void wc_FreeCertList(WC_DerCertList* list, void* heap)
function freeDecCertList (line 907) | static void freeDecCertList(WC_DerCertList** list, byte** pkey, word32* ...
function wc_PKCS12_parse (line 955) | int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
function wc_PKCS12_shroud_key (line 1390) | static int wc_PKCS12_shroud_key(WC_PKCS12* pkcs12, WC_RNG* rng,
function wc_PKCS12_create_key_bag (line 1484) | static int wc_PKCS12_create_key_bag(WC_PKCS12* pkcs12, WC_RNG* rng,
function wc_PKCS12_create_cert_bag (line 1569) | static int wc_PKCS12_create_cert_bag(WC_PKCS12* pkcs12,
function wc_PKCS12_encrypt_content (line 1677) | static int wc_PKCS12_encrypt_content(WC_PKCS12* pkcs12, WC_RNG* rng,
function WC_PKCS12 (line 1855) | WC_PKCS12* wc_PKCS12_create(char* pass, word32 passSz, char* name,
function wc_PKCS12_SetHeap (line 2296) | int wc_PKCS12_SetHeap(WC_PKCS12* pkcs12, void* heap)
FILE: src/wolfcrypt/src/pkcs7.c
type pkcs7Direction (line 55) | typedef enum {
type PKCS7SignerInfo (line 63) | struct PKCS7SignerInfo {
type PKCS7State (line 73) | struct PKCS7State {
type PKCS7_MaxLen (line 111) | enum PKCS7_MaxLen {
function wc_PKCS7_CreateStream (line 117) | static int wc_PKCS7_CreateStream(PKCS7* pkcs7)
function wc_PKCS7_ResetStream (line 133) | static void wc_PKCS7_ResetStream(PKCS7* pkcs7)
function wc_PKCS7_FreeStream (line 191) | static void wc_PKCS7_FreeStream(PKCS7* pkcs7)
function wc_PKCS7_GrowStream (line 209) | static int wc_PKCS7_GrowStream(PKCS7* pkcs7, word32 newSz)
function wc_PKCS7_AddDataToStream (line 236) | static int wc_PKCS7_AddDataToStream(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_GetMaxStream (line 320) | static long wc_PKCS7_GetMaxStream(PKCS7* pkcs7, byte flag, byte* in,
function wc_PKCS7_StreamStoreVar (line 375) | static void wc_PKCS7_StreamStoreVar(PKCS7* pkcs7, word32 var1, int var2,
function wc_PKCS7_StreamGetVar (line 386) | static void wc_PKCS7_StreamGetVar(PKCS7* pkcs7, word32* var1, int* var2,
function wc_PKCS7_StreamEndCase (line 399) | static int wc_PKCS7_StreamEndCase(PKCS7* pkcs7, word32* tmpIdx, word32* ...
function wc_PKCS7_ChangeState (line 485) | static void wc_PKCS7_ChangeState(PKCS7* pkcs7, int newState)
function wc_SetContentType (line 501) | static int wc_SetContentType(int pkcs7TypeOID, byte* output, word32 outp...
function wc_GetContentType (line 630) | static int wc_GetContentType(const byte* input, word32* inOutIdx, word32...
function wc_PKCS7_GetOIDBlockSize (line 642) | static int wc_PKCS7_GetOIDBlockSize(int oid)
function wc_PKCS7_GetOIDKeySize (line 682) | static int wc_PKCS7_GetOIDKeySize(int oid)
function PKCS7 (line 731) | PKCS7* wc_PKCS7_New(void* heap, int devId)
function wc_PKCS7_Init (line 756) | int wc_PKCS7_Init(PKCS7* pkcs7, void* heap, int devId)
type Pkcs7Cert (line 783) | struct Pkcs7Cert {
type Pkcs7EncodedRecip (line 791) | struct Pkcs7EncodedRecip {
function wc_PKCS7_FreeCertSet (line 801) | static void wc_PKCS7_FreeCertSet(PKCS7* pkcs7)
function wc_PKCS7_GetRecipientListSize (line 826) | static int wc_PKCS7_GetRecipientListSize(PKCS7* pkcs7)
function wc_PKCS7_FreeEncodedRecipientSet (line 846) | static void wc_PKCS7_FreeEncodedRecipientSet(PKCS7* pkcs7)
function wc_PKCS7_RecipientListIncludesType (line 871) | static int wc_PKCS7_RecipientListIncludesType(PKCS7* pkcs7, int type)
function wc_PKCS7_RecipientListVersionsAllZero (line 893) | static int wc_PKCS7_RecipientListVersionsAllZero(PKCS7* pkcs7)
function wc_PKCS7_InitWithCert (line 915) | int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz)
function wc_PKCS7_AddCertificate (line 1024) | int wc_PKCS7_AddCertificate(PKCS7* pkcs7, byte* derCert, word32 derCertSz)
function wc_PKCS7_FreeDecodedAttrib (line 1051) | static void wc_PKCS7_FreeDecodedAttrib(PKCS7DecodedAttrib* attrib, void*...
function wc_PKCS7_SignerInfoNew (line 1077) | static int wc_PKCS7_SignerInfoNew(PKCS7* pkcs7)
function wc_PKCS7_SignerInfoFree (line 1095) | static void wc_PKCS7_SignerInfoFree(PKCS7* pkcs7)
function wc_PKCS7_SignerInfoSetSID (line 1111) | static int wc_PKCS7_SignerInfoSetSID(PKCS7* pkcs7, byte* in, int inSz)
function wc_PKCS7_Free (line 1133) | void wc_PKCS7_Free(PKCS7* pkcs7)
function PKCS7DecodedAttrib (line 1185) | static PKCS7DecodedAttrib* findAttrib(PKCS7* pkcs7, const byte* oid, wor...
function wc_PKCS7_GetAttributeValue (line 1240) | int wc_PKCS7_GetAttributeValue(PKCS7* pkcs7, const byte* oid, word32 oidSz,
function wc_PKCS7_EncodeData (line 1269) | int wc_PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz)
type EncodedAttrib (line 1304) | typedef struct EncodedAttrib {
type ESD (line 1313) | typedef struct ESD {
function EncodeAttributes (line 1359) | static int EncodeAttributes(EncodedAttrib* ea, int eaSz,
type FlatAttrib (line 1388) | typedef struct FlatAttrib {
function FlatAttrib (line 1396) | static FlatAttrib* NewAttrib(void* heap)
function FreeAttribArray (line 1408) | static void FreeAttribArray(PKCS7* pkcs7, FlatAttrib** arr, int rows)
function SortAttribArray (line 1431) | static int SortAttribArray(FlatAttrib** arr, int rows)
function FlattenEncodedAttribs (line 1468) | static int FlattenEncodedAttribs(PKCS7* pkcs7, FlatAttrib** derArr, int ...
function FlattenAttributes (line 1512) | static int FlattenAttributes(PKCS7* pkcs7, byte* output, EncodedAttrib* ea,
function wc_PKCS7_RsaSign (line 1571) | static int wc_PKCS7_RsaSign(PKCS7* pkcs7, byte* in, word32 inSz, ESD* esd)
function wc_PKCS7_EcdsaSign (line 1633) | static int wc_PKCS7_EcdsaSign(PKCS7* pkcs7, byte* in, word32 inSz, ESD* ...
function wc_PKCS7_BuildSignedAttributes (line 1700) | static int wc_PKCS7_BuildSignedAttributes(PKCS7* pkcs7, ESD* esd,
function wc_PKCS7_SignedDataGetEncAlgoId (line 1796) | static int wc_PKCS7_SignedDataGetEncAlgoId(PKCS7* pkcs7, int* digEncAlgoId,
function wc_PKCS7_BuildDigestInfo (line 1895) | static int wc_PKCS7_BuildDigestInfo(PKCS7* pkcs7, byte* flatSignedAttribs,
function wc_PKCS7_SignedDataBuildSignature (line 1979) | static int wc_PKCS7_SignedDataBuildSignature(PKCS7* pkcs7,
function PKCS7_EncodeSigned (line 2083) | static int PKCS7_EncodeSigned(PKCS7* pkcs7, ESD* esd,
function wc_PKCS7_EncodeSignedData_ex (line 2503) | int wc_PKCS7_EncodeSignedData_ex(PKCS7* pkcs7, const byte* hashBuf, word...
function wc_PKCS7_SetDetached (line 2549) | int wc_PKCS7_SetDetached(PKCS7* pkcs7, word16 flag)
function wc_PKCS7_NoDefaultSignedAttribs (line 2570) | int wc_PKCS7_NoDefaultSignedAttribs(PKCS7* pkcs7)
function wc_PKCS7_EncodeSignedData (line 2581) | int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz)
function wc_PKCS7_EncodeSignedFPD (line 2655) | int wc_PKCS7_EncodeSignedFPD(PKCS7* pkcs7, byte* privateKey,
function wc_PKCS7_EncodeSignedEncryptedFPD (line 2725) | int wc_PKCS7_EncodeSignedEncryptedFPD(PKCS7* pkcs7, byte* encryptKey,
function wc_PKCS7_EncodeSignedCompressedFPD (line 2835) | int wc_PKCS7_EncodeSignedCompressedFPD(PKCS7* pkcs7, byte* privateKey,
function wc_PKCS7_EncodeSignedEncryptedCompressedFPD (line 2942) | int wc_PKCS7_EncodeSignedEncryptedCompressedFPD(PKCS7* pkcs7, byte* enc...
function wc_PKCS7_SetRsaSignRawDigestCb (line 3059) | int wc_PKCS7_SetRsaSignRawDigestCb(PKCS7* pkcs7, CallbackRsaSignRawDiges...
function wc_PKCS7_RsaVerify (line 3072) | static int wc_PKCS7_RsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
function wc_PKCS7_EcdsaVerify (line 3196) | static int wc_PKCS7_EcdsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
function wc_PKCS7_BuildSignedDataDigest (line 3327) | static int wc_PKCS7_BuildSignedDataDigest(PKCS7* pkcs7, byte* signedAttrib,
function wc_PKCS7_VerifyContentMessageDigest (line 3465) | static int wc_PKCS7_VerifyContentMessageDigest(PKCS7* pkcs7,
function wc_PKCS7_SignedDataVerifySignature (line 3585) | static int wc_PKCS7_SignedDataVerifySignature(PKCS7* pkcs7, byte* sig,
function wc_PKCS7_SetPublicKeyOID (line 3741) | static int wc_PKCS7_SetPublicKeyOID(PKCS7* pkcs7, int sigOID)
function wc_PKCS7_ParseAttribs (line 3821) | static int wc_PKCS7_ParseAttribs(PKCS7* pkcs7, byte* in, int inSz)
function wc_PKCS7_AllowDegenerate (line 3905) | void wc_PKCS7_AllowDegenerate(PKCS7* pkcs7, word16 flag)
function wc_PKCS7_ParseSignerInfo (line 3927) | static int wc_PKCS7_ParseSignerInfo(PKCS7* pkcs7, byte* in, word32 inSz,
function PKCS7_VerifySignedData (line 4095) | static int PKCS7_VerifySignedData(PKCS7* pkcs7, const byte* hashBuf,
function wc_PKCS7_GetSignerSID (line 5016) | int wc_PKCS7_GetSignerSID(PKCS7* pkcs7, byte* out, word32* outSz)
function wc_PKCS7_VerifySignedData_ex (line 5050) | int wc_PKCS7_VerifySignedData_ex(PKCS7* pkcs7, const byte* hashBuf,
function wc_PKCS7_VerifySignedData (line 5058) | int wc_PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
function PKCS7_GenerateContentEncryptionKey (line 5071) | static int PKCS7_GenerateContentEncryptionKey(PKCS7* pkcs7, word32 len)
function wc_PKCS7_KeyWrap (line 5124) | static int wc_PKCS7_KeyWrap(byte* cek, word32 cekSz, byte* kek,
type WC_PKCS7_KARI (line 5180) | typedef struct WC_PKCS7_KARI {
function WC_PKCS7_KARI (line 5204) | static WC_PKCS7_KARI* wc_PKCS7_KariNew(PKCS7* pkcs7, byte direction)
function wc_PKCS7_KariFree (line 5267) | static int wc_PKCS7_KariFree(WC_PKCS7_KARI* kari)
function wc_PKCS7_KariParseRecipCert (line 5321) | static int wc_PKCS7_KariParseRecipCert(WC_PKCS7_KARI* kari, const byte* ...
function wc_PKCS7_KariGenerateEphemeralKey (line 5392) | static int wc_PKCS7_KariGenerateEphemeralKey(WC_PKCS7_KARI* kari)
function wc_PKCS7_KariGenerateSharedInfo (line 5446) | static int wc_PKCS7_KariGenerateSharedInfo(WC_PKCS7_KARI* kari, int keyW...
function wc_PKCS7_KariGenerateKEK (line 5538) | static int wc_PKCS7_KariGenerateKEK(WC_PKCS7_KARI* kari,
function wc_PKCS7_AddRecipient_KARI (line 5645) | int wc_PKCS7_AddRecipient_KARI(PKCS7* pkcs7, const byte* cert, word32 ce...
function wc_PKCS7_AddRecipient_KTRI (line 6005) | int wc_PKCS7_AddRecipient_KTRI(PKCS7* pkcs7, const byte* cert, word32 ce...
function wc_PKCS7_EncryptContent (line 6413) | static int wc_PKCS7_EncryptContent(int encryptOID, byte* key, int keySz,
function wc_PKCS7_DecryptContent (line 6556) | static int wc_PKCS7_DecryptContent(PKCS7* pkcs7, int encryptOID, byte* key,
function wc_PKCS7_GenerateBlock (line 6707) | static int wc_PKCS7_GenerateBlock(PKCS7* pkcs7, WC_RNG* rng, byte* out,
function wc_PKCS7_SetSignerIdentifierType (line 6755) | int wc_PKCS7_SetSignerIdentifierType(PKCS7* pkcs7, int type)
function wc_PKCS7_SetContentType (line 6779) | int wc_PKCS7_SetContentType(PKCS7* pkcs7, byte* contentType, word32 sz)
function wc_PKCS7_GetPadSize (line 6797) | int wc_PKCS7_GetPadSize(word32 inputSz, word32 blockSz)
function wc_PKCS7_PadData (line 6812) | int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
function wc_PKCS7_AddRecipient_ORI (line 6840) | int wc_PKCS7_AddRecipient_ORI(PKCS7* pkcs7, CallbackOriEncrypt oriEncryp...
function wc_PKCS7_GenerateKEK_PWRI (line 6934) | static int wc_PKCS7_GenerateKEK_PWRI(PKCS7* pkcs7, byte* passwd, word32 ...
function wc_PKCS7_PwriKek_KeyWrap (line 6968) | static int wc_PKCS7_PwriKek_KeyWrap(PKCS7* pkcs7, const byte* kek, word3...
function wc_PKCS7_PwriKek_KeyUnWrap (line 7046) | static int wc_PKCS7_PwriKek_KeyUnWrap(PKCS7* pkcs7, const byte* kek,
function wc_PKCS7_AddRecipient_PWRI (line 7145) | int wc_PKCS7_AddRecipient_PWRI(PKCS7* pkcs7, byte* passwd, word32 pLen,
function wc_PKCS7_SetPassword (line 7416) | int wc_PKCS7_SetPassword(PKCS7* pkcs7, byte* passwd, word32 pLen)
function wc_PKCS7_AddRecipient_KEKRI (line 7446) | int wc_PKCS7_AddRecipient_KEKRI(PKCS7* pkcs7, int keyWrapOID, byte* kek,
function wc_PKCS7_GetCMSVersion (line 7653) | static int wc_PKCS7_GetCMSVersion(PKCS7* pkcs7, int cmsContentType)
function wc_PKCS7_EncodeEnvelopedData (line 7695) | int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outp...
function wc_PKCS7_DecryptKtri (line 7955) | static int wc_PKCS7_DecryptKtri(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_KariGetOriginatorIdentifierOrKey (line 8282) | static int wc_PKCS7_KariGetOriginatorIdentifierOrKey(WC_PKCS7_KARI* kari,
function wc_PKCS7_KariGetUserKeyingMaterial (line 8370) | static int wc_PKCS7_KariGetUserKeyingMaterial(WC_PKCS7_KARI* kari,
function wc_PKCS7_KariGetKeyEncryptionAlgorithmId (line 8431) | static int wc_PKCS7_KariGetKeyEncryptionAlgorithmId(WC_PKCS7_KARI* kari,
function wc_PKCS7_KariGetSubjectKeyIdentifier (line 8467) | static int wc_PKCS7_KariGetSubjectKeyIdentifier(WC_PKCS7_KARI* kari,
function wc_PKCS7_KariGetIssuerAndSerialNumber (line 8519) | static int wc_PKCS7_KariGetIssuerAndSerialNumber(WC_PKCS7_KARI* kari,
function wc_PKCS7_KariGetRecipientEncryptedKeys (line 8606) | static int wc_PKCS7_KariGetRecipientEncryptedKeys(WC_PKCS7_KARI* kari,
function wc_PKCS7_SetOriEncryptCtx (line 8672) | int wc_PKCS7_SetOriEncryptCtx(PKCS7* pkcs7, void* ctx)
function wc_PKCS7_SetOriDecryptCtx (line 8683) | int wc_PKCS7_SetOriDecryptCtx(PKCS7* pkcs7, void* ctx)
function wc_PKCS7_SetOriDecryptCb (line 8695) | int wc_PKCS7_SetOriDecryptCb(PKCS7* pkcs7, CallbackOriDecrypt cb)
function wc_PKCS7_SetWrapCEKCb (line 8707) | int wc_PKCS7_SetWrapCEKCb(PKCS7* pkcs7, CallbackWrapCEK cb)
function wc_PKCS7_DecryptOri (line 8733) | static int wc_PKCS7_DecryptOri(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_DecryptPwri (line 8827) | static int wc_PKCS7_DecryptPwri(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_DecryptKekri (line 9056) | static int wc_PKCS7_DecryptKekri(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_DecryptKari (line 9198) | static int wc_PKCS7_DecryptKari(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_DecryptRecipientInfos (line 9465) | static int wc_PKCS7_DecryptRecipientInfos(PKCS7* pkcs7, byte* in,
function wc_PKCS7_ParseToRecipientInfoSet (line 9704) | static int wc_PKCS7_ParseToRecipientInfoSet(PKCS7* pkcs7, byte* in,
function WOLFSSL_API (line 9978) | WOLFSSL_API int wc_PKCS7_SetKey(PKCS7* pkcs7, byte* key, word32 keySz)
function WOLFSSL_API (line 9991) | WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* in,
function wc_PKCS7_EncodeAuthEnvelopedData (line 10350) | int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output,
function WOLFSSL_API (line 10859) | WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
function wc_PKCS7_EncodeEncryptedData (line 11468) | int wc_PKCS7_EncodeEncryptedData(PKCS7* pkcs7, byte* output, word32 outp...
function wc_PKCS7_DecodeUnprotectedAttributes (line 11723) | static int wc_PKCS7_DecodeUnprotectedAttributes(PKCS7* pkcs7, byte* pkiMsg,
function wc_PKCS7_DecodeEncryptedData (line 11757) | int wc_PKCS7_DecodeEncryptedData(PKCS7* pkcs7, byte* in, word32 inSz,
function wc_PKCS7_SetDecodeEncryptedCb (line 12157) | int wc_PKCS7_SetDecodeEncryptedCb(PKCS7* pkcs7,
function wc_PKCS7_SetDecodeEncryptedCtx (line 12170) | int wc_PKCS7_SetDecodeEncryptedCtx(PKCS7* pkcs7, void* ctx)
function wc_PKCS7_EncodeCompressedData (line 12182) | int wc_PKCS7_EncodeCompressedData(PKCS7* pkcs7, byte* output, word32 out...
function wc_PKCS7_DecodeCompressedData (line 12325) | int wc_PKCS7_DecodeCompressedData(PKCS7* pkcs7, byte* pkiMsg, word32 pki...
FILE: src/wolfcrypt/src/poly1305.c
type word128 (line 93) | typedef struct word128 {
type word128 (line 108) | typedef unsigned __int128 word128;
type word128 (line 110) | typedef unsigned word128 __attribute__((mode(TI)));
function word64 (line 195) | static word64 U8TO64(const byte* p)
function U64TO8 (line 208) | static void U64TO8(byte* p, word64 v) {
function word32 (line 221) | static word32 U8TO32(const byte *p)
function U32TO8 (line 230) | static void U32TO8(byte *p, word32 v) {
function U32TO64 (line 239) | static void U32TO64(word32 v, byte* p)
function poly1305_blocks (line 249) | void poly1305_blocks(Poly1305* ctx, const unsigned char *m,
function poly1305_block (line 373) | void poly1305_block(Poly1305* ctx, const unsigned char *m)
function wc_Poly1305SetKey (line 385) | int wc_Poly1305SetKey(Poly1305* ctx, const byte* key, word32 keySz)
function wc_Poly1305Final (line 471) | int wc_Poly1305Final(Poly1305* ctx, byte* mac)
function wc_Poly1305Update (line 654) | int wc_Poly1305Update(Poly1305* ctx, const byte* m, word32 bytes)
function wc_Poly1305_MAC (line 764) | int wc_Poly1305_MAC(Poly1305* ctx, byte* additional, word32 addSz,
FILE: src/wolfcrypt/src/port/Espressif/esp32_aes.c
function esp_aes_hw_InUse (line 47) | static int esp_aes_hw_InUse()
function esp_aes_hw_Leave (line 78) | static void esp_aes_hw_Leave( void )
function esp_aes_hw_Set_KeyMode (line 93) | static void esp_aes_hw_Set_KeyMode(Aes *ctx, ESP32_AESPROCESS mode)
function esp_aes_bk (line 136) | static void esp_aes_bk(const byte* in, byte* out)
function wc_esp32AesEncrypt (line 171) | int wc_esp32AesEncrypt(Aes *aes, const byte* in, byte* out)
function wc_esp32AesDecrypt (line 192) | int wc_esp32AesDecrypt(Aes *aes, const byte* in, byte* out)
function wc_esp32AesCbcEncrypt (line 216) | int wc_esp32AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
function wc_esp32AesCbcDecrypt (line 262) | int wc_esp32AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
FILE: src/wolfcrypt/src/port/Espressif/esp32_mp.c
function esp_mp_hw_wait_clean (line 61) | static int esp_mp_hw_wait_clean()
function esp_mp_hw_lock (line 76) | static int esp_mp_hw_lock()
function esp_mp_hw_unlock (line 103) | static void esp_mp_hw_unlock( void )
function esp_calc_Mdash (line 113) | static int esp_calc_Mdash(mp_int *M, word32 k, mp_digit* md)
function process_start (line 139) | static void process_start(word32 reg)
function wait_uitil_done (line 147) | static int wait_uitil_done(word32 reg)
function esp_memblock_to_mpint (line 168) | static void esp_memblock_to_mpint(word32 mem_address, mp_int* mp, word32...
function esp_mpint_to_memblock (line 175) | static void esp_mpint_to_memblock(word32 mem_address, const mp_int* mp,
function word32 (line 196) | static word32 words2hwords(word32 wd)
function word32 (line 203) | static word32 bits2words(word32 bits)
function esp_get_rinv (line 211) | static int esp_get_rinv(mp_int *rinv, mp_int *M, word32 exp)
function esp_mp_mul (line 230) | int esp_mp_mul(fp_int* X, fp_int* Y, fp_int* Z)
function esp_mp_mulmod (line 300) | int esp_mp_mulmod(fp_int* X, fp_int* Y, fp_int* M, fp_int* Z)
function esp_mp_exptmod (line 428) | int esp_mp_exptmod(fp_int* X, fp_int* Y, word32 Ys, fp_int* M, fp_int* Z)
FILE: src/wolfcrypt/src/port/Espressif/esp32_sha.c
function word32 (line 75) | static word32 esp_sha_digest_size(enum SHA_TYPE type)
function esp_wait_until_idle (line 105) | static void esp_wait_until_idle()
function esp_sha_try_hw_lock (line 116) | int esp_sha_try_hw_lock(WC_ESP32SHA* ctx)
function esp_sha_hw_unlock (line 173) | void esp_sha_hw_unlock( void )
function esp_sha_start_process (line 190) | static void esp_sha_start_process(WC_ESP32SHA* sha, word32 address)
function esp_process_block (line 208) | static void esp_process_block(WC_ESP32SHA* ctx, word32 address,
function esp_digest_state (line 229) | static void esp_digest_state(WC_ESP32SHA* ctx, byte* hash, enum SHA_TYPE...
function esp_sha_process (line 282) | int esp_sha_process(struct wc_Sha* sha, const byte* data)
function esp_sha_digest_process (line 299) | int esp_sha_digest_process(struct wc_Sha* sha, byte blockproc)
function esp_sha256_process (line 325) | int esp_sha256_process(struct wc_Sha256* sha, const byte* data)
function esp_sha256_digest_process (line 345) | int esp_sha256_digest_process(struct wc_Sha256* sha, byte blockproc)
function esp_sha512_block (line 369) | void esp_sha512_block(struct wc_Sha512* sha, const word32* data, byte is...
function esp_sha512_process (line 403) | int esp_sha512_process(struct wc_Sha512* sha)
function esp_sha512_digest_process (line 417) | int esp_sha512_digest_process(struct wc_Sha512* sha, byte blockproc)
FILE: src/wolfcrypt/src/port/Espressif/esp32_util.c
function esp_CryptHwMutexInit (line 30) | int esp_CryptHwMutexInit(wolfSSL_Mutex* mutex) {
function esp_CryptHwMutexLock (line 34) | int esp_CryptHwMutexLock(wolfSSL_Mutex* mutex, TickType_t xBlockTime) {
function esp_CryptHwMutexUnLock (line 42) | int esp_CryptHwMutexUnLock(wolfSSL_Mutex* mutex) {
function wc_esp32TimerStart (line 56) | void wc_esp32TimerStart()
function wc_esp32elapsedTime (line 61) | uint64_t wc_esp32elapsedTime()
FILE: src/wolfcrypt/src/rabbit.c
function word32 (line 53) | static word32 RABBIT_g_func(word32 x)
function RABBIT_next_state (line 72) | static void RABBIT_next_state(RabbitCtx* ctx)
function wc_RabbitSetIV (line 109) | static void wc_RabbitSetIV(Rabbit* ctx, const byte* inIv)
function WC_INLINE (line 148) | static WC_INLINE int DoKey(Rabbit* ctx, const byte* key, const byte* iv)
function wc_Rabbit_SetHeap (line 203) | int wc_Rabbit_SetHeap(Rabbit* ctx, void* heap)
function wc_RabbitSetKey (line 219) | int wc_RabbitSetKey(Rabbit* ctx, const byte* key, const byte* iv)
function WC_INLINE (line 250) | static WC_INLINE int DoProcess(Rabbit* ctx, byte* output, const byte* in...
function wc_RabbitProcess (line 310) | int wc_RabbitProcess(Rabbit* ctx, byte* output, const byte* input, word3...
FILE: src/wolfcrypt/src/random.c
function wc_GenerateSeed (line 56) | int wc_GenerateSeed(OS_Seed* os, byte* seed, word32 sz)
function wc_InitRng_ex (line 61) | int wc_InitRng_ex(WC_RNG* rng, void* heap, int devId)
function wc_InitRng (line 68) | int wc_InitRng(WC_RNG* rng)
function wc_RNG_GenerateBlock (line 74) | int wc_RNG_GenerateBlock(WC_RNG* rng, byte* b, word32 sz)
function wc_RNG_GenerateByte (line 80) | int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
function wc_FreeRng (line 87) | int wc_FreeRng(WC_RNG* rng)
function wc_RNG_HealthTest (line 92) | int wc_RNG_HealthTest(int reseed, const byte* seedA, word32 seedASz,
function wc_InitRng_IntelRD (line 169) | static void wc_InitRng_IntelRD(void)
type DRBG (line 282) | typedef struct DRBG {
function Hash_df (line 302) | static int Hash_df(DRBG* drbg, byte* out, word32 outSz, byte type,
function Hash_DRBG_Reseed (line 391) | static int Hash_DRBG_Reseed(DRBG* drbg, const byte* seed, word32 seedSz)
function wc_RNG_DRBG_Reseed (line 417) | int wc_RNG_DRBG_Reseed(WC_RNG* rng, const byte* seed, word32 seedSz)
function WC_INLINE (line 426) | static WC_INLINE void array_add_one(byte* data, word32 dataSz)
function Hash_gen (line 438) | static int Hash_gen(DRBG* drbg, byte* out, word32 outSz, const byte* V)
function WC_INLINE (line 523) | static WC_INLINE void array_add(byte* d, word32 dLen, const byte* s, wor...
function Hash_DRBG_Generate (line 546) | static int Hash_DRBG_Generate(DRBG* drbg, byte* out, word32 outSz)
function Hash_DRBG_Instantiate (line 612) | static int Hash_DRBG_Instantiate(DRBG* drbg, const byte* seed, word32 se...
function Hash_DRBG_Uninstantiate (line 652) | static int Hash_DRBG_Uninstantiate(DRBG* drbg)
function wc_RNG_TestSeed (line 671) | int wc_RNG_TestSeed(const byte* seed, word32 seedSz)
function _InitRng (line 696) | static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
function WOLFSSL_ABI (line 833) | WOLFSSL_ABI
function WOLFSSL_ABI (line 851) | WOLFSSL_ABI
function wc_InitRng (line 865) | int wc_InitRng(WC_RNG* rng)
function wc_InitRng_ex (line 871) | int wc_InitRng_ex(WC_RNG* rng, void* heap, int devId)
function wc_InitRngNonce (line 877) | int wc_InitRngNonce(WC_RNG* rng, byte* nonce, word32 nonceSz)
function wc_InitRngNonce_ex (line 883) | int wc_InitRngNonce_ex(WC_RNG* rng, byte* nonce, word32 nonceSz,
function wc_RNG_GenerateBlock (line 891) | int wc_RNG_GenerateBlock(WC_RNG* rng, byte* output, word32 sz)
function wc_RNG_GenerateByte (line 984) | int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
function wc_FreeRng (line 990) | int wc_FreeRng(WC_RNG* rng)
function wc_RNG_HealthTest (line 1019) | int wc_RNG_HealthTest(int reseed, const byte* seedA, word32 seedASz,
function wc_RNG_HealthTest_ex (line 1030) | int wc_RNG_HealthTest_ex(int reseed, const byte* nonce, word32 nonceSz,
function wc_RNG_HealthTestLocal (line 1155) | static int wc_RN
Copy disabled (too large)
Download .json
Condensed preview — 184 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (13,454K chars).
[
{
"path": ".gitattributes",
"chars": 66,
"preview": "# Auto detect text files and perform LF normalization\n* text=auto\n"
},
{
"path": ".gitignore",
"chars": 290,
"preview": "# Prerequisites\n*.d\n\n# Compiled Object files\n*.slo\n*.lo\n*.o\n*.obj\n\n# Precompiled Headers\n*.gch\n*.pch\n\n# Compiled Dynamic"
},
{
"path": "LICENSE",
"chars": 1072,
"preview": "MIT License\n\nCopyright (c) 2020 Mixiaoxiao(谜小小)\n\nPermission is hereby granted, free of charge, to any person obtaining a"
},
{
"path": "README.md",
"chars": 2356,
"preview": "# Arduino-HomeKit-ESP32\n**[Deprecated]** Native Apple HomeKit accessory implementation for the ESP32 Arduino core.\n\nThis"
},
{
"path": "examples/ESP32_homekit_wolfssl_4_3_0/ESP32_homekit.ino",
"chars": 2140,
"preview": "#include \"Arduino.h\"\n#include \"WiFi.h\"\n#include \"arduino_homekit_server.h\"\n#include \"ESPButton.h\"\n\nextern \"C\" homekit_se"
},
{
"path": "examples/ESP32_homekit_wolfssl_4_3_0/ESPButton.h",
"chars": 7415,
"preview": "/*\n * ESPButton.h\n * Ticker-scan based Button Handler with debounce.\n * Default scan interval is 16ms (60FPS).\n * All ad"
},
{
"path": "examples/ESP32_homekit_wolfssl_4_3_0/builtin_led_accessory.c",
"chars": 3181,
"preview": "/*\n * builtin_led_accessory.c\n * Define the accessory in pure C language using the Macro in characteristics.h\n *\n * Cre"
},
{
"path": "library.json",
"chars": 494,
"preview": "{\n \"name\":\"HomeKit-ESP32\",\n \"description\":\"Apple HomeKit accessory server library for the ESP32 Arduino core.\",\n \"key"
},
{
"path": "library.properties",
"chars": 343,
"preview": "name=HomeKit-ESP32\nversion=1.0.0\nauthor=Mixiaoxiao\nmaintainer=Mixiaoxiao\nsentence=Native Apple HomeKit accessory impleme"
},
{
"path": "src/accessories.c",
"chars": 19577,
"preview": "#include <stdlib.h>\n#include <string.h>\n#include <homekit/types.h>\n\nbool homekit_value_equal(homekit_value_t *a, homekit"
},
{
"path": "src/arduino_homekit_server.h",
"chars": 6944,
"preview": "#ifndef ARDUINO_HOMEKIT_SERVER_H_\n#define ARDUINO_HOMEKIT_SERVER_H_\n\n\n#include <WiFiServer.h>\n#include <WiFiClient.h>\n#i"
},
{
"path": "src/arduino_homekit_server_esp32.cpp",
"chars": 113791,
"preview": "#if defined(ESP32)\n#include <Arduino.h>\n#include <esp_xpgm.h>\n#include <WiFi.h>\n#include <ESPmDNS.h>\n#include <WiFiServe"
},
{
"path": "src/arduino_homekit_server_esp8266.cpp",
"chars": 110795,
"preview": "#if defined(ESP8266)\n#include <Arduino.h>\n#include <esp_xpgm.h>\n#include <ESP8266WiFi.h>\n#include <ESP8266mDNS.h>\n#inclu"
},
{
"path": "src/base64.c",
"chars": 2388,
"preview": "#include \"base64.h\"\n\nstatic unsigned char base64_chars[] = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567"
},
{
"path": "src/base64.h",
"chars": 489,
"preview": "#pragma once\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stddef.h>\n\n\nsize_t base64_encoded_size(const unsigned ch"
},
{
"path": "src/cJSON.c",
"chars": 74441,
"preview": "/*\n Copyright (c) 2009-2017 Dave Gamble and cJSON contributors\n\n Permission is hereby granted, free of charge, to any "
},
{
"path": "src/cJSON.h",
"chars": 15426,
"preview": "/*\n Copyright (c) 2009-2017 Dave Gamble and cJSON contributors\n\n Permission is hereby granted, free of charge, to any "
},
{
"path": "src/cQueue.c",
"chars": 4713,
"preview": "/*!\\file cQueue.c\n** \\author SMFSW\n** \\copyright BSD 3-Clause License (c) 2017-2019, SMFSW\n** \\brief Queue handling libr"
},
{
"path": "src/cQueue.h",
"chars": 8933,
"preview": "/*!\\file cQueue.h\n** \\author SMFSW\n** \\copyright BSD 3-Clause License (c) 2017-2019, SMFSW\n** \\brief Queue handling libr"
},
{
"path": "src/constants.h",
"chars": 71,
"preview": "#pragma once\n\n#define DEVICE_ID_SIZE 36\n#define ACCESSORY_ID_SIZE 17\n"
},
{
"path": "src/crypto.c",
"chars": 13960,
"preview": "#include <string.h>\n\n#include \"user_settings.h\"\n#include <wolfssl/wolfcrypt/hmac.h>\n#include <wolfssl/wolfcrypt/ed25519."
},
{
"path": "src/crypto.h",
"chars": 3405,
"preview": "#ifndef __CRYPTO_H__\n#define __CRYPTO_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//wolfssl-3.13.0-stable\n\n#include <st"
},
{
"path": "src/esp_xpgm.h",
"chars": 1236,
"preview": "/*\n * xpgm.h\n *\n * Created on: 2020-03-08\n * Author: Wang Bin\n */\n\n#ifndef ESP_XPGM_H_\n#define ESP_XPGM_H_\n\n#ifdef"
},
{
"path": "src/homekit/characteristics.h",
"chars": 96705,
"preview": "#ifndef __HOMEKIT_CHARACTERISTICS__\n#define __HOMEKIT_CHARACTERISTICS__\n\n#include <homekit/types.h>\n\n#ifdef __cplusplus\n"
},
{
"path": "src/homekit/homekit.h",
"chars": 2503,
"preview": "#ifndef __HOMEKIT_H__\n#define __HOMEKIT_H__\n\n#include <homekit/types.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef"
},
{
"path": "src/homekit/tlv.h",
"chars": 1158,
"preview": "#ifndef __TLV_H__\n#define __TLV_H__\n\n#define __need_size_t\n#include <stdlib.h>\n#include <stdio.h>\n#include <stddef.h>\n#"
},
{
"path": "src/homekit/types.h",
"chars": 13343,
"preview": "#ifndef __HOMEKIT_TYPES_H__\n#define __HOMEKIT_TYPES_H__\n\n#include <stdbool.h>\n#include <stdint.h>\n\n#include <homekit/tlv"
},
{
"path": "src/homekit_debug.c",
"chars": 1059,
"preview": "#include <stdlib.h>\n#include <stdio.h>\n\n#include \"homekit_debug.h\"\n\n\nchar *binary_to_string(const byte *data, size_t siz"
},
{
"path": "src/homekit_debug.h",
"chars": 1592,
"preview": "#ifndef __HOMEKIT_DEBUG_H__\n#define __HOMEKIT_DEBUG_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdlib.h>\n#in"
},
{
"path": "src/http_parser.c",
"chars": 71607,
"preview": "/* Based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev\n *\n * Additional changes are licensed under the s"
},
{
"path": "src/http_parser.h",
"chars": 19050,
"preview": "/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.\n *\n * Permission is hereby granted, free of "
},
{
"path": "src/json.c",
"chars": 9630,
"preview": "#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include \"json.h\"\n\n#include \"homekit_debu"
},
{
"path": "src/json.h",
"chars": 995,
"preview": "#pragma once\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdbool.h>\n\nstruct json_stream;\ntypedef struct json_stre"
},
{
"path": "src/pairing.h",
"chars": 347,
"preview": "#ifndef __PAIRING_H__\n#define __PAIRING_H__\n\n#include \"constants.h\"\n#include \"crypto.h\"\n\n\ntypedef enum {\n pairing_per"
},
{
"path": "src/port.c",
"chars": 6906,
"preview": "#include <stdarg.h>\n#include \"port.h\"\n\n#ifdef ESP_OPEN_RTOS\n\n#include <string.h>\n#include <esp/hwrand.h>\n#include <espre"
},
{
"path": "src/port.h",
"chars": 1992,
"preview": "#ifndef __HOMEKIT_PORT_H_\n#define __HOMEKIT_PORT_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdint.h>\n#includ"
},
{
"path": "src/query_params.c",
"chars": 1367,
"preview": "#include <stdlib.h>\n#include <string.h>\n#include \"query_params.h\"\n\n\nquery_param_t *query_params_parse(const char *s) {\n "
},
{
"path": "src/query_params.h",
"chars": 457,
"preview": "#ifndef __HOMEKIT_QUERY_PARAMS__\n#define __HOMEKIT_QUERY_PARAMS__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struc"
},
{
"path": "src/storage.c",
"chars": 13571,
"preview": "#include <string.h>\n#include <ctype.h>\n#include \"constants.h\"\n#include \"pairing.h\"\n#include \"port.h\"\n\n#include \"storage."
},
{
"path": "src/storage.h",
"chars": 1117,
"preview": "#ifndef __STORAGE_H__\n#define __STORAGE_H__\n\n//#include \"EEPROM.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"pa"
},
{
"path": "src/tlv.c",
"chars": 5340,
"preview": "#include <stdlib.h>\n#include <string.h>\n\n#include <homekit/tlv.h>\n\n\ntlv_values_t *tlv_new() {\n tlv_values_t *values ="
},
{
"path": "src/types.c",
"chars": 2573,
"preview": "#include \"homekit/types.h\"\n\n//=========================\n// Compat for cplusplus\n//=========================\n\nhomekit_val"
},
{
"path": "src/user_settings.h",
"chars": 4680,
"preview": "#ifndef wolfcrypt_user_settings_h\n#define wolfcrypt_user_settings_h\n\n#define WOLFSSL_USER_SETTINGS\n\n//#define ARDUINO_HO"
},
{
"path": "src/watchdog.c",
"chars": 1313,
"preview": "// Base on esp_hw_wdt in github\n/*\n * Copyright (c) 2014-2017 Cesanta Software Limited\n * All rights reserved\n * Changed"
},
{
"path": "src/watchdog.h",
"chars": 273,
"preview": "#ifndef WATCHDOG_H_\n#define WATCHDOG_H_\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nvoid watchdog_disable_all();\n\nvoid wat"
},
{
"path": "src/wolfcrypt/src/aes.c",
"chars": 266862,
"preview": "/* aes.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/arc4.c",
"chars": 3542,
"preview": "/* arc4.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/asm.c",
"chars": 61213,
"preview": "/* asm.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/asn.c",
"chars": 478348,
"preview": "/* asn.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/blake2b.c",
"chars": 11440,
"preview": "/*\n BLAKE2 reference source code package - reference C implementations\n\n Written in 2012 by Samuel Neves <sneves@dei"
},
{
"path": "src/wolfcrypt/src/blake2s.c",
"chars": 11172,
"preview": "/*\n BLAKE2 reference source code package - reference C implementations\n\n Written in 2012 by Samuel Neves <sneves@dei"
},
{
"path": "src/wolfcrypt/src/camellia.c",
"chars": 59984,
"preview": "/* camellia.c ver 1.2.0\n *\n * Copyright (c) 2006,2007\n * NTT (Nippon Telegraph and Telephone Corporation) . All rights r"
},
{
"path": "src/wolfcrypt/src/chacha.c",
"chars": 8427,
"preview": "/* chacha.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/chacha20_poly1305.c",
"chars": 8086,
"preview": "/* chacha.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/cmac.c",
"chars": 5568,
"preview": "/* cmac.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/coding.c",
"chars": 13457,
"preview": "/* coding.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/compress.c",
"chars": 5621,
"preview": "/* compress.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfcrypt/src/cpuid.c",
"chars": 3455,
"preview": "/* cpuid.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfcrypt/src/cryptocb.c",
"chars": 18806,
"preview": "/* cryptocb.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfcrypt/src/curve25519.c",
"chars": 14610,
"preview": "/* curve25519.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfcrypt/src/des3.c",
"chars": 57972,
"preview": "/* des3.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/dh.c",
"chars": 83335,
"preview": "/* dh.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/dsa.c",
"chars": 24831,
"preview": "/* dsa.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/ecc.c",
"chars": 374570,
"preview": "/* ecc.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/ecc_fp.c",
"chars": 30,
"preview": "/* dummy ecc_fp.c for dist */\n"
},
{
"path": "src/wolfcrypt/src/ed25519.c",
"chars": 24528,
"preview": "/* ed25519.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfcrypt/src/error.c",
"chars": 13664,
"preview": "/* error.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfcrypt/src/evp.c",
"chars": 61691,
"preview": "/* evp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/fe_low_mem.c",
"chars": 11672,
"preview": "/* fe_low_mem.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfcrypt/src/fe_operations.c",
"chars": 39452,
"preview": "/* fe_operations.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free "
},
{
"path": "src/wolfcrypt/src/ge_low_mem.c",
"chars": 12694,
"preview": "/* ge_low_mem.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfcrypt/src/ge_operations.c",
"chars": 540794,
"preview": "/* ge_operations.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free "
},
{
"path": "src/wolfcrypt/src/hash.c",
"chars": 45064,
"preview": "/* hash.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/hc128.c",
"chars": 14479,
"preview": "/* hc128.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfcrypt/src/hmac.c",
"chars": 37782,
"preview": "/* hmac.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/idea.c",
"chars": 7963,
"preview": "/* idea.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/integer.c",
"chars": 119042,
"preview": "/* integer.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfcrypt/src/logging.c",
"chars": 21929,
"preview": "/* logging.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfcrypt/src/md2.c",
"chars": 4810,
"preview": "/* md2.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/md4.c",
"chars": 5748,
"preview": "/* md4.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/md5.c",
"chars": 16528,
"preview": "/* md5.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/memory.c",
"chars": 32684,
"preview": "/* memory.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/misc.c",
"chars": 10259,
"preview": "/* misc.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/pkcs12.c",
"chars": 70710,
"preview": "/* pkcs12.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/pkcs7.c",
"chars": 407631,
"preview": "/* pkcs7.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfcrypt/src/poly1305.c",
"chars": 22846,
"preview": "/* poly1305.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfcrypt/src/port/Espressif/README.md",
"chars": 5100,
"preview": "# ESP32 Port\n\nSupport for the ESP32-WROOM-32 on-board crypto hardware acceleration for symmetric AES, SHA1/SHA256/SHA384"
},
{
"path": "src/wolfcrypt/src/port/Espressif/esp32_aes.c",
"chars": 8471,
"preview": "/* esp32_aes.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfcrypt/src/port/Espressif/esp32_mp.c",
"chars": 15827,
"preview": "/* esp32_mp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfcrypt/src/port/Espressif/esp32_sha.c",
"chars": 11518,
"preview": "/* esp32_sha.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfcrypt/src/port/Espressif/esp32_util.c",
"chars": 1902,
"preview": "/* esp32_util.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfcrypt/src/pwdbased.c.unused",
"chars": 21808,
"preview": "/* pwdbased.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfcrypt/src/rabbit.c",
"chars": 10178,
"preview": "/* rabbit.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/random.c",
"chars": 67404,
"preview": "/* random.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/ripemd.c",
"chars": 15756,
"preview": "/* ripemd.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/rsa.c",
"chars": 123182,
"preview": "/* rsa.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/sha.c",
"chars": 24967,
"preview": "/* sha.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/sha256.c",
"chars": 47456,
"preview": "/* sha256.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/sha3.c",
"chars": 34805,
"preview": "/* sha3.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/sha512.c",
"chars": 35064,
"preview": "/* sha512.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/signature.c",
"chars": 15035,
"preview": "/* signature.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfcrypt/src/sp_arm32.c",
"chars": 2531504,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/sp_arm64.c",
"chars": 1645484,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/sp_armthumb.c",
"chars": 644280,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/sp_c32.c",
"chars": 548594,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/sp_c64.c",
"chars": 524168,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/sp_cortexm.c",
"chars": 609909,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/sp_int.c",
"chars": 50462,
"preview": "/* sp_int.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfcrypt/src/sp_x86_64.c",
"chars": 897989,
"preview": "/* sp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfcrypt/src/srp.c",
"chars": 21150,
"preview": "/* srp.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/tfm.c",
"chars": 110200,
"preview": "/* tfm.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfcrypt/src/wc_encrypt.c",
"chars": 16724,
"preview": "/* wc_encrypt.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfcrypt/src/wc_pkcs11.c",
"chars": 86590,
"preview": "/* wc_pkcs11.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfcrypt/src/wc_port.c",
"chars": 53778,
"preview": "/* port.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfcrypt/src/wolfevent.c",
"chars": 6518,
"preview": "/* wolfevent.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfcrypt/src/wolfmath.c",
"chars": 7077,
"preview": "/* wolfmath.c\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/version.h",
"chars": 1060,
"preview": "/* wolfssl_version.h.in\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is "
},
{
"path": "src/wolfssl/wolfcrypt/aes.h",
"chars": 14040,
"preview": "/* aes.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/arc4.h",
"chars": 1703,
"preview": "/* arc4.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/asn.h",
"chars": 47032,
"preview": "/* asn.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/asn_public.h",
"chars": 19859,
"preview": "/* asn_public.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfssl/wolfcrypt/blake2-impl.h",
"chars": 4028,
"preview": "/*\n BLAKE2 reference source code package - reference C implementations\n\n Written in 2012 by Samuel Neves <sneves@dei"
},
{
"path": "src/wolfssl/wolfcrypt/blake2-int.h",
"chars": 5843,
"preview": "/*\n BLAKE2 reference source code package - reference C implementations\n\n Written in 2012 by Samuel Neves <sneves@dei"
},
{
"path": "src/wolfssl/wolfcrypt/blake2.h",
"chars": 2588,
"preview": "/* blake2.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/camellia.h",
"chars": 3751,
"preview": "/* camellia.h ver 1.2.0\n *\n * Copyright (c) 2006,2007\n * NTT (Nippon Telegraph and Telephone Corporation) . All rights r"
},
{
"path": "src/wolfssl/wolfcrypt/chacha.h",
"chars": 2246,
"preview": "/* chacha.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/chacha20_poly1305.h",
"chars": 2928,
"preview": "/* chacha20_poly1305.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is f"
},
{
"path": "src/wolfssl/wolfcrypt/cmac.h",
"chars": 2594,
"preview": "/* cmac.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/coding.h",
"chars": 2673,
"preview": "/* coding.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/compress.h",
"chars": 1557,
"preview": "/* compress.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/wolfcrypt/cpuid.h",
"chars": 1826,
"preview": "/* cpuid.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfssl/wolfcrypt/cryptocb.h",
"chars": 8569,
"preview": "/* cryptocb.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/wolfcrypt/curve25519.h",
"chars": 5109,
"preview": "/* curve25519.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfssl/wolfcrypt/des3.h",
"chars": 4682,
"preview": "/* des3.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/dh.h",
"chars": 4486,
"preview": "/* dh.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfssl/wolfcrypt/dsa.h",
"chars": 3303,
"preview": "/* dsa.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/ecc.h",
"chars": 22224,
"preview": "/* ecc.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/ed25519.h",
"chars": 5684,
"preview": "/* ed25519.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfssl/wolfcrypt/error-crypt.h",
"chars": 12756,
"preview": "/* error-crypt.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free so"
},
{
"path": "src/wolfssl/wolfcrypt/fe_operations.h",
"chars": 7718,
"preview": "/* fe_operations.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free "
},
{
"path": "src/wolfssl/wolfcrypt/fips_test.h",
"chars": 1642,
"preview": "/* fips_test.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfssl/wolfcrypt/ge_operations.h",
"chars": 2928,
"preview": "/* ge_operations.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free "
},
{
"path": "src/wolfssl/wolfcrypt/hash.h",
"chars": 7708,
"preview": "/* hash.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/hc128.h",
"chars": 1785,
"preview": "/* hc128.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfssl/wolfcrypt/hmac.h",
"chars": 5448,
"preview": "/* hmac.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/idea.h",
"chars": 2470,
"preview": "/* idea.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/integer.h",
"chars": 14260,
"preview": "/* integer.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfssl/wolfcrypt/logging.h",
"chars": 5846,
"preview": "/* logging.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfssl/wolfcrypt/md2.h",
"chars": 1657,
"preview": "/* md2.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/md4.h",
"chars": 1674,
"preview": "/* md4.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/md5.h",
"chars": 3508,
"preview": "/* md5.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/mem_track.h",
"chars": 11393,
"preview": "/* mem_track.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfssl/wolfcrypt/memory.h",
"chars": 10209,
"preview": "/* memory.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/misc.h",
"chars": 3020,
"preview": "/* misc.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/mpi_class.h",
"chars": 21775,
"preview": "/* mpi_class.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfssl/wolfcrypt/mpi_superclass.h",
"chars": 3003,
"preview": "/* mpi_superclass.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free"
},
{
"path": "src/wolfssl/wolfcrypt/pkcs11.h",
"chars": 23976,
"preview": "/* pkcs11.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/pkcs12.h",
"chars": 2309,
"preview": "/* pkcs12.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/pkcs7.h",
"chars": 21144,
"preview": "/* pkcs7.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfssl/wolfcrypt/poly1305.h",
"chars": 3320,
"preview": "/* poly1305.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h",
"chars": 4399,
"preview": "/* esp32-crypt.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free so"
},
{
"path": "src/wolfssl/wolfcrypt/pwdbased.h",
"chars": 2967,
"preview": "/* pwdbased.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/wolfcrypt/rabbit.h",
"chars": 1722,
"preview": "/* rabbit.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/random.h",
"chars": 7549,
"preview": "/* random.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/ripemd.h",
"chars": 1761,
"preview": "/* ripemd.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/rsa.h",
"chars": 12787,
"preview": "/* rsa.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/selftest.h",
"chars": 1270,
"preview": "/* selftest.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/wolfcrypt/settings.h",
"chars": 61230,
"preview": "/* settings.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
},
{
"path": "src/wolfssl/wolfcrypt/sha.h",
"chars": 4879,
"preview": "/* sha.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/sha256.h",
"chars": 7443,
"preview": "/* sha256.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/sha3.h",
"chars": 4814,
"preview": "/* sha3.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software;"
},
{
"path": "src/wolfssl/wolfcrypt/sha512.h",
"chars": 6685,
"preview": "/* sha512.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/signature.h",
"chars": 2866,
"preview": "/* signature.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfssl/wolfcrypt/sp.h",
"chars": 4896,
"preview": "/* sp.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; y"
},
{
"path": "src/wolfssl/wolfcrypt/sp_int.h",
"chars": 9166,
"preview": "/* sp_int.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwar"
},
{
"path": "src/wolfssl/wolfcrypt/srp.h",
"chars": 10867,
"preview": "/* srp.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/tfm.h",
"chars": 23931,
"preview": "/* tfm.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software; "
},
{
"path": "src/wolfssl/wolfcrypt/types.h",
"chars": 35876,
"preview": "/* types.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free software"
},
{
"path": "src/wolfssl/wolfcrypt/visibility.h",
"chars": 2657,
"preview": "/* visibility.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfssl/wolfcrypt/wc_encrypt.h",
"chars": 3561,
"preview": "/* wc_encrypt.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free sof"
},
{
"path": "src/wolfssl/wolfcrypt/wc_pkcs11.h",
"chars": 3119,
"preview": "/* wc_pkcs11.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfssl/wolfcrypt/wc_port.h",
"chars": 24156,
"preview": "/* wc_port.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softwa"
},
{
"path": "src/wolfssl/wolfcrypt/wolfevent.h",
"chars": 3596,
"preview": "/* wolfevent.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free soft"
},
{
"path": "src/wolfssl/wolfcrypt/wolfmath.h",
"chars": 2803,
"preview": "/* wolfmath.h\n *\n * Copyright (C) 2006-2019 wolfSSL Inc.\n *\n * This file is part of wolfSSL.\n *\n * wolfSSL is free softw"
}
]
About this extraction
This page contains the full source code of the Mixiaoxiao/Arduino-HomeKit-ESP32 GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 184 files (11.9 MB), approximately 3.1M tokens, and a symbol index with 4914 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.