Commit Graph

145 Commits

Author SHA1 Message Date
Terra
2d498b827e
fix ed25519 export
Signed-off-by: Terra <terra@mcterra.id.au>
2025-04-24 10:02:06 +10:00
Christian Hohnstaedt
89b7c6beea codespell: Fix spelling issues, no functional changes 2025-03-28 18:11:18 +01:00
Christian Hohnstaedt
c9184b065f Add SHA3 hash algorithms 2024-10-06 22:28:04 +02:00
Christian Hohnstaedt
24c0236e29 Sane import-error of encrypted ED25519 keys
qCritical() terminates the application. This was not intended.
Rather print a reasonable error message.
2024-10-03 23:39:18 +02:00
Christian Hohnstaedt
a8ee4660d6 Close #593: App freezes/crashes when trying to export certain keys
Break an endless loop if the size of the encrypted private key is 0

Also add sanity check when updating the private key
that it has a size > 0. This should not happen, but anyway.
2024-10-03 10:55:32 +02:00
Christian Hohnstaedt
1ac1dc0a71 Extend password write dialogs by the file name
Now the Password dialog for exported items
also shows the file name of the current export
and not only the internal name of the item.
2024-09-14 01:13:18 +02:00
Christian Hohnstaedt
c806631906 Drop the Password input message for PVK files
Encrypted PVK files are not supported anymore since
39da47c217
So the password dialog messages are also supervlous.
2024-09-14 01:13:18 +02:00
Christian Hohnstaedt
778e5c2e3a Feature #313: Add JWK export
Export private and public keys as JWK.
2024-09-13 10:41:16 +02:00
Christian Hohnstaedt
4b6965d784 Related to #364 fix writeSSH2private() function
Move writeSSH2private() and write_SSH2_ed25519_private()
from pki_key.cpp (base class for public keys)
to pki_evp.cpp (derived class for private keys)

Extend the function to write RSA/DSA/EC in traditional
format.
Remove the PEM flag from the export format to not be catched
by (PEM | PRIVATE) selector in db_key::exportItem().
2024-08-24 15:09:00 +02:00
Christian Hohnstaedt
c730a886c8 Fix #364, comment#3: Remove ED25519 from PEM line
Actually, ED25519 has no "traditional" format.
While at it, replace the switch statement by
the simpler PEM_write_bio_PrivateKey_traditional()
2024-08-24 15:09:00 +02:00
Christian Hohnstaedt
db55a09a59 Abandon 3DES triggered by #218 Encryption for exported keys
Switch Key export in "Cert+PKCS#8" and "Database dump"
mode from DES3-EDE to AES-256
2024-08-21 10:20:41 +02:00
Christian Hohnstaedt
39da47c217 Drop support of encrypted PVK files.
The RC4 "encryption" is insecure.

The unencrypted PVK key is also insecure, but it does
not give users a false sense of security.
2024-08-20 11:03:27 +02:00
Christian Hohnstaedt
6b9c16a36a PEM Export of keys: Avoid endless loop
calling the pem() function with one argument
would call us (pem() with 2 arguments) again
and we would call him again. This is no good :-)
2024-02-23 12:21:53 +01:00
Christian Hohnstaedt
0a1a21608d Close #518: Export certificates for ovpn file
Create ovpn file with "ca", "cert" and "key"
Additionally put all intermediate CAs (if any)
tagged as "extra-certs".

"tls-auth" "OpenVPN Static key V1" not supported (yet)

Extend export-test by OpenVPN test case
2024-02-11 00:29:01 +01:00
Christian Hohnstaedt
6d01928d5d Automatically transform the key encryption scheme
When opening the database Find legacy encrypted keys and:
 - update them automatically when encrypted with the
   database password or
 - inform the user about a required action when encrypted with an
   individual passphrase

Related issues #458 #511 #503 #500 #494 #484 #482 #475

Remember a complete transformation of all keys
in the Settings["legacy-keys-updated"]
to avoid analyzing all keys each tim a database is opened.
2024-02-10 11:39:43 +01:00
Christian Hohnstaedt
e4483bc48d Move password verify logic into separate function
... and name it validateDatabasePassword().
It will also be used in the next commit to check
if the database password was entered correctly.
2024-02-09 22:46:26 +01:00
Christian Hohnstaedt
d32ab2e0d4 Close #458: Re-add support for legacy keys
With 2.5.0 support for decrypting pre 2.0.0 keys was dropped.
However, the database update in 2.0.0 and later did not convert the
keys.

Related issues #458 #511 #503 #500 #494 #484 #482 #475
2024-02-08 16:59:04 +01:00
Christian Hohnstaedt
41ff6818e9 Repeat password input on bad password 2023-12-30 11:02:42 +01:00
Christian Hohnstaedt
143d059ded Take care of OpenSSL and LibreSSL compatibility
OpenSSL 1.1.1 - 3.1.x are supported as well as
LibreSSL 3.6.x
2023-11-02 21:08:44 +01:00
Christian Hohnstaedt
d29d55ab20 Close #477: paste an encrypted private key results in a crash
Improve error- and password handling:
 - Also identify: (ERR_LIB_PROV:PROV_R_BAD_DECRYPT) as password error.
 - Do not use the OpenSSL internal bitfield definition (0xff000fff)
   but the official API: ERR_GET_LIB(), ERR_GET_REASON()
   Especially ERR_LIB_OFFSET changed from 24 to 23 in Openssl 3.0.0
 - First check for "Cancel", then for invalid password to avoid
   an "Invalid Password" message after aborting the password input dialog.
2023-11-02 14:27:58 +01:00
Christian Hohnstaedt
4fe06de78b Improve error handling in case of a wrong private password
instead of simply doing nothing.
2023-10-25 20:08:52 +02:00
Christian Hohnstaedt
26d5c73806 Improve EVP_PKEY_check()
According to the documentation EVP_PKEY_check() may
return -2 if the algorithm is not supported.
This has been observed with OpenSSL-1.1.1

See also b96951fdfd
2023-09-20 23:03:57 +02:00
Christian
d36eefaa7b Use correct free() function
EVP_PKEY must be freed by EVP_PKEY_free()
2023-09-15 10:48:05 +02:00
Christian Hohnstaedt
ab17dfd52f Simplify key checking algorithm
Since we dropped OpenSSL < 1.1.1 support, we can use
 EVP_PKEY_public_check() and EVP_PKEY_check()

Thanks to discussion in:
acb75afa6d
2023-05-16 09:49:46 +02:00
Christian Hohnstaedt
7206024d6a Fix deprecation warnings
The proposed "addAction()" with the KeySequence as 2nd argument
is only available soince Qt6.3 and not compatible with QT5
Change the call in a compatible way and set the shortcut afterwards.
2023-05-14 21:49:13 +02:00
Christian Hohnstaedt
ed475c8d9f Close #327: "Dump database" dumps everything to everywhere
Select the items to be dumped to the currently selected
directory.
2022-07-31 13:02:29 +02:00
Melg Eight
7bef74fb74
Enables usage of aes_256_cbc for private key export
Signed-off-by: Melg Eight <public.melg8@gmail.com>
2022-02-10 10:27:24 +03:00
Christian Hohnstaedt
4d401792a9 OpenSSL: Avoid all FILE pointer operations, use QFile
For interoprability reason.
To enforce it, set "#define OPENSSL_NO_STDIO 1"
All file access is done by reading/writing from/to BioByteArray()
which is filled by QFile:readAll()

Drop CRYPTO_malloc_debug / CRYPTO_mem_leaks
which is unused and disabled since many years.
2021-11-13 23:53:11 +01:00
Christian Hohnstädt
6ea01e80f6 Refactor item export: separate GUI and database
Collect all export formats in pki_export.

Each export format has assigned acouple of flags, indicating,
whether they are text, concatenateable, encrypted, usable for
multiple selections or only for a single item.
2021-11-13 14:49:02 +01:00
Christian Hohnstädt
be1a44d0a8 Consolidate export types and format in pki_export class
Move the descriptons from the ExportDialog into the
new pki_export class.

Also translate the exportType::etype to F_* flags
2021-10-30 11:51:35 +02:00
Christian Hohnstädt
13b0992780 Set Key export format separately via context menu
The popping up query dialog during PEM export via Drag&Drop
and Ctrl-C during Key export was pretty annoying.
2021-10-24 14:41:25 +02:00
Christian Hohnstädt
810b5509b1 pem_format(): Move private key cases to pki_evp
Support "exportType::PKCS8_encrypt"
2021-10-02 08:21:52 +02:00
Christian Hohnstaedt
0e5af2e452 Replace check_oom() by Q_CHECK_PTR()
Qt offers the functionality. No need to invent it ourselves.
2021-06-01 17:48:37 +02:00
Christian Hohnstaedt
f8915fbc98 PwDialog: Split into cmdline-core and GUI
Another step to split core and GUI components
2021-06-01 17:48:37 +02:00
Christian Hohnstaedt
0c5603ec20 XcaWarning: Split into Core and GUI element
one more step to split core and GUI components
2021-06-01 17:48:37 +02:00
Christian Hohnstaedt
82da759a4e XcaProgress: separate Cmdline progress from GUI progress
The generic XcaProgress object is used, which dynamically
creates a Cmdline progress object.
The Mainwindow replaces it by a GUI object, which integrates
into the status bar.
2021-06-01 17:48:37 +02:00
Christian Hohnstaedt
802a8787cf Adaptions to stay OpenSSL 3.0 alpha16 compatible 2021-05-12 08:49:28 +02:00
Christian Hohnstaedt
57802580c8 Drop backward-compatibility for old(<2.0.0) XCA databases 2021-05-10 20:41:12 +02:00
Christian Hohnstädt
1500e636c8 Drop OpenSSL backward compatibility hacks < 1.1.0
OpenSSL < 1.1.1 is out of support anyway
2021-05-09 12:25:32 +02:00
Christian Hohnstaedt
fdb2894e80 Close #142: Support Ed25519 Import private SSH2 key
Support loading OpenSSH ED25519 private key

Improve private key verification in general.
ED25519 does not support EVP_PKEY_sign(), so use
EVP_DigestSign(), which in turn only works since OpenSSL 1.1.1
resulting in a backward compatibility quirk in openssl_compat.
2021-04-01 11:02:22 +02:00
Christian Hohnstaedt
86cfff35d0 Close #142: Support Ed25519 Public export an Details
- Export SSH2 Public key
- Detect whether ED25519 key is private key
- Support ED25519 in the KeyDetails dialog
   o Display public key
   o Curve name
   o Fingerprints
   o Availability of private key
2021-04-01 11:02:22 +02:00
Christian Hohnstaedt
dbb3c48ef3 Close #142: Support Ed25519 Keygen
Support generating ED25519 keys
2021-04-01 11:02:22 +02:00
Christian Hohnstädt
1a0ef9c9ee Extend OpenSSL 1.0.2 compatibility layer
Add EVP_MD_CTX_new/free() and EVP_CIPHER_CTX_new/free()
as backward compatibility layer
2021-04-01 11:02:22 +02:00
Christian Hohnstaedt
46cbba45a3 pki_evp: Fix indentation 2021-04-01 11:02:22 +02:00
Christian Hohnstaedt
66cff37ad9 Close #208: XCA hung when importing EC keys. For example prime256v1
Fix Null-Pointer exception, which is strange, because:
 - it only happens on windows
 - the key still works fine
2021-02-06 22:52:54 +01:00
Christian Hohnstaedt
ea453d4336 Encapsulate all BIOs in the BioByteArray class
If we have a QByteArray (ba) and must provide it to
a BIO* expecting OpenSSL function, the following
construct provides it: BioByteArray(ba).ro()
directly providing the QByteArray buffer as BIO

It also supports mixed writes:
  BIO_write(bba, buf, size)
  bba += QByteArray
2020-04-06 22:07:57 +02:00
Christian Hohnstaedt
5543ec2fb8 Merge branch 'master' into develop 2020-04-02 07:35:18 +02:00
Christian Hohnstaedt
d54aa116db Avoid unused variable warning for OpenSSL 0.9.8 2020-03-29 22:33:57 +02:00
Christian Hohnstaedt
9c55caf82f Merge branch 'master' into develop 2020-03-23 06:53:06 +01:00
Christian Hohnstaedt
92846d6b38 Close #174: Microsoft's PVK RSA private key format
Support Import and export private and public PVK keys.
2020-03-22 08:12:38 +01:00