Commit Graph

33 Commits

Author SHA1 Message Date
Peter Marschall 16c889cf7d spelling fixes
Fix various spelling errors, mostly in comments but also in texts displayed.

Errors found & interactively fixed using 'codespell', with additional manual
checks after the fixes.
2020-08-30 10:35:14 +02:00
Frank Morgner bdca524aa8 Fixed memory leak
Credits to OSS-Fuzz
2019-08-27 15:59:46 +02:00
Jó Ágila Bitsch a7766b3de3 allow chaining for pkcs15-init --store-private-key EC keys
when importing a private key onto a pkcs15 card, if the card does not support
extended APDUs, we need to use chaining to store keys longer than 255 bytes.

While for RSA keys, this check was included, it was missing for EC keys.
This patch adds the SC_APDU_FLAGS_CHAINING flag to apdu.flags if data length is
greater than 255 and the card caps does not include SC_CARD_CAP_APDU_EXT.

Fixes #1747
2019-07-24 01:25:49 +02:00
Frank Morgner 410cdf0dcc refactored sc_get_challenge
Let sc_get_challenge() do sc_lock() and loop through the card driver's
get_challenge() until enough bytes were collected. The card driver's
get_challenge() now returns the number of bytes collected (less or equal
than requested) or an error code.

- Allow more code re-use.
- PIV driver now uses ASN.1 parser for reading the random bytes
2018-05-23 14:20:28 +02:00
Frank Morgner 439a95f2d2
If card initialization fails, return SC_ERROR_INVALID_CARD (#1251)
fixes https://github.com/OpenSC/OpenSC/issues/946
2018-05-18 23:49:29 +02:00
Peter Marschall 5abe99d228 fix typos
Mass-typo fixing, almost exclusively in comments and text strings.

While at it also fixed a few (very few) grammar errors.
2018-04-15 09:34:45 +02:00
Frank Morgner c3ffdecd0b rename SC_SEC_ENV_KEY_REF_ASYMMETRIC to SC_SEC_ENV_KEY_REF_SYMMETRIC
This reflects the actual use of the identifier by the card drivers.
2018-03-09 14:36:55 +01:00
Frank Morgner d719977d14 Reselect PKI-Applets after card reset
PKI-Applets may not be active if the card has been reset or unpowered.
The SELECT command used to activate the applet, is identical to the one
used during card matching or initialization.
2018-02-07 11:57:48 +01:00
Philip Wendland 6bffeb7a36 IsoApplet: fix dead code 2015-09-18 17:02:45 +02:00
Viktor Tarasov 3e0356b170 register CKM_ECDSA and CKM_ECDSA_SHA1 depending on card capabilities
fix #429
2015-05-08 20:45:56 +02:00
Philip Wendland 37b6f0bbdf IsoApplet: fix EC mechanism ext_flag 2015-05-08 20:19:36 +02:00
Philip Wendland c8d206ece1 IsoApplet: Increase indicated version to 00.06
Backward compatiblity with 00.05 is kept.
2015-03-29 13:34:58 +02:00
Philip Wendland 9078856675 IsoApplet: register ECC mechanisms only when ECC is supported by card
There are few Java Cards that do not support ECDSA at all.
Starting with IsoApplet version 00.06, the applet returns whether the card
supports ECDSA or not. This commit uses this information to decider whether to
register ECDSA mechanisms or not.
2015-03-29 13:34:58 +02:00
Philip Wendland 76facf0d73 IsoApplet: add support for GET CHALLENGE 2015-03-29 13:34:58 +02:00
Philip Wendland e258cec13e IsoApplet: Add nistp224, secp192k1 and secp256k1 curves
secp*k1 curves are only supported applet version >= 0.6.0 because of an issue
with encoding ECC public keys with small parameters.
2015-03-29 13:34:58 +02:00
Philip Wendland ab5ca331b2 IsoApplet: Obtain applet version and card capabilities *after* match_card() 2015-03-29 13:34:58 +02:00
Viktor Tarasov 090aed2fc2 ec: fix length of allocated mem for EC signature
discussion in PR #398
2015-03-29 13:08:01 +02:00
Viktor Tarasov 877fa862d9 isoApplet: prototype of asn1_sig_value_sequence_to_rs() has changed 2015-03-10 09:09:14 +01:00
Philip Wendland 74aeb8c923
IsoApplet: register supported EC curve *per curve* 2015-02-22 23:08:18 +01:00
Philip Wendland 85d16fbc57
IsoApplet: use helper function sc_asn1_sig_value_sequence_to_rs() introduced in #381 2015-02-20 23:02:04 +01:00
Philip Wendland 1aeebdaf1c
IsoApplet: react to changes of _sc_card_add_ec_alg() in fa923831f8 2015-02-20 22:56:23 +01:00
Philip Wendland a9d43af4bf
IsoApplet: use a buffer large enough when generating EC keys larger than 320 bit 2015-02-20 21:55:35 +01:00
Philip Wendland 5628a06353
IsoApplet: Align comments with spaces instead of tabs
Better view with tabstop=8.
2015-02-20 21:55:35 +01:00
Philip Wendland 43fa99c0f2
IsoApplet: Move the key gen debug info to the right places 2015-02-20 21:55:35 +01:00
Philip Wendland 0473decae4
IsoApplet: clear memory after prkey import.
Private key import via plain APDUs is dangerous and not recommended anyway, but clearing the apdu buffer does not hurt anyone.
2015-02-20 21:55:34 +01:00
Philip Wendland 73b391731b
IsoApplet: Don't set ECC field length of 512
512 is wrong for EC FP (correct would be 521 bit), and neither of those
two are currently supported by OpenSC.
2015-02-20 21:55:34 +01:00
Philip Wendland e791948e42
IsoApplet: Simplify the private key import
Use the new features of sc_asn1_put_tag introduced in OpenSC/OpenSC#314.
Additionally, a RSA private key is sent from one large buffer using either extended APDUs or chaining (in compliance to IsoApplet API version 00.05).
2015-02-20 21:55:34 +01:00
Philip Wendland 6cdf6c08a5
IsoApplet: use AID directly when selecting applet
Now that apdu.data is const (see ef94c6b875), this can be done without discarding the const qualifier of the aid parameter.
2015-02-20 21:55:34 +01:00
Philip Wendland 09acfd7ec0
IsoApplet: ECDSA signatures - only strip excess zeroes
It is required to strip excessive zeroes returned by some Java Cards when removeing the ASN1 structural information for PKCS#11 so that the x/y can be calculated by dividing the signature length by 2. However, the leading zero may only be stripped if it is excessive (outside the field length). Otherwise generated signatures are wrong in rare cases (1 out of 256).
2015-02-20 21:55:33 +01:00
Philip Wendland c463f1a7a1
IsoApplet: Do not set RSA hashes
See: 189e998486
The IsoApplet requires the host to do the hashes with RSA. OpenSC will
add all hashes that are available in software and will not expect the
card to do the hashing.
2015-02-20 21:55:33 +01:00
Philip Wendland e3cc851b72
IsoApplet: EC key-gen rework and refactorings
Rework the EC key generation mechanism to send the curve parameters to
the card. In earlier versions, the applet had a copy of the curve
parameters and there was a different algorithm reference for every
curve. This is unfeasible when trying to support a larger number of
curves because of size limitations of the applet.
This commit additionally includes some refactorings that should not
change the functionality.
2015-02-20 21:55:33 +01:00
Philip Wendland 6f9e894ebe
IsoApplet: set lock when doing command chaining 2015-02-20 21:55:33 +01:00
Philip Wendland 48bd6b0964
Add support for the IsoApplet (Java Card applet)
The IsoApplet can be found here:
https://github.com/philipWendland/IsoApplet
Add read/write support for this applet, including RSA and
ECC support.
2015-02-20 21:55:26 +01:00