OpenSSL Programming 20140424 01
OpenSSL Programming 20140424 01
Apple's libsecurity_ssl
PolarSSL (used by OpenVPN)
full list
● http://en.wikipedia.org/wiki/Comparison
_of_TLS_implementations
● http+ssh:// ?
● LibreSSL - OpenBSD's OpenSSL fork
concepts in cryptography
plaintext/ciphertext
block ciphers vs stream ciphers
symetric cryptography
public key cryptography
hash function
digital signature
message authentication code
digital certificates
security algorithms
Learn to code C
properly !!!
good programming practices
clear design
coding style (indentation matters too!)
compiler warnings
code versioning systems
code reviews
static code analyzers
unit testing
fuzz testing
automation testing
good C coding practices
input validation
bounds checking
string manipulation
initialize data
sanitize output
proper cleanup
error checking
principle of least priviledge and priviledge
separation
keep it simple
good C coding practices (2)
Build a habit of applying those!
All of them!
Always!
Apple's gotofail bug
● http://opensource.apple.com/source/Security/Security-
55471/libsecurity_ssl/lib/sslKeyExchange.c
Apple's gotofail bug (2)
OpenSSL's heartbleed
OpenSSL's heartbleed (2)
● http://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=4817504
OpenSSL's heartbleed (3)
EVP_CIPHER_CTX_cleanup(&ctx);
OpenSSL programming – create keys
/* Attempt to connect */
BIO_set_conn_hostname(bio, "hostname:port");
BIO_free_all(bio);
SSL_CTX_free(ctx);
error detection & reporting
printf("Error: %s\n",
ERR_reason_error_string(ERR_get_error()));
ERR_print_errors_fp(FILE *);
ERR_print_errors(BIO *);
(void)SSL_library_init();
SSL_load_error_strings();
printf("Error: %s\n",
ERR_error_string(SSL_get_error((ssl),(err)), NULL);
OpenSSL – server example
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
http://people.freebsd.org/~syrinx/presenta
tions/openssl/
download, untar & make
needs libbsd for Linux/Ubuntu
references
https://www.openssl.org/
http://www.libressl.org/
http://www.ietf.org/rfc/rfc2246.txt
http://www.ietf.org/rfc/rfc3546.txt
http://tools.ietf.org/html/rfc6347
http://tools.ietf.org/html/rfc6083
https://tools.ietf.org/html/rfc6520
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1255.pdf
http://cacr.uwaterloo.ca/hac/
https://www.peereboom.us/assl/assl/html/openssl.html
https://www.owasp.org/index.php/Guide_to_Cryptography
https://www.cs.utexas.edu/~shmat/shmat_oak14.pdf
https://www.ssllabs.com/
https://www.howsmyssl.com/
https://we.riseup.net/riseuplabs+paow/openpgp-best-
practices#openpgp-key-checks
http://www.secureconsulting.net/2008/03/the_key_management_lifec
ycle_1.html
questions?
thank you!