Commit graph

125 commits

Author SHA1 Message Date
cinap_lenrek 39f18c9d88 libsec: implement TLS-PSK for tlsClient()/tlsServer() 2015-12-25 17:05:05 +01:00
cinap_lenrek 9b0de7f9d6 tls: implement chacha20/poly1305 aead cipher suits 2015-12-21 04:55:54 +01:00
cinap_lenrek 8a60d9e2a8 libsec: use tsmemcmp() when comparing hashes, use mpfield() for ecc, use mptober() when right adjusting mpint to bytes 2015-12-16 21:23:40 +01:00
cinap_lenrek 3a40210df8 libsec: fix genprime() to produce normalized result
this fixed bug "assert_failed_m-flags__mpnorm_since_283cc2200e34".
2015-12-01 09:40:24 +01:00
cinap_lenrek 254031cf70 libsec: add chacha20 poly1305 aead, allow 64 bit iv's for chacha, add tsmemcmp()
chacha20 comes in two variants: ietf rfc7539, using 96 bit iv and 32 bit counter
and draft-agl-tls-chacha20poly1305 using 64 bit iv and a 64 bit counter. so
setupChachastate() now takes a ivlen argument which sets the mode.

add ccpoly_encrypt()/ccpoly_decrypt() routines.

to implement timing safe ccpoly_decrypt(), a constant time memcmp was needed, so
adding tsmemcmp() to libsec.
2015-11-26 15:25:10 +01:00
cinap_lenrek 847f3a0cf5 libsec: add chacha cipher (from charles forsyth) 2015-10-22 07:48:26 +02:00
cinap_lenrek 7effba9d98 libsec: add poly1305 2015-10-22 07:17:25 +02:00
cinap_lenrek 9112daa764 libsec: remove rc4 cipher suits for tls 2015-10-10 01:12:30 +02:00
cinap_lenrek 9ec1a07af2 libsec: clarify the code by declaring constant for DirectoryString and handle conversion in mkstring() 2015-10-09 18:52:32 +02:00
cinap_lenrek 6bb63f7832 libsec: use the right string encoding for various x509 fields
C= has to be PrintableString, E= and DC= are IA5String, everything
else is DirectoryString which can be PrintableString or UTF8String.
2015-10-09 18:31:49 +02:00
cinap_lenrek fc06f637cf libsec: cleanup newbytes()/newints()/newbits() and get rid of OFFSETOF() macro 2015-09-24 12:57:05 +02:00
cinap_lenrek 6641548938 libsec: fix memory leaks in X509req() and X509gen() and return malloced pointer
X509req() and X509gen() used to leak memory, and had no way for
the caller to free the allocated certificate/certificate request
buffer returned. this is not critical as these functions are only
used in short lived rsa(2) helper programs. but i prefer to have
library routines not leak memory as one does not know in advance
where the code is going to be used.
2015-09-23 17:33:52 +02:00
cinap_lenrek 9f50ee06f3 libsec: implement client certificate authentication for tls1.2
we used to negotiate tls1.1 for client cert authentication because the
signature generation was not implemented for tls1.2. this is now fixed
and tls1.2 can be negotiated with client certs.
2015-09-23 16:57:25 +02:00
cinap_lenrek ada54defbc libsec: handle missing signature case; can happen because some ciphers make it optional 2015-09-22 19:11:54 +02:00
cinap_lenrek 2c4d3dd510 libsec: make sure Elem is zero initialized so freevalfields() wont cause accidents 2015-09-22 18:39:48 +02:00
cinap_lenrek c3e1c158f6 libsec: implement dh parameter signature verification, stop lying about non-rsa ciphers, fix memory leaks in X509 code
actually verify the diffie hellman parameter signature, this
comes in two flavours. TLS1.2 uses X509 signature with a
single hash specified by the signature algorithm field in
the signature itself and pre TLS1.2 where md5+sha1 hashes
of the signed blob are pkcs1 padded and encrypted with the
rsa private key.

stop advertizing non-rsa cipher suits (DSS and ECDSA), as
we have not implmenented them.

fix some memory leaks in X509 code while we'r at it.
2015-09-22 18:10:52 +02:00
cinap_lenrek 8baa859319 libsec: fix memory leak in ecmul() 2015-09-22 18:04:06 +02:00
cinap_lenrek 029c271825 libsec: save some space making weakCipher bitamp of type char[] instead of int[] 2015-09-14 09:46:40 +02:00
cinap_lenrek 9733434e6e libsec: add TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 and TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 cipher suits 2015-09-14 09:27:06 +02:00
cinap_lenrek 33a4a56c1c libsec: send sigature_algoritms extension for TLS1.2, order ciphers
TLS1.2 requires the client to send the list of supported
signature and hash algorithm pairs. some servers will simply
reject the client hello otherwise. note that we do not implement
any dh/ecdh param signature verification.

order the cipher list to strogest first. aes128 is actually more
secure than aes256.
2015-09-13 13:39:51 +02:00
cinap_lenrek 455b42743d libsec: handle TLS 1.2 changes in CertificateRequest message 2015-09-12 13:04:47 +02:00
cinap_lenrek 7ed22aaeec libsec: add rfc5869 hmac-based key derivation function hkdf_x() 2015-09-02 11:30:17 +02:00
cinap_lenrek b749f36baa libsec: generalize pbkdf2_hmac_sha1() to pbkdf2_x() passing the hmac as an argument 2015-09-02 11:28:11 +02:00
cinap_lenrek 4c52aedfe9 libsec: declare aes_setupEnc static 2015-09-02 06:15:02 +02:00
cinap_lenrek b5737e8726 libsec: add curve25519 diffie hellman 2015-09-01 21:38:20 +02:00
cinap_lenrek e3a64494e7 libsec: remove flawed aes() digest and hmac_aes() implementations (thanks aiju) 2015-09-01 21:35:43 +02:00
cinap_lenrek 2095bdbf45 libsec: work arround 8c running out of registers compiling curve25519.c 2015-08-28 16:31:44 +02:00
cinap_lenrek 0e51046942 libsec: add curve25519() from http://code.google.com/p/curve25519-donna/
this is a portable version of curve25519() by google.
2015-08-28 12:08:54 +02:00
mischief 07b245943a libsec: add TLS_RSA_WITH_AES_128_CBC_SHA256 and TLS_RSA_WITH_AES_256_CBC_SHA256 ciphers 2015-08-27 01:53:48 -07:00
cinap_lenrek 3bb0b9f4ea libsec: add q parameter to dh_new() for subgroup support, sanitize dh parameters 2015-08-26 05:59:42 +02:00
glenda c4fdc6bfdb fix fuckup 2015-08-25 09:35:10 +00:00
mischief 6b402b83cf import E script from bell labs 2015-08-25 02:07:46 -07:00
cinap_lenrek 59d16c3900 libsec: fix probably_prime() endless loop for n == 3 2015-08-23 23:49:31 +02:00
cinap_lenrek a40c4006d2 libsec: add pbkdf2_hmac_sha1() (from wpapsk factotum module) 2015-08-20 00:45:08 +02:00
cinap_lenrek 7c3bbc3168 libsec: TLS1.2 server support, make cipher list with most prefered first 2015-08-17 22:27:56 +02:00
cinap_lenrek 7d7650dffc libsec: TLS1.2 client support 2015-08-17 21:16:58 +02:00
cinap_lenrek aa2b5bc0e7 libsec: fix mistake breaking tlsServer() (thanks sl) 2015-08-16 02:38:44 +02:00
cinap_lenrek 0c36c79e9b libsec: TLS1.1 support (needs new devtls) 2015-08-15 17:51:55 +02:00
cinap_lenrek ebe88f34cb fix library mkfiles for objtype=spim 2015-08-08 08:04:41 +02:00
cinap_lenrek 9e196fd0e2 libsec: increase handshake message buffer size (MaxChunk) to 32K (thanks sl)
_sl → webfs doesn't like packetfire.org: '/mnt/web/body' 0 No status tls: local handshake message too long 30781 16384
2015-07-24 06:18:59 +02:00
cinap_lenrek 9d3bc16469 libsec/tlshand: implement client side ECDHE (many thanks to pr!) 2015-06-07 22:14:01 +02:00
cinap_lenrek 079d3f4002 libsec/ecc: fix memory leak (free() vs mpfree()) 2015-06-07 22:12:46 +02:00
cinap_lenrek e601e1605b libsec: cleanup x509 and tlshand
- add overflow checks for newbytes(), newbits(), newints()
- remove suspicious nil check from estrdup()
- remove useless nil checks before free
2015-05-28 00:31:36 +02:00
cinap_lenrek a788f2000d libsec/x509: fix verify_signature(), digest_certinfo(), X509dump()
make digest_certinfo() return the digest length, otherwise
return -1 as an error and handle it in the callers.

pass expected digest length to verify_signature() and
check digest length from certificate! make sure we wont
run off the buffer.

fix newlines in error prints of X509dump().
2015-05-27 19:52:06 +02:00
cinap_lenrek 5f7d769a02 libsec/x509: use SHA2-256 digest algorithm instead of MD5
this implements SHA2 (224, 256, 384, 512) signature algorithms and
uses sha256WithRSAEncryption for X509req() and X509gen() instead
of oid_md5WithRSAEncryption.
2015-05-27 18:35:37 +02:00
cinap_lenrek 40360a992d libsec: implement tlsClient support for RFC6066 server name identification (SNI)
tlsClient() now can optionally send the server_name in the ClientHello
message by setting the TLSconn.serverName. This is required for some
https sites.
2015-05-21 02:26:57 +02:00
cinap_lenrek 12bb7bcfff libsec: remove aesCTRencrypt()/aesCTRdecrypt() (thanks mischief and qrstuv)
as mischief and qrstuv point out, these functions are not very usefull
and are even implemented wrong (incrementCTR()), so deleting the code.
2015-04-29 02:58:10 +02:00
cinap_lenrek 6409684518 libsec: add TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA client cipher suit support 2015-02-05 04:29:28 +01:00
cinap_lenrek c8008e1ffd libsec: experimental DHE client support for tls and cleanups 2014-09-14 02:30:46 +02:00
cinap_lenrek 6c68876db6 libsec: add diffie-hellman functions 2014-09-14 02:29:18 +02:00
cinap_lenrek 4cf00ca6cb libsec: fix hmac for keys bigger then 64 byte block size
RFC2104 defines HMAC for keys bigger than the 64 byte block
size as follows:

Applications that use keys longer than B (64) bytes will
first hash the key using H (the hash function) and then
use the resultant L byte string as the actual key to HMAC.
2014-09-14 02:26:26 +02:00
aiju 69fab298be libsec: ecgen() and ecdsasign() fix 2014-09-13 19:46:41 +02:00
cinap_lenrek d4e66accaa libsec: use u32int instead of uint when we need 32 bit (thanks erik) 2014-06-12 14:05:10 +02:00
ftrvxmtrx b4c3726381 libsec: fix dsagen 64-bit bug (thanks rsc) 2014-06-11 17:35:05 +02:00
cinap_lenrek 28f7f3f9d7 tlshand: cleanup 36 -> MD5dlen+SHA1dlen 2014-04-26 18:09:26 +02:00
cinap_lenrek 3b1a0ab1f3 tlshand: fix memory leaks, fix alloc element size for certs pointer array, error handling 2014-04-26 18:04:04 +02:00
cinap_lenrek bc137696be libsec: fix memory leaks in seq_decode() and octet_decode() of asn1 parser 2014-02-28 18:54:56 +01:00
cinap_lenrek 6354bd0728 libsec: skip missing thumbprint files; not an error 2014-02-28 02:08:59 +01:00
cinap_lenrek dd076567a4 libsec: improve thumbprint code
1) handle errors when loading thumbprint file.
initThumbprints() now returns nil and sets errstr
on error. a syntax error in a thumbprint file
should be reported instead of silently ignored!
(have to check users)

2) fix memory leak in initThumbprints(); we have to use
freeThumbprints() instead of free to release crltab.

3) use the actual head entries for thumbprint
storage in the thumbprints array. most thumbprint
files are rather sparse.

4) remove private emalloc() function. we shouldnt
just exit the calling process on allocation error,
instead handle error properly. this is a library!
2014-02-28 01:23:11 +01:00
mischief 99f9a60178 libsec: add aes_128_cbc and aes_256_cbc ciphers 2014-02-25 17:37:59 -08:00
mischief de4db6745e libsec: move static sendbuf into TlsConnection and give receive buffer a better name 2014-02-25 12:48:17 -08:00
cinap_lenrek a6d5f9ccae fix blowfish endianess confusion (thanks erik)
from /n/sources/patch/blowfish/readme:

Blowfish is broken. The order of the bytes in the ciphertext
is wrong. The problem is the conversion from the ciphertext
plaintext block to the array of u32int used by the core funcions
and vice versa.

This code has been tested on big endian and little endian
machines.

A test program is also included, bftets.c. It uses the
test vectors of blowfish available at
https://www.schneier.com/code/vectors.txt
2014-02-20 18:32:47 +01:00
cinap_lenrek ed9e9f98e9 libc and ape support for amd64 2014-02-01 10:31:41 +01:00
cinap_lenrek 56836bfdbd tls: fix various tlsClient()/tlsServer() related bugs
- TLSconn structure on stack but not initialized (zeroed)
- original filedescriptor double closed in error case
- original filedescriptor leaked in success case
- leaked TLSconn.sessionID and TLSconn.cert
- clarify in pushtls(2) and pushssl(2)
2013-09-14 19:19:08 +02:00
cinap_lenrek 3c3a573562 libsec: only send client cert when we have one (fix regression from r6e976b2004dd) 2013-08-15 00:29:42 +02:00
cinap_lenrek ffa6f9c6ea fix spaces 2012-11-15 19:41:13 +01:00
cinap_lenrek b28f60cdd3 add C-Keens tls-client-auth
This patch adds client TLS authentication to libsec in compliance with
rfc 4346.

A new -c flag has been introduced for tlsclient allowing the user to
specify a certificate in pem(8) format which will be provided to the
server upon request.

A -D debug flag has been introduced to enable debugging output.

The patch has been tested against OpenSSL 0.9.7j 04 May 2006.

It exists today because of the great (debugging) help and insight
provided by Matthias Bauer.

TODOs:

- specification of a certain client key in factotum is not possible at
	the moment
- tlssrv should support this too

These will get added in another patch.

The first try to submit this patch failed due to a network error.
Sorry for the duplication!

Kind regards,

Christian
2012-11-15 19:32:53 +01:00
cinap_lenrek 56aa8e173f libsec: add sha256WithRSAEncryption signature alg 2012-08-18 15:09:02 +02:00
aiju 964b86fcd9 more btc stuff 2012-06-08 17:23:29 +02:00
aiju d2357e6961 added ecdsa to factotum 2012-06-06 16:43:15 +02:00
aiju 005248b4c5 added elliptic curve stuff and RIPEMD-160 2012-06-04 11:50:37 +02:00
cinap_lenrek e6d455a3e6 libsec: setmalloctag 2011-11-16 21:24:26 +01:00
taruti 9655db2550 devfs crypto code - alpha version 2011-05-24 22:19:33 +00:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00