Hello, I'm somewhat confused by how OpenSC interprets the different algorithm flags in PKCS#11 [1] and in the generic libopensc PKCS#15 code[2]. Could somebody explain your view or what I get wrong.
- SC_ALGORITHM_RSA_RAW (CKM_RSA_X509) - card is capable of raw RSA, meaning it is willing to take in any data up to the modulus size and encrypt/decrypt it, without additional processing (caller needs to take care of details) - SC_ALGORITHM_PAD_PKCS1 (CKM_RSA_PKCS) - card will take the input, pad it with PKCS#1 and give the encrypted/signed result or decrypt, remove padding and return the data. - SC_ALGORITHM_RSA_HASH_NONE - Signals "the input is not a hash" ? - SC_ALGORITHM_RSA_HASH_MD5_SHA1 - (SSL) - This should probably not exist at all, SC_ALGORITHM_RSA_HASH_NONE should cover this. - SC_ALGORITHM_PAD_NONE - ? Same as RSA RAW? Who will deal with necessary padding? - SC_ALGORITHM_HASH_SHA1|SC_ALGORITHM_PAD_PKCS1 (CKM_SHA1_RSA_PKCS) - input is a SHA1 hash and card returns a PKCS#1 padded signature - what about DigestInfo header? SC_CARD_CAP_ONLY_RAW_HASH and SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED, card flags for D-trust, should control exactly this, but this is not a generic mechanism. Shouldn't this be part of the algorithm specification, it is not a card capability IMHO? If a card claims support for only _PAD_PKCS1 and _HASH_SHA1 only (meaning it would like to sign SHA1 hashes and pad the result with PCKS#15 and remove the PKCS#1 padding itself when decrypting), sc_pkcs15_compute_signature will strip the DiggestInfo header if the card does not claim SC_ALGORITHM_RSA_RAW and send the raw hash to the card (similar to SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED? I don't have CardOS, so I don't know the cardos tricks.) Is it supposed to be so? I'm confused. I would like it to be very explicit, without "surprises" or too much automagic adjustments done by OpenSC (eventually the caller should know almost exactly what is the input and the expected output what the card supports, without much automagic transcoding in OpenSC), but I'm not sure if I understand something basically incorrectly or the code in pkcs15-sec.c and padding.c (sc_get_encoding_flags) is smarter than I can manage. [1] http://www.opensc-project.org/opensc/browser/trunk/src/pkcs11/framework-pkcs15.c#L2511 [2] http://www.opensc-project.org/opensc/browser/trunk/src/libopensc/pkcs15-sec.c#L294 -- @martinpaljak.net +3725156495 I'm moving! martin.paljak.pri.ee -> martinpaljak.net _______________________________________________ opensc-devel mailing list [email protected] http://www.opensc-project.org/mailman/listinfo/opensc-devel
