Commit c9563b6c authored by Christopher Reis's avatar Christopher Reis

Re-updated with a bunch of extra libraries

Includes BMP180, cc3000, SSL, display, dsp, rtos, mpl3115A2, and wiznet
libraries
parent 02930aa2
No preview for this file type
http://developer.mbed.org/users/harrypowers/code/BMP180/#01c74f1b5f4d
01c74f1b5f4d3fdd80206eaaf423c412307c0ef1 4
01c74f1b5f4d3fdd80206eaaf423c412307c0ef1 default
4 01c74f1b5f4d3fdd80206eaaf423c412307c0ef1
[paths]
default = http://developer.mbed.org/users/harrypowers/code/BMP180/
revlogv1
fncache
store
dotencode
data/BMP180.cpp.i
data/BMP180.h.i
default
\ No newline at end of file
0
pull
http://developer.mbed.org/users/harrypowers/code/BMP180/
syntax: regexp
\.hgignore$
\.git$
\.svn$
\.orig$
\.msub$
\.meta$
\.ctags
\.uvproj$
\.uvopt$
\.project$
\.cproject$
\.launch$
\.project$
\.cproject$
\.launch$
Makefile$
\.ewp$
\.eww$
\ No newline at end of file
#include "BMP180.h"
BMP180::BMP180(PinName sda, PinName scl) : bmp180i2c(sda,scl)
{
bmp180i2c.frequency(BMP180FREQ);
oversampling_setting = OVERSAMPLING_HIGH_RESOLUTION;
rReg[0] = 0;
rReg[1] = 0;
rReg[2] = 0;
wReg[0] = 0;
wReg[1] = 0;
w[0] = 0xF4;
w[1] = 0xF4;
cmd = CMD_READ_CALIBRATION; // EEPROM calibration command
for (int i = 0; i < EEprom; i++) { // read the 22 registers of the EEPROM
bmp180i2c.write(BMP180ADDR, &cmd, 1);
bmp180i2c.read(BMP180ADDR, rReg, 1);
data[i] = rReg[0];
cmd += 1;
wait_ms(10);
}
// parameters AC1-AC6
//The calibration is partioned in 11 words of 16 bits, each of them representing a coefficient
ac1 = (data[0] <<8) | data[1]; // AC1(0xAA, 0xAB)... and so on
ac2 = (data[2] <<8) | data[3];
ac3 = (data[4] <<8) | data[5];
ac4 = (data[6] <<8) | data[7];
ac5 = (data[8] <<8) | data[9];
ac6 = (data[10] <<8) | data[11];
// parameters B1,B2
b1 = (data[12] <<8) | data[13];
b2 = (data[14] <<8) | data[15];
// parameters MB,MC,MD
mb = (data[16] <<8) | data[17];
mc = (data[18] <<8) | data[19];
md = (data[20] <<8) | data[21];
}
BMP180::~BMP180()
{
}
int BMP180::startTemperature() // Start temperature measurement
{
int errors = 0;
errors += bmp180i2c.write(BMP180ADDR, w, 2);
wReg[0] = 0xF4;
wReg[1] = 0x2E;
errors += bmp180i2c.write(BMP180ADDR, wReg, 2); // write 0x2E in reg 0XF4
return(errors);
}
int BMP180::readTemperature(long *t) // Get the temperature reading that was taken in startTemperature() but ensure 4.5 ms time has elapsed
{
int errors = 0;
rReg[0] = 0;
rReg[1] = 0;
rReg[2] = 0;
cmd = CMD_READ_VALUE; // 0xF6
errors += bmp180i2c.write(BMP180ADDR, &cmd, 1); // set pointer on 0xF6 before reading it?
errors += bmp180i2c.read(BMP180ADDR, rReg, 2); // read 0xF6 (MSB) and 0xF7 (LSB)// rReg is 3 long though
*t = (rReg[0] << 8) | rReg[1]; // UT = MSB << 8 + LSB
x1 = (((long) *t - (long) ac6) * (long) ac5) >> 15; // aka (ut-ac6) * ac5/pow(2,15)
x2 = ((long) mc << 11) / (x1 + md); // aka mc * pow(2, 11) / (x1 + md)
b5 = x1 + x2;
*t = ((b5 + 8) >> 4); // (b5+8)/pow(2, 4)
return(errors);
}
int BMP180::startPressure(int oversample) // Start pressure measurement! Note oversample will vary the time to complete this measurement. See defines above for oversampling constants to use!
{
int errors = 0;
oversampling_setting = BMP180::oversampleCheck(oversample);
int uncomp_pressure_cmd = 0x34 + (oversampling_setting<<6);
errors = bmp180i2c.write(BMP180ADDR, w, 2);
wReg[0] = 0xF4;
wReg[1] = uncomp_pressure_cmd;
errors += bmp180i2c.write(BMP180ADDR, wReg, 2);
return(errors);
}
int BMP180::readPressure(long *p) // Get the pressure reading that was taken in startPressure() but ensure time for the measurement to complete
{
int errors = 0;
rReg[0] = 0;
rReg[1] = 0;
rReg[2] = 0;
cmd = CMD_READ_VALUE; // 0xF6
errors += bmp180i2c.write(BMP180ADDR, &cmd, 1);
errors += bmp180i2c.read(BMP180ADDR, rReg, 3); // read 0xF6 (MSB), 0xF7 (LSB), 0xF8 (XLSB)
*p = ((rReg[0] << 16) | (rReg[1] << 8) | rReg[2]) >> (8 - oversampling_setting);
b6 = b5 - 4000; // realize b5 is set in readTemperature() function so that needs to be done first before this function!
x1 = (b6*b6) >> 12; // full formula(b2*(b6*b6)/pow(2,12))/pow(2,11)
x1 *= b2;
x1 >>= 11;
x2 = (ac2*b6);
x2 >>= 11;
x3 = x1 + x2;
b3 = (((((long)ac1 )*4 + x3) <<oversampling_setting) + 2) >> 2;
x1 = (ac3* b6) >> 13;
x2 = (b1 * ((b6*b6) >> 12) ) >> 16;
x3 = ((x1 + x2) + 2) >> 2;
b4 = (ac4 * (unsigned long) (x3 + 32768)) >> 15;
b7 = ((unsigned long) *p - b3) * (50000>>oversampling_setting);
if (b7 < 0x80000000) {
*p = (b7 << 1) / b4;
} else {
*p = (b7 / b4) << 1;
}
x1 = *p >> 8;
x1 *= x1; // pressure/pow(2,8) * pressure/pow(2, 8)
x1 = (x1 * 3038) >> 16;
x2 = ( *p * -7357) >> 16;
*p += (x1 + x2 + 3791) >> 4; // pressure in Pa
return(errors);
}
int BMP180::readTP(long *t, long *p, int oversample) // get both temperature and pressure calculations that are compensated
{
int errors = 0;
errors += BMP180::startTemperature();
wait_ms(4.5);
errors += BMP180::readTemperature(t);
errors += BMP180::startPressure(oversample);
switch (oversample) {
case OVERSAMPLING_ULTRA_LOW_POWER:
wait_ms(4.5);
break;
case OVERSAMPLING_STANDARD:
wait_ms(7.5);
break;
case OVERSAMPLING_HIGH_RESOLUTION:
wait_ms(13.5);
break;
case OVERSAMPLING_ULTRA_HIGH_RESOLUTION:
wait_ms(25.5);
break;
}
errors += BMP180::readPressure(p);
return(errors);
}
int BMP180::oversampleCheck(int oversample)
{
switch(oversample) {
case OVERSAMPLING_ULTRA_LOW_POWER:
break;
case OVERSAMPLING_STANDARD:
break;
case OVERSAMPLING_HIGH_RESOLUTION:
break;
case OVERSAMPLING_ULTRA_HIGH_RESOLUTION:
break;
default:
oversample = OVERSAMPLING_ULTRA_HIGH_RESOLUTION;
break;
}
return(oversample);
}
\ No newline at end of file
#ifndef BMP180_H
#define BMP180_H
/* BMP180 Digital Pressure Sensor Class for use with Mbed LPC1768 and other platforms
* BMP180 from Bosch Sensortec
* Copyright (c) 2013 Philip King Smith
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Bosch data sheet at: http://ae-bst.resource.bosch.com/media/products/dokumente/bmp180/BST-BMP180-DS000-09.pdf
* Some parts of the calculations used are infact from Rom Clement published Mbed code here: https://mbed.org/users/Rom/code/Barometer_bmp085/
* I only used snippets of the Rom's code because i was making this into a class and so this is structured totaly different then his code example is.
* I also used the Bosch data sheet showing the calculations and adjusted everything accordingly!
*/
#include "mbed.h"
#define EEprom 22 // The EEPROM has 176bits of calibration data (176/8 = 22 Bytes)
#define BMP180ADDR 0xEF // I2C address of BMP180 device
#define BMP180FREQ 1000000 // Data sheet says 3.4 MHz is max but not sure what mbed can do here!
#define CMD_READ_VALUE 0xF6
#define CMD_READ_CALIBRATION 0xAA
#define OVERSAMPLING_ULTRA_LOW_POWER 0 // these are the constants used in the oversample variable in the below code!
#define OVERSAMPLING_STANDARD 1
#define OVERSAMPLING_HIGH_RESOLUTION 2
#define OVERSAMPLING_ULTRA_HIGH_RESOLUTION 3
/** BMP180 Digital Pressure Sensor class using mbed's i2c class
*
* Example:
* @code
* // show how the BMP180 class works
* #include "mbed.h"
* #include "BMP180.h"
*
* int main()
* {
*
* long temp ;
* long pressure;
* int error ;
* BMP180 mybmp180(p9,p10);
* while(1) {
* error = mybmp180.readTP(&temp,&pressure,OVERSAMPLING_ULTRA_HIGH_RESOLUTION);
* printf("Temp is %ld\r\n",temp);
* printf("Pressure is %ld\r\n",pressure);
* printf("Error is %d\r\n\r\n",error);
* wait(2);
* }
* }
* @endcode
*/
class BMP180
{
public:
/** Create object connected to BMP180 pins ( remember both pins need pull up resisters)
*
* Ensure the pull up resistors are used on these pins. Also note there is no checking on
* if you use these pins p9, p10, p27, p28 so ensure you only use these ones on the LPC1768 device
*
* @param sda pin that BMP180 connected to (p9 or p28 as defined on LPC1768)
* @param slc pin that BMP180 connected to (p10 or p27 ad defined on LPC1768)
*/
BMP180(PinName sda, PinName slc); // Constructor
~BMP180(); // Destructor
/** Read Temperature and Pressure at the same time
*
* This function will only return when it has readings. This means that the time will vary depending on oversample setting!
* Note if your code can not wait for these readings to be taken and calculated you should use the functions below.
* These other functions are designed to allow your code to do other things then get the final readings.
* This function is only designed as a one shot give me the answer function.
*
* @param t the temperature fully compensated value is returned in this variable. Degrees celsius with one decimal so 253 is 25.3 C.
* @param p the barometric pressure fully compensated value is returned in this variable. Pressure is in Pa so 88007 is 88.007 kPa.
* @param oversample is the method method for reading sensor. OVERSAMPLING_ULTRA_HIGH_RESOLUTION is used if an incorrect value is passed to this function.
* @param returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
*/
int readTP(long *t, long *p, int oversample); // get both temperature and pressure fully compensated values! Note this only returns when measurements are complete
/** Start the temperature reading process but return after the commands are issued to BMP180
*
* This function is ment to start the temperature reading process but will return to allow other code to run then a reading could be made at a later time.
* Note the maximum time needed for this measurment is 4.5 ms.
*
* @param returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
*/
int startTemperature(); // Start temperature measurement
/** Reads the last temperature reading that was started with startTemperature() function
*
* This function will return the fully compensated value of the temperature in Degrees celsius with one decimal so 253 is 25.3 C.
* Note this function should normaly follow the startTemperature() function and should also preceed the startPressure() and readPressure() commands!
* Note this function should follow startTemperature() after 4.5 ms minimum has elapsed or reading will be incorrect.
*
* @param t the temperature fully compensated value is returned in this variable.
* @param returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
*/
int readTemperature(long *t); // Get the temperature reading that was taken in startTemperature() but ensure 4.5 ms time has elapsed
/** Start the pressure reading process but return after the commands are issued to BMP180
*
* This function is ment to start the pressure reading process but will return to allow other code to run then a reading could be made at a later time.
* Note the time needed for this reading pressure process will depend on oversample setting. The maximum time is 25.5 ms and minimum time is 4.5 ms.
*
* @param oversample is the method for reading sensor. OVERSAMPLING_ULTRA_HIGH_RESOLUTION is used if an incorrect value is passed to this function.
* @param returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
*/
int startPressure(int oversample); // Start pressure measurement! Note oversample will vary the time to complete this measurement. See defines above for oversampling constants to use!
/** Reads the last barometric pressure reading that was started with startPressure() function
*
* This function will return the fully compensated value of the barometric pressure in Pa.
* Note this function should follow startPressure() after the time needed to read the pressure. This time will vary but maximum time is 25.5 ms and minimum time is 4.5 ms.
* Note that this reading is dependent on temperature so the startTemperature() and readTemperature() functions should proceed this function or the pressure value will be incorrect!
*
* @param p the barometric pressure fully compensated value is returned in this variable. Pressure is in Pa so 88007 is 88.007 kPa.
* @param returns 0 for no errors during i2c communication. Any other number is just a i2c communication failure of some kind!
*/
int readPressure(long *p); // Get the pressure reading that was taken in startPressure() but ensure time for the measurement to complete
protected:
long x1;
long x2;
long x3;
short ac1;
short ac2;
short ac3;
unsigned short ac4;
unsigned short ac5;
unsigned short ac6;
short b1;
short b2;
long b3;
unsigned long b4;
long b5;
long b6;
unsigned long b7;
short mb;
short mc;
short md;
int oversampling_setting;
char rReg[3];
char wReg[2];
char cmd;
char data[EEprom];
char w[2];
I2C bmp180i2c; // the I2C class for this bmp180 communication.
int oversampleCheck(int oversample);
};
#endif
\ No newline at end of file
http://developer.mbed.org/users/toddouska/code/CyaSSL/#5045d2638c29
5045d2638c294437f81c59d0a55f56e91b95d69b 0
5045d2638c294437f81c59d0a55f56e91b95d69b default
0 5045d2638c294437f81c59d0a55f56e91b95d69b
[paths]
default = http://developer.mbed.org/users/toddouska/code/CyaSSL/
revlogv1
fncache
store
dotencode
data/integer.c.i
data/ssl.h.i
data/keys.c.i
data/sha512.h.i
data/ctc_hmac.h.i
data/asn.h.i
data/sha256.c.i
data/cyassl_int.c.i
data/mpi_superclass.h.i
data/mpi_class.h.i
data/rabbit.h.i
data/des3.h.i
data/sha256.h.i
data/asn.c.i
data/coding.h.i
data/pwdbased.h.i
data/ctc_sha.h.i
data/hc128.h.i
data/ctc_dsa.h.i
data/misc.c.i
data/random.h.i
data/cyassl_io.c.i
data/tls.c.i
data/cyassl_int.h.i
data/tfm.h.i
data/pwdbased.c.i
data/ctc_rsa.h.i
data/ssl.c.i
data/cyassl_error.h.i
data/types.h.i
data/ctc_md4.h.i
data/md4.c.i
data/ctc_ripemd.h.i
data/ctc_aes.h.i
data/hmac.c.i
data/aes.c.i
data/md5.c.i
data/coding.c.i
data/ctc_md5.h.i
data/misc.h.i
data/rsa.c.i
data/os_settings.h.i
data/arc4.h.i
data/error.h.i
data/integer.h.i
data/ctc_dh.h.i
data/random.c.i
data/arc4.c.i
data/rabbit.c.i
data/des3.c.i
data/sha.c.i
default
\ No newline at end of file
0
pull
http://developer.mbed.org/users/toddouska/code/CyaSSL/
syntax: regexp
\.hgignore$
\.git$
\.svn$
\.orig$
\.msub$
\.meta$
\.ctags
\.uvproj$
\.uvopt$
\.project$
\.cproject$
\.launch$
\.project$
\.cproject$
\.launch$
Makefile$
\.ewp$
\.eww$
\ No newline at end of file
This diff is collapsed.
/* arc4.c
*
* Copyright (C) 2006-2009 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
*/
#include "arc4.h"
void Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
{
word32 i;
word32 keyIndex = 0, stateIndex = 0;
arc4->x = 1;
arc4->y = 0;
for (i = 0; i < ARC4_STATE_SIZE; i++)
arc4->state[i] = i;
for (i = 0; i < ARC4_STATE_SIZE; i++) {
word32 a = arc4->state[i];
stateIndex += key[keyIndex] + a;
stateIndex &= 0xFF;
arc4->state[i] = arc4->state[stateIndex];
arc4->state[stateIndex] = a;
if (++keyIndex >= length)
keyIndex = 0;
}
}
static INLINE word32 MakeByte(word32* x, word32* y, byte* s)
{
word32 a = s[*x], b;
*y = (*y+a) & 0xff;
b = s[*y];
s[*x] = b;
s[*y] = a;
*x = (*x+1) & 0xff;
return s[(a+b) & 0xff];
}
void Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
{
word32 x = arc4->x;
word32 y = arc4->y;
while(length--)
*out++ = *in++ ^ MakeByte(&x, &y, arc4->state);
arc4->x = x;
arc4->y = y;
}
/* arc4.h
*
* Copyright (C) 2006-2009 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 "types.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
ARC4_STATE_SIZE = 256
};
/* ARC4 encryption and decryption */
typedef struct Arc4 {
byte x;
byte y;
byte state[ARC4_STATE_SIZE];
} Arc4;
void Arc4Process(Arc4*, byte*, const byte*, word32);
void Arc4SetKey(Arc4*, const byte*, word32);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_ARC4_H */
This diff is collapsed.
/* asn.h
*
* Copyright (C) 2006-2009 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 "types.h"
#include "ctc_rsa.h"
#include "ctc_dh.h"
#include "ctc_dsa.h"
#include "ctc_sha.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ASN Tags */
enum ASN_Tags {
ASN_INTEGER = 0x02,
ASN_BIT_STRING = 0x03,
ASN_OCTET_STRING = 0x04,
ASN_TAG_NULL = 0x05,
ASN_OBJECT_ID = 0x06,
ASN_SEQUENCE = 0x10,
ASN_SET = 0x11,
ASN_UTC_TIME = 0x17,
ASN_GENERALIZED_TIME = 0x18,
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 Misc_ASN {
ASN_NAME_MAX = 256,
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 = 25, /* sha + 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_RSA_E_SZ = 16, /* Max RSA public e size */
MAX_PUBLIC_KEY_SZ = MAX_NTRU_ENC_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ * 2,
/* use bigger NTRU size */
MAX_LENGTH_SZ = 4
};
enum Oid_Types {
hashType = 0,
sigType = 1,
keyType = 2
};
enum Sig_Sum {
SHAwDSA = 517,
MD2wRSA = 646,
MD5wRSA = 648,
SHAwRSA = 649
};
enum Hash_Sum {
MD2h = 646,
MD5h = 649,
SHAh = 88
};
enum Key_Sum {
DSAk = 515,
RSAk = 645,
NTRUk = 364
};
/* Certificate file Type */
enum CertType {
CERT_TYPE = 0,
PRIVATEKEY_TYPE,
CA_TYPE
};
enum VerifyType {
NO_VERIFY = 0,
VERIFY = 1
};
typedef 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 */
byte subjectHash[SHA_SIZE]; /* hash of all Names */
byte issuerHash[SHA_SIZE]; /* hash of all Names */
byte* signature; /* not owned, points into raw cert */
char* subjectCN; /* CommonName */
int subjectCNLen;
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 */
void* heap; /* for user memory overrides */
#ifdef CYASSL_CERT_GEN
/* easy access to sujbect 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;
#endif /* CYASSL_CERT_GEN */
} DecodedCert;
typedef struct Signer Signer;
/* 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;
};
void InitDecodedCert(DecodedCert*, byte*, void*);
void FreeDecodedCert(DecodedCert*);
int ParseCert(DecodedCert*, word32, int type, int verify, Signer* signer);
int ParseCertRelative(DecodedCert*, word32, int type, int verify,
Signer* signer);
word32 EncodeSignature(byte* out, const byte* digest, word32 digSz,int hashOID);
Signer* MakeSigner(void*);
void FreeSigners(Signer*, void*);
int RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey*, word32);
int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey*, word32);
int ToTraditional(byte* buffer, word32 length);
#ifndef NO_DH
int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, word32);
int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, word32 gSz);
#endif
#ifndef NO_DSA
int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*, word32);
int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*, word32);
#endif
#ifdef CYASSL_KEY_GEN
int RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
#endif
#if defined(CYASSL_KEY_GEN) || defined(CYASSL_CERT_GEN)
int DerToPem(const byte* der, word32 derSz, byte* output, word32 outputSz,
int type);
#endif
#ifdef CYASSL_CERT_GEN
enum cert_enums {
SERIAL_SIZE = 8,
NAME_SIZE = 64,
NAME_ENTRIES = 8,
JOINT_LEN = 2,
EMAIL_JOINT_LEN = 9,
RSA_KEY = 10,
NTRU_KEY = 11
};
typedef struct CertName {
char country[NAME_SIZE];
char state[NAME_SIZE];
char locality[NAME_SIZE];
char sur[NAME_SIZE];
char org[NAME_SIZE];
char unit[NAME_SIZE];
char commonName[NAME_SIZE];
char email[NAME_SIZE]; /* !!!! email has to be last !!!! */
} CertName;
/* for user to fill for certificate generation */
typedef struct Cert {
int version; /* x509 version */
byte serial[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 */
/* internal use only */
int bodySz; /* pre sign total size */
int keyType; /* public key type of subject */
} Cert;
/* Initialize and Set Certficate defaults:
version = 3 (0x2)
serial = 0 (Will be randomly generated)
sigType = MD5_WITH_RSA
issuer = blank
daysValid = 500
selfSigned = 1 (true) use subject as issuer
subject = blank
keyType = RSA_KEY (default)
*/
void InitCert(Cert*);
int MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, RNG*);
int SignCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, RNG*);
int MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, RNG*);
int SetIssuer(Cert*, const char*);
#ifdef HAVE_NTRU
int MakeNtruCert(Cert*, byte* derBuffer, word32 derSz, const byte* ntruKey,
word16 keySz, RNG*);
#endif
#endif /* CYASSL_CERT_GEN */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_ASN_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment