summaryrefslogtreecommitdiff
path: root/crypt.h (follow)
Commit message (Collapse)AuthorAge
* Switch to SPDX identifiers.Andre Noll2026-03-17
| | | | | | | | Generated with sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h followed by manually tweaking the result a bit. No license change intended.
* Improve crypto documentation.Andre Noll2025-10-08
| | | | | | | The new file commend for crypt.h, and a few minor improvements in the same file. No changes to openssl.c and gcrypt.c because those do not contain any doxygen comments. Also crypt_common.c is left untouched because this file received its dose of dedox earlier.
* Rename hash2 -> hash.Andre Noll2025-05-22
| | | | | Now that sha1 is no longer supported, the hash2 naming has become meaningless. Rename it back to "hash".
* Remove sha1.Andre Noll2025-05-22
| | | | | | | | | | | | | | | | Server and client prefer sha256 in the authentication protocol since paraslash-0.7.0, while 0.6.x clients and servers only know about sha1. This patch drops the compatibility code which enabled old clients to connect to new servers and vice versa. Now the client code no longer checks whether the sha256 feature is supported, but requests and uses the feature unconditionally. The server still announces the sha256 feature and accepts the corresponding feature request, but uses sha256 unconditionally. With this approach older 0.7.x clients are still compatible to current server versions and current clients can still talk to servers running older 0.7.x versions.
* apc_priv_decrypt: Let the callee allocate the buffer.Andre Noll2024-05-17
| | | | | | | This complements the previous commit which made the analogous change for public encryption. Passing char ** instead of char * to apc_priv_decrypt() allows us to get rid of the magic 1024 constant in client_common.c.
* apc_pub_encrypt: Let the callee allocate the buffer.Andre Noll2024-05-17
| | | | | | | | | | Change the encryption routine of the apc API to allocate a suitably sized buffer itself. Currently, the caller has to guess the size of the buffer to pass to the function and we reuse our 4k handshake buffer for that. While 4k is is plenty at the moment, that may change, and it's always better to use the exact size if it is readily available. This is the case here because the required buffer size is just the number of bits of the modulus of the key.
* Merge branch 'maint'Andre Noll2023-05-11
|\ | | | | | | | | | | | | | | | | | | Two fixes for gcc-12 warnings, and another fix for a benign but embarrassing braino in gcrypt.c. * maint: gcrypt: Fix return value of apc_get_pubkey(). error.h: Be more careful with error code masking. mp3_afh: Drop unused fields from struct mp3header.
| * gcrypt: Fix return value of apc_get_pubkey().Andre Noll2023-05-11
| | | | | | | | | | | | | | | | | | The function is supposed to return the key size in bytes, but it returns the number of *bits*. A consequence of this bug is that RSA keys which are too short to encrypt our 128 byte buffer are not rejected as they should be. This is not too serious because we'll fail later during the encryption step. Fix the bug anyway and clarify the documentation of apc_get_pubkey().
* | Introduce hash2 (sha256).Andre Noll2021-10-21
|/ | | | | | This adds a second hash function which will replace sha1. Both openssl and libgcrypt support sha256, so it is easy to do. There are no users of the new functions so far, so this patch has no effect yet.
* doc: Add missing \ref in crypt.h.Andre Noll2020-07-11
| | | | | This way, we get a warning when the name of the function changes but the comment is left unmodified.
* crypt_common: Constify hash pointers.Andre Noll2020-07-11
| | | | | hash_to_asc() and hash_compare() only read from the memory locations given by these pointers.
* crypt: Introduce crypt_shutdown().Andre Noll2018-02-26
| | | | | | | | | | This plugs a few harmless memory leaks in the openssl crypto backend. The leaks occur on exit and are only reported by valgrind if it is run with --leak-check=full --show-leak-kinds=all. The gcrypt backend has similar problems, but there is no way to provide a similar patch for libgrypt. The newly added comment in gcrypt.c explains why.
* crypt: Rename init_random_seed_or_die() -> crypt_init().Andre Noll2018-02-26
| | | | | At least the gcrypt implementation does more than just seed the PRNG. The new name is shorter and more descriptive.
* crypt: Rename RSA functions.Andre Noll2018-02-26
| | | | | | | | | | | This renames the functions and constants of the public crypto API which deal with RSA to have the common "apc" (asymmetric pubkey cryptosystem) prefix. This hides RSA as an implementation detail and makes it clear that the functions/constants are related to apc. Pure renaming, no semantic change. The only other changes are a new comment to crypt.h and a \ref statement in the doxygen comment of apc_free_pubkey().
* crypt.h: Remove two unused constants.Andre Noll2018-02-26
| | | | | | These should have been removed already last year in commit d9f54f43 (crypto: Remove support for ASN public keys), since that commit made the constants obsolete.
* Shorten copyright notice.Andre Noll2017-09-22
| | | | | | | | | | | | | | | | | | | | | The GPLv2 line does not add any additional information, so drop it. This leaves a single line of legalese text for most files, which is about the amount of screen real estate it deserves. This patch was created with the following script (plus some manual fixups): awk '{ if (NR <= 5) { gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g") if (gs != $0) year = gs next } if (NR == 6 && year != "") printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year) print }'
* Merge branch 'refs/heads/t/rm_rc4'Andre Noll2017-04-16
|\ | | | | | | | | | | | | | | | | | | | | This patch removes support for RC4, making the AES-based stream cipher mandadory. The aes_ctr128 server feature is made a no-op, breaking support with very old clients (<= 0.5.1). Cooking for three months. * refs/heads/t/rm_rc4: crypt: Remove RC4 support.
| * crypt: Remove RC4 support.Andre Noll2017-01-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple vulnerabilities have been discovered in the RC4 stream cipher, rendering it insecure. paraslash stopped using RC4 as the default stream cipher since version 0.5.2 (2014-04-11), but server and client still supported the broken cipher for backward compatibility. This commit removes the compatibility code from both the openssl and the libgcrypt code base, leaving aes_ctr128 as the only remaining stream cipher. The server still announces the aes_ctr128 feature, although it is now mandatory because the server will enable aes_ctr128 unconditionally, no matter whether it was requested by the client or not. The client, on the other hand, still requests this feature, regardless of whether it was announced by the server or not. This keeps unpatched clients => 0.5.2 working with new servers and vice versa. Regarding the public crypto API, sc_new() loses its boolean use_aes parameter. Otherwise the API remains the same. The patch also rewrites the crypto section of the manual to not mention RC4 any more.
* | crypto: Simplify asymetric key handling.Andre Noll2017-01-06
|/ | | | | | | | | | | | | | get_asymmetric_key() and free_asymmetric_key() are public because para_server maintains a copy to the public key of each user so that the keys need to be loaded only once. On the other hand, for private keys (used in para_client) key allocation and freeing is performed implicitly in priv_decrypt(), and no reference to the key is ever returned. So the crypto API can be simplified by exposing the interface only for public keys. Hence this patch renames get_asymmetric_key() to get_public_key() and drops the "private" argument. Similarly, free_asymmetric_key() is renamed to free_public_key().
* Update year in copyright headers.Andre Noll2015-01-12
| | | | | | | | | | | | | | | | Done with files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files In previous years we ran a similar script to set the second year in the range to the current year. This is kind of silly, so let's get rid of this useless information. This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in all file headers, i.e. only the first year (A) is left in. Accurate information including time stamps for each change can be obtained from the git history.
* doc: Change email address to maan@tuebingen.mpg.deAndre Noll2014-08-18
| | | | | | | | | | | | | | The mail server on systemlinux.org was down for more than a week lately, so let's use an alternative official address. This commit changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de. Most .c and .h files contain the email address in the copyright header, so they must all be patched. Three other files contain the address for a different reason: * README lists email and git, gitweb and home page URLs * configure.ac needs it for configure -h * version.c contains it for the -V option of all commands
* Merge branch 't/misc'Andre Noll2014-03-30
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various fixes, improvements, cleanups. Cooking since 2014-02-22. * t/misc: (29 commits) build: Don't link with -lreadline if readline was not found. audiod: Skip NULL pointer check in compute_time_diff(). audiod: Make compute_time_diff() return void. com_stat(): Remove pointless uptime variable. gcrypt: Fix gcc warning on Ubuntu Lucid. flac: Try to link also without -logg. version.c: Fix comment of version_single_line(). doxygen: Expand all macros, in particular config.h. recv_common.c: Improve documentation of check_receiver_arg(). audiod: get_time_string() comment fix. configure: Really print opus audio file handler if opus lib was found. Overhaul doxygen main page. afs.h: Don't try to list all supported audio formats. Change copyright year to 2014. Add link to sideband.h in doxygen main page. Doxify error2.c and add GPL header. Add -Wdeclaration-after-statement. Add some missing includes. Makefile.real: Add clean2 to the list of phony targets. mood.c: Fix a trivial whitespace issue. ...
| * Change copyright year to 2014.Andre Noll2014-02-22
| | | | | | | | | | | | | | | | | | This year, we're really on time. The changes in this patch were created by the following silly script: files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files
* | Implement aes_ctr128 and prefer it over RC4.Andre Noll2014-01-09
|/ | | | | | | | | | | | | | | | | | This adds the aes_ctr128 stream cipher to para_server, para_client and para_audiod. para_server now announces this cipher as a supported feature and para_client requests an aes_ctr128-encrypted session if the server supports it. If one or both sides don't understand the new feature, the RC4 fallback applies. So this change is backwards-compatible. Both gcrypt and openssl support aes_ctr128, and the two implementations are compatible to each other: a para_client linked against openssl can talk to a para_server which was linked against libgcrypt and vice versa. This patch also updates the documentation to talk about stream ciphers and session keys rather than to mention RC4 explicitly. A short section on AES is added which also explains how counter mode turns a block cipher into a stream cipher.
* Remove old stream cipher API.Andre Noll2013-04-03
| | | | | No users remained after the sideband compatibility code has been removed.
* Change copyright year to 2013.Andre Noll2013-03-25
| | | | Better late than never.
* Add sideband implementation.Andre Noll2012-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the new source files sideband.[ch] to the repository and links the corresponding object file into para_server, para_audiod and para_client. The sideband API enables the command handlers of para_server to send a multiplexed output stream. The client side (para_client or para_audiod) demultiplex the received stream afterwards. The design is as simple as it can be: Each data buffer is preceded by a 5-byte header containing the length and the band designator, a one-byte number which specifies the type of the data which follows. The server-side and the client-side implement their own variant of the send_sb() and recv_sb() functions for sending and receiving sideband packets. Two implementations are necessary because the underlying file descriptor is blocking on the server side (command handlers of para_server) while it is non-blocking on the client side (para_client and para_audiod). The sideband API allows to optionally filter all data (including the sideband header) through an arbitrary transformation. This patch adds a suitable transformation as a new public function performs RC4 to the crypto API. To keep the patch within reasonable size, this commit does not contain any users of the new sideband API yet. Subsequent commits will teach the authentication handshake code and the command handlers to send and receive data as sideband packets.
* Change year in copyright message to 2012.Andre Noll2012-01-07
|
* doc: Minor doxygen fixes.Andre Noll2011-10-01
| | | | | | | | | doxygen's \cond and \endcond commands treat the word after the command as the name of the section which should be excluded from the documentatation. So it is wrong to put an arbitrary comment there. This fixes a couple of doxygen warnings about unknown loglevel defines and makes these defines actually show up in the generated HTML.
* crypt: Move documentation to crypt.h.Andre Noll2011-07-06
| | | | | | | | Since we will have two implementations soon, the documentation of the public API should go to the common header. Also fix the documentation of pub_encrypt(): The size of the input buffer is never enough. 512 always suffices.
* stream cipher: Allow in-place encryption.Andre Noll2011-07-06
| | | | | | unlike openssl's RC4(), the RC4 implemenation of libgcrypt can encrypt a buffer in-place. For this the "buf" argument of the various send and receive functions must not be const.
* crypt: Move implementation-independent code to separate file.Andre Noll2011-07-06
| | | | | | | | | | | | This introduces crypt_common.c which contains helper functions from crypt.c which are independent of openssl. crypt.common.c contains two types of public functions: Frontend functions are called by users of the crypto API, and these functions are exported as usual through the crypt.h header file. Backend functions, on the other hand, are expected to be called only from the crypto implementation (i.e. from crypt.c or gcrypt.c). These functions are exported through the new crypt_backend.h header file.
* Move sha1.[ch] to crypt.[ch] and make crypto API independent of sha1.Andre Noll2011-03-27
| | | | | | | This patch moves all public functions related to sha1 to crypt.c. This allows to remove sha1.c, sha1.h and hash.h. It also removes the HASH_TYPE define and avoids the word "sha1" in the public API and its callers. The former sha1_hash() is now called hash_function().
* Remove rc4.h.Andre Noll2011-03-27
| | | | | It's kind of silly to have an extra file which contains only a singe preprocessor define. Move that define to crypt.h and kill rc4.h.
* Rename struct rc4_context and stream cipher send/receive functions.Andre Noll2011-03-27
| | | | | | | This only changes the name structures and functions. Unfortunately, the patch is rather large since it requires to fixup all callers of the affected functions. However, each change is either a simple rename or a trivial documentation adjustment.
* Replace direct use of RC4 by stream cipher abstraction.Andre Noll2011-03-27
| | | | | | | | | | | This introduces the new struct stream_cipher in crypt.h as well as two functions stream_cipher_new() and stream_cipher_free() which initialize a new stream cipher structure and deallocate such a structure, respectively. The users of RC4 are changed to call the new abstract functions, so they become independent from openssl. Consequently the affected files need no include openssl/rc4.h any more.
* Replace RSA by an abstract asymmetric key structure.Andre Noll2011-03-27
| | | | | | | | | | | This declares the new structure asymmetric_key in crypt.h but does not define it. Instead, it is defined in crypt.c so that only the functions in this file can access the members of the structure directly. Functions which previously took an (openssl-specific) RSA pointer are changed to receive a pointer to struct asymmetric_key instead, removing the requirement to include an openssl header file before crypt.h can be included.
* Replace 2010 in copyright message by 2011.Andre Noll2011-01-17
|
* Change year in COPYRIGHT to 2010.Andre Noll2010-04-05
| | | | Hey, this is earlier than last year :)
* Add documentation to struct rc4_context.Andre Noll2009-07-11
|
* Stronger crypto for client authentication.Andre Noll2009-06-21
| | | | | | | | | | | | | | | | | | | This patch changes the way clients are authenticated: - The size of the challenge has been increased from sizeof(unsigned long) to 64. Openssl's Rand_bytes() is used to get the random buffer for the challenge and the rc4 keys. - The client responds with the sha1 hash of the challenge rather than sending back the decrypted challenge in plain text. - The rc4 keys are now 2 x 32 bytes long. They are rsa encrypted and sent together with the challenge. - Authentication requests for invalid users are not immediatedly denied as this would reveal the fact that the user does not exist. - rsa keys are required to be at least 2048 bits long.
* Make rc4 encryption/decryption more explicit.Andre Noll2009-06-14
| | | | | | | | | | | | | | | | | The old code used a rather fancy way to (de)activate encryption on a per fd basis: In net.c there was an array of rc4 keys, indexed by fd. This is rather wastful because the array size is determined by the highest fd for which encryption is activated. It's also hard to comprehend and it's easy to get strange results if one forgets to deactivate the encryption after the fd is closed. This patch introduces a new structure, rc4_context, which consists of an fd and the needed rc4 keys. Users explicitly call the new rc4 variants of the receving/sending functions which take a pointer to a struct rc4_context instead of a file descriptor but are otherwise identical. Keep crypt simple!
* Use openssl's RAND_load_file() and RAND_bytes() to get randomness.Andre Noll2009-06-14
| | | | | This should yield random data that is cryptographically stronger than random().
* Change year of copyright from 2008 to 2009.Andre Noll2009-01-10
|
* Change year in Copyright comment from 2007 to 2008.Andre Noll2008-01-08
|
* replace standard GPL header by a one-line pointer to COPYINGAndre Noll2007-06-28
|
* be more carful wrt. signed vs. unsigned argument passingAndre Noll2007-05-26
|
* fix a memory leak in the RSA key handlingAndre Noll2007-02-11
| | | | | | | | RSA keys must be freed by using openssl's RSA_free() rather than the usual free(). This leak turns out to be more serious as the amount of leaked memory increased by about 300 bytes every time para_server reread the user list (i.e. the hup command was executed or para_server received SIGHUP).
* move LOAD_PUBLIC_KEY and LOAD_PRIVATE_KEY to crypt.hAndre2006-11-01
| | | | | and use LOAD_PUBLIC_KEY instead of hardcoding its value in server.c. Also, add a GPL header to crypt.h
* switch to the in-memory user listAndre2006-11-01
| | | | | | | In order to do so, the crypt functions had to be changed so that they take an rsa key instead of the filename of that key. Also, make _get_user() return -E_BAD_USER if the user was not found and move the corresponding error codes from COMMAND_ERRORS to SERVER_ERRORS in error.h.