mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 17:48:33 -04:00
Add FreeRTOS-Plus directory with new directory structure so it matches the FreeRTOS directory.
This commit is contained in:
parent
80f7e8cdd4
commit
64a3ab321a
528 changed files with 228252 additions and 0 deletions
80
FreeRTOS-Plus/Source/CyaSSL/cyassl/callbacks.h
Normal file
80
FreeRTOS-Plus/Source/CyaSSL/cyassl/callbacks.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* cyassl_callbacks.h
|
||||
*
|
||||
* Copyright (C) 2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_CALLBACKS_H
|
||||
#define CYASSL_CALLBACKS_H
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum { /* CALLBACK CONTSTANTS */
|
||||
MAX_PACKETNAME_SZ = 24,
|
||||
MAX_CIPHERNAME_SZ = 24,
|
||||
MAX_TIMEOUT_NAME_SZ = 24,
|
||||
MAX_PACKETS_HANDSHAKE = 14, /* 12 for client auth plus 2 alerts */
|
||||
MAX_VALUE_SZ = 128, /* all handshake packets but Cert should
|
||||
fit here */
|
||||
};
|
||||
|
||||
|
||||
typedef struct handShakeInfo_st {
|
||||
char cipherName[MAX_CIPHERNAME_SZ + 1]; /* negotiated cipher */
|
||||
char packetNames[MAX_PACKETS_HANDSHAKE][MAX_PACKETNAME_SZ + 1];
|
||||
/* SSL packet names */
|
||||
int numberPackets; /* actual # of packets */
|
||||
int negotiationError; /* cipher/parameter err */
|
||||
} HandShakeInfo;
|
||||
|
||||
|
||||
typedef struct timeval Timeval;
|
||||
|
||||
|
||||
typedef struct packetInfo_st {
|
||||
char packetName[MAX_PACKETNAME_SZ + 1]; /* SSL packet name */
|
||||
Timeval timestamp; /* when it occured */
|
||||
unsigned char value[MAX_VALUE_SZ]; /* if fits, it's here */
|
||||
unsigned char* bufferValue; /* otherwise here (non 0) */
|
||||
int valueSz; /* sz of value or buffer */
|
||||
} PacketInfo;
|
||||
|
||||
|
||||
typedef struct timeoutInfo_st {
|
||||
char timeoutName[MAX_TIMEOUT_NAME_SZ + 1]; /* timeout Name */
|
||||
int flags; /* for future use */
|
||||
int numberPackets; /* actual # of packets */
|
||||
PacketInfo packets[MAX_PACKETS_HANDSHAKE]; /* list of all packets */
|
||||
Timeval timeoutValue; /* timer that caused it */
|
||||
} TimeoutInfo;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CyaSSL_CALLBACKS_H */
|
||||
|
47
FreeRTOS-Plus/Source/CyaSSL/cyassl/crl.h
Normal file
47
FreeRTOS-Plus/Source/CyaSSL/cyassl/crl.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* crl.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_CRL_H
|
||||
#define CYASSL_CRL_H
|
||||
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/ctaocrypt/asn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CYASSL_CRL CYASSL_CRL;
|
||||
|
||||
CYASSL_LOCAL int InitCRL(CYASSL_CRL*, CYASSL_CERT_MANAGER*);
|
||||
CYASSL_LOCAL void FreeCRL(CYASSL_CRL*);
|
||||
|
||||
CYASSL_LOCAL int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int mon);
|
||||
CYASSL_LOCAL int BufferLoadCRL(CYASSL_CRL*, const byte*, long, int);
|
||||
CYASSL_LOCAL int CheckCertCRL(CYASSL_CRL*, DecodedCert*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_CRL_H */
|
113
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/aes.h
Normal file
113
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/aes.h
Normal file
|
@ -0,0 +1,113 @@
|
|||
/* aes.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_AES
|
||||
|
||||
#ifndef CTAO_CRYPT_AES_H
|
||||
#define CTAO_CRYPT_AES_H
|
||||
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef CYASSL_AESNI
|
||||
|
||||
#include <wmmintrin.h>
|
||||
|
||||
#if !defined (ALIGN16)
|
||||
#if defined (__GNUC__)
|
||||
#define ALIGN16 __attribute__ ( (aligned (16)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define ALIGN16 __declspec (align (16))
|
||||
#else
|
||||
#define ALIGN16
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_AESNI */
|
||||
|
||||
#if !defined (ALIGN16)
|
||||
#define ALIGN16
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
AES_ENC_TYPE = 1, /* cipher unique type */
|
||||
AES_ENCRYPTION = 0,
|
||||
AES_DECRYPTION = 1,
|
||||
AES_BLOCK_SIZE = 16
|
||||
};
|
||||
|
||||
|
||||
typedef struct Aes {
|
||||
/* AESNI needs key first, rounds 2nd, not sure why yet */
|
||||
ALIGN16 word32 key[60];
|
||||
word32 rounds;
|
||||
|
||||
ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
|
||||
#ifdef HAVE_AESGCM
|
||||
ALIGN16 byte H[AES_BLOCK_SIZE];
|
||||
#ifdef GCM_TABLE
|
||||
/* key-based fast multiplication table. */
|
||||
ALIGN16 byte M0[256][AES_BLOCK_SIZE];
|
||||
#endif /* GCM_TABLE */
|
||||
#endif /* HAVE_AESGCM */
|
||||
} Aes;
|
||||
|
||||
|
||||
CYASSL_API int AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
|
||||
int dir);
|
||||
CYASSL_API int AesSetIV(Aes* aes, const byte* iv);
|
||||
CYASSL_API void AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
|
||||
CYASSL_API void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
|
||||
CYASSL_API void AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
|
||||
CYASSL_API void AesEncryptDirect(Aes* aes, byte* out, const byte* in);
|
||||
CYASSL_API void AesDecryptDirect(Aes* aes, byte* out, const byte* in);
|
||||
|
||||
#ifdef HAVE_AESGCM
|
||||
CYASSL_API void AesGcmSetKey(Aes* aes, const byte* key, word32 len,
|
||||
const byte* implicitIV);
|
||||
CYASSL_API void AesGcmSetExpIV(Aes* aes, const byte* iv);
|
||||
CYASSL_API void AesGcmGetExpIV(Aes* aes, byte* iv);
|
||||
CYASSL_API void AesGcmIncExpIV(Aes* aes);
|
||||
CYASSL_API void AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
CYASSL_API int AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
#endif /* HAVE_AESGCM */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_AES_H */
|
||||
#endif /* NO_AES */
|
||||
|
57
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/arc4.h
Normal file
57
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/arc4.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* arc4.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_ARC4_H
|
||||
#define CTAO_CRYPT_ARC4_H
|
||||
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
ARC4_ENC_TYPE = 4, /* cipher unique type */
|
||||
ARC4_STATE_SIZE = 256
|
||||
};
|
||||
|
||||
/* ARC4 encryption and decryption */
|
||||
typedef struct Arc4 {
|
||||
byte x;
|
||||
byte y;
|
||||
byte state[ARC4_STATE_SIZE];
|
||||
} Arc4;
|
||||
|
||||
CYASSL_API void Arc4Process(Arc4*, byte*, const byte*, word32);
|
||||
CYASSL_API void Arc4SetKey(Arc4*, const byte*, word32);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_ARC4_H */
|
||||
|
485
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/asn.h
Normal file
485
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/asn.h
Normal file
|
@ -0,0 +1,485 @@
|
|||
/* asn.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_ASN_H
|
||||
#define CTAO_CRYPT_ASN_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <cyassl/ctaocrypt/rsa.h>
|
||||
#include <cyassl/ctaocrypt/dh.h>
|
||||
#include <cyassl/ctaocrypt/dsa.h>
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
#include <cyassl/ctaocrypt/md5.h>
|
||||
#include <cyassl/ctaocrypt/asn_public.h> /* public interface */
|
||||
#ifdef HAVE_ECC
|
||||
#include <cyassl/ctaocrypt/ecc.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
ISSUER = 0,
|
||||
SUBJECT = 1,
|
||||
|
||||
EXTERNAL_SERIAL_SIZE = 32,
|
||||
|
||||
BEFORE = 0,
|
||||
AFTER = 1
|
||||
};
|
||||
|
||||
/* ASN Tags */
|
||||
enum ASN_Tags {
|
||||
ASN_BOOLEAN = 0x01,
|
||||
ASN_INTEGER = 0x02,
|
||||
ASN_BIT_STRING = 0x03,
|
||||
ASN_OCTET_STRING = 0x04,
|
||||
ASN_TAG_NULL = 0x05,
|
||||
ASN_OBJECT_ID = 0x06,
|
||||
ASN_ENUMERATED = 0x0a,
|
||||
ASN_SEQUENCE = 0x10,
|
||||
ASN_SET = 0x11,
|
||||
ASN_UTC_TIME = 0x17,
|
||||
ASN_DNS_TYPE = 0x02,
|
||||
ASN_GENERALIZED_TIME = 0x18,
|
||||
CRL_EXTENSIONS = 0xa0,
|
||||
ASN_EXTENSIONS = 0xa3,
|
||||
ASN_LONG_LENGTH = 0x80
|
||||
};
|
||||
|
||||
enum ASN_Flags{
|
||||
ASN_CONSTRUCTED = 0x20,
|
||||
ASN_CONTEXT_SPECIFIC = 0x80
|
||||
};
|
||||
|
||||
enum DN_Tags {
|
||||
ASN_COMMON_NAME = 0x03, /* CN */
|
||||
ASN_SUR_NAME = 0x04, /* SN */
|
||||
ASN_COUNTRY_NAME = 0x06, /* C */
|
||||
ASN_LOCALITY_NAME = 0x07, /* L */
|
||||
ASN_STATE_NAME = 0x08, /* ST */
|
||||
ASN_ORG_NAME = 0x0a, /* O */
|
||||
ASN_ORGUNIT_NAME = 0x0b /* OU */
|
||||
};
|
||||
|
||||
enum PBES {
|
||||
PBE_MD5_DES = 0,
|
||||
PBE_SHA1_DES = 1,
|
||||
PBE_SHA1_DES3 = 2,
|
||||
PBE_SHA1_RC4_128 = 3,
|
||||
PBES2 = 13 /* algo ID */
|
||||
};
|
||||
|
||||
enum ENCRYPTION_TYPES {
|
||||
DES_TYPE = 0,
|
||||
DES3_TYPE = 1,
|
||||
RC4_TYPE = 2
|
||||
};
|
||||
|
||||
enum ECC_TYPES {
|
||||
ECC_PREFIX_0 = 160,
|
||||
ECC_PREFIX_1 = 161
|
||||
};
|
||||
|
||||
enum Misc_ASN {
|
||||
ASN_NAME_MAX = 256,
|
||||
MAX_SALT_SIZE = 64, /* MAX PKCS Salt length */
|
||||
MAX_IV_SIZE = 64, /* MAX PKCS Iv length */
|
||||
MAX_KEY_SIZE = 64, /* MAX PKCS Key length */
|
||||
PKCS5 = 5, /* PKCS oid tag */
|
||||
PKCS5v2 = 6, /* PKCS #5 v2.0 */
|
||||
PKCS12 = 12, /* PKCS #12 */
|
||||
MAX_UNICODE_SZ = 256,
|
||||
ASN_BOOL_SIZE = 2, /* including type */
|
||||
SHA_SIZE = 20,
|
||||
RSA_INTS = 8, /* RSA ints in private key */
|
||||
MIN_DATE_SIZE = 13,
|
||||
MAX_DATE_SIZE = 32,
|
||||
ASN_GEN_TIME_SZ = 15, /* 7 numbers * 2 + Zulu tag */
|
||||
MAX_ENCODED_SIG_SZ = 512,
|
||||
MAX_SIG_SZ = 256,
|
||||
MAX_ALGO_SZ = 20,
|
||||
MAX_SEQ_SZ = 5, /* enum(seq | con) + length(4) */
|
||||
MAX_SET_SZ = 5, /* enum(set | con) + length(4) */
|
||||
MAX_VERSION_SZ = 5, /* enum + id + version(byte) + (header(2))*/
|
||||
MAX_ENCODED_DIG_SZ = 73, /* sha512 + enum(bit or octet) + legnth(4) */
|
||||
MAX_RSA_INT_SZ = 517, /* RSA raw sz 4096 for bits + tag + len(4) */
|
||||
MAX_NTRU_KEY_SZ = 610, /* NTRU 112 bit public key */
|
||||
MAX_NTRU_ENC_SZ = 628, /* NTRU 112 bit DER public encoding */
|
||||
MAX_LENGTH_SZ = 4, /* Max length size for DER encoding */
|
||||
MAX_RSA_E_SZ = 16, /* Max RSA public e size */
|
||||
MAX_CA_SZ = 32, /* Max encoded CA basic constraint length */
|
||||
MAX_SN_SZ = 35, /* Max encoded serial number (INT) length */
|
||||
#ifdef CYASSL_CERT_GEN
|
||||
#ifdef CYASSL_ALT_NAMES
|
||||
MAX_EXTENSIONS_SZ = 1 + MAX_LENGTH_SZ + CTC_MAX_ALT_SIZE,
|
||||
#else
|
||||
MAX_EXTENSIONS_SZ = 1 + MAX_LENGTH_SZ + MAX_CA_SZ,
|
||||
#endif
|
||||
/* Max total extensions, id + len + others */
|
||||
#endif
|
||||
MAX_OCSP_EXT_SZ = 58, /* Max OCSP Extension length */
|
||||
MAX_OCSP_NONCE_SZ = 18, /* OCSP Nonce size */
|
||||
MAX_PUBLIC_KEY_SZ = MAX_NTRU_ENC_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ * 2
|
||||
/* use bigger NTRU size */
|
||||
};
|
||||
|
||||
|
||||
enum Oid_Types {
|
||||
hashType = 0,
|
||||
sigType = 1,
|
||||
keyType = 2
|
||||
};
|
||||
|
||||
|
||||
enum Hash_Sum {
|
||||
MD2h = 646,
|
||||
MD5h = 649,
|
||||
SHAh = 88,
|
||||
SHA256h = 414,
|
||||
SHA384h = 415,
|
||||
SHA512h = 416
|
||||
};
|
||||
|
||||
|
||||
enum Key_Sum {
|
||||
DSAk = 515,
|
||||
RSAk = 645,
|
||||
NTRUk = 364,
|
||||
ECDSAk = 518
|
||||
};
|
||||
|
||||
|
||||
enum Ecc_Sum {
|
||||
ECC_256R1 = 526,
|
||||
ECC_384R1 = 210,
|
||||
ECC_521R1 = 211,
|
||||
ECC_160R1 = 184,
|
||||
ECC_192R1 = 520,
|
||||
ECC_224R1 = 209
|
||||
};
|
||||
|
||||
|
||||
enum KDF_Sum {
|
||||
PBKDF2_OID = 660
|
||||
};
|
||||
|
||||
|
||||
enum Extensions_Sum {
|
||||
BASIC_CA_OID = 133,
|
||||
ALT_NAMES_OID = 131,
|
||||
CRL_DIST_OID = 145,
|
||||
AUTH_INFO_OID = 69,
|
||||
CA_ISSUER_OID = 117
|
||||
};
|
||||
|
||||
|
||||
enum VerifyType {
|
||||
NO_VERIFY = 0,
|
||||
VERIFY = 1
|
||||
};
|
||||
|
||||
|
||||
typedef struct DNS_entry DNS_entry;
|
||||
|
||||
struct DNS_entry {
|
||||
DNS_entry* next; /* next on DNS list */
|
||||
char* name; /* actual DNS name */
|
||||
};
|
||||
|
||||
typedef struct DecodedCert DecodedCert;
|
||||
typedef struct Signer Signer;
|
||||
|
||||
|
||||
struct DecodedCert {
|
||||
byte* publicKey;
|
||||
word32 pubKeySize;
|
||||
int pubKeyStored;
|
||||
word32 certBegin; /* offset to start of cert */
|
||||
word32 sigIndex; /* offset to start of signature */
|
||||
word32 sigLength; /* length of signature */
|
||||
word32 signatureOID; /* sum of algorithm object id */
|
||||
word32 keyOID; /* sum of key algo object id */
|
||||
DNS_entry* altNames; /* alt names list of dns entries */
|
||||
byte subjectHash[SHA_SIZE]; /* hash of all Names */
|
||||
byte issuerHash[SHA_SIZE]; /* hash of all Names */
|
||||
#ifdef HAVE_OCSP
|
||||
byte issuerKeyHash[SHA_SIZE]; /* hash of the public Key */
|
||||
#endif /* HAVE_OCSP */
|
||||
byte* signature; /* not owned, points into raw cert */
|
||||
char* subjectCN; /* CommonName */
|
||||
int subjectCNLen;
|
||||
int subjectCNStored; /* have we saved a copy we own */
|
||||
char issuer[ASN_NAME_MAX]; /* full name including common name */
|
||||
char subject[ASN_NAME_MAX]; /* full name including common name */
|
||||
int verify; /* Default to yes, but could be off */
|
||||
byte* source; /* byte buffer holder cert, NOT owner */
|
||||
word32 srcIdx; /* current offset into buffer */
|
||||
word32 maxIdx; /* max offset based on init size */
|
||||
void* heap; /* for user memory overrides */
|
||||
byte serial[EXTERNAL_SERIAL_SIZE]; /* raw serial number */
|
||||
int serialSz; /* raw serial bytes stored */
|
||||
byte* extensions; /* not owned, points into raw cert */
|
||||
int extensionsSz; /* length of cert extensions */
|
||||
word32 extensionsIdx; /* if want to go back and parse later */
|
||||
byte* extAuthInfo; /* Authority Information Access URI */
|
||||
int extAuthInfoSz; /* length of the URI */
|
||||
byte* extCrlInfo; /* CRL Distribution Points */
|
||||
int extCrlInfoSz; /* length of the URI */
|
||||
byte isCA; /* CA basic constraint true */
|
||||
#ifdef CYASSL_CERT_GEN
|
||||
/* easy access to subject info for other sign */
|
||||
char* subjectSN;
|
||||
int subjectSNLen;
|
||||
char* subjectC;
|
||||
int subjectCLen;
|
||||
char* subjectL;
|
||||
int subjectLLen;
|
||||
char* subjectST;
|
||||
int subjectSTLen;
|
||||
char* subjectO;
|
||||
int subjectOLen;
|
||||
char* subjectOU;
|
||||
int subjectOULen;
|
||||
char* subjectEmail;
|
||||
int subjectEmailLen;
|
||||
byte* beforeDate;
|
||||
int beforeDateLen;
|
||||
byte* afterDate;
|
||||
int afterDateLen;
|
||||
#endif /* CYASSL_CERT_GEN */
|
||||
};
|
||||
|
||||
|
||||
/* CA Signers */
|
||||
struct Signer {
|
||||
byte* publicKey;
|
||||
word32 pubKeySize;
|
||||
word32 keyOID; /* key type */
|
||||
char* name; /* common name */
|
||||
byte hash[SHA_DIGEST_SIZE]; /* sha hash of names in certificate */
|
||||
Signer* next;
|
||||
};
|
||||
|
||||
|
||||
/* not for public consumption but may use for testing sometimes */
|
||||
#ifdef CYASSL_TEST_CERT
|
||||
#define CYASSL_TEST_API CYASSL_API
|
||||
#else
|
||||
#define CYASSL_TEST_API CYASSL_LOCAL
|
||||
#endif
|
||||
|
||||
CYASSL_TEST_API void FreeAltNames(DNS_entry*, void*);
|
||||
CYASSL_TEST_API void InitDecodedCert(DecodedCert*, byte*, word32, void*);
|
||||
CYASSL_TEST_API void FreeDecodedCert(DecodedCert*);
|
||||
CYASSL_TEST_API int ParseCert(DecodedCert*, int type, int verify, void* cm);
|
||||
|
||||
CYASSL_LOCAL int ParseCertRelative(DecodedCert*, int type, int verify,void* cm);
|
||||
CYASSL_LOCAL int DecodeToKey(DecodedCert*, int verify);
|
||||
|
||||
CYASSL_LOCAL word32 EncodeSignature(byte* out, const byte* digest, word32 digSz,
|
||||
int hashOID);
|
||||
|
||||
CYASSL_LOCAL Signer* MakeSigner(void*);
|
||||
CYASSL_LOCAL void FreeSigners(Signer*, void*);
|
||||
|
||||
|
||||
CYASSL_LOCAL int ToTraditional(byte* buffer, word32 length);
|
||||
CYASSL_LOCAL int ToTraditionalEnc(byte* buffer, word32 length,const char*, int);
|
||||
|
||||
CYASSL_LOCAL int ValidateDate(const byte* date, byte format, int dateType);
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
/* ASN sig helpers */
|
||||
CYASSL_LOCAL int StoreECC_DSA_Sig(byte* out, word32* outLen, mp_int* r,
|
||||
mp_int* s);
|
||||
CYASSL_LOCAL int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen,
|
||||
mp_int* r, mp_int* s);
|
||||
/* private key helpers */
|
||||
CYASSL_LOCAL int EccPrivateKeyDecode(const byte* input,word32* inOutIdx,
|
||||
ecc_key*,word32);
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_CERT_GEN
|
||||
|
||||
enum cert_enums {
|
||||
NAME_ENTRIES = 8,
|
||||
JOINT_LEN = 2,
|
||||
EMAIL_JOINT_LEN = 9,
|
||||
RSA_KEY = 10,
|
||||
NTRU_KEY = 11
|
||||
};
|
||||
|
||||
|
||||
#endif /* CYASSL_CERT_GEN */
|
||||
|
||||
|
||||
|
||||
/* for pointer use */
|
||||
typedef struct CertStatus CertStatus;
|
||||
|
||||
#ifdef HAVE_OCSP
|
||||
|
||||
enum Ocsp_Response_Status {
|
||||
OCSP_SUCCESSFUL = 0, /* Response has valid confirmations */
|
||||
OCSP_MALFORMED_REQUEST = 1, /* Illegal confirmation request */
|
||||
OCSP_INTERNAL_ERROR = 2, /* Internal error in issuer */
|
||||
OCSP_TRY_LATER = 3, /* Try again later */
|
||||
OCSP_SIG_REQUIRED = 5, /* Must sign the request (4 is skipped) */
|
||||
OCSP_UNAUTHROIZED = 6 /* Request unauthorized */
|
||||
};
|
||||
|
||||
|
||||
enum Ocsp_Cert_Status {
|
||||
CERT_GOOD = 0,
|
||||
CERT_REVOKED = 1,
|
||||
CERT_UNKNOWN = 2
|
||||
};
|
||||
|
||||
|
||||
enum Ocsp_Sums {
|
||||
OCSP_BASIC_OID = 117,
|
||||
OCSP_NONCE_OID = 118
|
||||
};
|
||||
|
||||
|
||||
typedef struct OcspRequest OcspRequest;
|
||||
typedef struct OcspResponse OcspResponse;
|
||||
|
||||
|
||||
struct CertStatus {
|
||||
CertStatus* next;
|
||||
|
||||
byte serial[EXTERNAL_SERIAL_SIZE];
|
||||
int serialSz;
|
||||
|
||||
int status;
|
||||
|
||||
byte thisDate[MAX_DATE_SIZE];
|
||||
byte nextDate[MAX_DATE_SIZE];
|
||||
byte thisDateFormat;
|
||||
byte nextDateFormat;
|
||||
};
|
||||
|
||||
|
||||
struct OcspResponse {
|
||||
int responseStatus; /* return code from Responder */
|
||||
|
||||
byte* response; /* Pointer to beginning of OCSP Response */
|
||||
word32 responseSz; /* length of the OCSP Response */
|
||||
|
||||
byte producedDate[MAX_DATE_SIZE];
|
||||
/* Date at which this response was signed */
|
||||
byte producedDateFormat; /* format of the producedDate */
|
||||
byte* issuerHash;
|
||||
byte* issuerKeyHash;
|
||||
|
||||
byte* cert;
|
||||
word32 certSz;
|
||||
|
||||
byte* sig; /* Pointer to sig in source */
|
||||
word32 sigSz; /* Length in octets for the sig */
|
||||
word32 sigOID; /* OID for hash used for sig */
|
||||
|
||||
CertStatus* status; /* certificate status to fill out */
|
||||
|
||||
byte* nonce; /* pointer to nonce inside ASN.1 response */
|
||||
int nonceSz; /* length of the nonce string */
|
||||
|
||||
byte* source; /* pointer to source buffer, not owned */
|
||||
word32 maxIdx; /* max offset based on init size */
|
||||
};
|
||||
|
||||
|
||||
struct OcspRequest {
|
||||
DecodedCert* cert;
|
||||
|
||||
byte nonce[MAX_OCSP_NONCE_SZ];
|
||||
int nonceSz;
|
||||
|
||||
byte* issuerHash; /* pointer to issuerHash in source cert */
|
||||
byte* issuerKeyHash; /* pointer to issuerKeyHash in source cert */
|
||||
byte* serial; /* pointer to serial number in source cert */
|
||||
int serialSz; /* length of the serial number */
|
||||
|
||||
byte* dest; /* pointer to the destination ASN.1 buffer */
|
||||
word32 destSz; /* length of the destination buffer */
|
||||
};
|
||||
|
||||
|
||||
CYASSL_LOCAL void InitOcspResponse(OcspResponse*, CertStatus*, byte*, word32);
|
||||
CYASSL_LOCAL int OcspResponseDecode(OcspResponse*);
|
||||
|
||||
CYASSL_LOCAL void InitOcspRequest(OcspRequest*, DecodedCert*, byte*, word32);
|
||||
CYASSL_LOCAL int EncodeOcspRequest(OcspRequest*);
|
||||
|
||||
CYASSL_LOCAL int CompareOcspReqResp(OcspRequest*, OcspResponse*);
|
||||
|
||||
|
||||
#endif /* HAVE_OCSP */
|
||||
|
||||
|
||||
/* for pointer use */
|
||||
typedef struct RevokedCert RevokedCert;
|
||||
|
||||
#ifdef HAVE_CRL
|
||||
|
||||
struct RevokedCert {
|
||||
byte serialNumber[EXTERNAL_SERIAL_SIZE];
|
||||
int serialSz;
|
||||
RevokedCert* next;
|
||||
};
|
||||
|
||||
typedef struct DecodedCRL DecodedCRL;
|
||||
|
||||
struct DecodedCRL {
|
||||
word32 certBegin; /* offset to start of cert */
|
||||
word32 sigIndex; /* offset to start of signature */
|
||||
word32 sigLength; /* length of signature */
|
||||
word32 signatureOID; /* sum of algorithm object id */
|
||||
byte* signature; /* pointer into raw source, not owned */
|
||||
byte issuerHash[SHA_DIGEST_SIZE]; /* issuer hash */
|
||||
byte crlHash[MD5_DIGEST_SIZE]; /* raw crl data hash */
|
||||
byte lastDate[MAX_DATE_SIZE]; /* last date updated */
|
||||
byte nextDate[MAX_DATE_SIZE]; /* next update date */
|
||||
byte lastDateFormat; /* format of last date */
|
||||
byte nextDateFormat; /* format of next date */
|
||||
RevokedCert* certs; /* revoked cert list */
|
||||
int totalCerts; /* number on list */
|
||||
};
|
||||
|
||||
CYASSL_LOCAL void InitDecodedCRL(DecodedCRL*);
|
||||
CYASSL_LOCAL int ParseCRL(DecodedCRL*, const byte* buff, long sz, void* cm);
|
||||
CYASSL_LOCAL void FreeDecodedCRL(DecodedCRL*);
|
||||
|
||||
|
||||
#endif /* HAVE_CRL */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_ASN_H */
|
||||
|
155
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/asn_public.h
Normal file
155
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/asn_public.h
Normal file
|
@ -0,0 +1,155 @@
|
|||
/* asn_public.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_ASN_PUBLIC_H
|
||||
#define CTAO_CRYPT_ASN_PUBLIC_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#ifdef CYASSL_CERT_GEN
|
||||
#include <cyassl/ctaocrypt/rsa.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Certificate file Type */
|
||||
enum CertType {
|
||||
CERT_TYPE = 0,
|
||||
PRIVATEKEY_TYPE,
|
||||
DH_PARAM_TYPE,
|
||||
CRL_TYPE,
|
||||
CA_TYPE
|
||||
};
|
||||
|
||||
|
||||
/* Signature type, by OID sum */
|
||||
enum Ctc_SigType {
|
||||
CTC_SHAwDSA = 517,
|
||||
CTC_MD2wRSA = 646,
|
||||
CTC_MD5wRSA = 648,
|
||||
CTC_SHAwRSA = 649,
|
||||
CTC_SHAwECDSA = 520,
|
||||
CTC_SHA256wRSA = 655,
|
||||
CTC_SHA256wECDSA = 524,
|
||||
CTC_SHA384wRSA = 656,
|
||||
CTC_SHA384wECDSA = 525,
|
||||
CTC_SHA512wRSA = 657,
|
||||
CTC_SHA512wECDSA = 526
|
||||
};
|
||||
|
||||
|
||||
#ifdef CYASSL_CERT_GEN
|
||||
|
||||
enum Ctc_Misc {
|
||||
CTC_NAME_SIZE = 64,
|
||||
CTC_DATE_SIZE = 32,
|
||||
CTC_MAX_ALT_SIZE = 8192, /* may be huge */
|
||||
CTC_SERIAL_SIZE = 8
|
||||
};
|
||||
|
||||
typedef struct CertName {
|
||||
char country[CTC_NAME_SIZE];
|
||||
char state[CTC_NAME_SIZE];
|
||||
char locality[CTC_NAME_SIZE];
|
||||
char sur[CTC_NAME_SIZE];
|
||||
char org[CTC_NAME_SIZE];
|
||||
char unit[CTC_NAME_SIZE];
|
||||
char commonName[CTC_NAME_SIZE];
|
||||
char email[CTC_NAME_SIZE]; /* !!!! email has to be last !!!! */
|
||||
} CertName;
|
||||
|
||||
|
||||
/* for user to fill for certificate generation */
|
||||
typedef struct Cert {
|
||||
int version; /* x509 version */
|
||||
byte serial[CTC_SERIAL_SIZE]; /* serial number */
|
||||
int sigType; /* signature algo type */
|
||||
CertName issuer; /* issuer info */
|
||||
int daysValid; /* validity days */
|
||||
int selfSigned; /* self signed flag */
|
||||
CertName subject; /* subject info */
|
||||
int isCA; /* is this going to be a CA */
|
||||
/* internal use only */
|
||||
int bodySz; /* pre sign total size */
|
||||
int keyType; /* public key type of subject */
|
||||
#ifdef CYASSL_ALT_NAMES
|
||||
byte altNames[CTC_MAX_ALT_SIZE]; /* altNames copy */
|
||||
int altNamesSz; /* altNames size in bytes */
|
||||
byte beforeDate[CTC_DATE_SIZE]; /* before date copy */
|
||||
int beforeDateSz; /* size of copy */
|
||||
byte afterDate[CTC_DATE_SIZE]; /* after date copy */
|
||||
int afterDateSz; /* size of copy */
|
||||
#endif
|
||||
} Cert;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Initialize and Set Certficate defaults:
|
||||
version = 3 (0x2)
|
||||
serial = 0 (Will be randomly generated)
|
||||
sigType = SHA_WITH_RSA
|
||||
issuer = blank
|
||||
daysValid = 500
|
||||
selfSigned = 1 (true) use subject as issuer
|
||||
subject = blank
|
||||
isCA = 0 (false)
|
||||
keyType = RSA_KEY (default)
|
||||
*/
|
||||
CYASSL_API void InitCert(Cert*);
|
||||
CYASSL_API int MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, RNG*);
|
||||
CYASSL_API int SignCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, RNG*);
|
||||
CYASSL_API int MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
|
||||
RNG*);
|
||||
CYASSL_API int SetIssuer(Cert*, const char*);
|
||||
CYASSL_API int SetSubject(Cert*, const char*);
|
||||
#ifdef CYASSL_ALT_NAMES
|
||||
CYASSL_API int SetAltNames(Cert*, const char*);
|
||||
#endif
|
||||
CYASSL_API int SetIssuerBuffer(Cert*, const byte*, int);
|
||||
CYASSL_API int SetSubjectBuffer(Cert*, const byte*, int);
|
||||
CYASSL_API int SetAltNamesBuffer(Cert*, const byte*, int);
|
||||
CYASSL_API int SetDatesBuffer(Cert*, const byte*, int);
|
||||
|
||||
#ifdef HAVE_NTRU
|
||||
CYASSL_API int MakeNtruCert(Cert*, byte* derBuffer, word32 derSz,
|
||||
const byte* ntruKey, word16 keySz, RNG*);
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_CERT_GEN */
|
||||
|
||||
|
||||
#if defined(CYASSL_KEY_GEN) || defined(CYASSL_CERT_GEN)
|
||||
CYASSL_API int DerToPem(const byte* der, word32 derSz, byte* output,
|
||||
word32 outputSz, int type);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_ASN_PUBLIC_H */
|
||||
|
51
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/coding.h
Normal file
51
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/coding.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* coding.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_CODING_H
|
||||
#define CTAO_CRYPT_CODING_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* decode needed by CyaSSL */
|
||||
CYASSL_LOCAL int Base64_Decode(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(SESSION_CERTS) || defined(CYASSL_KEY_GEN) || defined(CYASSL_CERT_GEN) || defined(HAVE_WEBSERVER)
|
||||
/* encode isn't */
|
||||
CYASSL_API
|
||||
int Base64_Encode(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
CYASSL_LOCAL
|
||||
int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_CODING_H */
|
||||
|
81
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/des3.h
Normal file
81
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/des3.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* des3.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_DES3
|
||||
|
||||
#ifndef CTAO_CRYPT_DES3_H
|
||||
#define CTAO_CRYPT_DES3_H
|
||||
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
DES_ENC_TYPE = 2, /* cipher unique type */
|
||||
DES3_ENC_TYPE = 3, /* cipher unique type */
|
||||
DES_BLOCK_SIZE = 8,
|
||||
DES_KS_SIZE = 32,
|
||||
|
||||
DES_ENCRYPTION = 0,
|
||||
DES_DECRYPTION = 1,
|
||||
};
|
||||
|
||||
|
||||
/* DES encryption and decryption */
|
||||
typedef struct Des {
|
||||
word32 key[DES_KS_SIZE];
|
||||
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
} Des;
|
||||
|
||||
|
||||
/* DES3 encryption and decryption */
|
||||
typedef struct Des3 {
|
||||
word32 key[3][DES_KS_SIZE];
|
||||
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
} Des3;
|
||||
|
||||
|
||||
CYASSL_API void Des_SetKey(Des* des, const byte* key, const byte* iv, int dir);
|
||||
CYASSL_API void Des_SetIV(Des* des, const byte* iv);
|
||||
CYASSL_API void Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz);
|
||||
CYASSL_API void Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz);
|
||||
CYASSL_API void Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz);
|
||||
|
||||
CYASSL_API void Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir);
|
||||
CYASSL_API void Des3_SetIV(Des3* des, const byte* iv);
|
||||
CYASSL_API void Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz);
|
||||
CYASSL_API void Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_DES3 */
|
||||
#endif /* CTAO_CRYPT_DES3_H */
|
||||
|
67
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/dh.h
Normal file
67
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/dh.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* dh.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_DH
|
||||
|
||||
#ifndef CTAO_CRYPT_DH_H
|
||||
#define CTAO_CRYPT_DH_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <cyassl/ctaocrypt/integer.h>
|
||||
#include <cyassl/ctaocrypt/random.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Diffie-Hellman Key */
|
||||
typedef struct DhKey {
|
||||
mp_int p, g; /* group parameters */
|
||||
} DhKey;
|
||||
|
||||
|
||||
CYASSL_API void InitDhKey(DhKey* key);
|
||||
CYASSL_API void FreeDhKey(DhKey* key);
|
||||
|
||||
CYASSL_API int DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv,
|
||||
word32* privSz, byte* pub, word32* pubSz);
|
||||
CYASSL_API int DhAgree(DhKey* key, byte* agree, word32* agreeSz,
|
||||
const byte* priv, word32 privSz, const byte* otherPub,
|
||||
word32 pubSz);
|
||||
|
||||
CYASSL_API int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
|
||||
word32);
|
||||
CYASSL_API int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
|
||||
word32 gSz);
|
||||
CYASSL_API int DhParamsLoad(const byte* input, word32 inSz, byte* p,
|
||||
word32* pInOutSz, byte* g, word32* gInOutSz);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_DH_H */
|
||||
|
||||
#endif /* NO_DH */
|
||||
|
67
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/dsa.h
Normal file
67
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/dsa.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* dsa.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_DSA
|
||||
|
||||
#ifndef CTAO_CRYPT_DSA_H
|
||||
#define CTAO_CRYPT_DSA_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <cyassl/ctaocrypt/integer.h>
|
||||
#include <cyassl/ctaocrypt/random.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
DSA_PUBLIC = 0,
|
||||
DSA_PRIVATE = 1
|
||||
};
|
||||
|
||||
/* DSA */
|
||||
typedef struct DsaKey {
|
||||
mp_int p, q, g, y, x;
|
||||
int type; /* public or private */
|
||||
} DsaKey;
|
||||
|
||||
|
||||
CYASSL_API void InitDsaKey(DsaKey* key);
|
||||
CYASSL_API void FreeDsaKey(DsaKey* key);
|
||||
|
||||
CYASSL_API int DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng);
|
||||
CYASSL_API int DsaVerify(const byte* digest, const byte* sig, DsaKey* key,
|
||||
int* answer);
|
||||
|
||||
CYASSL_API int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
|
||||
word32);
|
||||
CYASSL_API int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
|
||||
word32);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_DSA_H */
|
||||
#endif /* NO_DSA */
|
||||
|
129
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/ecc.h
Normal file
129
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/ecc.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
/* ecc.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
|
||||
#ifndef CTAO_CRYPT_ECC_H
|
||||
#define CTAO_CRYPT_ECC_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <cyassl/ctaocrypt/integer.h>
|
||||
#include <cyassl/ctaocrypt/random.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
ECC_PUBLICKEY = 1,
|
||||
ECC_PRIVATEKEY = 2,
|
||||
ECC_MAXNAME = 16, /* MAX CURVE NAME LENGTH */
|
||||
SIG_HEADER_SZ = 6, /* ECC signature header size */
|
||||
ECC_BUFSIZE = 256, /* for exported keys temp buffer */
|
||||
ECC_MINSIZE = 20, /* MIN Private Key size */
|
||||
ECC_MAXSIZE = 66 /* MAX Private Key size */
|
||||
};
|
||||
|
||||
|
||||
/* ECC set type defined a NIST GF(p) curve */
|
||||
typedef struct {
|
||||
int size; /* The size of the curve in octets */
|
||||
const char* name; /* name of this curve */
|
||||
const char* prime; /* prime that defines the field, curve is in (hex) */
|
||||
const char* B; /* fields B param (hex) */
|
||||
const char* order; /* order of the curve (hex) */
|
||||
const char* Gx; /* x coordinate of the base point on curve (hex) */
|
||||
const char* Gy; /* y coordinate of the base point on curve (hex) */
|
||||
} ecc_set_type;
|
||||
|
||||
|
||||
/* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) =>
|
||||
(x/z^2, y/z^3, 1) when interpreted as affine */
|
||||
typedef struct {
|
||||
mp_int x; /* The x coordinate */
|
||||
mp_int y; /* The y coordinate */
|
||||
mp_int z; /* The z coordinate */
|
||||
} ecc_point;
|
||||
|
||||
|
||||
/* An ECC Key */
|
||||
typedef struct {
|
||||
int type; /* Public or Private */
|
||||
int idx; /* Index into the ecc_sets[] for the parameters of
|
||||
this curve if -1, this key is using user supplied
|
||||
curve in dp */
|
||||
const ecc_set_type* dp; /* domain parameters, either points to NIST
|
||||
curves (idx >= 0) or user supplied */
|
||||
ecc_point pubkey; /* public key */
|
||||
mp_int k; /* private key */
|
||||
} ecc_key;
|
||||
|
||||
|
||||
/* ECC predefined curve sets */
|
||||
extern const ecc_set_type ecc_sets[];
|
||||
|
||||
|
||||
CYASSL_API
|
||||
int ecc_make_key(RNG* rng, int keysize, ecc_key* key);
|
||||
CYASSL_API
|
||||
int ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
|
||||
word32* outlen);
|
||||
CYASSL_API
|
||||
int ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
RNG* rng, ecc_key* key);
|
||||
CYASSL_API
|
||||
int ecc_verify_hash(const byte* sig, word32 siglen, byte* hash, word32 hashlen,
|
||||
int* stat, ecc_key* key);
|
||||
CYASSL_API
|
||||
void ecc_init(ecc_key* key);
|
||||
CYASSL_API
|
||||
void ecc_free(ecc_key* key);
|
||||
|
||||
|
||||
/* ASN key helpers */
|
||||
CYASSL_API
|
||||
int ecc_export_x963(ecc_key*, byte* out, word32* outLen);
|
||||
CYASSL_API
|
||||
int ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);
|
||||
CYASSL_API
|
||||
int ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
|
||||
word32 pubSz, ecc_key* key);
|
||||
|
||||
/* size helper */
|
||||
CYASSL_API
|
||||
int ecc_size(ecc_key* key);
|
||||
CYASSL_API
|
||||
int ecc_sig_size(ecc_key* key);
|
||||
|
||||
/* TODO: fix mutex types */
|
||||
#define MUTEX_GLOBAL(x) int (x);
|
||||
#define MUTEX_LOCK(x)
|
||||
#define MUTEX_UNLOCK(x)
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_ECC_H */
|
||||
#endif /* HAVE_ECC */
|
115
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/error.h
Normal file
115
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/error.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* error.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_ERROR_H
|
||||
#define CTAO_CRYPT_ERROR_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* error codes */
|
||||
enum {
|
||||
MAX_ERROR_SZ = 80, /* max size of error string */
|
||||
MAX_CODE_E = -100, /* errors -101 - -199 */
|
||||
OPEN_RAN_E = -101, /* opening random device error */
|
||||
READ_RAN_E = -102, /* reading random device error */
|
||||
WINCRYPT_E = -103, /* windows crypt init error */
|
||||
CRYPTGEN_E = -104, /* windows crypt generation error */
|
||||
RAN_BLOCK_E = -105, /* reading random device would block */
|
||||
|
||||
MP_INIT_E = -110, /* mp_init error state */
|
||||
MP_READ_E = -111, /* mp_read error state */
|
||||
MP_EXPTMOD_E = -112, /* mp_exptmod error state */
|
||||
MP_TO_E = -113, /* mp_to_xxx error state, can't convert */
|
||||
MP_SUB_E = -114, /* mp_sub error state, can't subtract */
|
||||
MP_ADD_E = -115, /* mp_add error state, can't add */
|
||||
MP_MUL_E = -116, /* mp_mul error state, can't multiply */
|
||||
MP_MULMOD_E = -117, /* mp_mulmod error state, can't multiply mod */
|
||||
MP_MOD_E = -118, /* mp_mod error state, can't mod */
|
||||
MP_INVMOD_E = -119, /* mp_invmod error state, can't inv mod */
|
||||
MP_CMP_E = -120, /* mp_cmp error state */
|
||||
MP_ZERO_E = -121, /* got a mp zero result, not expected */
|
||||
|
||||
MEMORY_E = -125, /* out of memory error */
|
||||
|
||||
RSA_WRONG_TYPE_E = -130, /* RSA wrong block type for RSA function */
|
||||
RSA_BUFFER_E = -131, /* RSA buffer error, output too small or
|
||||
input too large */
|
||||
BUFFER_E = -132, /* output buffer too small or input too large */
|
||||
ALGO_ID_E = -133, /* setting algo id error */
|
||||
PUBLIC_KEY_E = -134, /* setting public key error */
|
||||
DATE_E = -135, /* setting date validity error */
|
||||
SUBJECT_E = -136, /* setting subject name error */
|
||||
ISSUER_E = -137, /* setting issuer name error */
|
||||
CA_TRUE_E = -138, /* setting CA basic constraint true error */
|
||||
EXTENSIONS_E = -139, /* setting extensions error */
|
||||
|
||||
ASN_PARSE_E = -140, /* ASN parsing error, invalid input */
|
||||
ASN_VERSION_E = -141, /* ASN version error, invalid number */
|
||||
ASN_GETINT_E = -142, /* ASN get big int error, invalid data */
|
||||
ASN_RSA_KEY_E = -143, /* ASN key init error, invalid input */
|
||||
ASN_OBJECT_ID_E = -144, /* ASN object id error, invalid id */
|
||||
ASN_TAG_NULL_E = -145, /* ASN tag error, not null */
|
||||
ASN_EXPECT_0_E = -146, /* ASN expect error, not zero */
|
||||
ASN_BITSTR_E = -147, /* ASN bit string error, wrong id */
|
||||
ASN_UNKNOWN_OID_E = -148, /* ASN oid error, unknown sum id */
|
||||
ASN_DATE_SZ_E = -149, /* ASN date error, bad size */
|
||||
ASN_BEFORE_DATE_E = -150, /* ASN date error, current date before */
|
||||
ASN_AFTER_DATE_E = -151, /* ASN date error, current date after */
|
||||
ASN_SIG_OID_E = -152, /* ASN signature error, mismatched oid */
|
||||
ASN_TIME_E = -153, /* ASN time error, unknown time type */
|
||||
ASN_INPUT_E = -154, /* ASN input error, not enough data */
|
||||
ASN_SIG_CONFIRM_E = -155, /* ASN sig error, confirm failure */
|
||||
ASN_SIG_HASH_E = -156, /* ASN sig error, unsupported hash type */
|
||||
ASN_SIG_KEY_E = -157, /* ASN sig error, unsupported key type */
|
||||
ASN_DH_KEY_E = -158, /* ASN key init error, invalid input */
|
||||
ASN_NTRU_KEY_E = -159, /* ASN ntru key decode error, invalid input */
|
||||
|
||||
ECC_BAD_ARG_E = -170, /* ECC input argument of wrong type */
|
||||
ASN_ECC_KEY_E = -171, /* ASN ECC bad input */
|
||||
ECC_CURVE_OID_E = -172, /* Unsupported ECC OID curve type */
|
||||
BAD_FUNC_ARG = -173, /* Bad function argument provided */
|
||||
NOT_COMPILED_IN = -174, /* Feature not compiled in */
|
||||
UNICODE_SIZE_E = -175, /* Unicode password too big */
|
||||
NO_PASSWORD = -176, /* no password provided by user */
|
||||
ALT_NAME_E = -177, /* alt name size problem, too big */
|
||||
|
||||
AES_GCM_AUTH_E = -180, /* AES-GCM Authentication check failure */
|
||||
|
||||
MIN_CODE_E = -200 /* errors -101 - -199 */
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API void CTaoCryptErrorString(int error, char* buffer);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_ERROR_H */
|
||||
|
60
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/hc128.h
Normal file
60
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/hc128.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* hc128.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_HC128
|
||||
|
||||
#ifndef CTAO_CRYPT_HC128_H
|
||||
#define CTAO_CRYPT_HC128_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
HC128_ENC_TYPE = 6 /* cipher unique type */
|
||||
};
|
||||
|
||||
/* HC-128 stream cipher */
|
||||
typedef struct HC128 {
|
||||
word32 T[1024]; /* P[i] = T[i]; Q[i] = T[1024 + i ]; */
|
||||
word32 X[16];
|
||||
word32 Y[16];
|
||||
word32 counter1024; /* counter1024 = i mod 1024 at the ith step */
|
||||
word32 key[8];
|
||||
word32 iv[8];
|
||||
} HC128;
|
||||
|
||||
|
||||
CYASSL_API void Hc128_Process(HC128*, byte*, const byte*, word32);
|
||||
CYASSL_API void Hc128_SetKey(HC128*, const byte* key, const byte* iv);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_HC128_H */
|
||||
|
||||
#endif /* HAVE_HC128 */
|
99
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/hmac.h
Normal file
99
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/hmac.h
Normal file
|
@ -0,0 +1,99 @@
|
|||
/* hmac.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_HMAC
|
||||
|
||||
#ifndef CTAO_CRYPT_HMAC_H
|
||||
#define CTAO_CRYPT_HMAC_H
|
||||
|
||||
#include <cyassl/ctaocrypt/md5.h>
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
|
||||
#ifndef NO_SHA256
|
||||
#include <cyassl/ctaocrypt/sha256.h>
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_SHA384
|
||||
#include <cyassl/ctaocrypt/sha512.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
IPAD = 0x36,
|
||||
OPAD = 0x5C,
|
||||
#if defined(CYASSL_SHA384)
|
||||
INNER_HASH_SIZE = SHA384_DIGEST_SIZE,
|
||||
HMAC_BLOCK_SIZE = SHA384_BLOCK_SIZE
|
||||
#elif !defined(NO_SHA256)
|
||||
INNER_HASH_SIZE = SHA256_DIGEST_SIZE,
|
||||
HMAC_BLOCK_SIZE = SHA256_BLOCK_SIZE,
|
||||
SHA384 = 5
|
||||
#else
|
||||
INNER_HASH_SIZE = SHA_DIGEST_SIZE,
|
||||
HMAC_BLOCK_SIZE = SHA_BLOCK_SIZE,
|
||||
SHA256 = 2, /* hash type unique */
|
||||
SHA384 = 5
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/* hash union */
|
||||
typedef union {
|
||||
Md5 md5;
|
||||
Sha sha;
|
||||
#ifndef NO_SHA256
|
||||
Sha256 sha256;
|
||||
#endif
|
||||
#ifdef CYASSL_SHA384
|
||||
Sha384 sha384;
|
||||
#endif
|
||||
} Hash;
|
||||
|
||||
/* Hmac digest */
|
||||
typedef struct Hmac {
|
||||
Hash hash;
|
||||
word32 ipad[HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/
|
||||
word32 opad[HMAC_BLOCK_SIZE / sizeof(word32)];
|
||||
word32 innerHash[INNER_HASH_SIZE / sizeof(word32)]; /* max size */
|
||||
byte macType; /* md5 sha or sha256 */
|
||||
byte innerHashKeyed; /* keyed flag */
|
||||
} Hmac;
|
||||
|
||||
|
||||
/* does init */
|
||||
CYASSL_API void HmacSetKey(Hmac*, int type, const byte* key, word32 keySz);
|
||||
CYASSL_API void HmacUpdate(Hmac*, const byte*, word32);
|
||||
CYASSL_API void HmacFinal(Hmac*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_HMAC_H */
|
||||
|
||||
#endif /* NO_HMAC */
|
||||
|
37
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/include.am
Normal file
37
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/include.am
Normal file
|
@ -0,0 +1,37 @@
|
|||
# vim:ft=automake
|
||||
# All paths should be given relative to the root
|
||||
|
||||
nobase_include_HEADERS+= \
|
||||
cyassl/ctaocrypt/aes.h \
|
||||
cyassl/ctaocrypt/arc4.h \
|
||||
cyassl/ctaocrypt/asn.h \
|
||||
cyassl/ctaocrypt/asn_public.h \
|
||||
cyassl/ctaocrypt/coding.h \
|
||||
cyassl/ctaocrypt/des3.h \
|
||||
cyassl/ctaocrypt/dh.h \
|
||||
cyassl/ctaocrypt/dsa.h \
|
||||
cyassl/ctaocrypt/ecc.h \
|
||||
cyassl/ctaocrypt/error.h \
|
||||
cyassl/ctaocrypt/hc128.h \
|
||||
cyassl/ctaocrypt/hmac.h \
|
||||
cyassl/ctaocrypt/integer.h \
|
||||
cyassl/ctaocrypt/md2.h \
|
||||
cyassl/ctaocrypt/md4.h \
|
||||
cyassl/ctaocrypt/md5.h \
|
||||
cyassl/ctaocrypt/misc.h \
|
||||
cyassl/ctaocrypt/pwdbased.h \
|
||||
cyassl/ctaocrypt/rabbit.h \
|
||||
cyassl/ctaocrypt/random.h \
|
||||
cyassl/ctaocrypt/ripemd.h \
|
||||
cyassl/ctaocrypt/rsa.h \
|
||||
cyassl/ctaocrypt/settings.h \
|
||||
cyassl/ctaocrypt/sha256.h \
|
||||
cyassl/ctaocrypt/sha512.h \
|
||||
cyassl/ctaocrypt/sha.h \
|
||||
cyassl/ctaocrypt/tfm.h \
|
||||
cyassl/ctaocrypt/types.h \
|
||||
cyassl/ctaocrypt/visibility.h \
|
||||
cyassl/ctaocrypt/logging.h \
|
||||
cyassl/ctaocrypt/memory.h \
|
||||
cyassl/ctaocrypt/mpi_class.h \
|
||||
cyassl/ctaocrypt/mpi_superclass.h
|
329
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/integer.h
Normal file
329
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/integer.h
Normal file
|
@ -0,0 +1,329 @@
|
|||
/* integer.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca,
|
||||
* http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_INTEGER_H
|
||||
#define CTAO_CRYPT_INTEGER_H
|
||||
|
||||
/* may optionally use fast math instead, not yet supported on all platforms and
|
||||
may not be faster on all
|
||||
*/
|
||||
#include <cyassl/ctaocrypt/types.h> /* will set MP_xxBIT if not default */
|
||||
#ifdef USE_FAST_MATH
|
||||
#include <cyassl/ctaocrypt/tfm.h>
|
||||
#else
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/mpi_class.h>
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
/* C++ compilers don't like assigning void * to mp_digit * */
|
||||
#define OPT_CAST(x) (x *)
|
||||
|
||||
#else
|
||||
|
||||
/* C on the other hand doesn't care */
|
||||
#define OPT_CAST(x)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* detect 64-bit mode if possible */
|
||||
#if defined(__x86_64__)
|
||||
#if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
|
||||
#define MP_64BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* some default configurations.
|
||||
*
|
||||
* A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
|
||||
* A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
|
||||
*
|
||||
* At the very least a mp_digit must be able to hold 7 bits
|
||||
* [any size beyond that is ok provided it doesn't overflow the data type]
|
||||
*/
|
||||
#ifdef MP_8BIT
|
||||
typedef unsigned char mp_digit;
|
||||
typedef unsigned short mp_word;
|
||||
#elif defined(MP_16BIT)
|
||||
typedef unsigned short mp_digit;
|
||||
typedef unsigned long mp_word;
|
||||
#elif defined(MP_64BIT)
|
||||
/* for GCC only on supported platforms */
|
||||
#ifndef CRYPT
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
#endif
|
||||
|
||||
typedef unsigned long mp_digit;
|
||||
typedef unsigned long mp_word __attribute__ ((mode(TI)));
|
||||
|
||||
#define DIGIT_BIT 60
|
||||
#else
|
||||
/* this is the default case, 28-bit digits */
|
||||
|
||||
/* this is to make porting into LibTomCrypt easier :-) */
|
||||
#ifndef CRYPT
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ulong64;
|
||||
typedef signed __int64 long64;
|
||||
#else
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef unsigned int mp_digit; /* long could be 64 now, changed TAO */
|
||||
typedef ulong64 mp_word;
|
||||
|
||||
#ifdef MP_31BIT
|
||||
/* this is an extension that uses 31-bit digits */
|
||||
#define DIGIT_BIT 31
|
||||
#else
|
||||
/* default case is 28-bit digits, defines MP_28BIT as a handy test macro */
|
||||
#define DIGIT_BIT 28
|
||||
#define MP_28BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* otherwise the bits per digit is calculated automatically from the size of
|
||||
a mp_digit */
|
||||
#ifndef DIGIT_BIT
|
||||
#define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1)))
|
||||
/* bits per digit */
|
||||
#endif
|
||||
|
||||
#define MP_DIGIT_BIT DIGIT_BIT
|
||||
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
|
||||
#define MP_DIGIT_MAX MP_MASK
|
||||
|
||||
/* equalities */
|
||||
#define MP_LT -1 /* less than */
|
||||
#define MP_EQ 0 /* equal to */
|
||||
#define MP_GT 1 /* greater than */
|
||||
|
||||
#define MP_ZPOS 0 /* positive integer */
|
||||
#define MP_NEG 1 /* negative */
|
||||
|
||||
#define MP_OKAY 0 /* ok result */
|
||||
#define MP_MEM -2 /* out of mem */
|
||||
#define MP_VAL -3 /* invalid input */
|
||||
#define MP_RANGE MP_VAL
|
||||
|
||||
#define MP_YES 1 /* yes response */
|
||||
#define MP_NO 0 /* no response */
|
||||
|
||||
/* Primality generation flags */
|
||||
#define LTM_PRIME_BBS 0x0001 /* BBS style prime */
|
||||
#define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
|
||||
#define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
|
||||
|
||||
typedef int mp_err;
|
||||
|
||||
/* define this to use lower memory usage routines (exptmods mostly) */
|
||||
#define MP_LOW_MEM
|
||||
|
||||
/* default precision */
|
||||
#ifndef MP_PREC
|
||||
#ifndef MP_LOW_MEM
|
||||
#define MP_PREC 32 /* default digits of precision */
|
||||
#else
|
||||
#define MP_PREC 1 /* default digits of precision */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD -
|
||||
BITS_PER_DIGIT*2) */
|
||||
#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
|
||||
|
||||
/* the infamous mp_int structure */
|
||||
typedef struct {
|
||||
int used, alloc, sign;
|
||||
mp_digit *dp;
|
||||
} mp_int;
|
||||
|
||||
/* callback for mp_prime_random, should fill dst with random bytes and return
|
||||
how many read [upto len] */
|
||||
typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
|
||||
|
||||
|
||||
#define USED(m) ((m)->used)
|
||||
#define DIGIT(m,k) ((m)->dp[(k)])
|
||||
#define SIGN(m) ((m)->sign)
|
||||
|
||||
|
||||
/* ---> Basic Manipulations <--- */
|
||||
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
|
||||
#define mp_iseven(a) \
|
||||
(((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
|
||||
#define mp_isodd(a) \
|
||||
(((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
|
||||
|
||||
|
||||
/* number of primes */
|
||||
#ifdef MP_8BIT
|
||||
#define PRIME_SIZE 31
|
||||
#else
|
||||
#define PRIME_SIZE 256
|
||||
#endif
|
||||
|
||||
#define mp_prime_random(a, t, size, bbs, cb, dat) \
|
||||
mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat)
|
||||
|
||||
#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
|
||||
#define mp_raw_size(mp) mp_signed_bin_size(mp)
|
||||
#define mp_toraw(mp, str) mp_to_signed_bin((mp), (str))
|
||||
#define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len))
|
||||
#define mp_mag_size(mp) mp_unsigned_bin_size(mp)
|
||||
#define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str))
|
||||
|
||||
#define mp_tobinary(M, S) mp_toradix((M), (S), 2)
|
||||
#define mp_tooctal(M, S) mp_toradix((M), (S), 8)
|
||||
#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
|
||||
#define mp_tohex(M, S) mp_toradix((M), (S), 16)
|
||||
|
||||
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
|
||||
|
||||
extern const char *mp_s_rmap;
|
||||
|
||||
/* 6 functions needed by Rsa */
|
||||
int mp_init (mp_int * a);
|
||||
void mp_clear (mp_int * a);
|
||||
int mp_unsigned_bin_size(mp_int * a);
|
||||
int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
|
||||
int mp_to_unsigned_bin (mp_int * a, unsigned char *b);
|
||||
int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y);
|
||||
/* end functions needed by Rsa */
|
||||
|
||||
/* functions added to support above needed, removed TOOM and KARATSUBA */
|
||||
int mp_count_bits (mp_int * a);
|
||||
int mp_init_copy (mp_int * a, mp_int * b);
|
||||
int mp_copy (mp_int * a, mp_int * b);
|
||||
int mp_grow (mp_int * a, int size);
|
||||
void bn_reverse (unsigned char *s, int len);
|
||||
int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
|
||||
void mp_zero (mp_int * a);
|
||||
void mp_clamp (mp_int * a);
|
||||
void mp_exch (mp_int * a, mp_int * b);
|
||||
void mp_rshd (mp_int * a, int b);
|
||||
int mp_mod_2d (mp_int * a, int b, mp_int * c);
|
||||
int mp_mul_2d (mp_int * a, int b, mp_int * c);
|
||||
int mp_lshd (mp_int * a, int b);
|
||||
int mp_abs (mp_int * a, mp_int * b);
|
||||
int mp_invmod (mp_int * a, mp_int * b, mp_int * c);
|
||||
int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_cmp_mag (mp_int * a, mp_int * b);
|
||||
int mp_cmp (mp_int * a, mp_int * b);
|
||||
int mp_cmp_d(mp_int * a, mp_digit b);
|
||||
void mp_set (mp_int * a, mp_digit b);
|
||||
int mp_mod (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d);
|
||||
int mp_div_2(mp_int * a, mp_int * b);
|
||||
int mp_add (mp_int * a, mp_int * b, mp_int * c);
|
||||
int s_mp_add (mp_int * a, mp_int * b, mp_int * c);
|
||||
int s_mp_sub (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_sub (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_reduce_is_2k_l(mp_int *a);
|
||||
int mp_reduce_is_2k(mp_int *a);
|
||||
int mp_dr_is_modulus(mp_int *a);
|
||||
int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int);
|
||||
int mp_montgomery_setup (mp_int * n, mp_digit * rho);
|
||||
int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
|
||||
int mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
|
||||
void mp_dr_setup(mp_int *a, mp_digit *d);
|
||||
int mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k);
|
||||
int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
|
||||
int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
|
||||
int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
|
||||
int mp_reduce (mp_int * x, mp_int * m, mp_int * mu);
|
||||
int mp_reduce_setup (mp_int * a, mp_int * b);
|
||||
int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode);
|
||||
int mp_montgomery_calc_normalization (mp_int * a, mp_int * b);
|
||||
int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int s_mp_sqr (mp_int * a, mp_int * b);
|
||||
int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int fast_s_mp_sqr (mp_int * a, mp_int * b);
|
||||
int mp_init_size (mp_int * a, int size);
|
||||
int mp_div_3 (mp_int * a, mp_int *c, mp_digit * d);
|
||||
int mp_mul_2(mp_int * a, mp_int * b);
|
||||
int mp_mul (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_sqr (mp_int * a, mp_int * b);
|
||||
int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
|
||||
int mp_mul_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
int mp_2expt (mp_int * a, int b);
|
||||
int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
|
||||
int mp_add_d (mp_int* a, mp_digit b, mp_int* c);
|
||||
int mp_set_int (mp_int * a, unsigned long b);
|
||||
/* end support added functions */
|
||||
|
||||
/* added */
|
||||
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
|
||||
mp_int* f);
|
||||
|
||||
#if defined(HAVE_ECC) || defined(CYASSL_KEY_GEN)
|
||||
int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c);
|
||||
#endif
|
||||
#ifdef HAVE_ECC
|
||||
int mp_read_radix(mp_int* a, const char* str, int radix);
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_KEY_GEN
|
||||
int mp_prime_is_prime (mp_int * a, int t, int *result);
|
||||
int mp_gcd (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_lcm (mp_int * a, mp_int * b, mp_int * c);
|
||||
#endif
|
||||
|
||||
#if defined(CYASSL_KEY_GEN) || defined(HAVE_ECC) || !defined(NO_PWDBASED)
|
||||
int mp_sub_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* USE_FAST_MATH */
|
||||
|
||||
#endif /* CTAO_CRYPT_INTEGER_H */
|
||||
|
70
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/logging.h
Normal file
70
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/logging.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* logging.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/* submitted by eof */
|
||||
|
||||
|
||||
#ifndef CYASSL_LOGGING_H
|
||||
#define CYASSL_LOGGING_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum CYA_Log_Levels {
|
||||
ERROR_LOG = 0,
|
||||
INFO_LOG,
|
||||
ENTER_LOG,
|
||||
LEAVE_LOG,
|
||||
OTHER_LOG
|
||||
};
|
||||
|
||||
typedef void (*CyaSSL_Logging_cb)(const int logLevel,
|
||||
const char *const logMessage);
|
||||
|
||||
CYASSL_API int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb log_function);
|
||||
|
||||
|
||||
#ifdef DEBUG_CYASSL
|
||||
|
||||
void CYASSL_ENTER(const char* msg);
|
||||
void CYASSL_LEAVE(const char* msg, int ret);
|
||||
|
||||
void CYASSL_ERROR(int);
|
||||
void CYASSL_MSG(const char* msg);
|
||||
|
||||
#else /* DEBUG_CYASSL */
|
||||
|
||||
#define CYASSL_ENTER(m)
|
||||
#define CYASSL_LEAVE(m, r)
|
||||
|
||||
#define CYASSL_ERROR(e)
|
||||
#define CYASSL_MSG(m)
|
||||
|
||||
#endif /* DEBUG_CYASSL */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_MEMORY_H */
|
64
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/md2.h
Normal file
64
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/md2.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* md2.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CYASSL_MD2
|
||||
|
||||
#ifndef CTAO_CRYPT_MD2_H
|
||||
#define CTAO_CRYPT_MD2_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
MD2 = 6, /* hash type unique */
|
||||
MD2_BLOCK_SIZE = 16,
|
||||
MD2_DIGEST_SIZE = 16,
|
||||
MD2_PAD_SIZE = 16,
|
||||
MD2_X_SIZE = 48
|
||||
};
|
||||
|
||||
|
||||
/* Md2 digest */
|
||||
typedef struct Md2 {
|
||||
word32 count; /* bytes % PAD_SIZE */
|
||||
byte X[MD2_X_SIZE];
|
||||
byte C[MD2_BLOCK_SIZE];
|
||||
byte buffer[MD2_BLOCK_SIZE];
|
||||
} Md2;
|
||||
|
||||
|
||||
CYASSL_API void InitMd2(Md2*);
|
||||
CYASSL_API void Md2Update(Md2*, const byte*, word32);
|
||||
CYASSL_API void Md2Final(Md2*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_MD2_H */
|
||||
#endif /* CYASSL_MD2 */
|
65
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/md4.h
Normal file
65
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/md4.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* md4.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_MD4
|
||||
|
||||
#ifndef CTAO_CRYPT_MD4_H
|
||||
#define CTAO_CRYPT_MD4_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
MD4_BLOCK_SIZE = 64,
|
||||
MD4_DIGEST_SIZE = 16,
|
||||
MD4_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
/* MD4 digest */
|
||||
typedef struct Md4 {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 digest[MD4_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[MD4_BLOCK_SIZE / sizeof(word32)];
|
||||
} Md4;
|
||||
|
||||
|
||||
CYASSL_API void InitMd4(Md4*);
|
||||
CYASSL_API void Md4Update(Md4*, const byte*, word32);
|
||||
CYASSL_API void Md4Final(Md4*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_MD4_H */
|
||||
|
||||
#endif /* NO_MD4 */
|
||||
|
62
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/md5.h
Normal file
62
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/md5.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* md5.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_MD5_H
|
||||
#define CTAO_CRYPT_MD5_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
MD5 = 0, /* hash type unique */
|
||||
MD5_BLOCK_SIZE = 64,
|
||||
MD5_DIGEST_SIZE = 16,
|
||||
MD5_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
/* MD5 digest */
|
||||
typedef struct Md5 {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 digest[MD5_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)];
|
||||
} Md5;
|
||||
|
||||
|
||||
CYASSL_API void InitMd5(Md5*);
|
||||
CYASSL_API void Md5Update(Md5*, const byte*, word32);
|
||||
CYASSL_API void Md5Final(Md5*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_MD5_H */
|
||||
|
55
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/memory.h
Normal file
55
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/memory.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* memory.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/* submitted by eof */
|
||||
|
||||
|
||||
#ifndef CYASSL_MEMORY_H
|
||||
#define CYASSL_MEMORY_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef void *(*CyaSSL_Malloc_cb)(size_t size);
|
||||
typedef void (*CyaSSL_Free_cb)(void *ptr);
|
||||
typedef void *(*CyaSSL_Realloc_cb)(void *ptr, size_t size);
|
||||
|
||||
|
||||
/* Public set function */
|
||||
CYASSL_API int CyaSSL_SetAllocators(CyaSSL_Malloc_cb malloc_function,
|
||||
CyaSSL_Free_cb free_function,
|
||||
CyaSSL_Realloc_cb realloc_function);
|
||||
|
||||
/* Public in case user app wants to use XMALLOC/XFREE */
|
||||
CYASSL_API void* CyaSSL_Malloc(size_t size);
|
||||
CYASSL_API void CyaSSL_Free(void *ptr);
|
||||
CYASSL_API void* CyaSSL_Realloc(void *ptr, size_t size);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CYASSL_MEMORY_H */
|
74
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/misc.h
Normal file
74
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/misc.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* misc.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_MISC_H
|
||||
#define CTAO_CRYPT_MISC_H
|
||||
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NO_INLINE
|
||||
CYASSL_LOCAL
|
||||
word32 rotlFixed(word32, word32);
|
||||
CYASSL_LOCAL
|
||||
word32 rotrFixed(word32, word32);
|
||||
|
||||
CYASSL_LOCAL
|
||||
word32 ByteReverseWord32(word32);
|
||||
CYASSL_LOCAL
|
||||
void ByteReverseWords(word32*, const word32*, word32);
|
||||
CYASSL_LOCAL
|
||||
void ByteReverseBytes(byte*, const byte*, word32);
|
||||
|
||||
CYASSL_LOCAL
|
||||
void XorWords(word*, const word*, word32);
|
||||
CYASSL_LOCAL
|
||||
void xorbuf(byte*, const byte*, word32);
|
||||
|
||||
#ifdef WORD64_AVAILABLE
|
||||
CYASSL_LOCAL
|
||||
word64 rotlFixed64(word64, word64);
|
||||
CYASSL_LOCAL
|
||||
word64 rotrFixed64(word64, word64);
|
||||
|
||||
CYASSL_LOCAL
|
||||
word64 ByteReverseWord64(word64);
|
||||
CYASSL_LOCAL
|
||||
void ByteReverseWords64(word64*, const word64*, word32);
|
||||
#endif /* WORD64_AVAILABLE */
|
||||
|
||||
#endif /* NO_INLINE */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_MISC_H */
|
||||
|
1018
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/mpi_class.h
Normal file
1018
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/mpi_class.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,95 @@
|
|||
/* mpi_superclass.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* super class file for PK algos */
|
||||
|
||||
/* default ... include all MPI */
|
||||
#define LTM_ALL
|
||||
|
||||
/* RSA only (does not support DH/DSA/ECC) */
|
||||
/* #define SC_RSA_1 */
|
||||
|
||||
/* For reference.... On an Athlon64 optimizing for speed...
|
||||
|
||||
LTM's mpi.o with all functions [striped] is 142KiB in size.
|
||||
|
||||
*/
|
||||
|
||||
/* Works for RSA only, mpi.o is 68KiB */
|
||||
#ifdef SC_RSA_1
|
||||
#define BN_MP_SHRINK_C
|
||||
#define BN_MP_LCM_C
|
||||
#define BN_MP_PRIME_RANDOM_EX_C
|
||||
#define BN_MP_INVMOD_C
|
||||
#define BN_MP_GCD_C
|
||||
#define BN_MP_MOD_C
|
||||
#define BN_MP_MULMOD_C
|
||||
#define BN_MP_ADDMOD_C
|
||||
#define BN_MP_EXPTMOD_C
|
||||
#define BN_MP_SET_INT_C
|
||||
#define BN_MP_INIT_MULTI_C
|
||||
#define BN_MP_CLEAR_MULTI_C
|
||||
#define BN_MP_UNSIGNED_BIN_SIZE_C
|
||||
#define BN_MP_TO_UNSIGNED_BIN_C
|
||||
#define BN_MP_MOD_D_C
|
||||
#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
|
||||
#define BN_REVERSE_C
|
||||
#define BN_PRIME_TAB_C
|
||||
|
||||
/* other modifiers */
|
||||
#define BN_MP_DIV_SMALL /* Slower division, not critical */
|
||||
|
||||
/* here we are on the last pass so we turn things off. The functions classes are still there
|
||||
* but we remove them specifically from the build. This also invokes tweaks in functions
|
||||
* like removing support for even moduli, etc...
|
||||
*/
|
||||
#ifdef LTM_LAST
|
||||
#undef BN_MP_TOOM_MUL_C
|
||||
#undef BN_MP_TOOM_SQR_C
|
||||
#undef BN_MP_KARATSUBA_MUL_C
|
||||
#undef BN_MP_KARATSUBA_SQR_C
|
||||
#undef BN_MP_REDUCE_C
|
||||
#undef BN_MP_REDUCE_SETUP_C
|
||||
#undef BN_MP_DR_IS_MODULUS_C
|
||||
#undef BN_MP_DR_SETUP_C
|
||||
#undef BN_MP_DR_REDUCE_C
|
||||
#undef BN_MP_REDUCE_IS_2K_C
|
||||
#undef BN_MP_REDUCE_2K_SETUP_C
|
||||
#undef BN_MP_REDUCE_2K_C
|
||||
#undef BN_S_MP_EXPTMOD_C
|
||||
#undef BN_MP_DIV_3_C
|
||||
#undef BN_S_MP_MUL_HIGH_DIGS_C
|
||||
#undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
|
||||
#undef BN_FAST_MP_INVMOD_C
|
||||
|
||||
/* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
|
||||
* which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
|
||||
* which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
|
||||
* trouble.
|
||||
*/
|
||||
#undef BN_S_MP_MUL_DIGS_C
|
||||
#undef BN_S_MP_SQR_C
|
||||
#undef BN_MP_MONTGOMERY_REDUCE_C
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
53
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/pwdbased.h
Normal file
53
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/pwdbased.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* pwdbased.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_PWDBASED
|
||||
|
||||
#ifndef CTAO_CRYPT_PWDBASED_H
|
||||
#define CTAO_CRYPT_PWDBASED_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <cyassl/ctaocrypt/md5.h> /* for hash type */
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_API int PBKDF1(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations, int kLen,
|
||||
int hashType);
|
||||
CYASSL_API int PBKDF2(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations, int kLen,
|
||||
int hashType);
|
||||
CYASSL_API int PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations,
|
||||
int kLen, int hashType, int purpose);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_PWDBASED_H */
|
||||
#endif /* NO_PWDBASED */
|
65
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/rabbit.h
Normal file
65
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/rabbit.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* rabbit.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NO_RABBIT
|
||||
|
||||
#ifndef CTAO_CRYPT_RABBIT_H
|
||||
#define CTAO_CRYPT_RABBIT_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
RABBIT_ENC_TYPE = 5 /* cipher unique type */
|
||||
};
|
||||
|
||||
|
||||
/* Rabbit Context */
|
||||
typedef struct RabbitCtx {
|
||||
word32 x[8];
|
||||
word32 c[8];
|
||||
word32 carry;
|
||||
} RabbitCtx;
|
||||
|
||||
|
||||
/* Rabbit stream cipher */
|
||||
typedef struct Rabbit {
|
||||
RabbitCtx masterCtx;
|
||||
RabbitCtx workCtx;
|
||||
} Rabbit;
|
||||
|
||||
|
||||
CYASSL_API void RabbitProcess(Rabbit*, byte*, const byte*, word32);
|
||||
CYASSL_API void RabbitSetKey(Rabbit*, const byte* key, const byte* iv);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_RABBIT_H */
|
||||
|
||||
#endif /* NO_RABBIT */
|
73
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/random.h
Normal file
73
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/random.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* random.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_RANDOM_H
|
||||
#define CTAO_CRYPT_RANDOM_H
|
||||
|
||||
#include <cyassl/ctaocrypt/arc4.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#if defined(_WIN64)
|
||||
typedef unsigned __int64 ProviderHandle;
|
||||
/* type HCRYPTPROV, avoid #include <windows.h> */
|
||||
#else
|
||||
typedef unsigned long ProviderHandle;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* OS specific seeder */
|
||||
typedef struct OS_Seed {
|
||||
#if defined(USE_WINDOWS_API)
|
||||
ProviderHandle handle;
|
||||
#else
|
||||
int fd;
|
||||
#endif
|
||||
} OS_Seed;
|
||||
|
||||
CYASSL_LOCAL
|
||||
int GenerateSeed(OS_Seed* os, byte* seed, word32 sz);
|
||||
|
||||
|
||||
/* secure Random Nnumber Generator */
|
||||
typedef struct RNG {
|
||||
OS_Seed seed;
|
||||
Arc4 cipher;
|
||||
} RNG;
|
||||
|
||||
|
||||
CYASSL_API int InitRng(RNG*);
|
||||
CYASSL_API void RNG_GenerateBlock(RNG*, byte*, word32 sz);
|
||||
CYASSL_API byte RNG_GenerateByte(RNG*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_RANDOM_H */
|
||||
|
64
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/ripemd.h
Normal file
64
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/ripemd.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* ripemd.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CYASSL_RIPEMD
|
||||
|
||||
#ifndef CTAO_CRYPT_RIPEMD_H
|
||||
#define CTAO_CRYPT_RIPEME_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
RIPEMD = 3, /* hash type unique */
|
||||
RIPEMD_BLOCK_SIZE = 64,
|
||||
RIPEMD_DIGEST_SIZE = 20,
|
||||
RIPEMD_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
/* RipeMd 160 digest */
|
||||
typedef struct RipeMd {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 digest[RIPEMD_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[RIPEMD_BLOCK_SIZE / sizeof(word32)];
|
||||
} RipeMd;
|
||||
|
||||
|
||||
CYASSL_API void InitRipeMd(RipeMd*);
|
||||
CYASSL_API void RipeMdUpdate(RipeMd*, const byte*, word32);
|
||||
CYASSL_API void RipeMdFinal(RipeMd*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_RIPEMD_H */
|
||||
#endif /* CYASSL_RIPEMD */
|
81
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/rsa.h
Normal file
81
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/rsa.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* rsa.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_RSA_H
|
||||
#define CTAO_CRYPT_RSA_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <cyassl/ctaocrypt/integer.h>
|
||||
#include <cyassl/ctaocrypt/random.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
RSA_PUBLIC = 0,
|
||||
RSA_PRIVATE = 1
|
||||
};
|
||||
|
||||
/* RSA */
|
||||
typedef struct RsaKey {
|
||||
mp_int n, e, d, p, q, dP, dQ, u;
|
||||
int type; /* public or private */
|
||||
void* heap; /* for user memory overrides */
|
||||
} RsaKey;
|
||||
|
||||
|
||||
CYASSL_API void InitRsaKey(RsaKey* key, void*);
|
||||
CYASSL_API void FreeRsaKey(RsaKey* key);
|
||||
|
||||
CYASSL_API int RsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key, RNG* rng);
|
||||
CYASSL_API int RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out,
|
||||
RsaKey* key);
|
||||
CYASSL_API int RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key);
|
||||
CYASSL_API int RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key, RNG* rng);
|
||||
CYASSL_API int RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
|
||||
RsaKey* key);
|
||||
CYASSL_API int RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key);
|
||||
CYASSL_API int RsaEncryptSize(RsaKey* key);
|
||||
|
||||
CYASSL_API int RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
||||
word32);
|
||||
CYASSL_API int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
||||
word32);
|
||||
#ifdef CYASSL_KEY_GEN
|
||||
CYASSL_API int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
|
||||
CYASSL_API int RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_RSA_H */
|
||||
|
322
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/settings.h
Normal file
322
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/settings.h
Normal file
|
@ -0,0 +1,322 @@
|
|||
/* settings.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/* Place OS specific preprocessor flags, defines, includes here, will be
|
||||
included into every file because types.h includes it */
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_SETTINGS_H
|
||||
#define CTAO_CRYPT_SETTINGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Uncomment next line if using IPHONE */
|
||||
/* #define IPHONE */
|
||||
|
||||
/* Uncomment next line if using ThreadX */
|
||||
/* #define THREADX */
|
||||
|
||||
/* Uncomment next line if using Micrium ucOS */
|
||||
/* #define MICRIUM */
|
||||
|
||||
/* Uncomment next line if using Mbed */
|
||||
/* #define MBED */
|
||||
|
||||
/* Uncomment next line if using Microchip PIC32 ethernet starter kit */
|
||||
/* #define MICROCHIP_PIC32 */
|
||||
|
||||
/* Uncomment next line if using FreeRTOS */
|
||||
/* #define FREERTOS */
|
||||
|
||||
/* Uncomment next line if using FreeRTOS Windows Simulator */
|
||||
/* #define FREERTOS_WINSIM */
|
||||
|
||||
/* Uncomment next line if using lwip */
|
||||
/* #define CYASSL_LWIP */
|
||||
|
||||
/* Uncomment next line if building CyaSSL for a game console */
|
||||
/* #define CYASSL_GAME_BUILD */
|
||||
|
||||
|
||||
#include <cyassl/ctaocrypt/visibility.h>
|
||||
|
||||
#ifdef IPHONE
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#endif
|
||||
|
||||
#ifdef THREADX
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#endif
|
||||
|
||||
#ifdef MICROCHIP_PIC32
|
||||
/* use MBED plus no filesystem */
|
||||
#define MBED
|
||||
#define NO_FILESYSTEM
|
||||
#endif
|
||||
|
||||
#ifdef MBED
|
||||
#define SINGLE_THREADED
|
||||
#define CYASSL_USER_IO
|
||||
#define NO_WRITEV
|
||||
#define NO_DEV_RANDOM
|
||||
#define NO_SHA512
|
||||
#define NO_DH
|
||||
#define NO_DSA
|
||||
#define NO_HC128
|
||||
#endif /* MBED */
|
||||
|
||||
#ifdef FREERTOS_WINSIM
|
||||
#define FREERTOS
|
||||
#define USE_WINDOWS_API
|
||||
#endif
|
||||
|
||||
#ifdef FREERTOS
|
||||
#define NO_WRITEV
|
||||
#define NO_SHA512
|
||||
#define NO_DH
|
||||
#define NO_DSA
|
||||
#define NO_HC128
|
||||
|
||||
#ifndef SINGLE_THREADED
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_GAME_BUILD
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#if defined(__PPU) || defined(__XENON)
|
||||
#define BIG_ENDIAN_ORDER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MICRIUM
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "net_cfg.h"
|
||||
#include "ssl_cfg.h"
|
||||
#include "net_secure_os.h"
|
||||
|
||||
#define CYASSL_TYPES
|
||||
|
||||
typedef CPU_INT08U byte;
|
||||
typedef CPU_INT16U word16;
|
||||
typedef CPU_INT32U word32;
|
||||
|
||||
#if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
|
||||
#define SIZEOF_LONG 4
|
||||
#undef SIZEOF_LONG_LONG
|
||||
#else
|
||||
#undef SIZEOF_LONG
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#endif
|
||||
|
||||
#define STRING_USER
|
||||
|
||||
#define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
|
||||
#define XSTRNCPY(pstr_dest, pstr_src, len_max) \
|
||||
((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
|
||||
(CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
|
||||
#define XSTRNCMP(pstr_1, pstr_2, len_max) \
|
||||
((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
|
||||
(CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
|
||||
#define XSTRSTR(pstr, pstr_srch) \
|
||||
((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
|
||||
(CPU_CHAR *)(pstr_srch)))
|
||||
#define XMEMSET(pmem, data_val, size) \
|
||||
((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
|
||||
(CPU_SIZE_T)(size)))
|
||||
#define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
|
||||
(void *)(psrc), (CPU_SIZE_T)(size)))
|
||||
#define XMEMCMP(pmem_1, pmem_2, size) \
|
||||
(((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
|
||||
(CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
|
||||
#define XMEMMOVE XMEMCPY
|
||||
|
||||
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
|
||||
#define MICRIUM_MALLOC
|
||||
#define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
|
||||
(CPU_SIZE_T)(s), (void *)0))
|
||||
#define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \
|
||||
(p), (void *)0))
|
||||
#define XREALLOC(p, n, h, t) realloc((p), (n))
|
||||
#endif
|
||||
|
||||
#if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
|
||||
#undef NO_FILESYSTEM
|
||||
#else
|
||||
#define NO_FILESYSTEM
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_TRACE_LEVEL == CYASSL_TRACE_LEVEL_DBG)
|
||||
#define DEBUG_CYASSL
|
||||
#else
|
||||
#undef DEBUG_CYASSL
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
|
||||
#define OPENSSL_EXTRA
|
||||
#else
|
||||
#undef OPENSSL_EXTRA
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
|
||||
#undef SINGLE_THREADED
|
||||
#else
|
||||
#define SINGLE_THREADED
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_DH_EN == DEF_ENABLED)
|
||||
#undef NO_DH
|
||||
#else
|
||||
#define NO_DH
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_DSA_EN == DEF_ENABLED)
|
||||
#undef NO_DSA
|
||||
#else
|
||||
#define NO_DSA
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_PSK_EN == DEF_ENABLED)
|
||||
#undef NO_PSK
|
||||
#else
|
||||
#define NO_PSK
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_3DES_EN == DEF_ENABLED)
|
||||
#undef NO_DES
|
||||
#else
|
||||
#define NO_DES
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_AES_EN == DEF_ENABLED)
|
||||
#undef NO_AES
|
||||
#else
|
||||
#define NO_AES
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_RC4_EN == DEF_ENABLED)
|
||||
#undef NO_RC4
|
||||
#else
|
||||
#define NO_RC4
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
|
||||
#undef NO_RABBIT
|
||||
#else
|
||||
#define NO_RABBIT
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_HC128_EN == DEF_ENABLED)
|
||||
#undef NO_HC128
|
||||
#else
|
||||
#define NO_HC128
|
||||
#endif
|
||||
|
||||
#if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
|
||||
#define BIG_ENDIAN_ORDER
|
||||
#else
|
||||
#undef BIG_ENDIAN_ORDER
|
||||
#define LITTLE_ENDIAN_ORDER
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_MD4_EN == DEF_ENABLED)
|
||||
#undef NO_MD4
|
||||
#else
|
||||
#define NO_MD4
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
|
||||
#undef NO_WRITEV
|
||||
#else
|
||||
#define NO_WRITEV
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
|
||||
#define NO_DEV_RANDOM
|
||||
#else
|
||||
#undef NO_DEV_RANDOM
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
|
||||
#define CYASSL_USER_IO
|
||||
#else
|
||||
#undef CYASSL_USER_IO
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
|
||||
#undef LARGE_STATIC_BUFFERS
|
||||
#undef STATIC_CHUNKS_ONLY
|
||||
#else
|
||||
#define LARGE_STATIC_BUFFERS
|
||||
#define STATIC_CHUNKS_ONLY
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
|
||||
#define CYASSL_DER_LOAD
|
||||
#else
|
||||
#undef CYASSL_DER_LOAD
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_DTLS_EN == DEF_ENABLED)
|
||||
#define CYASSL_DTLS
|
||||
#else
|
||||
#undef CYASSL_DTLS
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
|
||||
#define CYASSL_CALLBACKS
|
||||
#else
|
||||
#undef CYASSL_CALLBACKS
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
|
||||
#define USE_FAST_MATH
|
||||
#else
|
||||
#undef USE_FAST_MATH
|
||||
#endif
|
||||
|
||||
#if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#else
|
||||
#undef TFM_TIMING_RESISTANT
|
||||
#endif
|
||||
|
||||
#endif /* MICRIUM */
|
||||
|
||||
|
||||
#if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC)
|
||||
#define USE_CYASSL_MEMORY
|
||||
#endif
|
||||
|
||||
/* Place any other flags or defines here */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_SETTINGS_H */
|
||||
|
62
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/sha.h
Normal file
62
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/sha.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* sha.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_SHA_H
|
||||
#define CTAO_CRYPT_SHA_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
SHA = 1, /* hash type unique */
|
||||
SHA_BLOCK_SIZE = 64,
|
||||
SHA_DIGEST_SIZE = 20,
|
||||
SHA_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
/* Sha digest */
|
||||
typedef struct Sha {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
|
||||
} Sha;
|
||||
|
||||
|
||||
CYASSL_API void InitSha(Sha*);
|
||||
CYASSL_API void ShaUpdate(Sha*, const byte*, word32);
|
||||
CYASSL_API void ShaFinal(Sha*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_SHA_H */
|
||||
|
68
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/sha256.h
Normal file
68
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/sha256.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* sha256.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* code submitted by raphael.huck@efixo.com */
|
||||
|
||||
|
||||
#ifndef NO_SHA256
|
||||
|
||||
#ifndef CTAO_CRYPT_SHA256_H
|
||||
#define CTAO_CRYPT_SHA256_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
SHA256 = 2, /* hash type unique */
|
||||
SHA256_BLOCK_SIZE = 64,
|
||||
SHA256_DIGEST_SIZE = 32,
|
||||
SHA256_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
/* Sha256 digest */
|
||||
typedef struct Sha256 {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)];
|
||||
word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)];
|
||||
} Sha256;
|
||||
|
||||
|
||||
CYASSL_API void InitSha256(Sha256*);
|
||||
CYASSL_API void Sha256Update(Sha256*, const byte*, word32);
|
||||
CYASSL_API void Sha256Final(Sha256*, byte*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_SHA256_H */
|
||||
#endif /* NO_SHA256 */
|
||||
|
91
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/sha512.h
Normal file
91
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/sha512.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* sha512.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CYASSL_SHA512
|
||||
|
||||
#ifndef CTAO_CRYPT_SHA512_H
|
||||
#define CTAO_CRYPT_SHA512_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
SHA512 = 4, /* hash type unique */
|
||||
SHA512_BLOCK_SIZE = 128,
|
||||
SHA512_DIGEST_SIZE = 64,
|
||||
SHA512_PAD_SIZE = 112
|
||||
};
|
||||
|
||||
|
||||
/* Sha512 digest */
|
||||
typedef struct Sha512 {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)];
|
||||
word64 buffer[SHA512_BLOCK_SIZE / sizeof(word64)];
|
||||
} Sha512;
|
||||
|
||||
|
||||
CYASSL_API void InitSha512(Sha512*);
|
||||
CYASSL_API void Sha512Update(Sha512*, const byte*, word32);
|
||||
CYASSL_API void Sha512Final(Sha512*, byte*);
|
||||
|
||||
|
||||
#ifdef CYASSL_SHA384
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
SHA384 = 5, /* hash type unique */
|
||||
SHA384_BLOCK_SIZE = 128,
|
||||
SHA384_DIGEST_SIZE = 48,
|
||||
SHA384_PAD_SIZE = 112
|
||||
};
|
||||
|
||||
|
||||
/* Sha384 digest */
|
||||
typedef struct Sha384 {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
|
||||
word64 buffer[SHA384_BLOCK_SIZE / sizeof(word64)];
|
||||
} Sha384;
|
||||
|
||||
|
||||
CYASSL_API void InitSha384(Sha384*);
|
||||
CYASSL_API void Sha384Update(Sha384*, const byte*, word32);
|
||||
CYASSL_API void Sha384Final(Sha384*, byte*);
|
||||
|
||||
#endif /* CYASSL_SHA384 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CTAO_CRYPT_SHA512_H */
|
||||
#endif /* CYASSL_SHA512 */
|
686
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/tfm.h
Normal file
686
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/tfm.h
Normal file
|
@ -0,0 +1,686 @@
|
|||
/* tfm.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Based on public domain TomsFastMath 0.10 by Tom St Denis, tomstdenis@iahu.ca,
|
||||
* http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Edited by Moisés Guimarães (moises.guimaraes@phoebus.com.br)
|
||||
* to fit CyaSSL's needs.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_TFM_H
|
||||
#define CTAO_CRYPT_TFM_H
|
||||
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#ifndef CHAR_BIT
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
|
||||
/* autodetect x86-64 and make sure we are using 64-bit digits with x86-64 asm */
|
||||
#if defined(__x86_64__)
|
||||
#if defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM)
|
||||
#error x86-64 detected, x86-32/SSE2/ARM optimizations are not valid!
|
||||
#endif
|
||||
#if !defined(TFM_X86_64) && !defined(TFM_NO_ASM)
|
||||
#define TFM_X86_64
|
||||
#endif
|
||||
#endif
|
||||
#if defined(TFM_X86_64)
|
||||
#if !defined(FP_64BIT)
|
||||
#define FP_64BIT
|
||||
#endif
|
||||
#endif
|
||||
/* use 64-bit digit even if not using asm on x86_64 */
|
||||
#if defined(__x86_64__) && !defined(FP_64BIT)
|
||||
#define FP_64BIT
|
||||
#endif
|
||||
|
||||
/* try to detect x86-32 */
|
||||
#if defined(__i386__) && !defined(TFM_SSE2)
|
||||
#if defined(TFM_X86_64) || defined(TFM_ARM)
|
||||
#error x86-32 detected, x86-64/ARM optimizations are not valid!
|
||||
#endif
|
||||
#if !defined(TFM_X86) && !defined(TFM_NO_ASM)
|
||||
#define TFM_X86
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* make sure we're 32-bit for x86-32/sse/arm/ppc32 */
|
||||
#if (defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM) || defined(TFM_PPC32)) && defined(FP_64BIT)
|
||||
#warning x86-32, SSE2 and ARM, PPC32 optimizations require 32-bit digits (undefining)
|
||||
#undef FP_64BIT
|
||||
#endif
|
||||
|
||||
/* multi asms? */
|
||||
#ifdef TFM_X86
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
#ifdef TFM_X86_64
|
||||
#ifdef TFM_ASM
|
||||
#error TFM_ASM already defined!
|
||||
#endif
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
#ifdef TFM_SSE2
|
||||
#ifdef TFM_ASM
|
||||
#error TFM_ASM already defined!
|
||||
#endif
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
#ifdef TFM_ARM
|
||||
#ifdef TFM_ASM
|
||||
#error TFM_ASM already defined!
|
||||
#endif
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
#ifdef TFM_PPC32
|
||||
#ifdef TFM_ASM
|
||||
#error TFM_ASM already defined!
|
||||
#endif
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
#ifdef TFM_PPC64
|
||||
#ifdef TFM_ASM
|
||||
#error TFM_ASM already defined!
|
||||
#endif
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
#ifdef TFM_AVR32
|
||||
#ifdef TFM_ASM
|
||||
#error TFM_ASM already defined!
|
||||
#endif
|
||||
#define TFM_ASM
|
||||
#endif
|
||||
|
||||
/* we want no asm? */
|
||||
#ifdef TFM_NO_ASM
|
||||
#undef TFM_X86
|
||||
#undef TFM_X86_64
|
||||
#undef TFM_SSE2
|
||||
#undef TFM_ARM
|
||||
#undef TFM_PPC32
|
||||
#undef TFM_PPC64
|
||||
#undef TFM_AVR32
|
||||
#undef TFM_ASM
|
||||
#endif
|
||||
|
||||
/* ECC helpers */
|
||||
#ifdef TFM_ECC192
|
||||
#ifdef FP_64BIT
|
||||
#define TFM_MUL3
|
||||
#define TFM_SQR3
|
||||
#else
|
||||
#define TFM_MUL6
|
||||
#define TFM_SQR6
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TFM_ECC224
|
||||
#ifdef FP_64BIT
|
||||
#define TFM_MUL4
|
||||
#define TFM_SQR4
|
||||
#else
|
||||
#define TFM_MUL7
|
||||
#define TFM_SQR7
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TFM_ECC256
|
||||
#ifdef FP_64BIT
|
||||
#define TFM_MUL4
|
||||
#define TFM_SQR4
|
||||
#else
|
||||
#define TFM_MUL8
|
||||
#define TFM_SQR8
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TFM_ECC384
|
||||
#ifdef FP_64BIT
|
||||
#define TFM_MUL6
|
||||
#define TFM_SQR6
|
||||
#else
|
||||
#define TFM_MUL12
|
||||
#define TFM_SQR12
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TFM_ECC521
|
||||
#ifdef FP_64BIT
|
||||
#define TFM_MUL9
|
||||
#define TFM_SQR9
|
||||
#else
|
||||
#define TFM_MUL17
|
||||
#define TFM_SQR17
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* some default configurations.
|
||||
*/
|
||||
#if defined(FP_64BIT)
|
||||
/* for GCC only on supported platforms */
|
||||
#ifndef CRYPT
|
||||
typedef unsigned long ulong64;
|
||||
#endif
|
||||
typedef ulong64 fp_digit;
|
||||
typedef unsigned long fp_word __attribute__ ((mode(TI)));
|
||||
#else
|
||||
/* this is to make porting into LibTomCrypt easier :-) */
|
||||
#ifndef CRYPT
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ulong64;
|
||||
typedef signed __int64 long64;
|
||||
#else
|
||||
typedef unsigned long long ulong64;
|
||||
typedef signed long long long64;
|
||||
#endif
|
||||
#endif
|
||||
typedef unsigned int fp_digit;
|
||||
typedef ulong64 fp_word;
|
||||
#endif
|
||||
|
||||
/* # of digits this is */
|
||||
#define DIGIT_BIT (int)((CHAR_BIT) * sizeof(fp_digit))
|
||||
|
||||
/* Max size of any number in bits. Basically the largest size you will be
|
||||
* multiplying should be half [or smaller] of FP_MAX_SIZE-four_digit
|
||||
*
|
||||
* It defaults to 4096-bits [allowing multiplications upto 2048x2048 bits ]
|
||||
*/
|
||||
#ifndef FP_MAX_BITS
|
||||
#define FP_MAX_BITS 4096
|
||||
#endif
|
||||
#define FP_MAX_SIZE (FP_MAX_BITS+(8*DIGIT_BIT))
|
||||
|
||||
/* will this lib work? */
|
||||
#if (CHAR_BIT & 7)
|
||||
#error CHAR_BIT must be a multiple of eight.
|
||||
#endif
|
||||
#if FP_MAX_BITS % CHAR_BIT
|
||||
#error FP_MAX_BITS must be a multiple of CHAR_BIT
|
||||
#endif
|
||||
|
||||
#define FP_MASK (fp_digit)(-1)
|
||||
#define FP_SIZE (FP_MAX_SIZE/DIGIT_BIT)
|
||||
|
||||
/* signs */
|
||||
#define FP_ZPOS 0
|
||||
#define FP_NEG 1
|
||||
|
||||
/* return codes */
|
||||
#define FP_OKAY 0
|
||||
#define FP_VAL 1
|
||||
#define FP_MEM 2
|
||||
|
||||
/* equalities */
|
||||
#define FP_LT -1 /* less than */
|
||||
#define FP_EQ 0 /* equal to */
|
||||
#define FP_GT 1 /* greater than */
|
||||
|
||||
/* replies */
|
||||
#define FP_YES 1 /* yes response */
|
||||
#define FP_NO 0 /* no response */
|
||||
|
||||
/* a FP type */
|
||||
typedef struct {
|
||||
fp_digit dp[FP_SIZE];
|
||||
int used,
|
||||
sign;
|
||||
} fp_int;
|
||||
|
||||
/* externally define this symbol to ignore the default settings, useful for changing the build from the make process */
|
||||
#ifndef TFM_ALREADY_SET
|
||||
|
||||
/* do we want the large set of small multiplications ?
|
||||
Enable these if you are going to be doing a lot of small (<= 16 digit) multiplications say in ECC
|
||||
Or if you're on a 64-bit machine doing RSA as a 1024-bit integer == 16 digits ;-)
|
||||
*/
|
||||
/* need to refactor the function */
|
||||
/*#define TFM_SMALL_SET */
|
||||
|
||||
/* do we want huge code
|
||||
Enable these if you are doing 20, 24, 28, 32, 48, 64 digit multiplications (useful for RSA)
|
||||
Less important on 64-bit machines as 32 digits == 2048 bits
|
||||
*/
|
||||
#if 0
|
||||
#define TFM_MUL3
|
||||
#define TFM_MUL4
|
||||
#define TFM_MUL6
|
||||
#define TFM_MUL7
|
||||
#define TFM_MUL8
|
||||
#define TFM_MUL9
|
||||
#define TFM_MUL12
|
||||
#define TFM_MUL17
|
||||
#endif
|
||||
#ifdef TFM_SMALL_SET
|
||||
#define TFM_MUL20
|
||||
#define TFM_MUL24
|
||||
#define TFM_MUL28
|
||||
#define TFM_MUL32
|
||||
#if (FP_MAX_BITS >= 6144) && defined(FP_64BIT)
|
||||
#define TFM_MUL48
|
||||
#endif
|
||||
#if (FP_MAX_BITS >= 8192) && defined(FP_64BIT)
|
||||
#define TFM_MUL64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define TFM_SQR3
|
||||
#define TFM_SQR4
|
||||
#define TFM_SQR6
|
||||
#define TFM_SQR7
|
||||
#define TFM_SQR8
|
||||
#define TFM_SQR9
|
||||
#define TFM_SQR12
|
||||
#define TFM_SQR17
|
||||
#endif
|
||||
#ifdef TFM_SMALL_SET
|
||||
#define TFM_SQR20
|
||||
#define TFM_SQR24
|
||||
#define TFM_SQR28
|
||||
#define TFM_SQR32
|
||||
#define TFM_SQR48
|
||||
#define TFM_SQR64
|
||||
#endif
|
||||
|
||||
/* do we want some overflow checks
|
||||
Not required if you make sure your numbers are within range (e.g. by default a modulus for fp_exptmod() can only be upto 2048 bits long)
|
||||
*/
|
||||
/* #define TFM_CHECK */
|
||||
|
||||
/* Is the target a P4 Prescott
|
||||
*/
|
||||
/* #define TFM_PRESCOTT */
|
||||
|
||||
/* Do we want timing resistant fp_exptmod() ?
|
||||
* This makes it slower but also timing invariant with respect to the exponent
|
||||
*/
|
||||
/* #define TFM_TIMING_RESISTANT */
|
||||
|
||||
#endif /* TFM_ALREADY_SET */
|
||||
|
||||
/* functions */
|
||||
|
||||
/* returns a TFM ident string useful for debugging... */
|
||||
/*const char *fp_ident(void);*/
|
||||
|
||||
/* initialize [or zero] an fp int */
|
||||
#define fp_init(a) (void)XMEMSET((a), 0, sizeof(fp_int))
|
||||
#define fp_zero(a) fp_init(a)
|
||||
|
||||
/* zero/even/odd ? */
|
||||
#define fp_iszero(a) (((a)->used == 0) ? FP_YES : FP_NO)
|
||||
#define fp_iseven(a) (((a)->used >= 0 && (((a)->dp[0] & 1) == 0)) ? FP_YES : FP_NO)
|
||||
#define fp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? FP_YES : FP_NO)
|
||||
|
||||
/* set to a small digit */
|
||||
void fp_set(fp_int *a, fp_digit b);
|
||||
|
||||
/* copy from a to b */
|
||||
#define fp_copy(a, b) (void)(((a) != (b)) ? (XMEMCPY((b), (a), sizeof(fp_int))) : (void)0)
|
||||
#define fp_init_copy(a, b) fp_copy(b, a)
|
||||
|
||||
/* clamp digits */
|
||||
#define fp_clamp(a) { while ((a)->used && (a)->dp[(a)->used-1] == 0) --((a)->used); (a)->sign = (a)->used ? (a)->sign : FP_ZPOS; }
|
||||
|
||||
/* negate and absolute */
|
||||
#define fp_neg(a, b) { fp_copy(a, b); (b)->sign ^= 1; fp_clamp(b); }
|
||||
#define fp_abs(a, b) { fp_copy(a, b); (b)->sign = 0; }
|
||||
|
||||
/* right shift x digits */
|
||||
void fp_rshd(fp_int *a, int x);
|
||||
|
||||
/* left shift x digits */
|
||||
void fp_lshd(fp_int *a, int x);
|
||||
|
||||
/* signed comparison */
|
||||
int fp_cmp(fp_int *a, fp_int *b);
|
||||
|
||||
/* unsigned comparison */
|
||||
int fp_cmp_mag(fp_int *a, fp_int *b);
|
||||
|
||||
/* power of 2 operations */
|
||||
void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d);
|
||||
void fp_mod_2d(fp_int *a, int b, fp_int *c);
|
||||
void fp_mul_2d(fp_int *a, int b, fp_int *c);
|
||||
void fp_2expt (fp_int *a, int b);
|
||||
void fp_mul_2(fp_int *a, fp_int *c);
|
||||
void fp_div_2(fp_int *a, fp_int *c);
|
||||
|
||||
/* Counts the number of lsbs which are zero before the first zero bit */
|
||||
/*int fp_cnt_lsb(fp_int *a);*/
|
||||
|
||||
/* c = a + b */
|
||||
void fp_add(fp_int *a, fp_int *b, fp_int *c);
|
||||
|
||||
/* c = a - b */
|
||||
void fp_sub(fp_int *a, fp_int *b, fp_int *c);
|
||||
|
||||
/* c = a * b */
|
||||
void fp_mul(fp_int *a, fp_int *b, fp_int *c);
|
||||
|
||||
/* b = a*a */
|
||||
void fp_sqr(fp_int *a, fp_int *b);
|
||||
|
||||
/* a/b => cb + d == a */
|
||||
int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
int fp_mod(fp_int *a, fp_int *b, fp_int *c);
|
||||
|
||||
/* compare against a single digit */
|
||||
int fp_cmp_d(fp_int *a, fp_digit b);
|
||||
|
||||
/* c = a + b */
|
||||
void fp_add_d(fp_int *a, fp_digit b, fp_int *c);
|
||||
|
||||
/* c = a - b */
|
||||
void fp_sub_d(fp_int *a, fp_digit b, fp_int *c);
|
||||
|
||||
/* c = a * b */
|
||||
void fp_mul_d(fp_int *a, fp_digit b, fp_int *c);
|
||||
|
||||
/* a/b => cb + d == a */
|
||||
/*int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d);*/
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
/*int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c);*/
|
||||
|
||||
/* ---> number theory <--- */
|
||||
/* d = a + b (mod c) */
|
||||
/*int fp_addmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);*/
|
||||
|
||||
/* d = a - b (mod c) */
|
||||
/*int fp_submod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);*/
|
||||
|
||||
/* d = a * b (mod c) */
|
||||
int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
|
||||
|
||||
/* c = a * a (mod b) */
|
||||
int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c);
|
||||
|
||||
/* c = 1/a (mod b) */
|
||||
int fp_invmod(fp_int *a, fp_int *b, fp_int *c);
|
||||
|
||||
/* c = (a, b) */
|
||||
/*void fp_gcd(fp_int *a, fp_int *b, fp_int *c);*/
|
||||
|
||||
/* c = [a, b] */
|
||||
/*void fp_lcm(fp_int *a, fp_int *b, fp_int *c);*/
|
||||
|
||||
/* setups the montgomery reduction */
|
||||
int fp_montgomery_setup(fp_int *a, fp_digit *mp);
|
||||
|
||||
/* computes a = B**n mod b without division or multiplication useful for
|
||||
* normalizing numbers in a Montgomery system.
|
||||
*/
|
||||
void fp_montgomery_calc_normalization(fp_int *a, fp_int *b);
|
||||
|
||||
/* computes x/R == x (mod N) via Montgomery Reduction */
|
||||
void fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp);
|
||||
|
||||
/* d = a**b (mod c) */
|
||||
int fp_exptmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
|
||||
|
||||
/* primality stuff */
|
||||
|
||||
/* perform a Miller-Rabin test of a to the base b and store result in "result" */
|
||||
/*void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result);*/
|
||||
|
||||
/* 256 trial divisions + 8 Miller-Rabins, returns FP_YES if probable prime */
|
||||
/*int fp_isprime(fp_int *a);*/
|
||||
|
||||
/* Primality generation flags */
|
||||
/*#define TFM_PRIME_BBS 0x0001 */ /* BBS style prime */
|
||||
/*#define TFM_PRIME_SAFE 0x0002 */ /* Safe prime (p-1)/2 == prime */
|
||||
/*#define TFM_PRIME_2MSB_OFF 0x0004 */ /* force 2nd MSB to 0 */
|
||||
/*#define TFM_PRIME_2MSB_ON 0x0008 */ /* force 2nd MSB to 1 */
|
||||
|
||||
/* callback for fp_prime_random, should fill dst with random bytes and return how many read [upto len] */
|
||||
/*typedef int tfm_prime_callback(unsigned char *dst, int len, void *dat);*/
|
||||
|
||||
/*#define fp_prime_random(a, t, size, bbs, cb, dat) fp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?TFM_PRIME_BBS:0, cb, dat)*/
|
||||
|
||||
/*int fp_prime_random_ex(fp_int *a, int t, int size, int flags, tfm_prime_callback cb, void *dat);*/
|
||||
|
||||
/* radix conersions */
|
||||
int fp_count_bits(fp_int *a);
|
||||
|
||||
int fp_unsigned_bin_size(fp_int *a);
|
||||
void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c);
|
||||
void fp_to_unsigned_bin(fp_int *a, unsigned char *b);
|
||||
|
||||
/*int fp_signed_bin_size(fp_int *a);*/
|
||||
/*void fp_read_signed_bin(fp_int *a, unsigned char *b, int c);*/
|
||||
/*void fp_to_signed_bin(fp_int *a, unsigned char *b);*/
|
||||
|
||||
/*int fp_read_radix(fp_int *a, char *str, int radix);*/
|
||||
/*int fp_toradix(fp_int *a, char *str, int radix);*/
|
||||
/*int fp_toradix_n(fp_int * a, char *str, int radix, int maxlen);*/
|
||||
|
||||
|
||||
/* VARIOUS LOW LEVEL STUFFS */
|
||||
void s_fp_add(fp_int *a, fp_int *b, fp_int *c);
|
||||
void s_fp_sub(fp_int *a, fp_int *b, fp_int *c);
|
||||
void fp_reverse(unsigned char *s, int len);
|
||||
|
||||
void fp_mul_comba(fp_int *A, fp_int *B, fp_int *C);
|
||||
|
||||
#ifdef TFM_SMALL_SET
|
||||
void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
|
||||
#ifdef TFM_MUL3
|
||||
void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL4
|
||||
void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL6
|
||||
void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL7
|
||||
void fp_mul_comba7(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL8
|
||||
void fp_mul_comba8(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL9
|
||||
void fp_mul_comba9(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL12
|
||||
void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL17
|
||||
void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
|
||||
#ifdef TFM_MUL20
|
||||
void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL24
|
||||
void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL28
|
||||
void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL32
|
||||
void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL48
|
||||
void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
#ifdef TFM_MUL64
|
||||
void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C);
|
||||
#endif
|
||||
|
||||
void fp_sqr_comba(fp_int *A, fp_int *B);
|
||||
|
||||
#ifdef TFM_SMALL_SET
|
||||
void fp_sqr_comba_small(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
|
||||
#ifdef TFM_SQR3
|
||||
void fp_sqr_comba3(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR4
|
||||
void fp_sqr_comba4(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR6
|
||||
void fp_sqr_comba6(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR7
|
||||
void fp_sqr_comba7(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR8
|
||||
void fp_sqr_comba8(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR9
|
||||
void fp_sqr_comba9(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR12
|
||||
void fp_sqr_comba12(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR17
|
||||
void fp_sqr_comba17(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
|
||||
#ifdef TFM_SQR20
|
||||
void fp_sqr_comba20(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR24
|
||||
void fp_sqr_comba24(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR28
|
||||
void fp_sqr_comba28(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR32
|
||||
void fp_sqr_comba32(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR48
|
||||
void fp_sqr_comba48(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
#ifdef TFM_SQR64
|
||||
void fp_sqr_comba64(fp_int *A, fp_int *B);
|
||||
#endif
|
||||
/*extern const char *fp_s_rmap;*/
|
||||
|
||||
|
||||
/**
|
||||
* Used by CyaSSL
|
||||
*/
|
||||
|
||||
/* Types */
|
||||
typedef fp_digit mp_digit;
|
||||
typedef fp_word mp_word;
|
||||
typedef fp_int mp_int;
|
||||
|
||||
/* Constants */
|
||||
#define MP_LT FP_LT /* less than */
|
||||
#define MP_EQ FP_EQ /* equal to */
|
||||
#define MP_GT FP_GT /* greater than */
|
||||
#define MP_OKAY FP_OKAY /* ok result */
|
||||
#define MP_NO FP_NO /* yes/no result */
|
||||
#define MP_YES FP_YES /* yes/no result */
|
||||
|
||||
/* Prototypes */
|
||||
int mp_init (mp_int * a);
|
||||
void mp_clear (mp_int * a);
|
||||
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e, mp_int* f);
|
||||
|
||||
int mp_add (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_sub (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_add_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
|
||||
int mp_mul (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
|
||||
int mp_mod(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_invmod(mp_int *a, mp_int *b, mp_int *c);
|
||||
int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y);
|
||||
|
||||
int mp_cmp(mp_int *a, mp_int *b);
|
||||
int mp_cmp_d(mp_int *a, mp_digit b);
|
||||
|
||||
int mp_unsigned_bin_size(mp_int * a);
|
||||
int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
|
||||
int mp_to_unsigned_bin (mp_int * a, unsigned char *b);
|
||||
|
||||
int mp_sub_d(fp_int *a, fp_digit b, fp_int *c);
|
||||
int mp_copy(fp_int* a, fp_int* b);
|
||||
int mp_isodd(mp_int* a);
|
||||
int mp_iszero(mp_int* a);
|
||||
int mp_count_bits(mp_int *a);
|
||||
int mp_set_int(fp_int *a, fp_digit b);
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
int mp_read_radix(mp_int* a, const char* str, int radix);
|
||||
int mp_set(fp_int *a, fp_digit b);
|
||||
int mp_sqr(fp_int *A, fp_int *B);
|
||||
int mp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp);
|
||||
int mp_montgomery_setup(fp_int *a, fp_digit *rho);
|
||||
int mp_div_2(fp_int * a, fp_int * b);
|
||||
int mp_init_copy(fp_int * a, fp_int * b);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ECC) || defined(CYASSL_KEY_GEN)
|
||||
int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c);
|
||||
int mp_montgomery_calc_normalization(mp_int *a, mp_int *b);
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_KEY_GEN
|
||||
int mp_gcd(fp_int *a, fp_int *b, fp_int *c);
|
||||
int mp_lcm(fp_int *a, fp_int *b, fp_int *c);
|
||||
int mp_prime_is_prime(mp_int* a, int t, int* result);
|
||||
#endif /* CYASSL_KEY_GEN */
|
||||
|
||||
CYASSL_API word32 CheckRunTimeFastMath(void);
|
||||
|
||||
/* If user uses RSA, DH, DSA, or ECC math lib directly then fast math FP_SIZE
|
||||
must match, return 1 if a match otherwise 0 */
|
||||
#define CheckFastMathSettings() (FP_SIZE == CheckRunTimeFastMath())
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_TFM_H */
|
263
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/types.h
Normal file
263
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/types.h
Normal file
|
@ -0,0 +1,263 @@
|
|||
/* types.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_TYPES_H
|
||||
#define CTAO_CRYPT_TYPES_H
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WORDS_BIGENDIAN) || (defined(__MWERKS__) && !defined(__INTEL__))
|
||||
#define BIG_ENDIAN_ORDER
|
||||
#endif
|
||||
|
||||
#ifndef BIG_ENDIAN_ORDER
|
||||
#define LITTLE_ENDIAN_ORDER
|
||||
#endif
|
||||
|
||||
#ifndef CYASSL_TYPES
|
||||
#ifndef byte
|
||||
typedef unsigned char byte;
|
||||
#endif
|
||||
typedef unsigned short word16;
|
||||
typedef unsigned int word32;
|
||||
#endif
|
||||
|
||||
|
||||
/* try to set SIZEOF_LONG or LONG_LONG if user didn't */
|
||||
#if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__)
|
||||
#if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG)
|
||||
#if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \
|
||||
|| defined(__mips64) || defined(__x86_64__))
|
||||
/* long should be 64bit */
|
||||
#define SIZEOF_LONG 8
|
||||
#elif (defined__i386__)
|
||||
/* long long should be 64bit */
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##ui64
|
||||
typedef unsigned __int64 word64;
|
||||
#elif SIZEOF_LONG == 8
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##LL
|
||||
typedef unsigned long word64;
|
||||
#elif SIZEOF_LONG_LONG == 8
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##LL
|
||||
typedef unsigned long long word64;
|
||||
#else
|
||||
#define MP_16BIT /* for mp_int, mp_word needs to be twice as big as
|
||||
mp_digit, no 64 bit type so make mp_digit 16 bit */
|
||||
#endif
|
||||
|
||||
|
||||
/* These platforms have 64-bit CPU registers. */
|
||||
#if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
|
||||
defined(__mips64) || defined(__x86_64__))
|
||||
typedef word64 word;
|
||||
#else
|
||||
typedef word32 word;
|
||||
#ifdef WORD64_AVAILABLE
|
||||
#define CTAOCRYPT_SLOW_WORD64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
WORD_SIZE = sizeof(word),
|
||||
BIT_SIZE = 8,
|
||||
WORD_BITS = WORD_SIZE * BIT_SIZE
|
||||
};
|
||||
|
||||
|
||||
/* use inlining if compiler allows */
|
||||
#ifndef INLINE
|
||||
#ifndef NO_INLINE
|
||||
#ifdef _MSC_VER
|
||||
#define INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
#define INLINE inline
|
||||
#elif defined(THREADX)
|
||||
#define INLINE _Inline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* set up rotate style */
|
||||
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
|
||||
#define INTEL_INTRINSICS
|
||||
#define FAST_ROTATE
|
||||
#elif defined(__MWERKS__) && TARGET_CPU_PPC
|
||||
#define PPC_INTRINSICS
|
||||
#define FAST_ROTATE
|
||||
#elif defined(__GNUC__) && defined(__i386__)
|
||||
/* GCC does peephole optimizations which should result in using rotate
|
||||
instructions */
|
||||
#define FAST_ROTATE
|
||||
#endif
|
||||
|
||||
|
||||
/* Micrium will use Visual Studio for compilation but not the Win32 API */
|
||||
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS)
|
||||
#define USE_WINDOWS_API
|
||||
#endif
|
||||
|
||||
|
||||
/* idea to add global alloc override by Moisés Guimarães */
|
||||
/* default to libc stuff */
|
||||
/* XREALLOC is used once in normal math lib, not in fast math lib */
|
||||
/* XFREE on some embeded systems doesn't like free(0) so test */
|
||||
#ifdef XMALLOC_USER
|
||||
/* prototypes for user heap override functions */
|
||||
#include <stddef.h> /* for size_t */
|
||||
extern void *XMALLOC(size_t n, void* heap, int type);
|
||||
extern void *XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
extern void XFREE(void *p, void* heap, int type);
|
||||
#elif !defined(MICRIUM_MALLOC)
|
||||
/* default C runtime, can install different routines at runtime */
|
||||
#include <cyassl/ctaocrypt/memory.h>
|
||||
#define XMALLOC(s, h, t) CyaSSL_Malloc((s))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) CyaSSL_Free((xp));}
|
||||
#define XREALLOC(p, n, h, t) CyaSSL_Realloc((p), (n))
|
||||
#endif
|
||||
|
||||
#ifndef STRING_USER
|
||||
#include <string.h>
|
||||
char* mystrnstr(const char* s1, const char* s2, unsigned int n);
|
||||
|
||||
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
|
||||
#define XMEMSET(b,c,l) memset((b),(c),(l))
|
||||
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
|
||||
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
|
||||
|
||||
#define XSTRLEN(s1) strlen((s1))
|
||||
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
||||
/* strstr, strncmp, and strncat only used by CyaSSL proper, not required for
|
||||
CTaoCrypt only */
|
||||
#define XSTRSTR(s1,s2) strstr((s1),(s2))
|
||||
#define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
|
||||
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
|
||||
#define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
#ifndef CTYPE_USER
|
||||
#include <ctype.h>
|
||||
#define XTOUPPER(c) toupper((c))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* memory allocation types for user hints */
|
||||
enum {
|
||||
DYNAMIC_TYPE_CA = 1,
|
||||
DYNAMIC_TYPE_CERT = 2,
|
||||
DYNAMIC_TYPE_KEY = 3,
|
||||
DYNAMIC_TYPE_FILE = 4,
|
||||
DYNAMIC_TYPE_SUBJECT_CN = 5,
|
||||
DYNAMIC_TYPE_PUBLIC_KEY = 6,
|
||||
DYNAMIC_TYPE_SIGNER = 7,
|
||||
DYNAMIC_TYPE_NONE = 8,
|
||||
DYNAMIC_TYPE_BIGINT = 9,
|
||||
DYNAMIC_TYPE_RSA = 10,
|
||||
DYNAMIC_TYPE_METHOD = 11,
|
||||
DYNAMIC_TYPE_OUT_BUFFER = 12,
|
||||
DYNAMIC_TYPE_IN_BUFFER = 13,
|
||||
DYNAMIC_TYPE_INFO = 14,
|
||||
DYNAMIC_TYPE_DH = 15,
|
||||
DYNAMIC_TYPE_DOMAIN = 16,
|
||||
DYNAMIC_TYPE_SSL = 17,
|
||||
DYNAMIC_TYPE_CTX = 18,
|
||||
DYNAMIC_TYPE_WRITEV = 19,
|
||||
DYNAMIC_TYPE_OPENSSL = 20,
|
||||
DYNAMIC_TYPE_DSA = 21,
|
||||
DYNAMIC_TYPE_CRL = 22,
|
||||
DYNAMIC_TYPE_REVOKED = 23,
|
||||
DYNAMIC_TYPE_CRL_ENTRY = 24,
|
||||
DYNAMIC_TYPE_CERT_MANAGER = 25,
|
||||
DYNAMIC_TYPE_CRL_MONITOR = 26,
|
||||
DYNAMIC_TYPE_OCSP_STATUS = 27,
|
||||
DYNAMIC_TYPE_OCSP_ENTRY = 28,
|
||||
DYNAMIC_TYPE_ALTNAME = 29
|
||||
};
|
||||
|
||||
/* stack protection */
|
||||
enum {
|
||||
MIN_STACK_BUFFER = 8
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* settings detection for compile vs runtime math incombatibilities */
|
||||
enum {
|
||||
#if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x0
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
||||
CTC_SETTINGS = 0x1
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
|
||||
CTC_SETTINGS = 0x2
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
|
||||
CTC_SETTINGS = 0x4
|
||||
#elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x8
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
||||
CTC_SETTINGS = 0x10
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
|
||||
CTC_SETTINGS = 0x20
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
|
||||
CTC_SETTINGS = 0x40
|
||||
#else
|
||||
#error "bad math long / long long settings"
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API word32 CheckRunTimeSettings(void);
|
||||
|
||||
/* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long
|
||||
types need to match at compile time and run time, CheckCtcSettings will
|
||||
return 1 if a match otherwise 0 */
|
||||
#define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_TYPES_H */
|
||||
|
69
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/visibility.h
Normal file
69
FreeRTOS-Plus/Source/CyaSSL/cyassl/ctaocrypt/visibility.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* visibility.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/* Visibility control macros */
|
||||
|
||||
|
||||
#ifndef CTAO_CRYPT_VISIBILITY_H
|
||||
#define CTAO_CRYPT_VISIBILITY_H
|
||||
|
||||
|
||||
/* CYASSL_API is used for the public API symbols.
|
||||
It either imports or exports (or does nothing for static builds)
|
||||
|
||||
CYASSL_LOCAL is used for non-API symbols (private).
|
||||
*/
|
||||
|
||||
#if defined(BUILDING_CYASSL)
|
||||
#if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
|
||||
#define CYASSL_API __attribute__ ((visibility("default")))
|
||||
#define CYASSL_LOCAL __attribute__ ((visibility("hidden")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||
#define CYASSL_API __global
|
||||
#define CYASSL_LOCAL __hidden
|
||||
#elif defined(_MSC_VER)
|
||||
#ifdef CYASSL_DLL
|
||||
#define CYASSL_API extern __declspec(dllexport)
|
||||
#else
|
||||
#define CYASSL_API
|
||||
#endif
|
||||
#define CYASSL_LOCAL
|
||||
#else
|
||||
#define CYASSL_API
|
||||
#define CYASSL_LOCAL
|
||||
#endif /* HAVE_VISIBILITY */
|
||||
#else /* BUILDING_CYASSL */
|
||||
#if defined(_MSC_VER)
|
||||
#ifdef CYASSL_DLL
|
||||
#define CYASSL_API extern __declspec(dllimport)
|
||||
#else
|
||||
#define CYASSL_API
|
||||
#endif
|
||||
#define CYASSL_LOCAL
|
||||
#else
|
||||
#define CYASSL_API
|
||||
#define CYASSL_LOCAL
|
||||
#endif
|
||||
#endif /* BUILDING_CYASSL */
|
||||
|
||||
|
||||
#endif /* CTAO_CRYPT_VISIBILITY_H */
|
||||
|
133
FreeRTOS-Plus/Source/CyaSSL/cyassl/error.h
Normal file
133
FreeRTOS-Plus/Source/CyaSSL/cyassl/error.h
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* error.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_ERROR_H
|
||||
#define CYASSL_ERROR_H
|
||||
|
||||
#include <cyassl/ctaocrypt/error.h> /* pull in CTaoCrypt errors */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum CyaSSL_ErrorCodes {
|
||||
INPUT_CASE_ERROR = -201, /* process input state error */
|
||||
PREFIX_ERROR = -202, /* bad index to key rounds */
|
||||
MEMORY_ERROR = -203, /* out of memory */
|
||||
VERIFY_FINISHED_ERROR = -204, /* verify problem on finished */
|
||||
VERIFY_MAC_ERROR = -205, /* verify mac problem */
|
||||
PARSE_ERROR = -206, /* parse error on header */
|
||||
UNKNOWN_HANDSHAKE_TYPE = -207, /* weird handshake type */
|
||||
SOCKET_ERROR_E = -208, /* error state on socket */
|
||||
SOCKET_NODATA = -209, /* expected data, not there */
|
||||
INCOMPLETE_DATA = -210, /* don't have enough data to
|
||||
complete task */
|
||||
UNKNOWN_RECORD_TYPE = -211, /* unknown type in record hdr */
|
||||
DECRYPT_ERROR = -212, /* error during decryption */
|
||||
FATAL_ERROR = -213, /* recvd alert fatal error */
|
||||
ENCRYPT_ERROR = -214, /* error during encryption */
|
||||
FREAD_ERROR = -215, /* fread problem */
|
||||
NO_PEER_KEY = -216, /* need peer's key */
|
||||
NO_PRIVATE_KEY = -217, /* need the private key */
|
||||
RSA_PRIVATE_ERROR = -218, /* error during rsa priv op */
|
||||
NO_DH_PARAMS = -219, /* server missing DH params */
|
||||
BUILD_MSG_ERROR = -220, /* build message failure */
|
||||
|
||||
BAD_HELLO = -221, /* client hello malformed */
|
||||
DOMAIN_NAME_MISMATCH = -222, /* peer subject name mismatch */
|
||||
WANT_READ = -223, /* want read, call again */
|
||||
NOT_READY_ERROR = -224, /* handshake layer not ready */
|
||||
PMS_VERSION_ERROR = -225, /* pre m secret version error */
|
||||
VERSION_ERROR = -226, /* record layer version error */
|
||||
WANT_WRITE = -227, /* want write, call again */
|
||||
BUFFER_ERROR = -228, /* malformed buffer input */
|
||||
VERIFY_CERT_ERROR = -229, /* verify cert error */
|
||||
VERIFY_SIGN_ERROR = -230, /* verify sign error */
|
||||
CLIENT_ID_ERROR = -231, /* psk client identity error */
|
||||
SERVER_HINT_ERROR = -232, /* psk server hint error */
|
||||
PSK_KEY_ERROR = -233, /* psk key error */
|
||||
ZLIB_INIT_ERROR = -234, /* zlib init error */
|
||||
ZLIB_COMPRESS_ERROR = -235, /* zlib compression error */
|
||||
ZLIB_DECOMPRESS_ERROR = -236, /* zlib decompression error */
|
||||
|
||||
GETTIME_ERROR = -237, /* gettimeofday failed ??? */
|
||||
GETITIMER_ERROR = -238, /* getitimer failed ??? */
|
||||
SIGACT_ERROR = -239, /* sigaction failed ??? */
|
||||
SETITIMER_ERROR = -240, /* setitimer failed ??? */
|
||||
LENGTH_ERROR = -241, /* record layer length error */
|
||||
PEER_KEY_ERROR = -242, /* can't decode peer key */
|
||||
ZERO_RETURN = -243, /* peer sent close notify */
|
||||
SIDE_ERROR = -244, /* wrong client/server type */
|
||||
NO_PEER_CERT = -245, /* peer didn't send key */
|
||||
NTRU_KEY_ERROR = -246, /* NTRU key error */
|
||||
NTRU_DRBG_ERROR = -247, /* NTRU drbg error */
|
||||
NTRU_ENCRYPT_ERROR = -248, /* NTRU encrypt error */
|
||||
NTRU_DECRYPT_ERROR = -249, /* NTRU decrypt error */
|
||||
ECC_CURVETYPE_ERROR = -250, /* Bad ECC Curve Type */
|
||||
ECC_CURVE_ERROR = -251, /* Bad ECC Curve */
|
||||
ECC_PEERKEY_ERROR = -252, /* Bad Peer ECC Key */
|
||||
ECC_MAKEKEY_ERROR = -253, /* Bad Make ECC Key */
|
||||
ECC_EXPORT_ERROR = -254, /* Bad ECC Export Key */
|
||||
ECC_SHARED_ERROR = -255, /* Bad ECC Shared Secret */
|
||||
BAD_MUTEX_ERROR = -256, /* Bad mutex */
|
||||
NOT_CA_ERROR = -257, /* Not a CA cert error */
|
||||
BAD_PATH_ERROR = -258, /* Bad path for opendir */
|
||||
BAD_CERT_MANAGER_ERROR = -259, /* Bad Cert Manager */
|
||||
OCSP_CERT_REVOKED = -260, /* OCSP Certificate revoked */
|
||||
CRL_CERT_REVOKED = -261, /* CRL Certificate revoked */
|
||||
CRL_MISSING = -262, /* CRL Not loaded */
|
||||
MONITOR_RUNNING_E = -263, /* CRL Monitor already running */
|
||||
THREAD_CREATE_E = -264, /* Thread Create Error */
|
||||
OCSP_NEED_URL = -265, /* OCSP need an URL for lookup */
|
||||
OCSP_CERT_UNKNOWN = -266, /* OCSP responder doesn't know */
|
||||
OCSP_LOOKUP_FAIL = -267, /* OCSP lookup not successful */
|
||||
MAX_CHAIN_ERROR = -268, /* max chain depth exceeded */
|
||||
COOKIE_ERROR = -269, /* dtls cookie error */
|
||||
/* add strings to SetErrorString !!!!! */
|
||||
|
||||
/* begin negotiation parameter errors */
|
||||
UNSUPPORTED_SUITE = -290, /* unsupported cipher suite */
|
||||
MATCH_SUITE_ERROR = -291 /* can't match cipher suite */
|
||||
/* end negotiation parameter errors only 10 for now */
|
||||
/* add strings to SetErrorString !!!!! */
|
||||
};
|
||||
|
||||
|
||||
#ifdef CYASSL_CALLBACKS
|
||||
enum {
|
||||
MIN_PARAM_ERR = UNSUPPORTED_SUITE,
|
||||
MAX_PARAM_ERR = MIN_PARAM_ERR - 10
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_LOCAL
|
||||
void SetErrorString(int error, char* buffer);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CyaSSL_ERROR_H */
|
||||
|
20
FreeRTOS-Plus/Source/CyaSSL/cyassl/include.am
Normal file
20
FreeRTOS-Plus/Source/CyaSSL/cyassl/include.am
Normal file
|
@ -0,0 +1,20 @@
|
|||
# vim:ft=automake
|
||||
# All paths should be given relative to the root
|
||||
#
|
||||
|
||||
include cyassl/ctaocrypt/include.am
|
||||
include cyassl/openssl/include.am
|
||||
|
||||
EXTRA_DIST+= cyassl/sniffer_error.rc
|
||||
|
||||
nobase_include_HEADERS+= \
|
||||
cyassl/error.h \
|
||||
cyassl/internal.h \
|
||||
cyassl/ssl.h \
|
||||
cyassl/sniffer_error.h \
|
||||
cyassl/sniffer.h \
|
||||
cyassl/callbacks.h \
|
||||
cyassl/test.h \
|
||||
cyassl/version.h \
|
||||
cyassl/ocsp.h \
|
||||
cyassl/crl.h
|
1466
FreeRTOS-Plus/Source/CyaSSL/cyassl/internal.h
Normal file
1466
FreeRTOS-Plus/Source/CyaSSL/cyassl/internal.h
Normal file
File diff suppressed because it is too large
Load diff
52
FreeRTOS-Plus/Source/CyaSSL/cyassl/ocsp.h
Normal file
52
FreeRTOS-Plus/Source/CyaSSL/cyassl/ocsp.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* ssl.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* CyaSSL OCSP API */
|
||||
|
||||
#ifndef CYASSL_OCSP_H
|
||||
#define CYASSL_OCSP_H
|
||||
|
||||
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/ctaocrypt/asn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CYASSL_OCSP CYASSL_OCSP;
|
||||
|
||||
CYASSL_LOCAL int CyaSSL_OCSP_Init(CYASSL_OCSP*);
|
||||
CYASSL_LOCAL void CyaSSL_OCSP_Cleanup(CYASSL_OCSP*);
|
||||
|
||||
CYASSL_LOCAL int CyaSSL_OCSP_set_override_url(CYASSL_OCSP*, const char*);
|
||||
CYASSL_LOCAL int CyaSSL_OCSP_Lookup_Cert(CYASSL_OCSP*, DecodedCert*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_OCSP_H */
|
||||
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/asn1.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/asn1.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* asn1.h for openssl */
|
||||
|
23
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/bio.h
Normal file
23
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/bio.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* bio.h for openssl */
|
||||
|
||||
|
||||
#ifndef CYASSL_BIO_H_
|
||||
#define CYASSL_BIO_H_
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_BIO_H_ */
|
||||
|
115
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/bn.h
Normal file
115
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/bn.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* bn.h for openssl */
|
||||
|
||||
|
||||
#ifndef CYASSL_BN_H_
|
||||
#define CYASSL_BN_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CYASSL_BIGNUM {
|
||||
int neg; /* openssh deference */
|
||||
void* internal; /* our big num */
|
||||
} CYASSL_BIGNUM;
|
||||
|
||||
|
||||
typedef struct CYASSL_BN_CTX CYASSL_BN_CTX;
|
||||
|
||||
|
||||
CYASSL_API CYASSL_BN_CTX* CyaSSL_BN_CTX_new(void);
|
||||
CYASSL_API void CyaSSL_BN_CTX_init(CYASSL_BN_CTX*);
|
||||
CYASSL_API void CyaSSL_BN_CTX_free(CYASSL_BN_CTX*);
|
||||
|
||||
CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_new(void);
|
||||
CYASSL_API void CyaSSL_BN_free(CYASSL_BIGNUM*);
|
||||
CYASSL_API void CyaSSL_BN_clear_free(CYASSL_BIGNUM*);
|
||||
|
||||
|
||||
CYASSL_API int CyaSSL_BN_sub(CYASSL_BIGNUM*, const CYASSL_BIGNUM*,
|
||||
const CYASSL_BIGNUM*);
|
||||
CYASSL_API int CyaSSL_BN_mod(CYASSL_BIGNUM*, const CYASSL_BIGNUM*,
|
||||
const CYASSL_BIGNUM*, const CYASSL_BN_CTX*);
|
||||
|
||||
CYASSL_API const CYASSL_BIGNUM* CyaSSL_BN_value_one(void);
|
||||
|
||||
|
||||
CYASSL_API int CyaSSL_BN_num_bytes(const CYASSL_BIGNUM*);
|
||||
CYASSL_API int CyaSSL_BN_num_bits(const CYASSL_BIGNUM*);
|
||||
|
||||
CYASSL_API int CyaSSL_BN_is_zero(const CYASSL_BIGNUM*);
|
||||
CYASSL_API int CyaSSL_BN_is_one(const CYASSL_BIGNUM*);
|
||||
CYASSL_API int CyaSSL_BN_is_odd(const CYASSL_BIGNUM*);
|
||||
|
||||
CYASSL_API int CyaSSL_BN_cmp(const CYASSL_BIGNUM*, const CYASSL_BIGNUM*);
|
||||
|
||||
CYASSL_API int CyaSSL_BN_bn2bin(const CYASSL_BIGNUM*, unsigned char*);
|
||||
CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_bin2bn(const unsigned char*, int len,
|
||||
CYASSL_BIGNUM* ret);
|
||||
|
||||
CYASSL_API int CyaSSL_mask_bits(CYASSL_BIGNUM*, int n);
|
||||
|
||||
CYASSL_API int CyaSSL_BN_rand(CYASSL_BIGNUM*, int bits, int top, int bottom);
|
||||
CYASSL_API int CyaSSL_BN_is_bit_set(const CYASSL_BIGNUM*, int n);
|
||||
CYASSL_API int CyaSSL_BN_hex2bn(CYASSL_BIGNUM**, const char* str);
|
||||
|
||||
CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_dup(const CYASSL_BIGNUM*);
|
||||
CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_copy(CYASSL_BIGNUM*, const CYASSL_BIGNUM*);
|
||||
|
||||
CYASSL_API int CyaSSL_BN_set_word(CYASSL_BIGNUM*, unsigned long w);
|
||||
|
||||
CYASSL_API int CyaSSL_BN_dec2bn(CYASSL_BIGNUM**, const char* str);
|
||||
CYASSL_API char* CyaSSL_BN_bn2dec(const CYASSL_BIGNUM*);
|
||||
|
||||
|
||||
typedef CYASSL_BIGNUM BIGNUM;
|
||||
typedef CYASSL_BN_CTX BN_CTX;
|
||||
|
||||
#define BN_CTX_new CyaSSL_BN_CTX_new
|
||||
#define BN_CTX_init CyaSSL_BN_CTX_init
|
||||
#define BN_CTX_free CyaSSL_BN_CTX_free
|
||||
|
||||
#define BN_new CyaSSL_BN_new
|
||||
#define BN_free CyaSSL_BN_free
|
||||
#define BN_clear_free CyaSSL_BN_clear_free
|
||||
|
||||
#define BN_num_bytes CyaSSL_BN_num_bytes
|
||||
#define BN_num_bits CyaSSL_BN_num_bits
|
||||
|
||||
#define BN_is_zero CyaSSL_BN_is_zero
|
||||
#define BN_is_one CyaSSL_BN_is_one
|
||||
#define BN_is_odd CyaSSL_BN_is_odd
|
||||
|
||||
#define BN_cmp CyaSSL_BN_cmp
|
||||
|
||||
#define BN_bn2bin CyaSSL_BN_bn2bin
|
||||
#define BN_bin2bn CyaSSL_BN_bin2bn
|
||||
|
||||
#define BN_mod CyaSSL_BN_mod
|
||||
#define BN_sub CyaSSL_BN_sub
|
||||
#define BN_value_one CyaSSL_BN_value_one
|
||||
|
||||
#define BN_mask_bits CyaSSL_mask_bits
|
||||
|
||||
#define BN_rand CyaSSL_BN_rand
|
||||
#define BN_is_bit_set CyaSSL_BN_is_bit_set
|
||||
#define BN_hex2bn CyaSSL_BN_hex2bn
|
||||
|
||||
#define BN_dup CyaSSL_BN_dup
|
||||
#define BN_copy CyaSSL_BN_copy
|
||||
|
||||
#define BN_set_word CyaSSL_BN_set_word
|
||||
|
||||
#define BN_dec2bn CyaSSL_BN_dec2bn
|
||||
#define BN_bn2dec CyaSSL_BN_bn2dec
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL__H_ */
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/conf.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/conf.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* conf.h for openssl */
|
||||
|
26
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/crypto.h
Normal file
26
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/crypto.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* crypto.h for openSSL */
|
||||
|
||||
#ifndef CYASSL_CRYPTO_H_
|
||||
#define CYASSL_CRYPTO_H_
|
||||
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_crypto.h"
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_API const char* CyaSSLeay_version(int type);
|
||||
CYASSL_API unsigned long CyaSSLeay(void);
|
||||
|
||||
#define SSLeay_version CyaSSLeay_version
|
||||
#define SSLeay CyaSSLeay
|
||||
|
||||
|
||||
#define SSLEAY_VERSION 0x0090600fL
|
||||
#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION
|
||||
|
||||
|
||||
#endif /* header */
|
||||
|
87
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/des.h
Normal file
87
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/des.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* des.h
|
||||
*
|
||||
* Copyright (C) 2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* des.h defines mini des openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_DES_H_
|
||||
#define CYASSL_DES_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_des.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char CYASSL_DES_cblock[8];
|
||||
typedef /* const */ CYASSL_DES_cblock CYASSL_const_DES_cblock;
|
||||
typedef CYASSL_DES_cblock CYASSL_DES_key_schedule;
|
||||
|
||||
|
||||
enum {
|
||||
DES_ENCRYPT = 1,
|
||||
DES_DECRYPT = 0
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API void CyaSSL_DES_set_key_unchecked(CYASSL_const_DES_cblock*,
|
||||
CYASSL_DES_key_schedule*);
|
||||
CYASSL_API int CyaSSL_DES_key_sched(CYASSL_const_DES_cblock* key,
|
||||
CYASSL_DES_key_schedule* schedule);
|
||||
CYASSL_API void CyaSSL_DES_cbc_encrypt(const unsigned char* input,
|
||||
unsigned char* output, long length,
|
||||
CYASSL_DES_key_schedule* schedule, CYASSL_DES_cblock* ivec,
|
||||
int enc);
|
||||
CYASSL_API void CyaSSL_DES_ncbc_encrypt(const unsigned char* input,
|
||||
unsigned char* output, long length,
|
||||
CYASSL_DES_key_schedule* schedule,
|
||||
CYASSL_DES_cblock* ivec, int enc);
|
||||
|
||||
CYASSL_API void CyaSSL_DES_set_odd_parity(CYASSL_DES_cblock*);
|
||||
CYASSL_API void CyaSSL_DES_ecb_encrypt(CYASSL_DES_cblock*, CYASSL_DES_cblock*,
|
||||
CYASSL_DES_key_schedule*, int);
|
||||
|
||||
|
||||
typedef CYASSL_DES_cblock DES_cblock;
|
||||
typedef CYASSL_const_DES_cblock const_DES_cblock;
|
||||
typedef CYASSL_DES_key_schedule DES_key_schedule;
|
||||
|
||||
#define DES_set_key_unchecked CyaSSL_DES_set_key_unchecked
|
||||
#define DES_key_sched CyaSSL_DES_key_sched
|
||||
#define DES_cbc_encrypt CyaSSL_DES_cbc_encrypt
|
||||
#define DES_ncbc_encrypt CyaSSL_DES_ncbc_encrypt
|
||||
#define DES_set_odd_parity CyaSSL_DES_set_odd_parity
|
||||
#define DES_ecb_encrypt CyaSSL_DES_ecb_encrypt
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_DES_H_ */
|
52
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/dh.h
Normal file
52
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/dh.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* dh.h for openSSL */
|
||||
|
||||
|
||||
#ifndef CYASSL_DH_H_
|
||||
#define CYASSL_DH_H_
|
||||
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
#include <cyassl/openssl/bn.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct CYASSL_DH {
|
||||
CYASSL_BIGNUM* p;
|
||||
CYASSL_BIGNUM* g;
|
||||
CYASSL_BIGNUM* pub_key; /* openssh deference g^x */
|
||||
CYASSL_BIGNUM* priv_key; /* openssh deference x */
|
||||
void* internal; /* our DH */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
} CYASSL_DH;
|
||||
|
||||
|
||||
CYASSL_API CYASSL_DH* CyaSSL_DH_new(void);
|
||||
CYASSL_API void CyaSSL_DH_free(CYASSL_DH*);
|
||||
|
||||
CYASSL_API int CyaSSL_DH_size(CYASSL_DH*);
|
||||
CYASSL_API int CyaSSL_DH_generate_key(CYASSL_DH*);
|
||||
CYASSL_API int CyaSSL_DH_compute_key(unsigned char* key, CYASSL_BIGNUM* pub,
|
||||
CYASSL_DH*);
|
||||
|
||||
typedef CYASSL_DH DH;
|
||||
|
||||
#define DH_new CyaSSL_DH_new
|
||||
#define DH_free CyaSSL_DH_free
|
||||
|
||||
#define DH_size CyaSSL_DH_size
|
||||
#define DH_generate_key CyaSSL_DH_generate_key
|
||||
#define DH_compute_key CyaSSL_DH_compute_key
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* header */
|
53
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/dsa.h
Normal file
53
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/dsa.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* dsa.h for openSSL */
|
||||
|
||||
|
||||
#ifndef CYASSL_DSA_H_
|
||||
#define CYASSL_DSA_H_
|
||||
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
#include <cyassl/openssl/bn.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
struct CYASSL_DSA {
|
||||
CYASSL_BIGNUM* p;
|
||||
CYASSL_BIGNUM* q;
|
||||
CYASSL_BIGNUM* g;
|
||||
CYASSL_BIGNUM* pub_key; /* our y */
|
||||
CYASSL_BIGNUM* priv_key; /* our x */
|
||||
void* internal; /* our Dsa Key */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API CYASSL_DSA* CyaSSL_DSA_new(void);
|
||||
CYASSL_API void CyaSSL_DSA_free(CYASSL_DSA*);
|
||||
|
||||
CYASSL_API int CyaSSL_DSA_generate_key(CYASSL_DSA*);
|
||||
CYASSL_API int CyaSSL_DSA_generate_parameters_ex(CYASSL_DSA*, int bits,
|
||||
unsigned char* seed, int seedLen, int* counterRet,
|
||||
unsigned long* hRet, void* cb);
|
||||
|
||||
CYASSL_API int CyaSSL_DSA_LoadDer(CYASSL_DSA*, const unsigned char*, int sz);
|
||||
CYASSL_API int CyaSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet,
|
||||
CYASSL_DSA* dsa);
|
||||
|
||||
#define DSA_new CyaSSL_DSA_new
|
||||
#define DSA_free CyaSSL_DSA_free
|
||||
|
||||
#define DSA_generate_key CyaSSL_DSA_generate_key
|
||||
#define DSA_generate_parameters_ex CyaSSL_DSA_generate_parameters_ex
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* header */
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ec.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ec.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* ec.h for openssl */
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ecdsa.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ecdsa.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* ecdsa.h for openssl */
|
||||
|
5
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/engine.h
Normal file
5
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/engine.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
/* engine.h for libcurl */
|
||||
|
||||
#undef HAVE_OPENSSL_ENGINE_H
|
||||
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/err.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/err.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* err.h for openssl */
|
||||
|
239
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/evp.h
Normal file
239
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/evp.h
Normal file
|
@ -0,0 +1,239 @@
|
|||
/* evp.h
|
||||
*
|
||||
* Copyright (C) 2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* evp.h defines mini evp openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_EVP_H_
|
||||
#define CYASSL_EVP_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_evp.h"
|
||||
#endif
|
||||
|
||||
#include <cyassl/openssl/md5.h>
|
||||
#include <cyassl/openssl/sha.h>
|
||||
#include <cyassl/openssl/ripemd.h>
|
||||
#include <cyassl/openssl/rsa.h>
|
||||
#include <cyassl/openssl/dsa.h>
|
||||
|
||||
#include <cyassl/ctaocrypt/aes.h>
|
||||
#include <cyassl/ctaocrypt/des3.h>
|
||||
#include <cyassl/ctaocrypt/arc4.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef char CYASSL_EVP_MD;
|
||||
typedef char CYASSL_EVP_CIPHER;
|
||||
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_md5(void);
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_sha1(void);
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_sha256(void);
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_sha384(void);
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_sha512(void);
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_ripemd160(void);
|
||||
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_128_cbc(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_192_cbc(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_256_cbc(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_128_ctr(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_192_ctr(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_256_ctr(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_des_cbc(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_des_ede3_cbc(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_rc4(void);
|
||||
CYASSL_API const CYASSL_EVP_CIPHER* CyaSSL_EVP_enc_null(void);
|
||||
|
||||
|
||||
typedef union {
|
||||
CYASSL_MD5_CTX md5;
|
||||
CYASSL_SHA_CTX sha;
|
||||
CYASSL_SHA256_CTX sha256;
|
||||
#ifdef CYASSL_SHA384
|
||||
CYASSL_SHA384_CTX sha384;
|
||||
#endif
|
||||
#ifdef CYASSL_SHA512
|
||||
CYASSL_SHA512_CTX sha512;
|
||||
#endif
|
||||
#ifdef CYASSL_RIPEMD
|
||||
CYASSL_RIPEMD_CTX ripemd;
|
||||
#endif
|
||||
} CYASSL_Hasher;
|
||||
|
||||
|
||||
typedef struct CYASSL_EVP_MD_CTX {
|
||||
unsigned char macType;
|
||||
CYASSL_Hasher hash;
|
||||
} CYASSL_EVP_MD_CTX;
|
||||
|
||||
|
||||
typedef union {
|
||||
Aes aes;
|
||||
Des des;
|
||||
Des3 des3;
|
||||
Arc4 arc4;
|
||||
} CYASSL_Cipher;
|
||||
|
||||
|
||||
enum {
|
||||
AES_128_CBC_TYPE = 1,
|
||||
AES_192_CBC_TYPE = 2,
|
||||
AES_256_CBC_TYPE = 3,
|
||||
AES_128_CTR_TYPE = 4,
|
||||
AES_192_CTR_TYPE = 5,
|
||||
AES_256_CTR_TYPE = 6,
|
||||
DES_CBC_TYPE = 7,
|
||||
DES_EDE3_CBC_TYPE = 8,
|
||||
ARC4_TYPE = 9,
|
||||
NULL_CIPHER_TYPE = 10,
|
||||
EVP_PKEY_RSA = 11,
|
||||
EVP_PKEY_DSA = 12,
|
||||
NID_sha1 = 64,
|
||||
NID_md5 = 4
|
||||
};
|
||||
|
||||
|
||||
typedef struct CYASSL_EVP_CIPHER_CTX {
|
||||
int keyLen; /* user may set for variable */
|
||||
unsigned char enc; /* if encrypt side, then true */
|
||||
unsigned char cipherType;
|
||||
unsigned char iv[64]; /* working iv pointer into cipher */
|
||||
CYASSL_Cipher cipher;
|
||||
} CYASSL_EVP_CIPHER_CTX;
|
||||
|
||||
|
||||
CYASSL_API int CyaSSL_EVP_MD_size(const CYASSL_EVP_MD* md);
|
||||
CYASSL_API void CyaSSL_EVP_MD_CTX_init(CYASSL_EVP_MD_CTX* ctx);
|
||||
CYASSL_API int CyaSSL_EVP_MD_CTX_cleanup(CYASSL_EVP_MD_CTX* ctx);
|
||||
|
||||
CYASSL_API int CyaSSL_EVP_DigestInit(CYASSL_EVP_MD_CTX* ctx,
|
||||
const CYASSL_EVP_MD* type);
|
||||
CYASSL_API int CyaSSL_EVP_DigestUpdate(CYASSL_EVP_MD_CTX* ctx, const void* data,
|
||||
unsigned long sz);
|
||||
CYASSL_API int CyaSSL_EVP_DigestFinal(CYASSL_EVP_MD_CTX* ctx, unsigned char* md,
|
||||
unsigned int* s);
|
||||
CYASSL_API int CyaSSL_EVP_DigestFinal_ex(CYASSL_EVP_MD_CTX* ctx,
|
||||
unsigned char* md, unsigned int* s);
|
||||
CYASSL_API int CyaSSL_EVP_BytesToKey(const CYASSL_EVP_CIPHER*,
|
||||
const CYASSL_EVP_MD*, const unsigned char*,
|
||||
const unsigned char*, int, int, unsigned char*,
|
||||
unsigned char*);
|
||||
|
||||
CYASSL_API void CyaSSL_EVP_CIPHER_CTX_init(CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
CYASSL_API int CyaSSL_EVP_CIPHER_CTX_cleanup(CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
|
||||
CYASSL_API int CyaSSL_EVP_CIPHER_CTX_iv_length(const CYASSL_EVP_CIPHER_CTX*);
|
||||
|
||||
|
||||
CYASSL_API int CyaSSL_EVP_CipherInit(CYASSL_EVP_CIPHER_CTX* ctx,
|
||||
const CYASSL_EVP_CIPHER* type,
|
||||
unsigned char* key, unsigned char* iv,
|
||||
int enc);
|
||||
CYASSL_API int CyaSSL_EVP_CIPHER_CTX_key_length(CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
CYASSL_API int CyaSSL_EVP_CIPHER_CTX_set_key_length(CYASSL_EVP_CIPHER_CTX* ctx,
|
||||
int keylen);
|
||||
CYASSL_API int CyaSSL_EVP_Cipher(CYASSL_EVP_CIPHER_CTX* ctx,
|
||||
unsigned char* dst, unsigned char* src,
|
||||
unsigned int len);
|
||||
|
||||
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_get_digestbynid(int);
|
||||
|
||||
CYASSL_API CYASSL_RSA* CyaSSL_EVP_PKEY_get1_RSA(CYASSL_EVP_PKEY*);
|
||||
CYASSL_API CYASSL_DSA* CyaSSL_EVP_PKEY_get1_DSA(CYASSL_EVP_PKEY*);
|
||||
|
||||
/* these next ones don't need real OpenSSL type, for OpenSSH compat only */
|
||||
CYASSL_API void* CyaSSL_EVP_X_STATE(const CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
CYASSL_API int CyaSSL_EVP_X_STATE_LEN(const CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
|
||||
CYASSL_API void CyaSSL_3des_iv(CYASSL_EVP_CIPHER_CTX* ctx, int doset,
|
||||
unsigned char* iv, int len);
|
||||
CYASSL_API void CyaSSL_aes_ctr_iv(CYASSL_EVP_CIPHER_CTX* ctx, int doset,
|
||||
unsigned char* iv, int len);
|
||||
|
||||
CYASSL_API int CyaSSL_StoreExternalIV(CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
CYASSL_API int CyaSSL_SetInternalIV(CYASSL_EVP_CIPHER_CTX* ctx);
|
||||
|
||||
|
||||
/* end OpenSSH compat */
|
||||
|
||||
typedef CYASSL_EVP_MD EVP_MD;
|
||||
typedef CYASSL_EVP_CIPHER EVP_CIPHER;
|
||||
typedef CYASSL_EVP_MD_CTX EVP_MD_CTX;
|
||||
typedef CYASSL_EVP_CIPHER_CTX EVP_CIPHER_CTX;
|
||||
|
||||
#define EVP_md5 CyaSSL_EVP_md5
|
||||
#define EVP_sha1 CyaSSL_EVP_sha1
|
||||
#define EVP_sha256 CyaSSL_EVP_sha256
|
||||
#define EVP_sha384 CyaSSL_EVP_sha384
|
||||
#define EVP_sha512 CyaSSL_EVP_sha512
|
||||
#define EVP_ripemd160 CyaSSL_EVP_ripemd160
|
||||
|
||||
#define EVP_aes_128_cbc CyaSSL_EVP_aes_128_cbc
|
||||
#define EVP_aes_192_cbc CyaSSL_EVP_aes_192_cbc
|
||||
#define EVP_aes_256_cbc CyaSSL_EVP_aes_256_cbc
|
||||
#define EVP_aes_128_ctr CyaSSL_EVP_aes_128_ctr
|
||||
#define EVP_aes_192_ctr CyaSSL_EVP_aes_192_ctr
|
||||
#define EVP_aes_256_ctr CyaSSL_EVP_aes_256_ctr
|
||||
#define EVP_des_cbc CyaSSL_EVP_des_cbc
|
||||
#define EVP_des_ede3_cbc CyaSSL_EVP_des_ede3_cbc
|
||||
#define EVP_rc4 CyaSSL_EVP_rc4
|
||||
#define EVP_enc_null CyaSSL_EVP_enc_null
|
||||
|
||||
#define EVP_MD_size CyaSSL_EVP_MD_size
|
||||
#define EVP_MD_CTX_init CyaSSL_EVP_MD_CTX_init
|
||||
#define EVP_MD_CTX_cleanup CyaSSL_EVP_MD_CTX_cleanup
|
||||
#define EVP_DigestInit CyaSSL_EVP_DigestInit
|
||||
#define EVP_DigestUpdate CyaSSL_EVP_DigestUpdate
|
||||
#define EVP_DigestFinal CyaSSL_EVP_DigestFinal
|
||||
#define EVP_DigestFinal_ex CyaSSL_EVP_DigestFinal_ex
|
||||
#define EVP_BytesToKey CyaSSL_EVP_BytesToKey
|
||||
|
||||
#define EVP_CIPHER_CTX_init CyaSSL_EVP_CIPHER_CTX_init
|
||||
#define EVP_CIPHER_CTX_cleanup CyaSSL_EVP_CIPHER_CTX_cleanup
|
||||
#define EVP_CIPHER_CTX_iv_length CyaSSL_EVP_CIPHER_CTX_iv_length
|
||||
#define EVP_CIPHER_CTX_key_length CyaSSL_EVP_CIPHER_CTX_key_length
|
||||
#define EVP_CIPHER_CTX_set_key_length CyaSSL_EVP_CIPHER_CTX_set_key_length
|
||||
#define EVP_CipherInit CyaSSL_EVP_CipherInit
|
||||
#define EVP_Cipher CyaSSL_EVP_Cipher
|
||||
|
||||
#define EVP_get_digestbynid CyaSSL_EVP_get_digestbynid
|
||||
|
||||
#define EVP_PKEY_get1_RSA CyaSSL_EVP_PKEY_get1_RSA
|
||||
#define EVP_PKEY_get1_DSA CyaSSL_EVP_PKEY_get1_DSA
|
||||
|
||||
#ifndef EVP_MAX_MD_SIZE
|
||||
#define EVP_MAX_MD_SIZE 64 /* sha512 */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_EVP_H_ */
|
81
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/hmac.h
Normal file
81
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/hmac.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* hmac.h
|
||||
*
|
||||
* Copyright (C) 2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* hmac.h defines mini hamc openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_HMAC_H_
|
||||
#define CYASSL_HMAC_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_hmac.h"
|
||||
#endif
|
||||
|
||||
#include <cyassl/openssl/evp.h>
|
||||
#include <cyassl/ctaocrypt/hmac.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_API unsigned char* CyaSSL_HMAC(const CYASSL_EVP_MD* evp_md,
|
||||
const void* key, int key_len,
|
||||
const unsigned char* d, int n, unsigned char* md,
|
||||
unsigned int* md_len);
|
||||
|
||||
|
||||
typedef struct CYASSL_HMAC_CTX {
|
||||
Hmac hmac;
|
||||
int type;
|
||||
} CYASSL_HMAC_CTX;
|
||||
|
||||
|
||||
CYASSL_API void CyaSSL_HMAC_Init(CYASSL_HMAC_CTX* ctx, const void* key,
|
||||
int keylen, const EVP_MD* type);
|
||||
CYASSL_API void CyaSSL_HMAC_Update(CYASSL_HMAC_CTX* ctx,
|
||||
const unsigned char* data, int len);
|
||||
CYASSL_API void CyaSSL_HMAC_Final(CYASSL_HMAC_CTX* ctx, unsigned char* hash,
|
||||
unsigned int* len);
|
||||
CYASSL_API void CyaSSL_HMAC_cleanup(CYASSL_HMAC_CTX* ctx);
|
||||
|
||||
|
||||
typedef struct CYASSL_HMAC_CTX HMAC_CTX;
|
||||
|
||||
#define HMAC(a,b,c,d,e,f,g) CyaSSL_HMAC((a),(b),(c),(d),(e),(f),(g))
|
||||
|
||||
#define HMAC_Init CyaSSL_HMAC_Init
|
||||
#define HMAC_Update CyaSSL_HMAC_Update
|
||||
#define HMAC_Final CyaSSL_HMAC_Final
|
||||
#define HMAC_cleanup CyaSSL_HMAC_cleanup
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_HMAC_H_ */
|
36
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/include.am
Normal file
36
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/include.am
Normal file
|
@ -0,0 +1,36 @@
|
|||
# vim:ft=automake
|
||||
# All paths should be given relative to the root
|
||||
|
||||
nobase_include_HEADERS+= \
|
||||
cyassl/openssl/asn1.h \
|
||||
cyassl/openssl/bio.h \
|
||||
cyassl/openssl/bn.h \
|
||||
cyassl/openssl/conf.h \
|
||||
cyassl/openssl/crypto.h \
|
||||
cyassl/openssl/des.h \
|
||||
cyassl/openssl/dh.h \
|
||||
cyassl/openssl/dsa.h \
|
||||
cyassl/openssl/ecdsa.h \
|
||||
cyassl/openssl/ec.h \
|
||||
cyassl/openssl/engine.h \
|
||||
cyassl/openssl/err.h \
|
||||
cyassl/openssl/evp.h \
|
||||
cyassl/openssl/hmac.h \
|
||||
cyassl/openssl/lhash.h \
|
||||
cyassl/openssl/md4.h \
|
||||
cyassl/openssl/md5.h \
|
||||
cyassl/openssl/ripemd.h \
|
||||
cyassl/openssl/ocsp.h \
|
||||
cyassl/openssl/opensslconf.h \
|
||||
cyassl/openssl/opensslv.h \
|
||||
cyassl/openssl/ossl_typ.h \
|
||||
cyassl/openssl/pem.h \
|
||||
cyassl/openssl/pkcs12.h \
|
||||
cyassl/openssl/rand.h \
|
||||
cyassl/openssl/rsa.h \
|
||||
cyassl/openssl/sha.h \
|
||||
cyassl/openssl/ssl.h \
|
||||
cyassl/openssl/stack.h \
|
||||
cyassl/openssl/ui.h \
|
||||
cyassl/openssl/x509.h \
|
||||
cyassl/openssl/x509v3.h
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/lhash.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/lhash.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* lhash.h for openSSL */
|
||||
|
1
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/md4.h
Normal file
1
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/md4.h
Normal file
|
@ -0,0 +1 @@
|
|||
/* md4.h for libcurl */
|
39
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/md5.h
Normal file
39
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/md5.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* md5.h for openssl */
|
||||
|
||||
|
||||
#ifndef CYASSL_MD5_H_
|
||||
#define CYASSL_MD5_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_md5.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CYASSL_MD5_CTX {
|
||||
int holder[24]; /* big enough to hold ctaocrypt md5, but check on init */
|
||||
} CYASSL_MD5_CTX;
|
||||
|
||||
CYASSL_API void CyaSSL_MD5_Init(CYASSL_MD5_CTX*);
|
||||
CYASSL_API void CyaSSL_MD5_Update(CYASSL_MD5_CTX*, const void*, unsigned long);
|
||||
CYASSL_API void CyaSSL_MD5_Final(unsigned char*, CYASSL_MD5_CTX*);
|
||||
|
||||
|
||||
typedef CYASSL_MD5_CTX MD5_CTX;
|
||||
|
||||
#define MD5_Init CyaSSL_MD5_Init
|
||||
#define MD5_Update CyaSSL_MD5_Update
|
||||
#define MD5_Final CyaSSL_MD5_Final
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_MD5_H_ */
|
||||
|
1
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ocsp.h
Normal file
1
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ocsp.h
Normal file
|
@ -0,0 +1 @@
|
|||
/* ocsp.h for libcurl */
|
8
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/opensslconf.h
Normal file
8
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/opensslconf.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* opensslconf.h for openSSL */
|
||||
|
||||
|
||||
#ifndef OPENSSL_THREADS
|
||||
#define OPENSSL_THREADS
|
||||
#endif
|
||||
|
||||
|
12
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/opensslv.h
Normal file
12
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/opensslv.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* opensslv.h compatibility */
|
||||
|
||||
#ifndef CYASSL_OPENSSLV_H_
|
||||
#define CYASSL_OPENSSLV_H_
|
||||
|
||||
|
||||
/* api version compatibility */
|
||||
#define OPENSSL_VERSION_NUMBER 0x0090410fL
|
||||
|
||||
|
||||
#endif /* header */
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ossl_typ.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ossl_typ.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* ossl_typ.h for openssl */
|
||||
|
41
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/pem.h
Normal file
41
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/pem.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* pem.h for openssl */
|
||||
|
||||
|
||||
#ifndef CYASSL_PEM_H_
|
||||
#define CYASSL_PEM_H_
|
||||
|
||||
#include <cyassl/openssl/evp.h>
|
||||
#include <cyassl/openssl/bio.h>
|
||||
#include <cyassl/openssl/rsa.h>
|
||||
#include <cyassl/openssl/dsa.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_API int CyaSSL_PEM_write_bio_RSAPrivateKey(CYASSL_BIO* bio, RSA* rsa,
|
||||
const EVP_CIPHER* cipher,
|
||||
unsigned char* passwd, int len,
|
||||
pem_password_cb cb, void* arg);
|
||||
|
||||
CYASSL_API int CyaSSL_PEM_write_bio_DSAPrivateKey(CYASSL_BIO* bio, DSA* rsa,
|
||||
const EVP_CIPHER* cipher,
|
||||
unsigned char* passwd, int len,
|
||||
pem_password_cb cb, void* arg);
|
||||
|
||||
CYASSL_API CYASSL_EVP_PKEY* CyaSSL_PEM_read_bio_PrivateKey(CYASSL_BIO* bio,
|
||||
CYASSL_EVP_PKEY**, pem_password_cb cb, void* arg);
|
||||
|
||||
#define PEM_write_bio_RSAPrivateKey CyaSSL_PEM_write_bio_RSAPrivateKey
|
||||
#define PEM_write_bio_DSAPrivateKey CyaSSL_PEM_write_bio_DSAPrivateKey
|
||||
#define PEM_read_bio_PrivateKey CyaSSL_PEM_read_bio_PrivateKey
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_PEM_H_ */
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/pkcs12.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/pkcs12.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* pkcs12.h for openssl */
|
||||
|
4
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/rand.h
Normal file
4
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/rand.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* rand.h for openSSL */
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
|
37
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ripemd.h
Normal file
37
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ripemd.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* ripemd.h for openssl */
|
||||
|
||||
|
||||
#ifndef CYASSL_RIPEMD_H_
|
||||
#define CYASSL_RIPEMD_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CYASSL_RIPEMD_CTX {
|
||||
int holder[32]; /* big enough to hold ctaocrypt, but check on init */
|
||||
} CYASSL_RIPEMD_CTX;
|
||||
|
||||
CYASSL_API void CyaSSL_RIPEMD_Init(CYASSL_RIPEMD_CTX*);
|
||||
CYASSL_API void CyaSSL_RIPEMD_Update(CYASSL_RIPEMD_CTX*, const void*,
|
||||
unsigned long);
|
||||
CYASSL_API void CyaSSL_RIPEMD_Final(unsigned char*, CYASSL_RIPEMD_CTX*);
|
||||
|
||||
|
||||
typedef CYASSL_RIPEMD_CTX RIPEMD_CTX;
|
||||
|
||||
#define RIPEMD_Init CyaSSL_RIPEMD_Init
|
||||
#define RIPEMD_Update CyaSSL_RIPEMD_Update
|
||||
#define RIPEMD_Final CyaSSL_RIPEMD_Final
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_MD5_H_ */
|
||||
|
75
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/rsa.h
Normal file
75
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/rsa.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* rsa.h for openSSL */
|
||||
|
||||
|
||||
#ifndef CYASSL_RSA_H_
|
||||
#define CYASSL_RSA_H_
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
#include <cyassl/openssl/bn.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
RSA_PKCS1_PADDING = 1
|
||||
};
|
||||
|
||||
struct CYASSL_RSA {
|
||||
CYASSL_BIGNUM* n;
|
||||
CYASSL_BIGNUM* e;
|
||||
CYASSL_BIGNUM* d;
|
||||
CYASSL_BIGNUM* p;
|
||||
CYASSL_BIGNUM* q;
|
||||
CYASSL_BIGNUM* dmp1; /* dP */
|
||||
CYASSL_BIGNUM* dmq1; /* dQ */
|
||||
CYASSL_BIGNUM* iqmp; /* u */
|
||||
void* internal; /* our RSA */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API CYASSL_RSA* CyaSSL_RSA_new(void);
|
||||
CYASSL_API void CyaSSL_RSA_free(CYASSL_RSA*);
|
||||
|
||||
CYASSL_API int CyaSSL_RSA_generate_key_ex(CYASSL_RSA*, int bits, CYASSL_BIGNUM*,
|
||||
void* cb);
|
||||
|
||||
CYASSL_API int CyaSSL_RSA_blinding_on(CYASSL_RSA*, CYASSL_BN_CTX*);
|
||||
CYASSL_API int CyaSSL_RSA_public_encrypt(int len, unsigned char* fr,
|
||||
unsigned char* to, CYASSL_RSA*, int padding);
|
||||
CYASSL_API int CyaSSL_RSA_private_decrypt(int len, unsigned char* fr,
|
||||
unsigned char* to, CYASSL_RSA*, int padding);
|
||||
|
||||
CYASSL_API int CyaSSL_RSA_size(const CYASSL_RSA*);
|
||||
CYASSL_API int CyaSSL_RSA_sign(int type, const unsigned char* m,
|
||||
unsigned int mLen, unsigned char* sigRet,
|
||||
unsigned int* sigLen, CYASSL_RSA*);
|
||||
CYASSL_API int CyaSSL_RSA_public_decrypt(int flen, unsigned char* from,
|
||||
unsigned char* to, CYASSL_RSA*, int padding);
|
||||
CYASSL_API int CyaSSL_RSA_GenAdd(CYASSL_RSA*);
|
||||
CYASSL_API int CyaSSL_RSA_LoadDer(CYASSL_RSA*, const unsigned char*, int sz);
|
||||
|
||||
|
||||
#define RSA_new CyaSSL_RSA_new
|
||||
#define RSA_free CyaSSL_RSA_free
|
||||
|
||||
#define RSA_generate_key_ex CyaSSL_RSA_generate_key_ex
|
||||
|
||||
#define RSA_blinding_on CyaSSL_RSA_blinding_on
|
||||
#define RSA_public_encrypt CyaSSL_RSA_public_encrypt
|
||||
#define RSA_private_decrypt CyaSSL_RSA_private_decrypt
|
||||
|
||||
#define RSA_size CyaSSL_RSA_size
|
||||
#define RSA_sign CyaSSL_RSA_sign
|
||||
#define RSA_public_decrypt CyaSSL_RSA_public_decrypt
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* header */
|
125
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/sha.h
Normal file
125
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/sha.h
Normal file
|
@ -0,0 +1,125 @@
|
|||
/* sha.h for openssl */
|
||||
|
||||
|
||||
#ifndef CYASSL_SHA_H_
|
||||
#define CYASSL_SHA_H_
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_sha.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CYASSL_SHA_CTX {
|
||||
int holder[24]; /* big enough to hold ctaocrypt sha, but check on init */
|
||||
} CYASSL_SHA_CTX;
|
||||
|
||||
CYASSL_API void CyaSSL_SHA_Init(CYASSL_SHA_CTX*);
|
||||
CYASSL_API void CyaSSL_SHA_Update(CYASSL_SHA_CTX*, const void*, unsigned long);
|
||||
CYASSL_API void CyaSSL_SHA_Final(unsigned char*, CYASSL_SHA_CTX*);
|
||||
|
||||
/* SHA1 points to above, shouldn't use SHA0 ever */
|
||||
CYASSL_API void CyaSSL_SHA1_Init(CYASSL_SHA_CTX*);
|
||||
CYASSL_API void CyaSSL_SHA1_Update(CYASSL_SHA_CTX*, const void*, unsigned long);
|
||||
CYASSL_API void CyaSSL_SHA1_Final(unsigned char*, CYASSL_SHA_CTX*);
|
||||
|
||||
enum {
|
||||
SHA_DIGEST_LENGTH = 20
|
||||
};
|
||||
|
||||
|
||||
typedef CYASSL_SHA_CTX SHA_CTX;
|
||||
|
||||
#define SHA_Init CyaSSL_SHA_Init
|
||||
#define SHA_Update CyaSSL_SHA_Update
|
||||
#define SHA_Final CyaSSL_SHA_Final
|
||||
|
||||
#define SHA1_Init CyaSSL_SHA1_Init
|
||||
#define SHA1_Update CyaSSL_SHA1_Update
|
||||
#define SHA1_Final CyaSSL_SHA1_Final
|
||||
|
||||
|
||||
typedef struct CYASSL_SHA256_CTX {
|
||||
int holder[28]; /* big enough to hold ctaocrypt sha, but check on init */
|
||||
} CYASSL_SHA256_CTX;
|
||||
|
||||
CYASSL_API void CyaSSL_SHA256_Init(CYASSL_SHA256_CTX*);
|
||||
CYASSL_API void CyaSSL_SHA256_Update(CYASSL_SHA256_CTX*, const void*,
|
||||
unsigned long);
|
||||
CYASSL_API void CyaSSL_SHA256_Final(unsigned char*, CYASSL_SHA256_CTX*);
|
||||
|
||||
enum {
|
||||
SHA256_DIGEST_LENGTH = 20
|
||||
};
|
||||
|
||||
|
||||
typedef CYASSL_SHA256_CTX SHA256_CTX;
|
||||
|
||||
#define SHA256_Init CyaSSL_SHA256_Init
|
||||
#define SHA256_Update CyaSSL_SHA256_Update
|
||||
#define SHA256_Final CyaSSL_SHA256_Final
|
||||
|
||||
|
||||
#ifdef CYASSL_SHA384
|
||||
|
||||
typedef struct CYASSL_SHA384_CTX {
|
||||
long long holder[32]; /* big enough, but check on init */
|
||||
} CYASSL_SHA384_CTX;
|
||||
|
||||
CYASSL_API void CyaSSL_SHA384_Init(CYASSL_SHA384_CTX*);
|
||||
CYASSL_API void CyaSSL_SHA384_Update(CYASSL_SHA384_CTX*, const void*,
|
||||
unsigned long);
|
||||
CYASSL_API void CyaSSL_SHA384_Final(unsigned char*, CYASSL_SHA384_CTX*);
|
||||
|
||||
enum {
|
||||
SHA384_DIGEST_LENGTH = 48
|
||||
};
|
||||
|
||||
|
||||
typedef CYASSL_SHA384_CTX SHA384_CTX;
|
||||
|
||||
#define SHA384_Init CyaSSL_SHA384_Init
|
||||
#define SHA384_Update CyaSSL_SHA384_Update
|
||||
#define SHA384_Final CyaSSL_SHA384_Final
|
||||
|
||||
#endif /* CYASSL_SHA384 */
|
||||
|
||||
#ifdef CYASSL_SHA512
|
||||
|
||||
typedef struct CYASSL_SHA512_CTX {
|
||||
long long holder[36]; /* big enough, but check on init */
|
||||
} CYASSL_SHA512_CTX;
|
||||
|
||||
CYASSL_API void CyaSSL_SHA512_Init(CYASSL_SHA512_CTX*);
|
||||
CYASSL_API void CyaSSL_SHA512_Update(CYASSL_SHA512_CTX*, const void*,
|
||||
unsigned long);
|
||||
CYASSL_API void CyaSSL_SHA512_Final(unsigned char*, CYASSL_SHA512_CTX*);
|
||||
|
||||
enum {
|
||||
SHA512_DIGEST_LENGTH = 64
|
||||
};
|
||||
|
||||
|
||||
typedef CYASSL_SHA512_CTX SHA512_CTX;
|
||||
|
||||
#define SHA512_Init CyaSSL_SHA512_Init
|
||||
#define SHA512_Update CyaSSL_SHA512_Update
|
||||
#define SHA512_Final CyaSSL_SHA512_Final
|
||||
|
||||
#endif /* CYASSL_SHA512 */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_SHA_H_ */
|
||||
|
377
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ssl.h
Normal file
377
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ssl.h
Normal file
|
@ -0,0 +1,377 @@
|
|||
/* ssl.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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
|
||||
* a with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* ssl.h defines openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_OPENSSL_H_
|
||||
#define CYASSL_OPENSSL_H_
|
||||
|
||||
#include <cyassl/ssl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* wincrypt.h clashes */
|
||||
#undef X509_NAME
|
||||
#endif
|
||||
|
||||
|
||||
typedef CYASSL SSL;
|
||||
typedef CYASSL_SESSION SSL_SESSION;
|
||||
typedef CYASSL_METHOD SSL_METHOD;
|
||||
typedef CYASSL_CTX SSL_CTX;
|
||||
|
||||
typedef CYASSL_X509 X509;
|
||||
typedef CYASSL_X509_NAME X509_NAME;
|
||||
typedef CYASSL_X509_CHAIN X509_CHAIN;
|
||||
|
||||
|
||||
/* redeclare guard */
|
||||
#define CYASSL_TYPES_DEFINED
|
||||
|
||||
|
||||
typedef CYASSL_EVP_PKEY EVP_PKEY;
|
||||
typedef CYASSL_RSA RSA;
|
||||
typedef CYASSL_DSA DSA;
|
||||
typedef CYASSL_BIO BIO;
|
||||
typedef CYASSL_BIO_METHOD BIO_METHOD;
|
||||
typedef CYASSL_CIPHER SSL_CIPHER;
|
||||
typedef CYASSL_X509_LOOKUP X509_LOOKUP;
|
||||
typedef CYASSL_X509_LOOKUP_METHOD X509_LOOKUP_METHOD;
|
||||
typedef CYASSL_X509_CRL X509_CRL;
|
||||
typedef CYASSL_X509_EXTENSION X509_EXTENSION;
|
||||
typedef CYASSL_ASN1_TIME ASN1_TIME;
|
||||
typedef CYASSL_ASN1_INTEGER ASN1_INTEGER;
|
||||
typedef CYASSL_ASN1_OBJECT ASN1_OBJECT;
|
||||
typedef CYASSL_ASN1_STRING ASN1_STRING;
|
||||
typedef CYASSL_dynlock_value CRYPTO_dynlock_value;
|
||||
|
||||
#define ASN1_UTCTIME CYASSL_ASN1_TIME
|
||||
|
||||
typedef CYASSL_MD4_CTX MD4_CTX;
|
||||
typedef CYASSL_COMP_METHOD COMP_METHOD;
|
||||
typedef CYASSL_X509_STORE X509_STORE;
|
||||
typedef CYASSL_X509_REVOKED X509_REVOKED;
|
||||
typedef CYASSL_X509_OBJECT X509_OBJECT;
|
||||
typedef CYASSL_X509_STORE_CTX X509_STORE_CTX;
|
||||
|
||||
|
||||
#define SSLv3_server_method CyaSSLv3_server_method
|
||||
#define SSLv3_client_method CyaSSLv3_client_method
|
||||
#define TLSv1_server_method CyaTLSv1_server_method
|
||||
#define TLSv1_client_method CyaTLSv1_client_method
|
||||
#define TLSv1_1_server_method CyaTLSv1_1_server_method
|
||||
#define TLSv1_1_client_method CyaTLSv1_1_client_method
|
||||
#define TLSv1_2_server_method CyaTLSv1_2_server_method
|
||||
#define TLSv1_2_client_method CyaTLSv1_2_client_method
|
||||
|
||||
#ifdef CYASSL_DTLS
|
||||
#define DTLSv1_client_method CyaDTLSv1_client_method
|
||||
#define DTLSv1_server_method CyaDTLSv1_server_method
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
#define SSL_CTX_use_certificate_file CyaSSL_CTX_use_certificate_file
|
||||
#define SSL_CTX_use_PrivateKey_file CyaSSL_CTX_use_PrivateKey_file
|
||||
#define SSL_CTX_load_verify_locations CyaSSL_CTX_load_verify_locations
|
||||
#define SSL_CTX_use_certificate_chain_file CyaSSL_CTX_use_certificate_chain_file
|
||||
#define SSL_CTX_use_RSAPrivateKey_file CyaSSL_CTX_use_RSAPrivateKey_file
|
||||
|
||||
#define SSL_use_certificate_file CyaSSL_use_certificate_file
|
||||
#define SSL_use_PrivateKey_file CyaSSL_use_PrivateKey_file
|
||||
#define SSL_use_certificate_chain_file CyaSSL_use_certificate_chain_file
|
||||
#define SSL_use_RSAPrivateKey_file CyaSSL_use_RSAPrivateKey_file
|
||||
#endif
|
||||
|
||||
#define SSL_CTX_new CyaSSL_CTX_new
|
||||
#define SSL_new CyaSSL_new
|
||||
#define SSL_set_fd CyaSSL_set_fd
|
||||
#define SSL_get_fd CyaSSL_get_fd
|
||||
#define SSL_connect CyaSSL_connect
|
||||
|
||||
#define SSL_write CyaSSL_write
|
||||
#define SSL_read CyaSSL_read
|
||||
#define SSL_accept CyaSSL_accept
|
||||
#define SSL_CTX_free CyaSSL_CTX_free
|
||||
#define SSL_free CyaSSL_free
|
||||
#define SSL_shutdown CyaSSL_shutdown
|
||||
|
||||
#define SSL_CTX_set_quiet_shutdown CyaSSL_CTX_set_quiet_shutdown
|
||||
#define SSL_set_quiet_shutdown CyaSSL_set_quiet_shutdown
|
||||
#define SSL_get_error CyaSSL_get_error
|
||||
#define SSL_set_session CyaSSL_set_session
|
||||
#define SSL_get_session CyaSSL_get_session
|
||||
#define SSL_flush_sessions CyaSSL_flush_sessions
|
||||
|
||||
#define SSL_CTX_set_verify CyaSSL_CTX_set_verify
|
||||
#define SSL_set_verify CyaSSL_set_verify
|
||||
#define SSL_pending CyaSSL_pending
|
||||
#define SSL_load_error_strings CyaSSL_load_error_strings
|
||||
#define SSL_library_init CyaSSL_library_init
|
||||
#define SSL_CTX_set_session_cache_mode CyaSSL_CTX_set_session_cache_mode
|
||||
#define SSL_CTX_set_cipher_list CyaSSL_CTX_set_cipher_list
|
||||
#define SSL_set_cipher_list CyaSSL_set_cipher_list
|
||||
|
||||
#define ERR_error_string CyaSSL_ERR_error_string
|
||||
#define ERR_error_string_n CyaSSL_ERR_error_string_n
|
||||
|
||||
#define SSL_set_ex_data CyaSSL_set_ex_data
|
||||
#define SSL_get_shutdown CyaSSL_get_shutdown
|
||||
#define SSL_set_rfd CyaSSL_set_rfd
|
||||
#define SSL_set_wfd CyaSSL_set_wfd
|
||||
#define SSL_set_shutdown CyaSSL_set_shutdown
|
||||
#define SSL_set_session_id_context CyaSSL_set_session_id_context
|
||||
#define SSL_set_connect_state CyaSSL_set_connect_state
|
||||
#define SSL_set_accept_state CyaSSL_set_accept_state
|
||||
#define SSL_session_reused CyaSSL_session_reused
|
||||
#define SSL_SESSION_free CyaSSL_SESSION_free
|
||||
#define SSL_is_init_finished CyaSSL_is_init_finished
|
||||
|
||||
#define SSL_get_version CyaSSL_get_version
|
||||
#define SSL_get_current_cipher CyaSSL_get_current_cipher
|
||||
#define SSL_get_cipher CyaSSL_get_cipher
|
||||
#define SSL_CIPHER_description CyaSSL_CIPHER_description
|
||||
#define SSL_CIPHER_get_name CyaSSL_CIPHER_get_name
|
||||
#define SSL_get1_session CyaSSL_get1_session
|
||||
|
||||
#define SSL_get_keyblock_size CyaSSL_get_keyblock_size
|
||||
#define SSL_get_keys CyaSSL_get_keys
|
||||
|
||||
#define X509_free CyaSSL_X509_free
|
||||
#define OPENSSL_free CyaSSL_OPENSSL_free
|
||||
|
||||
#define OCSP_parse_url CyaSSL_OCSP_parse_url
|
||||
#define SSLv23_client_method CyaSSLv23_client_method
|
||||
#define SSLv2_client_method CyaSSLv2_client_method
|
||||
#define SSLv2_server_method CyaSSLv2_server_method
|
||||
|
||||
#define MD4_Init CyaSSL_MD4_Init
|
||||
#define MD4_Update CyaSSL_MD4_Update
|
||||
#define MD4_Final CyaSSL_MD4_Final
|
||||
|
||||
#define BIO_new CyaSSL_BIO_new
|
||||
#define BIO_free CyaSSL_BIO_free
|
||||
#define BIO_free_all CyaSSL_BIO_free_all
|
||||
#define BIO_read CyaSSL_BIO_read
|
||||
#define BIO_write CyaSSL_BIO_write
|
||||
#define BIO_push CyaSSL_BIO_push
|
||||
#define BIO_pop CyaSSL_BIO_pop
|
||||
#define BIO_flush CyaSSL_BIO_flush
|
||||
#define BIO_pending CyaSSL_BIO_pending
|
||||
|
||||
#define BIO_get_mem_data CyaSSL_BIO_get_mem_data
|
||||
#define BIO_new_mem_buf CyaSSL_BIO_new_mem_buf
|
||||
|
||||
#define BIO_f_buffer CyaSSL_BIO_f_buffer
|
||||
#define BIO_set_write_buffer_size CyaSSL_BIO_set_write_buffer_size
|
||||
#define BIO_f_ssl CyaSSL_BIO_f_ssl
|
||||
#define BIO_new_socket CyaSSL_BIO_new_socket
|
||||
#define SSL_set_bio CyaSSL_set_bio
|
||||
#define BIO_eof CyaSSL_BIO_eof
|
||||
#define BIO_set_ss CyaSSL_BIO_set_ss
|
||||
|
||||
#define BIO_s_mem CyaSSL_BIO_s_mem
|
||||
#define BIO_f_base64 CyaSSL_BIO_f_base64
|
||||
#define BIO_set_flags CyaSSL_BIO_set_flags
|
||||
|
||||
#define OpenSSL_add_all_algorithms CyaSSL_add_all_algorithms
|
||||
#define SSLeay_add_ssl_algorithms CyaSSL_add_all_algorithms
|
||||
#define SSLeay_add_all_algorithms CyaSSL_add_all_algorithms
|
||||
|
||||
#define RAND_screen CyaSSL_RAND_screen
|
||||
#define RAND_file_name CyaSSL_RAND_file_name
|
||||
#define RAND_write_file CyaSSL_RAND_write_file
|
||||
#define RAND_load_file CyaSSL_RAND_load_file
|
||||
#define RAND_egd CyaSSL_RAND_egd
|
||||
#define RAND_seed CyaSSL_RAND_seed
|
||||
#define RAND_add CyaSSL_RAND_add
|
||||
|
||||
#define COMP_zlib CyaSSL_COMP_zlib
|
||||
#define COMP_rle CyaSSL_COMP_rle
|
||||
#define SSL_COMP_add_compression_method CyaSSL_COMP_add_compression_method
|
||||
|
||||
#define SSL_get_ex_new_index CyaSSL_get_ex_new_index
|
||||
|
||||
#define CRYPTO_set_id_callback CyaSSL_set_id_callback
|
||||
#define CRYPTO_set_locking_callback CyaSSL_set_locking_callback
|
||||
#define CRYPTO_set_dynlock_create_callback CyaSSL_set_dynlock_create_callback
|
||||
#define CRYPTO_set_dynlock_lock_callback CyaSSL_set_dynlock_lock_callback
|
||||
#define CRYPTO_set_dynlock_destroy_callback CyaSSL_set_dynlock_destroy_callback
|
||||
#define CRYPTO_num_locks CyaSSL_num_locks
|
||||
|
||||
#define X509_STORE_CTX_get_current_cert CyaSSL_X509_STORE_CTX_get_current_cert
|
||||
#define X509_STORE_CTX_get_error CyaSSL_X509_STORE_CTX_get_error
|
||||
#define X509_STORE_CTX_get_error_depth CyaSSL_X509_STORE_CTX_get_error_depth
|
||||
|
||||
#define X509_NAME_oneline CyaSSL_X509_NAME_oneline
|
||||
#define X509_get_issuer_name CyaSSL_X509_get_issuer_name
|
||||
#define X509_get_subject_name CyaSSL_X509_get_subject_name
|
||||
#define X509_verify_cert_error_string CyaSSL_X509_verify_cert_error_string
|
||||
|
||||
#define X509_LOOKUP_add_dir CyaSSL_X509_LOOKUP_add_dir
|
||||
#define X509_LOOKUP_load_file CyaSSL_X509_LOOKUP_load_file
|
||||
#define X509_LOOKUP_hash_dir CyaSSL_X509_LOOKUP_hash_dir
|
||||
#define X509_LOOKUP_file CyaSSL_X509_LOOKUP_file
|
||||
|
||||
#define X509_STORE_add_lookup CyaSSL_X509_STORE_add_lookup
|
||||
#define X509_STORE_new CyaSSL_X509_STORE_new
|
||||
#define X509_STORE_get_by_subject CyaSSL_X509_STORE_get_by_subject
|
||||
#define X509_STORE_CTX_init CyaSSL_X509_STORE_CTX_init
|
||||
#define X509_STORE_CTX_cleanup CyaSSL_X509_STORE_CTX_cleanup
|
||||
|
||||
#define X509_CRL_get_lastUpdate CyaSSL_X509_CRL_get_lastUpdate
|
||||
#define X509_CRL_get_nextUpdate CyaSSL_X509_CRL_get_nextUpdate
|
||||
|
||||
#define X509_get_pubkey CyaSSL_X509_get_pubkey
|
||||
#define X509_CRL_verify CyaSSL_X509_CRL_verify
|
||||
#define X509_STORE_CTX_set_error CyaSSL_X509_STORE_CTX_set_error
|
||||
#define X509_OBJECT_free_contents CyaSSL_X509_OBJECT_free_contents
|
||||
#define EVP_PKEY_free CyaSSL_EVP_PKEY_free
|
||||
#define X509_cmp_current_time CyaSSL_X509_cmp_current_time
|
||||
#define sk_X509_REVOKED_num CyaSSL_sk_X509_REVOKED_num
|
||||
#define X509_CRL_get_REVOKED CyaSSL_X509_CRL_get_REVOKED
|
||||
#define sk_X509_REVOKED_value CyaSSL_sk_X509_REVOKED_value
|
||||
|
||||
#define X509_get_serialNumber CyaSSL_X509_get_serialNumber
|
||||
|
||||
#define ASN1_TIME_pr CyaSSL_ASN1_TIME_pr
|
||||
|
||||
#define ASN1_INTEGER_cmp CyaSSL_ASN1_INTEGER_cmp
|
||||
#define ASN1_INTEGER_get CyaSSL_ASN1_INTEGER_get
|
||||
|
||||
#define SSL_load_client_CA_file CyaSSL_load_client_CA_file
|
||||
|
||||
#define SSL_CTX_set_client_CA_list CyaSSL_CTX_set_client_CA_list
|
||||
#define X509_STORE_CTX_get_ex_data CyaSSL_X509_STORE_CTX_get_ex_data
|
||||
#define SSL_get_ex_data_X509_STORE_CTX_idx CyaSSL_get_ex_data_X509_STORE_CTX_idx
|
||||
#define SSL_get_ex_data CyaSSL_get_ex_data
|
||||
|
||||
#define SSL_CTX_set_default_passwd_cb_userdata CyaSSL_CTX_set_default_passwd_cb_userdata
|
||||
#define SSL_CTX_set_default_passwd_cb CyaSSL_CTX_set_default_passwd_cb
|
||||
|
||||
#define SSL_CTX_set_timeout CyaSSL_CTX_set_timeout
|
||||
#define SSL_CTX_set_info_callback CyaSSL_CTX_set_info_callback
|
||||
|
||||
#define ERR_peek_error CyaSSL_ERR_peek_error
|
||||
#define ERR_GET_REASON CyaSSL_ERR_GET_REASON
|
||||
|
||||
#define SSL_alert_type_string CyaSSL_alert_type_string
|
||||
#define SSL_alert_desc_string CyaSSL_alert_desc_string
|
||||
#define SSL_state_string CyaSSL_state_string
|
||||
|
||||
#define RSA_free CyaSSL_RSA_free
|
||||
#define RSA_generate_key CyaSSL_RSA_generate_key
|
||||
#define SSL_CTX_set_tmp_rsa_callback CyaSSL_CTX_set_tmp_rsa_callback
|
||||
|
||||
#define PEM_def_callback CyaSSL_PEM_def_callback
|
||||
|
||||
#define SSL_CTX_sess_accept CyaSSL_CTX_sess_accept
|
||||
#define SSL_CTX_sess_connect CyaSSL_CTX_sess_connect
|
||||
#define SSL_CTX_sess_accept_good CyaSSL_CTX_sess_accept_good
|
||||
#define SSL_CTX_sess_connect_good CyaSSL_CTX_sess_connect_good
|
||||
#define SSL_CTX_sess_accept_renegotiate CyaSSL_CTX_sess_accept_renegotiate
|
||||
#define SSL_CTX_sess_connect_renegotiate CyaSSL_CTX_sess_connect_renegotiate
|
||||
#define SSL_CTX_sess_hits CyaSSL_CTX_sess_hits
|
||||
#define SSL_CTX_sess_cb_hits CyaSSL_CTX_sess_cb_hits
|
||||
#define SSL_CTX_sess_cache_full CyaSSL_CTX_sess_cache_full
|
||||
#define SSL_CTX_sess_misses CyaSSL_CTX_sess_misses
|
||||
#define SSL_CTX_sess_timeouts CyaSSL_CTX_sess_timeouts
|
||||
#define SSL_CTX_sess_number CyaSSL_CTX_sess_number
|
||||
#define SSL_CTX_sess_get_cache_size CyaSSL_CTX_sess_get_cache_size
|
||||
|
||||
|
||||
#define SSL_DEFAULT_CIPHER_LIST CYASSL_DEFAULT_CIPHER_LIST
|
||||
#define RSA_F4 CYASSL_RSA_F4
|
||||
|
||||
#define SSL_CTX_set_psk_client_callback CyaSSL_CTX_set_psk_client_callback
|
||||
#define SSL_set_psk_client_callback CyaSSL_set_psk_client_callback
|
||||
|
||||
#define SSL_get_psk_identity_hint CyaSSL_get_psk_identity_hint
|
||||
#define SSL_get_psk_identity CyaSSL_get_psk_identity
|
||||
|
||||
#define SSL_CTX_use_psk_identity_hint CyaSSL_CTX_use_psk_identity_hint
|
||||
#define SSL_use_psk_identity_hint CyaSSL_use_psk_identity_hint
|
||||
|
||||
#define SSL_CTX_set_psk_server_callback CyaSSL_CTX_set_psk_server_callback
|
||||
#define SSL_set_psk_server_callback CyaSSL_set_psk_server_callback
|
||||
|
||||
#define ERR_get_error_line_data CyaSSL_ERR_get_error_line_data
|
||||
|
||||
#define ERR_get_error CyaSSL_ERR_get_error
|
||||
#define ERR_clear_error CyaSSL_ERR_clear_error
|
||||
|
||||
#define RAND_status CyaSSL_RAND_status
|
||||
#define RAND_bytes CyaSSL_RAND_bytes
|
||||
#define SSLv23_server_method CyaSSLv23_server_method
|
||||
#define SSL_CTX_set_options CyaSSL_CTX_set_options
|
||||
#define SSL_CTX_check_private_key CyaSSL_CTX_check_private_key
|
||||
|
||||
#define ERR_free_strings CyaSSL_ERR_free_strings
|
||||
#define ERR_remove_state CyaSSL_ERR_remove_state
|
||||
#define EVP_cleanup CyaSSL_EVP_cleanup
|
||||
|
||||
#define CRYPTO_cleanup_all_ex_data CyaSSL_cleanup_all_ex_data
|
||||
#define SSL_CTX_set_mode CyaSSL_CTX_set_mode
|
||||
#define SSL_CTX_get_mode CyaSSL_CTX_get_mode
|
||||
#define SSL_CTX_set_default_read_ahead CyaSSL_CTX_set_default_read_ahead
|
||||
|
||||
#define SSL_CTX_sess_set_cache_size CyaSSL_CTX_sess_set_cache_size
|
||||
#define SSL_CTX_set_default_verify_paths CyaSSL_CTX_set_default_verify_paths
|
||||
|
||||
#define SSL_CTX_set_session_id_context CyaSSL_CTX_set_session_id_context
|
||||
#define SSL_get_peer_certificate CyaSSL_get_peer_certificate
|
||||
|
||||
#define SSL_want_read CyaSSL_want_read
|
||||
#define SSL_want_write CyaSSL_want_write
|
||||
|
||||
#define BIO_prf CyaSSL_BIO_prf
|
||||
#define ASN1_UTCTIME_pr CyaSSL_ASN1_UTCTIME_pr
|
||||
|
||||
#define sk_num CyaSSL_sk_num
|
||||
#define sk_value CyaSSL_sk_value
|
||||
|
||||
#define SSL_CTX_get_ex_data CyaSSL_CTX_get_ex_data
|
||||
#define SSL_CTX_set_ex_data CyaSSL_CTX_set_ex_data
|
||||
#define SSL_CTX_sess_set_get_cb CyaSSL_CTX_sess_set_get_cb
|
||||
#define SSL_CTX_sess_set_new_cb CyaSSL_CTX_sess_set_new_cb
|
||||
#define SSL_CTX_sess_set_remove_cb CyaSSL_CTX_sess_set_remove_cb
|
||||
|
||||
#define i2d_SSL_SESSION CyaSSL_i2d_SSL_SESSION
|
||||
#define d2i_SSL_SESSION CyaSSL_d2i_SSL_SESSION
|
||||
#define SSL_SESSION_get_timeout CyaSSL_SESSION_get_timeout
|
||||
#define SSL_SESSION_get_time CyaSSL_SESSION_get_time
|
||||
#define SSL_CTX_get_ex_new_index CyaSSL_CTX_get_ex_new_index
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CyaSSL_openssl_h__ */
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/stack.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/stack.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* stack.h for openssl */
|
||||
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ui.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/ui.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* ui.h for openssl */
|
||||
|
3
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/x509.h
Normal file
3
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/x509.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* x509.h for openssl */
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/x509v3.h
Normal file
2
FreeRTOS-Plus/Source/CyaSSL/cyassl/openssl/x509v3.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* x509v3.h for openssl */
|
||||
|
74
FreeRTOS-Plus/Source/CyaSSL/cyassl/sniffer.h
Normal file
74
FreeRTOS-Plus/Source/CyaSSL/cyassl/sniffer.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* sniffer.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_SNIFFER_H
|
||||
#define CYASSL_SNIFFER_H
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef SSL_SNIFFER_EXPORTS
|
||||
#define SSL_SNIFFER_API __declspec(dllexport)
|
||||
#else
|
||||
#define SSL_SNIFFER_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SSL_SNIFFER_API
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
CYASSL_API
|
||||
SSL_SNIFFER_API int ssl_SetPrivateKey(const char* address, int port,
|
||||
const char* keyFile, int keyType,
|
||||
const char* password, char* error);
|
||||
|
||||
CYASSL_API
|
||||
SSL_SNIFFER_API int ssl_DecodePacket(const unsigned char* packet, int length,
|
||||
unsigned char* data, char* error);
|
||||
|
||||
CYASSL_API
|
||||
SSL_SNIFFER_API int ssl_Trace(const char* traceFile, char* error);
|
||||
|
||||
|
||||
CYASSL_API void ssl_InitSniffer(void);
|
||||
|
||||
CYASSL_API void ssl_FreeSniffer(void);
|
||||
|
||||
|
||||
/* ssl_SetPrivateKey keyTypes */
|
||||
enum {
|
||||
FILETYPE_PEM = 1,
|
||||
FILETYPE_DER = 2,
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CyaSSL_SNIFFER_H */
|
||||
|
107
FreeRTOS-Plus/Source/CyaSSL/cyassl/sniffer_error.h
Normal file
107
FreeRTOS-Plus/Source/CyaSSL/cyassl/sniffer_error.h
Normal file
|
@ -0,0 +1,107 @@
|
|||
/* sniffer_error.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CYASSL_SNIFFER_ERROR_H
|
||||
#define CYASSL_SNIFFER_ERROR_H
|
||||
|
||||
/* need to have errors as #defines since .rc files can't handle enums */
|
||||
/* need to start at 1 and go in order for same reason */
|
||||
|
||||
#define MEMORY_STR 1
|
||||
#define NEW_SERVER_STR 2
|
||||
#define IP_CHECK_STR 3
|
||||
#define SERVER_NOT_REG_STR 4
|
||||
#define TCP_CHECK_STR 5
|
||||
#define SERVER_PORT_NOT_REG_STR 6
|
||||
#define RSA_DECRYPT_STR 7
|
||||
#define RSA_DECODE_STR 8
|
||||
#define BAD_CIPHER_SPEC_STR 9
|
||||
#define SERVER_HELLO_INPUT_STR 10
|
||||
|
||||
#define BAD_SESSION_RESUME_STR 11
|
||||
#define SERVER_DID_RESUMPTION_STR 12
|
||||
#define CLIENT_HELLO_INPUT_STR 13
|
||||
#define CLIENT_RESUME_TRY_STR 14
|
||||
#define HANDSHAKE_INPUT_STR 15
|
||||
#define GOT_HELLO_VERIFY_STR 16
|
||||
#define GOT_SERVER_HELLO_STR 17
|
||||
#define GOT_CERT_REQ_STR 18
|
||||
#define GOT_SERVER_KEY_EX_STR 19
|
||||
#define GOT_CERT_STR 20
|
||||
|
||||
#define GOT_SERVER_HELLO_DONE_STR 21
|
||||
#define GOT_FINISHED_STR 22
|
||||
#define GOT_CLIENT_HELLO_STR 23
|
||||
#define GOT_CLIENT_KEY_EX_STR 24
|
||||
#define GOT_CERT_VER_STR 25
|
||||
#define GOT_UNKNOWN_HANDSHAKE_STR 26
|
||||
#define NEW_SESSION_STR 27
|
||||
#define BAD_NEW_SSL_STR 28
|
||||
#define GOT_PACKET_STR 29
|
||||
#define NO_DATA_STR 30
|
||||
|
||||
#define BAD_SESSION_STR 31
|
||||
#define GOT_OLD_CLIENT_HELLO_STR 32
|
||||
#define OLD_CLIENT_INPUT_STR 33
|
||||
#define OLD_CLIENT_OK_STR 34
|
||||
#define BAD_OLD_CLIENT_STR 35
|
||||
#define BAD_RECORD_HDR_STR 36
|
||||
#define RECORD_INPUT_STR 37
|
||||
#define GOT_HANDSHAKE_STR 38
|
||||
#define BAD_HANDSHAKE_STR 39
|
||||
#define GOT_CHANGE_CIPHER_STR 40
|
||||
|
||||
#define GOT_APP_DATA_STR 41
|
||||
#define BAD_APP_DATA_STR 42
|
||||
#define GOT_ALERT_STR 43
|
||||
#define ANOTHER_MSG_STR 44
|
||||
#define REMOVE_SESSION_STR 45
|
||||
#define KEY_FILE_STR 46
|
||||
#define BAD_IPVER_STR 47
|
||||
#define BAD_PROTO_STR 48
|
||||
#define PACKET_HDR_SHORT_STR 49
|
||||
#define GOT_UNKNOWN_RECORD_STR 50
|
||||
|
||||
#define BAD_TRACE_FILE_STR 51
|
||||
#define FATAL_ERROR_STR 52
|
||||
#define PARTIAL_INPUT_STR 53
|
||||
#define BUFFER_ERROR_STR 54
|
||||
#define PARTIAL_ADD_STR 55
|
||||
#define DUPLICATE_STR 56
|
||||
#define OUT_OF_ORDER_STR 57
|
||||
#define OVERLAP_DUPLICATE_STR 58
|
||||
#define OVERLAP_REASSEMBLY_BEGIN_STR 59
|
||||
#define OVERLAP_REASSEMBLY_END_STR 60
|
||||
|
||||
#define MISSED_CLIENT_HELLO_STR 61
|
||||
#define GOT_HELLO_REQUEST_STR 62
|
||||
#define GOT_SESSION_TICKET_STR 63
|
||||
#define BAD_INPUT_STR 64
|
||||
#define BAD_DECRYPT_TYPE 65
|
||||
#define BAD_FINISHED_MSG 66
|
||||
#define BAD_COMPRESSION_STR 67
|
||||
|
||||
/* !!!! also add to msgTable in sniffer.c and .rc file !!!! */
|
||||
|
||||
|
||||
#endif /* CyaSSL_SNIFFER_ERROR_H */
|
||||
|
85
FreeRTOS-Plus/Source/CyaSSL/cyassl/sniffer_error.rc
Normal file
85
FreeRTOS-Plus/Source/CyaSSL/cyassl/sniffer_error.rc
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
STRINGTABLE
|
||||
{
|
||||
1, "Out of Memory"
|
||||
2, "New SSL Sniffer Server Registered"
|
||||
3, "Checking IP Header"
|
||||
4, "SSL Sniffer Server Not Registered"
|
||||
5, "Checking TCP Header"
|
||||
|
||||
6, "SSL Sniffer Server Port Not Registered"
|
||||
7, "RSA Private Decrypt Error"
|
||||
8, "RSA Private Decode Error"
|
||||
9, "Set Cipher Spec Error"
|
||||
10, "Server Hello Input Malformed"
|
||||
|
||||
11, "Couldn't Resume Session Error"
|
||||
12, "Server Did Resumption"
|
||||
13, "Client Hello Input Malformed"
|
||||
14, "Client Trying to Resume"
|
||||
15, "Handshake Input Malformed"
|
||||
|
||||
16, "Got Hello Verify msg"
|
||||
17, "Got Server Hello msg"
|
||||
18, "Got Cert Request msg"
|
||||
19, "Got Server Key Exchange msg"
|
||||
20, "Got Cert msg"
|
||||
|
||||
21, "Got Server Hello Done msg"
|
||||
22, "Got Finished msg"
|
||||
23, "Got Client Hello msg"
|
||||
24, "Got Client Key Exchange msg"
|
||||
25, "Got Cert Verify msg"
|
||||
|
||||
26, "Got Unknown Handshake msg"
|
||||
27, "New SSL Sniffer Session created"
|
||||
28, "Couldn't create new SSL"
|
||||
29, "Got a Packet to decode"
|
||||
30, "No data present"
|
||||
|
||||
31, "Session Not Found"
|
||||
32, "Got an Old Client Hello msg"
|
||||
33, "Old Client Hello Input Malformed"
|
||||
34, "Old Client Hello OK"
|
||||
35, "Bad Old Client Hello"
|
||||
|
||||
36, "Bad Record Header"
|
||||
37, "Record Header Input Malformed"
|
||||
38, "Got a HandShake msg"
|
||||
39, "Bad HandShake msg"
|
||||
40, "Got a Change Cipher Spec msg"
|
||||
|
||||
41, "Got Application Data msg"
|
||||
42, "Bad Application Data"
|
||||
43, "Got an Alert msg"
|
||||
44, "Another msg to Process"
|
||||
45, "Removing Session From Table"
|
||||
|
||||
46, "Bad Key File"
|
||||
47, "Wrong IP Version"
|
||||
48, "Wrong Protocol type"
|
||||
49, "Packet Short for header processing"
|
||||
50, "Got Unknown Record Type"
|
||||
|
||||
51, "Can't Open Trace File"
|
||||
52, "Session in Fatal Error State"
|
||||
53, "Partial SSL record received"
|
||||
54, "Buffer Error, malformed input"
|
||||
55, "Added to Partial Input"
|
||||
|
||||
56, "Received a Duplicate Packet"
|
||||
57, "Received an Out of Order Packet"
|
||||
58, "Received an Overlap Duplicate Packet"
|
||||
59, "Received an Overlap Reassembly Begin Duplicate Packet"
|
||||
60, "Received an Overlap Reassembly End Duplicate Packet"
|
||||
|
||||
61, "Missed the Client Hello Entirely"
|
||||
62, "Got Hello Request msg"
|
||||
63, "Got Session Ticket msg"
|
||||
64, "Bad Input"
|
||||
65, "Bad Decrypt Type"
|
||||
|
||||
66, "Bad Finished Message Processing"
|
||||
67, "Bad Compression Type"
|
||||
}
|
||||
|
855
FreeRTOS-Plus/Source/CyaSSL/cyassl/ssl.h
Normal file
855
FreeRTOS-Plus/Source/CyaSSL/cyassl/ssl.h
Normal file
|
@ -0,0 +1,855 @@
|
|||
/* ssl.h
|
||||
*
|
||||
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/* CyaSSL API */
|
||||
|
||||
#ifndef CYASSL_SSL_H
|
||||
#define CYASSL_SSL_H
|
||||
|
||||
|
||||
/* for users not using preprocessor flags*/
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
#include <cyassl/version.h>
|
||||
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
#include <stdio.h> /* ERR_printf */
|
||||
#endif
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_ssl.h"
|
||||
#endif
|
||||
|
||||
#ifdef LIBCYASSL_VERSION_STRING
|
||||
#define CYASSL_VERSION LIBCYASSL_VERSION_STRING
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* wincrypt.h clashes */
|
||||
#undef OCSP_REQUEST
|
||||
#undef OCSP_RESPONSE
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CYASSL CYASSL;
|
||||
typedef struct CYASSL_SESSION CYASSL_SESSION;
|
||||
typedef struct CYASSL_METHOD CYASSL_METHOD;
|
||||
typedef struct CYASSL_CTX CYASSL_CTX;
|
||||
|
||||
typedef struct CYASSL_X509 CYASSL_X509;
|
||||
typedef struct CYASSL_X509_NAME CYASSL_X509_NAME;
|
||||
typedef struct CYASSL_X509_CHAIN CYASSL_X509_CHAIN;
|
||||
|
||||
typedef struct CYASSL_CERT_MANAGER CYASSL_CERT_MANAGER;
|
||||
|
||||
/* redeclare guard */
|
||||
#define CYASSL_TYPES_DEFINED
|
||||
|
||||
|
||||
typedef struct CYASSL_RSA CYASSL_RSA;
|
||||
typedef struct CYASSL_DSA CYASSL_DSA;
|
||||
typedef struct CYASSL_CIPHER CYASSL_CIPHER;
|
||||
typedef struct CYASSL_X509_LOOKUP CYASSL_X509_LOOKUP;
|
||||
typedef struct CYASSL_X509_LOOKUP_METHOD CYASSL_X509_LOOKUP_METHOD;
|
||||
typedef struct CYASSL_X509_CRL CYASSL_X509_CRL;
|
||||
typedef struct CYASSL_BIO CYASSL_BIO;
|
||||
typedef struct CYASSL_BIO_METHOD CYASSL_BIO_METHOD;
|
||||
typedef struct CYASSL_X509_EXTENSION CYASSL_X509_EXTENSION;
|
||||
typedef struct CYASSL_ASN1_TIME CYASSL_ASN1_TIME;
|
||||
typedef struct CYASSL_ASN1_INTEGER CYASSL_ASN1_INTEGER;
|
||||
typedef struct CYASSL_ASN1_OBJECT CYASSL_ASN1_OBJECT;
|
||||
typedef struct CYASSL_ASN1_STRING CYASSL_ASN1_STRING;
|
||||
typedef struct CYASSL_dynlock_value CYASSL_dynlock_value;
|
||||
|
||||
#define CYASSL_ASN1_UTCTIME CYASSL_ASN1_TIME
|
||||
|
||||
typedef struct CYASSL_EVP_PKEY {
|
||||
int type; /* openssh dereference */
|
||||
int save_type; /* openssh dereference */
|
||||
} CYASSL_EVP_PKEY;
|
||||
|
||||
typedef struct CYASSL_MD4_CTX {
|
||||
int buffer[32]; /* big enough to hold, check size in Init */
|
||||
} CYASSL_MD4_CTX;
|
||||
|
||||
|
||||
typedef struct CYASSL_COMP_METHOD {
|
||||
int type; /* stunnel dereference */
|
||||
} CYASSL_COMP_METHOD;
|
||||
|
||||
|
||||
typedef struct CYASSL_X509_STORE {
|
||||
int cache; /* stunnel dereference */
|
||||
} CYASSL_X509_STORE;
|
||||
|
||||
|
||||
typedef struct CYASSL_X509_REVOKED {
|
||||
CYASSL_ASN1_INTEGER* serialNumber; /* stunnel dereference */
|
||||
} CYASSL_X509_REVOKED;
|
||||
|
||||
|
||||
typedef struct CYASSL_X509_OBJECT {
|
||||
union {
|
||||
char* ptr;
|
||||
CYASSL_X509_CRL* crl; /* stunnel dereference */
|
||||
} data;
|
||||
} CYASSL_X509_OBJECT;
|
||||
|
||||
|
||||
/* in internal.h too, change there !! */
|
||||
typedef struct CYASSL_X509_STORE_CTX {
|
||||
int error;
|
||||
int error_depth;
|
||||
CYASSL_X509* current_cert; /* stunnel dereference */
|
||||
char* domain; /* subject CN domain name */
|
||||
void* ex_data; /* external data, for fortress build */
|
||||
/* in internal.h too, change there !! */
|
||||
} CYASSL_X509_STORE_CTX;
|
||||
|
||||
|
||||
CYASSL_API CYASSL_METHOD *CyaSSLv3_server_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaSSLv3_client_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaTLSv1_server_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaTLSv1_client_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaTLSv1_1_server_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaTLSv1_1_client_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaTLSv1_2_server_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaTLSv1_2_client_method(void);
|
||||
|
||||
#ifdef CYASSL_DTLS
|
||||
CYASSL_API CYASSL_METHOD *CyaDTLSv1_client_method(void);
|
||||
CYASSL_API CYASSL_METHOD *CyaDTLSv1_server_method(void);
|
||||
#endif
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
|
||||
CYASSL_API int CyaSSL_CTX_use_certificate_file(CYASSL_CTX*, const char*, int);
|
||||
CYASSL_API int CyaSSL_CTX_use_PrivateKey_file(CYASSL_CTX*, const char*, int);
|
||||
CYASSL_API int CyaSSL_CTX_load_verify_locations(CYASSL_CTX*, const char*,
|
||||
const char*);
|
||||
CYASSL_API int CyaSSL_CTX_use_certificate_chain_file(CYASSL_CTX *,
|
||||
const char *file);
|
||||
CYASSL_API int CyaSSL_CTX_use_RSAPrivateKey_file(CYASSL_CTX*, const char*, int);
|
||||
|
||||
CYASSL_API int CyaSSL_use_certificate_file(CYASSL*, const char*, int);
|
||||
CYASSL_API int CyaSSL_use_PrivateKey_file(CYASSL*, const char*, int);
|
||||
CYASSL_API int CyaSSL_use_certificate_chain_file(CYASSL*, const char *file);
|
||||
CYASSL_API int CyaSSL_use_RSAPrivateKey_file(CYASSL*, const char*, int);
|
||||
|
||||
#ifdef CYASSL_DER_LOAD
|
||||
CYASSL_API int CyaSSL_CTX_der_load_verify_locations(CYASSL_CTX*,
|
||||
const char*, int);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NTRU
|
||||
CYASSL_API int CyaSSL_CTX_use_NTRUPrivateKey_file(CYASSL_CTX*, const char*);
|
||||
/* load NTRU private key blob */
|
||||
#endif
|
||||
|
||||
CYASSL_API int CyaSSL_PemCertToDer(const char*, unsigned char*, int);
|
||||
|
||||
#endif /* NO_FILESYSTEM */
|
||||
|
||||
CYASSL_API CYASSL_CTX* CyaSSL_CTX_new(CYASSL_METHOD*);
|
||||
CYASSL_API CYASSL* CyaSSL_new(CYASSL_CTX*);
|
||||
CYASSL_API int CyaSSL_set_fd (CYASSL*, int);
|
||||
CYASSL_API int CyaSSL_get_fd(const CYASSL*);
|
||||
CYASSL_API int CyaSSL_connect(CYASSL*); /* please see note at top of README
|
||||
if you get an error from connect */
|
||||
CYASSL_API int CyaSSL_write(CYASSL*, const void*, int);
|
||||
CYASSL_API int CyaSSL_read(CYASSL*, void*, int);
|
||||
CYASSL_API int CyaSSL_accept(CYASSL*);
|
||||
CYASSL_API void CyaSSL_CTX_free(CYASSL_CTX*);
|
||||
CYASSL_API void CyaSSL_free(CYASSL*);
|
||||
CYASSL_API int CyaSSL_shutdown(CYASSL*);
|
||||
|
||||
CYASSL_API void CyaSSL_CTX_set_quiet_shutdown(CYASSL_CTX*, int);
|
||||
CYASSL_API void CyaSSL_set_quiet_shutdown(CYASSL*, int);
|
||||
|
||||
CYASSL_API int CyaSSL_get_error(CYASSL*, int);
|
||||
|
||||
CYASSL_API int CyaSSL_set_session(CYASSL* ssl,CYASSL_SESSION* session);
|
||||
CYASSL_API CYASSL_SESSION* CyaSSL_get_session(CYASSL* ssl);
|
||||
CYASSL_API void CyaSSL_flush_sessions(CYASSL_CTX *ctx, long tm);
|
||||
|
||||
|
||||
typedef int (*VerifyCallback)(int, CYASSL_X509_STORE_CTX*);
|
||||
typedef int (*pem_password_cb)(char*, int, int, void*);
|
||||
|
||||
CYASSL_API void CyaSSL_CTX_set_verify(CYASSL_CTX*, int,
|
||||
VerifyCallback verify_callback);
|
||||
CYASSL_API void CyaSSL_set_verify(CYASSL*, int, VerifyCallback verify_callback);
|
||||
|
||||
CYASSL_API int CyaSSL_pending(CYASSL*);
|
||||
|
||||
CYASSL_API void CyaSSL_load_error_strings(void);
|
||||
CYASSL_API int CyaSSL_library_init(void);
|
||||
CYASSL_API long CyaSSL_CTX_set_session_cache_mode(CYASSL_CTX*, long);
|
||||
|
||||
/* only supports full name from cipher_name[] delimited by : */
|
||||
CYASSL_API int CyaSSL_CTX_set_cipher_list(CYASSL_CTX*, const char*);
|
||||
CYASSL_API int CyaSSL_set_cipher_list(CYASSL*, const char*);
|
||||
|
||||
CYASSL_API int CyaSSL_ERR_GET_REASON(int err);
|
||||
CYASSL_API char* CyaSSL_ERR_error_string(unsigned long,char*);
|
||||
CYASSL_API void CyaSSL_ERR_error_string_n(unsigned long e, char* buf,
|
||||
unsigned long sz);
|
||||
|
||||
/* extras */
|
||||
|
||||
#define STACK_OF(x) x
|
||||
|
||||
CYASSL_API int CyaSSL_set_ex_data(CYASSL*, int, void*);
|
||||
CYASSL_API int CyaSSL_get_shutdown(const CYASSL*);
|
||||
CYASSL_API int CyaSSL_set_rfd(CYASSL*, int);
|
||||
CYASSL_API int CyaSSL_set_wfd(CYASSL*, int);
|
||||
CYASSL_API void CyaSSL_set_shutdown(CYASSL*, int);
|
||||
CYASSL_API int CyaSSL_set_session_id_context(CYASSL*, const unsigned char*,
|
||||
unsigned int);
|
||||
CYASSL_API void CyaSSL_set_connect_state(CYASSL*);
|
||||
CYASSL_API void CyaSSL_set_accept_state(CYASSL*);
|
||||
CYASSL_API int CyaSSL_session_reused(CYASSL*);
|
||||
CYASSL_API void CyaSSL_SESSION_free(CYASSL_SESSION* session);
|
||||
CYASSL_API int CyaSSL_is_init_finished(CYASSL*);
|
||||
|
||||
CYASSL_API const char* CyaSSL_get_version(CYASSL*);
|
||||
CYASSL_API CYASSL_CIPHER* CyaSSL_get_current_cipher(CYASSL*);
|
||||
CYASSL_API char* CyaSSL_CIPHER_description(CYASSL_CIPHER*, char*, int);
|
||||
CYASSL_API const char* CyaSSL_CIPHER_get_name(const CYASSL_CIPHER* cipher);
|
||||
CYASSL_API const char* CyaSSL_get_cipher(CYASSL*);
|
||||
CYASSL_API CYASSL_SESSION* CyaSSL_get1_session(CYASSL* ssl);
|
||||
/* what's ref count */
|
||||
|
||||
CYASSL_API void CyaSSL_X509_free(CYASSL_X509*);
|
||||
CYASSL_API void CyaSSL_OPENSSL_free(void*);
|
||||
|
||||
CYASSL_API int CyaSSL_OCSP_parse_url(char* url, char** host, char** port,
|
||||
char** path, int* ssl);
|
||||
|
||||
CYASSL_API CYASSL_METHOD* CyaSSLv23_client_method(void);
|
||||
CYASSL_API CYASSL_METHOD* CyaSSLv2_client_method(void);
|
||||
CYASSL_API CYASSL_METHOD* CyaSSLv2_server_method(void);
|
||||
|
||||
CYASSL_API void CyaSSL_MD4_Init(CYASSL_MD4_CTX*);
|
||||
CYASSL_API void CyaSSL_MD4_Update(CYASSL_MD4_CTX*, const void*, unsigned long);
|
||||
CYASSL_API void CyaSSL_MD4_Final(unsigned char*, CYASSL_MD4_CTX*);
|
||||
|
||||
|
||||
CYASSL_API CYASSL_BIO* CyaSSL_BIO_new(CYASSL_BIO_METHOD*);
|
||||
CYASSL_API int CyaSSL_BIO_free(CYASSL_BIO*);
|
||||
CYASSL_API int CyaSSL_BIO_free_all(CYASSL_BIO*);
|
||||
CYASSL_API int CyaSSL_BIO_read(CYASSL_BIO*, void*, int);
|
||||
CYASSL_API int CyaSSL_BIO_write(CYASSL_BIO*, const void*, int);
|
||||
CYASSL_API CYASSL_BIO* CyaSSL_BIO_push(CYASSL_BIO*, CYASSL_BIO* append);
|
||||
CYASSL_API CYASSL_BIO* CyaSSL_BIO_pop(CYASSL_BIO*);
|
||||
CYASSL_API int CyaSSL_BIO_flush(CYASSL_BIO*);
|
||||
CYASSL_API int CyaSSL_BIO_pending(CYASSL_BIO*);
|
||||
|
||||
CYASSL_API CYASSL_BIO_METHOD* CyaSSL_BIO_f_buffer(void);
|
||||
CYASSL_API long CyaSSL_BIO_set_write_buffer_size(CYASSL_BIO*, long size);
|
||||
CYASSL_API CYASSL_BIO_METHOD* CyaSSL_BIO_f_ssl(void);
|
||||
CYASSL_API CYASSL_BIO* CyaSSL_BIO_new_socket(int sfd, int flag);
|
||||
CYASSL_API int CyaSSL_BIO_eof(CYASSL_BIO*);
|
||||
|
||||
CYASSL_API CYASSL_BIO_METHOD* CyaSSL_BIO_s_mem(void);
|
||||
CYASSL_API CYASSL_BIO_METHOD* CyaSSL_BIO_f_base64(void);
|
||||
CYASSL_API void CyaSSL_BIO_set_flags(CYASSL_BIO*, int);
|
||||
|
||||
CYASSL_API int CyaSSL_BIO_get_mem_data(CYASSL_BIO* bio,const unsigned char** p);
|
||||
CYASSL_API CYASSL_BIO* CyaSSL_BIO_new_mem_buf(void* buf, int len);
|
||||
|
||||
|
||||
CYASSL_API long CyaSSL_BIO_set_ssl(CYASSL_BIO*, CYASSL*, int flag);
|
||||
CYASSL_API void CyaSSL_set_bio(CYASSL*, CYASSL_BIO* rd, CYASSL_BIO* wr);
|
||||
|
||||
CYASSL_API int CyaSSL_add_all_algorithms(void);
|
||||
|
||||
CYASSL_API void CyaSSL_RAND_screen(void);
|
||||
CYASSL_API const char* CyaSSL_RAND_file_name(char*, unsigned long);
|
||||
CYASSL_API int CyaSSL_RAND_write_file(const char*);
|
||||
CYASSL_API int CyaSSL_RAND_load_file(const char*, long);
|
||||
CYASSL_API int CyaSSL_RAND_egd(const char*);
|
||||
CYASSL_API int CyaSSL_RAND_seed(const void*, int);
|
||||
CYASSL_API void CyaSSL_RAND_add(const void*, int, double);
|
||||
|
||||
CYASSL_API CYASSL_COMP_METHOD* CyaSSL_COMP_zlib(void);
|
||||
CYASSL_API CYASSL_COMP_METHOD* CyaSSL_COMP_rle(void);
|
||||
CYASSL_API int CyaSSL_COMP_add_compression_method(int, void*);
|
||||
|
||||
CYASSL_API int CyaSSL_get_ex_new_index(long, void*, void*, void*, void*);
|
||||
|
||||
CYASSL_API void CyaSSL_set_id_callback(unsigned long (*f)(void));
|
||||
CYASSL_API void CyaSSL_set_locking_callback(void (*f)(int, int, const char*,
|
||||
int));
|
||||
CYASSL_API void CyaSSL_set_dynlock_create_callback(CYASSL_dynlock_value* (*f)
|
||||
(const char*, int));
|
||||
CYASSL_API void CyaSSL_set_dynlock_lock_callback(void (*f)(int,
|
||||
CYASSL_dynlock_value*, const char*, int));
|
||||
CYASSL_API void CyaSSL_set_dynlock_destroy_callback(void (*f)
|
||||
(CYASSL_dynlock_value*, const char*, int));
|
||||
CYASSL_API int CyaSSL_num_locks(void);
|
||||
|
||||
CYASSL_API CYASSL_X509* CyaSSL_X509_STORE_CTX_get_current_cert(
|
||||
CYASSL_X509_STORE_CTX*);
|
||||
CYASSL_API int CyaSSL_X509_STORE_CTX_get_error(CYASSL_X509_STORE_CTX*);
|
||||
CYASSL_API int CyaSSL_X509_STORE_CTX_get_error_depth(CYASSL_X509_STORE_CTX*);
|
||||
|
||||
CYASSL_API char* CyaSSL_X509_NAME_oneline(CYASSL_X509_NAME*, char*, int);
|
||||
CYASSL_API CYASSL_X509_NAME* CyaSSL_X509_get_issuer_name(CYASSL_X509*);
|
||||
CYASSL_API CYASSL_X509_NAME* CyaSSL_X509_get_subject_name(CYASSL_X509*);
|
||||
CYASSL_API const char* CyaSSL_X509_verify_cert_error_string(long);
|
||||
|
||||
CYASSL_API int CyaSSL_X509_LOOKUP_add_dir(CYASSL_X509_LOOKUP*,const char*,long);
|
||||
CYASSL_API int CyaSSL_X509_LOOKUP_load_file(CYASSL_X509_LOOKUP*, const char*,
|
||||
long);
|
||||
CYASSL_API CYASSL_X509_LOOKUP_METHOD* CyaSSL_X509_LOOKUP_hash_dir(void);
|
||||
CYASSL_API CYASSL_X509_LOOKUP_METHOD* CyaSSL_X509_LOOKUP_file(void);
|
||||
|
||||
CYASSL_API CYASSL_X509_LOOKUP* CyaSSL_X509_STORE_add_lookup(CYASSL_X509_STORE*,
|
||||
CYASSL_X509_LOOKUP_METHOD*);
|
||||
CYASSL_API CYASSL_X509_STORE* CyaSSL_X509_STORE_new(void);
|
||||
CYASSL_API int CyaSSL_X509_STORE_get_by_subject(CYASSL_X509_STORE_CTX*,
|
||||
int, CYASSL_X509_NAME*, CYASSL_X509_OBJECT*);
|
||||
CYASSL_API int CyaSSL_X509_STORE_CTX_init(CYASSL_X509_STORE_CTX*,
|
||||
CYASSL_X509_STORE*, CYASSL_X509*, STACK_OF(CYASSL_X509)*);
|
||||
CYASSL_API void CyaSSL_X509_STORE_CTX_cleanup(CYASSL_X509_STORE_CTX*);
|
||||
|
||||
CYASSL_API CYASSL_ASN1_TIME* CyaSSL_X509_CRL_get_lastUpdate(CYASSL_X509_CRL*);
|
||||
CYASSL_API CYASSL_ASN1_TIME* CyaSSL_X509_CRL_get_nextUpdate(CYASSL_X509_CRL*);
|
||||
|
||||
CYASSL_API CYASSL_EVP_PKEY* CyaSSL_X509_get_pubkey(CYASSL_X509*);
|
||||
CYASSL_API int CyaSSL_X509_CRL_verify(CYASSL_X509_CRL*, CYASSL_EVP_PKEY*);
|
||||
CYASSL_API void CyaSSL_X509_STORE_CTX_set_error(CYASSL_X509_STORE_CTX*,
|
||||
int);
|
||||
CYASSL_API void CyaSSL_X509_OBJECT_free_contents(CYASSL_X509_OBJECT*);
|
||||
CYASSL_API void CyaSSL_EVP_PKEY_free(CYASSL_EVP_PKEY*);
|
||||
CYASSL_API int CyaSSL_X509_cmp_current_time(const CYASSL_ASN1_TIME*);
|
||||
CYASSL_API int CyaSSL_sk_X509_REVOKED_num(CYASSL_X509_REVOKED*);
|
||||
|
||||
CYASSL_API CYASSL_X509_REVOKED* CyaSSL_X509_CRL_get_REVOKED(CYASSL_X509_CRL*);
|
||||
CYASSL_API CYASSL_X509_REVOKED* CyaSSL_sk_X509_REVOKED_value(
|
||||
CYASSL_X509_REVOKED*,int);
|
||||
CYASSL_API CYASSL_ASN1_INTEGER* CyaSSL_X509_get_serialNumber(CYASSL_X509*);
|
||||
|
||||
CYASSL_API int CyaSSL_ASN1_TIME_print(CYASSL_BIO*, const CYASSL_ASN1_TIME*);
|
||||
|
||||
CYASSL_API int CyaSSL_ASN1_INTEGER_cmp(const CYASSL_ASN1_INTEGER*,
|
||||
const CYASSL_ASN1_INTEGER*);
|
||||
CYASSL_API long CyaSSL_ASN1_INTEGER_get(const CYASSL_ASN1_INTEGER*);
|
||||
|
||||
CYASSL_API STACK_OF(CYASSL_X509_NAME)* CyaSSL_load_client_CA_file(const char*);
|
||||
|
||||
CYASSL_API void CyaSSL_CTX_set_client_CA_list(CYASSL_CTX*,
|
||||
STACK_OF(CYASSL_X509_NAME)*);
|
||||
CYASSL_API void* CyaSSL_X509_STORE_CTX_get_ex_data(CYASSL_X509_STORE_CTX*, int);
|
||||
CYASSL_API int CyaSSL_get_ex_data_X509_STORE_CTX_idx(void);
|
||||
CYASSL_API void* CyaSSL_get_ex_data(const CYASSL*, int);
|
||||
|
||||
CYASSL_API void CyaSSL_CTX_set_default_passwd_cb_userdata(CYASSL_CTX*,
|
||||
void* userdata);
|
||||
CYASSL_API void CyaSSL_CTX_set_default_passwd_cb(CYASSL_CTX*, pem_password_cb);
|
||||
|
||||
|
||||
CYASSL_API void CyaSSL_CTX_set_info_callback(CYASSL_CTX*, void (*)(void));
|
||||
|
||||
CYASSL_API unsigned long CyaSSL_ERR_peek_error(void);
|
||||
CYASSL_API int CyaSSL_GET_REASON(int);
|
||||
|
||||
CYASSL_API char* CyaSSL_alert_type_string_long(int);
|
||||
CYASSL_API char* CyaSSL_alert_desc_string_long(int);
|
||||
CYASSL_API char* CyaSSL_state_string_long(CYASSL*);
|
||||
|
||||
CYASSL_API CYASSL_RSA* CyaSSL_RSA_generate_key(int, unsigned long,
|
||||
void(*)(int, int, void*), void*);
|
||||
CYASSL_API void CyaSSL_CTX_set_tmp_rsa_callback(CYASSL_CTX*,
|
||||
CYASSL_RSA*(*)(CYASSL*, int, int));
|
||||
|
||||
CYASSL_API int CyaSSL_PEM_def_callback(char*, int num, int w, void* key);
|
||||
|
||||
CYASSL_API long CyaSSL_CTX_sess_accept(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_connect(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_accept_good(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_connect_good(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_accept_renegotiate(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_connect_renegotiate(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_hits(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_cb_hits(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_cache_full(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_misses(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_timeouts(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_number(CYASSL_CTX*);
|
||||
CYASSL_API long CyaSSL_CTX_sess_get_cache_size(CYASSL_CTX*);
|
||||
|
||||
|
||||
#define CYASSL_DEFAULT_CIPHER_LIST "" /* default all */
|
||||
#define CYASSL_RSA_F4 0x10001L
|
||||
|
||||
enum {
|
||||
OCSP_NOCERTS = 1,
|
||||
OCSP_NOINTERN = 2,
|
||||
OCSP_NOSIGS = 4,
|
||||
OCSP_NOCHAIN = 8,
|
||||
OCSP_NOVERIFY = 16,
|
||||
OCSP_NOEXPLICIT = 32,
|
||||
OCSP_NOCASIGN = 64,
|
||||
OCSP_NODELEGATED = 128,
|
||||
OCSP_NOCHECKS = 256,
|
||||
OCSP_TRUSTOTHER = 512,
|
||||
OCSP_RESPID_KEY = 1024,
|
||||
OCSP_NOTIME = 2048,
|
||||
|
||||
OCSP_CERTID = 2,
|
||||
OCSP_REQUEST = 4,
|
||||
OCSP_RESPONSE = 8,
|
||||
OCSP_BASICRESP = 16,
|
||||
|
||||
CYASSL_CRL_CHECKALL = 1,
|
||||
|
||||
ASN1_GENERALIZEDTIME = 4,
|
||||
|
||||
SSL_OP_MICROSOFT_SESS_ID_BUG = 1,
|
||||
SSL_OP_NETSCAPE_CHALLENGE_BUG = 2,
|
||||
SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 3,
|
||||
SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 4,
|
||||
SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 5,
|
||||
SSL_OP_MSIE_SSLV2_RSA_PADDING = 6,
|
||||
SSL_OP_SSLEAY_080_CLIENT_DH_BUG = 7,
|
||||
SSL_OP_TLS_D5_BUG = 8,
|
||||
SSL_OP_TLS_BLOCK_PADDING_BUG = 9,
|
||||
SSL_OP_TLS_ROLLBACK_BUG = 10,
|
||||
SSL_OP_ALL = 11,
|
||||
SSL_OP_EPHEMERAL_RSA = 12,
|
||||
SSL_OP_NO_SSLv3 = 13,
|
||||
SSL_OP_NO_TLSv1 = 14,
|
||||
SSL_OP_PKCS1_CHECK_1 = 15,
|
||||
SSL_OP_PKCS1_CHECK_2 = 16,
|
||||
SSL_OP_NETSCAPE_CA_DN_BUG = 17,
|
||||
SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 18,
|
||||
SSL_OP_SINGLE_DH_USE = 19,
|
||||
SSL_OP_NO_TICKET = 20,
|
||||
SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 21,
|
||||
SSL_OP_NO_QUERY_MTU = 22,
|
||||
SSL_OP_COOKIE_EXCHANGE = 23,
|
||||
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = 24,
|
||||
SSL_OP_SINGLE_ECDH_USE = 25,
|
||||
SSL_OP_CIPHER_SERVER_PREFERENCE = 26,
|
||||
|
||||
SSL_MAX_SSL_SESSION_ID_LENGTH = 32,
|
||||
|
||||
EVP_R_BAD_DECRYPT = 2,
|
||||
|
||||
SSL_CB_LOOP = 4,
|
||||
SSL_ST_CONNECT = 5,
|
||||
SSL_ST_ACCEPT = 6,
|
||||
SSL_CB_ALERT = 7,
|
||||
SSL_CB_READ = 8,
|
||||
SSL_CB_HANDSHAKE_DONE = 9,
|
||||
|
||||
SSL_MODE_ENABLE_PARTIAL_WRITE = 2,
|
||||
|
||||
BIO_FLAGS_BASE64_NO_NL = 1,
|
||||
BIO_CLOSE = 1,
|
||||
BIO_NOCLOSE = 0,
|
||||
|
||||
NID_undef = 0,
|
||||
|
||||
X509_FILETYPE_PEM = 8,
|
||||
X509_LU_X509 = 9,
|
||||
X509_LU_CRL = 12,
|
||||
|
||||
X509_V_ERR_CRL_SIGNATURE_FAILURE = 13,
|
||||
X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 14,
|
||||
X509_V_ERR_CRL_HAS_EXPIRED = 15,
|
||||
X509_V_ERR_CERT_REVOKED = 16,
|
||||
X509_V_ERR_CERT_CHAIN_TOO_LONG = 17,
|
||||
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 18,
|
||||
X509_V_ERR_CERT_NOT_YET_VALID = 19,
|
||||
X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 20,
|
||||
X509_V_ERR_CERT_HAS_EXPIRED = 21,
|
||||
X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 22,
|
||||
|
||||
X509_V_OK = 0,
|
||||
|
||||
CRYPTO_LOCK = 1,
|
||||
CRYPTO_NUM_LOCKS = 10
|
||||
};
|
||||
|
||||
/* extras end */
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
/* CyaSSL extension, provide last error from SSL_get_error
|
||||
since not using thread storage error queue */
|
||||
CYASSL_API void CyaSSL_ERR_print_errors_fp(FILE*, int err);
|
||||
#endif
|
||||
|
||||
enum { /* ssl Constants */
|
||||
SSL_ERROR_NONE = 0, /* for most functions */
|
||||
SSL_FAILURE = 0, /* for some functions */
|
||||
SSL_SUCCESS = 1,
|
||||
|
||||
SSL_BAD_CERTTYPE = -8,
|
||||
SSL_BAD_STAT = -7,
|
||||
SSL_BAD_PATH = -6,
|
||||
SSL_BAD_FILETYPE = -5,
|
||||
SSL_BAD_FILE = -4,
|
||||
SSL_NOT_IMPLEMENTED = -3,
|
||||
SSL_UNKNOWN = -2,
|
||||
SSL_FATAL_ERROR = -1,
|
||||
|
||||
SSL_FILETYPE_ASN1 = 2,
|
||||
SSL_FILETYPE_PEM = 1,
|
||||
SSL_FILETYPE_DEFAULT = 2, /* ASN1 */
|
||||
SSL_FILETYPE_RAW = 3, /* NTRU raw key blob */
|
||||
|
||||
SSL_VERIFY_NONE = 0,
|
||||
SSL_VERIFY_PEER = 1,
|
||||
SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2,
|
||||
SSL_VERIFY_CLIENT_ONCE = 4,
|
||||
|
||||
SSL_SESS_CACHE_OFF = 30,
|
||||
SSL_SESS_CACHE_CLIENT = 31,
|
||||
SSL_SESS_CACHE_SERVER = 32,
|
||||
SSL_SESS_CACHE_BOTH = 33,
|
||||
SSL_SESS_CACHE_NO_AUTO_CLEAR = 34,
|
||||
SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 35,
|
||||
|
||||
SSL_ERROR_WANT_READ = 2,
|
||||
SSL_ERROR_WANT_WRITE = 3,
|
||||
SSL_ERROR_WANT_CONNECT = 7,
|
||||
SSL_ERROR_WANT_ACCEPT = 8,
|
||||
SSL_ERROR_SYSCALL = 5,
|
||||
SSL_ERROR_WANT_X509_LOOKUP = 83,
|
||||
SSL_ERROR_ZERO_RETURN = 6,
|
||||
SSL_ERROR_SSL = 85,
|
||||
|
||||
SSL_SENT_SHUTDOWN = 1,
|
||||
SSL_RECEIVED_SHUTDOWN = 2,
|
||||
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = 4,
|
||||
SSL_OP_NO_SSLv2 = 8,
|
||||
|
||||
SSL_R_SSL_HANDSHAKE_FAILURE = 101,
|
||||
SSL_R_TLSV1_ALERT_UNKNOWN_CA = 102,
|
||||
SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN = 103,
|
||||
SSL_R_SSLV3_ALERT_BAD_CERTIFICATE = 104,
|
||||
|
||||
PEM_BUFSIZE = 1024
|
||||
};
|
||||
|
||||
|
||||
#ifndef NO_PSK
|
||||
typedef unsigned int (*psk_client_callback)(CYASSL*, const char*, char*,
|
||||
unsigned int, unsigned char*, unsigned int);
|
||||
CYASSL_API void CyaSSL_CTX_set_psk_client_callback(CYASSL_CTX*,
|
||||
psk_client_callback);
|
||||
CYASSL_API void CyaSSL_set_psk_client_callback(CYASSL*,psk_client_callback);
|
||||
|
||||
CYASSL_API const char* CyaSSL_get_psk_identity_hint(const CYASSL*);
|
||||
CYASSL_API const char* CyaSSL_get_psk_identity(const CYASSL*);
|
||||
|
||||
CYASSL_API int CyaSSL_CTX_use_psk_identity_hint(CYASSL_CTX*, const char*);
|
||||
CYASSL_API int CyaSSL_use_psk_identity_hint(CYASSL*, const char*);
|
||||
|
||||
typedef unsigned int (*psk_server_callback)(CYASSL*, const char*,
|
||||
unsigned char*, unsigned int);
|
||||
CYASSL_API void CyaSSL_CTX_set_psk_server_callback(CYASSL_CTX*,
|
||||
psk_server_callback);
|
||||
CYASSL_API void CyaSSL_set_psk_server_callback(CYASSL*,psk_server_callback);
|
||||
|
||||
#define PSK_TYPES_DEFINED
|
||||
#endif /* NO_PSK */
|
||||
|
||||
|
||||
/* extra begins */
|
||||
|
||||
enum { /* ERR Constants */
|
||||
ERR_TXT_STRING = 1
|
||||
};
|
||||
|
||||
CYASSL_API unsigned long CyaSSL_ERR_get_error_line_data(const char**, int*,
|
||||
const char**, int *);
|
||||
|
||||
CYASSL_API unsigned long CyaSSL_ERR_get_error(void);
|
||||
CYASSL_API void CyaSSL_ERR_clear_error(void);
|
||||
|
||||
|
||||
CYASSL_API int CyaSSL_RAND_status(void);
|
||||
CYASSL_API int CyaSSL_RAND_bytes(unsigned char* buf, int num);
|
||||
CYASSL_API CYASSL_METHOD *CyaSSLv23_server_method(void);
|
||||
CYASSL_API long CyaSSL_CTX_set_options(CYASSL_CTX*, long);
|
||||
CYASSL_API int CyaSSL_CTX_check_private_key(CYASSL_CTX*);
|
||||
|
||||
|
||||
CYASSL_API void CyaSSL_ERR_free_strings(void);
|
||||
CYASSL_API void CyaSSL_ERR_remove_state(unsigned long);
|
||||
CYASSL_API void CyaSSL_EVP_cleanup(void);
|
||||
|
||||
CYASSL_API void CyaSSL_cleanup_all_ex_data(void);
|
||||
CYASSL_API long CyaSSL_CTX_set_mode(CYASSL_CTX* ctx, long mode);
|
||||
CYASSL_API long CyaSSL_CTX_get_mode(CYASSL_CTX* ctx);
|
||||
CYASSL_API void CyaSSL_CTX_set_default_read_ahead(CYASSL_CTX* ctx, int m);
|
||||
|
||||
CYASSL_API long CyaSSL_CTX_sess_set_cache_size(CYASSL_CTX*, long);
|
||||
|
||||
CYASSL_API int CyaSSL_CTX_set_default_verify_paths(CYASSL_CTX*);
|
||||
CYASSL_API int CyaSSL_CTX_set_session_id_context(CYASSL_CTX*,
|
||||
const unsigned char*, unsigned int);
|
||||
CYASSL_API CYASSL_X509* CyaSSL_get_peer_certificate(CYASSL* ssl);
|
||||
|
||||
CYASSL_API int CyaSSL_want_read(CYASSL*);
|
||||
CYASSL_API int CyaSSL_want_write(CYASSL*);
|
||||
|
||||
CYASSL_API int CyaSSL_BIO_printf(CYASSL_BIO*, const char*, ...);
|
||||
CYASSL_API int CyaSSL_ASN1_UTCTIME_print(CYASSL_BIO*,
|
||||
const CYASSL_ASN1_UTCTIME*);
|
||||
CYASSL_API int CyaSSL_sk_num(CYASSL_X509_REVOKED*);
|
||||
CYASSL_API void* CyaSSL_sk_value(CYASSL_X509_REVOKED*, int);
|
||||
|
||||
/* stunnel 4.28 needs */
|
||||
CYASSL_API void* CyaSSL_CTX_get_ex_data(const CYASSL_CTX*, int);
|
||||
CYASSL_API int CyaSSL_CTX_set_ex_data(CYASSL_CTX*, int, void*);
|
||||
CYASSL_API void CyaSSL_CTX_sess_set_get_cb(CYASSL_CTX*,
|
||||
CYASSL_SESSION*(*f)(CYASSL*, unsigned char*, int, int*));
|
||||
CYASSL_API void CyaSSL_CTX_sess_set_new_cb(CYASSL_CTX*,
|
||||
int (*f)(CYASSL*, CYASSL_SESSION*));
|
||||
CYASSL_API void CyaSSL_CTX_sess_set_remove_cb(CYASSL_CTX*,
|
||||
void (*f)(CYASSL_CTX*, CYASSL_SESSION*));
|
||||
|
||||
CYASSL_API int CyaSSL_i2d_SSL_SESSION(CYASSL_SESSION*,unsigned char**);
|
||||
CYASSL_API CYASSL_SESSION* CyaSSL_d2i_SSL_SESSION(CYASSL_SESSION**,const unsigned char**,
|
||||
long);
|
||||
|
||||
CYASSL_API long CyaSSL_SESSION_get_timeout(const CYASSL_SESSION*);
|
||||
CYASSL_API long CyaSSL_SESSION_get_time(const CYASSL_SESSION*);
|
||||
CYASSL_API int CyaSSL_CTX_get_ex_new_index(long, void*, void*, void*, void*);
|
||||
|
||||
/* extra ends */
|
||||
|
||||
|
||||
/* CyaSSL extensions */
|
||||
|
||||
/* call before SSL_connect, if verifying will add name check to
|
||||
date check and signature check */
|
||||
CYASSL_API int CyaSSL_check_domain_name(CYASSL* ssl, const char* dn);
|
||||
|
||||
/* need to call once to load library (session cache) */
|
||||
CYASSL_API int CyaSSL_Init(void);
|
||||
/* call when done to cleanup/free session cache mutex / resources */
|
||||
CYASSL_API int CyaSSL_Cleanup(void);
|
||||
|
||||
/* turn logging on, only if compiled in */
|
||||
CYASSL_API int CyaSSL_Debugging_ON(void);
|
||||
/* turn logging off */
|
||||
CYASSL_API void CyaSSL_Debugging_OFF(void);
|
||||
|
||||
/* do accept or connect depedning on side */
|
||||
CYASSL_API int CyaSSL_negotiate(CYASSL* ssl);
|
||||
/* turn on CyaSSL data compression */
|
||||
CYASSL_API int CyaSSL_set_compression(CYASSL* ssl);
|
||||
|
||||
CYASSL_API int CyaSSL_set_timeout(CYASSL*, unsigned int);
|
||||
CYASSL_API int CyaSSL_CTX_set_timeout(CYASSL_CTX*, unsigned int);
|
||||
|
||||
/* get CyaSSL peer X509_CHAIN */
|
||||
CYASSL_API CYASSL_X509_CHAIN* CyaSSL_get_peer_chain(CYASSL* ssl);
|
||||
/* peer chain count */
|
||||
CYASSL_API int CyaSSL_get_chain_count(CYASSL_X509_CHAIN* chain);
|
||||
/* index cert length */
|
||||
CYASSL_API int CyaSSL_get_chain_length(CYASSL_X509_CHAIN*, int idx);
|
||||
/* index cert */
|
||||
CYASSL_API unsigned char* CyaSSL_get_chain_cert(CYASSL_X509_CHAIN*, int idx);
|
||||
/* get index cert in PEM */
|
||||
CYASSL_API int CyaSSL_get_chain_cert_pem(CYASSL_X509_CHAIN*, int idx,
|
||||
unsigned char* buffer, int inLen, int* outLen);
|
||||
CYASSL_API const unsigned char* CyaSSL_get_sessionID(const CYASSL_SESSION* s);
|
||||
CYASSL_API int CyaSSL_X509_get_serial_number(CYASSL_X509*,unsigned char*,int*);
|
||||
CYASSL_API char* CyaSSL_X509_get_subjectCN(CYASSL_X509*);
|
||||
CYASSL_API const unsigned char* CyaSSL_X509_get_der(CYASSL_X509*, int*);
|
||||
|
||||
CYASSL_API int CyaSSL_cmp_peer_cert_to_file(CYASSL*, const char*);
|
||||
|
||||
CYASSL_API char* CyaSSL_X509_get_next_altname(CYASSL_X509*);
|
||||
|
||||
/* connect enough to get peer cert */
|
||||
CYASSL_API int CyaSSL_connect_cert(CYASSL* ssl);
|
||||
|
||||
/* server Diffie-Hellman parameters */
|
||||
CYASSL_API int CyaSSL_SetTmpDH(CYASSL*, const unsigned char* p, int pSz,
|
||||
const unsigned char* g, int gSz);
|
||||
CYASSL_API int CyaSSL_SetTmpDH_buffer(CYASSL*, const unsigned char* b, long sz,
|
||||
int format);
|
||||
CYASSL_API int CyaSSL_SetTmpEC_DHE_Sz(CYASSL*, unsigned short);
|
||||
#ifndef NO_FILESYSTEM
|
||||
CYASSL_API int CyaSSL_SetTmpDH_file(CYASSL*, const char* f, int format);
|
||||
#endif
|
||||
|
||||
/* server ctx Diffie-Hellman parameters */
|
||||
CYASSL_API int CyaSSL_CTX_SetTmpDH(CYASSL_CTX*, const unsigned char* p,
|
||||
int pSz, const unsigned char* g, int gSz);
|
||||
CYASSL_API int CyaSSL_CTX_SetTmpDH_buffer(CYASSL_CTX*, const unsigned char* b,
|
||||
long sz, int format);
|
||||
CYASSL_API int CyaSSL_CTX_SetTmpEC_DHE_Sz(CYASSL_CTX*, unsigned short);
|
||||
#ifndef NO_FILESYSTEM
|
||||
CYASSL_API int CyaSSL_CTX_SetTmpDH_file(CYASSL_CTX*, const char* f,
|
||||
int format);
|
||||
#endif
|
||||
|
||||
/* keyblock size in bytes or -1 */
|
||||
CYASSL_API int CyaSSL_get_keyblock_size(CYASSL*);
|
||||
CYASSL_API int CyaSSL_get_keys(CYASSL*,unsigned char** ms, unsigned int* msLen,
|
||||
unsigned char** sr, unsigned int* srLen,
|
||||
unsigned char** cr, unsigned int* crLen);
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifndef NO_WRITEV
|
||||
#ifdef __PPU
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#else
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
/* allow writev style writing */
|
||||
CYASSL_API int CyaSSL_writev(CYASSL* ssl, const struct iovec* iov,
|
||||
int iovcnt);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* SSL_CTX versions */
|
||||
CYASSL_API int CyaSSL_CTX_load_verify_buffer(CYASSL_CTX*, const unsigned char*,
|
||||
long, int);
|
||||
CYASSL_API int CyaSSL_CTX_use_certificate_buffer(CYASSL_CTX*,
|
||||
const unsigned char*, long, int);
|
||||
CYASSL_API int CyaSSL_CTX_use_PrivateKey_buffer(CYASSL_CTX*,
|
||||
const unsigned char*, long, int);
|
||||
CYASSL_API int CyaSSL_CTX_use_certificate_chain_buffer(CYASSL_CTX*,
|
||||
const unsigned char*, long);
|
||||
CYASSL_API int CyaSSL_CTX_set_group_messages(CYASSL_CTX*);
|
||||
|
||||
/* SSL versions */
|
||||
CYASSL_API int CyaSSL_use_certificate_buffer(CYASSL*, const unsigned char*,
|
||||
long, int);
|
||||
CYASSL_API int CyaSSL_use_PrivateKey_buffer(CYASSL*, const unsigned char*, long,
|
||||
int);
|
||||
CYASSL_API int CyaSSL_use_certificate_chain_buffer(CYASSL*,
|
||||
const unsigned char*, long);
|
||||
CYASSL_API int CyaSSL_set_group_messages(CYASSL*);
|
||||
|
||||
/* I/O callbacks */
|
||||
typedef int (*CallbackIORecv)(char *buf, int sz, void *ctx);
|
||||
typedef int (*CallbackIOSend)(char *buf, int sz, void *ctx);
|
||||
|
||||
CYASSL_API void CyaSSL_SetIORecv(CYASSL_CTX*, CallbackIORecv);
|
||||
CYASSL_API void CyaSSL_SetIOSend(CYASSL_CTX*, CallbackIOSend);
|
||||
|
||||
CYASSL_API void CyaSSL_SetIOReadCtx(CYASSL* ssl, void *ctx);
|
||||
CYASSL_API void CyaSSL_SetIOWriteCtx(CYASSL* ssl, void *ctx);
|
||||
|
||||
/* CA cache callbacks */
|
||||
enum {
|
||||
CYASSL_SSLV3 = 0,
|
||||
CYASSL_TLSV1 = 1,
|
||||
CYASSL_TLSV1_1 = 2,
|
||||
CYASSL_TLSV1_2 = 3,
|
||||
CYASSL_USER_CA = 1, /* user added as trusted */
|
||||
CYASSL_CHAIN_CA = 2 /* added to cache from trusted chain */
|
||||
};
|
||||
|
||||
CYASSL_API int CyaSSL_SetVersion(CYASSL* ssl, int version);
|
||||
CYASSL_API int CyaSSL_KeyPemToDer(const unsigned char*, int sz, unsigned char*,
|
||||
int, const char*);
|
||||
|
||||
typedef void (*CallbackCACache)(unsigned char* der, int sz, int type);
|
||||
typedef void (*CbMissingCRL)(const char* url);
|
||||
|
||||
CYASSL_API void CyaSSL_CTX_SetCACb(CYASSL_CTX*, CallbackCACache);
|
||||
|
||||
|
||||
CYASSL_API CYASSL_CERT_MANAGER* CyaSSL_CertManagerNew(void);
|
||||
CYASSL_API void CyaSSL_CertManagerFree(CYASSL_CERT_MANAGER*);
|
||||
|
||||
CYASSL_API int CyaSSL_CertManagerLoadCA(CYASSL_CERT_MANAGER*, const char* f,
|
||||
const char* d);
|
||||
CYASSL_API int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER*, const char* f,
|
||||
int format);
|
||||
CYASSL_API int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm,
|
||||
const unsigned char* buff, int sz, int format);
|
||||
CYASSL_API int CyaSSL_CertManagerCheckCRL(CYASSL_CERT_MANAGER*, unsigned char*,
|
||||
int sz);
|
||||
CYASSL_API int CyaSSL_CertManagerEnableCRL(CYASSL_CERT_MANAGER*, int options);
|
||||
CYASSL_API int CyaSSL_CertManagerDisableCRL(CYASSL_CERT_MANAGER*);
|
||||
CYASSL_API int CyaSSL_CertManagerLoadCRL(CYASSL_CERT_MANAGER*, const char*, int,
|
||||
int);
|
||||
CYASSL_API int CyaSSL_CertManagerSetCRL_Cb(CYASSL_CERT_MANAGER*, CbMissingCRL);
|
||||
|
||||
CYASSL_API int CyaSSL_EnableCRL(CYASSL* ssl, int options);
|
||||
CYASSL_API int CyaSSL_DisableCRL(CYASSL* ssl);
|
||||
CYASSL_API int CyaSSL_LoadCRL(CYASSL*, const char*, int, int);
|
||||
CYASSL_API int CyaSSL_SetCRL_Cb(CYASSL*, CbMissingCRL);
|
||||
|
||||
CYASSL_API int CyaSSL_CTX_EnableCRL(CYASSL_CTX* ctx, int options);
|
||||
CYASSL_API int CyaSSL_CTX_DisableCRL(CYASSL_CTX* ctx);
|
||||
CYASSL_API int CyaSSL_CTX_LoadCRL(CYASSL_CTX*, const char*, int, int);
|
||||
CYASSL_API int CyaSSL_CTX_SetCRL_Cb(CYASSL_CTX*, CbMissingCRL);
|
||||
|
||||
#define CYASSL_CRL_MONITOR 0x01 /* monitor this dir flag */
|
||||
#define CYASSL_CRL_START_MON 0x02 /* start monitoring flag */
|
||||
|
||||
#ifdef CYASSL_CALLBACKS
|
||||
|
||||
/* used internally by CyaSSL while OpenSSL types aren't */
|
||||
#include <cyassl/callbacks.h>
|
||||
|
||||
typedef int (*HandShakeCallBack)(HandShakeInfo*);
|
||||
typedef int (*TimeoutCallBack)(TimeoutInfo*);
|
||||
|
||||
/* CyaSSL connect extension allowing HandShakeCallBack and/or TimeoutCallBack
|
||||
for diagnostics */
|
||||
CYASSL_API int CyaSSL_connect_ex(CYASSL*, HandShakeCallBack, TimeoutCallBack,
|
||||
Timeval);
|
||||
CYASSL_API int CyaSSL_accept_ex(CYASSL*, HandShakeCallBack, TimeoutCallBack,
|
||||
Timeval);
|
||||
|
||||
#endif /* CYASSL_CALLBACKS */
|
||||
|
||||
|
||||
CYASSL_API long CyaSSL_CTX_OCSP_set_options(CYASSL_CTX*, long);
|
||||
CYASSL_API int CyaSSL_CTX_OCSP_set_override_url(CYASSL_CTX*, const char*);
|
||||
|
||||
/* OCSP Options */
|
||||
#define CYASSL_OCSP_ENABLE 0x0001 /* Enable OCSP lookups */
|
||||
#define CYASSL_OCSP_URL_OVERRIDE 0x0002 /* Use the override URL instead of URL
|
||||
* in certificate */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CYASSL_SSL_H */
|
||||
|
806
FreeRTOS-Plus/Source/CyaSSL/cyassl/test.h
Normal file
806
FreeRTOS-Plus/Source/CyaSSL/cyassl/test.h
Normal file
|
@ -0,0 +1,806 @@
|
|||
/* test.h */
|
||||
|
||||
#ifndef CyaSSL_TEST_H
|
||||
#define CyaSSL_TEST_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#include <winsock2.h>
|
||||
#include <process.h>
|
||||
#ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */
|
||||
#include <ws2tcpip.h>
|
||||
#include <wspiapi.h>
|
||||
#endif
|
||||
#define SOCKET_T int
|
||||
#else
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <pthread.h>
|
||||
#ifdef NON_BLOCKING
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef TEST_IPV6
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#define SOCKET_T unsigned int
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* disable conversion warning */
|
||||
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
|
||||
#pragma warning(disable:4244 4996)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__MACH__) || defined(USE_WINDOWS_API)
|
||||
#ifndef _SOCKLEN_T
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* HPUX doesn't use socklent_t for third parameter to accept */
|
||||
#if !defined(__hpux__)
|
||||
typedef socklen_t* ACCEPT_THIRD_T;
|
||||
#else
|
||||
typedef int* ACCEPT_THIRD_T;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define CloseSocket(s) closesocket(s)
|
||||
#define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
|
||||
#else
|
||||
#define CloseSocket(s) close(s)
|
||||
#define StartTCP()
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SINGLE_THREADED
|
||||
typedef unsigned int THREAD_RETURN;
|
||||
typedef void* THREAD_TYPE;
|
||||
#define CYASSL_THREAD
|
||||
#else
|
||||
#ifdef _POSIX_THREADS
|
||||
typedef void* THREAD_RETURN;
|
||||
typedef pthread_t THREAD_TYPE;
|
||||
#define CYASSL_THREAD
|
||||
#define INFINITE -1
|
||||
#define WAIT_OBJECT_0 0L
|
||||
#else
|
||||
typedef unsigned int THREAD_RETURN;
|
||||
typedef HANDLE THREAD_TYPE;
|
||||
#define CYASSL_THREAD __stdcall
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TEST_IPV6
|
||||
typedef struct sockaddr_in6 SOCKADDR_IN_T;
|
||||
#define AF_INET_V AF_INET6
|
||||
#else
|
||||
typedef struct sockaddr_in SOCKADDR_IN_T;
|
||||
#define AF_INET_V AF_INET
|
||||
#endif
|
||||
|
||||
|
||||
#define SERVER_DEFAULT_VERSION 3
|
||||
#define CLIENT_DEFAULT_VERSION 3
|
||||
|
||||
/* all certs relative to CyaSSL home directory now */
|
||||
#define caCert "./certs/ca-cert.pem"
|
||||
#define eccCert "./certs/server-ecc.pem"
|
||||
#define eccKey "./certs/ecc-key.pem"
|
||||
#define svrCert "./certs/server-cert.pem"
|
||||
#define svrKey "./certs/server-key.pem"
|
||||
#define cliCert "./certs/client-cert.pem"
|
||||
#define cliKey "./certs/client-key.pem"
|
||||
#define ntruCert "./certs/ntru-cert.pem"
|
||||
#define ntruKey "./certs/ntru-key.raw"
|
||||
#define dhParam "./certs/dh2048.pem"
|
||||
#define cliEccKey "./certs/ecc-client-key.pem"
|
||||
#define cliEccCert "./certs/client-ecc-cert.pem"
|
||||
#define crlPemDir "./certs/crl"
|
||||
|
||||
typedef struct tcp_ready {
|
||||
int ready; /* predicate */
|
||||
#ifdef _POSIX_THREADS
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
#endif
|
||||
} tcp_ready;
|
||||
|
||||
|
||||
void InitTcpReady(tcp_ready*);
|
||||
void FreeTcpReady(tcp_ready*);
|
||||
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
tcp_ready* signal;
|
||||
} func_args;
|
||||
|
||||
void wait_tcp_ready(func_args*);
|
||||
|
||||
typedef THREAD_RETURN CYASSL_THREAD THREAD_FUNC(void*);
|
||||
|
||||
void start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*);
|
||||
void join_thread(THREAD_TYPE);
|
||||
|
||||
/* yaSSL */
|
||||
static const char* const yasslIP = "127.0.0.1";
|
||||
static const word16 yasslPort = 11111;
|
||||
|
||||
|
||||
static INLINE void err_sys(const char* msg)
|
||||
{
|
||||
printf("yassl error: %s\n", msg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
#define MY_EX_USAGE 2
|
||||
|
||||
extern int myoptind;
|
||||
extern char* myoptarg;
|
||||
|
||||
static INLINE int mygetopt(int argc, char** argv, char* optstring)
|
||||
{
|
||||
static char* next = NULL;
|
||||
|
||||
char c;
|
||||
char* cp;
|
||||
|
||||
if (myoptind == 0)
|
||||
next = NULL; /* we're starting new/over */
|
||||
|
||||
if (next == NULL || *next == '\0') {
|
||||
if (myoptind == 0)
|
||||
myoptind++;
|
||||
|
||||
if (myoptind >= argc || argv[myoptind][0] != '-' ||
|
||||
argv[myoptind][1] == '\0') {
|
||||
myoptarg = NULL;
|
||||
if (myoptind < argc)
|
||||
myoptarg = argv[myoptind];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[myoptind], "--") == 0) {
|
||||
myoptind++;
|
||||
myoptarg = NULL;
|
||||
|
||||
if (myoptind < argc)
|
||||
myoptarg = argv[myoptind];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
next = argv[myoptind];
|
||||
next++; /* skip - */
|
||||
myoptind++;
|
||||
}
|
||||
|
||||
c = *next++;
|
||||
cp = strchr(optstring, c);
|
||||
|
||||
if (cp == NULL || c == ':')
|
||||
return '?';
|
||||
|
||||
cp++;
|
||||
|
||||
if (*cp == ':') {
|
||||
if (*next != '\0') {
|
||||
myoptarg = next;
|
||||
next = NULL;
|
||||
}
|
||||
else if (myoptind < argc) {
|
||||
myoptarg = argv[myoptind];
|
||||
myoptind++;
|
||||
}
|
||||
else
|
||||
return '?';
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
|
||||
static INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
|
||||
{
|
||||
strncpy(passwd, "yassl123", sz);
|
||||
return 8;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static INLINE void showPeer(CYASSL* ssl)
|
||||
{
|
||||
#ifdef OPENSSL_EXTRA
|
||||
|
||||
CYASSL_CIPHER* cipher;
|
||||
CYASSL_X509* peer = CyaSSL_get_peer_certificate(ssl);
|
||||
if (peer) {
|
||||
char* altName;
|
||||
char* issuer = CyaSSL_X509_NAME_oneline(
|
||||
CyaSSL_X509_get_issuer_name(peer), 0, 0);
|
||||
char* subject = CyaSSL_X509_NAME_oneline(
|
||||
CyaSSL_X509_get_subject_name(peer), 0, 0);
|
||||
byte serial[32];
|
||||
int ret;
|
||||
int sz = sizeof(serial);
|
||||
|
||||
printf("peer's cert info:\n issuer : %s\n subject: %s\n", issuer,
|
||||
subject);
|
||||
|
||||
while ( (altName = CyaSSL_X509_get_next_altname(peer)) )
|
||||
printf(" altname = %s\n", altName);
|
||||
|
||||
ret = CyaSSL_X509_get_serial_number(peer, serial, &sz);
|
||||
if (ret == 0) {
|
||||
int i;
|
||||
int strLen;
|
||||
char serialMsg[80];
|
||||
|
||||
/* testsuite has multiple threads writing to stdout, get output
|
||||
message ready to write once */
|
||||
strLen = sprintf(serialMsg, " serial number");
|
||||
for (i = 0; i < sz; i++)
|
||||
sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]);
|
||||
printf("%s\n", serialMsg);
|
||||
}
|
||||
|
||||
XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
XFREE(issuer, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
}
|
||||
else
|
||||
printf("peer has no cert!\n");
|
||||
printf("SSL version is %s\n", CyaSSL_get_version(ssl));
|
||||
|
||||
cipher = CyaSSL_get_current_cipher(ssl);
|
||||
printf("SSL cipher suite is %s\n", CyaSSL_CIPHER_get_name(cipher));
|
||||
#endif
|
||||
|
||||
#if defined(SESSION_CERTS) && defined(SHOW_CERTS)
|
||||
{
|
||||
CYASSL_X509_CHAIN* chain = CyaSSL_get_peer_chain(ssl);
|
||||
int count = CyaSSL_get_chain_count(chain);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int length;
|
||||
unsigned char buffer[3072];
|
||||
|
||||
CyaSSL_get_chain_cert_pem(chain,i,buffer, sizeof(buffer), &length);
|
||||
buffer[length] = 0;
|
||||
printf("cert %d has length %d data = \n%s\n", i, length, buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
static INLINE void tcp_socket(SOCKET_T* sockfd, SOCKADDR_IN_T* addr,
|
||||
const char* peer, word16 port, int udp)
|
||||
{
|
||||
#ifndef TEST_IPV6
|
||||
const char* host = peer;
|
||||
|
||||
/* peer could be in human readable form */
|
||||
if (peer != INADDR_ANY && isalpha(peer[0])) {
|
||||
struct hostent* entry = gethostbyname(peer);
|
||||
|
||||
if (entry) {
|
||||
struct sockaddr_in tmp;
|
||||
memset(&tmp, 0, sizeof(struct sockaddr_in));
|
||||
memcpy(&tmp.sin_addr.s_addr, entry->h_addr_list[0],
|
||||
entry->h_length);
|
||||
host = inet_ntoa(tmp.sin_addr);
|
||||
}
|
||||
else
|
||||
err_sys("no entry for host");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (udp)
|
||||
*sockfd = socket(AF_INET_V, SOCK_DGRAM, 0);
|
||||
else
|
||||
*sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
|
||||
memset(addr, 0, sizeof(SOCKADDR_IN_T));
|
||||
|
||||
#ifndef TEST_IPV6
|
||||
addr->sin_family = AF_INET_V;
|
||||
addr->sin_port = htons(port);
|
||||
if (host == INADDR_ANY)
|
||||
addr->sin_addr.s_addr = INADDR_ANY;
|
||||
else
|
||||
addr->sin_addr.s_addr = inet_addr(host);
|
||||
#else
|
||||
addr->sin6_family = AF_INET_V;
|
||||
addr->sin6_port = htons(port);
|
||||
addr->sin6_addr = in6addr_loopback;
|
||||
#endif
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
#ifdef SO_NOSIGPIPE
|
||||
{
|
||||
int on = 1;
|
||||
socklen_t len = sizeof(on);
|
||||
int res = setsockopt(*sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, len);
|
||||
if (res < 0)
|
||||
err_sys("setsockopt SO_NOSIGPIPE failed\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TCP_NODELAY)
|
||||
if (!udp)
|
||||
{
|
||||
int on = 1;
|
||||
socklen_t len = sizeof(on);
|
||||
int res = setsockopt(*sockfd, IPPROTO_TCP, TCP_NODELAY, &on, len);
|
||||
if (res < 0)
|
||||
err_sys("setsockopt TCP_NODELAY failed\n");
|
||||
}
|
||||
#endif
|
||||
#endif /* USE_WINDOWS_API */
|
||||
}
|
||||
|
||||
|
||||
static INLINE void tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port,
|
||||
int udp)
|
||||
{
|
||||
SOCKADDR_IN_T addr;
|
||||
tcp_socket(sockfd, &addr, ip, port, udp);
|
||||
|
||||
if (connect(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
|
||||
err_sys("tcp connect failed");
|
||||
}
|
||||
|
||||
|
||||
static INLINE void tcp_listen(SOCKET_T* sockfd, int port, int useAnyAddr,
|
||||
int udp)
|
||||
{
|
||||
SOCKADDR_IN_T addr;
|
||||
|
||||
/* don't use INADDR_ANY by default, firewall may block, make user switch
|
||||
on */
|
||||
if (useAnyAddr)
|
||||
tcp_socket(sockfd, &addr, INADDR_ANY, port, udp);
|
||||
else
|
||||
tcp_socket(sockfd, &addr, yasslIP, port, udp);
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
{
|
||||
int on = 1;
|
||||
socklen_t len = sizeof(on);
|
||||
setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bind(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
|
||||
err_sys("tcp bind failed");
|
||||
if (!udp) {
|
||||
if (listen(*sockfd, 5) != 0)
|
||||
err_sys("tcp listen failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static INLINE int udp_read_connect(SOCKET_T sockfd)
|
||||
{
|
||||
SOCKADDR_IN_T cliaddr;
|
||||
byte b[1500];
|
||||
int n;
|
||||
socklen_t len = sizeof(cliaddr);
|
||||
|
||||
n = recvfrom(sockfd, (char*)b, sizeof(b), MSG_PEEK,
|
||||
(struct sockaddr*)&cliaddr, &len);
|
||||
if (n > 0) {
|
||||
if (connect(sockfd, (const struct sockaddr*)&cliaddr,
|
||||
sizeof(cliaddr)) != 0)
|
||||
err_sys("udp connect failed");
|
||||
}
|
||||
else
|
||||
err_sys("recvfrom failed");
|
||||
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
static INLINE void udp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args)
|
||||
{
|
||||
SOCKADDR_IN_T addr;
|
||||
|
||||
tcp_socket(sockfd, &addr, yasslIP, yasslPort, 1);
|
||||
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
{
|
||||
int on = 1;
|
||||
socklen_t len = sizeof(on);
|
||||
setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bind(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
|
||||
err_sys("tcp bind failed");
|
||||
|
||||
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
|
||||
/* signal ready to accept data */
|
||||
{
|
||||
tcp_ready* ready = args->signal;
|
||||
pthread_mutex_lock(&ready->mutex);
|
||||
ready->ready = 1;
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
*clientfd = udp_read_connect(*sockfd);
|
||||
}
|
||||
|
||||
static INLINE void tcp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args,
|
||||
int port, int useAnyAddr, int udp)
|
||||
{
|
||||
SOCKADDR_IN_T client;
|
||||
socklen_t client_len = sizeof(client);
|
||||
|
||||
if (udp) {
|
||||
udp_accept(sockfd, clientfd, args);
|
||||
return;
|
||||
}
|
||||
|
||||
tcp_listen(sockfd, port, useAnyAddr, udp);
|
||||
|
||||
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
|
||||
/* signal ready to tcp_accept */
|
||||
{
|
||||
tcp_ready* ready = args->signal;
|
||||
pthread_mutex_lock(&ready->mutex);
|
||||
ready->ready = 1;
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
*clientfd = accept(*sockfd, (struct sockaddr*)&client,
|
||||
(ACCEPT_THIRD_T)&client_len);
|
||||
if (*clientfd == -1)
|
||||
err_sys("tcp accept failed");
|
||||
}
|
||||
|
||||
|
||||
static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
|
||||
{
|
||||
#ifdef NON_BLOCKING
|
||||
#ifdef USE_WINDOWS_API
|
||||
unsigned long blocking = 1;
|
||||
int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
|
||||
#else
|
||||
int flags = fcntl(*sockfd, F_GETFL, 0);
|
||||
int ret = fcntl(*sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_PSK
|
||||
|
||||
static INLINE unsigned int my_psk_client_cb(CYASSL* ssl, const char* hint,
|
||||
char* identity, unsigned int id_max_len, unsigned char* key,
|
||||
unsigned int key_max_len)
|
||||
{
|
||||
/* identity is OpenSSL testing default for openssl s_client, keep same */
|
||||
strncpy(identity, "Client_identity", id_max_len);
|
||||
|
||||
|
||||
/* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
|
||||
unsigned binary */
|
||||
key[0] = 26;
|
||||
key[1] = 43;
|
||||
key[2] = 60;
|
||||
key[3] = 77;
|
||||
|
||||
return 4; /* length of key in octets or 0 for error */
|
||||
}
|
||||
|
||||
|
||||
static INLINE unsigned int my_psk_server_cb(CYASSL* ssl, const char* identity,
|
||||
unsigned char* key, unsigned int key_max_len)
|
||||
{
|
||||
/* identity is OpenSSL testing default for openssl s_client, keep same */
|
||||
if (strncmp(identity, "Client_identity", 15) != 0)
|
||||
return 0;
|
||||
|
||||
/* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
|
||||
unsigned binary */
|
||||
key[0] = 26;
|
||||
key[1] = 43;
|
||||
key[2] = 60;
|
||||
key[3] = 77;
|
||||
|
||||
return 4; /* length of key in octets or 0 for error */
|
||||
}
|
||||
|
||||
#endif /* NO_PSK */
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
static INLINE double current_time()
|
||||
{
|
||||
static int init = 0;
|
||||
static LARGE_INTEGER freq;
|
||||
|
||||
LARGE_INTEGER count;
|
||||
|
||||
if (!init) {
|
||||
QueryPerformanceFrequency(&freq);
|
||||
init = 1;
|
||||
}
|
||||
|
||||
QueryPerformanceCounter(&count);
|
||||
|
||||
return (double)count.QuadPart / freq.QuadPart;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
static INLINE double current_time()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
|
||||
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
|
||||
}
|
||||
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
|
||||
#ifdef NO_FILESYSTEM
|
||||
|
||||
enum {
|
||||
CYASSL_CA = 1,
|
||||
CYASSL_CERT = 2,
|
||||
CYASSL_KEY = 3
|
||||
};
|
||||
|
||||
static INLINE void load_buffer(CYASSL_CTX* ctx, const char* fname, int type)
|
||||
{
|
||||
/* test buffer load */
|
||||
long sz = 0;
|
||||
byte buff[10000];
|
||||
FILE* file = fopen(fname, "rb");
|
||||
|
||||
if (!file)
|
||||
err_sys("can't open file for buffer load "
|
||||
"Please run from CyaSSL home directory if not");
|
||||
fseek(file, 0, SEEK_END);
|
||||
sz = ftell(file);
|
||||
rewind(file);
|
||||
fread(buff, sizeof(buff), 1, file);
|
||||
|
||||
if (type == CYASSL_CA) {
|
||||
if (CyaSSL_CTX_load_verify_buffer(ctx, buff, sz, SSL_FILETYPE_PEM)
|
||||
!= SSL_SUCCESS)
|
||||
err_sys("can't load buffer ca file");
|
||||
}
|
||||
else if (type == CYASSL_CERT) {
|
||||
if (CyaSSL_CTX_use_certificate_buffer(ctx, buff, sz,
|
||||
SSL_FILETYPE_PEM) != SSL_SUCCESS)
|
||||
err_sys("can't load buffer cert file");
|
||||
}
|
||||
else if (type == CYASSL_KEY) {
|
||||
if (CyaSSL_CTX_use_PrivateKey_buffer(ctx, buff, sz,
|
||||
SSL_FILETYPE_PEM) != SSL_SUCCESS)
|
||||
err_sys("can't load buffer key file");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NO_FILESYSTEM */
|
||||
|
||||
#ifdef VERIFY_CALLBACK
|
||||
|
||||
static INLINE int myVerify(int preverify, CYASSL_X509_STORE_CTX* store)
|
||||
{
|
||||
char buffer[80];
|
||||
|
||||
printf("In verification callback, error = %d, %s\n", store->error,
|
||||
CyaSSL_ERR_error_string(store->error, buffer));
|
||||
#ifdef OPENSSL_EXTRA
|
||||
CYASSL_X509* peer = store->current_cert;
|
||||
if (peer) {
|
||||
char* issuer = CyaSSL_X509_NAME_oneline(
|
||||
CyaSSL_X509_get_issuer_name(peer), 0, 0);
|
||||
char* subject = CyaSSL_X509_NAME_oneline(
|
||||
CyaSSL_X509_get_subject_name(peer), 0, 0);
|
||||
printf("peer's cert info:\n issuer : %s\n subject: %s\n", issuer,
|
||||
subject);
|
||||
XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
XFREE(issuer, 0, DYNAMIC_TYPE_OPENSSL);
|
||||
}
|
||||
else
|
||||
printf("peer has no cert!\n");
|
||||
#endif
|
||||
printf("Subject's domain name is %s\n", store->domain);
|
||||
|
||||
printf("Allowing to continue anyway (shouldn't do this, EVER!!!)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* VERIFY_CALLBACK */
|
||||
|
||||
|
||||
#ifdef HAVE_CRL
|
||||
|
||||
static void INLINE CRL_CallBack(const char* url)
|
||||
{
|
||||
printf("CRL callback url = %s\n", url);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static INLINE void CaCb(unsigned char* der, int sz, int type)
|
||||
{
|
||||
printf("Got CA cache add callback, derSz = %d, type = %d\n", sz, type);
|
||||
}
|
||||
|
||||
|
||||
static INLINE void SetDH(CYASSL* ssl)
|
||||
{
|
||||
/* dh1024 p */
|
||||
static unsigned char p[] =
|
||||
{
|
||||
0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
|
||||
0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
|
||||
0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
|
||||
0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
|
||||
0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
|
||||
0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
|
||||
0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
|
||||
0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
|
||||
0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
|
||||
0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
|
||||
0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
|
||||
};
|
||||
|
||||
/* dh1024 g */
|
||||
static unsigned char g[] =
|
||||
{
|
||||
0x02,
|
||||
};
|
||||
|
||||
CyaSSL_SetTmpDH(ssl, p, sizeof(p), g, sizeof(g));
|
||||
}
|
||||
|
||||
static INLINE void SetDHCtx(CYASSL_CTX* ctx)
|
||||
{
|
||||
/* dh1024 p */
|
||||
static unsigned char p[] =
|
||||
{
|
||||
0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
|
||||
0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
|
||||
0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
|
||||
0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
|
||||
0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
|
||||
0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
|
||||
0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
|
||||
0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
|
||||
0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
|
||||
0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
|
||||
0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
|
||||
};
|
||||
|
||||
/* dh1024 g */
|
||||
static unsigned char g[] =
|
||||
{
|
||||
0x02,
|
||||
};
|
||||
|
||||
CyaSSL_CTX_SetTmpDH(ctx, p, sizeof(p), g, sizeof(g));
|
||||
}
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
|
||||
/* do back x number of directories */
|
||||
static INLINE void ChangeDirBack(int x)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
|
||||
if (x == 1)
|
||||
strncpy(path, "..\\", MAX_PATH);
|
||||
else if (x == 2)
|
||||
strncpy(path, "..\\..\\", MAX_PATH);
|
||||
else if (x == 3)
|
||||
strncpy(path, "..\\..\\..\\", MAX_PATH);
|
||||
else if (x == 4)
|
||||
strncpy(path, "..\\..\\..\\..\\", MAX_PATH);
|
||||
else
|
||||
strncpy(path, ".\\", MAX_PATH);
|
||||
|
||||
SetCurrentDirectoryA(path);
|
||||
}
|
||||
|
||||
/* does current dir contain str */
|
||||
static INLINE int CurrentDir(const char* str)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
|
||||
GetCurrentDirectoryA(sizeof(path), path);
|
||||
if (strstr(path, str))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
/* do back x number of directories */
|
||||
static INLINE void ChangeDirBack(int x)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
|
||||
if (x == 1)
|
||||
strncpy(path, "../", MAX_PATH);
|
||||
else if (x == 2)
|
||||
strncpy(path, "../../", MAX_PATH);
|
||||
else if (x == 3)
|
||||
strncpy(path, "../../../", MAX_PATH);
|
||||
else if (x == 4)
|
||||
strncpy(path, "../../../../", MAX_PATH);
|
||||
else
|
||||
strncpy(path, "./", MAX_PATH);
|
||||
|
||||
if (chdir(path) < 0)
|
||||
printf("chdir to %s failed\n", path);
|
||||
}
|
||||
|
||||
/* does current dir contain str */
|
||||
static INLINE int CurrentDir(const char* str)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
|
||||
if (getcwd(path, sizeof(path)) == NULL) {
|
||||
printf("no current dir?\n");
|
||||
return 0;
|
||||
}
|
||||
if (strstr(path, str))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
#endif /* CyaSSL_TEST_H */
|
||||
|
35
FreeRTOS-Plus/Source/CyaSSL/cyassl/version.h
Normal file
35
FreeRTOS-Plus/Source/CyaSSL/cyassl/version.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* cyassl_version.h.in
|
||||
*
|
||||
* Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBCYASSL_VERSION_STRING "2.3.0"
|
||||
#define LIBCYASSL_VERSION_HEX 0x02003000
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
35
FreeRTOS-Plus/Source/CyaSSL/cyassl/version.h.in
Normal file
35
FreeRTOS-Plus/Source/CyaSSL/cyassl/version.h.in
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* cyassl_version.h.in
|
||||
*
|
||||
* Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL 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.
|
||||
*
|
||||
* CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBCYASSL_VERSION_STRING "@VERSION@"
|
||||
#define LIBCYASSL_VERSION_HEX @HEX_VERSION@
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue