Commit Graph

2162 Commits

Author SHA1 Message Date
Viktor Tarasov cfd5aaba7d SM: initial implementation of secure messaging framework 2012-06-08 20:17:35 +02:00
Viktor Tarasov 2078654d2b OpenPGP: to be compiled on windows 2012-06-08 20:17:35 +02:00
Peter Marschall 9e04ae46bb OpenPGP: implement pgp_find_blob()
Replace the "one-trick-pony" pgp_do_iswritable() with a more generic
function returning the blob matching the passed tag.

This way we can get rid of the one-line function pgp_blob_iswritable() too.
comparisons like these can be done in the caller.
2012-06-08 20:17:35 +02:00
Peter Marschall f5dc252aa9 OpenPGP: set pin references to 0x01 - 0x03
Set pin references to 0x01 - 0x03 instead of 0x81 - 0x83.
The PINs are referenced as PIN1- PIN3 (resp. PW1 - PW3) in the OpenPGP
card specification.
Technically the APDUs to verify/change the PINs contain the values OR-ed
with 0x80, but this is just a technical detail of the implementation
which the emulated file system can hide in pgp_pin_cmd().

Pros & Cons:
+ consistent PIN naming
+ no trouble entering the correct PIN names in opensc-explorer et.al.
  ("verify CHV1" is way better than "verify CHV129")
- manually entering the correct APDU for VERIFY is a bit more complex.
  (who does this anyway, when there are better functions)

While at it, change if .. elsif ... cascade to switch statement.
2012-06-08 20:17:35 +02:00
hongquan 89c1dd37e4 OpenPGP PKCS#15: Add declaration of certificate object. Allow to read
certificate via PKCS#11 (not writing yet).
2012-06-08 20:17:35 +02:00
hongquan f515ed5be3 OpenPGP: Change the criteria to use ext APDU for put data.
Saner whitespace in logs
Correct spelling
2012-06-08 20:17:35 +02:00
hongquan df39590aa4 OpenPGP: Correct adding read access to ACL. 2012-06-08 20:17:35 +02:00
hongquan e269907e1d OpenPGP: support key generation in driver. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 9dd5a64d43 OpenPGP: Support another variant of PUT DATA to write to Extended Header list. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân fefe8bf2e6 OpenPGP: Check data size in pgp_put_data. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân f188a5dda3 OpenPGP: Implement pgp_update_binary() to update file content. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 935a7505d7 OpenPGP: Add Access Control List for emulated files. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân c891544990 OpenPGP: Use command chaining to send large data if extended APDU is not supported. 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 5673d13c15 OpenPGP: implement pgp_delete_file() 2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân 72088b6eeb OpenPGP: implement pgp_strip_path()
Strip away the non-existant DF 5015 from paths passed the driver.
2012-06-08 20:17:35 +02:00
Nguyễn Hồng Quân f7785ad1ec OpenPGP: correct use of pin_reference 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân 3ac834e277 OpenPGP: implement pgp_put_data() 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân a1ed22b6fd OpenPGP: implement pgp_do_iswritable() 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân d8d6902699 OpenPGP: implement pgp_seek_blob() 2012-06-08 20:17:34 +02:00
Nguyễn Hồng Quân 7e24102f2b OpenPGP: Make DO 7F21 treated as simple DO
Make DO 7F21 treated as simple DO, to make certificate contained in it visible.
2012-06-08 20:17:34 +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 1d2661c7ce pkcs15-pin: 'PIN' as particular choice of 'AuthenticationType'
Encode/decode 'PIN' pkcs15 object as particular choice of 'AuthenticationType' data.
Rudimental encoding/decoding of 'authKey' object.
2012-05-31 10:37:38 +02:00
Viktor Tarasov 666e08ffde pkcs15-pubkey: add 'subjectName' to 'CommonPubKeyAttributes'
Decode/encode 'subjectName' attribute from the 'CommonPubkeyAttributes'
Use macros for the size of the asn1_entry tables.
Use short call form for debug messages.
Procedure to convert the pkcs15 public key to EVP_PKEY type key.
Coding style issues.
2012-05-31 10:26:38 +02:00
Viktor Tarasov 4be79f3d30 pkcs15-prkey: 'algReference' from 'CommonKeyAttributes'
Decoding/encoding of the 'algReference' attribute from the 'CommonKeyAttributes'.
Use macros for the size of the asn1_entry tables.
Use short call form for debug messages.
Procedure to deduce from certificate the attributes of private key PKCS#15 object.
Procedure to convert the pkcs15 private key to EVP_PKEY type key.
Coding style issues.
2012-05-31 09:32:21 +02:00
Viktor Tarasov f7b5a6b6af PIV: pickup card driver from the SM branch
... where it was tested by Douglas.
2012-05-30 19:40:05 +02:00
Peter Marschall f04a1c5fef OpenPGP: stricter validity checks in PKCS15 init
Only add private/public keys that habe been defined:
check finger prints & algorithm identifier
2012-05-30 09:39:12 +02:00
Peter Marschall 742186f32f OpenPGP: remove unnecessary call to sc_get_data 2012-05-30 09:39:12 +02:00
Peter Marschall d38d615025 OpenPGP: parse more (extended) capabilities on init
* parse more extened capabilities & features into a private enum
* for v2.0 cards, always parse the "historical bytes" DO
  reason: ATR may be static and thus cannot reflect the state
2012-05-30 09:39:12 +02:00
Peter Marschall 67136b1781 OpenPGP: revert 7b4532736e
PKCS#15 spec v1.1 says:
TokenInfo.version: This field contains the number of the particular version
of this specification the application is based upon. For this version of this
document, the value of version shall be 0 (v1).

Thanks to Martin Paljak for the finding.
2012-05-30 09:39:12 +02:00
Peter Marschall 458517783c OpenPGP: fix access conditions for DOs
Follow the specs.
2012-05-30 09:39:11 +02:00
Peter Marschall 26aac71c9f OpenPGP: correct PIN type to UTF-8
OpenPGP card spec v1.1 and v2.0 make it absolutely clear:
"... The format of the CHVs is UTF-8 (case sensitive) ...".
2012-05-30 09:39:11 +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 be81263d8e log: config option to reopen debug file at every debug log ...
To be used in windows:
"In Windows, file handles can not be shared between DLL-s, each DLL has a separate file handle table.
For that reason reopen debug file before every debug message."

sc_context_repair() procedure from Hunter William
"Workaround some threading and data lifetime issues when card handle changes and need to re-associate card"
http://www.opensc-project.org/pipermail/opensc-devel/2011-December/017445.html
2012-05-29 19:44:54 +02:00
Viktor Tarasov 954d0b9375 pkcs15: DIR EF can have EF_LINEAR structure
and so, in this case the checking file size is not appropriate method to validate it.
;use short call form for the log messages;
2012-05-29 19:19:06 +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 9c882ff5c2 AuthentIC: add SM related procedures
Added to facilitate future SM merge,
for a while disabled by conditional macro.
2012-05-29 09:52:33 +02:00
Viktor Tarasov 230b782309 pkcs15: add 'sc_pkcs15_derive' missing for ECDH support
also, key path, that has to be selected before crypto operation,
can contain an aid.
2012-05-28 23:15:37 +02:00
Viktor Tarasov 9c5dbea883 pkcs11: ECHD and secret keys support from Douglas
This support were initially proposed by Douglas (https://github.com/dengert/OpenSC/commits/ecdh) and
then merged into SM branch (https://github.com/viktorTarasov/OpenSC-SM/tree/secure-messaging).
2012-05-28 20:06:23 +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
Viktor Tarasov 4b745f51af openpgp: 'ushort' type not defined for WIN32
Change-Id: Ifb28730af2d39440721be9d1e38ea1c6106167a2
2012-05-16 23:14:42 +02:00
Peter Marschall 07d51bea36 OpenPGP: get PKCS#15 token info from preparsed card data
Determine data for sc_pkcs15_card's tokeninfo structure
from sc_pkcs15_card's card structure.
This makes sure the two stay consistent as much as possible.
2012-05-16 17:01:09 +02:00
Peter Marschall 7b4532736e OpenPGP: set version for PKCS#15 2012-05-16 17:01:09 +02:00
Peter Marschall bc0949140d OpenPGP: format paths more nicely 2012-05-16 17:01:09 +02:00
Peter Marschall 0283a6f24e OpenPGP: only add keys with legal algorithm identifier 2012-05-16 17:01:09 +02:00
Peter Marschall 671ac54b71 OpenPGP: more data driven logic
Tie together in a struct what belongs together instead of relying
on the ordering of multiple unrelated arrays.
2012-05-16 17:01:09 +02:00
Peter Marschall 076a4ed2dc OpenPGP: slight cleanup
Use typedef'd types instead of their underlying structs,
use helper functions instead of reinventing the wheel,
and fix typos.
2012-05-16 17:01:09 +02:00
Peter Marschall 4c09e290e1 OpenPGP: make logic more data driven
Instead of doing lots of special-cases in code, create data structures
decide once which variant of the data to use, and then use it.
2012-05-16 17:01:09 +02:00