id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
751,427
rigclass.h
w1hkj_fldigi/src/include/rigclass.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _RIGCLASS_H #define _RIGCLASS_H #include <exception> #include <string> #include <hamlib/rig.h> class RigException : public std::exception { public: RigException(int e = 0) : err(e), msg(rigerror(e)) { } RigException(const char* m) : err(0), msg(m) { } RigException(const char* prefix, int e) : err(e), msg(std::string(prefix).append(": ").append(rigerror(e))) { } virtual ~RigException() throw() { } const char* what(void) const throw() { return msg.c_str(); } int error(void) const { return err; } protected: int err; std::string msg; }; class Rig { protected: RIG *rig; // Global ref. to the rig freq_t fnull; public: Rig(); Rig(rig_model_t rig_model); virtual ~Rig(); void init(rig_model_t rig_model); bool isOnLine() { return rig; } // This method open the communication port to the rig void open(void); // This method close the communication port to the rig void close(bool abort = false); void setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR); freq_t getFreq(vfo_t vfo = RIG_VFO_CURR); bool canSetFreq(); bool canGetFreq(); void setMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR); rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR); bool canSetMode(); bool canGetMode(); void setPTT (ptt_t ptt, vfo_t vfo = RIG_VFO_CURR); ptt_t getPTT (vfo_t vfo = RIG_VFO_CURR); bool canSetPTT(); bool canGetPTT(); void setVFO(vfo_t); vfo_t getVFO(); void setConf(token_t token, const char *val); void setConf(const char *name, const char *val); void getConf(token_t token, char *val); void getConf(const char *name, char *val); const char *getName(); const struct rig_caps* getCaps(void); token_t tokenLookup(const char *name); pbwidth_t passbandNormal (rmode_t mode); pbwidth_t passbandNarrow (rmode_t mode); pbwidth_t passbandWide (rmode_t mode); }; #endif
2,749
C++
.h
80
32.5125
88
0.677115
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,428
mfskvaricode.h
w1hkj_fldigi/src/include/mfskvaricode.h
// ---------------------------------------------------------------------------- // mfskvaricode.h -- MFSK Varicode // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _MFSKVARICODE_H #define _MFSKVARICODE_H extern const char *varienc(int c); extern int varidec(unsigned int symbol); #endif
1,113
C++
.h
27
40.074074
82
0.648199
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,429
speak.h
w1hkj_fldigi/src/include/speak.h
// ---------------------------------------------------------------------------- // speak.h Remote Log Interface for fldigi // // Copyright W1HKJ, Dave Freese 2009 // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _SPEAK_H #define _SPEAK_H extern const char *txtTalkInfo; void open_talker(); void close_talker(); void toggle_talker(); void speak(int c); #endif
1,069
C++
.h
28
37.035714
79
0.643202
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,430
dxcc.h
w1hkj_fldigi/src/include/dxcc.h
// ---------------------------------------------------------------------------- // dxcc.h // // Copyright (C) 2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef DXCC_H_ #define DXCC_H_ #include <vector> #include <string> #include <iostream> struct dxcc { const char* country; int cq_zone; int itu_zone; char continent[3]; float latitude; float longitude; float gmt_offset; dxcc(const char* cn = "", int cq = 0, int itu = 0, const char* ct = "", float lat = 0.0f, float lon = 0.0f, float tz = 0.0f); void print() { std::cout << country << ", " << cq_zone << ", " << itu_zone << ", " << continent << ", " << latitude << ", " << longitude << ", " << gmt_offset << "\n"; } }; enum qsl_t { QSL_LOTW, QSL_EQSL, QSL_END }; extern const char* qsl_names[]; bool dxcc_open(const char* filename); bool dxcc_is_open(void); void dxcc_close(void); const dxcc* dxcc_lookup(const char* callsign); const std::vector<dxcc*>* dxcc_entity_list(void); extern std::string cbolist; bool qsl_open(const char* filename, qsl_t qsl_type); unsigned char qsl_is_open(void); void qsl_close(void); unsigned char qsl_lookup(const char* callsign); extern void reload_cty_dat(); extern void default_cty_dat_pathname(); extern void select_cty_dat_pathname(); #endif // DXCC_H_
2,032
C++
.h
62
30.903226
79
0.641509
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,431
notifydialog.h
w1hkj_fldigi/src/include/notifydialog.h
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #ifndef notifydialog_h #define notifydialog_h #include <FL/Fl.H> #include "table.h" #include "flinput2.h" #include "flslider2.h" #include <FL/Fl_Double_Window.H> #include <FL/Fl_Group.H> extern Fl_Group *grpNotifyEvent; #include <FL/Fl_Choice.H> extern Fl_Choice *mnuNotifyEvent; #include <FL/Fl_Light_Button.H> extern Fl_Light_Button *btnNotifyEnabled; extern Fl_Input2 *inpNotifyRE; extern Fl_Group *grpNotifyFilter; #include <FL/Fl_Round_Button.H> extern Fl_Round_Button *chkNotifyFilterCall; extern Fl_Input2 *inpNotifyFilterCall; extern Fl_Round_Button *chkNotifyFilterDXCC; #include <FL/Fl_Button.H> extern Fl_Button *btnNotifyFilterDXCC; #include <FL/Fl_Check_Button.H> extern Fl_Check_Button *chkNotifyFilterNWB; extern Fl_Check_Button *chkNotifyFilterLOTW; extern Fl_Check_Button *chkNotifyFilterEQSL; extern Fl_Group *grpNotifyDup; extern Fl_Check_Button *chkNotifyDupIgnore; extern Fl_Choice *mnuNotifyDupWhich; extern Fl_Spinner2 *cntNotifyDupTime; extern Fl_Check_Button *chkNotifyDupBand; extern Fl_Check_Button *chkNotifyDupMode; extern Fl_Group *grpNotifyAction; extern Fl_Spinner2 *cntNotifyActionLimit; extern Fl_Input2 *inpNotifyActionDialog; extern Fl_Button *btnNotifyActionDialogDefault; extern Fl_Spinner2 *cntNotifyActionDialogTimeout; extern Fl_Input2 *inpNotifyActionRXMarker; extern Fl_Button *btnNotifyActionMarkerDefault; extern Fl_Input2 *inpNotifyActionMacro; extern Fl_Button *btnNotifyActionMacro; extern Fl_Input2 *inpNotifyActionProgram; extern Fl_Button *btnNotifyActionProgram; extern Fl_Button *btnNotifyAdd; extern Fl_Button *btnNotifyRemove; extern Fl_Button *btnNotifyUpdate; extern Fl_Button *btnNotifyTest; extern Fl_Button *btnNotifyClose; extern Table *tblNotifyList; Fl_Double_Window* make_notify_window(); extern Table *tblNotifyFilterDXCC; extern Fl_Input2 *inpNotifyDXCCSearchCountry; extern Fl_Input2 *inpNotifyDXCCSearchCallsign; extern Fl_Button *btnNotifyDXCCSelect; extern Fl_Button *btnNotifyDXCCDeselect; extern Fl_Button *btnNotifyDXCCClose; Fl_Double_Window* make_dxcc_window(); #endif
2,119
C++
.h
58
35.517241
73
0.841748
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,432
htmlstrings.h
w1hkj_fldigi/src/include/htmlstrings.h
// ---------------------------------------------------------------------------- // // htmlstrings.h // // Copyright (C) 2008 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef HTMLSTRINGS_H #define HTMLSTRINGS_H extern const char* szBeginner; extern const char* szAbout; #endif
1,007
C++
.h
27
36.185185
79
0.636643
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,433
ax25_decode.h
w1hkj_fldigi/src/include/ax25_decode.h
// --------------------------------------------------------------------- // ax25_decode.cxx -- AX25 Packet disassembler. // // This file is a proposed part of fldigi. Adapted very liberally from // rtty.cxx, with many thanks to John Hansen, W2FS, who wrote // 'dcc.doc' and 'dcc2.doc', GNU Octave, GNU Radio Companion, and finally // Bartek Kania (bk.gnarf.org) whose 'aprs.c' expository coding style helped // shape this implementation. // // Copyright (C) 2010, 2014 // Dave Freese, W1HKJ // Chris Sylvain, KB3CS // Robert Stiles, KK5VD // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi; if not, write to the // // Free Software Foundation, Inc. // 51 Franklin Street, Fifth Floor // Boston, MA 02110-1301 USA. // // --------------------------------------------------------------------- #ifndef __ax25_decode__ #define __ax25_decode__ #include <iostream> // 70 bytes addr + 256 payload + 2 FCS + 1 Control + 1 Protocol ID #define MAXOCTETS 340 // 136 bits minimum (including start and end flags) - AX.25 v2.2 section 3.9 // == 15 octets. we count only one of the two flags, though. #define MINOCTETS 14 enum PKT_MicE_field { Null = 0x00, Space = 0x20, Zero = 0x30, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, P0 = 0x40, P100, North = 0x50, East, South, West, Invalid = 0xFF }; struct PKT_PHG_table { const char *s; unsigned char l; }; //static void do_put_rx_char(unsigned char *cp); static void expand_MicE(unsigned char *cpI, unsigned char *cpE); static void expand_PHG(unsigned char *cpI); static void expand_Cmp(unsigned char *cpI); inline void put_rx_const(const char s[]); void ax25_decode(unsigned char *buffer, size_t count, bool pad, bool tx_flag); #endif /* defined(__ax25_decode__) */
2,281
C++
.h
72
30.291667
78
0.685286
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,434
fmt_dialog.h
w1hkj_fldigi/src/include/fmt_dialog.h
// ---------------------------------------------------------------------------- // fmt_dialog.h -- fmt modem // // Copyright (C) 2020 // Dave Freese, W1HKJ // JC Gibbons, N8OBJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef fmt_dialog_h #define fmt_dialog_h #include <FL/Fl.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Group.H> #include "plot_xy.h" #include <FL/Fl_Check_Button.H> #include <FL/Fl_Counter.H> #include <FL/Fl_Button.H> #include <FL/Fl_Light_Button.H> #include <FL/Fl_Output.H> #include <FL/Fl_Choice.H> #include <FL/Fl_Box.H> #include "combo.h" #include "fmt.h" extern plot_xy *fmt_plot; extern Fl_Group *ref_group; extern Fl_Light_Button *btn_ref_enable; extern Fl_Button *btn_ref_up; extern Fl_Counter *cnt_ref_freq; extern Fl_Button *btn_ref_dn; extern Fl_Button *btn_ref_reset; extern Fl_Button *btn_ref_clear; extern Fl_Output *fmt_ref_val; extern Fl_Output *fmt_ref_db; extern Fl_Box *ref_color; extern Fl_Group *unk_group; extern Fl_Light_Button *btn_unk_enable; extern Fl_Button *btn_unk_up; extern Fl_Counter *cnt_unk_freq; extern Fl_Button *btn_unk_dn; extern Fl_Button *btn_unk_reset; extern Fl_Button *btn_unk_clear; extern Fl_Output *fmt_unk_val; extern Fl_Output *fmt_unk_db; extern Fl_Box *unk_color; extern Fl_Group *fmt_record_group; extern Fl_Light_Button *btn_fmt_record ; extern Fl_Box *box_fmt_recording; extern Fl_ListBox *fmt_rec_interval; extern Fl_ListBox *fmt_scale; extern Fl_ListBox *fmt_cntr_minutes; extern Fl_Group* fmt_panel(int, int, int, int); extern void set_fmt_scope (); extern void clear_ref_scope(); extern void clear_unk_scope(); extern void show_1(bool); extern void show_2(bool); extern void cb_ref_reset (void *); extern void cb_ref_clear (void *); extern void cb_unk_reset (void *); extern void cb_unk_clear (void *); extern void put_unk_value (const char *msg); extern void put_ref_value (const char *msg); extern void put_unk_amp (const char *msg); extern void put_ref_amp (const char *msg); extern void set_ref_freq (void *); extern void set_unk_freq (void *); extern void set_unk_freq_value(double f); extern void set_ref_freq_value(double f); #endif
2,879
C++
.h
83
33.481928
79
0.699532
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,435
thor.h
w1hkj_fldigi/src/include/thor.h
// ---------------------------------------------------------------------------- // thor.h -- thor modem // // Copyright (C) 2008-2012 // David Freese <w1hkj@w1hkj.com> // John Douyere <vk2eta@gmail.com> // John Phelps <kl4yfd@gmail.com> // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _thor_H #define _thor_H #include <string> #include "complex.h" #include "modem.h" #include "globals.h" #include "filters.h" #include "fftfilt.h" #include "dominovar.h" #include "mbuffer.h" #include "picture.h" #include <FL/Fl_Shared_Image.H> // NASA coefficients for viterbi encode/decode algorithms #define THOR_K 7 #define THOR_POLY1 0x6d #define THOR_POLY2 0x4f //VK2ETA high speed modes // IEEE coefficients for viterbi encode/decode algorithms #define THOR_K15 15 #define K15_POLY1 044735 #define K15_POLY2 063057 //#include "mfskvaricode.h" #include "interleave.h" #include "viterbi.h" #define THORNUMTONES 18 #define THORMAXFFTS 8 #define THORBASEFREQ 1500.0 #define THORFIRSTIF 2000.0 #define THORSCOPESIZE 64 #define THORSLOWPATHS 3 #define THORFASTPATHS 5 #define THOR_IMAGESPP 10 // the following constant changes if a mode with more tones than 25x4 is // created #define MAXPATHS (8 * THORFASTPATHS * THORNUMTONES ) struct THORrxpipe { cmplx vector[THORMAXFFTS * THORNUMTONES * 6]; }; class thor : public modem { public: enum { TX_STATE_PREAMBLE, TX_STATE_START, TX_STATE_DATA, TX_STATE_END, TX_STATE_IMAGE, TX_STATE_AVATAR, TX_STATE_FLUSH, TX_STATE_RECEIVE }; enum THOR_STATE { TEXT, IMAGE_START, IMAGE_SYNC, IMAGE }; protected: // common variables double phase[THORMAXFFTS + 1]; double txphase; int symlen; int doublespaced; double tonespacing; int counter; unsigned int twosym; int paths; int numbins; bool slowcpu; int basetone; int lotone; int hitone; int extones; // rx variables C_FIR_filter *hilbert; sfft *binsfft[THORMAXFFTS]; fftfilt *fft; Cmovavg *vidfilter[THORSCOPESIZE]; Cmovavg *syncfilter; THORrxpipe *pipe; unsigned int pipeptr; unsigned int datashreg; mbuffer<double, 0, 2> scopedata; mbuffer<double, 0, 2> videodata; cmplx currvector; int currsymbol; int prev1symbol; int prev2symbol; double currmag; double prev1mag; double prev2mag; double met1; double met2; double sig; double noise; double s2n; int synccounter; unsigned char symbolbuf[MAX_VARICODE_LEN]; int symcounter; int symbolbit; bool filter_reset; bool staticburst; int fec_confidence; // tx variables int txstate; int txprevtone; unsigned int bitshreg; std::string strSecXmtText; unsigned int cptr; viterbi *Dec; interleave *Rxinlv; encoder *Enc; interleave *Txinlv; int bitstate; unsigned char symbolpair[2]; int flushlength; private: cmplx mixer(int n, const cmplx& in); // Rx void recvchar(int c); void decodesymbol(); void softdecodesymbol(); int harddecode(); int softdecode(); void update_syncscope(); void synchronize(); void reset_afc(); void eval_s2n(); int get_secondary_char(); void reset_filters(); void decodePairs(unsigned char symbol); bool preambledetect(int c); void softflushrx(); void parse_pic(int); // Tx void sendtone(int tone, int duration); void sendsymbol(int sym); void sendchar(unsigned char c, int secondary); void sendidle(); void sendsecondary(); void flushtx(); void Clearbits(); protected: void s2nreport(void); public: thor (trx_mode md); ~thor (); void init(); void rx_init(); void tx_init(); void restart(); int rx_process(const double *buf, int len); int tx_process(); // support for thor image transfers private: double amplitude; double pixel; double sync; double img_phase; unsigned char tx_pixel; int tx_pixelnbr; int image_mode; public: int byte; double picf; double picpeak; C_FIR_filter *picfilter; Cmovavg *pixfilter; Cmovavg *pixsyncfilter; double phidiff; double pic_phase; cmplx prevz; cmplx currz; double image_freq[10]; int image_counter; int picW; int picH; int row; int col; int rgb; int pixelnbr; static int IMAGEspp; int TXspp; static std::string imageheader; static std::string avatarheader; std::string pic_str; THOR_STATE state; bool b_ava; void recvpic(double smpl); void send_image(); void send_avatar(); void thor_send_avatar(); void m_thor_send_avatar(); void thor_send_image(std::string s = "", bool gray = false); }; #endif
5,187
C++
.h
218
21.862385
79
0.721138
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,436
pskcoeff.h
w1hkj_fldigi/src/include/pskcoeff.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _COEFF_H #define _COEFF_H #define FIRLEN 64 extern double gmfir1c[]; extern double gmfir2c[]; extern double pskcore_filter[]; extern double syncfilt[16]; extern void raisedcosfilt(double *, int len); extern void wsincfilt(double *, double fc, int len, bool blackman = true); #endif
1,185
C++
.h
29
39.655172
79
0.648696
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,437
throb.h
w1hkj_fldigi/src/include/throb.h
// ---------------------------------------------------------------------------- // throb.h -- BASIS FOR ALL MODEMS // // Copyright (C) 2006-2007 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _THROB_H #define _THROB_H #include "modem.h" #include "globals.h" #include "fftfilt.h" #include "filters.h" #include "complex.h" #include "mbuffer.h" #define THROB_SAMPLE_RATE 8000 #define SYMLEN 512 #define BUFFLEN 4096 #define SCOPE_DATA_LEN 1024 #define DOWN_SAMPLE 32 #define SYMLEN_1 8192 #define SYMLEN_2 4096 #define SYMLEN_4 2048 #define MAX_RX_SYMLEN (SYMLEN_1 / DOWN_SAMPLE) #define FilterFFTLen 8192 class throb : public modem { static double ThrobToneFreqsNar[]; static double ThrobToneFreqsWid[]; static double ThrobXToneFreqsNar[]; static double ThrobXToneFreqsWid[]; static unsigned char ThrobCharSet[]; static unsigned char ThrobXCharSet[]; static int ThrobTonePairs[][2]; static int ThrobXTonePairs[][2]; protected: int num_tones; int num_chars; int idlesym; int spacesym; char lastchar; double phaseacc; double phaseincr; fftfilt *fftfilter; C_FIR_filter *syncfilt; C_FIR_filter *hilbert; Cmovavg *snfilter; int symlen; double freqs[55]; // receive double *scope_data; cmplx *rxtone[55]; cmplx symbol[MAX_RX_SYMLEN]; double syncbuf[MAX_RX_SYMLEN]; mbuffer<double, MAX_RX_SYMLEN, 2> dispbuf; double rxcntr; double signal; double noise; double s2n; int rxsymlen; int symptr; int deccntr; int shift; int waitsync; cmplx mixer(cmplx in); void sync(cmplx in); void rx(cmplx in); void decodechar(int tone1, int tone2); int findtones(cmplx *word, int &tone1, int &tone2); cmplx *mk_rxtone(double freq, double *pulse, int len); void show_char(int); void flip_syms(); void reset_syms(); // transmit int txstate; int preamble; double *txpulse; double *outbuf; unsigned int buffptr; double *mk_semi_pulse(int len); double *mk_full_pulse(int len); void send(int); public: throb(trx_mode); ~throb(); void init(); void rx_init(); void tx_init(); void restart() {}; int rx_process(const double *buf, int len); int tx_process(); void update_syncscope(); }; #endif
2,959
C++
.h
107
25.831776
79
0.692936
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,438
charsetdistiller.h
w1hkj_fldigi/src/include/charsetdistiller.h
// ---------------------------------------------------------------------------- // charsetdistiller.h -- input charset cleaning and conversion // // Copyright (C) 2012 // Andrej Lajovic, S57LN // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef CHARSETDISTILLER_H #define CHARSETDISTILLER_H #include <string> #include "tiniconv.h" class CharsetDistiller { public: CharsetDistiller(const int charset_in = TINICONV_CHARSET_UTF_8); int set_input_encoding(const int charset_in); void rx(const unsigned char c); void rx(const unsigned char *c); void flush(); void reset(void); void clear(void); int data_length(void); int num_chars(void); const std::string &data(void); private: void process_buffer(void); void shift_first_out(); unsigned char buf[6]; // input buffer unsigned char *bufptr; // points to the next unused byte in the buffer tiniconv_ctx_s ctx; // libtiniconv conversion state for input encoding -> UTF-8 tiniconv_ctx_s ctx1252; // libtiniconv conversion state for CP1252 -> UTF-8 std::string outdata; // valid data int nutf8; // number of UTF-8 characters in the output buffer }; #endif
1,923
C++
.h
49
35.795918
85
0.655246
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,439
thorvaricode.h
w1hkj_fldigi/src/include/thorvaricode.h
// ---------------------------------------------------------------------------- // thorvaricode.h -- DEX Varicode // // Copyright (C) 2008 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _DEXVARICODE_H #define _DEXVARICODE_H extern const char *thorvarienc(int c, int secondary); extern int thorvaridec(unsigned int symbol); #endif
1,065
C++
.h
26
39.846154
79
0.642857
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,440
ICOMkeying.h
w1hkj_fldigi/src/include/ICOMkeying.h
// ---------------------------------------------------------------------------- // ICOMkeying.h serial string CW interface to Elecraft transceivers // // Copyright (C) 2020 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _ICOMKEYING_H #define _ICOMKEYING_H extern bool use_ICOMkeyer; extern int ICOMwpm; extern void set_ICOMkeyer(); extern void ICOMkeyer_send_char(int); #endif
1,113
C++
.h
28
38.607143
79
0.654024
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,441
fileselect.h
w1hkj_fldigi/src/include/fileselect.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef FILESELECT_H #define FILESELECT_H #include <config.h> namespace FSEL { void create(void); void destroy(void); const char* select(const char* title, const char* filter, const char* def = 0, int *fsel = NULL); const char* saveas(const char* title, const char* filter, const char* def = 0, int *fsel = NULL); const char* dir_select(const char* title, const char* filter, const char* def = 0); } #endif // FILESELECT_H
1,323
C++
.h
30
42.733333
98
0.644911
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,442
fmt.h
w1hkj_fldigi/src/include/fmt.h
// ---------------------------------------------------------------------------- // fmt.h -- frequency measurement modem // // Copyright (C) 2020 // Dave Freese, W1HKJ // JC Gibbons, N8OBJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _fmt_H #define _fmt_H #include <string> #include <ctime> #include <stdio.h> #include "complex.h" #include "filters.h" #include "fftfilt.h" #include "modem.h" #include "threads.h" #define DSP_CNT 1 //seconds #define MAX_MINUTES 120 #define MAX_DATA_PTS (60 * MAX_MINUTES) extern pthread_mutex_t scope_mutex; extern void fmt_write_file(); extern void FMT_thread_close(void); extern void cb_fmt_record_wav(bool); extern bool write_recs; extern bool record_unk; extern bool record_ref; class fmt : public modem { friend void fmt_write_file(); private: int sr; // 1..6; 8000 ... 48000 sps double unk_freq; Cmovavg *unk_ffilt; Cmovavg *unk_afilt; double unk_base_freq; double unk_amp; double ref_freq; Cmovavg *ref_ffilt; Cmovavg *ref_afilt; double ref_base_freq; double ref_amp; double movavg_len; double dspcnt; void writeFile(); // T&R discriminator double *fftbuff; double *unkbuff; double *refbuff; double bpf_width; double *BLACKMAN; double Ts; int ref_count; int unk_count; double dft_ref_base; double dft_ref_amp; double dft_unk_base; double dft_unk_amp; double am; double bm; double dm; double delta; double dmK; double srK; double twoPI; double blackman (double omega); double absdft (double *buff, double freq, double incr); int rx_process_dft (); C_FIR_filter *unk_bpfilter; C_FIR_filter *ref_bpfilter; void reset_bpf(); double evaluate_dft(double &freq); public: fmt(); ~fmt(); void init(); void rx_init(); void tx_init(); void restart(); void clear_ref_pipe(); void clear_unk_pipe(); int rx_process(const double *buf, int len); int tx_process(); void reset_unknown(); void reset_reference(); }; #endif
2,723
C++
.h
101
25.108911
79
0.674266
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,443
pwrmeter.h
w1hkj_fldigi/src/include/pwrmeter.h
// // pwrmeter.h // // PWRmeter bar widget routines. // ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef PWRMETER #define PWRMETER // // Include necessary headers. // #include <FL/Fl.H> #include <FL/Fl_Widget.H> // // PWRmeter class... // class PWRmeter : public Fl_Widget { public: enum {P25, P50, P100, P200, AUTO}; private: double value_, maximum_; int sval; // Size of sval bar... int bx, by, bw, bh; // Box areas... int tx, tw; // Temporary X + width int ty, th; // Temporary Y + height int sx; // meter left offset int meter_width; int meter_height; int select_; Fl_Color bgnd_; Fl_Color fgnd_; Fl_Color scale_color; static const char *W25_face; static const char *W50_face; static const char *W100_face; static const char *W200_face; void (*cbFunc)(Fl_Widget *, void *); protected: virtual void draw(); public: PWRmeter(int x, int y, int w, int h, const char *l = 0); void value(double v) { value_ = v; redraw(); } double value() const { return (value_); } void resize(int x, int y, int w, int h); int handle(int); void set_background(Fl_Color c1) { bgnd_ = c1; redraw(); } void set_metercolor(Fl_Color c2) { fgnd_ = c2; redraw(); } void set_scalecolor(Fl_Color c3) { scale_color = c3; redraw(); } void select(int sel); void callback (void (*cbf)(Fl_Widget *, void *) ){ cbFunc = cbf;} void do_callback() { if (cbFunc) cbFunc(this, (void*)0); } private: void select_auto(); void select_25W(); void select_50W(); void select_100W(); void select_200W(); }; #endif // !pwrmeter
2,405
C++
.h
80
28.325
79
0.644127
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,444
Nav.h
w1hkj_fldigi/src/include/Nav.h
// ---------------------------------------------------------------------------- // Nav.cxx -- Interface to Arduino Nano Nav keyer // // Copyright (C) 2018 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _USNAVFSK_H #define _USNAVFSK_H #include <math.h> #include <string> #include <cstring> #include <stdio.h> #include <iostream> #include <fstream> #include <sstream> #include <cstdlib> #include <FL/Fl.H> #include "debug.h" #include "fl_digi.h" #include "confdialog.h" #include "status.h" #include "serial.h" #include "qrunner.h" #include "threads.h" #include "FTextRXTX.h" extern bool use_Nav; extern bool open_NavFSK(); extern void close_NavFSK(); extern bool open_NavConfig(); extern void close_NavConfig(); extern bool Nav_read_byte(Cserial &serial, unsigned char &byte); extern std::string Nav_read_string(Cserial &serial, int msec_wait, std::string find); extern void Nav_send_char(int c); extern void Nav_sendString (Cserial &serial, const std::string &s); extern void Nav_PTT(int val); extern void Nav_write_eeprom(); extern void Nav_restore_eeprom(); extern std::string Nav_serial_read(Cserial &serial); extern void Nav_set_channel_1_att(int); extern void Nav_set_channel_2_att(int); extern void Nav_set_rf_att(int); extern void Nav_set_led(int); extern void Nav_set_cat_led(int); extern void Nav_set_wk_ptt(int); extern void Nav_set_baud(int); extern void Nav_set_stopbits(int); extern void Nav_set_polarity(int); extern void Nav_set_sidetone(int); extern void Nav_set_ptt(int); #endif
2,244
C++
.h
65
33.261538
85
0.70444
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,446
view_cw.h
w1hkj_fldigi/src/include/view_cw.h
// ---------------------------------------------------------------------------- // view_cw.h -- cw modem // // Copyright (C) 2008 // Dave Freese, W1HKJ // Modified for CW decoder // Copyright (C) 2014 // Mauri Niininen, AG1LE // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _VIEWCW_H #define _VIEWCW_H #include <iostream> #include "complex.h" #include "modem.h" #include "globals.h" #include "filters.h" #include "fftfilt.h" #include "morse.h" #define VCW_MAXCH 30 class view_cw; struct CW_CHANNEL { static cMorse *morse; fftfilt *VCW_filter; // linear phase finite impulse response bpf Cmovavg bitfilter; Cmovavg trackingfilter; int ch; double phase; double phase_increment; double ch_freq; double agc_peak; double sig_avg; double value; double phi1; double phi2; int smpl_ctr; int dec_ctr; cmplx zout; int timeout; std::string decode_str; std::string rx_rep_buf; int cw_receive_state; int two_dots; double norm_sig; double CWupper; double CWlower; double noise_floor; int cw_rr_start_timestamp; int cw_rr_end_timestamp; int curr_element; int last_element; int space_sent; int clrcount; int _ch; double metric; double lowerwpm; double upperwpm; CW_CHANNEL(); ~CW_CHANNEL(); int cw_lower_limit; int cw_upper_limit; void init(int ch, double freq); void update_tracking(int dot, int dash); inline int sample_count(unsigned int earlier, unsigned int later); void sync_parameters(); void reset(); int decode_state(int cw_event); void detect_tone(); void rx_process(const double *value, int len); double avg_signal() { return sig_avg; } double get_metric() { return metric; } void set_noise_floor(double nf) { noise_floor = nf; } double get_chfreq() { return ch_freq; } }; #define PEAKS_SIZE 4000 struct PEAKS { double mx[PEAKS_SIZE]; double mn[PEAKS_SIZE]; int mxpos[PEAKS_SIZE]; int mnpos[PEAKS_SIZE]; int mxcount; int mncount; }; class view_cw { private: trx_mode viewmode; double bandwidth; int nchannels; public: CW_CHANNEL channel[VCW_MAXCH]; view_cw(); ~view_cw(); void init(); void restart(); void rx_init(){}; void tx_init(SoundBase *sc){}; int rx_process(const double *buf, int len); int get_freq(int n); void clear(); void clearch(int n); }; #endif
3,027
C++
.h
116
24.155172
79
0.687783
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,447
spectrum.h
w1hkj_fldigi/src/include/spectrum.h
// ---------------------------------------------------------------------------- // digiscope.h, Miniature Oscilloscope/Phasescope Widget // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted in part from code contained in // gmfsk source code distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef SPECTRUM_H #define SPECTRUM_H #include <FL/Fl_Widget.H> #include "digiscope.h" class spectrum : public Digiscope { public: private: bool _paused; double _freq; double _db; double _db_diff; double _f_diff; double _gofreq; void handle_shift_leftclick(int x); void handle_leftclick( int x, int y); void handle_rightclick( int x, int y); public: spectrum(int, int, int, int); ~spectrum(); bool paused() { return _paused; } void paused(bool on) { _paused = on; } double freq() { return _freq; } double db() { return _db; } double db_diff() { return _db_diff; } double f_diff() { return _f_diff; } double gofreq() { return _gofreq; } void gofreq(double f) { _gofreq = f; } int handle(int); }; #endif
1,877
C++
.h
56
31.982143
79
0.662065
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,448
pixmaps.h
w1hkj_fldigi/src/include/pixmaps.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef PIXMAPS_H_ #define PIXMAPS_H_ extern const char *address_book_icon[]; extern const char *edit_undo_icon[]; extern const char *edit_select_all_icon[]; extern const char *edit_clear_icon[]; extern const char *edit_copy_icon[]; extern const char *edit_cut_icon[]; extern const char *edit_paste_icon[]; extern const char *file_open_icon[]; extern const char *format_indent_more_icon[]; extern const char *left_arrow_icon[]; extern const char *log_out_icon[]; extern const char *minus_icon[]; extern const char *net_icon[]; extern const char *plus_icon[]; extern const char *process_stop_icon[]; extern const char *right_arrow_icon[]; extern const char *save_as_icon[]; extern const char *save_icon[]; extern const char *time_icon[]; extern const char *trash_icon[]; extern const char *image_icon[]; extern const char *weather_clear_icon[]; extern const char *start_here_icon[]; extern const char *help_browser_icon[]; extern const char *system_search_icon[]; extern const char *system_software_update_icon[]; extern const char *utilities_terminal_icon[]; extern const char *emblem_symbolic_link_icon[]; extern const char *emblems_system_icon[]; extern const char *dialog_information_icon[]; extern const char *executable_icon[]; extern const char *other_icon[]; extern const char *folder_open_icon[]; extern const char *preferences_system_icon[]; extern const char *preferences_desktop_font_icon[]; extern const char *system_users_icon[]; extern const char *utilities_system_monitor_icon[]; extern const char *multimedia_player_icon[]; extern const char *chat_icon[]; extern const char *dialog_information_48_icon[]; extern const char *dialog_warning_48_icon[]; extern const char *refresh_icon[]; extern const char *text_editor_icon[]; extern const char *text_icon[]; extern const char *shutdown_icon[]; extern const char *applications_system_icon[]; extern const char *audio_card_icon[]; extern const char *help_about_icon[]; extern const char *insert_link_icon[]; extern const char *close_icon[]; extern const char *apply_icon[]; extern const char *enter_key_icon[]; extern const char *dialog_question_48_icon[]; extern const char *clear_sq_icon[]; extern const char *clear_row_icon[]; extern const char *rx1_icon[]; extern const char *tx1_icon[]; extern const char *rx2_icon[]; extern const char *tx2_icon[]; extern const char *rx_icon[]; extern const char *tx_icon[]; extern const char *fldigi_icon[]; extern const char *flarq_icon[]; extern const char *waterfall_icon[]; extern const char *dice_icon[]; extern const char *pskr_icon[]; extern const char *tango_view_refresh[]; #endif // PIXMAPS_H_
3,499
C++
.h
89
38.269663
79
0.723136
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,449
adif_def.h
w1hkj_fldigi/src/include/adif_def.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef ADIF_DEF #define ADIF_DEF #include <string> #include <cstring> #include <FL/Fl_Check_Button.H> #include "field_def.h" struct FIELD { int type; int fsize; const char *name; Fl_Check_Button **btn; }; extern FIELD fields[]; #endif
1,142
C++
.h
33
33.151515
79
0.632486
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,450
cmedia.h
w1hkj_fldigi/src/include/cmedia.h
// ---------------------------------------------------------------------------- // Copyright (C) 2020 // David Freese, W1HKJ // // This file is part of fldigi. // // flrig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // flrig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef CMEDIA_H #define CMEDIA_H #include <string> /* #ifdef __WIN32__ # include <windows.h> //# include "par_nt.h" # include <winioctl.h> # include <winbase.h> #endif */ extern bool set_cmedia(int, int); extern int get_cmedia(); extern int open_cmedia(std::string); extern void close_cmedia(); extern void init_hids(); extern void test_hid_ptt(); #endif
1,255
C++
.h
37
32.783784
79
0.638087
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,451
field_def.h
w1hkj_fldigi/src/include/field_def.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef FIELD_DEFS #define FIELD_DEFS // removed unused fields to reduce size of each record and speed up // record processing // field position should correspond with fields[] in adif_io.cxx enum ADIF_FIELD_POS { FREQ = 0, CALL, ADIF_MODE, SUBMODE, NAME, QSO_DATE, QSO_DATE_OFF, TIME_OFF, TIME_ON, QTH, RST_RCVD, RST_SENT, STATE, VE_PROV, NOTES, QSLRDATE, QSLSDATE, EQSLRDATE, EQSLSDATE, LOTWRDATE, LOTWSDATE, GRIDSQUARE, BAND, CNTY, COUNTRY, CQZ, DXCC, QSL_VIA, IOTA, ITUZ, CONT, SRX, STX, XCHG1, MYXCHG, CLASS, ARRL_SECT, TX_PWR, OP_CALL, STA_CALL, MY_GRID, MY_CITY, SS_SERNO, SS_PREC, SS_CHK, SS_SEC, AGE, TEN_TEN, CHECK, FD_CLASS, // for backward compatible logbook reads FD_SECTION, // for backward compatible logbook reads TROOPS, // JOTA scout troop sent TROOPR, // JOTA scout troop received SCOUTS, // JOTA scout name sent SCOUTR, // JOTA scout name received // do not add fields below this line; EXPORT must be last field in struc EXPORT, // flag used internally in fldigi's logbook NUMFIELDS }; // ADIF multiline string is a sequence of Characters and line-breaks, // where a line break is an ASCII CR (code 13) followed immediately by an ASCII LF (code 10) // Not sure fldigi is completely conformant with this. // #define ADIF_EOL "\r\n" #define ADIF_EOL "\n" // Forward declaration for QsoHelper. class cQsoRec ; // Helps for creating a new ADIF record. class QsoHelper { cQsoRec * qso_rec ; QsoHelper(); QsoHelper(const QsoHelper &); QsoHelper & operator=(const QsoHelper &); public: QsoHelper(int mode); ~QsoHelper(); // Inserts a key-value pair. void Push( ADIF_FIELD_POS pos, const std::string & value ); }; #endif
2,563
C++
.h
103
23.728155
93
0.703915
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,452
rx_extract.h
w1hkj_fldigi/src/include/rx_extract.h
// ---------------------------------------------------------------------------- // ex_extract.h Remote Log Interface for fldigi // // Copyright W1HKJ, Dave Freese 2006 // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _RX_EXTRACT_H #define _RX_EXTRACT_H #include <string> extern const char *txtWrapInfo; extern void rx_extract_add(int c); extern void select_flmsg_pathname(); extern std::string select_binary_pathname(std::string deffilename); extern bool extract_wrap; extern bool extract_flamp; #endif
1,214
C++
.h
30
39.3
79
0.667515
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,455
kmlserver.h
w1hkj_fldigi/src/include/kmlserver.h
// ---------------------------------------------------------------------------- // kmlserver.h -- KML Server // // Copyright (C) 2012 // Remi Chateauneu, F4ECW // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _KMLSERVER_H #define _KMLSERVER_H #include <limits.h> #include <string> #include <vector> #include <sstream> #include <coordinate.h> /// Keyhole Markup Language: This publishes a complete message, localisation+time+weather etc... class KmlServer { protected: /// Counts the number of complete messages written. int m_nb_broadcasts ; int exit_kml_server; int request_broadcast; public: /// List of key-value pairs displayed for example in Google Earth balloons. struct CustomDataT : public std::vector< std::pair< std::string, std::string > > { /// Also used when reloading a KML file. void Push( const char * k, const std::string & v ); /// TODO: Most of keys are duplicated. Should store them in a hash to reduce memory footprint. void Push( const char * k, const char * v ) { Push( k, std::string(v) ); } /// This helper makes insertions simpler. template< class Type > void Push( const char * k, const Type & v ) { std::stringstream strm ; strm << v ; Push( k, strm.str() ); } }; KmlServer() : m_nb_broadcasts(0), exit_kml_server(0), request_broadcast(0) {} virtual ~KmlServer() {} /// BEWARE: Will work until 2038. static const time_t UniqueEvent = INT_MAX ; /// This can for example go to a NMEA client. virtual void Broadcast( const std::string & category, time_t evtTim, const CoordinateT::Pair & refCoo, double altitude, const std::string & kml_name, const std::string & styleNam, const std::string & descrTxt, const CustomDataT & custDat ) = 0; /// Singleton. static KmlServer * GetInstance(void); /// Number of calls to Broadcast(). Debugging purpose only. int NbBroadcasts(void) const { return m_nb_broadcasts; } /// Debugging only, just to check what happens inside. void ResetCounter() { m_nb_broadcasts = 0;} virtual void Reset() = 0; /// TODO: Maybe have one display style per category, instead of the same for all. virtual void InitParams( const std::string & kml_command, const std::string & kml_dir, double kml_merge = 10000, int kml_retention = 0, // Keep all data. int kml_refresh = 120, int kml_balloon_style = 0) = 0; virtual void ReloadKmlFiles() = 0; /// Creates the process for the command to be run when KML data is saved. static void SpawnProcess(); /// Stops the sub-thread, flush KML data to the files. static void Exit(); static std::string Tm2Time( time_t tim ); /// No value means, now. static std::string Tm2Time(void); }; #endif // _KMLSERVER_H
3,539
C++
.h
91
36.637363
96
0.657818
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,456
strutil.h
w1hkj_fldigi/src/include/strutil.h
// ---------------------------------------------------------------------------- // strutil.h // // Copyright (C) 2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef STRUTIL_H_ #define STRUTIL_H_ #include <ostream> #include <iterator> #include <sstream> #include <algorithm> #include <string> #include <vector> #include <climits> std::vector<std::string> split(const char* re_str, const char* str, unsigned max_split = UINT_MAX); // Fills a string with snprintf format string. std::string strformat( const char * fmt, ... ); // Eliminates spaces and tabs at the beginning and the end. void strtrim( std::string & str ); // First letter of each word in ucasestr, the rest in lowercase. void strcapitalize( std::string & str ); // Returns the replacement of all occurences of a given string by another. std::string strreplace( const std::string & inp, const std::string & from, const std::string & to ); /// Edit distance: Returns an integer which is the distance between the two strings. size_t levenshtein(const std::string & source, const std::string & target); // Conversion to ucasestr. std::string ucasestr( std::string str ); std::string ucasestr( const char *str); // find independent of case size_t ufind(std::string s1, std::string s2, size_t idx = 0); // ---------------------------------------------------------------------------- /// This is a read-only replacement for std::stringstream. struct imemstream : public std::streambuf, public std::istream { /// Faster than stringstream because no copy. imemstream(char* s, std::size_t n) : std::istream( this ) { setg(s, s, s + n); } /// Faster than stringstream because no copy. imemstream(const std::string & r) : std::istream( this ) { char * s = const_cast< char * >( r.c_str() ); setg(s, s, s + r.size()); } }; // ---------------------------------------------------------------------------- /// Tells if type is a char[]. Used for SFINAE. template< class T > struct DtTyp { /// In the general case, data types are not char arrays. struct Any {}; }; /// Matches if the type is a char[]. template< size_t N > struct DtTyp< char[N] > { struct Array {}; static const size_t Size = N ; }; /// Reads all chars until after the delimiter. bool read_until_delim( char delim, std::istream & istrm ); /// Reads a char followed by the delimiter. bool read_until_delim( char delim, std::istream & istrm, char & ref, const char dflt ); /// Reads a double up to the given delimiter. inline bool read_until_delim( char delim, std::istream & istrm, double & ref ) { istrm >> ref ; if( ! istrm ) return false ; char tmp = istrm.get(); if( istrm.eof() ) { /// Resets to good to mean that it worked fine. istrm.clear(); return true ; } return tmp == delim ; } /// Reads a string up to the given delimiter. inline bool read_until_delim( char delim, std::istream & istrm, std::string & ref ) { std::getline( istrm, ref, delim ); if ( (istrm.rdstate() & std::istream::goodbit) == 0 ) return true ; else return false ; } /// For reading from a string with tokens separated by a char. Used to load CSV files. template< typename Tp > bool read_until_delim( char delim, std::istream & istrm, Tp & ref, typename DtTyp< Tp >::Any = typename DtTyp< Tp >::Any() ) { std::string parsed_str ; std::getline( istrm, parsed_str, delim ); if( ! ((istrm.rdstate() & std::istream::goodbit) == 0)) { return false ; } imemstream sstrm( parsed_str ); sstrm >> ref ; return true ; } /// Same, with a default value if there is nothing to read. template< typename Tp > bool read_until_delim( char delim, std::istream & istrm, Tp & ref, const Tp dflt, typename DtTyp< Tp >::Any = typename DtTyp< Tp >::Any() ) { std::string parsed_str ; std::getline( istrm, parsed_str, delim ) ; if( ! ((istrm.rdstate() & std::istream::goodbit) == 0) ) { return false ; } if( parsed_str.empty() ) { ref = dflt ; return true; } imemstream sstrm( parsed_str ); sstrm >> ref ; return true ; } /// For reading from a string with tokens separated by a char to a fixed-size array. template< typename Tp > bool read_until_delim( char delim, std::istream & istrm, Tp & ref, typename DtTyp< Tp >::Array = typename DtTyp< Tp >::Array() ) { istrm.getline( ref, DtTyp< Tp >::Size, delim ); // Should we return an error if buffer is too small? return( (istrm.rdstate() & std::istream::goodbit) == 0 ); } /// Same, with a default value if there is nothing to read. Fixed-size array. template< typename Tp > bool read_until_delim( char delim, std::istream & istrm, Tp & ref, const Tp dflt, typename DtTyp< Tp >::Array = typename DtTyp< Tp >::Array() ) { istrm.getline( ref, DtTyp< Tp >::Size, delim ); // If nothing to read, copy the default value. if( ref[0] == '\0' ) { strncpy( ref, dflt, DtTyp< Tp >::Size - 1 ); } // Should we return an error if buffer is too small? return ((istrm.rdstate() & std::istream::goodbit) == 0 ); } // ---------------------------------------------------------------------------- #endif // STRUTIL_H_ // Local Variables: // mode: c++ // c-file-style: "linux" // End:
5,817
C++
.h
156
35.660256
143
0.648625
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,457
dtmf.h
w1hkj_fldigi/src/include/dtmf.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #include <string> #include "filters.h" class cDTMF { private: //#define N 240 // 30 msec interval at 8000 sps #define RANGE 0.5 /* any thing higher than RANGE*peak is "on" */ #define THRESH 1000 /* 6 dB s/n for detection */ #define FLUSH_TIME 10 /* 10 frames ~ 330 millisecond */ #define NUMTONES 8 private: double power[NUMTONES]; //double thresh; double maxpower; double minpower; double data[350]; goertzel *filt[NUMTONES]; int framesize; static double coef[]; static int k[]; static const char *dtran[]; static int row[]; static int col[]; static const char rc[]; double outbuf[16384]; double shape[128]; int RT; int duration; int silence_time; int last; std::string dtmfchars; public: cDTMF() { for (int i = 0; i < 4; i++) filt[i] = new goertzel(240, row[i], 8000); for (int i = 0; i < 4; i++) filt[i+4] = new goertzel(240, col[i], 8000); for (int i = 0; i < 240; i++) data[i] = 0; dtmfchars.clear(); framesize = 240; // 8000 sr default silence_time = 0; last = ' '; } ~cDTMF() {}; // receive void calc_power(); int decode(); void receive(const float* buf, size_t len); // transmit void makeshape(); void silence(int); void two_tones(int); void send(); };
2,134
C++
.h
70
28.685714
79
0.63694
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,458
hidapi.h
w1hkj_fldigi/src/include/hidapi.h
/*********************************************************************** HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software Copyright 2009, All Rights Reserved. C++ implementation * Copyright 2021 * David Freese, W1HKJ * for use in fldigi This software is licensed under the terms of the GNU General Public License v3. ***********************************************************************/ #include <wchar.h> #define HID_API_VERSION_MAJOR 0 #define HID_API_VERSION_MINOR 10 #define HID_API_VERSION_PATCH 1 /* Helper macros */ #define HID_API_AS_STR_IMPL(x) #x #define HID_API_AS_STR(x) HID_API_AS_STR_IMPL(x) #define HID_API_TO_VERSION_STR(v1, v2, v3) HID_API_AS_STR(v1.v2.v3) #define HID_API_VERSION_STR HID_API_TO_VERSION_STR(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH) #ifdef __WIN32__ # include "hid_win.h" # else # ifdef __APPLE__ # include "hid_mac.h" # else # include "hid_lin.h" # endif #endif
1,007
C++
.h
30
31.833333
119
0.632505
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,459
logsupport.h
w1hkj_fldigi/src/include/logsupport.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef LOG_SUPPORT_H #define LOG_SUPPORT_H #include <string> #include <FL/Fl_Widget.H> #include <FL/Fl_Menu_.H> #include "qso_db.h" #include "adif_io.h" #include "lgbook.h" #ifdef __WOE32__ # define ADIF_SUFFIX "adi" #else # define ADIF_SUFFIX "adif" #endif enum savetype {ADIF, CSV, TEXT, LOTW, LO}; enum logtype { LOG_QSO, // No Contest LOG_GENERIC, // Generic contest LOG_AIDX, // Africa International DX LOG_FD, // ARRL Field Day LOG_AICW, // ARRL International DX (Cw) LOG_JOTA, // ARRL Jamboree On The Air LOG_KD, // ARRL Kids Day LOG_ARR, // ARRL Rookie Roundup LOG_RTTY, // ARRL RTTY LOG_ASCR, // ARRL School Club Roundup LOG_CWSS, // ARRL November Sweepstakes LOG_WFD, // ARRL Winter Field Day LOG_BART, // BARTG RTTY contest LOG_CQ_WPX, // CQ WPX LOG_CQWW_DX, // CQ WW Dx LOG_CQWW_RTTY, // CQ WW RTTY LOG_IARI, // Italian ARI International DX LOG_NAQP, // North American QSO Party LOG_NAS, // North American Sprint LOG_1010, // Ten Ten LOG_VHF, // VHF // LOG_WAE, // Worked All Europe LOG_SQSO // State QSO parties }; extern cQsoDb qsodb; extern cAdifIO adifFile; extern std::string logbook_filename; extern std::string sDate_on; extern std::string sDate_off; extern std::string sTime_on; extern std::string sTime_off; extern void loadBrowser(bool keep_pos = false); extern void Export_log(); extern void cb_SortByCall(); extern void cb_SortByDate(); extern void cb_SortByMode(); extern void cb_SortByFreq(); extern void cb_browser(Fl_Widget *, void *); extern void cb_mnuNewLogbook(Fl_Menu_* m, void* d); extern void cb_mnuOpenLogbook(Fl_Menu_* m, void* d); extern void cb_mnuSaveLogbook(Fl_Menu_*m, void* d); extern void cb_mnuMergeADIF_log(Fl_Menu_* m, void* d); extern void cb_mnuExportADIF_log(Fl_Menu_* m, void* d); extern void cb_mnuExportCSV_log(Fl_Menu_* m, void* d); extern void cb_mnuExportTEXT_log(Fl_Menu_* m, void* d); extern std::string lotw_rec(cQsoRec &rec); extern void cb_btnExportLoTW(); extern Fl_Double_Window *lotw_review_dialog; extern void cb_review_lotw(); extern void cb_send_lotw(); extern void send_to_lotw(void *); extern void cb_btn_verify_lotw(Fl_Button *, void *); extern void cb_btn_verify_eqsl(Fl_Button *, void *); extern void cb_btn_view_unmatched(Fl_Button *, void *); extern void cb_Export_Cabrillo(Fl_Menu_* m, void* d); extern void cb_export_date_select(); extern void saveLogbook(bool force = false); extern void cb_mnuShowLogbook(Fl_Menu_ *m, void* d); extern void activateButtons(); extern void saveRecord (); extern void clearRecord (); extern void updateRecord (); extern void deleteRecord (); extern void AddRecord (); extern void DisplayRecord (int idxRec); extern void SearchLastQSO (const char *); extern cQsoRec* SearchLog(const char *callsign); extern void DupCheck(); extern void show_dup(void *); extern void cb_search(Fl_Widget* w, void*); extern int log_search_handler(int); extern void reload_browser(); extern void restore_sort(); extern void cb_doExport(); extern void WriteCabrillo(); extern void dxcc_entity_cache_enable(bool v); extern bool qsodb_dxcc_entity_find(const char* country); extern void adif_read_OK(); extern std::string adif_record(cQsoRec *rec); extern std::string last_adif_record(); extern std::string all_adif_records(); extern void writeLog(std::string fname, cQsoDb *db); #endif
4,285
C++
.h
117
35.051282
79
0.703257
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,460
feld.h
w1hkj_fldigi/src/include/feld.h
// ---------------------------------------------------------------------------- // feld.h -- FELDHELL modem // // Copyright (C) 2006-2010 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // Copyright (C) 2004 // Lawrence Glaister (ve7it@shaw.ca) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _FELD_H #define _FELD_H #include "modem.h" #include "filters.h" #include "fftfilt.h" #include "mbuffer.h" #define FeldSampleRate 8000 #define FeldMaxSymLen 1024 #define MAXLEN 512 #define FELD_COLUMN_LEN 14 #define MAX_RX_COLUMN_LEN 42 class feld : public modem { enum FELD_STATE {PREAMBLE, POSTAMBLE, DATA}; protected: int RxColumnLen; int TxColumnLen; //rx double rxphacc; double rxdelta; double rxcounter; double agc; double peakval; double peakhold; double rxpixrate; double txpixrate; double downsampleinc; double upsampleinc; double phi2freq; C_FIR_filter *hilbert; fftfilt *lpfilt; Cmovavg *bbfilt; Cmovavg *average; //tx FELD_STATE tx_state; double txphacc; double txcounter; double hell_bandwidth; double filter_bandwidth; int depth; double feldcolumnrate; int hardkeying; int preamble; int postamble; int prevsymb; cmplx prev; double OnShape[MAXLEN]; double OffShape[MAXLEN]; mbuffer<int> col_data; int col_pointer; int fntnbr; cmplx mixer(cmplx); double nco(double); void rx(cmplx); void FSKH_rx(cmplx); void send_symbol(int currsymbol, int nextsymbol); void send_null_column(); void tx_char(char); void initKeyWaveform(); public: feld(trx_mode); ~feld(); void init(); void rx_init(); void tx_init(); void restart(); int rx_process(const double *buf, int len); int tx_process(); int get_font_data(unsigned char c, int col); }; #endif
2,556
C++
.h
96
24.916667
81
0.703234
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,461
kiss_io.h
w1hkj_fldigi/src/include/kiss_io.h
// ---------------------------------------------------------------------------- // kiss_io.h // // Support for KISS interface // // Copyright (c) 2014, 2016 // Robert Stiles, KK5VD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef KISSIO_H #define KISSIO_H #include <vector> #include <time.h> #include "threads.h" #include "socket.h" #include "modem.h" #include "psm/psm.h" #define HDLC_CNT_OFFSET 32 #define HDLC_CNT 0xDE #define HDLC_TCNT 0xE0 #define KISS_FEND 0xC0 #define KISS_FESC 0xDB #define KISS_TFEND 0xDC #define KISS_TFESC 0xDD #define KISS_DATA 0x00 #define KISS_TXDELAY 0x01 #define KISS_PERSIST 0x02 #define KISS_SLOTTIME 0x03 #define KISS_TXTAIL 0x04 #define KISS_DUPLEX 0x05 #define KISS_HARDWARE 0x06 #define KISS_RAW 0x07 // Non standard frame type for ARQ use #define KISS_RETURN 0x0F #define KISS_RAW_DISABLED 0x00 #define KISS_RAW_ONLY 0x01 #define KISS_RAW_ON 0x02 #define KISS_CMD(a) (a & 0x0F) #define KISS_PORT(a) ((a & 0xF0) >> 4) #define SET_KISS_TYPE_PORT(t,p) ((t & 0x0F) | ((p << 4) & 0xF0)) #define SMACK_CRC(a) (a & 0x08) #define SMACK_CRC_MASK(a) (a & 0xF7) #define SMACK_CRC_ASSIGN(a) ((a | 0x08) & 0xFF) #define CRC_LOW(a) (a & 0xFF) #define CRC_HIGH(a) ((a >> 8) & 0xFF) #define CRC_LOW_HIGH(l,h) (((h << 8) & 0xFF00) | (l & 0xFF)) #define CRC16_NONE 0 #define CRC16_CCITT 1 #define CRC16_FCS 2 #define CRC8_XOR 3 #define KISS_INVALID 512 #define KISS_HALF_DUPLEX 0 #define KISS_FULL_DUPLEX 1 #define BUFFER_PADDING 32 #define KISS_BUFFER_FACTOR 2 #define HDLC_BUFFER_FACTOR 3 #define KISS_CONNECT_RETRY_COUNT 10 #define KISS_RETRY_WAIT_TIME 1000 #define MAX_TEMP_BUFFER_SIZE 32000 #define TX_BUFFER_TIMEOUT (60 * 10) // Ten minute timeout #define DISABLE_TX_INHIBIT_DURATION 5 #define KPSQL_MIN_BANDWIDTH 400 #define TEST_INTERVAL_SECONDS 15 typedef struct { char *data; size_t size; } KISS_QUEUE_FRAME; typedef struct { char *cmd; void (*cmd_func) (char *arg); } EXEC_HARDWARE_CMD_MATCH; #define AX25_FRAME_MARKER 0xFF extern time_t temp_disable_tx_inhibit; extern time_t temp_disable_tx_duration; extern void AbortKiss(); extern bool bcast_rsid_kiss_frame(int new_wf_pos, int new_mode, int old_wf_pos, int old_mode, int notify); extern bool valid_kiss_modem(std::string _modem); extern void check_kiss_modem(void); extern void bcast_trxs_kiss_frame(int state); extern void bcast_tx_buffer_empty_kiss_frame(void); extern bool tcp_init(bool connect_flag); extern bool udp_init(void); extern void kiss_init(bool connect_flag); extern void kiss_close(bool override_flag); extern void connect_to_kiss_io(bool user_requested); extern bool kiss_thread_running(void); extern int kiss_get_char(void); extern void ax25_decode(unsigned char *buffer, size_t count, bool pad, bool tx_flag); extern void flush_kiss_tx_buffer(void); #endif // KISSIO_H
3,703
C++
.h
103
34.679612
106
0.683445
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,462
mbuffer.h
w1hkj_fldigi/src/include/mbuffer.h
// ---------------------------------------------------------------------------- // mbuffer.h // // Copyright (C) 2007 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- // A simple vector wrapper for fldigi's double-buffering needs. // Most vector operations are provided for mbuffers by redirecting them to the // current vector. // The template arguments are // 1) T - the type // 2) S - the apparent mbuffer size, i.e., the size of each vector. Defaults to 0. // A mbuffer instantiated with S == 0 is not very useful until resized // with alloc(). // 3) N - the number of vectors that we can cycle between. Defaults to 1. // Things to note: // 1) There is a T* conversion operator // 2) Operations that modify the length of the container are not provided // 3) Comparison operators are not implemented (but see (1)!) // 4) mbuffer<T, 0, N> is meant to be used when we don't know the size at // compile time, in which case we resize with alloc. The compiler will treat // mbuffers resized to different lengths in this way as objects of the same type. #ifndef MBUFFER_H #define MBUFFER_H #include <vector> #include <algorithm> #ifndef NDEBUG #include <iosfwd> #include <iterator> #endif #ifndef NDEBUG template <typename T, std::size_t S, std::size_t N> class mbuffer; template <typename T, std::size_t S, std::size_t N> std::ostream& operator<<(std::ostream& o, const mbuffer<T, S, N>& b); #endif // NDEBUG template <typename T, std::size_t S = 0, std::size_t N = 1> class mbuffer { protected: std::vector<T> data[N]; mutable std::size_t cur; public: explicit mbuffer(void) { alloc(S); } explicit mbuffer(std::size_t n) { alloc(n); } mbuffer(const std::vector<T>& v) { data[0] = v; // resize 1 to N only alloc(data[0].size(), 1); } mbuffer(const T* a, std::size_t n) { data[0].assign(a, a + n); // resize 1 to N only alloc(n, 1); } void alloc(std::size_t n, std::size_t start = 0) { for (size_t i = start; i < N; ++i) data[i].resize(n); cur = 0; } typedef typename std::vector<T>::iterator iterator; typedef typename std::vector<T>::const_iterator const_iterator; iterator begin(void) { return data[cur].begin(); } const_iterator begin(void) const { return data[cur].begin(); } iterator end(void) { return data[cur].end(); } const_iterator end(void) const { return data[cur].end(); } typedef typename std::vector<T>::reverse_iterator reverse_iterator; typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator; reverse_iterator rbegin(void) { return reverse_iterator(end()); } const_reverse_iterator rbegin(void) const { return const_reverse_iterator(end()); } reverse_iterator rend(void) { return reverse_iterator(begin()); } const_reverse_iterator rend(void) const { return const_reverse_iterator(begin()); } typedef typename std::vector<T>::value_type value_type; typedef typename std::vector<T>::reference reference; typedef typename std::vector<T>::const_reference const_reference; typedef typename std::vector<T>::size_type size_type; typedef typename std::vector<T>::difference_type difference_type; // These should be the same for all vectors in data[] size_type size(void) { return data[0].size(); } size_type max_size(void) { return data[0].max_size(); } size_type capacity(void) { return data[0].capacity(); } bool empty(void) { return data[0].empty(); } // Instead of these, we provide a conversion operator for T* // reference operator[](size_type i) { return data[cur][i]; } // const_reference operator[](size_type i) const { return data[cur][i]; } reference at(size_type i) { return data[cur].at(i); } const_reference at(size_type i) const { return data[cur].at(i); } reference front(void) { return data[cur].front(); } const_reference front(void) const { return data[cur].front(); } reference back(void) { return data[cur].back(); } const_reference back(void) const { return data[cur].back(); } // Operations that modify the size of data[cur] might invalidate // pointers to internal buffers. The rest of the data vectors would need // to be resized, e.g. with check_size below. For this reason these // operations are not provided, but are included here for completeness // void check_size(void) // { // for (size_t i = 0; i < N; ++i) // if (data[i].size() != data[cur].size()) // data[i].resize(data[cur].size()); // } // mbuffer<T, S, N>& operator=(const mbuffer<T, S, N>& o) // { // for (int i = 0; i < N; ++i) // std::copy(o.data[i].begin(), o.data[i].end(), data[i].begin()); // return *this; // } // std::vector<T>& operator=(const std::vector<T>& o) // { // std::copy(o.begin(), o.end(), data[cur].begin()); // check_size(); // return data[cur]; // } // The methods below would modify the length of the vector. // We would need to check_size() before returning from them. // There is no vector::assign; the one provided here fills the vector // with copies of the same value without causing a resize. void assign(const_reference v) { std::fill_n(begin(), size(), v); } // template <typename input_iterator> // void assign(input_iterator first, input_iterator last) // { // data[cur].assign(first, last); // } // void push_back(const_reference v) { data[cur].push_back(v); } // void pop_back(void) { data[cur].pop_back(); } // iterator insert(iterator pos, const_reference v) // { // return data[cur].insert(pos, v); // } // iterator insert(iterator pos, size_type n, const_reference v) // { // return data[cur].insert(pos, n, v); // } // template <typename input_iterator> // void insert(iterator pos, input_iterator first, input_iterator last) // { // data[cur].insert(pos, first, last); // } // iterator erase(iterator pos) { return data[cur].erase(pos); } // iterator erase(iterator first, iterator last) { return data[cur].erase(first, last); } // void clear(void) { data[cur].clear(); } void swap(mbuffer<T, S, N>& o) { for (int i = 0; i < N; ++i) std::swap(data[i].begin(), data[i].end(), o.data[i].begin()); } // void swap(std::vector<T>& o) // { // std::swap(data[cur].begin(), data[cur].end(), o.begin()); // check_size(); // o.check_size(); // } // and now for something completely different void next(void) const { if (++cur == N) cur = 0; } void prev(void) const { if (cur > 0) --cur; } void reset(void) const { cur = 0; } T* c_array(void) { return &data[cur][0]; } operator T*(void) { return c_array(); } const T* c_array(void) const { return &data[cur][0]; } operator const T*(void) const { return c_array(); } std::vector<T>& vec(void) { return data[cur]; } const std::vector<T>& vec(void) const { return data[cur]; } // We also do not provide vector<T> conversions // operator std::vector<T>&(void) { return vec(); } // operator const std::vector<T>&(void) const { return vec(); } std::size_t idx(void) { return cur; } std::size_t nvec(void) { return N; } std::vector<T>* vecp(std::size_t i) { return &data[i]; } #ifndef NDEBUG friend std::ostream& operator<<<>(std::ostream& o, const mbuffer<T, S, N>& b); #endif // NDEBUG }; #ifndef NDEBUG template <typename T, std::size_t S, std::size_t N> std::ostream& operator<<(std::ostream& o, const mbuffer<T, S, N>& b) { for (std::size_t i = 0; i < N; ++i) { o << '<' << i << ">\n"; copy(b.data[i].begin(), b.data[i].end(), std::ostream_iterator<T>(o, "\n")); } return o; } #endif // NDEBUG template <typename T, std::size_t S, std::size_t N> inline void swap(mbuffer<T, S, N>& a, mbuffer<T, S, N>& b) { a.swap(b); } #endif // MBUFFER_H // Local Variables: // mode: c++ // c-file-style: "linux" // End:
9,906
C++
.h
216
38.842593
97
0.559183
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,463
date.h
w1hkj_fldigi/src/include/date.h
/* -*-C++-*- "$Id: Fl_Date.H,v 1.4 2000/03/30 04:43:56 davefreese Exp $" Copyright 1999-2000 by the Dave Freese & the Flek development team. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. */ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef DATE_H #define DATE_H #include <iosfwd> typedef enum { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } weekday_t; typedef enum { JANUARY = 1, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER } month_t; class Date { friend std::ostream &operator<<(std::ostream &, Date &); protected: int year; int month; int day; int fmt; static const int mdays[]; static const int jdays[][13]; static const char *month_name[]; void helpIncrement(); public: Date(); Date( int m, int d, int y ); void setDate( int, int, int ); // set the date void setDate( Date & ); void setFormat (int); void today(); // set date to the present day void Year( int ); int Year(); void Month( int ); int Month(); void Day( int ); int Day(); void previous_month (); void next_month (); void previous_year (); void next_year (); bool endOfMonth( int ); bool leapYear (int); bool leapYear () { return leapYear (year); } bool isleapyear (int year) { return leapYear (year); } bool isleapyear () { return isleapyear (year); } int daysinmonth (int, int); int daysinmonth () { return daysinmonth (month, isleapyear (year)); } bool isvalid (int, int, int); bool datevalid (int year, int mon, int day) { return isvalid (mon, day, year); } bool datevalid () { return isvalid (month, day, year); } int dayofyear (int, int, int); int dayofyear () { return dayofyear (year, month, day); } int dayofepoch (int, int, int); int dayofepoch () { return dayofepoch (year, month, day); } int dayofweek (int, int, int); int dayofweek () { return dayofweek (year, month, day); } char *szDate (int); char *szDate (); double dJulian (); bool operator==( const Date & ); bool operator!=( const Date & ); bool operator<( const Date & ); bool operator>( const Date & ); void operator=( const Date & ); const Date &operator+=( int); // add days, modify object Date &operator++(); // pre-increment operator Date operator++( int ); // post-increment operator }; #endif
3,149
C++
.h
104
26.807692
79
0.648161
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,465
dsp.h
w1hkj_fldigi/src/include/dsp.h
/* * dsp.h -- various DSP algorithms * * based on mt63 code by Pawel Jalocha * Copyright (C) 1999-2004 Pawel Jalocha, SP9VRC * Copyright (c) 2007-2019 Dave Freese, W1HKJ * * This file is part of fldigi. * * Fldigi is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fldigi is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with fldigi. If not, see <http://www.gnu.org/licenses/>. * */ #include <cstdlib> #include <cstring> #include <cmath> // ---------------------------------------------------------------------------- // double/other-complex type template <class type> struct Cdspcmpx { type re,im; }; typedef Cdspcmpx<double> dspCmpx; // Some complex operators template <class type> inline void operator +=(Cdspcmpx<type> &Dst, Cdspcmpx<type> &Src) { Dst.re += Src.re; Dst.im += Src.im; } template <class type> inline void operator -=(Cdspcmpx<type> &Dst, Cdspcmpx<type> &Src) { Dst.re -= Src.re; Dst.im -= Src.im; } template <class type, class num> inline void operator *=(Cdspcmpx<type> &Dst, num Src) { Dst.re *= Src; Dst.im *= Src; } template <class type, class num> inline void operator /=(Cdspcmpx<type> &Dst, num Src) { Dst.re /= Src; Dst.im /= Src; } // scalar product of two vectors template <class typeA, class typeB> inline double dspScalProd(Cdspcmpx<typeA> &A, Cdspcmpx<typeB> &B) { return A.re * B.re + A.im * B.im; } template <class typeA, class typeB> inline double dspScalProd(typeA Ia, typeA Qa, Cdspcmpx<typeB> &B) { return Ia * B.re + Qa * B.im; } // complex multiply template <class typeDst, class typeA, class typeB> inline void CdspcmpxMultAxB(Cdspcmpx<typeDst> &Dst, Cdspcmpx<typeA> &A, Cdspcmpx<typeB> &B) { Dst.re = A.re * B.re - A.im * B.im; Dst.im = A.re * B.im + A.im * B.re; } template <class typeDst, class typeA, class typeB> inline void CdspcmpxMultAxB(typeDst &DstI, typeDst &DstQ, Cdspcmpx<typeA> &A, Cdspcmpx<typeB> &B) { DstI = A.re * B.re - A.im * B.im; DstQ = A.re * B.im + A.im * B.re; } // complex multiply, second argument with a "star" (B.im is negated) template <class typeDst, class typeA, class typeB> inline void CdspcmpxMultAxBs(Cdspcmpx<typeDst> &Dst, Cdspcmpx<typeA> &A, Cdspcmpx<typeB> &B) { Dst.re = A.re * B.re + A.im * B.im; Dst.im = A.im * B.re - A.re * B.im; } // ---------------------------------------------------------------------------- // signed 16-bit format (standard 16-bit audio) typedef short dspS16; // ---------------------------------------------------------------------------- template <class type>inline int dspRedspAllocArray(type **Array, int Size) { delete [] *Array; *Array = new type[Size]; return (*Array == 0); } template <class type>inline int dspAllocArray(type **Array, int Size) { *Array = new type[Size]; return (*Array == 0); } template <class type>inline void dspClearArray(type *Array, int Size) { memset(Array, 0, Size*sizeof(type)); } template <class type>inline void dspCopyArray(type *Dst, type *Src, int Size) { memcpy(Dst, Src, Size*sizeof(type)); } template <class type>inline void dspMoveArray(type *Dst, type *Src, int Size) { memmove(Dst, Src, Size*sizeof(type)); } template <class type> int dspAllocArray2D(type ***Array, int Size1, int Size2) { int i; (*Array) = new type *[Size1 * (sizeof(type *))]; if ((*Array) == NULL) return 1; for (i = 0; i < Size1; i++) (*Array)[i] = NULL; for (i = 0; i < Size1; i++) { (*Array)[i] = new type [Size2 * sizeof(type)]; if ((*Array)[i] == NULL) goto Error; } return 0; Error: for (i = 0; i < Size1; i++) delete [] (*Array)[i]; delete [] *Array; return 1; } template <class type> void dspFreeArray2D(type **Array, int Size1) { if (Array == 0) return; int i; for (i = 0; i < Size1; i++) delete [] (Array)[i]; delete [] Array; } template <class type> void dspClearArray2D(type **Array, int Size1, int Size2) { int i; for (i = 0; i < Size1; i++) memset(Array[i], 0, Size2 * sizeof(type)); } // ---------------------------------------------------------------------------- // processing buffers: template <class type> class dspSeq { public: dspSeq(); ~dspSeq(); int EnsureSpace(int ReqSpace); // make sure that there is enough space void Free(void); // free space to save RAM when buffer is not in use int Space; // that much is allocated in *Data int Len; // that much is filled up type *Data; // contains Len elements }; template <class type> dspSeq<type>::dspSeq() { Data = NULL; Len = Space = 0; } template <class type> dspSeq<type>::~dspSeq() { free(Data); } template <class type> int dspSeq<type>::EnsureSpace(int ReqSpace) { if (ReqSpace <= Space) return 0; Data = new type[ReqSpace * sizeof(type)]; if (Data == NULL) { Space = Len = 0; return -1; } Space = ReqSpace; return 0; } template <class type> void dspSeq<type>::Free(void) { delete [] Data; Data = NULL; Space = Len = 0; } typedef dspSeq<float> float_buff; typedef dspSeq<double> double_buff; typedef dspSeq<dspCmpx> dspCmpx_buff; typedef dspSeq<dspCmpx> dspCmpx_buff; // typedef dspSeq<short> int16_buff; <- this doesn't work - why ?! typedef dspSeq<dspS16> dspS16_buff; typedef dspSeq<char> char_buff; // ---------------------------------------------------------------------------- // First-In First-Out pipes template <class type> class dspFIFO { public: dspFIFO(); ~dspFIFO(); int Preset(int Max); void Free(void); void Clear(void); int Inp(type Elem); int Out(type &Elem); int InpReady(void); int OutReady(void); private: type *Buff; int Size; int Rd,Wr; }; template <class type> dspFIFO<type>::dspFIFO() { Buff = NULL; } template <class type> dspFIFO<type>::~dspFIFO() { free(Buff); } template <class type> void dspFIFO<type>::Free(void) { delete [] Buff; Buff = NULL; } template <class type> int dspFIFO<type>::Preset(int Max) { Size = Max + 1; if (dspRedspAllocArray(&Buff, Size)) return -1; Rd = 0; Wr = 0; return 0; } template <class type> void dspFIFO<type>::Clear(void) { Rd = Wr; } template <class type> int dspFIFO<type>::Inp(type Elem) { int w = Wr; Buff[w] = Elem; w += 1; if (w >= Size) w=0; if (w == Rd) return -1; Wr = w; return 0; } template <class type> int dspFIFO<type>::Out(type &Elem) { if (Rd == Wr) return -1; Elem = Buff[Rd]; Rd += 1; if (Rd >= Size) Rd = 0; return 0; } template <class type> int dspFIFO<type>::OutReady(void) { return (Wr >= Rd) ? Wr - Rd : Wr -Rd + Size; } template <class type> int dspFIFO<type>::InpReady(void) { return (Rd > Wr) ? Rd - Wr - 1 : Rd - Wr + Size - 1; } typedef dspFIFO<char> char_dspFIFO; // ---------------------------------------------------------------------------- // dspPower of single and complex values and dspSequences of these inline double dspPower(double X) { return X * X; } inline double dspPower(double I, double Q) { return I * I + Q * Q; } inline double dspPower(dspCmpx X) { return X.re * X.re + X.im * X.im; } double dspPower(double *X, int Len); double dspPower(double *I, double *Q, int Len); double dspPower(dspCmpx *X, int Len); inline double dspPower(double_buff *buff) { return dspPower(buff->Data, buff->Len); } inline double dspPower(dspCmpx_buff *buff) { return dspPower(buff->Data, buff->Len); } // dspAmplitude calculations inline double dspAmpl(double I, double Q) { return sqrt(I * I + Q * Q); } inline double dspAmpl(dspCmpx X) { return sqrt(X.re * X.re + X.im * X.im); } // dspPhase calculation (output = <-PI..PI) ) inline double dspPhase(double I, double Q) { return atan2(Q,I); } inline double dspPhase(dspCmpx X) { return atan2(X.im, X.re); } // dspPhase normalization inline double dspPhaseNorm(double dspPhase) { if (dspPhase >= M_PI) return dspPhase - 2 * M_PI; if (dspPhase < (-M_PI)) return dspPhase + 2 * M_PI; return dspPhase; } // ---------------------------------------------------------------------------- // min./max. of integers inline int dspIntmin(int i1, int i2) { return i1 < i2 ? i1 : i2; } inline int dspIntmax(int i1, int i2) { return i1 > i2 ? i1 : i2; } inline int dspIntmin(int i1, int i2, int i3) { return i1 < i2 ? (i1 < i3 ? i1 : i3) : (i2 < i3 ? i2 : i3); } inline int dspIntmax(int i1, int i2, int i3) { return i1 > i2 ? (i1 > i3 ? i1 : i3) : (i2 > i3 ? i2 : i3); } // ---------------------------------------------------------------------------- // Extreme search, dspAverage, fitting double dspAverage(double *Data, int Len); int dspCountInRange(double *Data, int Len, double Low, double Upp); inline int dspCountInRange(double_buff *Input, double Low, double Upp) { return dspCountInRange(Input->Data, Input->Len, Low, Upp); } inline double dspRMS(double *Data, int Len) { return sqrt(dspPower(Data, Len) / Len); } inline double dspRMS(dspCmpx *Data, int Len) { return sqrt(dspPower(Data, Len) / Len); } inline double dspRMS(double_buff *Input) { return dspRMS(Input->Data, Input->Len); } inline double dspRMS(dspCmpx_buff *Input) { return dspRMS(Input->Data, Input->Len); } template <class type> type dspFindMin(type *Data, int Len) { type Min; int i; Min = Data[0]; for (i = 1; i < Len; i++) if(Data[i] < Min) Min = Data[i]; return Min; } template <class type> type dspFindMin(type *Data, int Len, int &MinPos) { type Min; int i, pos; Min = Data[0]; pos=0; for (i = 1; i < Len; i++) if (Data[i] < Min) { Min = Data[i]; pos = i; } MinPos = pos; return Min; } template <class type> type dspFindMax(type *Data, int Len) { type Max; int i; Max = Data[0]; for (i = 1; i < Len; i++) if (Data[i] > Max) Max = Data[i]; return Max; } template <class type> type dspFindMax(type *Data, int Len, int &MaxPos) { type Max; int i, pos; Max = Data[0]; pos = 0; for (i = 1; i < Len; i++) if (Data[i] > Max) { Max = Data[i]; pos = i; } MaxPos = pos; return Max; } double dspFindMaxdspPower(dspCmpx *Data, int Len); double dspFindMaxdspPower(dspCmpx *Data, int Len, int &MaxPos); double dspFitPoly1(double *Data, int Len, double &A, double &B); double dspFitPoly2(double *Data, int Len, double &A, double &B, double &C); void dspFitPoly2(double Data[3], double &A, double &B, double &C); // ---------------------------------------------------------------------------- // "selective" dspAverage fit template <class type> int dspSelFitAver( type *Data, int Len, double SelThres, int Loops, double &Aver, double &dspRMS, int &Sel) { int i, loop, Incl;//, prev; double Sum, ErrSum, Lev, dLev, Diff, Thres; for (ErrSum = Sum = 0.0, i = 0; i < Len; i++) { Sum += Data[i]; ErrSum += dspPower(Data[i]); } Lev = Sum/Len; ErrSum /= Len; ErrSum -= Lev*Lev; // printf("Len=%d, Lev=%+7.4f, ErrSum=%7.4f, dspRMS=%7.4f\n", // Len,Lev,ErrSum,sqrt(ErrSum)); // prev = Len; Incl = 0; for (loop = 0; loop < Loops; loop++) { Thres = SelThres * SelThres * ErrSum; for (ErrSum = Sum = 0.0, Incl = 0, i = 0; i < Len; i++) { Diff = dspPower(Data[i]-Lev); if (Diff <= Thres) { Sum += Data[i]; ErrSum += Diff; Incl += 1; } // else printf(" %d",i); } Sum /= Incl; dLev = Sum - Lev; ErrSum /= Incl; ErrSum -= dLev * dLev; Lev += dLev; ErrSum = fabs(ErrSum); // printf("\nLoop #%d, Lev=%+7.4f, dLev=%+7.4f, ErrSum=%7.4f, dspRMS=%7.4f, Incl=%d\n", // loop,Lev,dLev,ErrSum,sqrt(ErrSum),Incl); // if(Incl==prev) { loop++; break; } // prev=Incl; } Aver = Lev; dspRMS = sqrt(ErrSum); Sel=Incl; return loop; } template <class type> int dspSelFitAver( Cdspcmpx<type> *Data, int Len, double SelThres, int Loops, Cdspcmpx<double> &Aver, double &dspRMS, int &Sel) { int i, loop, Incl;//, prev; dspCmpx Sum, Lev, dLev; double ErrSum, Diff, Thres; for (ErrSum = 0.0, Sum.re = Sum.im = 0.0, i = 0; i < Len; i++) { Sum.re += Data[i].re; Sum.im += Data[i].im; ErrSum += dspPower(Data[i]); } Lev.re = Sum.re / Len; Lev.im = Sum.im / Len; ErrSum /= Len; ErrSum -= dspPower(Lev); // printf("Len=%d, Lev=[%+7.4f,%+7.4f], ErrSum=%7.4f, dspRMS=%7.4f\n", // Len,Lev.re,Lev.im,ErrSum,sqrt(ErrSum)); Incl = 0; // prev = Len; for (loop = 0; loop < Loops; loop++) { Thres = 0.5 * SelThres * SelThres * ErrSum; for (ErrSum = 0.0, Sum.re = Sum.im = 0.0, Incl = 0, i = 0; i < Len; i++) { Diff = dspPower(Data[i].re - Lev.re, Data[i].im - Lev.im); if (Diff <= Thres) { Sum.re += Data[i].re; Sum.im += Data[i].im; ErrSum += Diff; Incl += 1; } // else printf(" %d",i); } Sum.re /= Incl; Sum.im /= Incl; dLev.re = Sum.re - Lev.re; dLev.im = Sum.im - Lev.im; ErrSum /= Incl; ErrSum -= dspPower(dLev); ErrSum = fabs(ErrSum); Lev.re += dLev.re; Lev.im += dLev.im; // printf("\nLoop #%d, Lev=[%+6.3f,%+6.3f], dLev=[%+6.3f,%+6.3f], ErrSum=%7.4f, dspRMS=%7.4f, Incl=%d\n", // loop, Lev.re,Lev.im, dLev.re,dLev.im, ErrSum,sqrt(ErrSum), Incl); // if(Incl==prev) { loop++; break; } // prev=Incl; } Aver = Lev; dspRMS = sqrt(ErrSum); Sel = Incl; return loop; } // ---------------------------------------------------------------------------- // white noise generator template <class type> void dspWhiteNoise(type &X) { double Rand, dspPower, dspPhase; Rand = ((double)rand() + 1.0) / ((double)RAND_MAX + 1.0); dspPower = sqrt(-2*log(Rand)); Rand = (double)rand() / (double)RAND_MAX; dspPhase = 2 * M_PI * Rand; X = dspPower * cos(dspPhase); } template <class type> void CdspcmpxdspWhiteNoise(Cdspcmpx<type> &X) { double Rand, dspPower, dspPhase; Rand = ((double)rand() + 1.0) / ((double)RAND_MAX + 1.0); dspPower = sqrt(-log(Rand)); Rand = (double)rand() / (double)RAND_MAX; dspPhase = 2 * M_PI* Rand; X.re = dspPower * cos(dspPhase); X.im = dspPower * sin(dspPhase); } // ---------------------------------------------------------------------------- // various window shapes (for the FFT and FIR filters) // these functions are supposed to be called with the argument "dspPhase" // between -PI and +PI. Most (or even all) will return zero for input // euqal -PI or +PI. double dspWindowHanning(double dspPhase); double WindowBlackman2(double dspPhase); // from Freq 5.1 FFT analyzer double dspWindowBlackman3(double dspPhase); // from the Motorola BBS // ---------------------------------------------------------------------------- // FIR shape calculation for a flat response from FreqLow to FreqUpp void dspWinFirI( double LowOmega, double UppOmega, double *Shape, int Len, double (*Window)(double), double shift = 0.0); void WinFirQ( double LowOmega, double UppOmega, double *Shape, int Len, double (*Window)(double), double shift = 0.0); // ---------------------------------------------------------------------------- // convert 16-bit signed or 8-bit unsigned into doubles void dspConvS16todouble(dspS16 *dspS16, double *dbl, int Len, double Gain = 1.0 / 32768.0); int dspConvS16todouble(dspS16 *dspS16, double_buff *dbl, int Len, double Gain = 1.0 / 32768.0); void dspConvdoubleTodspS16(double *dbl, dspS16 *dspS16, int Len, double Gain = 32768.0); inline int dspConvdoubleTodspS16(double_buff *dbl, dspS16_buff *dspS16, double Gain = 32768.0) { int err = dspS16->EnsureSpace(dbl->Len); if (err) return -1; dspConvdoubleTodspS16(dbl->Data, dspS16->Data, dbl->Len, Gain); dspS16->Len = dbl->Len; return 0; } void dspConvU8todouble(unsigned char *U8, double *dbl, int Len, double Gain = 1.0 / 128.0); int dspConvU8todouble(unsigned char *U8, double_buff *dbl, int Len, double Gain = 1.0 / 128.0); // ---------------------------------------------------------------------------- // other converts void dspConvCmpxTodspPower(dspCmpx *Inp, int InpLen, double *Out); int dspConvCmpxTodspPower(dspCmpx_buff *Input, double_buff *Output); void dspConvCmpxTodspAmpl(dspCmpx *Inp, int InpLen, double *Out); int dspConvCmpxTodspAmpl(dspCmpx_buff *Input, double_buff *Output); void dspConvCmpxTodspPhase(dspCmpx *Inp, int InpLen, double *Out); int dspConvCmpxTodspPhase(dspCmpx_buff *Input, double_buff *Output); // ---------------------------------------------------------------------------- // Pulse noise limiter class dspPulseLimiter { public: dspPulseLimiter(); ~dspPulseLimiter(); void Free(void); int Preset(int TapLen, double Limit=4.0); int Process(double *Inp, int InpLen, double *Out); int Process(double_buff *Input); double_buff Output; double dspRMS; private: int Len; double Thres; double *Tap; int Ptr; double PwrSum; }; // ---------------------------------------------------------------------------- // Signal level monitor class dspLevelMonitor { public: dspLevelMonitor(); ~dspLevelMonitor(); int Preset(double Integ, double Range = 0.75); int Process(double *Inp, int Len); int Process(double_buff *Input); double dspRMS; double OutOfRange; private: double PwrMid,PwrOut; double OutOfRangeMid; double MaxSqr; double W1, W2, W5; }; // ---------------------------------------------------------------------------- // Automatic Gain/Level Control for the Mixer class dspMixerAutoLevel { public: dspMixerAutoLevel(); // ~dspMixerAutoLevel(); int Process(double *Inp, int InpLen); int Process(double_buff *Inp) { return Process(Inp->Data, Inp->Len); } public: int IntegLen; // mean dspPower integration time [samples] double MinMS; // minimum acceptable dspAverage dspPower double MaxMS; // maximum acceptable dspAverage dspPower int PeakHold; // level holding time after a peak [samples] int MinHold; // minimal time between changing the mixer level [samples] int AdjStep; // mixer level adjusting step int MinLevel; // mimimum allowed mixer level int MaxLevel; // maximum allowed mixer level double AvedspRMS; // dspAverage dspPower of the input signal int Hold; // time counter for holding levels int Level; // actual mixer level }; // ---------------------------------------------------------------------------- // Two-element IIR low pass filter struct dspLowPass2elem { double Mid, Out; }; struct dspLowPass2weight { double W1, W2, W5; }; // first calculate the coefficiants W1,W2 and W5 for given integration time template <class typeLen, class typeW> inline void dspLowPass2Coeff(typeLen IntegLen, typeW &W1, typeW &W2, typeW &W5) { W1 = 1.0 / IntegLen; W2 = 2.0 / IntegLen; W5 = 5.0 / IntegLen; } template <class typeLen> inline void dspLowPass2Coeff(typeLen IntegLen, dspLowPass2weight &Weight) { Weight.W1 = 1.0 / IntegLen; Weight.W2 = 2.0 / IntegLen; Weight.W5 = 5.0 / IntegLen; } // then you can process samples template <class typeInp, class typeOut, class typeW> inline void dspLowPass2( typeInp Inp, typeOut &Mid, typeOut &Out, typeW W1, typeW W2, typeW W5) { double Sum, Diff; Sum = Mid + Out; Diff = Mid-Out; Mid += W2 * Inp - W1 * Sum; Out += W5 * Diff; } template <class typeInp, class typeW> inline void dspLowPass2( typeInp Inp, dspLowPass2elem &Elem, typeW W1, typeW W2, typeW W5) { double Sum, Diff; Sum = Elem.Mid + Elem.Out; Diff = Elem.Mid - Elem.Out; Elem.Mid += W2 * Inp - W1 * Sum; Elem.Out += W5 * Diff; } template <class typeInp> inline void dspLowPass2( typeInp Inp, dspLowPass2elem &Elem, dspLowPass2weight &Weight) { double Sum, Diff; Sum = Elem.Mid + Elem.Out; Diff = Elem.Mid - Elem.Out; Elem.Mid += Weight.W2 * Inp - Weight.W1 * Sum; Elem.Out += Weight.W5 * Diff; } void dspLowPass2( dspCmpx *Inp, dspCmpx *Mid, dspCmpx *Out, double W1, double W2, double W5); // ---------------------------------------------------------------------------- // periodic low pass class dspPeriodLowPass2 { public: dspPeriodLowPass2(); ~dspPeriodLowPass2(); void Free(void); int Preset(int Period, double IntegLen); int Process(double Inp, double &Out); int Process(double *Inp, int InpLen, double *Out); int Process(double_buff *Input); double_buff Output; private: int Len; double *TapMid,*TapOut; int TapPtr; double W1,W2,W5; }; // ---------------------------------------------------------------------------- // a simple dspDelay template <class type> class dspDelay { public: dspDelay(); ~dspDelay(); void Free(void); int Preset(int len); void Process(type *Inp, int InpLen, type *Out); int Process(dspSeq<type> *Input); dspSeq<type> Output; private: int Len; type *Tap; int TapPtr; }; template <class type> dspDelay<type>::dspDelay() { Tap = NULL; } template <class type> dspDelay<type>::~dspDelay() { delete [] Tap; } template <class type> void dspDelay<type>::Free(void) { delete [] Tap; Tap = NULL; } template <class type> int dspDelay<type>::Preset(int dspDelayLen) { Len = dspDelayLen; if (dspRedspAllocArray(&Tap,Len)) return -1; dspClearArray(Tap,Len); TapPtr = 0; return 0; } template <class type> void dspDelay<type>::Process(type *Inp, int InpLen, type *Out) { int i, batch; for (i = 0; i < InpLen; ) { for (batch = dspIntmin(InpLen - i, Len - TapPtr), i += batch; batch; batch--) { (*Out++) = Tap[TapPtr]; Tap[TapPtr++] = (*Inp++); } if (TapPtr >= Len) TapPtr = 0; } } template <class type> int dspDelay<type>::Process(dspSeq<type> *Input) { int err = Output.EnsureSpace(Input->Len); if (err) return -1; Process(Input->Data, Input->Len, Output.Data); Output.Len = Input->Len; return 0; } // ---------------------------------------------------------------------------- // dspDelayLine, like dspDelay but more flexible // The idea is that we hold addressable history of at least MaxdspDelay // samples. // After each input batch is processed, the InpPtr points to the first sample // of this batch and we can address samples backwards upto MaxdspDelay. // For more optimal performace we allocate more RAM than just for MaxdspDelay. // Infact the allocated size (MaxSize) should be at least // MaxdspDelay plus the largest expected input length. template <class type> class dspDelayLine { public: dspDelayLine(); ~dspDelayLine(); void Free(void); int Preset(int MaxdspDelay, int MaxSize = 0); int Process(type *Inp, int Len); int Process(dspSeq<type> *Input); type *Line; // line storage int dspDelay; // how many (at least) backward samples are stored int LineSize; // allocated size int DataLen; // length of the valid data type *InpPtr; // first sample for the most recent processed batch int InpLen; // number of samples for the most recent input }; template <class type> dspDelayLine<type>::dspDelayLine() { Line = NULL; } template <class type> dspDelayLine<type>::~dspDelayLine() { delete [] Line; } template <class type> void dspDelayLine<type>::Free(void) { delete [] Line; Line = NULL; } template <class type> int dspDelayLine<type>::Preset(int MaxdspDelay, int MaxSize) { LineSize = MaxSize; if (LineSize < (2 * MaxdspDelay)) LineSize = 2 * MaxdspDelay; DataLen = MaxdspDelay; dspDelay = MaxdspDelay; if (dspRedspAllocArray(&Line, LineSize)) return -1; dspClearArray(Line, LineSize); InpPtr = Line + DataLen; InpLen = 0; return 0; } template <class type> int dspDelayLine<type>::Process(type *Inp, int Len) { if ((DataLen + Len) > LineSize) { dspMoveArray(Line, Line + DataLen - dspDelay, dspDelay); DataLen = dspDelay; } if ((DataLen + Len) > LineSize) return -1; dspCopyArray(Line + DataLen, Inp, Len); InpPtr = Line + DataLen; InpLen = Len; DataLen += Len; return 0; } template <class type> int dspDelayLine<type>::Process(dspSeq<type> *Input) { return Process(Input->Data, Input->Len); } // ---------------------------------------------------------------------------- // Low pass "moving box" FIR filter // very unpure spectral response but CPU complexity very low // and independent on the integration time class dspBoxFilter { public: dspBoxFilter(); ~dspBoxFilter(); void Free(void); int Preset(int BoxLen); int Process(double Inp, double &Out); int Process(double *Inp, int InpLen, double *Out); int Process(double_buff *Input); void Recalibrate(); double_buff Output; private: int Len; double *Tap; int TapPtr; double Sum; }; class dspCmpxBoxFilter { public: dspCmpxBoxFilter(); ~dspCmpxBoxFilter(); void Free(void); int Preset(int BoxLen); int Process(dspCmpx *Inp, int InpLen, dspCmpx *Out); void Recalibrate(); int Process(dspCmpx_buff *Input); dspCmpx_buff Output; private: int Len; dspCmpx *Tap; int TapPtr; dspCmpx Sum; }; // ---------------------------------------------------------------------------- // FIR filter with a given shape class dspFirFilter { public: dspFirFilter(); ~dspFirFilter(); void Free(void); int Preset(int FilterLen, double *FilterShape = (double*)NULL); int Process(double *Inp, int InpLen, double *Out); int Process(double_buff *Input); // Response(double Freq, double *Resp); int ComputeShape(double LowOmega, double UppOmega, double (*Window)(double)); // UseExternShape(double *shape); double_buff Output; private: int Len; // Tap/Shape length double *Shape; // Response shape int ExternShape; // that we are using an externally provided shape double *Tap; int TapPtr; }; // ---------------------------------------------------------------------------- // a pair of FIR filters. quadrature split, decimate // the decimation rate must be integer class dspQuadrSplit { public: dspQuadrSplit(); ~dspQuadrSplit(); void Free(void); int Preset( int FilterLen, double *FilterShape_I, double *FilterShape_Q, int DecimateRate); int ComputeShape(double LowOmega, double UppOmega, double (*Window)(double)); // int Process(double *Inp, int InpLen, // double *OutI, double *OutQ, int MaxOutLen, int *OutLen); // int Process(double *Inp, int InpLen, // dspCmpx *Out, int MaxOutLen, int *OutLen); int Process(double_buff *Input); dspCmpx_buff Output; private: int Len; double_buff Tap; double *ShapeI, *ShapeQ; int ExternShape; int Rate; }; // ---------------------------------------------------------------------------- // reverse of dspQuadrSplit: interpolates and combines the I/Q // back into 'real' signal. class dspQuadrComb { public: dspQuadrComb(); ~dspQuadrComb(); void Free(void); int Preset( int FilterLen, double *FilterShape_I, double *FilterShape_Q, int DecimateRate); int ComputeShape(double LowOmega, double UppOmega, double (*Window)(double)); int Process(dspCmpx_buff *Input); double_buff Output; private: int Len; double *Tap; int TapPtr; double *ShapeI, *ShapeQ; int ExternShape; int Rate; }; // ---------------------------------------------------------------------------- // complex mix with an oscilator (carrier) // here we could avoid computing sine/cos at every sample class dspCmpxMixer { public: dspCmpxMixer(); // ~dspCmpxMixer(); void Free(void); int Preset(double CarrierOmega); int ProcessFast( double *InpI, double *InpQ, int InpLen, double *OutI, double *OutQ); int Process(dspCmpx *Inp, int InpLen, dspCmpx *Out); int ProcessFast(dspCmpx *Inp, int InpLen, dspCmpx *Out); int Process(dspCmpx_buff *Input); int ProcessFast(dspCmpx_buff *Input); dspCmpx_buff Output; public: double dspPhase, Omega; }; // ---------------------------------------------------------------------------- // FM demodulator (dspPhase rotation speed-meter) class dspFMdemod { public: dspFMdemod(); // ~dspFMdemod(); int Preset(double CenterOmega); int Process(double *InpI, double *InpQ, int InpLen, double *Out); int Process(dspCmpx *Inp, int InpLen, double *Out); int Process(dspCmpx_buff *Input); double_buff Output; private: double PrevdspPhase; public: double RefOmega; }; // ---------------------------------------------------------------------------- // Rate converter - real input/output, linear interpolation // expect large error when high frequency components are present // thus the best place to convert rates is after a low pass filter // of a demodulator. class dspRateConvLin { public: dspRateConvLin(); // ~dspRateConvLin(); void SetOutVsInp(double OutVsInp); void SetInpVsOut(double InpVsOut); int Process(double_buff *InpBuff); double_buff Output; private: double OutStep, OutdspPhase; double PrevSample; }; // ---------------------------------------------------------------------------- // Rate converter - real input/output, quadratic interpolation // similar limits like for RateConv1 class dspRateConvQuadr { public: dspRateConvQuadr(); // ~dspRateConvQuadr(); void SetOutVsInp(double OutVsInp); void SetInpVsOut(double InpVsOut); int Process(double *Inp, int InpLen, double *Out, int MaxOutLen, int *OutLen); int Process(double_buff *InpBuff); double_buff Output; private: double OutStep, OutdspPhase; double Tap[4]; int TapPtr; }; // ---------------------------------------------------------------------------- // Rate converter, real input/output, // bandwidth-limited interpolation, several shifted FIR filters class dspRateConvBL { public: dspRateConvBL(); ~dspRateConvBL(); void Free(void); int Preset(int FilterLen, double *FilterShape[], int FilterShapeNum); int ComputeShape(double LowOmega, double UppOmega, double (*Window)(double)); void SetOutVsInp(double OutVsInp); void SetInpVsOut(double InpVsOut); int Process(double_buff *Input); int ProcessLinI(double_buff *Input); double_buff Output; private: double OutStep, OutdspPhase; int Len; double *Tap; int TapSize; double **Shape; int ShapeNum; int ExternShape; }; // ---------------------------------------------------------------------------- // Sliding window (for FFT input) class dspCmpxSlideWindow { public: dspCmpxSlideWindow(); ~dspCmpxSlideWindow(); void Free(void); int Preset(int WindowLen, int SlideDist, double *WindowShape=(double*)NULL); int SetWindow(double (*NewWindow)(double dspPhase), double Scale=1.0); int Process(dspCmpx_buff *Input); dspCmpx_buff Output; private: int Len; // Window length dspCmpx *Buff; // storage int Dist; // distance between slides int Ptr; // data pointer in Buff double *Window; // window shape int ExternWindow; }; // ---------------------------------------------------------------------------- // Overlapping window (for IFFT output) class dspCmpxOverlapWindow { public: dspCmpxOverlapWindow(); ~dspCmpxOverlapWindow(); void Free(void); int Preset(int WindowLen, int SlideDist, double *WindowShape=(double*)NULL); int SetWindow(double (*NewWindow)(double dspPhase), double Scale=1.0); void Process(dspCmpx *Inp, dspCmpx *Out); int ProcessSilence(int Slides=1); int Process(dspCmpx_buff *Input); int Process(dspCmpx *Input); // int Process(dspCmpx_buff *Input); dspCmpx_buff Output; private: int Len; // Window length dspCmpx *Buff; // storage int Dist; // distance between slides double *Window; // window shape int ExternWindow; }; // ---------------------------------------------------------------------------- // FFT dspPhase corrector class dspFFT_TimeShift { public: dspFFT_TimeShift(); ~dspFFT_TimeShift(); void Free(void); int Preset(int FFTlen, int Backwards=0); int Process(dspCmpx *Data, int Time); private: int Len; // FFT length int LenMask; // length-1 for pointer wrapping dspCmpx *FreqTable; // sin/cos table int dspPhase; }; // ---------------------------------------------------------------------------- // bit synchronizer, the bit rate is the input rate divided by four class dspDiffBitSync4 { public: dspDiffBitSync4(int IntegBits);\ ~dspDiffBitSync4(); void Free(void); int Process(double *Inp, int InpLen, double *BitOut, double *IbitOut, int MaxOutLen, int *OutLen); double GetSyncDriftRate(); // get aver. sync. drift double GetSyncConfid(); private: // eg. 0.01 means 1 bit drift per 100 bits double *InpTap; int InpTapLen, InpTapPtr; // buffer tap, length and pointer int IntegLen; // integrate tdspIntming over that many bits double W1,W2,W5; // weights for the two-stage IIR lopass filter double DiffInteg0[4], DiffInteg[4]; // signal diff. integrators int DiffTapPtr; // integrator and bit-sdspAmpling pointer int BitPtr; double SyncdspPhase; // sync. pointer/dspPhase double SyncDrift0,SyncDrift; // low pass filter for the sync. drift rate double SyncConfid; }; // ---------------------------------------------------------------------------- // bit slicer, SNR/Tune meter class dspBitSlicer { public: dspBitSlicer(int IntegBits); ~dspBitSlicer(); int Process(double *Bits, double *IBits, int InpLen, double *OutBits); double GetSigToNoise(); double GetdspAmplAsym(); double GetTimeAsym(); private: int IntegLen,TapLen; double W1,W2,W5; double Sum0[2], Sum[2]; double SumSq0[2], SumSq[2]; double TimeAsym0, TimeAsym; double dspAmplAsym0, dspAmplAsym; double Noise[2]; double OptimThres; double *Tap; int TapPtr; double PrevBit, PrevIBit; }; // ---------------------------------------------------------------------------- // The decoder for the HDLC frames, // makes no AX.25 CRC check, only the length in bytes against MinLen and MaxLen // however it does not pass frames with non-complete bytes. class dspHDLCdecoder { public: dspHDLCdecoder(int minlen, int maxlen, int diff, int invert, int chan, int (*handler)(int, char *, int)); ~dspHDLCdecoder(); int Process(double *Inp, int InpLen); public: int AllFrameCount; int BadFrameCount; private: int MinLen,MaxLen; int RxDiff,RxInvert; int ChanId; int (*FrameHandler)(int ChanId, char *Frame, int Len); char *Buff; int Len,PrevLev; unsigned int ShiftReg; int BitCount,Count1s; }; // ---------------------------------------------------------------------------- // AX.25 CRC short unsigned int dspAX25CRC(char *Data, int Len); // ---------------------------------------------------------------------------- // check if the given number (an integer) is a dspPower of 2 template <class type> int dspPowerOf2(type I) { int c; if (I <= 0) return 0; for (c = 0; I != 0; I >>= 1) c += I & 1; return c == 1; } // ---------------------------------------------------------------------------- // radix-2 FFT class dsp_r2FFT { public: // size must a dspPower of 2: 2,4,8,16,32,64,128,256,... dsp_r2FFT(); ~dsp_r2FFT(); void Free(void); // preset tables for given processing size int Preset(int size); // scramble/unscramble input void Scramble(dspCmpx x[]); // apply input window // separate the result of a two real channels FFT void SeparTwoReals(dspCmpx Buff[], dspCmpx Out0[], dspCmpx Out1[]); // join spectra of two real channels void JoinTwoReals(dspCmpx Inp0[], dspCmpx Inp1[], dspCmpx Buff[]); // core process: the classic tripple loop of butterflies void CoreProc(dspCmpx x[]); // complex FFT process in place, includes unscrambling inline void ProcInPlace(dspCmpx x[]) { Scramble(x); CoreProc(x); } // define the FFT window and input/output scales (NULL => rectangular window) public: int Size; // FFT size int *BitRevIdx; // Bit-reverse indexing table for data (un)scrambling dspCmpx *Twiddle; // Twiddle factors (sine/cos values) private: // double *Window; // window shape (NULL => rectangular window // double WinInpScale, WinOutScale; // window scales on input/output private: // classic radix-2 butterflies inline void FFTbf(dspCmpx &x0, dspCmpx &x1, dspCmpx &W); // special 2-elem. FFT for the first pass inline void FFT2(dspCmpx &x0, dspCmpx &x1); // special 2-elem. FFT for the second pass inline void FFT4(dspCmpx &x0, dspCmpx &x1, dspCmpx &x2, dspCmpx &x3); }; // --------------------------------------------------------------------------- // Sliding window FFT for spectral analysis (e.g. SETI) // input: real-valued time-domain signal, // output: complex-valued Fourier Transform // // We use a little trick here to process two real-valued FFT // in one go using the complex FFT engine. // This cuts the CPU but makes the input->output dspDelay longer. class dspSlideWinFFT { public: dspSlideWinFFT(); ~dspSlideWinFFT(); void Free(); int Preset(int size, int step, double *window); int Preset(int size, int step, double (*NewWindow)(double dspPhase), double Scale=1.0); int SetWindow(double *window); int SetWindow(double (*NewWindow)(double dspPhase), double Scale=1.0); int Process(double_buff *Input); dsp_r2FFT FFT; // FFT engine dspCmpx_buff Output; // output buffer int Size; int SizeMask; // FFT size, size mask for pointer wrapping int Dist; int Left; // distance between slides, samples left before the next slide int Slide; // even/odd slide private: double *SlideBuff; int SlidePtr; // sliding window buffer, pointer double *Window; int ExternWindow; // window shape dspCmpx *FFTbuff; // FFT buffer }; // --------------------------------------------------------------------------- // Overlapping window Inverse FFT to convert spectra into time-domain signal class dspOvlapWinIFFT { public: dspOvlapWinIFFT(); ~dspOvlapWinIFFT(); void Free(void); int Preset(int size, int step, double *window); int Preset(int size, int step, double (*NewWindow)(double dspPhase), double Scale=1.0); int SetWindow(double *window); int SetWindow(double (*NewWindow)(double dspPhase), double Scale=1.0); int Process(dspCmpx *Input); dsp_r2FFT FFT; // FFT engine double_buff Output; // output buffer int Size; int SizeMask; // FFT size, size mask for pointer wrapping int Dist; // distance between slides int Slide; private: dspCmpx *Spectr[2]; dspCmpx *FFTbuff; // FFT buffer double *Window; int ExternWindow; // window shape double *OvlapBuff; int OvlapPtr; }; // --------------------------------------------------------------------------- // Sliding window FFT for spectral processing (e.g. de-noising) // input: real-valued signal // in the middle you are given a chance to process // the complex-valued Fourier Transform (SpectraProc() routine). // output: real-valued signal // If you don't touch the spectra in SpectralProc() // the output will be an exact copy (only dspDelayed) of the input. class dspSlideWinFFTproc { public: dspSlideWinFFTproc(); ~dspSlideWinFFTproc(); void Free(void); int Preset(int size, int step, void (*proc)(dspCmpx *Spectra, int Len), double *window); int Preset(int size, int step, void (*proc)(dspCmpx *Spectra, int Len), double (*NewWindow)(double dspPhase), double Scale=0.0); int SetWindow(double *window); int SetWindow(double (*NewWindow)(double dspPhase), double Scale=0.0); int Process(double_buff *Input); dsp_r2FFT FFT; double_buff Output; int Size; int SizeMask; int Dist; int Left; int Slide; private: double *SlideBuff; int SlidePtr; double *Window; int ExternWindow; dspCmpx *FFTbuff; dspCmpx *Spectr[2]; void (*SpectraProc)(dspCmpx *Spectra, int Len); double *OvlapBuff; int OvlapPtr; }; // --------------------------------------------------------------------------- // Walsh (Hadamard ?) transform. void dspWalshTrans(double *Data, int Len); void dspWalshInvTrans(double *Data, int Len); // ---------------------------------------------------------------------------
39,261
C++
.h
1,232
29.931006
107
0.647056
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,468
pkg.h
w1hkj_fldigi/src/include/pkg.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef PKG_H_ #define PKG_H_ #include <config.h> #if BUILD_FLDIGI # define PACKAGE_AUTHORS FLDIGI_AUTHORS #else # define PACKAGE_AUTHORS FLARQ_AUTHORS # undef PACKAGE # define PACKAGE "flarq" # undef PACKAGE_NAME # define PACKAGE_NAME "flarq" # undef PACKAGE_TARNAME # define PACKAGE_TARNAME "flarq" # undef PACKAGE_VERSION # define PACKAGE_VERSION FLARQ_VERSION # undef PACKAGE_STRING # define PACKAGE_STRING PACKAGE_TARNAME " " PACKAGE_VERSION # undef VERSION # define VERSION PACKAGE_VERSION #endif #endif
1,417
C++
.h
40
34.325
79
0.670794
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,469
raster.h
w1hkj_fldigi/src/include/raster.h
// ---------------------------------------------------------------------------- // raster.h, Raster scan Widget for display of fuzzy modes // // Copyright (C) 2006-2008 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _RASTER_H #define _RASTER_H #include <FL/Fl_Widget.H> #include "feld.h" class Raster : public Fl_Widget { public: private: unsigned char *vidbuf; int width; int height; int col; int Nrows; int rowheight; int rhs; int space; int vidpos; // column start position int numcols; // number of columns to redraw int yp; bool marquee; bool _reverse; public: Raster(int X, int Y, int W, int H, int rh = 2, bool rv = false); ~Raster(); void draw(); int handle(int); void resize(int x, int y, int w, int h); unsigned char *buffer() { return vidbuf;} int size() { return width * height;} int change_rowheight( int rh ); void data(int data[], int len); void clear(); void show() { Fl_Widget::show();} void hide() { Fl_Widget::hide();} void set_marquee(bool val) { marquee = val; } bool get_marquee() { return marquee; } void reverse(bool val) { _reverse = val; } }; #endif
1,852
C++
.h
59
29.847458
79
0.650084
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,470
confdialog.h
w1hkj_fldigi/src/include/confdialog.h
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #ifndef confdialog_h #define confdialog_h #include <FL/Fl.H> #include "font_browser.h" #include "globals.h" #include "modem.h" #include "configuration.h" #include "combo.h" #include "flinput2.h" #include "flslider2.h" #include "flmisc.h" extern Fl_Double_Window *dlgConfig; extern Mode_Browser* mode_browser; struct CONFIG_PAGE {Fl_Group *grp; std::string label; CONFIG_PAGE(Fl_Group *_grp = 0, std::string _lbl = "") { grp = _grp; label = _lbl; } ~CONFIG_PAGE() { if (grp) delete grp; } }; extern std::vector<CONFIG_PAGE *> config_pages; void SelectItem_CB(Fl_Widget *w); void cbWaterfallFontBrowser(Fl_Widget*, void*); void cbViewerFontBrowser(Fl_Widget*, void*); void cbFreqControlFontBrowser(Fl_Widget*, void*); void set_qrzxml_buttons(Fl_Button* b); void set_qrzweb_buttons(Fl_Button* b); class Fl_File_Chooser ; void createConfig(); #include <FL/Fl_Double_Window.H> #include <FL/Fl_Group.H> #include <FL/Fl_Tree.H> extern Fl_Tree *tab_tree; #include <FL/Fl_Button.H> extern Fl_Button *btn_collapse_tab_tree; extern Fl_Button *btnSpotColor; extern Fl_Button *btnRevColor; extern Fl_Button *btnTuneColor; extern Fl_Button *btnRxIDColor; extern Fl_Button *btnLkColor; extern Fl_Button *btnSql1Color; extern Fl_Button *btnXmtColor; extern Fl_Button *btnRxIDwideColor; extern Fl_Button *btnAfcColor; extern Fl_Button *btnSql2Color; extern Fl_Button *btnTxIDColor; #include <FL/Fl_Box.H> extern Fl_Box *spotcolor; extern Fl_Box *revcolor; extern Fl_Box *tunecolor; extern Fl_Box *rxidcolor; extern Fl_Box *lockcolor; extern Fl_Box *sql1color; extern Fl_Box *rxidcolorwide; extern Fl_Box *xmtcolor; extern Fl_Box *afccolor; extern Fl_Box *sql2color; extern Fl_Box *txidcolor; extern Fl_Button *btn_default_btn_color; extern Fl_Box *default_btn_color; extern Fl_Box *FDdisplay; extern Fl_Button *btn_freq_control_font; extern Fl_Button *btnBackgroundColor; extern Fl_Button *btnForegroundColor; extern Fl_Button *btnFD_SystemColor; extern Fl_Button *btnSmeter_bg_color; extern Fl_Button *btnSmeter_scale_color; extern Fl_Button *btnSmeter_meter_color; extern Fl_Button *btnPWR_bg_color; extern Fl_Button *btnPWR_scale_color; extern Fl_Button *btnPWR_meter_Color; extern Fl_ListBox *listboxPWRselect; #include <FL/Fl_Check_Button.H> extern Fl_Check_Button *btnUseGroupColors; extern Fl_Button *btnGroup1; extern Fl_Button *btnGroup2; extern Fl_Button *btnGroup3; extern Fl_Button *btnFkeyDEfaults; extern Fl_Button *btnMacroBtnFont; #include <FL/Fl_Output.H> extern Fl_Output *LOGGINGdisplay; extern Fl_Button *btnLOGGING_color; extern Fl_Button *btn_LOGGING_font; extern Fl_Button *btnLOGGINGdefault_colors_font; extern Fl_Output *LOGBOOKdisplay; extern Fl_Button *btnLOGBOOK_color; extern Fl_Button *btn_LOGBOOK_font; extern Fl_Button *btnLOGBOOKdefault_colors_font; extern Fl_Output *DXC_display; extern Fl_Button *btn_DXC_font; extern Fl_Button *btnDXCdefault_colors_font; extern Fl_Button *btn_DXC_even_lines; extern Fl_Button *btn_DXC_odd_lines; #include <FL/Fl_Input.H> extern Fl_Input *StreamText; extern Fl_Button *btnDXcolor; extern Fl_Button *btnDXfont; extern Fl_Button *btnDXalt_color; extern Fl_Button *btnDXdefault_colors_font; #include "fl_digi.h" extern Fl_ListBox *listbox_charset_status; extern Fl_Input *RxText; extern Fl_Button *btnRxColor; extern Fl_Button *btnTxColor; extern Fl_Input *TxText; extern Fl_Button *btnRxFont; extern Fl_Button *btnTxFont; extern Fl_Input *MacroText; extern Fl_Button *btnMacroEditFont; extern Fl_Button *btnXMIT; extern Fl_Button *btnCTRL; extern Fl_Button *btnSKIP; extern Fl_Button *btnALTR; extern Fl_Button *btnSEL; extern Fl_Button *btnNoTextColor; extern Fl_Button *btnTextDefaults; extern Fl_Check_Button *btn_show_all_codes; extern Fl_Button *btnTabColor; extern Fl_Button *btnTabDefaultColor; extern Fl_Box *lowcolor; extern Fl_Button *btnLowSignal; extern Fl_Box *normalcolor; #include <FL/Fl_Counter.H> extern Fl_Counter *cnt_normal_signal_level; extern Fl_Button *btnNormalSignal; extern Fl_Box *highcolor; extern Fl_Counter *cnt_high_signal_level; extern Fl_Button *btnHighSignal; extern Fl_Box *overcolor; extern Fl_Counter *cnt_over_signal_level; extern Fl_Button *btnOverSignal; #include <FL/Fl_Progress.H> #include "vumeter.h" extern vumeter *sig_vumeter; extern Fl_Button *btn_default_signal_levels; #include "contest.h" extern Fl_ListBox *listbox_contest; extern Fl_ListBox *listbox_QP_contests; extern Fl_Input2 *inp_contest_notes; #include <FL/Fl_Light_Button.H> extern Fl_Light_Button *btnDupCheckOn; extern Fl_Check_Button *btnDupBand; extern Fl_Check_Button *btnDupMode; extern Fl_Check_Button *btnDupTimeSpan; #include <FL/Fl_Color_Chooser.H> extern Fl_Button *btnDupColor; extern Fl_Button *btnPossibleDupColor; extern Fl_Check_Button *btnDupXchg1; extern Fl_Check_Button *btnDupState; extern Fl_Value_Input2 *nbrTimeSpan; extern Fl_Input2 *inpSend1; extern Fl_Check_Button *btn599; extern Fl_Check_Button *btnCutNbrs; extern Fl_Value_Input2 *nbrContestStart; extern Fl_Value_Input2 *nbrContestDigits; extern Fl_Check_Button *btnUseLeadingZeros; extern Fl_Button *btnResetSerNbr; extern Fl_Input2 *inp_my_FD_call; extern Fl_Input2 *inp_my_FD_section; extern Fl_Input2 *inp_my_FD_class; extern Fl_Input2 *inp_my_SCR_class; extern Fl_Input2 *inp_my_JOTA_troop; extern Fl_Input2 *inp_my_JOTA_scout; extern Fl_Group *sld; extern Fl_Check_Button *btnCWID; extern Fl_Value_Slider2 *sldrCWIDwpm; extern Fl_Button *bCWIDModes; extern Fl_Check_Button *chkRSidNotifyOnly; extern Fl_Button *bRSIDRxModes; extern Fl_Check_Button *chkRSidWideSearch; extern Fl_Check_Button *chkRSidMark; extern Fl_Check_Button *chkRSidAutoDisable; extern Fl_ListBox *listbox_rsid_errors; extern Fl_Check_Button *chkRSidShowAlert; extern Fl_Check_Button *chkRetainFreqLock; extern Fl_Check_Button *chkDisableFreqChange; extern Fl_Check_Button *chk_RSID_EOT; extern Fl_Counter *val_RSIDsquelch; extern Fl_Counter *val_pretone; extern Fl_Button *bRSIDTxModes; extern Fl_Check_Button *btn_post_rsid; extern Fl_Check_Button *btnsendid; extern Fl_Check_Button *btnsendvideotext; extern Fl_Input2 *valVideotext; extern Fl_Check_Button *chkID_SMALL; extern Fl_Value_Slider2 *sldrVideowidth; extern Fl_Check_Button *btn_vidlimit; extern Fl_Check_Button *btn_vidmodelimit; extern Fl_Button *bVideoIDModes; #include "maclogger.h" extern Fl_Check_Button *btnConnectToMaclogger; extern Fl_Check_Button *btn_capture_maclogger_radio; extern Fl_Check_Button *btn_capture_maclogger_log; extern Fl_Check_Button *btn_capture_maclogger_lookup; extern Fl_Check_Button *btn_capture_maclogger_spot_tune; extern Fl_Check_Button *btn_capture_maclogger_spot_report; extern Fl_Check_Button *btn_enable_maclogger_log; #include <FL/Fl_Text_Display.H> extern Fl_Text_Display *txt_UDP_data; extern Fl_Output *txt_maclogger_log_filename; extern Fl_Check_Button *btn_maclogger_spot_rx; extern Fl_Text_Display *txt_N3FJP_data; extern Fl_Input2 *txt_N3FJP_ip_address; extern Fl_Input2 *txt_N3FJP_ip_port_no; extern Fl_Button *btn_default_N3FJP_ip; extern Fl_Check_Button *btn_enable_N3FJP_log; extern Fl_Check_Button *btn_connect_to_n3fjp; extern Fl_Box *box_n3fjp_connected; extern Fl_Check_Button *btn_N3FJP_sweet_spot; extern Fl_Check_Button *btn_N3FJP_modem_carrier; extern Fl_Check_Button *btn_enable_N3FJP_RIGTX; #include <FL/Fl_Round_Button.H> extern Fl_Round_Button *btnQRZWEBnotavailable; extern Fl_Round_Button *btnQRZonline; extern Fl_Round_Button *btnHAMCALLonline; extern Fl_Round_Button *btnHamQTHonline; extern Fl_Round_Button *btnCallookOnline; extern Fl_Input2 *inp_qrzurl; extern Fl_Input2 *inp_hamcallurl; extern Fl_Input2 *inp_hamqthurl; extern Fl_Input2 *inp_callook_url; extern Fl_Round_Button *btnQRZXMLnotavailable; extern Fl_Round_Button *btnQRZcdrom; extern Fl_Round_Button *btnQRZsub; extern Fl_Round_Button *btnHamcall; extern Fl_Round_Button *btnHamQTH; extern Fl_Round_Button *btnCALLOOK; extern Fl_Input2 *txtQRZpathname; extern Fl_Input2 *inpQRZusername; extern Fl_Input2 *inpQRZuserpassword; extern Fl_Button *btnQRZpasswordShow; extern Fl_Check_Button *btn_notes_address; extern Fl_Check_Button *btn_clear_notes; extern Fl_Input2 *inpEQSL_www_url; extern Fl_Input2 *inpEQSL_id; extern Fl_Input2 *inpEQSL_pwd; extern Fl_Button *btnEQSL_pwd_show; extern Fl_Input2 *inpEQSL_nick; extern void cb_btn_verify_eqsl(Fl_Button*, void*); extern Fl_Button *btn_verify_eqsl; extern Fl_Check_Button *btn_send_when_logged; extern Fl_Check_Button *btn_send_datetime_off; extern Fl_Check_Button *btn_show_eqsl_delivery; extern Fl_Input2 *txt_eqsl_default_message; extern Fl_Box *eqsl_txt1; extern Fl_Box *eqsl_txt2; extern Fl_Box *eqsl_txt3; extern Fl_Input2 *txt_lotw_pathname; extern Fl_Input2 *inpLOTW_pwd; extern Fl_Check_Button *btn_submit_lotw_password; extern Fl_Input2 *inpLOTW_location; extern Fl_Button *btn_select_lotw; extern Fl_Check_Button *btn_lotw_quiet_mode; extern Fl_Check_Button *btn_submit_lotw; extern Fl_Check_Button *btn_show_lotw_delivery; extern Fl_Button *btn_export_lotw; extern Fl_Button *btn_review_lotw; extern Fl_Button *btn_send_lotw; extern Fl_Button *btnLOTW_pwd_show; extern void cb_btn_verify_lotw(Fl_Button*, void*); extern Fl_Button *btn_verify_lotw; extern void cb_btn_view_unmatched(Fl_Button*, void*); extern Fl_Button *btn_view_unmatched; extern Fl_Counter *cnt_tracefile_timeout; extern Fl_Check_Button *btnNagMe; extern Fl_Check_Button *btnClearOnSave; extern Fl_Check_Button *btnCallUpperCase; extern Fl_Check_Button *btnAutoFillQSO; extern Fl_Check_Button *btnDateTimeSort; extern Fl_Check_Button *btndate_time_force; extern Fl_Check_Button *btnRSTindefault; extern Fl_Check_Button *btnRSTdefault; #include "dxcc.h" extern Fl_Input2 *txt_cty_dat_pathname; extern Fl_Button *btn_select_cty_dat; extern Fl_Button *btn_default_cty_dat; extern Fl_Button *btn_reload_cty_dat; extern Fl_Input2 *inpMyPower; extern Fl_Check_Button *btnDisplayLogbookRead; extern Fl_Check_Button *btnCWuseSOMdecoding; extern Fl_Check_Button *btnCWrcvTrack; extern Fl_Value_Slider2 *sldrCWbandwidth; extern Fl_Check_Button *btnCWmfilt; #include <FL/Fl_Value_Output.H> extern Fl_Value_Output *valCWrcvWPM; extern Fl_Progress *prgsCWrcvWPM; extern Fl_Counter2 *cntLower; extern Fl_Counter2 *cntUpper; extern Fl_Counter2 *cntCWrange; #include <FL/Fl_Choice.H> extern Fl_Choice *mnu_cwrx_attack; extern Fl_Choice *mnu_cwrx_decay; extern Fl_Button *btn_cw_tracking_defaults; extern Fl_Value_Slider2 *sldrCWxmtWPM; extern Fl_Counter2 *cntCWdefWPM; extern Fl_Counter *cntCWlowerlimit; extern Fl_Counter *cntCWupperlimit; extern Fl_Value_Slider2 *sldrCWfarnsworth; extern Fl_Check_Button *btnCWusefarnsworth; extern Fl_Counter2 *cntCWdash2dot; extern Fl_Counter2 *cntCWrisetime; extern Fl_ListBox *i_listboxQSKshape; extern Fl_Check_Button *btnQSK; extern Fl_Counter2 *cntQSKfrequency; extern Fl_Counter2 *cntPreTiming; extern Fl_Counter2 *cntPostTiming; extern Fl_Counter2 *cntQSKamp; extern Fl_Counter2 *cntQSKrisetime; extern char szTestChar[]; extern Fl_ListBox *i_listbox_test_char; extern Fl_Check_Button *btnQSKadjust; extern Fl_ListBox *listbox_prosign[9]; extern Fl_Check_Button *btnCW_use_paren; extern Fl_Check_Button *btnCW_prosign_display; #include "cw.h" extern Fl_Check_Button *btn_A_aelig; extern Fl_Check_Button *btn_A_umlaut; extern Fl_Check_Button *btn_A_ring; extern Fl_Check_Button *btn_O_acute; extern Fl_Check_Button *btn_O_slash; extern Fl_Check_Button *btn_O_umlaut; extern Fl_Check_Button *btn_C_cedilla; extern Fl_Check_Button *btn_E_grave; extern Fl_Check_Button *btn_E_acute; extern Fl_Check_Button *btn_N_tilde; extern Fl_Check_Button *btn_U_umlaut; extern Fl_Check_Button *btn_U_circ; extern Fl_Check_Button *btn_CW_backslash; extern Fl_Check_Button *btn_CW_single_quote; extern Fl_Check_Button *btn_CW_dollar_sign; extern Fl_Check_Button *btn_CW_open_paren; extern Fl_Check_Button *btn_CW_close_paren; extern Fl_Check_Button *btn_CW_colon; extern Fl_Check_Button *btn_CW_semi_colon; extern Fl_Check_Button *btn_CW_underscore; extern Fl_Check_Button *btn_CW_at_symbol; extern Fl_Check_Button *btn_CW_exclamation; extern Fl_Check_Button *btn_CW_noise0; extern Fl_Check_Button *btn_CW_noise1; extern Fl_Check_Button *btn_CW_noise2; extern Fl_Check_Button *btn_CW_noise3; #include "combo.h" #include "winkeyer.h" extern Fl_ComboBox *select_WK_CommPort; extern Fl_Light_Button *btn_WKCW_connect; extern Fl_Box *box_WK_wait; extern Fl_Box *box_WK_break_in; extern Fl_Box *box_WK_busy; extern Fl_Box *box_WK_xoff; extern Fl_Box *box_WK_keydown; extern Fl_ComboBox *choice_WK_keyer_mode; extern Fl_ComboBox *choice_WK_hang; extern Fl_ComboBox *choice_WK_sidetone; extern Fl_ComboBox *choice_WK_output_pins; extern Fl_Check_Button *btn_WK_use_pot; extern Fl_Output *txt_WK_wpm; extern Fl_Check_Button *btn_WK_swap; extern Fl_Check_Button *btn_WK_auto_space; extern Fl_Check_Button *btn_WK_ct_space; extern Fl_Check_Button *btn_WK_paddledog; extern Fl_Check_Button *btn_WK_cut_zeronine; extern Fl_Check_Button *btn_WK_paddle_echo; extern Fl_Check_Button *btn_WK_serial_echo; extern Fl_Check_Button *btn_WK_sidetone_on; extern Fl_Check_Button *btn_WK_tone_on; extern Fl_Check_Button *btn_WK_ptt_on; extern Fl_Counter *cntr_WK_min_wpm; extern Fl_Counter *cntr_WK_rng_wpm; extern Fl_Counter *cntr_WK_farnsworth; extern Fl_Counter *cntr_WK_cmd_wpm; extern Fl_Counter *cntr_WK_ratio; extern Fl_Counter *cntr_WK_comp; extern Fl_Counter *cntr_WK_first_ext; extern Fl_Counter *cntr_WK_sample; extern Fl_Counter *cntr_WK_weight; extern Fl_Counter *cntr_WK_leadin; extern Fl_Counter *cntr_WK_tail; extern Fl_Check_Button *btnK3NG; #include "nanoIO.h" extern Fl_ComboBox *select_nanoCW_CommPort; extern Fl_Light_Button *btn_nanoCW_connect; extern Fl_Counter *cntr_nanoCW_paddle_WPM; #include "FTextRXTX.h" extern FTextView *txt_nano_CW_io; extern Fl_Counter *cntr_nanoCW_WPM; extern Fl_Counter2 *cnt_nanoCWdash2dot; extern Fl_ListBox *listbox_nanoIO_serbaud; extern Fl_ListBox *listbox_nano_keyer; extern Fl_ListBox *listbox_incr; extern Fl_Button *btn_cwfsk_save; extern Fl_Button *btn_cwfsk_query; extern Fl_Check_Button *btn_nanoIO_pot; extern Fl_Counter *cntr_nanoIO_min_wpm; extern Fl_Counter *cntr_nanoIO_rng_wpm; extern Fl_Check_Button *btn_disable_CW_PTT; extern Fl_Counter *cntrWPMtest; extern Fl_Button *btn_cal_variable; #include <FL/Fl_Value_Input.H> extern Fl_Value_Input *corr_var_wpm; extern Fl_Value_Input *usec_correc; extern Fl_Button *btn_correction; extern Fl_Check_Button *chk_nanoIO_CW_io; extern Fl_Check_Button *btn_CW_KEYLINE_flrig; extern Fl_Check_Button *btn_FLRIG_CW_disable_ptt; extern Fl_Check_Button *btn_CW_KEYLINE_catport; extern Fl_Check_Button *btn_CW_KEYLINE_shared_PTT; extern Fl_ListBox *listbox_CW_KEYLINE; extern Fl_Counter2 *cntCWkeycomp; extern Fl_ListBox *listbox_PTT_KEYLINE; extern Fl_ComboBox *select_CW_KEYLINE_CommPort; extern Fl_Light_Button *btn_CW_KEYLINE_connect; extern Fl_Light_Button *btn_cw_dtr_calibrate; extern Fl_Output *cwio_test_result; extern Fl_Check_Button *btn_use_ICOMkeying; extern Fl_Input *val_ICOMcivaddr; extern Fl_Check_Button *btn_use_ELCTkeying; extern Fl_Check_Button *btn_use_KNWDkeying; extern Fl_Check_Button *btn_use_YAESUkeying; extern Fl_Check_Button *btn_CAT_CW_disable_ptt; extern void CAT_keying_calibrate(); extern Fl_Button *btn_CAT_keying_calibrate; extern Fl_Value_Input *out_CATkeying_compensation; extern Fl_Button *btn_CAT_keying_clear; extern void CAT_keying_test(); extern Fl_Button *btn_CAT_keying_test; extern Fl_Value_Input *out_CATkeying_test_result; extern Fl_Input2 *txtSecondary; extern Fl_Check_Button *valDominoEX_FILTER; extern Fl_Counter2 *valDominoEX_BW; extern Fl_Check_Button *chkDominoEX_FEC; extern Fl_Value_Slider2 *valDomCWI; extern Fl_Counter2 *valDominoEX_PATHS; #include "fontdef.h" extern Fl_ListBox *listboxHellFont; extern Fl_ListBox *listboxHellPulse; extern Fl_Check_Button *btnFeldHellIdle; #include <FL/Fl_Value_Slider.H> extern Fl_Value_Slider *valHellXmtWidth; extern Fl_Check_Button *btnBlackboard; extern Fl_Check_Button *btnHellMarquee; extern Fl_Value_Slider *valHellRcvWidth; extern Fl_Value_Slider *valHellRcvHeight; extern Fl_Value_Slider2 *sldrHellBW; extern Fl_Value_Slider *val_hellagc; #include "fmt_dialog.h" extern Fl_ListBox *listbox_fmt_sr; extern Fl_Counter *cnt_fmt_rx_ppm; extern Fl_Button *btnFMT_plot_background; extern Fl_Button *btnFMT_unk_color; extern Fl_Button *btnFMT_plot_ref_color; extern Fl_Button *btnFMT_plot_axis; extern Fl_Button *btnFMT_legend_color; extern Fl_Check_Button *btn_fmt_plot_over_axis; extern Fl_Check_Button *btn_fmt_thick_lines; extern Fl_Counter *cnt_fmt_freq_corr; extern Fl_Button *bnt_FMT_dec_corr; extern Fl_Button *btn_FMT_incr_corr; extern Fl_Counter *cnt_fmt_freq_err; extern Fl_Counter *cnt_FMT_movavg_len; extern Fl_ListBox *listbox_fmt_dft_rate; extern Fl_Counter *cnt_FMT_bpf; extern Fl_Check_Button *btn_fmt_unk_bpf_on; extern Fl_Check_Button *btn_fmt_ref_bpf_on; extern Fl_Check_Button *btn_fmt_autorecord; extern Fl_Counter *cnt_fmt_auto_record_time; extern Fl_Check_Button *btn_fmt_record_wav; extern Fl_Check_Button *btn_fmt_sync_wav; extern Fl_Output *txt_fmt_wav_filename; extern Fl_Check_Button *btn_fmt_center_on_unknown; extern Fl_Check_Button *btn_fmt_center_on_reference; extern Fl_Check_Button *btn_fmt_center_on_median; extern Fl_Check_Button *btn_fmt_use_tabs; extern Fl_Value_Slider *valhits; extern Fl_Choice *sel_fsq_lpf; extern Fl_Value_Slider *sldrMovAvg; extern Fl_Choice *sel_fsq_heard_aging; extern Fl_Round_Button *btn_fsqbaud[5]; extern Fl_Choice *sel_fsq_frequency; extern Fl_Choice *sel_fsq_sounder; extern Fl_Counter *cntr_FSQ_time_out; extern Fl_Check_Button *btn_fsq_lowercase; extern Fl_Check_Button *btn_fsq_msg_dt_stamp; extern Fl_Check_Button *btn_fsq_msg_append; extern Fl_Counter *cntr_FSQ_notify_time_out; extern Fl_Output *txtAuditLog; extern Fl_Light_Button *btn_enable_auditlog; extern Fl_Button *btn_select_auditlog; extern Fl_Output *txtHeardLog; extern Fl_Light_Button *btn_enable_fsq_heard_log; extern Fl_Button *btn_select_fsq_heard_log; extern Fl_Button *btn_fsq_xmt_color; extern Fl_Button *btn_fsq_directed_color; extern Fl_Button *btn_fsq_undirected_color; extern Fl_Button *btn_fsq_color_defaults; extern Fl_Round_Button *btn_ifkpbaud[3]; extern Fl_Check_Button *btn_ifkp_lowercase; extern Fl_Check_Button *btn_ifkp_lowercase_call; #include "trx.h" extern Fl_Check_Button *btn_ifkp_freqlock; extern Fl_Output *txt_ifkp_audit_log; extern Fl_Light_Button *btn_enable_ifkp_audit_log; extern Fl_Button *btn_ifkp_select_auditlog; extern Fl_Output *txt_ifkp_heard_log; extern Fl_Light_Button *btn_enable_ifkp_heard_log; extern Fl_Button *btn_select_ifkp_heard_log; extern Fl_Check_Button *btnMT63_8bit; extern Fl_Check_Button *btnMT63_rx_integration; extern Fl_Check_Button *btnMT63_usetones; extern Fl_Check_Button *btnMT63_upper_lower; extern Fl_Spinner2 *MT63_tone_duration; extern Fl_Check_Button *btnMT63_at500; extern Fl_Check_Button *btnMT63_centered; extern Fl_Check_Button *btnMT63_manual; extern Fl_ListBox *i_listbox_contestia_bandwidth; extern Fl_ListBox *i_listbox_contestia_tones; extern Fl_Counter2 *cntContestia_smargin; extern Fl_Counter2 *cntContestia_sinteg; extern Fl_Check_Button *btnContestia_8bit; extern Fl_Check_Button *btnContestia_start_stop_tones; extern Fl_ListBox *i_listbox_olivia_bandwidth; extern Fl_ListBox *i_listbox_olivia_tones; extern Fl_Counter2 *cntOlivia_smargin; extern Fl_Counter2 *cntOlivia_sinteg; extern Fl_Check_Button *btn_olivia_reset_fec; extern Fl_Check_Button *btnOlivia_8bit; extern Fl_Check_Button *btnOlivia_start_stop_tones; extern Fl_Counter2 *cntSearchRange; extern Fl_Counter2 *cntACQsn; extern Fl_ListBox *listbox_psk_status_timeout; extern Fl_Check_Button *btnEnablePSKbrowsing; extern Fl_Check_Button *btnPSKpilot; extern Fl_Counter2 *cnt_pilot_power; extern Fl_Check_Button *btnPSK8Preamble; extern Fl_ListBox *i_listbox_rtty_afc_speed; extern Fl_Check_Button *chkUOSrx; extern Fl_Value_Input *rtty_rx_shape; extern Fl_Check_Button *btnRxTones[3]; extern Fl_Check_Button *btnPreferXhairScope; extern Fl_Check_Button *chk_true_scope; extern Fl_Check_Button *chk_useMARKfreq; extern Fl_Button *btnRTTY_mark_color; extern Fl_Check_Button *chk_audibleBELL; extern Fl_Check_Button *chk_visibleBELL; #include <FL/Fl_File_Input.H> extern Fl_File_Input *inp_wav_fname_bell_ring; extern Fl_Button *btn_select_bell_ring_wav; extern Fl_Choice *mnu_bell_ring_menu; extern Fl_Button *btn_test_bell_ring_wav; extern Fl_ListBox *selShift; extern Fl_Counter2 *selCustomShift; extern Fl_ListBox *selBaud; extern Fl_ListBox *selBits; extern Fl_ListBox *selParity; extern Fl_ListBox *selStopBits; extern Fl_Check_Button *btnAUTOCRLF; extern Fl_Counter2 *cntrAUTOCRLF; extern Fl_Check_Button *btnCRCRLF; extern Fl_Check_Button *chkUOStx; extern Fl_Check_Button *chk_shaped_rtty; extern Fl_Check_Button *chkPseudoFSK; extern Fl_Counter *cnt_TTY_LTRS; extern Fl_Check_Button *btnFSKenabled; extern Fl_Check_Button *btnFSKshared; extern Fl_ComboBox *select_FSK_CommPort; extern Fl_Check_Button *btnFSKreverse; extern Fl_Check_Button *btnFSKuseDTR; extern Fl_Button *btnFSKreset; extern Fl_Counter *cntr_xcvr_FSK_MARK; extern Fl_ListBox *sel_xcvr_FSK_shift; extern Fl_Check_Button *btnFSK_STOPBITS; extern Fl_Check_Button *btn_FSK_KEYLINE_flrig; extern Fl_ComboBox *select_nanoIO_CommPort; extern Fl_Light_Button *btn_nanoIO_connect; extern Fl_ListBox *listbox_nanoIO_serbaud2; extern FTextView *txt_nano_io; extern Fl_Button *btn_nanofsk_save; extern Fl_Button *btn_nanofsk_query; extern Fl_Check_Button *chk_nanoIO_polarity; extern Fl_ListBox *sel_nanoIO_baud; extern Fl_Group *grp_nanoio_debug; #include <FL/Fl_Browser.H> extern Fl_Browser *brws_nanoio_sent; extern Fl_Browser *brws_nanoio_rcvd; extern Fl_Button *btn_nanoio_clear_sent; extern Fl_Button *btn_nanoio_clear_both; extern Fl_Button *btn_nanoio_clear_rcvd; extern Fl_Light_Button *btn_nanoio_debug; extern Fl_Check_Button *chk_nanoIO_FSK_io; #include "Nav.h" extern Fl_ComboBox *select_USN_FSK_port; extern Fl_Light_Button *btn_Nav_connect; extern Fl_ComboBox *select_Nav_config_port; extern Fl_ListBox *sel_Nav_ch1; extern Fl_ListBox *sel_Nav_ch2; extern Fl_ListBox *sel_Nav_rf_att; extern Fl_ListBox *sel_Nav_wk_ptt; extern Fl_ListBox *sel_Nav_LED; extern Fl_ListBox *sel_Nav_CAT_LED; extern Fl_ListBox *sel_Nav_FSK_baud; extern Fl_ListBox *sel_Nav_FSK_stopbits; extern Fl_ListBox *sel_Nav_FSK_polarity; extern Fl_ListBox *sel_Nav_FSK_sidetone; extern Fl_ListBox *sel_Nav_FSK_ptt; extern Fl_Light_Button *btn_Nav_config; extern Fl_Check_Button *btnSynopAdifDecoding; extern Fl_Check_Button *btnSynopKmlDecoding; extern Fl_Check_Button *btnSynopInterleaved; extern Fl_ComboBox *select_WKFSK_CommPort; extern Fl_Light_Button *btn_WKFSK_connect; extern Fl_ListBox *sel_WKFSK_baud; extern Fl_ListBox *sel_WKFSK_stopbits; extern Fl_ListBox *sel_WKFSK_ptt; extern Fl_ListBox *sel_WKFSK_polarity; extern Fl_ListBox *sel_WKFSK_sidetone; extern Fl_ListBox *sel_WKFSK_auto_crlf; extern Fl_ListBox *sel_WKFSK_diddle; extern Fl_ListBox *sel_WKFSK_diddle_char; extern Fl_ListBox *sel_WKFSK_usos; extern Fl_ListBox *sel_WKFSK_monitor; extern Fl_Input2 *txtTHORSecondary; extern Fl_Check_Button *valTHOR_FILTER; extern Fl_Counter2 *valTHOR_BW; extern Fl_Value_Slider2 *valThorCWI; extern Fl_Check_Button *valTHOR_PREAMBLE; extern Fl_Check_Button *valTHOR_SOFTSYMBOLS; extern Fl_Check_Button *valTHOR_SOFTBITS; extern Fl_Counter2 *valTHOR_PATHS; extern Fl_Check_Button *btnNvtxAdifLog; extern Fl_Check_Button *btnNvtxKmlLog; extern Fl_Counter *cntrWEFAX_Shift; extern Fl_Counter *cntrWEFAX_Center; extern Fl_Counter *cntrWEFAX_MaxRows; extern Fl_Input *btnWefaxSaveDir; extern Fl_Button *btnSelectFaxDestDir; extern Fl_Check_Button *btnWefaxAdifLog; extern Fl_Choice *wefax_choice_rx_filter; extern Fl_Counter *auto_after_nrows; extern Fl_Counter *align_stop_after; extern Fl_Counter *align_every_nrows; extern Fl_Counter *wefax_correlation; extern Fl_Counter *cntr_correlation_rows; extern Fl_Input2 *txt_auto_flrig_pathname; extern Fl_Button *btn_select_flrig; extern Fl_Input2 *txt_auto_flamp_pathname; extern Fl_Button *btn_select_auto_flamp; extern Fl_Input2 *txt_auto_flnet_pathname; extern Fl_Button *btn_select_auto_flnet; extern Fl_Input2 *txt_auto_fllog_pathname; extern Fl_Button *btn_select_fllog; extern Fl_Input2 *txt_auto_prog1_pathname; extern Fl_Button *btn_select_prog1; extern Fl_Input2 *txt_auto_prog2_pathname; extern Fl_Button *btn_select_prog2; extern Fl_Input2 *txt_auto_prog3_pathname; extern Fl_Button *btn_select_prog3; extern Fl_Check_Button *btn_flrig_auto_enable; extern Fl_Check_Button *btn_flamp_auto_enable; extern Fl_Check_Button *btn_flnet_auto_enable; extern Fl_Check_Button *btn_fllog_auto_enable; extern Fl_Check_Button *btn_prog1_auto_enable; extern Fl_Check_Button *btn_prog2_auto_enable; extern Fl_Check_Button *btn_prog3_auto_enable; extern Fl_Button *btn_test_flrig; extern Fl_Button *btn_test_flamp; extern Fl_Button *btn_test_flnet; extern Fl_Button *btn_test_fllog; extern Fl_Button *btn_test_prog1; extern Fl_Button *btn_test_prog2; extern Fl_Button *btn_test_prog3; extern Fl_Check_Button *chkSlowCpu; extern Fl_Check_Button *chkDTMFdecode; extern Fl_Input *btnKmlSaveDir; extern Fl_Input *inputKmlRootFile; extern Fl_Counter *cntKmlMergeDistance; extern Fl_Counter *cntKmlRetentionTime; extern Fl_Spinner2 *cntKmlRefreshInterval; extern Fl_ListBox *listbox_kml_balloon_style; extern Fl_Input *btnKmlCommand; extern Fl_Button *btlTestKmlCommand; extern Fl_Button *btnSelectKmlDestDir; extern Fl_Button *btlPurge; extern Fl_Check_Button *btnKmlPurgeOnStartup; extern Fl_Check_Button *btn_kml_enabled; extern Fl_Check_Button *chkAutoExtract; extern Fl_Check_Button *chk_open_wrap_folder; extern Fl_Check_Button *chk_open_flmsg; extern Fl_Check_Button *chk_open_flmsg_print; extern Fl_Input2 *txt_flmsg_pathname; extern Fl_Button *btn_select_flmsg; extern Fl_Value_Slider *sldr_extract_timeout; extern Fl_Check_Button *chk_transfer__to_open_flmsg; extern Fl_Check_Button *btnPSKRepAuto; extern Fl_Check_Button *btnPSKRepLog; extern Fl_Check_Button *btnPSKRepQRG; extern Fl_Check_Button *btn_report_when_visible; extern Fl_Check_Button *btn_pskrep_autostart; extern Fl_Box *box_connected_to_pskrep; extern Fl_Input2 *inpPSKRepHost; extern Fl_Input2 *inpPSKRepPort; extern Fl_Button *btnPSKRepInit; extern Fl_Box *boxPSKRepMsg; extern Fl_Counter *cntBusyChannelSeconds; extern Fl_Check_Button *btnEnableBusyChannel; extern Fl_Counter *cntPSMTXBufferFlushTimer; extern Fl_Counter *cntPSMBandwidthMargins; extern Fl_Counter *cntPSMValidSamplePeriod; extern Fl_Check_Button *btnEnable_csma; extern Fl_Counter *cntPersistance; extern Fl_Counter *cntSlotTime; extern Fl_Counter *cntTransmitDelay; extern Fl_Output *OutputSlotTimeMS; extern Fl_Output *OutputTransmitDelayMS; extern Fl_Output *OutputPersistancePercent; extern Fl_Check_Button *btnEnable_histogram; extern Fl_Counter *cntPSMThreshold; extern Fl_Counter *cntKPSQLAttenuation; extern Fl_Check_Button *btn_show_psm_button; extern Fl_Button *btnBuyChannelDefaults; extern Fl_Group *grpTalker; extern void open_talker(); extern void close_talker(); extern Fl_Light_Button *btnConnectTalker; extern Fl_Check_Button *btn_auto_talk; extern Fl_Check_Button *chkRxStream; extern Fl_Check_Button *btnTXLEVEL_by_mode; extern Fl_Check_Button *btnSQLCH_by_mode; extern Fl_Check_Button *btnAFC_by_mode; extern Fl_Check_Button *btnREVERSE_by_mode; extern Fl_Value_Input2 *valCWsweetspot; extern Fl_Value_Input2 *valRTTYsweetspot; extern Fl_Value_Input2 *valPSKsweetspot; extern Fl_Check_Button *btnStartAtSweetSpot; extern Fl_Check_Button *btnCWIsLSB; extern Fl_Check_Button *btnDisable_p2p_io_widgets; extern Fl_Check_Button *btnEnable_arq; extern Fl_Check_Button *btnEnable_kiss; extern Fl_Input2 *txtKiss_ip_address; extern Fl_Input2 *txtKiss_ip_io_port_no; extern Fl_Input2 *txtKiss_ip_out_port_no; extern Fl_Check_Button *btnEnable_dual_port; extern Fl_Button *btn_restart_kiss; extern Fl_Button *btn_connect_kiss_io; extern Fl_Button *btnDefault_kiss_ip; extern Fl_Check_Button *btnKissTCPIO; extern Fl_Check_Button *btnKissUDPIO; extern Fl_Check_Button *btnKissTCPListen; extern Fl_Check_Button *btnEnable_7bit_modem_inhibit; extern Fl_Check_Button *btnEnable_auto_connect; extern Fl_Check_Button *btnEnable_ax25_decode; extern Fl_Input2 *txtArq_ip_address; extern Fl_Input2 *txtArq_ip_port_no; extern Fl_Button *btnDefault_arq_ip; extern Fl_Button *btn_restart_arq; extern Fl_Button *btnDefault_xmlrpc_ip; extern Fl_Input2 *txtXmlrpc_ip_address; extern Fl_Input2 *txtXmlrpc_ip_port_no; extern Fl_Button *btn_restart_xml; extern Fl_Button *btnDefault_flrig_ip; extern Fl_Input2 *txt_flrig_ip_address; extern Fl_Input2 *txt_flrig_ip_port; #include "rigsupport.h" extern Fl_Button *btn_reconnect_flrig_server; extern Fl_Input *txt_fllog_ip_address; extern Fl_Input *txt_fllog_ip_port; extern Fl_Button *btn_reconnect_log_server; extern Fl_Button *btnDefault_fllog_ip; extern Fl_Group *grpOperator; extern Fl_Input2 *inpMyCallsign; extern Fl_Input2 *inpOperCallsign; extern Fl_Input2 *inpMyName; extern Fl_Input2 *inpMyAntenna; extern Fl_Input2 *inpMyQth; extern Fl_Input2 *inpMyLocator; #include "counties.h" extern Fl_ListBox *listbox_states; extern Fl_Input2 *inp_QP_state_short; extern Fl_ListBox *listbox_counties; extern Fl_Input2 *inp_QP_short_county; extern Fl_Group *grpRigFlrig; extern Fl_Check_Button *chk_flrig_keys_modem; extern Fl_Button *btnDefault_flrig_ip_mirror; extern Fl_Input2 *txt_flrig_ip_address_mirror; extern Fl_Input2 *txt_flrig_ip_port_mirror; extern Fl_Button *btn_reconnect_flrig_server_mirror; extern Fl_Check_Button *btn_fldigi_client_to_flrig; extern Fl_Check_Button *btn_flrig_auto_shutdown; extern Fl_Counter2 *val_flrig_poll; extern Fl_Group *grpRigCat; extern Fl_Check_Button *chkUSERIGCAT; extern Fl_Group *grpRigCAT; extern Fl_Output *txtXmlRigFilename; extern Fl_Button *btnSelectRigXmlFile; extern Fl_ComboBox *inpXmlRigDevice; extern Fl_Value_Input2 *cntRigCatRetries; extern Fl_Value_Input2 *cntRigCatTimeout; extern Fl_Value_Input2 *cntRigCatWait; extern Fl_ListBox *listbox_xml_rig_baudrate; extern Fl_Counter2 *valRigCatStopbits; extern Fl_Button *btnInitRIGCAT; extern Fl_Check_Button *btnRigCatEcho; extern Fl_Round_Button *btnRigCatCMDptt; extern Fl_Round_Button *btnRigCatRTSptt; extern Fl_Round_Button *btnRigCatDTRptt; extern Fl_Check_Button *btnRigCatRTSplus; extern Fl_Check_Button *btnRigCatDTRplus; extern Fl_Check_Button *chkRigCatRTSCTSflow; extern Fl_Check_Button *chk_restore_tio; extern Fl_Check_Button *chkRigCatVSP; extern Fl_Value_Input2 *cntRigCatInitDelay; extern Fl_Group *grpRigGPIO; extern Fl_Check_Button *btn_gpio_ptt2; extern Fl_Button *btnInitHWPTT2; extern Fl_Check_Button *btn_enable_gpio[17]; extern Fl_Check_Button *btn_gpio_on[17]; extern Fl_Counter *cnt_gpio_pulse_width; extern Fl_Group *grpRigHamlib; extern Fl_Check_Button *chkUSEHAMLIB; extern Fl_Group *grpHamlib; extern Fl_ListBox *cboHamlibRig; extern Fl_ComboBox *inpRIGdev; extern Fl_Value_Input2 *cntHamlibRetries; extern Fl_Value_Input2 *cntHamlibTimeout; extern Fl_Value_Input2 *cntHamlibWriteDelay; extern Fl_Value_Input2 *cntHamlibWait; extern Fl_ListBox *listbox_baudrate; extern Fl_Counter2 *valHamRigStopbits; extern Fl_Counter2 *valHamRigPollrate; extern Fl_Check_Button *btnHamlibCMDptt; extern Fl_Check_Button *btnHamlibPTT_ON_DATA; extern Fl_Check_Button *btnHamlibDTRplus; extern Fl_Check_Button *chkHamlibRTSplus; extern Fl_Check_Button *chkHamlibRTSCTSflow; extern Fl_Check_Button *chkHamlibXONXOFFflow; extern Fl_Check_Button *chk_hamlib_cw_is_lsb; extern Fl_Check_Button *chk_hamlib_rtty_is_usb; extern Fl_Counter2 *val_hamlib_mode_delay; extern Fl_ListBox *listbox_sideband; extern Fl_Input2 *inpHamlibConfig; extern Fl_Button *btnInitHAMLIB; extern Fl_Button *btn_hamlib_get_defaults; extern Fl_Group *grpRigHardware; extern Fl_Check_Button *btnPTTrightchannel; extern Fl_Round_Button *btnTTYptt; extern Fl_ComboBox *inpTTYdev; extern Fl_Round_Button *btnSCU_17; extern Fl_Round_Button *btnUsePPortPTT; extern Fl_Round_Button *btnUseUHrouterPTT; extern Fl_Round_Button *btnRTSptt; extern Fl_Round_Button *btnRTSplusV; extern Fl_Round_Button *btnDTRptt; extern Fl_Round_Button *btnDTRplusV; extern Fl_Check_Button *btn_gpio_ptt; extern Fl_Button *btnInitHWPTT; extern Fl_Group *grpPTTdelays; extern Fl_Counter *cntPTT_on_delay; extern Fl_Counter *cntPTT_off_delay; extern Fl_Group *grp_cmedia_ptt; extern Fl_Round_Button *btn_use_cmedia_PTT; extern Fl_ComboBox *inp_cmedia_dev; extern Fl_ComboBox *inp_cmedia_GPIO_line; extern Fl_Button *btn_init_cmedia_PTT; #include "cmedia.h" extern Fl_Button *btn_test_cmedia; extern Fl_File_Input *inp_wav_fname_regex; #include <FL/Fl_Native_File_Chooser.H> extern Fl_Button *btn_select_regex_wav; extern Fl_Choice *mnu_regex_alert_menu; extern Fl_Check_Button *btn_enable_regex_match_wa; #include "audio_alert.h" extern Fl_Button *btn_test_regex_wav; extern Fl_File_Input *inp_wav_fname_mycall; extern Fl_Button *btn_select_mycall_wav; extern Fl_Choice *mnu_mycall_alert_menu; extern Fl_Check_Button *btn_enable_mycall_match_wav; extern Fl_Button *btn_test_mycall_wav; extern Fl_File_Input *inp_wav_fname_rsid; extern Fl_Button *btn_select_rsid_wav; extern Fl_Choice *mnu_rsid_alert_menu; extern Fl_Check_Button *btn_enable_rsid_match_wav; extern Fl_Button *btn_test_rsid_wav; extern Fl_File_Input *inp_wav_flmsg_rcvd; extern Fl_Button *btn_select_rx_extract_msg; extern Fl_Choice *mnu_rx_extract_alert_menu; extern Fl_Check_Button *btn_enable_flmsg_wav; extern Fl_Button *btn_test_flmsg_extract_wav; extern Fl_File_Input *inp_wav_flmsg_timed_out; extern Fl_Button *btn_select_rx_extract_timed_out; extern Fl_Choice *mnu_rx_timed_out_alert_menu; extern Fl_Button *btn_test_rx_extract_timed_out; extern Fl_Check_Button *btn_enable_flmsg_time_out_wav; extern Fl_Value_Slider2 *sldrAlertVolume; extern Fl_Group *grpSoundDevices; extern Fl_Group *AudioOSS; #include <FL/Fl_Input_Choice.H> extern Fl_Input_Choice *menuOSSDev; extern Fl_Group *AudioPort; extern Fl_Choice *menuPortInDev; extern Fl_Choice *menuPortOutDev; extern Fl_Group *AudioPulse; extern Fl_Input2 *inpPulseServer; extern Fl_Group *AudioNull; extern Fl_Round_Button *btnAudioIO[4]; extern Fl_Group *AudioDuplex; extern Fl_Round_Button *btn_is_full_duplex; extern Fl_Group *AudioAlerts; extern Fl_Choice *menuAlertsDev; extern Fl_Round_Button *btn_enable_audio_alerts; extern Fl_Check_Button *chkAudioStereoOut; extern Fl_Check_Button *chkReverseAudio; extern Fl_Check_Button *btnPTTrightchannel2; extern Fl_Check_Button *btnQSK2; extern Fl_Check_Button *chkPseudoFSK2; extern Fl_Check_Button *chkReverseRxAudio; extern Fl_Group *grpAudioSampleRate; extern Fl_ListBox *menuInSampleRate; extern Fl_ListBox *menuOutSampleRate; #include <FL/fl_ask.H> extern Fl_ListBox *menuSampleConverter; extern Fl_Spinner2 *cntRxRateCorr; extern Fl_Spinner2 *cntTxRateCorr; extern Fl_Spinner2 *cntTxOffset; extern Fl_Button *bnt_dec_rit; extern Fl_Counter *cntRIT; extern Fl_Button *btn_incr_rit; extern Fl_Box *lowcolor2; extern Fl_Button *btnLowSignal2; extern Fl_Box *normalcolor2; extern Fl_Counter *cnt_normal_signal_level2; extern Fl_Button *btnNormalSignal2; extern Fl_Box *highcolor2; extern Fl_Counter *cnt_high_signal_level2; extern Fl_Button *btnHighSignal2; extern Fl_Box *overcolor2; extern Fl_Counter *cnt_over_signal_level2; extern Fl_Button *btnOverSignal2; extern vumeter *sig_vumeter2; extern Fl_Button *btn_default_signal_levels2; extern Fl_ListBox *listbox_wav_samplerate; extern Fl_Check_Button *btn_record_both; extern Fl_Spinner2 *cntChannels; extern Fl_Spinner2 *cntTimeout; extern Fl_ListBox *listboxViewerLabel; extern Fl_Button *btnViewerFont; extern Fl_Check_Button *btnFixedIntervals; extern Fl_Check_Button *btnMarquee; extern Fl_Check_Button *btnAscend; extern Fl_Check_Button *btnBrowserHistory; #include "Viewer.h" extern Fl_Button *bwsrHiLite_1_color; extern Fl_Button *bwsrHiLite_2_color; extern Fl_Button *bwsrHiLite_even_lines; extern Fl_Button *bwsrHiLite_odd_lines; extern Fl_Button *bwsrHiLite_select; extern Fl_Button *bwsrSliderColor; extern Fl_Button *bwsrSldrSelColor; extern Fl_Check_Button *btnShowTooltips; extern Fl_Check_Button *chkMenuIcons; extern Fl_ListBox *listboxScheme; extern Fl_Button *bVisibleModes; extern Fl_ListBox *listbox_language; extern Fl_Check_Button *btn_rx_lowercase; extern Fl_Check_Button *btn_tx_lowercase; extern Fl_Check_Button *btn_save_config_on_exit; extern Fl_Check_Button *btn2_save_macros_on_exit; extern Fl_Check_Button *btn2NagMe; extern Fl_Check_Button *btn2_confirm_exit; extern Fl_Check_Button *btn_check_for_updates; extern Fl_Check_Button *btn_tx_show_timer; #include <FL/Fl_Spinner.H> extern Fl_Spinner *val_tx_timeout; extern Fl_Check_Button *btnMacroMouseWheel; extern Fl_Counter *cnt_macro_height; extern Fl_Round_Button *btn_scheme_0; extern Fl_Round_Button *btn_scheme_1; extern Fl_Round_Button *btn_scheme_2; extern Fl_Round_Button *btn_scheme_3; extern Fl_Round_Button *btn_scheme_4; extern Fl_Round_Button *btn_scheme_5; extern Fl_Round_Button *btn_scheme_6; extern Fl_Round_Button *btn_scheme_7; extern Fl_Round_Button *btn_scheme_8; extern Fl_Round_Button *btn_scheme_9; extern Fl_Round_Button *btn_scheme_10; extern Fl_Round_Button *btn_scheme_11; extern Fl_Round_Button *btn_scheme_12; extern Fl_Check_Button *btnUseLastMacro; extern Fl_Check_Button *btnDisplayMacroFilename; extern Fl_Check_Button *btn_save_macros_on_exit; extern Fl_Check_Button *btn_macro_post; extern Fl_Check_Button *btn_4bar_position; extern Fl_Check_Button *btnRXClicks; extern Fl_Check_Button *btnRXTooltips; extern Fl_Input2 *inpNonword; extern Fl_Check_Button *btnUSunits; extern Fl_Check_Button *btn_clear_fields; extern Fl_Choice *sel_lsd; extern Fl_Check_Button *btn_rxtx_swap; extern Fl_Check_Button *btnWF_UIrev; extern Fl_Check_Button *btnWF_UIx1; extern Fl_Check_Button *btnWF_UIwfcarrier; extern Fl_Check_Button *btnWF_UIwfshift; extern Fl_Check_Button *btnWF_UIwfreflevel; extern Fl_Check_Button *btnWF_UIwfdrop; extern Fl_Check_Button *btnWF_UIwfampspan; extern Fl_Check_Button *btnWF_UIwfstore; extern Fl_Check_Button *btnWF_UIwfmode; extern Fl_Check_Button *btnWF_UIqsy; extern Fl_Check_Button *btnWF_UIxmtlock; extern Fl_Button *btn_wf_enable_all; extern Fl_Button *btn_wf_disable_all; #include "colorbox.h" extern colorbox *WF_Palette; extern Fl_Button *btnColor[9]; extern Fl_Button *btnLoadPalette; extern Fl_Button *btnSavePalette; extern Fl_Check_Button *btnUseCursorLines; extern Fl_Button *btnCursorBWcolor; extern Fl_Check_Button *btnUseWideCursor; extern Fl_Check_Button *btnUseCursorCenterLine; extern Fl_Button *btnCursorCenterLineColor; extern Fl_Check_Button *btnUseWideCenter; extern Fl_Check_Button *btnUseBWTracks; extern Fl_Button *btnBwTracksColor; extern Fl_Check_Button *btnUseWideTracks; extern Fl_Button *btnNotchColor; extern Fl_Check_Button *chkShowAudioScale; extern Fl_Button *btnWaterfallFont; extern Fl_Check_Button *btnViewXmtSignal; extern Fl_Counter *valTxMonitorLevel; extern Fl_Counter2 *cntLowFreqCutoff; extern Fl_Check_Button *btnWFaveraging; extern Fl_ListBox *listboxFFTPrefilter; extern Fl_Counter2 *cntrWfwidth; extern Fl_Counter2 *wf_latency; extern Fl_Counter *cntr_drop_speed; extern Fl_Counter2 *cntrWfheight; extern Fl_Check_Button *btnWaterfallHistoryDefault; extern Fl_Check_Button *btnWaterfallQSY; extern Fl_Check_Button *btnWaterfallClickInsert; extern Fl_Input2 *inpWaterfallClickText; extern Fl_ListBox *listboxWaterfallWheelAction; extern Fl_Check_Button *btnWFspectrum_center; extern Fl_Check_Button *btnWFspectrum_dbvals; extern Fl_Counter *cntr_spectrum_freq_scale; extern Fl_Check_Button *btn_spectrum_modem_scale; extern Fl_Counter2 *cntServerCarrier; extern Fl_Counter2 *cntServerOffset; extern Fl_Counter2 *cntServerACQsn; extern Fl_Counter2 *cntServerAFCrange; extern Fl_Check_Button *btnPSKmailSweetSpot; extern Fl_Check_Button *btn_arq_s2n_report; extern Fl_Input *txt_wx_url; extern Fl_Button *btn_default_wx_url; extern Fl_Input *inpWXsta; #include "weather.h" extern Fl_Button *btn_metar_search; extern Fl_Check_Button *btn_wx_full; extern Fl_Check_Button *btn_wx_station_name; extern Fl_Check_Button *btn_wx_condx; extern Fl_Check_Button *btn_wx_fahrenheit; extern Fl_Check_Button *btn_wx_celsius; extern Fl_Check_Button *btn_wx_mph; extern Fl_Check_Button *btn_wx_kph; extern Fl_Check_Button *btn_wx_inches; extern Fl_Check_Button *btn_wx_mbars; extern Fl_Button *btnSaveConfig; #include <FL/Fl_Return_Button.H> extern Fl_Return_Button *btnCloseConfig; extern Fl_Button *btnResetConfig; Fl_Double_Window* ConfigureDialog(); void openConfig(); void closeDialog(); void WefaxDestDirSet(Fl_File_Chooser *w, void *userdata); void KmlDestDirSet(Fl_File_Chooser *w, void *userdata); #endif
40,725
C++
.h
1,070
37.056075
182
0.813562
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,471
network.h
w1hkj_fldigi/src/include/network.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014...2019 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef NETWORK_H_ #define NETWORK_H_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <sstream> #include <fstream> #include <string> #include <cmath> #include "mbedtls/config.h" #include "mbedtls/net.h" #include "mbedtls/net_sockets.h" #include "mbedtls/debug.h" #include "mbedtls/ssl.h" #include "mbedtls/entropy.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/certs.h" extern bool get_http(const std::string& url, std::string& reply, double timeout = 0.0); extern char ca_crt_rsa[]; extern size_t ca_crt_rsa_size; //---------------------------------------------------------------------- //#define DEBUG_LEVEL 1 #define MBEDTLS_EXIT_SUCCESS 0 #define MBEDTLS_EXIT_FAILURE 1 #define MBEDTLS_DEBUG_C #define MBEDTLS_CHECK_PARAMS #define H_FIELD_SIZE 512 #define H_READ_SIZE 2048 typedef struct { char method[8]; int status; char content_type[H_FIELD_SIZE]; long content_length; bool chunked; bool close; char location[H_FIELD_SIZE]; char referrer[H_FIELD_SIZE]; char cookie[H_FIELD_SIZE]; char boundary[H_FIELD_SIZE]; } HTTP_HEADER; typedef struct { bool verify; mbedtls_net_context ssl_fd; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; mbedtls_x509_crt cacert; } HTTP_SSL; typedef struct { bool https; char host[256]; char port[8]; char path[H_FIELD_SIZE]; } HTTP_URL; typedef struct { HTTP_URL url; HTTP_HEADER request; HTTP_HEADER response; HTTP_SSL tls; long length; char r_buf[H_READ_SIZE]; long r_len; bool header_end; char *body; long body_size; long body_len; } HTTP_INFO; //---------------------------------------------------------------------- class Url { std::string _url; std::string _host; std::string _port; std::string _request; std::string _data; std::string _pers; std::string server_port; bool _https; int _err; char err_string[1024]; char buf[4096]; mbedtls_net_context server_fd; uint32_t flags; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; mbedtls_x509_crt cacert; bool _debug; static int _rotate_log; double _timeout; std::ofstream debug_file; int http_get(std::string &response); int https_get(std::string &response); public: Url() { init(); }; Url(std::string url) { init(); _url = url; parse(url); } ~Url() { if (debug_file) { debug_file.close(); } }; void init() { _https = false; server_port.clear(); _url.clear(); _host.clear(); _port.clear(); _request.clear(); _data.clear(); _pers = "fldigi"; _timeout = 5.0; debug(); } void parse(std::string url); std::string host() { return _host; } std::string port() { return _port; } std::string request() { return _request; } std::string data() { return _data; } std::string url() { return _url; } std::string strerr() { return err_string; }; int error() { return _err; } bool https() { return _https; } std::string str_https() { if (_https) return "true"; return "false"; } int get(std::string response); int get(std::string url, std::string &response); void timeout(double t) { _timeout = t; } double timeout() { return _timeout; } void debug(); }; #endif // NETWORK_H_
4,439
C++
.h
164
24.493902
87
0.630435
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,472
rxmon.h
w1hkj_fldigi/src/include/rxmon.h
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #ifndef rxmon_h #define rxmon_h #include <FL/Fl.H> #include "configuration.h" #include "combo.h" #include "flinput2.h" #include "flslider2.h" #include <FL/Fl_Double_Window.H> #include <FL/Fl_Check_Button.H> extern Fl_Check_Button *btn_mon_xcvr_audio; #include <FL/Fl_Group.H> extern Fl_Value_Slider2 *sldrRxFilt_bw; extern Fl_Value_Slider2 *sldrRxFilt_mid; extern Fl_Value_Slider2 *sldrRxFilt_low; extern Fl_Value_Slider2 *sldrRxFilt_high; extern Fl_Check_Button *btn_RxFilt_at_track; extern Fl_Value_Slider2 *sldrRxFilt_vol; extern Fl_Check_Button *btn_mon_dsp_audio; Fl_Double_Window* make_rxaudio_dialog(); #endif
692
C++
.h
21
31.904762
73
0.78806
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,473
charsetlist.h
w1hkj_fldigi/src/include/charsetlist.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef CHARSETLIST_H #define CHARSETLIST_H struct charset_info { const char *name; int tiniconv_id; }; extern const struct charset_info charset_list[]; extern const unsigned int number_of_charsets; #endif
1,105
C++
.h
29
36.758621
79
0.642724
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,474
log.h
w1hkj_fldigi/src/include/log.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _LOG_H #define _LOG_H #include <cstdio> #include <string> class cLogfile { public: enum log_t { LOG_RX, LOG_TX, LOG_START, LOG_STOP }; private: FILE* logfile; bool retflag; log_t logtype; public: cLogfile(const std::string& fname); ~cLogfile(); void log_to_file(log_t type, const std::string& s); void log_to_file_start(); void log_to_file_stop(); }; #endif
1,270
C++
.h
38
32.026316
79
0.638662
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,475
view_rtty.h
w1hkj_fldigi/src/include/view_rtty.h
// ---------------------------------------------------------------------------- // rtty.h -- RTTY modem // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // gmfsk Copyright (C) 2001, 2002, 2003 // Tomi Manninen (oh2bns@sral.fi) // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef VIEW_RTTY_H #define VIEW_RTTY_H //#include "rtty.h" #include "complex.h" #include "modem.h" #include "globals.h" #include "filters.h" #include "fftfilt.h" #include "digiscope.h" #define VIEW_RTTY_SampleRate 8000 #define VIEW_MAXPIPE 1024 #define VIEW_RTTY_MAXBITS (2 * VIEW_RTTY_SampleRate / 23 + 1) #define MAX_CHANNELS 30 class view_rtty : public modem { public: enum CHANNEL_STATE {IDLE, SRCHG, RCVNG, WAITING}; enum RTTY_RX_STATE { RTTY_RX_STATE_IDLE = 0, RTTY_RX_STATE_START, RTTY_RX_STATE_DATA, RTTY_RX_STATE_PARITY, RTTY_RX_STATE_STOP, RTTY_RX_STATE_STOP2 }; enum RTTY_PARITY { RTTY_PARITY_NONE = 0, RTTY_PARITY_EVEN, RTTY_PARITY_ODD, RTTY_PARITY_ZERO, RTTY_PARITY_ONE }; static const double SHIFT[]; static const double BAUD[]; static const int BITS[]; static const int FILTLEN[]; static const int numshifts; static const int numbauds; int filter_length; private: struct RTTY_CHANNEL { int state; double phaseacc; fftfilt *mark_filt; fftfilt *space_filt; Cmovavg *bits; bool nubit; bool bit; bool bit_buf[VIEW_RTTY_MAXBITS]; double mark_phase; double space_phase; double metric; int rxmode; RTTY_RX_STATE rxstate; double frequency; double freqerr; double phase; double posfreq; double negfreq; double freqerrhi; double freqerrlo; double poserr; double negerr; int poscnt; int negcnt; int timeout; double mark_mag; double space_mag; double mark_env; double space_env; double noise_floor; double mark_noise; double space_noise; double sigpwr; double noisepwr; double avgsig; double prevsymbol; cmplx prevsmpl; int counter; int bitcntr; int rxdata; int inp_ptr; cmplx mark_history[VIEW_MAXPIPE]; cmplx space_history[VIEW_MAXPIPE]; int sigsearch; }; double shift; int symbollen; int nbits; int stoplen; int msb; bool useFSK; RTTY_CHANNEL channel[MAX_CHANNELS]; double rtty_squelch; double rtty_shift; double rtty_BW; double rtty_baud; int rtty_bits; RTTY_PARITY rtty_parity; int rtty_stop; bool rtty_msbfirst; int bflen; double bp_filt_lo; double bp_filt_hi; int txmode; int preamble; void clear_syncscope(); void update_syncscope(); cmplx mixer(double &phase, double f, cmplx in); unsigned char bitreverse(unsigned char in, int n); int decode_char(int ch); int rttyparity(unsigned int); bool rx(int ch, bool bit); int rttyxprocess(); char baudot_dec(int ch, unsigned char data); void Metric(int ch); public: view_rtty(trx_mode mode); ~view_rtty(); void init(); void rx_init(); void tx_init() {} void restart(); void reset_filters(int ch); int rx_process(const double *buf, int len); int tx_process(); void find_signals(); void clearch(int ch); void clear(); int get_freq(int n) { return (int)channel[n].frequency;} bool is_mark_space(int ch, int &); bool is_mark(int ch); }; //extern view_rtty *rttyviewer; #endif
3,982
C++
.h
158
23.297468
81
0.708025
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,476
sound.h
w1hkj_fldigi/src/include/sound.h
// ---------------------------------------------------------------------------- // // sound.h // // Copyright (C) 2006-2007 // Dave Freese, W1HKJ // // Copyright (C) 2007-2009 // Stelios Bounanos, M0GLD // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _SOUND_H #define _SOUND_H #include <iostream> #include <string> #include <cstring> #include <climits> # include <sndfile.h> #include <samplerate.h> #define SCBLOCKSIZE 512 class SndException : public std::exception { public: SndException(int err_ = 0) : err(err_), msg(std::string("Sound error: ") + err_to_str(err_)) { } SndException(const char* msg_) : err(1), msg(msg_) { } SndException(int err_, const std::string& msg_) : err(err_), msg(msg_) { } virtual ~SndException() throw() { } const char* what(void) const throw() { return msg.c_str(); } int error(void) const { return err; } protected: const char* err_to_str(int e) { return strerror(e); } int err; std::string msg; }; class SoundBase { protected: int sample_frequency; int txppm; int rxppm; // for interface to the samplerate resampling library SRC_STATE *tx_src_state; SRC_STATE *rx_src_state; double *wrt_buffer; SNDFILE* ofCapture; SNDFILE* ifPlayback; SNDFILE* ofGenerate; // 2 channel writes SRC_STATE *writ_src_state_left; SRC_STATE *writ_src_state_right; SRC_DATA *writ_src_data_left; SRC_DATA *writ_src_data_right; float *src_write_buffer_left; float *src_write_buffer_right; // 1 channel reads SRC_STATE *play_src_state; SRC_DATA *play_src_data; float *src_rd_out_buffer; float *src_rd_inp_buffer; float *out_pointer; double req_sample_rate; SF_INFO play_info; float modem_wr_sr; float modem_play_sr; bool new_playback; sf_count_t read_file(SNDFILE* file, float* buf, size_t count); void write_file(SNDFILE* file, float* buf_left, float *buf_right, size_t count); void write_file(SNDFILE* file, double* buf_left, double *buf_right, size_t count); public: SoundBase(); virtual ~SoundBase(); virtual int Open(int mode, int freq = 8000) = 0; virtual void Close(unsigned dir = UINT_MAX) = 0; virtual void Abort(unsigned dir = UINT_MAX) = 0; virtual size_t Write(double *, size_t) = 0; virtual size_t Write_stereo(double *, double *, size_t) = 0; virtual size_t resample_write(float *buf, size_t count) = 0; virtual size_t Read(float *, size_t) = 0; virtual void flush(unsigned dir = UINT_MAX) = 0; virtual bool must_close(int dir = 0) = 0; int startCapture(std::string fname, int format); void stopCapture(); int startPlayback(std::string fname, int format); void stopPlayback(); int startGenerate(std::string fname, int format); void stopGenerate(); int AudioMP3(std::string fname); int AudioWAV(std::string fname); int Audio(std::string fname); }; #if USE_OSS class SoundOSS : public SoundBase { private: std::string device; int device_fd; int version; int capability_mask; int format_mask; int channels; int play_format; int mode; bool formatok; unsigned char *cbuff; SRC_DATA *rx_src_data; SRC_DATA *tx_src_data; float *snd_buffer; float *src_buffer; void getVersion(); void getCapabilities(); void getFormats(); void setfragsize(); void Channels(int); void Frequency(int); void Format(int); int BufferSize(int); bool wait_till_finished(); bool reset_device(); public: SoundOSS(const char *dev = "/dev/dsp"); ~SoundOSS(); int Open(int mode, int freq = 8000); void Close(unsigned dir = UINT_MAX); void Abort(unsigned dir = UINT_MAX) { Close(dir); } size_t Write(double *, size_t); size_t Write_stereo(double *, double *, size_t); size_t resample_write(float *buf, size_t count); size_t Read(float *, size_t); bool must_close(int dir = 0) { return true; } void flush(unsigned dir = UINT_MAX) { wait_till_finished(); } private: int Fd() { return device_fd; } int Frequency() { return sample_frequency;}; int Version() {return version;}; int Capabilities() {return capability_mask;}; int Formats() { return format_mask;}; int Channels() { return channels;}; int Format() { return play_format;}; bool FormatOK() { return formatok;}; }; #endif // USE_OSS #if USE_PORTAUDIO # include <pthread.h> # include <semaphore.h> # include <vector> # include <portaudio.h> # include "ringbuffer.h" class SoundPort : public SoundBase { public: typedef std::vector<const PaDeviceInfo*>::const_iterator device_iterator; static void initialize(void); static void terminate(void); static const std::vector<const PaDeviceInfo*>& devices(void); static void devices_info(std::string& in, std::string& out); static const std::vector<double>& get_supported_rates(const std::string& name, unsigned dir); public: SoundPort(const char *in_dev, const char *out_dev); ~SoundPort(); int Open(int mode, int freq = 8000); void Close(unsigned dir = UINT_MAX); void Abort(unsigned dir = UINT_MAX); size_t Write(double *buf, size_t count); size_t Write_stereo(double *bufleft, double *bufright, size_t count); size_t Read(float *buf, size_t count); bool must_close(int dir = 0); void flush(unsigned dir = UINT_MAX); private: void src_data_reset(unsigned dir); static long src_read_cb(void* arg, float** data); size_t resample_write(float* buf, size_t count); device_iterator name_to_device(std::string& name, unsigned dir); void init_stream(unsigned dir); void start_stream(unsigned dir); void pause_stream(unsigned dir); bool stream_active(unsigned dir); bool full_duplex_device(const PaDeviceInfo* dev); double find_srate(unsigned dir); static void probe_supported_rates(const device_iterator& idev); void pa_perror(int err, const char* str = 0); static void init_hostapi_ext(void); static PaStreamCallback stream_process; static PaStreamFinishedCallback stream_stopped; private: static bool pa_init; static std::vector<const PaDeviceInfo*> devs; float* fbuf; float* src_buffer; SRC_DATA *tx_src_data; enum { spa_continue = paContinue, spa_complete = paComplete, spa_abort = paAbort, spa_drain, spa_pause }; struct stream_data { std::string device; device_iterator idev; PaStream* stream; PaStreamParameters params; unsigned frames_per_buffer; double dev_sample_rate; double src_ratio; sem_t* rwsem; pthread_mutex_t* cmutex; pthread_cond_t* ccond; int state; ringbuffer<float>* rb; size_t blocksize; size_t advance; } sd[2]; }; class SndPortException : public SndException { public: SndPortException(int err_ = 0) : SndException(err_, std::string("PortAudio error: ") + err_to_str(err_)) { } SndPortException(const char* msg_) : SndException(msg_) { } protected: const char* err_to_str(int e) { return Pa_GetErrorText(e); } }; #endif // USE_PORTAUDIO #if USE_PULSEAUDIO # include <pulse/simple.h> # include <pulse/error.h> extern "C" { const char* pa_get_library_version(void); }; class SoundPulse : public SoundBase { public: SoundPulse(const char* dev); virtual ~SoundPulse(); int Open(int mode, int freq = 8000); void Close(unsigned dir = UINT_MAX); void Abort(unsigned dir = UINT_MAX); size_t Write(double* buf, size_t count); size_t Write_stereo(double* bufleft, double* bufright, size_t count); size_t Read(float *buf, size_t count); bool must_close(int dir = 0) { return false; } void flush(unsigned dir = UINT_MAX); private: void src_data_reset(int mode); static long src_read_cb(void* arg, float** data); size_t resample_write(float* buf, size_t count); private: struct stream_data { pa_simple* stream; pa_sample_spec stream_params; pa_buffer_attr buffer_attrs; pa_stream_direction_t dir; double src_ratio; size_t blocksize; } sd[2]; SRC_DATA* tx_src_data; float* fbuf; float* rbuf; float* snd_buffer; float* src_buffer; }; class SndPulseException : public SndException { public: SndPulseException(int err_ = 0) : SndException(err_, std::string("PulseAudio error: ") + err_to_str(err_)) { } SndPulseException(const char* msg_) : SndException(msg_) { } protected: const char* err_to_str(int e) { return pa_strerror(e); } }; #endif // USE_PULSEAUDIO class SoundNull : public SoundBase { public: int Open(int mode, int freq = 44100) { sample_frequency = freq; return 0; } void Close(unsigned) { } void Abort(unsigned) { } size_t Write(double* buf, size_t count); size_t Write_stereo(double* bufleft, double* bufright, size_t count); size_t Read(float *buf, size_t count); size_t resample_write(float* buf, size_t count){return 0;}; bool must_close(int dir = 0) { return false; } void flush(unsigned); }; namespace SND_SUPPORT { bool format_supported(int format); void get_file_params(std::string def_fname, std::string &fname, int &format, bool check); void tag_file(SNDFILE *sndfile, const char *title); }; #endif // SOUND_H
9,973
C++
.h
303
29.706271
94
0.677456
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,477
pskeval.h
w1hkj_fldigi/src/include/pskeval.h
// ---------------------------------------------------------------------------- // pskeval.cxx -- psk signal evaluator // // Copyright (C) 2008 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _PSKEVAL_H #define _PSKEVAL_H #include "complex.h" #include "filters.h" #include "waterfall.h" #define FLOWER 200 #define FUPPER 4000 class pskeval { private: double sigpwr[WF_FFTLEN]; double sigmin; double bw; public: pskeval(); ~pskeval(); void clear(); void setbw(double w) { bw = w;} void sigdensity(); double sigpeak(int &f, int f1, int f2); double peak(int &f, int f1, int f2, double level); double power(int f1, int f2); }; #endif
1,445
C++
.h
45
30.733333
82
0.658065
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,478
vumeter.h
w1hkj_fldigi/src/include/vumeter.h
// // vumeter.h // // vumeter bar widget routines. // ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _VUMETER_H #define _VUMETER_H // // Include necessary headers. // #include <FL/Fl.H> #include <FL/Fl_Box.H> #include <FL/Fl_Group.H> // // vumeter class... // class vumeter : public Fl_Widget { private: double value_, minimum_, maximum_, peakv_, peak_[10], vals_[10]; int avg_; int aging_; Fl_Color bgnd_; Fl_Color fgnd_; Fl_Color scale_color; Fl_Color peak_color; static const char *meter_face; void (*cbFunc)(Fl_Widget *, void *); protected: virtual void draw(); public: vumeter(int x, int y, int w, int h, const char *label = ""); void maximum(double v) { maximum_ = v; redraw(); } double maximum() const { return (maximum_); } void minimum(double v) { minimum_ = v; redraw(); } double minimum() const { return (minimum_); } void value(double v); double value(); void aging (int n); void avg (int n); void clear(); void set_background(Fl_Color c1) { bgnd_ = c1; redraw(); } void set_metercolor(Fl_Color c2) { fgnd_ = c2; redraw(); } void set_scalecolor(Fl_Color c3) { scale_color = c3; redraw(); } void set_peakcolor(Fl_Color c4) { peak_color = c4; redraw(); } int handle(int e) { if (Fl::event_inside( this )) { if (e == FL_RELEASE) { do_callback(); return 1; } } return 0; } void callback (void (*cbf)(Fl_Widget *, void *) ){ cbFunc = cbf;} void do_callback() { if (cbFunc) cbFunc(this, (void*)0); } }; #endif // !vumeter
2,368
C++
.h
82
26.792683
79
0.631184
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,479
testsigs.h
w1hkj_fldigi/src/include/testsigs.h
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #ifndef testsigs_h #define testsigs_h #include <FL/Fl.H> #include <FL/Fl_Double_Window.H> #include "flslider2.h" extern Fl_Counter2 *noiseDB; #include <FL/Fl_Check_Button.H> extern Fl_Check_Button *btnNoiseOn; #include <FL/Fl_Counter.H> extern Fl_Counter *ctrl_freq_offset; extern Fl_Check_Button *btnOffsetOn; extern Fl_Counter2 *xmtimd; extern Fl_Check_Button *btn_imd_on; #include <FL/Fl_Box.H> Fl_Double_Window* make_testdialog(); #endif
517
C++
.h
17
29.352941
73
0.783567
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,480
flinput2.h
w1hkj_fldigi/src/include/flinput2.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef FL_INPUT2_ #define FL_INPUT2_ #include <FL/Fl_Input.H> class Fl_Input2 : public Fl_Input { private: int ascii_cnt; // restart the numeric keypad entries. int ascii_chr; // character value of ASCII > 0x80 int handle_key_ascii(int key); char *utf8text; int utf8cnt; public: Fl_Input2(int x, int y, int w, int h, const char* l = 0); int handle(int event); }; #endif // FL_INPUT2_
1,290
C++
.h
35
35.514286
79
0.6392
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,481
tabdefs.h
w1hkj_fldigi/src/include/tabdefs.h
// ---------------------------------------------------------------------------- // // tabdefs.h // // Copyright (C) 2019 // Dave Freese, W1HKJ // // This file is part of fldigi. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef TABDEFS_H #define TABDEFS_H #define TAB_OLIVIA _("Modem/Olivia") #define TAB_CONTESTIA _("Modem/Contestia") #define TAB_DOMINOEX _("Modem/DominoEX") #define TAB_RTTY _("Modem/TTY/Rx") #define TAB_IFKP _("Modem/IFKP") #define TAB_FMT _("Modem/FMT") #define TAB_FSQ _("Modem/FSQ") #define TAB_THOR _("Modem/Thor") #define TAB_PSK _("Modem/Psk") #define TAB_MT63 _("Modem/MT-63") #define TAB_NAVTEX _("Modem/Navtex") #define TAB_WEFAX _("Modem/Wefax") #define TAB_FELDHELL _("Modem/Feld Hell") #define TAB_CW _("Modem/CW/General") #define TAB_STATION _("Operator-Station") #define TAB_RSID _("IDs/RsID") #define TAB_CPU _("Misc/CPU") #define TAB_NBEMS _("Misc/NBEMS") #define TAB_PSKREPORTER _("Misc/PSK reporter") #define TAB_SWEETSPOT _("Misc/Sweet Spot") #define TAB_TEXT_CAPTURE _("Misc/Rx text capture") #define TAB_DTMF _("Misc/DTMF") #define TAB_MISC_KML _("Misc/KML") #define TAB_AUTOSTART _("Misc/Autostart") #define TAB_MISC_IO _("Misc/IO") #define TAB_MISC_PSM _("Misc/PSM") #define TAB_CONTEST_GEN _("Contests/General") #define TAB_SOUND_DEVICES _("Soundcard/Devices") #define TAB_CONFIG_DIALOG _("Configure") #define TAB_UI_GENERAL _("UI/General") #define TAB_UI_BROWSER _("UI/Browser") #define TAB_UI_MACRO_BTNS _("UI/Macro buttons") #define TAB_UI_RXTEXT _("UI/Rx Text") #define TAB_UI_TOUCH _("UI/Touch") #define TAB_LOGGING _("Logging") #define TAB_WEB _("Web") #define TAB_CONTESTS _("Contests") #define TAB_RIG_CONTROL _("Rig Control") #define TAB_RIG_FLRIG _("Rig Control/flrig") #define TAB_RIG_RIGCAT _("Rig Control/CAT (rigcat)") #define TAB_RIG_HAMLIB _("Rig Control/Hamlib") #define TAB_WATERFALL _("Waterfall") #define TAB_LOG_N3FJP _("Logging/N3FJP logs") #define TAB_LOG_MACLOGGER _("Logging/MacLogger") #define TAB_LOG_LOTW _("Logging/LoTW") #define TAB_UI_CF_RXTX _("Colors-Fonts/Rx-Tx") #define TAB_UI_LOGGING_CLRS _("Colors-Fonts/Logging controls") #define TAB_UI_TAB_CLRS _("Colors-Fonts/Tabs") #define TAB_UI_FD_CLRS _("Colors-Fonts/FreqDisp - Meters") #define TAB_UI_FKEY_CLRS _("Colors-Fonts/Function keys") #define TAB_PSKMAIL _("Web/Pskmail") #define TAB_MISC_WX _("Web/WX") #endif
3,101
C++
.h
77
39.090909
79
0.670764
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,482
locator.h
w1hkj_fldigi/src/include/locator.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef LOCATOR_H_ #define LOCATOR_H_ #include <config.h> namespace QRB { enum {QRB_OK, QRB_EINVAL}; int qrb(double lon1, double lat1, double lon2, double lat2, double *distance, double *azimuth); double distance_long_path(double distance); double azimuth_long_path(double azimuth); int longlat2locator(double longitude, double latitude, char *locator_res, int pair_count); int locator2longlat(double *longitude, double *latitude, const char *locator); double dms2dec(int degrees, int minutes, double seconds, int sw); int dec2dms(double dec, int *degrees, int *minutes, double *seconds, int *sw); int dec2dmmm(double dec, int *degrees, double *minutes, int *sw); double dmmm2dec(int degrees, double minutes, int sw); } #endif /* LOCATOR_H_ */
1,654
C++
.h
35
45.657143
96
0.677861
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,483
record_browse.h
w1hkj_fldigi/src/include/record_browse.h
// generated by Fast Light User Interface Designer (fluid) version 1.0305 #ifndef record_browse_h #define record_browse_h #include <FL/Fl.H> #include "record_loader_gui.h" #include <FL/Fl_Double_Window.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Group.H> extern Fl_Group *tabDataFiles; #include <FL/Fl_Input_Choice.H> extern Fl_Input_Choice *inpDataSources; #include <FL/Fl_Light_Button.H> extern Fl_Light_Button *btnDataSourceUpdate; #include <FL/Fl_Button.H> extern Fl_Button *btnDataSourceReset; Fl_Double_Window* make_record_loader_window(); #endif
562
C++
.h
17
32
73
0.788603
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,484
pskvaricode.h
w1hkj_fldigi/src/include/pskvaricode.h
// ---------------------------------------------------------------------------- // varicode.h -- PSK31 Varicode // // Copyright (C) 2006 // Dave Freese, W1HKJ // // This file is part of fldigi. Adapted from code contained in gmfsk source code // distribution. // // Fldigi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Fldigi is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _VARICODE_H #define _VARICODE_H extern const char *psk_varicode_encode(unsigned char c); extern int psk_varicode_decode(unsigned int symbol); #endif
1,138
C++
.h
27
40.962963
82
0.650407
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,485
hid_lin.h
w1hkj_fldigi/src/include/hid_lin.h
/*********************************************************************** HIDAPI - Multi-Platform library for communication with HID devices. hid_lin.h Alan Ott Signal 11 Software Copyright 2009, All Rights Reserved. C++ implementation * Copyright 2021 * David Freese, W1HKJ * for use in fldigi This software is licensed under the terms of the GNU General Public License v3. ***********************************************************************/ #ifndef HIDAPI_H__ #define HIDAPI_H__ #include <cstring> #include <cstdio> #include <string> #include <wchar.h> #include <locale.h> #include <pthread.h> #include <sys/time.h> #include <unistd.h> #include <dlfcn.h> class hid_device { public: int device_handle; int blocking; int uses_numbered_reports; hid_device() { device_handle = -1; blocking = 1; uses_numbered_reports = 0; } ~hid_device() {} /** @brief Write an Output report to a HID device. The first byte of @p data[] must contain the Report ID. For devices which only support a single report, this must be set to 0x0. The remaining bytes contain the report data. Since the Report ID is mandatory, calls to hid_write() will always contain one more byte than the report contains. For example, if a hid report is 16 bytes long, 17 bytes must be passed to hid_write(), the Report ID (or 0x0, for devices with a single report), followed by the report data (16 bytes). In this example, the length passed in would be 17. hid_write() will send the data on the first OUT endpoint, if one exists. If it does not, it will send the data through the Control Endpoint (Endpoint 0). @ingroup API @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send. @returns This function returns the actual number of bytes written and -1 on error. */ int hid_write(const unsigned char *data, size_t length); /** @brief Read an Input report from a HID device with timeout. Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports. @ingroup API @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for the report number. @param milliseconds timeout in milliseconds or -1 for blocking wait. @returns This function returns the actual number of bytes read and -1 on error. If no packet was available to be read within the timeout period, this function returns 0. */ int hid_read_timeout(unsigned char *data, size_t length, int milliseconds); /** @brief Read an Input report from a HID device. Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for the report number. @returns This function returns the actual number of bytes read and -1 on error. If no packet was available to be read and the handle is in non-blocking mode, this function returns 0. */ int hid_read(unsigned char *data, size_t length); /** @brief Get a feature report from a HID device. Set the first byte of @p data[] to the Report ID of the report to be read. Make sure to allow space for this extra byte in @p data[]. Upon return, the first byte will still contain the Report ID, and the report data will start in data[1]. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into, including the Report ID. Set the first byte of @p data[] to the Report ID of the report to be read, or set it to zero if your device does not use numbered reports. @param length The number of bytes to read, including an extra byte for the report ID. The buffer can be longer than the actual report. @returns This function returns the number of bytes read plus one for the report ID (which is still in the first byte), or -1 on error. */ int hid_get_feature_report(unsigned char *data, size_t length); /** @brief Set the device handle to be non-blocking. In non-blocking mode calls to hid_read() will return immediately with a value of 0 if there is no data to be read. In blocking mode, hid_read() will wait (block) until there is data to read before returning. Nonblocking can be turned on and off at any time. @ingroup API @param device A device handle returned from hid_open(). @param nonblock enable or not the nonblocking reads - 1 to enable nonblocking - 0 to disable nonblocking. @returns This function returns 0 on success and -1 on error. */ int hid_set_nonblocking(int nonblock); /** @brief Send a Feature report to the device. Feature reports are sent over the Control endpoint as a Set_Report transfer. The first byte of @p data[] must contain the Report ID. For devices which only support a single report, this must be set to 0x0. The remaining bytes contain the report data. Since the Report ID is mandatory, calls to hid_send_feature_report() will always contain one more byte than the report contains. For example, if a hid report is 16 bytes long, 17 bytes must be passed to hid_send_feature_report(): the Report ID (or 0x0, for devices which do not use numbered reports), followed by the report data (16 bytes). In this example, the length passed in would be 17. @ingroup API @param device A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send, including the report number. @returns This function returns the actual number of bytes written and -1 on error. */ int hid_send_feature_report(const unsigned char *data, size_t length); /** @brief Close a HID device. @ingroup API @param device A device handle returned from hid_open(). */ void hid_close(); const char* hid_error(); }; /// hidapi info structure class hid_device_info { public: std::string path; unsigned short vendor_id; unsigned short product_id; unsigned short release_number; std::string str_serial_number; std::string str_manufacturer_string; std::string str_product_string; unsigned short usage_page; // Usage Page for this Device/Interface (Windows/Mac only). unsigned short usage;// Usage for this Device/Interface (Windows/Mac only).*/ /** The USB interface which this logical device represents. Valid on both Linux implementations in all cases, and valid on the Windows implementation only if the device contains more than one interface. */ int interface_number; hid_device_info *next; hid_device_info() {} ~hid_device_info() {} }; /** @brief Enumerate the HID Devices. This function returns a linked list of all the HID devices attached to the system which match vendor_id and product_id. If @p vendor_id is set to 0 then any vendor matches. If @p product_id is set to 0 then any product matches. If @p vendor_id and @p product_id are both set to 0, then all HID devices will be returned. @ingroup API @param vendor_id The Vendor ID (VID) of the types of device to open. @param product_id The Product ID (PID) of the types of device to open. @returns This function returns a pointer to a linked list of type struct #hid_device, containing information about the HID devices attached to the system, or NULL in the case of failure. Free this linked list by calling hid_free_enumeration(). */ hid_device_info *hid_enumerate(unsigned short vendor_id, unsigned short product_id); /** @brief Free an enumeration Linked List This function frees a linked list created by hid_enumerate(). @ingroup API @param devs Pointer to a list of struct_device returned from hid_enumerate(). */ void hid_free_enumeration(hid_device_info *devs); /** @brief Initialize the HIDAPI library. This function initializes the HIDAPI library. Calling it is not strictly necessary, as it will be called automatically by hid_enumerate() and any of the hid_open_*() functions if it is needed. This function should be called at the beginning of execution however, if there is a chance of HIDAPI handles being opened by different threads simultaneously. @ingroup API @returns This function returns 0 on success and -1 on error. */ int hid_init(void); /** @brief Finalize the HIDAPI library. This function frees all of the static data associated with HIDAPI. It should be called at the end of execution to avoid memory leaks. @ingroup API @returns This function returns 0 on success and -1 on error. */ /** @brief Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. If @p serial_number is NULL, the first device with the specified VID and PID is opened. @ingroup API @param vendor_id The Vendor ID (VID) of the device to open. @param product_id The Product ID (PID) of the device to open. @param serial_number The Serial Number of the device to open (Optionally NULL). @returns This function returns a pointer to a #hid_device object on success or NULL on failure. */ hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, std::string serial_number = ""); /** @brief Open a HID device by its path name. The path name be determined by calling hid_enumerate(), or a platform-specific path name can be used (eg: /dev/hidraw0 on Linux). @ingroup API @param path The path name of the device to open @returns This function returns a pointer to a #hid_device object on success or NULL on failure. */ hid_device * hid_open_path(std::string path); int hid_exit(void); #endif
9,938
C++
.h
248
37.741935
108
0.751665
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,486
pj_fifo.h
w1hkj_fldigi/src/include/jalocha/pj_fifo.h
// (c) 2019, David Freese, W1HKJ #ifndef __FIFO_H__ #define __FIFO_H__ #include "pj_struc.h" // a simple FIFO buffer template <class Type> class FIFO { public: size_t Len; private: size_t ReadPtr; size_t WritePtr; Type *Data; public: FIFO() { Init(); } ~FIFO() { delete [] Data; } void Init(void) { Data = 0; Len = 0; } void Free(void) { delete [] Data; Data = 0; Len = 0; } void Reset(void) { ReadPtr = WritePtr = 0; } void Clear(void) { ReadPtr = WritePtr; } int Preset(void) { if (ReallocArray(&Data, Len) < 0) return -1; Reset(); return 0; } // increment the pointer (with wrapping around) void IncrPtr(size_t &Ptr, size_t Step = 1) { Ptr += Step; if (Ptr >= Len) Ptr-=Len; } // FIFO is full ? int Full(void) { size_t Ptr = WritePtr; IncrPtr(Ptr); return (Ptr == ReadPtr); } // FIFO is empty ? int Empty(void) { return (ReadPtr == WritePtr); } // how many elements we can write = space left in the FIFO size_t WriteReady(void) { int Ready = ReadPtr - WritePtr; if (Ready <= 0) Ready += Len; return Ready - 1; } // how many elements we can read = space taken in the FIFO size_t ReadReady(void) { int Ready = WritePtr - ReadPtr; if (Ready < 0) Ready += Len; return Ready; } // write a new element int Write(Type &NewData) { size_t Ptr = WritePtr; IncrPtr(Ptr); if (Ptr == ReadPtr) return 0; Data[WritePtr] = NewData; WritePtr = Ptr; return 1; } // read the oldest element int Read(Type &OldData) { if (ReadPtr == WritePtr) return 0; OldData = Data[ReadPtr]; IncrPtr(ReadPtr); return 1; } // lookup data in the FIFO but without taking them out int Lookup(Type &OldData, size_t Offset = 0) { size_t Ready = ReadReady(); if (Offset >= Ready) return 0; size_t Ptr = ReadPtr; IncrPtr(Ptr,Offset); OldData = Data[Ptr]; return 1; } }; #endif // of __FIFO_H__
1,894
C++
.h
89
18.707865
59
0.648573
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,488
pj_struc.h
w1hkj_fldigi/src/include/jalocha/pj_struc.h
// data structures, includes dynamically allocated vectors and arrays // (c) 1999-2003, Pawel Jalocha // (c) 2019, David Freese, W1HKJ #ifndef __STRUC_H__ #define __STRUC_H__ #include <stdio.h> #include <stdlib.h> #include <string.h> // ======================================================================== // array re(sizing), copy, move, preset, etc. template <class type> inline int ReallocArray(type **Array, size_t Size) { delete [] *Array; *Array = new type[Size]; return (*Array == 0); } template <class type> inline int AllocArray(type **Array, size_t Size) { (*Array)= new type[Size]; return (*Array)== 0 ; } template <class type> inline void ClearArray(type *Array, size_t Size) { memset(Array,0,Size*sizeof(type)); } template <class type> void PresetArray(type *Array, size_t Size, const type &Val) { size_t i; for (i = 0; i < Size; i++) Array[i] = Val; } template <class type> inline void CopyArray(type *Dst, type *Src, size_t Size) { memcpy(Dst, Src, Size * sizeof(type)); } template <class type> inline void MoveArray(type *Dst, type *Src, size_t Size) { memmove(Dst ,Src, Size * sizeof(type)); } template <class type> void PrintArray(type *Array, size_t Size, char *ValueFormat, char *IndexFormat=(char *)"%3d", size_t Columns=10) { size_t Idx,Col; for (Col = 0, Idx = 0; Idx < Size; Idx++) { if (Col == 0) { printf(IndexFormat,Idx); printf(":"); } printf(" "); printf(ValueFormat, Array[Idx]); Col++; if (Col >= Columns) { printf("\n"); Col=0; } } if (Col > 0) printf("\n"); } // ======================================================================== // a sequence of any (fixed size) items template <class type> class Seq { public: Seq(); ~Seq(); // default constructor/destructor Seq(Seq<type> &SrcSeq); // copy constructor void Init(); // user callable "constructor" int EnsureSpace(size_t ReqSpace); // make sure that there is enough space int EnsureSpace(void) { return EnsureSpace(Len); } int SetLen(size_t NewLen) { Len=NewLen; return EnsureSpace(Len); } int ReallocLen(size_t NewLen); int EnsureSpaceSafe(size_t ReqSpace); void Free(void); // free all allocated space, remove all data void Clear(void) { Len=0; } // clear the sequence (set length to zero) size_t Index(type *Item) { return (size_t)(Item-Elem); } type &operator[] (int idx) { return (Elem[idx]); } // [index] operator Seq<type> const &operator=(Seq<type> const &SrcSeq); // assignment operator type *First(void) { return Elem; } type *Last(void) { return Elem+(Len-1); } type *Append(size_t Num=1); // add one or more elements at the seq. end, returns the pointer to the new element(s) type *Insert(size_t Pos=0, size_t Num=1); // insert Num elements at Pos void Delete(size_t Pos=0, size_t Num=1); // delete Num elements at Pos void Shift(int Pos, const type &Fill); // shift left or right with filling int Truncate(size_t Margin=0); // remove unused but allocated space int Copy(type *Data, size_t DataLen); int Copy(Seq<type> &Src, size_t StartPos=0) // copy the contains of another sequence { return Copy(Src.Elem + StartPos, Src.Len - StartPos); } int Copy(Seq<type> &Seq, size_t StartPos, size_t MaxLen); void Move(Seq<type> &Seq); // move the contains of another sequence, clear the other sequence int Join(const type &Data); int Join(type *Data, size_t DataLen); // join (append) given data int Join(Seq<type> &Seq) { return Join(Seq.Elem,Seq.Len); } // join a copy of the other sequence int NullTerm(void); // null-terminate (for character strings) void Reverse(void); // reverse the sequence order void FillWith(const type &Data, size_t StartPos=0); // fill with given value void Print(char *Format, size_t Columns=10); int SaveToFile(FILE *File); int LoadFromFile(FILE *File); public: size_t Space; // that many elements are allocated in *Elem size_t Len; // that many elements are used up type *Elem; // the storage space, contains Len elements } ; template <class type> Seq<type>::Seq() { Elem=0; Len=Space=0; } template <class type> void Seq<type>::Init() { Elem=0; Len=Space=0; } template <class type> Seq<type>::~Seq() { delete [] (Elem); } template <class type> Seq<type>::Seq(Seq<type> &SrcSeq) { if (EnsureSpace(SrcSeq.Len) == 0) { Len = SrcSeq.Len; memcpy(Elem, SrcSeq.Elem, Len * sizeof(type)); } } template <class type> void Seq<type>::Free(void) { delete [] Elem; Elem = 0; Space = Len = 0; } template <class type> int Seq<type>::EnsureSpace(size_t ReqSpace) { if (ReqSpace <= Space) return 0; delete [] Elem; Elem = new type[ReqSpace * sizeof(type)]; if (Elem == 0) { Space = Len = 0; return -1; } Space = ReqSpace; return 0; } template <class type> Seq<type> const &Seq<type>::operator=(Seq<type> const &SrcSeq) { if ((this != &SrcSeq) && (EnsureSpace(SrcSeq.Len) == 0)) { Len = SrcSeq.Len; memcpy(Elem, SrcSeq.Elem, Len* sizeof(type)); } return (*this); } template <class type> int Seq<type>::ReallocLen(size_t NewLen) { delete [] Elem; Elem = new type[NewLen * sizeof(type)]; if (Elem == 0) { Space = Len = 0; return -1; } Space = Len = NewLen; return 0; } template <class type> int Seq<type>::Truncate(size_t Margin) { if (Space == (Len + Margin)) return 0; delete [] Elem; Elem = new type[(Len + Margin) * sizeof(type)]; if (Elem == 0) { Space = Len = 0; return -1; } Space = Len+Margin; return 0; } template <class type> void Seq<type>::Move(Seq<type> &Seq) { delete [] Elem; Len = Seq.Len; Space = Seq.Space; Elem = Seq.Elem; Seq.Elem = 0; Seq.Len = Seq.Space = 0; } template <class type> int Seq<type>::Copy(type *Data, size_t DataLen) { if (EnsureSpace(DataLen)) return -1; memcpy(Elem, Data, DataLen * sizeof(type)); Len = DataLen; return 0; } template <class type> int Seq<type>::Copy(Seq<type> &Src, size_t StartPos, size_t MaxLen) { int DataLen; DataLen = Src.Len - StartPos; if (DataLen > MaxLen) DataLen = MaxLen; if (EnsureSpace(DataLen)) return -1; memcpy(Elem, Src.Elem + StartPos, DataLen * sizeof(type)); Len = DataLen; return 0; } template <class type> int Seq<type>::Join(const type &Data) { if (EnsureSpace(Len + 1)) return -1; Elem[Len++] = Data; return 0; } template <class type> int Seq<type>::Join(type *Data, size_t DataLen) { if (EnsureSpace(Len + DataLen)) return -1; memcpy(Elem + Len, Data, DataLen * sizeof(type)); Len += DataLen; return 0; } template <class type> type *Seq<type>::Insert(size_t Pos, size_t Num) { if (EnsureSpace(Len + Num)) return 0; if ((Len - Pos) > 0) memmove(Elem + Pos + Num, Elem + Pos, (Len - Pos) * sizeof(type)); Len += Num; return Elem + Pos; } template <class type> void Seq<type>::Delete(size_t Pos, size_t Num) { if ((Len - Pos - Num) > 0) memmove(Elem + Pos, Elem + Pos + Num, (Len - Pos - Num) * sizeof(type)); Len -= Num; } template <class type> type *Seq<type>::Append(size_t Num) { if (EnsureSpace(Len + Num)) return 0; Len += Num; return Elem + (Len - Num); } template <class type> void Seq<type>::Reverse(void) { size_t i, j; type T; for (i = 0,j = Len - 1; i < j; i++, j--) { T = Elem[i]; Elem[i] = Elem[j]; Elem[j] = T; } } template <class type> void Seq<type>::FillWith(const type &Data, size_t StartPos) { size_t i; for (i = StartPos; i < Len; i++) Elem[i] = Data; } template <class type> void Seq<type>::Shift(int Pos, const type &Fill) { size_t i; if (Pos > 0) { // shift toward higher positions - data inserted at the start of the sequence if (Pos < Len) memmove(Elem+Pos,Elem,(Len-Pos)*sizeof(type)); else Pos = Len; for (i = 0; i < Pos; i++) Elem[i] = Fill; } else if (Pos < 0) { // shift toward lower positions - data inserted at the end Pos = (-Pos); if (Pos < Len) memmove(Elem,Elem+Pos,(Len-Pos)*sizeof(type)); else Pos = Len; for (i = Len - Pos; i < Len; i++) Elem[i]=Fill; } } template <class type> void Seq<type>::Print(char *Format, size_t Columns) { size_t i,Col; for (Col = 0, i = 0; i < Len; i++) { if (Col == 0) { printf("%3d:",i); } printf(" "); printf(Format,Elem[i]); Col++; if (Col >= Columns) { printf("\n"); Col=0; } } if (Col > 0) printf("\n"); } // ======================================================================== // A buffer structure for processing a continues series of samples. // It is a linear array: // - data between "Read" and "Write" is ready to be readout // - data between "Write" and "Size" is still beeing written or processed // - data before "Read" has been read-out and is thus obsolete // As more data comes the samples must be shifted and the obsolete data removed: // this is done by: RemovePastData() template <class Type> class SampleBuffer { public: SampleBuffer() { Sample = 0; AllocSize = Size = Read = Write = 0; } ~SampleBuffer() { delete [] Sample; } void Free(void) { delete [] Sample; Sample = 0; AllocSize = Size = Read = Write = 0; } int EnsureSize(size_t MaxSize) { // printf(" SampleBuffer::EnsureSize(%d)\n",MaxSize); if (MaxSize <= AllocSize) return 0; delete [] Sample; Sample = new Type[MaxSize * sizeof(Type)]; if (Sample == 0) { AllocSize = Size = 0; return -1; } AllocSize = MaxSize; return 0; } int EnsureWriteLen(size_t MaxWriteLen) // ensure enough space for writing new data { return EnsureSize(Write+MaxWriteLen); } void SetEmpty(void) // remove all data, make buffer empty { Read = Write = Size = 0; } void RemovePastData(void) // remove data before the read pointer { memcpy(Sample, Sample + Read, (Size - Read) * sizeof(Type)); Write -= Read; Size -= Read; Read = 0; } Type &operator[] (size_t Idx) // access data given by index { return Sample[Idx]; } size_t ReadLen(void) // length of data to be read { return Write - Read; } Type *ReadPtr(void) // get pointer to read data { return Sample + Read; } size_t WriteLen(void) // length of data that can be written { return Size - Write; } Type *WritePtr(void) // get pointer to write data { return Sample + Write; } void Print(char *Title=0) { printf("%s Sample=%08X, Read=%d, Write=%d, Size=%d, AllocSize=%d\n", Title ? Title:"SampleBuffer:", (int)Sample, Read, Write, Size, AllocSize); } public: Type *Sample; // allocated storage pointer size_t Read; // index to data that is ready to be read size_t Write; // index to data that is still to be written size_t Size; // current size of data (includes data before the read pointer) size_t AllocSize; // allocated size for data } ; // ======================================================================== #endif // __STRUC_H__
10,787
C++
.h
370
27.008108
115
0.64232
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,489
pj_cmpx.h
w1hkj_fldigi/src/include/jalocha/pj_cmpx.h
// Complex numbers // (c) 1999-2003, Pawel Jalocha // (c) 2019, David Freese, W1HKJ #ifndef __CMPX_H__ #define __CMPX_H__ #include <stdio.h> #include <math.h> // ---------------------------------------------------------------------------- // float/double/other-complex type template <class Type> class Cmpx { public: Type Re,Im; public: template <class Type2> Cmpx<Type> const &operator=(const Cmpx<Type2> &New) { Re = New.Re; Im = New.Im; return (*this); } template <class Type2> Cmpx<Type> const &operator=(const Type2 &New) { Re = New; Im = 0; return (*this); } template <class Type2> void Set(Type2 NewRe, Type2 NewIm = 0) { Re = NewRe; Im = NewIm; } template <class Type2> void Set(Cmpx<Type2> New) { Re = New.Re; Im = New.Im; } void SetPhase(double Phase, double Mag = 1.0) { Re = Mag * cos(Phase); Im = Mag * sin(Phase); } void Conugate(void) { Im = (-Im); } void Negate(void) { Re = (-Re); Im = (-Im); } void QuarterTurnLeft(void) { Type OldIm = Im; Im = Re; Re = (-OldIm); } void QuarterTurnRight(void) { Type OldIm = Im; Im = (-Re); Re = OldIm; } double Energy(void) { return Re * Re + Im * Im; } double Mag2(void) { return Re * Re + Im * Im; } double Mag(void) { return sqrt(Re * Re + Im * Im); } double Phase(void) { return atan2(Im, Re); } int Zero(void) { return (Re == 0) && (Im == 0); } int NotZero(void) { return (Re != 0) || (Im != 0); } // template <class Type2> // void operator *= (const Type2 Mult) // { Re*=Mult; Im*=Mult; } // template <class Type2> // void operator /= (const Type2 Mult) // { Re*=Mult; Im*=Mult; } template <class Type2> double VectDotProd(Cmpx<Type2> X) { return Re * X.Re + Im * X.Im; } void Print(char *Form = (char *)"%+6.3f") { printf("["); printf(Form, Re); printf(","); printf(Form, Im); printf("]"); } } ; typedef Cmpx<float> fcmpx; typedef Cmpx<double> dcmpx; // Some complex operators: // at least with the BC++ they carry some overhead because // a function is always called instead of making the code inline. template <class type> // equal (both Re and Im) ? inline int operator ==(Cmpx<type> &Left, Cmpx<type> &Right) { return (Left.Re == Right.Re) && (Left.Im == Right.Im); } template <class LeftType, class RightType> // equal (both Re and Im) ? inline int operator !=(Cmpx<LeftType> &Left, Cmpx<RightType> &Right) { return (Left.Re != Right.Re) || (Left.Im != Right.Im); } template <class type> // equal ? inline int operator ==(Cmpx<type> &Left, type &Right) { return (Left.Re == Right) && (Left.Im == 0); } template <class LeftType, class RightType> // not equal ? inline int operator !=(Cmpx<LeftType> &Left, RightType &Right) { return (Left.Re != Right) || (Left.Im != 0); } template <class type> // bigger (magnitude) ? inline int operator >(Cmpx<type> &Left, Cmpx<type> &Right) { return Left.Mag2() > Right.Mag2(); } template <class type> // smaller (magnitude) ? inline int operator <(Cmpx<type> &Left, Cmpx<type> &Right) { return Left.Mag2() < Right.Mag2(); } template <class type> // addition to the argument on the left inline void operator +=(Cmpx<type> &Dst, Cmpx<type> &Src) { Dst.Re += Src.Re; Dst.Im += Src.Im; } template <class type> // subtraction from the argument on the left inline void operator -=(Cmpx<type> &Dst, Cmpx<type> &Src) { Dst.Re -= Src.Re; Dst.Im -= Src.Im; } template <class type, class num> // multiplication by a scalar inline void operator *=(Cmpx<type> &Dst, num Src) { Dst.Re *= Src; Dst.Im *= Src; } template <class type, class type2> // multiplication by another complex number inline void operator *=(Cmpx<type> &Dst, Cmpx<type2> Src) { type Re = Dst.Re * Src.Re - Dst.Im * Src.Im; type Im = Dst.Re * Src.Im + Dst.Im * Src.Re; Dst.Re = Re; Dst.Im = Im; } template <class type, class num> // division by a scalar inline void operator /=(Cmpx<type> &Dst, num Src) { Dst.Re /= Src; Dst.Im /= Src; } template <class type> // scalar multiplication inline double operator *(Cmpx<type> &Left, Cmpx<type> &Right) { return Left.Re * Right.Re + Left.Im * Right.Im; } // some arithmetic functions: // scalar product of two vectors template <class typeA, class typeB> inline double ScalProd(Cmpx<typeA> &A, Cmpx<typeB> &B) { return A.Re * B.Re + A.Im * B.Im; } template <class typeA, class typeB> inline double ScalProd(typeA Ia, typeA Qa, Cmpx<typeB> &B) { return Ia * B.Re + Qa*B.Im; } // complex multiply template <class typeDst, class typeA, class typeB> inline void CmpxMultAxB(Cmpx<typeDst> &Dst, Cmpx<typeA> &A, Cmpx<typeB> &B) { Dst.Re = A.Re * B.Re - A.Im * B.Im; Dst.Im = A.Re * B.Im + A.Im * B.Re; } template <class typeDst, class typeA, class typeB> inline void CmpxMultAxB(typeDst &DstI, typeDst &DstQ, Cmpx<typeA> &A, Cmpx<typeB> &B) { DstI = A.Re * B.Re - A.Im * B.Im; DstQ = A.Re * B.Im + A.Im * B.Re; } // complex multiply, second argument with a "star" (B.im is negated) // (effectively subtracts the phase of the second argument) template <class typeDst, class typeA, class typeB> inline void CmpxMultAxBs(Cmpx<typeDst> &Dst, Cmpx<typeA> &A, Cmpx<typeB> &B) { Dst.Re = A.Re * B.Re + A.Im * B.Im; Dst.Im = A.Im * B.Re - A.Re * B.Im; } template <class Type> void CmpxSqrt(Cmpx<Type> &X) { Type Mag = X.Mag(); int NegIm = (X.Im < 0); X.Im = sqrt((Mag - X.Re) / 2); X.Re = sqrt((Mag + X.Re) / 2); if (NegIm) X.Re = (-X.Re); } template <class Type> void CmpxSquare(Cmpx<Type> &X) { Type Re = X.Re * X.Re - X.Im * X.Im; X.Im = 2 * X.Re * X.Im; X.Re = Re; } // ---------------------------------------------------------------------------- #endif /* __CMPX_H__ */
5,665
C++
.h
197
26.725888
87
0.63425
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,490
pj_gray.h
w1hkj_fldigi/src/include/jalocha/pj_gray.h
// Gray code convertion // (c) 2004, Pawel Jalocha // (c) 2019, David Freese, W1HKJ #ifndef __GRAY_H__ #define __GRAY_H__ #include <stdint.h> template <class Type> Type GrayCode(Type Binary) { return Binary ^ (Binary >> 1); } inline uint8_t BinaryCode(uint8_t Gray) { Gray ^= (Gray >> 4); Gray ^= (Gray >> 2); Gray ^= (Gray >> 1); return Gray; } inline uint16_t BinaryCode(uint16_t Gray) { Gray ^= (Gray >> 8); Gray ^= (Gray >> 4); Gray ^= (Gray >> 2); Gray ^= (Gray >> 1); return Gray; } inline uint32_t BinaryCode(uint32_t Gray) { Gray ^= (Gray >> 16); Gray ^= (Gray >> 8); Gray ^= (Gray >> 4); Gray ^= (Gray >> 2); Gray ^= (Gray >> 1); return Gray; } #endif
685
C++
.h
32
19.65625
43
0.609907
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,491
pj_fft.h
w1hkj_fldigi/src/include/jalocha/pj_fft.h
// Fast Fourier Transform // (c) 1999-2004, Pawel Jalocha #ifndef __FFT_H__ #define __FFT_H__ #include <math.h> #include "pj_cmpx.h" #include "pj_struc.h" // ---------------------------------------------------------------------------- /* How to use the r2FFT class: 1. define the object: r2FFT<dcmpx> FFT; 2. preset it for given FFT length: ret=FFT.Preset(1024); if return code is negative => your RAM is out, you can't use the FFT object. - after FFT.Preset() you have the unscrambling table in FFT.BitRevIdx[] and the full (co)sine table in FFT.Twiddle[] 3. for forward complex FFT of "Data": FFT.Process(Data); (this includes unscrambling) 4. for inverse complex FFT of "Data": - first: negate the imaginary part of "Data" - second: execute FFT.Process(Data); - third: negate (again) the imaginary part of "Data" New feature: you can call FFT.Process(Data,Len); 5. You may call FFT.Free() to free allocated RAM, but you will need to call FFT.Preset() before using the FFT object again. 6. Scaling: each pass of the FFT.Process(Data) multiplies the energy of the sequence contained in "Data" by the length of the FFT. To get the same scale (amplitude) after executing one forward and another inverse FFT you need to multiply the sequence by 1/length. 7. To make an FFT of two _real_ time sequences in one go: - place the first time sequence in the real part of complex "Data" - place the second time sequence in the imaginary part of "Data" - execute: FFT.Process(Data); - execute: FFT.SeparTwoReals(Data,Spectr1,Spectr2); where Spectr1/2 are complex arrays half the size of the FFT length. Spectr1/2 contains now the complex FFT result for the first and second real input sequence - Scaling: the sequence energy is multiplied by FFT length 8. To execute an Inverse FFT as to get two real sequences out of two spectral data: - have the two freq. sequeces in Spectr1/2 - execute: FFT.JoinTwoReals(Spectr1,Spect2,Data); - execute: FFT.Process(Data); - Data[].Re contains the first time sequence - Data[].Im contains the second time sequence - Spectr1/2 and Data arrays are like for SeparTwoReals() - Scaling: the sequence energy is multiplied by _twice_ the FFT length */ template <class Type> class r2FFT { public: // size must a power of 2: 2,4,8,16,32,64,128,256,... r2FFT(int MaxSize) { BitRevIdx = 0; Twiddle = 0; Preset(MaxSize); } r2FFT() { BitRevIdx = 0; Twiddle = 0; } ~r2FFT() { delete [] BitRevIdx; //free(BitRevIdx); delete [] Twiddle; //free(Twiddle); } void Free(void) { delete [] BitRevIdx; //free(BitRevIdx); delete [] Twiddle; //free(Twiddle); BitRevIdx = 0; Twiddle = 0; } // preset tables for given (maximum) processing size int Preset(int MaxSize) { size_t idx, ridx, mask, rmask; double phase; size_t Size4; if (MaxSize < 4) goto Error; Size = MaxSize; while ((MaxSize & 1) == 0) MaxSize >>= 1; if (MaxSize != 1) goto Error; if (ReallocArray(&BitRevIdx, Size) < 0) goto Error; if (ReallocArray(&Twiddle,Size) < 0) goto Error; Size4 = Size/4; for (idx = 0; idx < Size4; idx++) { phase = (2 * M_PI * idx)/Size; Twiddle[idx].SetPhase(phase); } for ( ; idx < Size; idx++) { Twiddle[idx].Re = (-Twiddle[idx - Size4].Im); Twiddle[idx].Im = Twiddle[idx - Size4].Re; } for (ridx = 0, idx=0; idx < Size; idx++) { for (ridx = 0, mask = Size/2, rmask = 1; mask; mask >>= 1, rmask <<= 1) { if (idx & mask) ridx |= rmask; } BitRevIdx[idx] = ridx; /* printf("%04x %04x\n",idx,ridx); */ } return 0; Error: Free(); return -1; } // scramble/unscramble (I)FFT input template <class DataType> void Scramble(DataType x[]) { size_t idx, ridx; DataType tmp; for (idx = 0; idx < Size; idx++) { if ((ridx = BitRevIdx[idx]) > idx) { tmp = x[idx]; x[idx] = x[ridx]; x[ridx] = tmp; /* printf("%d <=> %d\n",idx,ridx); */ } } } template <class DataType> void Scramble(DataType x[], size_t ShrinkShift) { size_t idx,ridx; DataType tmp; size_t Len = Size >> ShrinkShift; for (idx = 0; idx < Len; idx++) { ridx = BitRevIdx[idx]; ridx >>= ShrinkShift; if (ridx > idx) { tmp = x[idx]; x[idx] = x[ridx]; x[ridx] = tmp; /* printf("%d <=> %d\n",idx,ridx); */ } } } // separate the result of a two real channels FFT template <class BuffType, class DataType> void SeparTwoReals(BuffType Buff[], DataType Out0[], DataType Out1[]) { int idx, HalfSize = Size/2; // for(idx=0; idx<Size; idx++) // printf("%2d %9.5f %9.5f\n",idx,Buff[idx].Re,Buff[idx].Im); Out0[0].Re = Buff[0].Re; Out1[0].Re = Buff[0].Im; for (idx = 1; idx < HalfSize; idx++) { Out0[idx].Re = Buff[idx].Re + Buff[Size - idx].Re; Out0[idx].Im = Buff[idx].Im - Buff[Size - idx].Im; Out1[idx].Re = Buff[idx].Im + Buff[Size - idx].Im; Out1[idx].Im = (-Buff[idx].Re) + Buff[Size - idx].Re; } Out0[0].Im = Buff[HalfSize].Re; Out1[0].Im = Buff[HalfSize].Im; // for(idx=0; idx<HalfSize; idx++) // printf("%2d %9.5f %9.5f %9.5f %9.5f\n", // idx,Out0[idx].Re,Out0[idx].Im,Out1[idx].Re,Out1[idx].Im); } // the oposite of SeparTwoReals() // but we NEGATE the .Im part for Inverse FFT // and we NEGATE the Inp1[] so that after Process() // both .Re and .Im come out right (no need to negate the .Im part) // as a "by-product" we multiply the transform by 2 template <class BuffType, class DataType> void JoinTwoReals(DataType Inp0[], DataType Inp1[], BuffType Buff[]) { int idx, HalfSize = Size/2; // for(idx=0; idx<HalfSize; idx++) // printf("%2d %9.5f %9.5f %9.5f %9.5f\n", // idx,Inp0[idx].Re,Inp0[idx].Im,Inp1[idx].Re,Inp1[idx].Im); Buff[0].Re = 2 * Inp0[0].Re; Buff[0].Im = (2 * Inp1[0].Re); for (idx = 1; idx < HalfSize; idx++) { Buff[idx].Re = Inp0[idx].Re +Inp1[idx].Im; Buff[idx].Im = (-Inp0[idx].Im)+Inp1[idx].Re; Buff[Size-idx].Re = Inp0[idx].Re - Inp1[idx].Im; Buff[Size-idx].Im = Inp0[idx].Im + Inp1[idx].Re; } Buff[HalfSize].Re = 2 * Inp0[0].Im; Buff[HalfSize].Im = 2 * Inp1[0].Im; // for(idx=0; idx<Size; idx++) // printf("%2d %9.5f %9.5f\n",idx,Buff[idx].Re,Buff[idx].Im); } // core process: the classic tripple loop of butterflies // radix-2 FFT: the first and the second pass are by hand // looks like there is no gain by separating the second pass // and even the first pass is in question ? template <class BuffType> void CoreProc(BuffType x[]) { size_t Groups, GroupSize2, Group, Bf, TwidIdx; size_t Size2 = Size/2; for (Bf = 0; Bf < Size; Bf += 2) FFT2(x[Bf], x[Bf + 1]); // first pass // for(Bf=0; Bf<Size; Bf+=4) FFT4(x[Bf],x[Bf+1],x[Bf+2],x[Bf+3]); // second // for(Groups=Size2/4,GroupSize2=4; Groups; Groups>>=1, GroupSize2<<=1) for (Groups = Size2/2, GroupSize2 = 2; Groups; Groups >>= 1, GroupSize2 <<= 1) { for (Group = 0, Bf = 0; Group < Groups; Group++, Bf += GroupSize2) { for (TwidIdx = 0; TwidIdx < Size2; TwidIdx += Groups, Bf++) { FFTbf(x[Bf], x[Bf + GroupSize2], Twiddle[TwidIdx]); } } } } // radix-2 FFT with a "shrink" factor template <class BuffType> void CoreProc(BuffType x[], size_t ShrinkShift) { size_t Groups, GroupSize2, Group, Bf, TwidIdx, TwidIncr; size_t Len = Size >> ShrinkShift; size_t Size2 = Size/2; size_t Len2 = Len/2; for (Bf = 0; Bf < Len; Bf += 2) FFT2(x[Bf], x[Bf + 1]); // first pass // for(Bf=0; Bf<Len; Bf+=4) FFT4(x[Bf],x[Bf+1],x[Bf+2],x[Bf+3]); // second for (Groups = Len2/2, TwidIncr = Size2/2, GroupSize2 = 2; Groups; Groups >>= 1, TwidIncr >>= 1, GroupSize2 <<= 1) { for (Group = 0, Bf = 0; Group < Groups; Group++, Bf += GroupSize2) { for (TwidIdx = 0; TwidIdx < Size2; TwidIdx += TwidIncr, Bf++) { FFTbf(x[Bf], x[Bf + GroupSize2], Twiddle[TwidIdx]); } } } } // complex FFT process in place, includes unscrambling template <class BuffType> int Process(BuffType x[]) { Scramble(x); CoreProc(x); return 0; } // find the "shrink" factor for processing batches smaller than declared by Preset() int FindShrinkShift(size_t Len) { size_t Shift; for(Shift=0; Len<Size; Shift++) Len<<=1; if (Len!=Size) return -1; return Shift; } // process data with length smaller than requested by Preset() (but still a power of 2) template <class BuffType> int Process(BuffType x[], size_t Len) { if(Len<4) return -1; if(Len==Size) { Scramble(x); CoreProc(x); return 0; } int ShrinkShift=FindShrinkShift(Len); if(ShrinkShift<0) return -1; Scramble(x,ShrinkShift); CoreProc(x,ShrinkShift); return 0; } public: size_t Size; // FFT size (needs to be power of 2) size_t *BitRevIdx; // Bit-reverse indexing table for data (un)scrambling Type *Twiddle; // Twiddle factors (sine/cos values) private: // classic radix-2 butterflies template <class BuffType> inline void FFTbf(BuffType &x0, BuffType &x1, Type &W) { Type x1W; x1W.Re = x1.Re*W.Re + x1.Im*W.Im; // x1W.Re=x1.Re*W.Re-x1.Im*W.Im; x1W.Im = (-x1.Re*W.Im) + x1.Im*W.Re; // x1W.Im=x1.Re*W.Im+x1.Im*W.Re; x1.Re = x0.Re - x1W.Re; x1.Im = x0.Im - x1W.Im; x0.Re = x0.Re + x1W.Re; x0.Im = x0.Im + x1W.Im; } // special 2-point FFT for the first pass template <class BuffType> inline void FFT2(BuffType &x0, BuffType &x1) { Type x1W; x1W.Re = x1.Re; x1W.Im = x1.Im; x1.Re = x0.Re - x1.Re; x1.Im = x0.Im - x1.Im; x0.Re += x1W.Re; x0.Im += x1W.Im; } // special 4-point FFT for the second pass template <class BuffType> inline void FFT4(BuffType &x0, BuffType &x1, BuffType &x2, BuffType &x3) { Type x1W; x1W.Re = x2.Re; x1W.Im = x2.Im; x2.Re = x0.Re - x1W.Re; x2.Im = x0.Im - x1W.Im; x0.Re = x0.Re + x1W.Re; x0.Im = x0.Im + x1W.Im; x1W.Re = x3.Im; x1W.Im = (-x3.Re); x3.Re = x1.Re - x1W.Re; x3.Im = x1.Im - x1W.Im; x1.Re = x1.Re + x1W.Re; x1.Im = x1.Im + x1W.Im; } }; #endif // __FFT_H__
9,906
C++
.h
280
32.432143
88
0.640271
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,492
pj_fht.h
w1hkj_fldigi/src/include/jalocha/pj_fht.h
// Fast Hadamard Transform, Pawel Jalocha, December 2004 // (c) 1999-2003, Pawel Jalocha // (c) 2019, David Freese, W1HKJ #ifndef __FHT_H__ #define __FHT_H__ // Forward Fast Hadamard Transform template <class Type> // Type can be float, Cmpx<>, int8_t, etc. void FHT(Type *Data, size_t Len) { size_t Step, Ptr, Ptr2; Type Bit1, Bit2, NewBit1, NewBit2; for (Step = 1; Step < Len; Step *= 2) { for (Ptr = 0; Ptr < Len; Ptr += 2 * Step) { for (Ptr2 = Ptr; (Ptr2 - Ptr) < Step; Ptr2 += 1) { Bit1 = Data[Ptr2]; Bit2 = Data[Ptr2 + Step]; NewBit1 = Bit2; NewBit1 += Bit1; NewBit2 = Bit2; NewBit2 -= Bit1; Data[Ptr2] = NewBit1; Data[Ptr2 + Step] = NewBit2; } } } } // Inverse Fast Hadamard Transform template <class Type> void IFHT(Type *Data, size_t Len) { size_t Step, Ptr, Ptr2; Type Bit1, Bit2, NewBit1, NewBit2; for (Step = Len/2; Step; Step /= 2) { for (Ptr = 0; Ptr < Len; Ptr += 2 * Step) { for (Ptr2 = Ptr; (Ptr2 - Ptr) < Step; Ptr2 += 1) { Bit1 = Data[Ptr2]; Bit2 = Data[Ptr2 + Step]; NewBit1 = Bit1; NewBit1 -= Bit2; NewBit2 = Bit1; NewBit2 += Bit2; Data[Ptr2] = NewBit1; Data[Ptr2 + Step] = NewBit2; } } } } #endif // of __FHT_H__
1,234
C++
.h
45
24.244444
65
0.601523
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,493
pj_lowpass3.h
w1hkj_fldigi/src/include/jalocha/pj_lowpass3.h
// (c) 1999-2003, Pawel Jalocha // (c) 2019, David Freese, W1HKJ #ifndef __LOWPASS3_H__ #define __LOWPASS3_H__ // ========================================================================== // IIR low pass filter for integration (averaging) purposes // Overshoot is about 1% for Feedback=0.5, and about 1e-6 for Feedback=0.1 // Weight is 1 / PeakingTime template <class Type> class LowPass3_Filter { public: Type Out1, Out2, Output; template <class InpType, class WeightType> void Process(InpType Inp, WeightType Weight, WeightType Feedback = 0.1) { Weight *= 2.0; Type DiffI1 = Inp; DiffI1 -= Out1; Type Diff12 = Out1; Diff12 -= Out2; Type Diff23 = Out2; Diff23 -= Output; DiffI1 *= Weight; Out1 += DiffI1; Diff12 *= Weight; Out2 += Diff12; Diff23 *= Weight; Output += Diff23; Diff23 *= Feedback; Out2 += Diff23; } template <class LevelType> void operator = (LevelType Level) { Out1 = Level; Out2 = Level; Output=Level; } template <class LevelType> void Set(LevelType Level = 0) { Out1 = Level; Out2 = Level; Output=Level; } }; // ========================================================================== #endif // of __LOWPASS3_H__
1,205
C++
.h
38
29.184211
77
0.591184
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,495
pkcs12.h
w1hkj_fldigi/src/include/mbedtls/pkcs12.h
/** * \file pkcs12.h * * \brief PKCS#12 Personal Information Exchange Syntax */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PKCS12_H #define MBEDTLS_PKCS12_H #include "md.h" #include "cipher.h" #include "asn1.h" #include <stddef.h> #define MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA -0x1F80 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE -0x1F00 /**< Feature not available, e.g. unsupported encryption scheme. */ #define MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT -0x1E80 /**< PBE ASN.1 data not as expected. */ #define MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH -0x1E00 /**< Given private key password does not allow for correct decryption. */ #define MBEDTLS_PKCS12_DERIVE_KEY 1 /**< encryption/decryption key */ #define MBEDTLS_PKCS12_DERIVE_IV 2 /**< initialization vector */ #define MBEDTLS_PKCS12_DERIVE_MAC_KEY 3 /**< integrity / MAC key */ #define MBEDTLS_PKCS12_PBE_DECRYPT 0 #define MBEDTLS_PKCS12_PBE_ENCRYPT 1 #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_ASN1_PARSE_C) /** * \brief PKCS12 Password Based function (encryption / decryption) * for pbeWithSHAAnd128BitRC4 * * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT * \param pwd the password used (may be NULL if no password is used) * \param pwdlen length of the password (may be 0) * \param input the input data * \param len data length * \param output the output buffer * * \return 0 if successful, or a MBEDTLS_ERR_XXX code */ int mbedtls_pkcs12_pbe_sha1_rc4_128( mbedtls_asn1_buf *pbe_params, int mode, const unsigned char *pwd, size_t pwdlen, const unsigned char *input, size_t len, unsigned char *output ); /** * \brief PKCS12 Password Based function (encryption / decryption) * for cipher-based and mbedtls_md-based PBE's * * \param pbe_params an ASN1 buffer containing the pkcs-12PbeParams structure * \param mode either MBEDTLS_PKCS12_PBE_ENCRYPT or MBEDTLS_PKCS12_PBE_DECRYPT * \param cipher_type the cipher used * \param md_type the mbedtls_md used * \param pwd the password used (may be NULL if no password is used) * \param pwdlen length of the password (may be 0) * \param input the input data * \param len data length * \param output the output buffer * * \return 0 if successful, or a MBEDTLS_ERR_XXX code */ int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode, mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type, const unsigned char *pwd, size_t pwdlen, const unsigned char *input, size_t len, unsigned char *output ); #endif /* MBEDTLS_ASN1_PARSE_C */ /** * \brief The PKCS#12 derivation function uses a password and a salt * to produce pseudo-random bits for a particular "purpose". * * Depending on the given id, this function can produce an * encryption/decryption key, an nitialization vector or an * integrity key. * * \param data buffer to store the derived data in * \param datalen length to fill * \param pwd password to use (may be NULL if no password is used) * \param pwdlen length of the password (may be 0) * \param salt salt buffer to use * \param saltlen length of the salt * \param mbedtls_md mbedtls_md type to use during the derivation * \param id id that describes the purpose (can be MBEDTLS_PKCS12_DERIVE_KEY, * MBEDTLS_PKCS12_DERIVE_IV or MBEDTLS_PKCS12_DERIVE_MAC_KEY) * \param iterations number of iterations * * \return 0 if successful, or a MD, BIGNUM type error. */ int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, const unsigned char *pwd, size_t pwdlen, const unsigned char *salt, size_t saltlen, mbedtls_md_type_t mbedtls_md, int id, int iterations ); #ifdef __cplusplus } #endif #endif /* pkcs12.h */
5,254
C++
.h
113
42.80531
140
0.662051
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,496
nist_kw.h
w1hkj_fldigi/src/include/mbedtls/nist_kw.h
/** * \file nist_kw.h * * \brief This file provides an API for key wrapping (KW) and key wrapping with * padding (KWP) as defined in NIST SP 800-38F. * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf * * Key wrapping specifies a deterministic authenticated-encryption mode * of operation, according to <em>NIST SP 800-38F: Recommendation for * Block Cipher Modes of Operation: Methods for Key Wrapping</em>. Its * purpose is to protect cryptographic keys. * * Its equivalent is RFC 3394 for KW, and RFC 5649 for KWP. * https://tools.ietf.org/html/rfc3394 * https://tools.ietf.org/html/rfc5649 * */ /* * Copyright (C) 2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_NIST_KW_H #define MBEDTLS_NIST_KW_H #include "cipher.h" #ifdef __cplusplus extern "C" { #endif typedef enum { MBEDTLS_KW_MODE_KW = 0, MBEDTLS_KW_MODE_KWP = 1 } mbedtls_nist_kw_mode_t; #if !defined(MBEDTLS_NIST_KW_ALT) // Regular implementation // /** * \brief The key wrapping context-type definition. The key wrapping context is passed * to the APIs called. * * \note The definition of this type may change in future library versions. * Don't make any assumptions on this context! */ typedef struct { mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */ } mbedtls_nist_kw_context; #else /* MBEDTLS_NIST_key wrapping_ALT */ #include "nist_kw_alt.h" #endif /* MBEDTLS_NIST_KW_ALT */ /** * \brief This function initializes the specified key wrapping context * to make references valid and prepare the context * for mbedtls_nist_kw_setkey() or mbedtls_nist_kw_free(). * * \param ctx The key wrapping context to initialize. * */ void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx ); /** * \brief This function initializes the key wrapping context set in the * \p ctx parameter and sets the encryption key. * * \param ctx The key wrapping context. * \param cipher The 128-bit block cipher to use. Only AES is supported. * \param key The Key Encryption Key (KEK). * \param keybits The KEK size in bits. This must be acceptable by the cipher. * \param is_wrap Specify whether the operation within the context is wrapping or unwrapping * * \return \c 0 on success. * \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for any invalid input. * \return \c MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE for 128-bit block ciphers * which are not supported. * \return cipher-specific error code on failure of the underlying cipher. */ int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits, const int is_wrap ); /** * \brief This function releases and clears the specified key wrapping context * and underlying cipher sub-context. * * \param ctx The key wrapping context to clear. */ void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx ); /** * \brief This function encrypts a buffer using key wrapping. * * \param ctx The key wrapping context to use for encryption. * \param mode The key wrapping mode to use (MBEDTLS_KW_MODE_KW or MBEDTLS_KW_MODE_KWP) * \param input The buffer holding the input data. * \param in_len The length of the input data in Bytes. * The input uses units of 8 Bytes called semiblocks. * <ul><li>For KW mode: a multiple of 8 bytes between 16 and 2^57-8 inclusive. </li> * <li>For KWP mode: any length between 1 and 2^32-1 inclusive.</li></ul> * \param[out] output The buffer holding the output data. * <ul><li>For KW mode: Must be at least 8 bytes larger than \p in_len.</li> * <li>For KWP mode: Must be at least 8 bytes larger rounded up to a multiple of * 8 bytes for KWP (15 bytes at most).</li></ul> * \param[out] out_len The number of bytes written to the output buffer. \c 0 on failure. * \param[in] out_size The capacity of the output buffer. * * \return \c 0 on success. * \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length. * \return cipher-specific error code on failure of the underlying cipher. */ int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode, const unsigned char *input, size_t in_len, unsigned char *output, size_t* out_len, size_t out_size ); /** * \brief This function decrypts a buffer using key wrapping. * * \param ctx The key wrapping context to use for decryption. * \param mode The key wrapping mode to use (MBEDTLS_KW_MODE_KW or MBEDTLS_KW_MODE_KWP) * \param input The buffer holding the input data. * \param in_len The length of the input data in Bytes. * The input uses units of 8 Bytes called semiblocks. * The input must be a multiple of semiblocks. * <ul><li>For KW mode: a multiple of 8 bytes between 24 and 2^57 inclusive. </li> * <li>For KWP mode: a multiple of 8 bytes between 16 and 2^32 inclusive.</li></ul> * \param[out] output The buffer holding the output data. * The output buffer's minimal length is 8 bytes shorter than \p in_len. * \param[out] out_len The number of bytes written to the output buffer. \c 0 on failure. * For KWP mode, the length could be up to 15 bytes shorter than \p in_len, * depending on how much padding was added to the data. * \param[in] out_size The capacity of the output buffer. * * \return \c 0 on success. * \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length. * \return \c MBEDTLS_ERR_CIPHER_AUTH_FAILED for verification failure of the ciphertext. * \return cipher-specific error code on failure of the underlying cipher. */ int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode, const unsigned char *input, size_t in_len, unsigned char *output, size_t* out_len, size_t out_size); #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) /** * \brief The key wrapping checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_nist_kw_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_NIST_KW_H */
7,707
C++
.h
164
43.780488
101
0.655905
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,497
chachapoly.h
w1hkj_fldigi/src/include/mbedtls/chachapoly.h
/** * \file chachapoly.h * * \brief This file contains the AEAD-ChaCha20-Poly1305 definitions and * functions. * * ChaCha20-Poly1305 is an algorithm for Authenticated Encryption * with Associated Data (AEAD) that can be used to encrypt and * authenticate data. It is based on ChaCha20 and Poly1305 by Daniel * Bernstein and was standardized in RFC 7539. * * \author Daniel King <damaki.gh@gmail.com> */ /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CHACHAPOLY_H #define MBEDTLS_CHACHAPOLY_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif /* for shared error codes */ #include "poly1305.h" #define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054 /**< The requested operation is not permitted in the current state. */ #define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056 /**< Authenticated decryption failed: data was not authentic. */ #ifdef __cplusplus extern "C" { #endif typedef enum { MBEDTLS_CHACHAPOLY_ENCRYPT, /**< The mode value for performing encryption. */ MBEDTLS_CHACHAPOLY_DECRYPT /**< The mode value for performing decryption. */ } mbedtls_chachapoly_mode_t; #if !defined(MBEDTLS_CHACHAPOLY_ALT) #include "chacha20.h" typedef struct mbedtls_chachapoly_context { mbedtls_chacha20_context chacha20_ctx; /**< The ChaCha20 context. */ mbedtls_poly1305_context poly1305_ctx; /**< The Poly1305 context. */ uint64_t aad_len; /**< The length (bytes) of the Additional Authenticated Data. */ uint64_t ciphertext_len; /**< The length (bytes) of the ciphertext. */ int state; /**< The current state of the context. */ mbedtls_chachapoly_mode_t mode; /**< Cipher mode (encrypt or decrypt). */ } mbedtls_chachapoly_context; #else /* !MBEDTLS_CHACHAPOLY_ALT */ #include "chachapoly_alt.h" #endif /* !MBEDTLS_CHACHAPOLY_ALT */ /** * \brief This function initializes the specified ChaCha20-Poly1305 context. * * It must be the first API called before using * the context. It must be followed by a call to * \c mbedtls_chachapoly_setkey() before any operation can be * done, and to \c mbedtls_chachapoly_free() once all * operations with that context have been finished. * * In order to encrypt or decrypt full messages at once, for * each message you should make a single call to * \c mbedtls_chachapoly_crypt_and_tag() or * \c mbedtls_chachapoly_auth_decrypt(). * * In order to encrypt messages piecewise, for each * message you should make a call to * \c mbedtls_chachapoly_starts(), then 0 or more calls to * \c mbedtls_chachapoly_update_aad(), then 0 or more calls to * \c mbedtls_chachapoly_update(), then one call to * \c mbedtls_chachapoly_finish(). * * \warning Decryption with the piecewise API is discouraged! Always * use \c mbedtls_chachapoly_auth_decrypt() when possible! * * If however this is not possible because the data is too * large to fit in memory, you need to: * * - call \c mbedtls_chachapoly_starts() and (if needed) * \c mbedtls_chachapoly_update_aad() as above, * - call \c mbedtls_chachapoly_update() multiple times and * ensure its output (the plaintext) is NOT used in any other * way than placing it in temporary storage at this point, * - call \c mbedtls_chachapoly_finish() to compute the * authentication tag and compared it in constant time to the * tag received with the ciphertext. * * If the tags are not equal, you must immediately discard * all previous outputs of \c mbedtls_chachapoly_update(), * otherwise you can now safely use the plaintext. * * \param ctx The ChachaPoly context to initialize. Must not be \c NULL. */ void mbedtls_chachapoly_init( mbedtls_chachapoly_context *ctx ); /** * \brief This function releases and clears the specified * ChaCha20-Poly1305 context. * * \param ctx The ChachaPoly context to clear. This may be \c NULL, in which * case this function is a no-op. */ void mbedtls_chachapoly_free( mbedtls_chachapoly_context *ctx ); /** * \brief This function sets the ChaCha20-Poly1305 * symmetric encryption key. * * \param ctx The ChaCha20-Poly1305 context to which the key should be * bound. This must be initialized. * \param key The \c 256 Bit (\c 32 Bytes) key. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx, const unsigned char key[32] ); /** * \brief This function starts a ChaCha20-Poly1305 encryption or * decryption operation. * * \warning You must never use the same nonce twice with the same key. * This would void any confidentiality and authenticity * guarantees for the messages encrypted with the same nonce * and key. * * \note If the context is being used for AAD only (no data to * encrypt or decrypt) then \p mode can be set to any value. * * \warning Decryption with the piecewise API is discouraged, see the * warning on \c mbedtls_chachapoly_init(). * * \param ctx The ChaCha20-Poly1305 context. This must be initialized * and bound to a key. * \param nonce The nonce/IV to use for the message. * This must be a redable buffer of length \c 12 Bytes. * \param mode The operation to perform: #MBEDTLS_CHACHAPOLY_ENCRYPT or * #MBEDTLS_CHACHAPOLY_DECRYPT (discouraged, see warning). * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx, const unsigned char nonce[12], mbedtls_chachapoly_mode_t mode ); /** * \brief This function feeds additional data to be authenticated * into an ongoing ChaCha20-Poly1305 operation. * * The Additional Authenticated Data (AAD), also called * Associated Data (AD) is only authenticated but not * encrypted nor included in the encrypted output. It is * usually transmitted separately from the ciphertext or * computed locally by each party. * * \note This function is called before data is encrypted/decrypted. * I.e. call this function to process the AAD before calling * \c mbedtls_chachapoly_update(). * * You may call this function multiple times to process * an arbitrary amount of AAD. It is permitted to call * this function 0 times, if no AAD is used. * * This function cannot be called any more if data has * been processed by \c mbedtls_chachapoly_update(), * or if the context has been finished. * * \warning Decryption with the piecewise API is discouraged, see the * warning on \c mbedtls_chachapoly_init(). * * \param ctx The ChaCha20-Poly1305 context. This must be initialized * and bound to a key. * \param aad_len The length in Bytes of the AAD. The length has no * restrictions. * \param aad Buffer containing the AAD. * This pointer can be \c NULL if `aad_len == 0`. * * \return \c 0 on success. * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA * if \p ctx or \p aad are NULL. * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE * if the operations has not been started or has been * finished, or if the AAD has been finished. */ int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx, const unsigned char *aad, size_t aad_len ); /** * \brief Thus function feeds data to be encrypted or decrypted * into an on-going ChaCha20-Poly1305 * operation. * * The direction (encryption or decryption) depends on the * mode that was given when calling * \c mbedtls_chachapoly_starts(). * * You may call this function multiple times to process * an arbitrary amount of data. It is permitted to call * this function 0 times, if no data is to be encrypted * or decrypted. * * \warning Decryption with the piecewise API is discouraged, see the * warning on \c mbedtls_chachapoly_init(). * * \param ctx The ChaCha20-Poly1305 context to use. This must be initialized. * \param len The length (in bytes) of the data to encrypt or decrypt. * \param input The buffer containing the data to encrypt or decrypt. * This pointer can be \c NULL if `len == 0`. * \param output The buffer to where the encrypted or decrypted data is * written. This must be able to hold \p len bytes. * This pointer can be \c NULL if `len == 0`. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE * if the operation has not been started or has been * finished. * \return Another negative error code on other kinds of failure. */ int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx, size_t len, const unsigned char *input, unsigned char *output ); /** * \brief This function finished the ChaCha20-Poly1305 operation and * generates the MAC (authentication tag). * * \param ctx The ChaCha20-Poly1305 context to use. This must be initialized. * \param mac The buffer to where the 128-bit (16 bytes) MAC is written. * * \warning Decryption with the piecewise API is discouraged, see the * warning on \c mbedtls_chachapoly_init(). * * \return \c 0 on success. * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE * if the operation has not been started or has been * finished. * \return Another negative error code on other kinds of failure. */ int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx, unsigned char mac[16] ); /** * \brief This function performs a complete ChaCha20-Poly1305 * authenticated encryption with the previously-set key. * * \note Before using this function, you must set the key with * \c mbedtls_chachapoly_setkey(). * * \warning You must never use the same nonce twice with the same key. * This would void any confidentiality and authenticity * guarantees for the messages encrypted with the same nonce * and key. * * \param ctx The ChaCha20-Poly1305 context to use (holds the key). * This must be initialized. * \param length The length (in bytes) of the data to encrypt or decrypt. * \param nonce The 96-bit (12 bytes) nonce/IV to use. * \param aad The buffer containing the additional authenticated * data (AAD). This pointer can be \c NULL if `aad_len == 0`. * \param aad_len The length (in bytes) of the AAD data to process. * \param input The buffer containing the data to encrypt or decrypt. * This pointer can be \c NULL if `ilen == 0`. * \param output The buffer to where the encrypted or decrypted data * is written. This pointer can be \c NULL if `ilen == 0`. * \param tag The buffer to where the computed 128-bit (16 bytes) MAC * is written. This must not be \c NULL. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_chachapoly_encrypt_and_tag( mbedtls_chachapoly_context *ctx, size_t length, const unsigned char nonce[12], const unsigned char *aad, size_t aad_len, const unsigned char *input, unsigned char *output, unsigned char tag[16] ); /** * \brief This function performs a complete ChaCha20-Poly1305 * authenticated decryption with the previously-set key. * * \note Before using this function, you must set the key with * \c mbedtls_chachapoly_setkey(). * * \param ctx The ChaCha20-Poly1305 context to use (holds the key). * \param length The length (in Bytes) of the data to decrypt. * \param nonce The \c 96 Bit (\c 12 bytes) nonce/IV to use. * \param aad The buffer containing the additional authenticated data (AAD). * This pointer can be \c NULL if `aad_len == 0`. * \param aad_len The length (in bytes) of the AAD data to process. * \param tag The buffer holding the authentication tag. * This must be a readable buffer of length \c 16 Bytes. * \param input The buffer containing the data to decrypt. * This pointer can be \c NULL if `ilen == 0`. * \param output The buffer to where the decrypted data is written. * This pointer can be \c NULL if `ilen == 0`. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED * if the data was not authentic. * \return Another negative error code on other kinds of failure. */ int mbedtls_chachapoly_auth_decrypt( mbedtls_chachapoly_context *ctx, size_t length, const unsigned char nonce[12], const unsigned char *aad, size_t aad_len, const unsigned char tag[16], const unsigned char *input, unsigned char *output ); #if defined(MBEDTLS_SELF_TEST) /** * \brief The ChaCha20-Poly1305 checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_chachapoly_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_CHACHAPOLY_H */
16,359
C++
.h
337
44.183976
130
0.597537
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,498
pk_internal.h
w1hkj_fldigi/src/include/mbedtls/pk_internal.h
/** * \file pk_internal.h * * \brief Public Key abstraction layer: wrapper functions */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PK_WRAP_H #define MBEDTLS_PK_WRAP_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "pk.h" struct mbedtls_pk_info_t { /** Public key type */ mbedtls_pk_type_t type; /** Type name */ const char *name; /** Get key size in bits */ size_t (*get_bitlen)( const void * ); /** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */ int (*can_do)( mbedtls_pk_type_t type ); /** Verify signature */ int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len ); /** Make signature */ int (*sign_func)( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** Verify signature (restartable) */ int (*verify_rs_func)( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len, void *rs_ctx ); /** Make signature (restartable) */ int (*sign_rs_func)( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, void *rs_ctx ); #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ /** Decrypt message */ int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** Encrypt message */ int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** Check public-private key pair */ int (*check_pair_func)( const void *pub, const void *prv ); /** Allocate a new context */ void * (*ctx_alloc_func)( void ); /** Free the given context */ void (*ctx_free_func)( void *ctx ); #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** Allocate the restart context */ void * (*rs_alloc_func)( void ); /** Free the restart context */ void (*rs_free_func)( void *rs_ctx ); #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ /** Interface with the debug module */ void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items ); }; #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) /* Container for RSA-alt */ typedef struct { void *key; mbedtls_pk_rsa_alt_decrypt_func decrypt_func; mbedtls_pk_rsa_alt_sign_func sign_func; mbedtls_pk_rsa_alt_key_len_func key_len_func; } mbedtls_rsa_alt_context; #endif #if defined(MBEDTLS_RSA_C) extern const mbedtls_pk_info_t mbedtls_rsa_info; #endif #if defined(MBEDTLS_ECP_C) extern const mbedtls_pk_info_t mbedtls_eckey_info; extern const mbedtls_pk_info_t mbedtls_eckeydh_info; #endif #if defined(MBEDTLS_ECDSA_C) extern const mbedtls_pk_info_t mbedtls_ecdsa_info; #endif #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) extern const mbedtls_pk_info_t mbedtls_rsa_alt_info; #endif #endif /* MBEDTLS_PK_WRAP_H */
4,757
C++
.h
115
34.634783
77
0.626597
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,499
dhm.h
w1hkj_fldigi/src/include/mbedtls/dhm.h
/** * \file dhm.h * * \brief This file contains Diffie-Hellman-Merkle (DHM) key exchange * definitions and functions. * * Diffie-Hellman-Merkle (DHM) key exchange is defined in * <em>RFC-2631: Diffie-Hellman Key Agreement Method</em> and * <em>Public-Key Cryptography Standards (PKCS) #3: Diffie * Hellman Key Agreement Standard</em>. * * <em>RFC-3526: More Modular Exponential (MODP) Diffie-Hellman groups for * Internet Key Exchange (IKE)</em> defines a number of standardized * Diffie-Hellman groups for IKE. * * <em>RFC-5114: Additional Diffie-Hellman Groups for Use with IETF * Standards</em> defines a number of standardized Diffie-Hellman * groups that can be used. * * \warning The security of the DHM key exchange relies on the proper choice * of prime modulus - optimally, it should be a safe prime. The usage * of non-safe primes both decreases the difficulty of the underlying * discrete logarithm problem and can lead to small subgroup attacks * leaking private exponent bits when invalid public keys are used * and not detected. This is especially relevant if the same DHM * parameters are reused for multiple key exchanges as in static DHM, * while the criticality of small-subgroup attacks is lower for * ephemeral DHM. * * \warning For performance reasons, the code does neither perform primality * nor safe primality tests, nor the expensive checks for invalid * subgroups. Moreover, even if these were performed, non-standardized * primes cannot be trusted because of the possibility of backdoors * that can't be effectively checked for. * * \warning Diffie-Hellman-Merkle is therefore a security risk when not using * standardized primes generated using a trustworthy ("nothing up * my sleeve") method, such as the RFC 3526 / 7919 primes. In the TLS * protocol, DH parameters need to be negotiated, so using the default * primes systematically is not always an option. If possible, use * Elliptic Curve Diffie-Hellman (ECDH), which has better performance, * and for which the TLS protocol mandates the use of standard * parameters. * */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_DHM_H #define MBEDTLS_DHM_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "bignum.h" /* * DHM Error codes */ #define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters. */ #define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */ #define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */ #define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */ #define MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 /**< Making of the public value failed. */ #define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */ #define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */ #define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */ #define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read or write of file failed. */ /* MBEDTLS_ERR_DHM_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_DHM_HW_ACCEL_FAILED -0x3500 /**< DHM hardware accelerator failed. */ #define MBEDTLS_ERR_DHM_SET_GROUP_FAILED -0x3580 /**< Setting the modulus and generator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_DHM_ALT) /** * \brief The DHM context structure. */ typedef struct mbedtls_dhm_context { size_t len; /*!< The size of \p P in Bytes. */ mbedtls_mpi P; /*!< The prime modulus. */ mbedtls_mpi G; /*!< The generator. */ mbedtls_mpi X; /*!< Our secret value. */ mbedtls_mpi GX; /*!< Our public key = \c G^X mod \c P. */ mbedtls_mpi GY; /*!< The public key of the peer = \c G^Y mod \c P. */ mbedtls_mpi K; /*!< The shared secret = \c G^(XY) mod \c P. */ mbedtls_mpi RP; /*!< The cached value = \c R^2 mod \c P. */ mbedtls_mpi Vi; /*!< The blinding value. */ mbedtls_mpi Vf; /*!< The unblinding value. */ mbedtls_mpi pX; /*!< The previous \c X. */ } mbedtls_dhm_context; #else /* MBEDTLS_DHM_ALT */ #include "dhm_alt.h" #endif /* MBEDTLS_DHM_ALT */ /** * \brief This function initializes the DHM context. * * \param ctx The DHM context to initialize. */ void mbedtls_dhm_init( mbedtls_dhm_context *ctx ); /** * \brief This function parses the DHM parameters in a * TLS ServerKeyExchange handshake message * (DHM modulus, generator, and public key). * * \note In a TLS handshake, this is the how the client * sets up its DHM context from the server's public * DHM key material. * * \param ctx The DHM context to use. This must be initialized. * \param p On input, *p must be the start of the input buffer. * On output, *p is updated to point to the end of the data * that has been read. On success, this is the first byte * past the end of the ServerKeyExchange parameters. * On error, this is the point at which an error has been * detected, which is usually not useful except to debug * failures. * \param end The end of the input buffer. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx, unsigned char **p, const unsigned char *end ); /** * \brief This function generates a DHM key pair and exports its * public part together with the DHM parameters in the format * used in a TLS ServerKeyExchange handshake message. * * \note This function assumes that the DHM parameters \c ctx->P * and \c ctx->G have already been properly set. For that, use * mbedtls_dhm_set_group() below in conjunction with * mbedtls_mpi_read_binary() and mbedtls_mpi_read_string(). * * \note In a TLS handshake, this is the how the server generates * and exports its DHM key material. * * \param ctx The DHM context to use. This must be initialized * and have the DHM parameters set. It may or may not * already have imported the peer's public key. * \param x_size The private key size in Bytes. * \param olen The address at which to store the number of Bytes * written on success. This must not be \c NULL. * \param output The destination buffer. This must be a writable buffer of * sufficient size to hold the reduced binary presentation of * the modulus, the generator and the public key, each wrapped * with a 2-byte length field. It is the responsibility of the * caller to ensure that enough space is available. Refer to * mbedtls_mpi_size() to computing the byte-size of an MPI. * \param f_rng The RNG function. Must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng doesn't need a context parameter. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function sets the prime modulus and generator. * * \note This function can be used to set \c ctx->P, \c ctx->G * in preparation for mbedtls_dhm_make_params(). * * \param ctx The DHM context to configure. This must be initialized. * \param P The MPI holding the DHM prime modulus. This must be * an initialized MPI. * \param G The MPI holding the DHM generator. This must be an * initialized MPI. * * \return \c 0 if successful. * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_set_group( mbedtls_dhm_context *ctx, const mbedtls_mpi *P, const mbedtls_mpi *G ); /** * \brief This function imports the raw public value of the peer. * * \note In a TLS handshake, this is the how the server imports * the Client's public DHM key. * * \param ctx The DHM context to use. This must be initialized and have * its DHM parameters set, e.g. via mbedtls_dhm_set_group(). * It may or may not already have generated its own private key. * \param input The input buffer containing the \c G^Y value of the peer. * This must be a readable buffer of size \p ilen Bytes. * \param ilen The size of the input buffer \p input in Bytes. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function creates a DHM key pair and exports * the raw public key in big-endian format. * * \note The destination buffer is always fully written * so as to contain a big-endian representation of G^X mod P. * If it is larger than \c ctx->len, it is padded accordingly * with zero-bytes at the beginning. * * \param ctx The DHM context to use. This must be initialized and * have the DHM parameters set. It may or may not already * have imported the peer's public key. * \param x_size The private key size in Bytes. * \param output The destination buffer. This must be a writable buffer of * size \p olen Bytes. * \param olen The length of the destination buffer. This must be at least * equal to `ctx->len` (the size of \c P). * \param f_rng The RNG function. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL * if \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function derives and exports the shared secret * \c (G^Y)^X mod \c P. * * \note If \p f_rng is not \c NULL, it is used to blind the input as * a countermeasure against timing attacks. Blinding is used * only if our private key \c X is re-used, and not used * otherwise. We recommend always passing a non-NULL * \p f_rng argument. * * \param ctx The DHM context to use. This must be initialized * and have its own private key generated and the peer's * public key imported. * \param output The buffer to write the generated shared key to. This * must be a writable buffer of size \p output_size Bytes. * \param output_size The size of the destination buffer. This must be at * least the size of \c ctx->len (the size of \c P). * \param olen On exit, holds the actual number of Bytes written. * \param f_rng The RNG function, for blinding purposes. This may * b \c NULL if blinding isn't needed. * \param p_rng The RNG context. This may be \c NULL if \p f_rng * doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, unsigned char *output, size_t output_size, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function frees and clears the components * of a DHM context. * * \param ctx The DHM context to free and clear. This may be \c NULL, * in which case this function is a no-op. If it is not \c NULL, * it must point to an initialized DHM context. */ void mbedtls_dhm_free( mbedtls_dhm_context *ctx ); #if defined(MBEDTLS_ASN1_PARSE_C) /** \ingroup x509_module */ /** * \brief This function parses DHM parameters in PEM or DER format. * * \param dhm The DHM context to import the DHM parameters into. * This must be initialized. * \param dhmin The input buffer. This must be a readable buffer of * length \p dhminlen Bytes. * \param dhminlen The size of the input buffer \p dhmin, including the * terminating \c NULL Byte for PEM data. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX or \c MBEDTLS_ERR_PEM_XXX error * code on failure. */ int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen ); #if defined(MBEDTLS_FS_IO) /** \ingroup x509_module */ /** * \brief This function loads and parses DHM parameters from a file. * * \param dhm The DHM context to load the parameters to. * This must be initialized. * \param path The filename to read the DHM parameters from. * This must not be \c NULL. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_DHM_XXX or \c MBEDTLS_ERR_PEM_XXX * error code on failure. */ int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ); #endif /* MBEDTLS_FS_IO */ #endif /* MBEDTLS_ASN1_PARSE_C */ /** * \brief The DMH checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_dhm_self_test( int verbose ); #ifdef __cplusplus } #endif /** * RFC 3526, RFC 5114 and RFC 7919 standardize a number of * Diffie-Hellman groups, some of which are included here * for use within the SSL/TLS module and the user's convenience * when configuring the Diffie-Hellman parameters by hand * through \c mbedtls_ssl_conf_dh_param. * * The following lists the source of the above groups in the standards: * - RFC 5114 section 2.2: 2048-bit MODP Group with 224-bit Prime Order Subgroup * - RFC 3526 section 3: 2048-bit MODP Group * - RFC 3526 section 4: 3072-bit MODP Group * - RFC 3526 section 5: 4096-bit MODP Group * - RFC 7919 section A.1: ffdhe2048 * - RFC 7919 section A.2: ffdhe3072 * - RFC 7919 section A.3: ffdhe4096 * - RFC 7919 section A.4: ffdhe6144 * - RFC 7919 section A.5: ffdhe8192 * * The constants with suffix "_p" denote the chosen prime moduli, while * the constants with suffix "_g" denote the chosen generator * of the associated prime field. * * The constants further suffixed with "_bin" are provided in binary format, * while all other constants represent null-terminated strings holding the * hexadecimal presentation of the respective numbers. * * The primes from RFC 3526 and RFC 7919 have been generating by the following * trust-worthy procedure: * - Fix N in { 2048, 3072, 4096, 6144, 8192 } and consider the N-bit number * the first and last 64 bits are all 1, and the remaining N - 128 bits of * which are 0x7ff...ff. * - Add the smallest multiple of the first N - 129 bits of the binary expansion * of pi (for RFC 5236) or e (for RFC 7919) to this intermediate bit-string * such that the resulting integer is a safe-prime. * - The result is the respective RFC 3526 / 7919 prime, and the corresponding * generator is always chosen to be 2 (which is a square for these prime, * hence the corresponding subgroup has order (p-1)/2 and avoids leaking a * bit in the private exponent). * */ #if !defined(MBEDTLS_DEPRECATED_REMOVED) /** * \warning The origin of the primes in RFC 5114 is not documented and * their use therefore constitutes a security risk! * * \deprecated The hex-encoded primes from RFC 5114 are deprecated and are * likely to be removed in a future version of the library without * replacement. */ /** * The hexadecimal presentation of the prime underlying the * 2048-bit MODP Group with 224-bit Prime Order Subgroup, as defined * in <em>RFC-5114: Additional Diffie-Hellman Groups for Use with * IETF Standards</em>. */ #define MBEDTLS_DHM_RFC5114_MODP_2048_P \ MBEDTLS_DEPRECATED_STRING_CONSTANT( \ "AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \ "B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \ "EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \ "9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \ "C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \ "B3BF8A317091883681286130BC8985DB1602E714415D9330" \ "278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \ "CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \ "BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \ "C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \ "CF9DE5384E71B81C0AC4DFFE0C10E64F" ) /** * The hexadecimal presentation of the chosen generator of the 2048-bit MODP * Group with 224-bit Prime Order Subgroup, as defined in <em>RFC-5114: * Additional Diffie-Hellman Groups for Use with IETF Standards</em>. */ #define MBEDTLS_DHM_RFC5114_MODP_2048_G \ MBEDTLS_DEPRECATED_STRING_CONSTANT( \ "AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF" \ "74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA" \ "AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7" \ "C17669101999024AF4D027275AC1348BB8A762D0521BC98A" \ "E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE" \ "F180EB34118E98D119529A45D6F834566E3025E316A330EF" \ "BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB" \ "10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381" \ "B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269" \ "EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179" \ "81BC087F2A7065B384B890D3191F2BFA" ) /** * The hexadecimal presentation of the prime underlying the 2048-bit MODP * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP) * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>. * * \deprecated The hex-encoded primes from RFC 3625 are deprecated and * superseded by the corresponding macros providing them as * binary constants. Their hex-encoded constants are likely * to be removed in a future version of the library. * */ #define MBEDTLS_DHM_RFC3526_MODP_2048_P \ MBEDTLS_DEPRECATED_STRING_CONSTANT( \ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \ "15728E5A8AACAA68FFFFFFFFFFFFFFFF" ) /** * The hexadecimal presentation of the chosen generator of the 2048-bit MODP * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP) * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>. */ #define MBEDTLS_DHM_RFC3526_MODP_2048_G \ MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" ) /** * The hexadecimal presentation of the prime underlying the 3072-bit MODP * Group, as defined in <em>RFC-3072: More Modular Exponential (MODP) * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>. */ #define MBEDTLS_DHM_RFC3526_MODP_3072_P \ MBEDTLS_DEPRECATED_STRING_CONSTANT( \ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \ "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF" ) /** * The hexadecimal presentation of the chosen generator of the 3072-bit MODP * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP) * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>. */ #define MBEDTLS_DHM_RFC3526_MODP_3072_G \ MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" ) /** * The hexadecimal presentation of the prime underlying the 4096-bit MODP * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP) * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>. */ #define MBEDTLS_DHM_RFC3526_MODP_4096_P \ MBEDTLS_DEPRECATED_STRING_CONSTANT( \ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \ "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \ "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \ "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \ "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \ "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \ "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \ "FFFFFFFFFFFFFFFF" ) /** * The hexadecimal presentation of the chosen generator of the 4096-bit MODP * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP) * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>. */ #define MBEDTLS_DHM_RFC3526_MODP_4096_G \ MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" ) #endif /* MBEDTLS_DEPRECATED_REMOVED */ /* * Trustworthy DHM parameters in binary form */ #define MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, \ 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, \ 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, \ 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, \ 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, \ 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, \ 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, \ 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, \ 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, \ 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, \ 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, \ 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, \ 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, \ 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, \ 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, \ 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, \ 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, \ 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, \ 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, \ 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, \ 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, \ 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, \ 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, \ 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, \ 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, \ 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, \ 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, \ 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, \ 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, \ 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC3526_MODP_3072_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, \ 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, \ 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, \ 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, \ 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, \ 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, \ 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, \ 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, \ 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, \ 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, \ 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, \ 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, \ 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, \ 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, \ 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, \ 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, \ 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, \ 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, \ 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, \ 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, \ 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, \ 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, \ 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, \ 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, \ 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, \ 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, \ 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, \ 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, \ 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, \ 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, \ 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, \ 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, \ 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, \ 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, \ 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, \ 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, \ 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, \ 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, \ 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, \ 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, \ 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, \ 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, \ 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, \ 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, \ 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, \ 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x3A, 0xD2, 0xCA, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC3526_MODP_3072_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC3526_MODP_4096_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, \ 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, \ 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, \ 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, \ 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, \ 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, \ 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, \ 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, \ 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, \ 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, \ 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, \ 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, \ 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, \ 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, \ 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, \ 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, \ 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, \ 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, \ 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, \ 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, \ 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, \ 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, \ 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, \ 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, \ 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, \ 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, \ 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, \ 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, \ 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, \ 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, \ 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, \ 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, \ 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, \ 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, \ 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, \ 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, \ 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, \ 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, \ 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, \ 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, \ 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, \ 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, \ 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, \ 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, \ 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, \ 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x21, 0x08, 0x01, \ 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, \ 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, \ 0x99, 0xC3, 0x27, 0x18, 0x6A, 0xF4, 0xE2, 0x3C, \ 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, \ 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, \ 0xDB, 0xBB, 0xC2, 0xDB, 0x04, 0xDE, 0x8E, 0xF9, \ 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, \ 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, \ 0x99, 0xB2, 0x96, 0x4F, 0xA0, 0x90, 0xC3, 0xA2, \ 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, \ 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, \ 0xB8, 0x1B, 0xDD, 0x76, 0x21, 0x70, 0x48, 0x1C, \ 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, \ 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, \ 0x86, 0xFF, 0xB7, 0xDC, 0x90, 0xA6, 0xC0, 0x8F, \ 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x06, 0x31, 0x99, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC3526_MODP_4096_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC7919_FFDHE2048_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A, \ 0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1, \ 0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95, \ 0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB, \ 0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9, \ 0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8, \ 0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A, \ 0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61, \ 0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0, \ 0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3, \ 0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35, \ 0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77, \ 0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72, \ 0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35, \ 0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A, \ 0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61, \ 0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB, \ 0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68, \ 0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4, \ 0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19, \ 0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70, \ 0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC, \ 0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61, \ 0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF, \ 0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83, \ 0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73, \ 0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05, \ 0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2, \ 0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA, \ 0x88, 0x6B, 0x42, 0x38, 0x61, 0x28, 0x5C, 0x97, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, } #define MBEDTLS_DHM_RFC7919_FFDHE2048_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC7919_FFDHE3072_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A, \ 0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1, \ 0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95, \ 0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB, \ 0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9, \ 0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8, \ 0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A, \ 0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61, \ 0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0, \ 0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3, \ 0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35, \ 0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77, \ 0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72, \ 0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35, \ 0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A, \ 0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61, \ 0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB, \ 0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68, \ 0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4, \ 0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19, \ 0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70, \ 0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC, \ 0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61, \ 0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF, \ 0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83, \ 0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73, \ 0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05, \ 0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2, \ 0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA, \ 0x88, 0x6B, 0x42, 0x38, 0x61, 0x1F, 0xCF, 0xDC, \ 0xDE, 0x35, 0x5B, 0x3B, 0x65, 0x19, 0x03, 0x5B, \ 0xBC, 0x34, 0xF4, 0xDE, 0xF9, 0x9C, 0x02, 0x38, \ 0x61, 0xB4, 0x6F, 0xC9, 0xD6, 0xE6, 0xC9, 0x07, \ 0x7A, 0xD9, 0x1D, 0x26, 0x91, 0xF7, 0xF7, 0xEE, \ 0x59, 0x8C, 0xB0, 0xFA, 0xC1, 0x86, 0xD9, 0x1C, \ 0xAE, 0xFE, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, \ 0xB4, 0x13, 0x0C, 0x93, 0xBC, 0x43, 0x79, 0x44, \ 0xF4, 0xFD, 0x44, 0x52, 0xE2, 0xD7, 0x4D, 0xD3, \ 0x64, 0xF2, 0xE2, 0x1E, 0x71, 0xF5, 0x4B, 0xFF, \ 0x5C, 0xAE, 0x82, 0xAB, 0x9C, 0x9D, 0xF6, 0x9E, \ 0xE8, 0x6D, 0x2B, 0xC5, 0x22, 0x36, 0x3A, 0x0D, \ 0xAB, 0xC5, 0x21, 0x97, 0x9B, 0x0D, 0xEA, 0xDA, \ 0x1D, 0xBF, 0x9A, 0x42, 0xD5, 0xC4, 0x48, 0x4E, \ 0x0A, 0xBC, 0xD0, 0x6B, 0xFA, 0x53, 0xDD, 0xEF, \ 0x3C, 0x1B, 0x20, 0xEE, 0x3F, 0xD5, 0x9D, 0x7C, \ 0x25, 0xE4, 0x1D, 0x2B, 0x66, 0xC6, 0x2E, 0x37, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC7919_FFDHE3072_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC7919_FFDHE4096_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A, \ 0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1, \ 0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95, \ 0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB, \ 0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9, \ 0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8, \ 0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A, \ 0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61, \ 0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0, \ 0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3, \ 0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35, \ 0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77, \ 0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72, \ 0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35, \ 0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A, \ 0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61, \ 0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB, \ 0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68, \ 0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4, \ 0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19, \ 0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70, \ 0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC, \ 0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61, \ 0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF, \ 0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83, \ 0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73, \ 0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05, \ 0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2, \ 0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA, \ 0x88, 0x6B, 0x42, 0x38, 0x61, 0x1F, 0xCF, 0xDC, \ 0xDE, 0x35, 0x5B, 0x3B, 0x65, 0x19, 0x03, 0x5B, \ 0xBC, 0x34, 0xF4, 0xDE, 0xF9, 0x9C, 0x02, 0x38, \ 0x61, 0xB4, 0x6F, 0xC9, 0xD6, 0xE6, 0xC9, 0x07, \ 0x7A, 0xD9, 0x1D, 0x26, 0x91, 0xF7, 0xF7, 0xEE, \ 0x59, 0x8C, 0xB0, 0xFA, 0xC1, 0x86, 0xD9, 0x1C, \ 0xAE, 0xFE, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, \ 0xB4, 0x13, 0x0C, 0x93, 0xBC, 0x43, 0x79, 0x44, \ 0xF4, 0xFD, 0x44, 0x52, 0xE2, 0xD7, 0x4D, 0xD3, \ 0x64, 0xF2, 0xE2, 0x1E, 0x71, 0xF5, 0x4B, 0xFF, \ 0x5C, 0xAE, 0x82, 0xAB, 0x9C, 0x9D, 0xF6, 0x9E, \ 0xE8, 0x6D, 0x2B, 0xC5, 0x22, 0x36, 0x3A, 0x0D, \ 0xAB, 0xC5, 0x21, 0x97, 0x9B, 0x0D, 0xEA, 0xDA, \ 0x1D, 0xBF, 0x9A, 0x42, 0xD5, 0xC4, 0x48, 0x4E, \ 0x0A, 0xBC, 0xD0, 0x6B, 0xFA, 0x53, 0xDD, 0xEF, \ 0x3C, 0x1B, 0x20, 0xEE, 0x3F, 0xD5, 0x9D, 0x7C, \ 0x25, 0xE4, 0x1D, 0x2B, 0x66, 0x9E, 0x1E, 0xF1, \ 0x6E, 0x6F, 0x52, 0xC3, 0x16, 0x4D, 0xF4, 0xFB, \ 0x79, 0x30, 0xE9, 0xE4, 0xE5, 0x88, 0x57, 0xB6, \ 0xAC, 0x7D, 0x5F, 0x42, 0xD6, 0x9F, 0x6D, 0x18, \ 0x77, 0x63, 0xCF, 0x1D, 0x55, 0x03, 0x40, 0x04, \ 0x87, 0xF5, 0x5B, 0xA5, 0x7E, 0x31, 0xCC, 0x7A, \ 0x71, 0x35, 0xC8, 0x86, 0xEF, 0xB4, 0x31, 0x8A, \ 0xED, 0x6A, 0x1E, 0x01, 0x2D, 0x9E, 0x68, 0x32, \ 0xA9, 0x07, 0x60, 0x0A, 0x91, 0x81, 0x30, 0xC4, \ 0x6D, 0xC7, 0x78, 0xF9, 0x71, 0xAD, 0x00, 0x38, \ 0x09, 0x29, 0x99, 0xA3, 0x33, 0xCB, 0x8B, 0x7A, \ 0x1A, 0x1D, 0xB9, 0x3D, 0x71, 0x40, 0x00, 0x3C, \ 0x2A, 0x4E, 0xCE, 0xA9, 0xF9, 0x8D, 0x0A, 0xCC, \ 0x0A, 0x82, 0x91, 0xCD, 0xCE, 0xC9, 0x7D, 0xCF, \ 0x8E, 0xC9, 0xB5, 0x5A, 0x7F, 0x88, 0xA4, 0x6B, \ 0x4D, 0xB5, 0xA8, 0x51, 0xF4, 0x41, 0x82, 0xE1, \ 0xC6, 0x8A, 0x00, 0x7E, 0x5E, 0x65, 0x5F, 0x6A, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC7919_FFDHE4096_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC7919_FFDHE6144_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A, \ 0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1, \ 0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95, \ 0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB, \ 0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9, \ 0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8, \ 0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A, \ 0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61, \ 0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0, \ 0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3, \ 0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35, \ 0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77, \ 0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72, \ 0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35, \ 0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A, \ 0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61, \ 0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB, \ 0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68, \ 0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4, \ 0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19, \ 0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70, \ 0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC, \ 0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61, \ 0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF, \ 0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83, \ 0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73, \ 0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05, \ 0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2, \ 0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA, \ 0x88, 0x6B, 0x42, 0x38, 0x61, 0x1F, 0xCF, 0xDC, \ 0xDE, 0x35, 0x5B, 0x3B, 0x65, 0x19, 0x03, 0x5B, \ 0xBC, 0x34, 0xF4, 0xDE, 0xF9, 0x9C, 0x02, 0x38, \ 0x61, 0xB4, 0x6F, 0xC9, 0xD6, 0xE6, 0xC9, 0x07, \ 0x7A, 0xD9, 0x1D, 0x26, 0x91, 0xF7, 0xF7, 0xEE, \ 0x59, 0x8C, 0xB0, 0xFA, 0xC1, 0x86, 0xD9, 0x1C, \ 0xAE, 0xFE, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, \ 0xB4, 0x13, 0x0C, 0x93, 0xBC, 0x43, 0x79, 0x44, \ 0xF4, 0xFD, 0x44, 0x52, 0xE2, 0xD7, 0x4D, 0xD3, \ 0x64, 0xF2, 0xE2, 0x1E, 0x71, 0xF5, 0x4B, 0xFF, \ 0x5C, 0xAE, 0x82, 0xAB, 0x9C, 0x9D, 0xF6, 0x9E, \ 0xE8, 0x6D, 0x2B, 0xC5, 0x22, 0x36, 0x3A, 0x0D, \ 0xAB, 0xC5, 0x21, 0x97, 0x9B, 0x0D, 0xEA, 0xDA, \ 0x1D, 0xBF, 0x9A, 0x42, 0xD5, 0xC4, 0x48, 0x4E, \ 0x0A, 0xBC, 0xD0, 0x6B, 0xFA, 0x53, 0xDD, 0xEF, \ 0x3C, 0x1B, 0x20, 0xEE, 0x3F, 0xD5, 0x9D, 0x7C, \ 0x25, 0xE4, 0x1D, 0x2B, 0x66, 0x9E, 0x1E, 0xF1, \ 0x6E, 0x6F, 0x52, 0xC3, 0x16, 0x4D, 0xF4, 0xFB, \ 0x79, 0x30, 0xE9, 0xE4, 0xE5, 0x88, 0x57, 0xB6, \ 0xAC, 0x7D, 0x5F, 0x42, 0xD6, 0x9F, 0x6D, 0x18, \ 0x77, 0x63, 0xCF, 0x1D, 0x55, 0x03, 0x40, 0x04, \ 0x87, 0xF5, 0x5B, 0xA5, 0x7E, 0x31, 0xCC, 0x7A, \ 0x71, 0x35, 0xC8, 0x86, 0xEF, 0xB4, 0x31, 0x8A, \ 0xED, 0x6A, 0x1E, 0x01, 0x2D, 0x9E, 0x68, 0x32, \ 0xA9, 0x07, 0x60, 0x0A, 0x91, 0x81, 0x30, 0xC4, \ 0x6D, 0xC7, 0x78, 0xF9, 0x71, 0xAD, 0x00, 0x38, \ 0x09, 0x29, 0x99, 0xA3, 0x33, 0xCB, 0x8B, 0x7A, \ 0x1A, 0x1D, 0xB9, 0x3D, 0x71, 0x40, 0x00, 0x3C, \ 0x2A, 0x4E, 0xCE, 0xA9, 0xF9, 0x8D, 0x0A, 0xCC, \ 0x0A, 0x82, 0x91, 0xCD, 0xCE, 0xC9, 0x7D, 0xCF, \ 0x8E, 0xC9, 0xB5, 0x5A, 0x7F, 0x88, 0xA4, 0x6B, \ 0x4D, 0xB5, 0xA8, 0x51, 0xF4, 0x41, 0x82, 0xE1, \ 0xC6, 0x8A, 0x00, 0x7E, 0x5E, 0x0D, 0xD9, 0x02, \ 0x0B, 0xFD, 0x64, 0xB6, 0x45, 0x03, 0x6C, 0x7A, \ 0x4E, 0x67, 0x7D, 0x2C, 0x38, 0x53, 0x2A, 0x3A, \ 0x23, 0xBA, 0x44, 0x42, 0xCA, 0xF5, 0x3E, 0xA6, \ 0x3B, 0xB4, 0x54, 0x32, 0x9B, 0x76, 0x24, 0xC8, \ 0x91, 0x7B, 0xDD, 0x64, 0xB1, 0xC0, 0xFD, 0x4C, \ 0xB3, 0x8E, 0x8C, 0x33, 0x4C, 0x70, 0x1C, 0x3A, \ 0xCD, 0xAD, 0x06, 0x57, 0xFC, 0xCF, 0xEC, 0x71, \ 0x9B, 0x1F, 0x5C, 0x3E, 0x4E, 0x46, 0x04, 0x1F, \ 0x38, 0x81, 0x47, 0xFB, 0x4C, 0xFD, 0xB4, 0x77, \ 0xA5, 0x24, 0x71, 0xF7, 0xA9, 0xA9, 0x69, 0x10, \ 0xB8, 0x55, 0x32, 0x2E, 0xDB, 0x63, 0x40, 0xD8, \ 0xA0, 0x0E, 0xF0, 0x92, 0x35, 0x05, 0x11, 0xE3, \ 0x0A, 0xBE, 0xC1, 0xFF, 0xF9, 0xE3, 0xA2, 0x6E, \ 0x7F, 0xB2, 0x9F, 0x8C, 0x18, 0x30, 0x23, 0xC3, \ 0x58, 0x7E, 0x38, 0xDA, 0x00, 0x77, 0xD9, 0xB4, \ 0x76, 0x3E, 0x4E, 0x4B, 0x94, 0xB2, 0xBB, 0xC1, \ 0x94, 0xC6, 0x65, 0x1E, 0x77, 0xCA, 0xF9, 0x92, \ 0xEE, 0xAA, 0xC0, 0x23, 0x2A, 0x28, 0x1B, 0xF6, \ 0xB3, 0xA7, 0x39, 0xC1, 0x22, 0x61, 0x16, 0x82, \ 0x0A, 0xE8, 0xDB, 0x58, 0x47, 0xA6, 0x7C, 0xBE, \ 0xF9, 0xC9, 0x09, 0x1B, 0x46, 0x2D, 0x53, 0x8C, \ 0xD7, 0x2B, 0x03, 0x74, 0x6A, 0xE7, 0x7F, 0x5E, \ 0x62, 0x29, 0x2C, 0x31, 0x15, 0x62, 0xA8, 0x46, \ 0x50, 0x5D, 0xC8, 0x2D, 0xB8, 0x54, 0x33, 0x8A, \ 0xE4, 0x9F, 0x52, 0x35, 0xC9, 0x5B, 0x91, 0x17, \ 0x8C, 0xCF, 0x2D, 0xD5, 0xCA, 0xCE, 0xF4, 0x03, \ 0xEC, 0x9D, 0x18, 0x10, 0xC6, 0x27, 0x2B, 0x04, \ 0x5B, 0x3B, 0x71, 0xF9, 0xDC, 0x6B, 0x80, 0xD6, \ 0x3F, 0xDD, 0x4A, 0x8E, 0x9A, 0xDB, 0x1E, 0x69, \ 0x62, 0xA6, 0x95, 0x26, 0xD4, 0x31, 0x61, 0xC1, \ 0xA4, 0x1D, 0x57, 0x0D, 0x79, 0x38, 0xDA, 0xD4, \ 0xA4, 0x0E, 0x32, 0x9C, 0xD0, 0xE4, 0x0E, 0x65, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC7919_FFDHE6144_G_BIN { 0x02 } #define MBEDTLS_DHM_RFC7919_FFDHE8192_P_BIN { \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A, \ 0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1, \ 0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95, \ 0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB, \ 0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9, \ 0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8, \ 0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A, \ 0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61, \ 0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0, \ 0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3, \ 0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35, \ 0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77, \ 0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72, \ 0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35, \ 0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A, \ 0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61, \ 0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB, \ 0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68, \ 0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4, \ 0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19, \ 0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70, \ 0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC, \ 0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61, \ 0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF, \ 0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83, \ 0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73, \ 0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05, \ 0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2, \ 0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA, \ 0x88, 0x6B, 0x42, 0x38, 0x61, 0x1F, 0xCF, 0xDC, \ 0xDE, 0x35, 0x5B, 0x3B, 0x65, 0x19, 0x03, 0x5B, \ 0xBC, 0x34, 0xF4, 0xDE, 0xF9, 0x9C, 0x02, 0x38, \ 0x61, 0xB4, 0x6F, 0xC9, 0xD6, 0xE6, 0xC9, 0x07, \ 0x7A, 0xD9, 0x1D, 0x26, 0x91, 0xF7, 0xF7, 0xEE, \ 0x59, 0x8C, 0xB0, 0xFA, 0xC1, 0x86, 0xD9, 0x1C, \ 0xAE, 0xFE, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, \ 0xB4, 0x13, 0x0C, 0x93, 0xBC, 0x43, 0x79, 0x44, \ 0xF4, 0xFD, 0x44, 0x52, 0xE2, 0xD7, 0x4D, 0xD3, \ 0x64, 0xF2, 0xE2, 0x1E, 0x71, 0xF5, 0x4B, 0xFF, \ 0x5C, 0xAE, 0x82, 0xAB, 0x9C, 0x9D, 0xF6, 0x9E, \ 0xE8, 0x6D, 0x2B, 0xC5, 0x22, 0x36, 0x3A, 0x0D, \ 0xAB, 0xC5, 0x21, 0x97, 0x9B, 0x0D, 0xEA, 0xDA, \ 0x1D, 0xBF, 0x9A, 0x42, 0xD5, 0xC4, 0x48, 0x4E, \ 0x0A, 0xBC, 0xD0, 0x6B, 0xFA, 0x53, 0xDD, 0xEF, \ 0x3C, 0x1B, 0x20, 0xEE, 0x3F, 0xD5, 0x9D, 0x7C, \ 0x25, 0xE4, 0x1D, 0x2B, 0x66, 0x9E, 0x1E, 0xF1, \ 0x6E, 0x6F, 0x52, 0xC3, 0x16, 0x4D, 0xF4, 0xFB, \ 0x79, 0x30, 0xE9, 0xE4, 0xE5, 0x88, 0x57, 0xB6, \ 0xAC, 0x7D, 0x5F, 0x42, 0xD6, 0x9F, 0x6D, 0x18, \ 0x77, 0x63, 0xCF, 0x1D, 0x55, 0x03, 0x40, 0x04, \ 0x87, 0xF5, 0x5B, 0xA5, 0x7E, 0x31, 0xCC, 0x7A, \ 0x71, 0x35, 0xC8, 0x86, 0xEF, 0xB4, 0x31, 0x8A, \ 0xED, 0x6A, 0x1E, 0x01, 0x2D, 0x9E, 0x68, 0x32, \ 0xA9, 0x07, 0x60, 0x0A, 0x91, 0x81, 0x30, 0xC4, \ 0x6D, 0xC7, 0x78, 0xF9, 0x71, 0xAD, 0x00, 0x38, \ 0x09, 0x29, 0x99, 0xA3, 0x33, 0xCB, 0x8B, 0x7A, \ 0x1A, 0x1D, 0xB9, 0x3D, 0x71, 0x40, 0x00, 0x3C, \ 0x2A, 0x4E, 0xCE, 0xA9, 0xF9, 0x8D, 0x0A, 0xCC, \ 0x0A, 0x82, 0x91, 0xCD, 0xCE, 0xC9, 0x7D, 0xCF, \ 0x8E, 0xC9, 0xB5, 0x5A, 0x7F, 0x88, 0xA4, 0x6B, \ 0x4D, 0xB5, 0xA8, 0x51, 0xF4, 0x41, 0x82, 0xE1, \ 0xC6, 0x8A, 0x00, 0x7E, 0x5E, 0x0D, 0xD9, 0x02, \ 0x0B, 0xFD, 0x64, 0xB6, 0x45, 0x03, 0x6C, 0x7A, \ 0x4E, 0x67, 0x7D, 0x2C, 0x38, 0x53, 0x2A, 0x3A, \ 0x23, 0xBA, 0x44, 0x42, 0xCA, 0xF5, 0x3E, 0xA6, \ 0x3B, 0xB4, 0x54, 0x32, 0x9B, 0x76, 0x24, 0xC8, \ 0x91, 0x7B, 0xDD, 0x64, 0xB1, 0xC0, 0xFD, 0x4C, \ 0xB3, 0x8E, 0x8C, 0x33, 0x4C, 0x70, 0x1C, 0x3A, \ 0xCD, 0xAD, 0x06, 0x57, 0xFC, 0xCF, 0xEC, 0x71, \ 0x9B, 0x1F, 0x5C, 0x3E, 0x4E, 0x46, 0x04, 0x1F, \ 0x38, 0x81, 0x47, 0xFB, 0x4C, 0xFD, 0xB4, 0x77, \ 0xA5, 0x24, 0x71, 0xF7, 0xA9, 0xA9, 0x69, 0x10, \ 0xB8, 0x55, 0x32, 0x2E, 0xDB, 0x63, 0x40, 0xD8, \ 0xA0, 0x0E, 0xF0, 0x92, 0x35, 0x05, 0x11, 0xE3, \ 0x0A, 0xBE, 0xC1, 0xFF, 0xF9, 0xE3, 0xA2, 0x6E, \ 0x7F, 0xB2, 0x9F, 0x8C, 0x18, 0x30, 0x23, 0xC3, \ 0x58, 0x7E, 0x38, 0xDA, 0x00, 0x77, 0xD9, 0xB4, \ 0x76, 0x3E, 0x4E, 0x4B, 0x94, 0xB2, 0xBB, 0xC1, \ 0x94, 0xC6, 0x65, 0x1E, 0x77, 0xCA, 0xF9, 0x92, \ 0xEE, 0xAA, 0xC0, 0x23, 0x2A, 0x28, 0x1B, 0xF6, \ 0xB3, 0xA7, 0x39, 0xC1, 0x22, 0x61, 0x16, 0x82, \ 0x0A, 0xE8, 0xDB, 0x58, 0x47, 0xA6, 0x7C, 0xBE, \ 0xF9, 0xC9, 0x09, 0x1B, 0x46, 0x2D, 0x53, 0x8C, \ 0xD7, 0x2B, 0x03, 0x74, 0x6A, 0xE7, 0x7F, 0x5E, \ 0x62, 0x29, 0x2C, 0x31, 0x15, 0x62, 0xA8, 0x46, \ 0x50, 0x5D, 0xC8, 0x2D, 0xB8, 0x54, 0x33, 0x8A, \ 0xE4, 0x9F, 0x52, 0x35, 0xC9, 0x5B, 0x91, 0x17, \ 0x8C, 0xCF, 0x2D, 0xD5, 0xCA, 0xCE, 0xF4, 0x03, \ 0xEC, 0x9D, 0x18, 0x10, 0xC6, 0x27, 0x2B, 0x04, \ 0x5B, 0x3B, 0x71, 0xF9, 0xDC, 0x6B, 0x80, 0xD6, \ 0x3F, 0xDD, 0x4A, 0x8E, 0x9A, 0xDB, 0x1E, 0x69, \ 0x62, 0xA6, 0x95, 0x26, 0xD4, 0x31, 0x61, 0xC1, \ 0xA4, 0x1D, 0x57, 0x0D, 0x79, 0x38, 0xDA, 0xD4, \ 0xA4, 0x0E, 0x32, 0x9C, 0xCF, 0xF4, 0x6A, 0xAA, \ 0x36, 0xAD, 0x00, 0x4C, 0xF6, 0x00, 0xC8, 0x38, \ 0x1E, 0x42, 0x5A, 0x31, 0xD9, 0x51, 0xAE, 0x64, \ 0xFD, 0xB2, 0x3F, 0xCE, 0xC9, 0x50, 0x9D, 0x43, \ 0x68, 0x7F, 0xEB, 0x69, 0xED, 0xD1, 0xCC, 0x5E, \ 0x0B, 0x8C, 0xC3, 0xBD, 0xF6, 0x4B, 0x10, 0xEF, \ 0x86, 0xB6, 0x31, 0x42, 0xA3, 0xAB, 0x88, 0x29, \ 0x55, 0x5B, 0x2F, 0x74, 0x7C, 0x93, 0x26, 0x65, \ 0xCB, 0x2C, 0x0F, 0x1C, 0xC0, 0x1B, 0xD7, 0x02, \ 0x29, 0x38, 0x88, 0x39, 0xD2, 0xAF, 0x05, 0xE4, \ 0x54, 0x50, 0x4A, 0xC7, 0x8B, 0x75, 0x82, 0x82, \ 0x28, 0x46, 0xC0, 0xBA, 0x35, 0xC3, 0x5F, 0x5C, \ 0x59, 0x16, 0x0C, 0xC0, 0x46, 0xFD, 0x82, 0x51, \ 0x54, 0x1F, 0xC6, 0x8C, 0x9C, 0x86, 0xB0, 0x22, \ 0xBB, 0x70, 0x99, 0x87, 0x6A, 0x46, 0x0E, 0x74, \ 0x51, 0xA8, 0xA9, 0x31, 0x09, 0x70, 0x3F, 0xEE, \ 0x1C, 0x21, 0x7E, 0x6C, 0x38, 0x26, 0xE5, 0x2C, \ 0x51, 0xAA, 0x69, 0x1E, 0x0E, 0x42, 0x3C, 0xFC, \ 0x99, 0xE9, 0xE3, 0x16, 0x50, 0xC1, 0x21, 0x7B, \ 0x62, 0x48, 0x16, 0xCD, 0xAD, 0x9A, 0x95, 0xF9, \ 0xD5, 0xB8, 0x01, 0x94, 0x88, 0xD9, 0xC0, 0xA0, \ 0xA1, 0xFE, 0x30, 0x75, 0xA5, 0x77, 0xE2, 0x31, \ 0x83, 0xF8, 0x1D, 0x4A, 0x3F, 0x2F, 0xA4, 0x57, \ 0x1E, 0xFC, 0x8C, 0xE0, 0xBA, 0x8A, 0x4F, 0xE8, \ 0xB6, 0x85, 0x5D, 0xFE, 0x72, 0xB0, 0xA6, 0x6E, \ 0xDE, 0xD2, 0xFB, 0xAB, 0xFB, 0xE5, 0x8A, 0x30, \ 0xFA, 0xFA, 0xBE, 0x1C, 0x5D, 0x71, 0xA8, 0x7E, \ 0x2F, 0x74, 0x1E, 0xF8, 0xC1, 0xFE, 0x86, 0xFE, \ 0xA6, 0xBB, 0xFD, 0xE5, 0x30, 0x67, 0x7F, 0x0D, \ 0x97, 0xD1, 0x1D, 0x49, 0xF7, 0xA8, 0x44, 0x3D, \ 0x08, 0x22, 0xE5, 0x06, 0xA9, 0xF4, 0x61, 0x4E, \ 0x01, 0x1E, 0x2A, 0x94, 0x83, 0x8F, 0xF8, 0x8C, \ 0xD6, 0x8C, 0x8B, 0xB7, 0xC5, 0xC6, 0x42, 0x4C, \ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #define MBEDTLS_DHM_RFC7919_FFDHE8192_G_BIN { 0x02 } #endif /* dhm.h */
54,873
C++
.h
1,044
47.90613
117
0.625535
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,500
cmac.h
w1hkj_fldigi/src/include/mbedtls/cmac.h
/** * \file cmac.h * * \brief This file contains CMAC definitions and functions. * * The Cipher-based Message Authentication Code (CMAC) Mode for * Authentication is defined in <em>RFC-4493: The AES-CMAC Algorithm</em>. */ /* * Copyright (C) 2015-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CMAC_H #define MBEDTLS_CMAC_H #include "cipher.h" #ifdef __cplusplus extern "C" { #endif /* MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A /**< CMAC hardware accelerator failed. */ #define MBEDTLS_AES_BLOCK_SIZE 16 #define MBEDTLS_DES3_BLOCK_SIZE 8 #if defined(MBEDTLS_AES_C) #define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /**< The longest block used by CMAC is that of AES. */ #else #define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /**< The longest block used by CMAC is that of 3DES. */ #endif #if !defined(MBEDTLS_CMAC_ALT) /** * The CMAC context structure. */ struct mbedtls_cmac_context_t { /** The internal state of the CMAC algorithm. */ unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX]; /** Unprocessed data - either data that was not block aligned and is still * pending processing, or the final block. */ unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX]; /** The length of data pending processing. */ size_t unprocessed_len; }; #else /* !MBEDTLS_CMAC_ALT */ #include "cmac_alt.h" #endif /* !MBEDTLS_CMAC_ALT */ /** * \brief This function sets the CMAC key, and prepares to authenticate * the input data. * Must be called with an initialized cipher context. * * \param ctx The cipher context used for the CMAC operation, initialized * as one of the following types: MBEDTLS_CIPHER_AES_128_ECB, * MBEDTLS_CIPHER_AES_192_ECB, MBEDTLS_CIPHER_AES_256_ECB, * or MBEDTLS_CIPHER_DES_EDE3_ECB. * \param key The CMAC key. * \param keybits The length of the CMAC key in bits. * Must be supported by the cipher. * * \return \c 0 on success. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, const unsigned char *key, size_t keybits ); /** * \brief This function feeds an input buffer into an ongoing CMAC * computation. * * It is called between mbedtls_cipher_cmac_starts() or * mbedtls_cipher_cmac_reset(), and mbedtls_cipher_cmac_finish(). * Can be called repeatedly. * * \param ctx The cipher context used for the CMAC operation. * \param input The buffer holding the input data. * \param ilen The length of the input data. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the CMAC operation, and writes * the result to the output buffer. * * It is called after mbedtls_cipher_cmac_update(). * It can be followed by mbedtls_cipher_cmac_reset() and * mbedtls_cipher_cmac_update(), or mbedtls_cipher_free(). * * \param ctx The cipher context used for the CMAC operation. * \param output The output buffer for the CMAC checksum result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, unsigned char *output ); /** * \brief This function prepares the authentication of another * message with the same key as the previous CMAC * operation. * * It is called after mbedtls_cipher_cmac_finish() * and before mbedtls_cipher_cmac_update(). * * \param ctx The cipher context used for the CMAC operation. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ); /** * \brief This function calculates the full generic CMAC * on the input buffer with the provided key. * * The function allocates the context, performs the * calculation, and frees the context. * * The CMAC result is calculated as * output = generic CMAC(cmac key, input buffer). * * * \param cipher_info The cipher information. * \param key The CMAC key. * \param keylen The length of the CMAC key in bits. * \param input The buffer holding the input data. * \param ilen The length of the input data. * \param output The buffer for the generic CMAC result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ); #if defined(MBEDTLS_AES_C) /** * \brief This function implements the AES-CMAC-PRF-128 pseudorandom * function, as defined in * <em>RFC-4615: The Advanced Encryption Standard-Cipher-based * Message Authentication Code-Pseudo-Random Function-128 * (AES-CMAC-PRF-128) Algorithm for the Internet Key * Exchange Protocol (IKE).</em> * * \param key The key to use. * \param key_len The key length in Bytes. * \param input The buffer holding the input data. * \param in_len The length of the input data in Bytes. * \param output The buffer holding the generated 16 Bytes of * pseudorandom output. * * \return \c 0 on success. */ int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len, const unsigned char *input, size_t in_len, unsigned char output[16] ); #endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) ) /** * \brief The CMAC checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_cmac_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_CMAC_H */
8,062
C++
.h
189
39.502646
99
0.611104
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,501
compat-1.3.h
w1hkj_fldigi/src/include/mbedtls/compat-1.3.h
/** * \file compat-1.3.h * * \brief Compatibility definitions for using mbed TLS with client code written * for the PolarSSL naming conventions. * * \deprecated Use the new names directly instead */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #warning "Including compat-1.3.h is deprecated" #endif #ifndef MBEDTLS_COMPAT13_H #define MBEDTLS_COMPAT13_H /* * config.h options */ #if defined MBEDTLS_AESNI_C #define POLARSSL_AESNI_C MBEDTLS_AESNI_C #endif #if defined MBEDTLS_AES_ALT #define POLARSSL_AES_ALT MBEDTLS_AES_ALT #endif #if defined MBEDTLS_AES_C #define POLARSSL_AES_C MBEDTLS_AES_C #endif #if defined MBEDTLS_AES_ROM_TABLES #define POLARSSL_AES_ROM_TABLES MBEDTLS_AES_ROM_TABLES #endif #if defined MBEDTLS_ARC4_ALT #define POLARSSL_ARC4_ALT MBEDTLS_ARC4_ALT #endif #if defined MBEDTLS_ARC4_C #define POLARSSL_ARC4_C MBEDTLS_ARC4_C #endif #if defined MBEDTLS_ASN1_PARSE_C #define POLARSSL_ASN1_PARSE_C MBEDTLS_ASN1_PARSE_C #endif #if defined MBEDTLS_ASN1_WRITE_C #define POLARSSL_ASN1_WRITE_C MBEDTLS_ASN1_WRITE_C #endif #if defined MBEDTLS_BASE64_C #define POLARSSL_BASE64_C MBEDTLS_BASE64_C #endif #if defined MBEDTLS_BIGNUM_C #define POLARSSL_BIGNUM_C MBEDTLS_BIGNUM_C #endif #if defined MBEDTLS_BLOWFISH_ALT #define POLARSSL_BLOWFISH_ALT MBEDTLS_BLOWFISH_ALT #endif #if defined MBEDTLS_BLOWFISH_C #define POLARSSL_BLOWFISH_C MBEDTLS_BLOWFISH_C #endif #if defined MBEDTLS_CAMELLIA_ALT #define POLARSSL_CAMELLIA_ALT MBEDTLS_CAMELLIA_ALT #endif #if defined MBEDTLS_CAMELLIA_C #define POLARSSL_CAMELLIA_C MBEDTLS_CAMELLIA_C #endif #if defined MBEDTLS_CAMELLIA_SMALL_MEMORY #define POLARSSL_CAMELLIA_SMALL_MEMORY MBEDTLS_CAMELLIA_SMALL_MEMORY #endif #if defined MBEDTLS_CCM_C #define POLARSSL_CCM_C MBEDTLS_CCM_C #endif #if defined MBEDTLS_CERTS_C #define POLARSSL_CERTS_C MBEDTLS_CERTS_C #endif #if defined MBEDTLS_CIPHER_C #define POLARSSL_CIPHER_C MBEDTLS_CIPHER_C #endif #if defined MBEDTLS_CIPHER_MODE_CBC #define POLARSSL_CIPHER_MODE_CBC MBEDTLS_CIPHER_MODE_CBC #endif #if defined MBEDTLS_CIPHER_MODE_CFB #define POLARSSL_CIPHER_MODE_CFB MBEDTLS_CIPHER_MODE_CFB #endif #if defined MBEDTLS_CIPHER_MODE_CTR #define POLARSSL_CIPHER_MODE_CTR MBEDTLS_CIPHER_MODE_CTR #endif #if defined MBEDTLS_CIPHER_NULL_CIPHER #define POLARSSL_CIPHER_NULL_CIPHER MBEDTLS_CIPHER_NULL_CIPHER #endif #if defined MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS #define POLARSSL_CIPHER_PADDING_ONE_AND_ZEROS MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS #endif #if defined MBEDTLS_CIPHER_PADDING_PKCS7 #define POLARSSL_CIPHER_PADDING_PKCS7 MBEDTLS_CIPHER_PADDING_PKCS7 #endif #if defined MBEDTLS_CIPHER_PADDING_ZEROS #define POLARSSL_CIPHER_PADDING_ZEROS MBEDTLS_CIPHER_PADDING_ZEROS #endif #if defined MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN #define POLARSSL_CIPHER_PADDING_ZEROS_AND_LEN MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN #endif #if defined MBEDTLS_CTR_DRBG_C #define POLARSSL_CTR_DRBG_C MBEDTLS_CTR_DRBG_C #endif #if defined MBEDTLS_DEBUG_C #define POLARSSL_DEBUG_C MBEDTLS_DEBUG_C #endif #if defined MBEDTLS_DEPRECATED_REMOVED #define POLARSSL_DEPRECATED_REMOVED MBEDTLS_DEPRECATED_REMOVED #endif #if defined MBEDTLS_DEPRECATED_WARNING #define POLARSSL_DEPRECATED_WARNING MBEDTLS_DEPRECATED_WARNING #endif #if defined MBEDTLS_DES_ALT #define POLARSSL_DES_ALT MBEDTLS_DES_ALT #endif #if defined MBEDTLS_DES_C #define POLARSSL_DES_C MBEDTLS_DES_C #endif #if defined MBEDTLS_DHM_C #define POLARSSL_DHM_C MBEDTLS_DHM_C #endif #if defined MBEDTLS_ECDH_C #define POLARSSL_ECDH_C MBEDTLS_ECDH_C #endif #if defined MBEDTLS_ECDSA_C #define POLARSSL_ECDSA_C MBEDTLS_ECDSA_C #endif #if defined MBEDTLS_ECDSA_DETERMINISTIC #define POLARSSL_ECDSA_DETERMINISTIC MBEDTLS_ECDSA_DETERMINISTIC #endif #if defined MBEDTLS_ECP_C #define POLARSSL_ECP_C MBEDTLS_ECP_C #endif #if defined MBEDTLS_ECP_DP_BP256R1_ENABLED #define POLARSSL_ECP_DP_BP256R1_ENABLED MBEDTLS_ECP_DP_BP256R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_BP384R1_ENABLED #define POLARSSL_ECP_DP_BP384R1_ENABLED MBEDTLS_ECP_DP_BP384R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_BP512R1_ENABLED #define POLARSSL_ECP_DP_BP512R1_ENABLED MBEDTLS_ECP_DP_BP512R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_CURVE25519_ENABLED #define POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_CURVE25519_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP192K1_ENABLED #define POLARSSL_ECP_DP_SECP192K1_ENABLED MBEDTLS_ECP_DP_SECP192K1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP192R1_ENABLED #define POLARSSL_ECP_DP_SECP192R1_ENABLED MBEDTLS_ECP_DP_SECP192R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP224K1_ENABLED #define POLARSSL_ECP_DP_SECP224K1_ENABLED MBEDTLS_ECP_DP_SECP224K1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP224R1_ENABLED #define POLARSSL_ECP_DP_SECP224R1_ENABLED MBEDTLS_ECP_DP_SECP224R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP256K1_ENABLED #define POLARSSL_ECP_DP_SECP256K1_ENABLED MBEDTLS_ECP_DP_SECP256K1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP256R1_ENABLED #define POLARSSL_ECP_DP_SECP256R1_ENABLED MBEDTLS_ECP_DP_SECP256R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP384R1_ENABLED #define POLARSSL_ECP_DP_SECP384R1_ENABLED MBEDTLS_ECP_DP_SECP384R1_ENABLED #endif #if defined MBEDTLS_ECP_DP_SECP521R1_ENABLED #define POLARSSL_ECP_DP_SECP521R1_ENABLED MBEDTLS_ECP_DP_SECP521R1_ENABLED #endif #if defined MBEDTLS_ECP_FIXED_POINT_OPTIM #define POLARSSL_ECP_FIXED_POINT_OPTIM MBEDTLS_ECP_FIXED_POINT_OPTIM #endif #if defined MBEDTLS_ECP_MAX_BITS #define POLARSSL_ECP_MAX_BITS MBEDTLS_ECP_MAX_BITS #endif #if defined MBEDTLS_ECP_NIST_OPTIM #define POLARSSL_ECP_NIST_OPTIM MBEDTLS_ECP_NIST_OPTIM #endif #if defined MBEDTLS_ECP_WINDOW_SIZE #define POLARSSL_ECP_WINDOW_SIZE MBEDTLS_ECP_WINDOW_SIZE #endif #if defined MBEDTLS_ENABLE_WEAK_CIPHERSUITES #define POLARSSL_ENABLE_WEAK_CIPHERSUITES MBEDTLS_ENABLE_WEAK_CIPHERSUITES #endif #if defined MBEDTLS_ENTROPY_C #define POLARSSL_ENTROPY_C MBEDTLS_ENTROPY_C #endif #if defined MBEDTLS_ENTROPY_FORCE_SHA256 #define POLARSSL_ENTROPY_FORCE_SHA256 MBEDTLS_ENTROPY_FORCE_SHA256 #endif #if defined MBEDTLS_ERROR_C #define POLARSSL_ERROR_C MBEDTLS_ERROR_C #endif #if defined MBEDTLS_ERROR_STRERROR_DUMMY #define POLARSSL_ERROR_STRERROR_DUMMY MBEDTLS_ERROR_STRERROR_DUMMY #endif #if defined MBEDTLS_FS_IO #define POLARSSL_FS_IO MBEDTLS_FS_IO #endif #if defined MBEDTLS_GCM_C #define POLARSSL_GCM_C MBEDTLS_GCM_C #endif #if defined MBEDTLS_GENPRIME #define POLARSSL_GENPRIME MBEDTLS_GENPRIME #endif #if defined MBEDTLS_HAVEGE_C #define POLARSSL_HAVEGE_C MBEDTLS_HAVEGE_C #endif #if defined MBEDTLS_HAVE_ASM #define POLARSSL_HAVE_ASM MBEDTLS_HAVE_ASM #endif #if defined MBEDTLS_HAVE_SSE2 #define POLARSSL_HAVE_SSE2 MBEDTLS_HAVE_SSE2 #endif #if defined MBEDTLS_HAVE_TIME #define POLARSSL_HAVE_TIME MBEDTLS_HAVE_TIME #endif #if defined MBEDTLS_HMAC_DRBG_C #define POLARSSL_HMAC_DRBG_C MBEDTLS_HMAC_DRBG_C #endif #if defined MBEDTLS_HMAC_DRBG_MAX_INPUT #define POLARSSL_HMAC_DRBG_MAX_INPUT MBEDTLS_HMAC_DRBG_MAX_INPUT #endif #if defined MBEDTLS_HMAC_DRBG_MAX_REQUEST #define POLARSSL_HMAC_DRBG_MAX_REQUEST MBEDTLS_HMAC_DRBG_MAX_REQUEST #endif #if defined MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT #define POLARSSL_HMAC_DRBG_MAX_SEED_INPUT MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT #endif #if defined MBEDTLS_HMAC_DRBG_RESEED_INTERVAL #define POLARSSL_HMAC_DRBG_RESEED_INTERVAL MBEDTLS_HMAC_DRBG_RESEED_INTERVAL #endif #if defined MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED #define POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED #define POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED #define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED #define POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED #define POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED #define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED #define POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_PSK_ENABLED #define POLARSSL_KEY_EXCHANGE_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_PSK_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_RSA_ENABLED #define POLARSSL_KEY_EXCHANGE_RSA_ENABLED MBEDTLS_KEY_EXCHANGE_RSA_ENABLED #endif #if defined MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED #define POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED #endif #if defined MBEDTLS_MD2_ALT #define POLARSSL_MD2_ALT MBEDTLS_MD2_ALT #endif #if defined MBEDTLS_MD2_C #define POLARSSL_MD2_C MBEDTLS_MD2_C #endif #if defined MBEDTLS_MD2_PROCESS_ALT #define POLARSSL_MD2_PROCESS_ALT MBEDTLS_MD2_PROCESS_ALT #endif #if defined MBEDTLS_MD4_ALT #define POLARSSL_MD4_ALT MBEDTLS_MD4_ALT #endif #if defined MBEDTLS_MD4_C #define POLARSSL_MD4_C MBEDTLS_MD4_C #endif #if defined MBEDTLS_MD4_PROCESS_ALT #define POLARSSL_MD4_PROCESS_ALT MBEDTLS_MD4_PROCESS_ALT #endif #if defined MBEDTLS_MD5_ALT #define POLARSSL_MD5_ALT MBEDTLS_MD5_ALT #endif #if defined MBEDTLS_MD5_C #define POLARSSL_MD5_C MBEDTLS_MD5_C #endif #if defined MBEDTLS_MD5_PROCESS_ALT #define POLARSSL_MD5_PROCESS_ALT MBEDTLS_MD5_PROCESS_ALT #endif #if defined MBEDTLS_MD_C #define POLARSSL_MD_C MBEDTLS_MD_C #endif #if defined MBEDTLS_MEMORY_ALIGN_MULTIPLE #define POLARSSL_MEMORY_ALIGN_MULTIPLE MBEDTLS_MEMORY_ALIGN_MULTIPLE #endif #if defined MBEDTLS_MEMORY_BACKTRACE #define POLARSSL_MEMORY_BACKTRACE MBEDTLS_MEMORY_BACKTRACE #endif #if defined MBEDTLS_MEMORY_BUFFER_ALLOC_C #define POLARSSL_MEMORY_BUFFER_ALLOC_C MBEDTLS_MEMORY_BUFFER_ALLOC_C #endif #if defined MBEDTLS_MEMORY_DEBUG #define POLARSSL_MEMORY_DEBUG MBEDTLS_MEMORY_DEBUG #endif #if defined MBEDTLS_MPI_MAX_SIZE #define POLARSSL_MPI_MAX_SIZE MBEDTLS_MPI_MAX_SIZE #endif #if defined MBEDTLS_MPI_WINDOW_SIZE #define POLARSSL_MPI_WINDOW_SIZE MBEDTLS_MPI_WINDOW_SIZE #endif #if defined MBEDTLS_NET_C #define POLARSSL_NET_C MBEDTLS_NET_C #endif #if defined MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES #define POLARSSL_NO_DEFAULT_ENTROPY_SOURCES MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES #endif #if defined MBEDTLS_NO_PLATFORM_ENTROPY #define POLARSSL_NO_PLATFORM_ENTROPY MBEDTLS_NO_PLATFORM_ENTROPY #endif #if defined MBEDTLS_OID_C #define POLARSSL_OID_C MBEDTLS_OID_C #endif #if defined MBEDTLS_PADLOCK_C #define POLARSSL_PADLOCK_C MBEDTLS_PADLOCK_C #endif #if defined MBEDTLS_PEM_PARSE_C #define POLARSSL_PEM_PARSE_C MBEDTLS_PEM_PARSE_C #endif #if defined MBEDTLS_PEM_WRITE_C #define POLARSSL_PEM_WRITE_C MBEDTLS_PEM_WRITE_C #endif #if defined MBEDTLS_PKCS11_C #define POLARSSL_PKCS11_C MBEDTLS_PKCS11_C #endif #if defined MBEDTLS_PKCS12_C #define POLARSSL_PKCS12_C MBEDTLS_PKCS12_C #endif #if defined MBEDTLS_PKCS1_V15 #define POLARSSL_PKCS1_V15 MBEDTLS_PKCS1_V15 #endif #if defined MBEDTLS_PKCS1_V21 #define POLARSSL_PKCS1_V21 MBEDTLS_PKCS1_V21 #endif #if defined MBEDTLS_PKCS5_C #define POLARSSL_PKCS5_C MBEDTLS_PKCS5_C #endif #if defined MBEDTLS_PK_C #define POLARSSL_PK_C MBEDTLS_PK_C #endif #if defined MBEDTLS_PK_PARSE_C #define POLARSSL_PK_PARSE_C MBEDTLS_PK_PARSE_C #endif #if defined MBEDTLS_PK_PARSE_EC_EXTENDED #define POLARSSL_PK_PARSE_EC_EXTENDED MBEDTLS_PK_PARSE_EC_EXTENDED #endif #if defined MBEDTLS_PK_RSA_ALT_SUPPORT #define POLARSSL_PK_RSA_ALT_SUPPORT MBEDTLS_PK_RSA_ALT_SUPPORT #endif #if defined MBEDTLS_PK_WRITE_C #define POLARSSL_PK_WRITE_C MBEDTLS_PK_WRITE_C #endif #if defined MBEDTLS_PLATFORM_C #define POLARSSL_PLATFORM_C MBEDTLS_PLATFORM_C #endif #if defined MBEDTLS_PLATFORM_EXIT_ALT #define POLARSSL_PLATFORM_EXIT_ALT MBEDTLS_PLATFORM_EXIT_ALT #endif #if defined MBEDTLS_PLATFORM_EXIT_MACRO #define POLARSSL_PLATFORM_EXIT_MACRO MBEDTLS_PLATFORM_EXIT_MACRO #endif #if defined MBEDTLS_PLATFORM_FPRINTF_ALT #define POLARSSL_PLATFORM_FPRINTF_ALT MBEDTLS_PLATFORM_FPRINTF_ALT #endif #if defined MBEDTLS_PLATFORM_FPRINTF_MACRO #define POLARSSL_PLATFORM_FPRINTF_MACRO MBEDTLS_PLATFORM_FPRINTF_MACRO #endif #if defined MBEDTLS_PLATFORM_FREE_MACRO #define POLARSSL_PLATFORM_FREE_MACRO MBEDTLS_PLATFORM_FREE_MACRO #endif #if defined MBEDTLS_PLATFORM_MEMORY #define POLARSSL_PLATFORM_MEMORY MBEDTLS_PLATFORM_MEMORY #endif #if defined MBEDTLS_PLATFORM_NO_STD_FUNCTIONS #define POLARSSL_PLATFORM_NO_STD_FUNCTIONS MBEDTLS_PLATFORM_NO_STD_FUNCTIONS #endif #if defined MBEDTLS_PLATFORM_PRINTF_ALT #define POLARSSL_PLATFORM_PRINTF_ALT MBEDTLS_PLATFORM_PRINTF_ALT #endif #if defined MBEDTLS_PLATFORM_PRINTF_MACRO #define POLARSSL_PLATFORM_PRINTF_MACRO MBEDTLS_PLATFORM_PRINTF_MACRO #endif #if defined MBEDTLS_PLATFORM_SNPRINTF_ALT #define POLARSSL_PLATFORM_SNPRINTF_ALT MBEDTLS_PLATFORM_SNPRINTF_ALT #endif #if defined MBEDTLS_PLATFORM_SNPRINTF_MACRO #define POLARSSL_PLATFORM_SNPRINTF_MACRO MBEDTLS_PLATFORM_SNPRINTF_MACRO #endif #if defined MBEDTLS_PLATFORM_STD_EXIT #define POLARSSL_PLATFORM_STD_EXIT MBEDTLS_PLATFORM_STD_EXIT #endif #if defined MBEDTLS_PLATFORM_STD_FPRINTF #define POLARSSL_PLATFORM_STD_FPRINTF MBEDTLS_PLATFORM_STD_FPRINTF #endif #if defined MBEDTLS_PLATFORM_STD_FREE #define POLARSSL_PLATFORM_STD_FREE MBEDTLS_PLATFORM_STD_FREE #endif #if defined MBEDTLS_PLATFORM_STD_MEM_HDR #define POLARSSL_PLATFORM_STD_MEM_HDR MBEDTLS_PLATFORM_STD_MEM_HDR #endif #if defined MBEDTLS_PLATFORM_STD_PRINTF #define POLARSSL_PLATFORM_STD_PRINTF MBEDTLS_PLATFORM_STD_PRINTF #endif #if defined MBEDTLS_PLATFORM_STD_SNPRINTF #define POLARSSL_PLATFORM_STD_SNPRINTF MBEDTLS_PLATFORM_STD_SNPRINTF #endif #if defined MBEDTLS_PSK_MAX_LEN #define POLARSSL_PSK_MAX_LEN MBEDTLS_PSK_MAX_LEN #endif #if defined MBEDTLS_REMOVE_ARC4_CIPHERSUITES #define POLARSSL_REMOVE_ARC4_CIPHERSUITES MBEDTLS_REMOVE_ARC4_CIPHERSUITES #endif #if defined MBEDTLS_RIPEMD160_ALT #define POLARSSL_RIPEMD160_ALT MBEDTLS_RIPEMD160_ALT #endif #if defined MBEDTLS_RIPEMD160_C #define POLARSSL_RIPEMD160_C MBEDTLS_RIPEMD160_C #endif #if defined MBEDTLS_RIPEMD160_PROCESS_ALT #define POLARSSL_RIPEMD160_PROCESS_ALT MBEDTLS_RIPEMD160_PROCESS_ALT #endif #if defined MBEDTLS_RSA_C #define POLARSSL_RSA_C MBEDTLS_RSA_C #endif #if defined MBEDTLS_RSA_NO_CRT #define POLARSSL_RSA_NO_CRT MBEDTLS_RSA_NO_CRT #endif #if defined MBEDTLS_SELF_TEST #define POLARSSL_SELF_TEST MBEDTLS_SELF_TEST #endif #if defined MBEDTLS_SHA1_ALT #define POLARSSL_SHA1_ALT MBEDTLS_SHA1_ALT #endif #if defined MBEDTLS_SHA1_C #define POLARSSL_SHA1_C MBEDTLS_SHA1_C #endif #if defined MBEDTLS_SHA1_PROCESS_ALT #define POLARSSL_SHA1_PROCESS_ALT MBEDTLS_SHA1_PROCESS_ALT #endif #if defined MBEDTLS_SHA256_ALT #define POLARSSL_SHA256_ALT MBEDTLS_SHA256_ALT #endif #if defined MBEDTLS_SHA256_C #define POLARSSL_SHA256_C MBEDTLS_SHA256_C #endif #if defined MBEDTLS_SHA256_PROCESS_ALT #define POLARSSL_SHA256_PROCESS_ALT MBEDTLS_SHA256_PROCESS_ALT #endif #if defined MBEDTLS_SHA512_ALT #define POLARSSL_SHA512_ALT MBEDTLS_SHA512_ALT #endif #if defined MBEDTLS_SHA512_C #define POLARSSL_SHA512_C MBEDTLS_SHA512_C #endif #if defined MBEDTLS_SHA512_PROCESS_ALT #define POLARSSL_SHA512_PROCESS_ALT MBEDTLS_SHA512_PROCESS_ALT #endif #if defined MBEDTLS_SSL_ALL_ALERT_MESSAGES #define POLARSSL_SSL_ALL_ALERT_MESSAGES MBEDTLS_SSL_ALL_ALERT_MESSAGES #endif #if defined MBEDTLS_SSL_ALPN #define POLARSSL_SSL_ALPN MBEDTLS_SSL_ALPN #endif #if defined MBEDTLS_SSL_CACHE_C #define POLARSSL_SSL_CACHE_C MBEDTLS_SSL_CACHE_C #endif #if defined MBEDTLS_SSL_CBC_RECORD_SPLITTING #define POLARSSL_SSL_CBC_RECORD_SPLITTING MBEDTLS_SSL_CBC_RECORD_SPLITTING #endif #if defined MBEDTLS_SSL_CLI_C #define POLARSSL_SSL_CLI_C MBEDTLS_SSL_CLI_C #endif #if defined MBEDTLS_SSL_COOKIE_C #define POLARSSL_SSL_COOKIE_C MBEDTLS_SSL_COOKIE_C #endif #if defined MBEDTLS_SSL_COOKIE_TIMEOUT #define POLARSSL_SSL_COOKIE_TIMEOUT MBEDTLS_SSL_COOKIE_TIMEOUT #endif #if defined MBEDTLS_SSL_DEBUG_ALL #define POLARSSL_SSL_DEBUG_ALL MBEDTLS_SSL_DEBUG_ALL #endif #if defined MBEDTLS_SSL_DTLS_ANTI_REPLAY #define POLARSSL_SSL_DTLS_ANTI_REPLAY MBEDTLS_SSL_DTLS_ANTI_REPLAY #endif #if defined MBEDTLS_SSL_DTLS_BADMAC_LIMIT #define POLARSSL_SSL_DTLS_BADMAC_LIMIT MBEDTLS_SSL_DTLS_BADMAC_LIMIT #endif #if defined MBEDTLS_SSL_DTLS_HELLO_VERIFY #define POLARSSL_SSL_DTLS_HELLO_VERIFY MBEDTLS_SSL_DTLS_HELLO_VERIFY #endif #if defined MBEDTLS_SSL_ENCRYPT_THEN_MAC #define POLARSSL_SSL_ENCRYPT_THEN_MAC MBEDTLS_SSL_ENCRYPT_THEN_MAC #endif #if defined MBEDTLS_SSL_EXTENDED_MASTER_SECRET #define POLARSSL_SSL_EXTENDED_MASTER_SECRET MBEDTLS_SSL_EXTENDED_MASTER_SECRET #endif #if defined MBEDTLS_SSL_FALLBACK_SCSV #define POLARSSL_SSL_FALLBACK_SCSV MBEDTLS_SSL_FALLBACK_SCSV #endif #if defined MBEDTLS_SSL_HW_RECORD_ACCEL #define POLARSSL_SSL_HW_RECORD_ACCEL MBEDTLS_SSL_HW_RECORD_ACCEL #endif #if defined MBEDTLS_SSL_MAX_FRAGMENT_LENGTH #define POLARSSL_SSL_MAX_FRAGMENT_LENGTH MBEDTLS_SSL_MAX_FRAGMENT_LENGTH #endif #if defined MBEDTLS_SSL_PROTO_DTLS #define POLARSSL_SSL_PROTO_DTLS MBEDTLS_SSL_PROTO_DTLS #endif #if defined MBEDTLS_SSL_PROTO_SSL3 #define POLARSSL_SSL_PROTO_SSL3 MBEDTLS_SSL_PROTO_SSL3 #endif #if defined MBEDTLS_SSL_PROTO_TLS1 #define POLARSSL_SSL_PROTO_TLS1 MBEDTLS_SSL_PROTO_TLS1 #endif #if defined MBEDTLS_SSL_PROTO_TLS1_1 #define POLARSSL_SSL_PROTO_TLS1_1 MBEDTLS_SSL_PROTO_TLS1_1 #endif #if defined MBEDTLS_SSL_PROTO_TLS1_2 #define POLARSSL_SSL_PROTO_TLS1_2 MBEDTLS_SSL_PROTO_TLS1_2 #endif #if defined MBEDTLS_SSL_RENEGOTIATION #define POLARSSL_SSL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION #endif #if defined MBEDTLS_SSL_SERVER_NAME_INDICATION #define POLARSSL_SSL_SERVER_NAME_INDICATION MBEDTLS_SSL_SERVER_NAME_INDICATION #endif #if defined MBEDTLS_SSL_SESSION_TICKETS #define POLARSSL_SSL_SESSION_TICKETS MBEDTLS_SSL_SESSION_TICKETS #endif #if defined MBEDTLS_SSL_SRV_C #define POLARSSL_SSL_SRV_C MBEDTLS_SSL_SRV_C #endif #if defined MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE #define POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE #endif #if defined MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO #define POLARSSL_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO #endif #if defined MBEDTLS_SSL_TLS_C #define POLARSSL_SSL_TLS_C MBEDTLS_SSL_TLS_C #endif #if defined MBEDTLS_SSL_TRUNCATED_HMAC #define POLARSSL_SSL_TRUNCATED_HMAC MBEDTLS_SSL_TRUNCATED_HMAC #endif #if defined MBEDTLS_THREADING_ALT #define POLARSSL_THREADING_ALT MBEDTLS_THREADING_ALT #endif #if defined MBEDTLS_THREADING_C #define POLARSSL_THREADING_C MBEDTLS_THREADING_C #endif #if defined MBEDTLS_THREADING_PTHREAD #define POLARSSL_THREADING_PTHREAD MBEDTLS_THREADING_PTHREAD #endif #if defined MBEDTLS_TIMING_ALT #define POLARSSL_TIMING_ALT MBEDTLS_TIMING_ALT #endif #if defined MBEDTLS_TIMING_C #define POLARSSL_TIMING_C MBEDTLS_TIMING_C #endif #if defined MBEDTLS_VERSION_C #define POLARSSL_VERSION_C MBEDTLS_VERSION_C #endif #if defined MBEDTLS_VERSION_FEATURES #define POLARSSL_VERSION_FEATURES MBEDTLS_VERSION_FEATURES #endif #if defined MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 #define POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3 MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 #endif #if defined MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION #endif #if defined MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE #define POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE #endif #if defined MBEDTLS_X509_CHECK_KEY_USAGE #define POLARSSL_X509_CHECK_KEY_USAGE MBEDTLS_X509_CHECK_KEY_USAGE #endif #if defined MBEDTLS_X509_CREATE_C #define POLARSSL_X509_CREATE_C MBEDTLS_X509_CREATE_C #endif #if defined MBEDTLS_X509_CRL_PARSE_C #define POLARSSL_X509_CRL_PARSE_C MBEDTLS_X509_CRL_PARSE_C #endif #if defined MBEDTLS_X509_CRT_PARSE_C #define POLARSSL_X509_CRT_PARSE_C MBEDTLS_X509_CRT_PARSE_C #endif #if defined MBEDTLS_X509_CRT_WRITE_C #define POLARSSL_X509_CRT_WRITE_C MBEDTLS_X509_CRT_WRITE_C #endif #if defined MBEDTLS_X509_CSR_PARSE_C #define POLARSSL_X509_CSR_PARSE_C MBEDTLS_X509_CSR_PARSE_C #endif #if defined MBEDTLS_X509_CSR_WRITE_C #define POLARSSL_X509_CSR_WRITE_C MBEDTLS_X509_CSR_WRITE_C #endif #if defined MBEDTLS_X509_MAX_INTERMEDIATE_CA #define POLARSSL_X509_MAX_INTERMEDIATE_CA MBEDTLS_X509_MAX_INTERMEDIATE_CA #endif #if defined MBEDTLS_X509_RSASSA_PSS_SUPPORT #define POLARSSL_X509_RSASSA_PSS_SUPPORT MBEDTLS_X509_RSASSA_PSS_SUPPORT #endif #if defined MBEDTLS_X509_USE_C #define POLARSSL_X509_USE_C MBEDTLS_X509_USE_C #endif #if defined MBEDTLS_XTEA_ALT #define POLARSSL_XTEA_ALT MBEDTLS_XTEA_ALT #endif #if defined MBEDTLS_XTEA_C #define POLARSSL_XTEA_C MBEDTLS_XTEA_C #endif #if defined MBEDTLS_ZLIB_SUPPORT #define POLARSSL_ZLIB_SUPPORT MBEDTLS_ZLIB_SUPPORT #endif /* * Misc names (macros, types, functions, enum constants...) */ #define AES_DECRYPT MBEDTLS_AES_DECRYPT #define AES_ENCRYPT MBEDTLS_AES_ENCRYPT #define ASN1_BIT_STRING MBEDTLS_ASN1_BIT_STRING #define ASN1_BMP_STRING MBEDTLS_ASN1_BMP_STRING #define ASN1_BOOLEAN MBEDTLS_ASN1_BOOLEAN #define ASN1_CHK_ADD MBEDTLS_ASN1_CHK_ADD #define ASN1_CONSTRUCTED MBEDTLS_ASN1_CONSTRUCTED #define ASN1_CONTEXT_SPECIFIC MBEDTLS_ASN1_CONTEXT_SPECIFIC #define ASN1_GENERALIZED_TIME MBEDTLS_ASN1_GENERALIZED_TIME #define ASN1_IA5_STRING MBEDTLS_ASN1_IA5_STRING #define ASN1_INTEGER MBEDTLS_ASN1_INTEGER #define ASN1_NULL MBEDTLS_ASN1_NULL #define ASN1_OCTET_STRING MBEDTLS_ASN1_OCTET_STRING #define ASN1_OID MBEDTLS_ASN1_OID #define ASN1_PRIMITIVE MBEDTLS_ASN1_PRIMITIVE #define ASN1_PRINTABLE_STRING MBEDTLS_ASN1_PRINTABLE_STRING #define ASN1_SEQUENCE MBEDTLS_ASN1_SEQUENCE #define ASN1_SET MBEDTLS_ASN1_SET #define ASN1_T61_STRING MBEDTLS_ASN1_T61_STRING #define ASN1_UNIVERSAL_STRING MBEDTLS_ASN1_UNIVERSAL_STRING #define ASN1_UTC_TIME MBEDTLS_ASN1_UTC_TIME #define ASN1_UTF8_STRING MBEDTLS_ASN1_UTF8_STRING #define BADCERT_CN_MISMATCH MBEDTLS_X509_BADCERT_CN_MISMATCH #define BADCERT_EXPIRED MBEDTLS_X509_BADCERT_EXPIRED #define BADCERT_FUTURE MBEDTLS_X509_BADCERT_FUTURE #define BADCERT_MISSING MBEDTLS_X509_BADCERT_MISSING #define BADCERT_NOT_TRUSTED MBEDTLS_X509_BADCERT_NOT_TRUSTED #define BADCERT_OTHER MBEDTLS_X509_BADCERT_OTHER #define BADCERT_REVOKED MBEDTLS_X509_BADCERT_REVOKED #define BADCERT_SKIP_VERIFY MBEDTLS_X509_BADCERT_SKIP_VERIFY #define BADCRL_EXPIRED MBEDTLS_X509_BADCRL_EXPIRED #define BADCRL_FUTURE MBEDTLS_X509_BADCRL_FUTURE #define BADCRL_NOT_TRUSTED MBEDTLS_X509_BADCRL_NOT_TRUSTED #define BLOWFISH_BLOCKSIZE MBEDTLS_BLOWFISH_BLOCKSIZE #define BLOWFISH_DECRYPT MBEDTLS_BLOWFISH_DECRYPT #define BLOWFISH_ENCRYPT MBEDTLS_BLOWFISH_ENCRYPT #define BLOWFISH_MAX_KEY MBEDTLS_BLOWFISH_MAX_KEY_BITS #define BLOWFISH_MIN_KEY MBEDTLS_BLOWFISH_MIN_KEY_BITS #define BLOWFISH_ROUNDS MBEDTLS_BLOWFISH_ROUNDS #define CAMELLIA_DECRYPT MBEDTLS_CAMELLIA_DECRYPT #define CAMELLIA_ENCRYPT MBEDTLS_CAMELLIA_ENCRYPT #define COLLECT_SIZE MBEDTLS_HAVEGE_COLLECT_SIZE #define CTR_DRBG_BLOCKSIZE MBEDTLS_CTR_DRBG_BLOCKSIZE #define CTR_DRBG_ENTROPY_LEN MBEDTLS_CTR_DRBG_ENTROPY_LEN #define CTR_DRBG_KEYBITS MBEDTLS_CTR_DRBG_KEYBITS #define CTR_DRBG_KEYSIZE MBEDTLS_CTR_DRBG_KEYSIZE #define CTR_DRBG_MAX_INPUT MBEDTLS_CTR_DRBG_MAX_INPUT #define CTR_DRBG_MAX_REQUEST MBEDTLS_CTR_DRBG_MAX_REQUEST #define CTR_DRBG_MAX_SEED_INPUT MBEDTLS_CTR_DRBG_MAX_SEED_INPUT #define CTR_DRBG_PR_OFF MBEDTLS_CTR_DRBG_PR_OFF #define CTR_DRBG_PR_ON MBEDTLS_CTR_DRBG_PR_ON #define CTR_DRBG_RESEED_INTERVAL MBEDTLS_CTR_DRBG_RESEED_INTERVAL #define CTR_DRBG_SEEDLEN MBEDTLS_CTR_DRBG_SEEDLEN #define DEPRECATED MBEDTLS_DEPRECATED #define DES_DECRYPT MBEDTLS_DES_DECRYPT #define DES_ENCRYPT MBEDTLS_DES_ENCRYPT #define DES_KEY_SIZE MBEDTLS_DES_KEY_SIZE #define ENTROPY_BLOCK_SIZE MBEDTLS_ENTROPY_BLOCK_SIZE #define ENTROPY_MAX_GATHER MBEDTLS_ENTROPY_MAX_GATHER #define ENTROPY_MAX_SEED_SIZE MBEDTLS_ENTROPY_MAX_SEED_SIZE #define ENTROPY_MAX_SOURCES MBEDTLS_ENTROPY_MAX_SOURCES #define ENTROPY_MIN_HARDCLOCK MBEDTLS_ENTROPY_MIN_HARDCLOCK #define ENTROPY_MIN_HAVEGE MBEDTLS_ENTROPY_MIN_HAVEGE #define ENTROPY_MIN_PLATFORM MBEDTLS_ENTROPY_MIN_PLATFORM #define ENTROPY_SOURCE_MANUAL MBEDTLS_ENTROPY_SOURCE_MANUAL #define EXT_AUTHORITY_KEY_IDENTIFIER MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER #define EXT_BASIC_CONSTRAINTS MBEDTLS_X509_EXT_BASIC_CONSTRAINTS #define EXT_CERTIFICATE_POLICIES MBEDTLS_X509_EXT_CERTIFICATE_POLICIES #define EXT_CRL_DISTRIBUTION_POINTS MBEDTLS_X509_EXT_CRL_DISTRIBUTION_POINTS #define EXT_EXTENDED_KEY_USAGE MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE #define EXT_FRESHEST_CRL MBEDTLS_X509_EXT_FRESHEST_CRL #define EXT_INIHIBIT_ANYPOLICY MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY #define EXT_ISSUER_ALT_NAME MBEDTLS_X509_EXT_ISSUER_ALT_NAME #define EXT_KEY_USAGE MBEDTLS_X509_EXT_KEY_USAGE #define EXT_NAME_CONSTRAINTS MBEDTLS_X509_EXT_NAME_CONSTRAINTS #define EXT_NS_CERT_TYPE MBEDTLS_X509_EXT_NS_CERT_TYPE #define EXT_POLICY_CONSTRAINTS MBEDTLS_X509_EXT_POLICY_CONSTRAINTS #define EXT_POLICY_MAPPINGS MBEDTLS_X509_EXT_POLICY_MAPPINGS #define EXT_SUBJECT_ALT_NAME MBEDTLS_X509_EXT_SUBJECT_ALT_NAME #define EXT_SUBJECT_DIRECTORY_ATTRS MBEDTLS_X509_EXT_SUBJECT_DIRECTORY_ATTRS #define EXT_SUBJECT_KEY_IDENTIFIER MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER #define GCM_DECRYPT MBEDTLS_GCM_DECRYPT #define GCM_ENCRYPT MBEDTLS_GCM_ENCRYPT #define KU_CRL_SIGN MBEDTLS_X509_KU_CRL_SIGN #define KU_DATA_ENCIPHERMENT MBEDTLS_X509_KU_DATA_ENCIPHERMENT #define KU_DIGITAL_SIGNATURE MBEDTLS_X509_KU_DIGITAL_SIGNATURE #define KU_KEY_AGREEMENT MBEDTLS_X509_KU_KEY_AGREEMENT #define KU_KEY_CERT_SIGN MBEDTLS_X509_KU_KEY_CERT_SIGN #define KU_KEY_ENCIPHERMENT MBEDTLS_X509_KU_KEY_ENCIPHERMENT #define KU_NON_REPUDIATION MBEDTLS_X509_KU_NON_REPUDIATION #define LN_2_DIV_LN_10_SCALE100 MBEDTLS_LN_2_DIV_LN_10_SCALE100 #define MEMORY_VERIFY_ALLOC MBEDTLS_MEMORY_VERIFY_ALLOC #define MEMORY_VERIFY_ALWAYS MBEDTLS_MEMORY_VERIFY_ALWAYS #define MEMORY_VERIFY_FREE MBEDTLS_MEMORY_VERIFY_FREE #define MEMORY_VERIFY_NONE MBEDTLS_MEMORY_VERIFY_NONE #define MPI_CHK MBEDTLS_MPI_CHK #define NET_PROTO_TCP MBEDTLS_NET_PROTO_TCP #define NET_PROTO_UDP MBEDTLS_NET_PROTO_UDP #define NS_CERT_TYPE_EMAIL MBEDTLS_X509_NS_CERT_TYPE_EMAIL #define NS_CERT_TYPE_EMAIL_CA MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA #define NS_CERT_TYPE_OBJECT_SIGNING MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING #define NS_CERT_TYPE_OBJECT_SIGNING_CA MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA #define NS_CERT_TYPE_RESERVED MBEDTLS_X509_NS_CERT_TYPE_RESERVED #define NS_CERT_TYPE_SSL_CA MBEDTLS_X509_NS_CERT_TYPE_SSL_CA #define NS_CERT_TYPE_SSL_CLIENT MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT #define NS_CERT_TYPE_SSL_SERVER MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER #define OID_ANSI_X9_62 MBEDTLS_OID_ANSI_X9_62 #define OID_ANSI_X9_62_FIELD_TYPE MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE #define OID_ANSI_X9_62_PRIME_FIELD MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD #define OID_ANSI_X9_62_SIG MBEDTLS_OID_ANSI_X9_62_SIG #define OID_ANSI_X9_62_SIG_SHA2 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 #define OID_ANY_EXTENDED_KEY_USAGE MBEDTLS_OID_ANY_EXTENDED_KEY_USAGE #define OID_AT MBEDTLS_OID_AT #define OID_AT_CN MBEDTLS_OID_AT_CN #define OID_AT_COUNTRY MBEDTLS_OID_AT_COUNTRY #define OID_AT_DN_QUALIFIER MBEDTLS_OID_AT_DN_QUALIFIER #define OID_AT_GENERATION_QUALIFIER MBEDTLS_OID_AT_GENERATION_QUALIFIER #define OID_AT_GIVEN_NAME MBEDTLS_OID_AT_GIVEN_NAME #define OID_AT_INITIALS MBEDTLS_OID_AT_INITIALS #define OID_AT_LOCALITY MBEDTLS_OID_AT_LOCALITY #define OID_AT_ORGANIZATION MBEDTLS_OID_AT_ORGANIZATION #define OID_AT_ORG_UNIT MBEDTLS_OID_AT_ORG_UNIT #define OID_AT_POSTAL_ADDRESS MBEDTLS_OID_AT_POSTAL_ADDRESS #define OID_AT_POSTAL_CODE MBEDTLS_OID_AT_POSTAL_CODE #define OID_AT_PSEUDONYM MBEDTLS_OID_AT_PSEUDONYM #define OID_AT_SERIAL_NUMBER MBEDTLS_OID_AT_SERIAL_NUMBER #define OID_AT_STATE MBEDTLS_OID_AT_STATE #define OID_AT_SUR_NAME MBEDTLS_OID_AT_SUR_NAME #define OID_AT_TITLE MBEDTLS_OID_AT_TITLE #define OID_AT_UNIQUE_IDENTIFIER MBEDTLS_OID_AT_UNIQUE_IDENTIFIER #define OID_AUTHORITY_KEY_IDENTIFIER MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER #define OID_BASIC_CONSTRAINTS MBEDTLS_OID_BASIC_CONSTRAINTS #define OID_CERTICOM MBEDTLS_OID_CERTICOM #define OID_CERTIFICATE_POLICIES MBEDTLS_OID_CERTIFICATE_POLICIES #define OID_CLIENT_AUTH MBEDTLS_OID_CLIENT_AUTH #define OID_CMP MBEDTLS_OID_CMP #define OID_CODE_SIGNING MBEDTLS_OID_CODE_SIGNING #define OID_COUNTRY_US MBEDTLS_OID_COUNTRY_US #define OID_CRL_DISTRIBUTION_POINTS MBEDTLS_OID_CRL_DISTRIBUTION_POINTS #define OID_CRL_NUMBER MBEDTLS_OID_CRL_NUMBER #define OID_DES_CBC MBEDTLS_OID_DES_CBC #define OID_DES_EDE3_CBC MBEDTLS_OID_DES_EDE3_CBC #define OID_DIGEST_ALG_MD2 MBEDTLS_OID_DIGEST_ALG_MD2 #define OID_DIGEST_ALG_MD4 MBEDTLS_OID_DIGEST_ALG_MD4 #define OID_DIGEST_ALG_MD5 MBEDTLS_OID_DIGEST_ALG_MD5 #define OID_DIGEST_ALG_SHA1 MBEDTLS_OID_DIGEST_ALG_SHA1 #define OID_DIGEST_ALG_SHA224 MBEDTLS_OID_DIGEST_ALG_SHA224 #define OID_DIGEST_ALG_SHA256 MBEDTLS_OID_DIGEST_ALG_SHA256 #define OID_DIGEST_ALG_SHA384 MBEDTLS_OID_DIGEST_ALG_SHA384 #define OID_DIGEST_ALG_SHA512 MBEDTLS_OID_DIGEST_ALG_SHA512 #define OID_DOMAIN_COMPONENT MBEDTLS_OID_DOMAIN_COMPONENT #define OID_ECDSA_SHA1 MBEDTLS_OID_ECDSA_SHA1 #define OID_ECDSA_SHA224 MBEDTLS_OID_ECDSA_SHA224 #define OID_ECDSA_SHA256 MBEDTLS_OID_ECDSA_SHA256 #define OID_ECDSA_SHA384 MBEDTLS_OID_ECDSA_SHA384 #define OID_ECDSA_SHA512 MBEDTLS_OID_ECDSA_SHA512 #define OID_EC_ALG_ECDH MBEDTLS_OID_EC_ALG_ECDH #define OID_EC_ALG_UNRESTRICTED MBEDTLS_OID_EC_ALG_UNRESTRICTED #define OID_EC_BRAINPOOL_V1 MBEDTLS_OID_EC_BRAINPOOL_V1 #define OID_EC_GRP_BP256R1 MBEDTLS_OID_EC_GRP_BP256R1 #define OID_EC_GRP_BP384R1 MBEDTLS_OID_EC_GRP_BP384R1 #define OID_EC_GRP_BP512R1 MBEDTLS_OID_EC_GRP_BP512R1 #define OID_EC_GRP_SECP192K1 MBEDTLS_OID_EC_GRP_SECP192K1 #define OID_EC_GRP_SECP192R1 MBEDTLS_OID_EC_GRP_SECP192R1 #define OID_EC_GRP_SECP224K1 MBEDTLS_OID_EC_GRP_SECP224K1 #define OID_EC_GRP_SECP224R1 MBEDTLS_OID_EC_GRP_SECP224R1 #define OID_EC_GRP_SECP256K1 MBEDTLS_OID_EC_GRP_SECP256K1 #define OID_EC_GRP_SECP256R1 MBEDTLS_OID_EC_GRP_SECP256R1 #define OID_EC_GRP_SECP384R1 MBEDTLS_OID_EC_GRP_SECP384R1 #define OID_EC_GRP_SECP521R1 MBEDTLS_OID_EC_GRP_SECP521R1 #define OID_EMAIL_PROTECTION MBEDTLS_OID_EMAIL_PROTECTION #define OID_EXTENDED_KEY_USAGE MBEDTLS_OID_EXTENDED_KEY_USAGE #define OID_FRESHEST_CRL MBEDTLS_OID_FRESHEST_CRL #define OID_GOV MBEDTLS_OID_GOV #define OID_HMAC_SHA1 MBEDTLS_OID_HMAC_SHA1 #define OID_ID_CE MBEDTLS_OID_ID_CE #define OID_INIHIBIT_ANYPOLICY MBEDTLS_OID_INIHIBIT_ANYPOLICY #define OID_ISO_CCITT_DS MBEDTLS_OID_ISO_CCITT_DS #define OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ISO_IDENTIFIED_ORG #define OID_ISO_ITU_COUNTRY MBEDTLS_OID_ISO_ITU_COUNTRY #define OID_ISO_ITU_US_ORG MBEDTLS_OID_ISO_ITU_US_ORG #define OID_ISO_MEMBER_BODIES MBEDTLS_OID_ISO_MEMBER_BODIES #define OID_ISSUER_ALT_NAME MBEDTLS_OID_ISSUER_ALT_NAME #define OID_KEY_USAGE MBEDTLS_OID_KEY_USAGE #define OID_KP MBEDTLS_OID_KP #define OID_MGF1 MBEDTLS_OID_MGF1 #define OID_NAME_CONSTRAINTS MBEDTLS_OID_NAME_CONSTRAINTS #define OID_NETSCAPE MBEDTLS_OID_NETSCAPE #define OID_NS_BASE_URL MBEDTLS_OID_NS_BASE_URL #define OID_NS_CA_POLICY_URL MBEDTLS_OID_NS_CA_POLICY_URL #define OID_NS_CA_REVOCATION_URL MBEDTLS_OID_NS_CA_REVOCATION_URL #define OID_NS_CERT MBEDTLS_OID_NS_CERT #define OID_NS_CERT_SEQUENCE MBEDTLS_OID_NS_CERT_SEQUENCE #define OID_NS_CERT_TYPE MBEDTLS_OID_NS_CERT_TYPE #define OID_NS_COMMENT MBEDTLS_OID_NS_COMMENT #define OID_NS_DATA_TYPE MBEDTLS_OID_NS_DATA_TYPE #define OID_NS_RENEWAL_URL MBEDTLS_OID_NS_RENEWAL_URL #define OID_NS_REVOCATION_URL MBEDTLS_OID_NS_REVOCATION_URL #define OID_NS_SSL_SERVER_NAME MBEDTLS_OID_NS_SSL_SERVER_NAME #define OID_OCSP_SIGNING MBEDTLS_OID_OCSP_SIGNING #define OID_OIW_SECSIG MBEDTLS_OID_OIW_SECSIG #define OID_OIW_SECSIG_ALG MBEDTLS_OID_OIW_SECSIG_ALG #define OID_OIW_SECSIG_SHA1 MBEDTLS_OID_OIW_SECSIG_SHA1 #define OID_ORGANIZATION MBEDTLS_OID_ORGANIZATION #define OID_ORG_ANSI_X9_62 MBEDTLS_OID_ORG_ANSI_X9_62 #define OID_ORG_CERTICOM MBEDTLS_OID_ORG_CERTICOM #define OID_ORG_DOD MBEDTLS_OID_ORG_DOD #define OID_ORG_GOV MBEDTLS_OID_ORG_GOV #define OID_ORG_NETSCAPE MBEDTLS_OID_ORG_NETSCAPE #define OID_ORG_OIW MBEDTLS_OID_ORG_OIW #define OID_ORG_RSA_DATA_SECURITY MBEDTLS_OID_ORG_RSA_DATA_SECURITY #define OID_ORG_TELETRUST MBEDTLS_OID_ORG_TELETRUST #define OID_PKCS MBEDTLS_OID_PKCS #define OID_PKCS1 MBEDTLS_OID_PKCS1 #define OID_PKCS12 MBEDTLS_OID_PKCS12 #define OID_PKCS12_PBE MBEDTLS_OID_PKCS12_PBE #define OID_PKCS12_PBE_SHA1_DES2_EDE_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC #define OID_PKCS12_PBE_SHA1_DES3_EDE_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC #define OID_PKCS12_PBE_SHA1_RC2_128_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_128_CBC #define OID_PKCS12_PBE_SHA1_RC2_40_CBC MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_40_CBC #define OID_PKCS12_PBE_SHA1_RC4_128 MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_128 #define OID_PKCS12_PBE_SHA1_RC4_40 MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_40 #define OID_PKCS1_MD2 MBEDTLS_OID_PKCS1_MD2 #define OID_PKCS1_MD4 MBEDTLS_OID_PKCS1_MD4 #define OID_PKCS1_MD5 MBEDTLS_OID_PKCS1_MD5 #define OID_PKCS1_RSA MBEDTLS_OID_PKCS1_RSA #define OID_PKCS1_SHA1 MBEDTLS_OID_PKCS1_SHA1 #define OID_PKCS1_SHA224 MBEDTLS_OID_PKCS1_SHA224 #define OID_PKCS1_SHA256 MBEDTLS_OID_PKCS1_SHA256 #define OID_PKCS1_SHA384 MBEDTLS_OID_PKCS1_SHA384 #define OID_PKCS1_SHA512 MBEDTLS_OID_PKCS1_SHA512 #define OID_PKCS5 MBEDTLS_OID_PKCS5 #define OID_PKCS5_PBES2 MBEDTLS_OID_PKCS5_PBES2 #define OID_PKCS5_PBE_MD2_DES_CBC MBEDTLS_OID_PKCS5_PBE_MD2_DES_CBC #define OID_PKCS5_PBE_MD2_RC2_CBC MBEDTLS_OID_PKCS5_PBE_MD2_RC2_CBC #define OID_PKCS5_PBE_MD5_DES_CBC MBEDTLS_OID_PKCS5_PBE_MD5_DES_CBC #define OID_PKCS5_PBE_MD5_RC2_CBC MBEDTLS_OID_PKCS5_PBE_MD5_RC2_CBC #define OID_PKCS5_PBE_SHA1_DES_CBC MBEDTLS_OID_PKCS5_PBE_SHA1_DES_CBC #define OID_PKCS5_PBE_SHA1_RC2_CBC MBEDTLS_OID_PKCS5_PBE_SHA1_RC2_CBC #define OID_PKCS5_PBKDF2 MBEDTLS_OID_PKCS5_PBKDF2 #define OID_PKCS5_PBMAC1 MBEDTLS_OID_PKCS5_PBMAC1 #define OID_PKCS9 MBEDTLS_OID_PKCS9 #define OID_PKCS9_CSR_EXT_REQ MBEDTLS_OID_PKCS9_CSR_EXT_REQ #define OID_PKCS9_EMAIL MBEDTLS_OID_PKCS9_EMAIL #define OID_PKIX MBEDTLS_OID_PKIX #define OID_POLICY_CONSTRAINTS MBEDTLS_OID_POLICY_CONSTRAINTS #define OID_POLICY_MAPPINGS MBEDTLS_OID_POLICY_MAPPINGS #define OID_PRIVATE_KEY_USAGE_PERIOD MBEDTLS_OID_PRIVATE_KEY_USAGE_PERIOD #define OID_RSASSA_PSS MBEDTLS_OID_RSASSA_PSS #define OID_RSA_COMPANY MBEDTLS_OID_RSA_COMPANY #define OID_RSA_SHA_OBS MBEDTLS_OID_RSA_SHA_OBS #define OID_SERVER_AUTH MBEDTLS_OID_SERVER_AUTH #define OID_SIZE MBEDTLS_OID_SIZE #define OID_SUBJECT_ALT_NAME MBEDTLS_OID_SUBJECT_ALT_NAME #define OID_SUBJECT_DIRECTORY_ATTRS MBEDTLS_OID_SUBJECT_DIRECTORY_ATTRS #define OID_SUBJECT_KEY_IDENTIFIER MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER #define OID_TELETRUST MBEDTLS_OID_TELETRUST #define OID_TIME_STAMPING MBEDTLS_OID_TIME_STAMPING #define PADLOCK_ACE MBEDTLS_PADLOCK_ACE #define PADLOCK_ALIGN16 MBEDTLS_PADLOCK_ALIGN16 #define PADLOCK_PHE MBEDTLS_PADLOCK_PHE #define PADLOCK_PMM MBEDTLS_PADLOCK_PMM #define PADLOCK_RNG MBEDTLS_PADLOCK_RNG #define PKCS12_DERIVE_IV MBEDTLS_PKCS12_DERIVE_IV #define PKCS12_DERIVE_KEY MBEDTLS_PKCS12_DERIVE_KEY #define PKCS12_DERIVE_MAC_KEY MBEDTLS_PKCS12_DERIVE_MAC_KEY #define PKCS12_PBE_DECRYPT MBEDTLS_PKCS12_PBE_DECRYPT #define PKCS12_PBE_ENCRYPT MBEDTLS_PKCS12_PBE_ENCRYPT #define PKCS5_DECRYPT MBEDTLS_PKCS5_DECRYPT #define PKCS5_ENCRYPT MBEDTLS_PKCS5_ENCRYPT #define POLARSSL_AESNI_AES MBEDTLS_AESNI_AES #define POLARSSL_AESNI_CLMUL MBEDTLS_AESNI_CLMUL #define POLARSSL_AESNI_H MBEDTLS_AESNI_H #define POLARSSL_AES_H MBEDTLS_AES_H #define POLARSSL_ARC4_H MBEDTLS_ARC4_H #define POLARSSL_ASN1_H MBEDTLS_ASN1_H #define POLARSSL_ASN1_WRITE_H MBEDTLS_ASN1_WRITE_H #define POLARSSL_BASE64_H MBEDTLS_BASE64_H #define POLARSSL_BIGNUM_H MBEDTLS_BIGNUM_H #define POLARSSL_BLOWFISH_H MBEDTLS_BLOWFISH_H #define POLARSSL_BN_MUL_H MBEDTLS_BN_MUL_H #define POLARSSL_CAMELLIA_H MBEDTLS_CAMELLIA_H #define POLARSSL_CCM_H MBEDTLS_CCM_H #define POLARSSL_CERTS_H MBEDTLS_CERTS_H #define POLARSSL_CHECK_CONFIG_H MBEDTLS_CHECK_CONFIG_H #define POLARSSL_CIPHERSUITE_NODTLS MBEDTLS_CIPHERSUITE_NODTLS #define POLARSSL_CIPHERSUITE_SHORT_TAG MBEDTLS_CIPHERSUITE_SHORT_TAG #define POLARSSL_CIPHERSUITE_WEAK MBEDTLS_CIPHERSUITE_WEAK #define POLARSSL_CIPHER_AES_128_CBC MBEDTLS_CIPHER_AES_128_CBC #define POLARSSL_CIPHER_AES_128_CCM MBEDTLS_CIPHER_AES_128_CCM #define POLARSSL_CIPHER_AES_128_CFB128 MBEDTLS_CIPHER_AES_128_CFB128 #define POLARSSL_CIPHER_AES_128_CTR MBEDTLS_CIPHER_AES_128_CTR #define POLARSSL_CIPHER_AES_128_ECB MBEDTLS_CIPHER_AES_128_ECB #define POLARSSL_CIPHER_AES_128_GCM MBEDTLS_CIPHER_AES_128_GCM #define POLARSSL_CIPHER_AES_192_CBC MBEDTLS_CIPHER_AES_192_CBC #define POLARSSL_CIPHER_AES_192_CCM MBEDTLS_CIPHER_AES_192_CCM #define POLARSSL_CIPHER_AES_192_CFB128 MBEDTLS_CIPHER_AES_192_CFB128 #define POLARSSL_CIPHER_AES_192_CTR MBEDTLS_CIPHER_AES_192_CTR #define POLARSSL_CIPHER_AES_192_ECB MBEDTLS_CIPHER_AES_192_ECB #define POLARSSL_CIPHER_AES_192_GCM MBEDTLS_CIPHER_AES_192_GCM #define POLARSSL_CIPHER_AES_256_CBC MBEDTLS_CIPHER_AES_256_CBC #define POLARSSL_CIPHER_AES_256_CCM MBEDTLS_CIPHER_AES_256_CCM #define POLARSSL_CIPHER_AES_256_CFB128 MBEDTLS_CIPHER_AES_256_CFB128 #define POLARSSL_CIPHER_AES_256_CTR MBEDTLS_CIPHER_AES_256_CTR #define POLARSSL_CIPHER_AES_256_ECB MBEDTLS_CIPHER_AES_256_ECB #define POLARSSL_CIPHER_AES_256_GCM MBEDTLS_CIPHER_AES_256_GCM #define POLARSSL_CIPHER_ARC4_128 MBEDTLS_CIPHER_ARC4_128 #define POLARSSL_CIPHER_BLOWFISH_CBC MBEDTLS_CIPHER_BLOWFISH_CBC #define POLARSSL_CIPHER_BLOWFISH_CFB64 MBEDTLS_CIPHER_BLOWFISH_CFB64 #define POLARSSL_CIPHER_BLOWFISH_CTR MBEDTLS_CIPHER_BLOWFISH_CTR #define POLARSSL_CIPHER_BLOWFISH_ECB MBEDTLS_CIPHER_BLOWFISH_ECB #define POLARSSL_CIPHER_CAMELLIA_128_CBC MBEDTLS_CIPHER_CAMELLIA_128_CBC #define POLARSSL_CIPHER_CAMELLIA_128_CCM MBEDTLS_CIPHER_CAMELLIA_128_CCM #define POLARSSL_CIPHER_CAMELLIA_128_CFB128 MBEDTLS_CIPHER_CAMELLIA_128_CFB128 #define POLARSSL_CIPHER_CAMELLIA_128_CTR MBEDTLS_CIPHER_CAMELLIA_128_CTR #define POLARSSL_CIPHER_CAMELLIA_128_ECB MBEDTLS_CIPHER_CAMELLIA_128_ECB #define POLARSSL_CIPHER_CAMELLIA_128_GCM MBEDTLS_CIPHER_CAMELLIA_128_GCM #define POLARSSL_CIPHER_CAMELLIA_192_CBC MBEDTLS_CIPHER_CAMELLIA_192_CBC #define POLARSSL_CIPHER_CAMELLIA_192_CCM MBEDTLS_CIPHER_CAMELLIA_192_CCM #define POLARSSL_CIPHER_CAMELLIA_192_CFB128 MBEDTLS_CIPHER_CAMELLIA_192_CFB128 #define POLARSSL_CIPHER_CAMELLIA_192_CTR MBEDTLS_CIPHER_CAMELLIA_192_CTR #define POLARSSL_CIPHER_CAMELLIA_192_ECB MBEDTLS_CIPHER_CAMELLIA_192_ECB #define POLARSSL_CIPHER_CAMELLIA_192_GCM MBEDTLS_CIPHER_CAMELLIA_192_GCM #define POLARSSL_CIPHER_CAMELLIA_256_CBC MBEDTLS_CIPHER_CAMELLIA_256_CBC #define POLARSSL_CIPHER_CAMELLIA_256_CCM MBEDTLS_CIPHER_CAMELLIA_256_CCM #define POLARSSL_CIPHER_CAMELLIA_256_CFB128 MBEDTLS_CIPHER_CAMELLIA_256_CFB128 #define POLARSSL_CIPHER_CAMELLIA_256_CTR MBEDTLS_CIPHER_CAMELLIA_256_CTR #define POLARSSL_CIPHER_CAMELLIA_256_ECB MBEDTLS_CIPHER_CAMELLIA_256_ECB #define POLARSSL_CIPHER_CAMELLIA_256_GCM MBEDTLS_CIPHER_CAMELLIA_256_GCM #define POLARSSL_CIPHER_DES_CBC MBEDTLS_CIPHER_DES_CBC #define POLARSSL_CIPHER_DES_ECB MBEDTLS_CIPHER_DES_ECB #define POLARSSL_CIPHER_DES_EDE3_CBC MBEDTLS_CIPHER_DES_EDE3_CBC #define POLARSSL_CIPHER_DES_EDE3_ECB MBEDTLS_CIPHER_DES_EDE3_ECB #define POLARSSL_CIPHER_DES_EDE_CBC MBEDTLS_CIPHER_DES_EDE_CBC #define POLARSSL_CIPHER_DES_EDE_ECB MBEDTLS_CIPHER_DES_EDE_ECB #define POLARSSL_CIPHER_H MBEDTLS_CIPHER_H #define POLARSSL_CIPHER_ID_3DES MBEDTLS_CIPHER_ID_3DES #define POLARSSL_CIPHER_ID_AES MBEDTLS_CIPHER_ID_AES #define POLARSSL_CIPHER_ID_ARC4 MBEDTLS_CIPHER_ID_ARC4 #define POLARSSL_CIPHER_ID_BLOWFISH MBEDTLS_CIPHER_ID_BLOWFISH #define POLARSSL_CIPHER_ID_CAMELLIA MBEDTLS_CIPHER_ID_CAMELLIA #define POLARSSL_CIPHER_ID_DES MBEDTLS_CIPHER_ID_DES #define POLARSSL_CIPHER_ID_NONE MBEDTLS_CIPHER_ID_NONE #define POLARSSL_CIPHER_ID_NULL MBEDTLS_CIPHER_ID_NULL #define POLARSSL_CIPHER_MODE_AEAD MBEDTLS_CIPHER_MODE_AEAD #define POLARSSL_CIPHER_MODE_STREAM MBEDTLS_CIPHER_MODE_STREAM #define POLARSSL_CIPHER_MODE_WITH_PADDING MBEDTLS_CIPHER_MODE_WITH_PADDING #define POLARSSL_CIPHER_NONE MBEDTLS_CIPHER_NONE #define POLARSSL_CIPHER_NULL MBEDTLS_CIPHER_NULL #define POLARSSL_CIPHER_VARIABLE_IV_LEN MBEDTLS_CIPHER_VARIABLE_IV_LEN #define POLARSSL_CIPHER_VARIABLE_KEY_LEN MBEDTLS_CIPHER_VARIABLE_KEY_LEN #define POLARSSL_CIPHER_WRAP_H MBEDTLS_CIPHER_WRAP_H #define POLARSSL_CONFIG_H MBEDTLS_CONFIG_H #define POLARSSL_CTR_DRBG_H MBEDTLS_CTR_DRBG_H #define POLARSSL_DEBUG_H MBEDTLS_DEBUG_H #define POLARSSL_DECRYPT MBEDTLS_DECRYPT #define POLARSSL_DES_H MBEDTLS_DES_H #define POLARSSL_DHM_H MBEDTLS_DHM_H #define POLARSSL_DHM_RFC3526_MODP_2048_G MBEDTLS_DHM_RFC3526_MODP_2048_G #define POLARSSL_DHM_RFC3526_MODP_2048_P MBEDTLS_DHM_RFC3526_MODP_2048_P #define POLARSSL_DHM_RFC3526_MODP_3072_G MBEDTLS_DHM_RFC3526_MODP_3072_G #define POLARSSL_DHM_RFC3526_MODP_3072_P MBEDTLS_DHM_RFC3526_MODP_3072_P #define POLARSSL_DHM_RFC5114_MODP_2048_G MBEDTLS_DHM_RFC5114_MODP_2048_G #define POLARSSL_DHM_RFC5114_MODP_2048_P MBEDTLS_DHM_RFC5114_MODP_2048_P #define POLARSSL_ECDH_H MBEDTLS_ECDH_H #define POLARSSL_ECDH_OURS MBEDTLS_ECDH_OURS #define POLARSSL_ECDH_THEIRS MBEDTLS_ECDH_THEIRS #define POLARSSL_ECDSA_H MBEDTLS_ECDSA_H #define POLARSSL_ECP_DP_BP256R1 MBEDTLS_ECP_DP_BP256R1 #define POLARSSL_ECP_DP_BP384R1 MBEDTLS_ECP_DP_BP384R1 #define POLARSSL_ECP_DP_BP512R1 MBEDTLS_ECP_DP_BP512R1 #define POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_CURVE25519 #define POLARSSL_ECP_DP_MAX MBEDTLS_ECP_DP_MAX #define POLARSSL_ECP_DP_NONE MBEDTLS_ECP_DP_NONE #define POLARSSL_ECP_DP_SECP192K1 MBEDTLS_ECP_DP_SECP192K1 #define POLARSSL_ECP_DP_SECP192R1 MBEDTLS_ECP_DP_SECP192R1 #define POLARSSL_ECP_DP_SECP224K1 MBEDTLS_ECP_DP_SECP224K1 #define POLARSSL_ECP_DP_SECP224R1 MBEDTLS_ECP_DP_SECP224R1 #define POLARSSL_ECP_DP_SECP256K1 MBEDTLS_ECP_DP_SECP256K1 #define POLARSSL_ECP_DP_SECP256R1 MBEDTLS_ECP_DP_SECP256R1 #define POLARSSL_ECP_DP_SECP384R1 MBEDTLS_ECP_DP_SECP384R1 #define POLARSSL_ECP_DP_SECP521R1 MBEDTLS_ECP_DP_SECP521R1 #define POLARSSL_ECP_H MBEDTLS_ECP_H #define POLARSSL_ECP_MAX_BYTES MBEDTLS_ECP_MAX_BYTES #define POLARSSL_ECP_MAX_PT_LEN MBEDTLS_ECP_MAX_PT_LEN #define POLARSSL_ECP_PF_COMPRESSED MBEDTLS_ECP_PF_COMPRESSED #define POLARSSL_ECP_PF_UNCOMPRESSED MBEDTLS_ECP_PF_UNCOMPRESSED #define POLARSSL_ECP_TLS_NAMED_CURVE MBEDTLS_ECP_TLS_NAMED_CURVE #define POLARSSL_ENCRYPT MBEDTLS_ENCRYPT #define POLARSSL_ENTROPY_H MBEDTLS_ENTROPY_H #define POLARSSL_ENTROPY_POLL_H MBEDTLS_ENTROPY_POLL_H #define POLARSSL_ENTROPY_SHA256_ACCUMULATOR MBEDTLS_ENTROPY_SHA256_ACCUMULATOR #define POLARSSL_ENTROPY_SHA512_ACCUMULATOR MBEDTLS_ENTROPY_SHA512_ACCUMULATOR #define POLARSSL_ERROR_H MBEDTLS_ERROR_H #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH MBEDTLS_ERR_AES_INVALID_KEY_LENGTH #define POLARSSL_ERR_ASN1_BUF_TOO_SMALL MBEDTLS_ERR_ASN1_BUF_TOO_SMALL #define POLARSSL_ERR_ASN1_INVALID_DATA MBEDTLS_ERR_ASN1_INVALID_DATA #define POLARSSL_ERR_ASN1_INVALID_LENGTH MBEDTLS_ERR_ASN1_INVALID_LENGTH #define POLARSSL_ERR_ASN1_LENGTH_MISMATCH MBEDTLS_ERR_ASN1_LENGTH_MISMATCH #define POLARSSL_ERR_ASN1_MALLOC_FAILED MBEDTLS_ERR_ASN1_ALLOC_FAILED #define POLARSSL_ERR_ASN1_OUT_OF_DATA MBEDTLS_ERR_ASN1_OUT_OF_DATA #define POLARSSL_ERR_ASN1_UNEXPECTED_TAG MBEDTLS_ERR_ASN1_UNEXPECTED_TAG #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL #define POLARSSL_ERR_BASE64_INVALID_CHARACTER MBEDTLS_ERR_BASE64_INVALID_CHARACTER #define POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH #define POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH #define POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH #define POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH #define POLARSSL_ERR_CCM_AUTH_FAILED MBEDTLS_ERR_CCM_AUTH_FAILED #define POLARSSL_ERR_CCM_BAD_INPUT MBEDTLS_ERR_CCM_BAD_INPUT #define POLARSSL_ERR_CIPHER_ALLOC_FAILED MBEDTLS_ERR_CIPHER_ALLOC_FAILED #define POLARSSL_ERR_CIPHER_AUTH_FAILED MBEDTLS_ERR_CIPHER_AUTH_FAILED #define POLARSSL_ERR_CIPHER_BAD_INPUT_DATA MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA #define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE #define POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED #define POLARSSL_ERR_CIPHER_INVALID_PADDING MBEDTLS_ERR_CIPHER_INVALID_PADDING #define POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED #define POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR #define POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG #define POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG #define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH #define POLARSSL_ERR_DHM_BAD_INPUT_DATA MBEDTLS_ERR_DHM_BAD_INPUT_DATA #define POLARSSL_ERR_DHM_CALC_SECRET_FAILED MBEDTLS_ERR_DHM_CALC_SECRET_FAILED #define POLARSSL_ERR_DHM_FILE_IO_ERROR MBEDTLS_ERR_DHM_FILE_IO_ERROR #define POLARSSL_ERR_DHM_INVALID_FORMAT MBEDTLS_ERR_DHM_INVALID_FORMAT #define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED #define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED #define POLARSSL_ERR_DHM_MALLOC_FAILED MBEDTLS_ERR_DHM_ALLOC_FAILED #define POLARSSL_ERR_DHM_READ_PARAMS_FAILED MBEDTLS_ERR_DHM_READ_PARAMS_FAILED #define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED #define POLARSSL_ERR_ECP_BAD_INPUT_DATA MBEDTLS_ERR_ECP_BAD_INPUT_DATA #define POLARSSL_ERR_ECP_BUFFER_TOO_SMALL MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL #define POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE #define POLARSSL_ERR_ECP_INVALID_KEY MBEDTLS_ERR_ECP_INVALID_KEY #define POLARSSL_ERR_ECP_MALLOC_FAILED MBEDTLS_ERR_ECP_ALLOC_FAILED #define POLARSSL_ERR_ECP_RANDOM_FAILED MBEDTLS_ERR_ECP_RANDOM_FAILED #define POLARSSL_ERR_ECP_SIG_LEN_MISMATCH MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH #define POLARSSL_ERR_ECP_VERIFY_FAILED MBEDTLS_ERR_ECP_VERIFY_FAILED #define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR #define POLARSSL_ERR_ENTROPY_MAX_SOURCES MBEDTLS_ERR_ENTROPY_MAX_SOURCES #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_ENTROPY_SOURCE_FAILED #define POLARSSL_ERR_GCM_AUTH_FAILED MBEDTLS_ERR_GCM_AUTH_FAILED #define POLARSSL_ERR_GCM_BAD_INPUT MBEDTLS_ERR_GCM_BAD_INPUT #define POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED #define POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR #define POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG #define POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG #define POLARSSL_ERR_MD_ALLOC_FAILED MBEDTLS_ERR_MD_ALLOC_FAILED #define POLARSSL_ERR_MD_BAD_INPUT_DATA MBEDTLS_ERR_MD_BAD_INPUT_DATA #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE #define POLARSSL_ERR_MD_FILE_IO_ERROR MBEDTLS_ERR_MD_FILE_IO_ERROR #define POLARSSL_ERR_MPI_BAD_INPUT_DATA MBEDTLS_ERR_MPI_BAD_INPUT_DATA #define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL #define POLARSSL_ERR_MPI_DIVISION_BY_ZERO MBEDTLS_ERR_MPI_DIVISION_BY_ZERO #define POLARSSL_ERR_MPI_FILE_IO_ERROR MBEDTLS_ERR_MPI_FILE_IO_ERROR #define POLARSSL_ERR_MPI_INVALID_CHARACTER MBEDTLS_ERR_MPI_INVALID_CHARACTER #define POLARSSL_ERR_MPI_MALLOC_FAILED MBEDTLS_ERR_MPI_ALLOC_FAILED #define POLARSSL_ERR_MPI_NEGATIVE_VALUE MBEDTLS_ERR_MPI_NEGATIVE_VALUE #define POLARSSL_ERR_MPI_NOT_ACCEPTABLE MBEDTLS_ERR_MPI_NOT_ACCEPTABLE #define POLARSSL_ERR_NET_ACCEPT_FAILED MBEDTLS_ERR_NET_ACCEPT_FAILED #define POLARSSL_ERR_NET_BIND_FAILED MBEDTLS_ERR_NET_BIND_FAILED #define POLARSSL_ERR_NET_CONNECT_FAILED MBEDTLS_ERR_NET_CONNECT_FAILED #define POLARSSL_ERR_NET_CONN_RESET MBEDTLS_ERR_NET_CONN_RESET #define POLARSSL_ERR_NET_LISTEN_FAILED MBEDTLS_ERR_NET_LISTEN_FAILED #define POLARSSL_ERR_NET_RECV_FAILED MBEDTLS_ERR_NET_RECV_FAILED #define POLARSSL_ERR_NET_SEND_FAILED MBEDTLS_ERR_NET_SEND_FAILED #define POLARSSL_ERR_NET_SOCKET_FAILED MBEDTLS_ERR_NET_SOCKET_FAILED #define POLARSSL_ERR_NET_TIMEOUT MBEDTLS_ERR_SSL_TIMEOUT #define POLARSSL_ERR_NET_UNKNOWN_HOST MBEDTLS_ERR_NET_UNKNOWN_HOST #define POLARSSL_ERR_NET_WANT_READ MBEDTLS_ERR_SSL_WANT_READ #define POLARSSL_ERR_NET_WANT_WRITE MBEDTLS_ERR_SSL_WANT_WRITE #define POLARSSL_ERR_OID_BUF_TOO_SMALL MBEDTLS_ERR_OID_BUF_TOO_SMALL #define POLARSSL_ERR_OID_NOT_FOUND MBEDTLS_ERR_OID_NOT_FOUND #define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED #define POLARSSL_ERR_PEM_BAD_INPUT_DATA MBEDTLS_ERR_PEM_BAD_INPUT_DATA #define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE #define POLARSSL_ERR_PEM_INVALID_DATA MBEDTLS_ERR_PEM_INVALID_DATA #define POLARSSL_ERR_PEM_INVALID_ENC_IV MBEDTLS_ERR_PEM_INVALID_ENC_IV #define POLARSSL_ERR_PEM_MALLOC_FAILED MBEDTLS_ERR_PEM_ALLOC_FAILED #define POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT #define POLARSSL_ERR_PEM_PASSWORD_MISMATCH MBEDTLS_ERR_PEM_PASSWORD_MISMATCH #define POLARSSL_ERR_PEM_PASSWORD_REQUIRED MBEDTLS_ERR_PEM_PASSWORD_REQUIRED #define POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG #define POLARSSL_ERR_PKCS12_BAD_INPUT_DATA MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA #define POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE #define POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH #define POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT #define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA #define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE #define POLARSSL_ERR_PKCS5_INVALID_FORMAT MBEDTLS_ERR_PKCS5_INVALID_FORMAT #define POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH #define POLARSSL_ERR_PK_BAD_INPUT_DATA MBEDTLS_ERR_PK_BAD_INPUT_DATA #define POLARSSL_ERR_PK_FEATURE_UNAVAILABLE MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE #define POLARSSL_ERR_PK_FILE_IO_ERROR MBEDTLS_ERR_PK_FILE_IO_ERROR #define POLARSSL_ERR_PK_INVALID_ALG MBEDTLS_ERR_PK_INVALID_ALG #define POLARSSL_ERR_PK_INVALID_PUBKEY MBEDTLS_ERR_PK_INVALID_PUBKEY #define POLARSSL_ERR_PK_KEY_INVALID_FORMAT MBEDTLS_ERR_PK_KEY_INVALID_FORMAT #define POLARSSL_ERR_PK_KEY_INVALID_VERSION MBEDTLS_ERR_PK_KEY_INVALID_VERSION #define POLARSSL_ERR_PK_MALLOC_FAILED MBEDTLS_ERR_PK_ALLOC_FAILED #define POLARSSL_ERR_PK_PASSWORD_MISMATCH MBEDTLS_ERR_PK_PASSWORD_MISMATCH #define POLARSSL_ERR_PK_PASSWORD_REQUIRED MBEDTLS_ERR_PK_PASSWORD_REQUIRED #define POLARSSL_ERR_PK_SIG_LEN_MISMATCH MBEDTLS_ERR_PK_SIG_LEN_MISMATCH #define POLARSSL_ERR_PK_TYPE_MISMATCH MBEDTLS_ERR_PK_TYPE_MISMATCH #define POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE #define POLARSSL_ERR_PK_UNKNOWN_PK_ALG MBEDTLS_ERR_PK_UNKNOWN_PK_ALG #define POLARSSL_ERR_RSA_BAD_INPUT_DATA MBEDTLS_ERR_RSA_BAD_INPUT_DATA #define POLARSSL_ERR_RSA_INVALID_PADDING MBEDTLS_ERR_RSA_INVALID_PADDING #define POLARSSL_ERR_RSA_KEY_CHECK_FAILED MBEDTLS_ERR_RSA_KEY_CHECK_FAILED #define POLARSSL_ERR_RSA_KEY_GEN_FAILED MBEDTLS_ERR_RSA_KEY_GEN_FAILED #define POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE #define POLARSSL_ERR_RSA_PRIVATE_FAILED MBEDTLS_ERR_RSA_PRIVATE_FAILED #define POLARSSL_ERR_RSA_PUBLIC_FAILED MBEDTLS_ERR_RSA_PUBLIC_FAILED #define POLARSSL_ERR_RSA_RNG_FAILED MBEDTLS_ERR_RSA_RNG_FAILED #define POLARSSL_ERR_RSA_VERIFY_FAILED MBEDTLS_ERR_RSA_VERIFY_FAILED #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY #define POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP #define POLARSSL_ERR_SSL_BAD_HS_FINISHED MBEDTLS_ERR_SSL_BAD_HS_FINISHED #define POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET #define POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION #define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO #define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE #define POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE #define POLARSSL_ERR_SSL_BAD_INPUT_DATA MBEDTLS_ERR_SSL_BAD_INPUT_DATA #define POLARSSL_ERR_SSL_BUFFER_TOO_SMALL MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL #define POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED #define POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED #define POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE #define POLARSSL_ERR_SSL_COMPRESSION_FAILED MBEDTLS_ERR_SSL_COMPRESSION_FAILED #define POLARSSL_ERR_SSL_CONN_EOF MBEDTLS_ERR_SSL_CONN_EOF #define POLARSSL_ERR_SSL_COUNTER_WRAPPING MBEDTLS_ERR_SSL_COUNTER_WRAPPING #define POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE #define POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE #define POLARSSL_ERR_SSL_HELLO_VERIFY_REQUIRED MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED #define POLARSSL_ERR_SSL_HW_ACCEL_FAILED MBEDTLS_ERR_SSL_HW_ACCEL_FAILED #define POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH #define POLARSSL_ERR_SSL_INTERNAL_ERROR MBEDTLS_ERR_SSL_INTERNAL_ERROR #define POLARSSL_ERR_SSL_INVALID_MAC MBEDTLS_ERR_SSL_INVALID_MAC #define POLARSSL_ERR_SSL_INVALID_RECORD MBEDTLS_ERR_SSL_INVALID_RECORD #define POLARSSL_ERR_SSL_MALLOC_FAILED MBEDTLS_ERR_SSL_ALLOC_FAILED #define POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN #define POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE #define POLARSSL_ERR_SSL_NO_RNG MBEDTLS_ERR_SSL_NO_RNG #define POLARSSL_ERR_SSL_NO_USABLE_CIPHERSUITE MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE #define POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY #define POLARSSL_ERR_SSL_PEER_VERIFY_FAILED MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED #define POLARSSL_ERR_SSL_PK_TYPE_MISMATCH MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH #define POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED #define POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED #define POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE #define POLARSSL_ERR_SSL_UNKNOWN_CIPHER MBEDTLS_ERR_SSL_UNKNOWN_CIPHER #define POLARSSL_ERR_SSL_UNKNOWN_IDENTITY MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY #define POLARSSL_ERR_SSL_WAITING_SERVER_HELLO_RENEGO MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO #define POLARSSL_ERR_THREADING_BAD_INPUT_DATA MBEDTLS_ERR_THREADING_BAD_INPUT_DATA #define POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE #define POLARSSL_ERR_THREADING_MUTEX_ERROR MBEDTLS_ERR_THREADING_MUTEX_ERROR #define POLARSSL_ERR_X509_BAD_INPUT_DATA MBEDTLS_ERR_X509_BAD_INPUT_DATA #define POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT #define POLARSSL_ERR_X509_CERT_VERIFY_FAILED MBEDTLS_ERR_X509_CERT_VERIFY_FAILED #define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE #define POLARSSL_ERR_X509_FILE_IO_ERROR MBEDTLS_ERR_X509_FILE_IO_ERROR #define POLARSSL_ERR_X509_INVALID_ALG MBEDTLS_ERR_X509_INVALID_ALG #define POLARSSL_ERR_X509_INVALID_DATE MBEDTLS_ERR_X509_INVALID_DATE #define POLARSSL_ERR_X509_INVALID_EXTENSIONS MBEDTLS_ERR_X509_INVALID_EXTENSIONS #define POLARSSL_ERR_X509_INVALID_FORMAT MBEDTLS_ERR_X509_INVALID_FORMAT #define POLARSSL_ERR_X509_INVALID_NAME MBEDTLS_ERR_X509_INVALID_NAME #define POLARSSL_ERR_X509_INVALID_SERIAL MBEDTLS_ERR_X509_INVALID_SERIAL #define POLARSSL_ERR_X509_INVALID_SIGNATURE MBEDTLS_ERR_X509_INVALID_SIGNATURE #define POLARSSL_ERR_X509_INVALID_VERSION MBEDTLS_ERR_X509_INVALID_VERSION #define POLARSSL_ERR_X509_MALLOC_FAILED MBEDTLS_ERR_X509_ALLOC_FAILED #define POLARSSL_ERR_X509_SIG_MISMATCH MBEDTLS_ERR_X509_SIG_MISMATCH #define POLARSSL_ERR_X509_UNKNOWN_OID MBEDTLS_ERR_X509_UNKNOWN_OID #define POLARSSL_ERR_X509_UNKNOWN_SIG_ALG MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG #define POLARSSL_ERR_X509_UNKNOWN_VERSION MBEDTLS_ERR_X509_UNKNOWN_VERSION #define POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH #define POLARSSL_GCM_H MBEDTLS_GCM_H #define POLARSSL_HAVEGE_H MBEDTLS_HAVEGE_H #define POLARSSL_HAVE_INT32 MBEDTLS_HAVE_INT32 #define POLARSSL_HAVE_INT64 MBEDTLS_HAVE_INT64 #define POLARSSL_HAVE_UDBL MBEDTLS_HAVE_UDBL #define POLARSSL_HAVE_X86 MBEDTLS_HAVE_X86 #define POLARSSL_HAVE_X86_64 MBEDTLS_HAVE_X86_64 #define POLARSSL_HMAC_DRBG_H MBEDTLS_HMAC_DRBG_H #define POLARSSL_HMAC_DRBG_PR_OFF MBEDTLS_HMAC_DRBG_PR_OFF #define POLARSSL_HMAC_DRBG_PR_ON MBEDTLS_HMAC_DRBG_PR_ON #define POLARSSL_KEY_EXCHANGE_DHE_PSK MBEDTLS_KEY_EXCHANGE_DHE_PSK #define POLARSSL_KEY_EXCHANGE_DHE_RSA MBEDTLS_KEY_EXCHANGE_DHE_RSA #define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA #define POLARSSL_KEY_EXCHANGE_ECDHE_PSK MBEDTLS_KEY_EXCHANGE_ECDHE_PSK #define POLARSSL_KEY_EXCHANGE_ECDHE_RSA MBEDTLS_KEY_EXCHANGE_ECDHE_RSA #define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA #define POLARSSL_KEY_EXCHANGE_ECDH_RSA MBEDTLS_KEY_EXCHANGE_ECDH_RSA #define POLARSSL_KEY_EXCHANGE_NONE MBEDTLS_KEY_EXCHANGE_NONE #define POLARSSL_KEY_EXCHANGE_PSK MBEDTLS_KEY_EXCHANGE_PSK #define POLARSSL_KEY_EXCHANGE_RSA MBEDTLS_KEY_EXCHANGE_RSA #define POLARSSL_KEY_EXCHANGE_RSA_PSK MBEDTLS_KEY_EXCHANGE_RSA_PSK #define POLARSSL_KEY_EXCHANGE__SOME__ECDHE_ENABLED MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED #define POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED #define POLARSSL_KEY_EXCHANGE__WITH_CERT__ENABLED MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED #define POLARSSL_KEY_LENGTH_DES MBEDTLS_KEY_LENGTH_DES #define POLARSSL_KEY_LENGTH_DES_EDE MBEDTLS_KEY_LENGTH_DES_EDE #define POLARSSL_KEY_LENGTH_DES_EDE3 MBEDTLS_KEY_LENGTH_DES_EDE3 #define POLARSSL_KEY_LENGTH_NONE MBEDTLS_KEY_LENGTH_NONE #define POLARSSL_MAX_BLOCK_LENGTH MBEDTLS_MAX_BLOCK_LENGTH #define POLARSSL_MAX_IV_LENGTH MBEDTLS_MAX_IV_LENGTH #define POLARSSL_MD2_H MBEDTLS_MD2_H #define POLARSSL_MD4_H MBEDTLS_MD4_H #define POLARSSL_MD5_H MBEDTLS_MD5_H #define POLARSSL_MD_H MBEDTLS_MD_H #define POLARSSL_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE #define POLARSSL_MD_MD2 MBEDTLS_MD_MD2 #define POLARSSL_MD_MD4 MBEDTLS_MD_MD4 #define POLARSSL_MD_MD5 MBEDTLS_MD_MD5 #define POLARSSL_MD_NONE MBEDTLS_MD_NONE #define POLARSSL_MD_RIPEMD160 MBEDTLS_MD_RIPEMD160 #define POLARSSL_MD_SHA1 MBEDTLS_MD_SHA1 #define POLARSSL_MD_SHA224 MBEDTLS_MD_SHA224 #define POLARSSL_MD_SHA256 MBEDTLS_MD_SHA256 #define POLARSSL_MD_SHA384 MBEDTLS_MD_SHA384 #define POLARSSL_MD_SHA512 MBEDTLS_MD_SHA512 #define POLARSSL_MD_WRAP_H MBEDTLS_MD_WRAP_H #define POLARSSL_MEMORY_BUFFER_ALLOC_H MBEDTLS_MEMORY_BUFFER_ALLOC_H #define POLARSSL_MODE_CBC MBEDTLS_MODE_CBC #define POLARSSL_MODE_CCM MBEDTLS_MODE_CCM #define POLARSSL_MODE_CFB MBEDTLS_MODE_CFB #define POLARSSL_MODE_CTR MBEDTLS_MODE_CTR #define POLARSSL_MODE_ECB MBEDTLS_MODE_ECB #define POLARSSL_MODE_GCM MBEDTLS_MODE_GCM #define POLARSSL_MODE_NONE MBEDTLS_MODE_NONE #define POLARSSL_MODE_OFB MBEDTLS_MODE_OFB #define POLARSSL_MODE_STREAM MBEDTLS_MODE_STREAM #define POLARSSL_MPI_MAX_BITS MBEDTLS_MPI_MAX_BITS #define POLARSSL_MPI_MAX_BITS_SCALE100 MBEDTLS_MPI_MAX_BITS_SCALE100 #define POLARSSL_MPI_MAX_LIMBS MBEDTLS_MPI_MAX_LIMBS #define POLARSSL_MPI_RW_BUFFER_SIZE MBEDTLS_MPI_RW_BUFFER_SIZE #define POLARSSL_NET_H MBEDTLS_NET_SOCKETS_H #define POLARSSL_NET_LISTEN_BACKLOG MBEDTLS_NET_LISTEN_BACKLOG #define POLARSSL_OID_H MBEDTLS_OID_H #define POLARSSL_OPERATION_NONE MBEDTLS_OPERATION_NONE #define POLARSSL_PADDING_NONE MBEDTLS_PADDING_NONE #define POLARSSL_PADDING_ONE_AND_ZEROS MBEDTLS_PADDING_ONE_AND_ZEROS #define POLARSSL_PADDING_PKCS7 MBEDTLS_PADDING_PKCS7 #define POLARSSL_PADDING_ZEROS MBEDTLS_PADDING_ZEROS #define POLARSSL_PADDING_ZEROS_AND_LEN MBEDTLS_PADDING_ZEROS_AND_LEN #define POLARSSL_PADLOCK_H MBEDTLS_PADLOCK_H #define POLARSSL_PEM_H MBEDTLS_PEM_H #define POLARSSL_PKCS11_H MBEDTLS_PKCS11_H #define POLARSSL_PKCS12_H MBEDTLS_PKCS12_H #define POLARSSL_PKCS5_H MBEDTLS_PKCS5_H #define POLARSSL_PK_DEBUG_ECP MBEDTLS_PK_DEBUG_ECP #define POLARSSL_PK_DEBUG_MAX_ITEMS MBEDTLS_PK_DEBUG_MAX_ITEMS #define POLARSSL_PK_DEBUG_MPI MBEDTLS_PK_DEBUG_MPI #define POLARSSL_PK_DEBUG_NONE MBEDTLS_PK_DEBUG_NONE #define POLARSSL_PK_ECDSA MBEDTLS_PK_ECDSA #define POLARSSL_PK_ECKEY MBEDTLS_PK_ECKEY #define POLARSSL_PK_ECKEY_DH MBEDTLS_PK_ECKEY_DH #define POLARSSL_PK_H MBEDTLS_PK_H #define POLARSSL_PK_NONE MBEDTLS_PK_NONE #define POLARSSL_PK_RSA MBEDTLS_PK_RSA #define POLARSSL_PK_RSASSA_PSS MBEDTLS_PK_RSASSA_PSS #define POLARSSL_PK_RSA_ALT MBEDTLS_PK_RSA_ALT #define POLARSSL_PK_WRAP_H MBEDTLS_PK_WRAP_H #define POLARSSL_PLATFORM_H MBEDTLS_PLATFORM_H #define POLARSSL_PREMASTER_SIZE MBEDTLS_PREMASTER_SIZE #define POLARSSL_RIPEMD160_H MBEDTLS_RIPEMD160_H #define POLARSSL_RSA_H MBEDTLS_RSA_H #define POLARSSL_SHA1_H MBEDTLS_SHA1_H #define POLARSSL_SHA256_H MBEDTLS_SHA256_H #define POLARSSL_SHA512_H MBEDTLS_SHA512_H #define POLARSSL_SSL_CACHE_H MBEDTLS_SSL_CACHE_H #define POLARSSL_SSL_CIPHERSUITES_H MBEDTLS_SSL_CIPHERSUITES_H #define POLARSSL_SSL_COOKIE_H MBEDTLS_SSL_COOKIE_H #define POLARSSL_SSL_H MBEDTLS_SSL_H #define POLARSSL_THREADING_H MBEDTLS_THREADING_H #define POLARSSL_THREADING_IMPL MBEDTLS_THREADING_IMPL #define POLARSSL_TIMING_H MBEDTLS_TIMING_H #define POLARSSL_VERSION_H MBEDTLS_VERSION_H #define POLARSSL_VERSION_MAJOR MBEDTLS_VERSION_MAJOR #define POLARSSL_VERSION_MINOR MBEDTLS_VERSION_MINOR #define POLARSSL_VERSION_NUMBER MBEDTLS_VERSION_NUMBER #define POLARSSL_VERSION_PATCH MBEDTLS_VERSION_PATCH #define POLARSSL_VERSION_STRING MBEDTLS_VERSION_STRING #define POLARSSL_VERSION_STRING_FULL MBEDTLS_VERSION_STRING_FULL #define POLARSSL_X509_CRL_H MBEDTLS_X509_CRL_H #define POLARSSL_X509_CRT_H MBEDTLS_X509_CRT_H #define POLARSSL_X509_CSR_H MBEDTLS_X509_CSR_H #define POLARSSL_X509_H MBEDTLS_X509_H #define POLARSSL_XTEA_H MBEDTLS_XTEA_H #define RSA_CRYPT MBEDTLS_RSA_CRYPT #define RSA_PKCS_V15 MBEDTLS_RSA_PKCS_V15 #define RSA_PKCS_V21 MBEDTLS_RSA_PKCS_V21 #define RSA_PRIVATE MBEDTLS_RSA_PRIVATE #define RSA_PUBLIC MBEDTLS_RSA_PUBLIC #define RSA_SALT_LEN_ANY MBEDTLS_RSA_SALT_LEN_ANY #define RSA_SIGN MBEDTLS_RSA_SIGN #define SSL_ALERT_LEVEL_FATAL MBEDTLS_SSL_ALERT_LEVEL_FATAL #define SSL_ALERT_LEVEL_WARNING MBEDTLS_SSL_ALERT_LEVEL_WARNING #define SSL_ALERT_MSG_ACCESS_DENIED MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED #define SSL_ALERT_MSG_BAD_CERT MBEDTLS_SSL_ALERT_MSG_BAD_CERT #define SSL_ALERT_MSG_BAD_RECORD_MAC MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC #define SSL_ALERT_MSG_CERT_EXPIRED MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED #define SSL_ALERT_MSG_CERT_REVOKED MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED #define SSL_ALERT_MSG_CERT_UNKNOWN MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN #define SSL_ALERT_MSG_CLOSE_NOTIFY MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY #define SSL_ALERT_MSG_DECODE_ERROR MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR #define SSL_ALERT_MSG_DECOMPRESSION_FAILURE MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE #define SSL_ALERT_MSG_DECRYPTION_FAILED MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED #define SSL_ALERT_MSG_DECRYPT_ERROR MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR #define SSL_ALERT_MSG_EXPORT_RESTRICTION MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION #define SSL_ALERT_MSG_HANDSHAKE_FAILURE MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE #define SSL_ALERT_MSG_ILLEGAL_PARAMETER MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER #define SSL_ALERT_MSG_INAPROPRIATE_FALLBACK MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK #define SSL_ALERT_MSG_INSUFFICIENT_SECURITY MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY #define SSL_ALERT_MSG_INTERNAL_ERROR MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR #define SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL #define SSL_ALERT_MSG_NO_CERT MBEDTLS_SSL_ALERT_MSG_NO_CERT #define SSL_ALERT_MSG_NO_RENEGOTIATION MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION #define SSL_ALERT_MSG_PROTOCOL_VERSION MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION #define SSL_ALERT_MSG_RECORD_OVERFLOW MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW #define SSL_ALERT_MSG_UNEXPECTED_MESSAGE MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE #define SSL_ALERT_MSG_UNKNOWN_CA MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA #define SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY #define SSL_ALERT_MSG_UNRECOGNIZED_NAME MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME #define SSL_ALERT_MSG_UNSUPPORTED_CERT MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT #define SSL_ALERT_MSG_UNSUPPORTED_EXT MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT #define SSL_ALERT_MSG_USER_CANCELED MBEDTLS_SSL_ALERT_MSG_USER_CANCELED #define SSL_ANTI_REPLAY_DISABLED MBEDTLS_SSL_ANTI_REPLAY_DISABLED #define SSL_ANTI_REPLAY_ENABLED MBEDTLS_SSL_ANTI_REPLAY_ENABLED #define SSL_ARC4_DISABLED MBEDTLS_SSL_ARC4_DISABLED #define SSL_ARC4_ENABLED MBEDTLS_SSL_ARC4_ENABLED #define SSL_BUFFER_LEN ( ( ( MBEDTLS_SSL_IN_BUFFER_LEN ) < ( MBEDTLS_SSL_OUT_BUFFER_LEN ) ) \ ? ( MBEDTLS_SSL_IN_BUFFER_LEN ) : ( MBEDTLS_SSL_OUT_BUFFER_LEN ) ) #define SSL_CACHE_DEFAULT_MAX_ENTRIES MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES #define SSL_CACHE_DEFAULT_TIMEOUT MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT #define SSL_CBC_RECORD_SPLITTING_DISABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED #define SSL_CBC_RECORD_SPLITTING_ENABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED #define SSL_CERTIFICATE_REQUEST MBEDTLS_SSL_CERTIFICATE_REQUEST #define SSL_CERTIFICATE_VERIFY MBEDTLS_SSL_CERTIFICATE_VERIFY #define SSL_CERT_TYPE_ECDSA_SIGN MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN #define SSL_CERT_TYPE_RSA_SIGN MBEDTLS_SSL_CERT_TYPE_RSA_SIGN #define SSL_CHANNEL_INBOUND MBEDTLS_SSL_CHANNEL_INBOUND #define SSL_CHANNEL_OUTBOUND MBEDTLS_SSL_CHANNEL_OUTBOUND #define SSL_CIPHERSUITES MBEDTLS_SSL_CIPHERSUITES #define SSL_CLIENT_CERTIFICATE MBEDTLS_SSL_CLIENT_CERTIFICATE #define SSL_CLIENT_CHANGE_CIPHER_SPEC MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC #define SSL_CLIENT_FINISHED MBEDTLS_SSL_CLIENT_FINISHED #define SSL_CLIENT_HELLO MBEDTLS_SSL_CLIENT_HELLO #define SSL_CLIENT_KEY_EXCHANGE MBEDTLS_SSL_CLIENT_KEY_EXCHANGE #define SSL_COMPRESSION_ADD MBEDTLS_SSL_COMPRESSION_ADD #define SSL_COMPRESS_DEFLATE MBEDTLS_SSL_COMPRESS_DEFLATE #define SSL_COMPRESS_NULL MBEDTLS_SSL_COMPRESS_NULL #define SSL_DEBUG_BUF MBEDTLS_SSL_DEBUG_BUF #define SSL_DEBUG_CRT MBEDTLS_SSL_DEBUG_CRT #define SSL_DEBUG_ECP MBEDTLS_SSL_DEBUG_ECP #define SSL_DEBUG_MPI MBEDTLS_SSL_DEBUG_MPI #define SSL_DEBUG_MSG MBEDTLS_SSL_DEBUG_MSG #define SSL_DEBUG_RET MBEDTLS_SSL_DEBUG_RET #define SSL_DEFAULT_TICKET_LIFETIME MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME #define SSL_DTLS_TIMEOUT_DFL_MAX MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX #define SSL_DTLS_TIMEOUT_DFL_MIN MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN #define SSL_EMPTY_RENEGOTIATION_INFO MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO #define SSL_ETM_DISABLED MBEDTLS_SSL_ETM_DISABLED #define SSL_ETM_ENABLED MBEDTLS_SSL_ETM_ENABLED #define SSL_EXTENDED_MS_DISABLED MBEDTLS_SSL_EXTENDED_MS_DISABLED #define SSL_EXTENDED_MS_ENABLED MBEDTLS_SSL_EXTENDED_MS_ENABLED #define SSL_FALLBACK_SCSV MBEDTLS_SSL_FALLBACK_SCSV #define SSL_FLUSH_BUFFERS MBEDTLS_SSL_FLUSH_BUFFERS #define SSL_HANDSHAKE_OVER MBEDTLS_SSL_HANDSHAKE_OVER #define SSL_HANDSHAKE_WRAPUP MBEDTLS_SSL_HANDSHAKE_WRAPUP #define SSL_HASH_MD5 MBEDTLS_SSL_HASH_MD5 #define SSL_HASH_NONE MBEDTLS_SSL_HASH_NONE #define SSL_HASH_SHA1 MBEDTLS_SSL_HASH_SHA1 #define SSL_HASH_SHA224 MBEDTLS_SSL_HASH_SHA224 #define SSL_HASH_SHA256 MBEDTLS_SSL_HASH_SHA256 #define SSL_HASH_SHA384 MBEDTLS_SSL_HASH_SHA384 #define SSL_HASH_SHA512 MBEDTLS_SSL_HASH_SHA512 #define SSL_HELLO_REQUEST MBEDTLS_SSL_HELLO_REQUEST #define SSL_HS_CERTIFICATE MBEDTLS_SSL_HS_CERTIFICATE #define SSL_HS_CERTIFICATE_REQUEST MBEDTLS_SSL_HS_CERTIFICATE_REQUEST #define SSL_HS_CERTIFICATE_VERIFY MBEDTLS_SSL_HS_CERTIFICATE_VERIFY #define SSL_HS_CLIENT_HELLO MBEDTLS_SSL_HS_CLIENT_HELLO #define SSL_HS_CLIENT_KEY_EXCHANGE MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE #define SSL_HS_FINISHED MBEDTLS_SSL_HS_FINISHED #define SSL_HS_HELLO_REQUEST MBEDTLS_SSL_HS_HELLO_REQUEST #define SSL_HS_HELLO_VERIFY_REQUEST MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST #define SSL_HS_NEW_SESSION_TICKET MBEDTLS_SSL_HS_NEW_SESSION_TICKET #define SSL_HS_SERVER_HELLO MBEDTLS_SSL_HS_SERVER_HELLO #define SSL_HS_SERVER_HELLO_DONE MBEDTLS_SSL_HS_SERVER_HELLO_DONE #define SSL_HS_SERVER_KEY_EXCHANGE MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE #define SSL_INITIAL_HANDSHAKE MBEDTLS_SSL_INITIAL_HANDSHAKE #define SSL_IS_CLIENT MBEDTLS_SSL_IS_CLIENT #define SSL_IS_FALLBACK MBEDTLS_SSL_IS_FALLBACK #define SSL_IS_NOT_FALLBACK MBEDTLS_SSL_IS_NOT_FALLBACK #define SSL_IS_SERVER MBEDTLS_SSL_IS_SERVER #define SSL_LEGACY_ALLOW_RENEGOTIATION MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION #define SSL_LEGACY_BREAK_HANDSHAKE MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE #define SSL_LEGACY_NO_RENEGOTIATION MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION #define SSL_LEGACY_RENEGOTIATION MBEDTLS_SSL_LEGACY_RENEGOTIATION #define SSL_MAC_ADD MBEDTLS_SSL_MAC_ADD #define SSL_MAJOR_VERSION_3 MBEDTLS_SSL_MAJOR_VERSION_3 #define SSL_MAX_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN #define SSL_MAX_FRAG_LEN_1024 MBEDTLS_SSL_MAX_FRAG_LEN_1024 #define SSL_MAX_FRAG_LEN_2048 MBEDTLS_SSL_MAX_FRAG_LEN_2048 #define SSL_MAX_FRAG_LEN_4096 MBEDTLS_SSL_MAX_FRAG_LEN_4096 #define SSL_MAX_FRAG_LEN_512 MBEDTLS_SSL_MAX_FRAG_LEN_512 #define SSL_MAX_FRAG_LEN_INVALID MBEDTLS_SSL_MAX_FRAG_LEN_INVALID #define SSL_MAX_FRAG_LEN_NONE MBEDTLS_SSL_MAX_FRAG_LEN_NONE #define SSL_MAX_MAJOR_VERSION MBEDTLS_SSL_MAX_MAJOR_VERSION #define SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MAX_MINOR_VERSION #define SSL_MINOR_VERSION_0 MBEDTLS_SSL_MINOR_VERSION_0 #define SSL_MINOR_VERSION_1 MBEDTLS_SSL_MINOR_VERSION_1 #define SSL_MINOR_VERSION_2 MBEDTLS_SSL_MINOR_VERSION_2 #define SSL_MINOR_VERSION_3 MBEDTLS_SSL_MINOR_VERSION_3 #define SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MIN_MAJOR_VERSION #define SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MIN_MINOR_VERSION #define SSL_MSG_ALERT MBEDTLS_SSL_MSG_ALERT #define SSL_MSG_APPLICATION_DATA MBEDTLS_SSL_MSG_APPLICATION_DATA #define SSL_MSG_CHANGE_CIPHER_SPEC MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC #define SSL_MSG_HANDSHAKE MBEDTLS_SSL_MSG_HANDSHAKE #define SSL_PADDING_ADD MBEDTLS_SSL_PADDING_ADD #define SSL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION #define SSL_RENEGOTIATION_DISABLED MBEDTLS_SSL_RENEGOTIATION_DISABLED #define SSL_RENEGOTIATION_DONE MBEDTLS_SSL_RENEGOTIATION_DONE #define SSL_RENEGOTIATION_ENABLED MBEDTLS_SSL_RENEGOTIATION_ENABLED #define SSL_RENEGOTIATION_NOT_ENFORCED MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED #define SSL_RENEGOTIATION_PENDING MBEDTLS_SSL_RENEGOTIATION_PENDING #define SSL_RENEGO_MAX_RECORDS_DEFAULT MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT #define SSL_RETRANS_FINISHED MBEDTLS_SSL_RETRANS_FINISHED #define SSL_RETRANS_PREPARING MBEDTLS_SSL_RETRANS_PREPARING #define SSL_RETRANS_SENDING MBEDTLS_SSL_RETRANS_SENDING #define SSL_RETRANS_WAITING MBEDTLS_SSL_RETRANS_WAITING #define SSL_SECURE_RENEGOTIATION MBEDTLS_SSL_SECURE_RENEGOTIATION #define SSL_SERVER_CERTIFICATE MBEDTLS_SSL_SERVER_CERTIFICATE #define SSL_SERVER_CHANGE_CIPHER_SPEC MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC #define SSL_SERVER_FINISHED MBEDTLS_SSL_SERVER_FINISHED #define SSL_SERVER_HELLO MBEDTLS_SSL_SERVER_HELLO #define SSL_SERVER_HELLO_DONE MBEDTLS_SSL_SERVER_HELLO_DONE #define SSL_SERVER_HELLO_VERIFY_REQUEST_SENT MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT #define SSL_SERVER_KEY_EXCHANGE MBEDTLS_SSL_SERVER_KEY_EXCHANGE #define SSL_SERVER_NEW_SESSION_TICKET MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET #define SSL_SESSION_TICKETS_DISABLED MBEDTLS_SSL_SESSION_TICKETS_DISABLED #define SSL_SESSION_TICKETS_ENABLED MBEDTLS_SSL_SESSION_TICKETS_ENABLED #define SSL_SIG_ANON MBEDTLS_SSL_SIG_ANON #define SSL_SIG_ECDSA MBEDTLS_SSL_SIG_ECDSA #define SSL_SIG_RSA MBEDTLS_SSL_SIG_RSA #define SSL_TRANSPORT_DATAGRAM MBEDTLS_SSL_TRANSPORT_DATAGRAM #define SSL_TRANSPORT_STREAM MBEDTLS_SSL_TRANSPORT_STREAM #define SSL_TRUNCATED_HMAC_LEN MBEDTLS_SSL_TRUNCATED_HMAC_LEN #define SSL_TRUNC_HMAC_DISABLED MBEDTLS_SSL_TRUNC_HMAC_DISABLED #define SSL_TRUNC_HMAC_ENABLED MBEDTLS_SSL_TRUNC_HMAC_ENABLED #define SSL_VERIFY_DATA_MAX_LEN MBEDTLS_SSL_VERIFY_DATA_MAX_LEN #define SSL_VERIFY_NONE MBEDTLS_SSL_VERIFY_NONE #define SSL_VERIFY_OPTIONAL MBEDTLS_SSL_VERIFY_OPTIONAL #define SSL_VERIFY_REQUIRED MBEDTLS_SSL_VERIFY_REQUIRED #define TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA #define TLS_DHE_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA #define TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 #define TLS_DHE_PSK_WITH_AES_128_CCM MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM #define TLS_DHE_PSK_WITH_AES_128_CCM_8 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8 #define TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 #define TLS_DHE_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA #define TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 #define TLS_DHE_PSK_WITH_AES_256_CCM MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM #define TLS_DHE_PSK_WITH_AES_256_CCM_8 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8 #define TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 #define TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_DHE_PSK_WITH_NULL_SHA MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA #define TLS_DHE_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 #define TLS_DHE_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 #define TLS_DHE_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA #define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 #define TLS_DHE_RSA_WITH_AES_128_CCM MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM #define TLS_DHE_RSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8 #define TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 #define TLS_DHE_RSA_WITH_AES_256_CCM MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM #define TLS_DHE_RSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8 #define TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 #define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA #define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA #define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 #define TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_DHE_RSA_WITH_DES_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA #define TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA #define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA #define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 #define TLS_ECDHE_ECDSA_WITH_AES_128_CCM MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM #define TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 #define TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 #define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA #define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 #define TLS_ECDHE_ECDSA_WITH_AES_256_CCM MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM #define TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 #define TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_ECDHE_ECDSA_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA #define TLS_ECDHE_ECDSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA #define TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA #define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA #define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 #define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA #define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 #define TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_ECDHE_PSK_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA #define TLS_ECDHE_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 #define TLS_ECDHE_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 #define TLS_ECDHE_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA #define TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA #define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA #define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 #define TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 #define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA #define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 #define TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 #define TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_ECDHE_RSA_WITH_NULL_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA #define TLS_ECDHE_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA #define TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA #define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA #define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 #define TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 #define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA #define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 #define TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_ECDH_ECDSA_WITH_NULL_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA #define TLS_ECDH_ECDSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA #define TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA #define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA #define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 #define TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 #define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA #define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 #define TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 #define TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_ECDH_RSA_WITH_NULL_SHA MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA #define TLS_ECDH_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA #define TLS_EXT_ALPN MBEDTLS_TLS_EXT_ALPN #define TLS_EXT_ENCRYPT_THEN_MAC MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC #define TLS_EXT_EXTENDED_MASTER_SECRET MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET #define TLS_EXT_MAX_FRAGMENT_LENGTH MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH #define TLS_EXT_RENEGOTIATION_INFO MBEDTLS_TLS_EXT_RENEGOTIATION_INFO #define TLS_EXT_SERVERNAME MBEDTLS_TLS_EXT_SERVERNAME #define TLS_EXT_SERVERNAME_HOSTNAME MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME #define TLS_EXT_SESSION_TICKET MBEDTLS_TLS_EXT_SESSION_TICKET #define TLS_EXT_SIG_ALG MBEDTLS_TLS_EXT_SIG_ALG #define TLS_EXT_SUPPORTED_ELLIPTIC_CURVES MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES #define TLS_EXT_SUPPORTED_POINT_FORMATS MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS #define TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT #define TLS_EXT_TRUNCATED_HMAC MBEDTLS_TLS_EXT_TRUNCATED_HMAC #define TLS_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA #define TLS_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA #define TLS_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 #define TLS_PSK_WITH_AES_128_CCM MBEDTLS_TLS_PSK_WITH_AES_128_CCM #define TLS_PSK_WITH_AES_128_CCM_8 MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 #define TLS_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 #define TLS_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA #define TLS_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 #define TLS_PSK_WITH_AES_256_CCM MBEDTLS_TLS_PSK_WITH_AES_256_CCM #define TLS_PSK_WITH_AES_256_CCM_8 MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8 #define TLS_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 #define TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_PSK_WITH_NULL_SHA MBEDTLS_TLS_PSK_WITH_NULL_SHA #define TLS_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_PSK_WITH_NULL_SHA256 #define TLS_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_PSK_WITH_NULL_SHA384 #define TLS_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_PSK_WITH_RC4_128_SHA #define TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA #define TLS_RSA_PSK_WITH_AES_128_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA #define TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 #define TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 #define TLS_RSA_PSK_WITH_AES_256_CBC_SHA MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA #define TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 #define TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 #define TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 #define TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_RSA_PSK_WITH_NULL_SHA MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA #define TLS_RSA_PSK_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 #define TLS_RSA_PSK_WITH_NULL_SHA384 MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 #define TLS_RSA_PSK_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA #define TLS_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA #define TLS_RSA_WITH_AES_128_CBC_SHA MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA #define TLS_RSA_WITH_AES_128_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 #define TLS_RSA_WITH_AES_128_CCM MBEDTLS_TLS_RSA_WITH_AES_128_CCM #define TLS_RSA_WITH_AES_128_CCM_8 MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8 #define TLS_RSA_WITH_AES_128_GCM_SHA256 MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 #define TLS_RSA_WITH_AES_256_CBC_SHA MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA #define TLS_RSA_WITH_AES_256_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 #define TLS_RSA_WITH_AES_256_CCM MBEDTLS_TLS_RSA_WITH_AES_256_CCM #define TLS_RSA_WITH_AES_256_CCM_8 MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8 #define TLS_RSA_WITH_AES_256_GCM_SHA384 MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 #define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA #define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 #define TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 #define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA #define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 #define TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 #define TLS_RSA_WITH_DES_CBC_SHA MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA #define TLS_RSA_WITH_NULL_MD5 MBEDTLS_TLS_RSA_WITH_NULL_MD5 #define TLS_RSA_WITH_NULL_SHA MBEDTLS_TLS_RSA_WITH_NULL_SHA #define TLS_RSA_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_WITH_NULL_SHA256 #define TLS_RSA_WITH_RC4_128_MD5 MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 #define TLS_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_WITH_RC4_128_SHA #define X509_CRT_VERSION_1 MBEDTLS_X509_CRT_VERSION_1 #define X509_CRT_VERSION_2 MBEDTLS_X509_CRT_VERSION_2 #define X509_CRT_VERSION_3 MBEDTLS_X509_CRT_VERSION_3 #define X509_FORMAT_DER MBEDTLS_X509_FORMAT_DER #define X509_FORMAT_PEM MBEDTLS_X509_FORMAT_PEM #define X509_MAX_DN_NAME_SIZE MBEDTLS_X509_MAX_DN_NAME_SIZE #define X509_RFC5280_MAX_SERIAL_LEN MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN #define X509_RFC5280_UTC_TIME_LEN MBEDTLS_X509_RFC5280_UTC_TIME_LEN #define XTEA_DECRYPT MBEDTLS_XTEA_DECRYPT #define XTEA_ENCRYPT MBEDTLS_XTEA_ENCRYPT #define _asn1_bitstring mbedtls_asn1_bitstring #define _asn1_buf mbedtls_asn1_buf #define _asn1_named_data mbedtls_asn1_named_data #define _asn1_sequence mbedtls_asn1_sequence #define _ssl_cache_context mbedtls_ssl_cache_context #define _ssl_cache_entry mbedtls_ssl_cache_entry #define _ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t #define _ssl_context mbedtls_ssl_context #define _ssl_flight_item mbedtls_ssl_flight_item #define _ssl_handshake_params mbedtls_ssl_handshake_params #define _ssl_key_cert mbedtls_ssl_key_cert #define _ssl_premaster_secret mbedtls_ssl_premaster_secret #define _ssl_session mbedtls_ssl_session #define _ssl_transform mbedtls_ssl_transform #define _x509_crl mbedtls_x509_crl #define _x509_crl_entry mbedtls_x509_crl_entry #define _x509_crt mbedtls_x509_crt #define _x509_csr mbedtls_x509_csr #define _x509_time mbedtls_x509_time #define _x509write_cert mbedtls_x509write_cert #define _x509write_csr mbedtls_x509write_csr #define aes_context mbedtls_aes_context #define aes_crypt_cbc mbedtls_aes_crypt_cbc #define aes_crypt_cfb128 mbedtls_aes_crypt_cfb128 #define aes_crypt_cfb8 mbedtls_aes_crypt_cfb8 #define aes_crypt_ctr mbedtls_aes_crypt_ctr #define aes_crypt_ecb mbedtls_aes_crypt_ecb #define aes_free mbedtls_aes_free #define aes_init mbedtls_aes_init #define aes_self_test mbedtls_aes_self_test #define aes_setkey_dec mbedtls_aes_setkey_dec #define aes_setkey_enc mbedtls_aes_setkey_enc #define aesni_crypt_ecb mbedtls_aesni_crypt_ecb #define aesni_gcm_mult mbedtls_aesni_gcm_mult #define aesni_inverse_key mbedtls_aesni_inverse_key #define aesni_setkey_enc mbedtls_aesni_setkey_enc #define aesni_supports mbedtls_aesni_has_support #define alarmed mbedtls_timing_alarmed #define arc4_context mbedtls_arc4_context #define arc4_crypt mbedtls_arc4_crypt #define arc4_free mbedtls_arc4_free #define arc4_init mbedtls_arc4_init #define arc4_self_test mbedtls_arc4_self_test #define arc4_setup mbedtls_arc4_setup #define asn1_bitstring mbedtls_asn1_bitstring #define asn1_buf mbedtls_asn1_buf #define asn1_find_named_data mbedtls_asn1_find_named_data #define asn1_free_named_data mbedtls_asn1_free_named_data #define asn1_free_named_data_list mbedtls_asn1_free_named_data_list #define asn1_get_alg mbedtls_asn1_get_alg #define asn1_get_alg_null mbedtls_asn1_get_alg_null #define asn1_get_bitstring mbedtls_asn1_get_bitstring #define asn1_get_bitstring_null mbedtls_asn1_get_bitstring_null #define asn1_get_bool mbedtls_asn1_get_bool #define asn1_get_int mbedtls_asn1_get_int #define asn1_get_len mbedtls_asn1_get_len #define asn1_get_mpi mbedtls_asn1_get_mpi #define asn1_get_sequence_of mbedtls_asn1_get_sequence_of #define asn1_get_tag mbedtls_asn1_get_tag #define asn1_named_data mbedtls_asn1_named_data #define asn1_sequence mbedtls_asn1_sequence #define asn1_store_named_data mbedtls_asn1_store_named_data #define asn1_write_algorithm_identifier mbedtls_asn1_write_algorithm_identifier #define asn1_write_bitstring mbedtls_asn1_write_bitstring #define asn1_write_bool mbedtls_asn1_write_bool #define asn1_write_ia5_string mbedtls_asn1_write_ia5_string #define asn1_write_int mbedtls_asn1_write_int #define asn1_write_len mbedtls_asn1_write_len #define asn1_write_mpi mbedtls_asn1_write_mpi #define asn1_write_null mbedtls_asn1_write_null #define asn1_write_octet_string mbedtls_asn1_write_octet_string #define asn1_write_oid mbedtls_asn1_write_oid #define asn1_write_printable_string mbedtls_asn1_write_printable_string #define asn1_write_raw_buffer mbedtls_asn1_write_raw_buffer #define asn1_write_tag mbedtls_asn1_write_tag #define base64_decode mbedtls_base64_decode #define base64_encode mbedtls_base64_encode #define base64_self_test mbedtls_base64_self_test #define blowfish_context mbedtls_blowfish_context #define blowfish_crypt_cbc mbedtls_blowfish_crypt_cbc #define blowfish_crypt_cfb64 mbedtls_blowfish_crypt_cfb64 #define blowfish_crypt_ctr mbedtls_blowfish_crypt_ctr #define blowfish_crypt_ecb mbedtls_blowfish_crypt_ecb #define blowfish_free mbedtls_blowfish_free #define blowfish_init mbedtls_blowfish_init #define blowfish_setkey mbedtls_blowfish_setkey #define camellia_context mbedtls_camellia_context #define camellia_crypt_cbc mbedtls_camellia_crypt_cbc #define camellia_crypt_cfb128 mbedtls_camellia_crypt_cfb128 #define camellia_crypt_ctr mbedtls_camellia_crypt_ctr #define camellia_crypt_ecb mbedtls_camellia_crypt_ecb #define camellia_free mbedtls_camellia_free #define camellia_init mbedtls_camellia_init #define camellia_self_test mbedtls_camellia_self_test #define camellia_setkey_dec mbedtls_camellia_setkey_dec #define camellia_setkey_enc mbedtls_camellia_setkey_enc #define ccm_auth_decrypt mbedtls_ccm_auth_decrypt #define ccm_context mbedtls_ccm_context #define ccm_encrypt_and_tag mbedtls_ccm_encrypt_and_tag #define ccm_free mbedtls_ccm_free #define ccm_init mbedtls_ccm_init #define ccm_self_test mbedtls_ccm_self_test #define cipher_auth_decrypt mbedtls_cipher_auth_decrypt #define cipher_auth_encrypt mbedtls_cipher_auth_encrypt #define cipher_base_t mbedtls_cipher_base_t #define cipher_check_tag mbedtls_cipher_check_tag #define cipher_context_t mbedtls_cipher_context_t #define cipher_crypt mbedtls_cipher_crypt #define cipher_definition_t mbedtls_cipher_definition_t #define cipher_definitions mbedtls_cipher_definitions #define cipher_finish mbedtls_cipher_finish #define cipher_free mbedtls_cipher_free #define cipher_get_block_size mbedtls_cipher_get_block_size #define cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode #define cipher_get_iv_size mbedtls_cipher_get_iv_size #define cipher_get_key_size mbedtls_cipher_get_key_bitlen #define cipher_get_name mbedtls_cipher_get_name #define cipher_get_operation mbedtls_cipher_get_operation #define cipher_get_type mbedtls_cipher_get_type #define cipher_id_t mbedtls_cipher_id_t #define cipher_info_from_string mbedtls_cipher_info_from_string #define cipher_info_from_type mbedtls_cipher_info_from_type #define cipher_info_from_values mbedtls_cipher_info_from_values #define cipher_info_t mbedtls_cipher_info_t #define cipher_init mbedtls_cipher_init #define cipher_init_ctx mbedtls_cipher_setup #define cipher_list mbedtls_cipher_list #define cipher_mode_t mbedtls_cipher_mode_t #define cipher_padding_t mbedtls_cipher_padding_t #define cipher_reset mbedtls_cipher_reset #define cipher_set_iv mbedtls_cipher_set_iv #define cipher_set_padding_mode mbedtls_cipher_set_padding_mode #define cipher_setkey mbedtls_cipher_setkey #define cipher_type_t mbedtls_cipher_type_t #define cipher_update mbedtls_cipher_update #define cipher_update_ad mbedtls_cipher_update_ad #define cipher_write_tag mbedtls_cipher_write_tag #define ctr_drbg_context mbedtls_ctr_drbg_context #define ctr_drbg_free mbedtls_ctr_drbg_free #define ctr_drbg_init mbedtls_ctr_drbg_init #define ctr_drbg_random mbedtls_ctr_drbg_random #define ctr_drbg_random_with_add mbedtls_ctr_drbg_random_with_add #define ctr_drbg_reseed mbedtls_ctr_drbg_reseed #define ctr_drbg_self_test mbedtls_ctr_drbg_self_test #define ctr_drbg_set_entropy_len mbedtls_ctr_drbg_set_entropy_len #define ctr_drbg_set_prediction_resistance mbedtls_ctr_drbg_set_prediction_resistance #define ctr_drbg_set_reseed_interval mbedtls_ctr_drbg_set_reseed_interval #define ctr_drbg_update mbedtls_ctr_drbg_update #define ctr_drbg_update_seed_file mbedtls_ctr_drbg_update_seed_file #define ctr_drbg_write_seed_file mbedtls_ctr_drbg_write_seed_file #define debug_print_buf mbedtls_debug_print_buf #define debug_print_crt mbedtls_debug_print_crt #define debug_print_ecp mbedtls_debug_print_ecp #define debug_print_mpi mbedtls_debug_print_mpi #define debug_print_msg mbedtls_debug_print_msg #define debug_print_ret mbedtls_debug_print_ret #define debug_set_threshold mbedtls_debug_set_threshold #define des3_context mbedtls_des3_context #define des3_crypt_cbc mbedtls_des3_crypt_cbc #define des3_crypt_ecb mbedtls_des3_crypt_ecb #define des3_free mbedtls_des3_free #define des3_init mbedtls_des3_init #define des3_set2key_dec mbedtls_des3_set2key_dec #define des3_set2key_enc mbedtls_des3_set2key_enc #define des3_set3key_dec mbedtls_des3_set3key_dec #define des3_set3key_enc mbedtls_des3_set3key_enc #define des_context mbedtls_des_context #define des_crypt_cbc mbedtls_des_crypt_cbc #define des_crypt_ecb mbedtls_des_crypt_ecb #define des_free mbedtls_des_free #define des_init mbedtls_des_init #define des_key_check_key_parity mbedtls_des_key_check_key_parity #define des_key_check_weak mbedtls_des_key_check_weak #define des_key_set_parity mbedtls_des_key_set_parity #define des_self_test mbedtls_des_self_test #define des_setkey_dec mbedtls_des_setkey_dec #define des_setkey_enc mbedtls_des_setkey_enc #define dhm_calc_secret mbedtls_dhm_calc_secret #define dhm_context mbedtls_dhm_context #define dhm_free mbedtls_dhm_free #define dhm_init mbedtls_dhm_init #define dhm_make_params mbedtls_dhm_make_params #define dhm_make_public mbedtls_dhm_make_public #define dhm_parse_dhm mbedtls_dhm_parse_dhm #define dhm_parse_dhmfile mbedtls_dhm_parse_dhmfile #define dhm_read_params mbedtls_dhm_read_params #define dhm_read_public mbedtls_dhm_read_public #define dhm_self_test mbedtls_dhm_self_test #define ecdh_calc_secret mbedtls_ecdh_calc_secret #define ecdh_compute_shared mbedtls_ecdh_compute_shared #define ecdh_context mbedtls_ecdh_context #define ecdh_free mbedtls_ecdh_free #define ecdh_gen_public mbedtls_ecdh_gen_public #define ecdh_get_params mbedtls_ecdh_get_params #define ecdh_init mbedtls_ecdh_init #define ecdh_make_params mbedtls_ecdh_make_params #define ecdh_make_public mbedtls_ecdh_make_public #define ecdh_read_params mbedtls_ecdh_read_params #define ecdh_read_public mbedtls_ecdh_read_public #define ecdh_side mbedtls_ecdh_side #define ecdsa_context mbedtls_ecdsa_context #define ecdsa_free mbedtls_ecdsa_free #define ecdsa_from_keypair mbedtls_ecdsa_from_keypair #define ecdsa_genkey mbedtls_ecdsa_genkey #define ecdsa_info mbedtls_ecdsa_info #define ecdsa_init mbedtls_ecdsa_init #define ecdsa_read_signature mbedtls_ecdsa_read_signature #define ecdsa_sign mbedtls_ecdsa_sign #define ecdsa_sign_det mbedtls_ecdsa_sign_det #define ecdsa_verify mbedtls_ecdsa_verify #define ecdsa_write_signature mbedtls_ecdsa_write_signature #define ecdsa_write_signature_det mbedtls_ecdsa_write_signature_det #define eckey_info mbedtls_eckey_info #define eckeydh_info mbedtls_eckeydh_info #define ecp_check_privkey mbedtls_ecp_check_privkey #define ecp_check_pub_priv mbedtls_ecp_check_pub_priv #define ecp_check_pubkey mbedtls_ecp_check_pubkey #define ecp_copy mbedtls_ecp_copy #define ecp_curve_info mbedtls_ecp_curve_info #define ecp_curve_info_from_grp_id mbedtls_ecp_curve_info_from_grp_id #define ecp_curve_info_from_name mbedtls_ecp_curve_info_from_name #define ecp_curve_info_from_tls_id mbedtls_ecp_curve_info_from_tls_id #define ecp_curve_list mbedtls_ecp_curve_list #define ecp_gen_key mbedtls_ecp_gen_key #define ecp_gen_keypair mbedtls_ecp_gen_keypair #define ecp_group mbedtls_ecp_group #define ecp_group_copy mbedtls_ecp_group_copy #define ecp_group_free mbedtls_ecp_group_free #define ecp_group_id mbedtls_ecp_group_id #define ecp_group_init mbedtls_ecp_group_init #define ecp_grp_id_list mbedtls_ecp_grp_id_list #define ecp_is_zero mbedtls_ecp_is_zero #define ecp_keypair mbedtls_ecp_keypair #define ecp_keypair_free mbedtls_ecp_keypair_free #define ecp_keypair_init mbedtls_ecp_keypair_init #define ecp_mul mbedtls_ecp_mul #define ecp_point mbedtls_ecp_point #define ecp_point_free mbedtls_ecp_point_free #define ecp_point_init mbedtls_ecp_point_init #define ecp_point_read_binary mbedtls_ecp_point_read_binary #define ecp_point_read_string mbedtls_ecp_point_read_string #define ecp_point_write_binary mbedtls_ecp_point_write_binary #define ecp_self_test mbedtls_ecp_self_test #define ecp_set_zero mbedtls_ecp_set_zero #define ecp_tls_read_group mbedtls_ecp_tls_read_group #define ecp_tls_read_point mbedtls_ecp_tls_read_point #define ecp_tls_write_group mbedtls_ecp_tls_write_group #define ecp_tls_write_point mbedtls_ecp_tls_write_point #define ecp_use_known_dp mbedtls_ecp_group_load #define entropy_add_source mbedtls_entropy_add_source #define entropy_context mbedtls_entropy_context #define entropy_free mbedtls_entropy_free #define entropy_func mbedtls_entropy_func #define entropy_gather mbedtls_entropy_gather #define entropy_init mbedtls_entropy_init #define entropy_self_test mbedtls_entropy_self_test #define entropy_update_manual mbedtls_entropy_update_manual #define entropy_update_seed_file mbedtls_entropy_update_seed_file #define entropy_write_seed_file mbedtls_entropy_write_seed_file #define error_strerror mbedtls_strerror #define f_source_ptr mbedtls_entropy_f_source_ptr #define gcm_auth_decrypt mbedtls_gcm_auth_decrypt #define gcm_context mbedtls_gcm_context #define gcm_crypt_and_tag mbedtls_gcm_crypt_and_tag #define gcm_finish mbedtls_gcm_finish #define gcm_free mbedtls_gcm_free #define gcm_init mbedtls_gcm_init #define gcm_self_test mbedtls_gcm_self_test #define gcm_starts mbedtls_gcm_starts #define gcm_update mbedtls_gcm_update #define get_timer mbedtls_timing_get_timer #define hardclock mbedtls_timing_hardclock #define hardclock_poll mbedtls_hardclock_poll #define havege_free mbedtls_havege_free #define havege_init mbedtls_havege_init #define havege_poll mbedtls_havege_poll #define havege_random mbedtls_havege_random #define havege_state mbedtls_havege_state #define hmac_drbg_context mbedtls_hmac_drbg_context #define hmac_drbg_free mbedtls_hmac_drbg_free #define hmac_drbg_init mbedtls_hmac_drbg_init #define hmac_drbg_random mbedtls_hmac_drbg_random #define hmac_drbg_random_with_add mbedtls_hmac_drbg_random_with_add #define hmac_drbg_reseed mbedtls_hmac_drbg_reseed #define hmac_drbg_self_test mbedtls_hmac_drbg_self_test #define hmac_drbg_set_entropy_len mbedtls_hmac_drbg_set_entropy_len #define hmac_drbg_set_prediction_resistance mbedtls_hmac_drbg_set_prediction_resistance #define hmac_drbg_set_reseed_interval mbedtls_hmac_drbg_set_reseed_interval #define hmac_drbg_update mbedtls_hmac_drbg_update #define hmac_drbg_update_seed_file mbedtls_hmac_drbg_update_seed_file #define hmac_drbg_write_seed_file mbedtls_hmac_drbg_write_seed_file #define hr_time mbedtls_timing_hr_time #define key_exchange_type_t mbedtls_key_exchange_type_t #define md mbedtls_md #define md2 mbedtls_md2 #define md2_context mbedtls_md2_context #define md2_finish mbedtls_md2_finish #define md2_free mbedtls_md2_free #define md2_info mbedtls_md2_info #define md2_init mbedtls_md2_init #define md2_process mbedtls_md2_process #define md2_self_test mbedtls_md2_self_test #define md2_starts mbedtls_md2_starts #define md2_update mbedtls_md2_update #define md4 mbedtls_md4 #define md4_context mbedtls_md4_context #define md4_finish mbedtls_md4_finish #define md4_free mbedtls_md4_free #define md4_info mbedtls_md4_info #define md4_init mbedtls_md4_init #define md4_process mbedtls_md4_process #define md4_self_test mbedtls_md4_self_test #define md4_starts mbedtls_md4_starts #define md4_update mbedtls_md4_update #define md5 mbedtls_md5 #define md5_context mbedtls_md5_context #define md5_finish mbedtls_md5_finish #define md5_free mbedtls_md5_free #define md5_info mbedtls_md5_info #define md5_init mbedtls_md5_init #define md5_process mbedtls_md5_process #define md5_self_test mbedtls_md5_self_test #define md5_starts mbedtls_md5_starts #define md5_update mbedtls_md5_update #define md_context_t mbedtls_md_context_t #define md_file mbedtls_md_file #define md_finish mbedtls_md_finish #define md_free mbedtls_md_free #define md_get_name mbedtls_md_get_name #define md_get_size mbedtls_md_get_size #define md_get_type mbedtls_md_get_type #define md_hmac mbedtls_md_hmac #define md_hmac_finish mbedtls_md_hmac_finish #define md_hmac_reset mbedtls_md_hmac_reset #define md_hmac_starts mbedtls_md_hmac_starts #define md_hmac_update mbedtls_md_hmac_update #define md_info_from_string mbedtls_md_info_from_string #define md_info_from_type mbedtls_md_info_from_type #define md_info_t mbedtls_md_info_t #define md_init mbedtls_md_init #define md_init_ctx mbedtls_md_init_ctx #define md_list mbedtls_md_list #define md_process mbedtls_md_process #define md_starts mbedtls_md_starts #define md_type_t mbedtls_md_type_t #define md_update mbedtls_md_update #define memory_buffer_alloc_cur_get mbedtls_memory_buffer_alloc_cur_get #define memory_buffer_alloc_free mbedtls_memory_buffer_alloc_free #define memory_buffer_alloc_init mbedtls_memory_buffer_alloc_init #define memory_buffer_alloc_max_get mbedtls_memory_buffer_alloc_max_get #define memory_buffer_alloc_max_reset mbedtls_memory_buffer_alloc_max_reset #define memory_buffer_alloc_self_test mbedtls_memory_buffer_alloc_self_test #define memory_buffer_alloc_status mbedtls_memory_buffer_alloc_status #define memory_buffer_alloc_verify mbedtls_memory_buffer_alloc_verify #define memory_buffer_set_verify mbedtls_memory_buffer_set_verify #define mpi mbedtls_mpi #define mpi_add_abs mbedtls_mpi_add_abs #define mpi_add_int mbedtls_mpi_add_int #define mpi_add_mpi mbedtls_mpi_add_mpi #define mpi_cmp_abs mbedtls_mpi_cmp_abs #define mpi_cmp_int mbedtls_mpi_cmp_int #define mpi_cmp_mpi mbedtls_mpi_cmp_mpi #define mpi_copy mbedtls_mpi_copy #define mpi_div_int mbedtls_mpi_div_int #define mpi_div_mpi mbedtls_mpi_div_mpi #define mpi_exp_mod mbedtls_mpi_exp_mod #define mpi_fill_random mbedtls_mpi_fill_random #define mpi_free mbedtls_mpi_free #define mpi_gcd mbedtls_mpi_gcd #define mpi_gen_prime mbedtls_mpi_gen_prime #define mpi_get_bit mbedtls_mpi_get_bit #define mpi_grow mbedtls_mpi_grow #define mpi_init mbedtls_mpi_init #define mpi_inv_mod mbedtls_mpi_inv_mod #define mpi_is_prime mbedtls_mpi_is_prime #define mpi_lsb mbedtls_mpi_lsb #define mpi_lset mbedtls_mpi_lset #define mpi_mod_int mbedtls_mpi_mod_int #define mpi_mod_mpi mbedtls_mpi_mod_mpi #define mpi_msb mbedtls_mpi_bitlen #define mpi_mul_int mbedtls_mpi_mul_int #define mpi_mul_mpi mbedtls_mpi_mul_mpi #define mpi_read_binary mbedtls_mpi_read_binary #define mpi_read_file mbedtls_mpi_read_file #define mpi_read_string mbedtls_mpi_read_string #define mpi_safe_cond_assign mbedtls_mpi_safe_cond_assign #define mpi_safe_cond_swap mbedtls_mpi_safe_cond_swap #define mpi_self_test mbedtls_mpi_self_test #define mpi_set_bit mbedtls_mpi_set_bit #define mpi_shift_l mbedtls_mpi_shift_l #define mpi_shift_r mbedtls_mpi_shift_r #define mpi_shrink mbedtls_mpi_shrink #define mpi_size mbedtls_mpi_size #define mpi_sub_abs mbedtls_mpi_sub_abs #define mpi_sub_int mbedtls_mpi_sub_int #define mpi_sub_mpi mbedtls_mpi_sub_mpi #define mpi_swap mbedtls_mpi_swap #define mpi_write_binary mbedtls_mpi_write_binary #define mpi_write_file mbedtls_mpi_write_file #define mpi_write_string mbedtls_mpi_write_string #define net_accept mbedtls_net_accept #define net_bind mbedtls_net_bind #define net_close mbedtls_net_free #define net_connect mbedtls_net_connect #define net_recv mbedtls_net_recv #define net_recv_timeout mbedtls_net_recv_timeout #define net_send mbedtls_net_send #define net_set_block mbedtls_net_set_block #define net_set_nonblock mbedtls_net_set_nonblock #define net_usleep mbedtls_net_usleep #define oid_descriptor_t mbedtls_oid_descriptor_t #define oid_get_attr_short_name mbedtls_oid_get_attr_short_name #define oid_get_cipher_alg mbedtls_oid_get_cipher_alg #define oid_get_ec_grp mbedtls_oid_get_ec_grp #define oid_get_extended_key_usage mbedtls_oid_get_extended_key_usage #define oid_get_md_alg mbedtls_oid_get_md_alg #define oid_get_numeric_string mbedtls_oid_get_numeric_string #define oid_get_oid_by_ec_grp mbedtls_oid_get_oid_by_ec_grp #define oid_get_oid_by_md mbedtls_oid_get_oid_by_md #define oid_get_oid_by_pk_alg mbedtls_oid_get_oid_by_pk_alg #define oid_get_oid_by_sig_alg mbedtls_oid_get_oid_by_sig_alg #define oid_get_pk_alg mbedtls_oid_get_pk_alg #define oid_get_pkcs12_pbe_alg mbedtls_oid_get_pkcs12_pbe_alg #define oid_get_sig_alg mbedtls_oid_get_sig_alg #define oid_get_sig_alg_desc mbedtls_oid_get_sig_alg_desc #define oid_get_x509_ext_type mbedtls_oid_get_x509_ext_type #define operation_t mbedtls_operation_t #define padlock_supports mbedtls_padlock_has_support #define padlock_xcryptcbc mbedtls_padlock_xcryptcbc #define padlock_xcryptecb mbedtls_padlock_xcryptecb #define pem_context mbedtls_pem_context #define pem_free mbedtls_pem_free #define pem_init mbedtls_pem_init #define pem_read_buffer mbedtls_pem_read_buffer #define pem_write_buffer mbedtls_pem_write_buffer #define pk_can_do mbedtls_pk_can_do #define pk_check_pair mbedtls_pk_check_pair #define pk_context mbedtls_pk_context #define pk_debug mbedtls_pk_debug #define pk_debug_item mbedtls_pk_debug_item #define pk_debug_type mbedtls_pk_debug_type #define pk_decrypt mbedtls_pk_decrypt #define pk_ec mbedtls_pk_ec #define pk_encrypt mbedtls_pk_encrypt #define pk_free mbedtls_pk_free #define pk_get_len mbedtls_pk_get_len #define pk_get_name mbedtls_pk_get_name #define pk_get_size mbedtls_pk_get_bitlen #define pk_get_type mbedtls_pk_get_type #define pk_info_from_type mbedtls_pk_info_from_type #define pk_info_t mbedtls_pk_info_t #define pk_init mbedtls_pk_init #define pk_init_ctx mbedtls_pk_setup #define pk_init_ctx_rsa_alt mbedtls_pk_setup_rsa_alt #define pk_load_file mbedtls_pk_load_file #define pk_parse_key mbedtls_pk_parse_key #define pk_parse_keyfile mbedtls_pk_parse_keyfile #define pk_parse_public_key mbedtls_pk_parse_public_key #define pk_parse_public_keyfile mbedtls_pk_parse_public_keyfile #define pk_parse_subpubkey mbedtls_pk_parse_subpubkey #define pk_rsa mbedtls_pk_rsa #define pk_rsa_alt_decrypt_func mbedtls_pk_rsa_alt_decrypt_func #define pk_rsa_alt_key_len_func mbedtls_pk_rsa_alt_key_len_func #define pk_rsa_alt_sign_func mbedtls_pk_rsa_alt_sign_func #define pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options #define pk_sign mbedtls_pk_sign #define pk_type_t mbedtls_pk_type_t #define pk_verify mbedtls_pk_verify #define pk_verify_ext mbedtls_pk_verify_ext #define pk_write_key_der mbedtls_pk_write_key_der #define pk_write_key_pem mbedtls_pk_write_key_pem #define pk_write_pubkey mbedtls_pk_write_pubkey #define pk_write_pubkey_der mbedtls_pk_write_pubkey_der #define pk_write_pubkey_pem mbedtls_pk_write_pubkey_pem #define pkcs11_context mbedtls_pkcs11_context #define pkcs11_decrypt mbedtls_pkcs11_decrypt #define pkcs11_priv_key_free mbedtls_pkcs11_priv_key_free #define pkcs11_priv_key_init mbedtls_pkcs11_priv_key_bind #define pkcs11_sign mbedtls_pkcs11_sign #define pkcs11_x509_cert_init mbedtls_pkcs11_x509_cert_bind #define pkcs12_derivation mbedtls_pkcs12_derivation #define pkcs12_pbe mbedtls_pkcs12_pbe #define pkcs12_pbe_sha1_rc4_128 mbedtls_pkcs12_pbe_sha1_rc4_128 #define pkcs5_pbes2 mbedtls_pkcs5_pbes2 #define pkcs5_pbkdf2_hmac mbedtls_pkcs5_pbkdf2_hmac #define pkcs5_self_test mbedtls_pkcs5_self_test #define platform_entropy_poll mbedtls_platform_entropy_poll #define platform_set_exit mbedtls_platform_set_exit #define platform_set_fprintf mbedtls_platform_set_fprintf #define platform_set_printf mbedtls_platform_set_printf #define platform_set_snprintf mbedtls_platform_set_snprintf #define polarssl_exit mbedtls_exit #define polarssl_fprintf mbedtls_fprintf #define polarssl_free mbedtls_free #define polarssl_mutex_free mbedtls_mutex_free #define polarssl_mutex_init mbedtls_mutex_init #define polarssl_mutex_lock mbedtls_mutex_lock #define polarssl_mutex_unlock mbedtls_mutex_unlock #define polarssl_printf mbedtls_printf #define polarssl_snprintf mbedtls_snprintf #define polarssl_strerror mbedtls_strerror #define ripemd160 mbedtls_ripemd160 #define ripemd160_context mbedtls_ripemd160_context #define ripemd160_finish mbedtls_ripemd160_finish #define ripemd160_free mbedtls_ripemd160_free #define ripemd160_info mbedtls_ripemd160_info #define ripemd160_init mbedtls_ripemd160_init #define ripemd160_process mbedtls_ripemd160_process #define ripemd160_self_test mbedtls_ripemd160_self_test #define ripemd160_starts mbedtls_ripemd160_starts #define ripemd160_update mbedtls_ripemd160_update #define rsa_alt_context mbedtls_rsa_alt_context #define rsa_alt_info mbedtls_rsa_alt_info #define rsa_check_privkey mbedtls_rsa_check_privkey #define rsa_check_pub_priv mbedtls_rsa_check_pub_priv #define rsa_check_pubkey mbedtls_rsa_check_pubkey #define rsa_context mbedtls_rsa_context #define rsa_copy mbedtls_rsa_copy #define rsa_free mbedtls_rsa_free #define rsa_gen_key mbedtls_rsa_gen_key #define rsa_info mbedtls_rsa_info #define rsa_init mbedtls_rsa_init #define rsa_pkcs1_decrypt mbedtls_rsa_pkcs1_decrypt #define rsa_pkcs1_encrypt mbedtls_rsa_pkcs1_encrypt #define rsa_pkcs1_sign mbedtls_rsa_pkcs1_sign #define rsa_pkcs1_verify mbedtls_rsa_pkcs1_verify #define rsa_private mbedtls_rsa_private #define rsa_public mbedtls_rsa_public #define rsa_rsaes_oaep_decrypt mbedtls_rsa_rsaes_oaep_decrypt #define rsa_rsaes_oaep_encrypt mbedtls_rsa_rsaes_oaep_encrypt #define rsa_rsaes_pkcs1_v15_decrypt mbedtls_rsa_rsaes_pkcs1_v15_decrypt #define rsa_rsaes_pkcs1_v15_encrypt mbedtls_rsa_rsaes_pkcs1_v15_encrypt #define rsa_rsassa_pkcs1_v15_sign mbedtls_rsa_rsassa_pkcs1_v15_sign #define rsa_rsassa_pkcs1_v15_verify mbedtls_rsa_rsassa_pkcs1_v15_verify #define rsa_rsassa_pss_sign mbedtls_rsa_rsassa_pss_sign #define rsa_rsassa_pss_verify mbedtls_rsa_rsassa_pss_verify #define rsa_rsassa_pss_verify_ext mbedtls_rsa_rsassa_pss_verify_ext #define rsa_self_test mbedtls_rsa_self_test #define rsa_set_padding mbedtls_rsa_set_padding #define safer_memcmp mbedtls_ssl_safer_memcmp #define set_alarm mbedtls_set_alarm #define sha1 mbedtls_sha1 #define sha1_context mbedtls_sha1_context #define sha1_finish mbedtls_sha1_finish #define sha1_free mbedtls_sha1_free #define sha1_info mbedtls_sha1_info #define sha1_init mbedtls_sha1_init #define sha1_process mbedtls_sha1_process #define sha1_self_test mbedtls_sha1_self_test #define sha1_starts mbedtls_sha1_starts #define sha1_update mbedtls_sha1_update #define sha224_info mbedtls_sha224_info #define sha256 mbedtls_sha256 #define sha256_context mbedtls_sha256_context #define sha256_finish mbedtls_sha256_finish #define sha256_free mbedtls_sha256_free #define sha256_info mbedtls_sha256_info #define sha256_init mbedtls_sha256_init #define sha256_process mbedtls_sha256_process #define sha256_self_test mbedtls_sha256_self_test #define sha256_starts mbedtls_sha256_starts #define sha256_update mbedtls_sha256_update #define sha384_info mbedtls_sha384_info #define sha512 mbedtls_sha512 #define sha512_context mbedtls_sha512_context #define sha512_finish mbedtls_sha512_finish #define sha512_free mbedtls_sha512_free #define sha512_info mbedtls_sha512_info #define sha512_init mbedtls_sha512_init #define sha512_process mbedtls_sha512_process #define sha512_self_test mbedtls_sha512_self_test #define sha512_starts mbedtls_sha512_starts #define sha512_update mbedtls_sha512_update #define source_state mbedtls_entropy_source_state #define ssl_cache_context mbedtls_ssl_cache_context #define ssl_cache_entry mbedtls_ssl_cache_entry #define ssl_cache_free mbedtls_ssl_cache_free #define ssl_cache_get mbedtls_ssl_cache_get #define ssl_cache_init mbedtls_ssl_cache_init #define ssl_cache_set mbedtls_ssl_cache_set #define ssl_cache_set_max_entries mbedtls_ssl_cache_set_max_entries #define ssl_cache_set_timeout mbedtls_ssl_cache_set_timeout #define ssl_check_cert_usage mbedtls_ssl_check_cert_usage #define ssl_ciphersuite_from_id mbedtls_ssl_ciphersuite_from_id #define ssl_ciphersuite_from_string mbedtls_ssl_ciphersuite_from_string #define ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t #define ssl_ciphersuite_uses_ec mbedtls_ssl_ciphersuite_uses_ec #define ssl_ciphersuite_uses_psk mbedtls_ssl_ciphersuite_uses_psk #define ssl_close_notify mbedtls_ssl_close_notify #define ssl_context mbedtls_ssl_context #define ssl_cookie_check mbedtls_ssl_cookie_check #define ssl_cookie_check_t mbedtls_ssl_cookie_check_t #define ssl_cookie_ctx mbedtls_ssl_cookie_ctx #define ssl_cookie_free mbedtls_ssl_cookie_free #define ssl_cookie_init mbedtls_ssl_cookie_init #define ssl_cookie_set_timeout mbedtls_ssl_cookie_set_timeout #define ssl_cookie_setup mbedtls_ssl_cookie_setup #define ssl_cookie_write mbedtls_ssl_cookie_write #define ssl_cookie_write_t mbedtls_ssl_cookie_write_t #define ssl_derive_keys mbedtls_ssl_derive_keys #define ssl_dtls_replay_check mbedtls_ssl_dtls_replay_check #define ssl_dtls_replay_update mbedtls_ssl_dtls_replay_update #define ssl_fetch_input mbedtls_ssl_fetch_input #define ssl_flight_item mbedtls_ssl_flight_item #define ssl_flush_output mbedtls_ssl_flush_output #define ssl_free mbedtls_ssl_free #define ssl_get_alpn_protocol mbedtls_ssl_get_alpn_protocol #define ssl_get_bytes_avail mbedtls_ssl_get_bytes_avail #define ssl_get_ciphersuite mbedtls_ssl_get_ciphersuite #define ssl_get_ciphersuite_id mbedtls_ssl_get_ciphersuite_id #define ssl_get_ciphersuite_name mbedtls_ssl_get_ciphersuite_name #define ssl_get_ciphersuite_sig_pk_alg mbedtls_ssl_get_ciphersuite_sig_pk_alg #define ssl_get_peer_cert mbedtls_ssl_get_peer_cert #define ssl_get_record_expansion mbedtls_ssl_get_record_expansion #define ssl_get_session mbedtls_ssl_get_session #define ssl_get_verify_result mbedtls_ssl_get_verify_result #define ssl_get_version mbedtls_ssl_get_version #define ssl_handshake mbedtls_ssl_handshake #define ssl_handshake_client_step mbedtls_ssl_handshake_client_step #define ssl_handshake_free mbedtls_ssl_handshake_free #define ssl_handshake_params mbedtls_ssl_handshake_params #define ssl_handshake_server_step mbedtls_ssl_handshake_server_step #define ssl_handshake_step mbedtls_ssl_handshake_step #define ssl_handshake_wrapup mbedtls_ssl_handshake_wrapup #define ssl_hdr_len mbedtls_ssl_hdr_len #define ssl_hs_hdr_len mbedtls_ssl_hs_hdr_len #define ssl_hw_record_activate mbedtls_ssl_hw_record_activate #define ssl_hw_record_finish mbedtls_ssl_hw_record_finish #define ssl_hw_record_init mbedtls_ssl_hw_record_init #define ssl_hw_record_read mbedtls_ssl_hw_record_read #define ssl_hw_record_reset mbedtls_ssl_hw_record_reset #define ssl_hw_record_write mbedtls_ssl_hw_record_write #define ssl_init mbedtls_ssl_init #define ssl_key_cert mbedtls_ssl_key_cert #define ssl_legacy_renegotiation mbedtls_ssl_conf_legacy_renegotiation #define ssl_list_ciphersuites mbedtls_ssl_list_ciphersuites #define ssl_md_alg_from_hash mbedtls_ssl_md_alg_from_hash #define ssl_optimize_checksum mbedtls_ssl_optimize_checksum #define ssl_own_cert mbedtls_ssl_own_cert #define ssl_own_key mbedtls_ssl_own_key #define ssl_parse_certificate mbedtls_ssl_parse_certificate #define ssl_parse_change_cipher_spec mbedtls_ssl_parse_change_cipher_spec #define ssl_parse_finished mbedtls_ssl_parse_finished #define ssl_pk_alg_from_sig mbedtls_ssl_pk_alg_from_sig #define ssl_pkcs11_decrypt mbedtls_ssl_pkcs11_decrypt #define ssl_pkcs11_key_len mbedtls_ssl_pkcs11_key_len #define ssl_pkcs11_sign mbedtls_ssl_pkcs11_sign #define ssl_psk_derive_premaster mbedtls_ssl_psk_derive_premaster #define ssl_read mbedtls_ssl_read #define ssl_read_record mbedtls_ssl_read_record #define ssl_read_version mbedtls_ssl_read_version #define ssl_recv_flight_completed mbedtls_ssl_recv_flight_completed #define ssl_renegotiate mbedtls_ssl_renegotiate #define ssl_resend mbedtls_ssl_resend #define ssl_reset_checksum mbedtls_ssl_reset_checksum #define ssl_send_alert_message mbedtls_ssl_send_alert_message #define ssl_send_fatal_handshake_failure mbedtls_ssl_send_fatal_handshake_failure #define ssl_send_flight_completed mbedtls_ssl_send_flight_completed #define ssl_session mbedtls_ssl_session #define ssl_session_free mbedtls_ssl_session_free #define ssl_session_init mbedtls_ssl_session_init #define ssl_session_reset mbedtls_ssl_session_reset #define ssl_set_alpn_protocols mbedtls_ssl_conf_alpn_protocols #define ssl_set_arc4_support mbedtls_ssl_conf_arc4_support #define ssl_set_authmode mbedtls_ssl_conf_authmode #define ssl_set_bio mbedtls_ssl_set_bio #define ssl_set_ca_chain mbedtls_ssl_conf_ca_chain #define ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting #define ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites #define ssl_set_ciphersuites_for_version mbedtls_ssl_conf_ciphersuites_for_version #define ssl_set_client_transport_id mbedtls_ssl_set_client_transport_id #define ssl_set_curves mbedtls_ssl_conf_curves #define ssl_set_dbg mbedtls_ssl_conf_dbg #define ssl_set_dh_param mbedtls_ssl_conf_dh_param #define ssl_set_dh_param_ctx mbedtls_ssl_conf_dh_param_ctx #define ssl_set_dtls_anti_replay mbedtls_ssl_conf_dtls_anti_replay #define ssl_set_dtls_badmac_limit mbedtls_ssl_conf_dtls_badmac_limit #define ssl_set_dtls_cookies mbedtls_ssl_conf_dtls_cookies #define ssl_set_encrypt_then_mac mbedtls_ssl_conf_encrypt_then_mac #define ssl_set_endpoint mbedtls_ssl_conf_endpoint #define ssl_set_extended_master_secret mbedtls_ssl_conf_extended_master_secret #define ssl_set_fallback mbedtls_ssl_conf_fallback #define ssl_set_handshake_timeout mbedtls_ssl_conf_handshake_timeout #define ssl_set_hostname mbedtls_ssl_set_hostname #define ssl_set_max_frag_len mbedtls_ssl_conf_max_frag_len #define ssl_set_max_version mbedtls_ssl_conf_max_version #define ssl_set_min_version mbedtls_ssl_conf_min_version #define ssl_set_own_cert mbedtls_ssl_conf_own_cert #define ssl_set_psk mbedtls_ssl_conf_psk #define ssl_set_psk_cb mbedtls_ssl_conf_psk_cb #define ssl_set_renegotiation mbedtls_ssl_conf_renegotiation #define ssl_set_renegotiation_enforced mbedtls_ssl_conf_renegotiation_enforced #define ssl_set_renegotiation_period mbedtls_ssl_conf_renegotiation_period #define ssl_set_rng mbedtls_ssl_conf_rng #define ssl_set_session mbedtls_ssl_set_session #define ssl_set_session_cache mbedtls_ssl_conf_session_cache #define ssl_set_session_tickets mbedtls_ssl_conf_session_tickets #define ssl_set_sni mbedtls_ssl_conf_sni #define ssl_set_transport mbedtls_ssl_conf_transport #define ssl_set_truncated_hmac mbedtls_ssl_conf_truncated_hmac #define ssl_set_verify mbedtls_ssl_conf_verify #define ssl_sig_from_pk mbedtls_ssl_sig_from_pk #define ssl_states mbedtls_ssl_states #define ssl_transform mbedtls_ssl_transform #define ssl_transform_free mbedtls_ssl_transform_free #define ssl_write mbedtls_ssl_write #define ssl_write_certificate mbedtls_ssl_write_certificate #define ssl_write_change_cipher_spec mbedtls_ssl_write_change_cipher_spec #define ssl_write_finished mbedtls_ssl_write_finished #define ssl_write_record mbedtls_ssl_write_record #define ssl_write_version mbedtls_ssl_write_version #define supported_ciphers mbedtls_cipher_supported #define t_sint mbedtls_mpi_sint #define t_udbl mbedtls_t_udbl #define t_uint mbedtls_mpi_uint #define test_ca_crt mbedtls_test_ca_crt #define test_ca_crt_ec mbedtls_test_ca_crt_ec #define test_ca_crt_rsa mbedtls_test_ca_crt_rsa #define test_ca_key mbedtls_test_ca_key #define test_ca_key_ec mbedtls_test_ca_key_ec #define test_ca_key_rsa mbedtls_test_ca_key_rsa #define test_ca_list mbedtls_test_cas_pem #define test_ca_pwd mbedtls_test_ca_pwd #define test_ca_pwd_ec mbedtls_test_ca_pwd_ec #define test_ca_pwd_rsa mbedtls_test_ca_pwd_rsa #define test_cli_crt mbedtls_test_cli_crt #define test_cli_crt_ec mbedtls_test_cli_crt_ec #define test_cli_crt_rsa mbedtls_test_cli_crt_rsa #define test_cli_key mbedtls_test_cli_key #define test_cli_key_ec mbedtls_test_cli_key_ec #define test_cli_key_rsa mbedtls_test_cli_key_rsa #define test_srv_crt mbedtls_test_srv_crt #define test_srv_crt_ec mbedtls_test_srv_crt_ec #define test_srv_crt_rsa mbedtls_test_srv_crt_rsa #define test_srv_key mbedtls_test_srv_key #define test_srv_key_ec mbedtls_test_srv_key_ec #define test_srv_key_rsa mbedtls_test_srv_key_rsa #define threading_mutex_t mbedtls_threading_mutex_t #define threading_set_alt mbedtls_threading_set_alt #define timing_self_test mbedtls_timing_self_test #define version_check_feature mbedtls_version_check_feature #define version_get_number mbedtls_version_get_number #define version_get_string mbedtls_version_get_string #define version_get_string_full mbedtls_version_get_string_full #define x509_bitstring mbedtls_x509_bitstring #define x509_buf mbedtls_x509_buf #define x509_crl mbedtls_x509_crl #define x509_crl_entry mbedtls_x509_crl_entry #define x509_crl_free mbedtls_x509_crl_free #define x509_crl_info mbedtls_x509_crl_info #define x509_crl_init mbedtls_x509_crl_init #define x509_crl_parse mbedtls_x509_crl_parse #define x509_crl_parse_der mbedtls_x509_crl_parse_der #define x509_crl_parse_file mbedtls_x509_crl_parse_file #define x509_crt mbedtls_x509_crt #define x509_crt_check_extended_key_usage mbedtls_x509_crt_check_extended_key_usage #define x509_crt_check_key_usage mbedtls_x509_crt_check_key_usage #define x509_crt_free mbedtls_x509_crt_free #define x509_crt_info mbedtls_x509_crt_info #define x509_crt_init mbedtls_x509_crt_init #define x509_crt_parse mbedtls_x509_crt_parse #define x509_crt_parse_der mbedtls_x509_crt_parse_der #define x509_crt_parse_file mbedtls_x509_crt_parse_file #define x509_crt_parse_path mbedtls_x509_crt_parse_path #define x509_crt_revoked mbedtls_x509_crt_is_revoked #define x509_crt_verify mbedtls_x509_crt_verify #define x509_csr mbedtls_x509_csr #define x509_csr_free mbedtls_x509_csr_free #define x509_csr_info mbedtls_x509_csr_info #define x509_csr_init mbedtls_x509_csr_init #define x509_csr_parse mbedtls_x509_csr_parse #define x509_csr_parse_der mbedtls_x509_csr_parse_der #define x509_csr_parse_file mbedtls_x509_csr_parse_file #define x509_dn_gets mbedtls_x509_dn_gets #define x509_get_alg mbedtls_x509_get_alg #define x509_get_alg_null mbedtls_x509_get_alg_null #define x509_get_ext mbedtls_x509_get_ext #define x509_get_name mbedtls_x509_get_name #define x509_get_rsassa_pss_params mbedtls_x509_get_rsassa_pss_params #define x509_get_serial mbedtls_x509_get_serial #define x509_get_sig mbedtls_x509_get_sig #define x509_get_sig_alg mbedtls_x509_get_sig_alg #define x509_get_time mbedtls_x509_get_time #define x509_key_size_helper mbedtls_x509_key_size_helper #define x509_name mbedtls_x509_name #define x509_self_test mbedtls_x509_self_test #define x509_sequence mbedtls_x509_sequence #define x509_serial_gets mbedtls_x509_serial_gets #define x509_set_extension mbedtls_x509_set_extension #define x509_sig_alg_gets mbedtls_x509_sig_alg_gets #define x509_string_to_names mbedtls_x509_string_to_names #define x509_time mbedtls_x509_time #define x509_time_expired mbedtls_x509_time_is_past #define x509_time_future mbedtls_x509_time_is_future #define x509_write_extensions mbedtls_x509_write_extensions #define x509_write_names mbedtls_x509_write_names #define x509_write_sig mbedtls_x509_write_sig #define x509write_cert mbedtls_x509write_cert #define x509write_crt_der mbedtls_x509write_crt_der #define x509write_crt_free mbedtls_x509write_crt_free #define x509write_crt_init mbedtls_x509write_crt_init #define x509write_crt_pem mbedtls_x509write_crt_pem #define x509write_crt_set_authority_key_identifier mbedtls_x509write_crt_set_authority_key_identifier #define x509write_crt_set_basic_constraints mbedtls_x509write_crt_set_basic_constraints #define x509write_crt_set_extension mbedtls_x509write_crt_set_extension #define x509write_crt_set_issuer_key mbedtls_x509write_crt_set_issuer_key #define x509write_crt_set_issuer_name mbedtls_x509write_crt_set_issuer_name #define x509write_crt_set_key_usage mbedtls_x509write_crt_set_key_usage #define x509write_crt_set_md_alg mbedtls_x509write_crt_set_md_alg #define x509write_crt_set_ns_cert_type mbedtls_x509write_crt_set_ns_cert_type #define x509write_crt_set_serial mbedtls_x509write_crt_set_serial #define x509write_crt_set_subject_key mbedtls_x509write_crt_set_subject_key #define x509write_crt_set_subject_key_identifier mbedtls_x509write_crt_set_subject_key_identifier #define x509write_crt_set_subject_name mbedtls_x509write_crt_set_subject_name #define x509write_crt_set_validity mbedtls_x509write_crt_set_validity #define x509write_crt_set_version mbedtls_x509write_crt_set_version #define x509write_csr mbedtls_x509write_csr #define x509write_csr_der mbedtls_x509write_csr_der #define x509write_csr_free mbedtls_x509write_csr_free #define x509write_csr_init mbedtls_x509write_csr_init #define x509write_csr_pem mbedtls_x509write_csr_pem #define x509write_csr_set_extension mbedtls_x509write_csr_set_extension #define x509write_csr_set_key mbedtls_x509write_csr_set_key #define x509write_csr_set_key_usage mbedtls_x509write_csr_set_key_usage #define x509write_csr_set_md_alg mbedtls_x509write_csr_set_md_alg #define x509write_csr_set_ns_cert_type mbedtls_x509write_csr_set_ns_cert_type #define x509write_csr_set_subject_name mbedtls_x509write_csr_set_subject_name #define xtea_context mbedtls_xtea_context #define xtea_crypt_cbc mbedtls_xtea_crypt_cbc #define xtea_crypt_ecb mbedtls_xtea_crypt_ecb #define xtea_free mbedtls_xtea_free #define xtea_init mbedtls_xtea_init #define xtea_self_test mbedtls_xtea_self_test #define xtea_setup mbedtls_xtea_setup #endif /* compat-1.3.h */ #endif /* MBEDTLS_DEPRECATED_REMOVED */
129,838
C++
.h
2,521
50.478382
108
0.828774
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,502
rsa.h
w1hkj_fldigi/src/include/mbedtls/rsa.h
/** * \file rsa.h * * \brief This file provides an API for the RSA public-key cryptosystem. * * The RSA public-key cryptosystem is defined in <em>Public-Key * Cryptography Standards (PKCS) #1 v1.5: RSA Encryption</em> * and <em>Public-Key Cryptography Standards (PKCS) #1 v2.1: * RSA Cryptography Specifications</em>. * */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_RSA_H #define MBEDTLS_RSA_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "bignum.h" #include "md.h" #if defined(MBEDTLS_THREADING_C) #include "threading.h" #endif /* * RSA Error codes */ #define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */ #define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */ #define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the validity check of the library. */ #define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */ #define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */ #define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */ #define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */ #define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */ /* MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION is deprecated and should not be used. */ #define MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION -0x4500 /**< The implementation does not offer the requested operation, for example, because of security violations or lack of functionality. */ /* MBEDTLS_ERR_RSA_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_RSA_HW_ACCEL_FAILED -0x4580 /**< RSA hardware accelerator failed. */ /* * RSA constants */ #define MBEDTLS_RSA_PUBLIC 0 /**< Request private key operation. */ #define MBEDTLS_RSA_PRIVATE 1 /**< Request public key operation. */ #define MBEDTLS_RSA_PKCS_V15 0 /**< Use PKCS#1 v1.5 encoding. */ #define MBEDTLS_RSA_PKCS_V21 1 /**< Use PKCS#1 v2.1 encoding. */ #define MBEDTLS_RSA_SIGN 1 /**< Identifier for RSA signature operations. */ #define MBEDTLS_RSA_CRYPT 2 /**< Identifier for RSA encryption and decryption operations. */ #define MBEDTLS_RSA_SALT_LEN_ANY -1 /* * The above constants may be used even if the RSA module is compile out, * eg for alternative (PKCS#11) RSA implemenations in the PK layers. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_RSA_ALT) // Regular implementation // /** * \brief The RSA context structure. * * \note Direct manipulation of the members of this structure * is deprecated. All manipulation should instead be done through * the public interface functions. */ typedef struct mbedtls_rsa_context { int ver; /*!< Always 0.*/ size_t len; /*!< The size of \p N in Bytes. */ mbedtls_mpi N; /*!< The public modulus. */ mbedtls_mpi E; /*!< The public exponent. */ mbedtls_mpi D; /*!< The private exponent. */ mbedtls_mpi P; /*!< The first prime factor. */ mbedtls_mpi Q; /*!< The second prime factor. */ mbedtls_mpi DP; /*!< <code>D % (P - 1)</code>. */ mbedtls_mpi DQ; /*!< <code>D % (Q - 1)</code>. */ mbedtls_mpi QP; /*!< <code>1 / (Q % P)</code>. */ mbedtls_mpi RN; /*!< cached <code>R^2 mod N</code>. */ mbedtls_mpi RP; /*!< cached <code>R^2 mod P</code>. */ mbedtls_mpi RQ; /*!< cached <code>R^2 mod Q</code>. */ mbedtls_mpi Vi; /*!< The cached blinding value. */ mbedtls_mpi Vf; /*!< The cached un-blinding value. */ int padding; /*!< Selects padding mode: #MBEDTLS_RSA_PKCS_V15 for 1.5 padding and #MBEDTLS_RSA_PKCS_V21 for OAEP or PSS. */ int hash_id; /*!< Hash identifier of mbedtls_md_type_t type, as specified in md.h for use in the MGF mask generating function used in the EME-OAEP and EMSA-PSS encodings. */ #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex. */ #endif } mbedtls_rsa_context; #else /* MBEDTLS_RSA_ALT */ #include "rsa_alt.h" #endif /* MBEDTLS_RSA_ALT */ /** * \brief This function initializes an RSA context. * * \note Set padding to #MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP * encryption scheme and the RSASSA-PSS signature scheme. * * \note The \p hash_id parameter is ignored when using * #MBEDTLS_RSA_PKCS_V15 padding. * * \note The choice of padding mode is strictly enforced for private key * operations, since there might be security concerns in * mixing padding modes. For public key operations it is * a default value, which can be overriden by calling specific * \c rsa_rsaes_xxx or \c rsa_rsassa_xxx functions. * * \note The hash selected in \p hash_id is always used for OEAP * encryption. For PSS signatures, it is always used for * making signatures, but can be overriden for verifying them. * If set to #MBEDTLS_MD_NONE, it is always overriden. * * \param ctx The RSA context to initialize. This must not be \c NULL. * \param padding The padding mode to use. This must be either * #MBEDTLS_RSA_PKCS_V15 or #MBEDTLS_RSA_PKCS_V21. * \param hash_id The hash identifier of ::mbedtls_md_type_t type, if * \p padding is #MBEDTLS_RSA_PKCS_V21. It is unused * otherwise. */ void mbedtls_rsa_init( mbedtls_rsa_context *ctx, int padding, int hash_id ); /** * \brief This function imports a set of core parameters into an * RSA context. * * \note This function can be called multiple times for successive * imports, if the parameters are not simultaneously present. * * Any sequence of calls to this function should be followed * by a call to mbedtls_rsa_complete(), which checks and * completes the provided information to a ready-for-use * public or private RSA key. * * \note See mbedtls_rsa_complete() for more information on which * parameters are necessary to set up a private or public * RSA key. * * \note The imported parameters are copied and need not be preserved * for the lifetime of the RSA context being set up. * * \param ctx The initialized RSA context to store the parameters in. * \param N The RSA modulus. This may be \c NULL. * \param P The first prime factor of \p N. This may be \c NULL. * \param Q The second prime factor of \p N. This may be \c NULL. * \param D The private exponent. This may be \c NULL. * \param E The public exponent. This may be \c NULL. * * \return \c 0 on success. * \return A non-zero error code on failure. */ int mbedtls_rsa_import( mbedtls_rsa_context *ctx, const mbedtls_mpi *N, const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *D, const mbedtls_mpi *E ); /** * \brief This function imports core RSA parameters, in raw big-endian * binary format, into an RSA context. * * \note This function can be called multiple times for successive * imports, if the parameters are not simultaneously present. * * Any sequence of calls to this function should be followed * by a call to mbedtls_rsa_complete(), which checks and * completes the provided information to a ready-for-use * public or private RSA key. * * \note See mbedtls_rsa_complete() for more information on which * parameters are necessary to set up a private or public * RSA key. * * \note The imported parameters are copied and need not be preserved * for the lifetime of the RSA context being set up. * * \param ctx The initialized RSA context to store the parameters in. * \param N The RSA modulus. This may be \c NULL. * \param N_len The Byte length of \p N; it is ignored if \p N == NULL. * \param P The first prime factor of \p N. This may be \c NULL. * \param P_len The Byte length of \p P; it ns ignored if \p P == NULL. * \param Q The second prime factor of \p N. This may be \c NULL. * \param Q_len The Byte length of \p Q; it is ignored if \p Q == NULL. * \param D The private exponent. This may be \c NULL. * \param D_len The Byte length of \p D; it is ignored if \p D == NULL. * \param E The public exponent. This may be \c NULL. * \param E_len The Byte length of \p E; it is ignored if \p E == NULL. * * \return \c 0 on success. * \return A non-zero error code on failure. */ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx, unsigned char const *N, size_t N_len, unsigned char const *P, size_t P_len, unsigned char const *Q, size_t Q_len, unsigned char const *D, size_t D_len, unsigned char const *E, size_t E_len ); /** * \brief This function completes an RSA context from * a set of imported core parameters. * * To setup an RSA public key, precisely \p N and \p E * must have been imported. * * To setup an RSA private key, sufficient information must * be present for the other parameters to be derivable. * * The default implementation supports the following: * <ul><li>Derive \p P, \p Q from \p N, \p D, \p E.</li> * <li>Derive \p N, \p D from \p P, \p Q, \p E.</li></ul> * Alternative implementations need not support these. * * If this function runs successfully, it guarantees that * the RSA context can be used for RSA operations without * the risk of failure or crash. * * \warning This function need not perform consistency checks * for the imported parameters. In particular, parameters that * are not needed by the implementation might be silently * discarded and left unchecked. To check the consistency * of the key material, see mbedtls_rsa_check_privkey(). * * \param ctx The initialized RSA context holding imported parameters. * * \return \c 0 on success. * \return #MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the attempted derivations * failed. * */ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ); /** * \brief This function exports the core parameters of an RSA key. * * If this function runs successfully, the non-NULL buffers * pointed to by \p N, \p P, \p Q, \p D, and \p E are fully * written, with additional unused space filled leading by * zero Bytes. * * Possible reasons for returning * #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED:<ul> * <li>An alternative RSA implementation is in use, which * stores the key externally, and either cannot or should * not export it into RAM.</li> * <li>A SW or HW implementation might not support a certain * deduction. For example, \p P, \p Q from \p N, \p D, * and \p E if the former are not part of the * implementation.</li></ul> * * If the function fails due to an unsupported operation, * the RSA context stays intact and remains usable. * * \param ctx The initialized RSA context. * \param N The MPI to hold the RSA modulus. * This may be \c NULL if this field need not be exported. * \param P The MPI to hold the first prime factor of \p N. * This may be \c NULL if this field need not be exported. * \param Q The MPI to hold the second prime factor of \p N. * This may be \c NULL if this field need not be exported. * \param D The MPI to hold the private exponent. * This may be \c NULL if this field need not be exported. * \param E The MPI to hold the public exponent. * This may be \c NULL if this field need not be exported. * * \return \c 0 on success. * \return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED if exporting the * requested parameters cannot be done due to missing * functionality or because of security policies. * \return A non-zero return code on any other failure. * */ int mbedtls_rsa_export( const mbedtls_rsa_context *ctx, mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q, mbedtls_mpi *D, mbedtls_mpi *E ); /** * \brief This function exports core parameters of an RSA key * in raw big-endian binary format. * * If this function runs successfully, the non-NULL buffers * pointed to by \p N, \p P, \p Q, \p D, and \p E are fully * written, with additional unused space filled leading by * zero Bytes. * * Possible reasons for returning * #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED:<ul> * <li>An alternative RSA implementation is in use, which * stores the key externally, and either cannot or should * not export it into RAM.</li> * <li>A SW or HW implementation might not support a certain * deduction. For example, \p P, \p Q from \p N, \p D, * and \p E if the former are not part of the * implementation.</li></ul> * If the function fails due to an unsupported operation, * the RSA context stays intact and remains usable. * * \note The length parameters are ignored if the corresponding * buffer pointers are NULL. * * \param ctx The initialized RSA context. * \param N The Byte array to store the RSA modulus, * or \c NULL if this field need not be exported. * \param N_len The size of the buffer for the modulus. * \param P The Byte array to hold the first prime factor of \p N, * or \c NULL if this field need not be exported. * \param P_len The size of the buffer for the first prime factor. * \param Q The Byte array to hold the second prime factor of \p N, * or \c NULL if this field need not be exported. * \param Q_len The size of the buffer for the second prime factor. * \param D The Byte array to hold the private exponent, * or \c NULL if this field need not be exported. * \param D_len The size of the buffer for the private exponent. * \param E The Byte array to hold the public exponent, * or \c NULL if this field need not be exported. * \param E_len The size of the buffer for the public exponent. * * \return \c 0 on success. * \return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED if exporting the * requested parameters cannot be done due to missing * functionality or because of security policies. * \return A non-zero return code on any other failure. */ int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx, unsigned char *N, size_t N_len, unsigned char *P, size_t P_len, unsigned char *Q, size_t Q_len, unsigned char *D, size_t D_len, unsigned char *E, size_t E_len ); /** * \brief This function exports CRT parameters of a private RSA key. * * \note Alternative RSA implementations not using CRT-parameters * internally can implement this function based on * mbedtls_rsa_deduce_opt(). * * \param ctx The initialized RSA context. * \param DP The MPI to hold \c D modulo `P-1`, * or \c NULL if it need not be exported. * \param DQ The MPI to hold \c D modulo `Q-1`, * or \c NULL if it need not be exported. * \param QP The MPI to hold modular inverse of \c Q modulo \c P, * or \c NULL if it need not be exported. * * \return \c 0 on success. * \return A non-zero error code on failure. * */ int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx, mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP ); /** * \brief This function sets padding for an already initialized RSA * context. See mbedtls_rsa_init() for details. * * \param ctx The initialized RSA context to be configured. * \param padding The padding mode to use. This must be either * #MBEDTLS_RSA_PKCS_V15 or #MBEDTLS_RSA_PKCS_V21. * \param hash_id The #MBEDTLS_RSA_PKCS_V21 hash identifier. */ void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id ); /** * \brief This function retrieves the length of RSA modulus in Bytes. * * \param ctx The initialized RSA context. * * \return The length of the RSA modulus in Bytes. * */ size_t mbedtls_rsa_get_len( const mbedtls_rsa_context *ctx ); /** * \brief This function generates an RSA keypair. * * \note mbedtls_rsa_init() must be called before this function, * to set up the RSA context. * * \param ctx The initialized RSA context used to hold the key. * \param f_rng The RNG function to be used for key generation. * This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. * This may be \c NULL if \p f_rng doesn't need a context. * \param nbits The size of the public key in bits. * \param exponent The public exponent to use. For example, \c 65537. * This must be odd and greater than \c 1. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, unsigned int nbits, int exponent ); /** * \brief This function checks if a context contains at least an RSA * public key. * * If the function runs successfully, it is guaranteed that * enough information is present to perform an RSA public key * operation using mbedtls_rsa_public(). * * \param ctx The initialized RSA context to check. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. * */ int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ); /** * \brief This function checks if a context contains an RSA private key * and perform basic consistency checks. * * \note The consistency checks performed by this function not only * ensure that mbedtls_rsa_private() can be called successfully * on the given context, but that the various parameters are * mutually consistent with high probability, in the sense that * mbedtls_rsa_public() and mbedtls_rsa_private() are inverses. * * \warning This function should catch accidental misconfigurations * like swapping of parameters, but it cannot establish full * trust in neither the quality nor the consistency of the key * material that was used to setup the given RSA context: * <ul><li>Consistency: Imported parameters that are irrelevant * for the implementation might be silently dropped. If dropped, * the current function does not have access to them, * and therefore cannot check them. See mbedtls_rsa_complete(). * If you want to check the consistency of the entire * content of an PKCS1-encoded RSA private key, for example, you * should use mbedtls_rsa_validate_params() before setting * up the RSA context. * Additionally, if the implementation performs empirical checks, * these checks substantiate but do not guarantee consistency.</li> * <li>Quality: This function is not expected to perform * extended quality assessments like checking that the prime * factors are safe. Additionally, it is the responsibility of the * user to ensure the trustworthiness of the source of his RSA * parameters, which goes beyond what is effectively checkable * by the library.</li></ul> * * \param ctx The initialized RSA context to check. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ); /** * \brief This function checks a public-private RSA key pair. * * It checks each of the contexts, and makes sure they match. * * \param pub The initialized RSA context holding the public key. * \param prv The initialized RSA context holding the private key. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv ); /** * \brief This function performs an RSA public key operation. * * \param ctx The initialized RSA context to use. * \param input The input buffer. This must be a readable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * \param output The output buffer. This must be a writable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \note This function does not handle message padding. * * \note Make sure to set \p input[0] = 0 or ensure that * input is smaller than \p N. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_public( mbedtls_rsa_context *ctx, const unsigned char *input, unsigned char *output ); /** * \brief This function performs an RSA private key operation. * * \note Blinding is used if and only if a PRNG is provided. * * \note If blinding is used, both the base of exponentation * and the exponent are blinded, providing protection * against some side-channel attacks. * * \warning It is deprecated and a security risk to not provide * a PRNG here and thereby prevent the use of blinding. * Future versions of the library may enforce the presence * of a PRNG. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function, used for blinding. It is discouraged * and deprecated to pass \c NULL here, in which case * blinding will be omitted. * \param p_rng The RNG context to pass to \p f_rng. This may be \c NULL * if \p f_rng is \c NULL or if \p f_rng doesn't need a context. * \param input The input buffer. This must be a readable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * \param output The output buffer. This must be a writable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. * */ int mbedtls_rsa_private( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, const unsigned char *input, unsigned char *output ); /** * \brief This function adds the message padding, then performs an RSA * operation. * * It is the generic wrapper for performing a PKCS#1 encryption * operation using the \p mode from the context. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PUBLIC. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG to use. It is mandatory for PKCS#1 v2.1 padding * encoding, and for PKCS#1 v1.5 padding encoding when used * with \p mode set to #MBEDTLS_RSA_PUBLIC. For PKCS#1 v1.5 * padding encoding and \p mode set to #MBEDTLS_RSA_PRIVATE, * it is used for blinding and should be provided in this * case; see mbedtls_rsa_private() for more. * \param p_rng The RNG context to be passed to \p f_rng. May be * \c NULL if \p f_rng is \c NULL or if \p f_rng doesn't * need a context argument. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param ilen The length of the plaintext in Bytes. * \param input The input data to encrypt. This must be a readable * buffer of size \p ilen Bytes. This must not be \c NULL. * \param output The output buffer. This must be a writable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t ilen, const unsigned char *input, unsigned char *output ); /** * \brief This function performs a PKCS#1 v1.5 encryption operation * (RSAES-PKCS1-v1_5-ENCRYPT). * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PUBLIC. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function to use. It is needed for padding generation * if \p mode is #MBEDTLS_RSA_PUBLIC. If \p mode is * #MBEDTLS_RSA_PRIVATE (discouraged), it is used for * blinding and should be provided; see mbedtls_rsa_private(). * \param p_rng The RNG context to be passed to \p f_rng. This may * be \c NULL if \p f_rng is \c NULL or if \p f_rng * doesn't need a context argument. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param ilen The length of the plaintext in Bytes. * \param input The input data to encrypt. This must be a readable * buffer of size \p ilen Bytes. This must not be \c NULL. * \param output The output buffer. This must be a writable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t ilen, const unsigned char *input, unsigned char *output ); /** * \brief This function performs a PKCS#1 v2.1 OAEP encryption * operation (RSAES-OAEP-ENCRYPT). * * \note The output buffer must be as large as the size * of ctx->N. For example, 128 Bytes if RSA-1024 is used. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PUBLIC. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initnialized RSA context to use. * \param f_rng The RNG function to use. This is needed for padding * generation and must be provided. * \param p_rng The RNG context to be passed to \p f_rng. This may * be \c NULL if \p f_rng doesn't need a context argument. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param label The buffer holding the custom label to use. * This must be a readable buffer of length \p label_len * Bytes. It may be \c NULL if \p label_len is \c 0. * \param label_len The length of the label in Bytes. * \param ilen The length of the plaintext buffer \p input in Bytes. * \param input The input data to encrypt. This must be a readable * buffer of size \p ilen Bytes. This must not be \c NULL. * \param output The output buffer. This must be a writable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, const unsigned char *label, size_t label_len, size_t ilen, const unsigned char *input, unsigned char *output ); /** * \brief This function performs an RSA operation, then removes the * message padding. * * It is the generic wrapper for performing a PKCS#1 decryption * operation using the \p mode from the context. * * \note The output buffer length \c output_max_len should be * as large as the size \p ctx->len of \p ctx->N (for example, * 128 Bytes if RSA-1024 is used) to be able to hold an * arbitrary decrypted message. If it is not large enough to * hold the decryption of the particular ciphertext provided, * the function returns \c MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PRIVATE. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. If \p mode is * #MBEDTLS_RSA_PUBLIC, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param olen The address at which to store the length of * the plaintext. This must not be \c NULL. * \param input The ciphertext buffer. This must be a readable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * \param output The buffer used to hold the plaintext. This must * be a writable buffer of length \p output_max_len Bytes. * \param output_max_len The length in Bytes of the output buffer \p output. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ); /** * \brief This function performs a PKCS#1 v1.5 decryption * operation (RSAES-PKCS1-v1_5-DECRYPT). * * \note The output buffer length \c output_max_len should be * as large as the size \p ctx->len of \p ctx->N, for example, * 128 Bytes if RSA-1024 is used, to be able to hold an * arbitrary decrypted message. If it is not large enough to * hold the decryption of the particular ciphertext provided, * the function returns #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PRIVATE. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. If \p mode is * #MBEDTLS_RSA_PUBLIC, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param olen The address at which to store the length of * the plaintext. This must not be \c NULL. * \param input The ciphertext buffer. This must be a readable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * \param output The buffer used to hold the plaintext. This must * be a writable buffer of length \p output_max_len Bytes. * \param output_max_len The length in Bytes of the output buffer \p output. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. * */ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ); /** * \brief This function performs a PKCS#1 v2.1 OAEP decryption * operation (RSAES-OAEP-DECRYPT). * * \note The output buffer length \c output_max_len should be * as large as the size \p ctx->len of \p ctx->N, for * example, 128 Bytes if RSA-1024 is used, to be able to * hold an arbitrary decrypted message. If it is not * large enough to hold the decryption of the particular * ciphertext provided, the function returns * #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PRIVATE. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. If \p mode is * #MBEDTLS_RSA_PUBLIC, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param label The buffer holding the custom label to use. * This must be a readable buffer of length \p label_len * Bytes. It may be \c NULL if \p label_len is \c 0. * \param label_len The length of the label in Bytes. * \param olen The address at which to store the length of * the plaintext. This must not be \c NULL. * \param input The ciphertext buffer. This must be a readable buffer * of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * \param output The buffer used to hold the plaintext. This must * be a writable buffer of length \p output_max_len Bytes. * \param output_max_len The length in Bytes of the output buffer \p output. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, const unsigned char *label, size_t label_len, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ); /** * \brief This function performs a private RSA operation to sign * a message digest using PKCS#1. * * It is the generic wrapper for performing a PKCS#1 * signature using the \p mode from the context. * * \note The \p sig buffer must be as large as the size * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. * * \note For PKCS#1 v2.1 encoding, see comments on * mbedtls_rsa_rsassa_pss_sign() for details on * \p md_alg and \p hash_id. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PRIVATE. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function to use. If the padding mode is PKCS#1 v2.1, * this must be provided. If the padding mode is PKCS#1 v1.5 and * \p mode is #MBEDTLS_RSA_PRIVATE, it is used for blinding * and should be provided; see mbedtls_rsa_private() for more * more. It is ignored otherwise. * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL * if \p f_rng is \c NULL or doesn't need a context argument. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * Ths is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param sig The buffer to hold the signature. This must be a writable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the signing operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); /** * \brief This function performs a PKCS#1 v1.5 signature * operation (RSASSA-PKCS1-v1_5-SIGN). * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PRIVATE. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. If \p mode is * #MBEDTLS_RSA_PUBLIC, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL * if \p f_rng is \c NULL or doesn't need a context argument. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * Ths is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param sig The buffer to hold the signature. This must be a writable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the signing operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); /** * \brief This function performs a PKCS#1 v2.1 PSS signature * operation (RSASSA-PSS-SIGN). * * \note The \p hash_id in the RSA context is the one used for the * encoding. \p md_alg in the function call is the type of hash * that is encoded. According to <em>RFC-3447: Public-Key * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography * Specifications</em> it is advised to keep both hashes the * same. * * \note This function always uses the maximum possible salt size, * up to the length of the payload hash. This choice of salt * size complies with FIPS 186-4 ยง5.5 (e) and RFC 8017 (PKCS#1 * v2.2) ยง9.1.1 step 3. Furthermore this function enforces a * minimum salt size which is the hash size minus 2 bytes. If * this minimum size is too large given the key size (the salt * size, plus the hash size, plus 2 bytes must be no more than * the key size in bytes), this function returns * #MBEDTLS_ERR_RSA_BAD_INPUT_DATA. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PRIVATE. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA context to use. * \param f_rng The RNG function. It must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL * if \p f_rng doesn't need a context argument. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * Ths is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param sig The buffer to hold the signature. This must be a writable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the signing operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); /** * \brief This function performs a public RSA operation and checks * the message digest. * * This is the generic wrapper for performing a PKCS#1 * verification using the mode from the context. * * \note For PKCS#1 v2.1 encoding, see comments on * mbedtls_rsa_rsassa_pss_verify() about \p md_alg and * \p hash_id. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it * set to #MBEDTLS_RSA_PUBLIC. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA public key context to use. * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. Otherwise, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * This is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param sig The buffer holding the signature. This must be a readable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the verify operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, const unsigned char *sig ); /** * \brief This function performs a PKCS#1 v1.5 verification * operation (RSASSA-PKCS1-v1_5-VERIFY). * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it * set to #MBEDTLS_RSA_PUBLIC. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA public key context to use. * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. Otherwise, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * This is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param sig The buffer holding the signature. This must be a readable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the verify operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, const unsigned char *sig ); /** * \brief This function performs a PKCS#1 v2.1 PSS verification * operation (RSASSA-PSS-VERIFY). * * The hash function for the MGF mask generating function * is that specified in the RSA context. * * \note The \p hash_id in the RSA context is the one used for the * verification. \p md_alg in the function call is the type of * hash that is verified. According to <em>RFC-3447: Public-Key * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography * Specifications</em> it is advised to keep both hashes the * same. If \p hash_id in the RSA context is unset, * the \p md_alg from the function call is used. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it * implicitly set to #MBEDTLS_RSA_PUBLIC. * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. * * \param ctx The initialized RSA public key context to use. * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. Otherwise, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * This is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param sig The buffer holding the signature. This must be a readable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the verify operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, const unsigned char *sig ); /** * \brief This function performs a PKCS#1 v2.1 PSS verification * operation (RSASSA-PSS-VERIFY). * * The hash function for the MGF mask generating function * is that specified in \p mgf1_hash_id. * * \note The \p sig buffer must be as large as the size * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. * * \note The \p hash_id in the RSA context is ignored. * * \param ctx The initialized RSA public key context to use. * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, * this is used for blinding and should be provided; see * mbedtls_rsa_private() for more. Otherwise, it is ignored. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a context. * \param mode The mode of operation. This must be either * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. * \param md_alg The message-digest algorithm used to hash the original data. * Use #MBEDTLS_MD_NONE for signing raw data. * \param hashlen The length of the message digest. * This is only used if \p md_alg is #MBEDTLS_MD_NONE. * \param hash The buffer holding the message digest or raw data. * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable * buffer of length \p hashlen Bytes. If \p md_alg is not * #MBEDTLS_MD_NONE, it must be a readable buffer of length * the size of the hash corresponding to \p md_alg. * \param mgf1_hash_id The message digest used for mask generation. * \param expected_salt_len The length of the salt used in padding. Use * #MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length. * \param sig The buffer holding the signature. This must be a readable * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes * for an 2048-bit RSA modulus. * * \return \c 0 if the verify operation was successful. * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, mbedtls_md_type_t mgf1_hash_id, int expected_salt_len, const unsigned char *sig ); /** * \brief This function copies the components of an RSA context. * * \param dst The destination context. This must be initialized. * \param src The source context. This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure. */ int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src ); /** * \brief This function frees the components of an RSA key. * * \param ctx The RSA context to free. May be \c NULL, in which case * this function is a no-op. If it is not \c NULL, it must * point to an initialized RSA context. */ void mbedtls_rsa_free( mbedtls_rsa_context *ctx ); /** * \brief The RSA checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_rsa_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* rsa.h */
64,459
C++
.h
1,214
48.472817
203
0.588938
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,503
timing.h
w1hkj_fldigi/src/include/mbedtls/timing.h
/** * \file timing.h * * \brief Portable interface to timeouts and to the CPU cycle counter */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_TIMING_H #define MBEDTLS_TIMING_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stdint.h> #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_TIMING_ALT) // Regular implementation // /** * \brief timer structure */ struct mbedtls_timing_hr_time { unsigned char opaque[32]; }; /** * \brief Context for mbedtls_timing_set/get_delay() */ typedef struct mbedtls_timing_delay_context { struct mbedtls_timing_hr_time timer; uint32_t int_ms; uint32_t fin_ms; } mbedtls_timing_delay_context; #else /* MBEDTLS_TIMING_ALT */ #include "timing_alt.h" #endif /* MBEDTLS_TIMING_ALT */ extern volatile int mbedtls_timing_alarmed; /** * \brief Return the CPU cycle counter value * * \warning This is only a best effort! Do not rely on this! * In particular, it is known to be unreliable on virtual * machines. * * \note This value starts at an unspecified origin and * may wrap around. */ unsigned long mbedtls_timing_hardclock( void ); /** * \brief Return the elapsed time in milliseconds * * \param val points to a timer structure * \param reset If 0, query the elapsed time. Otherwise (re)start the timer. * * \return Elapsed time since the previous reset in ms. When * restarting, this is always 0. * * \note To initialize a timer, call this function with reset=1. * * Determining the elapsed time and resetting the timer is not * atomic on all platforms, so after the sequence * `{ get_timer(1); ...; time1 = get_timer(1); ...; time2 = * get_timer(0) }` the value time1+time2 is only approximately * the delay since the first reset. */ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ); /** * \brief Setup an alarm clock * * \param seconds delay before the "mbedtls_timing_alarmed" flag is set * (must be >=0) * * \warning Only one alarm at a time is supported. In a threaded * context, this means one for the whole process, not one per * thread. */ void mbedtls_set_alarm( int seconds ); /** * \brief Set a pair of delays to watch * (See \c mbedtls_timing_get_delay().) * * \param data Pointer to timing data. * Must point to a valid \c mbedtls_timing_delay_context struct. * \param int_ms First (intermediate) delay in milliseconds. * The effect if int_ms > fin_ms is unspecified. * \param fin_ms Second (final) delay in milliseconds. * Pass 0 to cancel the current delay. * * \note To set a single delay, either use \c mbedtls_timing_set_timer * directly or use this function with int_ms == fin_ms. */ void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ); /** * \brief Get the status of delays * (Memory helper: number of delays passed.) * * \param data Pointer to timing data * Must point to a valid \c mbedtls_timing_delay_context struct. * * \return -1 if cancelled (fin_ms = 0), * 0 if none of the delays are passed, * 1 if only the intermediate delay is passed, * 2 if the final delay is passed. */ int mbedtls_timing_get_delay( void *data ); #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine * * \return 0 if successful, or 1 if a test failed */ int mbedtls_timing_self_test( int verbose ); #endif #ifdef __cplusplus } #endif #endif /* timing.h */
4,863
C++
.h
139
33.115108
88
0.641037
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,504
ctr_drbg.h
w1hkj_fldigi/src/include/mbedtls/ctr_drbg.h
/** * \file ctr_drbg.h * * \brief This file contains CTR_DRBG definitions and functions. * * CTR_DRBG is a standardized way of building a PRNG from a block-cipher * in counter mode operation, as defined in <em>NIST SP 800-90A: * Recommendation for Random Number Generation Using Deterministic Random * Bit Generators</em>. * * The Mbed TLS implementation of CTR_DRBG uses AES-256 (default) or AES-128 * as the underlying block cipher. * * \warning Using 128-bit keys for CTR_DRBG limits the security of generated * keys and operations that use random values generated to 128-bit security. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CTR_DRBG_H #define MBEDTLS_CTR_DRBG_H #include "aes.h" #if defined(MBEDTLS_THREADING_C) #include "threading.h" #endif #define MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */ #define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< The requested random buffer length is too big. */ #define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< The input (entropy + additional data) is too large. */ #define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read or write error in file. */ #define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< The block size used by the cipher. */ #if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY) #define MBEDTLS_CTR_DRBG_KEYSIZE 16 /**< The key size used by the cipher (compile-time choice: 128 bits). */ #else #define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< The key size used by the cipher (compile-time choice: 256 bits). */ #endif #define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 ) /**< The key size for the DRBG operation, in bits. */ #define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE ) /**< The seed length, calculated as (counter + AES key). */ /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h or define them using the compiler command * line. * \{ */ #if !defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) #if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256) #define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< The amount of entropy used per seed by default: * <ul><li>48 with SHA-512.</li> * <li>32 with SHA-256.</li></ul> */ #else #define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32 /**< Amount of entropy used per seed by default: * <ul><li>48 with SHA-512.</li> * <li>32 with SHA-256.</li></ul> */ #endif #endif #if !defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL) #define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< The interval before reseed is performed by default. */ #endif #if !defined(MBEDTLS_CTR_DRBG_MAX_INPUT) #define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< The maximum number of additional input Bytes. */ #endif #if !defined(MBEDTLS_CTR_DRBG_MAX_REQUEST) #define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< The maximum number of requested Bytes per call. */ #endif #if !defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT) #define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< The maximum size of seed or reseed buffer. */ #endif /* \} name SECTION: Module settings */ #define MBEDTLS_CTR_DRBG_PR_OFF 0 /**< Prediction resistance is disabled. */ #define MBEDTLS_CTR_DRBG_PR_ON 1 /**< Prediction resistance is enabled. */ #ifdef __cplusplus extern "C" { #endif /** * \brief The CTR_DRBG context structure. */ typedef struct mbedtls_ctr_drbg_context { unsigned char counter[16]; /*!< The counter (V). */ int reseed_counter; /*!< The reseed counter. */ int prediction_resistance; /*!< This determines whether prediction resistance is enabled, that is whether to systematically reseed before each random generation. */ size_t entropy_len; /*!< The amount of entropy grabbed on each seed or reseed operation. */ int reseed_interval; /*!< The reseed interval. */ mbedtls_aes_context aes_ctx; /*!< The AES context. */ /* * Callbacks (Entropy) */ int (*f_entropy)(void *, unsigned char *, size_t); /*!< The entropy callback function. */ void *p_entropy; /*!< The context for the entropy function. */ #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; #endif } mbedtls_ctr_drbg_context; /** * \brief This function initializes the CTR_DRBG context, * and prepares it for mbedtls_ctr_drbg_seed() * or mbedtls_ctr_drbg_free(). * * \param ctx The CTR_DRBG context to initialize. */ void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx ); /** * \brief This function seeds and sets up the CTR_DRBG * entropy source for future reseeds. * * \note Personalization data can be provided in addition to the more generic * entropy source, to make this instantiation as unique as possible. * * \param ctx The CTR_DRBG context to seed. * \param f_entropy The entropy callback, taking as arguments the * \p p_entropy context, the buffer to fill, and the length of the buffer. * \param p_entropy The entropy context. * \param custom Personalization data, that is device-specific identifiers. Can be NULL. * \param len The length of the personalization data. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure. */ int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len ); /** * \brief This function clears CTR_CRBG context data. * * \param ctx The CTR_DRBG context to clear. */ void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx ); /** * \brief This function turns prediction resistance on or off. * The default value is off. * * \note If enabled, entropy is gathered at the beginning of * every call to mbedtls_ctr_drbg_random_with_add(). * Only use this if your entropy source has sufficient * throughput. * * \param ctx The CTR_DRBG context. * \param resistance #MBEDTLS_CTR_DRBG_PR_ON or #MBEDTLS_CTR_DRBG_PR_OFF. */ void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx, int resistance ); /** * \brief This function sets the amount of entropy grabbed on each * seed or reseed. The default value is * #MBEDTLS_CTR_DRBG_ENTROPY_LEN. * * \param ctx The CTR_DRBG context. * \param len The amount of entropy to grab. */ void mbedtls_ctr_drbg_set_entropy_len( mbedtls_ctr_drbg_context *ctx, size_t len ); /** * \brief This function sets the reseed interval. * The default value is #MBEDTLS_CTR_DRBG_RESEED_INTERVAL. * * \param ctx The CTR_DRBG context. * \param interval The reseed interval. */ void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx, int interval ); /** * \brief This function reseeds the CTR_DRBG context, that is * extracts data from the entropy source. * * \param ctx The CTR_DRBG context. * \param additional Additional data to add to the state. Can be NULL. * \param len The length of the additional data. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure. */ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t len ); /** * \brief This function updates the state of the CTR_DRBG context. * * \param ctx The CTR_DRBG context. * \param additional The data to update the state with. * \param add_len Length of \p additional in bytes. This must be at * most #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG if * \p add_len is more than * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT. * \return An error from the underlying AES cipher on failure. */ int mbedtls_ctr_drbg_update_ret( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ); /** * \brief This function updates a CTR_DRBG instance with additional * data and uses it to generate random data. * * \note The function automatically reseeds if the reseed counter is exceeded. * * \param p_rng The CTR_DRBG context. This must be a pointer to a * #mbedtls_ctr_drbg_context structure. * \param output The buffer to fill. * \param output_len The length of the buffer. * \param additional Additional data to update. Can be NULL. * \param add_len The length of the additional data. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure. */ int mbedtls_ctr_drbg_random_with_add( void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len ); /** * \brief This function uses CTR_DRBG to generate random data. * * \note The function automatically reseeds if the reseed counter is exceeded. * * \param p_rng The CTR_DRBG context. This must be a pointer to a * #mbedtls_ctr_drbg_context structure. * \param output The buffer to fill. * \param output_len The length of the buffer. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure. */ int mbedtls_ctr_drbg_random( void *p_rng, unsigned char *output, size_t output_len ); #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function updates the state of the CTR_DRBG context. * * \deprecated Superseded by mbedtls_ctr_drbg_update_ret() * in 2.16.0. * * \note If \p add_len is greater than * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used. * The remaining Bytes are silently discarded. * * \param ctx The CTR_DRBG context. * \param additional The data to update the state with. * \param add_len Length of \p additional data. */ MBEDTLS_DEPRECATED void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ #if defined(MBEDTLS_FS_IO) /** * \brief This function writes a seed file. * * \param ctx The CTR_DRBG context. * \param path The name of the file. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error. * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on * failure. */ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ); /** * \brief This function reads and updates a seed file. The seed * is added to this instance. * * \param ctx The CTR_DRBG context. * \param path The name of the file. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error. * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG on failure. */ int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ); #endif /* MBEDTLS_FS_IO */ /** * \brief The CTR_DRBG checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_ctr_drbg_self_test( int verbose ); /* Internal functions (do not call directly) */ int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *, int (*)(void *, unsigned char *, size_t), void *, const unsigned char *, size_t, size_t ); #ifdef __cplusplus } #endif #endif /* ctr_drbg.h */
14,264
C++
.h
333
39.033033
161
0.624244
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,505
pkcs5.h
w1hkj_fldigi/src/include/mbedtls/pkcs5.h
/** * \file pkcs5.h * * \brief PKCS#5 functions * * \author Mathias Olsson <mathias@kompetensum.com> */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PKCS5_H #define MBEDTLS_PKCS5_H #include "asn1.h" #include "md.h" #include <stddef.h> #include <stdint.h> #define MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA -0x2f80 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_PKCS5_INVALID_FORMAT -0x2f00 /**< Unexpected ASN.1 data. */ #define MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE -0x2e80 /**< Requested encryption or digest alg not available. */ #define MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH -0x2e00 /**< Given private key password does not allow for correct decryption. */ #define MBEDTLS_PKCS5_DECRYPT 0 #define MBEDTLS_PKCS5_ENCRYPT 1 #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_ASN1_PARSE_C) /** * \brief PKCS#5 PBES2 function * * \param pbe_params the ASN.1 algorithm parameters * \param mode either MBEDTLS_PKCS5_DECRYPT or MBEDTLS_PKCS5_ENCRYPT * \param pwd password to use when generating key * \param pwdlen length of password * \param data data to process * \param datalen length of data * \param output output buffer * * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails. */ int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode, const unsigned char *pwd, size_t pwdlen, const unsigned char *data, size_t datalen, unsigned char *output ); #endif /* MBEDTLS_ASN1_PARSE_C */ /** * \brief PKCS#5 PBKDF2 using HMAC * * \param ctx Generic HMAC context * \param password Password to use when generating key * \param plen Length of password * \param salt Salt to use when generating key * \param slen Length of salt * \param iteration_count Iteration count * \param key_length Length of generated key in bytes * \param output Generated key. Must be at least as big as key_length * * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails. */ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *password, size_t plen, const unsigned char *salt, size_t slen, unsigned int iteration_count, uint32_t key_length, unsigned char *output ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_pkcs5_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* pkcs5.h */
3,525
C++
.h
89
36.516854
140
0.681659
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,506
cipher_internal.h
w1hkj_fldigi/src/include/mbedtls/cipher_internal.h
/** * \file cipher_internal.h * * \brief Cipher wrappers. * * \author Adriaan de Jong <dejong@fox-it.com> */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CIPHER_WRAP_H #define MBEDTLS_CIPHER_WRAP_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "cipher.h" #ifdef __cplusplus extern "C" { #endif /** * Base cipher information. The non-mode specific functions and values. */ struct mbedtls_cipher_base_t { /** Base Cipher type (e.g. MBEDTLS_CIPHER_ID_AES) */ mbedtls_cipher_id_t cipher; /** Encrypt using ECB */ int (*ecb_func)( void *ctx, mbedtls_operation_t mode, const unsigned char *input, unsigned char *output ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** Encrypt using CBC */ int (*cbc_func)( void *ctx, mbedtls_operation_t mode, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ); #endif #if defined(MBEDTLS_CIPHER_MODE_CFB) /** Encrypt using CFB (Full length) */ int (*cfb_func)( void *ctx, mbedtls_operation_t mode, size_t length, size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ); #endif #if defined(MBEDTLS_CIPHER_MODE_OFB) /** Encrypt using OFB (Full length) */ int (*ofb_func)( void *ctx, size_t length, size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ); #endif #if defined(MBEDTLS_CIPHER_MODE_CTR) /** Encrypt using CTR */ int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ); #endif #if defined(MBEDTLS_CIPHER_MODE_XTS) /** Encrypt or decrypt using XTS. */ int (*xts_func)( void *ctx, mbedtls_operation_t mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output ); #endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) /** Encrypt using STREAM */ int (*stream_func)( void *ctx, size_t length, const unsigned char *input, unsigned char *output ); #endif /** Set key for encryption purposes */ int (*setkey_enc_func)( void *ctx, const unsigned char *key, unsigned int key_bitlen ); /** Set key for decryption purposes */ int (*setkey_dec_func)( void *ctx, const unsigned char *key, unsigned int key_bitlen); /** Allocate a new context */ void * (*ctx_alloc_func)( void ); /** Free the given context */ void (*ctx_free_func)( void *ctx ); }; typedef struct { mbedtls_cipher_type_t type; const mbedtls_cipher_info_t *info; } mbedtls_cipher_definition_t; extern const mbedtls_cipher_definition_t mbedtls_cipher_definitions[]; extern int mbedtls_cipher_supported[]; #ifdef __cplusplus } #endif #endif /* MBEDTLS_CIPHER_WRAP_H */
3,994
C++
.h
106
32.113208
88
0.657099
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,507
camellia.h
w1hkj_fldigi/src/include/mbedtls/camellia.h
/** * \file camellia.h * * \brief Camellia block cipher */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CAMELLIA_H #define MBEDTLS_CAMELLIA_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> #include "platform_util.h" #define MBEDTLS_CAMELLIA_ENCRYPT 1 #define MBEDTLS_CAMELLIA_DECRYPT 0 #if !defined(MBEDTLS_DEPRECATED_REMOVED) #define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0024 ) #endif /* !MBEDTLS_DEPRECATED_REMOVED */ #define MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA -0x0024 /**< Bad input data. */ #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */ /* MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027 /**< Camellia hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_CAMELLIA_ALT) // Regular implementation // /** * \brief CAMELLIA context structure */ typedef struct mbedtls_camellia_context { int nr; /*!< number of rounds */ uint32_t rk[68]; /*!< CAMELLIA round keys */ } mbedtls_camellia_context; #else /* MBEDTLS_CAMELLIA_ALT */ #include "camellia_alt.h" #endif /* MBEDTLS_CAMELLIA_ALT */ /** * \brief Initialize a CAMELLIA context. * * \param ctx The CAMELLIA context to be initialized. * This must not be \c NULL. */ void mbedtls_camellia_init( mbedtls_camellia_context *ctx ); /** * \brief Clear a CAMELLIA context. * * \param ctx The CAMELLIA context to be cleared. This may be \c NULL, * in which case this function returns immediately. If it is not * \c NULL, it must be initialized. */ void mbedtls_camellia_free( mbedtls_camellia_context *ctx ); /** * \brief Perform a CAMELLIA key schedule operation for encryption. * * \param ctx The CAMELLIA context to use. This must be initialized. * \param key The encryption key to use. This must be a readable buffer * of size \p keybits Bits. * \param keybits The length of \p key in Bits. This must be either \c 128, * \c 192 or \c 256. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief Perform a CAMELLIA key schedule operation for decryption. * * \param ctx The CAMELLIA context to use. This must be initialized. * \param key The decryption key. This must be a readable buffer * of size \p keybits Bits. * \param keybits The length of \p key in Bits. This must be either \c 128, * \c 192 or \c 256. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief Perform a CAMELLIA-ECB block encryption/decryption operation. * * \param ctx The CAMELLIA context to use. This must be initialized * and bound to a key. * \param mode The mode of operation. This must be either * #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. * \param input The input block. This must be a readable buffer * of size \c 16 Bytes. * \param output The output block. This must be a writable buffer * of size \c 16 Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief Perform a CAMELLIA-CBC buffer encryption/decryption operation. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If on the other hand you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * \param ctx The CAMELLIA context to use. This must be initialized * and bound to a key. * \param mode The mode of operation. This must be either * #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. * \param length The length in Bytes of the input data \p input. * This must be a multiple of \c 16 Bytes. * \param iv The initialization vector. This must be a read/write buffer * of length \c 16 Bytes. It is updated to allow streaming * use as explained above. * \param input The buffer holding the input data. This must point to a * readable buffer of length \p length Bytes. * \param output The buffer holding the output data. This must point to a * writable buffer of length \p length Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CIPHER_MODE_CFB) /** * \brief Perform a CAMELLIA-CFB128 buffer encryption/decryption * operation. * * \note Due to the nature of CFB mode, you should use the same * key for both encryption and decryption. In particular, calls * to this function should be preceded by a key-schedule via * mbedtls_camellia_setkey_enc() regardless of whether \p mode * is #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If on the other hand you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * \param ctx The CAMELLIA context to use. This must be initialized * and bound to a key. * \param mode The mode of operation. This must be either * #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. * \param length The length of the input data \p input. Any value is allowed. * \param iv_off The current offset in the IV. This must be smaller * than \c 16 Bytes. It is updated after this call to allow * the aforementioned streaming usage. * \param iv The initialization vector. This must be a read/write buffer * of length \c 16 Bytes. It is updated after this call to * allow the aforementioned streaming usage. * \param input The buffer holding the input data. This must be a readable * buffer of size \p length Bytes. * \param output The buffer to hold the output data. This must be a writable * buffer of length \p length Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CFB */ #if defined(MBEDTLS_CIPHER_MODE_CTR) /** * \brief Perform a CAMELLIA-CTR buffer encryption/decryption operation. * * *note Due to the nature of CTR mode, you should use the same * key for both encryption and decryption. In particular, calls * to this function should be preceded by a key-schedule via * mbedtls_camellia_setkey_enc() regardless of whether \p mode * is #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. * * \warning You must never reuse a nonce value with the same key. Doing so * would void the encryption for the two messages encrypted with * the same nonce and key. * * There are two common strategies for managing nonces with CTR: * * 1. You can handle everything as a single message processed over * successive calls to this function. In that case, you want to * set \p nonce_counter and \p nc_off to 0 for the first call, and * then preserve the values of \p nonce_counter, \p nc_off and \p * stream_block across calls to this function as they will be * updated by this function. * * With this strategy, you must not encrypt more than 2**128 * blocks of data with the same key. * * 2. You can encrypt separate messages by dividing the \p * nonce_counter buffer in two areas: the first one used for a * per-message nonce, handled by yourself, and the second one * updated by this function internally. * * For example, you might reserve the first \c 12 Bytes for the * per-message nonce, and the last \c 4 Bytes for internal use. * In that case, before calling this function on a new message you * need to set the first \c 12 Bytes of \p nonce_counter to your * chosen nonce value, the last four to \c 0, and \p nc_off to \c 0 * (which will cause \p stream_block to be ignored). That way, you * can encrypt at most \c 2**96 messages of up to \c 2**32 blocks * each with the same key. * * The per-message nonce (or information sufficient to reconstruct * it) needs to be communicated with the ciphertext and must be * unique. The recommended way to ensure uniqueness is to use a * message counter. An alternative is to generate random nonces, * but this limits the number of messages that can be securely * encrypted: for example, with 96-bit random nonces, you should * not encrypt more than 2**32 messages with the same key. * * Note that for both stategies, sizes are measured in blocks and * that a CAMELLIA block is \c 16 Bytes. * * \warning Upon return, \p stream_block contains sensitive data. Its * content must not be written to insecure storage and should be * securely discarded as soon as it's no longer needed. * * \param ctx The CAMELLIA context to use. This must be initialized * and bound to a key. * \param length The length of the input data \p input in Bytes. * Any value is allowed. * \param nc_off The offset in the current \p stream_block (for resuming * within current cipher stream). The offset pointer to * should be \c 0 at the start of a stream. It is updated * at the end of this call. * \param nonce_counter The 128-bit nonce and counter. This must be a read/write * buffer of length \c 16 Bytes. * \param stream_block The saved stream-block for resuming. This must be a * read/write buffer of length \c 16 Bytes. * \param input The input data stream. This must be a readable buffer of * size \p length Bytes. * \param output The output data stream. This must be a writable buffer * of size \p length Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_camellia_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* camellia.h */
14,191
C++
.h
302
43.304636
112
0.622197
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,508
md5.h
w1hkj_fldigi/src/include/mbedtls/md5.h
/** * \file md5.h * * \brief MD5 message digest algorithm (hash function) * * \warning MD5 is considered a weak message digest and its use constitutes a * security risk. We recommend considering stronger message * digests instead. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_MD5_H #define MBEDTLS_MD5_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* MBEDTLS_ERR_MD5_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_MD5_ALT) // Regular implementation // /** * \brief MD5 context structure * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ typedef struct mbedtls_md5_context { uint32_t total[2]; /*!< number of bytes processed */ uint32_t state[4]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ } mbedtls_md5_context; #else /* MBEDTLS_MD5_ALT */ #include "md5_alt.h" #endif /* MBEDTLS_MD5_ALT */ /** * \brief Initialize MD5 context * * \param ctx MD5 context to be initialized * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md5_init( mbedtls_md5_context *ctx ); /** * \brief Clear MD5 context * * \param ctx MD5 context to be cleared * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md5_free( mbedtls_md5_context *ctx ); /** * \brief Clone (the state of) an MD5 context * * \param dst The destination context * \param src The context to be cloned * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md5_clone( mbedtls_md5_context *dst, const mbedtls_md5_context *src ); /** * \brief MD5 context setup * * \param ctx context to be initialized * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md5_starts_ret( mbedtls_md5_context *ctx ); /** * \brief MD5 process buffer * * \param ctx MD5 context * \param input buffer holding the data * \param ilen length of the input data * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md5_update_ret( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD5 final digest * * \param ctx MD5 context * \param output MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx, unsigned char output[16] ); /** * \brief MD5 process data block (internal use only) * * \param ctx MD5 context * \param data buffer holding one block of data * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief MD5 context setup * * \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0 * * \param ctx context to be initialized * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md5_starts( mbedtls_md5_context *ctx ); /** * \brief MD5 process buffer * * \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0 * * \param ctx MD5 context * \param input buffer holding the data * \param ilen length of the input data * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD5 final digest * * \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0 * * \param ctx MD5 context * \param output MD5 checksum result * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] ); /** * \brief MD5 process data block (internal use only) * * \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0 * * \param ctx MD5 context * \param data buffer holding one block of data * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Output = MD5( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md5_ret( const unsigned char *input, size_t ilen, unsigned char output[16] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Output = MD5( input buffer ) * * \deprecated Superseded by mbedtls_md5_ret() in 2.7.0 * * \param input buffer holding the data * \param ilen length of the input data * \param output MD5 checksum result * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md5_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_md5.h */
9,635
C++
.h
284
30.584507
106
0.63768
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,509
check_config.h
w1hkj_fldigi/src/include/mbedtls/check_config.h
/** * \file check_config.h * * \brief Consistency checks for configuration options */ /* * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ /* * It is recommended to include this file from your config.h * in order to catch dependency issues early. */ #ifndef MBEDTLS_CHECK_CONFIG_H #define MBEDTLS_CHECK_CONFIG_H /* * We assume CHAR_BIT is 8 in many places. In practice, this is true on our * target platforms, so not an issue, but let's just be extra sure. */ #include <limits.h> #if CHAR_BIT != 8 #error "mbed TLS requires a platform with 8-bit chars" #endif #if defined(_WIN32) #if !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_C is required on Windows" #endif /* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as * it would confuse config.pl. */ #if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \ !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) #define MBEDTLS_PLATFORM_SNPRINTF_ALT #endif #endif /* _WIN32 */ #if defined(TARGET_LIKE_MBED) && \ ( defined(MBEDTLS_NET_C) || defined(MBEDTLS_TIMING_C) ) #error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS" #endif #if defined(MBEDTLS_DEPRECATED_WARNING) && \ !defined(__GNUC__) && !defined(__clang__) #error "MBEDTLS_DEPRECATED_WARNING only works with GCC and Clang" #endif #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME) #error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense" #endif #if defined(MBEDTLS_AESNI_C) && !defined(MBEDTLS_HAVE_ASM) #error "MBEDTLS_AESNI_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C) #error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_DHM_C) && !defined(MBEDTLS_BIGNUM_C) #error "MBEDTLS_DHM_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) && !defined(MBEDTLS_SSL_TRUNCATED_HMAC) #error "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT defined, but not all prerequisites" #endif #if defined(MBEDTLS_CMAC_C) && \ !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C) #error "MBEDTLS_CMAC_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_NIST_KW_C) && \ ( !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CIPHER_C) ) #error "MBEDTLS_NIST_KW_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C) #error "MBEDTLS_ECDH_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECDSA_C) && \ ( !defined(MBEDTLS_ECP_C) || \ !defined(MBEDTLS_ASN1_PARSE_C) || \ !defined(MBEDTLS_ASN1_WRITE_C) ) #error "MBEDTLS_ECDSA_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECJPAKE_C) && \ ( !defined(MBEDTLS_ECP_C) || !defined(MBEDTLS_MD_C) ) #error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_RESTARTABLE) && \ ( defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \ defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) || \ defined(MBEDTLS_ECDSA_SIGN_ALT) || \ defined(MBEDTLS_ECDSA_VERIFY_ALT) || \ defined(MBEDTLS_ECDSA_GENKEY_ALT) || \ defined(MBEDTLS_ECP_INTERNAL_ALT) || \ defined(MBEDTLS_ECP_ALT) ) #error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative ECP implementation" #endif #if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C) #error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \ !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) ) #error "MBEDTLS_ECP_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C) #error "MBEDTLS_PK_PARSE_C defined, but not all prerequesites" #endif #if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \ !defined(MBEDTLS_SHA256_C)) #error "MBEDTLS_ENTROPY_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \ defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64) #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" #endif #if defined(MBEDTLS_ENTROPY_C) && \ ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \ && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32) #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" #endif #if defined(MBEDTLS_ENTROPY_C) && \ defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C) #error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites" #endif #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ ( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) ) #error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites" #endif #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ ( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \ defined(MBEDTLS_HAVEGE_C) ) #error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too" #endif #if defined(MBEDTLS_GCM_C) && ( \ !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) ) #error "MBEDTLS_GCM_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) #error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C) #error "MBEDTLS_HAVEGE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_HKDF_C) && !defined(MBEDTLS_MD_C) #error "MBEDTLS_HKDF_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C) #error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \ ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) #error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) #error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C) #error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \ !defined(MBEDTLS_ECDH_C) #error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \ !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) #error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \ !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) #error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDSA_C) || \ !defined(MBEDTLS_X509_CRT_PARSE_C) ) #error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ !defined(MBEDTLS_PKCS1_V15) ) #error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ !defined(MBEDTLS_PKCS1_V15) ) #error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \ ( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \ !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) ) #error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites" #endif #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM) #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C) #error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C) #error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PK_C) && \ ( !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) ) #error "MBEDTLS_PK_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C) #error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C) #error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PKCS11_C) && !defined(MBEDTLS_PK_C) #error "MBEDTLS_PKCS11_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\ defined(MBEDTLS_PLATFORM_EXIT_ALT) ) #error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\ ( !defined(MBEDTLS_PLATFORM_C) ||\ !defined(MBEDTLS_HAVE_TIME) ) #error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ ( !defined(MBEDTLS_PLATFORM_C) ||\ !defined(MBEDTLS_HAVE_TIME) ) #error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ ( !defined(MBEDTLS_PLATFORM_C) ||\ !defined(MBEDTLS_HAVE_TIME) ) #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ defined(MBEDTLS_PLATFORM_TIME_ALT) ) #error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ defined(MBEDTLS_PLATFORM_TIME_ALT) ) #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\ defined(MBEDTLS_PLATFORM_FPRINTF_ALT) ) #error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) #error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ defined(MBEDTLS_PLATFORM_STD_FREE) #error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO) #error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is" #endif #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) #error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ defined(MBEDTLS_PLATFORM_STD_CALLOC) #error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO) #error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is" #endif #if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\ defined(MBEDTLS_PLATFORM_PRINTF_ALT) ) #error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\ defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) ) #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\ !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) #error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY) #error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\ !defined(MBEDTLS_PLATFORM_EXIT_ALT) #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_TIME) &&\ ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\ !defined(MBEDTLS_HAVE_TIME) ) #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\ !defined(MBEDTLS_PLATFORM_FPRINTF_ALT) #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\ !defined(MBEDTLS_PLATFORM_PRINTF_ALT) #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\ !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites" #endif #if defined(MBEDTLS_ENTROPY_NV_SEED) &&\ ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) ) #error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\ !defined(MBEDTLS_ENTROPY_NV_SEED) #error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\ !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) #error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\ !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) #error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites" #endif #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\ defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) #error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously" #endif #if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\ ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\ defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) #error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously" #endif #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ !defined(MBEDTLS_OID_C) ) #error "MBEDTLS_RSA_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \ !defined(MBEDTLS_PKCS1_V15) ) #error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled" #endif #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \ ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) ) #error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_PROTO_SSL3) && ( !defined(MBEDTLS_MD5_C) || \ !defined(MBEDTLS_SHA1_C) ) #error "MBEDTLS_SSL_PROTO_SSL3 defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_PROTO_TLS1) && ( !defined(MBEDTLS_MD5_C) || \ !defined(MBEDTLS_SHA1_C) ) #error "MBEDTLS_SSL_PROTO_TLS1 defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_PROTO_TLS1_1) && ( !defined(MBEDTLS_MD5_C) || \ !defined(MBEDTLS_SHA1_C) ) #error "MBEDTLS_SSL_PROTO_TLS1_1 defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && ( !defined(MBEDTLS_SHA1_C) && \ !defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA512_C) ) #error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_PROTO_DTLS) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_2) #error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C) #error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \ !defined(MBEDTLS_MD_C) ) #error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C) #error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_TLS_C) && (!defined(MBEDTLS_SSL_PROTO_SSL3) && \ !defined(MBEDTLS_SSL_PROTO_TLS1) && !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_2)) #error "MBEDTLS_SSL_TLS_C defined, but no protocols are active" #endif #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ defined(MBEDTLS_SSL_PROTO_TLS1_1) && !defined(MBEDTLS_SSL_PROTO_TLS1)) #error "Illegal protocol selection" #endif #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_TLS1) && \ defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_SSL_PROTO_TLS1_1)) #error "Illegal protocol selection" #endif #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ defined(MBEDTLS_SSL_PROTO_TLS1_2) && (!defined(MBEDTLS_SSL_PROTO_TLS1) || \ !defined(MBEDTLS_SSL_PROTO_TLS1_1))) #error "Illegal protocol selection" #endif #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS) #error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \ !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) #error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \ ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) #error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \ ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) #error "MBEDTLS_SSL_DTLS_BADMAC_LIMIT defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \ !defined(MBEDTLS_SSL_PROTO_TLS1) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_2) #error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequsites" #endif #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \ !defined(MBEDTLS_SSL_PROTO_TLS1) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ !defined(MBEDTLS_SSL_PROTO_TLS1_2) #error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequsites" #endif #if defined(MBEDTLS_SSL_TICKET_C) && !defined(MBEDTLS_CIPHER_C) #error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) && \ !defined(MBEDTLS_SSL_PROTO_SSL3) && !defined(MBEDTLS_SSL_PROTO_TLS1) #error "MBEDTLS_SSL_CBC_RECORD_SPLITTING defined, but not all prerequisites" #endif #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \ !defined(MBEDTLS_X509_CRT_PARSE_C) #error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" #endif #if defined(MBEDTLS_THREADING_PTHREAD) #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) #error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites" #endif #define MBEDTLS_THREADING_IMPL #endif #if defined(MBEDTLS_THREADING_ALT) #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) #error "MBEDTLS_THREADING_ALT defined, but not all prerequisites" #endif #define MBEDTLS_THREADING_IMPL #endif #if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL) #error "MBEDTLS_THREADING_C defined, single threading implementation required" #endif #undef MBEDTLS_THREADING_IMPL #if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C) #error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \ !defined(MBEDTLS_PK_PARSE_C) ) #error "MBEDTLS_X509_USE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \ !defined(MBEDTLS_PK_WRITE_C) ) #error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) #error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) #error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) #error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) #error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) #error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites" #endif #if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64) #error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously" #endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */ #if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \ defined(MBEDTLS_HAVE_ASM) #error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously" #endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */ /* * Avoid warning from -pedantic. This is a convenient place for this * workaround since this is included by every single file before the * #if defined(MBEDTLS_xxx_C) that results in emtpy translation units. */ typedef int mbedtls_iso_c_forbids_empty_translation_units; #endif /* MBEDTLS_CHECK_CONFIG_H */
27,616
C++
.h
569
46.188049
137
0.730458
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,510
hmac_drbg.h
w1hkj_fldigi/src/include/mbedtls/hmac_drbg.h
/** * \file hmac_drbg.h * * \brief HMAC_DRBG (NIST SP 800-90A) */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_HMAC_DRBG_H #define MBEDTLS_HMAC_DRBG_H #include "md.h" #if defined(MBEDTLS_THREADING_C) #include "threading.h" #endif /* * Error codes */ #define MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -0x0003 /**< Too many random requested in single call. */ #define MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG -0x0005 /**< Input too large (Entropy + additional). */ #define MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR -0x0007 /**< Read/write error in file. */ #define MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED -0x0009 /**< The entropy source failed. */ /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h or define them on the compiler command line. * \{ */ #if !defined(MBEDTLS_HMAC_DRBG_RESEED_INTERVAL) #define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ #endif #if !defined(MBEDTLS_HMAC_DRBG_MAX_INPUT) #define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ #endif #if !defined(MBEDTLS_HMAC_DRBG_MAX_REQUEST) #define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ #endif #if !defined(MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT) #define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ #endif /* \} name SECTION: Module settings */ #define MBEDTLS_HMAC_DRBG_PR_OFF 0 /**< No prediction resistance */ #define MBEDTLS_HMAC_DRBG_PR_ON 1 /**< Prediction resistance enabled */ #ifdef __cplusplus extern "C" { #endif /** * HMAC_DRBG context. */ typedef struct mbedtls_hmac_drbg_context { /* Working state: the key K is not stored explicitely, * but is implied by the HMAC context */ mbedtls_md_context_t md_ctx; /*!< HMAC context (inc. K) */ unsigned char V[MBEDTLS_MD_MAX_SIZE]; /*!< V in the spec */ int reseed_counter; /*!< reseed counter */ /* Administrative state */ size_t entropy_len; /*!< entropy bytes grabbed on each (re)seed */ int prediction_resistance; /*!< enable prediction resistance (Automatic reseed before every random generation) */ int reseed_interval; /*!< reseed interval */ /* Callbacks */ int (*f_entropy)(void *, unsigned char *, size_t); /*!< entropy function */ void *p_entropy; /*!< context for the entropy function */ #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; #endif } mbedtls_hmac_drbg_context; /** * \brief HMAC_DRBG context initialization * Makes the context ready for mbedtls_hmac_drbg_seed(), * mbedtls_hmac_drbg_seed_buf() or * mbedtls_hmac_drbg_free(). * * \param ctx HMAC_DRBG context to be initialized */ void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx ); /** * \brief HMAC_DRBG initial seeding * Seed and setup entropy source for future reseeds. * * \param ctx HMAC_DRBG context to be seeded * \param md_info MD algorithm to use for HMAC_DRBG * \param f_entropy Entropy callback (p_entropy, buffer to fill, buffer * length) * \param p_entropy Entropy context * \param custom Personalization data (Device specific identifiers) * (Can be NULL) * \param len Length of personalization data * * \note The "security strength" as defined by NIST is set to: * 128 bits if md_alg is SHA-1, * 192 bits if md_alg is SHA-224, * 256 bits if md_alg is SHA-256 or higher. * Note that SHA-256 is just as efficient as SHA-224. * * \return 0 if successful, or * MBEDTLS_ERR_MD_BAD_INPUT_DATA, or * MBEDTLS_ERR_MD_ALLOC_FAILED, or * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED. */ int mbedtls_hmac_drbg_seed( mbedtls_hmac_drbg_context *ctx, const mbedtls_md_info_t * md_info, int (*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len ); /** * \brief Initilisation of simpified HMAC_DRBG (never reseeds). * (For use with deterministic ECDSA.) * * \param ctx HMAC_DRBG context to be initialised * \param md_info MD algorithm to use for HMAC_DRBG * \param data Concatenation of entropy string and additional data * \param data_len Length of data in bytes * * \return 0 if successful, or * MBEDTLS_ERR_MD_BAD_INPUT_DATA, or * MBEDTLS_ERR_MD_ALLOC_FAILED. */ int mbedtls_hmac_drbg_seed_buf( mbedtls_hmac_drbg_context *ctx, const mbedtls_md_info_t * md_info, const unsigned char *data, size_t data_len ); /** * \brief Enable / disable prediction resistance (Default: Off) * * Note: If enabled, entropy is used for ctx->entropy_len before each call! * Only use this if you have ample supply of good entropy! * * \param ctx HMAC_DRBG context * \param resistance MBEDTLS_HMAC_DRBG_PR_ON or MBEDTLS_HMAC_DRBG_PR_OFF */ void mbedtls_hmac_drbg_set_prediction_resistance( mbedtls_hmac_drbg_context *ctx, int resistance ); /** * \brief Set the amount of entropy grabbed on each reseed * (Default: given by the security strength, which * depends on the hash used, see \c mbedtls_hmac_drbg_init() ) * * \param ctx HMAC_DRBG context * \param len Amount of entropy to grab, in bytes */ void mbedtls_hmac_drbg_set_entropy_len( mbedtls_hmac_drbg_context *ctx, size_t len ); /** * \brief Set the reseed interval * (Default: MBEDTLS_HMAC_DRBG_RESEED_INTERVAL) * * \param ctx HMAC_DRBG context * \param interval Reseed interval */ void mbedtls_hmac_drbg_set_reseed_interval( mbedtls_hmac_drbg_context *ctx, int interval ); /** * \brief HMAC_DRBG update state * * \param ctx HMAC_DRBG context * \param additional Additional data to update state with, or NULL * \param add_len Length of additional data, or 0 * * \return \c 0 on success, or an error from the underlying * hash calculation. * * \note Additional data is optional, pass NULL and 0 as second * third argument if no additional data is being used. */ int mbedtls_hmac_drbg_update_ret( mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t add_len ); /** * \brief HMAC_DRBG reseeding (extracts data from entropy source) * * \param ctx HMAC_DRBG context * \param additional Additional data to add to state (Can be NULL) * \param len Length of additional data * * \return 0 if successful, or * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED */ int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t len ); /** * \brief HMAC_DRBG generate random with additional update input * * Note: Automatically reseeds if reseed_counter is reached or PR is enabled. * * \param p_rng HMAC_DRBG context * \param output Buffer to fill * \param output_len Length of the buffer * \param additional Additional data to update with (can be NULL) * \param add_len Length of additional data (can be 0) * * \return 0 if successful, or * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED, or * MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG, or * MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG. */ int mbedtls_hmac_drbg_random_with_add( void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len ); /** * \brief HMAC_DRBG generate random * * Note: Automatically reseeds if reseed_counter is reached or PR is enabled. * * \param p_rng HMAC_DRBG context * \param output Buffer to fill * \param out_len Length of the buffer * * \return 0 if successful, or * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED, or * MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG */ int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len ); /** * \brief Free an HMAC_DRBG context * * \param ctx HMAC_DRBG context to free. */ void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx ); #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief HMAC_DRBG update state * * \deprecated Superseded by mbedtls_hmac_drbg_update_ret() * in 2.16.0. * * \param ctx HMAC_DRBG context * \param additional Additional data to update state with, or NULL * \param add_len Length of additional data, or 0 * * \note Additional data is optional, pass NULL and 0 as second * third argument if no additional data is being used. */ MBEDTLS_DEPRECATED void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t add_len ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ #if defined(MBEDTLS_FS_IO) /** * \brief Write a seed file * * \param ctx HMAC_DRBG context * \param path Name of the file * * \return 0 if successful, 1 on file error, or * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED */ int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ); /** * \brief Read and update a seed file. Seed is added to this * instance * * \param ctx HMAC_DRBG context * \param path Name of the file * * \return 0 if successful, 1 on file error, * MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED or * MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG */ int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ); #endif /* MBEDTLS_FS_IO */ #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_hmac_drbg_self_test( int verbose ); #endif #ifdef __cplusplus } #endif #endif /* hmac_drbg.h */
12,299
C++
.h
297
38.023569
117
0.612917
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,511
ripemd160.h
w1hkj_fldigi/src/include/mbedtls/ripemd160.h
/** * \file ripemd160.h * * \brief RIPE MD-160 message digest */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_RIPEMD160_H #define MBEDTLS_RIPEMD160_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED -0x0031 /**< RIPEMD160 hardware accelerator failed */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_RIPEMD160_ALT) // Regular implementation // /** * \brief RIPEMD-160 context structure */ typedef struct mbedtls_ripemd160_context { uint32_t total[2]; /*!< number of bytes processed */ uint32_t state[5]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ } mbedtls_ripemd160_context; #else /* MBEDTLS_RIPEMD160_ALT */ #include "ripemd160.h" #endif /* MBEDTLS_RIPEMD160_ALT */ /** * \brief Initialize RIPEMD-160 context * * \param ctx RIPEMD-160 context to be initialized */ void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx ); /** * \brief Clear RIPEMD-160 context * * \param ctx RIPEMD-160 context to be cleared */ void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx ); /** * \brief Clone (the state of) an RIPEMD-160 context * * \param dst The destination context * \param src The context to be cloned */ void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst, const mbedtls_ripemd160_context *src ); /** * \brief RIPEMD-160 context setup * * \param ctx context to be initialized * * \return 0 if successful */ int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx ); /** * \brief RIPEMD-160 process buffer * * \param ctx RIPEMD-160 context * \param input buffer holding the data * \param ilen length of the input data * * \return 0 if successful */ int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief RIPEMD-160 final digest * * \param ctx RIPEMD-160 context * \param output RIPEMD-160 checksum result * * \return 0 if successful */ int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx, unsigned char output[20] ); /** * \brief RIPEMD-160 process data block (internal use only) * * \param ctx RIPEMD-160 context * \param data buffer holding one block of data * * \return 0 if successful */ int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief RIPEMD-160 context setup * * \deprecated Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0 * * \param ctx context to be initialized */ MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx ); /** * \brief RIPEMD-160 process buffer * * \deprecated Superseded by mbedtls_ripemd160_update_ret() in 2.7.0 * * \param ctx RIPEMD-160 context * \param input buffer holding the data * \param ilen length of the input data */ MBEDTLS_DEPRECATED void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief RIPEMD-160 final digest * * \deprecated Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0 * * \param ctx RIPEMD-160 context * \param output RIPEMD-160 checksum result */ MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] ); /** * \brief RIPEMD-160 process data block (internal use only) * * \deprecated Superseded by mbedtls_internal_ripemd160_process() in 2.7.0 * * \param ctx RIPEMD-160 context * \param data buffer holding one block of data */ MBEDTLS_DEPRECATED void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Output = RIPEMD-160( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output RIPEMD-160 checksum result * * \return 0 if successful */ int mbedtls_ripemd160_ret( const unsigned char *input, size_t ilen, unsigned char output[20] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Output = RIPEMD-160( input buffer ) * * \deprecated Superseded by mbedtls_ripemd160_ret() in 2.7.0 * * \param input buffer holding the data * \param ilen length of the input data * \param output RIPEMD-160 checksum result */ MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input, size_t ilen, unsigned char output[20] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_ripemd160_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_ripemd160.h */
7,067
C++
.h
210
28.7
112
0.638905
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,512
aria.h
w1hkj_fldigi/src/include/mbedtls/aria.h
/** * \file aria.h * * \brief ARIA block cipher * * The ARIA algorithm is a symmetric block cipher that can encrypt and * decrypt information. It is defined by the Korean Agency for * Technology and Standards (KATS) in <em>KS X 1213:2004</em> (in * Korean, but see http://210.104.33.10/ARIA/index-e.html in English) * and also described by the IETF in <em>RFC 5794</em>. */ /* Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ARIA_H #define MBEDTLS_ARIA_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> #include "platform_util.h" #define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */ #define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */ #define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */ #define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maxiumum number of rounds in ARIA. */ #define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */ #if !defined(MBEDTLS_DEPRECATED_REMOVED) #define MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x005C ) #endif /* !MBEDTLS_DEPRECATED_REMOVED */ #define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C /**< Bad input data. */ #define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */ /* MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE is deprecated and should not be used. */ #define MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE -0x005A /**< Feature not available. For example, an unsupported ARIA key size. */ /* MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED -0x0058 /**< ARIA hardware accelerator failed. */ #if !defined(MBEDTLS_ARIA_ALT) // Regular implementation // #ifdef __cplusplus extern "C" { #endif /** * \brief The ARIA context-type definition. */ typedef struct mbedtls_aria_context { unsigned char nr; /*!< The number of rounds (12, 14 or 16) */ /*! The ARIA round keys. */ uint32_t rk[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4]; } mbedtls_aria_context; #else /* MBEDTLS_ARIA_ALT */ #include "aria_alt.h" #endif /* MBEDTLS_ARIA_ALT */ /** * \brief This function initializes the specified ARIA context. * * It must be the first API called before using * the context. * * \param ctx The ARIA context to initialize. This must not be \c NULL. */ void mbedtls_aria_init( mbedtls_aria_context *ctx ); /** * \brief This function releases and clears the specified ARIA context. * * \param ctx The ARIA context to clear. This may be \c NULL, in which * case this function returns immediately. If it is not \c NULL, * it must point to an initialized ARIA context. */ void mbedtls_aria_free( mbedtls_aria_context *ctx ); /** * \brief This function sets the encryption key. * * \param ctx The ARIA context to which the key should be bound. * This must be initialized. * \param key The encryption key. This must be a readable buffer * of size \p keybits Bits. * \param keybits The size of \p key in Bits. Valid options are: * <ul><li>128 bits</li> * <li>192 bits</li> * <li>256 bits</li></ul> * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief This function sets the decryption key. * * \param ctx The ARIA context to which the key should be bound. * This must be initialized. * \param key The decryption key. This must be a readable buffer * of size \p keybits Bits. * \param keybits The size of data passed. Valid options are: * <ul><li>128 bits</li> * <li>192 bits</li> * <li>256 bits</li></ul> * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief This function performs an ARIA single-block encryption or * decryption operation. * * It performs encryption or decryption (depending on whether * the key was set for encryption on decryption) on the input * data buffer defined in the \p input parameter. * * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or * mbedtls_aria_setkey_dec() must be called before the first * call to this API with the same context. * * \param ctx The ARIA context to use for encryption or decryption. * This must be initialized and bound to a key. * \param input The 16-Byte buffer holding the input data. * \param output The 16-Byte buffer holding the output data. * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief This function performs an ARIA-CBC encryption or decryption operation * on full blocks. * * It performs the operation defined in the \p mode * parameter (encrypt/decrypt), on the input data buffer defined in * the \p input parameter. * * It can be called as many times as needed, until all the input * data is processed. mbedtls_aria_init(), and either * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called * before the first call to this API with the same context. * * \note This function operates on aligned blocks, that is, the input size * must be a multiple of the ARIA block size of 16 Bytes. * * \note Upon exit, the content of the IV is updated so that you can * call the same function again on the next * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If you need to retain the contents of the IV, you should * either save it manually or use the cipher module instead. * * * \param ctx The ARIA context to use for encryption or decryption. * This must be initialized and bound to a key. * \param mode The mode of operation. This must be either * #MBEDTLS_ARIA_ENCRYPT for encryption, or * #MBEDTLS_ARIA_DECRYPT for decryption. * \param length The length of the input data in Bytes. This must be a * multiple of the block size (16 Bytes). * \param iv Initialization vector (updated after use). * This must be a readable buffer of size 16 Bytes. * \param input The buffer holding the input data. This must * be a readable buffer of length \p length Bytes. * \param output The buffer holding the output data. This must * be a writable buffer of length \p length Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CIPHER_MODE_CFB) /** * \brief This function performs an ARIA-CFB128 encryption or decryption * operation. * * It performs the operation defined in the \p mode * parameter (encrypt or decrypt), on the input data buffer * defined in the \p input parameter. * * For CFB, you must set up the context with mbedtls_aria_setkey_enc(), * regardless of whether you are performing an encryption or decryption * operation, that is, regardless of the \p mode parameter. This is * because CFB mode uses the same key schedule for encryption and * decryption. * * \note Upon exit, the content of the IV is updated so that you can * call the same function again on the next * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If you need to retain the contents of the * IV, you must either save it manually or use the cipher * module instead. * * * \param ctx The ARIA context to use for encryption or decryption. * This must be initialized and bound to a key. * \param mode The mode of operation. This must be either * #MBEDTLS_ARIA_ENCRYPT for encryption, or * #MBEDTLS_ARIA_DECRYPT for decryption. * \param length The length of the input data \p input in Bytes. * \param iv_off The offset in IV (updated after use). * This must not be larger than 15. * \param iv The initialization vector (updated after use). * This must be a readable buffer of size 16 Bytes. * \param input The buffer holding the input data. This must * be a readable buffer of length \p length Bytes. * \param output The buffer holding the output data. This must * be a writable buffer of length \p length Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CFB */ #if defined(MBEDTLS_CIPHER_MODE_CTR) /** * \brief This function performs an ARIA-CTR encryption or decryption * operation. * * This function performs the operation defined in the \p mode * parameter (encrypt/decrypt), on the input data buffer * defined in the \p input parameter. * * Due to the nature of CTR, you must use the same key schedule * for both encryption and decryption operations. Therefore, you * must use the context initialized with mbedtls_aria_setkey_enc() * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT. * * \warning You must never reuse a nonce value with the same key. Doing so * would void the encryption for the two messages encrypted with * the same nonce and key. * * There are two common strategies for managing nonces with CTR: * * 1. You can handle everything as a single message processed over * successive calls to this function. In that case, you want to * set \p nonce_counter and \p nc_off to 0 for the first call, and * then preserve the values of \p nonce_counter, \p nc_off and \p * stream_block across calls to this function as they will be * updated by this function. * * With this strategy, you must not encrypt more than 2**128 * blocks of data with the same key. * * 2. You can encrypt separate messages by dividing the \p * nonce_counter buffer in two areas: the first one used for a * per-message nonce, handled by yourself, and the second one * updated by this function internally. * * For example, you might reserve the first 12 bytes for the * per-message nonce, and the last 4 bytes for internal use. In that * case, before calling this function on a new message you need to * set the first 12 bytes of \p nonce_counter to your chosen nonce * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p * stream_block to be ignored). That way, you can encrypt at most * 2**96 messages of up to 2**32 blocks each with the same key. * * The per-message nonce (or information sufficient to reconstruct * it) needs to be communicated with the ciphertext and must be unique. * The recommended way to ensure uniqueness is to use a message * counter. An alternative is to generate random nonces, but this * limits the number of messages that can be securely encrypted: * for example, with 96-bit random nonces, you should not encrypt * more than 2**32 messages with the same key. * * Note that for both stategies, sizes are measured in blocks and * that an ARIA block is 16 bytes. * * \warning Upon return, \p stream_block contains sensitive data. Its * content must not be written to insecure storage and should be * securely discarded as soon as it's no longer needed. * * \param ctx The ARIA context to use for encryption or decryption. * This must be initialized and bound to a key. * \param length The length of the input data \p input in Bytes. * \param nc_off The offset in Bytes in the current \p stream_block, * for resuming within the current cipher stream. The * offset pointer should be \c 0 at the start of a * stream. This must not be larger than \c 15 Bytes. * \param nonce_counter The 128-bit nonce and counter. This must point to * a read/write buffer of length \c 16 bytes. * \param stream_block The saved stream block for resuming. This must * point to a read/write buffer of length \c 16 bytes. * This is overwritten by the function. * \param input The buffer holding the input data. This must * be a readable buffer of length \p length Bytes. * \param output The buffer holding the output data. This must * be a writable buffer of length \p length Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE], unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine. * * \return \c 0 on success, or \c 1 on failure. */ int mbedtls_aria_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif #endif /* aria.h */
16,479
C++
.h
346
43.869942
128
0.625567
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,513
cipher.h
w1hkj_fldigi/src/include/mbedtls/cipher.h
/** * \file cipher.h * * \brief This file contains an abstraction interface for use with the cipher * primitives provided by the library. It provides a common interface to all of * the available cipher operations. * * \author Adriaan de Jong <dejong@fox-it.com> */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CIPHER_H #define MBEDTLS_CIPHER_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include "mbedtls/platform_util.h" #if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) || defined(MBEDTLS_CHACHAPOLY_C) #define MBEDTLS_CIPHER_MODE_AEAD #endif #if defined(MBEDTLS_CIPHER_MODE_CBC) #define MBEDTLS_CIPHER_MODE_WITH_PADDING #endif #if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \ defined(MBEDTLS_CHACHA20_C) #define MBEDTLS_CIPHER_MODE_STREAM #endif #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline #endif #define MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */ #define MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA -0x6100 /**< Bad input parameters. */ #define MBEDTLS_ERR_CIPHER_ALLOC_FAILED -0x6180 /**< Failed to allocate memory. */ #define MBEDTLS_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */ #define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */ #define MBEDTLS_ERR_CIPHER_AUTH_FAILED -0x6300 /**< Authentication failed (for AEAD modes). */ #define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT -0x6380 /**< The context is invalid. For example, because it was freed. */ /* MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED -0x6400 /**< Cipher hardware accelerator failed. */ #define MBEDTLS_CIPHER_VARIABLE_IV_LEN 0x01 /**< Cipher accepts IVs of variable length. */ #define MBEDTLS_CIPHER_VARIABLE_KEY_LEN 0x02 /**< Cipher accepts keys of variable length. */ #ifdef __cplusplus extern "C" { #endif /** * \brief Supported cipher types. * * \warning RC4 and DES are considered weak ciphers and their use * constitutes a security risk. Arm recommends considering stronger * ciphers instead. */ typedef enum { MBEDTLS_CIPHER_ID_NONE = 0, /**< Placeholder to mark the end of cipher ID lists. */ MBEDTLS_CIPHER_ID_NULL, /**< The identity cipher, treated as a stream cipher. */ MBEDTLS_CIPHER_ID_AES, /**< The AES cipher. */ MBEDTLS_CIPHER_ID_DES, /**< The DES cipher. */ MBEDTLS_CIPHER_ID_3DES, /**< The Triple DES cipher. */ MBEDTLS_CIPHER_ID_CAMELLIA, /**< The Camellia cipher. */ MBEDTLS_CIPHER_ID_BLOWFISH, /**< The Blowfish cipher. */ MBEDTLS_CIPHER_ID_ARC4, /**< The RC4 cipher. */ MBEDTLS_CIPHER_ID_ARIA, /**< The Aria cipher. */ MBEDTLS_CIPHER_ID_CHACHA20, /**< The ChaCha20 cipher. */ } mbedtls_cipher_id_t; /** * \brief Supported {cipher type, cipher mode} pairs. * * \warning RC4 and DES are considered weak ciphers and their use * constitutes a security risk. Arm recommends considering stronger * ciphers instead. */ typedef enum { MBEDTLS_CIPHER_NONE = 0, /**< Placeholder to mark the end of cipher-pair lists. */ MBEDTLS_CIPHER_NULL, /**< The identity stream cipher. */ MBEDTLS_CIPHER_AES_128_ECB, /**< AES cipher with 128-bit ECB mode. */ MBEDTLS_CIPHER_AES_192_ECB, /**< AES cipher with 192-bit ECB mode. */ MBEDTLS_CIPHER_AES_256_ECB, /**< AES cipher with 256-bit ECB mode. */ MBEDTLS_CIPHER_AES_128_CBC, /**< AES cipher with 128-bit CBC mode. */ MBEDTLS_CIPHER_AES_192_CBC, /**< AES cipher with 192-bit CBC mode. */ MBEDTLS_CIPHER_AES_256_CBC, /**< AES cipher with 256-bit CBC mode. */ MBEDTLS_CIPHER_AES_128_CFB128, /**< AES cipher with 128-bit CFB128 mode. */ MBEDTLS_CIPHER_AES_192_CFB128, /**< AES cipher with 192-bit CFB128 mode. */ MBEDTLS_CIPHER_AES_256_CFB128, /**< AES cipher with 256-bit CFB128 mode. */ MBEDTLS_CIPHER_AES_128_CTR, /**< AES cipher with 128-bit CTR mode. */ MBEDTLS_CIPHER_AES_192_CTR, /**< AES cipher with 192-bit CTR mode. */ MBEDTLS_CIPHER_AES_256_CTR, /**< AES cipher with 256-bit CTR mode. */ MBEDTLS_CIPHER_AES_128_GCM, /**< AES cipher with 128-bit GCM mode. */ MBEDTLS_CIPHER_AES_192_GCM, /**< AES cipher with 192-bit GCM mode. */ MBEDTLS_CIPHER_AES_256_GCM, /**< AES cipher with 256-bit GCM mode. */ MBEDTLS_CIPHER_CAMELLIA_128_ECB, /**< Camellia cipher with 128-bit ECB mode. */ MBEDTLS_CIPHER_CAMELLIA_192_ECB, /**< Camellia cipher with 192-bit ECB mode. */ MBEDTLS_CIPHER_CAMELLIA_256_ECB, /**< Camellia cipher with 256-bit ECB mode. */ MBEDTLS_CIPHER_CAMELLIA_128_CBC, /**< Camellia cipher with 128-bit CBC mode. */ MBEDTLS_CIPHER_CAMELLIA_192_CBC, /**< Camellia cipher with 192-bit CBC mode. */ MBEDTLS_CIPHER_CAMELLIA_256_CBC, /**< Camellia cipher with 256-bit CBC mode. */ MBEDTLS_CIPHER_CAMELLIA_128_CFB128, /**< Camellia cipher with 128-bit CFB128 mode. */ MBEDTLS_CIPHER_CAMELLIA_192_CFB128, /**< Camellia cipher with 192-bit CFB128 mode. */ MBEDTLS_CIPHER_CAMELLIA_256_CFB128, /**< Camellia cipher with 256-bit CFB128 mode. */ MBEDTLS_CIPHER_CAMELLIA_128_CTR, /**< Camellia cipher with 128-bit CTR mode. */ MBEDTLS_CIPHER_CAMELLIA_192_CTR, /**< Camellia cipher with 192-bit CTR mode. */ MBEDTLS_CIPHER_CAMELLIA_256_CTR, /**< Camellia cipher with 256-bit CTR mode. */ MBEDTLS_CIPHER_CAMELLIA_128_GCM, /**< Camellia cipher with 128-bit GCM mode. */ MBEDTLS_CIPHER_CAMELLIA_192_GCM, /**< Camellia cipher with 192-bit GCM mode. */ MBEDTLS_CIPHER_CAMELLIA_256_GCM, /**< Camellia cipher with 256-bit GCM mode. */ MBEDTLS_CIPHER_DES_ECB, /**< DES cipher with ECB mode. */ MBEDTLS_CIPHER_DES_CBC, /**< DES cipher with CBC mode. */ MBEDTLS_CIPHER_DES_EDE_ECB, /**< DES cipher with EDE ECB mode. */ MBEDTLS_CIPHER_DES_EDE_CBC, /**< DES cipher with EDE CBC mode. */ MBEDTLS_CIPHER_DES_EDE3_ECB, /**< DES cipher with EDE3 ECB mode. */ MBEDTLS_CIPHER_DES_EDE3_CBC, /**< DES cipher with EDE3 CBC mode. */ MBEDTLS_CIPHER_BLOWFISH_ECB, /**< Blowfish cipher with ECB mode. */ MBEDTLS_CIPHER_BLOWFISH_CBC, /**< Blowfish cipher with CBC mode. */ MBEDTLS_CIPHER_BLOWFISH_CFB64, /**< Blowfish cipher with CFB64 mode. */ MBEDTLS_CIPHER_BLOWFISH_CTR, /**< Blowfish cipher with CTR mode. */ MBEDTLS_CIPHER_ARC4_128, /**< RC4 cipher with 128-bit mode. */ MBEDTLS_CIPHER_AES_128_CCM, /**< AES cipher with 128-bit CCM mode. */ MBEDTLS_CIPHER_AES_192_CCM, /**< AES cipher with 192-bit CCM mode. */ MBEDTLS_CIPHER_AES_256_CCM, /**< AES cipher with 256-bit CCM mode. */ MBEDTLS_CIPHER_CAMELLIA_128_CCM, /**< Camellia cipher with 128-bit CCM mode. */ MBEDTLS_CIPHER_CAMELLIA_192_CCM, /**< Camellia cipher with 192-bit CCM mode. */ MBEDTLS_CIPHER_CAMELLIA_256_CCM, /**< Camellia cipher with 256-bit CCM mode. */ MBEDTLS_CIPHER_ARIA_128_ECB, /**< Aria cipher with 128-bit key and ECB mode. */ MBEDTLS_CIPHER_ARIA_192_ECB, /**< Aria cipher with 192-bit key and ECB mode. */ MBEDTLS_CIPHER_ARIA_256_ECB, /**< Aria cipher with 256-bit key and ECB mode. */ MBEDTLS_CIPHER_ARIA_128_CBC, /**< Aria cipher with 128-bit key and CBC mode. */ MBEDTLS_CIPHER_ARIA_192_CBC, /**< Aria cipher with 192-bit key and CBC mode. */ MBEDTLS_CIPHER_ARIA_256_CBC, /**< Aria cipher with 256-bit key and CBC mode. */ MBEDTLS_CIPHER_ARIA_128_CFB128, /**< Aria cipher with 128-bit key and CFB-128 mode. */ MBEDTLS_CIPHER_ARIA_192_CFB128, /**< Aria cipher with 192-bit key and CFB-128 mode. */ MBEDTLS_CIPHER_ARIA_256_CFB128, /**< Aria cipher with 256-bit key and CFB-128 mode. */ MBEDTLS_CIPHER_ARIA_128_CTR, /**< Aria cipher with 128-bit key and CTR mode. */ MBEDTLS_CIPHER_ARIA_192_CTR, /**< Aria cipher with 192-bit key and CTR mode. */ MBEDTLS_CIPHER_ARIA_256_CTR, /**< Aria cipher with 256-bit key and CTR mode. */ MBEDTLS_CIPHER_ARIA_128_GCM, /**< Aria cipher with 128-bit key and GCM mode. */ MBEDTLS_CIPHER_ARIA_192_GCM, /**< Aria cipher with 192-bit key and GCM mode. */ MBEDTLS_CIPHER_ARIA_256_GCM, /**< Aria cipher with 256-bit key and GCM mode. */ MBEDTLS_CIPHER_ARIA_128_CCM, /**< Aria cipher with 128-bit key and CCM mode. */ MBEDTLS_CIPHER_ARIA_192_CCM, /**< Aria cipher with 192-bit key and CCM mode. */ MBEDTLS_CIPHER_ARIA_256_CCM, /**< Aria cipher with 256-bit key and CCM mode. */ MBEDTLS_CIPHER_AES_128_OFB, /**< AES 128-bit cipher in OFB mode. */ MBEDTLS_CIPHER_AES_192_OFB, /**< AES 192-bit cipher in OFB mode. */ MBEDTLS_CIPHER_AES_256_OFB, /**< AES 256-bit cipher in OFB mode. */ MBEDTLS_CIPHER_AES_128_XTS, /**< AES 128-bit cipher in XTS block mode. */ MBEDTLS_CIPHER_AES_256_XTS, /**< AES 256-bit cipher in XTS block mode. */ MBEDTLS_CIPHER_CHACHA20, /**< ChaCha20 stream cipher. */ MBEDTLS_CIPHER_CHACHA20_POLY1305, /**< ChaCha20-Poly1305 AEAD cipher. */ } mbedtls_cipher_type_t; /** Supported cipher modes. */ typedef enum { MBEDTLS_MODE_NONE = 0, /**< None. */ MBEDTLS_MODE_ECB, /**< The ECB cipher mode. */ MBEDTLS_MODE_CBC, /**< The CBC cipher mode. */ MBEDTLS_MODE_CFB, /**< The CFB cipher mode. */ MBEDTLS_MODE_OFB, /**< The OFB cipher mode. */ MBEDTLS_MODE_CTR, /**< The CTR cipher mode. */ MBEDTLS_MODE_GCM, /**< The GCM cipher mode. */ MBEDTLS_MODE_STREAM, /**< The stream cipher mode. */ MBEDTLS_MODE_CCM, /**< The CCM cipher mode. */ MBEDTLS_MODE_XTS, /**< The XTS cipher mode. */ MBEDTLS_MODE_CHACHAPOLY, /**< The ChaCha-Poly cipher mode. */ } mbedtls_cipher_mode_t; /** Supported cipher padding types. */ typedef enum { MBEDTLS_PADDING_PKCS7 = 0, /**< PKCS7 padding (default). */ MBEDTLS_PADDING_ONE_AND_ZEROS, /**< ISO/IEC 7816-4 padding. */ MBEDTLS_PADDING_ZEROS_AND_LEN, /**< ANSI X.923 padding. */ MBEDTLS_PADDING_ZEROS, /**< Zero padding (not reversible). */ MBEDTLS_PADDING_NONE, /**< Never pad (full blocks only). */ } mbedtls_cipher_padding_t; /** Type of operation. */ typedef enum { MBEDTLS_OPERATION_NONE = -1, MBEDTLS_DECRYPT = 0, MBEDTLS_ENCRYPT, } mbedtls_operation_t; enum { /** Undefined key length. */ MBEDTLS_KEY_LENGTH_NONE = 0, /** Key length, in bits (including parity), for DES keys. */ MBEDTLS_KEY_LENGTH_DES = 64, /** Key length in bits, including parity, for DES in two-key EDE. */ MBEDTLS_KEY_LENGTH_DES_EDE = 128, /** Key length in bits, including parity, for DES in three-key EDE. */ MBEDTLS_KEY_LENGTH_DES_EDE3 = 192, }; /** Maximum length of any IV, in Bytes. */ #define MBEDTLS_MAX_IV_LENGTH 16 /** Maximum block size of any cipher, in Bytes. */ #define MBEDTLS_MAX_BLOCK_LENGTH 16 /** * Base cipher information (opaque struct). */ typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t; /** * CMAC context (opaque struct). */ typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t; /** * Cipher information. Allows calling cipher functions * in a generic way. */ typedef struct mbedtls_cipher_info_t { /** Full cipher identifier. For example, * MBEDTLS_CIPHER_AES_256_CBC. */ mbedtls_cipher_type_t type; /** The cipher mode. For example, MBEDTLS_MODE_CBC. */ mbedtls_cipher_mode_t mode; /** The cipher key length, in bits. This is the * default length for variable sized ciphers. * Includes parity bits for ciphers like DES. */ unsigned int key_bitlen; /** Name of the cipher. */ const char * name; /** IV or nonce size, in Bytes. * For ciphers that accept variable IV sizes, * this is the recommended size. */ unsigned int iv_size; /** Bitflag comprised of MBEDTLS_CIPHER_VARIABLE_IV_LEN and * MBEDTLS_CIPHER_VARIABLE_KEY_LEN indicating whether the * cipher supports variable IV or variable key sizes, respectively. */ int flags; /** The block size, in Bytes. */ unsigned int block_size; /** Struct for base cipher information and functions. */ const mbedtls_cipher_base_t *base; } mbedtls_cipher_info_t; /** * Generic cipher context. */ typedef struct mbedtls_cipher_context_t { /** Information about the associated cipher. */ const mbedtls_cipher_info_t *cipher_info; /** Key length to use. */ int key_bitlen; /** Operation that the key of the context has been * initialized for. */ mbedtls_operation_t operation; #if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) /** Padding functions to use, if relevant for * the specific cipher mode. */ void (*add_padding)( unsigned char *output, size_t olen, size_t data_len ); int (*get_padding)( unsigned char *input, size_t ilen, size_t *data_len ); #endif /** Buffer for input that has not been processed yet. */ unsigned char unprocessed_data[MBEDTLS_MAX_BLOCK_LENGTH]; /** Number of Bytes that have not been processed yet. */ size_t unprocessed_len; /** Current IV or NONCE_COUNTER for CTR-mode, data unit (or sector) number * for XTS-mode. */ unsigned char iv[MBEDTLS_MAX_IV_LENGTH]; /** IV size in Bytes, for ciphers with variable-length IVs. */ size_t iv_size; /** The cipher-specific context. */ void *cipher_ctx; #if defined(MBEDTLS_CMAC_C) /** CMAC-specific context. */ mbedtls_cmac_context_t *cmac_ctx; #endif } mbedtls_cipher_context_t; /** * \brief This function retrieves the list of ciphers supported by the generic * cipher module. * * \return A statically-allocated array of ciphers. The last entry * is zero. */ const int *mbedtls_cipher_list( void ); /** * \brief This function retrieves the cipher-information * structure associated with the given cipher name. * * \param cipher_name Name of the cipher to search for. This must not be * \c NULL. * * \return The cipher information structure associated with the * given \p cipher_name. * \return \c NULL if the associated cipher information is not found. */ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name ); /** * \brief This function retrieves the cipher-information * structure associated with the given cipher type. * * \param cipher_type Type of the cipher to search for. * * \return The cipher information structure associated with the * given \p cipher_type. * \return \c NULL if the associated cipher information is not found. */ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type ); /** * \brief This function retrieves the cipher-information * structure associated with the given cipher ID, * key size and mode. * * \param cipher_id The ID of the cipher to search for. For example, * #MBEDTLS_CIPHER_ID_AES. * \param key_bitlen The length of the key in bits. * \param mode The cipher mode. For example, #MBEDTLS_MODE_CBC. * * \return The cipher information structure associated with the * given \p cipher_id. * \return \c NULL if the associated cipher information is not found. */ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id, int key_bitlen, const mbedtls_cipher_mode_t mode ); /** * \brief This function initializes a \p cipher_context as NONE. * * \param ctx The context to be initialized. This must not be \c NULL. */ void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ); /** * \brief This function frees and clears the cipher-specific * context of \p ctx. Freeing \p ctx itself remains the * responsibility of the caller. * * \param ctx The context to be freed. If this is \c NULL, the * function has no effect, otherwise this must point to an * initialized context. */ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ); /** * \brief This function initializes and fills the cipher-context * structure with the appropriate values. It also clears * the structure. * * \param ctx The context to initialize. This must be initialized. * \param cipher_info The cipher to use. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return #MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the * cipher-specific context fails. * * \internal Currently, the function also clears the structure. * In future versions, the caller will be required to call * mbedtls_cipher_init() on the structure first. */ int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ); /** * \brief This function returns the block size of the given cipher. * * \param ctx The context of the cipher. This must be initialized. * * \return The block size of the underlying cipher. * \return \c 0 if \p ctx has not been initialized. */ static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, 0 ); if( ctx->cipher_info == NULL ) return 0; return ctx->cipher_info->block_size; } /** * \brief This function returns the mode of operation for * the cipher. For example, MBEDTLS_MODE_CBC. * * \param ctx The context of the cipher. This must be initialized. * * \return The mode of operation. * \return #MBEDTLS_MODE_NONE if \p ctx has not been initialized. */ static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, MBEDTLS_MODE_NONE ); if( ctx->cipher_info == NULL ) return MBEDTLS_MODE_NONE; return ctx->cipher_info->mode; } /** * \brief This function returns the size of the IV or nonce * of the cipher, in Bytes. * * \param ctx The context of the cipher. This must be initialized. * * \return The recommended IV size if no IV has been set. * \return \c 0 for ciphers not using an IV or a nonce. * \return The actual size if an IV has been set. */ static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, 0 ); if( ctx->cipher_info == NULL ) return 0; if( ctx->iv_size != 0 ) return (int) ctx->iv_size; return (int) ctx->cipher_info->iv_size; } /** * \brief This function returns the type of the given cipher. * * \param ctx The context of the cipher. This must be initialized. * * \return The type of the cipher. * \return #MBEDTLS_CIPHER_NONE if \p ctx has not been initialized. */ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, MBEDTLS_CIPHER_NONE ); if( ctx->cipher_info == NULL ) return MBEDTLS_CIPHER_NONE; return ctx->cipher_info->type; } /** * \brief This function returns the name of the given cipher * as a string. * * \param ctx The context of the cipher. This must be initialized. * * \return The name of the cipher. * \return NULL if \p ctx has not been not initialized. */ static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, 0 ); if( ctx->cipher_info == NULL ) return 0; return ctx->cipher_info->name; } /** * \brief This function returns the key length of the cipher. * * \param ctx The context of the cipher. This must be initialized. * * \return The key length of the cipher in bits. * \return #MBEDTLS_KEY_LENGTH_NONE if ctx \p has not been * initialized. */ static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, MBEDTLS_KEY_LENGTH_NONE ); if( ctx->cipher_info == NULL ) return MBEDTLS_KEY_LENGTH_NONE; return (int) ctx->cipher_info->key_bitlen; } /** * \brief This function returns the operation of the given cipher. * * \param ctx The context of the cipher. This must be initialized. * * \return The type of operation: #MBEDTLS_ENCRYPT or #MBEDTLS_DECRYPT. * \return #MBEDTLS_OPERATION_NONE if \p ctx has not been initialized. */ static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_cipher_context_t *ctx ) { MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, MBEDTLS_OPERATION_NONE ); if( ctx->cipher_info == NULL ) return MBEDTLS_OPERATION_NONE; return ctx->operation; } /** * \brief This function sets the key to use with the given context. * * \param ctx The generic cipher context. This must be initialized and * bound to a cipher information structure. * \param key The key to use. This must be a readable buffer of at * least \p key_bitlen Bits. * \param key_bitlen The key length to use, in Bits. * \param operation The operation that the key will be used for: * #MBEDTLS_ENCRYPT or #MBEDTLS_DECRYPT. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, int key_bitlen, const mbedtls_operation_t operation ); #if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) /** * \brief This function sets the padding mode, for cipher modes * that use padding. * * The default passing mode is PKCS7 padding. * * \param ctx The generic cipher context. This must be initialized and * bound to a cipher information structure. * \param mode The padding mode. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE * if the selected padding mode is not supported. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode * does not support padding. */ int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ); #endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ /** * \brief This function sets the initialization vector (IV) * or nonce. * * \note Some ciphers do not use IVs nor nonce. For these * ciphers, this function has no effect. * * \param ctx The generic cipher context. This must be initialized and * bound to a cipher information structure. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. This * must be a readable buffer of at least \p iv_len Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size IV. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. */ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len ); /** * \brief This function resets the cipher state. * * \param ctx The generic cipher context. This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. */ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ); #if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) /** * \brief This function adds additional data for AEAD ciphers. * Currently supported with GCM and ChaCha20+Poly1305. * This must be called exactly once, after * mbedtls_cipher_reset(). * * \param ctx The generic cipher context. This must be initialized. * \param ad The additional data to use. This must be a readable * buffer of at least \p ad_len Bytes. * \param ad_len the Length of \p ad Bytes. * * \return \c 0 on success. * \return A specific error code on failure. */ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, const unsigned char *ad, size_t ad_len ); #endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ /** * \brief The generic cipher update function. It encrypts or * decrypts using the given cipher context. Writes as * many block-sized blocks of data as possible to output. * Any data that cannot be written immediately is either * added to the next block, or flushed when * mbedtls_cipher_finish() is called. * Exception: For MBEDTLS_MODE_ECB, expects a single block * in size. For example, 16 Bytes for AES. * * \note If the underlying cipher is used in GCM mode, all calls * to this function, except for the last one before * mbedtls_cipher_finish(), must have \p ilen as a * multiple of the block size of the cipher. * * \param ctx The generic cipher context. This must be initialized and * bound to a key. * \param input The buffer holding the input data. This must be a * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data. * \param output The buffer for the output data. This must be able to * hold at least `ilen + block_size`. This must not be the * same buffer as \p input. * \param olen The length of the output data, to be updated with the * actual number of Bytes written. This must not be * \c NULL. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE on an * unsupported mode for a cipher. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ); /** * \brief The generic cipher finalization function. If data still * needs to be flushed from an incomplete block, the data * contained in it is padded to the size of * the last block, and written to the \p output buffer. * * \param ctx The generic cipher context. This must be initialized and * bound to a key. * \param output The buffer to write data to. This needs to be a writable * buffer of at least \p block_size Bytes. * \param olen The length of the data written to the \p output buffer. * This may not be \c NULL. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED on decryption * expecting a full block but not receiving one. * \return #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding * while decrypting. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen ); #if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) /** * \brief This function writes a tag for AEAD ciphers. * Currently supported with GCM and ChaCha20+Poly1305. * This must be called after mbedtls_cipher_finish(). * * \param ctx The generic cipher context. This must be initialized, * bound to a key, and have just completed a cipher * operation through mbedtls_cipher_finish() the tag for * which should be written. * \param tag The buffer to write the tag to. This must be a writable * buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to write. * * \return \c 0 on success. * \return A specific error code on failure. */ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, unsigned char *tag, size_t tag_len ); /** * \brief This function checks the tag for AEAD ciphers. * Currently supported with GCM and ChaCha20+Poly1305. * This must be called after mbedtls_cipher_finish(). * * \param ctx The generic cipher context. This must be initialized. * \param tag The buffer holding the tag. This must be a readable * buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to check. * * \return \c 0 on success. * \return A specific error code on failure. */ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, const unsigned char *tag, size_t tag_len ); #endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ /** * \brief The generic all-in-one encryption/decryption function, * for all ciphers except AEAD constructs. * * \param ctx The generic cipher context. This must be initialized. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. * This must be a readable buffer of at least \p iv_len * Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size * IV. * \param input The buffer holding the input data. This must be a * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data in Bytes. * \param output The buffer for the output data. This must be able to * hold at least `ilen + block_size`. This must not be the * same buffer as \p input. * \param olen The length of the output data, to be updated with the * actual number of Bytes written. This must not be * \c NULL. * * \note Some ciphers do not use IVs nor nonce. For these * ciphers, use \p iv = NULL and \p iv_len = 0. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED on decryption * expecting a full block but not receiving one. * \return #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding * while decrypting. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ); #if defined(MBEDTLS_CIPHER_MODE_AEAD) /** * \brief The generic autenticated encryption (AEAD) function. * * \param ctx The generic cipher context. This must be initialized and * bound to a key. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. * This must be a readable buffer of at least \p iv_len * Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size IV. * \param ad The additional data to authenticate. This must be a * readable buffer of at least \p ad_len Bytes. * \param ad_len The length of \p ad. * \param input The buffer holding the input data. This must be a * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data. * \param output The buffer for the output data. This must be able to * hold at least \p ilen Bytes. * \param olen The length of the output data, to be updated with the * actual number of Bytes written. This must not be * \c NULL. * \param tag The buffer for the authentication tag. This must be a * writable buffer of at least \p tag_len Bytes. * \param tag_len The desired length of the authentication tag. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, unsigned char *tag, size_t tag_len ); /** * \brief The generic autenticated decryption (AEAD) function. * * \note If the data is not authentic, then the output buffer * is zeroed out to prevent the unauthentic plaintext being * used, making this interface safer. * * \param ctx The generic cipher context. This must be initialized and * and bound to a key. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. * This must be a readable buffer of at least \p iv_len * Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size IV. * \param ad The additional data to be authenticated. This must be a * readable buffer of at least \p ad_len Bytes. * \param ad_len The length of \p ad. * \param input The buffer holding the input data. This must be a * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data. * \param output The buffer for the output data. * This must be able to hold at least \p ilen Bytes. * \param olen The length of the output data, to be updated with the * actual number of Bytes written. This must not be * \c NULL. * \param tag The buffer holding the authentication tag. This must be * a readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the authentication tag. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on * parameter-verification failure. * \return #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic. * \return A cipher-specific error code on failure. */ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, const unsigned char *tag, size_t tag_len ); #endif /* MBEDTLS_CIPHER_MODE_AEAD */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_CIPHER_H */
39,416
C++
.h
798
45.798246
123
0.611722
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,514
md4.h
w1hkj_fldigi/src/include/mbedtls/md4.h
/** * \file md4.h * * \brief MD4 message digest algorithm (hash function) * * \warning MD4 is considered a weak message digest and its use constitutes a * security risk. We recommend considering stronger message digests * instead. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) * */ #ifndef MBEDTLS_MD4_H #define MBEDTLS_MD4_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* MBEDTLS_ERR_MD4_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD4_HW_ACCEL_FAILED -0x002D /**< MD4 hardware accelerator failed */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_MD4_ALT) // Regular implementation // /** * \brief MD4 context structure * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ typedef struct mbedtls_md4_context { uint32_t total[2]; /*!< number of bytes processed */ uint32_t state[4]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ } mbedtls_md4_context; #else /* MBEDTLS_MD4_ALT */ #include "md4_alt.h" #endif /* MBEDTLS_MD4_ALT */ /** * \brief Initialize MD4 context * * \param ctx MD4 context to be initialized * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md4_init( mbedtls_md4_context *ctx ); /** * \brief Clear MD4 context * * \param ctx MD4 context to be cleared * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md4_free( mbedtls_md4_context *ctx ); /** * \brief Clone (the state of) an MD4 context * * \param dst The destination context * \param src The context to be cloned * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md4_clone( mbedtls_md4_context *dst, const mbedtls_md4_context *src ); /** * \brief MD4 context setup * * \param ctx context to be initialized * * \return 0 if successful * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ int mbedtls_md4_starts_ret( mbedtls_md4_context *ctx ); /** * \brief MD4 process buffer * * \param ctx MD4 context * \param input buffer holding the data * \param ilen length of the input data * * \return 0 if successful * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md4_update_ret( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD4 final digest * * \param ctx MD4 context * \param output MD4 checksum result * * \return 0 if successful * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md4_finish_ret( mbedtls_md4_context *ctx, unsigned char output[16] ); /** * \brief MD4 process data block (internal use only) * * \param ctx MD4 context * \param data buffer holding one block of data * * \return 0 if successful * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief MD4 context setup * * \deprecated Superseded by mbedtls_md4_starts_ret() in 2.7.0 * * \param ctx context to be initialized * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md4_starts( mbedtls_md4_context *ctx ); /** * \brief MD4 process buffer * * \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0 * * \param ctx MD4 context * \param input buffer holding the data * \param ilen length of the input data * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD4 final digest * * \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0 * * \param ctx MD4 context * \param output MD4 checksum result * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] ); /** * \brief MD4 process data block (internal use only) * * \deprecated Superseded by mbedtls_internal_md4_process() in 2.7.0 * * \param ctx MD4 context * \param data buffer holding one block of data * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Output = MD4( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output MD4 checksum result * * \return 0 if successful * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md4_ret( const unsigned char *input, size_t ilen, unsigned char output[16] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Output = MD4( input buffer ) * * \deprecated Superseded by mbedtls_md4_ret() in 2.7.0 * * \param input buffer holding the data * \param ilen length of the input data * \param output MD4 checksum result * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed * * \warning MD4 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md4_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_md4.h */
9,629
C++
.h
284
30.56338
106
0.63809
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,515
entropy.h
w1hkj_fldigi/src/include/mbedtls/entropy.h
/** * \file entropy.h * * \brief Entropy accumulator implementation */ /* * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ENTROPY_H #define MBEDTLS_ENTROPY_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256) #include "sha512.h" #define MBEDTLS_ENTROPY_SHA512_ACCUMULATOR #else #if defined(MBEDTLS_SHA256_C) #define MBEDTLS_ENTROPY_SHA256_ACCUMULATOR #include "sha256.h" #endif #endif #if defined(MBEDTLS_THREADING_C) #include "threading.h" #endif #if defined(MBEDTLS_HAVEGE_C) #include "havege.h" #endif #define MBEDTLS_ERR_ENTROPY_SOURCE_FAILED -0x003C /**< Critical entropy source failure. */ #define MBEDTLS_ERR_ENTROPY_MAX_SOURCES -0x003E /**< No more sources can be added. */ #define MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 /**< No sources have been added to poll. */ #define MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE -0x003D /**< No strong sources have been added to poll. */ #define MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR -0x003F /**< Read/write error in file. */ /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h or define them on the compiler command line. * \{ */ #if !defined(MBEDTLS_ENTROPY_MAX_SOURCES) #define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ #endif #if !defined(MBEDTLS_ENTROPY_MAX_GATHER) #define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ #endif /* \} name SECTION: Module settings */ #if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) #define MBEDTLS_ENTROPY_BLOCK_SIZE 64 /**< Block size of entropy accumulator (SHA-512) */ #else #define MBEDTLS_ENTROPY_BLOCK_SIZE 32 /**< Block size of entropy accumulator (SHA-256) */ #endif #define MBEDTLS_ENTROPY_MAX_SEED_SIZE 1024 /**< Maximum size of seed we read from seed file */ #define MBEDTLS_ENTROPY_SOURCE_MANUAL MBEDTLS_ENTROPY_MAX_SOURCES #define MBEDTLS_ENTROPY_SOURCE_STRONG 1 /**< Entropy source is strong */ #define MBEDTLS_ENTROPY_SOURCE_WEAK 0 /**< Entropy source is weak */ #ifdef __cplusplus extern "C" { #endif /** * \brief Entropy poll callback pointer * * \param data Callback-specific data pointer * \param output Data to fill * \param len Maximum size to provide * \param olen The actual amount of bytes put into the buffer (Can be 0) * * \return 0 if no critical failures occurred, * MBEDTLS_ERR_ENTROPY_SOURCE_FAILED otherwise */ typedef int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, size_t len, size_t *olen); /** * \brief Entropy source state */ typedef struct mbedtls_entropy_source_state { mbedtls_entropy_f_source_ptr f_source; /**< The entropy source callback */ void * p_source; /**< The callback data pointer */ size_t size; /**< Amount received in bytes */ size_t threshold; /**< Minimum bytes required before release */ int strong; /**< Is the source strong? */ } mbedtls_entropy_source_state; /** * \brief Entropy context structure */ typedef struct mbedtls_entropy_context { int accumulator_started; #if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) mbedtls_sha512_context accumulator; #else mbedtls_sha256_context accumulator; #endif int source_count; mbedtls_entropy_source_state source[MBEDTLS_ENTROPY_MAX_SOURCES]; #if defined(MBEDTLS_HAVEGE_C) mbedtls_havege_state havege_data; #endif #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; /*!< mutex */ #endif #if defined(MBEDTLS_ENTROPY_NV_SEED) int initial_entropy_run; #endif } mbedtls_entropy_context; /** * \brief Initialize the context * * \param ctx Entropy context to initialize */ void mbedtls_entropy_init( mbedtls_entropy_context *ctx ); /** * \brief Free the data in the context * * \param ctx Entropy context to free */ void mbedtls_entropy_free( mbedtls_entropy_context *ctx ); /** * \brief Adds an entropy source to poll * (Thread-safe if MBEDTLS_THREADING_C is enabled) * * \param ctx Entropy context * \param f_source Entropy function * \param p_source Function data * \param threshold Minimum required from source before entropy is released * ( with mbedtls_entropy_func() ) (in bytes) * \param strong MBEDTLS_ENTROPY_SOURCE_STRONG or * MBEDTLS_ENTROPY_SOURCE_WEAK. * At least one strong source needs to be added. * Weaker sources (such as the cycle counter) can be used as * a complement. * * \return 0 if successful or MBEDTLS_ERR_ENTROPY_MAX_SOURCES */ int mbedtls_entropy_add_source( mbedtls_entropy_context *ctx, mbedtls_entropy_f_source_ptr f_source, void *p_source, size_t threshold, int strong ); /** * \brief Trigger an extra gather poll for the accumulator * (Thread-safe if MBEDTLS_THREADING_C is enabled) * * \param ctx Entropy context * * \return 0 if successful, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED */ int mbedtls_entropy_gather( mbedtls_entropy_context *ctx ); /** * \brief Retrieve entropy from the accumulator * (Maximum length: MBEDTLS_ENTROPY_BLOCK_SIZE) * (Thread-safe if MBEDTLS_THREADING_C is enabled) * * \param data Entropy context * \param output Buffer to fill * \param len Number of bytes desired, must be at most MBEDTLS_ENTROPY_BLOCK_SIZE * * \return 0 if successful, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED */ int mbedtls_entropy_func( void *data, unsigned char *output, size_t len ); /** * \brief Add data to the accumulator manually * (Thread-safe if MBEDTLS_THREADING_C is enabled) * * \param ctx Entropy context * \param data Data to add * \param len Length of data * * \return 0 if successful */ int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx, const unsigned char *data, size_t len ); #if defined(MBEDTLS_ENTROPY_NV_SEED) /** * \brief Trigger an update of the seed file in NV by using the * current entropy pool. * * \param ctx Entropy context * * \return 0 if successful */ int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx ); #endif /* MBEDTLS_ENTROPY_NV_SEED */ #if defined(MBEDTLS_FS_IO) /** * \brief Write a seed file * * \param ctx Entropy context * \param path Name of the file * * \return 0 if successful, * MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR on file error, or * MBEDTLS_ERR_ENTROPY_SOURCE_FAILED */ int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *path ); /** * \brief Read and update a seed file. Seed is added to this * instance. No more than MBEDTLS_ENTROPY_MAX_SEED_SIZE bytes are * read from the seed file. The rest is ignored. * * \param ctx Entropy context * \param path Name of the file * * \return 0 if successful, * MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR on file error, * MBEDTLS_ERR_ENTROPY_SOURCE_FAILED */ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *path ); #endif /* MBEDTLS_FS_IO */ #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine * * This module self-test also calls the entropy self-test, * mbedtls_entropy_source_self_test(); * * \return 0 if successful, or 1 if a test failed */ int mbedtls_entropy_self_test( int verbose ); #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) /** * \brief Checkup routine * * Verifies the integrity of the hardware entropy source * provided by the function 'mbedtls_hardware_poll()'. * * Note this is the only hardware entropy source that is known * at link time, and other entropy sources configured * dynamically at runtime by the function * mbedtls_entropy_add_source() will not be tested. * * \return 0 if successful, or 1 if a test failed */ int mbedtls_entropy_source_self_test( int verbose ); #endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif #endif /* entropy.h */
9,866
C++
.h
261
35.559387
117
0.656919
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,516
sha1.h
w1hkj_fldigi/src/include/mbedtls/sha1.h
/** * \file sha1.h * * \brief This file contains SHA-1 definitions and functions. * * The Secure Hash Algorithm 1 (SHA-1) cryptographic hash function is defined in * <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. We recommend considering stronger message * digests instead. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SHA1_H #define MBEDTLS_SHA1_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035 /**< SHA-1 hardware accelerator failed */ #define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073 /**< SHA-1 input data was malformed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_SHA1_ALT) // Regular implementation // /** * \brief The SHA-1 context structure. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ typedef struct mbedtls_sha1_context { uint32_t total[2]; /*!< The number of Bytes processed. */ uint32_t state[5]; /*!< The intermediate digest state. */ unsigned char buffer[64]; /*!< The data block being processed. */ } mbedtls_sha1_context; #else /* MBEDTLS_SHA1_ALT */ #include "sha1_alt.h" #endif /* MBEDTLS_SHA1_ALT */ /** * \brief This function initializes a SHA-1 context. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param ctx The SHA-1 context to initialize. * This must not be \c NULL. * */ void mbedtls_sha1_init( mbedtls_sha1_context *ctx ); /** * \brief This function clears a SHA-1 context. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param ctx The SHA-1 context to clear. This may be \c NULL, * in which case this function does nothing. If it is * not \c NULL, it must point to an initialized * SHA-1 context. * */ void mbedtls_sha1_free( mbedtls_sha1_context *ctx ); /** * \brief This function clones the state of a SHA-1 context. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param dst The SHA-1 context to clone to. This must be initialized. * \param src The SHA-1 context to clone from. This must be initialized. * */ void mbedtls_sha1_clone( mbedtls_sha1_context *dst, const mbedtls_sha1_context *src ); /** * \brief This function starts a SHA-1 checksum calculation. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param ctx The SHA-1 context to initialize. This must be initialized. * * \return \c 0 on success. * \return A negative error code on failure. * */ int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ); /** * \brief This function feeds an input buffer into an ongoing SHA-1 * checksum calculation. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param ctx The SHA-1 context. This must be initialized * and have a hash operation started. * \param input The buffer holding the input data. * This must be a readable buffer of length \p ilen Bytes. * \param ilen The length of the input data \p input in Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the SHA-1 operation, and writes * the result to the output buffer. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param ctx The SHA-1 context to use. This must be initialized and * have a hash operation started. * \param output The SHA-1 checksum result. This must be a writable * buffer of length \c 20 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] ); /** * \brief SHA-1 process data block (internal use only). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param ctx The SHA-1 context to use. This must be initialized. * \param data The data block being processed. This must be a * readable buffer of length \c 64 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. * */ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function starts a SHA-1 checksum calculation. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0. * * \param ctx The SHA-1 context to initialize. This must be initialized. * */ MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx ); /** * \brief This function feeds an input buffer into an ongoing SHA-1 * checksum calculation. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0. * * \param ctx The SHA-1 context. This must be initialized and * have a hash operation started. * \param input The buffer holding the input data. * This must be a readable buffer of length \p ilen Bytes. * \param ilen The length of the input data \p input in Bytes. * */ MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the SHA-1 operation, and writes * the result to the output buffer. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0. * * \param ctx The SHA-1 context. This must be initialized and * have a hash operation started. * \param output The SHA-1 checksum result. * This must be a writable buffer of length \c 20 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] ); /** * \brief SHA-1 process data block (internal use only). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0. * * \param ctx The SHA-1 context. This must be initialized. * \param data The data block being processed. * This must be a readable buffer of length \c 64 bytes. * */ MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief This function calculates the SHA-1 checksum of a buffer. * * The function allocates the context, performs the * calculation, and frees the context. * * The SHA-1 result is calculated as * output = SHA-1(input buffer). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \param input The buffer holding the input data. * This must be a readable buffer of length \p ilen Bytes. * \param ilen The length of the input data \p input in Bytes. * \param output The SHA-1 checksum result. * This must be a writable buffer of length \c 20 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. * */ int mbedtls_sha1_ret( const unsigned char *input, size_t ilen, unsigned char output[20] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function calculates the SHA-1 checksum of a buffer. * * The function allocates the context, performs the * calculation, and frees the context. * * The SHA-1 result is calculated as * output = SHA-1(input buffer). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0 * * \param input The buffer holding the input data. * This must be a readable buffer of length \p ilen Bytes. * \param ilen The length of the input data \p input in Bytes. * \param output The SHA-1 checksum result. This must be a writable * buffer of size \c 20 Bytes. * */ MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief The SHA-1 checkup routine. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * * \return \c 0 on success. * \return \c 1 on failure. * */ int mbedtls_sha1_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_sha1.h */
12,983
C++
.h
325
36.738462
108
0.631283
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,517
aes.h
w1hkj_fldigi/src/include/mbedtls/aes.h
/** * \file aes.h * * \brief This file contains AES definitions and functions. * * The Advanced Encryption Standard (AES) specifies a FIPS-approved * cryptographic algorithm that can be used to protect electronic * data. * * The AES algorithm is a symmetric block cipher that can * encrypt and decrypt information. For more information, see * <em>FIPS Publication 197: Advanced Encryption Standard</em> and * <em>ISO/IEC 18033-2:2006: Information technology -- Security * techniques -- Encryption algorithms -- Part 2: Asymmetric * ciphers</em>. * * The AES-XTS block mode is standardized by NIST SP 800-38E * <https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38e.pdf> * and described in detail by IEEE P1619 * <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>. */ /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_AES_H #define MBEDTLS_AES_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* padlock.c and aesni.c rely on these values! */ #define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */ #define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */ /* Error codes in range 0x0020-0x0022 */ #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ /* Error codes in range 0x0021-0x0025 */ #define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */ /* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */ #define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */ /* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */ #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline #endif #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_AES_ALT) // Regular implementation // /** * \brief The AES context-type definition. */ typedef struct mbedtls_aes_context { int nr; /*!< The number of rounds. */ uint32_t *rk; /*!< AES round keys. */ uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can hold 32 extra Bytes, which can be used for one of the following purposes: <ul><li>Alignment if VIA padlock is used.</li> <li>Simplifying key expansion in the 256-bit case by generating an extra round key. </li></ul> */ } mbedtls_aes_context; #if defined(MBEDTLS_CIPHER_MODE_XTS) /** * \brief The AES XTS context-type definition. */ typedef struct mbedtls_aes_xts_context { mbedtls_aes_context crypt; /*!< The AES context to use for AES block encryption or decryption. */ mbedtls_aes_context tweak; /*!< The AES context used for tweak computation. */ } mbedtls_aes_xts_context; #endif /* MBEDTLS_CIPHER_MODE_XTS */ #else /* MBEDTLS_AES_ALT */ #include "aes_alt.h" #endif /* MBEDTLS_AES_ALT */ /** * \brief This function initializes the specified AES context. * * It must be the first API called before using * the context. * * \param ctx The AES context to initialize. This must not be \c NULL. */ void mbedtls_aes_init( mbedtls_aes_context *ctx ); /** * \brief This function releases and clears the specified AES context. * * \param ctx The AES context to clear. * If this is \c NULL, this function does nothing. * Otherwise, the context must have been at least initialized. */ void mbedtls_aes_free( mbedtls_aes_context *ctx ); #if defined(MBEDTLS_CIPHER_MODE_XTS) /** * \brief This function initializes the specified AES XTS context. * * It must be the first API called before using * the context. * * \param ctx The AES XTS context to initialize. This must not be \c NULL. */ void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx ); /** * \brief This function releases and clears the specified AES XTS context. * * \param ctx The AES XTS context to clear. * If this is \c NULL, this function does nothing. * Otherwise, the context must have been at least initialized. */ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ); #endif /* MBEDTLS_CIPHER_MODE_XTS */ /** * \brief This function sets the encryption key. * * \param ctx The AES context to which the key should be bound. * It must be initialized. * \param key The encryption key. * This must be a readable buffer of size \p keybits bits. * \param keybits The size of data passed in bits. Valid options are: * <ul><li>128 bits</li> * <li>192 bits</li> * <li>256 bits</li></ul> * * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief This function sets the decryption key. * * \param ctx The AES context to which the key should be bound. * It must be initialized. * \param key The decryption key. * This must be a readable buffer of size \p keybits bits. * \param keybits The size of data passed. Valid options are: * <ul><li>128 bits</li> * <li>192 bits</li> * <li>256 bits</li></ul> * * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); #if defined(MBEDTLS_CIPHER_MODE_XTS) /** * \brief This function prepares an XTS context for encryption and * sets the encryption key. * * \param ctx The AES XTS context to which the key should be bound. * It must be initialized. * \param key The encryption key. This is comprised of the XTS key1 * concatenated with the XTS key2. * This must be a readable buffer of size \p keybits bits. * \param keybits The size of \p key passed in bits. Valid options are: * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li> * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul> * * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief This function prepares an XTS context for decryption and * sets the decryption key. * * \param ctx The AES XTS context to which the key should be bound. * It must be initialized. * \param key The decryption key. This is comprised of the XTS key1 * concatenated with the XTS key2. * This must be a readable buffer of size \p keybits bits. * \param keybits The size of \p key passed in bits. Valid options are: * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li> * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul> * * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits ); #endif /* MBEDTLS_CIPHER_MODE_XTS */ /** * \brief This function performs an AES single-block encryption or * decryption operation. * * It performs the operation defined in the \p mode parameter * (encrypt or decrypt), on the input data buffer defined in * the \p input parameter. * * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or * mbedtls_aes_setkey_dec() must be called before the first * call to this API with the same context. * * \param ctx The AES context to use for encryption or decryption. * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. * \param input The buffer holding the input data. * It must be readable and at least \c 16 Bytes long. * \param output The buffer where the output data will be written. * It must be writeable and at least \c 16 Bytes long. * \return \c 0 on success. */ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief This function performs an AES-CBC encryption or decryption operation * on full blocks. * * It performs the operation defined in the \p mode * parameter (encrypt/decrypt), on the input data buffer defined in * the \p input parameter. * * It can be called as many times as needed, until all the input * data is processed. mbedtls_aes_init(), and either * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called * before the first call to this API with the same context. * * \note This function operates on full blocks, that is, the input size * must be a multiple of the AES block size of \c 16 Bytes. * * \note Upon exit, the content of the IV is updated so that you can * call the same function again on the next * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If you need to retain the contents of the IV, you should * either save it manually or use the cipher module instead. * * * \param ctx The AES context to use for encryption or decryption. * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. * \param length The length of the input data in Bytes. This must be a * multiple of the block size (\c 16 Bytes). * \param iv Initialization vector (updated after use). * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH * on failure. */ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CIPHER_MODE_XTS) /** * \brief This function performs an AES-XTS encryption or decryption * operation for an entire XTS data unit. * * AES-XTS encrypts or decrypts blocks based on their location as * defined by a data unit number. The data unit number must be * provided by \p data_unit. * * NIST SP 800-38E limits the maximum size of a data unit to 2^20 * AES blocks. If the data unit is larger than this, this function * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH. * * \param ctx The AES XTS context to use for AES XTS operations. * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. * \param length The length of a data unit in Bytes. This can be any * length between 16 bytes and 2^24 bytes inclusive * (between 1 and 2^20 block cipher blocks). * \param data_unit The address of the data unit encoded as an array of 16 * bytes in little-endian format. For disk encryption, this * is typically the index of the block device sector that * contains the data. * \param input The buffer holding the input data (which is an entire * data unit). This function reads \p length Bytes from \p * input. * \param output The buffer holding the output data (which is an entire * data unit). This function writes \p length Bytes to \p * output. * * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is * smaller than an AES block in size (16 Bytes) or if \p * length is larger than 2^20 blocks (16 MiB). */ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, int mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_XTS */ #if defined(MBEDTLS_CIPHER_MODE_CFB) /** * \brief This function performs an AES-CFB128 encryption or decryption * operation. * * It performs the operation defined in the \p mode * parameter (encrypt or decrypt), on the input data buffer * defined in the \p input parameter. * * For CFB, you must set up the context with mbedtls_aes_setkey_enc(), * regardless of whether you are performing an encryption or decryption * operation, that is, regardless of the \p mode parameter. This is * because CFB mode uses the same key schedule for encryption and * decryption. * * \note Upon exit, the content of the IV is updated so that you can * call the same function again on the next * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If you need to retain the contents of the * IV, you must either save it manually or use the cipher * module instead. * * * \param ctx The AES context to use for encryption or decryption. * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. * \param length The length of the input data in Bytes. * \param iv_off The offset in IV (updated after use). * It must point to a valid \c size_t. * \param iv The initialization vector (updated after use). * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. */ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ); /** * \brief This function performs an AES-CFB8 encryption or decryption * operation. * * It performs the operation defined in the \p mode * parameter (encrypt/decrypt), on the input data buffer defined * in the \p input parameter. * * Due to the nature of CFB, you must use the same key schedule for * both encryption and decryption operations. Therefore, you must * use the context initialized with mbedtls_aes_setkey_enc() for * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT. * * \note Upon exit, the content of the IV is updated so that you can * call the same function again on the next * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * * \param ctx The AES context to use for encryption or decryption. * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT * \param length The length of the input data. * \param iv The initialization vector (updated after use). * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. */ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ); #endif /*MBEDTLS_CIPHER_MODE_CFB */ #if defined(MBEDTLS_CIPHER_MODE_OFB) /** * \brief This function performs an AES-OFB (Output Feedback Mode) * encryption or decryption operation. * * For OFB, you must set up the context with * mbedtls_aes_setkey_enc(), regardless of whether you are * performing an encryption or decryption operation. This is * because OFB mode uses the same key schedule for encryption and * decryption. * * The OFB operation is identical for encryption or decryption, * therefore no operation mode needs to be specified. * * \note Upon exit, the content of iv, the Initialisation Vector, is * updated so that you can call the same function again on the next * block(s) of data and get the same result as if it was encrypted * in one call. This allows a "streaming" usage, by initialising * iv_off to 0 before the first call, and preserving its value * between calls. * * For non-streaming use, the iv should be initialised on each call * to a unique value, and iv_off set to 0 on each call. * * If you need to retain the contents of the initialisation vector, * you must either save it manually or use the cipher module * instead. * * \warning For the OFB mode, the initialisation vector must be unique * every encryption operation. Reuse of an initialisation vector * will compromise security. * * \param ctx The AES context to use for encryption or decryption. * It must be initialized and bound to a key. * \param length The length of the input data. * \param iv_off The offset in IV (updated after use). * It must point to a valid \c size_t. * \param iv The initialization vector (updated after use). * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. */ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_OFB */ #if defined(MBEDTLS_CIPHER_MODE_CTR) /** * \brief This function performs an AES-CTR encryption or decryption * operation. * * This function performs the operation defined in the \p mode * parameter (encrypt/decrypt), on the input data buffer * defined in the \p input parameter. * * Due to the nature of CTR, you must use the same key schedule * for both encryption and decryption operations. Therefore, you * must use the context initialized with mbedtls_aes_setkey_enc() * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT. * * \warning You must never reuse a nonce value with the same key. Doing so * would void the encryption for the two messages encrypted with * the same nonce and key. * * There are two common strategies for managing nonces with CTR: * * 1. You can handle everything as a single message processed over * successive calls to this function. In that case, you want to * set \p nonce_counter and \p nc_off to 0 for the first call, and * then preserve the values of \p nonce_counter, \p nc_off and \p * stream_block across calls to this function as they will be * updated by this function. * * With this strategy, you must not encrypt more than 2**128 * blocks of data with the same key. * * 2. You can encrypt separate messages by dividing the \p * nonce_counter buffer in two areas: the first one used for a * per-message nonce, handled by yourself, and the second one * updated by this function internally. * * For example, you might reserve the first 12 bytes for the * per-message nonce, and the last 4 bytes for internal use. In that * case, before calling this function on a new message you need to * set the first 12 bytes of \p nonce_counter to your chosen nonce * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p * stream_block to be ignored). That way, you can encrypt at most * 2**96 messages of up to 2**32 blocks each with the same key. * * The per-message nonce (or information sufficient to reconstruct * it) needs to be communicated with the ciphertext and must be unique. * The recommended way to ensure uniqueness is to use a message * counter. An alternative is to generate random nonces, but this * limits the number of messages that can be securely encrypted: * for example, with 96-bit random nonces, you should not encrypt * more than 2**32 messages with the same key. * * Note that for both stategies, sizes are measured in blocks and * that an AES block is 16 bytes. * * \warning Upon return, \p stream_block contains sensitive data. Its * content must not be written to insecure storage and should be * securely discarded as soon as it's no longer needed. * * \param ctx The AES context to use for encryption or decryption. * It must be initialized and bound to a key. * \param length The length of the input data. * \param nc_off The offset in the current \p stream_block, for * resuming within the current cipher stream. The * offset pointer should be 0 at the start of a stream. * It must point to a valid \c size_t. * \param nonce_counter The 128-bit nonce and counter. * It must be a readable-writeable buffer of \c 16 Bytes. * \param stream_block The saved stream block for resuming. This is * overwritten by the function. * It must be a readable-writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. */ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ /** * \brief Internal AES block encryption function. This is only * exposed to allow overriding it using * \c MBEDTLS_AES_ENCRYPT_ALT. * * \param ctx The AES context to use for encryption. * \param input The plaintext block. * \param output The output (ciphertext) block. * * \return \c 0 on success. */ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); /** * \brief Internal AES block decryption function. This is only * exposed to allow overriding it using see * \c MBEDTLS_AES_DECRYPT_ALT. * * \param ctx The AES context to use for decryption. * \param input The ciphertext block. * \param output The output (plaintext) block. * * \return \c 0 on success. */ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Deprecated internal AES block encryption function * without return value. * * \deprecated Superseded by mbedtls_internal_aes_encrypt() * * \param ctx The AES context to use for encryption. * \param input Plaintext block. * \param output Output (ciphertext) block. */ MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); /** * \brief Deprecated internal AES block decryption function * without return value. * * \deprecated Superseded by mbedtls_internal_aes_decrypt() * * \param ctx The AES context to use for decryption. * \param input Ciphertext block. * \param output Output (plaintext) block. */ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_aes_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* aes.h */
29,539
C++
.h
632
42.344937
139
0.605882
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,518
platform_util.h
w1hkj_fldigi/src/include/mbedtls/platform_util.h
/** * \file platform_util.h * * \brief Common and shared functions used by multiple modules in the Mbed TLS * library. */ /* * Copyright (C) 2018, Arm Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PLATFORM_UTIL_H #define MBEDTLS_PLATFORM_UTIL_H #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #if defined(MBEDTLS_HAVE_TIME_DATE) #include "mbedtls/platform_time.h" #include <time.h> #endif /* MBEDTLS_HAVE_TIME_DATE */ #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_CHECK_PARAMS) #if defined(MBEDTLS_PARAM_FAILED) /** An alternative definition of MBEDTLS_PARAM_FAILED has been set in config.h. * * This flag can be used to check whether it is safe to assume that * MBEDTLS_PARAM_FAILED() will expand to a call to mbedtls_param_failed(). */ #define MBEDTLS_PARAM_FAILED_ALT #else /* MBEDTLS_PARAM_FAILED */ #define MBEDTLS_PARAM_FAILED( cond ) \ mbedtls_param_failed( #cond, __FILE__, __LINE__ ) /** * \brief User supplied callback function for parameter validation failure. * See #MBEDTLS_CHECK_PARAMS for context. * * This function will be called unless an alternative treatement * is defined through the #MBEDTLS_PARAM_FAILED macro. * * This function can return, and the operation will be aborted, or * alternatively, through use of setjmp()/longjmp() can resume * execution in the application code. * * \param failure_condition The assertion that didn't hold. * \param file The file where the assertion failed. * \param line The line in the file where the assertion failed. */ void mbedtls_param_failed( const char *failure_condition, const char *file, int line ); #endif /* MBEDTLS_PARAM_FAILED */ /* Internal macro meant to be called only from within the library. */ #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) \ do { \ if( !(cond) ) \ { \ MBEDTLS_PARAM_FAILED( cond ); \ return( ret ); \ } \ } while( 0 ) /* Internal macro meant to be called only from within the library. */ #define MBEDTLS_INTERNAL_VALIDATE( cond ) \ do { \ if( !(cond) ) \ { \ MBEDTLS_PARAM_FAILED( cond ); \ return; \ } \ } while( 0 ) #else /* MBEDTLS_CHECK_PARAMS */ /* Internal macros meant to be called only from within the library. */ #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 ) #define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 ) #endif /* MBEDTLS_CHECK_PARAMS */ /* Internal helper macros for deprecating API constants. */ #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) /* Deliberately don't (yet) export MBEDTLS_DEPRECATED here * to avoid conflict with other headers which define and use * it, too. We might want to move all these definitions here at * some point for uniformity. */ #define MBEDTLS_DEPRECATED __attribute__((deprecated)) MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t; #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \ ( (mbedtls_deprecated_string_constant_t) ( VAL ) ) MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \ ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) ) #undef MBEDTLS_DEPRECATED #else /* MBEDTLS_DEPRECATED_WARNING */ #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL #endif /* MBEDTLS_DEPRECATED_WARNING */ #endif /* MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Securely zeroize a buffer * * The function is meant to wipe the data contained in a buffer so * that it can no longer be recovered even if the program memory * is later compromised. Call this function on sensitive data * stored on the stack before returning from a function, and on * sensitive data stored on the heap before freeing the heap * object. * * It is extremely difficult to guarantee that calls to * mbedtls_platform_zeroize() are not removed by aggressive * compiler optimizations in a portable way. For this reason, Mbed * TLS provides the configuration option * MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure * mbedtls_platform_zeroize() to use a suitable implementation for * their platform and needs * * \param buf Buffer to be zeroized * \param len Length of the buffer in bytes * */ void mbedtls_platform_zeroize( void *buf, size_t len ); #if defined(MBEDTLS_HAVE_TIME_DATE) /** * \brief Platform-specific implementation of gmtime_r() * * The function is a thread-safe abstraction that behaves * similarly to the gmtime_r() function from Unix/POSIX. * * Mbed TLS will try to identify the underlying platform and * make use of an appropriate underlying implementation (e.g. * gmtime_r() for POSIX and gmtime_s() for Windows). If this is * not possible, then gmtime() will be used. In this case, calls * from the library to gmtime() will be guarded by the mutex * mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is * enabled. It is recommended that calls from outside the library * are also guarded by this mutex. * * If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will * unconditionally use the alternative implementation for * mbedtls_platform_gmtime_r() supplied by the user at compile time. * * \param tt Pointer to an object containing time (in seconds) since the * epoch to be converted * \param tm_buf Pointer to an object where the results will be stored * * \return Pointer to an object of type struct tm on success, otherwise * NULL */ struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt, struct tm *tm_buf ); #endif /* MBEDTLS_HAVE_TIME_DATE */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_PLATFORM_UTIL_H */
7,617
C++
.h
171
41.654971
81
0.641454
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,519
ssl_internal.h
w1hkj_fldigi/src/include/mbedtls/ssl_internal.h
/** * \file ssl_internal.h * * \brief Internal functions shared by the SSL modules */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SSL_INTERNAL_H #define MBEDTLS_SSL_INTERNAL_H #include "ssl.h" #include "cipher.h" #if defined(MBEDTLS_MD5_C) #include "md5.h" #endif #if defined(MBEDTLS_SHA1_C) #include "sha1.h" #endif #if defined(MBEDTLS_SHA256_C) #include "sha256.h" #endif #if defined(MBEDTLS_SHA512_C) #include "sha512.h" #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) #include "ecjpake.h" #endif #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline #endif /* Determine minimum supported version */ #define MBEDTLS_SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3 #if defined(MBEDTLS_SSL_PROTO_SSL3) #define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_0 #else #if defined(MBEDTLS_SSL_PROTO_TLS1) #define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_1 #else #if defined(MBEDTLS_SSL_PROTO_TLS1_1) #define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_2 #else #if defined(MBEDTLS_SSL_PROTO_TLS1_2) #define MBEDTLS_SSL_MIN_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_3 #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ #endif /* MBEDTLS_SSL_PROTO_TLS1 */ #endif /* MBEDTLS_SSL_PROTO_SSL3 */ #define MBEDTLS_SSL_MIN_VALID_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_1 #define MBEDTLS_SSL_MIN_VALID_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3 /* Determine maximum supported version */ #define MBEDTLS_SSL_MAX_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3 #if defined(MBEDTLS_SSL_PROTO_TLS1_2) #define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_3 #else #if defined(MBEDTLS_SSL_PROTO_TLS1_1) #define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_2 #else #if defined(MBEDTLS_SSL_PROTO_TLS1) #define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_1 #else #if defined(MBEDTLS_SSL_PROTO_SSL3) #define MBEDTLS_SSL_MAX_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_0 #endif /* MBEDTLS_SSL_PROTO_SSL3 */ #endif /* MBEDTLS_SSL_PROTO_TLS1 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ /* Shorthand for restartable ECC */ #if defined(MBEDTLS_ECP_RESTARTABLE) && \ defined(MBEDTLS_SSL_CLI_C) && \ defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #define MBEDTLS_SSL__ECP_RESTARTABLE #endif #define MBEDTLS_SSL_INITIAL_HANDSHAKE 0 #define MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS 1 /* In progress */ #define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */ #define MBEDTLS_SSL_RENEGOTIATION_PENDING 3 /* Requested (server only) */ /* * DTLS retransmission states, see RFC 6347 4.2.4 * * The SENDING state is merged in PREPARING for initial sends, * but is distinct for resends. * * Note: initial state is wrong for server, but is not used anyway. */ #define MBEDTLS_SSL_RETRANS_PREPARING 0 #define MBEDTLS_SSL_RETRANS_SENDING 1 #define MBEDTLS_SSL_RETRANS_WAITING 2 #define MBEDTLS_SSL_RETRANS_FINISHED 3 /* * Allow extra bytes for record, authentication and encryption overhead: * counter (8) + header (5) + IV(16) + MAC (16-48) + padding (0-256) * and allow for a maximum of 1024 of compression expansion if * enabled. */ #if defined(MBEDTLS_ZLIB_SUPPORT) #define MBEDTLS_SSL_COMPRESSION_ADD 1024 #else #define MBEDTLS_SSL_COMPRESSION_ADD 0 #endif #if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_MODE_CBC) /* Ciphersuites using HMAC */ #if defined(MBEDTLS_SHA512_C) #define MBEDTLS_SSL_MAC_ADD 48 /* SHA-384 used for HMAC */ #elif defined(MBEDTLS_SHA256_C) #define MBEDTLS_SSL_MAC_ADD 32 /* SHA-256 used for HMAC */ #else #define MBEDTLS_SSL_MAC_ADD 20 /* SHA-1 used for HMAC */ #endif #else /* AEAD ciphersuites: GCM and CCM use a 128 bits tag */ #define MBEDTLS_SSL_MAC_ADD 16 #endif #if defined(MBEDTLS_CIPHER_MODE_CBC) #define MBEDTLS_SSL_PADDING_ADD 256 #else #define MBEDTLS_SSL_PADDING_ADD 0 #endif #define MBEDTLS_SSL_PAYLOAD_OVERHEAD ( MBEDTLS_SSL_COMPRESSION_ADD + \ MBEDTLS_MAX_IV_LENGTH + \ MBEDTLS_SSL_MAC_ADD + \ MBEDTLS_SSL_PADDING_ADD \ ) #define MBEDTLS_SSL_IN_PAYLOAD_LEN ( MBEDTLS_SSL_PAYLOAD_OVERHEAD + \ ( MBEDTLS_SSL_IN_CONTENT_LEN ) ) #define MBEDTLS_SSL_OUT_PAYLOAD_LEN ( MBEDTLS_SSL_PAYLOAD_OVERHEAD + \ ( MBEDTLS_SSL_OUT_CONTENT_LEN ) ) /* The maximum number of buffered handshake messages. */ #define MBEDTLS_SSL_MAX_BUFFERED_HS 4 /* Maximum length we can advertise as our max content length for RFC 6066 max_fragment_length extension negotiation purposes (the lesser of both sizes, if they are unequal.) */ #define MBEDTLS_TLS_EXT_ADV_CONTENT_LEN ( \ (MBEDTLS_SSL_IN_CONTENT_LEN > MBEDTLS_SSL_OUT_CONTENT_LEN) \ ? ( MBEDTLS_SSL_OUT_CONTENT_LEN ) \ : ( MBEDTLS_SSL_IN_CONTENT_LEN ) \ ) /* * Check that we obey the standard's message size bounds */ #if MBEDTLS_SSL_MAX_CONTENT_LEN > 16384 #error "Bad configuration - record content too large." #endif #if MBEDTLS_SSL_IN_CONTENT_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN #error "Bad configuration - incoming record content should not be larger than MBEDTLS_SSL_MAX_CONTENT_LEN." #endif #if MBEDTLS_SSL_OUT_CONTENT_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN #error "Bad configuration - outgoing record content should not be larger than MBEDTLS_SSL_MAX_CONTENT_LEN." #endif #if MBEDTLS_SSL_IN_PAYLOAD_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN + 2048 #error "Bad configuration - incoming protected record payload too large." #endif #if MBEDTLS_SSL_OUT_PAYLOAD_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN + 2048 #error "Bad configuration - outgoing protected record payload too large." #endif /* Calculate buffer sizes */ /* Note: Even though the TLS record header is only 5 bytes long, we're internally using 8 bytes to store the implicit sequence number. */ #define MBEDTLS_SSL_HEADER_LEN 13 #define MBEDTLS_SSL_IN_BUFFER_LEN \ ( ( MBEDTLS_SSL_HEADER_LEN ) + ( MBEDTLS_SSL_IN_PAYLOAD_LEN ) ) #define MBEDTLS_SSL_OUT_BUFFER_LEN \ ( ( MBEDTLS_SSL_HEADER_LEN ) + ( MBEDTLS_SSL_OUT_PAYLOAD_LEN ) ) #ifdef MBEDTLS_ZLIB_SUPPORT /* Compression buffer holds both IN and OUT buffers, so should be size of the larger */ #define MBEDTLS_SSL_COMPRESS_BUFFER_LEN ( \ ( MBEDTLS_SSL_IN_BUFFER_LEN > MBEDTLS_SSL_OUT_BUFFER_LEN ) \ ? MBEDTLS_SSL_IN_BUFFER_LEN \ : MBEDTLS_SSL_OUT_BUFFER_LEN \ ) #endif /* * TLS extension flags (for extensions with outgoing ServerHello content * that need it (e.g. for RENEGOTIATION_INFO the server already knows because * of state of the renegotiation flag, so no indicator is required) */ #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT (1 << 0) #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK (1 << 1) #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) /* * Abstraction for a grid of allowed signature-hash-algorithm pairs. */ struct mbedtls_ssl_sig_hash_set_t { /* At the moment, we only need to remember a single suitable * hash algorithm per signature algorithm. As long as that's * the case - and we don't need a general lookup function - * we can implement the sig-hash-set as a map from signatures * to hash algorithms. */ mbedtls_md_type_t rsa; mbedtls_md_type_t ecdsa; }; #endif /* MBEDTLS_SSL_PROTO_TLS1_2 && MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ /* * This structure contains the parameters only needed during handshake. */ struct mbedtls_ssl_handshake_params { /* * Handshake specific crypto variables */ #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) mbedtls_ssl_sig_hash_set_t hash_algs; /*!< Set of suitable sig-hash pairs */ #endif #if defined(MBEDTLS_DHM_C) mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */ #endif #if defined(MBEDTLS_ECDH_C) mbedtls_ecdh_context ecdh_ctx; /*!< ECDH key exchange */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) mbedtls_ecjpake_context ecjpake_ctx; /*!< EC J-PAKE key exchange */ #if defined(MBEDTLS_SSL_CLI_C) unsigned char *ecjpake_cache; /*!< Cache for ClientHello ext */ size_t ecjpake_cache_len; /*!< Length of cached data */ #endif #endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) const mbedtls_ecp_curve_info **curves; /*!< Supported elliptic curves */ #endif #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) unsigned char *psk; /*!< PSK from the callback */ size_t psk_len; /*!< Length of PSK from callback */ #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_ssl_key_cert *key_cert; /*!< chosen key/cert pair (server) */ #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) int sni_authmode; /*!< authmode from SNI callback */ mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */ mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */ mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */ #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL__ECP_RESTARTABLE) int ecrs_enabled; /*!< Handshake supports EC restart? */ mbedtls_x509_crt_restart_ctx ecrs_ctx; /*!< restart context */ enum { /* this complements ssl->state with info on intra-state operations */ ssl_ecrs_none = 0, /*!< nothing going on (yet) */ ssl_ecrs_crt_verify, /*!< Certificate: crt_verify() */ ssl_ecrs_ske_start_processing, /*!< ServerKeyExchange: pk_verify() */ ssl_ecrs_cke_ecdh_calc_secret, /*!< ClientKeyExchange: ECDH step 2 */ ssl_ecrs_crt_vrfy_sign, /*!< CertificateVerify: pk_sign() */ } ecrs_state; /*!< current (or last) operation */ size_t ecrs_n; /*!< place for saving a length */ #endif #if defined(MBEDTLS_SSL_PROTO_DTLS) unsigned int out_msg_seq; /*!< Outgoing handshake sequence number */ unsigned int in_msg_seq; /*!< Incoming handshake sequence number */ unsigned char *verify_cookie; /*!< Cli: HelloVerifyRequest cookie Srv: unused */ unsigned char verify_cookie_len; /*!< Cli: cookie length Srv: flag for sending a cookie */ uint32_t retransmit_timeout; /*!< Current value of timeout */ unsigned char retransmit_state; /*!< Retransmission state */ mbedtls_ssl_flight_item *flight; /*!< Current outgoing flight */ mbedtls_ssl_flight_item *cur_msg; /*!< Current message in flight */ unsigned char *cur_msg_p; /*!< Position in current message */ unsigned int in_flight_start_seq; /*!< Minimum message sequence in the flight being received */ mbedtls_ssl_transform *alt_transform_out; /*!< Alternative transform for resending messages */ unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter for resending messages */ struct { size_t total_bytes_buffered; /*!< Cumulative size of heap allocated * buffers used for message buffering. */ uint8_t seen_ccs; /*!< Indicates if a CCS message has * been seen in the current flight. */ struct mbedtls_ssl_hs_buffer { unsigned is_valid : 1; unsigned is_fragmented : 1; unsigned is_complete : 1; unsigned char *data; size_t data_len; } hs[MBEDTLS_SSL_MAX_BUFFERED_HS]; struct { unsigned char *data; size_t len; unsigned epoch; } future_record; } buffering; uint16_t mtu; /*!< Handshake mtu, used to fragment outgoing messages */ #endif /* MBEDTLS_SSL_PROTO_DTLS */ /* * Checksum contexts */ #if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_1) mbedtls_md5_context fin_md5; mbedtls_sha1_context fin_sha1; #endif #if defined(MBEDTLS_SSL_PROTO_TLS1_2) #if defined(MBEDTLS_SHA256_C) mbedtls_sha256_context fin_sha256; #endif #if defined(MBEDTLS_SHA512_C) mbedtls_sha512_context fin_sha512; #endif #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ void (*update_checksum)(mbedtls_ssl_context *, const unsigned char *, size_t); void (*calc_verify)(mbedtls_ssl_context *, unsigned char *); void (*calc_finished)(mbedtls_ssl_context *, unsigned char *, int); int (*tls_prf)(const unsigned char *, size_t, const char *, const unsigned char *, size_t, unsigned char *, size_t); size_t pmslen; /*!< premaster length */ unsigned char randbytes[64]; /*!< random bytes */ unsigned char premaster[MBEDTLS_PREMASTER_SIZE]; /*!< premaster secret */ int resume; /*!< session resume indicator*/ int max_major_ver; /*!< max. major version client*/ int max_minor_ver; /*!< max. minor version client*/ int cli_exts; /*!< client extension presence*/ #if defined(MBEDTLS_SSL_SESSION_TICKETS) int new_session_ticket; /*!< use NewSessionTicket? */ #endif /* MBEDTLS_SSL_SESSION_TICKETS */ #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) int extended_ms; /*!< use Extended Master Secret? */ #endif #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) unsigned int async_in_progress : 1; /*!< an asynchronous operation is in progress */ #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) /** Asynchronous operation context. This field is meant for use by the * asynchronous operation callbacks (mbedtls_ssl_config::f_async_sign_start, * mbedtls_ssl_config::f_async_decrypt_start, * mbedtls_ssl_config::f_async_resume, mbedtls_ssl_config::f_async_cancel). * The library does not use it internally. */ void *user_async_ctx; #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ }; typedef struct mbedtls_ssl_hs_buffer mbedtls_ssl_hs_buffer; /* * This structure contains a full set of runtime transform parameters * either in negotiation or active. */ struct mbedtls_ssl_transform { /* * Session specific crypto layer */ const mbedtls_ssl_ciphersuite_t *ciphersuite_info; /*!< Chosen cipersuite_info */ unsigned int keylen; /*!< symmetric key length (bytes) */ size_t minlen; /*!< min. ciphertext length */ size_t ivlen; /*!< IV length */ size_t fixed_ivlen; /*!< Fixed part of IV (AEAD) */ size_t maclen; /*!< MAC length */ unsigned char iv_enc[16]; /*!< IV (encryption) */ unsigned char iv_dec[16]; /*!< IV (decryption) */ #if defined(MBEDTLS_SSL_PROTO_SSL3) /* Needed only for SSL v3.0 secret */ unsigned char mac_enc[20]; /*!< SSL v3.0 secret (enc) */ unsigned char mac_dec[20]; /*!< SSL v3.0 secret (dec) */ #endif /* MBEDTLS_SSL_PROTO_SSL3 */ mbedtls_md_context_t md_ctx_enc; /*!< MAC (encryption) */ mbedtls_md_context_t md_ctx_dec; /*!< MAC (decryption) */ mbedtls_cipher_context_t cipher_ctx_enc; /*!< encryption context */ mbedtls_cipher_context_t cipher_ctx_dec; /*!< decryption context */ /* * Session specific compression layer */ #if defined(MBEDTLS_ZLIB_SUPPORT) z_stream ctx_deflate; /*!< compression context */ z_stream ctx_inflate; /*!< decompression context */ #endif }; #if defined(MBEDTLS_X509_CRT_PARSE_C) /* * List of certificate + private key pairs */ struct mbedtls_ssl_key_cert { mbedtls_x509_crt *cert; /*!< cert */ mbedtls_pk_context *key; /*!< private key */ mbedtls_ssl_key_cert *next; /*!< next key/cert pair */ }; #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_PROTO_DTLS) /* * List of handshake messages kept around for resending */ struct mbedtls_ssl_flight_item { unsigned char *p; /*!< message, including handshake headers */ size_t len; /*!< length of p */ unsigned char type; /*!< type of the message: handshake or CCS */ mbedtls_ssl_flight_item *next; /*!< next handshake message(s) */ }; #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) /* Find an entry in a signature-hash set matching a given hash algorithm. */ mbedtls_md_type_t mbedtls_ssl_sig_hash_set_find( mbedtls_ssl_sig_hash_set_t *set, mbedtls_pk_type_t sig_alg ); /* Add a signature-hash-pair to a signature-hash set */ void mbedtls_ssl_sig_hash_set_add( mbedtls_ssl_sig_hash_set_t *set, mbedtls_pk_type_t sig_alg, mbedtls_md_type_t md_alg ); /* Allow exactly one hash algorithm for each signature. */ void mbedtls_ssl_sig_hash_set_const_hash( mbedtls_ssl_sig_hash_set_t *set, mbedtls_md_type_t md_alg ); /* Setup an empty signature-hash set */ static inline void mbedtls_ssl_sig_hash_set_init( mbedtls_ssl_sig_hash_set_t *set ) { mbedtls_ssl_sig_hash_set_const_hash( set, MBEDTLS_MD_NONE ); } #endif /* MBEDTLS_SSL_PROTO_TLS1_2) && MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ /** * \brief Free referenced items in an SSL transform context and clear * memory * * \param transform SSL transform context */ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ); /** * \brief Free referenced items in an SSL handshake context and clear * memory * * \param ssl SSL context */ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ); void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl ); int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ); int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ); void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ); /** * \brief Update record layer * * This function roughly separates the implementation * of the logic of (D)TLS from the implementation * of the secure transport. * * \param ssl The SSL context to use. * \param update_hs_digest This indicates if the handshake digest * should be automatically updated in case * a handshake message is found. * * \return 0 or non-zero error code. * * \note A clarification on what is called 'record layer' here * is in order, as many sensible definitions are possible: * * The record layer takes as input an untrusted underlying * transport (stream or datagram) and transforms it into * a serially multiplexed, secure transport, which * conceptually provides the following: * * (1) Three datagram based, content-agnostic transports * for handshake, alert and CCS messages. * (2) One stream- or datagram-based transport * for application data. * (3) Functionality for changing the underlying transform * securing the contents. * * The interface to this functionality is given as follows: * * a Updating * [Currently implemented by mbedtls_ssl_read_record] * * Check if and on which of the four 'ports' data is pending: * Nothing, a controlling datagram of type (1), or application * data (2). In any case data is present, internal buffers * provide access to the data for the user to process it. * Consumption of type (1) datagrams is done automatically * on the next update, invalidating that the internal buffers * for previous datagrams, while consumption of application * data (2) is user-controlled. * * b Reading of application data * [Currently manual adaption of ssl->in_offt pointer] * * As mentioned in the last paragraph, consumption of data * is different from the automatic consumption of control * datagrams (1) because application data is treated as a stream. * * c Tracking availability of application data * [Currently manually through decreasing ssl->in_msglen] * * For efficiency and to retain datagram semantics for * application data in case of DTLS, the record layer * provides functionality for checking how much application * data is still available in the internal buffer. * * d Changing the transformation securing the communication. * * Given an opaque implementation of the record layer in the * above sense, it should be possible to implement the logic * of (D)TLS on top of it without the need to know anything * about the record layer's internals. This is done e.g. * in all the handshake handling functions, and in the * application data reading function mbedtls_ssl_read. * * \note The above tries to give a conceptual picture of the * record layer, but the current implementation deviates * from it in some places. For example, our implementation of * the update functionality through mbedtls_ssl_read_record * discards datagrams depending on the current state, which * wouldn't fall under the record layer's responsibility * following the above definition. * */ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl, unsigned update_hs_digest ); int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ); int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_change_cipher_spec( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ); void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl, const mbedtls_ssl_ciphersuite_t *ciphersuite_info ); #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exchange_type_t key_ex ); #endif #if defined(MBEDTLS_PK_C) unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk ); unsigned char mbedtls_ssl_sig_from_pk_alg( mbedtls_pk_type_t type ); mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig ); #endif mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash ); unsigned char mbedtls_ssl_hash_from_md_alg( int md ); int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md ); #if defined(MBEDTLS_ECP_C) int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id ); #endif #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl, mbedtls_md_type_t md ); #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) static inline mbedtls_pk_context *mbedtls_ssl_own_key( mbedtls_ssl_context *ssl ) { mbedtls_ssl_key_cert *key_cert; if( ssl->handshake != NULL && ssl->handshake->key_cert != NULL ) key_cert = ssl->handshake->key_cert; else key_cert = ssl->conf->key_cert; return( key_cert == NULL ? NULL : key_cert->key ); } static inline mbedtls_x509_crt *mbedtls_ssl_own_cert( mbedtls_ssl_context *ssl ) { mbedtls_ssl_key_cert *key_cert; if( ssl->handshake != NULL && ssl->handshake->key_cert != NULL ) key_cert = ssl->handshake->key_cert; else key_cert = ssl->conf->key_cert; return( key_cert == NULL ? NULL : key_cert->cert ); } /* * Check usage of a certificate wrt extensions: * keyUsage, extendedKeyUsage (later), and nSCertType (later). * * Warning: cert_endpoint is the endpoint of the cert (ie, of our peer when we * check a cert we received from them)! * * Return 0 if everything is OK, -1 if not. */ int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt *cert, const mbedtls_ssl_ciphersuite_t *ciphersuite, int cert_endpoint, uint32_t *flags ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ void mbedtls_ssl_write_version( int major, int minor, int transport, unsigned char ver[2] ); void mbedtls_ssl_read_version( int *major, int *minor, int transport, const unsigned char ver[2] ); static inline size_t mbedtls_ssl_hdr_len( const mbedtls_ssl_context *ssl ) { #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) return( 13 ); #else ((void) ssl); #endif return( 5 ); } static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl ) { #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) return( 12 ); #else ((void) ssl); #endif return( 4 ); } #if defined(MBEDTLS_SSL_PROTO_DTLS) void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl ); void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl ); int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ); int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl ); #endif /* Visible for testing purposes only */ #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) int mbedtls_ssl_dtls_replay_check( mbedtls_ssl_context *ssl ); void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl ); #endif /* constant-time buffer comparison */ static inline int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n ) { size_t i; volatile const unsigned char *A = (volatile const unsigned char *) a; volatile const unsigned char *B = (volatile const unsigned char *) b; volatile unsigned char diff = 0; for( i = 0; i < n; i++ ) { /* Read volatile data in order before computing diff. * This avoids IAR compiler warning: * 'the order of volatile accesses is undefined ..' */ unsigned char x = A[i], y = B[i]; diff |= x ^ y; } return( diff ); } #if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_1) int mbedtls_ssl_get_key_exchange_md_ssl_tls( mbedtls_ssl_context *ssl, unsigned char *output, unsigned char *data, size_t data_len ); #endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \ MBEDTLS_SSL_PROTO_TLS1_1 */ #if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_2) int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl, unsigned char *hash, size_t *hashlen, unsigned char *data, size_t data_len, mbedtls_md_type_t md_alg ); #endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ MBEDTLS_SSL_PROTO_TLS1_2 */ #ifdef __cplusplus } #endif #endif /* ssl_internal.h */
30,969
C++
.h
674
41.274481
107
0.634494
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,520
xtea.h
w1hkj_fldigi/src/include/mbedtls/xtea.h
/** * \file xtea.h * * \brief XTEA block cipher (32-bit) */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_XTEA_H #define MBEDTLS_XTEA_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> #define MBEDTLS_XTEA_ENCRYPT 1 #define MBEDTLS_XTEA_DECRYPT 0 #define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028 /**< The data input has an invalid length. */ /* MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029 /**< XTEA hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_XTEA_ALT) // Regular implementation // /** * \brief XTEA context structure */ typedef struct mbedtls_xtea_context { uint32_t k[4]; /*!< key */ } mbedtls_xtea_context; #else /* MBEDTLS_XTEA_ALT */ #include "xtea_alt.h" #endif /* MBEDTLS_XTEA_ALT */ /** * \brief Initialize XTEA context * * \param ctx XTEA context to be initialized */ void mbedtls_xtea_init( mbedtls_xtea_context *ctx ); /** * \brief Clear XTEA context * * \param ctx XTEA context to be cleared */ void mbedtls_xtea_free( mbedtls_xtea_context *ctx ); /** * \brief XTEA key schedule * * \param ctx XTEA context to be initialized * \param key the secret key */ void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] ); /** * \brief XTEA cipher function * * \param ctx XTEA context * \param mode MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT * \param input 8-byte input block * \param output 8-byte output block * * \return 0 if successful */ int mbedtls_xtea_crypt_ecb( mbedtls_xtea_context *ctx, int mode, const unsigned char input[8], unsigned char output[8] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief XTEA CBC cipher function * * \param ctx XTEA context * \param mode MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT * \param length the length of input, multiple of 8 * \param iv initialization vector for CBC mode * \param input input block * \param output output block * * \return 0 if successful, * MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH if the length % 8 != 0 */ int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output); #endif /* MBEDTLS_CIPHER_MODE_CBC */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_xtea_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* xtea.h */
3,788
C++
.h
120
28.533333
112
0.662832
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,521
ssl_ticket.h
w1hkj_fldigi/src/include/mbedtls/ssl_ticket.h
/** * \file ssl_ticket.h * * \brief TLS server ticket callbacks implementation */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SSL_TICKET_H #define MBEDTLS_SSL_TICKET_H /* * This implementation of the session ticket callbacks includes key * management, rotating the keys periodically in order to preserve forward * secrecy, when MBEDTLS_HAVE_TIME is defined. */ #include "ssl.h" #include "cipher.h" #if defined(MBEDTLS_THREADING_C) #include "threading.h" #endif #ifdef __cplusplus extern "C" { #endif /** * \brief Information for session ticket protection */ typedef struct mbedtls_ssl_ticket_key { unsigned char name[4]; /*!< random key identifier */ uint32_t generation_time; /*!< key generation timestamp (seconds) */ mbedtls_cipher_context_t ctx; /*!< context for auth enc/decryption */ } mbedtls_ssl_ticket_key; /** * \brief Context for session ticket handling functions */ typedef struct mbedtls_ssl_ticket_context { mbedtls_ssl_ticket_key keys[2]; /*!< ticket protection keys */ unsigned char active; /*!< index of the currently active key */ uint32_t ticket_lifetime; /*!< lifetime of tickets in seconds */ /** Callback for getting (pseudo-)random numbers */ int (*f_rng)(void *, unsigned char *, size_t); void *p_rng; /*!< context for the RNG function */ #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; #endif } mbedtls_ssl_ticket_context; /** * \brief Initialize a ticket context. * (Just make it ready for mbedtls_ssl_ticket_setup() * or mbedtls_ssl_ticket_free().) * * \param ctx Context to be initialized */ void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ); /** * \brief Prepare context to be actually used * * \param ctx Context to be set up * \param f_rng RNG callback function * \param p_rng RNG callback context * \param cipher AEAD cipher to use for ticket protection. * Recommended value: MBEDTLS_CIPHER_AES_256_GCM. * \param lifetime Tickets lifetime in seconds * Recommended value: 86400 (one day). * * \note It is highly recommended to select a cipher that is at * least as strong as the the strongest ciphersuite * supported. Usually that means a 256-bit key. * * \note The lifetime of the keys is twice the lifetime of tickets. * It is recommended to pick a reasonnable lifetime so as not * to negate the benefits of forward secrecy. * * \return 0 if successful, * or a specific MBEDTLS_ERR_XXX error code */ int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_cipher_type_t cipher, uint32_t lifetime ); /** * \brief Implementation of the ticket write callback * * \note See \c mbedlts_ssl_ticket_write_t for description */ mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write; /** * \brief Implementation of the ticket parse callback * * \note See \c mbedlts_ssl_ticket_parse_t for description */ mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse; /** * \brief Free a context's content and zeroize it. * * \param ctx Context to be cleaned up */ void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ); #ifdef __cplusplus } #endif #endif /* ssl_ticket.h */
4,494
C++
.h
122
34.704918
78
0.667355
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,522
ecp.h
w1hkj_fldigi/src/include/mbedtls/ecp.h
/** * \file ecp.h * * \brief This file provides an API for Elliptic Curves over GF(P) (ECP). * * The use of ECP in cryptography and TLS is defined in * <em>Standards for Efficient Cryptography Group (SECG): SEC1 * Elliptic Curve Cryptography</em> and * <em>RFC-4492: Elliptic Curve Cryptography (ECC) Cipher Suites * for Transport Layer Security (TLS)</em>. * * <em>RFC-2409: The Internet Key Exchange (IKE)</em> defines ECP * group types. * */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ECP_H #define MBEDTLS_ECP_H #include "bignum.h" /* * ECP error codes */ #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00 /**< The buffer is too small to write to. */ #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80 /**< The requested feature is not available, for example, the requested curve is not supported. */ #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00 /**< The signature is not valid. */ #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 /**< Memory allocation failed. */ #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as ephemeral key, failed. */ #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */ #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< The buffer contains a valid signature followed by more data. */ /* MBEDTLS_ERR_ECP_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80 /**< The ECP hardware accelerator failed. */ #define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00 /**< Operation in progress, call again with the same parameters to continue. */ #ifdef __cplusplus extern "C" { #endif /** * Domain-parameter identifiers: curve, subgroup, and generator. * * \note Only curves over prime fields are supported. * * \warning This library does not support validation of arbitrary domain * parameters. Therefore, only standardized domain parameters from trusted * sources should be used. See mbedtls_ecp_group_load(). */ typedef enum { MBEDTLS_ECP_DP_NONE = 0, /*!< Curve not defined. */ MBEDTLS_ECP_DP_SECP192R1, /*!< Domain parameters for the 192-bit curve defined by FIPS 186-4 and SEC1. */ MBEDTLS_ECP_DP_SECP224R1, /*!< Domain parameters for the 224-bit curve defined by FIPS 186-4 and SEC1. */ MBEDTLS_ECP_DP_SECP256R1, /*!< Domain parameters for the 256-bit curve defined by FIPS 186-4 and SEC1. */ MBEDTLS_ECP_DP_SECP384R1, /*!< Domain parameters for the 384-bit curve defined by FIPS 186-4 and SEC1. */ MBEDTLS_ECP_DP_SECP521R1, /*!< Domain parameters for the 521-bit curve defined by FIPS 186-4 and SEC1. */ MBEDTLS_ECP_DP_BP256R1, /*!< Domain parameters for 256-bit Brainpool curve. */ MBEDTLS_ECP_DP_BP384R1, /*!< Domain parameters for 384-bit Brainpool curve. */ MBEDTLS_ECP_DP_BP512R1, /*!< Domain parameters for 512-bit Brainpool curve. */ MBEDTLS_ECP_DP_CURVE25519, /*!< Domain parameters for Curve25519. */ MBEDTLS_ECP_DP_SECP192K1, /*!< Domain parameters for 192-bit "Koblitz" curve. */ MBEDTLS_ECP_DP_SECP224K1, /*!< Domain parameters for 224-bit "Koblitz" curve. */ MBEDTLS_ECP_DP_SECP256K1, /*!< Domain parameters for 256-bit "Koblitz" curve. */ MBEDTLS_ECP_DP_CURVE448, /*!< Domain parameters for Curve448. */ } mbedtls_ecp_group_id; /** * The number of supported curves, plus one for #MBEDTLS_ECP_DP_NONE. * * \note Montgomery curves are currently excluded. */ #define MBEDTLS_ECP_DP_MAX 12 /** * Curve information, for use by other modules. */ typedef struct mbedtls_ecp_curve_info { mbedtls_ecp_group_id grp_id; /*!< An internal identifier. */ uint16_t tls_id; /*!< The TLS NamedCurve identifier. */ uint16_t bit_size; /*!< The curve size in bits. */ const char *name; /*!< A human-friendly name. */ } mbedtls_ecp_curve_info; /** * \brief The ECP point structure, in Jacobian coordinates. * * \note All functions expect and return points satisfying * the following condition: <code>Z == 0</code> or * <code>Z == 1</code>. Other values of \p Z are * used only by internal functions. * The point is zero, or "at infinity", if <code>Z == 0</code>. * Otherwise, \p X and \p Y are its standard (affine) * coordinates. */ typedef struct mbedtls_ecp_point { mbedtls_mpi X; /*!< The X coordinate of the ECP point. */ mbedtls_mpi Y; /*!< The Y coordinate of the ECP point. */ mbedtls_mpi Z; /*!< The Z coordinate of the ECP point. */ } mbedtls_ecp_point; #if !defined(MBEDTLS_ECP_ALT) /* * default mbed TLS elliptic curve arithmetic implementation * * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an * alternative implementation for the whole module and it will replace this * one.) */ /** * \brief The ECP group structure. * * We consider two types of curve equations: * <ul><li>Short Weierstrass: <code>y^2 = x^3 + A x + B mod P</code> * (SEC1 + RFC-4492)</li> * <li>Montgomery: <code>y^2 = x^3 + A x^2 + x mod P</code> (Curve25519, * Curve448)</li></ul> * In both cases, the generator (\p G) for a prime-order subgroup is fixed. * * For Short Weierstrass, this subgroup is the whole curve, and its * cardinality is denoted by \p N. Our code requires that \p N is an * odd prime as mbedtls_ecp_mul() requires an odd number, and * mbedtls_ecdsa_sign() requires that it is prime for blinding purposes. * * For Montgomery curves, we do not store \p A, but <code>(A + 2) / 4</code>, * which is the quantity used in the formulas. Additionally, \p nbits is * not the size of \p N but the required size for private keys. * * If \p modp is NULL, reduction modulo \p P is done using a generic algorithm. * Otherwise, \p modp must point to a function that takes an \p mbedtls_mpi in the * range of <code>0..2^(2*pbits)-1</code>, and transforms it in-place to an integer * which is congruent mod \p P to the given MPI, and is close enough to \p pbits * in size, so that it may be efficiently brought in the 0..P-1 range by a few * additions or subtractions. Therefore, it is only an approximative modular * reduction. It must return 0 on success and non-zero on failure. * * \note Alternative implementations must keep the group IDs distinct. If * two group structures have the same ID, then they must be * identical. * */ typedef struct mbedtls_ecp_group { mbedtls_ecp_group_id id; /*!< An internal group identifier. */ mbedtls_mpi P; /*!< The prime modulus of the base field. */ mbedtls_mpi A; /*!< For Short Weierstrass: \p A in the equation. For Montgomery curves: <code>(A + 2) / 4</code>. */ mbedtls_mpi B; /*!< For Short Weierstrass: \p B in the equation. For Montgomery curves: unused. */ mbedtls_ecp_point G; /*!< The generator of the subgroup used. */ mbedtls_mpi N; /*!< The order of \p G. */ size_t pbits; /*!< The number of bits in \p P.*/ size_t nbits; /*!< For Short Weierstrass: The number of bits in \p P. For Montgomery curves: the number of bits in the private keys. */ unsigned int h; /*!< \internal 1 if the constants are static. */ int (*modp)(mbedtls_mpi *); /*!< The function for fast pseudo-reduction mod \p P (see above).*/ int (*t_pre)(mbedtls_ecp_point *, void *); /*!< Unused. */ int (*t_post)(mbedtls_ecp_point *, void *); /*!< Unused. */ void *t_data; /*!< Unused. */ mbedtls_ecp_point *T; /*!< Pre-computed points for ecp_mul_comb(). */ size_t T_size; /*!< The number of pre-computed points. */ } mbedtls_ecp_group; #if defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Internal restart context for multiplication * * \note Opaque struct */ typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx; /** * \brief Internal restart context for ecp_muladd() * * \note Opaque struct */ typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx; /** * \brief General context for resuming ECC operations */ typedef struct { unsigned ops_done; /*!< current ops count */ unsigned depth; /*!< call depth (0 = top-level) */ mbedtls_ecp_restart_mul_ctx *rsm; /*!< ecp_mul_comb() sub-context */ mbedtls_ecp_restart_muladd_ctx *ma; /*!< ecp_muladd() sub-context */ } mbedtls_ecp_restart_ctx; /* * Operation counts for restartable functions */ #define MBEDTLS_ECP_OPS_CHK 3 /*!< basic ops count for ecp_check_pubkey() */ #define MBEDTLS_ECP_OPS_DBL 8 /*!< basic ops count for ecp_double_jac() */ #define MBEDTLS_ECP_OPS_ADD 11 /*!< basic ops count for see ecp_add_mixed() */ #define MBEDTLS_ECP_OPS_INV 120 /*!< empirical equivalent for mpi_mod_inv() */ /** * \brief Internal; for restartable functions in other modules. * Check and update basic ops budget. * * \param grp Group structure * \param rs_ctx Restart context * \param ops Number of basic ops to do * * \return \c 0 if doing \p ops basic ops is still allowed, * \return #MBEDTLS_ERR_ECP_IN_PROGRESS otherwise. */ int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp, mbedtls_ecp_restart_ctx *rs_ctx, unsigned ops ); /* Utility macro for checking and updating ops budget */ #define MBEDTLS_ECP_BUDGET( ops ) \ MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, rs_ctx, \ (unsigned) (ops) ) ); #else /* MBEDTLS_ECP_RESTARTABLE */ #define MBEDTLS_ECP_BUDGET( ops ) /* no-op; for compatibility */ /* We want to declare restartable versions of existing functions anyway */ typedef void mbedtls_ecp_restart_ctx; #endif /* MBEDTLS_ECP_RESTARTABLE */ /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h, or define them using the compiler command line. * \{ */ #if !defined(MBEDTLS_ECP_MAX_BITS) /** * The maximum size of the groups, that is, of \c N and \c P. */ #define MBEDTLS_ECP_MAX_BITS 521 /**< The maximum size of groups, in bits. */ #endif #define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 ) #define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 ) #if !defined(MBEDTLS_ECP_WINDOW_SIZE) /* * Maximum "window" size used for point multiplication. * Default: 6. * Minimum value: 2. Maximum value: 7. * * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) ) * points used for point multiplication. This value is directly tied to EC * peak memory usage, so decreasing it by one should roughly cut memory usage * by two (if large curves are in use). * * Reduction in size may reduce speed, but larger curves are impacted first. * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1): * w-size: 6 5 4 3 2 * 521 145 141 135 120 97 * 384 214 209 198 177 146 * 256 320 320 303 262 226 * 224 475 475 453 398 342 * 192 640 640 633 587 476 */ #define MBEDTLS_ECP_WINDOW_SIZE 6 /**< The maximum window size used. */ #endif /* MBEDTLS_ECP_WINDOW_SIZE */ #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM) /* * Trade memory for speed on fixed-point multiplication. * * This speeds up repeated multiplication of the generator (that is, the * multiplication in ECDSA signatures, and half of the multiplications in * ECDSA verification and ECDHE) by a factor roughly 3 to 4. * * The cost is increasing EC peak memory usage by a factor roughly 2. * * Change this value to 0 to reduce peak memory usage. */ #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up. */ #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */ /* \} name SECTION: Module settings */ #else /* MBEDTLS_ECP_ALT */ #include "ecp_alt.h" #endif /* MBEDTLS_ECP_ALT */ /** * \brief The ECP key-pair structure. * * A generic key-pair that may be used for ECDSA and fixed ECDH, for example. * * \note Members are deliberately in the same order as in the * ::mbedtls_ecdsa_context structure. */ typedef struct mbedtls_ecp_keypair { mbedtls_ecp_group grp; /*!< Elliptic curve and base point */ mbedtls_mpi d; /*!< our secret value */ mbedtls_ecp_point Q; /*!< our public value */ } mbedtls_ecp_keypair; /* * Point formats, from RFC 4492's enum ECPointFormat */ #define MBEDTLS_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format. */ #define MBEDTLS_ECP_PF_COMPRESSED 1 /**< Compressed point format. */ /* * Some other constants from RFC 4492 */ #define MBEDTLS_ECP_TLS_NAMED_CURVE 3 /**< The named_curve of ECCurveType. */ #if defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Set the maximum number of basic operations done in a row. * * If more operations are needed to complete a computation, * #MBEDTLS_ERR_ECP_IN_PROGRESS will be returned by the * function performing the computation. It is then the * caller's responsibility to either call again with the same * parameters until it returns 0 or an error code; or to free * the restart context if the operation is to be aborted. * * It is strictly required that all input parameters and the * restart context be the same on successive calls for the * same operation, but output parameters need not be the * same; they must not be used until the function finally * returns 0. * * This only applies to functions whose documentation * mentions they may return #MBEDTLS_ERR_ECP_IN_PROGRESS (or * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS for functions in the * SSL module). For functions that accept a "restart context" * argument, passing NULL disables restart and makes the * function equivalent to the function with the same name * with \c _restartable removed. For functions in the ECDH * module, restart is disabled unless the function accepts * an "ECDH context" argument and * mbedtls_ecdh_enable_restart() was previously called on * that context. For function in the SSL module, restart is * only enabled for specific sides and key exchanges * (currently only for clients and ECDHE-ECDSA). * * \param max_ops Maximum number of basic operations done in a row. * Default: 0 (unlimited). * Lower (non-zero) values mean ECC functions will block for * a lesser maximum amount of time. * * \note A "basic operation" is defined as a rough equivalent of a * multiplication in GF(p) for the NIST P-256 curve. * As an indication, with default settings, a scalar * multiplication (full run of \c mbedtls_ecp_mul()) is: * - about 3300 basic operations for P-256 * - about 9400 basic operations for P-384 * * \note Very low values are not always respected: sometimes * functions need to block for a minimum number of * operations, and will do so even if max_ops is set to a * lower value. That minimum depends on the curve size, and * can be made lower by decreasing the value of * \c MBEDTLS_ECP_WINDOW_SIZE. As an indication, here is the * lowest effective value for various curves and values of * that parameter (w for short): * w=6 w=5 w=4 w=3 w=2 * P-256 208 208 160 136 124 * P-384 682 416 320 272 248 * P-521 1364 832 640 544 496 * * \note This setting is currently ignored by Curve25519. */ void mbedtls_ecp_set_max_ops( unsigned max_ops ); /** * \brief Check if restart is enabled (max_ops != 0) * * \return \c 0 if \c max_ops == 0 (restart disabled) * \return \c 1 otherwise (restart enabled) */ int mbedtls_ecp_restart_is_enabled( void ); #endif /* MBEDTLS_ECP_RESTARTABLE */ /** * \brief This function retrieves the information defined in * mbedtls_ecp_curve_info() for all supported curves in order * of preference. * * \return A statically allocated array. The last entry is 0. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ); /** * \brief This function retrieves the list of internal group * identifiers of all supported curves in the order of * preference. * * \return A statically allocated array, * terminated with MBEDTLS_ECP_DP_NONE. */ const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void ); /** * \brief This function retrieves curve information from an internal * group identifier. * * \param grp_id An \c MBEDTLS_ECP_DP_XXX value. * * \return The associated curve information on success. * \return NULL on failure. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id ); /** * \brief This function retrieves curve information from a TLS * NamedCurve value. * * \param tls_id An \c MBEDTLS_ECP_DP_XXX value. * * \return The associated curve information on success. * \return NULL on failure. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id ); /** * \brief This function retrieves curve information from a * human-readable name. * * \param name The human-readable name. * * \return The associated curve information on success. * \return NULL on failure. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name ); /** * \brief This function initializes a point as zero. * * \param pt The point to initialize. */ void mbedtls_ecp_point_init( mbedtls_ecp_point *pt ); /** * \brief This function initializes an ECP group context * without loading any domain parameters. * * \note After this function is called, domain parameters * for various ECP groups can be loaded through the * mbedtls_ecp_load() or mbedtls_ecp_tls_read_group() * functions. */ void mbedtls_ecp_group_init( mbedtls_ecp_group *grp ); /** * \brief This function initializes a key pair as an invalid one. * * \param key The key pair to initialize. */ void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key ); /** * \brief This function frees the components of a point. * * \param pt The point to free. */ void mbedtls_ecp_point_free( mbedtls_ecp_point *pt ); /** * \brief This function frees the components of an ECP group. * * \param grp The group to free. This may be \c NULL, in which * case this function returns immediately. If it is not * \c NULL, it must point to an initialized ECP group. */ void mbedtls_ecp_group_free( mbedtls_ecp_group *grp ); /** * \brief This function frees the components of a key pair. * * \param key The key pair to free. This may be \c NULL, in which * case this function returns immediately. If it is not * \c NULL, it must point to an initialized ECP key pair. */ void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key ); #if defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Initialize a restart context. * * \param ctx The restart context to initialize. This must * not be \c NULL. */ void mbedtls_ecp_restart_init( mbedtls_ecp_restart_ctx *ctx ); /** * \brief Free the components of a restart context. * * \param ctx The restart context to free. This may be \c NULL, in which * case this function returns immediately. If it is not * \c NULL, it must point to an initialized restart context. */ void mbedtls_ecp_restart_free( mbedtls_ecp_restart_ctx *ctx ); #endif /* MBEDTLS_ECP_RESTARTABLE */ /** * \brief This function copies the contents of point \p Q into * point \p P. * * \param P The destination point. This must be initialized. * \param Q The source point. This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return Another negative error code for other kinds of failure. */ int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ); /** * \brief This function copies the contents of group \p src into * group \p dst. * * \param dst The destination group. This must be initialized. * \param src The source group. This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src ); /** * \brief This function sets a point to the point at infinity. * * \param pt The point to set. This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt ); /** * \brief This function checks if a point is the point at infinity. * * \param pt The point to test. This must be initialized. * * \return \c 1 if the point is zero. * \return \c 0 if the point is non-zero. * \return A negative error code on failure. */ int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt ); /** * \brief This function compares two points. * * \note This assumes that the points are normalized. Otherwise, * they may compare as "not equal" even if they are. * * \param P The first point to compare. This must be initialized. * \param Q The second point to compare. This must be initialized. * * \return \c 0 if the points are equal. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the points are not equal. */ int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ); /** * \brief This function imports a non-zero point from two ASCII * strings. * * \param P The destination point. This must be initialized. * \param radix The numeric base of the input. * \param x The first affine coordinate, as a null-terminated string. * \param y The second affine coordinate, as a null-terminated string. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_MPI_XXX error code on failure. */ int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix, const char *x, const char *y ); /** * \brief This function exports a point into unsigned binary data. * * \param grp The group to which the point should belong. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param P The point to export. This must be initialized. * \param format The point format. This must be either * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED. * \param olen The address at which to store the length of * the output in Bytes. This must not be \c NULL. * \param buf The output buffer. This must be a writable buffer * of length \p buflen Bytes. * \param buflen The length of the output buffer \p buf in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output buffer * is too small to hold the point. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, int format, size_t *olen, unsigned char *buf, size_t buflen ); /** * \brief This function imports a point from unsigned binary data. * * \note This function does not check that the point actually * belongs to the given group, see mbedtls_ecp_check_pubkey() * for that. * * \param grp The group to which the point should belong. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param P The destination context to import the point to. * This must be initialized. * \param buf The input buffer. This must be a readable buffer * of length \p ilen Bytes. * \param ilen The length of the input buffer \p buf in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format * is not implemented. */ int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, const unsigned char *buf, size_t ilen ); /** * \brief This function imports a point from a TLS ECPoint record. * * \note On function return, \p *buf is updated to point immediately * after the ECPoint record. * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param pt The destination point. * \param buf The address of the pointer to the start of the input buffer. * \param len The length of the buffer. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_MPI_XXX error code on initialization * failure. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid. */ int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, const unsigned char **buf, size_t len ); /** * \brief This function exports a point as a TLS ECPoint record * defined in RFC 4492, Section 5.4. * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param pt The point to be exported. This must be initialized. * \param format The point format to use. This must be either * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED. * \param olen The address at which to store the length in Bytes * of the data written. * \param buf The target buffer. This must be a writable buffer of * length \p blen Bytes. * \param blen The length of the target buffer \p buf in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid. * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the target buffer * is too small to hold the exported point. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt, int format, size_t *olen, unsigned char *buf, size_t blen ); /** * \brief This function sets up an ECP group context * from a standardized set of domain parameters. * * \note The index should be a value of the NamedCurve enum, * as defined in <em>RFC-4492: Elliptic Curve Cryptography * (ECC) Cipher Suites for Transport Layer Security (TLS)</em>, * usually in the form of an \c MBEDTLS_ECP_DP_XXX macro. * * \param grp The group context to setup. This must be initialized. * \param id The identifier of the domain parameter set to load. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if \p id doesn't * correspond to a known group. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ); /** * \brief This function sets up an ECP group context from a TLS * ECParameters record as defined in RFC 4492, Section 5.4. * * \note The read pointer \p buf is updated to point right after * the ECParameters record on exit. * * \param grp The group context to setup. This must be initialized. * \param buf The address of the pointer to the start of the input buffer. * \param len The length of the input buffer \c *buf in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid. * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the group is not * recognized. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len ); /** * \brief This function extracts an elliptic curve group ID from a * TLS ECParameters record as defined in RFC 4492, Section 5.4. * * \note The read pointer \p buf is updated to point right after * the ECParameters record on exit. * * \param grp The address at which to store the group id. * This must not be \c NULL. * \param buf The address of the pointer to the start of the input buffer. * \param len The length of the input buffer \c *buf in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid. * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the group is not * recognized. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_tls_read_group_id( mbedtls_ecp_group_id *grp, const unsigned char **buf, size_t len ); /** * \brief This function exports an elliptic curve as a TLS * ECParameters record as defined in RFC 4492, Section 5.4. * * \param grp The ECP group to be exported. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param olen The address at which to store the number of Bytes written. * This must not be \c NULL. * \param buf The buffer to write to. This must be a writable buffer * of length \p blen Bytes. * \param blen The length of the output buffer \p buf in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output * buffer is too small to hold the exported group. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, unsigned char *buf, size_t blen ); /** * \brief This function performs a scalar multiplication of a point * by an integer: \p R = \p m * \p P. * * It is not thread-safe to use same group in multiple threads. * * \note To prevent timing attacks, this function * executes the exact same sequence of base-field * operations for any valid \p m. It avoids any if-branch or * array index depending on the value of \p m. * * \note If \p f_rng is not NULL, it is used to randomize * intermediate results to prevent potential timing attacks * targeting these results. We recommend always providing * a non-NULL \p f_rng. The overhead is negligible. * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param R The point in which to store the result of the calculation. * This must be initialized. * \param m The integer by which to multiply. This must be initialized. * \param P The point to multiply. This must be initialized. * \param f_rng The RNG function. This may be \c NULL if randomization * of intermediate results isn't desired (discouraged). * \param p_rng The RNG context to be passed to \p p_rng. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private * key, or \p P is not a valid public key. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function performs multiplication of a point by * an integer: \p R = \p m * \p P in a restartable way. * * \see mbedtls_ecp_mul() * * \note This function does the same as \c mbedtls_ecp_mul(), but * it can return early and restart according to the limit set * with \c mbedtls_ecp_set_max_ops() to reduce blocking. * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param R The point in which to store the result of the calculation. * This must be initialized. * \param m The integer by which to multiply. This must be initialized. * \param P The point to multiply. This must be initialized. * \param f_rng The RNG function. This may be \c NULL if randomization * of intermediate results isn't desired (discouraged). * \param p_rng The RNG context to be passed to \p p_rng. * \param rs_ctx The restart context (NULL disables restart). * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private * key, or \p P is not a valid public key. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_mul_restartable( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_ecp_restart_ctx *rs_ctx ); /** * \brief This function performs multiplication and addition of two * points by integers: \p R = \p m * \p P + \p n * \p Q * * It is not thread-safe to use same group in multiple threads. * * \note In contrast to mbedtls_ecp_mul(), this function does not * guarantee a constant execution flow and timing. * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param R The point in which to store the result of the calculation. * This must be initialized. * \param m The integer by which to multiply \p P. * This must be initialized. * \param P The point to multiply by \p m. This must be initialized. * \param n The integer by which to multiply \p Q. * This must be initialized. * \param Q The point to be multiplied by \p n. * This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m or \p n are not * valid private keys, or \p P or \p Q are not valid public * keys. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q ); /** * \brief This function performs multiplication and addition of two * points by integers: \p R = \p m * \p P + \p n * \p Q in a * restartable way. * * \see \c mbedtls_ecp_muladd() * * \note This function works the same as \c mbedtls_ecp_muladd(), * but it can return early and restart according to the limit * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param R The point in which to store the result of the calculation. * This must be initialized. * \param m The integer by which to multiply \p P. * This must be initialized. * \param P The point to multiply by \p m. This must be initialized. * \param n The integer by which to multiply \p Q. * This must be initialized. * \param Q The point to be multiplied by \p n. * This must be initialized. * \param rs_ctx The restart context (NULL disables restart). * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m or \p n are not * valid private keys, or \p P or \p Q are not valid public * keys. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_muladd_restartable( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q, mbedtls_ecp_restart_ctx *rs_ctx ); /** * \brief This function checks that a point is a valid public key * on this curve. * * It only checks that the point is non-zero, has * valid coordinates and lies on the curve. It does not verify * that it is indeed a multiple of \p G. This additional * check is computationally more expensive, is not required * by standards, and should not be necessary if the group * used has a small cofactor. In particular, it is useless for * the NIST groups which all have a cofactor of 1. * * \note This function uses bare components rather than an * ::mbedtls_ecp_keypair structure, to ease use with other * structures, such as ::mbedtls_ecdh_context or * ::mbedtls_ecdsa_context. * * \param grp The ECP group the point should belong to. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param pt The point to check. This must be initialized. * * \return \c 0 if the point is a valid public key. * \return #MBEDTLS_ERR_ECP_INVALID_KEY if the point is not * a valid public key for the given curve. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ); /** * \brief This function checks that an \p mbedtls_mpi is a * valid private key for this curve. * * \note This function uses bare components rather than an * ::mbedtls_ecp_keypair structure to ease use with other * structures, such as ::mbedtls_ecdh_context or * ::mbedtls_ecdsa_context. * * \param grp The ECP group the private key should belong to. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param d The integer to check. This must be initialized. * * \return \c 0 if the point is a valid private key. * \return #MBEDTLS_ERR_ECP_INVALID_KEY if the point is not a valid * private key for the given curve. * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d ); /** * \brief This function generates a private key. * * \param grp The ECP group to generate a private key for. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param d The destination MPI (secret part). This must be initialized. * \param f_rng The RNG function. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. This may be * \c NULL if \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code * on failure. */ int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp, mbedtls_mpi *d, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function generates a keypair with a configurable base * point. * * \note This function uses bare components rather than an * ::mbedtls_ecp_keypair structure to ease use with other * structures, such as ::mbedtls_ecdh_context or * ::mbedtls_ecdsa_context. * * \param grp The ECP group to generate a key pair for. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param G The base point to use. This must be initialized * and belong to \p grp. It replaces the default base * point \c grp->G used by mbedtls_ecp_gen_keypair(). * \param d The destination MPI (secret part). * This must be initialized. * \param Q The destination point (public part). * This must be initialized. * \param f_rng The RNG function. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may * be \c NULL if \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code * on failure. */ int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, const mbedtls_ecp_point *G, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function generates an ECP keypair. * * \note This function uses bare components rather than an * ::mbedtls_ecp_keypair structure to ease use with other * structures, such as ::mbedtls_ecdh_context or * ::mbedtls_ecdsa_context. * * \param grp The ECP group to generate a key pair for. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param d The destination MPI (secret part). * This must be initialized. * \param Q The destination point (public part). * This must be initialized. * \param f_rng The RNG function. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may * be \c NULL if \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code * on failure. */ int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function generates an ECP key. * * \param grp_id The ECP group identifier. * \param key The destination key. This must be initialized. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may * be \c NULL if \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code * on failure. */ int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function checks that the keypair objects * \p pub and \p prv have the same group and the * same public point, and that the private key in * \p prv is consistent with the public key. * * \param pub The keypair structure holding the public key. This * must be initialized. If it contains a private key, that * part is ignored. * \param prv The keypair structure holding the full keypair. * This must be initialized. * * \return \c 0 on success, meaning that the keys are valid and match. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the keys are invalid or do not match. * \return An \c MBEDTLS_ERR_ECP_XXX or an \c MBEDTLS_ERR_MPI_XXX * error code on calculation failure. */ int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv ); #if defined(MBEDTLS_SELF_TEST) /** * \brief The ECP checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_ecp_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif #endif /* ecp.h */
50,754
C++
.h
1,050
45.026667
165
0.606073
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,523
sha256.h
w1hkj_fldigi/src/include/mbedtls/sha256.h
/** * \file sha256.h * * \brief This file contains SHA-224 and SHA-256 definitions and functions. * * The Secure Hash Algorithms 224 and 256 (SHA-224 and SHA-256) cryptographic * hash functions are defined in <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SHA256_H #define MBEDTLS_SHA256_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037 /**< SHA-256 hardware accelerator failed */ #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074 /**< SHA-256 input data was malformed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_SHA256_ALT) // Regular implementation // /** * \brief The SHA-256 context structure. * * The structure is used both for SHA-256 and for SHA-224 * checksum calculations. The choice between these two is * made in the call to mbedtls_sha256_starts_ret(). */ typedef struct mbedtls_sha256_context { uint32_t total[2]; /*!< The number of Bytes processed. */ uint32_t state[8]; /*!< The intermediate digest state. */ unsigned char buffer[64]; /*!< The data block being processed. */ int is224; /*!< Determines which function to use: 0: Use SHA-256, or 1: Use SHA-224. */ } mbedtls_sha256_context; #else /* MBEDTLS_SHA256_ALT */ #include "sha256_alt.h" #endif /* MBEDTLS_SHA256_ALT */ /** * \brief This function initializes a SHA-256 context. * * \param ctx The SHA-256 context to initialize. This must not be \c NULL. */ void mbedtls_sha256_init( mbedtls_sha256_context *ctx ); /** * \brief This function clears a SHA-256 context. * * \param ctx The SHA-256 context to clear. This may be \c NULL, in which * case this function returns immediately. If it is not \c NULL, * it must point to an initialized SHA-256 context. */ void mbedtls_sha256_free( mbedtls_sha256_context *ctx ); /** * \brief This function clones the state of a SHA-256 context. * * \param dst The destination context. This must be initialized. * \param src The context to clone. This must be initialized. */ void mbedtls_sha256_clone( mbedtls_sha256_context *dst, const mbedtls_sha256_context *src ); /** * \brief This function starts a SHA-224 or SHA-256 checksum * calculation. * * \param ctx The context to use. This must be initialized. * \param is224 This determines which function to use. This must be * either \c 0 for SHA-256, or \c 1 for SHA-224. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 ); /** * \brief This function feeds an input buffer into an ongoing * SHA-256 checksum calculation. * * \param ctx The SHA-256 context. This must be initialized * and have a hash operation started. * \param input The buffer holding the data. This must be a readable * buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the SHA-256 operation, and writes * the result to the output buffer. * * \param ctx The SHA-256 context. This must be initialized * and have a hash operation started. * \param output The SHA-224 or SHA-256 checksum result. * This must be a writable buffer of length \c 32 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, unsigned char output[32] ); /** * \brief This function processes a single data block within * the ongoing SHA-256 computation. This function is for * internal use only. * * \param ctx The SHA-256 context. This must be initialized. * \param data The buffer holding one block of data. This must * be a readable buffer of length \c 64 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function starts a SHA-224 or SHA-256 checksum * calculation. * * \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0. * * \param ctx The context to use. This must be initialized. * \param is224 Determines which function to use. This must be * either \c 0 for SHA-256, or \c 1 for SHA-224. */ MBEDTLS_DEPRECATED void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ); /** * \brief This function feeds an input buffer into an ongoing * SHA-256 checksum calculation. * * \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0. * * \param ctx The SHA-256 context to use. This must be * initialized and have a hash operation started. * \param input The buffer holding the data. This must be a readable * buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the SHA-256 operation, and writes * the result to the output buffer. * * \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0. * * \param ctx The SHA-256 context. This must be initialized and * have a hash operation started. * \param output The SHA-224 or SHA-256 checksum result. This must be * a writable buffer of length \c 32 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] ); /** * \brief This function processes a single data block within * the ongoing SHA-256 computation. This function is for * internal use only. * * \deprecated Superseded by mbedtls_internal_sha256_process() in 2.7.0. * * \param ctx The SHA-256 context. This must be initialized. * \param data The buffer holding one block of data. This must be * a readable buffer of size \c 64 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief This function calculates the SHA-224 or SHA-256 * checksum of a buffer. * * The function allocates the context, performs the * calculation, and frees the context. * * The SHA-256 result is calculated as * output = SHA-256(input buffer). * * \param input The buffer holding the data. This must be a readable * buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. * \param output The SHA-224 or SHA-256 checksum result. This must * be a writable buffer of length \c 32 Bytes. * \param is224 Determines which function to use. This must be * either \c 0 for SHA-256, or \c 1 for SHA-224. */ int mbedtls_sha256_ret( const unsigned char *input, size_t ilen, unsigned char output[32], int is224 ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function calculates the SHA-224 or SHA-256 checksum * of a buffer. * * The function allocates the context, performs the * calculation, and frees the context. * * The SHA-256 result is calculated as * output = SHA-256(input buffer). * * \deprecated Superseded by mbedtls_sha256_ret() in 2.7.0. * * \param input The buffer holding the data. This must be a readable * buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. * \param output The SHA-224 or SHA-256 checksum result. This must be * a writable buffer of length \c 32 Bytes. * \param is224 Determines which function to use. This must be either * \c 0 for SHA-256, or \c 1 for SHA-224. */ MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input, size_t ilen, unsigned char output[32], int is224 ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief The SHA-224 and SHA-256 checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_sha256_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_sha256.h */
11,183
C++
.h
269
37.464684
110
0.622979
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,524
pem.h
w1hkj_fldigi/src/include/mbedtls/pem.h
/** * \file pem.h * * \brief Privacy Enhanced Mail (PEM) decoding */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PEM_H #define MBEDTLS_PEM_H #include <stddef.h> /** * \name PEM Error codes * These error codes are returned in case of errors reading the * PEM data. * \{ */ #define MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT -0x1080 /**< No PEM header or footer found. */ #define MBEDTLS_ERR_PEM_INVALID_DATA -0x1100 /**< PEM string is not as expected. */ #define MBEDTLS_ERR_PEM_ALLOC_FAILED -0x1180 /**< Failed to allocate memory. */ #define MBEDTLS_ERR_PEM_INVALID_ENC_IV -0x1200 /**< RSA IV is not in hex-format. */ #define MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG -0x1280 /**< Unsupported key encryption algorithm. */ #define MBEDTLS_ERR_PEM_PASSWORD_REQUIRED -0x1300 /**< Private key password can't be empty. */ #define MBEDTLS_ERR_PEM_PASSWORD_MISMATCH -0x1380 /**< Given private key password does not allow for correct decryption. */ #define MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE -0x1400 /**< Unavailable feature, e.g. hashing/encryption combination. */ #define MBEDTLS_ERR_PEM_BAD_INPUT_DATA -0x1480 /**< Bad input parameters to function. */ /* \} name */ #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_PEM_PARSE_C) /** * \brief PEM context structure */ typedef struct mbedtls_pem_context { unsigned char *buf; /*!< buffer for decoded data */ size_t buflen; /*!< length of the buffer */ unsigned char *info; /*!< buffer for extra header information */ } mbedtls_pem_context; /** * \brief PEM context setup * * \param ctx context to be initialized */ void mbedtls_pem_init( mbedtls_pem_context *ctx ); /** * \brief Read a buffer for PEM information and store the resulting * data into the specified context buffers. * * \param ctx context to use * \param header header string to seek and expect * \param footer footer string to seek and expect * \param data source data to look in (must be nul-terminated) * \param pwd password for decryption (can be NULL) * \param pwdlen length of password * \param use_len destination for total length used (set after header is * correctly read, so unless you get * MBEDTLS_ERR_PEM_BAD_INPUT_DATA or * MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT, use_len is * the length to skip) * * \note Attempts to check password correctness by verifying if * the decrypted text starts with an ASN.1 sequence of * appropriate length * * \return 0 on success, or a specific PEM error code */ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const char *footer, const unsigned char *data, const unsigned char *pwd, size_t pwdlen, size_t *use_len ); /** * \brief PEM context memory freeing * * \param ctx context to be freed */ void mbedtls_pem_free( mbedtls_pem_context *ctx ); #endif /* MBEDTLS_PEM_PARSE_C */ #if defined(MBEDTLS_PEM_WRITE_C) /** * \brief Write a buffer of PEM information from a DER encoded * buffer. * * \param header header string to write * \param footer footer string to write * \param der_data DER data to write * \param der_len length of the DER data * \param buf buffer to write to * \param buf_len length of output buffer * \param olen total length written / required (if buf_len is not enough) * * \return 0 on success, or a specific PEM or BASE64 error code. On * MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL olen is the required * size. */ int mbedtls_pem_write_buffer( const char *header, const char *footer, const unsigned char *der_data, size_t der_len, unsigned char *buf, size_t buf_len, size_t *olen ); #endif /* MBEDTLS_PEM_WRITE_C */ #ifdef __cplusplus } #endif #endif /* pem.h */
5,100
C++
.h
122
39.139344
140
0.646538
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,525
blowfish.h
w1hkj_fldigi/src/include/mbedtls/blowfish.h
/** * \file blowfish.h * * \brief Blowfish block cipher */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_BLOWFISH_H #define MBEDTLS_BLOWFISH_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> #include "platform_util.h" #define MBEDTLS_BLOWFISH_ENCRYPT 1 #define MBEDTLS_BLOWFISH_DECRYPT 0 #define MBEDTLS_BLOWFISH_MAX_KEY_BITS 448 #define MBEDTLS_BLOWFISH_MIN_KEY_BITS 32 #define MBEDTLS_BLOWFISH_ROUNDS 16 /**< Rounds to use. When increasing this value, make sure to extend the initialisation vectors */ #define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */ #if !defined(MBEDTLS_DEPRECATED_REMOVED) #define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0016 ) #endif /* !MBEDTLS_DEPRECATED_REMOVED */ #define MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA -0x0016 /**< Bad input data. */ #define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */ /* MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017 /**< Blowfish hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_BLOWFISH_ALT) // Regular implementation // /** * \brief Blowfish context structure */ typedef struct mbedtls_blowfish_context { uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2]; /*!< Blowfish round keys */ uint32_t S[4][256]; /*!< key dependent S-boxes */ } mbedtls_blowfish_context; #else /* MBEDTLS_BLOWFISH_ALT */ #include "blowfish_alt.h" #endif /* MBEDTLS_BLOWFISH_ALT */ /** * \brief Initialize a Blowfish context. * * \param ctx The Blowfish context to be initialized. * This must not be \c NULL. */ void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx ); /** * \brief Clear a Blowfish context. * * \param ctx The Blowfish context to be cleared. * This may be \c NULL, in which case this function * returns immediately. If it is not \c NULL, it must * point to an initialized Blowfish context. */ void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx ); /** * \brief Perform a Blowfish key schedule operation. * * \param ctx The Blowfish context to perform the key schedule on. * \param key The encryption key. This must be a readable buffer of * length \p keybits Bits. * \param keybits The length of \p key in Bits. This must be between * \c 32 and \c 448 and a multiple of \c 8. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief Perform a Blowfish-ECB block encryption/decryption operation. * * \param ctx The Blowfish context to use. This must be initialized * and bound to a key. * \param mode The mode of operation. Possible values are * #MBEDTLS_BLOWFISH_ENCRYPT for encryption, or * #MBEDTLS_BLOWFISH_DECRYPT for decryption. * \param input The input block. This must be a readable buffer * of size \c 8 Bytes. * \param output The output block. This must be a writable buffer * of size \c 8 Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, int mode, const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief Perform a Blowfish-CBC buffer encryption/decryption operation. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If on the other hand you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * \param ctx The Blowfish context to use. This must be initialized * and bound to a key. * \param mode The mode of operation. Possible values are * #MBEDTLS_BLOWFISH_ENCRYPT for encryption, or * #MBEDTLS_BLOWFISH_DECRYPT for decryption. * \param length The length of the input data in Bytes. This must be * multiple of \c 8. * \param iv The initialization vector. This must be a read/write buffer * of length \c 8 Bytes. It is updated by this function. * \param input The input data. This must be a readable buffer of length * \p length Bytes. * \param output The output data. This must be a writable buffer of length * \p length Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CIPHER_MODE_CFB) /** * \brief Perform a Blowfish CFB buffer encryption/decryption operation. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If on the other hand you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * \param ctx The Blowfish context to use. This must be initialized * and bound to a key. * \param mode The mode of operation. Possible values are * #MBEDTLS_BLOWFISH_ENCRYPT for encryption, or * #MBEDTLS_BLOWFISH_DECRYPT for decryption. * \param length The length of the input data in Bytes. * \param iv_off The offset in the initialiation vector. * The value pointed to must be smaller than \c 8 Bytes. * It is updated by this function to support the aforementioned * streaming usage. * \param iv The initialization vector. This must be a read/write buffer * of size \c 8 Bytes. It is updated after use. * \param input The input data. This must be a readable buffer of length * \p length Bytes. * \param output The output data. This must be a writable buffer of length * \p length Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output ); #endif /*MBEDTLS_CIPHER_MODE_CFB */ #if defined(MBEDTLS_CIPHER_MODE_CTR) /** * \brief Perform a Blowfish-CTR buffer encryption/decryption operation. * * \warning You must never reuse a nonce value with the same key. Doing so * would void the encryption for the two messages encrypted with * the same nonce and key. * * There are two common strategies for managing nonces with CTR: * * 1. You can handle everything as a single message processed over * successive calls to this function. In that case, you want to * set \p nonce_counter and \p nc_off to 0 for the first call, and * then preserve the values of \p nonce_counter, \p nc_off and \p * stream_block across calls to this function as they will be * updated by this function. * * With this strategy, you must not encrypt more than 2**64 * blocks of data with the same key. * * 2. You can encrypt separate messages by dividing the \p * nonce_counter buffer in two areas: the first one used for a * per-message nonce, handled by yourself, and the second one * updated by this function internally. * * For example, you might reserve the first 4 bytes for the * per-message nonce, and the last 4 bytes for internal use. In that * case, before calling this function on a new message you need to * set the first 4 bytes of \p nonce_counter to your chosen nonce * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p * stream_block to be ignored). That way, you can encrypt at most * 2**32 messages of up to 2**32 blocks each with the same key. * * The per-message nonce (or information sufficient to reconstruct * it) needs to be communicated with the ciphertext and must be unique. * The recommended way to ensure uniqueness is to use a message * counter. * * Note that for both stategies, sizes are measured in blocks and * that a Blowfish block is 8 bytes. * * \warning Upon return, \p stream_block contains sensitive data. Its * content must not be written to insecure storage and should be * securely discarded as soon as it's no longer needed. * * \param ctx The Blowfish context to use. This must be initialized * and bound to a key. * \param length The length of the input data in Bytes. * \param nc_off The offset in the current stream_block (for resuming * within current cipher stream). The offset pointer * should be \c 0 at the start of a stream and must be * smaller than \c 8. It is updated by this function. * \param nonce_counter The 64-bit nonce and counter. This must point to a * read/write buffer of length \c 8 Bytes. * \param stream_block The saved stream-block for resuming. This must point to * a read/write buffer of length \c 8 Bytes. * \param input The input data. This must be a readable buffer of * length \p length Bytes. * \param output The output data. This must be a writable buffer of * length \p length Bytes. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ #ifdef __cplusplus } #endif #endif /* blowfish.h */
12,726
C++
.h
269
43.6171
145
0.627965
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,526
bignum.h
w1hkj_fldigi/src/include/mbedtls/bignum.h
/** * \file bignum.h * * \brief Multi-precision integer library */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_BIGNUM_H #define MBEDTLS_BIGNUM_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> #if defined(MBEDTLS_FS_IO) #include <stdio.h> #endif #define MBEDTLS_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An error occurred while reading from or writing to a file. */ #define MBEDTLS_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_MPI_INVALID_CHARACTER -0x0006 /**< There is an invalid character in the digit string. */ #define MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< The buffer is too small to write to. */ #define MBEDTLS_ERR_MPI_NEGATIVE_VALUE -0x000A /**< The input arguments are negative or result in illegal output. */ #define MBEDTLS_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< The input argument for division is zero, which is not allowed. */ #define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */ #define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */ #define MBEDTLS_MPI_CHK(f) do { if( ( ret = f ) != 0 ) goto cleanup; } while( 0 ) /* * Maximum size MPIs are allowed to grow to in number of limbs. */ #define MBEDTLS_MPI_MAX_LIMBS 10000 #if !defined(MBEDTLS_MPI_WINDOW_SIZE) /* * Maximum window size used for modular exponentiation. Default: 6 * Minimum value: 1. Maximum value: 6. * * Result is an array of ( 2 << MBEDTLS_MPI_WINDOW_SIZE ) MPIs used * for the sliding window calculation. (So 64 by default) * * Reduction in size, reduces speed. */ #define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ #endif /* !MBEDTLS_MPI_WINDOW_SIZE */ #if !defined(MBEDTLS_MPI_MAX_SIZE) /* * Maximum size of MPIs allowed in bits and bytes for user-MPIs. * ( Default: 512 bytes => 4096 bits, Maximum tested: 2048 bytes => 16384 bits ) * * Note: Calculations can temporarily result in larger MPIs. So the number * of limbs required (MBEDTLS_MPI_MAX_LIMBS) is higher. */ #define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ #endif /* !MBEDTLS_MPI_MAX_SIZE */ #define MBEDTLS_MPI_MAX_BITS ( 8 * MBEDTLS_MPI_MAX_SIZE ) /**< Maximum number of bits for usable MPIs. */ /* * When reading from files with mbedtls_mpi_read_file() and writing to files with * mbedtls_mpi_write_file() the buffer should have space * for a (short) label, the MPI (in the provided radix), the newline * characters and the '\0'. * * By default we assume at least a 10 char label, a minimum radix of 10 * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars). * Autosized at compile time for at least a 10 char label, a minimum radix * of 10 (decimal) for a number of MBEDTLS_MPI_MAX_BITS size. * * This used to be statically sized to 1250 for a maximum of 4096 bit * numbers (1234 decimal chars). * * Calculate using the formula: * MBEDTLS_MPI_RW_BUFFER_SIZE = ceil(MBEDTLS_MPI_MAX_BITS / ln(10) * ln(2)) + * LabelSize + 6 */ #define MBEDTLS_MPI_MAX_BITS_SCALE100 ( 100 * MBEDTLS_MPI_MAX_BITS ) #define MBEDTLS_LN_2_DIV_LN_10_SCALE100 332 #define MBEDTLS_MPI_RW_BUFFER_SIZE ( ((MBEDTLS_MPI_MAX_BITS_SCALE100 + MBEDTLS_LN_2_DIV_LN_10_SCALE100 - 1) / MBEDTLS_LN_2_DIV_LN_10_SCALE100) + 10 + 6 ) /* * Define the base integer type, architecture-wise. * * 32 or 64-bit integer types can be forced regardless of the underlying * architecture by defining MBEDTLS_HAVE_INT32 or MBEDTLS_HAVE_INT64 * respectively and undefining MBEDTLS_HAVE_ASM. * * Double-width integers (e.g. 128-bit in 64-bit architectures) can be * disabled by defining MBEDTLS_NO_UDBL_DIVISION. */ #if !defined(MBEDTLS_HAVE_INT32) #if defined(_MSC_VER) && defined(_M_AMD64) /* Always choose 64-bit when using MSC */ #if !defined(MBEDTLS_HAVE_INT64) #define MBEDTLS_HAVE_INT64 #endif /* !MBEDTLS_HAVE_INT64 */ typedef int64_t mbedtls_mpi_sint; typedef uint64_t mbedtls_mpi_uint; #elif defined(__GNUC__) && ( \ defined(__amd64__) || defined(__x86_64__) || \ defined(__ppc64__) || defined(__powerpc64__) || \ defined(__ia64__) || defined(__alpha__) || \ ( defined(__sparc__) && defined(__arch64__) ) || \ defined(__s390x__) || defined(__mips64) ) #if !defined(MBEDTLS_HAVE_INT64) #define MBEDTLS_HAVE_INT64 #endif /* MBEDTLS_HAVE_INT64 */ typedef int64_t mbedtls_mpi_sint; typedef uint64_t mbedtls_mpi_uint; #if !defined(MBEDTLS_NO_UDBL_DIVISION) /* mbedtls_t_udbl defined as 128-bit unsigned int */ typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI))); #define MBEDTLS_HAVE_UDBL #endif /* !MBEDTLS_NO_UDBL_DIVISION */ #elif defined(__ARMCC_VERSION) && defined(__aarch64__) /* * __ARMCC_VERSION is defined for both armcc and armclang and * __aarch64__ is only defined by armclang when compiling 64-bit code */ #if !defined(MBEDTLS_HAVE_INT64) #define MBEDTLS_HAVE_INT64 #endif /* !MBEDTLS_HAVE_INT64 */ typedef int64_t mbedtls_mpi_sint; typedef uint64_t mbedtls_mpi_uint; #if !defined(MBEDTLS_NO_UDBL_DIVISION) /* mbedtls_t_udbl defined as 128-bit unsigned int */ typedef __uint128_t mbedtls_t_udbl; #define MBEDTLS_HAVE_UDBL #endif /* !MBEDTLS_NO_UDBL_DIVISION */ #elif defined(MBEDTLS_HAVE_INT64) /* Force 64-bit integers with unknown compiler */ typedef int64_t mbedtls_mpi_sint; typedef uint64_t mbedtls_mpi_uint; #endif #endif /* !MBEDTLS_HAVE_INT32 */ #if !defined(MBEDTLS_HAVE_INT64) /* Default to 32-bit compilation */ #if !defined(MBEDTLS_HAVE_INT32) #define MBEDTLS_HAVE_INT32 #endif /* !MBEDTLS_HAVE_INT32 */ typedef int32_t mbedtls_mpi_sint; typedef uint32_t mbedtls_mpi_uint; #if !defined(MBEDTLS_NO_UDBL_DIVISION) typedef uint64_t mbedtls_t_udbl; #define MBEDTLS_HAVE_UDBL #endif /* !MBEDTLS_NO_UDBL_DIVISION */ #endif /* !MBEDTLS_HAVE_INT64 */ #ifdef __cplusplus extern "C" { #endif /** * \brief MPI structure */ typedef struct mbedtls_mpi { int s; /*!< integer sign */ size_t n; /*!< total # of limbs */ mbedtls_mpi_uint *p; /*!< pointer to limbs */ } mbedtls_mpi; /** * \brief Initialize an MPI context. * * This makes the MPI ready to be set or freed, * but does not define a value for the MPI. * * \param X The MPI context to initialize. This must not be \c NULL. */ void mbedtls_mpi_init( mbedtls_mpi *X ); /** * \brief This function frees the components of an MPI context. * * \param X The MPI context to be cleared. This may be \c NULL, * in which case this function is a no-op. If it is * not \c NULL, it must point to an initialized MPI. */ void mbedtls_mpi_free( mbedtls_mpi *X ); /** * \brief Enlarge an MPI to the specified number of limbs. * * \note This function does nothing if the MPI is * already large enough. * * \param X The MPI to grow. It must be initialized. * \param nblimbs The target number of limbs. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs ); /** * \brief This function resizes an MPI downwards, keeping at least the * specified number of limbs. * * If \c X is smaller than \c nblimbs, it is resized up * instead. * * \param X The MPI to shrink. This must point to an initialized MPI. * \param nblimbs The minimum number of limbs to keep. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed * (this can only happen when resizing up). * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs ); /** * \brief Make a copy of an MPI. * * \param X The destination MPI. This must point to an initialized MPI. * \param Y The source MPI. This must point to an initialized MPI. * * \note The limb-buffer in the destination MPI is enlarged * if necessary to hold the value in the source MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ); /** * \brief Swap the contents of two MPIs. * * \param X The first MPI. It must be initialized. * \param Y The second MPI. It must be initialized. */ void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ); /** * \brief Perform a safe conditional copy of MPI which doesn't * reveal whether the condition was true or not. * * \param X The MPI to conditionally assign to. This must point * to an initialized MPI. * \param Y The MPI to be assigned from. This must point to an * initialized MPI. * \param assign The condition deciding whether to perform the * assignment or not. Possible values: * * \c 1: Perform the assignment `X = Y`. * * \c 0: Keep the original value of \p X. * * \note This function is equivalent to * `if( assign ) mbedtls_mpi_copy( X, Y );` * except that it avoids leaking any information about whether * the assignment was done or not (the above code may leak * information through branch prediction and/or memory access * patterns analysis). * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign ); /** * \brief Perform a safe conditional swap which doesn't * reveal whether the condition was true or not. * * \param X The first MPI. This must be initialized. * \param Y The second MPI. This must be initialized. * \param assign The condition deciding whether to perform * the swap or not. Possible values: * * \c 1: Swap the values of \p X and \p Y. * * \c 0: Keep the original values of \p X and \p Y. * * \note This function is equivalent to * if( assign ) mbedtls_mpi_swap( X, Y ); * except that it avoids leaking any information about whether * the assignment was done or not (the above code may leak * information through branch prediction and/or memory access * patterns analysis). * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on other kinds of failure. * */ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char assign ); /** * \brief Store integer value in MPI. * * \param X The MPI to set. This must be initialized. * \param z The value to use. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ); /** * \brief Get a specific bit from an MPI. * * \param X The MPI to query. This must be initialized. * \param pos Zero-based index of the bit to query. * * \return \c 0 or \c 1 on success, depending on whether bit \c pos * of \c X is unset or set. * \return A negative error code on failure. */ int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos ); /** * \brief Modify a specific bit in an MPI. * * \note This function will grow the target MPI if necessary to set a * bit to \c 1 in a not yet existing limb. It will not grow if * the bit should be set to \c 0. * * \param X The MPI to modify. This must be initialized. * \param pos Zero-based index of the bit to modify. * \param val The desired value of bit \c pos: \c 0 or \c 1. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val ); /** * \brief Return the number of bits of value \c 0 before the * least significant bit of value \c 1. * * \note This is the same as the zero-based index of * the least significant bit of value \c 1. * * \param X The MPI to query. * * \return The number of bits of value \c 0 before the least significant * bit of value \c 1 in \p X. */ size_t mbedtls_mpi_lsb( const mbedtls_mpi *X ); /** * \brief Return the number of bits up to and including the most * significant bit of value \c 1. * * * \note This is same as the one-based index of the most * significant bit of value \c 1. * * \param X The MPI to query. This must point to an initialized MPI. * * \return The number of bits up to and including the most * significant bit of value \c 1. */ size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X ); /** * \brief Return the total size of an MPI value in bytes. * * \param X The MPI to use. This must point to an initialized MPI. * * \note The value returned by this function may be less than * the number of bytes used to store \p X internally. * This happens if and only if there are trailing bytes * of value zero. * * \return The least number of bytes capable of storing * the absolute value of \p X. */ size_t mbedtls_mpi_size( const mbedtls_mpi *X ); /** * \brief Import an MPI from an ASCII string. * * \param X The destination MPI. This must point to an initialized MPI. * \param radix The numeric base of the input string. * \param s Null-terminated string buffer. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ); /** * \brief Export an MPI to an ASCII string. * * \param X The source MPI. This must point to an initialized MPI. * \param radix The numeric base of the output string. * \param buf The buffer to write the string to. This must be writable * buffer of length \p buflen Bytes. * \param buflen The available size in Bytes of \p buf. * \param olen The address at which to store the length of the string * written, including the final \c NULL byte. This must * not be \c NULL. * * \note You can call this function with `buflen == 0` to obtain the * minimum required buffer size in `*olen`. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if the target buffer \p buf * is too small to hold the value of \p X in the desired base. * In this case, `*olen` is nonetheless updated to contain the * size of \p buf required for a successful call. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, char *buf, size_t buflen, size_t *olen ); #if defined(MBEDTLS_FS_IO) /** * \brief Read an MPI from a line in an opened file. * * \param X The destination MPI. This must point to an initialized MPI. * \param radix The numeric base of the string representation used * in the source line. * \param fin The input file handle to use. This must not be \c NULL. * * \note On success, this function advances the file stream * to the end of the current line or to EOF. * * The function returns \c 0 on an empty line. * * Leading whitespaces are ignored, as is a * '0x' prefix for radix \c 16. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if the file read buffer * is too small. * \return Another negative error code on failure. */ int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ); /** * \brief Export an MPI into an opened file. * * \param p A string prefix to emit prior to the MPI data. * For example, this might be a label, or "0x" when * printing in base \c 16. This may be \c NULL if no prefix * is needed. * \param X The source MPI. This must point to an initialized MPI. * \param radix The numeric base to be used in the emitted string. * \param fout The output file handle. This may be \c NULL, in which case * the output is written to \c stdout. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout ); #endif /* MBEDTLS_FS_IO */ /** * \brief Import an MPI from unsigned big endian binary data. * * \param X The destination MPI. This must point to an initialized MPI. * \param buf The input buffer. This must be a readable buffer of length * \p buflen Bytes. * \param buflen The length of the input buffer \p p in Bytes. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen ); /** * \brief Export an MPI into unsigned big endian binary data * of fixed size. * * \param X The source MPI. This must point to an initialized MPI. * \param buf The output buffer. This must be a writable buffer of length * \p buflen Bytes. * \param buflen The size of the output buffer \p buf in Bytes. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't * large enough to hold the value of \p X. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen ); /** * \brief Perform a left-shift on an MPI: X <<= count * * \param X The MPI to shift. This must point to an initialized MPI. * \param count The number of bits to shift by. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count ); /** * \brief Perform a right-shift on an MPI: X >>= count * * \param X The MPI to shift. This must point to an initialized MPI. * \param count The number of bits to shift by. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count ); /** * \brief Compare the absolute values of two MPIs. * * \param X The left-hand MPI. This must point to an initialized MPI. * \param Y The right-hand MPI. This must point to an initialized MPI. * * \return \c 1 if `|X|` is greater than `|Y|`. * \return \c -1 if `|X|` is lesser than `|Y|`. * \return \c 0 if `|X|` is equal to `|Y|`. */ int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y ); /** * \brief Compare two MPIs. * * \param X The left-hand MPI. This must point to an initialized MPI. * \param Y The right-hand MPI. This must point to an initialized MPI. * * \return \c 1 if \p X is greater than \p Y. * \return \c -1 if \p X is lesser than \p Y. * \return \c 0 if \p X is equal to \p Y. */ int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y ); /** * \brief Compare an MPI with an integer. * * \param X The left-hand MPI. This must point to an initialized MPI. * \param z The integer value to compare \p X to. * * \return \c 1 if \p X is greater than \p z. * \return \c -1 if \p X is lesser than \p z. * \return \c 0 if \p X is equal to \p z. */ int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z ); /** * \brief Perform an unsigned addition of MPIs: X = |A| + |B| * * \param X The destination MPI. This must point to an initialized MPI. * \param A The first summand. This must point to an initialized MPI. * \param B The second summand. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform an unsigned subtraction of MPIs: X = |A| - |B| * * \param X The destination MPI. This must point to an initialized MPI. * \param A The minuend. This must point to an initialized MPI. * \param B The subtrahend. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p B is greater than \p A. * \return Another negative error code on different kinds of failure. * */ int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform a signed addition of MPIs: X = A + B * * \param X The destination MPI. This must point to an initialized MPI. * \param A The first summand. This must point to an initialized MPI. * \param B The second summand. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform a signed subtraction of MPIs: X = A - B * * \param X The destination MPI. This must point to an initialized MPI. * \param A The minuend. This must point to an initialized MPI. * \param B The subtrahend. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform a signed addition of an MPI and an integer: X = A + b * * \param X The destination MPI. This must point to an initialized MPI. * \param A The first summand. This must point to an initialized MPI. * \param b The second summand. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ); /** * \brief Perform a signed subtraction of an MPI and an integer: * X = A - b * * \param X The destination MPI. This must point to an initialized MPI. * \param A The minuend. This must point to an initialized MPI. * \param b The subtrahend. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ); /** * \brief Perform a multiplication of two MPIs: X = A * B * * \param X The destination MPI. This must point to an initialized MPI. * \param A The first factor. This must point to an initialized MPI. * \param B The second factor. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. * */ int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform a multiplication of an MPI with an unsigned integer: * X = A * b * * \param X The destination MPI. This must point to an initialized MPI. * \param A The first factor. This must point to an initialized MPI. * \param b The second factor. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. * */ int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b ); /** * \brief Perform a division with remainder of two MPIs: * A = Q * B + R * * \param Q The destination MPI for the quotient. * This may be \c NULL if the value of the * quotient is not needed. * \param R The destination MPI for the remainder value. * This may be \c NULL if the value of the * remainder is not needed. * \param A The dividend. This must point to an initialized MPi. * \param B The divisor. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p B equals zero. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform a division with remainder of an MPI by an integer: * A = Q * b + R * * \param Q The destination MPI for the quotient. * This may be \c NULL if the value of the * quotient is not needed. * \param R The destination MPI for the remainder value. * This may be \c NULL if the value of the * remainder is not needed. * \param A The dividend. This must point to an initialized MPi. * \param b The divisor. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p b equals zero. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b ); /** * \brief Perform a modular reduction. R = A mod B * * \param R The destination MPI for the residue value. * This must point to an initialized MPI. * \param A The MPI to compute the residue of. * This must point to an initialized MPI. * \param B The base of the modular reduction. * This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p B equals zero. * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p B is negative. * \return Another negative error code on different kinds of failure. * */ int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Perform a modular reduction with respect to an integer. * r = A mod b * * \param r The address at which to store the residue. * This must not be \c NULL. * \param A The MPI to compute the residue of. * This must point to an initialized MPi. * \param b The integer base of the modular reduction. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p b equals zero. * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p b is negative. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b ); /** * \brief Perform a sliding-window exponentiation: X = A^E mod N * * \param X The destination MPI. This must point to an initialized MPI. * \param A The base of the exponentiation. * This must point to an initialized MPI. * \param E The exponent MPI. This must point to an initialized MPI. * \param N The base for the modular reduction. This must point to an * initialized MPI. * \param _RR A helper MPI depending solely on \p N which can be used to * speed-up multiple modular exponentiations for the same value * of \p N. This may be \c NULL. If it is not \c NULL, it must * point to an initialized MPI. If it hasn't been used after * the call to mbedtls_mpi_init(), this function will compute * the helper value and store it in \p _RR for reuse on * subsequent calls to this function. Otherwise, the function * will assume that \p _RR holds the helper value set by a * previous call to mbedtls_mpi_exp_mod(), and reuse it. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \c N is negative or * even, or if \c E is negative. * \return Another negative error code on different kinds of failures. * */ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR ); /** * \brief Fill an MPI with a number of random bytes. * * \param X The destination MPI. This must point to an initialized MPI. * \param size The number of random bytes to generate. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. This may be * \c NULL if \p f_rng doesn't need a context argument. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on failure. * * \note The bytes obtained from the RNG are interpreted * as a big-endian representation of an MPI; this can * be relevant in applications like deterministic ECDSA. */ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Compute the greatest common divisor: G = gcd(A, B) * * \param G The destination MPI. This must point to an initialized MPI. * \param A The first operand. This must point to an initialized MPI. * \param B The second operand. This must point to an initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B ); /** * \brief Compute the modular inverse: X = A^-1 mod N * * \param X The destination MPI. This must point to an initialized MPI. * \param A The MPI to calculate the modular inverse of. This must point * to an initialized MPI. * \param N The base of the modular inversion. This must point to an * initialized MPI. * * \return \c 0 if successful. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p N is less than * or equal to one. * \return #MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if \p has no modular inverse * with respect to \p N. */ int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Perform a Miller-Rabin primality test with error * probability of 2<sup>-80</sup>. * * \deprecated Superseded by mbedtls_mpi_is_prime_ext() which allows * specifying the number of Miller-Rabin rounds. * * \param X The MPI to check for primality. * This must point to an initialized MPI. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. * This may be \c NULL if \p f_rng doesn't use a * context parameter. * * \return \c 0 if successful, i.e. \p X is probably prime. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if \p X is not prime. * \return Another negative error code on other kinds of failure. */ MBEDTLS_DEPRECATED int mbedtls_mpi_is_prime( const mbedtls_mpi *X, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Miller-Rabin primality test. * * \warning If \p X is potentially generated by an adversary, for example * when validating cryptographic parameters that you didn't * generate yourself and that are supposed to be prime, then * \p rounds should be at least the half of the security * strength of the cryptographic algorithm. On the other hand, * if \p X is chosen uniformly or non-adversially (as is the * case when mbedtls_mpi_gen_prime calls this function), then * \p rounds can be much lower. * * \param X The MPI to check for primality. * This must point to an initialized MPI. * \param rounds The number of bases to perform the Miller-Rabin primality * test for. The probability of returning 0 on a composite is * at most 2<sup>-2*\p rounds</sup>. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. * This may be \c NULL if \p f_rng doesn't use * a context parameter. * * \return \c 0 if successful, i.e. \p X is probably prime. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if \p X is not prime. * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_is_prime_ext( const mbedtls_mpi *X, int rounds, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Flags for mbedtls_mpi_gen_prime() * * Each of these flags is a constraint on the result X returned by * mbedtls_mpi_gen_prime(). */ typedef enum { MBEDTLS_MPI_GEN_PRIME_FLAG_DH = 0x0001, /**< (X-1)/2 is prime too */ MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR = 0x0002, /**< lower error rate from 2<sup>-80</sup> to 2<sup>-128</sup> */ } mbedtls_mpi_gen_prime_flag_t; /** * \brief Generate a prime number. * * \param X The destination MPI to store the generated prime in. * This must point to an initialized MPi. * \param nbits The required size of the destination MPI in bits. * This must be between \c 3 and #MBEDTLS_MPI_MAX_BITS. * \param flags A mask of flags of type #mbedtls_mpi_gen_prime_flag_t. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. * This may be \c NULL if \p f_rng doesn't use * a context parameter. * * \return \c 0 if successful, in which case \p X holds a * probably prime number. * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. * \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if `nbits` is not between * \c 3 and #MBEDTLS_MPI_MAX_BITS. */ int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_mpi_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* bignum.h */
40,636
C++
.h
898
42.185969
165
0.616528
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,527
platform.h
w1hkj_fldigi/src/include/mbedtls/platform.h
/** * \file platform.h * * \brief This file contains the definitions and functions of the * Mbed TLS platform abstraction layer. * * The platform abstraction layer removes the need for the library * to directly link to standard C library functions or operating * system services, making the library easier to port and embed. * Application developers and users of the library can provide their own * implementations of these functions, or implementations specific to * their platform, which can be statically linked to the library or * dynamically configured at runtime. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PLATFORM_H #define MBEDTLS_PLATFORM_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #if defined(MBEDTLS_HAVE_TIME) #include "platform_time.h" #endif #define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070 /**< Hardware accelerator failed */ #define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072 /**< The requested feature is not supported by the platform */ #ifdef __cplusplus extern "C" { #endif /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h or define them on the compiler command line. * \{ */ #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) #include <stdio.h> #include <stdlib.h> #include <time.h> #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) #if defined(_WIN32) #define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< The default \c snprintf function to use. */ #else #define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< The default \c snprintf function to use. */ #endif #endif #if !defined(MBEDTLS_PLATFORM_STD_PRINTF) #define MBEDTLS_PLATFORM_STD_PRINTF printf /**< The default \c printf function to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF) #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< The default \c fprintf function to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_CALLOC) #define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< The default \c calloc function to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_FREE) #define MBEDTLS_PLATFORM_STD_FREE free /**< The default \c free function to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_EXIT) #define MBEDTLS_PLATFORM_STD_EXIT exit /**< The default \c exit function to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_TIME) #define MBEDTLS_PLATFORM_STD_TIME time /**< The default \c time function to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) #define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< The default exit value to use. */ #endif #if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) #define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< The default exit value to use. */ #endif #if defined(MBEDTLS_FS_IO) #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) #define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read #endif #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write #endif #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE) #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" #endif #endif /* MBEDTLS_FS_IO */ #else /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) #include MBEDTLS_PLATFORM_STD_MEM_HDR #endif #endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ /* \} name SECTION: Module settings */ /* * The function pointers for calloc and free. */ #if defined(MBEDTLS_PLATFORM_MEMORY) #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \ defined(MBEDTLS_PLATFORM_CALLOC_MACRO) #define mbedtls_free MBEDTLS_PLATFORM_FREE_MACRO #define mbedtls_calloc MBEDTLS_PLATFORM_CALLOC_MACRO #else /* For size_t */ #include <stddef.h> extern void *mbedtls_calloc( size_t n, size_t size ); extern void mbedtls_free( void *ptr ); /** * \brief This function dynamically sets the memory-management * functions used by the library, during runtime. * * \param calloc_func The \c calloc function implementation. * \param free_func The \c free function implementation. * * \return \c 0. */ int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ), void (*free_func)( void * ) ); #endif /* MBEDTLS_PLATFORM_FREE_MACRO && MBEDTLS_PLATFORM_CALLOC_MACRO */ #else /* !MBEDTLS_PLATFORM_MEMORY */ #define mbedtls_free free #define mbedtls_calloc calloc #endif /* MBEDTLS_PLATFORM_MEMORY && !MBEDTLS_PLATFORM_{FREE,CALLOC}_MACRO */ /* * The function pointers for fprintf */ #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) /* We need FILE * */ #include <stdio.h> extern int (*mbedtls_fprintf)( FILE *stream, const char *format, ... ); /** * \brief This function dynamically configures the fprintf * function that is called when the * mbedtls_fprintf() function is invoked by the library. * * \param fprintf_func The \c fprintf function implementation. * * \return \c 0. */ int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *, ... ) ); #else #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) #define mbedtls_fprintf MBEDTLS_PLATFORM_FPRINTF_MACRO #else #define mbedtls_fprintf fprintf #endif /* MBEDTLS_PLATFORM_FPRINTF_MACRO */ #endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */ /* * The function pointers for printf */ #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) extern int (*mbedtls_printf)( const char *format, ... ); /** * \brief This function dynamically configures the snprintf * function that is called when the mbedtls_snprintf() * function is invoked by the library. * * \param printf_func The \c printf function implementation. * * \return \c 0 on success. */ int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) ); #else /* !MBEDTLS_PLATFORM_PRINTF_ALT */ #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) #define mbedtls_printf MBEDTLS_PLATFORM_PRINTF_MACRO #else #define mbedtls_printf printf #endif /* MBEDTLS_PLATFORM_PRINTF_MACRO */ #endif /* MBEDTLS_PLATFORM_PRINTF_ALT */ /* * The function pointers for snprintf * * The snprintf implementation should conform to C99: * - it *must* always correctly zero-terminate the buffer * (except when n == 0, then it must leave the buffer untouched) * - however it is acceptable to return -1 instead of the required length when * the destination buffer is too short. */ #if defined(_WIN32) /* For Windows (inc. MSYS2), we provide our own fixed implementation */ int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... ); #endif #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) extern int (*mbedtls_snprintf)( char * s, size_t n, const char * format, ... ); /** * \brief This function allows configuring a custom * \c snprintf function pointer. * * \param snprintf_func The \c snprintf function implementation. * * \return \c 0 on success. */ int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n, const char * format, ... ) ); #else /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) #define mbedtls_snprintf MBEDTLS_PLATFORM_SNPRINTF_MACRO #else #define mbedtls_snprintf MBEDTLS_PLATFORM_STD_SNPRINTF #endif /* MBEDTLS_PLATFORM_SNPRINTF_MACRO */ #endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ /* * The function pointers for exit */ #if defined(MBEDTLS_PLATFORM_EXIT_ALT) extern void (*mbedtls_exit)( int status ); /** * \brief This function dynamically configures the exit * function that is called when the mbedtls_exit() * function is invoked by the library. * * \param exit_func The \c exit function implementation. * * \return \c 0 on success. */ int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); #else #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) #define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO #else #define mbedtls_exit exit #endif /* MBEDTLS_PLATFORM_EXIT_MACRO */ #endif /* MBEDTLS_PLATFORM_EXIT_ALT */ /* * The default exit values */ #if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) #define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS #else #define MBEDTLS_EXIT_SUCCESS 0 #endif #if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) #define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE #else #define MBEDTLS_EXIT_FAILURE 1 #endif /* * The function pointers for reading from and writing a seed file to * Non-Volatile storage (NV) in a platform-independent way * * Only enabled when the NV seed entropy source is enabled */ #if defined(MBEDTLS_ENTROPY_NV_SEED) #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) /* Internal standard platform definitions */ int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len ); int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len ); #endif #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) extern int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ); extern int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ); /** * \brief This function allows configuring custom seed file writing and * reading functions. * * \param nv_seed_read_func The seed reading function implementation. * \param nv_seed_write_func The seed writing function implementation. * * \return \c 0 on success. */ int mbedtls_platform_set_nv_seed( int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ), int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) ); #else #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \ defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) #define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO #define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO #else #define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read #define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write #endif #endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ #endif /* MBEDTLS_ENTROPY_NV_SEED */ #if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT) /** * \brief The platform context structure. * * \note This structure may be used to assist platform-specific * setup or teardown operations. */ typedef struct mbedtls_platform_context { char dummy; /**< A placeholder member, as empty structs are not portable. */ } mbedtls_platform_context; #else #include "platform_alt.h" #endif /* !MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */ /** * \brief This function performs any platform-specific initialization * operations. * * \note This function should be called before any other library functions. * * Its implementation is platform-specific, and unless * platform-specific code is provided, it does nothing. * * \note The usage and necessity of this function is dependent on the platform. * * \param ctx The platform context. * * \return \c 0 on success. */ int mbedtls_platform_setup( mbedtls_platform_context *ctx ); /** * \brief This function performs any platform teardown operations. * * \note This function should be called after every other Mbed TLS module * has been correctly freed using the appropriate free function. * * Its implementation is platform-specific, and unless * platform-specific code is provided, it does nothing. * * \note The usage and necessity of this function is dependent on the platform. * * \param ctx The platform context. * */ void mbedtls_platform_teardown( mbedtls_platform_context *ctx ); #ifdef __cplusplus } #endif #endif /* platform.h */
12,983
C++
.h
340
36.176471
121
0.714048
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,528
gcm.h
w1hkj_fldigi/src/include/mbedtls/gcm.h
/** * \file gcm.h * * \brief This file contains GCM definitions and functions. * * The Galois/Counter Mode (GCM) for 128-bit block ciphers is defined * in <em>D. McGrew, J. Viega, The Galois/Counter Mode of Operation * (GCM), Natl. Inst. Stand. Technol.</em> * * For more information on GCM, see <em>NIST SP 800-38D: Recommendation for * Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC</em>. * */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_GCM_H #define MBEDTLS_GCM_H #include "cipher.h" #include <stdint.h> #define MBEDTLS_GCM_ENCRYPT 1 #define MBEDTLS_GCM_DECRYPT 0 #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012 /**< Authenticated decryption failed. */ /* MBEDTLS_ERR_GCM_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED -0x0013 /**< GCM hardware accelerator failed. */ #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_GCM_ALT) /** * \brief The GCM context structure. */ typedef struct mbedtls_gcm_context { mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */ uint64_t HL[16]; /*!< Precalculated HTable low. */ uint64_t HH[16]; /*!< Precalculated HTable high. */ uint64_t len; /*!< The total length of the encrypted data. */ uint64_t add_len; /*!< The total length of the additional data. */ unsigned char base_ectr[16]; /*!< The first ECTR for tag. */ unsigned char y[16]; /*!< The Y working value. */ unsigned char buf[16]; /*!< The buf working value. */ int mode; /*!< The operation to perform: #MBEDTLS_GCM_ENCRYPT or #MBEDTLS_GCM_DECRYPT. */ } mbedtls_gcm_context; #else /* !MBEDTLS_GCM_ALT */ #include "gcm_alt.h" #endif /* !MBEDTLS_GCM_ALT */ /** * \brief This function initializes the specified GCM context, * to make references valid, and prepares the context * for mbedtls_gcm_setkey() or mbedtls_gcm_free(). * * The function does not bind the GCM context to a particular * cipher, nor set the key. For this purpose, use * mbedtls_gcm_setkey(). * * \param ctx The GCM context to initialize. This must not be \c NULL. */ void mbedtls_gcm_init( mbedtls_gcm_context *ctx ); /** * \brief This function associates a GCM context with a * cipher algorithm and a key. * * \param ctx The GCM context. This must be initialized. * \param cipher The 128-bit block cipher to use. * \param key The encryption key. This must be a readable buffer of at * least \p keybits bits. * \param keybits The key size in bits. Valid options are: * <ul><li>128 bits</li> * <li>192 bits</li> * <li>256 bits</li></ul> * * \return \c 0 on success. * \return A cipher-specific error code on failure. */ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits ); /** * \brief This function performs GCM encryption or decryption of a buffer. * * \note For encryption, the output buffer can be the same as the * input buffer. For decryption, the output buffer cannot be * the same as input buffer. If the buffers overlap, the output * buffer must trail at least 8 Bytes behind the input buffer. * * \warning When this function performs a decryption, it outputs the * authentication tag and does not verify that the data is * authentic. You should use this function to perform encryption * only. For decryption, use mbedtls_gcm_auth_decrypt() instead. * * \param ctx The GCM context to use for encryption or decryption. This * must be initialized. * \param mode The operation to perform: * - #MBEDTLS_GCM_ENCRYPT to perform authenticated encryption. * The ciphertext is written to \p output and the * authentication tag is written to \p tag. * - #MBEDTLS_GCM_DECRYPT to perform decryption. * The plaintext is written to \p output and the * authentication tag is written to \p tag. * Note that this mode is not recommended, because it does * not verify the authenticity of the data. For this reason, * you should use mbedtls_gcm_auth_decrypt() instead of * calling this function in decryption mode. * \param length The length of the input data, which is equal to the length * of the output data. * \param iv The initialization vector. This must be a readable buffer of * at least \p iv_len Bytes. * \param iv_len The length of the IV. * \param add The buffer holding the additional data. This must be of at * least that size in Bytes. * \param add_len The length of the additional data. * \param input The buffer holding the input data. If \p length is greater * than zero, this must be a readable buffer of at least that * size in Bytes. * \param output The buffer for holding the output data. If \p length is greater * than zero, this must be a writable buffer of at least that * size in Bytes. * \param tag_len The length of the tag to generate. * \param tag The buffer for holding the tag. This must be a readable * buffer of at least \p tag_len Bytes. * * \return \c 0 if the encryption or decryption was performed * successfully. Note that in #MBEDTLS_GCM_DECRYPT mode, * this does not indicate that the data is authentic. * \return #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are * not valid or a cipher-specific error code if the encryption * or decryption failed. */ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx, int mode, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, size_t tag_len, unsigned char *tag ); /** * \brief This function performs a GCM authenticated decryption of a * buffer. * * \note For decryption, the output buffer cannot be the same as * input buffer. If the buffers overlap, the output buffer * must trail at least 8 Bytes behind the input buffer. * * \param ctx The GCM context. This must be initialized. * \param length The length of the ciphertext to decrypt, which is also * the length of the decrypted plaintext. * \param iv The initialization vector. This must be a readable buffer * of at least \p iv_len Bytes. * \param iv_len The length of the IV. * \param add The buffer holding the additional data. This must be of at * least that size in Bytes. * \param add_len The length of the additional data. * \param tag The buffer holding the tag to verify. This must be a * readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to verify. * \param input The buffer holding the ciphertext. If \p length is greater * than zero, this must be a readable buffer of at least that * size. * \param output The buffer for holding the decrypted plaintext. If \p length * is greater than zero, this must be a writable buffer of at * least that size. * * \return \c 0 if successful and authenticated. * \return #MBEDTLS_ERR_GCM_AUTH_FAILED if the tag does not match. * \return #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are * not valid or a cipher-specific error code if the decryption * failed. */ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *tag, size_t tag_len, const unsigned char *input, unsigned char *output ); /** * \brief This function starts a GCM encryption or decryption * operation. * * \param ctx The GCM context. This must be initialized. * \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or * #MBEDTLS_GCM_DECRYPT. * \param iv The initialization vector. This must be a readable buffer of * at least \p iv_len Bytes. * \param iv_len The length of the IV. * \param add The buffer holding the additional data, or \c NULL * if \p add_len is \c 0. * \param add_len The length of the additional data. If \c 0, * \p add may be \c NULL. * * \return \c 0 on success. */ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, int mode, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len ); /** * \brief This function feeds an input buffer into an ongoing GCM * encryption or decryption operation. * * ` The function expects input to be a multiple of 16 * Bytes. Only the last call before calling * mbedtls_gcm_finish() can be less than 16 Bytes. * * \note For decryption, the output buffer cannot be the same as * input buffer. If the buffers overlap, the output buffer * must trail at least 8 Bytes behind the input buffer. * * \param ctx The GCM context. This must be initialized. * \param length The length of the input data. This must be a multiple of * 16 except in the last call before mbedtls_gcm_finish(). * \param input The buffer holding the input data. If \p length is greater * than zero, this must be a readable buffer of at least that * size in Bytes. * \param output The buffer for holding the output data. If \p length is * greater than zero, this must be a writable buffer of at * least that size in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_GCM_BAD_INPUT on failure. */ int mbedtls_gcm_update( mbedtls_gcm_context *ctx, size_t length, const unsigned char *input, unsigned char *output ); /** * \brief This function finishes the GCM operation and generates * the authentication tag. * * It wraps up the GCM stream, and generates the * tag. The tag can have a maximum length of 16 Bytes. * * \param ctx The GCM context. This must be initialized. * \param tag The buffer for holding the tag. This must be a readable * buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to generate. This must be at least * four. * * \return \c 0 on success. * \return #MBEDTLS_ERR_GCM_BAD_INPUT on failure. */ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, unsigned char *tag, size_t tag_len ); /** * \brief This function clears a GCM context and the underlying * cipher sub-context. * * \param ctx The GCM context to clear. If this is \c NULL, the call has * no effect. Otherwise, this must be initialized. */ void mbedtls_gcm_free( mbedtls_gcm_context *ctx ); /** * \brief The GCM checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_gcm_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* gcm.h */
13,920
C++
.h
295
42.732203
108
0.589105
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,529
pk.h
w1hkj_fldigi/src/include/mbedtls/pk.h
/** * \file pk.h * * \brief Public Key abstraction layer */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PK_H #define MBEDTLS_PK_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "md.h" #if defined(MBEDTLS_RSA_C) #include "rsa.h" #endif #if defined(MBEDTLS_ECP_C) #include "ecp.h" #endif #if defined(MBEDTLS_ECDSA_C) #include "ecdsa.h" #endif #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline #endif #define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80 /**< Memory allocation failed. */ #define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00 /**< Type mismatch, eg attempt to encrypt with an ECDSA key */ #define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_PK_FILE_IO_ERROR -0x3E00 /**< Read/write of file failed. */ #define MBEDTLS_ERR_PK_KEY_INVALID_VERSION -0x3D80 /**< Unsupported key version */ #define MBEDTLS_ERR_PK_KEY_INVALID_FORMAT -0x3D00 /**< Invalid key tag or value. */ #define MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -0x3C80 /**< Key algorithm is unsupported (only RSA and EC are supported). */ #define MBEDTLS_ERR_PK_PASSWORD_REQUIRED -0x3C00 /**< Private key password can't be empty. */ #define MBEDTLS_ERR_PK_PASSWORD_MISMATCH -0x3B80 /**< Given private key password does not allow for correct decryption. */ #define MBEDTLS_ERR_PK_INVALID_PUBKEY -0x3B00 /**< The pubkey tag or value is invalid (only RSA and EC are supported). */ #define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80 /**< The algorithm tag or value is invalid. */ #define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */ #define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */ #define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The buffer contains a valid signature followed by more data. */ /* MBEDTLS_ERR_PK_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880 /**< PK hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif /** * \brief Public key types */ typedef enum { MBEDTLS_PK_NONE=0, MBEDTLS_PK_RSA, MBEDTLS_PK_ECKEY, MBEDTLS_PK_ECKEY_DH, MBEDTLS_PK_ECDSA, MBEDTLS_PK_RSA_ALT, MBEDTLS_PK_RSASSA_PSS, } mbedtls_pk_type_t; /** * \brief Options for RSASSA-PSS signature verification. * See \c mbedtls_rsa_rsassa_pss_verify_ext() */ typedef struct mbedtls_pk_rsassa_pss_options { mbedtls_md_type_t mgf1_hash_id; int expected_salt_len; } mbedtls_pk_rsassa_pss_options; /** * \brief Types for interfacing with the debug module */ typedef enum { MBEDTLS_PK_DEBUG_NONE = 0, MBEDTLS_PK_DEBUG_MPI, MBEDTLS_PK_DEBUG_ECP, } mbedtls_pk_debug_type; /** * \brief Item to send to the debug module */ typedef struct mbedtls_pk_debug_item { mbedtls_pk_debug_type type; const char *name; void *value; } mbedtls_pk_debug_item; /** Maximum number of item send for debugging, plus 1 */ #define MBEDTLS_PK_DEBUG_MAX_ITEMS 3 /** * \brief Public key information and operations */ typedef struct mbedtls_pk_info_t mbedtls_pk_info_t; /** * \brief Public key container */ typedef struct mbedtls_pk_context { const mbedtls_pk_info_t * pk_info; /**< Public key information */ void * pk_ctx; /**< Underlying public key context */ } mbedtls_pk_context; #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Context for resuming operations */ typedef struct { const mbedtls_pk_info_t * pk_info; /**< Public key information */ void * rs_ctx; /**< Underlying restart context */ } mbedtls_pk_restart_ctx; #else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ /* Now we can declare functions that take a pointer to that */ typedef void mbedtls_pk_restart_ctx; #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ #if defined(MBEDTLS_RSA_C) /** * Quick access to an RSA context inside a PK context. * * \warning You must make sure the PK context actually holds an RSA context * before using this function! */ static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk ) { return( (mbedtls_rsa_context *) (pk).pk_ctx ); } #endif /* MBEDTLS_RSA_C */ #if defined(MBEDTLS_ECP_C) /** * Quick access to an EC context inside a PK context. * * \warning You must make sure the PK context actually holds an EC context * before using this function! */ static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk ) { return( (mbedtls_ecp_keypair *) (pk).pk_ctx ); } #endif /* MBEDTLS_ECP_C */ #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) /** * \brief Types for RSA-alt abstraction */ typedef int (*mbedtls_pk_rsa_alt_decrypt_func)( void *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ); typedef int (*mbedtls_pk_rsa_alt_sign_func)( void *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); typedef size_t (*mbedtls_pk_rsa_alt_key_len_func)( void *ctx ); #endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ /** * \brief Return information associated with the given PK type * * \param pk_type PK type to search for. * * \return The PK info associated with the type or NULL if not found. */ const mbedtls_pk_info_t *mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type ); /** * \brief Initialize a #mbedtls_pk_context (as NONE). * * \param ctx The context to initialize. * This must not be \c NULL. */ void mbedtls_pk_init( mbedtls_pk_context *ctx ); /** * \brief Free the components of a #mbedtls_pk_context. * * \param ctx The context to clear. It must have been initialized. * If this is \c NULL, this function does nothing. */ void mbedtls_pk_free( mbedtls_pk_context *ctx ); #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Initialize a restart context * * \param ctx The context to initialize. * This must not be \c NULL. */ void mbedtls_pk_restart_init( mbedtls_pk_restart_ctx *ctx ); /** * \brief Free the components of a restart context * * \param ctx The context to clear. It must have been initialized. * If this is \c NULL, this function does nothing. */ void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx ); #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ /** * \brief Initialize a PK context with the information given * and allocates the type-specific PK subcontext. * * \param ctx Context to initialize. It must not have been set * up yet (type #MBEDTLS_PK_NONE). * \param info Information to use * * \return 0 on success, * MBEDTLS_ERR_PK_BAD_INPUT_DATA on invalid input, * MBEDTLS_ERR_PK_ALLOC_FAILED on allocation failure. * * \note For contexts holding an RSA-alt key, use * \c mbedtls_pk_setup_rsa_alt() instead. */ int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ); #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) /** * \brief Initialize an RSA-alt context * * \param ctx Context to initialize. It must not have been set * up yet (type #MBEDTLS_PK_NONE). * \param key RSA key pointer * \param decrypt_func Decryption function * \param sign_func Signing function * \param key_len_func Function returning key length in bytes * * \return 0 on success, or MBEDTLS_ERR_PK_BAD_INPUT_DATA if the * context wasn't already initialized as RSA_ALT. * * \note This function replaces \c mbedtls_pk_setup() for RSA-alt. */ int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, mbedtls_pk_rsa_alt_decrypt_func decrypt_func, mbedtls_pk_rsa_alt_sign_func sign_func, mbedtls_pk_rsa_alt_key_len_func key_len_func ); #endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ /** * \brief Get the size in bits of the underlying key * * \param ctx The context to query. It must have been initialized. * * \return Key size in bits, or 0 on error */ size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ); /** * \brief Get the length in bytes of the underlying key * * \param ctx The context to query. It must have been initialized. * * \return Key length in bytes, or 0 on error */ static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx ) { return( ( mbedtls_pk_get_bitlen( ctx ) + 7 ) / 8 ); } /** * \brief Tell if a context can do the operation given by type * * \param ctx The context to query. It must have been initialized. * \param type The desired type. * * \return 1 if the context can do operations on the given type. * \return 0 if the context cannot do the operations on the given * type. This is always the case for a context that has * been initialized but not set up, or that has been * cleared with mbedtls_pk_free(). */ int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ); /** * \brief Verify signature (including padding if relevant). * * \param ctx The PK context to use. It must have been set up. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) * \param sig Signature to verify * \param sig_len Signature length * * \return 0 on success (signature is valid), * #MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if there is a valid * signature in sig but its length is less than \p siglen, * or a specific error code. * * \note For RSA keys, the default padding type is PKCS#1 v1.5. * Use \c mbedtls_pk_verify_ext( MBEDTLS_PK_RSASSA_PSS, ... ) * to verify RSASSA_PSS signatures. * * \note If hash_len is 0, then the length associated with md_alg * is used instead, or an error returned if it is invalid. * * \note md_alg may be MBEDTLS_MD_NONE, only if hash_len != 0 */ int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len ); /** * \brief Restartable version of \c mbedtls_pk_verify() * * \note Performs the same job as \c mbedtls_pk_verify(), but can * return early and restart according to the limit set with * \c mbedtls_ecp_set_max_ops() to reduce blocking for ECC * operations. For RSA, same as \c mbedtls_pk_verify(). * * \param ctx The PK context to use. It must have been set up. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) * \param sig Signature to verify * \param sig_len Signature length * \param rs_ctx Restart context (NULL to disable restart) * * \return See \c mbedtls_pk_verify(), or * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). */ int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len, mbedtls_pk_restart_ctx *rs_ctx ); /** * \brief Verify signature, with options. * (Includes verification of the padding depending on type.) * * \param type Signature type (inc. possible padding type) to verify * \param options Pointer to type-specific options, or NULL * \param ctx The PK context to use. It must have been set up. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) * \param sig Signature to verify * \param sig_len Signature length * * \return 0 on success (signature is valid), * #MBEDTLS_ERR_PK_TYPE_MISMATCH if the PK context can't be * used for this type of signatures, * #MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if there is a valid * signature in sig but its length is less than \p siglen, * or a specific error code. * * \note If hash_len is 0, then the length associated with md_alg * is used instead, or an error returned if it is invalid. * * \note md_alg may be MBEDTLS_MD_NONE, only if hash_len != 0 * * \note If type is MBEDTLS_PK_RSASSA_PSS, then options must point * to a mbedtls_pk_rsassa_pss_options structure, * otherwise it must be NULL. */ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options, mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len ); /** * \brief Make signature, including padding if relevant. * * \param ctx The PK context to use. It must have been set up * with a private key. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) * \param sig Place to write the signature * \param sig_len Number of bytes written * \param f_rng RNG function * \param p_rng RNG parameter * * \return 0 on success, or a specific error code. * * \note For RSA keys, the default padding type is PKCS#1 v1.5. * There is no interface in the PK module to make RSASSA-PSS * signatures yet. * * \note If hash_len is 0, then the length associated with md_alg * is used instead, or an error returned if it is invalid. * * \note For RSA, md_alg may be MBEDTLS_MD_NONE if hash_len != 0. * For ECDSA, md_alg may never be MBEDTLS_MD_NONE. */ int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Restartable version of \c mbedtls_pk_sign() * * \note Performs the same job as \c mbedtls_pk_sign(), but can * return early and restart according to the limit set with * \c mbedtls_ecp_set_max_ops() to reduce blocking for ECC * operations. For RSA, same as \c mbedtls_pk_sign(). * * \param ctx The PK context to use. It must have been set up * with a private key. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) * \param sig Place to write the signature * \param sig_len Number of bytes written * \param f_rng RNG function * \param p_rng RNG parameter * \param rs_ctx Restart context (NULL to disable restart) * * \return See \c mbedtls_pk_sign(), or * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). */ int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_pk_restart_ctx *rs_ctx ); /** * \brief Decrypt message (including padding if relevant). * * \param ctx The PK context to use. It must have been set up * with a private key. * \param input Input to decrypt * \param ilen Input size * \param output Decrypted output * \param olen Decrypted message length * \param osize Size of the output buffer * \param f_rng RNG function * \param p_rng RNG parameter * * \note For RSA keys, the default padding type is PKCS#1 v1.5. * * \return 0 on success, or a specific error code. */ int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Encrypt message (including padding if relevant). * * \param ctx The PK context to use. It must have been set up. * \param input Message to encrypt * \param ilen Message size * \param output Encrypted output * \param olen Encrypted output length * \param osize Size of the output buffer * \param f_rng RNG function * \param p_rng RNG parameter * * \note For RSA keys, the default padding type is PKCS#1 v1.5. * * \return 0 on success, or a specific error code. */ int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Check if a public-private pair of keys matches. * * \param pub Context holding a public key. * \param prv Context holding a private (and public) key. * * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA */ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv ); /** * \brief Export debug information * * \param ctx The PK context to use. It must have been initialized. * \param items Place to write debug items * * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA */ int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items ); /** * \brief Access the type name * * \param ctx The PK context to use. It must have been initialized. * * \return Type name on success, or "invalid PK" */ const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx ); /** * \brief Get the key type * * \param ctx The PK context to use. It must have been initialized. * * \return Type on success. * \return #MBEDTLS_PK_NONE for a context that has not been set up. */ mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ); #if defined(MBEDTLS_PK_PARSE_C) /** \ingroup pk_module */ /** * \brief Parse a private key in PEM or DER format * * \param ctx The PK context to fill. It must have been initialized * but not set up. * \param key Input buffer to parse. * The buffer must contain the input exactly, with no * extra trailing material. For PEM, the buffer must * contain a null-terminated string. * \param keylen Size of \b key in bytes. * For PEM data, this includes the terminating null byte, * so \p keylen must be equal to `strlen(key) + 1`. * \param pwd Optional password for decryption. * Pass \c NULL if expecting a non-encrypted key. * Pass a string of \p pwdlen bytes if expecting an encrypted * key; a non-encrypted key will also be accepted. * The empty password is not supported. * \param pwdlen Size of the password in bytes. * Ignored if \p pwd is \c NULL. * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a * specific key type, check the result with mbedtls_pk_can_do(). * * \note The key is also checked for correctness. * * \return 0 if successful, or a specific PK or PEM error code */ int mbedtls_pk_parse_key( mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen ); /** \ingroup pk_module */ /** * \brief Parse a public key in PEM or DER format * * \param ctx The PK context to fill. It must have been initialized * but not set up. * \param key Input buffer to parse. * The buffer must contain the input exactly, with no * extra trailing material. For PEM, the buffer must * contain a null-terminated string. * \param keylen Size of \b key in bytes. * For PEM data, this includes the terminating null byte, * so \p keylen must be equal to `strlen(key) + 1`. * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a * specific key type, check the result with mbedtls_pk_can_do(). * * \note The key is also checked for correctness. * * \return 0 if successful, or a specific PK or PEM error code */ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen ); #if defined(MBEDTLS_FS_IO) /** \ingroup pk_module */ /** * \brief Load and parse a private key * * \param ctx The PK context to fill. It must have been initialized * but not set up. * \param path filename to read the private key from * \param password Optional password to decrypt the file. * Pass \c NULL if expecting a non-encrypted key. * Pass a null-terminated string if expecting an encrypted * key; a non-encrypted key will also be accepted. * The empty password is not supported. * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a * specific key type, check the result with mbedtls_pk_can_do(). * * \note The key is also checked for correctness. * * \return 0 if successful, or a specific PK or PEM error code */ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, const char *path, const char *password ); /** \ingroup pk_module */ /** * \brief Load and parse a public key * * \param ctx The PK context to fill. It must have been initialized * but not set up. * \param path filename to read the public key from * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If * you need a specific key type, check the result with * mbedtls_pk_can_do(). * * \note The key is also checked for correctness. * * \return 0 if successful, or a specific PK or PEM error code */ int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ); #endif /* MBEDTLS_FS_IO */ #endif /* MBEDTLS_PK_PARSE_C */ #if defined(MBEDTLS_PK_WRITE_C) /** * \brief Write a private key to a PKCS#1 or SEC1 DER structure * Note: data is written at the end of the buffer! Use the * return value to determine where you should start * using the buffer * * \param ctx PK context which must contain a valid private key. * \param buf buffer to write to * \param size size of the buffer * * \return length of data written if successful, or a specific * error code */ int mbedtls_pk_write_key_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); /** * \brief Write a public key to a SubjectPublicKeyInfo DER structure * Note: data is written at the end of the buffer! Use the * return value to determine where you should start * using the buffer * * \param ctx PK context which must contain a valid public or private key. * \param buf buffer to write to * \param size size of the buffer * * \return length of data written if successful, or a specific * error code */ int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); #if defined(MBEDTLS_PEM_WRITE_C) /** * \brief Write a public key to a PEM string * * \param ctx PK context which must contain a valid public or private key. * \param buf Buffer to write to. The output includes a * terminating null byte. * \param size Size of the buffer in bytes. * * \return 0 if successful, or a specific error code */ int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); /** * \brief Write a private key to a PKCS#1 or SEC1 PEM string * * \param ctx PK context which must contain a valid private key. * \param buf Buffer to write to. The output includes a * terminating null byte. * \param size Size of the buffer in bytes. * * \return 0 if successful, or a specific error code */ int mbedtls_pk_write_key_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size ); #endif /* MBEDTLS_PEM_WRITE_C */ #endif /* MBEDTLS_PK_WRITE_C */ /* * WARNING: Low-level functions. You probably do not want to use these unless * you are certain you do ;) */ #if defined(MBEDTLS_PK_PARSE_C) /** * \brief Parse a SubjectPublicKeyInfo DER structure * * \param p the position in the ASN.1 data * \param end end of the buffer * \param pk The PK context to fill. It must have been initialized * but not set up. * * \return 0 if successful, or a specific PK error code */ int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end, mbedtls_pk_context *pk ); #endif /* MBEDTLS_PK_PARSE_C */ #if defined(MBEDTLS_PK_WRITE_C) /** * \brief Write a subjectPublicKey to ASN.1 data * Note: function works backwards in data buffer * * \param p reference to current position pointer * \param start start of the buffer (for bounds-checking) * \param key PK context which must contain a valid public or private key. * * \return the length written or a negative error code */ int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start, const mbedtls_pk_context *key ); #endif /* MBEDTLS_PK_WRITE_C */ /* * Internal module functions. You probably do not want to use these unless you * know you do. */ #if defined(MBEDTLS_FS_IO) int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n ); #endif #ifdef __cplusplus } #endif #endif /* MBEDTLS_PK_H */
29,002
C++
.h
692
39.108382
127
0.630092
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,530
hkdf.h
w1hkj_fldigi/src/include/mbedtls/hkdf.h
/** * \file hkdf.h * * \brief This file contains the HKDF interface. * * The HMAC-based Extract-and-Expand Key Derivation Function (HKDF) is * specified by RFC 5869. */ /* * Copyright (C) 2016-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_HKDF_H #define MBEDTLS_HKDF_H #include "md.h" /** * \name HKDF Error codes * \{ */ #define MBEDTLS_ERR_HKDF_BAD_INPUT_DATA -0x5F80 /**< Bad input parameters to function. */ /* \} name */ #ifdef __cplusplus extern "C" { #endif /** * \brief This is the HMAC-based Extract-and-Expand Key Derivation Function * (HKDF). * * \param md A hash function; md.size denotes the length of the hash * function output in bytes. * \param salt An optional salt value (a non-secret random value); * if the salt is not provided, a string of all zeros of * md.size length is used as the salt. * \param salt_len The length in bytes of the optional \p salt. * \param ikm The input keying material. * \param ikm_len The length in bytes of \p ikm. * \param info An optional context and application specific information * string. This can be a zero-length string. * \param info_len The length of \p info in bytes. * \param okm The output keying material of \p okm_len bytes. * \param okm_len The length of the output keying material in bytes. This * must be less than or equal to 255 * md.size bytes. * * \return 0 on success. * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid. * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying * MD layer. */ int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, size_t salt_len, const unsigned char *ikm, size_t ikm_len, const unsigned char *info, size_t info_len, unsigned char *okm, size_t okm_len ); /** * \brief Take the input keying material \p ikm and extract from it a * fixed-length pseudorandom key \p prk. * * \warning This function should only be used if the security of it has been * studied and established in that particular context (eg. TLS 1.3 * key schedule). For standard HKDF security guarantees use * \c mbedtls_hkdf instead. * * \param md A hash function; md.size denotes the length of the * hash function output in bytes. * \param salt An optional salt value (a non-secret random value); * if the salt is not provided, a string of all zeros * of md.size length is used as the salt. * \param salt_len The length in bytes of the optional \p salt. * \param ikm The input keying material. * \param ikm_len The length in bytes of \p ikm. * \param[out] prk A pseudorandom key of at least md.size bytes. * * \return 0 on success. * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid. * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying * MD layer. */ int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, const unsigned char *salt, size_t salt_len, const unsigned char *ikm, size_t ikm_len, unsigned char *prk ); /** * \brief Expand the supplied \p prk into several additional pseudorandom * keys, which is the output of the HKDF. * * \warning This function should only be used if the security of it has been * studied and established in that particular context (eg. TLS 1.3 * key schedule). For standard HKDF security guarantees use * \c mbedtls_hkdf instead. * * \param md A hash function; md.size denotes the length of the hash * function output in bytes. * \param prk A pseudorandom key of at least md.size bytes. \p prk is * usually the output from the HKDF extract step. * \param prk_len The length in bytes of \p prk. * \param info An optional context and application specific information * string. This can be a zero-length string. * \param info_len The length of \p info in bytes. * \param okm The output keying material of \p okm_len bytes. * \param okm_len The length of the output keying material in bytes. This * must be less than or equal to 255 * md.size bytes. * * \return 0 on success. * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid. * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying * MD layer. */ int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, size_t prk_len, const unsigned char *info, size_t info_len, unsigned char *okm, size_t okm_len ); #ifdef __cplusplus } #endif #endif /* hkdf.h */
5,797
C++
.h
127
42.377953
91
0.639173
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,531
debug.h
w1hkj_fldigi/src/include/mbedtls/debug.h
/** * \file debug.h * * \brief Functions for controlling and providing debug output from the library. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_DEBUG_H #define MBEDTLS_DEBUG_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "ssl.h" #if defined(MBEDTLS_ECP_C) #include "ecp.h" #endif #if defined(MBEDTLS_DEBUG_C) #define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__ #define MBEDTLS_SSL_DEBUG_MSG( level, args ) \ mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \ MBEDTLS_DEBUG_STRIP_PARENS args ) #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \ mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ) #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \ mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ) #if defined(MBEDTLS_BIGNUM_C) #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \ mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ) #endif #if defined(MBEDTLS_ECP_C) #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \ mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X ) #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \ mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ) #endif #if defined(MBEDTLS_ECDH_C) #define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) \ mbedtls_debug_printf_ecdh( ssl, level, __FILE__, __LINE__, ecdh, attr ) #endif #else /* MBEDTLS_DEBUG_C */ #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) do { } while( 0 ) #endif /* MBEDTLS_DEBUG_C */ #ifdef __cplusplus extern "C" { #endif /** * \brief Set the threshold error level to handle globally all debug output. * Debug messages that have a level over the threshold value are * discarded. * (Default value: 0 = No debug ) * * \param threshold theshold level of messages to filter on. Messages at a * higher level will be discarded. * - Debug levels * - 0 No debug * - 1 Error * - 2 State change * - 3 Informational * - 4 Verbose */ void mbedtls_debug_set_threshold( int threshold ); /** * \brief Print a message to the debug output. This function is always used * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl * context, file and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the message has occurred in * \param line line number the message has occurred at * \param format format specifier, in printf format * \param ... variables used by the format specifier * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *format, ... ); /** * \brief Print the return value of a function to the debug output. This * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro, * which supplies the ssl context, file and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the error has occurred in * \param line line number the error has occurred in * \param text the name of the function that returned the error * \param ret the return code value * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, int ret ); /** * \brief Output a buffer of size len bytes to the debug output. This function * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro, * which supplies the ssl context, file and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the error has occurred in * \param line line number the error has occurred in * \param text a name or label for the buffer being dumped. Normally the * variable or buffer name * \param buf the buffer to be outputted * \param len length of the buffer * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const unsigned char *buf, size_t len ); #if defined(MBEDTLS_BIGNUM_C) /** * \brief Print a MPI variable to the debug output. This function is always * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the * ssl context, file and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the error has occurred in * \param line line number the error has occurred in * \param text a name or label for the MPI being output. Normally the * variable name * \param X the MPI variable * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_mpi *X ); #endif #if defined(MBEDTLS_ECP_C) /** * \brief Print an ECP point to the debug output. This function is always * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the * ssl context, file and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the error has occurred in * \param line line number the error has occurred in * \param text a name or label for the ECP point being output. Normally the * variable name * \param X the ECP point * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_ecp_point *X ); #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * \brief Print a X.509 certificate structure to the debug output. This * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro, * which supplies the ssl context, file and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the error has occurred in * \param line line number the error has occurred in * \param text a name or label for the certificate being output * \param crt X.509 certificate structure * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_x509_crt *crt ); #endif #if defined(MBEDTLS_ECDH_C) typedef enum { MBEDTLS_DEBUG_ECDH_Q, MBEDTLS_DEBUG_ECDH_QP, MBEDTLS_DEBUG_ECDH_Z, } mbedtls_debug_ecdh_attr; /** * \brief Print a field of the ECDH structure in the SSL context to the debug * output. This function is always used through the * MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file * and line number parameters. * * \param ssl SSL context * \param level error level of the debug message * \param file file the error has occurred in * \param line line number the error has occurred in * \param ecdh the ECDH context * \param attr the identifier of the attribute being output * * \attention This function is intended for INTERNAL usage within the * library only. */ void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level, const char *file, int line, const mbedtls_ecdh_context *ecdh, mbedtls_debug_ecdh_attr attr ); #endif #ifdef __cplusplus } #endif #endif /* debug.h */
10,319
C++
.h
239
39.610879
80
0.634998
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,532
threading.h
w1hkj_fldigi/src/include/mbedtls/threading.h
/** * \file threading.h * * \brief Threading abstraction layer */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_THREADING_H #define MBEDTLS_THREADING_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif /* MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE is deprecated and should not be * used. */ #define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A /**< The selected feature is not available. */ #define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA -0x001C /**< Bad input parameters to function. */ #define MBEDTLS_ERR_THREADING_MUTEX_ERROR -0x001E /**< Locking / unlocking / free failed with error code. */ #if defined(MBEDTLS_THREADING_PTHREAD) #include <pthread.h> typedef struct mbedtls_threading_mutex_t { pthread_mutex_t mutex; char is_valid; } mbedtls_threading_mutex_t; #endif #if defined(MBEDTLS_THREADING_ALT) /* You should define the mbedtls_threading_mutex_t type in your header */ #include "threading_alt.h" /** * \brief Set your alternate threading implementation function * pointers and initialize global mutexes. If used, this * function must be called once in the main thread before any * other mbed TLS function is called, and * mbedtls_threading_free_alt() must be called once in the main * thread after all other mbed TLS functions. * * \note mutex_init() and mutex_free() don't return a status code. * If mutex_init() fails, it should leave its argument (the * mutex) in a state such that mutex_lock() will fail when * called with this argument. * * \param mutex_init the init function implementation * \param mutex_free the free function implementation * \param mutex_lock the lock function implementation * \param mutex_unlock the unlock function implementation */ void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ), void (*mutex_free)( mbedtls_threading_mutex_t * ), int (*mutex_lock)( mbedtls_threading_mutex_t * ), int (*mutex_unlock)( mbedtls_threading_mutex_t * ) ); /** * \brief Free global mutexes. */ void mbedtls_threading_free_alt( void ); #endif /* MBEDTLS_THREADING_ALT */ #if defined(MBEDTLS_THREADING_C) /* * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock * * All these functions are expected to work or the result will be undefined. */ extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex ); extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex ); extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex ); extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex ); /* * Global mutexes */ #if defined(MBEDTLS_FS_IO) extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; #endif #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) /* This mutex may or may not be used in the default definition of * mbedtls_platform_gmtime_r(), but in order to determine that, * we need to check POSIX features, hence modify _POSIX_C_SOURCE. * With the current approach, this declaration is orphaned, lacking * an accompanying definition, in case mbedtls_platform_gmtime_r() * doesn't need it, but that's not a problem. */ extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex; #endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */ #endif /* MBEDTLS_THREADING_C */ #ifdef __cplusplus } #endif #endif /* threading.h */
4,625
C++
.h
109
40.091743
125
0.70651
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,533
ecdh.h
w1hkj_fldigi/src/include/mbedtls/ecdh.h
/** * \file ecdh.h * * \brief This file contains ECDH definitions and functions. * * The Elliptic Curve Diffie-Hellman (ECDH) protocol is an anonymous * key agreement protocol allowing two parties to establish a shared * secret over an insecure channel. Each party must have an * elliptic-curve public–private key pair. * * For more information, see <em>NIST SP 800-56A Rev. 2: Recommendation for * Pair-Wise Key Establishment Schemes Using Discrete Logarithm * Cryptography</em>. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ECDH_H #define MBEDTLS_ECDH_H #include "ecp.h" /* * Use a backward compatible ECDH context. * * This flag is always enabled for now and future versions might add a * configuration option that conditionally undefines this flag. * The configuration option in question may have a different name. * * Features undefining this flag, must have a warning in their description in * config.h stating that the feature breaks backward compatibility. */ #define MBEDTLS_ECDH_LEGACY_CONTEXT #ifdef __cplusplus extern "C" { #endif /** * Defines the source of the imported EC key. */ typedef enum { MBEDTLS_ECDH_OURS, /**< Our key. */ MBEDTLS_ECDH_THEIRS, /**< The key of the peer. */ } mbedtls_ecdh_side; #if !defined(MBEDTLS_ECDH_LEGACY_CONTEXT) /** * Defines the ECDH implementation used. * * Later versions of the library may add new variants, therefore users should * not make any assumptions about them. */ typedef enum { MBEDTLS_ECDH_VARIANT_NONE = 0, /*!< Implementation not defined. */ MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0,/*!< The default Mbed TLS implementation */ } mbedtls_ecdh_variant; /** * The context used by the default ECDH implementation. * * Later versions might change the structure of this context, therefore users * should not make any assumptions about the structure of * mbedtls_ecdh_context_mbed. */ typedef struct mbedtls_ecdh_context_mbed { mbedtls_ecp_group grp; /*!< The elliptic curve used. */ mbedtls_mpi d; /*!< The private key. */ mbedtls_ecp_point Q; /*!< The public key. */ mbedtls_ecp_point Qp; /*!< The value of the public key of the peer. */ mbedtls_mpi z; /*!< The shared secret. */ #if defined(MBEDTLS_ECP_RESTARTABLE) mbedtls_ecp_restart_ctx rs; /*!< The restart context for EC computations. */ #endif } mbedtls_ecdh_context_mbed; #endif /** * * \warning Performing multiple operations concurrently on the same * ECDSA context is not supported; objects of this type * should not be shared between multiple threads. * \brief The ECDH context structure. */ typedef struct mbedtls_ecdh_context { #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) mbedtls_ecp_group grp; /*!< The elliptic curve used. */ mbedtls_mpi d; /*!< The private key. */ mbedtls_ecp_point Q; /*!< The public key. */ mbedtls_ecp_point Qp; /*!< The value of the public key of the peer. */ mbedtls_mpi z; /*!< The shared secret. */ int point_format; /*!< The format of point export in TLS messages. */ mbedtls_ecp_point Vi; /*!< The blinding value. */ mbedtls_ecp_point Vf; /*!< The unblinding value. */ mbedtls_mpi _d; /*!< The previous \p d. */ #if defined(MBEDTLS_ECP_RESTARTABLE) int restart_enabled; /*!< The flag for restartable mode. */ mbedtls_ecp_restart_ctx rs; /*!< The restart context for EC computations. */ #endif /* MBEDTLS_ECP_RESTARTABLE */ #else uint8_t point_format; /*!< The format of point export in TLS messages as defined in RFC 4492. */ mbedtls_ecp_group_id grp_id;/*!< The elliptic curve used. */ mbedtls_ecdh_variant var; /*!< The ECDH implementation/structure used. */ union { mbedtls_ecdh_context_mbed mbed_ecdh; } ctx; /*!< Implementation-specific context. The context in use is specified by the \c var field. */ #if defined(MBEDTLS_ECP_RESTARTABLE) uint8_t restart_enabled; /*!< The flag for restartable mode. Functions of an alternative implementation not supporting restartable mode must return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED error if this flag is set. */ #endif /* MBEDTLS_ECP_RESTARTABLE */ #endif /* MBEDTLS_ECDH_LEGACY_CONTEXT */ } mbedtls_ecdh_context; /** * \brief This function generates an ECDH keypair on an elliptic * curve. * * This function performs the first of two core computations * implemented during the ECDH key exchange. The second core * computation is performed by mbedtls_ecdh_compute_shared(). * * \see ecp.h * * \param grp The ECP group to use. This must be initialized and have * domain parameters loaded, for example through * mbedtls_ecp_load() or mbedtls_ecp_tls_read_group(). * \param d The destination MPI (private key). * This must be initialized. * \param Q The destination point (public key). * This must be initialized. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL in case \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return Another \c MBEDTLS_ERR_ECP_XXX or * \c MBEDTLS_MPI_XXX error code on failure. */ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function computes the shared secret. * * This function performs the second of two core computations * implemented during the ECDH key exchange. The first core * computation is performed by mbedtls_ecdh_gen_public(). * * \see ecp.h * * \note If \p f_rng is not NULL, it is used to implement * countermeasures against side-channel attacks. * For more information, see mbedtls_ecp_mul(). * * \param grp The ECP group to use. This must be initialized and have * domain parameters loaded, for example through * mbedtls_ecp_load() or mbedtls_ecp_tls_read_group(). * \param z The destination MPI (shared secret). * This must be initialized. * \param Q The public key from another party. * This must be initialized. * \param d Our secret exponent (private key). * This must be initialized. * \param f_rng The RNG function. This may be \c NULL if randomization * of intermediate results during the ECP computations is * not needed (discouraged). See the documentation of * mbedtls_ecp_mul() for more. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't need a * context argument. * * \return \c 0 on success. * \return Another \c MBEDTLS_ERR_ECP_XXX or * \c MBEDTLS_MPI_XXX error code on failure. */ int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, const mbedtls_ecp_point *Q, const mbedtls_mpi *d, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function initializes an ECDH context. * * \param ctx The ECDH context to initialize. This must not be \c NULL. */ void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ); /** * \brief This function sets up the ECDH context with the information * given. * * This function should be called after mbedtls_ecdh_init() but * before mbedtls_ecdh_make_params(). There is no need to call * this function before mbedtls_ecdh_read_params(). * * This is the first function used by a TLS server for ECDHE * ciphersuites. * * \param ctx The ECDH context to set up. This must be initialized. * \param grp_id The group id of the group to set up the context for. * * \return \c 0 on success. */ int mbedtls_ecdh_setup( mbedtls_ecdh_context *ctx, mbedtls_ecp_group_id grp_id ); /** * \brief This function frees a context. * * \param ctx The context to free. This may be \c NULL, in which * case this function does nothing. If it is not \c NULL, * it must point to an initialized ECDH context. */ void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ); /** * \brief This function generates an EC key pair and exports its * in the format used in a TLS ServerKeyExchange handshake * message. * * This is the second function used by a TLS server for ECDHE * ciphersuites. (It is called after mbedtls_ecdh_setup().) * * \see ecp.h * * \param ctx The ECDH context to use. This must be initialized * and bound to a group, for example via mbedtls_ecdh_setup(). * \param olen The address at which to store the number of Bytes written. * \param buf The destination buffer. This must be a writable buffer of * length \p blen Bytes. * \param blen The length of the destination buffer \p buf in Bytes. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL in case \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function parses the ECDHE parameters in a * TLS ServerKeyExchange handshake message. * * \note In a TLS handshake, this is the how the client * sets up its ECDHE context from the server's public * ECDHE key material. * * \see ecp.h * * \param ctx The ECDHE context to use. This must be initialized. * \param buf On input, \c *buf must be the start of the input buffer. * On output, \c *buf is updated to point to the end of the * data that has been read. On success, this is the first byte * past the end of the ServerKeyExchange parameters. * On error, this is the point at which an error has been * detected, which is usually not useful except to debug * failures. * \param end The end of the input buffer. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX error code on failure. * */ int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, const unsigned char **buf, const unsigned char *end ); /** * \brief This function sets up an ECDH context from an EC key. * * It is used by clients and servers in place of the * ServerKeyEchange for static ECDH, and imports ECDH * parameters from the EC key information of a certificate. * * \see ecp.h * * \param ctx The ECDH context to set up. This must be initialized. * \param key The EC key to use. This must be initialized. * \param side Defines the source of the key. Possible values are: * - #MBEDTLS_ECDH_OURS: The key is ours. * - #MBEDTLS_ECDH_THEIRS: The key is that of the peer. * * \return \c 0 on success. * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. * */ int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, mbedtls_ecdh_side side ); /** * \brief This function generates a public key and exports it * as a TLS ClientKeyExchange payload. * * This is the second function used by a TLS client for ECDH(E) * ciphersuites. * * \see ecp.h * * \param ctx The ECDH context to use. This must be initialized * and bound to a group, the latter usually by * mbedtls_ecdh_read_params(). * \param olen The address at which to store the number of Bytes written. * This must not be \c NULL. * \param buf The destination buffer. This must be a writable buffer * of length \p blen Bytes. * \param blen The size of the destination buffer \p buf in Bytes. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL in case \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function parses and processes the ECDHE payload of a * TLS ClientKeyExchange message. * * This is the third function used by a TLS server for ECDH(E) * ciphersuites. (It is called after mbedtls_ecdh_setup() and * mbedtls_ecdh_make_params().) * * \see ecp.h * * \param ctx The ECDH context to use. This must be initialized * and bound to a group, for example via mbedtls_ecdh_setup(). * \param buf The pointer to the ClientKeyExchange payload. This must * be a readable buffer of length \p blen Bytes. * \param blen The length of the input buffer \p buf in Bytes. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, const unsigned char *buf, size_t blen ); /** * \brief This function derives and exports the shared secret. * * This is the last function used by both TLS client * and servers. * * \note If \p f_rng is not NULL, it is used to implement * countermeasures against side-channel attacks. * For more information, see mbedtls_ecp_mul(). * * \see ecp.h * \param ctx The ECDH context to use. This must be initialized * and have its own private key generated and the peer's * public key imported. * \param olen The address at which to store the total number of * Bytes written on success. This must not be \c NULL. * \param buf The buffer to write the generated shared key to. This * must be a writable buffer of size \p blen Bytes. * \param blen The length of the destination buffer \p buf in Bytes. * \param f_rng The RNG function, for blinding purposes. This may * b \c NULL if blinding isn't needed. * \param p_rng The RNG context. This may be \c NULL if \p f_rng * doesn't need a context argument. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #if defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief This function enables restartable EC computations for this * context. (Default: disabled.) * * \see \c mbedtls_ecp_set_max_ops() * * \note It is not possible to safely disable restartable * computations once enabled, except by free-ing the context, * which cancels possible in-progress operations. * * \param ctx The ECDH context to use. This must be initialized. */ void mbedtls_ecdh_enable_restart( mbedtls_ecdh_context *ctx ); #endif /* MBEDTLS_ECP_RESTARTABLE */ #ifdef __cplusplus } #endif #endif /* ecdh.h */
18,606
C++
.h
413
41.249395
90
0.609026
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,534
ssl.h
w1hkj_fldigi/src/include/mbedtls/ssl.h
/** * \file ssl.h * * \brief SSL/TLS functions. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SSL_H #define MBEDTLS_SSL_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "bignum.h" #include "ecp.h" #include "ssl_ciphersuites.h" #if defined(MBEDTLS_X509_CRT_PARSE_C) #include "x509_crt.h" #include "x509_crl.h" #endif #if defined(MBEDTLS_DHM_C) #include "dhm.h" #endif #if defined(MBEDTLS_ECDH_C) #include "ecdh.h" #endif #if defined(MBEDTLS_ZLIB_SUPPORT) #if defined(MBEDTLS_DEPRECATED_WARNING) #warning "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and will be removed in the next major revision of the library" #endif #if defined(MBEDTLS_DEPRECATED_REMOVED) #error "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and cannot be used if MBEDTLS_DEPRECATED_REMOVED is set" #endif #include "zlib.h" #endif #if defined(MBEDTLS_HAVE_TIME) #include "platform_time.h" #endif /* * SSL Error codes */ #define MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE -0x7080 /**< The requested feature is not available. */ #define MBEDTLS_ERR_SSL_BAD_INPUT_DATA -0x7100 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_SSL_INVALID_MAC -0x7180 /**< Verification of the message MAC failed. */ #define MBEDTLS_ERR_SSL_INVALID_RECORD -0x7200 /**< An invalid SSL record was received. */ #define MBEDTLS_ERR_SSL_CONN_EOF -0x7280 /**< The connection indicated an EOF. */ #define MBEDTLS_ERR_SSL_UNKNOWN_CIPHER -0x7300 /**< An unknown cipher was received. */ #define MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN -0x7380 /**< The server has no ciphersuites in common with the client. */ #define MBEDTLS_ERR_SSL_NO_RNG -0x7400 /**< No RNG was provided to the SSL module. */ #define MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480 /**< No client certification received from the client, but required by the authentication mode. */ #define MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500 /**< Our own certificate(s) is/are too large to send in an SSL message. */ #define MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED -0x7580 /**< The own certificate is not set, but needed by the server. */ #define MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600 /**< The own private key or pre-shared key is not set, but needed. */ #define MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED -0x7680 /**< No CA Chain is set, but required to operate. */ #define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE -0x7700 /**< An unexpected message was received from our peer. */ #define MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780 /**< A fatal alert message was received from our peer. */ #define MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED -0x7800 /**< Verification of our peer failed. */ #define MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880 /**< The peer notified us that the connection is going to be closed. */ #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900 /**< Processing of the ClientHello handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980 /**< Processing of the ServerHello handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00 /**< Processing of the Certificate handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80 /**< Processing of the CertificateRequest handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00 /**< Processing of the ServerKeyExchange handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80 /**< Processing of the ServerHelloDone handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00 /**< Processing of the ClientKeyExchange handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP -0x7C80 /**< Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public. */ #define MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS -0x7D00 /**< Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret. */ #define MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80 /**< Processing of the CertificateVerify handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00 /**< Processing of the ChangeCipherSpec handshake message failed. */ #define MBEDTLS_ERR_SSL_BAD_HS_FINISHED -0x7E80 /**< Processing of the Finished handshake message failed. */ #define MBEDTLS_ERR_SSL_ALLOC_FAILED -0x7F00 /**< Memory allocation failed */ #define MBEDTLS_ERR_SSL_HW_ACCEL_FAILED -0x7F80 /**< Hardware acceleration function returned with error */ #define MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80 /**< Hardware acceleration function skipped / left alone data */ #define MBEDTLS_ERR_SSL_COMPRESSION_FAILED -0x6F00 /**< Processing of the compression / decompression failed */ #define MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80 /**< Handshake protocol not within min/max boundaries */ #define MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET -0x6E00 /**< Processing of the NewSessionTicket handshake message failed. */ #define MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED -0x6D80 /**< Session ticket has expired. */ #define MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH -0x6D00 /**< Public key type mismatch (eg, asked for RSA key exchange and presented EC key) */ #define MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY -0x6C80 /**< Unknown identity received (eg, PSK identity) */ #define MBEDTLS_ERR_SSL_INTERNAL_ERROR -0x6C00 /**< Internal error (eg, unexpected failure in lower-level module) */ #define MBEDTLS_ERR_SSL_COUNTER_WRAPPING -0x6B80 /**< A counter would wrap (eg, too many messages exchanged). */ #define MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO -0x6B00 /**< Unexpected message at ServerHello in renegotiation. */ #define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80 /**< DTLS client must retry for hello verification */ #define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00 /**< A buffer is too small to receive or write a message */ #define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980 /**< None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages). */ #define MBEDTLS_ERR_SSL_WANT_READ -0x6900 /**< No data of requested type currently available on underlying transport. */ #define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880 /**< Connection requires a write call. */ #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800 /**< The operation timed out. */ #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780 /**< The client initiated a reconnect from the same port. */ #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700 /**< Record header looks valid but is not expected. */ #define MBEDTLS_ERR_SSL_NON_FATAL -0x6680 /**< The alert message received indicates a non-fatal error. */ #define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */ #define MBEDTLS_ERR_SSL_CONTINUE_PROCESSING -0x6580 /**< Internal-only message signaling that further message-processing should be done */ #define MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -0x6500 /**< The asynchronous operation is not completed yet. */ #define MBEDTLS_ERR_SSL_EARLY_MESSAGE -0x6480 /**< Internal-only message signaling that a message arrived early. */ #define MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -0x7000 /**< A cryptographic operation is in progress. Try again later. */ /* * Various constants */ #define MBEDTLS_SSL_MAJOR_VERSION_3 3 #define MBEDTLS_SSL_MINOR_VERSION_0 0 /*!< SSL v3.0 */ #define MBEDTLS_SSL_MINOR_VERSION_1 1 /*!< TLS v1.0 */ #define MBEDTLS_SSL_MINOR_VERSION_2 2 /*!< TLS v1.1 */ #define MBEDTLS_SSL_MINOR_VERSION_3 3 /*!< TLS v1.2 */ #define MBEDTLS_SSL_TRANSPORT_STREAM 0 /*!< TLS */ #define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1 /*!< DTLS */ #define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255 /*!< Maximum host name defined in RFC 1035 */ /* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c * NONE must be zero so that memset()ing structure to zero works */ #define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0 /*!< don't use this extension */ #define MBEDTLS_SSL_MAX_FRAG_LEN_512 1 /*!< MaxFragmentLength 2^9 */ #define MBEDTLS_SSL_MAX_FRAG_LEN_1024 2 /*!< MaxFragmentLength 2^10 */ #define MBEDTLS_SSL_MAX_FRAG_LEN_2048 3 /*!< MaxFragmentLength 2^11 */ #define MBEDTLS_SSL_MAX_FRAG_LEN_4096 4 /*!< MaxFragmentLength 2^12 */ #define MBEDTLS_SSL_MAX_FRAG_LEN_INVALID 5 /*!< first invalid value */ #define MBEDTLS_SSL_IS_CLIENT 0 #define MBEDTLS_SSL_IS_SERVER 1 #define MBEDTLS_SSL_IS_NOT_FALLBACK 0 #define MBEDTLS_SSL_IS_FALLBACK 1 #define MBEDTLS_SSL_EXTENDED_MS_DISABLED 0 #define MBEDTLS_SSL_EXTENDED_MS_ENABLED 1 #define MBEDTLS_SSL_ETM_DISABLED 0 #define MBEDTLS_SSL_ETM_ENABLED 1 #define MBEDTLS_SSL_COMPRESS_NULL 0 #define MBEDTLS_SSL_COMPRESS_DEFLATE 1 #define MBEDTLS_SSL_VERIFY_NONE 0 #define MBEDTLS_SSL_VERIFY_OPTIONAL 1 #define MBEDTLS_SSL_VERIFY_REQUIRED 2 #define MBEDTLS_SSL_VERIFY_UNSET 3 /* Used only for sni_authmode */ #define MBEDTLS_SSL_LEGACY_RENEGOTIATION 0 #define MBEDTLS_SSL_SECURE_RENEGOTIATION 1 #define MBEDTLS_SSL_RENEGOTIATION_DISABLED 0 #define MBEDTLS_SSL_RENEGOTIATION_ENABLED 1 #define MBEDTLS_SSL_ANTI_REPLAY_DISABLED 0 #define MBEDTLS_SSL_ANTI_REPLAY_ENABLED 1 #define MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED -1 #define MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT 16 #define MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION 0 #define MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION 1 #define MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE 2 #define MBEDTLS_SSL_TRUNC_HMAC_DISABLED 0 #define MBEDTLS_SSL_TRUNC_HMAC_ENABLED 1 #define MBEDTLS_SSL_TRUNCATED_HMAC_LEN 10 /* 80 bits, rfc 6066 section 7 */ #define MBEDTLS_SSL_SESSION_TICKETS_DISABLED 0 #define MBEDTLS_SSL_SESSION_TICKETS_ENABLED 1 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED 0 #define MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED 1 #define MBEDTLS_SSL_ARC4_ENABLED 0 #define MBEDTLS_SSL_ARC4_DISABLED 1 #define MBEDTLS_SSL_PRESET_DEFAULT 0 #define MBEDTLS_SSL_PRESET_SUITEB 2 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1 #define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0 /* * Default range for DTLS retransmission timer value, in milliseconds. * RFC 6347 4.2.4.1 says from 1 second to 60 seconds. */ #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN 1000 #define MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX 60000 /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h or define them on the compiler command line. * \{ */ #if !defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME) #define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ #endif /* * Maximum fragment length in bytes, * determines the size of each of the two internal I/O buffers. * * Note: the RFC defines the default size of SSL / TLS messages. If you * change the value here, other clients / servers may not be able to * communicate with you anymore. Only change this value if you control * both sides of the connection and have it reduced at both sides, or * if you're using the Max Fragment Length extension and you know all your * peers are using it too! */ #if !defined(MBEDTLS_SSL_MAX_CONTENT_LEN) #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /**< Size of the input / output buffer */ #endif #if !defined(MBEDTLS_SSL_IN_CONTENT_LEN) #define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN #endif #if !defined(MBEDTLS_SSL_OUT_CONTENT_LEN) #define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN #endif /* * Maximum number of heap-allocated bytes for the purpose of * DTLS handshake message reassembly and future message buffering. */ #if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING) #define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 #endif /* \} name SECTION: Module settings */ /* * Length of the verify data for secure renegotiation */ #if defined(MBEDTLS_SSL_PROTO_SSL3) #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 36 #else #define MBEDTLS_SSL_VERIFY_DATA_MAX_LEN 12 #endif /* * Signaling ciphersuite values (SCSV) */ #define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF /**< renegotiation info ext */ #define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600 /**< RFC 7507 section 2 */ /* * Supported Signature and Hash algorithms (For TLS 1.2) * RFC 5246 section 7.4.1.4.1 */ #define MBEDTLS_SSL_HASH_NONE 0 #define MBEDTLS_SSL_HASH_MD5 1 #define MBEDTLS_SSL_HASH_SHA1 2 #define MBEDTLS_SSL_HASH_SHA224 3 #define MBEDTLS_SSL_HASH_SHA256 4 #define MBEDTLS_SSL_HASH_SHA384 5 #define MBEDTLS_SSL_HASH_SHA512 6 #define MBEDTLS_SSL_SIG_ANON 0 #define MBEDTLS_SSL_SIG_RSA 1 #define MBEDTLS_SSL_SIG_ECDSA 3 /* * Client Certificate Types * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5 */ #define MBEDTLS_SSL_CERT_TYPE_RSA_SIGN 1 #define MBEDTLS_SSL_CERT_TYPE_ECDSA_SIGN 64 /* * Message, alert and handshake types */ #define MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC 20 #define MBEDTLS_SSL_MSG_ALERT 21 #define MBEDTLS_SSL_MSG_HANDSHAKE 22 #define MBEDTLS_SSL_MSG_APPLICATION_DATA 23 #define MBEDTLS_SSL_ALERT_LEVEL_WARNING 1 #define MBEDTLS_SSL_ALERT_LEVEL_FATAL 2 #define MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */ #define MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */ #define MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */ #define MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */ #define MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */ #define MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */ #define MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */ #define MBEDTLS_SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */ #define MBEDTLS_SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */ #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */ #define MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */ #define MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */ #define MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */ #define MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */ #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */ #define MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */ #define MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */ #define MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */ #define MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */ #define MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */ #define MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */ #define MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */ #define MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK 86 /* 0x56 */ #define MBEDTLS_SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */ #define MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */ #define MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */ #define MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */ #define MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY 115 /* 0x73 */ #define MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL 120 /* 0x78 */ #define MBEDTLS_SSL_HS_HELLO_REQUEST 0 #define MBEDTLS_SSL_HS_CLIENT_HELLO 1 #define MBEDTLS_SSL_HS_SERVER_HELLO 2 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4 #define MBEDTLS_SSL_HS_CERTIFICATE 11 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13 #define MBEDTLS_SSL_HS_SERVER_HELLO_DONE 14 #define MBEDTLS_SSL_HS_CERTIFICATE_VERIFY 15 #define MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE 16 #define MBEDTLS_SSL_HS_FINISHED 20 /* * TLS extensions */ #define MBEDTLS_TLS_EXT_SERVERNAME 0 #define MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME 0 #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10 #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11 #define MBEDTLS_TLS_EXT_SIG_ALG 13 #define MBEDTLS_TLS_EXT_ALPN 16 #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */ #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */ #define MBEDTLS_TLS_EXT_SESSION_TICKET 35 #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */ #define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01 /* * Size defines */ #if !defined(MBEDTLS_PSK_MAX_LEN) #define MBEDTLS_PSK_MAX_LEN 32 /* 256 bits */ #endif /* Dummy type used only for its size */ union mbedtls_ssl_premaster_secret { #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) unsigned char _pms_rsa[48]; /* RFC 5246 8.1.1 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) unsigned char _pms_dhm[MBEDTLS_MPI_MAX_SIZE]; /* RFC 5246 8.1.2 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) unsigned char _pms_ecdh[MBEDTLS_ECP_MAX_BYTES]; /* RFC 4492 5.10 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) unsigned char _pms_psk[4 + 2 * MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 2 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES + MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */ #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */ #endif }; #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) #ifdef __cplusplus extern "C" { #endif /* * SSL state machine */ typedef enum { MBEDTLS_SSL_HELLO_REQUEST, MBEDTLS_SSL_CLIENT_HELLO, MBEDTLS_SSL_SERVER_HELLO, MBEDTLS_SSL_SERVER_CERTIFICATE, MBEDTLS_SSL_SERVER_KEY_EXCHANGE, MBEDTLS_SSL_CERTIFICATE_REQUEST, MBEDTLS_SSL_SERVER_HELLO_DONE, MBEDTLS_SSL_CLIENT_CERTIFICATE, MBEDTLS_SSL_CLIENT_KEY_EXCHANGE, MBEDTLS_SSL_CERTIFICATE_VERIFY, MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC, MBEDTLS_SSL_CLIENT_FINISHED, MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC, MBEDTLS_SSL_SERVER_FINISHED, MBEDTLS_SSL_FLUSH_BUFFERS, MBEDTLS_SSL_HANDSHAKE_WRAPUP, MBEDTLS_SSL_HANDSHAKE_OVER, MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET, MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT, } mbedtls_ssl_states; /** * \brief Callback type: send data on the network. * * \note That callback may be either blocking or non-blocking. * * \param ctx Context for the send callback (typically a file descriptor) * \param buf Buffer holding the data to send * \param len Length of the data to send * * \return The callback must return the number of bytes sent if any, * or a non-zero error code. * If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_WRITE * must be returned when the operation would block. * * \note The callback is allowed to send fewer bytes than requested. * It must always return the number of bytes actually sent. */ typedef int mbedtls_ssl_send_t( void *ctx, const unsigned char *buf, size_t len ); /** * \brief Callback type: receive data from the network. * * \note That callback may be either blocking or non-blocking. * * \param ctx Context for the receive callback (typically a file * descriptor) * \param buf Buffer to write the received data to * \param len Length of the receive buffer * * \return The callback must return the number of bytes received, * or a non-zero error code. * If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_READ * must be returned when the operation would block. * * \note The callback may receive fewer bytes than the length of the * buffer. It must always return the number of bytes actually * received and written to the buffer. */ typedef int mbedtls_ssl_recv_t( void *ctx, unsigned char *buf, size_t len ); /** * \brief Callback type: receive data from the network, with timeout * * \note That callback must block until data is received, or the * timeout delay expires, or the operation is interrupted by a * signal. * * \param ctx Context for the receive callback (typically a file descriptor) * \param buf Buffer to write the received data to * \param len Length of the receive buffer * \param timeout Maximum nomber of millisecondes to wait for data * 0 means no timeout (potentially waiting forever) * * \return The callback must return the number of bytes received, * or a non-zero error code: * \c MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out, * \c MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. * * \note The callback may receive fewer bytes than the length of the * buffer. It must always return the number of bytes actually * received and written to the buffer. */ typedef int mbedtls_ssl_recv_timeout_t( void *ctx, unsigned char *buf, size_t len, uint32_t timeout ); /** * \brief Callback type: set a pair of timers/delays to watch * * \param ctx Context pointer * \param int_ms Intermediate delay in milliseconds * \param fin_ms Final delay in milliseconds * 0 cancels the current timer. * * \note This callback must at least store the necessary information * for the associated \c mbedtls_ssl_get_timer_t callback to * return correct information. * * \note If using a event-driven style of programming, an event must * be generated when the final delay is passed. The event must * cause a call to \c mbedtls_ssl_handshake() with the proper * SSL context to be scheduled. Care must be taken to ensure * that at most one such call happens at a time. * * \note Only one timer at a time must be running. Calling this * function while a timer is running must cancel it. Cancelled * timers must not generate any event. */ typedef void mbedtls_ssl_set_timer_t( void * ctx, uint32_t int_ms, uint32_t fin_ms ); /** * \brief Callback type: get status of timers/delays * * \param ctx Context pointer * * \return This callback must return: * -1 if cancelled (fin_ms == 0), * 0 if none of the delays have passed, * 1 if only the intermediate delay has passed, * 2 if the final delay has passed. */ typedef int mbedtls_ssl_get_timer_t( void * ctx ); /* Defined below */ typedef struct mbedtls_ssl_session mbedtls_ssl_session; typedef struct mbedtls_ssl_context mbedtls_ssl_context; typedef struct mbedtls_ssl_config mbedtls_ssl_config; /* Defined in ssl_internal.h */ typedef struct mbedtls_ssl_transform mbedtls_ssl_transform; typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params; typedef struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t; #if defined(MBEDTLS_X509_CRT_PARSE_C) typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert; #endif #if defined(MBEDTLS_SSL_PROTO_DTLS) typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item; #endif #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * \brief Callback type: start external signature operation. * * This callback is called during an SSL handshake to start * a signature decryption operation using an * external processor. The parameter \p cert contains * the public key; it is up to the callback function to * determine how to access the associated private key. * * This function typically sends or enqueues a request, and * does not wait for the operation to complete. This allows * the handshake step to be non-blocking. * * The parameters \p ssl and \p cert are guaranteed to remain * valid throughout the handshake. On the other hand, this * function must save the contents of \p hash if the value * is needed for later processing, because the \p hash buffer * is no longer valid after this function returns. * * This function may call mbedtls_ssl_set_async_operation_data() * to store an operation context for later retrieval * by the resume or cancel callback. * * \note For RSA signatures, this function must produce output * that is consistent with PKCS#1 v1.5 in the same way as * mbedtls_rsa_pkcs1_sign(). Before the private key operation, * apply the padding steps described in RFC 8017, section 9.2 * "EMSA-PKCS1-v1_5" as follows. * - If \p md_alg is #MBEDTLS_MD_NONE, apply the PKCS#1 v1.5 * encoding, treating \p hash as the DigestInfo to be * padded. In other words, apply EMSA-PKCS1-v1_5 starting * from step 3, with `T = hash` and `tLen = hash_len`. * - If `md_alg != MBEDTLS_MD_NONE`, apply the PKCS#1 v1.5 * encoding, treating \p hash as the hash to be encoded and * padded. In other words, apply EMSA-PKCS1-v1_5 starting * from step 2, with `digestAlgorithm` obtained by calling * mbedtls_oid_get_oid_by_md() on \p md_alg. * * \note For ECDSA signatures, the output format is the DER encoding * `Ecdsa-Sig-Value` defined in * [RFC 4492 section 5.4](https://tools.ietf.org/html/rfc4492#section-5.4). * * \param ssl The SSL connection instance. It should not be * modified other than via * mbedtls_ssl_set_async_operation_data(). * \param cert Certificate containing the public key. * In simple cases, this is one of the pointers passed to * mbedtls_ssl_conf_own_cert() when configuring the SSL * connection. However, if other callbacks are used, this * property may not hold. For example, if an SNI callback * is registered with mbedtls_ssl_conf_sni(), then * this callback determines what certificate is used. * \param md_alg Hash algorithm. * \param hash Buffer containing the hash. This buffer is * no longer valid when the function returns. * \param hash_len Size of the \c hash buffer in bytes. * * \return 0 if the operation was started successfully and the SSL * stack should call the resume callback immediately. * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if the operation * was started successfully and the SSL stack should return * immediately without calling the resume callback yet. * \return #MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH if the external * processor does not support this key. The SSL stack will * use the private key object instead. * \return Any other error indicates a fatal failure and is * propagated up the call chain. The callback should * use \c MBEDTLS_ERR_PK_xxx error codes, and <b>must not</b> * use \c MBEDTLS_ERR_SSL_xxx error codes except as * directed in the documentation of this callback. */ typedef int mbedtls_ssl_async_sign_t( mbedtls_ssl_context *ssl, mbedtls_x509_crt *cert, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len ); /** * \brief Callback type: start external decryption operation. * * This callback is called during an SSL handshake to start * an RSA decryption operation using an * external processor. The parameter \p cert contains * the public key; it is up to the callback function to * determine how to access the associated private key. * * This function typically sends or enqueues a request, and * does not wait for the operation to complete. This allows * the handshake step to be non-blocking. * * The parameters \p ssl and \p cert are guaranteed to remain * valid throughout the handshake. On the other hand, this * function must save the contents of \p input if the value * is needed for later processing, because the \p input buffer * is no longer valid after this function returns. * * This function may call mbedtls_ssl_set_async_operation_data() * to store an operation context for later retrieval * by the resume or cancel callback. * * \warning RSA decryption as used in TLS is subject to a potential * timing side channel attack first discovered by Bleichenbacher * in 1998. This attack can be remotely exploitable * in practice. To avoid this attack, you must ensure that * if the callback performs an RSA decryption, the time it * takes to execute and return the result does not depend * on whether the RSA decryption succeeded or reported * invalid padding. * * \param ssl The SSL connection instance. It should not be * modified other than via * mbedtls_ssl_set_async_operation_data(). * \param cert Certificate containing the public key. * In simple cases, this is one of the pointers passed to * mbedtls_ssl_conf_own_cert() when configuring the SSL * connection. However, if other callbacks are used, this * property may not hold. For example, if an SNI callback * is registered with mbedtls_ssl_conf_sni(), then * this callback determines what certificate is used. * \param input Buffer containing the input ciphertext. This buffer * is no longer valid when the function returns. * \param input_len Size of the \p input buffer in bytes. * * \return 0 if the operation was started successfully and the SSL * stack should call the resume callback immediately. * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if the operation * was started successfully and the SSL stack should return * immediately without calling the resume callback yet. * \return #MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH if the external * processor does not support this key. The SSL stack will * use the private key object instead. * \return Any other error indicates a fatal failure and is * propagated up the call chain. The callback should * use \c MBEDTLS_ERR_PK_xxx error codes, and <b>must not</b> * use \c MBEDTLS_ERR_SSL_xxx error codes except as * directed in the documentation of this callback. */ typedef int mbedtls_ssl_async_decrypt_t( mbedtls_ssl_context *ssl, mbedtls_x509_crt *cert, const unsigned char *input, size_t input_len ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ /** * \brief Callback type: resume external operation. * * This callback is called during an SSL handshake to resume * an external operation started by the * ::mbedtls_ssl_async_sign_t or * ::mbedtls_ssl_async_decrypt_t callback. * * This function typically checks the status of a pending * request or causes the request queue to make progress, and * does not wait for the operation to complete. This allows * the handshake step to be non-blocking. * * This function may call mbedtls_ssl_get_async_operation_data() * to retrieve an operation context set by the start callback. * It may call mbedtls_ssl_set_async_operation_data() to modify * this context. * * Note that when this function returns a status other than * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS, it must free any * resources associated with the operation. * * \param ssl The SSL connection instance. It should not be * modified other than via * mbedtls_ssl_set_async_operation_data(). * \param output Buffer containing the output (signature or decrypted * data) on success. * \param output_len On success, number of bytes written to \p output. * \param output_size Size of the \p output buffer in bytes. * * \return 0 if output of the operation is available in the * \p output buffer. * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if the operation * is still in progress. Subsequent requests for progress * on the SSL connection will call the resume callback * again. * \return Any other error means that the operation is aborted. * The SSL handshake is aborted. The callback should * use \c MBEDTLS_ERR_PK_xxx error codes, and <b>must not</b> * use \c MBEDTLS_ERR_SSL_xxx error codes except as * directed in the documentation of this callback. */ typedef int mbedtls_ssl_async_resume_t( mbedtls_ssl_context *ssl, unsigned char *output, size_t *output_len, size_t output_size ); /** * \brief Callback type: cancel external operation. * * This callback is called if an SSL connection is closed * while an asynchronous operation is in progress. Note that * this callback is not called if the * ::mbedtls_ssl_async_resume_t callback has run and has * returned a value other than * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS, since in that case * the asynchronous operation has already completed. * * This function may call mbedtls_ssl_get_async_operation_data() * to retrieve an operation context set by the start callback. * * \param ssl The SSL connection instance. It should not be * modified. */ typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ /* * This structure is used for storing current session data. */ struct mbedtls_ssl_session { #if defined(MBEDTLS_HAVE_TIME) mbedtls_time_t start; /*!< starting time */ #endif int ciphersuite; /*!< chosen ciphersuite */ int compression; /*!< chosen compression */ size_t id_len; /*!< session id length */ unsigned char id[32]; /*!< session identifier */ unsigned char master[48]; /*!< the master secret */ #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_x509_crt *peer_cert; /*!< peer X.509 cert chain */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ uint32_t verify_result; /*!< verification result */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) unsigned char *ticket; /*!< RFC 5077 session ticket */ size_t ticket_len; /*!< session ticket length */ uint32_t ticket_lifetime; /*!< ticket lifetime hint */ #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) unsigned char mfl_code; /*!< MaxFragmentLength negotiated by peer */ #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ #if defined(MBEDTLS_SSL_TRUNCATED_HMAC) int trunc_hmac; /*!< flag for truncated hmac activation */ #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) int encrypt_then_mac; /*!< flag for EtM activation */ #endif }; /** * SSL/TLS configuration to be shared between mbedtls_ssl_context structures. */ struct mbedtls_ssl_config { /* Group items by size (largest first) to minimize padding overhead */ /* * Pointers */ const int *ciphersuite_list[4]; /*!< allowed ciphersuites per version */ /** Callback for printing debug output */ void (*f_dbg)(void *, int, const char *, int, const char *); void *p_dbg; /*!< context for the debug function */ /** Callback for getting (pseudo-)random numbers */ int (*f_rng)(void *, unsigned char *, size_t); void *p_rng; /*!< context for the RNG function */ /** Callback to retrieve a session from the cache */ int (*f_get_cache)(void *, mbedtls_ssl_session *); /** Callback to store a session into the cache */ int (*f_set_cache)(void *, const mbedtls_ssl_session *); void *p_cache; /*!< context for cache callbacks */ #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) /** Callback for setting cert according to SNI extension */ int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t); void *p_sni; /*!< context for SNI callback */ #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) /** Callback to customize X.509 certificate chain verification */ int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *); void *p_vrfy; /*!< context for X.509 verify calllback */ #endif #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) /** Callback to retrieve PSK key from identity */ int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t); void *p_psk; /*!< context for PSK callback */ #endif #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) /** Callback to create & write a cookie for ClientHello veirifcation */ int (*f_cookie_write)( void *, unsigned char **, unsigned char *, const unsigned char *, size_t ); /** Callback to verify validity of a ClientHello cookie */ int (*f_cookie_check)( void *, const unsigned char *, size_t, const unsigned char *, size_t ); void *p_cookie; /*!< context for the cookie callbacks */ #endif #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C) /** Callback to create & write a session ticket */ int (*f_ticket_write)( void *, const mbedtls_ssl_session *, unsigned char *, const unsigned char *, size_t *, uint32_t * ); /** Callback to parse a session ticket into a session structure */ int (*f_ticket_parse)( void *, mbedtls_ssl_session *, unsigned char *, size_t); void *p_ticket; /*!< context for the ticket callbacks */ #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */ #if defined(MBEDTLS_SSL_EXPORT_KEYS) /** Callback to export key block and master secret */ int (*f_export_keys)( void *, const unsigned char *, const unsigned char *, size_t, size_t, size_t ); void *p_export_keys; /*!< context for key export callback */ #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) const mbedtls_x509_crt_profile *cert_profile; /*!< verification profile */ mbedtls_ssl_key_cert *key_cert; /*!< own certificate/key pair(s) */ mbedtls_x509_crt *ca_chain; /*!< trusted CAs */ mbedtls_x509_crl *ca_crl; /*!< trusted CAs CRLs */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_ssl_async_sign_t *f_async_sign_start; /*!< start asynchronous signature operation */ mbedtls_ssl_async_decrypt_t *f_async_decrypt_start; /*!< start asynchronous decryption operation */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ mbedtls_ssl_async_resume_t *f_async_resume; /*!< resume asynchronous operation */ mbedtls_ssl_async_cancel_t *f_async_cancel; /*!< cancel asynchronous operation */ void *p_async_config_data; /*!< Configuration data set by mbedtls_ssl_conf_async_private_cb(). */ #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) const int *sig_hashes; /*!< allowed signature hashes */ #endif #if defined(MBEDTLS_ECP_C) const mbedtls_ecp_group_id *curve_list; /*!< allowed curves */ #endif #if defined(MBEDTLS_DHM_C) mbedtls_mpi dhm_P; /*!< prime modulus for DHM */ mbedtls_mpi dhm_G; /*!< generator for DHM */ #endif #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) unsigned char *psk; /*!< pre-shared key. This field should only be set via mbedtls_ssl_conf_psk() */ size_t psk_len; /*!< length of the pre-shared key. This field should only be set via mbedtls_ssl_conf_psk() */ unsigned char *psk_identity; /*!< identity for PSK negotiation. This field should only be set via mbedtls_ssl_conf_psk() */ size_t psk_identity_len;/*!< length of identity. This field should only be set via mbedtls_ssl_conf_psk() */ #endif #if defined(MBEDTLS_SSL_ALPN) const char **alpn_list; /*!< ordered list of protocols */ #endif /* * Numerical settings (int then char) */ uint32_t read_timeout; /*!< timeout for mbedtls_ssl_read (ms) */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint32_t hs_timeout_min; /*!< initial value of the handshake retransmission timeout (ms) */ uint32_t hs_timeout_max; /*!< maximum value of the handshake retransmission timeout (ms) */ #endif #if defined(MBEDTLS_SSL_RENEGOTIATION) int renego_max_records; /*!< grace period for renegotiation */ unsigned char renego_period[8]; /*!< value of the record counters that triggers renegotiation */ #endif #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) unsigned int badmac_limit; /*!< limit of records with a bad MAC */ #endif #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) unsigned int dhm_min_bitlen; /*!< min. bit length of the DHM prime */ #endif unsigned char max_major_ver; /*!< max. major version used */ unsigned char max_minor_ver; /*!< max. minor version used */ unsigned char min_major_ver; /*!< min. major version used */ unsigned char min_minor_ver; /*!< min. minor version used */ /* * Flags (bitfields) */ unsigned int endpoint : 1; /*!< 0: client, 1: server */ unsigned int transport : 1; /*!< stream (TLS) or datagram (DTLS) */ unsigned int authmode : 2; /*!< MBEDTLS_SSL_VERIFY_XXX */ /* needed even with renego disabled for LEGACY_BREAK_HANDSHAKE */ unsigned int allow_legacy_renegotiation : 2 ; /*!< MBEDTLS_LEGACY_XXX */ #if defined(MBEDTLS_ARC4_C) unsigned int arc4_disabled : 1; /*!< blacklist RC4 ciphersuites? */ #endif #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) unsigned int mfl_code : 3; /*!< desired fragment length */ #endif #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) unsigned int encrypt_then_mac : 1 ; /*!< negotiate encrypt-then-mac? */ #endif #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) unsigned int extended_ms : 1; /*!< negotiate extended master secret? */ #endif #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) unsigned int anti_replay : 1; /*!< detect and prevent replay? */ #endif #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) unsigned int cbc_record_splitting : 1; /*!< do cbc record splitting */ #endif #if defined(MBEDTLS_SSL_RENEGOTIATION) unsigned int disable_renegotiation : 1; /*!< disable renegotiation? */ #endif #if defined(MBEDTLS_SSL_TRUNCATED_HMAC) unsigned int trunc_hmac : 1; /*!< negotiate truncated hmac? */ #endif #if defined(MBEDTLS_SSL_SESSION_TICKETS) unsigned int session_tickets : 1; /*!< use session tickets? */ #endif #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C) unsigned int fallback : 1; /*!< is this a fallback? */ #endif #if defined(MBEDTLS_SSL_SRV_C) unsigned int cert_req_ca_list : 1; /*!< enable sending CA list in Certificate Request messages? */ #endif }; struct mbedtls_ssl_context { const mbedtls_ssl_config *conf; /*!< configuration information */ /* * Miscellaneous */ int state; /*!< SSL handshake: current state */ #if defined(MBEDTLS_SSL_RENEGOTIATION) int renego_status; /*!< Initial, in progress, pending? */ int renego_records_seen; /*!< Records since renego request, or with DTLS, number of retransmissions of request if renego_max_records is < 0 */ #endif /* MBEDTLS_SSL_RENEGOTIATION */ int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */ int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */ #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) unsigned badmac_seen; /*!< records with a bad MAC received */ #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ mbedtls_ssl_send_t *f_send; /*!< Callback for network send */ mbedtls_ssl_recv_t *f_recv; /*!< Callback for network receive */ mbedtls_ssl_recv_timeout_t *f_recv_timeout; /*!< Callback for network receive with timeout */ void *p_bio; /*!< context for I/O operations */ /* * Session layer */ mbedtls_ssl_session *session_in; /*!< current session data (in) */ mbedtls_ssl_session *session_out; /*!< current session data (out) */ mbedtls_ssl_session *session; /*!< negotiated session data */ mbedtls_ssl_session *session_negotiate; /*!< session data in negotiation */ mbedtls_ssl_handshake_params *handshake; /*!< params required only during the handshake process */ /* * Record layer transformations */ mbedtls_ssl_transform *transform_in; /*!< current transform params (in) */ mbedtls_ssl_transform *transform_out; /*!< current transform params (in) */ mbedtls_ssl_transform *transform; /*!< negotiated transform params */ mbedtls_ssl_transform *transform_negotiate; /*!< transform params in negotiation */ /* * Timers */ void *p_timer; /*!< context for the timer callbacks */ mbedtls_ssl_set_timer_t *f_set_timer; /*!< set timer callback */ mbedtls_ssl_get_timer_t *f_get_timer; /*!< get timer callback */ /* * Record layer (incoming data) */ unsigned char *in_buf; /*!< input buffer */ unsigned char *in_ctr; /*!< 64-bit incoming message counter TLS: maintained by us DTLS: read from peer */ unsigned char *in_hdr; /*!< start of record header */ unsigned char *in_len; /*!< two-bytes message length field */ unsigned char *in_iv; /*!< ivlen-byte IV */ unsigned char *in_msg; /*!< message contents (in_iv+ivlen) */ unsigned char *in_offt; /*!< read offset in application data */ int in_msgtype; /*!< record header: message type */ size_t in_msglen; /*!< record header: message length */ size_t in_left; /*!< amount of data read so far */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint16_t in_epoch; /*!< DTLS epoch for incoming records */ size_t next_record_offset; /*!< offset of the next record in datagram (equal to in_left if none) */ #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) uint64_t in_window_top; /*!< last validated record seq_num */ uint64_t in_window; /*!< bitmask for replay detection */ #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ size_t in_hslen; /*!< current handshake message length, including the handshake header */ int nb_zero; /*!< # of 0-length encrypted messages */ int keep_current_message; /*!< drop or reuse current message on next call to record layer? */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint8_t disable_datagram_packing; /*!< Disable packing multiple records * within a single datagram. */ #endif /* MBEDTLS_SSL_PROTO_DTLS */ /* * Record layer (outgoing data) */ unsigned char *out_buf; /*!< output buffer */ unsigned char *out_ctr; /*!< 64-bit outgoing message counter */ unsigned char *out_hdr; /*!< start of record header */ unsigned char *out_len; /*!< two-bytes message length field */ unsigned char *out_iv; /*!< ivlen-byte IV */ unsigned char *out_msg; /*!< message contents (out_iv+ivlen) */ int out_msgtype; /*!< record header: message type */ size_t out_msglen; /*!< record header: message length */ size_t out_left; /*!< amount of data not yet written */ unsigned char cur_out_ctr[8]; /*!< Outgoing record sequence number. */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint16_t mtu; /*!< path mtu, used to fragment outgoing messages */ #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_ZLIB_SUPPORT) unsigned char *compress_buf; /*!< zlib data buffer */ #endif /* MBEDTLS_ZLIB_SUPPORT */ #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) signed char split_done; /*!< current record already splitted? */ #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ /* * PKI layer */ int client_auth; /*!< flag for client auth. */ /* * User settings */ #if defined(MBEDTLS_X509_CRT_PARSE_C) char *hostname; /*!< expected peer CN for verification (and SNI if available) */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_ALPN) const char *alpn_chosen; /*!< negotiated protocol */ #endif /* MBEDTLS_SSL_ALPN */ /* * Information for DTLS hello verify */ #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) unsigned char *cli_id; /*!< transport-level ID of the client */ size_t cli_id_len; /*!< length of cli_id */ #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */ /* * Secure renegotiation */ /* needed to know when to send extension on server */ int secure_renegotiation; /*!< does peer support legacy or secure renegotiation */ #if defined(MBEDTLS_SSL_RENEGOTIATION) size_t verify_data_len; /*!< length of verify data stored */ char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */ char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */ #endif /* MBEDTLS_SSL_RENEGOTIATION */ }; #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) #define MBEDTLS_SSL_CHANNEL_OUTBOUND 0 #define MBEDTLS_SSL_CHANNEL_INBOUND 1 extern int (*mbedtls_ssl_hw_record_init)(mbedtls_ssl_context *ssl, const unsigned char *key_enc, const unsigned char *key_dec, size_t keylen, const unsigned char *iv_enc, const unsigned char *iv_dec, size_t ivlen, const unsigned char *mac_enc, const unsigned char *mac_dec, size_t maclen); extern int (*mbedtls_ssl_hw_record_activate)(mbedtls_ssl_context *ssl, int direction); extern int (*mbedtls_ssl_hw_record_reset)(mbedtls_ssl_context *ssl); extern int (*mbedtls_ssl_hw_record_write)(mbedtls_ssl_context *ssl); extern int (*mbedtls_ssl_hw_record_read)(mbedtls_ssl_context *ssl); extern int (*mbedtls_ssl_hw_record_finish)(mbedtls_ssl_context *ssl); #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ /** * \brief Return the name of the ciphersuite associated with the * given ID * * \param ciphersuite_id SSL ciphersuite ID * * \return a string containing the ciphersuite name */ const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id ); /** * \brief Return the ID of the ciphersuite associated with the * given name * * \param ciphersuite_name SSL ciphersuite name * * \return the ID with the ciphersuite or 0 if not found */ int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name ); /** * \brief Initialize an SSL context * Just makes the context ready for mbedtls_ssl_setup() or * mbedtls_ssl_free() * * \param ssl SSL context */ void mbedtls_ssl_init( mbedtls_ssl_context *ssl ); /** * \brief Set up an SSL context for use * * \note No copy of the configuration context is made, it can be * shared by many mbedtls_ssl_context structures. * * \warning The conf structure will be accessed during the session. * It must not be modified or freed as long as the session * is active. * * \warning This function must be called exactly once per context. * Calling mbedtls_ssl_setup again is not supported, even * if no session is active. * * \param ssl SSL context * \param conf SSL configuration to use * * \return 0 if successful, or MBEDTLS_ERR_SSL_ALLOC_FAILED if * memory allocation failed */ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl, const mbedtls_ssl_config *conf ); /** * \brief Reset an already initialized SSL context for re-use * while retaining application-set variables, function * pointers and data. * * \param ssl SSL context * \return 0 if successful, or MBEDTLS_ERR_SSL_ALLOC_FAILED, MBEDTLS_ERR_SSL_HW_ACCEL_FAILED or * MBEDTLS_ERR_SSL_COMPRESSION_FAILED */ int mbedtls_ssl_session_reset( mbedtls_ssl_context *ssl ); /** * \brief Set the current endpoint type * * \param conf SSL configuration * \param endpoint must be MBEDTLS_SSL_IS_CLIENT or MBEDTLS_SSL_IS_SERVER */ void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint ); /** * \brief Set the transport type (TLS or DTLS). * Default: TLS * * \note For DTLS, you must either provide a recv callback that * doesn't block, or one that handles timeouts, see * \c mbedtls_ssl_set_bio(). You also need to provide timer * callbacks with \c mbedtls_ssl_set_timer_cb(). * * \param conf SSL configuration * \param transport transport type: * MBEDTLS_SSL_TRANSPORT_STREAM for TLS, * MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS. */ void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport ); /** * \brief Set the certificate verification mode * Default: NONE on server, REQUIRED on client * * \param conf SSL configuration * \param authmode can be: * * MBEDTLS_SSL_VERIFY_NONE: peer certificate is not checked * (default on server) * (insecure on client) * * MBEDTLS_SSL_VERIFY_OPTIONAL: peer certificate is checked, however the * handshake continues even if verification failed; * mbedtls_ssl_get_verify_result() can be called after the * handshake is complete. * * MBEDTLS_SSL_VERIFY_REQUIRED: peer *must* present a valid certificate, * handshake is aborted if verification failed. * (default on client) * * \note On client, MBEDTLS_SSL_VERIFY_REQUIRED is the recommended mode. * With MBEDTLS_SSL_VERIFY_OPTIONAL, the user needs to call mbedtls_ssl_get_verify_result() at * the right time(s), which may not be obvious, while REQUIRED always perform * the verification as soon as possible. For example, REQUIRED was protecting * against the "triple handshake" attack even before it was found. */ void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode ); #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * \brief Set the verification callback (Optional). * * If set, the verify callback is called for each * certificate in the chain. For implementation * information, please see \c mbedtls_x509_crt_verify() * * \param conf SSL configuration * \param f_vrfy verification function * \param p_vrfy verification parameter */ void mbedtls_ssl_conf_verify( mbedtls_ssl_config *conf, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ /** * \brief Set the random number generator callback * * \param conf SSL configuration * \param f_rng RNG function * \param p_rng RNG parameter */ void mbedtls_ssl_conf_rng( mbedtls_ssl_config *conf, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Set the debug callback * * The callback has the following argument: * void * opaque context for the callback * int debug level * const char * file name * int line number * const char * message * * \param conf SSL configuration * \param f_dbg debug function * \param p_dbg debug parameter */ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf, void (*f_dbg)(void *, int, const char *, int, const char *), void *p_dbg ); /** * \brief Set the underlying BIO callbacks for write, read and * read-with-timeout. * * \param ssl SSL context * \param p_bio parameter (context) shared by BIO callbacks * \param f_send write callback * \param f_recv read callback * \param f_recv_timeout blocking read callback with timeout. * * \note One of f_recv or f_recv_timeout can be NULL, in which case * the other is used. If both are non-NULL, f_recv_timeout is * used and f_recv is ignored (as if it were NULL). * * \note The two most common use cases are: * - non-blocking I/O, f_recv != NULL, f_recv_timeout == NULL * - blocking I/O, f_recv == NULL, f_recv_timout != NULL * * \note For DTLS, you need to provide either a non-NULL * f_recv_timeout callback, or a f_recv that doesn't block. * * \note See the documentations of \c mbedtls_ssl_sent_t, * \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for * the conventions those callbacks must follow. * * \note On some platforms, net_sockets.c provides * \c mbedtls_net_send(), \c mbedtls_net_recv() and * \c mbedtls_net_recv_timeout() that are suitable to be used * here. */ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl, void *p_bio, mbedtls_ssl_send_t *f_send, mbedtls_ssl_recv_t *f_recv, mbedtls_ssl_recv_timeout_t *f_recv_timeout ); #if defined(MBEDTLS_SSL_PROTO_DTLS) /** * \brief Set the Maximum Tranport Unit (MTU). * Special value: 0 means unset (no limit). * This represents the maximum size of a datagram payload * handled by the transport layer (usually UDP) as determined * by the network link and stack. In practice, this controls * the maximum size datagram the DTLS layer will pass to the * \c f_send() callback set using \c mbedtls_ssl_set_bio(). * * \note The limit on datagram size is converted to a limit on * record payload by subtracting the current overhead of * encapsulation and encryption/authentication if any. * * \note This can be called at any point during the connection, for * example when a Path Maximum Transfer Unit (PMTU) * estimate becomes available from other sources, * such as lower (or higher) protocol layers. * * \note This setting only controls the size of the packets we send, * and does not restrict the size of the datagrams we're * willing to receive. Client-side, you can request the * server to use smaller records with \c * mbedtls_ssl_conf_max_frag_len(). * * \note If both a MTU and a maximum fragment length have been * configured (or negotiated with the peer), the resulting * lower limit on record payload (see first note) is used. * * \note This can only be used to decrease the maximum size * of datagrams (hence records, see first note) sent. It * cannot be used to increase the maximum size of records over * the limit set by #MBEDTLS_SSL_OUT_CONTENT_LEN. * * \note Values lower than the current record layer expansion will * result in an error when trying to send data. * * \note Using record compression together with a non-zero MTU value * will result in an error when trying to send data. * * \param ssl SSL context * \param mtu Value of the path MTU in bytes */ void mbedtls_ssl_set_mtu( mbedtls_ssl_context *ssl, uint16_t mtu ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ /** * \brief Set the timeout period for mbedtls_ssl_read() * (Default: no timeout.) * * \param conf SSL configuration context * \param timeout Timeout value in milliseconds. * Use 0 for no timeout (default). * * \note With blocking I/O, this will only work if a non-NULL * \c f_recv_timeout was set with \c mbedtls_ssl_set_bio(). * With non-blocking I/O, this will only work if timer * callbacks were set with \c mbedtls_ssl_set_timer_cb(). * * \note With non-blocking I/O, you may also skip this function * altogether and handle timeouts at the application layer. */ void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout ); /** * \brief Set the timer callbacks (Mandatory for DTLS.) * * \param ssl SSL context * \param p_timer parameter (context) shared by timer callbacks * \param f_set_timer set timer callback * \param f_get_timer get timer callback. Must return: * * \note See the documentation of \c mbedtls_ssl_set_timer_t and * \c mbedtls_ssl_get_timer_t for the conventions this pair of * callbacks must follow. * * \note On some platforms, timing.c provides * \c mbedtls_timing_set_delay() and * \c mbedtls_timing_get_delay() that are suitable for using * here, except if using an event-driven style. * * \note See also the "DTLS tutorial" article in our knowledge base. * https://tls.mbed.org/kb/how-to/dtls-tutorial */ void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *ssl, void *p_timer, mbedtls_ssl_set_timer_t *f_set_timer, mbedtls_ssl_get_timer_t *f_get_timer ); /** * \brief Callback type: generate and write session ticket * * \note This describes what a callback implementation should do. * This callback should generate an encrypted and * authenticated ticket for the session and write it to the * output buffer. Here, ticket means the opaque ticket part * of the NewSessionTicket structure of RFC 5077. * * \param p_ticket Context for the callback * \param session SSL session to be written in the ticket * \param start Start of the output buffer * \param end End of the output buffer * \param tlen On exit, holds the length written * \param lifetime On exit, holds the lifetime of the ticket in seconds * * \return 0 if successful, or * a specific MBEDTLS_ERR_XXX code. */ typedef int mbedtls_ssl_ticket_write_t( void *p_ticket, const mbedtls_ssl_session *session, unsigned char *start, const unsigned char *end, size_t *tlen, uint32_t *lifetime ); #if defined(MBEDTLS_SSL_EXPORT_KEYS) /** * \brief Callback type: Export key block and master secret * * \note This is required for certain uses of TLS, e.g. EAP-TLS * (RFC 5216) and Thread. The key pointers are ephemeral and * therefore must not be stored. The master secret and keys * should not be used directly except as an input to a key * derivation function. * * \param p_expkey Context for the callback * \param ms Pointer to master secret (fixed length: 48 bytes) * \param kb Pointer to key block, see RFC 5246 section 6.3 * (variable length: 2 * maclen + 2 * keylen + 2 * ivlen). * \param maclen MAC length * \param keylen Key length * \param ivlen IV length * * \return 0 if successful, or * a specific MBEDTLS_ERR_XXX code. */ typedef int mbedtls_ssl_export_keys_t( void *p_expkey, const unsigned char *ms, const unsigned char *kb, size_t maclen, size_t keylen, size_t ivlen ); #endif /* MBEDTLS_SSL_EXPORT_KEYS */ /** * \brief Callback type: parse and load session ticket * * \note This describes what a callback implementation should do. * This callback should parse a session ticket as generated * by the corresponding mbedtls_ssl_ticket_write_t function, * and, if the ticket is authentic and valid, load the * session. * * \note The implementation is allowed to modify the first len * bytes of the input buffer, eg to use it as a temporary * area for the decrypted ticket contents. * * \param p_ticket Context for the callback * \param session SSL session to be loaded * \param buf Start of the buffer containing the ticket * \param len Length of the ticket. * * \return 0 if successful, or * MBEDTLS_ERR_SSL_INVALID_MAC if not authentic, or * MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED if expired, or * any other non-zero code for other failures. */ typedef int mbedtls_ssl_ticket_parse_t( void *p_ticket, mbedtls_ssl_session *session, unsigned char *buf, size_t len ); #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_SRV_C) /** * \brief Configure SSL session ticket callbacks (server only). * (Default: none.) * * \note On server, session tickets are enabled by providing * non-NULL callbacks. * * \note On client, use \c mbedtls_ssl_conf_session_tickets(). * * \param conf SSL configuration context * \param f_ticket_write Callback for writing a ticket * \param f_ticket_parse Callback for parsing a ticket * \param p_ticket Context shared by the two callbacks */ void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf, mbedtls_ssl_ticket_write_t *f_ticket_write, mbedtls_ssl_ticket_parse_t *f_ticket_parse, void *p_ticket ); #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */ #if defined(MBEDTLS_SSL_EXPORT_KEYS) /** * \brief Configure key export callback. * (Default: none.) * * \note See \c mbedtls_ssl_export_keys_t. * * \param conf SSL configuration context * \param f_export_keys Callback for exporting keys * \param p_export_keys Context for the callback */ void mbedtls_ssl_conf_export_keys_cb( mbedtls_ssl_config *conf, mbedtls_ssl_export_keys_t *f_export_keys, void *p_export_keys ); #endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) /** * \brief Configure asynchronous private key operation callbacks. * * \param conf SSL configuration context * \param f_async_sign Callback to start a signature operation. See * the description of ::mbedtls_ssl_async_sign_t * for more information. This may be \c NULL if the * external processor does not support any signature * operation; in this case the private key object * associated with the certificate will be used. * \param f_async_decrypt Callback to start a decryption operation. See * the description of ::mbedtls_ssl_async_decrypt_t * for more information. This may be \c NULL if the * external processor does not support any decryption * operation; in this case the private key object * associated with the certificate will be used. * \param f_async_resume Callback to resume an asynchronous operation. See * the description of ::mbedtls_ssl_async_resume_t * for more information. This may not be \c NULL unless * \p f_async_sign and \p f_async_decrypt are both * \c NULL. * \param f_async_cancel Callback to cancel an asynchronous operation. See * the description of ::mbedtls_ssl_async_cancel_t * for more information. This may be \c NULL if * no cleanup is needed. * \param config_data A pointer to configuration data which can be * retrieved with * mbedtls_ssl_conf_get_async_config_data(). The * library stores this value without dereferencing it. */ void mbedtls_ssl_conf_async_private_cb( mbedtls_ssl_config *conf, mbedtls_ssl_async_sign_t *f_async_sign, mbedtls_ssl_async_decrypt_t *f_async_decrypt, mbedtls_ssl_async_resume_t *f_async_resume, mbedtls_ssl_async_cancel_t *f_async_cancel, void *config_data ); /** * \brief Retrieve the configuration data set by * mbedtls_ssl_conf_async_private_cb(). * * \param conf SSL configuration context * \return The configuration data set by * mbedtls_ssl_conf_async_private_cb(). */ void *mbedtls_ssl_conf_get_async_config_data( const mbedtls_ssl_config *conf ); /** * \brief Retrieve the asynchronous operation user context. * * \note This function may only be called while a handshake * is in progress. * * \param ssl The SSL context to access. * * \return The asynchronous operation user context that was last * set during the current handshake. If * mbedtls_ssl_set_async_operation_data() has not yet been * called during the current handshake, this function returns * \c NULL. */ void *mbedtls_ssl_get_async_operation_data( const mbedtls_ssl_context *ssl ); /** * \brief Retrieve the asynchronous operation user context. * * \note This function may only be called while a handshake * is in progress. * * \param ssl The SSL context to access. * \param ctx The new value of the asynchronous operation user context. * Call mbedtls_ssl_get_async_operation_data() later during the * same handshake to retrieve this value. */ void mbedtls_ssl_set_async_operation_data( mbedtls_ssl_context *ssl, void *ctx ); #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ /** * \brief Callback type: generate a cookie * * \param ctx Context for the callback * \param p Buffer to write to, * must be updated to point right after the cookie * \param end Pointer to one past the end of the output buffer * \param info Client ID info that was passed to * \c mbedtls_ssl_set_client_transport_id() * \param ilen Length of info in bytes * * \return The callback must return 0 on success, * or a negative error code. */ typedef int mbedtls_ssl_cookie_write_t( void *ctx, unsigned char **p, unsigned char *end, const unsigned char *info, size_t ilen ); /** * \brief Callback type: verify a cookie * * \param ctx Context for the callback * \param cookie Cookie to verify * \param clen Length of cookie * \param info Client ID info that was passed to * \c mbedtls_ssl_set_client_transport_id() * \param ilen Length of info in bytes * * \return The callback must return 0 if cookie is valid, * or a negative error code. */ typedef int mbedtls_ssl_cookie_check_t( void *ctx, const unsigned char *cookie, size_t clen, const unsigned char *info, size_t ilen ); #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) /** * \brief Register callbacks for DTLS cookies * (Server only. DTLS only.) * * Default: dummy callbacks that fail, in order to force you to * register working callbacks (and initialize their context). * * To disable HelloVerifyRequest, register NULL callbacks. * * \warning Disabling hello verification allows your server to be used * for amplification in DoS attacks against other hosts. * Only disable if you known this can't happen in your * particular environment. * * \note See comments on \c mbedtls_ssl_handshake() about handling * the MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED that is expected * on the first handshake attempt when this is enabled. * * \note This is also necessary to handle client reconnection from * the same port as described in RFC 6347 section 4.2.8 (only * the variant with cookies is supported currently). See * comments on \c mbedtls_ssl_read() for details. * * \param conf SSL configuration * \param f_cookie_write Cookie write callback * \param f_cookie_check Cookie check callback * \param p_cookie Context for both callbacks */ void mbedtls_ssl_conf_dtls_cookies( mbedtls_ssl_config *conf, mbedtls_ssl_cookie_write_t *f_cookie_write, mbedtls_ssl_cookie_check_t *f_cookie_check, void *p_cookie ); /** * \brief Set client's transport-level identification info. * (Server only. DTLS only.) * * This is usually the IP address (and port), but could be * anything identify the client depending on the underlying * network stack. Used for HelloVerifyRequest with DTLS. * This is *not* used to route the actual packets. * * \param ssl SSL context * \param info Transport-level info identifying the client (eg IP + port) * \param ilen Length of info in bytes * * \note An internal copy is made, so the info buffer can be reused. * * \return 0 on success, * MBEDTLS_ERR_SSL_BAD_INPUT_DATA if used on client, * MBEDTLS_ERR_SSL_ALLOC_FAILED if out of memory. */ int mbedtls_ssl_set_client_transport_id( mbedtls_ssl_context *ssl, const unsigned char *info, size_t ilen ); #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */ #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) /** * \brief Enable or disable anti-replay protection for DTLS. * (DTLS only, no effect on TLS.) * Default: enabled. * * \param conf SSL configuration * \param mode MBEDTLS_SSL_ANTI_REPLAY_ENABLED or MBEDTLS_SSL_ANTI_REPLAY_DISABLED. * * \warning Disabling this is a security risk unless the application * protocol handles duplicated packets in a safe way. You * should not disable this without careful consideration. * However, if your application already detects duplicated * packets and needs information about them to adjust its * transmission strategy, then you'll want to disable this. */ void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode ); #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) /** * \brief Set a limit on the number of records with a bad MAC * before terminating the connection. * (DTLS only, no effect on TLS.) * Default: 0 (disabled). * * \param conf SSL configuration * \param limit Limit, or 0 to disable. * * \note If the limit is N, then the connection is terminated when * the Nth non-authentic record is seen. * * \note Records with an invalid header are not counted, only the * ones going through the authentication-decryption phase. * * \note This is a security trade-off related to the fact that it's * often relatively easy for an active attacker ot inject UDP * datagrams. On one hand, setting a low limit here makes it * easier for such an attacker to forcibly terminated a * connection. On the other hand, a high limit or no limit * might make us waste resources checking authentication on * many bogus packets. */ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limit ); #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ #if defined(MBEDTLS_SSL_PROTO_DTLS) /** * \brief Allow or disallow packing of multiple handshake records * within a single datagram. * * \param ssl The SSL context to configure. * \param allow_packing This determines whether datagram packing may * be used or not. A value of \c 0 means that every * record will be sent in a separate datagram; a * value of \c 1 means that, if space permits, * multiple handshake messages (including CCS) belonging to * a single flight may be packed within a single datagram. * * \note This is enabled by default and should only be disabled * for test purposes, or if datagram packing causes * interoperability issues with peers that don't support it. * * \note Allowing datagram packing reduces the network load since * there's less overhead if multiple messages share the same * datagram. Also, it increases the handshake efficiency * since messages belonging to a single datagram will not * be reordered in transit, and so future message buffering * or flight retransmission (if no buffering is used) as * means to deal with reordering are needed less frequently. * * \note Application records are not affected by this option and * are currently always sent in separate datagrams. * */ void mbedtls_ssl_set_datagram_packing( mbedtls_ssl_context *ssl, unsigned allow_packing ); /** * \brief Set retransmit timeout values for the DTLS handshake. * (DTLS only, no effect on TLS.) * * \param conf SSL configuration * \param min Initial timeout value in milliseconds. * Default: 1000 (1 second). * \param max Maximum timeout value in milliseconds. * Default: 60000 (60 seconds). * * \note Default values are from RFC 6347 section 4.2.4.1. * * \note The 'min' value should typically be slightly above the * expected round-trip time to your peer, plus whatever time * it takes for the peer to process the message. For example, * if your RTT is about 600ms and you peer needs up to 1s to * do the cryptographic operations in the handshake, then you * should set 'min' slightly above 1600. Lower values of 'min' * might cause spurious resends which waste network resources, * while larger value of 'min' will increase overall latency * on unreliable network links. * * \note The more unreliable your network connection is, the larger * your max / min ratio needs to be in order to achieve * reliable handshakes. * * \note Messages are retransmitted up to log2(ceil(max/min)) times. * For example, if min = 1s and max = 5s, the retransmit plan * goes: send ... 1s -> resend ... 2s -> resend ... 4s -> * resend ... 5s -> give up and return a timeout error. */ void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_SRV_C) /** * \brief Set the session cache callbacks (server-side only) * If not set, no session resuming is done (except if session * tickets are enabled too). * * The session cache has the responsibility to check for stale * entries based on timeout. See RFC 5246 for recommendations. * * Warning: session.peer_cert is cleared by the SSL/TLS layer on * connection shutdown, so do not cache the pointer! Either set * it to NULL or make a full copy of the certificate. * * The get callback is called once during the initial handshake * to enable session resuming. The get function has the * following parameters: (void *parameter, mbedtls_ssl_session *session) * If a valid entry is found, it should fill the master of * the session object with the cached values and return 0, * return 1 otherwise. Optionally peer_cert can be set as well * if it is properly present in cache entry. * * The set callback is called once during the initial handshake * to enable session resuming after the entire handshake has * been finished. The set function has the following parameters: * (void *parameter, const mbedtls_ssl_session *session). The function * should create a cache entry for future retrieval based on * the data in the session structure and should keep in mind * that the mbedtls_ssl_session object presented (and all its referenced * data) is cleared by the SSL/TLS layer when the connection is * terminated. It is recommended to add metadata to determine if * an entry is still valid in the future. Return 0 if * successfully cached, return 1 otherwise. * * \param conf SSL configuration * \param p_cache parmater (context) for both callbacks * \param f_get_cache session get callback * \param f_set_cache session set callback */ void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf, void *p_cache, int (*f_get_cache)(void *, mbedtls_ssl_session *), int (*f_set_cache)(void *, const mbedtls_ssl_session *) ); #endif /* MBEDTLS_SSL_SRV_C */ #if defined(MBEDTLS_SSL_CLI_C) /** * \brief Request resumption of session (client-side only) * Session data is copied from presented session structure. * * \param ssl SSL context * \param session session context * * \return 0 if successful, * MBEDTLS_ERR_SSL_ALLOC_FAILED if memory allocation failed, * MBEDTLS_ERR_SSL_BAD_INPUT_DATA if used server-side or * arguments are otherwise invalid * * \sa mbedtls_ssl_get_session() */ int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session ); #endif /* MBEDTLS_SSL_CLI_C */ /** * \brief Set the list of allowed ciphersuites and the preference * order. First in the list has the highest preference. * (Overrides all version-specific lists) * * The ciphersuites array is not copied, and must remain * valid for the lifetime of the ssl_config. * * Note: The server uses its own preferences * over the preference of the client unless * MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE is defined! * * \param conf SSL configuration * \param ciphersuites 0-terminated list of allowed ciphersuites */ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, const int *ciphersuites ); /** * \brief Set the list of allowed ciphersuites and the * preference order for a specific version of the protocol. * (Only useful on the server side) * * The ciphersuites array is not copied, and must remain * valid for the lifetime of the ssl_config. * * \param conf SSL configuration * \param ciphersuites 0-terminated list of allowed ciphersuites * \param major Major version number (only MBEDTLS_SSL_MAJOR_VERSION_3 * supported) * \param minor Minor version number (MBEDTLS_SSL_MINOR_VERSION_0, * MBEDTLS_SSL_MINOR_VERSION_1 and MBEDTLS_SSL_MINOR_VERSION_2, * MBEDTLS_SSL_MINOR_VERSION_3 supported) * * \note With DTLS, use MBEDTLS_SSL_MINOR_VERSION_2 for DTLS 1.0 * and MBEDTLS_SSL_MINOR_VERSION_3 for DTLS 1.2 */ void mbedtls_ssl_conf_ciphersuites_for_version( mbedtls_ssl_config *conf, const int *ciphersuites, int major, int minor ); #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * \brief Set the X.509 security profile used for verification * * \note The restrictions are enforced for all certificates in the * chain. However, signatures in the handshake are not covered * by this setting but by \b mbedtls_ssl_conf_sig_hashes(). * * \param conf SSL configuration * \param profile Profile to use */ void mbedtls_ssl_conf_cert_profile( mbedtls_ssl_config *conf, const mbedtls_x509_crt_profile *profile ); /** * \brief Set the data required to verify peer certificate * * \note See \c mbedtls_x509_crt_verify() for notes regarding the * parameters ca_chain (maps to trust_ca for that function) * and ca_crl. * * \param conf SSL configuration * \param ca_chain trusted CA chain (meaning all fully trusted top-level CAs) * \param ca_crl trusted CA CRLs */ void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf, mbedtls_x509_crt *ca_chain, mbedtls_x509_crl *ca_crl ); /** * \brief Set own certificate chain and private key * * \note own_cert should contain in order from the bottom up your * certificate chain. The top certificate (self-signed) * can be omitted. * * \note On server, this function can be called multiple times to * provision more than one cert/key pair (eg one ECDSA, one * RSA with SHA-256, one RSA with SHA-1). An adequate * certificate will be selected according to the client's * advertised capabilities. In case mutliple certificates are * adequate, preference is given to the one set by the first * call to this function, then second, etc. * * \note On client, only the first call has any effect. That is, * only one client certificate can be provisioned. The * server's preferences in its CertficateRequest message will * be ignored and our only cert will be sent regardless of * whether it matches those preferences - the server can then * decide what it wants to do with it. * * \note The provided \p pk_key needs to match the public key in the * first certificate in \p own_cert, or all handshakes using * that certificate will fail. It is your responsibility * to ensure that; this function will not perform any check. * You may use mbedtls_pk_check_pair() in order to perform * this check yourself, but be aware that this function can * be computationally expensive on some key types. * * \param conf SSL configuration * \param own_cert own public certificate chain * \param pk_key own private key * * \return 0 on success or MBEDTLS_ERR_SSL_ALLOC_FAILED */ int mbedtls_ssl_conf_own_cert( mbedtls_ssl_config *conf, mbedtls_x509_crt *own_cert, mbedtls_pk_context *pk_key ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) /** * \brief Set the Pre Shared Key (PSK) and the expected identity name * * \note This is mainly useful for clients. Servers will usually * want to use \c mbedtls_ssl_conf_psk_cb() instead. * * \note Currently clients can only register one pre-shared key. * In other words, the servers' identity hint is ignored. * Support for setting multiple PSKs on clients and selecting * one based on the identity hint is not a planned feature but * feedback is welcomed. * * \param conf SSL configuration * \param psk pointer to the pre-shared key * \param psk_len pre-shared key length * \param psk_identity pointer to the pre-shared key identity * \param psk_identity_len identity key length * * \return 0 if successful or MBEDTLS_ERR_SSL_ALLOC_FAILED */ int mbedtls_ssl_conf_psk( mbedtls_ssl_config *conf, const unsigned char *psk, size_t psk_len, const unsigned char *psk_identity, size_t psk_identity_len ); /** * \brief Set the Pre Shared Key (PSK) for the current handshake * * \note This should only be called inside the PSK callback, * ie the function passed to \c mbedtls_ssl_conf_psk_cb(). * * \param ssl SSL context * \param psk pointer to the pre-shared key * \param psk_len pre-shared key length * * \return 0 if successful or MBEDTLS_ERR_SSL_ALLOC_FAILED */ int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl, const unsigned char *psk, size_t psk_len ); /** * \brief Set the PSK callback (server-side only). * * If set, the PSK callback is called for each * handshake where a PSK ciphersuite was negotiated. * The caller provides the identity received and wants to * receive the actual PSK data and length. * * The callback has the following parameters: (void *parameter, * mbedtls_ssl_context *ssl, const unsigned char *psk_identity, * size_t identity_len) * If a valid PSK identity is found, the callback should use * \c mbedtls_ssl_set_hs_psk() on the ssl context to set the * correct PSK and return 0. * Any other return value will result in a denied PSK identity. * * \note If you set a PSK callback using this function, then you * don't need to set a PSK key and identity using * \c mbedtls_ssl_conf_psk(). * * \param conf SSL configuration * \param f_psk PSK identity function * \param p_psk PSK identity parameter */ void mbedtls_ssl_conf_psk_cb( mbedtls_ssl_config *conf, int (*f_psk)(void *, mbedtls_ssl_context *, const unsigned char *, size_t), void *p_psk ); #endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */ #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C) #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Set the Diffie-Hellman public P and G values, * read as hexadecimal strings (server-side only) * (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG]) * * \param conf SSL configuration * \param dhm_P Diffie-Hellman-Merkle modulus * \param dhm_G Diffie-Hellman-Merkle generator * * \deprecated Superseded by \c mbedtls_ssl_conf_dh_param_bin. * * \return 0 if successful */ MBEDTLS_DEPRECATED int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf, const char *dhm_P, const char *dhm_G ); #endif /* MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Set the Diffie-Hellman public P and G values * from big-endian binary presentations. * (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG]_BIN) * * \param conf SSL configuration * \param dhm_P Diffie-Hellman-Merkle modulus in big-endian binary form * \param P_len Length of DHM modulus * \param dhm_G Diffie-Hellman-Merkle generator in big-endian binary form * \param G_len Length of DHM generator * * \return 0 if successful */ int mbedtls_ssl_conf_dh_param_bin( mbedtls_ssl_config *conf, const unsigned char *dhm_P, size_t P_len, const unsigned char *dhm_G, size_t G_len ); /** * \brief Set the Diffie-Hellman public P and G values, * read from existing context (server-side only) * * \param conf SSL configuration * \param dhm_ctx Diffie-Hellman-Merkle context * * \return 0 if successful */ int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx ); #endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */ #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) /** * \brief Set the minimum length for Diffie-Hellman parameters. * (Client-side only.) * (Default: 1024 bits.) * * \param conf SSL configuration * \param bitlen Minimum bit length of the DHM prime */ void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, unsigned int bitlen ); #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */ #if defined(MBEDTLS_ECP_C) /** * \brief Set the allowed curves in order of preference. * (Default: all defined curves.) * * On server: this only affects selection of the ECDHE curve; * the curves used for ECDH and ECDSA are determined by the * list of available certificates instead. * * On client: this affects the list of curves offered for any * use. The server can override our preference order. * * Both sides: limits the set of curves accepted for use in * ECDHE and in the peer's end-entity certificate. * * \note This has no influence on which curves are allowed inside the * certificate chains, see \c mbedtls_ssl_conf_cert_profile() * for that. For the end-entity certificate however, the key * will be accepted only if it is allowed both by this list * and by the cert profile. * * \note This list should be ordered by decreasing preference * (preferred curve first). * * \param conf SSL configuration * \param curves Ordered list of allowed curves, * terminated by MBEDTLS_ECP_DP_NONE. */ void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, const mbedtls_ecp_group_id *curves ); #endif /* MBEDTLS_ECP_C */ #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) /** * \brief Set the allowed hashes for signatures during the handshake. * (Default: all available hashes except MD5.) * * \note This only affects which hashes are offered and can be used * for signatures during the handshake. Hashes for message * authentication and the TLS PRF are controlled by the * ciphersuite, see \c mbedtls_ssl_conf_ciphersuites(). Hashes * used for certificate signature are controlled by the * verification profile, see \c mbedtls_ssl_conf_cert_profile(). * * \note This list should be ordered by decreasing preference * (preferred hash first). * * \param conf SSL configuration * \param hashes Ordered list of allowed signature hashes, * terminated by \c MBEDTLS_MD_NONE. */ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, const int *hashes ); #endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * \brief Set or reset the hostname to check against the received * server certificate. It sets the ServerName TLS extension, * too, if that extension is enabled. (client-side only) * * \param ssl SSL context * \param hostname the server hostname, may be NULL to clear hostname * \note Maximum hostname length MBEDTLS_SSL_MAX_HOST_NAME_LEN. * * \return 0 if successful, MBEDTLS_ERR_SSL_ALLOC_FAILED on * allocation failure, MBEDTLS_ERR_SSL_BAD_INPUT_DATA on * too long input hostname. * * Hostname set to the one provided on success (cleared * when NULL). On allocation failure hostname is cleared. * On too long input failure, old hostname is unchanged. */ int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) /** * \brief Set own certificate and key for the current handshake * * \note Same as \c mbedtls_ssl_conf_own_cert() but for use within * the SNI callback. * * \param ssl SSL context * \param own_cert own public certificate chain * \param pk_key own private key * * \return 0 on success or MBEDTLS_ERR_SSL_ALLOC_FAILED */ int mbedtls_ssl_set_hs_own_cert( mbedtls_ssl_context *ssl, mbedtls_x509_crt *own_cert, mbedtls_pk_context *pk_key ); /** * \brief Set the data required to verify peer certificate for the * current handshake * * \note Same as \c mbedtls_ssl_conf_ca_chain() but for use within * the SNI callback. * * \param ssl SSL context * \param ca_chain trusted CA chain (meaning all fully trusted top-level CAs) * \param ca_crl trusted CA CRLs */ void mbedtls_ssl_set_hs_ca_chain( mbedtls_ssl_context *ssl, mbedtls_x509_crt *ca_chain, mbedtls_x509_crl *ca_crl ); /** * \brief Set authmode for the current handshake. * * \note Same as \c mbedtls_ssl_conf_authmode() but for use within * the SNI callback. * * \param ssl SSL context * \param authmode MBEDTLS_SSL_VERIFY_NONE, MBEDTLS_SSL_VERIFY_OPTIONAL or * MBEDTLS_SSL_VERIFY_REQUIRED */ void mbedtls_ssl_set_hs_authmode( mbedtls_ssl_context *ssl, int authmode ); /** * \brief Set server side ServerName TLS extension callback * (optional, server-side only). * * If set, the ServerName callback is called whenever the * server receives a ServerName TLS extension from the client * during a handshake. The ServerName callback has the * following parameters: (void *parameter, mbedtls_ssl_context *ssl, * const unsigned char *hostname, size_t len). If a suitable * certificate is found, the callback must set the * certificate(s) and key(s) to use with \c * mbedtls_ssl_set_hs_own_cert() (can be called repeatedly), * and may optionally adjust the CA and associated CRL with \c * mbedtls_ssl_set_hs_ca_chain() as well as the client * authentication mode with \c mbedtls_ssl_set_hs_authmode(), * then must return 0. If no matching name is found, the * callback must either set a default cert, or * return non-zero to abort the handshake at this point. * * \param conf SSL configuration * \param f_sni verification function * \param p_sni verification parameter */ void mbedtls_ssl_conf_sni( mbedtls_ssl_config *conf, int (*f_sni)(void *, mbedtls_ssl_context *, const unsigned char *, size_t), void *p_sni ); #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) /** * \brief Set the EC J-PAKE password for current handshake. * * \note An internal copy is made, and destroyed as soon as the * handshake is completed, or when the SSL context is reset or * freed. * * \note The SSL context needs to be already set up. The right place * to call this function is between \c mbedtls_ssl_setup() or * \c mbedtls_ssl_reset() and \c mbedtls_ssl_handshake(). * * \param ssl SSL context * \param pw EC J-PAKE password (pre-shared secret) * \param pw_len length of pw in bytes * * \return 0 on success, or a negative error code. */ int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl, const unsigned char *pw, size_t pw_len ); #endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_SSL_ALPN) /** * \brief Set the supported Application Layer Protocols. * * \param conf SSL configuration * \param protos Pointer to a NULL-terminated list of supported protocols, * in decreasing preference order. The pointer to the list is * recorded by the library for later reference as required, so * the lifetime of the table must be atleast as long as the * lifetime of the SSL configuration structure. * * \return 0 on success, or MBEDTLS_ERR_SSL_BAD_INPUT_DATA. */ int mbedtls_ssl_conf_alpn_protocols( mbedtls_ssl_config *conf, const char **protos ); /** * \brief Get the name of the negotiated Application Layer Protocol. * This function should be called after the handshake is * completed. * * \param ssl SSL context * * \return Protcol name, or NULL if no protocol was negotiated. */ const char *mbedtls_ssl_get_alpn_protocol( const mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_ALPN */ /** * \brief Set the maximum supported version sent from the client side * and/or accepted at the server side * (Default: MBEDTLS_SSL_MAX_MAJOR_VERSION, MBEDTLS_SSL_MAX_MINOR_VERSION) * * \note This ignores ciphersuites from higher versions. * * \note With DTLS, use MBEDTLS_SSL_MINOR_VERSION_2 for DTLS 1.0 and * MBEDTLS_SSL_MINOR_VERSION_3 for DTLS 1.2 * * \param conf SSL configuration * \param major Major version number (only MBEDTLS_SSL_MAJOR_VERSION_3 supported) * \param minor Minor version number (MBEDTLS_SSL_MINOR_VERSION_0, * MBEDTLS_SSL_MINOR_VERSION_1 and MBEDTLS_SSL_MINOR_VERSION_2, * MBEDTLS_SSL_MINOR_VERSION_3 supported) */ void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor ); /** * \brief Set the minimum accepted SSL/TLS protocol version * (Default: TLS 1.0) * * \note Input outside of the SSL_MAX_XXXXX_VERSION and * SSL_MIN_XXXXX_VERSION range is ignored. * * \note MBEDTLS_SSL_MINOR_VERSION_0 (SSL v3) should be avoided. * * \note With DTLS, use MBEDTLS_SSL_MINOR_VERSION_2 for DTLS 1.0 and * MBEDTLS_SSL_MINOR_VERSION_3 for DTLS 1.2 * * \param conf SSL configuration * \param major Major version number (only MBEDTLS_SSL_MAJOR_VERSION_3 supported) * \param minor Minor version number (MBEDTLS_SSL_MINOR_VERSION_0, * MBEDTLS_SSL_MINOR_VERSION_1 and MBEDTLS_SSL_MINOR_VERSION_2, * MBEDTLS_SSL_MINOR_VERSION_3 supported) */ void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor ); #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C) /** * \brief Set the fallback flag (client-side only). * (Default: MBEDTLS_SSL_IS_NOT_FALLBACK). * * \note Set to MBEDTLS_SSL_IS_FALLBACK when preparing a fallback * connection, that is a connection with max_version set to a * lower value than the value you're willing to use. Such * fallback connections are not recommended but are sometimes * necessary to interoperate with buggy (version-intolerant) * servers. * * \warning You should NOT set this to MBEDTLS_SSL_IS_FALLBACK for * non-fallback connections! This would appear to work for a * while, then cause failures when the server is upgraded to * support a newer TLS version. * * \param conf SSL configuration * \param fallback MBEDTLS_SSL_IS_NOT_FALLBACK or MBEDTLS_SSL_IS_FALLBACK */ void mbedtls_ssl_conf_fallback( mbedtls_ssl_config *conf, char fallback ); #endif /* MBEDTLS_SSL_FALLBACK_SCSV && MBEDTLS_SSL_CLI_C */ #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) /** * \brief Enable or disable Encrypt-then-MAC * (Default: MBEDTLS_SSL_ETM_ENABLED) * * \note This should always be enabled, it is a security * improvement, and should not cause any interoperability * issue (used only if the peer supports it too). * * \param conf SSL configuration * \param etm MBEDTLS_SSL_ETM_ENABLED or MBEDTLS_SSL_ETM_DISABLED */ void mbedtls_ssl_conf_encrypt_then_mac( mbedtls_ssl_config *conf, char etm ); #endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) /** * \brief Enable or disable Extended Master Secret negotiation. * (Default: MBEDTLS_SSL_EXTENDED_MS_ENABLED) * * \note This should always be enabled, it is a security fix to the * protocol, and should not cause any interoperability issue * (used only if the peer supports it too). * * \param conf SSL configuration * \param ems MBEDTLS_SSL_EXTENDED_MS_ENABLED or MBEDTLS_SSL_EXTENDED_MS_DISABLED */ void mbedtls_ssl_conf_extended_master_secret( mbedtls_ssl_config *conf, char ems ); #endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ #if defined(MBEDTLS_ARC4_C) /** * \brief Disable or enable support for RC4 * (Default: MBEDTLS_SSL_ARC4_DISABLED) * * \warning Use of RC4 in DTLS/TLS has been prohibited by RFC 7465 * for security reasons. Use at your own risk. * * \note This function is deprecated and will likely be removed in * a future version of the library. * RC4 is disabled by default at compile time and needs to be * actively enabled for use with legacy systems. * * \param conf SSL configuration * \param arc4 MBEDTLS_SSL_ARC4_ENABLED or MBEDTLS_SSL_ARC4_DISABLED */ void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 ); #endif /* MBEDTLS_ARC4_C */ #if defined(MBEDTLS_SSL_SRV_C) /** * \brief Whether to send a list of acceptable CAs in * CertificateRequest messages. * (Default: do send) * * \param conf SSL configuration * \param cert_req_ca_list MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED or * MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED */ void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf, char cert_req_ca_list ); #endif /* MBEDTLS_SSL_SRV_C */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** * \brief Set the maximum fragment length to emit and/or negotiate * (Default: the smaller of MBEDTLS_SSL_IN_CONTENT_LEN and * MBEDTLS_SSL_OUT_CONTENT_LEN, usually 2^14 bytes) * (Server: set maximum fragment length to emit, * usually negotiated by the client during handshake * (Client: set maximum fragment length to emit *and* * negotiate with the server during handshake) * * \note With TLS, this currently only affects ApplicationData (sent * with \c mbedtls_ssl_read()), not handshake messages. * With DTLS, this affects both ApplicationData and handshake. * * \note This sets the maximum length for a record's payload, * excluding record overhead that will be added to it, see * \c mbedtls_ssl_get_record_expansion(). * * \note For DTLS, it is also possible to set a limit for the total * size of daragrams passed to the transport layer, including * record overhead, see \c mbedtls_ssl_set_mtu(). * * \param conf SSL configuration * \param mfl_code Code for maximum fragment length (allowed values: * MBEDTLS_SSL_MAX_FRAG_LEN_512, MBEDTLS_SSL_MAX_FRAG_LEN_1024, * MBEDTLS_SSL_MAX_FRAG_LEN_2048, MBEDTLS_SSL_MAX_FRAG_LEN_4096) * * \return 0 if successful or MBEDTLS_ERR_SSL_BAD_INPUT_DATA */ int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code ); #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ #if defined(MBEDTLS_SSL_TRUNCATED_HMAC) /** * \brief Activate negotiation of truncated HMAC * (Default: MBEDTLS_SSL_TRUNC_HMAC_DISABLED) * * \param conf SSL configuration * \param truncate Enable or disable (MBEDTLS_SSL_TRUNC_HMAC_ENABLED or * MBEDTLS_SSL_TRUNC_HMAC_DISABLED) */ void mbedtls_ssl_conf_truncated_hmac( mbedtls_ssl_config *conf, int truncate ); #endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) /** * \brief Enable / Disable 1/n-1 record splitting * (Default: MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED) * * \note Only affects SSLv3 and TLS 1.0, not higher versions. * Does not affect non-CBC ciphersuites in any version. * * \param conf SSL configuration * \param split MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED or * MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED */ void mbedtls_ssl_conf_cbc_record_splitting( mbedtls_ssl_config *conf, char split ); #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) /** * \brief Enable / Disable session tickets (client only). * (Default: MBEDTLS_SSL_SESSION_TICKETS_ENABLED.) * * \note On server, use \c mbedtls_ssl_conf_session_tickets_cb(). * * \param conf SSL configuration * \param use_tickets Enable or disable (MBEDTLS_SSL_SESSION_TICKETS_ENABLED or * MBEDTLS_SSL_SESSION_TICKETS_DISABLED) */ void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets ); #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ #if defined(MBEDTLS_SSL_RENEGOTIATION) /** * \brief Enable / Disable renegotiation support for connection when * initiated by peer * (Default: MBEDTLS_SSL_RENEGOTIATION_DISABLED) * * \warning It is recommended to always disable renegotation unless you * know you need it and you know what you're doing. In the * past, there have been several issues associated with * renegotiation or a poor understanding of its properties. * * \note Server-side, enabling renegotiation also makes the server * susceptible to a resource DoS by a malicious client. * * \param conf SSL configuration * \param renegotiation Enable or disable (MBEDTLS_SSL_RENEGOTIATION_ENABLED or * MBEDTLS_SSL_RENEGOTIATION_DISABLED) */ void mbedtls_ssl_conf_renegotiation( mbedtls_ssl_config *conf, int renegotiation ); #endif /* MBEDTLS_SSL_RENEGOTIATION */ /** * \brief Prevent or allow legacy renegotiation. * (Default: MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION) * * MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION allows connections to * be established even if the peer does not support * secure renegotiation, but does not allow renegotiation * to take place if not secure. * (Interoperable and secure option) * * MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION allows renegotiations * with non-upgraded peers. Allowing legacy renegotiation * makes the connection vulnerable to specific man in the * middle attacks. (See RFC 5746) * (Most interoperable and least secure option) * * MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE breaks off connections * if peer does not support secure renegotiation. Results * in interoperability issues with non-upgraded peers * that do not support renegotiation altogether. * (Most secure option, interoperability issues) * * \param conf SSL configuration * \param allow_legacy Prevent or allow (SSL_NO_LEGACY_RENEGOTIATION, * SSL_ALLOW_LEGACY_RENEGOTIATION or * MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE) */ void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy ); #if defined(MBEDTLS_SSL_RENEGOTIATION) /** * \brief Enforce renegotiation requests. * (Default: enforced, max_records = 16) * * When we request a renegotiation, the peer can comply or * ignore the request. This function allows us to decide * whether to enforce our renegotiation requests by closing * the connection if the peer doesn't comply. * * However, records could already be in transit from the peer * when the request is emitted. In order to increase * reliability, we can accept a number of records before the * expected handshake records. * * The optimal value is highly dependent on the specific usage * scenario. * * \note With DTLS and server-initiated renegotiation, the * HelloRequest is retransmited every time mbedtls_ssl_read() times * out or receives Application Data, until: * - max_records records have beens seen, if it is >= 0, or * - the number of retransmits that would happen during an * actual handshake has been reached. * Please remember the request might be lost a few times * if you consider setting max_records to a really low value. * * \warning On client, the grace period can only happen during * mbedtls_ssl_read(), as opposed to mbedtls_ssl_write() and mbedtls_ssl_renegotiate() * which always behave as if max_record was 0. The reason is, * if we receive application data from the server, we need a * place to write it, which only happens during mbedtls_ssl_read(). * * \param conf SSL configuration * \param max_records Use MBEDTLS_SSL_RENEGOTIATION_NOT_ENFORCED if you don't want to * enforce renegotiation, or a non-negative value to enforce * it but allow for a grace period of max_records records. */ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_records ); /** * \brief Set record counter threshold for periodic renegotiation. * (Default: 2^48 - 1) * * Renegotiation is automatically triggered when a record * counter (outgoing or ingoing) crosses the defined * threshold. The default value is meant to prevent the * connection from being closed when the counter is about to * reached its maximal value (it is not allowed to wrap). * * Lower values can be used to enforce policies such as "keys * must be refreshed every N packets with cipher X". * * The renegotiation period can be disabled by setting * conf->disable_renegotiation to * MBEDTLS_SSL_RENEGOTIATION_DISABLED. * * \note When the configured transport is * MBEDTLS_SSL_TRANSPORT_DATAGRAM the maximum renegotiation * period is 2^48 - 1, and for MBEDTLS_SSL_TRANSPORT_STREAM, * the maximum renegotiation period is 2^64 - 1. * * \param conf SSL configuration * \param period The threshold value: a big-endian 64-bit number. */ void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf, const unsigned char period[8] ); #endif /* MBEDTLS_SSL_RENEGOTIATION */ /** * \brief Check if there is data already read from the * underlying transport but not yet processed. * * \param ssl SSL context * * \return 0 if nothing's pending, 1 otherwise. * * \note This is different in purpose and behaviour from * \c mbedtls_ssl_get_bytes_avail in that it considers * any kind of unprocessed data, not only unread * application data. If \c mbedtls_ssl_get_bytes * returns a non-zero value, this function will * also signal pending data, but the converse does * not hold. For example, in DTLS there might be * further records waiting to be processed from * the current underlying transport's datagram. * * \note If this function returns 1 (data pending), this * does not imply that a subsequent call to * \c mbedtls_ssl_read will provide any data; * e.g., the unprocessed data might turn out * to be an alert or a handshake message. * * \note This function is useful in the following situation: * If the SSL/TLS module successfully returns from an * operation - e.g. a handshake or an application record * read - and you're awaiting incoming data next, you * must not immediately idle on the underlying transport * to have data ready, but you need to check the value * of this function first. The reason is that the desired * data might already be read but not yet processed. * If, in contrast, a previous call to the SSL/TLS module * returned MBEDTLS_ERR_SSL_WANT_READ, it is not necessary * to call this function, as the latter error code entails * that all internal data has been processed. * */ int mbedtls_ssl_check_pending( const mbedtls_ssl_context *ssl ); /** * \brief Return the number of application data bytes * remaining to be read from the current record. * * \param ssl SSL context * * \return How many bytes are available in the application * data record read buffer. * * \note When working over a datagram transport, this is * useful to detect the current datagram's boundary * in case \c mbedtls_ssl_read has written the maximal * amount of data fitting into the input buffer. * */ size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl ); /** * \brief Return the result of the certificate verification * * \param ssl The SSL context to use. * * \return \c 0 if the certificate verification was successful. * \return \c -1u if the result is not available. This may happen * e.g. if the handshake aborts early, or a verification * callback returned a fatal error. * \return A bitwise combination of \c MBEDTLS_X509_BADCERT_XXX * and \c MBEDTLS_X509_BADCRL_XXX failure flags; see x509.h. */ uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl ); /** * \brief Return the name of the current ciphersuite * * \param ssl SSL context * * \return a string containing the ciphersuite name */ const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl ); /** * \brief Return the current SSL version (SSLv3/TLSv1/etc) * * \param ssl SSL context * * \return a string containing the SSL version */ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl ); /** * \brief Return the (maximum) number of bytes added by the record * layer: header + encryption/MAC overhead (inc. padding) * * \note This function is not available (always returns an error) * when record compression is enabled. * * \param ssl SSL context * * \return Current maximum record expansion in bytes, or * MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE if compression is * enabled, which makes expansion much less predictable */ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** * \brief Return the maximum fragment length (payload, in bytes). * This is the value negotiated with peer if any, * or the locally configured value. * * \sa mbedtls_ssl_conf_max_frag_len() * \sa mbedtls_ssl_get_max_record_payload() * * \param ssl SSL context * * \return Current maximum fragment length. */ size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ /** * \brief Return the current maximum outgoing record payload in bytes. * This takes into account the config.h setting \c * MBEDTLS_SSL_OUT_CONTENT_LEN, the configured and negotiated * max fragment length extension if used, and for DTLS the * path MTU as configured and current record expansion. * * \note With DTLS, \c mbedtls_ssl_write() will return an error if * called with a larger length value. * With TLS, \c mbedtls_ssl_write() will fragment the input if * necessary and return the number of bytes written; it is up * to the caller to call \c mbedtls_ssl_write() again in * order to send the remaining bytes if any. * * \note This function is not available (always returns an error) * when record compression is enabled. * * \sa mbedtls_ssl_set_mtu() * \sa mbedtls_ssl_get_max_frag_len() * \sa mbedtls_ssl_get_record_expansion() * * \param ssl SSL context * * \return Current maximum payload for an outgoing record, * or a negative error code. */ int mbedtls_ssl_get_max_out_record_payload( const mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * \brief Return the peer certificate from the current connection * * Note: Can be NULL in case no certificate was sent during * the handshake. Different calls for the same connection can * return the same or different pointers for the same * certificate and even a different certificate altogether. * The peer cert CAN change in a single connection if * renegotiation is performed. * * \param ssl SSL context * * \return the current peer certificate */ const mbedtls_x509_crt *mbedtls_ssl_get_peer_cert( const mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_CLI_C) /** * \brief Save session in order to resume it later (client-side only) * Session data is copied to presented session structure. * * * \param ssl SSL context * \param session session context * * \return 0 if successful, * MBEDTLS_ERR_SSL_ALLOC_FAILED if memory allocation failed, * MBEDTLS_ERR_SSL_BAD_INPUT_DATA if used server-side or * arguments are otherwise invalid. * * \note Only the server certificate is copied, and not the full chain, * so you should not attempt to validate the certificate again * by calling \c mbedtls_x509_crt_verify() on it. * Instead, you should use the results from the verification * in the original handshake by calling \c mbedtls_ssl_get_verify_result() * after loading the session again into a new SSL context * using \c mbedtls_ssl_set_session(). * * \note Once the session object is not needed anymore, you should * free it by calling \c mbedtls_ssl_session_free(). * * \sa mbedtls_ssl_set_session() */ int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session *session ); #endif /* MBEDTLS_SSL_CLI_C */ /** * \brief Perform the SSL handshake * * \param ssl SSL context * * \return \c 0 if successful. * \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE * if the handshake is incomplete and waiting for data to * be available for reading from or writing to the underlying * transport - in this case you must call this function again * when the underlying transport is ready for the operation. * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous * operation is in progress (see * mbedtls_ssl_conf_async_private_cb()) - in this case you * must call this function again when the operation is ready. * \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic * operation is in progress (see mbedtls_ecp_set_max_ops()) - * in this case you must call this function again to complete * the handshake when you're done attending other tasks. * \return #MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED if DTLS is in use * and the client did not demonstrate reachability yet - in * this case you must stop using the context (see below). * \return Another SSL error code - in this case you must stop using * the context (see below). * * \warning If this function returns something other than * \c 0, * #MBEDTLS_ERR_SSL_WANT_READ, * #MBEDTLS_ERR_SSL_WANT_WRITE, * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, * you must stop using the SSL context for reading or writing, * and either free it or call \c mbedtls_ssl_session_reset() * on it before re-using it for a new connection; the current * connection must be closed. * * \note If DTLS is in use, then you may choose to handle * #MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging * purposes, as it is an expected return value rather than an * actual error, but you still need to reset/free the context. * * \note Remarks regarding event-driven DTLS: * If the function returns #MBEDTLS_ERR_SSL_WANT_READ, no datagram * from the underlying transport layer is currently being processed, * and it is safe to idle until the timer or the underlying transport * signal a new event. This is not true for a successful handshake, * in which case the datagram of the underlying transport that is * currently being processed might or might not contain further * DTLS records. */ int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl ); /** * \brief Perform a single step of the SSL handshake * * \note The state of the context (ssl->state) will be at * the next state after this function returns \c 0. Do not * call this function if state is MBEDTLS_SSL_HANDSHAKE_OVER. * * \param ssl SSL context * * \return See mbedtls_ssl_handshake(). * * \warning If this function returns something other than \c 0, * #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE, * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using * the SSL context for reading or writing, and either free it * or call \c mbedtls_ssl_session_reset() on it before * re-using it for a new connection; the current connection * must be closed. */ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_RENEGOTIATION) /** * \brief Initiate an SSL renegotiation on the running connection. * Client: perform the renegotiation right now. * Server: request renegotiation, which will be performed * during the next call to mbedtls_ssl_read() if honored by * client. * * \param ssl SSL context * * \return 0 if successful, or any mbedtls_ssl_handshake() return * value except #MBEDTLS_ERR_SSL_CLIENT_RECONNECT that can't * happen during a renegotiation. * * \warning If this function returns something other than \c 0, * #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE, * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using * the SSL context for reading or writing, and either free it * or call \c mbedtls_ssl_session_reset() on it before * re-using it for a new connection; the current connection * must be closed. * */ int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_RENEGOTIATION */ /** * \brief Read at most 'len' application data bytes * * \param ssl SSL context * \param buf buffer that will hold the data * \param len maximum number of bytes to read * * \return The (positive) number of bytes read if successful. * \return \c 0 if the read end of the underlying transport was closed * - in this case you must stop using the context (see below). * \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE * if the handshake is incomplete and waiting for data to * be available for reading from or writing to the underlying * transport - in this case you must call this function again * when the underlying transport is ready for the operation. * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous * operation is in progress (see * mbedtls_ssl_conf_async_private_cb()) - in this case you * must call this function again when the operation is ready. * \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic * operation is in progress (see mbedtls_ecp_set_max_ops()) - * in this case you must call this function again to complete * the handshake when you're done attending other tasks. * \return #MBEDTLS_ERR_SSL_CLIENT_RECONNECT if we're at the server * side of a DTLS connection and the client is initiating a * new connection using the same source port. See below. * \return Another SSL error code - in this case you must stop using * the context (see below). * * \warning If this function returns something other than * a positive value, * #MBEDTLS_ERR_SSL_WANT_READ, * #MBEDTLS_ERR_SSL_WANT_WRITE, * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS, * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS or * #MBEDTLS_ERR_SSL_CLIENT_RECONNECT, * you must stop using the SSL context for reading or writing, * and either free it or call \c mbedtls_ssl_session_reset() * on it before re-using it for a new connection; the current * connection must be closed. * * \note When this function returns #MBEDTLS_ERR_SSL_CLIENT_RECONNECT * (which can only happen server-side), it means that a client * is initiating a new connection using the same source port. * You can either treat that as a connection close and wait * for the client to resend a ClientHello, or directly * continue with \c mbedtls_ssl_handshake() with the same * context (as it has been reset internally). Either way, you * must make sure this is seen by the application as a new * connection: application state, if any, should be reset, and * most importantly the identity of the client must be checked * again. WARNING: not validating the identity of the client * again, or not transmitting the new identity to the * application layer, would allow authentication bypass! * * \note Remarks regarding event-driven DTLS: * - If the function returns #MBEDTLS_ERR_SSL_WANT_READ, no datagram * from the underlying transport layer is currently being processed, * and it is safe to idle until the timer or the underlying transport * signal a new event. * - This function may return MBEDTLS_ERR_SSL_WANT_READ even if data was * initially available on the underlying transport, as this data may have * been only e.g. duplicated messages or a renegotiation request. * Therefore, you must be prepared to receive MBEDTLS_ERR_SSL_WANT_READ even * when reacting to an incoming-data event from the underlying transport. * - On success, the datagram of the underlying transport that is currently * being processed may contain further DTLS records. You should call * \c mbedtls_ssl_check_pending to check for remaining records. * */ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ); /** * \brief Try to write exactly 'len' application data bytes * * \warning This function will do partial writes in some cases. If the * return value is non-negative but less than length, the * function must be called again with updated arguments: * buf + ret, len - ret (if ret is the return value) until * it returns a value equal to the last 'len' argument. * * \param ssl SSL context * \param buf buffer holding the data * \param len how many bytes must be written * * \return The (non-negative) number of bytes actually written if * successful (may be less than \p len). * \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE * if the handshake is incomplete and waiting for data to * be available for reading from or writing to the underlying * transport - in this case you must call this function again * when the underlying transport is ready for the operation. * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous * operation is in progress (see * mbedtls_ssl_conf_async_private_cb()) - in this case you * must call this function again when the operation is ready. * \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic * operation is in progress (see mbedtls_ecp_set_max_ops()) - * in this case you must call this function again to complete * the handshake when you're done attending other tasks. * \return Another SSL error code - in this case you must stop using * the context (see below). * * \warning If this function returns something other than * a non-negative value, * #MBEDTLS_ERR_SSL_WANT_READ, * #MBEDTLS_ERR_SSL_WANT_WRITE, * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, * you must stop using the SSL context for reading or writing, * and either free it or call \c mbedtls_ssl_session_reset() * on it before re-using it for a new connection; the current * connection must be closed. * * \note When this function returns #MBEDTLS_ERR_SSL_WANT_WRITE/READ, * it must be called later with the *same* arguments, * until it returns a value greater that or equal to 0. When * the function returns #MBEDTLS_ERR_SSL_WANT_WRITE there may be * some partial data in the output buffer, however this is not * yet sent. * * \note If the requested length is greater than the maximum * fragment length (either the built-in limit or the one set * or negotiated with the peer), then: * - with TLS, less bytes than requested are written. * - with DTLS, MBEDTLS_ERR_SSL_BAD_INPUT_DATA is returned. * \c mbedtls_ssl_get_max_frag_len() may be used to query the * active maximum fragment length. * * \note Attempting to write 0 bytes will result in an empty TLS * application record being sent. */ int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len ); /** * \brief Send an alert message * * \param ssl SSL context * \param level The alert level of the message * (MBEDTLS_SSL_ALERT_LEVEL_WARNING or MBEDTLS_SSL_ALERT_LEVEL_FATAL) * \param message The alert message (SSL_ALERT_MSG_*) * * \return 0 if successful, or a specific SSL error code. * * \note If this function returns something other than 0 or * MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using * the SSL context for reading or writing, and either free it or * call \c mbedtls_ssl_session_reset() on it before re-using it * for a new connection; the current connection must be closed. */ int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl, unsigned char level, unsigned char message ); /** * \brief Notify the peer that the connection is being closed * * \param ssl SSL context * * \return 0 if successful, or a specific SSL error code. * * \note If this function returns something other than 0 or * MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using * the SSL context for reading or writing, and either free it or * call \c mbedtls_ssl_session_reset() on it before re-using it * for a new connection; the current connection must be closed. */ int mbedtls_ssl_close_notify( mbedtls_ssl_context *ssl ); /** * \brief Free referenced items in an SSL context and clear memory * * \param ssl SSL context */ void mbedtls_ssl_free( mbedtls_ssl_context *ssl ); /** * \brief Initialize an SSL configuration context * Just makes the context ready for * mbedtls_ssl_config_defaults() or mbedtls_ssl_config_free(). * * \note You need to call mbedtls_ssl_config_defaults() unless you * manually set all of the relevent fields yourself. * * \param conf SSL configuration context */ void mbedtls_ssl_config_init( mbedtls_ssl_config *conf ); /** * \brief Load reasonnable default SSL configuration values. * (You need to call mbedtls_ssl_config_init() first.) * * \param conf SSL configuration context * \param endpoint MBEDTLS_SSL_IS_CLIENT or MBEDTLS_SSL_IS_SERVER * \param transport MBEDTLS_SSL_TRANSPORT_STREAM for TLS, or * MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS * \param preset a MBEDTLS_SSL_PRESET_XXX value * * \note See \c mbedtls_ssl_conf_transport() for notes on DTLS. * * \return 0 if successful, or * MBEDTLS_ERR_XXX_ALLOC_FAILED on memory allocation error. */ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, int endpoint, int transport, int preset ); /** * \brief Free an SSL configuration context * * \param conf SSL configuration context */ void mbedtls_ssl_config_free( mbedtls_ssl_config *conf ); /** * \brief Initialize SSL session structure * * \param session SSL session */ void mbedtls_ssl_session_init( mbedtls_ssl_session *session ); /** * \brief Free referenced items in an SSL session including the * peer certificate and clear memory * * \note A session object can be freed even if the SSL context * that was used to retrieve the session is still in use. * * \param session SSL session */ void mbedtls_ssl_session_free( mbedtls_ssl_session *session ); #ifdef __cplusplus } #endif #endif /* ssl.h */
152,008
C++
.h
3,016
46.871353
167
0.611771
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false