Commit Graph

21 Commits

Author SHA1 Message Date
Jakub Jelen b351bf5ea4 openpgp: Initial support for (X)EdDSA keys 2021-03-01 15:42:29 +01:00
alex-nitrokey 606fae5a8e
Use ecpointQ for better code readability 2019-10-09 15:02:36 +02:00
alex-nitrokey ca5b3977d8
Fix ecc oid handling while storing existing keys 2019-10-08 17:11:00 +02:00
Alexander Paetzelt 09a594d0f0 OpenPGP Card v3 ECC support (#1506)
* pgp: initialize ecc keys for OPC3

* Add supported ECC algorithms by card version

* Add tasks identified so far

* pgp: Recognize ECC set on card

* pgp: get_pubkey_pem read ECC pubkey from card

* pgp: minor code changes for ECC compatibility

* pgp: expand sc_cardctl_openpgp_keygen_info to hold ec info

* Fix segfault problem in pkcs15-pubkey.c

* pgp: enable key generation with pkcs15-init and ECC

* pgp: adapt calculate_and_store_fingerprint to accept ECC

* pgp: adapt rest of pgp_gen_key and subfunctions to accept ECC

* pgp: add kdf parameters for ECDH fingerprint calculation

* pgp: enable key import with pkcs15-init and ECC

* pkcs15-pubkey: fix_ec_parameters onlz accpets explicit data or named_curve

* Fix some mistakes during merge

* More clean up for PR

* Fix some ugly alignments

* Improve code readability

* Prevent unitialized variable by using FUNC_RETURN

* OpenPGP: add length check

* pgp: save exponent length in bits for sc_cardctl_openpgp_keystore_info_t

* pgp: length checks and reallocations

* pgp: oid init added

* OpenPGP: slightly re-factor pgp_update_new_algo_attr()

* replace loop copy with memcpy()
* use ushort2bebytes() to set RSA modulus & exponent
* use symbolic name SC_OPENPGP_KEYFORMAT_RSA_STD for the key import format

* OpenPGP: slighly re-factor pgp_parse_and_set_pubkey_output()

* check for RSA modulus & exponent lengths not being a multiple of 8
* make sure RSA modulus & exponent lengths are always set
* remove a left-over RSA setting from the EC code

* pgp: adding BYTES4BITS

* pgp: initialization of values in pgp_build_extended_header_list based on key type

* pgp: add BYTES4BITS and remove unnecessary tests

* Fix broken pgp_update_new_algo_attr

* pgp: fix the ecpoint_len variable
2019-01-30 22:00:36 +01:00
Frank Morgner 24b50a4277 replace sc_debug with sc_log 2018-12-06 09:26:42 +01:00
Peter Marschall 248ece23c6 OpenPGP: bail out on non-RSA key generation/import
Also add the necessary algorithm info where necessary.
2018-10-10 14:52:29 +02:00
Peter Marschall c2f02f72bd OpenPGP: adapt data structures to support RSA alternatives
* update callers to use the adapted structures.
2018-10-10 14:52:29 +02:00
Peter Marschall 772d20969a OpenPGP: first steps to support key types beyond RSA
- rename 'keytype' in some OpenPGP-specific types to 'key_id'
  because they key ID was what the field was used for
- introduce field 'algorithm' in the structures above
  to indicate the key's algorithm: RSA, ...
- define constant SC_OPENPGP_KEYALGO_RSA and use it
- rename constants SC_OPENPGP_KEYFORMAT_* to SC_OPENPGP_KEYFORMAT_RSA_*
  because they are RSA specific
2018-10-10 14:52:29 +02:00
Frank Morgner 260716f968 fixed memory leak 2017-11-09 12:42:29 +01:00
Maciej S. Szmigiero 62cbda6cd9 Fix log messages format and parameter issues flagged by GCC
Since "Add GCC format checking attributes to log functions" commit GCC
warns us about problems with format strings and their arguments provided
to OpenSC message logging functions.

This commit fixes all cases where GCC warned about incorrect format on
64-bit Linux, 32-bit and 64-bit mingw builds (with SM and OpenSSL enabled).
Well, almost all since on mingw GCC does not recognize "ll" size specifier
(present at least since Visual Studio 2005, also in mingw own CRT) so these
(few) warnings about it remain.

In most cases format size specifier for size_t type was missing (usually
size was left at default int level, with is different on 64-bit x86).
Some formats had too few / too many arguments.
In some cases pointers were printed as integers.
Some long variables were missing "l" prefix (especially with regard to %x
format).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 11:05:16 +02:00
Maciej S. Szmigiero 80f5c8b835 Code files don't need execute permission
Some .c files had execute permission bit set needlessly.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Nguyễn Hồng Quân 91fc129f19 PKCS15-OpenPGP: Change error log
Only one DO is supported now.
2016-07-17 13:22:55 +02:00
Nguyễn Hồng Quân 70890a8f61 Merge branch 'master' into gnuk
Conflicts:
	src/libopensc/card-openpgp.c
	src/tools/openpgp-tool.c
2015-08-31 21:55:14 +08:00
Frank Morgner 87b2403673 fixed out of bounds access/write 2015-01-28 07:00:02 +01:00
Nguyễn Hồng Quân bbca9c4827 pkcs15-openpgp: Change to sc_put_data instead of sc_update_binary when writing certificate. 2014-07-14 02:02:07 +08:00
Nguyễn Hồng Quân 9a2a6e6dc0 PKCS15-OpenPGP: Allow to store data to pkcs15 data object.
Only one DO is supported now.
2014-07-14 02:02:07 +08:00
Nguyễn Hồng Quân e34866f188 OpenPGP: Accept authentication key for S/MIME decrypting.
The card contains only 1 certificate, which can be used for encrypting.
But this certificate is bound with authentication key, so when decrypting,
the authentication key will be presented to check.
This commit allows to bypass the check in driver. However, it is not enough.
The users have to import the same key to "Encryption key" to help the card find
right key to work.

OpenPGP: Add log and comments.

OpenPGP: Pretend to select dummy files.
Some files are needed by pkcs15init, but not exist in OpenPGP card.
We pretend to know these dummy files to make pkcs15init successful.

Compilation error on windows:
when declaring array use explicit size, add pkcs15-openpgp.obj in Makefile.mak
2012-07-29 14:04:08 +02:00
Nguyễn Hồng Quân 241bfded4d OpenPGP-pkcs15init: Support generating key via pkcs15-init tool.
OpenPGP-pkcs15int: Add more debug log.

OpenPGP-pkcs15init: Add more checks in key generation.
Check for key ID. Set default key.
Check for result of key generation from driver.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân b67063dcd8 pkcs15init-openpgp: Support for private key import in pkcs15init.
Example command:
pkcs15-init --delete-objects privkey,pubkey --id 3 --store-private-key quan-key.pem  --auth-id 3 --verify-pin --extractable --id 3

pkcs15init-OpenPGP: Some parts in openpgp.profile are not used.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân 70b7b4aa54 pkcs15init-OpenPGP: Add store_data functions.
We need this function to use OpenPGP's specific action flow instead pkcs15init's default.
This will help to avoid redundant steps which may make the overall process fail.
2012-07-29 13:09:08 +02:00
Nguyễn Hồng Quân ed0e2be305 Add pkcs15init-binding for OpenPGP 2012-07-29 12:09:56 +02:00