summaryrefslogtreecommitdiff
path: root/sys/src/libsec
AgeCommit message (Collapse)Author
2020-12-07libsec: open internal file-descriptors with OCEXEC flagcinap_lenrek
2020-04-28libsec/base58enc: null-terminate the resultSigrid
2020-03-01libsec: remove hash pickle functions, document ripemd160, cleanup sechash(2) ↵cinap_lenrek
manpage
2019-08-30auth/rsa2asn1: implement private key export with -a flag (thanks kvik)cinap_lenrek
kvik writes: I needed to convert the RSA private key that was laying around in secstore into a format understood by UNIX® tools like SSH. With asn12rsa(8) we can go from the ASN.1/DER to Plan 9 format, but not back - so I wrote the libsec function asn1encodeRSApriv(2) and used it in rsa2asn1(8) by adding the -a flag which causes the full private key to be encoded and output.
2019-05-03libsec: dummy mkfile for arm64cinap_lenrek
2018-12-02libsec: fix memory leak in pkcs1_decrypt()cinap_lenrek
2018-01-06libsec: remove asn1toDSApriv()cinap_lenrek
2017-12-30libsec: implement SPKI fingerprinting for okCertificate()cinap_lenrek
Instead of only using a hash over the whole certificate for white/black-listing, now we can also use a hash over the Subject Public Key Info (SPKI) field of the certificate which contians the public key algorithm and the public key itself. This allows certificates to be renewed independendtly of the public key. X509dump() now prints the public key thumbprint in addition to the certificate thumbprint. tlsclient will print the certificate when run with -D flag. okCertificate() will print the public key thumbprint in its error string when no match has been found.
2017-12-30libsec: fix mistake: strnchr -> strchrcinap_lenrek
2017-12-30libsec: avoid unneccesary memory copies and redundant code in x509cinap_lenrek
getting rid of some functions that take Byte* and instead pass uchar* and length. keeping the signature and public key fields in CertX509 as Bits* allows ownership transfer by swapping pointers. use common code to copy CN from subject field.
2017-12-29libsec: get rid of dummy data[1] in Bytes and Ints types (thanks pr)cinap_lenrek
2017-11-30libsec: make includes consistent for sha2block*.ccinap_lenrek
2017-11-30libsec: unroll portable sha1block functioncinap_lenrek
just 6-10% slower than most assembly versions. 20% faster on zynq.
2017-11-30libsec: unroll portable sha2block functionscinap_lenrek
- unroll the loops - rotate the taps on each step, avoiding copies - simplify boolean formulas for Ch() and Maj() this yields arround 40% throughput increase on 32/64bit archs for sha2_256 and sha2_512 on amd64.
2017-11-27libsec: optimize aesCBCencrypt()/aesCBCdecrypt()cinap_lenrek
- get rid of the temporary copies and memmoves() - when the data pointer is aligned, do xor and copying inline speedup for auth/aescbc encryption depends on arch: - zynq 7% (arm) - t23 13% (386) - x230 20% (amd64, aes-ni) - apu2 25% (amd64, aes-ni)
2017-11-20libsec: write optimized _chachablock() function for amd64 / sse2cinap_lenrek
doing 4 quarterround's in parallel using 128-bit vector registers. for second round shuffle the columns and then shuffle back. code is rather obvious. only trick here is for the first quaterround PSHUFLW/PSHUFHW is used to swap the halfwords for the <<<16 rotation.
2017-11-12libsec: AES-NI support for amd64cinap_lenrek
Add assembler versions for aes_encrypt/aes_decrypt and the key setup using AES-NI instruction set. This makes aes_encrypt and aes_decrypt into function pointers which get initialized by the first call to setupAESstate(). Note that the expanded round key words are *NOT* stored in big endian order as with the portable implementation. For that reason the AESstate.ekey and AESstate.dkey fields have been changed to void* forcing an error when someone is accessing the roundkey words. One offender was aesXCBmac, which doesnt appear to be used and the code looks horrible so it has been deleted. The AES-NI implementation is for amd64 only as it requires the kernel to save/restore the FPU state across syscalls and pagefaults.
2017-10-29libsec: rewrite aex_xts_encrypt()/aes_xts_decrypt()cinap_lenrek
the previous implementation was not portable at all, assuming little endian in gf_mulx() and that one can cast unaligned pointers to ulong in xor128(). also the error code is likely to be ignored, so better abort() when the length is not a multiple of the AES block size. we also pass in full AESstate structures now instead of the expanded key longs, so that we do not need to hardcode the number of rounds. this allows each indiviaul keys to be bigger than 128 bit.
2017-10-17libsec: make sectorNumber argument for aes_xts routines uvlongcinap_lenrek
2017-10-17libsec: add AES CFB and AES OFB stream cipherscinap_lenrek
2017-10-06libsec: export asn1encodedigest(), asn1encodeRSApub(), asn1toRSApub(), ↵cinap_lenrek
pkcs1padbuf() and pkcs1unpadbuf()
2017-10-05libsec: allow \r\n terminated lines in decodePEM()cinap_lenrek
2017-04-23libsec: sha256 support for thumbprint files, use it in ssh as wellcinap_lenrek
initThumbprints() now takes an application tag argument so x509 and ssh can coexist. the thumbprint entries can now hold both sha1 and sha256 hashes. okThumbprint() now takes a len argument for the hash length used. the new function okCertificate() hashes the certificate with both and checks for any matches. on failure, okCertificate() returns 0 and sets error string. we also check for include loops now in thumbfiles, limiting the number of includes to 8.
2017-04-04tlshand: simplify tlsReadN()cinap_lenrek
2017-04-04tlshand: fix mpint to bytes conversion, reorganize send/recv buffer, check ↵cinap_lenrek
for overflow in msgSend() when converting mpint to bytes, always pad it to the size of the modulus (RSA,DHE,ECDHE). mptobytes() now takes a byte len parameter which the caller usually calculates from the group modulus using mpsignif(). this bug sometimes caused "bad record mac" after the handshake. use a shared buffer, given that msgSend()/msgRecv() don't overlap we can use the first half for sending, and the top half for receiving, shifting down as neccesary. the space beween sendp and recvp is free. explicitely check for overflow in msgSend().
2017-04-03tlshand: fix ECDHE and DHE for SSLv3cinap_lenrek
2017-02-10libsec: zero name buffer in X509toECpub()cinap_lenrek
2017-02-10libsec: make X509toECpub() return CN name like X509toRSApub()cinap_lenrek
2017-02-10libsec: revert asn1mpint(), rewrite rsa signature validation, cleanupscinap_lenrek
reverting asn1mpint() as all users really just expect unsigned integers here. also openssl seems to interpret rsa modulus as unsigned no matter what... so keeping it as it was before. handle nil cipher bytes in factotum_rsa_decrypt() due to pkcs1padbuf() failing. apply some lessions from intels berzerk paper: instead of parsing the decrypted digest info blob, we generate the *expected* blob's for all digest algorithms that match the digest size and compare the results. provide pkcs1 pad and unpad functions that consistently enforce minimum padding size and handles block types 1 and 2.
2017-02-06libsec: handle signed asn.1 bigint to mpint conversion for x509cinap_lenrek
2017-02-06rsagen: prefer 65537 as the default exponent when elen == 0, otherwise pick ↵cinap_lenrek
randomly
2017-02-06libsec: fix mkbigint(), asn.1 uses two's compement signed representationcinap_lenrek
quick fix is to bias the rounding so the msb will always be zero. should write proper conversion code to actually deal with signed mpints... also for asn1mpint()... -- cinap
2017-02-06libsec: check if modulus is too small for message in pkcs1padbuf()cinap_lenrek
2017-02-06libsec: need PKCS#9 "Extension Request" attribute (rsareq())cinap_lenrek
2017-02-05libsec: have rsagen() always produce postive !dk to avoid confusioncinap_lenrek
2017-01-15libsec: avoid temp variables in chacha/salsa ENCRYPT() macrocinap_lenrek
given that we only pass uchar* with constant offsets to the s and d arguments of ENCRYPT(), we do not need the temporary variables sp/dp and the compiler is smart enougth to combine the const offset with the ones from GET4() and PUT4() and emit single load and store instructions for the byte accesses.
2017-01-12libsec: implement extended 192-bit nonce xchacha variant and hchacha functioncinap_lenrek
2016-12-28libsec: replace des based X9.17 genrandom() with chacha random number generatorcinap_lenrek
2016-11-17libsec: remove unused get32() functioncinap_lenrek
2016-11-17libsec: remove unused aes_setupDecftrvxmtrx
2016-10-30libsec: add secp384r1 curve parameters for tlscinap_lenrek
2016-07-10libsec: add scrypt password based key derivation functioncinap_lenrek
2016-06-26chacha: calculate rounds in separate function (helps registerizer), get rid ↵cinap_lenrek
of unrolled code
2016-05-12auth/rsa2x509: generate x509v3 cert as extension field might not otherwise ↵cinap_lenrek
not be expected
2016-05-12auth/rsa2x509, auth/rsa2csr: allow appending SubjectAlternativeNames (SAN) ↵cinap_lenrek
to multi-domain certificate generation
2016-05-04retire the dec alpha portcinap_lenrek
2016-04-22libsec: implement server side SCSV preventing silly client fallbackscinap_lenrek
silly clients (web*) reconnect when the handshake failed with a lower protocol version, which allows downgrade attacks (POODLE). but instead of stopping this madness, they invented a new magic TLSID to indicate to the server that this connection attempt is a retry, and rely on the server to notice and stop them from sabotaging themselfs.
2016-04-21libsec: order tlshand cipher suits by: keyexchange>=cipher>=hash, ignore ↵cinap_lenrek
client preference client preference is usualy crazy, so just ignore it. we always want the diffie hellman suits before static rsa and prefer chacha over aes-gcm.
2016-04-21libsec: remove affine coordinate point operations from ecccinap_lenrek
we now just do point addtion in jacobian coordinate system, and convert the result to affine when s->z == nil.
2016-04-20libsec: implement elliptic curve group operations in jacobian coordinate systemcinap_lenrek