forked from espressif/arduino-esp32
IDF master cf457d412 (#5073)
esp-dsp: master 7cc5073 esp-face: master 420fc7e esp-rainmaker: f1b82c7 esp32-camera: master 2dded7c esp_littlefs: master d268e18
This commit is contained in:
@ -301,6 +301,7 @@ typedef void (* esp_blufi_event_cb_t)(esp_blufi_cb_event_t event, esp_blufi_cb_p
|
||||
* @param len : length of data from phone
|
||||
* @param output_data : data want to send to phone
|
||||
* @param output_len : length of data want to send to phone
|
||||
* @param need_free : output reporting if memory needs to be freed or not *
|
||||
*/
|
||||
typedef void (*esp_blufi_negotiate_data_handler_t)(uint8_t *data, int len, uint8_t **output_data, int *output_len, bool *need_free);
|
||||
|
||||
@ -311,7 +312,7 @@ typedef void (*esp_blufi_negotiate_data_handler_t)(uint8_t *data, int len, uint8
|
||||
* @param crypt_len : length of plain text
|
||||
* @return Nonnegative number is encrypted length, if error, return negative number;
|
||||
*/
|
||||
typedef int (* esp_blufi_encrypt_func_t)(uint8_t iv8, uint8_t *crypt_data, int cyprt_len);
|
||||
typedef int (* esp_blufi_encrypt_func_t)(uint8_t iv8, uint8_t *crypt_data, int crypt_len);
|
||||
|
||||
/**
|
||||
* @brief BLUFI decrypt the data after negotiate a share key
|
||||
|
@ -259,7 +259,7 @@ typedef union {
|
||||
/**
|
||||
* @brief GATT Client callback function type
|
||||
* @param event : Event type
|
||||
* @param gatts_if : GATT client access interface, normally
|
||||
* @param gattc_if : GATT client access interface, normally
|
||||
* different gattc_if correspond to different profile
|
||||
* @param param : Point to callback parameter, currently is union type
|
||||
*/
|
||||
|
@ -188,7 +188,7 @@ typedef void (* esp_hf_incoming_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
*
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*
|
||||
* @param[out] length of data successfully read
|
||||
* @return length of data successfully read
|
||||
*/
|
||||
typedef uint32_t (* esp_hf_outgoing_data_cb_t) (uint8_t *buf, uint32_t len);
|
||||
|
||||
|
@ -273,7 +273,7 @@ typedef void (* esp_hf_client_incoming_data_cb_t)(const uint8_t *buf, uint32_t l
|
||||
*
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*
|
||||
* @param[out] length of data successfully read
|
||||
* @return length of data successfully read
|
||||
*
|
||||
*/
|
||||
typedef uint32_t (* esp_hf_client_outgoing_data_cb_t)(uint8_t *buf, uint32_t len);
|
||||
|
@ -164,6 +164,7 @@
|
||||
#define CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT 30
|
||||
#define CONFIG_BT_BLE_RPA_SUPPORTED 1
|
||||
#define CONFIG_BT_BLE_50_FEATURES_SUPPORTED 1
|
||||
#define CONFIG_BT_BLE_42_FEATURES_SUPPORTED 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0xdb5c
|
||||
#define CONFIG_COAP_MBEDTLS_PSK 1
|
||||
#define CONFIG_COAP_LOG_DEFAULT_LEVEL 0
|
||||
@ -178,8 +179,6 @@
|
||||
#define CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ 160
|
||||
#define CONFIG_ESP32C3_REV_MIN_0 1
|
||||
#define CONFIG_ESP32C3_REV_MIN 0
|
||||
#define CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR 1
|
||||
#define CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES 4
|
||||
#define CONFIG_ESP32C3_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_ESP32C3_BROWNOUT_DET 1
|
||||
#define CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_7 1
|
||||
@ -205,15 +204,17 @@
|
||||
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP 1
|
||||
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_BT 1
|
||||
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH 1
|
||||
#define CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR 1
|
||||
#define CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES 4
|
||||
#define CONFIG_ESP_SLEEP_POWER_DOWN_FLASH 1
|
||||
#define CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL 120
|
||||
#define CONFIG_ESP_NETIF_TCPIP_LWIP 1
|
||||
#define CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER 1
|
||||
#define CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP 1
|
||||
#define CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE 1
|
||||
#define CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK 1
|
||||
#define CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP 1
|
||||
#define CONFIG_ESP_SYSTEM_PD_FLASH 1
|
||||
#define CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU 1
|
||||
#define CONFIG_ESP_SYSTEM_MEMPROT_FEATURE 1
|
||||
#define CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK 1
|
||||
#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
@ -356,8 +357,6 @@
|
||||
#define CONFIG_LWIP_MAX_RAW_PCBS 16
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000
|
||||
#define CONFIG_LCP_ECHOINTERVAL 0
|
||||
#define CONFIG_LCP_MAXECHOFAILS 3
|
||||
#define CONFIG_LWIP_ESP_LWIP_ASSERT 1
|
||||
#define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1
|
||||
#define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1
|
||||
@ -526,6 +525,8 @@
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT CONFIG_PTHREAD_TASK_PRIO_DEFAULT
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT
|
||||
#define CONFIG_ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
|
||||
#define CONFIG_ESP_SYSTEM_PD_FLASH CONFIG_ESP_SLEEP_POWER_DOWN_FLASH
|
||||
#define CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
|
||||
#define CONFIG_FLASHMODE_DIO CONFIG_ESPTOOLPY_FLASHMODE_DIO
|
||||
#define CONFIG_GAP_TRACE_LEVEL_WARNING CONFIG_BT_LOG_GAP_TRACE_LEVEL_WARNING
|
||||
#define CONFIG_GARP_TMR_INTERVAL CONFIG_LWIP_GARP_TMR_INTERVAL
|
||||
@ -597,5 +598,5 @@
|
||||
#define CONFIG_TIMER_TASK_STACK_SIZE CONFIG_ESP_TIMER_TASK_STACK_SIZE
|
||||
#define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX
|
||||
#define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "1cb31e509"
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "cf457d412"
|
||||
#define CONFIG_ARDUINO_IDF_BRANCH "master"
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "esp_attr.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#if SOC_DEDICATED_GPIO_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -171,3 +173,5 @@ esp_err_t dedic_gpio_bundle_set_interrupt_and_callback(dedic_gpio_bundle_handle_
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //SOC_DEDICATED_GPIO_SUPPORTED
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
@ -494,28 +494,6 @@ esp_err_t gpio_sleep_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
|
||||
* - ESP_ERR_INVALID_ARG : Parameter error
|
||||
*/
|
||||
esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
|
||||
|
||||
#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
/**
|
||||
* @brief Emulate ESP32S2 behaviour to backup FUN_PU, FUN_PD information
|
||||
*
|
||||
* @note Need to be called before sleep.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t gpio_sleep_pupd_config_apply(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Emulate ESP32S2 behaviour to restore FUN_PU, FUN_PD information
|
||||
*
|
||||
* @note Need to be called after sleep.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
|
@ -33,9 +33,39 @@ extern "C" {
|
||||
|
||||
#define I2C_APB_CLK_FREQ APB_CLK_FREQ /*!< I2C source clock is APB clock, 80MHz */
|
||||
|
||||
#define I2C_NUM_0 (0) /*!< I2C port 0 */
|
||||
#define I2C_NUM_1 (1) /*!< I2C port 1 */
|
||||
#define I2C_NUM_MAX (SOC_I2C_NUM) /*!< I2C port max */
|
||||
#define I2C_NUM_0 (0) /*!< I2C port 0 */
|
||||
#if SOC_I2C_NUM >= 2
|
||||
#define I2C_NUM_1 (1) /*!< I2C port 1 */
|
||||
#endif
|
||||
|
||||
// I2C clk flags for users to use, can be expanded in the future.
|
||||
#define I2C_SCLK_SRC_FLAG_FOR_NOMAL (0) /*!< Any one clock source that is available for the specified frequency may be choosen*/
|
||||
#define I2C_SCLK_SRC_FLAG_AWARE_DFS (1 << 0) /*!< For REF tick clock, it won't change with APB.*/
|
||||
#define I2C_SCLK_SRC_FLAG_LIGHT_SLEEP (1 << 1) /*!< For light sleep mode.*/
|
||||
|
||||
/**
|
||||
* @brief I2C initialization parameters
|
||||
*/
|
||||
typedef struct{
|
||||
i2c_mode_t mode; /*!< I2C mode */
|
||||
int sda_io_num; /*!< GPIO number for I2C sda signal */
|
||||
int scl_io_num; /*!< GPIO number for I2C scl signal */
|
||||
bool sda_pullup_en; /*!< Internal GPIO pull mode for I2C sda signal*/
|
||||
bool scl_pullup_en; /*!< Internal GPIO pull mode for I2C scl signal*/
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t clk_speed; /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
|
||||
} master; /*!< I2C master config */
|
||||
struct {
|
||||
uint8_t addr_10bit_en; /*!< I2C 10bit address mode enable for slave mode */
|
||||
uint16_t slave_addr; /*!< I2C address for slave mode */
|
||||
} slave; /*!< I2C slave config */
|
||||
};
|
||||
uint32_t clk_flags; /*!< Bitwise of ``I2C_SCLK_SRC_FLAG_**FOR_DFS**`` for clk source choice*/
|
||||
} i2c_config_t;
|
||||
|
||||
|
||||
typedef void *i2c_cmd_handle_t; /*!< I2C command handle */
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "hal/i2s_types.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
#include "driver/adc.h"
|
||||
#endif
|
||||
@ -82,21 +83,6 @@ esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin);
|
||||
esp_err_t i2s_set_pdm_rx_down_sample(i2s_port_t i2s_num, i2s_pdm_dsr_t dsr);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set I2S dac mode, I2S built-in DAC is disabled by default
|
||||
*
|
||||
* @param dac_mode DAC mode configurations - see i2s_dac_mode_t
|
||||
*
|
||||
* @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
* If either of the built-in DAC channel are enabled, the other one can not
|
||||
* be used as RTC DAC function at the same time.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode);
|
||||
|
||||
/**
|
||||
* @brief Install and start I2S driver.
|
||||
*
|
||||
@ -331,7 +317,23 @@ esp_err_t i2s_adc_enable(i2s_port_t i2s_num);
|
||||
* - ESP_ERR_INVALID_STATE Driver state error
|
||||
*/
|
||||
esp_err_t i2s_adc_disable(i2s_port_t i2s_num);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set I2S dac mode, I2S built-in DAC is disabled by default
|
||||
*
|
||||
* @param dac_mode DAC mode configurations - see i2s_dac_mode_t
|
||||
*
|
||||
* @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
* If either of the built-in DAC channel are enabled, the other one can not
|
||||
* be used as RTC DAC function at the same time.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode);
|
||||
#endif //SOC_I2S_SUPPORTS_ADC_DAC
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -17,10 +17,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/rtc_io_periph.h"
|
||||
#include "hal/rtc_io_types.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -42,6 +44,7 @@ static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
|
||||
|
||||
#define RTC_GPIO_IS_VALID_GPIO(gpio_num) rtc_gpio_is_valid_gpio(gpio_num) // Deprecated, use rtc_gpio_is_valid_gpio()
|
||||
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
/**
|
||||
* @brief Get RTC IO index number by gpio number.
|
||||
*
|
||||
@ -52,15 +55,9 @@ static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
|
||||
*/
|
||||
static inline int rtc_io_number_get(gpio_num_t gpio_num)
|
||||
{
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
return rtc_io_num_map[gpio_num];
|
||||
#else
|
||||
return gpio_num;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Init a GPIO as RTC GPIO
|
||||
*
|
||||
|
@ -28,6 +28,12 @@ extern "C" {
|
||||
/// Handle representing an SD SPI device
|
||||
typedef int sdspi_dev_handle_t;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
|
||||
#define SDSPI_DEFAULT_HOST HSPI_HOST
|
||||
#else
|
||||
#define SDSPI_DEFAULT_HOST SPI2_HOST
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default sdmmc_host_t structure initializer for SD over SPI driver
|
||||
*
|
||||
@ -37,7 +43,7 @@ typedef int sdspi_dev_handle_t;
|
||||
*/
|
||||
#define SDSPI_HOST_DEFAULT() {\
|
||||
.flags = SDMMC_HOST_FLAG_SPI | SDMMC_HOST_FLAG_DEINIT_ARG, \
|
||||
.slot = HSPI_HOST, \
|
||||
.slot = SDSPI_DEFAULT_HOST, \
|
||||
.max_freq_khz = SDMMC_FREQ_DEFAULT, \
|
||||
.io_voltage = 3.3f, \
|
||||
.init = &sdspi_host_init, \
|
||||
@ -71,7 +77,7 @@ typedef struct {
|
||||
* Macro defining default configuration of SD SPI device.
|
||||
*/
|
||||
#define SDSPI_DEVICE_CONFIG_DEFAULT() {\
|
||||
.host_id = HSPI_HOST, \
|
||||
.host_id = SDSPI_DEFAULT_HOST, \
|
||||
.gpio_cs = GPIO_NUM_13, \
|
||||
.gpio_cd = SDSPI_SLOT_NO_CD, \
|
||||
.gpio_wp = SDSPI_SLOT_NO_WP, \
|
||||
@ -228,7 +234,7 @@ typedef struct {
|
||||
*
|
||||
* @note The SDIO over sdspi needs an extra interrupt line. Call ``gpio_install_isr_service()`` before this function.
|
||||
*
|
||||
* @param slot SPI controller to use (HSPI_HOST or VSPI_HOST)
|
||||
* @param slot SPI controller to use (SPI2_HOST or SPI3_HOST)
|
||||
* @param slot_config pointer to slot configuration structure
|
||||
|
||||
* @deprecated Use `sdspi_host_init_device` instead.
|
||||
|
@ -106,7 +106,7 @@ typedef struct {
|
||||
int sclk_io_num; ///< GPIO pin for Spi CLocK signal, or -1 if not used.
|
||||
int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used.
|
||||
int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used.
|
||||
int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4094 if 0.
|
||||
int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled.
|
||||
uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags.
|
||||
int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see
|
||||
* ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored
|
||||
@ -119,7 +119,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief Initialize a SPI bus
|
||||
*
|
||||
* @warning For now, only supports HSPI and VSPI.
|
||||
* @warning SPI0/1 is not supported
|
||||
*
|
||||
* @param host_id SPI peripheral that controls this bus
|
||||
* @param bus_config Pointer to a spi_bus_config_t struct specifying how the host should be initialized
|
||||
|
@ -88,7 +88,7 @@ struct spi_slave_transaction_t {
|
||||
/**
|
||||
* @brief Initialize a SPI bus as a slave interface
|
||||
*
|
||||
* @warning For now, only supports HSPI and VSPI.
|
||||
* @warning SPI0/1 is not supported
|
||||
*
|
||||
* @param host SPI peripheral to use as a SPI slave interface
|
||||
* @param bus_config Pointer to a spi_bus_config_t struct specifying how the host should be initialized
|
||||
|
45
tools/sdk/esp32c3/include/driver/include/esp_private/gpio.h
Normal file
45
tools/sdk/esp32c3/include/driver/include/esp_private/gpio.h
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include <esp_types.h>
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH
|
||||
#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
/**
|
||||
* @brief Emulate ESP32S2 behaviour to backup FUN_PU, FUN_PD information
|
||||
*
|
||||
* @note Need to be called before sleep.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t gpio_sleep_pupd_config_apply(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Emulate ESP32S2 behaviour to restore FUN_PU, FUN_PD information
|
||||
*
|
||||
* @note Need to be called after sleep.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num);
|
||||
#endif
|
||||
#endif
|
@ -26,6 +26,22 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef IRAM_SRAM_START
|
||||
#define IRAM_SRAM_START 0x4037C000
|
||||
#endif
|
||||
|
||||
#ifndef DRAM_SRAM_START
|
||||
#define DRAM_SRAM_START 0x3FC7C000
|
||||
#endif
|
||||
|
||||
#ifndef MAP_DRAM_TO_IRAM
|
||||
#define MAP_DRAM_TO_IRAM(addr) (addr - DRAM_SRAM_START + IRAM_SRAM_START)
|
||||
#endif
|
||||
|
||||
#ifndef MAP_IRAM_TO_DRAM
|
||||
#define MAP_IRAM_TO_DRAM(addr) (addr - IRAM_SRAM_START + DRAM_SRAM_START)
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MEMPROT_NONE = 0x00000000,
|
||||
MEMPROT_IRAM0_SRAM = 0x00000001,
|
||||
@ -34,6 +50,7 @@ typedef enum {
|
||||
} mem_type_prot_t;
|
||||
|
||||
typedef enum {
|
||||
MEMPROT_SPLITLINE_NONE = 0,
|
||||
MEMPROT_IRAM0_DRAM0_SPLITLINE,
|
||||
MEMPROT_IRAM0_LINE_0_SPLITLINE,
|
||||
MEMPROT_IRAM0_LINE_1_SPLITLINE,
|
||||
@ -42,6 +59,7 @@ typedef enum {
|
||||
} split_line_t;
|
||||
|
||||
typedef enum {
|
||||
MEMPROT_PMS_AREA_NONE = 0,
|
||||
MEMPROT_IRAM0_PMS_AREA_0,
|
||||
MEMPROT_IRAM0_PMS_AREA_1,
|
||||
MEMPROT_IRAM0_PMS_AREA_2,
|
||||
@ -52,43 +70,386 @@ typedef enum {
|
||||
MEMPROT_DRAM0_PMS_AREA_3
|
||||
} pms_area_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MEMPROT_PMS_WORLD_0 = 0,
|
||||
MEMPROT_PMS_WORLD_1,
|
||||
MEMPROT_PMS_WORLD_2,
|
||||
MEMPROT_PMS_WORLD_INVALID = 0xFFFFFFFF
|
||||
} pms_world_t;
|
||||
|
||||
const char *mem_type_to_str(mem_type_prot_t mem_type);
|
||||
const char *split_line_to_str(split_line_t line_type);
|
||||
const char *pms_to_str(pms_area_t area_type);
|
||||
typedef enum
|
||||
{
|
||||
MEMPROT_PMS_OP_READ = 0,
|
||||
MEMPROT_PMS_OP_WRITE,
|
||||
MEMPROT_PMS_OP_FETCH,
|
||||
MEMPROT_PMS_OP_INVALID = 0xFFFFFFFF
|
||||
} pms_operation_type_t;
|
||||
|
||||
void *esp_memprot_get_main_split_addr(void);
|
||||
void esp_memprot_set_split_line_lock(bool lock);
|
||||
/**
|
||||
* @brief Converts Memory protection type to string
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*/
|
||||
const char *esp_memprot_mem_type_to_str(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Converts Split line type to string
|
||||
*
|
||||
* @param line_type Split line type (see split_line_t enum)
|
||||
*/
|
||||
const char *esp_memprot_split_line_to_str(split_line_t line_type);
|
||||
|
||||
/**
|
||||
* @brief Converts PMS Area type to string
|
||||
*
|
||||
* @param area_type PMS Area type (see pms_area_t enum)
|
||||
*/
|
||||
const char *esp_memprot_pms_to_str(pms_area_t area_type);
|
||||
|
||||
/**
|
||||
* @brief Returns PMS splitting address for given Split line type
|
||||
*
|
||||
* The value is taken from PMS configuration registers (IRam0 range)
|
||||
* For details on split lines see 'esp_memprot_set_prot_int' function description
|
||||
*
|
||||
* @param line_type Split line type (see split_line_t enum)
|
||||
*
|
||||
* @return appropriate split line address
|
||||
*/
|
||||
uint32_t *esp_memprot_get_split_addr(split_line_t line_type);
|
||||
|
||||
/**
|
||||
* @brief Returns default main IRAM/DRAM splitting address
|
||||
*
|
||||
* The address value is given by _iram_text_end global (IRam0 range)
|
||||
|
||||
* @return Main I/D split line (IRam0_DRam0_Split_Addr)
|
||||
*/
|
||||
void *esp_memprot_get_default_main_split_addr(void);
|
||||
|
||||
/**
|
||||
* @brief Sets a lock for the main IRAM/DRAM splitting address
|
||||
*
|
||||
* Locks can be unlocked only by digital system reset
|
||||
*/
|
||||
void esp_memprot_set_split_line_lock(void);
|
||||
|
||||
/**
|
||||
* @brief Gets a lock status for the main IRAM/DRAM splitting address
|
||||
*
|
||||
* @return true/false (locked/unlocked)
|
||||
*/
|
||||
bool esp_memprot_get_split_line_lock(void);
|
||||
|
||||
/**
|
||||
* @brief Sets required split line address
|
||||
*
|
||||
* @param line_type Split line type (see split_line_t enum)
|
||||
* @param line_addr target address from a memory range relevant to given line_type (IRAM/DRAM)
|
||||
*/
|
||||
void esp_memprot_set_split_line(split_line_t line_type, const void *line_addr);
|
||||
|
||||
void esp_memprot_set_pms_lock(mem_type_prot_t mem_type, bool lock);
|
||||
/**
|
||||
* @brief Sets a lock for PMS Area settings of required Memory type
|
||||
*
|
||||
* Locks can be unlocked only by digital system reset
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*/
|
||||
void esp_memprot_set_pms_lock(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Gets a lock status for PMS Area settings of required Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return true/false (locked/unlocked)
|
||||
*/
|
||||
bool esp_memprot_get_pms_lock(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Sets permissions for given PMS Area in IRam0 memory range (MEMPROT_IRAM0_SRAM)
|
||||
*
|
||||
* @param area_type IRam0 PMS Area type (see pms_area_t enum)
|
||||
* @param r Read permission flag
|
||||
* @param w Write permission flag
|
||||
* @param x Execute permission flag
|
||||
*/
|
||||
void esp_memprot_iram_set_pms_area(pms_area_t area_type, bool r, bool w, bool x);
|
||||
|
||||
/**
|
||||
* @brief Gets current permissions for given PMS Area in IRam0 memory range (MEMPROT_IRAM0_SRAM)
|
||||
*
|
||||
* @param area_type IRam0 PMS Area type (see pms_area_t enum)
|
||||
* @param r Read permission flag holder
|
||||
* @param w Write permission flag holder
|
||||
* @param x Execute permission flag holder
|
||||
*/
|
||||
void esp_memprot_iram_get_pms_area(pms_area_t area_type, bool *r, bool *w, bool *x);
|
||||
|
||||
/**
|
||||
* @brief Sets permissions for given PMS Area in DRam0 memory range (MEMPROT_DRAM0_SRAM)
|
||||
*
|
||||
* @param area_type DRam0 PMS Area type (see pms_area_t enum)
|
||||
* @param r Read permission flag
|
||||
* @param w Write permission flag
|
||||
*/
|
||||
void esp_memprot_dram_set_pms_area(pms_area_t area_type, bool r, bool w);
|
||||
|
||||
void esp_memprot_set_monitor_lock(mem_type_prot_t mem_type, bool lock);
|
||||
/**
|
||||
* @brief Gets current permissions for given PMS Area in DRam0 memory range (MEMPROT_DRAM0_SRAM)
|
||||
*
|
||||
* @param area_type DRam0 PMS Area type (see pms_area_t enum)
|
||||
* @param r Read permission flag holder
|
||||
* @param w Write permission flag holder
|
||||
*/
|
||||
void esp_memprot_dram_get_pms_area(pms_area_t area_type, bool *r, bool *w);
|
||||
|
||||
/**
|
||||
* @brief Sets a lock for PMS interrupt monitor settings of required Memory type
|
||||
*
|
||||
* Locks can be unlocked only by digital system reset
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*/
|
||||
void esp_memprot_set_monitor_lock(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Gets a lock status for PMS interrupt monitor settings of required Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return true/false (locked/unlocked)
|
||||
*/
|
||||
bool esp_memprot_get_monitor_lock(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Enable PMS violation interrupt monitoring of required Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
* @param enable/disable
|
||||
*/
|
||||
void esp_memprot_set_monitor_en(mem_type_prot_t mem_type, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Gets enable/disable status for PMS interrupt monitor settings of required Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return true/false (enabled/disabled)
|
||||
*/
|
||||
bool esp_memprot_get_monitor_en(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Gets CPU ID for currently active PMS violation interrupt
|
||||
*
|
||||
* @return CPU ID (CPU_PRO for ESP32C3)
|
||||
*/
|
||||
int IRAM_ATTR esp_memprot_intr_get_cpuid(void);
|
||||
|
||||
/**
|
||||
* @brief Clears current interrupt ON flag for given Memory type
|
||||
*
|
||||
* Interrupt clearing happens in two steps:
|
||||
* 1. Interrupt CLR flag is set (to clear the interrupt ON status)
|
||||
* 2. Interrupt CLR flag is reset (to allow further monitoring)
|
||||
* This operation is non-atomic by PMS module design
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*/
|
||||
void IRAM_ATTR esp_memprot_monitor_clear_intr(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns active PMS violation interrupt (if any)
|
||||
*
|
||||
* This function iterates through supported Memory type status registers
|
||||
* and returns the first interrupt-on flag. If none is found active,
|
||||
* MEMPROT_NONE is returned.
|
||||
* Order of checking (in current version):
|
||||
* 1. MEMPROT_IRAM0_SRAM
|
||||
* 2. MEMPROT_DRAM0_SRAM
|
||||
*
|
||||
* @return mem_type Memory protection type related to active interrupt found (see mem_type_prot_t enum)
|
||||
*/
|
||||
mem_type_prot_t IRAM_ATTR esp_memprot_get_active_intr_memtype(void);
|
||||
|
||||
/**
|
||||
* @brief Checks whether any violation interrupt is active
|
||||
*
|
||||
* @return true/false (yes/no)
|
||||
*/
|
||||
bool IRAM_ATTR esp_memprot_is_locked_any(void);
|
||||
|
||||
/**
|
||||
* @brief Checks whether any violation interrupt is enabled
|
||||
*
|
||||
* @return true/false (yes/no)
|
||||
*/
|
||||
bool IRAM_ATTR esp_memprot_is_intr_ena_any(void);
|
||||
|
||||
uint32_t IRAM_ATTR esp_memprot_get_violate_intr_on(mem_type_prot_t mem_type);
|
||||
/**
|
||||
* @brief Checks whether any violation interrupt is enabled
|
||||
*
|
||||
* @return true/false (yes/no)
|
||||
*/
|
||||
bool IRAM_ATTR esp_memprot_get_violate_intr_on(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns the address which caused the violation interrupt (if any)
|
||||
*
|
||||
* The address is taken from appropriate PMS violation status register, based given Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return faulting address
|
||||
*/
|
||||
uint32_t IRAM_ATTR esp_memprot_get_violate_addr(mem_type_prot_t mem_type);
|
||||
uint32_t IRAM_ATTR esp_memprot_get_violate_world(mem_type_prot_t mem_type);
|
||||
uint32_t IRAM_ATTR esp_memprot_get_violate_wr(mem_type_prot_t mem_type);
|
||||
uint32_t IRAM_ATTR esp_memprot_get_violate_loadstore(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns the World identifier of the code causing the violation interrupt (if any)
|
||||
*
|
||||
* The value is taken from appropriate PMS violation status register, based given Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return World identifier (see pms_world_t enum)
|
||||
*/
|
||||
pms_world_t IRAM_ATTR esp_memprot_get_violate_world(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns Read or Write operation type which caused the violation interrupt (if any)
|
||||
*
|
||||
* The value (bit) is taken from appropriate PMS violation status register, based given Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return PMS operation type relevant to mem_type parameter (se pms_operation_type_t)
|
||||
*/
|
||||
pms_operation_type_t IRAM_ATTR esp_memprot_get_violate_wr(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns LoadStore flag of the operation type which caused the violation interrupt (if any)
|
||||
*
|
||||
* The value (bit) is taken from appropriate PMS violation status register, based given Memory type
|
||||
* Effective only on IRam0 access
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return true/false (LoadStore bit on/off)
|
||||
*/
|
||||
bool IRAM_ATTR esp_memprot_get_violate_loadstore(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns byte-enables for the address which caused the violation interrupt (if any)
|
||||
*
|
||||
* The value is taken from appropriate PMS violation status register, based given Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return byte-enables
|
||||
*/
|
||||
uint32_t IRAM_ATTR esp_memprot_get_violate_byte_en(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Returns raw contents of DRam0 status register 1
|
||||
*
|
||||
* @return 32-bit register value
|
||||
*/
|
||||
uint32_t IRAM_ATTR esp_memprot_get_dram_status_reg_1(void);
|
||||
|
||||
/**
|
||||
* @brief Returns raw contents of DRam0 status register 2
|
||||
*
|
||||
* @return 32-bit register value
|
||||
*/
|
||||
uint32_t IRAM_ATTR esp_memprot_get_dram_status_reg_2(void);
|
||||
|
||||
/**
|
||||
* @brief Returns raw contents of IRam0 status register
|
||||
*
|
||||
* @return 32-bit register value
|
||||
*/
|
||||
uint32_t IRAM_ATTR esp_memprot_get_iram_status_reg(void);
|
||||
|
||||
/**
|
||||
* @brief Register PMS violation interrupt in global interrupt matrix for given Memory type
|
||||
*
|
||||
* Memory protection components uses specific interrupt number, see ETS_MEMPROT_ERR_INUM
|
||||
* The registration makes the panic-handler routine being called when the interrupt appears
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*/
|
||||
void esp_memprot_set_intr_matrix(mem_type_prot_t mem_type);
|
||||
|
||||
/**
|
||||
* @brief Convenient routine for setting the PMS defaults
|
||||
*
|
||||
* Called on application startup, depending on CONFIG_ESP_SYSTEM_MEMPROT_FEATURE Kconfig settings
|
||||
* For implementation details see 'esp_memprot_set_prot_int' description
|
||||
*
|
||||
* @param invoke_panic_handler register all interrupts for panic handling (true/false)
|
||||
* @param lock_feature lock the defaults to prevent further PMS settings changes (true/false)
|
||||
* @param mem_type_mask 32-bit field of specific PMS parts to configure (see 'esp_memprot_set_prot_int')
|
||||
*/
|
||||
void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask);
|
||||
|
||||
/**
|
||||
* @brief Internal routine for setting the PMS defaults
|
||||
*
|
||||
* Called on application startup from within 'esp_memprot_set_prot'. Allows setting a specific splitting address
|
||||
* (main I/D split line) - see the parameter 'split_addr'. If the 'split_addr' equals to NULL, default I/D split line
|
||||
* is used (&_iram_text_end) and all the remaining lines share the same address.
|
||||
* The function sets all the split lines and PMS areas to the same space,
|
||||
* ie there is a single instruction space and single data space at the end.
|
||||
* The PMS split lines and permission areas scheme described below:
|
||||
*
|
||||
* DRam0/DMA IRam0
|
||||
* -----------------------------------------------
|
||||
* ... | IRam0_PMS_0 |
|
||||
* DRam0_PMS_0 ----------------------------------------------- IRam0_line1_Split_addr
|
||||
* ... | IRam0_PMS_1 |
|
||||
* ... ----------------------------------------------- IRam0_line0_Split_addr
|
||||
* | IRam0_PMS_2 |
|
||||
* =============================================== IRam0_DRam0_Split_addr (main I/D)
|
||||
* | DRam0_PMS_1 |
|
||||
* DRam0_DMA_line0_Split_addr ----------------------------------------------- ...
|
||||
* | DRam0_PMS_2 | ...
|
||||
* DRam0_DMA_line1_Split_addr ----------------------------------------------- IRam0_PMS_3
|
||||
* | DRam0_PMS_3 | ...
|
||||
* -----------------------------------------------
|
||||
*
|
||||
* Default settings provided by 'esp_memprot_set_prot_int' are as follows:
|
||||
*
|
||||
* DRam0/DMA IRam0
|
||||
* -----------------------------------------------
|
||||
* | IRam0_PMS_0 = IRam0_PMS_1 = IRam0_PMS_2 |
|
||||
* | DRam0_PMS_0 | IRam0_line1_Split_addr
|
||||
* DRam0_DMA_line0_Split_addr | | =
|
||||
* = =============================================== IRam0_line0_Split_addr
|
||||
* DRam0_DMA_line1_Split_addr | | =
|
||||
* | DRam0_PMS_1 = DRam0_PMS_2 = DRam0_PMS_3 | IRam0_DRam0_Split_addr (main I/D)
|
||||
* | IRam0_PMS_3 |
|
||||
* -----------------------------------------------
|
||||
*
|
||||
* Once the memprot feature is locked, it can be unlocked only by digital system reset
|
||||
*
|
||||
* @param invoke_panic_handler register all the violation interrupts for panic handling (true/false)
|
||||
* @param lock_feature lock the defaults to prevent further PMS settings changes (true/false)
|
||||
* @param split_addr specific main I/D adrees or NULL to use default ($_iram_text_end)
|
||||
* @param mem_type_mask 32-bit field of specific PMS parts to configure (members of mem_type_prot_t)
|
||||
*/
|
||||
void esp_memprot_set_prot_int(bool invoke_panic_handler, bool lock_feature, void *split_addr, uint32_t *mem_type_mask);
|
||||
|
||||
/**
|
||||
* @brief Returns raw contents of PMS interrupt monitor register for given Memory type
|
||||
*
|
||||
* @param mem_type Memory protection type (see mem_type_prot_t enum)
|
||||
*
|
||||
* @return 32-bit register value
|
||||
*/
|
||||
uint32_t esp_memprot_get_monitor_enable_reg(mem_type_prot_t mem_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,77 +0,0 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @file esp_clk.h
|
||||
*
|
||||
* This file contains declarations of clock related functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get the calibration value of RTC slow clock
|
||||
*
|
||||
* The value is in the same format as returned by rtc_clk_cal (microseconds,
|
||||
* in Q13.19 fixed-point format).
|
||||
*
|
||||
* @return the calibration value obtained using rtc_clk_cal, at startup time
|
||||
*/
|
||||
uint32_t esp_clk_slowclk_cal_get(void);
|
||||
|
||||
/**
|
||||
* @brief Update the calibration value of RTC slow clock
|
||||
*
|
||||
* The value has to be in the same format as returned by rtc_clk_cal (microseconds,
|
||||
* in Q13.19 fixed-point format).
|
||||
* This value is used by timekeeping functions (such as gettimeofday) to
|
||||
* calculate current time based on RTC counter value.
|
||||
* @param value calibration value obtained using rtc_clk_cal
|
||||
*/
|
||||
void esp_clk_slowclk_cal_set(uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Return current CPU clock frequency
|
||||
* When frequency switching is performed, this frequency may change.
|
||||
* However it is guaranteed that the frequency never changes with a critical
|
||||
* section.
|
||||
*
|
||||
* @return CPU clock frequency, in Hz
|
||||
*/
|
||||
int esp_clk_cpu_freq(void);
|
||||
|
||||
/**
|
||||
* @brief Return current APB clock frequency
|
||||
*
|
||||
* When frequency switching is performed, this frequency may change.
|
||||
* However it is guaranteed that the frequency never changes with a critical
|
||||
* section.
|
||||
*
|
||||
* @return APB clock frequency, in Hz
|
||||
*/
|
||||
int esp_clk_apb_freq(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read value of RTC counter, converting it to microseconds
|
||||
* @attention The value returned by this function may change abruptly when
|
||||
* calibration value of RTC counter is updated via esp_clk_slowclk_cal_set
|
||||
* function. This should not happen unless application calls esp_clk_slowclk_cal_set.
|
||||
* In ESP-IDF, esp_clk_slowclk_cal_set is only called in startup code.
|
||||
*
|
||||
* @return Value or RTC counter, expressed in microseconds
|
||||
*/
|
||||
uint64_t esp_clk_rtc_time(void);
|
@ -135,6 +135,8 @@ typedef struct {
|
||||
bool is_async; /*!< Set asynchronous mode, only supported with HTTPS for now */
|
||||
bool use_global_ca_store; /*!< Use a global ca_store for all the connections in which this bool is set. */
|
||||
bool skip_cert_common_name_check; /*!< Skip any validation of server certificate CN field */
|
||||
esp_err_t (*crt_bundle_attach)(void *conf); /*!< Function pointer to esp_crt_bundle_attach. Enables the use of certification
|
||||
bundle for server verification, must be enabled in menuconfig */
|
||||
bool keep_alive_enable; /*!< Enable keep-alive timeout */
|
||||
int keep_alive_idle; /*!< Keep-alive idle time. Default is 5 (second) */
|
||||
int keep_alive_interval; /*!< Keep-alive interval time. Default is 5 (second) */
|
||||
|
@ -0,0 +1,72 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bit_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Chip models
|
||||
*/
|
||||
typedef enum {
|
||||
CHIP_ESP32 = 1, //!< ESP32
|
||||
CHIP_ESP32S2 = 2, //!< ESP32-S2
|
||||
CHIP_ESP32S3 = 4, //!< ESP32-S3
|
||||
CHIP_ESP32C3 = 5, //!< ESP32-C3
|
||||
} esp_chip_model_t;
|
||||
|
||||
/* Chip feature flags, used in esp_chip_info_t */
|
||||
#define CHIP_FEATURE_EMB_FLASH BIT(0) //!< Chip has embedded flash memory
|
||||
#define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi
|
||||
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
|
||||
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
|
||||
|
||||
/**
|
||||
* @brief The structure represents information about the chip
|
||||
*/
|
||||
typedef struct {
|
||||
esp_chip_model_t model; //!< chip model, one of esp_chip_model_t
|
||||
uint32_t features; //!< bit mask of CHIP_FEATURE_x feature flags
|
||||
uint8_t cores; //!< number of CPU cores
|
||||
uint8_t revision; //!< chip revision number
|
||||
} esp_chip_info_t;
|
||||
|
||||
/**
|
||||
* @brief Fill an esp_chip_info_t structure with information about the chip
|
||||
* @param[out] out_info structure to be filled
|
||||
*/
|
||||
void esp_chip_info(esp_chip_info_t* out_info);
|
||||
|
||||
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
||||
/**
|
||||
* @brief Cache lock bug exists or not
|
||||
*
|
||||
* @return
|
||||
* - ture : bug exists
|
||||
* - false : bug not exists
|
||||
*/
|
||||
bool soc_has_cache_lock_bug(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,2 @@
|
||||
#warning esp_clk.h has been replaced by esp32/clk.h, please include esp32/clk.h instead
|
||||
#include "esp32/clk.h"
|
17
tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr.h
Normal file
17
tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead
|
||||
#include "esp_intr_alloc.h"
|
134
tools/sdk/esp32c3/include/esp_hw_support/include/esp_mac.h
Normal file
134
tools/sdk/esp32c3/include/esp_hw_support/include/esp_mac.h
Normal file
@ -0,0 +1,134 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_MAC_WIFI_STA,
|
||||
ESP_MAC_WIFI_SOFTAP,
|
||||
ESP_MAC_BT,
|
||||
ESP_MAC_ETH,
|
||||
} esp_mac_type_t;
|
||||
|
||||
/** @cond */
|
||||
#define TWO_UNIVERSAL_MAC_ADDR 2
|
||||
#define FOUR_UNIVERSAL_MAC_ADDR 4
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES
|
||||
#endif
|
||||
/** @endcond */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or
|
||||
* external storage e.g. flash and EEPROM.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC
|
||||
* address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing
|
||||
* WiFi/BT/Ethernet.
|
||||
*
|
||||
* @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero).
|
||||
*
|
||||
* @note If not using a valid OUI, set the "locally administered" bit
|
||||
* (bit value 0x02 in the first byte) to avoid collisions.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is set using esp_base_mac_addr_set.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_MAC base MAC address has not been set
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which was previously written to BLK3 of EFUSE.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* This API returns the custom base MAC address which was previously written to BLK3 of EFUSE.
|
||||
* Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also
|
||||
* possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE
|
||||
* ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Read base MAC address and set MAC address of the interface.
|
||||
*
|
||||
* This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address
|
||||
* from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap,
|
||||
* bluetooth and ethernet.
|
||||
*
|
||||
* @param mac MAC address of the interface, length: 6 bytes.
|
||||
* @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Derive local MAC address from universal MAC address.
|
||||
*
|
||||
* This function derives a local MAC address from an universal MAC address.
|
||||
* A `definition of local vs universal MAC address can be found on Wikipedia
|
||||
* <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`.
|
||||
* In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage.
|
||||
* Local MAC address is derived from the universal MAC address.
|
||||
*
|
||||
* @param local_mac Derived local MAC address, length: 6 bytes.
|
||||
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -67,6 +67,17 @@ int esp_clk_cpu_freq(void);
|
||||
*/
|
||||
int esp_clk_apb_freq(void);
|
||||
|
||||
/**
|
||||
* @brief Return frequency of the main XTAL
|
||||
*
|
||||
* Frequency of the main XTAL can be either auto-detected or set at compile
|
||||
* time (see CONFIG_ESP32_XTAL_FREQ_SEL sdkconfig option). In both cases, this
|
||||
* function returns the actual value at run time.
|
||||
*
|
||||
* @return XTAL frequency, in Hz
|
||||
*/
|
||||
int esp_clk_xtal_freq(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read value of RTC counter, converting it to microseconds
|
@ -0,0 +1,54 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get one random 32-bit word from hardware RNG
|
||||
*
|
||||
* The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For
|
||||
* random values, call this function after WiFi or Bluetooth are started.
|
||||
*
|
||||
* If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an
|
||||
* entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions'
|
||||
* documentation for more details.
|
||||
*
|
||||
* Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be
|
||||
* considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF
|
||||
* bootloader is running, but this should not be relied upon for any use.
|
||||
*
|
||||
* @return Random value between 0 and UINT32_MAX
|
||||
*/
|
||||
uint32_t esp_random(void);
|
||||
|
||||
/**
|
||||
* @brief Fill a buffer with random bytes from hardware RNG
|
||||
*
|
||||
* @note This function has the same restrictions regarding available entropy as esp_random()
|
||||
*
|
||||
* @param buf Pointer to buffer to fill with random numbers.
|
||||
* @param len Length of buffer in bytes
|
||||
*/
|
||||
void esp_fill_random(void *buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -441,6 +441,18 @@ void esp_default_wake_deep_sleep(void);
|
||||
*/
|
||||
void esp_deep_sleep_disable_rom_logging(void);
|
||||
|
||||
#ifdef SOC_PM_SUPPORT_CPU_PD
|
||||
/**
|
||||
* @brief CPU Power down low-level initialize
|
||||
*
|
||||
* @param enable enable or disable CPU power down during light sleep
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM not enough retention memory
|
||||
*/
|
||||
esp_err_t esp_sleep_cpu_pd_low_init(bool enable);
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH
|
||||
/**
|
||||
* @brief Configure to isolate all GPIO pins in sleep state
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_private/esp_clk.h"
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_private/esp_clk.h"
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_private/esp_clk.h"
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_private/esp_clk.h"
|
@ -63,6 +63,14 @@ typedef enum {
|
||||
*/
|
||||
esp_err_t esp_pm_configure(const void* config);
|
||||
|
||||
/**
|
||||
* @brief Get implementation-specific power management configuration
|
||||
* @param config pointer to implementation-specific configuration structure (e.g. esp_pm_config_esp32)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the pointer is null
|
||||
*/
|
||||
esp_err_t esp_pm_get_configuration(void* config);
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to the power management lock
|
||||
|
@ -41,6 +41,7 @@ typedef struct {
|
||||
uint32_t pc; /* PC of the current frame */
|
||||
uint32_t sp; /* SP of the current frame */
|
||||
uint32_t next_pc; /* PC of the current frame's caller */
|
||||
const void *exc_frame; /* Pointer to the full frame data structure, if applicable */
|
||||
} esp_backtrace_frame_t;
|
||||
|
||||
/**
|
||||
@ -87,6 +88,24 @@ extern void esp_backtrace_get_start(uint32_t *pc, uint32_t *sp, uint32_t *next_p
|
||||
*/
|
||||
bool esp_backtrace_get_next_frame(esp_backtrace_frame_t *frame);
|
||||
|
||||
/**
|
||||
* @brief Print the backtrace from specified frame.
|
||||
*
|
||||
* @param depth The maximum number of stack frames to print (should be > 0)
|
||||
* @param frame Starting frame to print from
|
||||
* @param panic Indicator if backtrace print is during a system panic
|
||||
*
|
||||
* @note On the ESP32, users must call esp_backtrace_get_start() first to flush the stack.
|
||||
* @note If a esp_backtrace_frame_t* frame is obtained though a call to esp_backtrace_get_start()
|
||||
* from some example function func_a(), then frame is only valid within the frame/scope of func_a().
|
||||
* Users should not attempt to pass/use frame other frames within the same stack of different stacks.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Backtrace successfully printed to completion or to depth limit
|
||||
* - ESP_FAIL Backtrace is corrupted
|
||||
*/
|
||||
esp_err_t IRAM_ATTR esp_backtrace_print_from_frame(int depth, const esp_backtrace_frame_t* frame, bool panic);
|
||||
|
||||
/**
|
||||
* @brief Print the backtrace of the current stack
|
||||
*
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef __ESP_CROSSCORE_INT_H
|
||||
#define __ESP_CROSSCORE_INT_H
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -54,6 +56,8 @@ void esp_crosscore_int_send_yield(int core_id);
|
||||
*/
|
||||
void esp_crosscore_int_send_freq_switch(int core_id);
|
||||
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
/**
|
||||
* Send an interrupt to a CPU indicating it should print its current backtrace
|
||||
*
|
||||
@ -63,6 +67,7 @@ void esp_crosscore_int_send_freq_switch(int core_id);
|
||||
* @param core_id Core that should print its backtrace
|
||||
*/
|
||||
void esp_crosscore_int_send_print_backtrace(int core_id);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -31,10 +31,11 @@ extern bool g_spiram_ok; // [refactor-todo] better way to communicate this from
|
||||
// array, one per core.
|
||||
typedef void (*sys_startup_fn_t)(void);
|
||||
|
||||
/* This array of per-CPU system layer startup functions is initialized in the non-port part of esp_system */
|
||||
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
|
||||
extern sys_startup_fn_t g_startup_fn[SOC_CPU_CORES_NUM];
|
||||
extern sys_startup_fn_t const g_startup_fn[SOC_CPU_CORES_NUM];
|
||||
#else
|
||||
extern sys_startup_fn_t g_startup_fn[1];
|
||||
extern sys_startup_fn_t const g_startup_fn[1];
|
||||
#endif
|
||||
|
||||
// Utility to execute `sys_startup_fn_t` for the current core.
|
||||
|
@ -24,31 +24,17 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// For backward compatibility. These headers
|
||||
// contains hardware operation functions and definitions
|
||||
// that were originally declared in this header.
|
||||
#include "esp_mac.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include "esp_random.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_MAC_WIFI_STA,
|
||||
ESP_MAC_WIFI_SOFTAP,
|
||||
ESP_MAC_BT,
|
||||
ESP_MAC_ETH,
|
||||
} esp_mac_type_t;
|
||||
|
||||
/** @cond */
|
||||
#define TWO_UNIVERSAL_MAC_ADDR 2
|
||||
#define FOUR_UNIVERSAL_MAC_ADDR 4
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES
|
||||
#endif
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Reset reasons
|
||||
*/
|
||||
@ -138,120 +124,6 @@ uint32_t esp_get_free_internal_heap_size(void);
|
||||
*/
|
||||
uint32_t esp_get_minimum_free_heap_size( void );
|
||||
|
||||
/**
|
||||
* @brief Get one random 32-bit word from hardware RNG
|
||||
*
|
||||
* The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For
|
||||
* random values, call this function after WiFi or Bluetooth are started.
|
||||
*
|
||||
* If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an
|
||||
* entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions'
|
||||
* documentation for more details.
|
||||
*
|
||||
* Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be
|
||||
* considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF
|
||||
* bootloader is running, but this should not be relied upon for any use.
|
||||
*
|
||||
* @return Random value between 0 and UINT32_MAX
|
||||
*/
|
||||
uint32_t esp_random(void);
|
||||
|
||||
/**
|
||||
* @brief Fill a buffer with random bytes from hardware RNG
|
||||
*
|
||||
* @note This function has the same restrictions regarding available entropy as esp_random()
|
||||
*
|
||||
* @param buf Pointer to buffer to fill with random numbers.
|
||||
* @param len Length of buffer in bytes
|
||||
*/
|
||||
void esp_fill_random(void *buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or
|
||||
* external storage e.g. flash and EEPROM.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC
|
||||
* address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing
|
||||
* WiFi/BT/Ethernet.
|
||||
*
|
||||
* @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero).
|
||||
*
|
||||
* @note If not using a valid OUI, set the "locally administered" bit
|
||||
* (bit value 0x02 in the first byte) to avoid collisions.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is set using esp_base_mac_addr_set.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_MAC base MAC address has not been set
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which was previously written to BLK3 of EFUSE.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* This API returns the custom base MAC address which was previously written to BLK3 of EFUSE.
|
||||
* Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also
|
||||
* possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE
|
||||
* ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Read base MAC address and set MAC address of the interface.
|
||||
*
|
||||
* This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address
|
||||
* from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap,
|
||||
* bluetooth and ethernet.
|
||||
*
|
||||
* @param mac MAC address of the interface, length: 6 bytes.
|
||||
* @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Derive local MAC address from universal MAC address.
|
||||
*
|
||||
* This function derives a local MAC address from an universal MAC address.
|
||||
* A `definition of local vs universal MAC address can be found on Wikipedia
|
||||
* <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`.
|
||||
* In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage.
|
||||
* Local MAC address is derived from the universal MAC address.
|
||||
*
|
||||
* @param local_mac Derived local MAC address, length: 6 bytes.
|
||||
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac);
|
||||
|
||||
/**
|
||||
* @brief Trigger a software abort
|
||||
*
|
||||
@ -259,50 +131,6 @@ esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac)
|
||||
*/
|
||||
void __attribute__((noreturn)) esp_system_abort(const char* details);
|
||||
|
||||
/**
|
||||
* @brief Chip models
|
||||
*/
|
||||
typedef enum {
|
||||
CHIP_ESP32 = 1, //!< ESP32
|
||||
CHIP_ESP32S2 = 2, //!< ESP32-S2
|
||||
CHIP_ESP32S3 = 4, //!< ESP32-S3
|
||||
CHIP_ESP32C3 = 5, //!< ESP32-C3
|
||||
} esp_chip_model_t;
|
||||
|
||||
/* Chip feature flags, used in esp_chip_info_t */
|
||||
#define CHIP_FEATURE_EMB_FLASH BIT(0) //!< Chip has embedded flash memory
|
||||
#define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi
|
||||
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
|
||||
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
|
||||
|
||||
/**
|
||||
* @brief The structure represents information about the chip
|
||||
*/
|
||||
typedef struct {
|
||||
esp_chip_model_t model; //!< chip model, one of esp_chip_model_t
|
||||
uint32_t features; //!< bit mask of CHIP_FEATURE_x feature flags
|
||||
uint8_t cores; //!< number of CPU cores
|
||||
uint8_t revision; //!< chip revision number
|
||||
} esp_chip_info_t;
|
||||
|
||||
/**
|
||||
* @brief Fill an esp_chip_info_t structure with information about the chip
|
||||
* @param[out] out_info structure to be filled
|
||||
*/
|
||||
void esp_chip_info(esp_chip_info_t* out_info);
|
||||
|
||||
|
||||
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
||||
/**
|
||||
* @brief Cache lock bug exists or not
|
||||
*
|
||||
* @return
|
||||
* - ture : bug exists
|
||||
* - false : bug not exists
|
||||
*/
|
||||
bool soc_has_cache_lock_bug(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -12,22 +12,34 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief initialize cache invalid access interrupt
|
||||
*
|
||||
* This function enables cache invalid access interrupt source and connects it
|
||||
* to interrupt input number ETS_CACHEERR_INUM (see soc/soc.h). It is called
|
||||
* from the startup code.
|
||||
* to interrupt input number. It is called from the startup code.
|
||||
*
|
||||
* On ESP32, the interrupt input number is ETS_MEMACCESS_ERR_INUM. On other targets
|
||||
* it is ETS_CACHEERR_INUM. See soc/soc.h for more information.
|
||||
*/
|
||||
void esp_cache_err_int_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief get the CPU which caused cache invalid access interrupt
|
||||
* @brief get the CPU which caused cache invalid access interrupt. Helper function in
|
||||
* panic handling.
|
||||
* @return
|
||||
* - PRO_CPU_NUM, if PRO_CPU has caused cache IA interrupt
|
||||
* - APP_CPU_NUM, if APP_CPU has caused cache IA interrupt
|
||||
* - (-1) otherwise
|
||||
*/
|
||||
int esp_cache_err_get_cpuid(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,80 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "eri.h"
|
||||
#include "xtensa-debug-module.h"
|
||||
#include "xt_trax.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TRAX_DOWNCOUNT_WORDS,
|
||||
TRAX_DOWNCOUNT_INSTRUCTIONS
|
||||
} trax_downcount_unit_t;
|
||||
|
||||
typedef enum {
|
||||
TRAX_ENA_NONE = 0,
|
||||
TRAX_ENA_PRO,
|
||||
TRAX_ENA_APP,
|
||||
TRAX_ENA_PRO_APP,
|
||||
TRAX_ENA_PRO_APP_SWAP
|
||||
} trax_ena_select_t;
|
||||
|
||||
/**
|
||||
* @brief Enable the trax memory blocks to be used as Trax memory.
|
||||
*
|
||||
* @param pro_cpu_enable : true if Trax needs to be enabled for the pro CPU
|
||||
* @param app_cpu_enable : true if Trax needs to be enabled for the pro CPU
|
||||
* @param swap_regions : Normally, the pro CPU writes to Trax mem block 0 while
|
||||
* the app cpu writes to block 1. Setting this to true
|
||||
* inverts this.
|
||||
*
|
||||
* @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax enable is requested for 2 CPUs
|
||||
* but memmap only has room for 1, or if Trax memmap is disabled
|
||||
* entirely.
|
||||
*/
|
||||
int trax_enable(trax_ena_select_t ena);
|
||||
|
||||
/**
|
||||
* @brief Start a Trax trace on the current CPU
|
||||
*
|
||||
* @param units_until_stop : Set the units of the delay that gets passed to
|
||||
* trax_trigger_traceend_after_delay. One of TRAX_DOWNCOUNT_WORDS
|
||||
* or TRAX_DOWNCOUNT_INSTRUCTIONS.
|
||||
*
|
||||
* @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax is disabled.
|
||||
*/
|
||||
int trax_start_trace(trax_downcount_unit_t units_until_stop);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Trigger a Trax trace stop after the indicated delay. If this is called
|
||||
* before and the previous delay hasn't ended yet, this will overwrite
|
||||
* that delay with the new value. The delay will always start at the time
|
||||
* the function is called.
|
||||
*
|
||||
* @param delay : The delay to stop the trace in, in the unit indicated to
|
||||
* trax_start_trace. Note: the trace memory has 4K words available.
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
int trax_trigger_traceend_after_delay(int delay);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "cache_err_int.h"
|
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "cache_err_int.h"
|
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "cache_err_int.h"
|
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "cache_err_int.h"
|
@ -17,11 +17,37 @@
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_private/panic_internal.h"
|
||||
#include "esp_core_dump_summary_extra_info.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define APP_ELF_SHA256_SZ (CONFIG_APP_RETRIEVE_LEN_ELF_SHA + 1)
|
||||
|
||||
/**
|
||||
* @brief Backtrace information
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t bt[16]; /*!< Backtrace (array of PC) */
|
||||
uint32_t depth; /*!< Number of backtrace entries */
|
||||
bool corrupted; /*!< Status flag for backtrace is corrupt or not */
|
||||
} esp_core_dump_bt_info_t;
|
||||
|
||||
/**
|
||||
* @brief Core dump summary, Most meaningful contents of the core dump
|
||||
* are accommodated in this structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t exc_tcb; /*!< TCB pointer to the task causing exception */
|
||||
char exc_task[16]; /*!< Name of the task that caused exception */
|
||||
uint32_t exc_pc; /*!< Program counter for exception */
|
||||
esp_core_dump_bt_info_t exc_bt_info; /*!< Backtrace information for task causing exception */
|
||||
uint32_t core_dump_version; /*!< Core dump version */
|
||||
uint8_t app_elf_sha256[APP_ELF_SHA256_SZ]; /*!< Crashing application's SHA256 sum as a string */
|
||||
esp_core_dump_summary_extra_info_t ex_info; /*!< Architecture specific extra data */
|
||||
} esp_core_dump_summary_t;
|
||||
|
||||
/**************************************************************************************/
|
||||
/******************************** EXCEPTION MODE API **********************************/
|
||||
/**************************************************************************************/
|
||||
@ -89,6 +115,24 @@ void esp_core_dump_to_uart(panic_info_t *info);
|
||||
*/
|
||||
esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t *out_size);
|
||||
|
||||
/**
|
||||
* @brief Erases coredump data in flash. esp_core_dump_image_get() will then return
|
||||
* ESP_ERR_NOT_FOUND. Can be used after a coredump has been transmitted successfully.
|
||||
* This function is always available, even when core dump is disabled in menuconfig.
|
||||
*
|
||||
* @return ESP_OK on success, otherwise \see esp_err_t
|
||||
*/
|
||||
esp_err_t esp_core_dump_image_erase(void);
|
||||
|
||||
/**
|
||||
* @brief Get the summary of a core dump. This function works only with ELF format core dumps.
|
||||
*
|
||||
* @param summary Summary of the core dump
|
||||
*
|
||||
* @return ESP_OK on success, otherwise \see esp_err_t
|
||||
*/
|
||||
esp_err_t esp_core_dump_get_summary(esp_core_dump_summary_t *summary);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
@ -11,29 +11,24 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU
|
||||
/**
|
||||
* @brief CPU Power down low-level initialize
|
||||
*
|
||||
* @param enable enable or disable CPU power down during light sleep
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM not enough retention memory
|
||||
* @brief RISC-V architecture specific extra information
|
||||
*/
|
||||
esp_err_t esp_sleep_cpu_pd_low_init(bool enable);
|
||||
#endif
|
||||
typedef struct {
|
||||
uint32_t mstatus; /* Machine Status */
|
||||
uint32_t mtvec; /* Machine Trap-Vector Base Address */
|
||||
uint32_t mcause; /* Machine Trap Cause */
|
||||
uint32_t mtval; /* Machine Trap Value */
|
||||
uint32_t exc_a[8]; /*!< a register set when the exception caused */
|
||||
} esp_core_dump_summary_extra_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <xtensa/config/core-isa.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define EPCx_REGISTER_COUNT XCHAL_NUM_INTLEVELS
|
||||
|
||||
/**
|
||||
* @brief Xtensa architecture specific extra information
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t exc_cause; /*!< Cause of exception */
|
||||
uint32_t exc_vaddr; /*!< Virtual address of exception */
|
||||
uint32_t exc_a[16]; /*!< a register set when the exception caused */
|
||||
uint32_t epcx[EPCx_REGISTER_COUNT]; /*!< PC register address at exception level(1 to 7) */
|
||||
uint8_t epcx_reg_bits; /*!< Bit mask of available EPCx registers */
|
||||
} esp_core_dump_summary_extra_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1203,6 +1203,10 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
|
||||
/**
|
||||
* Starts the real time kernel tick processing.
|
||||
*
|
||||
* NOTE: In ESP-IDF the scheduler is started automatically during
|
||||
* application startup, vTaskStartScheduler() should not be called from
|
||||
* ESP-IDF applications.
|
||||
*
|
||||
* After calling the kernel has control over which tasks are executed and when.
|
||||
*
|
||||
* See the demo application file main.c for an example of creating
|
||||
|
@ -32,6 +32,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following defines are used to disable USB JTAG when pins 18 and pins 19
|
||||
* are set to be used as GPIO.
|
||||
* See gpio_pad_select_gpio() below.
|
||||
*
|
||||
* TODO: Delete these definitions once the USB device registers definition is
|
||||
* merged.
|
||||
*/
|
||||
#define USB_DEVICE_CONF0_REG (0x60043018)
|
||||
#define USB_DEVICE_USB_PAD_ENABLE (BIT(14))
|
||||
|
||||
// Get GPIO hardware instance with giving gpio num
|
||||
#define GPIO_LL_GET_HW(num) (((num) == 0) ? (&GPIO) : NULL)
|
||||
|
||||
@ -379,6 +390,20 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign
|
||||
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[gpio]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Select a function for the pin in the IOMUX
|
||||
*
|
||||
* @param pin_name Pin name to configure
|
||||
* @param func Function to assign to the pin
|
||||
*/
|
||||
static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func)
|
||||
{
|
||||
if (pin_name == IO_MUX_GPIO18_REG || pin_name == IO_MUX_GPIO19_REG) {
|
||||
CLEAR_PERI_REG_MASK(USB_DEVICE_CONF0_REG, USB_DEVICE_USB_PAD_ENABLE);
|
||||
}
|
||||
PIN_FUNC_SELECT(pin_name, func);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set peripheral output to an GPIO pad through the IOMUX.
|
||||
*
|
||||
@ -392,7 +417,7 @@ static inline void gpio_ll_iomux_out(gpio_dev_t *hw, uint8_t gpio_num, int func,
|
||||
{
|
||||
hw->func_out_sel_cfg[gpio_num].oen_sel = 0;
|
||||
hw->func_out_sel_cfg[gpio_num].oen_inv_sel = oen_inv;
|
||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio_num], func);
|
||||
gpio_ll_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_num], func);
|
||||
}
|
||||
|
||||
static inline void gpio_ll_force_hold_all(gpio_dev_t *hw)
|
||||
|
@ -905,6 +905,7 @@ static inline void i2c_ll_slave_init(i2c_dev_t *hw)
|
||||
ctrl_reg.sda_force_out = 1;
|
||||
ctrl_reg.scl_force_out = 1;
|
||||
hw->ctr.val = ctrl_reg.val;
|
||||
hw->ctr.slv_tx_auto_start_en = 1;
|
||||
hw->fifo_conf.fifo_addr_cfg_en = 0;
|
||||
}
|
||||
|
||||
|
@ -15,21 +15,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "soc/sensitive_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* === globals ====
|
||||
/* ******************************************************************************************************
|
||||
* *** GLOBALS ***
|
||||
* NOTE: in this version, all the configurations apply only to WORLD_0
|
||||
*/
|
||||
#ifndef SRAM_IRAM_START
|
||||
#define SRAM_IRAM_START 0x4037C000
|
||||
#endif
|
||||
|
||||
#ifndef SRAM_DRAM_START
|
||||
#define SRAM_DRAM_START 0x3FC7C000
|
||||
#endif
|
||||
#define IRAM_SRAM_START 0x4037C000
|
||||
#define DRAM_SRAM_START 0x3FC7C000
|
||||
|
||||
/* ICache size is fixed to 16KB on ESP32-C3 */
|
||||
#ifndef ICACHE_SIZE
|
||||
@ -40,36 +38,12 @@ extern "C" {
|
||||
#define I_D_SRAM_SEGMENT_SIZE 0x20000
|
||||
#endif
|
||||
|
||||
#ifndef I_D_SRAM_OFFSET
|
||||
#define I_D_SRAM_OFFSET (SRAM_IRAM_START - SRAM_DRAM_START)
|
||||
#endif
|
||||
|
||||
/* 2nd stage bootloader iram_loader_seg start address */
|
||||
#ifndef SRAM_DRAM_END
|
||||
#define SRAM_DRAM_END (0x403D0000 - I_D_SRAM_OFFSET)
|
||||
#endif
|
||||
|
||||
#ifndef SRAM_IRAM_ORG
|
||||
#define SRAM_IRAM_ORG (SRAM_IRAM_START + ICACHE_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef SRAM_DRAM_ORG
|
||||
#define SRAM_DRAM_ORG (SRAM_DRAM_START + ICACHE_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef I_D_SRAM_SIZE
|
||||
#define I_D_SRAM_SIZE SRAM_DRAM_END - SRAM_DRAM_ORG
|
||||
#endif
|
||||
|
||||
#define I_D_SPLIT_LINE_SHIFT 0x9
|
||||
#define I_D_FAULT_ADDR_SHIFT 0x2
|
||||
|
||||
#define MAP_DRAM_TO_IRAM(addr) (addr - SRAM_DRAM_START + SRAM_IRAM_START)
|
||||
#define MAP_IRAM_TO_DRAM(addr) (addr - SRAM_IRAM_START + SRAM_DRAM_START)
|
||||
|
||||
|
||||
static inline void memprot_ll_set_iram0_dram0_split_line_lock(bool lock)
|
||||
static inline void memprot_ll_set_iram0_dram0_split_line_lock(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG, lock ? 1 : 0);
|
||||
REG_WRITE(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG, 1);
|
||||
}
|
||||
|
||||
static inline bool memprot_ll_get_iram0_dram0_split_line_lock(void)
|
||||
@ -77,12 +51,19 @@ static inline bool memprot_ll_get_iram0_dram0_split_line_lock(void)
|
||||
return REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG) == 1;
|
||||
}
|
||||
|
||||
static inline void* memprot_ll_get_split_addr_from_reg(uint32_t regval, uint32_t base)
|
||||
{
|
||||
return (void*)
|
||||
(base + ((regval & SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_M)
|
||||
>> (SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_S - I_D_SPLIT_LINE_SHIFT)));
|
||||
}
|
||||
|
||||
/**
|
||||
* === IRAM0 ====
|
||||
/* ******************************************************************************************************
|
||||
* *** IRAM0 ***
|
||||
*/
|
||||
|
||||
//16kB (CACHE)
|
||||
#define IRAM0_SRAM_LEVEL_0_LOW SRAM_IRAM_START //0x40370000
|
||||
#define IRAM0_SRAM_LEVEL_0_LOW IRAM_SRAM_START //0x40370000
|
||||
#define IRAM0_SRAM_LEVEL_0_HIGH (IRAM0_SRAM_LEVEL_0_LOW + ICACHE_SIZE - 0x1) //0x4037FFFF
|
||||
|
||||
//128kB (LEVEL 1)
|
||||
@ -107,7 +88,10 @@ static inline uint32_t memprot_ll_iram0_get_intr_source_num(void)
|
||||
return ETS_CORE0_IRAM0_PMS_INTR_SOURCE;
|
||||
}
|
||||
|
||||
/* SPLIT LINE */
|
||||
|
||||
///////////////////////////////////
|
||||
// IRAM0 - SPLIT LINES
|
||||
///////////////////////////////////
|
||||
|
||||
static inline void memprot_ll_set_iram0_split_line(const void *line_addr, uint32_t sensitive_reg)
|
||||
{
|
||||
@ -125,7 +109,7 @@ static inline void memprot_ll_set_iram0_split_line(const void *line_addr, uint32
|
||||
category[2] = 0x2;
|
||||
}
|
||||
|
||||
//category bits are the same for all areas
|
||||
//NOTE: category & split line address bits are the same for all the areas
|
||||
uint32_t category_bits =
|
||||
(category[0] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_0_S) |
|
||||
(category[1] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_1_S) |
|
||||
@ -154,12 +138,30 @@ static inline void memprot_ll_set_iram0_split_line_I_1(const void *line_addr)
|
||||
memprot_ll_set_iram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG);
|
||||
}
|
||||
|
||||
|
||||
/* PMS */
|
||||
|
||||
static inline void memprot_ll_iram0_set_pms_lock(bool lock)
|
||||
static inline void* memprot_ll_get_iram0_split_line_main_I_D(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG, lock ? 1 : 0);
|
||||
return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_1_REG), SOC_DIRAM_IRAM_LOW);
|
||||
}
|
||||
|
||||
static inline void* memprot_ll_get_iram0_split_line_I_0(void)
|
||||
{
|
||||
return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG), SOC_DIRAM_IRAM_LOW);
|
||||
}
|
||||
|
||||
static inline void* memprot_ll_get_iram0_split_line_I_1(void)
|
||||
{
|
||||
return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG), SOC_DIRAM_IRAM_LOW);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// IRAM0 - PMS CONFIGURATION
|
||||
///////////////////////////////////
|
||||
|
||||
// lock
|
||||
static inline void memprot_ll_iram0_set_pms_lock(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG, 1);
|
||||
}
|
||||
|
||||
static inline bool memprot_ll_iram0_get_pms_lock(void)
|
||||
@ -167,7 +169,7 @@ static inline bool memprot_ll_iram0_get_pms_lock(void)
|
||||
return REG_READ(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG) == 1;
|
||||
}
|
||||
|
||||
//world_0 permissions
|
||||
// permission settings
|
||||
static inline uint32_t memprot_ll_iram0_set_permissions(bool r, bool w, bool x)
|
||||
{
|
||||
uint32_t permissions = 0;
|
||||
@ -204,11 +206,46 @@ static inline void memprot_ll_iram0_set_pms_area_3(bool r, bool w, bool x)
|
||||
REG_SET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3, memprot_ll_iram0_set_permissions(r, w, x));
|
||||
}
|
||||
|
||||
/* MONITOR */
|
||||
|
||||
static inline void memprot_ll_iram0_set_monitor_lock(bool lock)
|
||||
static inline void memprot_ll_iram0_get_permissions(uint32_t perms, bool *r, bool *w, bool *x)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG, lock ? 1 : 0);
|
||||
*r = perms & SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R;
|
||||
*w = perms & SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W;
|
||||
*x = perms & SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_F;
|
||||
}
|
||||
|
||||
static inline void memprot_ll_iram0_get_pms_area_0(bool *r, bool *w, bool *x)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_0);
|
||||
memprot_ll_iram0_get_permissions( permissions, r, w, x);
|
||||
}
|
||||
|
||||
static inline void memprot_ll_iram0_get_pms_area_1(bool *r, bool *w, bool *x)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_1);
|
||||
memprot_ll_iram0_get_permissions( permissions, r, w, x);
|
||||
}
|
||||
|
||||
static inline void memprot_ll_iram0_get_pms_area_2(bool *r, bool *w, bool *x)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_2);
|
||||
memprot_ll_iram0_get_permissions( permissions, r, w, x);
|
||||
}
|
||||
|
||||
static inline void memprot_ll_iram0_get_pms_area_3(bool *r, bool *w, bool *x)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3);
|
||||
memprot_ll_iram0_get_permissions( permissions, r, w, x);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// IRAM0 - MONITOR
|
||||
///////////////////////////////////
|
||||
|
||||
// lock
|
||||
static inline void memprot_ll_iram0_set_monitor_lock(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG, 1);
|
||||
}
|
||||
|
||||
static inline bool memprot_ll_iram0_get_monitor_lock(void)
|
||||
@ -216,6 +253,7 @@ static inline bool memprot_ll_iram0_get_monitor_lock(void)
|
||||
return REG_READ(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG) == 1;
|
||||
}
|
||||
|
||||
// interrupt enable/clear
|
||||
static inline void memprot_ll_iram0_set_monitor_en(bool enable)
|
||||
{
|
||||
if ( enable ) {
|
||||
@ -227,27 +265,38 @@ static inline void memprot_ll_iram0_set_monitor_en(bool enable)
|
||||
|
||||
static inline bool memprot_ll_iram0_get_monitor_en(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_EN ) == 1;
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_EN ) == 1;
|
||||
}
|
||||
|
||||
static inline void memprot_ll_iram0_clear_monitor_intr(void)
|
||||
{
|
||||
REG_SET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_CLR );
|
||||
}
|
||||
|
||||
static inline void memprot_ll_iram0_reset_clear_monitor_intr(void)
|
||||
{
|
||||
REG_CLR_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_CLR );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_enable_register(void)
|
||||
{
|
||||
return REG_READ(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG);
|
||||
}
|
||||
|
||||
// // permission violation status
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_status_intr(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_INTR );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_INTR );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_wr(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_WR );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_WR );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_loadstore(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_LOADSTORE );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_LOADSTORE );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_world(void)
|
||||
@ -257,16 +306,22 @@ static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_world(void)
|
||||
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_addr(void)
|
||||
{
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR );
|
||||
uint32_t addr = REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR );
|
||||
return addr > 0 ? (addr << I_D_FAULT_ADDR_SHIFT) + IRAM0_ADDRESS_LOW : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_iram0_get_monitor_status_register(void)
|
||||
{
|
||||
return REG_READ(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* === DRAM0 ====
|
||||
/* ******************************************************************************************************
|
||||
* *** DRAM0 ***
|
||||
*/
|
||||
|
||||
//cache not available from DRAM
|
||||
#define DRAM0_SRAM_LEVEL_0_LOW SRAM_DRAM_START //0x3FC7C000
|
||||
//cache not available from DRAM (!)
|
||||
#define DRAM0_SRAM_LEVEL_0_LOW DRAM_SRAM_START //0x3FC7C000
|
||||
#define DRAM0_SRAM_LEVEL_0_HIGH (DRAM0_SRAM_LEVEL_0_LOW + ICACHE_SIZE - 0x1) //0x3FC7FFFF
|
||||
|
||||
//128kB
|
||||
@ -291,7 +346,9 @@ static inline uint32_t memprot_ll_dram0_get_intr_source_num(void)
|
||||
}
|
||||
|
||||
|
||||
/* SPLIT LINE */
|
||||
///////////////////////////////////
|
||||
// DRAM0 - SPLIT LINES
|
||||
///////////////////////////////////
|
||||
|
||||
static inline void memprot_ll_set_dram0_split_line(const void *line_addr, uint32_t sensitive_reg)
|
||||
{
|
||||
@ -309,7 +366,7 @@ static inline void memprot_ll_set_dram0_split_line(const void *line_addr, uint32
|
||||
category[2] = 0x2;
|
||||
}
|
||||
|
||||
//category bits are the same for all areas
|
||||
//NOTE: line address & category bits, shifts and masks are the same for all the areas
|
||||
uint32_t category_bits =
|
||||
(category[0] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_0_S) |
|
||||
(category[1] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_1_S) |
|
||||
@ -332,12 +389,25 @@ static inline void memprot_ll_set_dram0_split_line_D_1(const void *line_addr)
|
||||
memprot_ll_set_dram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG);
|
||||
}
|
||||
|
||||
|
||||
/* PMS */
|
||||
|
||||
static inline void memprot_ll_dram0_set_pms_lock(bool lock)
|
||||
static inline void* memprot_ll_get_dram0_split_line_D_0(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG, lock ? 1 : 0);
|
||||
return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG), SOC_DIRAM_DRAM_LOW);
|
||||
}
|
||||
|
||||
static inline void* memprot_ll_get_dram0_split_line_D_1(void)
|
||||
{
|
||||
return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG), SOC_DIRAM_DRAM_LOW);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// DRAM0 - PMS CONFIGURATION
|
||||
///////////////////////////////////
|
||||
|
||||
// lock
|
||||
static inline void memprot_ll_dram0_set_pms_lock(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG, 1);
|
||||
}
|
||||
|
||||
static inline bool memprot_ll_dram0_get_pms_lock(void)
|
||||
@ -345,6 +415,7 @@ static inline bool memprot_ll_dram0_get_pms_lock(void)
|
||||
return REG_READ(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG) == 1;
|
||||
}
|
||||
|
||||
// permission settings
|
||||
static inline uint32_t memprot_ll_dram0_set_permissions(bool r, bool w)
|
||||
{
|
||||
uint32_t permissions = 0;
|
||||
@ -378,12 +449,44 @@ static inline void memprot_ll_dram0_set_pms_area_3(bool r, bool w)
|
||||
REG_SET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3, memprot_ll_dram0_set_permissions(r, w));
|
||||
}
|
||||
|
||||
|
||||
/* MONITOR */
|
||||
|
||||
static inline void memprot_ll_dram0_set_monitor_lock(bool lock)
|
||||
static inline void memprot_ll_dram0_get_permissions(uint32_t perms, bool *r, bool *w )
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG, lock ? 1 : 0);
|
||||
*r = perms & SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R;
|
||||
*w = perms & SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W;
|
||||
}
|
||||
|
||||
static inline void memprot_ll_dram0_get_pms_area_0(bool *r, bool *w)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_0);
|
||||
memprot_ll_dram0_get_permissions( permissions, r, w);
|
||||
}
|
||||
|
||||
static inline void memprot_ll_dram0_get_pms_area_1(bool *r, bool *w)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_1);
|
||||
memprot_ll_dram0_get_permissions( permissions, r, w);
|
||||
}
|
||||
|
||||
static inline void memprot_ll_dram0_get_pms_area_2(bool *r, bool *w)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_2);
|
||||
memprot_ll_dram0_get_permissions( permissions, r, w);
|
||||
}
|
||||
|
||||
static inline void memprot_ll_dram0_get_pms_area_3(bool *r, bool *w)
|
||||
{
|
||||
uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3);
|
||||
memprot_ll_dram0_get_permissions( permissions, r, w);
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// DRAM0 - MONITOR
|
||||
///////////////////////////////////
|
||||
|
||||
// lock
|
||||
static inline void memprot_ll_dram0_set_monitor_lock(void)
|
||||
{
|
||||
REG_WRITE(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG, 1);
|
||||
}
|
||||
|
||||
static inline bool memprot_ll_dram0_get_monitor_lock(void)
|
||||
@ -391,6 +494,7 @@ static inline bool memprot_ll_dram0_get_monitor_lock(void)
|
||||
return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG) == 1;
|
||||
}
|
||||
|
||||
// interrupt enable/clear
|
||||
static inline void memprot_ll_dram0_set_monitor_en(bool enable)
|
||||
{
|
||||
if ( enable ) {
|
||||
@ -406,18 +510,29 @@ static inline bool memprot_ll_dram0_get_monitor_en(void)
|
||||
}
|
||||
|
||||
static inline void memprot_ll_dram0_clear_monitor_intr(void)
|
||||
{
|
||||
REG_SET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_CLR );
|
||||
}
|
||||
|
||||
static inline void memprot_ll_dram0_reset_clear_monitor_intr(void)
|
||||
{
|
||||
REG_CLR_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_CLR );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_enable_register(void)
|
||||
{
|
||||
return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG);
|
||||
}
|
||||
|
||||
// permission violation status
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_intr(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_INTR );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_INTR );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_lock(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_LOCK );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_LOCK );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_world(void)
|
||||
@ -427,19 +542,29 @@ static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_world(void)
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_addr(void)
|
||||
{
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR );
|
||||
uint32_t addr = REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR );
|
||||
return addr > 0 ? (addr << I_D_FAULT_ADDR_SHIFT) + DRAM0_ADDRESS_LOW : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_wr(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_3_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_WR );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_3_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_WR );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_byte_en(void)
|
||||
{
|
||||
return REG_GET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_BYTEEN );
|
||||
return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_BYTEEN );
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_register_1(void)
|
||||
{
|
||||
return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG);
|
||||
}
|
||||
|
||||
static inline uint32_t memprot_ll_dram0_get_monitor_status_register_2(void)
|
||||
{
|
||||
return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_3_REG);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -466,6 +466,14 @@ void gpio_hal_sleep_pupd_config_unapply(gpio_hal_context_t *hal, gpio_num_t gpio
|
||||
|
||||
#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
|
||||
/**
|
||||
* @brief Select a function for the pin in the IOMUX
|
||||
*
|
||||
* @param pin_name Pin name to configure
|
||||
* @param func Function to assign to the pin
|
||||
*/
|
||||
#define gpio_hal_iomux_func_sel(pin_name, func) gpio_ll_iomux_func_sel(pin_name, func)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -79,36 +79,9 @@ typedef enum {
|
||||
I2C_SCLK_MAX,
|
||||
} i2c_sclk_t;
|
||||
|
||||
// I2C clk flags for users to use, can be expanded in the future.
|
||||
#define I2C_SCLK_SRC_FLAG_FOR_NOMAL (0) /*!< Any one clock source that is available for the specified frequency may be choosen*/
|
||||
#define I2C_SCLK_SRC_FLAG_AWARE_DFS (1 << 0) /*!< For REF tick clock, it won't change with APB.*/
|
||||
#define I2C_SCLK_SRC_FLAG_LIGHT_SLEEP (1 << 1) /*!< For light sleep mode.*/
|
||||
|
||||
/// Use the highest speed that is available for the clock source picked by clk_flags
|
||||
#define I2C_CLK_FREQ_MAX (-1)
|
||||
|
||||
/**
|
||||
* @brief I2C initialization parameters
|
||||
*/
|
||||
typedef struct{
|
||||
i2c_mode_t mode; /*!< I2C mode */
|
||||
int sda_io_num; /*!< GPIO number for I2C sda signal */
|
||||
int scl_io_num; /*!< GPIO number for I2C scl signal */
|
||||
bool sda_pullup_en; /*!< Internal GPIO pull mode for I2C sda signal*/
|
||||
bool scl_pullup_en; /*!< Internal GPIO pull mode for I2C scl signal*/
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t clk_speed; /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
|
||||
} master; /*!< I2C master config */
|
||||
struct {
|
||||
uint8_t addr_10bit_en; /*!< I2C 10bit address mode enable for slave mode */
|
||||
uint16_t slave_addr; /*!< I2C address for slave mode */
|
||||
} slave; /*!< I2C slave config */
|
||||
};
|
||||
uint32_t clk_flags; /*!< Bitwise of ``I2C_SCLK_SRC_FLAG_**FOR_DFS**`` for clk source choice*/
|
||||
} i2c_config_t;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
typedef enum{
|
||||
I2C_CMD_RESTART = 0, /*!<I2C restart command */
|
||||
|
@ -115,7 +115,6 @@ typedef enum {
|
||||
I2S_CLK_APLL, /*!< Clock from APLL*/
|
||||
} i2s_clock_src_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief I2S configuration parameters for i2s_param_config function
|
||||
*
|
||||
@ -145,6 +144,7 @@ typedef enum {
|
||||
I2S_EVENT_MAX, /*!< I2S event max index*/
|
||||
} i2s_event_type_t;
|
||||
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
/**
|
||||
* @brief I2S DAC mode for i2s_set_dac_mode.
|
||||
*
|
||||
@ -157,6 +157,7 @@ typedef enum {
|
||||
I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/
|
||||
I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/
|
||||
} i2s_dac_mode_t;
|
||||
#endif //SOC_I2S_SUPPORTS_ADC_DAC
|
||||
|
||||
/**
|
||||
* @brief Event structure used in I2S event queue
|
||||
|
@ -160,7 +160,7 @@ typedef struct {
|
||||
* Init the peripheral and the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param host_id Index of the SPI peripheral. 0 for SPI1, 1 for HSPI (SPI2) and 2 for VSPI (SPI3).
|
||||
* @param host_id Index of the SPI peripheral. 0 for SPI1, 1 for SPI2 and 2 for SPI3.
|
||||
* @param hal_config Configuration of the hal defined by the upper layer.
|
||||
*/
|
||||
void spi_hal_init(spi_hal_context_t *hal, uint32_t host_id, const spi_hal_config_t *hal_config);
|
||||
|
@ -91,8 +91,8 @@ typedef struct {
|
||||
/**
|
||||
* Init the peripheral and the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param host_id Index of the SPI peripheral. 0 for SPI1, 1 for HSPI (SPI2) and 2 for VSPI (SPI3).
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param hal_config Configuration of the HAL
|
||||
*/
|
||||
void spi_slave_hal_init(spi_slave_hal_context_t *hal, const spi_slave_hal_config_t *hal_config);
|
||||
|
||||
|
@ -44,21 +44,16 @@ FLAG_ATTR(spi_event_t)
|
||||
|
||||
/** @cond */ //Doxy command to hide preprocessor definitions from docs */
|
||||
|
||||
//alias for different chips
|
||||
//alias for different chips, deprecated for the chips after esp32s2
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define SPI_HOST SPI1_HOST
|
||||
#define HSPI_HOST SPI2_HOST
|
||||
#define VSPI_HOST SPI3_HOST
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2 and later
|
||||
#define SPI_HOST SPI1_HOST
|
||||
#define FSPI_HOST SPI2_HOST
|
||||
#define HSPI_HOST SPI3_HOST
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
/* No SPI3_host on C3 */
|
||||
#define SPI_HOST SPI1_HOST
|
||||
#define FSPI_HOST SPI2_HOST
|
||||
#define HSPI_HOST SPI2_HOST
|
||||
#endif
|
||||
|
||||
/** @endcond */
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include "sodium/crypto_onetimeauth_poly1305.h"
|
||||
#include "sodium/crypto_pwhash.h"
|
||||
#include "sodium/crypto_pwhash_argon2i.h"
|
||||
#include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
|
||||
#include "sodium/crypto_scalarmult.h"
|
||||
#include "sodium/crypto_scalarmult_curve25519.h"
|
||||
#include "sodium/crypto_secretbox.h"
|
||||
#include "sodium/crypto_secretbox_xsalsa20poly1305.h"
|
||||
#include "sodium/crypto_secretstream_xchacha20poly1305.h"
|
||||
#include "sodium/crypto_shorthash.h"
|
||||
#include "sodium/crypto_shorthash_siphash24.h"
|
||||
#include "sodium/crypto_sign.h"
|
||||
@ -48,18 +48,19 @@
|
||||
#include "sodium/crypto_verify_32.h"
|
||||
#include "sodium/crypto_verify_64.h"
|
||||
#include "sodium/randombytes.h"
|
||||
#ifdef __native_client__
|
||||
# include "sodium/randombytes_nativeclient.h"
|
||||
#endif
|
||||
#include "sodium/randombytes_salsa20_random.h"
|
||||
#include "sodium/randombytes_internal_random.h"
|
||||
#include "sodium/randombytes_sysrandom.h"
|
||||
#include "sodium/runtime.h"
|
||||
#include "sodium/utils.h"
|
||||
|
||||
#ifndef SODIUM_LIBRARY_MINIMAL
|
||||
# include "sodium/crypto_box_curve25519xchacha20poly1305.h"
|
||||
# include "sodium/crypto_core_ed25519.h"
|
||||
# include "sodium/crypto_core_ristretto255.h"
|
||||
# include "sodium/crypto_scalarmult_ed25519.h"
|
||||
# include "sodium/crypto_scalarmult_ristretto255.h"
|
||||
# include "sodium/crypto_secretbox_xchacha20poly1305.h"
|
||||
# include "sodium/crypto_stream_aes128ctr.h"
|
||||
# include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
|
||||
# include "sodium/crypto_stream_salsa2012.h"
|
||||
# include "sodium/crypto_stream_salsa208.h"
|
||||
# include "sodium/crypto_stream_xchacha20.h"
|
||||
|
@ -12,6 +12,15 @@ SODIUM_EXPORT
|
||||
int sodium_init(void)
|
||||
__attribute__ ((warn_unused_result));
|
||||
|
||||
/* ---- */
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_set_misuse_handler(void (*handler)(void));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void sodium_misuse(void)
|
||||
__attribute__ ((noreturn));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,6 +1,26 @@
|
||||
#ifndef crypto_aead_aes256gcm_H
|
||||
#define crypto_aead_aes256gcm_H
|
||||
|
||||
/*
|
||||
* WARNING: Despite being the most popular AEAD construction due to its
|
||||
* use in TLS, safely using AES-GCM in a different context is tricky.
|
||||
*
|
||||
* No more than ~ 350 GB of input data should be encrypted with a given key.
|
||||
* This is for ~ 16 KB messages -- Actual figures vary according to
|
||||
* message sizes.
|
||||
*
|
||||
* In addition, nonces are short and repeated nonces would totally destroy
|
||||
* the security of this scheme.
|
||||
*
|
||||
* Nonces should thus come from atomic counters, which can be difficult to
|
||||
* set up in a distributed environment.
|
||||
*
|
||||
* Unless you absolutely need AES-GCM, use crypto_aead_xchacha20poly1305_ietf_*()
|
||||
* instead. It doesn't have any of these limitations.
|
||||
* Or, if you don't need to authenticate additional data, just stick to
|
||||
* crypto_secretbox().
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "export.h"
|
||||
|
||||
@ -30,7 +50,15 @@ size_t crypto_aead_aes256gcm_npubbytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_aes256gcm_abytes(void);
|
||||
|
||||
typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512];
|
||||
#define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \
|
||||
(16ULL * ((1ULL << 32) - 2ULL)))
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_aes256gcm_messagebytes_max(void);
|
||||
|
||||
typedef struct CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state_ {
|
||||
unsigned char opaque[512];
|
||||
} crypto_aead_aes256gcm_state;
|
||||
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_aes256gcm_statebytes(void);
|
||||
@ -44,7 +72,8 @@ int crypto_aead_aes256gcm_encrypt(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt(unsigned char *m,
|
||||
@ -56,7 +85,7 @@ int crypto_aead_aes256gcm_decrypt(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c,
|
||||
@ -68,7 +97,8 @@ int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m,
|
||||
@ -80,13 +110,14 @@ int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
/* -- Precomputation interface -- */
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_beforenm(crypto_aead_aes256gcm_state *ctx_,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c,
|
||||
@ -97,7 +128,8 @@ int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_);
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
|
||||
@ -109,7 +141,7 @@ int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c,
|
||||
@ -121,7 +153,8 @@ int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_);
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m,
|
||||
@ -133,10 +166,11 @@ int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]);
|
||||
void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ size_t crypto_aead_chacha20poly1305_ietf_npubbytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_chacha20poly1305_ietf_abytes(void);
|
||||
|
||||
#define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \
|
||||
(64ULL * ((1ULL << 32) - 1ULL)))
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c,
|
||||
unsigned long long *clen_p,
|
||||
@ -39,7 +45,8 @@ int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m,
|
||||
@ -51,7 +58,7 @@ int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
||||
@ -63,7 +70,8 @@ int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
||||
@ -75,10 +83,11 @@ int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]);
|
||||
void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* -- Original ChaCha20-Poly1305 construction with a 64-bit nonce and a 64-bit internal counter -- */
|
||||
|
||||
@ -98,6 +107,11 @@ size_t crypto_aead_chacha20poly1305_npubbytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_chacha20poly1305_abytes(void);
|
||||
|
||||
#define crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX \
|
||||
(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ABYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_chacha20poly1305_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
|
||||
unsigned long long *clen_p,
|
||||
@ -107,7 +121,8 @@ int crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_decrypt(unsigned char *m,
|
||||
@ -119,7 +134,7 @@ int crypto_aead_chacha20poly1305_decrypt(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c,
|
||||
@ -131,7 +146,8 @@ int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m,
|
||||
@ -143,17 +159,19 @@ int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]);
|
||||
void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* Aliases */
|
||||
|
||||
#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES
|
||||
#define crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -27,6 +27,11 @@ size_t crypto_aead_xchacha20poly1305_ietf_npubbytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_xchacha20poly1305_ietf_abytes(void);
|
||||
|
||||
#define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \
|
||||
(SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
|
||||
unsigned long long *clen_p,
|
||||
@ -36,7 +41,8 @@ int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m,
|
||||
@ -48,7 +54,7 @@ int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
||||
@ -60,7 +66,8 @@ int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
||||
@ -72,17 +79,19 @@ int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
||||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]);
|
||||
void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* Aliases */
|
||||
|
||||
#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES
|
||||
#define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -27,15 +27,17 @@ const char *crypto_auth_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_verify(const unsigned char *h, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES]);
|
||||
void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@ -46,20 +46,22 @@ size_t crypto_auth_hmacsha256_statebytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
|
||||
const unsigned char *key,
|
||||
size_t keylen);
|
||||
size_t keylen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]);
|
||||
void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@ -46,19 +46,20 @@ size_t crypto_auth_hmacsha512_statebytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
|
||||
const unsigned char *key,
|
||||
size_t keylen);
|
||||
size_t keylen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES]);
|
||||
void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -21,15 +21,17 @@ SODIUM_EXPORT
|
||||
size_t crypto_auth_hmacsha512256_keybytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen,const unsigned char *k);
|
||||
int crypto_auth_hmacsha512256(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@ -41,19 +43,20 @@ size_t crypto_auth_hmacsha512256_statebytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
|
||||
const unsigned char *key,
|
||||
size_t keylen);
|
||||
size_t keylen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES]);
|
||||
void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -40,35 +40,41 @@ size_t crypto_box_noncebytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_macbytes(void);
|
||||
|
||||
#define crypto_box_MESSAGEBYTES_MAX crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_messagebytes_max(void);
|
||||
|
||||
#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305"
|
||||
SODIUM_EXPORT
|
||||
const char *crypto_box_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int crypto_box_keypair(unsigned char *pk, unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_easy(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_easy(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_detached(unsigned char *c, unsigned char *mac,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *n, const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
|
||||
@ -77,7 +83,7 @@ int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7)));
|
||||
|
||||
/* -- Precomputation interface -- */
|
||||
|
||||
@ -88,30 +94,31 @@ size_t crypto_box_beforenmbytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_easy_afternm(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_easy_afternm(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c,
|
||||
const unsigned char *mac,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
/* -- Ephemeral SK interface -- */
|
||||
|
||||
@ -121,13 +128,14 @@ size_t crypto_box_sealbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_seal(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *pk);
|
||||
unsigned long long mlen, const unsigned char *pk)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_seal_open(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
@ -143,24 +151,24 @@ SODIUM_EXPORT
|
||||
int crypto_box(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_afternm(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define crypto_box_curve25519xchacha20poly1305_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "crypto_stream_xchacha20.h"
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -36,14 +37,21 @@ size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_curve25519xchacha20poly1305_macbytes(void);
|
||||
|
||||
#define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \
|
||||
(crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk,
|
||||
unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk,
|
||||
unsigned char *sk);
|
||||
unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
|
||||
@ -52,7 +60,7 @@ int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
|
||||
@ -61,7 +69,7 @@ int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
|
||||
@ -71,7 +79,7 @@ int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
|
||||
@ -81,7 +89,7 @@ int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7)));
|
||||
|
||||
/* -- Precomputation interface -- */
|
||||
|
||||
@ -89,14 +97,15 @@ SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
|
||||
@ -104,7 +113,7 @@ int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
|
||||
@ -112,7 +121,8 @@ int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m,
|
||||
@ -121,7 +131,31 @@ int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
/* -- Ephemeral SK interface -- */
|
||||
|
||||
#define crypto_box_curve25519xchacha20poly1305_SEALBYTES \
|
||||
(crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \
|
||||
crypto_box_curve25519xchacha20poly1305_MACBYTES)
|
||||
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
|
||||
const unsigned char *c,
|
||||
unsigned long long clen,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define crypto_box_curve25519xsalsa20poly1305_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "crypto_stream_xsalsa20.h"
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -35,6 +36,31 @@ size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void);
|
||||
|
||||
/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
|
||||
#define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \
|
||||
(crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk,
|
||||
unsigned char *sk,
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk,
|
||||
unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void);
|
||||
@ -52,7 +78,7 @@ int crypto_box_curve25519xsalsa20poly1305(unsigned char *c,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
|
||||
@ -61,29 +87,15 @@ int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
|
||||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk,
|
||||
unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk,
|
||||
unsigned char *sk);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
|
||||
@ -91,7 +103,7 @@ int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -0,0 +1,100 @@
|
||||
#ifndef crypto_core_ed25519_H
|
||||
#define crypto_core_ed25519_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_core_ed25519_BYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_bytes(void);
|
||||
|
||||
#define crypto_core_ed25519_UNIFORMBYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_uniformbytes(void);
|
||||
|
||||
#define crypto_core_ed25519_HASHBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_hashbytes(void);
|
||||
|
||||
#define crypto_core_ed25519_SCALARBYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_scalarbytes(void);
|
||||
|
||||
#define crypto_core_ed25519_NONREDUCEDSCALARBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_nonreducedscalarbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_is_valid_point(const unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_add(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_sub(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_from_hash(unsigned char *p, const unsigned char *h)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_random(unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_random(unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_scalar_invert(unsigned char *recip, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_negate(unsigned char *neg, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_complement(unsigned char *comp, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_add(unsigned char *z, const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_sub(unsigned char *z, const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_mul(unsigned char *z, const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* The interval `s` is sampled from should be at least 317 bits to ensure almost
|
||||
* uniformity of `r` over `L`.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_reduce(unsigned char *r, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -26,7 +26,8 @@ size_t crypto_core_hchacha20_constbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_hchacha20(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ size_t crypto_core_hsalsa20_constbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -0,0 +1,100 @@
|
||||
#ifndef crypto_core_ristretto255_H
|
||||
#define crypto_core_ristretto255_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_core_ristretto255_BYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_bytes(void);
|
||||
|
||||
#define crypto_core_ristretto255_HASHBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_hashbytes(void);
|
||||
|
||||
#define crypto_core_ristretto255_SCALARBYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_scalarbytes(void);
|
||||
|
||||
#define crypto_core_ristretto255_NONREDUCEDSCALARBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_nonreducedscalarbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_is_valid_point(const unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_add(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_sub(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_from_hash(unsigned char *p,
|
||||
const unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_random(unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_random(unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_scalar_invert(unsigned char *recip,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_negate(unsigned char *neg,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_complement(unsigned char *comp,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_add(unsigned char *z,
|
||||
const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_sub(unsigned char *z,
|
||||
const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_mul(unsigned char *z,
|
||||
const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* The interval `s` is sampled from should be at least 317 bits to ensure almost
|
||||
* uniformity of `r` over `L`.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_reduce(unsigned char *r,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -26,7 +26,8 @@ size_t crypto_core_salsa20_constbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_salsa20(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ size_t crypto_core_salsa2012_constbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_salsa2012(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -10,23 +10,28 @@ extern "C" {
|
||||
|
||||
#define crypto_core_salsa208_OUTPUTBYTES 64U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_salsa208_outputbytes(void);
|
||||
size_t crypto_core_salsa208_outputbytes(void)
|
||||
__attribute__ ((deprecated));
|
||||
|
||||
#define crypto_core_salsa208_INPUTBYTES 16U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_salsa208_inputbytes(void);
|
||||
size_t crypto_core_salsa208_inputbytes(void)
|
||||
__attribute__ ((deprecated));
|
||||
|
||||
#define crypto_core_salsa208_KEYBYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_salsa208_keybytes(void);
|
||||
size_t crypto_core_salsa208_keybytes(void)
|
||||
__attribute__ ((deprecated));
|
||||
|
||||
#define crypto_core_salsa208_CONSTBYTES 16U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_salsa208_constbytes(void);
|
||||
size_t crypto_core_salsa208_constbytes(void)
|
||||
__attribute__ ((deprecated));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_salsa208(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ size_t crypto_generichash_keybytes(void);
|
||||
SODIUM_EXPORT
|
||||
const char *crypto_generichash_primitive(void);
|
||||
|
||||
/*
|
||||
* Important when writing bindings for other programming languages:
|
||||
* the state address should be 64-bytes aligned.
|
||||
*/
|
||||
typedef crypto_generichash_blake2b_state crypto_generichash_state;
|
||||
|
||||
SODIUM_EXPORT
|
||||
@ -49,24 +53,29 @@ size_t crypto_generichash_statebytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash(unsigned char *out, size_t outlen,
|
||||
const unsigned char *in, unsigned long long inlen,
|
||||
const unsigned char *key, size_t keylen);
|
||||
const unsigned char *key, size_t keylen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_init(crypto_generichash_state *state,
|
||||
const unsigned char *key,
|
||||
const size_t keylen, const size_t outlen);
|
||||
const size_t keylen, const size_t outlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_update(crypto_generichash_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_final(crypto_generichash_state *state,
|
||||
unsigned char *out, const size_t outlen);
|
||||
unsigned char *out, const size_t outlen)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]);
|
||||
void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -20,13 +20,8 @@ extern "C" {
|
||||
# pragma pack(push, 1)
|
||||
#endif
|
||||
|
||||
typedef CRYPTO_ALIGN(64) struct crypto_generichash_blake2b_state {
|
||||
uint64_t h[8];
|
||||
uint64_t t[2];
|
||||
uint64_t f[2];
|
||||
uint8_t buf[2 * 128];
|
||||
size_t buflen;
|
||||
uint8_t last_node;
|
||||
typedef struct CRYPTO_ALIGN(64) crypto_generichash_blake2b_state {
|
||||
unsigned char opaque[384];
|
||||
} crypto_generichash_blake2b_state;
|
||||
|
||||
#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
@ -74,7 +69,8 @@ SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b(unsigned char *out, size_t outlen,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *key, size_t keylen);
|
||||
const unsigned char *key, size_t keylen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen,
|
||||
@ -83,36 +79,37 @@ int crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen,
|
||||
const unsigned char *key,
|
||||
size_t keylen,
|
||||
const unsigned char *salt,
|
||||
const unsigned char *personal);
|
||||
const unsigned char *personal)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state,
|
||||
const unsigned char *key,
|
||||
const size_t keylen, const size_t outlen);
|
||||
const size_t keylen, const size_t outlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_init_salt_personal(crypto_generichash_blake2b_state *state,
|
||||
const unsigned char *key,
|
||||
const size_t keylen, const size_t outlen,
|
||||
const unsigned char *salt,
|
||||
const unsigned char *personal);
|
||||
const unsigned char *personal)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_update(crypto_generichash_blake2b_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state,
|
||||
unsigned char *out,
|
||||
const size_t outlen);
|
||||
const size_t outlen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_generichash_blake2b_keygen(unsigned char k[crypto_generichash_blake2b_KEYBYTES]);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int _crypto_generichash_blake2b_pick_best_implementation(void);
|
||||
void crypto_generichash_blake2b_keygen(unsigned char k[crypto_generichash_blake2b_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ size_t crypto_hash_bytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
#define crypto_hash_PRIMITIVE "sha512"
|
||||
SODIUM_EXPORT
|
||||
|
@ -36,19 +36,22 @@ size_t crypto_hash_sha256_bytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256_init(crypto_hash_sha256_state *state);
|
||||
int crypto_hash_sha256_init(crypto_hash_sha256_state *state)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256_update(crypto_hash_sha256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256_final(crypto_hash_sha256_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -36,19 +36,22 @@ size_t crypto_hash_sha512_bytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512_init(crypto_hash_sha512_state *state);
|
||||
int crypto_hash_sha512_init(crypto_hash_sha512_state *state)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512_update(crypto_hash_sha512_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512_final(crypto_hash_sha512_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -39,10 +39,12 @@ SODIUM_EXPORT
|
||||
int crypto_kdf_derive_from_key(unsigned char *subkey, size_t subkey_len,
|
||||
uint64_t subkey_id,
|
||||
const char ctx[crypto_kdf_CONTEXTBYTES],
|
||||
const unsigned char key[crypto_kdf_KEYBYTES]);
|
||||
const unsigned char key[crypto_kdf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES]);
|
||||
void crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ SODIUM_EXPORT
|
||||
int crypto_kdf_blake2b_derive_from_key(unsigned char *subkey, size_t subkey_len,
|
||||
uint64_t subkey_id,
|
||||
const char ctx[crypto_kdf_blake2b_CONTEXTBYTES],
|
||||
const unsigned char key[crypto_kdf_blake2b_KEYBYTES]);
|
||||
const unsigned char key[crypto_kdf_blake2b_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -35,11 +35,13 @@ const char *crypto_kx_primitive(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_seed_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
|
||||
unsigned char sk[crypto_kx_SECRETKEYBYTES],
|
||||
const unsigned char seed[crypto_kx_SEEDBYTES]);
|
||||
const unsigned char seed[crypto_kx_SEEDBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
|
||||
unsigned char sk[crypto_kx_SECRETKEYBYTES]);
|
||||
unsigned char sk[crypto_kx_SECRETKEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
||||
@ -47,7 +49,7 @@ int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
||||
const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES],
|
||||
const unsigned char client_sk[crypto_kx_SECRETKEYBYTES],
|
||||
const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES])
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
||||
@ -55,7 +57,7 @@ int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
||||
const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES],
|
||||
const unsigned char server_sk[crypto_kx_SECRETKEYBYTES],
|
||||
const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES])
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -32,28 +32,31 @@ const char *crypto_onetimeauth_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_init(crypto_onetimeauth_state *state,
|
||||
const unsigned char *key);
|
||||
const unsigned char *key) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_update(crypto_onetimeauth_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_final(crypto_onetimeauth_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES]);
|
||||
void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ extern "C" {
|
||||
|
||||
#include "export.h"
|
||||
|
||||
typedef CRYPTO_ALIGN(16) struct crypto_onetimeauth_poly1305_state {
|
||||
typedef struct CRYPTO_ALIGN(16) crypto_onetimeauth_poly1305_state {
|
||||
unsigned char opaque[256];
|
||||
} crypto_onetimeauth_poly1305_state;
|
||||
|
||||
@ -35,34 +35,35 @@ SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state,
|
||||
const unsigned char *key);
|
||||
const unsigned char *key)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_onetimeauth_poly1305_keygen(unsigned char k[crypto_onetimeauth_poly1305_KEYBYTES]);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int _crypto_onetimeauth_poly1305_pick_best_implementation(void);
|
||||
void crypto_onetimeauth_poly1305_keygen(unsigned char k[crypto_onetimeauth_poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "crypto_pwhash_argon2i.h"
|
||||
#include "crypto_pwhash_argon2id.h"
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -17,96 +18,122 @@ extern "C" {
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_alg_argon2i13(void);
|
||||
|
||||
#define crypto_pwhash_ALG_DEFAULT crypto_pwhash_ALG_ARGON2I13
|
||||
#define crypto_pwhash_ALG_ARGON2ID13 crypto_pwhash_argon2id_ALG_ARGON2ID13
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_alg_argon2id13(void);
|
||||
|
||||
#define crypto_pwhash_ALG_DEFAULT crypto_pwhash_ALG_ARGON2ID13
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_alg_default(void);
|
||||
|
||||
#define crypto_pwhash_BYTES_MIN crypto_pwhash_argon2i_BYTES_MIN
|
||||
#define crypto_pwhash_BYTES_MIN crypto_pwhash_argon2id_BYTES_MIN
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_bytes_min(void);
|
||||
|
||||
#define crypto_pwhash_BYTES_MAX crypto_pwhash_argon2i_BYTES_MAX
|
||||
#define crypto_pwhash_BYTES_MAX crypto_pwhash_argon2id_BYTES_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_bytes_max(void);
|
||||
|
||||
#define crypto_pwhash_PASSWD_MIN crypto_pwhash_argon2i_PASSWD_MIN
|
||||
#define crypto_pwhash_PASSWD_MIN crypto_pwhash_argon2id_PASSWD_MIN
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_passwd_min(void);
|
||||
|
||||
#define crypto_pwhash_PASSWD_MAX crypto_pwhash_argon2i_PASSWD_MAX
|
||||
#define crypto_pwhash_PASSWD_MAX crypto_pwhash_argon2id_PASSWD_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_passwd_max(void);
|
||||
|
||||
#define crypto_pwhash_SALTBYTES crypto_pwhash_argon2i_SALTBYTES
|
||||
#define crypto_pwhash_SALTBYTES crypto_pwhash_argon2id_SALTBYTES
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_saltbytes(void);
|
||||
|
||||
#define crypto_pwhash_STRBYTES crypto_pwhash_argon2i_STRBYTES
|
||||
#define crypto_pwhash_STRBYTES crypto_pwhash_argon2id_STRBYTES
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_strbytes(void);
|
||||
|
||||
#define crypto_pwhash_STRPREFIX crypto_pwhash_argon2i_STRPREFIX
|
||||
#define crypto_pwhash_STRPREFIX crypto_pwhash_argon2id_STRPREFIX
|
||||
SODIUM_EXPORT
|
||||
const char *crypto_pwhash_strprefix(void);
|
||||
|
||||
#define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_argon2i_OPSLIMIT_MIN
|
||||
#define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_argon2id_OPSLIMIT_MIN
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_opslimit_min(void);
|
||||
|
||||
#define crypto_pwhash_OPSLIMIT_MAX crypto_pwhash_argon2i_OPSLIMIT_MAX
|
||||
#define crypto_pwhash_OPSLIMIT_MAX crypto_pwhash_argon2id_OPSLIMIT_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_opslimit_max(void);
|
||||
|
||||
#define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_argon2i_MEMLIMIT_MIN
|
||||
#define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_argon2id_MEMLIMIT_MIN
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_memlimit_min(void);
|
||||
|
||||
#define crypto_pwhash_MEMLIMIT_MAX crypto_pwhash_argon2i_MEMLIMIT_MAX
|
||||
#define crypto_pwhash_MEMLIMIT_MAX crypto_pwhash_argon2id_MEMLIMIT_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_memlimit_max(void);
|
||||
|
||||
#define crypto_pwhash_OPSLIMIT_INTERACTIVE crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE
|
||||
#define crypto_pwhash_OPSLIMIT_INTERACTIVE crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_opslimit_interactive(void);
|
||||
|
||||
#define crypto_pwhash_MEMLIMIT_INTERACTIVE crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE
|
||||
#define crypto_pwhash_MEMLIMIT_INTERACTIVE crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_memlimit_interactive(void);
|
||||
|
||||
#define crypto_pwhash_OPSLIMIT_MODERATE crypto_pwhash_argon2i_OPSLIMIT_MODERATE
|
||||
#define crypto_pwhash_OPSLIMIT_MODERATE crypto_pwhash_argon2id_OPSLIMIT_MODERATE
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_opslimit_moderate(void);
|
||||
|
||||
#define crypto_pwhash_MEMLIMIT_MODERATE crypto_pwhash_argon2i_MEMLIMIT_MODERATE
|
||||
#define crypto_pwhash_MEMLIMIT_MODERATE crypto_pwhash_argon2id_MEMLIMIT_MODERATE
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_memlimit_moderate(void);
|
||||
|
||||
#define crypto_pwhash_OPSLIMIT_SENSITIVE crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE
|
||||
#define crypto_pwhash_OPSLIMIT_SENSITIVE crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_opslimit_sensitive(void);
|
||||
|
||||
#define crypto_pwhash_MEMLIMIT_SENSITIVE crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE
|
||||
#define crypto_pwhash_MEMLIMIT_SENSITIVE crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_memlimit_sensitive(void);
|
||||
|
||||
/*
|
||||
* With this function, do not forget to store all parameters, including the
|
||||
* algorithm identifier in order to produce deterministic output.
|
||||
* The crypto_pwhash_* definitions, including crypto_pwhash_ALG_DEFAULT,
|
||||
* may change.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash(unsigned char * const out, unsigned long long outlen,
|
||||
const char * const passwd, unsigned long long passwdlen,
|
||||
const unsigned char * const salt,
|
||||
unsigned long long opslimit, size_t memlimit, int alg)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* The output string already includes all the required parameters, including
|
||||
* the algorithm identifier. The string is all that has to be stored in
|
||||
* order to verify a password.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str(char out[crypto_pwhash_STRBYTES],
|
||||
const char * const passwd, unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES],
|
||||
const char * const passwd, unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit, int alg)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES],
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#define crypto_pwhash_PRIMITIVE "argon2i"
|
||||
SODIUM_EXPORT
|
||||
@ -118,4 +145,3 @@ const char *crypto_pwhash_primitive(void)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -22,7 +22,7 @@ int crypto_pwhash_argon2i_alg_argon2i13(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2i_bytes_min(void);
|
||||
|
||||
#define crypto_pwhash_argon2i_BYTES_MAX 4294967295U
|
||||
#define crypto_pwhash_argon2i_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2i_bytes_max(void);
|
||||
|
||||
@ -54,11 +54,12 @@ size_t crypto_pwhash_argon2i_opslimit_min(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2i_opslimit_max(void);
|
||||
|
||||
#define crypto_pwhash_argon2i_MEMLIMIT_MIN 1U
|
||||
#define crypto_pwhash_argon2i_MEMLIMIT_MIN 8192U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2i_memlimit_min(void);
|
||||
|
||||
#define crypto_pwhash_argon2i_MEMLIMIT_MAX ((SIZE_MAX >= 1ULL << 48) ? 4398046510080U : (SIZE_MAX >= 1ULL << 32) ? 2147483648U : 32768U)
|
||||
#define crypto_pwhash_argon2i_MEMLIMIT_MAX \
|
||||
((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2i_memlimit_max(void);
|
||||
|
||||
@ -94,24 +95,25 @@ int crypto_pwhash_argon2i(unsigned char * const out,
|
||||
const unsigned char * const salt,
|
||||
unsigned long long opslimit, size_t memlimit,
|
||||
int alg)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2i_str(char out[crypto_pwhash_argon2i_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2i_str_verify(const char str[crypto_pwhash_argon2i_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int _crypto_pwhash_argon2i_pick_best_implementation(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2i_str_needs_rehash(const char str[crypto_pwhash_argon2i_STRBYTES],
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -0,0 +1,122 @@
|
||||
#ifndef crypto_pwhash_argon2id_H
|
||||
#define crypto_pwhash_argon2id_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wlong-long"
|
||||
# endif
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_pwhash_argon2id_ALG_ARGON2ID13 2
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_alg_argon2id13(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_BYTES_MIN 16U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_bytes_min(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_bytes_max(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_PASSWD_MIN 0U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_passwd_min(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_PASSWD_MAX 4294967295U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_passwd_max(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_SALTBYTES 16U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_saltbytes(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_STRBYTES 128U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_strbytes(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_STRPREFIX "$argon2id$"
|
||||
SODIUM_EXPORT
|
||||
const char *crypto_pwhash_argon2id_strprefix(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_OPSLIMIT_MIN 1U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_opslimit_min(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_OPSLIMIT_MAX 4294967295U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_opslimit_max(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_MEMLIMIT_MIN 8192U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_memlimit_min(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_MEMLIMIT_MAX \
|
||||
((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_memlimit_max(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE 2U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_opslimit_interactive(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE 67108864U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_memlimit_interactive(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_OPSLIMIT_MODERATE 3U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_opslimit_moderate(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_MEMLIMIT_MODERATE 268435456U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_memlimit_moderate(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE 4U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_opslimit_sensitive(void);
|
||||
|
||||
#define crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE 1073741824U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_argon2id_memlimit_sensitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id(unsigned char * const out,
|
||||
unsigned long long outlen,
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen,
|
||||
const unsigned char * const salt,
|
||||
unsigned long long opslimit, size_t memlimit,
|
||||
int alg)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_str_needs_rehash(const char str[crypto_pwhash_argon2id_STRBYTES],
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -18,7 +18,8 @@ extern "C" {
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_scryptsalsa208sha256_bytes_min(void);
|
||||
|
||||
#define crypto_pwhash_scryptsalsa208sha256_BYTES_MAX SIZE_MAX
|
||||
#define crypto_pwhash_scryptsalsa208sha256_BYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX, 0x1fffffffe0ULL)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_scryptsalsa208sha256_bytes_max(void);
|
||||
|
||||
@ -26,7 +27,7 @@ size_t crypto_pwhash_scryptsalsa208sha256_bytes_max(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_scryptsalsa208sha256_passwd_min(void);
|
||||
|
||||
#define crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX SIZE_MAX
|
||||
#define crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX SODIUM_SIZE_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_scryptsalsa208sha256_passwd_max(void);
|
||||
|
||||
@ -54,7 +55,8 @@ size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_scryptsalsa208sha256_memlimit_min(void);
|
||||
|
||||
#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX ((SIZE_MAX >= 68719476736U) ? 68719476736U : SIZE_MAX)
|
||||
#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX \
|
||||
SODIUM_MIN(SIZE_MAX, 68719476736ULL)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max(void);
|
||||
|
||||
@ -82,7 +84,7 @@ int crypto_pwhash_scryptsalsa208sha256(unsigned char * const out,
|
||||
const unsigned char * const salt,
|
||||
unsigned long long opslimit,
|
||||
size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
||||
@ -90,20 +92,26 @@ int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208
|
||||
unsigned long long passwdlen,
|
||||
unsigned long long opslimit,
|
||||
size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen,
|
||||
const uint8_t * salt, size_t saltlen,
|
||||
uint64_t N, uint32_t r, uint32_t p,
|
||||
uint8_t * buf, size_t buflen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
||||
unsigned long long opslimit,
|
||||
size_t memlimit)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -23,12 +23,21 @@ SODIUM_EXPORT
|
||||
const char *crypto_scalarmult_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n);
|
||||
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
*
|
||||
* Or unless this is not an option, use the crypto_kx() API instead.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -17,17 +17,23 @@ size_t crypto_scalarmult_curve25519_bytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_curve25519_scalarbytes(void);
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
*
|
||||
* Or unless this is not an option, use the crypto_kx() API instead.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_curve25519(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_curve25519_base(unsigned char *q, const unsigned char *n);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int _crypto_scalarmult_curve25519_pick_best_implementation(void);
|
||||
int crypto_scalarmult_curve25519_base(unsigned char *q,
|
||||
const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
|
||||
#ifndef crypto_scalarmult_ed25519_H
|
||||
#define crypto_scalarmult_ed25519_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_scalarmult_ed25519_BYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_ed25519_bytes(void);
|
||||
|
||||
#define crypto_scalarmult_ed25519_SCALARBYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_ed25519_scalarbytes(void);
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
*
|
||||
* Or unless this is not an option, use the crypto_kx() API instead.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519_noclamp(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519_base(unsigned char *q, const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519_base_noclamp(unsigned char *q, const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,43 @@
|
||||
|
||||
#ifndef crypto_scalarmult_ristretto255_H
|
||||
#define crypto_scalarmult_ristretto255_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_scalarmult_ristretto255_BYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_ristretto255_bytes(void);
|
||||
|
||||
#define crypto_scalarmult_ristretto255_SCALARBYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_ristretto255_scalarbytes(void);
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
*
|
||||
* Or unless this is not an option, use the crypto_kx() API instead.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ristretto255(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ristretto255_base(unsigned char *q,
|
||||
const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -29,23 +29,28 @@ size_t crypto_secretbox_macbytes(void);
|
||||
SODIUM_EXPORT
|
||||
const char *crypto_secretbox_primitive(void);
|
||||
|
||||
#define crypto_secretbox_MESSAGEBYTES_MAX crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_open_detached(unsigned char *m,
|
||||
@ -54,10 +59,11 @@ int crypto_secretbox_open_detached(unsigned char *m,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES]);
|
||||
void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
@ -72,13 +78,13 @@ size_t crypto_secretbox_boxzerobytes(void);
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_open(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define crypto_secretbox_xchacha20poly1305_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "crypto_stream_xchacha20.h"
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -23,12 +24,18 @@ size_t crypto_secretbox_xchacha20poly1305_noncebytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_xchacha20poly1305_macbytes(void);
|
||||
|
||||
#define crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX \
|
||||
(crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_secretbox_xchacha20poly1305_MACBYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_xchacha20poly1305_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
|
||||
@ -36,7 +43,7 @@ int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
|
||||
@ -44,7 +51,8 @@ int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
|
||||
@ -53,7 +61,7 @@ int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define crypto_secretbox_xsalsa20poly1305_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "crypto_stream_xsalsa20.h"
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -23,6 +24,34 @@ size_t crypto_secretbox_xsalsa20poly1305_noncebytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_xsalsa20poly1305_macbytes(void);
|
||||
|
||||
/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
|
||||
#define crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX \
|
||||
(crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_secretbox_xsalsa20poly1305_MACBYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xsalsa20poly1305(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
|
||||
const unsigned char *c,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void);
|
||||
@ -33,24 +62,6 @@ size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xsalsa20poly1305(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
|
||||
const unsigned char *c,
|
||||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -0,0 +1,108 @@
|
||||
#ifndef crypto_secretstream_xchacha20poly1305_H
|
||||
#define crypto_secretstream_xchacha20poly1305_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "crypto_aead_xchacha20poly1305.h"
|
||||
#include "crypto_stream_chacha20.h"
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wlong-long"
|
||||
# endif
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_ABYTES \
|
||||
(1U + crypto_aead_xchacha20poly1305_ietf_ABYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretstream_xchacha20poly1305_abytes(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_HEADERBYTES \
|
||||
crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretstream_xchacha20poly1305_headerbytes(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_KEYBYTES \
|
||||
crypto_aead_xchacha20poly1305_ietf_KEYBYTES
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretstream_xchacha20poly1305_keybytes(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_secretstream_xchacha20poly1305_ABYTES, \
|
||||
(64ULL * ((1ULL << 32) - 2ULL)))
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretstream_xchacha20poly1305_messagebytes_max(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_TAG_MESSAGE 0x00
|
||||
SODIUM_EXPORT
|
||||
unsigned char crypto_secretstream_xchacha20poly1305_tag_message(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_TAG_PUSH 0x01
|
||||
SODIUM_EXPORT
|
||||
unsigned char crypto_secretstream_xchacha20poly1305_tag_push(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_TAG_REKEY 0x02
|
||||
SODIUM_EXPORT
|
||||
unsigned char crypto_secretstream_xchacha20poly1305_tag_rekey(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_TAG_FINAL \
|
||||
(crypto_secretstream_xchacha20poly1305_TAG_PUSH | \
|
||||
crypto_secretstream_xchacha20poly1305_TAG_REKEY)
|
||||
SODIUM_EXPORT
|
||||
unsigned char crypto_secretstream_xchacha20poly1305_tag_final(void);
|
||||
|
||||
typedef struct crypto_secretstream_xchacha20poly1305_state {
|
||||
unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES];
|
||||
unsigned char nonce[crypto_stream_chacha20_ietf_NONCEBYTES];
|
||||
unsigned char _pad[8];
|
||||
} crypto_secretstream_xchacha20poly1305_state;
|
||||
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretstream_xchacha20poly1305_statebytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretstream_xchacha20poly1305_keygen
|
||||
(unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_init_push
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
|
||||
const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_push
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
unsigned char *c, unsigned long long *clen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *ad, unsigned long long adlen, unsigned char tag)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_init_pull
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
const unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
|
||||
const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_pull
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
unsigned char *m, unsigned long long *mlen_p, unsigned char *tag_p,
|
||||
const unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *ad, unsigned long long adlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretstream_xchacha20poly1305_rekey
|
||||
(crypto_secretstream_xchacha20poly1305_state *state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -27,10 +27,12 @@ const char *crypto_shorthash_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES]);
|
||||
void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ size_t crypto_shorthash_siphash24_keybytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
#ifndef SODIUM_LIBRARY_MINIMAL
|
||||
/* -- 128-bit output -- */
|
||||
@ -38,7 +39,8 @@ size_t crypto_shorthash_siphashx24_keybytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -41,56 +41,64 @@ size_t crypto_sign_publickeybytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_sign_secretkeybytes(void);
|
||||
|
||||
#define crypto_sign_MESSAGEBYTES_MAX crypto_sign_ed25519_MESSAGEBYTES_MAX
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_sign_messagebytes_max(void);
|
||||
|
||||
#define crypto_sign_PRIMITIVE "ed25519"
|
||||
SODIUM_EXPORT
|
||||
const char *crypto_sign_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign(unsigned char *sm, unsigned long long *smlen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p,
|
||||
const unsigned char *sm, unsigned long long smlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_verify_detached(const unsigned char *sig,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_init(crypto_sign_state *state);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_update(crypto_sign_state *state,
|
||||
const unsigned char *m, unsigned long long mlen);
|
||||
const unsigned char *m, unsigned long long mlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig,
|
||||
unsigned long long *siglen_p,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 2, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_final_verify(crypto_sign_state *state, unsigned char *sig,
|
||||
int crypto_sign_final_verify(crypto_sign_state *state, const unsigned char *sig,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -35,73 +35,87 @@ size_t crypto_sign_ed25519_publickeybytes(void);
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_sign_ed25519_secretkeybytes(void);
|
||||
|
||||
#define crypto_sign_ed25519_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES)
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_sign_ed25519_messagebytes_max(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p,
|
||||
const unsigned char *sm, unsigned long long smlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_detached(unsigned char *sig,
|
||||
unsigned long long *siglen_p,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_verify_detached(const unsigned char *sig,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk,
|
||||
const unsigned char *ed25519_pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk,
|
||||
const unsigned char *ed25519_sk);
|
||||
const unsigned char *ed25519_sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_sk_to_seed(unsigned char *seed,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk);
|
||||
int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state);
|
||||
int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_update(crypto_sign_ed25519ph_state *state,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen);
|
||||
unsigned long long mlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_final_create(crypto_sign_ed25519ph_state *state,
|
||||
unsigned char *sig,
|
||||
unsigned long long *siglen_p,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 2, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_final_verify(crypto_sign_ed25519ph_state *state,
|
||||
unsigned char *sig,
|
||||
const unsigned char *sig,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user