summaryrefslogtreecommitdiff
path: root/lib/privkey.c
Commit message (Collapse)AuthorAgeFilesLines
* gnutls_privkey_sign_data2: removed unnecessary text [ci skip]Nikos Mavrogiannopoulos2019-11-051-13/+9
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* pk: implement deterministic ECDSA/DSADaiki Ueno2019-08-081-0/+8
| | | | | | | This exposes the deterministic ECDSA/DSA functionality through the GNUTLS_PRIVKEY_FLAG_REPRODUCIBLE flag. Signed-off-by: Daiki Ueno <dueno@redhat.com>
* privkey_sign_prehashed: remove unused argumentDaiki Ueno2019-08-081-5/+4
| | | | Signed-off-by: Daiki Ueno <dueno@redhat.com>
* privkey_sign_raw_data: remove unnecessary local variableDaiki Ueno2019-08-081-3/+1
| | | | Signed-off-by: Daiki Ueno <dueno@redhat.com>
* gnutls_privkey_sign_hash2: accept the GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA flagtmp-fix-raw-flag-in-newapiNikos Mavrogiannopoulos2019-06-101-4/+12
| | | | | | | | | | Previously this flag was ignored, although documented not to. This patch also enables the tests sign-verify-newapi and sign-verify-data-newapi which were supposed to test this interface, but were never enabled. This was caught by Andreas Metzler. Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* Use https:// for www.gnu.org and www.example.comTim Rühsen2019-03-131-1/+1
| | | | Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
* Constant time/cache PKCS#1 RSA decryptiontmp-fix-CVE-2018-16868Simo Sorce2018-11-301-0/+76
| | | | | | | | | | | This patch tries to make the code have the same time and memory access aptterns across all branches of the decryption function so that timining or cache side channels are minimized or neutralized. To do so it uses a new nettle rsa decryption function that is side-channel silent. Signed-off-by: Simo Sorce <simo@redhat.com>
* privkey_sign_raw_data: use assert to mark code which always succeedsNikos Mavrogiannopoulos2018-08-131-0/+1
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Support GOST private keys generationDmitry Eremin-Solenikov2018-06-231-0/+16
| | | | Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* signatures: distinguish RSA-PSS signatures with RSA PKCS#1 1.5 certificates ↵Nikos Mavrogiannopoulos2018-03-091-6/+11
| | | | | | | | | | | | | | | | | from "pure" This change enhances signature algorithms to have a private key algorithm parameter. That is, to allow signature algorithms operating with a private key of type X while the public key is of type Y. That is useful for the RSA-PSS signatures which are of two types; one which is seen from servers having PKCS#1 1.5 certificates, the other with RSA-PSS certificates, while both utilize RSA-PSS private keys. This is a draft-ietf-tls-tls13-23 change. Resolves #400 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_privkey_import_ext4: enhanced with GNUTLS_PRIVKEY_INFO_PK_ALGO_BITS flagNikos Mavrogiannopoulos2018-03-021-3/+9
| | | | | | | | | | | | | | That flag is utilized by the information function to obtain the value of the parameters (e.g., modulus). That information is necessary to safely handle RSA-PSS keys. For RSA-PSS keys this is a regression since 3.6.0 where this API was introduced, but as this change is necessary and 3.6.x is not yet marked as stable, it should be acceptable. Relates #402 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* _gnutls_find_rsa_pss_salt_size: add a validity check for salt sizeNikos Mavrogiannopoulos2018-03-021-2/+7
| | | | | | | | That is, in order to reject invalid parameters. Resolves #402 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* doc: improve documentation on provable private keysNikos Mavrogiannopoulos2017-10-091-6/+27
| | | | | | Resolves #301 Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* sign APIs: introduce RSA-RAW signing algorithmNikos Mavrogiannopoulos2017-08-171-24/+41
| | | | | | | | | This ensures that there is a signing algorithm for all the operations we support. Previously, we required GNUTLS_SIGN_UNKNOWN to be acceptable by signing functions to accomodate for raw RSA operations. Now we make that explicit and in the process clean-up the API. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_privkey_import_ext4: introduced to allow signing with RSA-PSS or ↵Nikos Mavrogiannopoulos2017-08-151-38/+142
| | | | | | | | | | | | Ed25519 keys That function allows a signing callback which passes the signature algorithm, providing all the information to callback for signing. It also introduces GNUTLS_PRIVKEY_INFO_HAVE_SIGN_ALGO flag which allows the library to query the private key of the supported signature algorithms. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_pk_params_st: separate flags/qbits and curveNikos Mavrogiannopoulos2017-08-081-1/+3
| | | | | | | | | | Previously we were using the field flags to store the size of q in case of GNUTLS_PK_DH, some key generation flags in case of GNUTLS_PK_RSA, and the curve in case of elliptic curve key. Separate this into multiple fields to reduce confusion on the field. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* privkey: reject signing with ext keys and GNUTLS_PK_RSA_PSS or ↵Nikos Mavrogiannopoulos2017-08-041-0/+3
| | | | | | GNUTLS_PK_EDDSA_ED25519 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* privkey: return less specific but more appropriate error on invalid pks for ↵Nikos Mavrogiannopoulos2017-08-041-1/+1
| | | | | | ext keys Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* prior to negotiating a signature check compatibility with private keyNikos Mavrogiannopoulos2017-08-041-0/+42
| | | | | | | | | | | | | That is, check if the private key can support the public key operation needed for the signature. That in particular includes, excluding the Ed25519 and RSA-PSS from being used with the 'EXT' keys as the current API cannot handle them, and RSA-PSS from being used by PKCS#11 RSA keys which do not provide the CKM_RSA_PKCS_PSS mechanism. Relates #234 Resolves #209 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_x509_privkey_generate*: allow specifying the SPKI parameters for key ↵Nikos Mavrogiannopoulos2017-08-041-4/+4
| | | | | | | | | | generation This in turn removes the need for reading the flag GNUTLS_PRIVKEY_FLAG_REPRODUCIBLE on the key generation process. The flag is now only used during key signing which is also its documented purpose. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* _gnutls_privkey_update_spki_params: use GNUTLS_E_CONSTRAINT_ERROR on ↵Nikos Mavrogiannopoulos2017-08-041-3/+2
| | | | | | | | | | | | | mismatch of hash That is a more specific error code for hash mismatch between public key information and signature. In addition only override the salt size, if it is set to zero without the proper flags. That prevents the update function from setting an invalid (lower) than the expected size. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Added convention for missing SubjectPublicKeyInfo params fieldNikos Mavrogiannopoulos2017-08-031-8/+14
| | | | | | | | That is, when that field is missing, the spki_st structure field pk will be set to GNUTLS_PK_UNKNOWN. In that case other fields are undefined. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_x509_privkey_int: eliminated duplicate pk_algorithm fieldNikos Mavrogiannopoulos2017-08-031-1/+1
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* abstract.h: added functions to read and write SPKI informationNikos Mavrogiannopoulos2017-08-031-0/+52
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* pkcs11: added support for signatures with RSA-PSSNikos Mavrogiannopoulos2017-08-031-48/+34
| | | | | | Relates #209 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_pk_params_st: renamed sign field to spkiNikos Mavrogiannopoulos2017-08-031-1/+1
| | | | | | | | | | The name "sign" was ambiguous with regard to its intented use, as it could refer to digital signature parameters which was not exactly the case. That field contains parameters present in the subject public key info (SPKI), which could be used in a digital signature, but not necessarily. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Clarified the purpose of the spki params related functionsNikos Mavrogiannopoulos2017-08-031-14/+14
| | | | | | | | | | | | | | | | _gnutls_privkey_get_sign_params was renamed to _gnutls_privkey_get_spki_params, _gnutls_privkey_update_sign_params to _gnutls_privkey_update_spki_params, and the dig entry of gnutls_x509_spki_st was renamed to rsa_pss_dig. The reason is that there could be a confusion on the purpose of the 'dig' entry, as it could be assumed to be the signature's hash algorithm in the general case. That could not be because the SPKI parameters do not contain it for any other algorithm than RSA-PSS. As such, make a logical separation from SPKI reading functions with the signature reading functions and try to use the gnutls_sign_entry_st when signature information is required. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Pass the signature algorithm lower in the verification stackNikos Mavrogiannopoulos2017-08-031-32/+45
| | | | | | | This will allow enhancing the back-ends (PKCS#11 and ext) for signing with the new signature algorithms like RSA-PSS and Ed25519. Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* privkey_sign_and_hash_data: in pre-hashed schemes, allow empty hash algorithmNikos Mavrogiannopoulos2017-07-171-3/+8
| | | | | | | In these schemes the hash algorithm is fixed in the signature algorithm and thus the empty (unknown) value will act as a wildcard. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* privkey_sign_and_hash_data: added sanity check on param validityNikos Mavrogiannopoulos2017-07-171-0/+3
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* privkey_sign_and_hash_data: handle prehashed signaturesNikos Mavrogiannopoulos2017-07-171-6/+6
| | | | | | | This allows this function to handle ed25519, i.e., allows it to operate for PKCS#7 signatures. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Added support for EdDSA (Ed25519) curve keysNikos Mavrogiannopoulos2017-07-171-37/+49
| | | | | | | | This adds support for draft-ietf-curdle-pkix-04. Resolves #25 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Removed support for openpgp certificates and keysNikos Mavrogiannopoulos2017-06-161-229/+0
| | | | | | Resolves #178 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* abstract API: introduced new signing functionsNikos Mavrogiannopoulos2017-06-071-8/+122
| | | | | | | | | That is, the gnutls_privkey_sign_data2() and gnutls_privkey_sign_hash2(). The new functions perform signing with input the signature algorithm instead of the hash algorithm; that allows to use algorithms where the hash algorithm is not used, or the public key algorithm may be different than the key's. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_privkey_st: removed unused elementtmp-multi-updatesNikos Mavrogiannopoulos2017-06-071-1/+1
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* Only accept known public key algorithms in the GNUTLS_PRIVKEY_EXT private keysNikos Mavrogiannopoulos2017-05-311-0/+8
| | | | | | | The reason is that this API, assumes very low level primitives which are not available for the newer RSA-PSS private keys. Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* _gnutls_privkey_*_sign_params: added support for GNUTLS_PRIVKEY_EXT keysNikos Mavrogiannopoulos2017-05-311-0/+4
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* Separated use of GNUTLS_PRIVKEY_FLAG_PROVABLE and ↵Nikos Mavrogiannopoulos2017-05-311-1/+1
| | | | | | | | GNUTLS_PRIVKEY_SIGN_FLAG_REPRODUCIBLE For simplicity, rename GNUTLS_PRIVKEY_SIGN_FLAG_REPRODUCIBLE to GNUTLS_PRIVKEY_FLAG_REPRODUCIBLE. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* _gnutls_privkey_find_sign_params: renamed and simplifiedNikos Mavrogiannopoulos2017-05-311-9/+48
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_privkey_sign_hash: removed duplicate codeNikos Mavrogiannopoulos2017-05-311-15/+1
| | | | | | The same code was available in _gnutls_privkey_find_sign_params(). Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_privkey_sign_hash: use the GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS flagNikos Mavrogiannopoulos2017-05-291-1/+21
| | | | | | | | That is, the privkey_sign_hash() function was made static (no users other than the same file), and gnutls_privkey_sign_hash will take into account the GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS, if specified. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* x509: implement RSA-PSS signature schemeDaiki Ueno2017-05-291-19/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enables RSA-PSS signature scheme in the X.509 functions and certtool. When creating RSA-PSS signature, there are 3 different scenarios: a. both a private key and a certificate are RSA-PSS b. the private key is RSA, while the certificate is RSA-PSS c. both the private key and the certificate are RSA For (a) and (b), the RSA-PSS parameters are read from the certificate. Any conflicts in parameters between the private key and the certificate are reported as an error. For (c), the sign functions, such as gnutls_x509_crt_privkey_sign() or gnutls_privkey_sign_data(), shall be instructed to generate an RSA-PSS signature. This can be done with the new flag GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS. Verification is similar to signing, except for the case (c), use the flag GNUTLS_VERIFY_USE_RSA_PSS instead of GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS. From the command line, certtool has a couple of new options: --rsa-pss and --rsa-pss-sign. The --rsa-pss option indicates that the generated private key or certificate is restricted to RSA-PSS, while the --rsa-pss-sign option indicates that the generated certificate is signed with RSA-PSS. For simplicity, there is no means of choosing arbitrary salt length. When it is not given by a private key or a certificate, it is automatically calculated from the underlying hash algorithm and the RSA modulus bits. [minor naming changes by nmav] Signed-off-by: Daiki Ueno <dueno@redhat.com> Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* gnutls_pkcs11_privkey_init: document limitation on created object [ci skip]Nikos Mavrogiannopoulos2017-03-131-1/+10
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
* gnutls_privkey_export_x509: doc updateNikos Mavrogiannopoulos2017-03-081-2/+3
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* In import_tpm_key_cb() fix the wrong password loopNikos Mavrogiannopoulos2016-12-051-0/+9
| | | | | | | | When calling import_tpm_key() once it initializes the key, but a second call fails due to the key being already initialized. Ensure that failure of import_tpm_key() leaves the key on a clear state. Reported by James Bottomley <James.Bottomley@HansenPartnership.com>.
* several spacing fixes to keep syntax-check happyNikos Mavrogiannopoulos2016-09-111-4/+4
|
* keys: custom URLs take precedence over pre-defined URLsNikos Mavrogiannopoulos2016-04-281-10/+10
| | | | | | | This allows applications to define the own 'system:' or 'pkcs11:' URLs. Resolves #89
* doc: updated docs related to private key generationNikos Mavrogiannopoulos2016-04-141-6/+10
|
* doc: document the sign function requirements in gnutls_privkey_import_extNikos Mavrogiannopoulos2015-10-221-0/+5
|
* Use separate PEM headers for provable private keysNikos Mavrogiannopoulos2015-09-131-0/+20
| | | | | Also introduce GNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT to allow exporting provable private keys in the old compatibility format.