summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* pkcs: extract PBE-based encryption and decryption functionstmp-cms-supportDmitry Baryshkov2022-09-113-264/+189
| | | | | | | Extract internal functions used by both PKCS#12 and PKCS#8 to handle PBE-based encryption of the data. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: consolidate encryption functionsDmitry Baryshkov2022-09-113-173/+78
| | | | | | | Use _gnutls_pkcs7_en/decrypt_int() to implement _gnutls_pkcs_raw_en/decrypt_data(). Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: add support for EncryptedDataDmitry Baryshkov2022-09-119-5/+702
| | | | | | | Add support for parsing, decrypting and encrypting EncryptedData PKCS7/CMS files. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkix.asn: add RC2 CBC parametersDmitry Baryshkov2022-09-111-0/+4
| | | | | | | Add SEQUENCE for RC2 CBC parameters. It includes IV and a magic describing RC2 key bits. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: move writing attributes to pkcs7-attrs.cDmitry Baryshkov2022-09-115-119/+93
| | | | | | | Move functions that write PKCS7 attributes to pkcs7-attrs.c, they will be reused by encrypted/enveloped files support. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* lib: add function to get cipher by OIDDmitry Baryshkov2022-09-116-5/+43
| | | | | | Add function returning gnutls_cipher_algorithm_t by corresponding OID. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: add support for DigestedData CMS filesDmitry Baryshkov2022-09-119-0/+397
| | | | | | Add support for creating and verifying DigestedData CMS files. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: support Data Content TypeDmitry Baryshkov2022-09-114-68/+182
| | | | | | | As a first step towards supporting different PKCS7 content types, add support for plain Data Content Type. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: rename data fieldsDmitry Baryshkov2022-09-113-80/+80
| | | | | | | Rename data fields to use word 'content' rather than 'signed'. Other PKCS#7 types have different usage types for these data elements. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: drop expanded field, just reinit alwaysDmitry Baryshkov2022-09-112-8/+4
| | | | Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* pkcs7: rearrange code to ease adding other pkcs7 typesDmitry Baryshkov2022-09-114-2207/+2239
| | | | | | Rearrange functions splitting pkcs7 signed support to separate file. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
* Merge branch 'fix_nettle_alignment' into 'master'Daiki Ueno2022-08-301-2/+2
|\ | | | | | | | | cipher: Ensure correct alignment See merge request gnutls/gnutls!1633
| * cipher: Ensure correct alignmentDoug Nazar2022-08-281-2/+2
| | | | | | | | | | | | Unsigned math is required to calculate the current alignment. Signed-off-by: Doug Nazar <nazard@nazar.ca>
* | gnutls_session_channel_binding: perform check on "tls-exporter"Daiki Ueno2022-08-291-1/+16
|/ | | | | | | | | According to RFC9622 4.2, the "tls-exporter" channel binding is only usable when the handshake is bound to a unique master secret. This adds a check whether either TLS 1.3 or extended master secret extension is negotiated. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* Merge branch 'wip/dueno/cpuid-fixes' into 'master'Daiki Ueno2022-08-241-11/+38
|\ | | | | | | | | | | | | accelerated: clear AVX bits if it cannot be queried through XSAVE Closes #1282 See merge request gnutls/gnutls!1631
| * accelerated: clear AVX bits if it cannot be queried through XSAVEDaiki Ueno2022-08-231-11/+38
| | | | | | | | | | | | | | | | | | | | | | The algorithm to detect AVX is described in 14.3 of "Intel® 64 and IA-32 Architectures Software Developer’s Manual". GnuTLS previously only followed that algorithm when registering the crypto backend, while the CRYPTOGAMS derived SHA code assembly expects that the extension bits are propagated to _gnutls_x86_cpuid_s. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | Unload custom allocators in gnutls_crypto_deinit()Tobias Heider2022-08-231-3/+5
| | | | | | | | | | | | Closes #1398 Signed-off-by: Tobias Heider <tobias.heider@canonical.com>
* | Merge branch 'restrict-allowlisting-api' into 'master'Daiki Ueno2022-08-177-190/+641
|\ \ | | | | | | | | | | | | restrict allowlisting api to before priority string initialization See merge request gnutls/gnutls!1533
| * | update documentation on allowlisting APIAlexander Sosedkin2022-08-161-15/+54
| | | | | | | | | | | | | | | | | | (in a separate commit so that it's easier to compare) Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
| * | plumb allowlisting API through the config, restrict usage to early timesAlexander Sosedkin2022-08-167-148/+432
| | | | | | | | | | | | Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
| * | lib/priority: extract parts of cfg_apply into cfg_*_set_array*Alexander Sosedkin2022-08-151-39/+178
| | | | | | | | | | | | Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
| * | lib/priority: move sigalgs filtering to set_ciphersuite_listAlexander Sosedkin2022-08-151-18/+7
| | | | | | | | | | | | Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
* | | Merge branch 'wip/dueno/fips-rsa-key-sizes' into 'master'Daiki Ueno2022-08-161-23/+31
|\ \ \ | | | | | | | | | | | | | | | | fips: mark RSA SigVer operation approved for known modulus sizes See merge request gnutls/gnutls!1630
| * | | nettle: mark RSA SigVer operation approved for known modulus sizesDaiki Ueno2022-08-131-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SP800-131A rev2 suggests certain RSA modulus sizes under 2048 bits (1024, 1280, 1536, and 1792) may continue to be used for signature verification but not for signature generation. This loosen the current service indicator report to approve them. Signed-off-by: Daiki Ueno <ueno@gnu.org>
| * | | nettle: check RSA modulus size in bits rather than bytesDaiki Ueno2022-08-121-20/+20
| | |/ | |/| | | | | | | | | | | | | | | | | | | Previously we checked RSA modulus size clamped to byte unit instead of bits. This makes the check stricter by explicitly calculating the modulus size in bits. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | | windows: Avoid -Wint-conversion errorsMartin Storsjo2022-08-161-4/+4
| |/ |/| | | | | | | | | | | | | | | | | | | Clang 15 made "incompatible pointer to integer conversion" an error instead of a plain warning. This fixes errors like these: system/keys-win.c:257:13: error: incompatible pointer to integer conversion initializing 'HCRYPTHASH' (aka 'unsigned long') with an expression of type 'void *' [-Wint-conversion] HCRYPTHASH hHash = NULL; ^ ~~~~ Signed-off-by: Martin Storsjo <martin@martin.st>
* | fips: disable GNUTLS_CIPHER_3DES_CBC self-testAlexander Sosedkin2022-08-091-5/+0
|/ | | | Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
* _gnutls_decrypt_pbes1_des_md5_data: use public crypto APIDaiki Ueno2022-08-041-6/+4
| | | | | | | | This is a follow-up of e7f9267342bc2231149a640163c82b63c86f1dfd. In the decryption code path with PBES1, algorithm checks for FIPS was not applied, because it used internal functions that bypass those checks. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* Update doc for GNUTLS_CB_TLS_EXPORTER towards RFC9266.Simon Josefsson2022-07-301-1/+1
| | | | Signed-off-by: Simon Josefsson <simon@josefsson.org>
* KTLS: hotfixFrantisek Krenzelok2022-07-291-1/+2
| | | | | | | | | | session->internals.pull_func is set to system_read during gnutls_init() so check for user set pull/push function added in commit mentioned bellow will never pass. source: 2d3cba6bb21acb40141180298f3924c73c7de8f8 Signed-off-by: Frantisek Krenzelok <krenzelok.frantisek@gmail.com>
* Merge branch 'wip/dueno/socket-no-wrap' into 'master'Daiki Ueno2022-07-281-1/+8
|\ | | | | | | | | Make gnutls-cli work with KTLS See merge request gnutls/gnutls!1617
| * handshake: do not enable KTLS if custom pull/push functions are setDaiki Ueno2022-07-271-1/+8
| | | | | | | | | | | | | | | | If gnutls_transport_set_pull_function or gnutls_transport_set_push_function is used, we can't assume the underlying transport handle is an FD. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | Fix double free during gnutls_pkcs7_verifyZoltan Fridrich2022-07-271-1/+2
|/ | | | Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
* Fix memory leak in gnutls_pkcs7_importZoltan Fridrich2022-07-261-1/+5
| | | | Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
* crypto-api: add block cipher API with automatic paddingDaiki Ueno2022-07-223-0/+184
| | | | | | | | This adds a couple of functions gnutls_cipher_encrypt3 and gnutls_cipher_decrypt3, which add or remove padding as necessary if the length of the plaintext is not a multiple of the block size. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* Merge branch 'wip/dueno/minor-f36' into 'master'Daiki Ueno2022-07-224-6/+8
|\ | | | | | | | | | | | | Suppress compile time warnings on Fedora 36 Closes #1386 See merge request gnutls/gnutls!1606
| * crypto-selftests: fix decryption check condition in test_cipher_aeadDaiki Ueno2022-07-201-1/+3
| | | | | | | | | | | | Spotted by gcc-analyzer 12. Signed-off-by: Daiki Ueno <ueno@gnu.org>
| * x509, tpm2: use asn1_node instead of deprecated ASN1_TYPEDaiki Ueno2022-07-203-5/+5
| | | | | | | | Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | accelerated: aarch64: add OpenBSD/aarch64 supportBrad Smith2022-07-151-0/+22
| | | | | | | | Signed-off-by: Brad Smith <brad@comstyle.com>
* | cipher: limit plaintext length supplied to AES-GCMDaiki Ueno2022-07-139-29/+158
| | | | | | | | | | | | | | According to SP800-38D 5.2.1.1, input data length of AES-GCM encryption function must be less than or equal to 2^39-256 bits. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | Add self-test code inside a FIPS contextRichard Costa2022-07-091-0/+19
| | | | | | | | | | | | | | | | | | | | | | Self-test code exercise lots of different FIPS-related code with side-effects. So, in order to prevent it from losing information when executing inside another context, we create an appropriated one. If the self-test fails, then the library is placed in error state, so it doesn't matter for other contexts. Signed-off-by: Richard Maciel Costa <richard.costa@suse.com>
* | Increase the limit of TLS PSK usernames from 128 to 65535 charactersZoltan Fridrich2022-07-0814-139/+184
|/ | | | | Co-authored-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
* Merge branch 'wip/dueno/ktls-fixes' into 'master'Daiki Ueno2022-06-302-11/+22
|\ | | | | | | | | Minor fixes on KTLS See merge request gnutls/gnutls!1604
| * ktls: _gnutls_ktls_enable: fix GNUTLS_KTLS_SEND calculationDaiki Ueno2022-06-281-5/+16
| | | | | | | | | | | | | | | | | | Previously, if the first setsockopt for GNUTLS_KTLS_RECV fails and the same socket is used for both sending and receiving, GNUTLS_KTLS_SEND was unconditionally set. This fixes the conditions and also adds more logging. Signed-off-by: Daiki Ueno <ueno@gnu.org>
| * handshake: do not reset KTLS enablement in gnutls_handshakeDaiki Ueno2022-06-281-6/+6
| | | | | | | | | | | | | | As gnutls_handshake can be repeatedly called upon non-blocking setup, we shouldn't try to call setsockopt for KTLS upon every call. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | Merge branch 'wip/dueno/hkdf-limit' into 'master'Daiki Ueno2022-06-291-0/+5
|\ \ | | | | | | | | | | | | nettle: restrict output size of HKDF-Expand to 255 * HashLen See merge request gnutls/gnutls!1602
| * | nettle: restrict output size of HKDF-Expand to 255 * HashLenDaiki Ueno2022-06-291-0/+5
| |/ | | | | | | | | | | | | | | | | | | RFC 5869 2.3 requires that requested output length of HKDF-Expand to be equal to or less than 255 times hash output size. Inspired by the report by Guido Vranken in: https://lists.gnupg.org/pipermail/gcrypt-devel/2022-June/005328.html Signed-off-by: Daiki Ueno <ueno@gnu.org>
* | fips: make service indicator logging louderDaiki Ueno2022-06-292-36/+58
|/ | | | | | | | | | Previously, the only way to monitor the FIPS context transtion was to increase logging level to debug (2), which produces unrelated output. This changes the minimum logging level to audit (1) for when the transition happens. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* KTLS: disable by default enable by configFrantišek Krenželok2022-06-143-8/+8
| | | | | | | KTLS will be disabled by default when build with `--enable-ktls` to enable it, use config file option `ktls = true` in [global] section. Signed-off-by: Frantisek Krenzelok <krenzelok.frantisek@gmail.com>
* fips: provide function to manually run FIPS self-testsDaiki Ueno2022-06-094-72/+91
| | | | | | | | | | | | | | | | | FIPS140-3 IG 10.3.E Periodic Self-Testing says: At security levels 1 and 2, acceptable means for initiating the periodic self-tests include a provided service, resetting, rebooting or power cycling. Neither resetting, rebooting, nor power-cycling is suitable because those involve operations outside of the module. Therefore this patch adds a new API to manually run the substance of FIPS140 self-tests. Suggeested by Richard Costa and Stephan Mueller in: https://gitlab.com/gnutls/gnutls/-/issues/1364 Signed-off-by: Daiki Ueno <ueno@gnu.org>