Commit Graph

101 Commits

Author SHA1 Message Date
Frank Morgner 755ac78a02 added fuzzing with libFuzzer and OSS-Fuzz
makes cmocka detection not required for building tests
2019-07-26 15:23:02 +02:00
Frank Morgner 27526de021 implemented sc_format_apdu_ex 2019-03-05 13:54:13 +01:00
Frank Morgner 141ec6ab23 added shortcut to update binary via sfid 2019-01-15 07:31:20 +01:00
Frank Morgner b01ca2dcc9
added support for colors (#1534)
because everyone loves colors
2018-11-25 22:08:36 +01:00
Hannu Honkanen aa814fd8e8 Implemented C_Wrap into PKCS#11 interface. Added support for wrapping and unwrapping with secret keys into framework-pkcs15.c and all the way to the card driver level. 2018-10-31 10:24:19 +02:00
Hannu Honkanen 5f51d5d315 Added implementation of C_UnwrapKey all the way from PKCS#11 interface to the card driver level.
Not yet complete, but can be run with CKA_TOKEN=FALSE set in the target object. Currently unwrapping emulated
with a decrypt operation in card-myeid.c. To be improved.
2018-10-31 10:22:16 +02:00
Frank Morgner ea6f7cfe1d
Added memory locking for secrets (#1491)
When caching a PIN in memory or using an OpenSSL private key this data should not be swapped to disk.
2018-10-10 14:52:01 +02:00
Frank Morgner db4ed9f4a2 export _sc_match_atr_block 2018-09-14 08:23:08 +02:00
Frank Morgner 5d7ed37246 Removed configuration option `paranoid-memory`
Don't pretend that we're capable of performing memory locking. The
implementation of that, `sc_mem_alloc_secure()` (also removed), was
almost unused anyway.
2018-05-18 12:46:51 +02:00
Frank Morgner f862060614 EAC: Clearify naming of functions and data
Use names that are specific to EAC, not the German ID card (nPA),
because Protocol and Commands are defined by BSI TR-03110 and ICAO.
Functions that are nPA specific are moved to card-npa.h.
2018-02-20 22:16:51 +01:00
Frank Morgner b4072af26e export sc_card_find_ec_alg 2017-11-17 10:04:46 +01:00
Frank Morgner bf828014e5 macOS: Added support for notifications
- adds framework for user defined message strings
- automatically determine the system's language
2017-08-02 19:02:05 +02:00
Timo Teräs 3d8cf274ff pkcs15init: add support for secret key upload and generation 2017-06-13 10:40:36 +02:00
Jakuje 0e70c59aef If the underlying PKCS#15 structure does not provide label for a cert… (#1045) 2017-05-30 00:05:30 +02:00
Frank Morgner 7c3bb44cdf minidriver: added support for session pin 2017-05-22 16:25:08 +02:00
Frank Morgner 40acedcc21 Added support for PIN commands via escape commands
As defined in BSI TR-03119 to issue SCardTransmit (with Uses
Pseudo-APDU) instead of SCardControl (with FEATURE_VERIFY_PIN_DIRECT).
It allows using a very basic PC/SC reader driver without special support
for PIN verification or modification (such as the default CCID driver on
Windows).

Also gets IFD vendor information via escape commands.

PC/SC's Get Uid command is now only triggered if enable_escape = true;
was set by the user to allow disabling wrapped commands on broken
readers (see https://github.com/OpenSC/OpenSC/issues/810)
2017-03-20 21:28:48 +01:00
Frank Morgner a4f64d9439 Added (external) card driver for German ID card
(Imported libcardnpa from https://github.com/frankmorgner/vsmartcard)

- Added generic SM implementation of ISO/IEC 7816-8
- Added implementation of extended access control as defined by
  - BSI TR-03110
  - ICAO Doc 9303
  - ISO/IEC 7501
- Added tool for German ID card (and other EAC tokens)
- renamed folder libsm to sm
2017-03-20 21:28:48 +01:00
Frank Morgner 2f10de4f5c use sc_pkcs15_get_pin_info in C_GetTokenInfo
introduced paramter to signal back the login state
- used for the pin command SC_PIN_CMD_GET_INFO
- implemented in accordance to ISO 7816-4; all other implementations
  are currently set to an unknown login state

implemented and exporeted sc_pkcs15_get_pin_info

use sc_pkcs15_get_pin_info in C_GetTokenInfo

C_GetSessionInfo: Check whether a logout was done

Closes https://github.com/OpenSC/OpenSC/pull/624

rebased by @viktorTarasov
2016-07-17 14:07:43 +02:00
Frank Morgner 836842a6bb remove unused `scconf_entry` 2016-06-14 14:57:58 +02:00
Viktor Tarasov 66515989d8 win32: method to get config option from registers 2016-04-17 12:43:18 +02:00
Viktor Tarasov 47eb21175c p15: auxiliary data in prkey info data type 2016-04-08 10:48:58 +02:00
Frank Morgner ef40021417 use sc_debug_hex for hexdump 2016-03-07 10:39:42 +01:00
LE TOUX Vincent 6a243449a0 First support for GIDS card
- minidriver included by default in Windows
- GIDS Applet is available here https://github.com/vletoux/GidsApplet
- some informative technical information is available here
  http://www.mysmartlogon.com/knowledge-base/generic-identity-device-specification-gids-kb/

closes https://github.com/OpenSC/OpenSC/pull/651
2016-02-19 00:12:16 +01:00
Frank Morgner 83ef753799 Implemented atomic PKCS#11 transactions 2015-12-06 10:42:45 +01:00
Frank Morgner 9f318b829f remove slots of removed readers 2015-04-21 02:00:06 +02:00
Frank Morgner d7ab0df51d export sc_pkcs15_bind_internal
allows bootstrapping an external pkcs15 driver
2015-04-12 11:28:25 +02:00
Frank Morgner db860c0d2a export sc_sm_stop 2015-04-04 22:09:22 +02:00
Viktor Tarasov 80c496671f helper functions to change format of ECDSA signature 2015-02-20 14:20:19 +01:00
Andreas Schwier be200ab3c8 Merge pull request #282 from CardContact/fix-deleted-related-public-key
framework-pkcs15: Duplicate public key related to private key rather than referencing the framework object

Referencing the related public key is required to return PKCS#11 attributes for a private key only available
in the public key object (i.e. CKA_MODULUS). This patch adds a copy of the public key to the private key object rather than
referencing the public key object in the framework. This prevents SEGV when the public key framework object
is deleted with C_DestroyObject, but the reference from the public key remains intact.

The bug leads to all kind of stability problems when keys are created and deleted in the same session.

The patch is in particular important if OpenSC is used with EJBCA or any other application using the
SUN PKCS#11 provider: When generating key pairs, then the public key object is eventually garbage collected
which removes the related object in the PKCS#11 module. Because there is no fixed time for this operation,
corruption occurs at random.

In a next step, the remaining related_xxx fields in sc_pkcs11_object should be revised and possibly removed.

framework: Added more error checking
2014-09-07 23:47:24 +02:00
Viktor Tarasov 883d42b1f8 libopensc: export 'iasecc_sdo_encode_update_field'
used by 'local SMM' module
2014-05-02 13:43:10 +02:00
Viktor Tarasov 13d1b8e9f2 pkcs15init: file 'content' and 'prop-attrs' in the card profile
Now it's possible to describe in the card profile
the 'prop-attr' and 'encoded-content' data of the file to create
2013-12-29 20:05:35 +01:00
Viktor Tarasov 98325ab7f2 pkcs15: export 'sc_pkcs15_serialize_guid' ...
change name of exported 'sc_pkcs15_get_guid' to 'sc_pkcs15_get_object_guid' ;
add more 'CALLED' and 'RETURN' macros ;
2013-12-29 19:46:56 +01:00
Viktor Tarasov 7a03f1883b libopensc: create and export 'sc_match_atr_block' 2013-12-29 19:46:56 +01:00
Andreas Schwier d4be8ec747 sc_pkcs15_encode_pubkey_as_spki replaces sc_pkcs15_encode_pubkey_with_param.
The name implies what the format of the returned value, a SPKI.

The support for spki as a pkcs15 format of a pubkey, is extended to
work for any algorithm not just EC pubkeys. PKCS#15 appears to allow this.

sc_pkcs15_decode_pubkey_with_param will look for a SPKI
and attempt to use it for any algorithm, including RSA.
(RSA is the null case, as there are no algorithm parameters.)

sc_pkcs15_encode_pubkey_as_spki is exported from libopensc.

pkcs15-piv.c will use sc_pkcs15_encode_pubkey_as_spki to load public keys
as SPKI for RSA and EC.

The pubkey->data is never a SPKI, it is the DER encoding of the
pubkey without the parameters.  If an spki is needed, use the
sc_pkcs15_encode_pubkey_as_spki to get the DER encoding of the spki.

As in the previous set of patches, pkcs15-tool.c will output both
sc_pkcs15_decode_pubkey_with_param and its internal.
This was left for testing, and the pubkey_pem_encode should be deleted
2013-12-06 09:23:57 +01:00
Frank Morgner 07818329ab made sc_apdu_t.data 'const' (which it used to be)
fixes a lot of warnings which pass a const buffer to the APDU's data

Note that a non-const data member is only required for sc_allocate_apdu
sc_free_apdu. They are currently used with an explicit typecast.
However, sc_allocate_apdu and sc_free_apdu both are not used once in the
entire project. One might also simply throw both functions away.
-- Both are thrown away. (VT)
2013-08-03 18:26:04 +02:00
Frank Morgner 9a05414f9a let OpenSC compile without OpenSSL and without SM 2013-07-10 16:22:33 +02:00
Viktor Tarasov 6a4de6d551 libopensc: APDU 'allocate & copy'and 'free' procedures 2013-01-06 17:30:41 +01:00
Viktor Tarasov 8d7c773561 SM: move SM APDU procedures to dedicated source file
new SM errors: 'session-already-opened' and 'invalid-checksum'
declare typed data for DH SM session
2013-01-06 16:40:17 +01:00
Andreas Schwier ffb20e5916 sc-hsm: Added sc-hsm-tool with DKEK support and key wrap / unwrap 2012-11-11 12:53:03 +01:00
Viktor Tarasov 58b4304957 libopensc: 'init', 'format', 'compare', 'is-valid' OID procedures
In a reason of number of bugs(*) that concern the OID management,
the general usage OID procedures 'init', 'format', 'compare', 'is-valid' are introduced.
These procedures should be used by all actors: libopensc, pkcs15, pkcs11, tools, ....

(*)
This bug reported by Andreas Schwier :
8e75d971cb (commitcomment-1792477)

In pkcs15-algo sc_asn1_get_algorithm_info() can return the OID without ending '-1's:
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L452
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L459
2012-09-06 10:47:29 +02:00
Viktor Tarasov 41861e42b0 no 'pace' in common part
'PACE' is extremely card specific protocol and has not to be ostensibly
present in the common part of OpenSC:
 * currently in OpenSC there is no card driver that supports or uses this protocol;
 * amazing content of the common 'sc_perform_pace' -- beside the verbose logs
   the only substantial action is to call the card/reader specific handler.
   According to the current sources and the pull request 83
   this 'common' procedure is called by the card driver or
   card specific tool/operation.
 * currently the 'PACE' can be thouroghly tested only by one person (Frank Morgner),
   and only using the OpenSSL patched with the PACE specific patch.
   So, at least a dedicated configuration option could be introduced when comiting PACE to the common part.
 * common 'sc_perfom_pace' has the same role as the 'initialize-SM' handler of the existing SM framework
   and can be implemented as card specific SM, as the others cards do.
   This confirmed by Frank Morgner, the author of PACE commits and nPA card driver, himself.
   (https://github.com/OpenSC/OpenSC/pull/83)
2012-08-30 18:51:42 +02:00
Viktor Tarasov 0518ced8e0 asn1: export 'asn1-write-element' function
... used by OpenPGP driver
2012-07-29 13:09:00 +02:00
Viktor Tarasov ea5a19e27e iasecc: SM add related procedures 2012-06-08 20:17:35 +02:00
Viktor Tarasov 2cff47d9b3 pkcs11-tool: support for secret-key objects
support of 'secret-key' objects
key conversion procedures are now in libopensc library
change name for OPENSC NON-REPUDIATION CKA attribute
2012-06-02 18:25:23 +02:00
Viktor Tarasov 6c2fa7b462 pkcs15-skey: support for 'SecretKey' object type
For a while only implemented decoding of 'genericSecretKey', 'desKey', 'des2Key' and 'des3Key' keys.
2012-05-31 11:36:04 +02:00
Viktor Tarasov 6d4d1b4aca win32: do not export 'sc_pkcs15_remove_df' procedure
in source it replaced by static 'sc_pkcs15_remove_dfs'
2012-05-30 09:25:57 +02:00
Viktor Tarasov 6337149ef7 pkcs15: decode 'seInfo', 'profileIndication', 'lastUpdate'
Encode,decode  'lastUpdate', 'seInfo', 'profileIndication' of TokenInfo (CIAInfo).
Trailing whitespaces.
2012-05-30 09:03:27 +02:00
Viktor Tarasov 9d5404bac6 libopensc: some usefull macros, crc32 calculation procedure
Introduce some usefull define macros, error code 'inconsistent configuration'.
Introduce procedure to calculate CRC32 digest,
to be used in minidriver to calculate the 'freshness' values.
2012-05-29 11:29:44 +02:00
Viktor Tarasov bf752f3c61 pkcs15: new procedure to find an Auth PKCS#15 object (PIN) by flags 2012-05-25 09:19:19 +02:00
Viktor Tarasov 80266ff466 pkcs15: new procedure to get application by it's symbolic name
At the moment symbolic names for the on-card applications are 'generic', 'protected'.
This distinction used by pkcs11 and minidriver module to select the
'master' application in the cases when only reduced number of slots (one)
can be exposed by module (minidriver) or particular configuration (pkcs11).
2012-05-23 08:50:18 +02:00