DTLS example using CyaSSL 2.7.0 and x509 certs. Doesn't work at present due to DTLS handshake failure. Debugging.
Dependencies: NTPClient VodafoneUSBModem cyassl-lib mbed-rtos mbed-src
Revision 0:35b690909566, committed 2013-09-05
- Comitter:
- ashleymills
- Date:
- Thu Sep 05 15:56:41 2013 +0000
- Commit message:
- Initial commit. Doesn't work properly. DTLS handshake fails.
Changed in this revision
diff -r 000000000000 -r 35b690909566 NTPClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPClient.lib Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/NTPClient/#881559865a93
diff -r 000000000000 -r 35b690909566 VodafoneUSBModem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VodafoneUSBModem.lib Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/VodafoneUSBModem/#f8d65dc86a97
diff -r 000000000000 -r 35b690909566 bsd_socket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bsd_socket.h Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,140 @@ +#ifndef BSD_SOCKET_H_ +#define BSD_SOCKET_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "lwip/sockets.h" + +#include "lwip/inet.h" + +#include "lwip/netdb.h" + +//Sockets + +inline int accept(int s, struct sockaddr *addr, socklen_t *addrlen) +{ + return lwip_accept(s, addr, addrlen); +} + +inline int bind(int s, const struct sockaddr *name, socklen_t namelen) +{ + return lwip_bind(s, name, namelen); +} + +inline int shutdown(int s, int how) +{ + return lwip_shutdown(s, how); +} + +inline int getsockname (int s, struct sockaddr *name, socklen_t *namelen) +{ + return lwip_getsockname(s, name, namelen); +} + +inline int getpeername (int s, struct sockaddr *name, socklen_t *namelen) +{ + return lwip_getpeername(s, name, namelen); +} + +inline int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) +{ + return lwip_getsockopt(s, level, optname, optval, optlen); +} + +inline int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen) +{ + return lwip_setsockopt(s, level, optname, optval, optlen); +} + +inline int connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + return lwip_connect(s, name, namelen); +} + +inline int listen(int s, int backlog) +{ + return lwip_listen(s, backlog); +} + +inline int recv(int s, void *mem, size_t len, int flags) +{ + return lwip_recv(s, mem, len, flags); +} + +inline int recvfrom(int s, void *mem, size_t len, int flags, + struct sockaddr *from, socklen_t *fromlen) +{ + return lwip_recvfrom(s, mem, len, flags, from, fromlen); +} + +inline int send(int s, const void *dataptr, size_t size, int flags) +{ + return lwip_send(s, dataptr, size, flags); +} + +inline int sendto(int s, const void *dataptr, size_t size, int flags, + const struct sockaddr *to, socklen_t tolen) +{ + return lwip_sendto(s, dataptr, size, flags, to, tolen); +} + +inline int socket(int domain, int type, int protocol) +{ + return lwip_socket(domain, type, protocol); +} + +inline int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, + struct timeval *timeout) +{ + return lwip_select(maxfdp1, readset, writeset, exceptset, timeout); +} + +inline int ioctlsocket(int s, long cmd, void *argp) +{ + return lwip_ioctl(s, cmd, argp); +} + +inline int read(int s, void *mem, size_t len) +{ + return lwip_read(s, mem, len); +} + +inline int write(int s, const void *dataptr, size_t size) +{ + return lwip_write(s, dataptr, size); +} + +inline int close(int s) +{ + return lwip_close(s); +} + +//DNS +/* +inline struct hostent *gethostbyname(const char *name) +{ + return lwip_gethostbyname(name); +} + +inline int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) +{ + return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop); +}*/ + +inline void freeaddrinfo(struct addrinfo *ai) +{ + return lwip_freeaddrinfo(ai); +} + +inline int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) +{ + return lwip_getaddrinfo(nodename, servname, hints, res); +} + +#ifdef __cplusplus +} +#endif + +#endif
diff -r 000000000000 -r 35b690909566 certs/device_certificate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/certs/device_certificate.h Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,151 @@ +#pragma once + +const static unsigned char deviceCertificate[] = { +/* +0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, + 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x72, 0x54, 0x43, 0x43, + 0x41, 0x68, 0x61, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x43, + 0x4d, 0x54, 0x4d, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, + 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42, 0x51, 0x41, 0x77, + 0x5a, 0x7a, 0x45, 0x4c, 0x4d, 0x41, 0x6b, 0x47, 0x41, 0x31, 0x55, 0x45, + 0x42, 0x68, 0x4d, 0x43, 0x52, 0x30, 0x49, 0x78, 0x0a, 0x45, 0x6a, 0x41, + 0x51, 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, 0x67, 0x4d, 0x43, 0x55, 0x4a, + 0x6c, 0x63, 0x6d, 0x74, 0x7a, 0x61, 0x47, 0x6c, 0x79, 0x5a, 0x54, 0x45, + 0x51, 0x4d, 0x41, 0x34, 0x47, 0x41, 0x31, 0x55, 0x45, 0x42, 0x77, 0x77, + 0x48, 0x54, 0x6d, 0x56, 0x33, 0x59, 0x6e, 0x56, 0x79, 0x65, 0x54, 0x45, + 0x52, 0x4d, 0x41, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, + 0x49, 0x0a, 0x56, 0x6d, 0x39, 0x6b, 0x59, 0x57, 0x5a, 0x76, 0x62, 0x6d, + 0x55, 0x78, 0x44, 0x44, 0x41, 0x4b, 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, + 0x73, 0x4d, 0x41, 0x31, 0x49, 0x6d, 0x52, 0x44, 0x45, 0x52, 0x4d, 0x41, + 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x77, 0x77, 0x49, 0x52, 0x45, + 0x31, 0x54, 0x5a, 0x58, 0x4a, 0x32, 0x5a, 0x58, 0x49, 0x77, 0x48, 0x68, + 0x63, 0x4e, 0x4d, 0x54, 0x4d, 0x77, 0x0a, 0x4f, 0x54, 0x41, 0x7a, 0x4d, + 0x54, 0x51, 0x77, 0x4e, 0x6a, 0x41, 0x35, 0x57, 0x68, 0x63, 0x4e, 0x4d, + 0x6a, 0x4d, 0x77, 0x4e, 0x7a, 0x45, 0x7a, 0x4d, 0x54, 0x51, 0x77, 0x4e, + 0x6a, 0x41, 0x35, 0x57, 0x6a, 0x42, 0x55, 0x4d, 0x51, 0x73, 0x77, 0x43, + 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x48, 0x51, + 0x6a, 0x45, 0x53, 0x4d, 0x42, 0x41, 0x47, 0x41, 0x31, 0x55, 0x45, 0x0a, + 0x43, 0x41, 0x77, 0x4a, 0x51, 0x6d, 0x56, 0x79, 0x61, 0x33, 0x4e, 0x6f, + 0x61, 0x58, 0x4a, 0x6c, 0x4d, 0x52, 0x45, 0x77, 0x44, 0x77, 0x59, 0x44, + 0x56, 0x51, 0x51, 0x4b, 0x44, 0x41, 0x68, 0x57, 0x62, 0x32, 0x52, 0x68, + 0x5a, 0x6d, 0x39, 0x75, 0x5a, 0x54, 0x45, 0x4d, 0x4d, 0x41, 0x6f, 0x47, + 0x41, 0x31, 0x55, 0x45, 0x43, 0x77, 0x77, 0x44, 0x55, 0x69, 0x5a, 0x45, + 0x4d, 0x52, 0x41, 0x77, 0x0a, 0x44, 0x67, 0x59, 0x44, 0x56, 0x51, 0x51, + 0x44, 0x44, 0x41, 0x64, 0x45, 0x5a, 0x58, 0x5a, 0x70, 0x59, 0x32, 0x55, + 0x78, 0x4d, 0x49, 0x47, 0x66, 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, + 0x47, 0x53, 0x49, 0x62, 0x33, 0x44, 0x51, 0x45, 0x42, 0x41, 0x51, 0x55, + 0x41, 0x41, 0x34, 0x47, 0x4e, 0x41, 0x44, 0x43, 0x42, 0x69, 0x51, 0x4b, + 0x42, 0x67, 0x51, 0x44, 0x49, 0x71, 0x41, 0x59, 0x48, 0x0a, 0x67, 0x53, + 0x53, 0x77, 0x74, 0x70, 0x4a, 0x56, 0x68, 0x78, 0x49, 0x53, 0x56, 0x46, + 0x41, 0x49, 0x31, 0x7a, 0x6e, 0x4f, 0x75, 0x74, 0x47, 0x7a, 0x62, 0x65, + 0x65, 0x37, 0x4d, 0x59, 0x6f, 0x77, 0x6f, 0x37, 0x66, 0x2b, 0x48, 0x2b, + 0x6f, 0x4e, 0x71, 0x34, 0x6b, 0x69, 0x38, 0x70, 0x50, 0x49, 0x57, 0x30, + 0x6a, 0x71, 0x63, 0x32, 0x2b, 0x48, 0x72, 0x6e, 0x41, 0x64, 0x6c, 0x42, + 0x77, 0x6d, 0x0a, 0x76, 0x67, 0x69, 0x64, 0x73, 0x64, 0x4a, 0x38, 0x77, + 0x65, 0x53, 0x32, 0x6a, 0x31, 0x36, 0x37, 0x47, 0x4f, 0x61, 0x35, 0x47, + 0x56, 0x69, 0x30, 0x7a, 0x77, 0x5a, 0x76, 0x50, 0x7a, 0x55, 0x4b, 0x44, + 0x35, 0x53, 0x43, 0x69, 0x4c, 0x45, 0x65, 0x46, 0x36, 0x56, 0x53, 0x63, + 0x36, 0x44, 0x34, 0x62, 0x51, 0x6f, 0x58, 0x62, 0x6e, 0x6f, 0x35, 0x52, + 0x30, 0x77, 0x55, 0x2f, 0x64, 0x2b, 0x64, 0x0a, 0x59, 0x6b, 0x67, 0x50, + 0x66, 0x2b, 0x6d, 0x58, 0x6c, 0x4d, 0x43, 0x34, 0x6a, 0x37, 0x64, 0x32, + 0x39, 0x50, 0x41, 0x66, 0x38, 0x63, 0x46, 0x6d, 0x76, 0x50, 0x6e, 0x33, + 0x34, 0x2f, 0x43, 0x33, 0x5a, 0x75, 0x58, 0x72, 0x43, 0x51, 0x49, 0x44, + 0x41, 0x51, 0x41, 0x42, 0x6f, 0x33, 0x73, 0x77, 0x65, 0x54, 0x41, 0x4a, + 0x42, 0x67, 0x4e, 0x56, 0x48, 0x52, 0x4d, 0x45, 0x41, 0x6a, 0x41, 0x41, + 0x0a, 0x4d, 0x43, 0x77, 0x47, 0x43, 0x57, 0x43, 0x47, 0x53, 0x41, 0x47, + 0x47, 0x2b, 0x45, 0x49, 0x42, 0x44, 0x51, 0x51, 0x66, 0x46, 0x68, 0x31, + 0x50, 0x63, 0x47, 0x56, 0x75, 0x55, 0x31, 0x4e, 0x4d, 0x49, 0x45, 0x64, + 0x6c, 0x62, 0x6d, 0x56, 0x79, 0x59, 0x58, 0x52, 0x6c, 0x5a, 0x43, 0x42, + 0x44, 0x5a, 0x58, 0x4a, 0x30, 0x61, 0x57, 0x5a, 0x70, 0x59, 0x32, 0x46, + 0x30, 0x5a, 0x54, 0x41, 0x64, 0x0a, 0x42, 0x67, 0x4e, 0x56, 0x48, 0x51, + 0x34, 0x45, 0x46, 0x67, 0x51, 0x55, 0x4c, 0x52, 0x51, 0x47, 0x51, 0x7a, + 0x79, 0x75, 0x2b, 0x41, 0x49, 0x4b, 0x48, 0x53, 0x48, 0x59, 0x59, 0x64, + 0x6d, 0x57, 0x6a, 0x38, 0x62, 0x36, 0x6e, 0x65, 0x6b, 0x77, 0x48, 0x77, + 0x59, 0x44, 0x56, 0x52, 0x30, 0x6a, 0x42, 0x42, 0x67, 0x77, 0x46, 0x6f, + 0x41, 0x55, 0x71, 0x69, 0x63, 0x61, 0x62, 0x34, 0x68, 0x79, 0x0a, 0x6a, + 0x43, 0x30, 0x74, 0x77, 0x6c, 0x72, 0x46, 0x64, 0x49, 0x4b, 0x6c, 0x52, + 0x4e, 0x45, 0x39, 0x6f, 0x78, 0x55, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, + 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42, + 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, 0x6b, 0x41, 0x64, 0x62, 0x6d, + 0x54, 0x7a, 0x55, 0x2f, 0x6b, 0x2b, 0x45, 0x5a, 0x61, 0x67, 0x37, 0x30, + 0x4b, 0x51, 0x72, 0x0a, 0x30, 0x75, 0x52, 0x66, 0x77, 0x43, 0x61, 0x76, + 0x75, 0x37, 0x4e, 0x4d, 0x72, 0x58, 0x33, 0x37, 0x45, 0x72, 0x6b, 0x54, + 0x50, 0x31, 0x4c, 0x75, 0x43, 0x30, 0x2f, 0x66, 0x4a, 0x65, 0x78, 0x54, + 0x4b, 0x63, 0x71, 0x30, 0x72, 0x66, 0x65, 0x2f, 0x72, 0x36, 0x56, 0x4d, + 0x32, 0x65, 0x6f, 0x49, 0x71, 0x55, 0x43, 0x4e, 0x47, 0x56, 0x70, 0x61, + 0x75, 0x57, 0x49, 0x55, 0x65, 0x44, 0x34, 0x4e, 0x0a, 0x38, 0x59, 0x66, + 0x4d, 0x64, 0x63, 0x47, 0x34, 0x46, 0x4d, 0x70, 0x65, 0x53, 0x39, 0x36, + 0x65, 0x78, 0x33, 0x61, 0x46, 0x6f, 0x6c, 0x30, 0x6f, 0x59, 0x6e, 0x78, + 0x63, 0x55, 0x5a, 0x61, 0x72, 0x54, 0x33, 0x36, 0x2f, 0x5a, 0x37, 0x71, + 0x6d, 0x73, 0x47, 0x4f, 0x2b, 0x76, 0x4a, 0x34, 0x66, 0x2b, 0x63, 0x57, + 0x4b, 0x39, 0x64, 0x4b, 0x6c, 0x4d, 0x53, 0x6d, 0x78, 0x4e, 0x5a, 0x44, + 0x74, 0x0a, 0x78, 0x36, 0x38, 0x76, 0x59, 0x34, 0x76, 0x43, 0x52, 0x79, + 0x75, 0x61, 0x5a, 0x61, 0x50, 0x58, 0x4b, 0x4f, 0x67, 0x5a, 0x32, 0x72, + 0x77, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, + 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x0a +*/ + + 0x30, 0x82, 0x02, 0xad, 0x30, 0x82, 0x02, 0x16, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x02, 0x31, 0x33, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x67, 0x31, 0x0b, + 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x47, 0x42, 0x31, + 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x09, 0x42, 0x65, + 0x72, 0x6b, 0x73, 0x68, 0x69, 0x72, 0x65, 0x31, 0x10, 0x30, 0x0e, 0x06, + 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x4e, 0x65, 0x77, 0x62, 0x75, 0x72, + 0x79, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, + 0x56, 0x6f, 0x64, 0x61, 0x66, 0x6f, 0x6e, 0x65, 0x31, 0x0c, 0x30, 0x0a, + 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x52, 0x26, 0x44, 0x31, 0x11, + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x44, 0x4d, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, + 0x39, 0x30, 0x33, 0x31, 0x34, 0x30, 0x36, 0x30, 0x39, 0x5a, 0x17, 0x0d, + 0x32, 0x33, 0x30, 0x37, 0x31, 0x33, 0x31, 0x34, 0x30, 0x36, 0x30, 0x39, + 0x5a, 0x30, 0x54, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, + 0x13, 0x02, 0x47, 0x42, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, + 0x08, 0x0c, 0x09, 0x42, 0x65, 0x72, 0x6b, 0x73, 0x68, 0x69, 0x72, 0x65, + 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x56, + 0x6f, 0x64, 0x61, 0x66, 0x6f, 0x6e, 0x65, 0x31, 0x0c, 0x30, 0x0a, 0x06, + 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x52, 0x26, 0x44, 0x31, 0x10, 0x30, + 0x0e, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x07, 0x44, 0x65, 0x76, 0x69, + 0x63, 0x65, 0x31, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, + 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xc8, 0xa8, 0x06, 0x07, + 0x81, 0x24, 0xb0, 0xb6, 0x92, 0x55, 0x87, 0x12, 0x12, 0x54, 0x50, 0x08, + 0xd7, 0x39, 0xce, 0xba, 0xd1, 0xb3, 0x6d, 0xe7, 0xbb, 0x31, 0x8a, 0x30, + 0xa3, 0xb7, 0xfe, 0x1f, 0xea, 0x0d, 0xab, 0x89, 0x22, 0xf2, 0x93, 0xc8, + 0x5b, 0x48, 0xea, 0x73, 0x6f, 0x87, 0xae, 0x70, 0x1d, 0x94, 0x1c, 0x26, + 0xbe, 0x08, 0x9d, 0xb1, 0xd2, 0x7c, 0xc1, 0xe4, 0xb6, 0x8f, 0x5e, 0xbb, + 0x18, 0xe6, 0xb9, 0x19, 0x58, 0xb4, 0xcf, 0x06, 0x6f, 0x3f, 0x35, 0x0a, + 0x0f, 0x94, 0x82, 0x88, 0xb1, 0x1e, 0x17, 0xa5, 0x52, 0x73, 0xa0, 0xf8, + 0x6d, 0x0a, 0x17, 0x6e, 0x7a, 0x39, 0x47, 0x4c, 0x14, 0xfd, 0xdf, 0x9d, + 0x62, 0x48, 0x0f, 0x7f, 0xe9, 0x97, 0x94, 0xc0, 0xb8, 0x8f, 0xb7, 0x76, + 0xf4, 0xf0, 0x1f, 0xf1, 0xc1, 0x66, 0xbc, 0xf9, 0xf7, 0xe3, 0xf0, 0xb7, + 0x66, 0xe5, 0xeb, 0x09, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x7b, 0x30, + 0x79, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, + 0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, + 0x0d, 0x04, 0x1f, 0x16, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, + 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, + 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x2d, 0x14, 0x06, + 0x43, 0x3c, 0xae, 0xf8, 0x02, 0x0a, 0x1d, 0x21, 0xd8, 0x61, 0xd9, 0x96, + 0x8f, 0xc6, 0xfa, 0x9d, 0xe9, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, + 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xaa, 0x27, 0x1a, 0x6f, 0x88, 0x72, + 0x8c, 0x2d, 0x2d, 0xc2, 0x5a, 0xc5, 0x74, 0x82, 0xa5, 0x44, 0xd1, 0x3d, + 0xa3, 0x15, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x90, 0x07, 0x5b, + 0x99, 0x3c, 0xd4, 0xfe, 0x4f, 0x84, 0x65, 0xa8, 0x3b, 0xd0, 0xa4, 0x2b, + 0xd2, 0xe4, 0x5f, 0xc0, 0x26, 0xaf, 0xbb, 0xb3, 0x4c, 0xad, 0x7d, 0xfb, + 0x12, 0xb9, 0x13, 0x3f, 0x52, 0xee, 0x0b, 0x4f, 0xdf, 0x25, 0xec, 0x53, + 0x29, 0xca, 0xb4, 0xad, 0xf7, 0xbf, 0xaf, 0xa5, 0x4c, 0xd9, 0xea, 0x08, + 0xa9, 0x40, 0x8d, 0x19, 0x5a, 0x5a, 0xb9, 0x62, 0x14, 0x78, 0x3e, 0x0d, + 0xf1, 0x87, 0xcc, 0x75, 0xc1, 0xb8, 0x14, 0xca, 0x5e, 0x4b, 0xde, 0x9e, + 0xc7, 0x76, 0x85, 0xa2, 0x5d, 0x28, 0x62, 0x7c, 0x5c, 0x51, 0x96, 0xab, + 0x4f, 0x7e, 0xbf, 0x67, 0xba, 0xa6, 0xb0, 0x63, 0xbe, 0xbc, 0x9e, 0x1f, + 0xf9, 0xc5, 0x8a, 0xf5, 0xd2, 0xa5, 0x31, 0x29, 0xb1, 0x35, 0x90, 0xed, + 0xc7, 0xaf, 0x2f, 0x63, 0x8b, 0xc2, 0x47, 0x2b, 0x9a, 0x65, 0xa3, 0xd7, + 0x28, 0xe8, 0x19, 0xda, 0xbc + +}; + +static const int deviceCertificateLength = sizeof(deviceCertificate); //689;
diff -r 000000000000 -r 35b690909566 certs/device_private_key.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/certs/device_private_key.h Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,138 @@ + #pragma once + + const static unsigned char devicePrivateKey[] = { + /* + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x50, + 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x64, 0x77, 0x49, 0x42, + 0x41, 0x44, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47, + 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x45, 0x46, 0x41, 0x41, 0x53, 0x43, + 0x41, 0x6d, 0x45, 0x77, 0x67, 0x67, 0x4a, 0x64, 0x41, 0x67, 0x45, 0x41, + 0x41, 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x69, 0x6f, 0x42, 0x67, 0x65, 0x42, + 0x4a, 0x4c, 0x43, 0x32, 0x6b, 0x6c, 0x57, 0x48, 0x0a, 0x45, 0x68, 0x4a, + 0x55, 0x55, 0x41, 0x6a, 0x58, 0x4f, 0x63, 0x36, 0x36, 0x30, 0x62, 0x4e, + 0x74, 0x35, 0x37, 0x73, 0x78, 0x69, 0x6a, 0x43, 0x6a, 0x74, 0x2f, 0x34, + 0x66, 0x36, 0x67, 0x32, 0x72, 0x69, 0x53, 0x4c, 0x79, 0x6b, 0x38, 0x68, + 0x62, 0x53, 0x4f, 0x70, 0x7a, 0x62, 0x34, 0x65, 0x75, 0x63, 0x42, 0x32, + 0x55, 0x48, 0x43, 0x61, 0x2b, 0x43, 0x4a, 0x32, 0x78, 0x30, 0x6e, 0x7a, + 0x42, 0x0a, 0x35, 0x4c, 0x61, 0x50, 0x58, 0x72, 0x73, 0x59, 0x35, 0x72, + 0x6b, 0x5a, 0x57, 0x4c, 0x54, 0x50, 0x42, 0x6d, 0x38, 0x2f, 0x4e, 0x51, + 0x6f, 0x50, 0x6c, 0x49, 0x4b, 0x49, 0x73, 0x52, 0x34, 0x58, 0x70, 0x56, + 0x4a, 0x7a, 0x6f, 0x50, 0x68, 0x74, 0x43, 0x68, 0x64, 0x75, 0x65, 0x6a, + 0x6c, 0x48, 0x54, 0x42, 0x54, 0x39, 0x33, 0x35, 0x31, 0x69, 0x53, 0x41, + 0x39, 0x2f, 0x36, 0x5a, 0x65, 0x55, 0x0a, 0x77, 0x4c, 0x69, 0x50, 0x74, + 0x33, 0x62, 0x30, 0x38, 0x42, 0x2f, 0x78, 0x77, 0x57, 0x61, 0x38, 0x2b, + 0x66, 0x66, 0x6a, 0x38, 0x4c, 0x64, 0x6d, 0x35, 0x65, 0x73, 0x4a, 0x41, + 0x67, 0x4d, 0x42, 0x41, 0x41, 0x45, 0x43, 0x67, 0x59, 0x41, 0x4a, 0x32, + 0x39, 0x65, 0x50, 0x2f, 0x74, 0x52, 0x69, 0x71, 0x6c, 0x57, 0x2b, 0x52, + 0x67, 0x69, 0x70, 0x52, 0x65, 0x4d, 0x34, 0x79, 0x2f, 0x70, 0x58, 0x0a, + 0x49, 0x65, 0x36, 0x7a, 0x74, 0x69, 0x36, 0x77, 0x6a, 0x39, 0x71, 0x4f, + 0x55, 0x54, 0x7a, 0x31, 0x43, 0x33, 0x52, 0x67, 0x66, 0x35, 0x45, 0x5a, + 0x57, 0x6e, 0x6e, 0x51, 0x57, 0x6b, 0x76, 0x57, 0x32, 0x52, 0x30, 0x64, + 0x75, 0x59, 0x42, 0x67, 0x73, 0x36, 0x6f, 0x2b, 0x62, 0x51, 0x2f, 0x58, + 0x54, 0x36, 0x6c, 0x62, 0x33, 0x39, 0x72, 0x77, 0x37, 0x56, 0x4a, 0x6d, + 0x49, 0x4a, 0x2b, 0x30, 0x0a, 0x44, 0x59, 0x67, 0x6a, 0x66, 0x64, 0x4a, + 0x61, 0x43, 0x6a, 0x6c, 0x71, 0x67, 0x74, 0x69, 0x49, 0x64, 0x57, 0x49, + 0x52, 0x4f, 0x57, 0x2f, 0x59, 0x4e, 0x72, 0x6f, 0x77, 0x68, 0x68, 0x55, + 0x62, 0x55, 0x65, 0x36, 0x51, 0x66, 0x56, 0x68, 0x67, 0x31, 0x62, 0x62, + 0x4a, 0x31, 0x79, 0x30, 0x6a, 0x47, 0x36, 0x4f, 0x31, 0x6a, 0x65, 0x39, + 0x64, 0x73, 0x30, 0x30, 0x53, 0x69, 0x53, 0x44, 0x75, 0x0a, 0x66, 0x2b, + 0x79, 0x42, 0x51, 0x4a, 0x66, 0x4a, 0x37, 0x72, 0x6c, 0x68, 0x49, 0x56, + 0x6f, 0x2b, 0x55, 0x51, 0x4a, 0x42, 0x41, 0x50, 0x42, 0x62, 0x52, 0x7a, + 0x48, 0x4c, 0x39, 0x4c, 0x4e, 0x64, 0x4a, 0x4e, 0x62, 0x52, 0x2b, 0x45, + 0x47, 0x64, 0x79, 0x6a, 0x33, 0x46, 0x6b, 0x47, 0x35, 0x68, 0x4d, 0x75, + 0x6e, 0x51, 0x51, 0x78, 0x4a, 0x6e, 0x63, 0x41, 0x46, 0x46, 0x6a, 0x62, + 0x33, 0x6a, 0x0a, 0x43, 0x6a, 0x41, 0x47, 0x30, 0x41, 0x37, 0x55, 0x64, + 0x66, 0x39, 0x4c, 0x48, 0x2f, 0x67, 0x74, 0x2b, 0x65, 0x46, 0x79, 0x59, + 0x4c, 0x4f, 0x39, 0x59, 0x45, 0x77, 0x2b, 0x41, 0x50, 0x45, 0x4f, 0x49, + 0x78, 0x6c, 0x2f, 0x57, 0x76, 0x35, 0x68, 0x68, 0x68, 0x4d, 0x43, 0x51, + 0x51, 0x44, 0x56, 0x74, 0x30, 0x62, 0x66, 0x35, 0x76, 0x77, 0x4f, 0x65, + 0x65, 0x72, 0x31, 0x54, 0x30, 0x74, 0x59, 0x0a, 0x44, 0x71, 0x42, 0x4b, + 0x46, 0x56, 0x4c, 0x65, 0x53, 0x67, 0x6a, 0x42, 0x52, 0x73, 0x41, 0x6c, + 0x46, 0x47, 0x51, 0x56, 0x6d, 0x6a, 0x33, 0x55, 0x5a, 0x47, 0x71, 0x74, + 0x63, 0x49, 0x65, 0x47, 0x61, 0x6a, 0x49, 0x57, 0x4c, 0x63, 0x76, 0x42, + 0x45, 0x6b, 0x76, 0x37, 0x39, 0x6d, 0x52, 0x50, 0x6a, 0x52, 0x66, 0x38, + 0x61, 0x4f, 0x69, 0x36, 0x2b, 0x39, 0x6c, 0x63, 0x64, 0x78, 0x6a, 0x46, + 0x0a, 0x76, 0x70, 0x33, 0x7a, 0x41, 0x6b, 0x45, 0x41, 0x75, 0x30, 0x51, + 0x53, 0x79, 0x79, 0x79, 0x43, 0x51, 0x63, 0x45, 0x66, 0x63, 0x37, 0x50, + 0x79, 0x50, 0x59, 0x56, 0x6e, 0x7a, 0x67, 0x73, 0x41, 0x68, 0x63, 0x39, + 0x37, 0x4d, 0x49, 0x71, 0x50, 0x78, 0x32, 0x59, 0x4a, 0x38, 0x53, 0x4f, + 0x30, 0x31, 0x4b, 0x35, 0x78, 0x41, 0x49, 0x77, 0x2b, 0x54, 0x46, 0x2b, + 0x69, 0x63, 0x37, 0x36, 0x66, 0x0a, 0x63, 0x4f, 0x69, 0x35, 0x57, 0x4c, + 0x71, 0x5a, 0x74, 0x31, 0x43, 0x6b, 0x46, 0x36, 0x4c, 0x7a, 0x62, 0x74, + 0x79, 0x35, 0x34, 0x69, 0x4c, 0x45, 0x7a, 0x59, 0x39, 0x45, 0x4f, 0x77, + 0x4a, 0x42, 0x41, 0x4b, 0x70, 0x50, 0x34, 0x31, 0x42, 0x64, 0x59, 0x44, + 0x4d, 0x64, 0x48, 0x34, 0x77, 0x63, 0x67, 0x39, 0x75, 0x4a, 0x31, 0x46, + 0x30, 0x56, 0x66, 0x7a, 0x4f, 0x63, 0x5a, 0x6a, 0x75, 0x34, 0x0a, 0x61, + 0x54, 0x6c, 0x6a, 0x64, 0x5a, 0x72, 0x74, 0x6a, 0x79, 0x5a, 0x71, 0x57, + 0x38, 0x55, 0x5a, 0x37, 0x7a, 0x62, 0x44, 0x2f, 0x47, 0x52, 0x47, 0x58, + 0x4b, 0x44, 0x68, 0x4e, 0x75, 0x4a, 0x31, 0x61, 0x56, 0x30, 0x6f, 0x41, + 0x4a, 0x78, 0x71, 0x38, 0x6b, 0x54, 0x49, 0x6e, 0x57, 0x43, 0x64, 0x6e, + 0x49, 0x56, 0x42, 0x73, 0x64, 0x63, 0x43, 0x51, 0x48, 0x48, 0x79, 0x39, + 0x43, 0x39, 0x66, 0x0a, 0x35, 0x35, 0x71, 0x42, 0x51, 0x32, 0x73, 0x33, + 0x71, 0x5a, 0x49, 0x70, 0x43, 0x6d, 0x53, 0x76, 0x67, 0x6f, 0x6f, 0x39, + 0x61, 0x70, 0x4f, 0x32, 0x32, 0x4c, 0x50, 0x57, 0x6a, 0x4e, 0x6a, 0x7a, + 0x5a, 0x72, 0x32, 0x62, 0x57, 0x59, 0x59, 0x6a, 0x39, 0x61, 0x36, 0x71, + 0x50, 0x4d, 0x33, 0x43, 0x33, 0x4a, 0x45, 0x57, 0x51, 0x39, 0x33, 0x73, + 0x68, 0x55, 0x74, 0x39, 0x54, 0x38, 0x55, 0x6e, 0x0a, 0x74, 0x52, 0x38, + 0x45, 0x66, 0x72, 0x5a, 0x43, 0x64, 0x51, 0x6f, 0x51, 0x79, 0x7a, 0x67, + 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x50, + 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a + */ + + 0x30, 0x82, 0x02, 0x5d, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xc8, + 0xa8, 0x06, 0x07, 0x81, 0x24, 0xb0, 0xb6, 0x92, 0x55, 0x87, 0x12, 0x12, + 0x54, 0x50, 0x08, 0xd7, 0x39, 0xce, 0xba, 0xd1, 0xb3, 0x6d, 0xe7, 0xbb, + 0x31, 0x8a, 0x30, 0xa3, 0xb7, 0xfe, 0x1f, 0xea, 0x0d, 0xab, 0x89, 0x22, + 0xf2, 0x93, 0xc8, 0x5b, 0x48, 0xea, 0x73, 0x6f, 0x87, 0xae, 0x70, 0x1d, + 0x94, 0x1c, 0x26, 0xbe, 0x08, 0x9d, 0xb1, 0xd2, 0x7c, 0xc1, 0xe4, 0xb6, + 0x8f, 0x5e, 0xbb, 0x18, 0xe6, 0xb9, 0x19, 0x58, 0xb4, 0xcf, 0x06, 0x6f, + 0x3f, 0x35, 0x0a, 0x0f, 0x94, 0x82, 0x88, 0xb1, 0x1e, 0x17, 0xa5, 0x52, + 0x73, 0xa0, 0xf8, 0x6d, 0x0a, 0x17, 0x6e, 0x7a, 0x39, 0x47, 0x4c, 0x14, + 0xfd, 0xdf, 0x9d, 0x62, 0x48, 0x0f, 0x7f, 0xe9, 0x97, 0x94, 0xc0, 0xb8, + 0x8f, 0xb7, 0x76, 0xf4, 0xf0, 0x1f, 0xf1, 0xc1, 0x66, 0xbc, 0xf9, 0xf7, + 0xe3, 0xf0, 0xb7, 0x66, 0xe5, 0xeb, 0x09, 0x02, 0x03, 0x01, 0x00, 0x01, + 0x02, 0x81, 0x80, 0x09, 0xdb, 0xd7, 0x8f, 0xfe, 0xd4, 0x62, 0xaa, 0x55, + 0xbe, 0x46, 0x08, 0xa9, 0x45, 0xe3, 0x38, 0xcb, 0xfa, 0x57, 0x21, 0xee, + 0xb3, 0xb6, 0x2e, 0xb0, 0x8f, 0xda, 0x8e, 0x51, 0x3c, 0xf5, 0x0b, 0x74, + 0x60, 0x7f, 0x91, 0x19, 0x5a, 0x79, 0xd0, 0x5a, 0x4b, 0xd6, 0xd9, 0x1d, + 0x1d, 0xb9, 0x80, 0x60, 0xb3, 0xaa, 0x3e, 0x6d, 0x0f, 0xd7, 0x4f, 0xa9, + 0x5b, 0xdf, 0xda, 0xf0, 0xed, 0x52, 0x66, 0x20, 0x9f, 0xb4, 0x0d, 0x88, + 0x23, 0x7d, 0xd2, 0x5a, 0x0a, 0x39, 0x6a, 0x82, 0xd8, 0x88, 0x75, 0x62, + 0x11, 0x39, 0x6f, 0xd8, 0x36, 0xba, 0x30, 0x86, 0x15, 0x1b, 0x51, 0xee, + 0x90, 0x7d, 0x58, 0x60, 0xd5, 0xb6, 0xc9, 0xd7, 0x2d, 0x23, 0x1b, 0xa3, + 0xb5, 0x8d, 0xef, 0x5d, 0xb3, 0x4d, 0x12, 0x89, 0x20, 0xee, 0x7f, 0xec, + 0x81, 0x40, 0x97, 0xc9, 0xee, 0xb9, 0x61, 0x21, 0x5a, 0x3e, 0x51, 0x02, + 0x41, 0x00, 0xf0, 0x5b, 0x47, 0x31, 0xcb, 0xf4, 0xb3, 0x5d, 0x24, 0xd6, + 0xd1, 0xf8, 0x41, 0x9d, 0xca, 0x3d, 0xc5, 0x90, 0x6e, 0x61, 0x32, 0xe9, + 0xd0, 0x43, 0x12, 0x67, 0x70, 0x01, 0x45, 0x8d, 0xbd, 0xe3, 0x0a, 0x30, + 0x06, 0xd0, 0x0e, 0xd4, 0x75, 0xff, 0x4b, 0x1f, 0xf8, 0x2d, 0xf9, 0xe1, + 0x72, 0x60, 0xb3, 0xbd, 0x60, 0x4c, 0x3e, 0x00, 0xf1, 0x0e, 0x23, 0x19, + 0x7f, 0x5a, 0xfe, 0x61, 0x86, 0x13, 0x02, 0x41, 0x00, 0xd5, 0xb7, 0x46, + 0xdf, 0xe6, 0xfc, 0x0e, 0x79, 0xea, 0xf5, 0x4f, 0x4b, 0x58, 0x0e, 0xa0, + 0x4a, 0x15, 0x52, 0xde, 0x4a, 0x08, 0xc1, 0x46, 0xc0, 0x25, 0x14, 0x64, + 0x15, 0x9a, 0x3d, 0xd4, 0x64, 0x6a, 0xad, 0x70, 0x87, 0x86, 0x6a, 0x32, + 0x16, 0x2d, 0xcb, 0xc1, 0x12, 0x4b, 0xfb, 0xf6, 0x64, 0x4f, 0x8d, 0x17, + 0xfc, 0x68, 0xe8, 0xba, 0xfb, 0xd9, 0x5c, 0x77, 0x18, 0xc5, 0xbe, 0x9d, + 0xf3, 0x02, 0x41, 0x00, 0xbb, 0x44, 0x12, 0xcb, 0x2c, 0x82, 0x41, 0xc1, + 0x1f, 0x73, 0xb3, 0xf2, 0x3d, 0x85, 0x67, 0xce, 0x0b, 0x00, 0x85, 0xcf, + 0x7b, 0x30, 0x8a, 0x8f, 0xc7, 0x66, 0x09, 0xf1, 0x23, 0xb4, 0xd4, 0xae, + 0x71, 0x00, 0x8c, 0x3e, 0x4c, 0x5f, 0xa2, 0x73, 0xbe, 0x9f, 0x70, 0xe8, + 0xb9, 0x58, 0xba, 0x99, 0xb7, 0x50, 0xa4, 0x17, 0xa2, 0xf3, 0x6e, 0xdc, + 0xb9, 0xe2, 0x22, 0xc4, 0xcd, 0x8f, 0x44, 0x3b, 0x02, 0x41, 0x00, 0xaa, + 0x4f, 0xe3, 0x50, 0x5d, 0x60, 0x33, 0x1d, 0x1f, 0x8c, 0x1c, 0x83, 0xdb, + 0x89, 0xd4, 0x5d, 0x15, 0x7f, 0x33, 0x9c, 0x66, 0x3b, 0xb8, 0x69, 0x39, + 0x63, 0x75, 0x9a, 0xed, 0x8f, 0x26, 0x6a, 0x5b, 0xc5, 0x19, 0xef, 0x36, + 0xc3, 0xfc, 0x64, 0x46, 0x5c, 0xa0, 0xe1, 0x36, 0xe2, 0x75, 0x69, 0x5d, + 0x28, 0x00, 0x9c, 0x6a, 0xf2, 0x44, 0xc8, 0x9d, 0x60, 0x9d, 0x9c, 0x85, + 0x41, 0xb1, 0xd7, 0x02, 0x40, 0x71, 0xf2, 0xf4, 0x2f, 0x5f, 0xe7, 0x9a, + 0x81, 0x43, 0x6b, 0x37, 0xa9, 0x92, 0x29, 0x0a, 0x64, 0xaf, 0x82, 0x8a, + 0x3d, 0x6a, 0x93, 0xb6, 0xd8, 0xb3, 0xd6, 0x8c, 0xd8, 0xf3, 0x66, 0xbd, + 0x9b, 0x59, 0x86, 0x23, 0xf5, 0xae, 0xaa, 0x3c, 0xcd, 0xc2, 0xdc, 0x91, + 0x16, 0x43, 0xdd, 0xec, 0x85, 0x4b, 0x7d, 0x4f, 0xc5, 0x27, 0xb5, 0x1f, + 0x04, 0x7e, 0xb6, 0x42, 0x75, 0x0a, 0x10, 0xcb, 0x38 + +}; + +const static int devicePrivateKeyLength = sizeof(devicePrivateKey); \ No newline at end of file
diff -r 000000000000 -r 35b690909566 certs/root_certificate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/certs/root_certificate.h Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,144 @@ +#pragma once + +const static unsigned char rootCertificate[] = { + 0x30, 0x82, 0x02, 0x95, 0x30, 0x82, 0x01, 0xfe, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x02, 0x11, 0x11, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x67, 0x31, 0x0b, + 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x47, 0x42, 0x31, + 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x09, 0x42, 0x65, + 0x72, 0x6b, 0x73, 0x68, 0x69, 0x72, 0x65, 0x31, 0x10, 0x30, 0x0e, 0x06, + 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x4e, 0x65, 0x77, 0x62, 0x75, 0x72, + 0x79, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, + 0x56, 0x6f, 0x64, 0x61, 0x66, 0x6f, 0x6e, 0x65, 0x31, 0x0c, 0x30, 0x0a, + 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x52, 0x26, 0x44, 0x31, 0x11, + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x44, 0x4d, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, + 0x39, 0x30, 0x33, 0x31, 0x34, 0x30, 0x36, 0x30, 0x38, 0x5a, 0x17, 0x0d, + 0x32, 0x33, 0x30, 0x37, 0x31, 0x33, 0x31, 0x34, 0x30, 0x36, 0x30, 0x38, + 0x5a, 0x30, 0x67, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, + 0x13, 0x02, 0x47, 0x42, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, + 0x08, 0x0c, 0x09, 0x42, 0x65, 0x72, 0x6b, 0x73, 0x68, 0x69, 0x72, 0x65, + 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x4e, + 0x65, 0x77, 0x62, 0x75, 0x72, 0x79, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, + 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x56, 0x6f, 0x64, 0x61, 0x66, 0x6f, 0x6e, + 0x65, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, + 0x52, 0x26, 0x44, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, + 0x0c, 0x08, 0x44, 0x4d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x81, + 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, + 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, + 0x81, 0x81, 0x00, 0xba, 0x95, 0x99, 0x1e, 0x6e, 0x75, 0x45, 0xb3, 0x24, + 0x12, 0x4b, 0xca, 0x02, 0xf8, 0x25, 0x33, 0xde, 0x81, 0x71, 0x65, 0x52, + 0x73, 0x15, 0xbb, 0x29, 0xa5, 0xc5, 0x86, 0x6d, 0x40, 0xae, 0xdb, 0x75, + 0xd5, 0x59, 0xb9, 0x29, 0x30, 0xb4, 0xac, 0x8f, 0xb4, 0x92, 0x21, 0xb9, + 0xe2, 0x4c, 0x61, 0xbd, 0x8e, 0xde, 0xb9, 0x67, 0x94, 0x71, 0x0a, 0x89, + 0x28, 0x7c, 0x54, 0x4c, 0x58, 0xd4, 0x5a, 0xff, 0x13, 0x70, 0x9a, 0xf3, + 0x9a, 0x32, 0x1e, 0xe4, 0x4b, 0x61, 0x8a, 0x92, 0xe9, 0x74, 0xdf, 0x95, + 0xfc, 0xf2, 0x42, 0x3b, 0xf1, 0x62, 0x2d, 0x74, 0xa2, 0xca, 0x44, 0x2c, + 0x0b, 0xe5, 0x61, 0xc9, 0x4f, 0x01, 0x28, 0xd6, 0x2b, 0xa6, 0xca, 0x72, + 0x89, 0x0d, 0x74, 0xf4, 0xa3, 0xe8, 0xc9, 0xb1, 0xfc, 0x90, 0xae, 0xd6, + 0xd8, 0x85, 0xdf, 0xd9, 0xdf, 0x40, 0x68, 0xba, 0xf3, 0x72, 0x05, 0x02, + 0x03, 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, + 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xaa, 0x27, 0x1a, 0x6f, 0x88, + 0x72, 0x8c, 0x2d, 0x2d, 0xc2, 0x5a, 0xc5, 0x74, 0x82, 0xa5, 0x44, 0xd1, + 0x3d, 0xa3, 0x15, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, + 0x30, 0x16, 0x80, 0x14, 0xaa, 0x27, 0x1a, 0x6f, 0x88, 0x72, 0x8c, 0x2d, + 0x2d, 0xc2, 0x5a, 0xc5, 0x74, 0x82, 0xa5, 0x44, 0xd1, 0x3d, 0xa3, 0x15, + 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, + 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x7d, 0x38, 0x65, + 0xbb, 0x6b, 0xbb, 0xde, 0x19, 0xb7, 0xaa, 0xe6, 0x49, 0x5f, 0x9e, 0xe3, + 0xa0, 0xc4, 0x67, 0xfc, 0xdf, 0xa5, 0xd8, 0xa6, 0x38, 0xab, 0x5e, 0x98, + 0x23, 0xe8, 0x19, 0x22, 0x82, 0x65, 0x2c, 0x5f, 0xee, 0x21, 0x9c, 0x3a, + 0xe0, 0xeb, 0xb1, 0x7c, 0xa3, 0x5f, 0x22, 0xf2, 0xaf, 0x08, 0xbe, 0x78, + 0x2d, 0x0f, 0xbf, 0xa6, 0x58, 0x7e, 0xf0, 0x2c, 0xec, 0x99, 0x97, 0x63, + 0x75, 0x5f, 0x52, 0xff, 0x5f, 0x89, 0x79, 0xf7, 0xbe, 0x46, 0x11, 0x28, + 0x82, 0x34, 0xaf, 0x16, 0x3b, 0x36, 0xa3, 0x25, 0x5a, 0x30, 0x28, 0xd9, + 0x3b, 0x15, 0xae, 0x8e, 0xf6, 0x49, 0xdd, 0x77, 0x61, 0xa5, 0x76, 0x49, + 0xb1, 0xd9, 0xc4, 0xc7, 0x8a, 0xe0, 0x98, 0x78, 0xa3, 0xdd, 0xeb, 0x37, + 0x4b, 0x36, 0xab, 0x4d, 0x28, 0xcf, 0x55, 0x6f, 0x0c, 0xa4, 0x15, 0x38, + 0x1f, 0xc3, 0x4a, 0x95, 0x62 + /* PEM + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, + 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6c, 0x54, 0x43, 0x43, + 0x41, 0x66, 0x36, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x43, + 0x45, 0x52, 0x45, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, + 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42, 0x51, 0x41, 0x77, + 0x5a, 0x7a, 0x45, 0x4c, 0x4d, 0x41, 0x6b, 0x47, 0x41, 0x31, 0x55, 0x45, + 0x42, 0x68, 0x4d, 0x43, 0x52, 0x30, 0x49, 0x78, 0x0a, 0x45, 0x6a, 0x41, + 0x51, 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, 0x67, 0x4d, 0x43, 0x55, 0x4a, + 0x6c, 0x63, 0x6d, 0x74, 0x7a, 0x61, 0x47, 0x6c, 0x79, 0x5a, 0x54, 0x45, + 0x51, 0x4d, 0x41, 0x34, 0x47, 0x41, 0x31, 0x55, 0x45, 0x42, 0x77, 0x77, + 0x48, 0x54, 0x6d, 0x56, 0x33, 0x59, 0x6e, 0x56, 0x79, 0x65, 0x54, 0x45, + 0x52, 0x4d, 0x41, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, + 0x49, 0x0a, 0x56, 0x6d, 0x39, 0x6b, 0x59, 0x57, 0x5a, 0x76, 0x62, 0x6d, + 0x55, 0x78, 0x44, 0x44, 0x41, 0x4b, 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, + 0x73, 0x4d, 0x41, 0x31, 0x49, 0x6d, 0x52, 0x44, 0x45, 0x52, 0x4d, 0x41, + 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x77, 0x77, 0x49, 0x52, 0x45, + 0x31, 0x54, 0x5a, 0x58, 0x4a, 0x32, 0x5a, 0x58, 0x49, 0x77, 0x48, 0x68, + 0x63, 0x4e, 0x4d, 0x54, 0x4d, 0x77, 0x0a, 0x4f, 0x54, 0x41, 0x7a, 0x4d, + 0x54, 0x51, 0x77, 0x4e, 0x6a, 0x41, 0x34, 0x57, 0x68, 0x63, 0x4e, 0x4d, + 0x6a, 0x4d, 0x77, 0x4e, 0x7a, 0x45, 0x7a, 0x4d, 0x54, 0x51, 0x77, 0x4e, + 0x6a, 0x41, 0x34, 0x57, 0x6a, 0x42, 0x6e, 0x4d, 0x51, 0x73, 0x77, 0x43, + 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x48, 0x51, + 0x6a, 0x45, 0x53, 0x4d, 0x42, 0x41, 0x47, 0x41, 0x31, 0x55, 0x45, 0x0a, + 0x43, 0x41, 0x77, 0x4a, 0x51, 0x6d, 0x56, 0x79, 0x61, 0x33, 0x4e, 0x6f, + 0x61, 0x58, 0x4a, 0x6c, 0x4d, 0x52, 0x41, 0x77, 0x44, 0x67, 0x59, 0x44, + 0x56, 0x51, 0x51, 0x48, 0x44, 0x41, 0x64, 0x4f, 0x5a, 0x58, 0x64, 0x69, + 0x64, 0x58, 0x4a, 0x35, 0x4d, 0x52, 0x45, 0x77, 0x44, 0x77, 0x59, 0x44, + 0x56, 0x51, 0x51, 0x4b, 0x44, 0x41, 0x68, 0x57, 0x62, 0x32, 0x52, 0x68, + 0x5a, 0x6d, 0x39, 0x75, 0x0a, 0x5a, 0x54, 0x45, 0x4d, 0x4d, 0x41, 0x6f, + 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x77, 0x77, 0x44, 0x55, 0x69, 0x5a, + 0x45, 0x4d, 0x52, 0x45, 0x77, 0x44, 0x77, 0x59, 0x44, 0x56, 0x51, 0x51, + 0x44, 0x44, 0x41, 0x68, 0x45, 0x54, 0x56, 0x4e, 0x6c, 0x63, 0x6e, 0x5a, + 0x6c, 0x63, 0x6a, 0x43, 0x42, 0x6e, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, + 0x71, 0x68, 0x6b, 0x69, 0x47, 0x39, 0x77, 0x30, 0x42, 0x0a, 0x41, 0x51, + 0x45, 0x46, 0x41, 0x41, 0x4f, 0x42, 0x6a, 0x51, 0x41, 0x77, 0x67, 0x59, + 0x6b, 0x43, 0x67, 0x59, 0x45, 0x41, 0x75, 0x70, 0x57, 0x5a, 0x48, 0x6d, + 0x35, 0x31, 0x52, 0x62, 0x4d, 0x6b, 0x45, 0x6b, 0x76, 0x4b, 0x41, 0x76, + 0x67, 0x6c, 0x4d, 0x39, 0x36, 0x42, 0x63, 0x57, 0x56, 0x53, 0x63, 0x78, + 0x57, 0x37, 0x4b, 0x61, 0x58, 0x46, 0x68, 0x6d, 0x31, 0x41, 0x72, 0x74, + 0x74, 0x31, 0x0a, 0x31, 0x56, 0x6d, 0x35, 0x4b, 0x54, 0x43, 0x30, 0x72, + 0x49, 0x2b, 0x30, 0x6b, 0x69, 0x47, 0x35, 0x34, 0x6b, 0x78, 0x68, 0x76, + 0x59, 0x37, 0x65, 0x75, 0x57, 0x65, 0x55, 0x63, 0x51, 0x71, 0x4a, 0x4b, + 0x48, 0x78, 0x55, 0x54, 0x46, 0x6a, 0x55, 0x57, 0x76, 0x38, 0x54, 0x63, + 0x4a, 0x72, 0x7a, 0x6d, 0x6a, 0x49, 0x65, 0x35, 0x45, 0x74, 0x68, 0x69, + 0x70, 0x4c, 0x70, 0x64, 0x4e, 0x2b, 0x56, 0x0a, 0x2f, 0x50, 0x4a, 0x43, + 0x4f, 0x2f, 0x46, 0x69, 0x4c, 0x58, 0x53, 0x69, 0x79, 0x6b, 0x51, 0x73, + 0x43, 0x2b, 0x56, 0x68, 0x79, 0x55, 0x38, 0x42, 0x4b, 0x4e, 0x59, 0x72, + 0x70, 0x73, 0x70, 0x79, 0x69, 0x51, 0x31, 0x30, 0x39, 0x4b, 0x50, 0x6f, + 0x79, 0x62, 0x48, 0x38, 0x6b, 0x4b, 0x37, 0x57, 0x32, 0x49, 0x58, 0x66, + 0x32, 0x64, 0x39, 0x41, 0x61, 0x4c, 0x72, 0x7a, 0x63, 0x67, 0x55, 0x43, + 0x0a, 0x41, 0x77, 0x45, 0x41, 0x41, 0x61, 0x4e, 0x51, 0x4d, 0x45, 0x34, + 0x77, 0x48, 0x51, 0x59, 0x44, 0x56, 0x52, 0x30, 0x4f, 0x42, 0x42, 0x59, + 0x45, 0x46, 0x4b, 0x6f, 0x6e, 0x47, 0x6d, 0x2b, 0x49, 0x63, 0x6f, 0x77, + 0x74, 0x4c, 0x63, 0x4a, 0x61, 0x78, 0x58, 0x53, 0x43, 0x70, 0x55, 0x54, + 0x52, 0x50, 0x61, 0x4d, 0x56, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, + 0x64, 0x49, 0x77, 0x51, 0x59, 0x0a, 0x4d, 0x42, 0x61, 0x41, 0x46, 0x4b, + 0x6f, 0x6e, 0x47, 0x6d, 0x2b, 0x49, 0x63, 0x6f, 0x77, 0x74, 0x4c, 0x63, + 0x4a, 0x61, 0x78, 0x58, 0x53, 0x43, 0x70, 0x55, 0x54, 0x52, 0x50, 0x61, + 0x4d, 0x56, 0x4d, 0x41, 0x77, 0x47, 0x41, 0x31, 0x55, 0x64, 0x45, 0x77, + 0x51, 0x46, 0x4d, 0x41, 0x4d, 0x42, 0x41, 0x66, 0x38, 0x77, 0x44, 0x51, + 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, 0x0a, 0x41, + 0x51, 0x45, 0x46, 0x42, 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, 0x66, + 0x54, 0x68, 0x6c, 0x75, 0x32, 0x75, 0x37, 0x33, 0x68, 0x6d, 0x33, 0x71, + 0x75, 0x5a, 0x4a, 0x58, 0x35, 0x37, 0x6a, 0x6f, 0x4d, 0x52, 0x6e, 0x2f, + 0x4e, 0x2b, 0x6c, 0x32, 0x4b, 0x59, 0x34, 0x71, 0x31, 0x36, 0x59, 0x49, + 0x2b, 0x67, 0x5a, 0x49, 0x6f, 0x4a, 0x6c, 0x4c, 0x46, 0x2f, 0x75, 0x49, + 0x5a, 0x77, 0x36, 0x0a, 0x34, 0x4f, 0x75, 0x78, 0x66, 0x4b, 0x4e, 0x66, + 0x49, 0x76, 0x4b, 0x76, 0x43, 0x4c, 0x35, 0x34, 0x4c, 0x51, 0x2b, 0x2f, + 0x70, 0x6c, 0x68, 0x2b, 0x38, 0x43, 0x7a, 0x73, 0x6d, 0x5a, 0x64, 0x6a, + 0x64, 0x56, 0x39, 0x53, 0x2f, 0x31, 0x2b, 0x4a, 0x65, 0x66, 0x65, 0x2b, + 0x52, 0x68, 0x45, 0x6f, 0x67, 0x6a, 0x53, 0x76, 0x46, 0x6a, 0x73, 0x32, + 0x6f, 0x79, 0x56, 0x61, 0x4d, 0x43, 0x6a, 0x5a, 0x0a, 0x4f, 0x78, 0x57, + 0x75, 0x6a, 0x76, 0x5a, 0x4a, 0x33, 0x58, 0x64, 0x68, 0x70, 0x58, 0x5a, + 0x4a, 0x73, 0x64, 0x6e, 0x45, 0x78, 0x34, 0x72, 0x67, 0x6d, 0x48, 0x69, + 0x6a, 0x33, 0x65, 0x73, 0x33, 0x53, 0x7a, 0x61, 0x72, 0x54, 0x53, 0x6a, + 0x50, 0x56, 0x57, 0x38, 0x4d, 0x70, 0x42, 0x55, 0x34, 0x48, 0x38, 0x4e, + 0x4b, 0x6c, 0x57, 0x49, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, + 0x4e, 0x44, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, + 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a + */ +}; + +static const int rootCertificateLength = sizeof(rootCertificate); \ No newline at end of file
diff -r 000000000000 -r 35b690909566 cyassl-lib.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cyassl-lib.lib Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/ashleymills/code/cyassl-lib/#c0ce1562443a
diff -r 000000000000 -r 35b690909566 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,366 @@ +#define __DEBUG__ 4 //Maximum verbosity +#ifndef __MODULE__ +#define __MODULE__ "main.cpp" +#endif + +#define DEBUG_CYASSL 1 +#include "bsd_socket.h" +#include "mbed.h" +#include "rtos.h" +#include "dbg.h" +#include "cyassl/ssl.h" +#include "VodafoneUSBModem.h" +//#include "EthernetInterface.h" +#include "NTPClient.h" + +#include "logging.h" + +#define APN_GDSP + +#ifdef APN_GDSP + #define APN "ppinternetd.gdsp" + #define APN_USERNAME "" + #define APN_PASSWORD "" +#endif + +#ifdef APN_CONTRACT + #define APN "internet" + #define APN_USERNAME "web" + #define APN_PASSWORD "web" +#endif + +#ifdef APN_PAYG + #define APN "smart" + #define APN_USERNAME "web" + #define APN_PASSWORD "web" +#endif + +#include "certs/device_certificate.h" +#include "certs/device_private_key.h" +#include "certs/root_certificate.h" + +#include <cyassl/ctaocrypt/types.h> + + +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) +{ + (void)ssl; + (void)hint; + (void)key_max_len; + + DBG("PSK client callback callled."); + + // 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) +{ + (void)ssl; + (void)key_max_len; + + + DBG("PSK server callback called."); + + // 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 +} +*/ + +sockaddr_in bindAddr,serverAddress; + +bool connectToSocketUDP(char *ipAddress, int port, int *sockfd) { + *sockfd = -1; + // create the socket + if((*sockfd=socket(AF_INET,SOCK_DGRAM,0))<0) { + DBG("Error opening socket"); + return false; + } + socklen_t sockAddrInLen = sizeof(struct sockaddr_in); + + // bind socket to 11111 + memset(&bindAddr, 0x00, sockAddrInLen); + bindAddr.sin_family = AF_INET; // IP family + bindAddr.sin_port = htons(11111); + bindAddr.sin_addr.s_addr = IPADDR_ANY; // 32 bit IP representation + // call bind + if(bind(*sockfd,(const struct sockaddr *)&bindAddr,sockAddrInLen)!=0) { + DBG("Error binding socket"); + perror(NULL); + } + + INFO("UDP socket created and bound to: %s:%d",inet_ntoa(bindAddr.sin_addr),ntohs(bindAddr.sin_port)); + + // create the socket address + + memset(&serverAddress, 0x00, sizeof(struct sockaddr_in)); + serverAddress.sin_addr.s_addr = inet_addr(ipAddress); + serverAddress.sin_family = AF_INET; + serverAddress.sin_port = htons(port); + + // do socket connect + //LOG("Connecting socket to %s:%d", inet_ntoa(serverAddress.sin_addr), ntohs(serverAddress.sin_port)); + if(connect(*sockfd, (const struct sockaddr *)&serverAddress, sizeof(serverAddress))<0) { + shutdown(*sockfd,SHUT_RDWR); + close(*sockfd); + DBG("Could not connect"); + return false; + } + return true; +} + +bool connectToSocket(char *ipAddress, int port, int *sockfd) { + *sockfd = -1; + // create the socket + if((*sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { + DBG("Error opening socket"); + return false; + } + + // create the socket address + sockaddr_in serverAddress; + std::memset(&serverAddress, 0, sizeof(struct sockaddr_in)); + serverAddress.sin_addr.s_addr = inet_addr(ipAddress); + serverAddress.sin_family = AF_INET; + serverAddress.sin_port = htons(port); + + // do socket connect + //LOG("Connecting socket to %s:%d", inet_ntoa(serverAddress.sin_addr), ntohs(serverAddress.sin_port)); + if(connect(*sockfd, (const struct sockaddr *)&serverAddress, sizeof(serverAddress))<0) { + shutdown(*sockfd,SHUT_RDWR); + close(*sockfd); + DBG("Could not connect"); + return false; + } + return true; +} +/* +int handshakeCallback(HandShakeInfo* hinfo) { + DBG("Handshake callback called"); +} +int timeoutCallback(TimeoutInfo *tinfo) { + DBG("Timeout callback called"); +} +*/ + + +DigitalOut myled(LED1); +//#define INTERFACE EthernetInterface +#define INTERFACE VodafoneUSBModem + +void printError(CYASSL *ssl, int resultCode) { + int err = CyaSSL_get_error(ssl, resultCode); + char errorString[80]; + CyaSSL_ERR_error_string(err, errorString); + DBG("Error: CyaSSL_write %s", errorString); +} + +void debugCallback(const int logLevel,const char *const logMessage) { + DBG(logMessage); +} + + +int main() { + DBG_INIT(); + DBG_SET_SPEED(115200); + DBG_SET_NEWLINE("\r\n"); + DBG("\r\n\r\n\r\n\r\n"); + + int ret = 0; + + // init modem + INTERFACE modem; + // connnect modem to cellular network + DBG("connecting to network interface"); + if(modem.connect(APN,APN_USERNAME,APN_PASSWORD)!=0) { + DBG("Error connecting to mobile network"); + } + /* + modem.init(); + if(modem.connect(10000)) { + DBG("Error initialising ethernet interface"); + } + */ + DBG("Connected to network interface"); + + //DBG("IP: %s",modem.getIPAddress()); + + // need to set the time before doing anything else + NTPClient ntp; + time_t currentTime = time(NULL); + int obtainedTimeSuccessfully = false; + // try 100 times and then just force a watchdog reboot + for(int i=0; i<100; i++) { + obtainedTimeSuccessfully = false; + + if(ntp.setTime("0.pool.ntp.org")==0) { + // there is a bug from somewhere which results in a negative timestamp + currentTime = time(NULL); + if(currentTime>0) { + obtainedTimeSuccessfully = true; + INFO("Time set successfully, time is now (UTC): %s", ctime(¤tTime)); + } + } + if(obtainedTimeSuccessfully) { + break; + } + } + + + // set SSL method to SSL v3 (TLS v1.2) + //CyaSSLv23_client_method(); + + CyaSSL_Init();// Initialize CyaSSL + if(CyaSSL_Debugging_ON()==0) { + DBG("CyaSSL debugging enabled"); + } else { + DBG("CyaSSL debugging not compiled in"); + } + + CyaSSL_SetLoggingCb(&debugCallback); + + + + // set client method + + // TLS + //CYASSL_CTX* ctx = CyaSSL_CTX_new(CyaSSLv23_client_method()); + + // DTLS + CYASSL_METHOD* method = CyaDTLSv1_2_client_method(); + if(method == NULL) { + // unable to get method + } + CYASSL_CTX* ctx; + ctx = CyaSSL_CTX_new(method); + if(ctx == NULL){ + DBG("CyaSSL_CTX_new error.\n"); + exit(EXIT_FAILURE); + } + + DBG("Setup SSL context"); + + + + + // use pre-shared keys + //CyaSSL_CTX_set_psk_client_callback(ctx,my_psk_client_cb); + /* + if(CyaSSL_CTX_load_verify_buffer(ctx, serverCert, strlen((const char*)serverCert),SSL_FILETYPE_PEM)==0) { + DBG("loaded server cert OK"); + }*/ + + + // load certificates for CA and us + // load CA cert + ret = CyaSSL_CTX_load_verify_buffer(ctx,rootCertificate, rootCertificateLength,SSL_FILETYPE_ASN1); + // load device cert + ret = CyaSSL_CTX_use_certificate_buffer(ctx, deviceCertificate, deviceCertificateLength, SSL_FILETYPE_ASN1); + // load device private key + ret = CyaSSL_CTX_use_PrivateKey_buffer(ctx, devicePrivateKey, devicePrivateKeyLength, SSL_FILETYPE_ASN1); + + + int sockfd = NULL; + //if(!connectToSocketUDP("192.168.1.99", 11111, &sockfd)) { + if(!connectToSocketUDP("95.47.118.120", 11111, &sockfd)) { + DBG("Error connecting to socket"); + } + + /* + // connect to SSL enabled webserver + int sockfd = NULL; + if(!connectToSocket("95.47.118.120", 11111, &sockfd)) { + DBG("Error connecting to socket"); + } + DBG("Connected to non-SSL socket"); + */ + + // hook into SSL + // Create CYASSL object + CYASSL* ssl; + ssl = CyaSSL_new(ctx); + if(ssl == NULL) { + DBG("CyaSSL_new error."); + exit(EXIT_FAILURE); + } + DBG("CyaSSL_new OK"); + + // setup callbacks for handshake failure + /* + Timeval timeout; + timeout.tv_sec = 5; + timeout.tv_usec = 0; + ret = CyaSSL_connect_ex(ssl, handshakeCallback, timeoutCallback, timeout); + */ + + // attach to socket + DBG("Attaching CyaSSL to socket"); + CyaSSL_set_fd(ssl, sockfd); + DBG("Attached CyaSSL to socket"); + + // DTLS stuff + ret = CyaSSL_dtls_set_peer(ssl, &serverAddress, sizeof(serverAddress)); + if(ret != SSL_SUCCESS) { + // failed to set DTLS peer + DBG("Failed to set DTLS peer"); + } + + ret = CyaSSL_dtls(ssl); + if(ret) { + // SSL session has been configured to use DTLS + DBG("DTLS configured"); + } else { + DBG("DTLS not configured"); + } + + + + DBG("Issuing CyaSSL_connect"); + int result = CyaSSL_connect(ssl); + if(result!=SSL_SUCCESS) { + DBG("CyaSSL_connect failed"); + printError(ssl,result); + } + DBG("CyaSSL_connect OK"); + + result = CyaSSL_write(ssl,"onion",5); + DBG("Wrote %d things",result); + if(result<0) { + printError(ssl,result); + } + + char buffer[200]; + int d =0; + if((d=CyaSSL_read(ssl, &buffer, 200))>0) { + DBG("Received %d bytes: %s",d,buffer); + } + + // clean up + CyaSSL_CTX_free(ctx); + CyaSSL_Cleanup(); + +} \ No newline at end of file
diff -r 000000000000 -r 35b690909566 mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#869ef732a8a2
diff -r 000000000000 -r 35b690909566 mbed-src.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Thu Sep 05 15:56:41 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#398f4c622e1b