IsoApplet: Align comments with spaces instead of tabs
Better view with tabstop=8.
This commit is contained in:
parent
43fa99c0f2
commit
5628a06353
|
@ -70,16 +70,16 @@ static struct sc_card_driver isoApplet_drv =
|
||||||
* SELECT an applet on the smartcard. (Not in the emulated filesystem.)
|
* SELECT an applet on the smartcard. (Not in the emulated filesystem.)
|
||||||
* The response will be written to resp.
|
* The response will be written to resp.
|
||||||
*
|
*
|
||||||
* @param[in] card
|
* @param[in] card
|
||||||
* @param[in] aid The applet ID.
|
* @param[in] aid The applet ID.
|
||||||
* @param[in] aid_len The legth of aid.
|
* @param[in] aid_len The legth of aid.
|
||||||
* @param[out] resp The response of the applet upon selection.
|
* @param[out] resp The response of the applet upon selection.
|
||||||
* @param[in,out] resp_len In: The buffer size of resp. Out: The length of the response.
|
* @param[in,out] resp_len In: The buffer size of resp. Out: The length of the response.
|
||||||
*
|
*
|
||||||
* @return SC_SUCCESS: The applet is present and could be selected.
|
* @return SC_SUCCESS: The applet is present and could be selected.
|
||||||
* any other: Transmit failure or the card returned an error.
|
* any other: Transmit failure or the card returned an error.
|
||||||
* The card will return an error when the applet is
|
* The card will return an error when the applet is
|
||||||
* not present.
|
* not present.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_select_applet(sc_card_t *card, const u8 *aid, const size_t aid_len, u8 *resp, size_t *resp_len)
|
isoApplet_select_applet(sc_card_t *card, const u8 *aid, const size_t aid_len, u8 *resp, size_t *resp_len)
|
||||||
|
@ -232,8 +232,8 @@ isoApplet_init(sc_card_t *card)
|
||||||
*
|
*
|
||||||
* @param entry The OpenSC ACL entry.
|
* @param entry The OpenSC ACL entry.
|
||||||
*
|
*
|
||||||
* @return The security condition byte. No restriction (0x00)
|
* @return The security condition byte. No restriction (0x00)
|
||||||
* if unknown operation.
|
* if unknown operation.
|
||||||
*/
|
*/
|
||||||
static u8
|
static u8
|
||||||
isoApplet_acl_to_security_condition_byte(const sc_acl_entry_t *entry)
|
isoApplet_acl_to_security_condition_byte(const sc_acl_entry_t *entry)
|
||||||
|
@ -267,8 +267,8 @@ isoApplet_acl_to_security_condition_byte(const sc_acl_entry_t *entry)
|
||||||
* Note: IsoApplet currently only supports a "onepin" option.
|
* Note: IsoApplet currently only supports a "onepin" option.
|
||||||
*
|
*
|
||||||
* Format of the sec_attr: 8 Bytes:
|
* Format of the sec_attr: 8 Bytes:
|
||||||
* 7 - ISO 7816-4 table 16 or 17
|
* 7 - ISO 7816-4 table 16 or 17
|
||||||
* 6 to 0 - ISO 7816-4 table 20
|
* 6 to 0 - ISO 7816-4 table 20
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_create_file(sc_card_t *card, sc_file_t *file)
|
isoApplet_create_file(sc_card_t *card, sc_file_t *file)
|
||||||
|
@ -284,34 +284,34 @@ isoApplet_create_file(sc_card_t *card, sc_file_t *file)
|
||||||
|
|
||||||
if(file->type == SC_FILE_TYPE_DF)
|
if(file->type == SC_FILE_TYPE_DF)
|
||||||
{
|
{
|
||||||
const int df_idx[8] = /* These are the SC operations. */
|
const int df_idx[8] = /* These are the SC operations. */
|
||||||
{
|
{
|
||||||
0, /* Reserved. */
|
0, /* Reserved. */
|
||||||
SC_AC_OP_DELETE_SELF, //b6
|
SC_AC_OP_DELETE_SELF, /* b6 */
|
||||||
SC_AC_OP_LOCK, //b5
|
SC_AC_OP_LOCK, /* b5 */
|
||||||
SC_AC_OP_ACTIVATE, //b4
|
SC_AC_OP_ACTIVATE, /* b4 */
|
||||||
SC_AC_OP_DEACTIVATE, //b3
|
SC_AC_OP_DEACTIVATE, /* b3 */
|
||||||
SC_AC_OP_CREATE_DF, //b2
|
SC_AC_OP_CREATE_DF, /* b2 */
|
||||||
SC_AC_OP_CREATE_EF, //b1
|
SC_AC_OP_CREATE_EF, /* b1 */
|
||||||
SC_AC_OP_DELETE //b0
|
SC_AC_OP_DELETE /* b0 */
|
||||||
};
|
};
|
||||||
for(i=0; i<8; i++)
|
for(i=0; i<8; i++)
|
||||||
{
|
{
|
||||||
idx[i] = df_idx[i];
|
idx[i] = df_idx[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //EF
|
else /* EF */
|
||||||
{
|
{
|
||||||
const int ef_idx[8] =
|
const int ef_idx[8] =
|
||||||
{
|
{
|
||||||
0, /* Reserved. */
|
0, /* Reserved. */
|
||||||
SC_AC_OP_DELETE_SELF, //b6
|
SC_AC_OP_DELETE_SELF, /* b6 */
|
||||||
SC_AC_OP_LOCK, //b5
|
SC_AC_OP_LOCK, /* b5 */
|
||||||
SC_AC_OP_ACTIVATE, //b4
|
SC_AC_OP_ACTIVATE, /* b4 */
|
||||||
SC_AC_OP_DEACTIVATE, //b3
|
SC_AC_OP_DEACTIVATE, /* b3 */
|
||||||
SC_AC_OP_WRITE, //b2
|
SC_AC_OP_WRITE, /* b2 */
|
||||||
SC_AC_OP_UPDATE, //b1
|
SC_AC_OP_UPDATE, /* b1 */
|
||||||
SC_AC_OP_READ //b0
|
SC_AC_OP_READ /* b0 */
|
||||||
};
|
};
|
||||||
for(i=0; i<8; i++)
|
for(i=0; i<8; i++)
|
||||||
{
|
{
|
||||||
|
@ -341,9 +341,9 @@ isoApplet_create_file(sc_card_t *card, sc_file_t *file)
|
||||||
* and the saByte (Encoded according to IsoApplet FCI proprietary security
|
* and the saByte (Encoded according to IsoApplet FCI proprietary security
|
||||||
* information, see also ISO 7816-4 table 20).
|
* information, see also ISO 7816-4 table 20).
|
||||||
*
|
*
|
||||||
* @param[in,out] file
|
* @param[in,out] file
|
||||||
* @param[in] operation The OpenSC operation.
|
* @param[in] operation The OpenSC operation.
|
||||||
* @param[in] saByte The security condition byte returned by the applet.
|
* @param[in] saByte The security condition byte returned by the applet.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_add_sa_to_acl(sc_file_t *file, unsigned int operation, u8 saByte)
|
isoApplet_add_sa_to_acl(sc_file_t *file, unsigned int operation, u8 saByte)
|
||||||
|
@ -446,19 +446,19 @@ isoApplet_process_fci(sc_card_t *card, sc_file_t *file,
|
||||||
* @brief Encode the EC parameters as a concatenation of TLV enrties.
|
* @brief Encode the EC parameters as a concatenation of TLV enrties.
|
||||||
*
|
*
|
||||||
* The format is:
|
* The format is:
|
||||||
* 81 - prime
|
* 81 - prime
|
||||||
* 82 - coefficient A
|
* 82 - coefficient A
|
||||||
* 83 - coefficient B
|
* 83 - coefficient B
|
||||||
* 84 - base point G
|
* 84 - base point G
|
||||||
* 85 - order
|
* 85 - order
|
||||||
* 87 - cofactor
|
* 87 - cofactor
|
||||||
*
|
*
|
||||||
* @param[in] card
|
* @param[in] card
|
||||||
* @param[in] params The ECparameters containing the information of the curve.
|
* @param[in] params The ECparameters containing the information of the curve.
|
||||||
* @param[out] out The array the encoded parameters are written to.
|
* @param[out] out The array the encoded parameters are written to.
|
||||||
* @param[in] out_len The size of out
|
* @param[in] out_len The size of out
|
||||||
* @param[out] ptr A pointer pointing to the end of the parameters in out
|
* @param[out] ptr A pointer pointing to the end of the parameters in out
|
||||||
* (the first untouched byte behind the parameters).
|
* (the first untouched byte behind the parameters).
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_put_ec_params(sc_card_t *card, sc_cardctl_isoApplet_ec_parameters_t *params, u8 *out, size_t out_len, u8 **ptr)
|
isoApplet_put_ec_params(sc_card_t *card, sc_cardctl_isoApplet_ec_parameters_t *params, u8 *out, size_t out_len, u8 **ptr)
|
||||||
|
@ -551,11 +551,11 @@ isoApplet_ctl_generate_key(sc_card_t *card, sc_cardctl_isoApplet_genkey_t *args)
|
||||||
/* GENERATE ASYMMETRIC KEY PAIR
|
/* GENERATE ASYMMETRIC KEY PAIR
|
||||||
* We use a larger buffer here, even if the card does not support extended apdus.
|
* We use a larger buffer here, even if the card does not support extended apdus.
|
||||||
* There are two cases:
|
* There are two cases:
|
||||||
* 1) The card can do ext. apdus: The data fits in one apdu.
|
* 1) The card can do ext. apdus: The data fits in one apdu.
|
||||||
* 2) The card can't do ext. apdus: sc_transmit_apdu will handle that - the
|
* 2) The card can't do ext. apdus: sc_transmit_apdu will handle that - the
|
||||||
* card will send SW_BYTES_REMAINING, OpenSC will automaticall do a
|
* card will send SW_BYTES_REMAINING, OpenSC will automaticall do a
|
||||||
* GET RESPONSE to get the remaining data, and will append it to the data
|
* GET RESPONSE to get the remaining data, and will append it to the data
|
||||||
* buffer. */
|
* buffer. */
|
||||||
if(args->algorithm_ref == SC_ISOAPPLET_ALG_REF_EC_GEN)
|
if(args->algorithm_ref == SC_ISOAPPLET_ALG_REF_EC_GEN)
|
||||||
{
|
{
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x46, 0x00, 0x00);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x46, 0x00, 0x00);
|
||||||
|
@ -694,10 +694,10 @@ isoApplet_ctl_generate_key(sc_card_t *card, sc_cardctl_isoApplet_genkey_t *args)
|
||||||
* one RSA field (P, Q, etc.). The first apdu must contain the outer tag (7F48).
|
* one RSA field (P, Q, etc.). The first apdu must contain the outer tag (7F48).
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param rsa The RSA private key to import.
|
* @param rsa The RSA private key to import.
|
||||||
*
|
*
|
||||||
* @return SC_ERROR_INVALID_ARGUMENTS: The RSA key does not contain CRT fields.
|
* @return SC_ERROR_INVALID_ARGUMENTS: The RSA key does not contain CRT fields.
|
||||||
* other errors: Transmit errors / errors returned by card.
|
* other errors: Transmit errors / errors returned by card.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_put_data_prkey_rsa(sc_card_t *card, sc_cardctl_isoApplet_import_key_t *args)
|
isoApplet_put_data_prkey_rsa(sc_card_t *card, sc_cardctl_isoApplet_import_key_t *args)
|
||||||
|
@ -808,21 +808,21 @@ out:
|
||||||
* @brief Use PUT DATA to import a private EC key.
|
* @brief Use PUT DATA to import a private EC key.
|
||||||
*
|
*
|
||||||
* Format of transmitted data:
|
* Format of transmitted data:
|
||||||
* 0xE0 - Private class, constructed encoding, number one.
|
* 0xE0 - Private class, constructed encoding, number one.
|
||||||
* 0x81 - prime
|
* 0x81 - prime
|
||||||
* 0x82 - coefficient A
|
* 0x82 - coefficient A
|
||||||
* 0x83 - coefficient B
|
* 0x83 - coefficient B
|
||||||
* 0x84 - base point G
|
* 0x84 - base point G
|
||||||
* 0x85 - order
|
* 0x85 - order
|
||||||
* 0x87 - cofactor
|
* 0x87 - cofactor
|
||||||
* 0x88 - private D (private key)
|
* 0x88 - private D (private key)
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param ec The EC private key to import.
|
* @param ec The EC private key to import.
|
||||||
*
|
*
|
||||||
* @return SC_ERROR_INVALID_ARGUMENTS: Curve parameters or private component is missing.
|
* @return SC_ERROR_INVALID_ARGUMENTS: Curve parameters or private component is missing.
|
||||||
* other errors: Transmit errors / errors returned by card.
|
* other errors: Transmit errors / errors returned by card.
|
||||||
* ASN1 errors.
|
* ASN1 errors.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_put_data_prkey_ec(sc_card_t *card, sc_cardctl_isoApplet_import_key_t *args)
|
isoApplet_put_data_prkey_ec(sc_card_t *card, sc_cardctl_isoApplet_import_key_t *args)
|
||||||
|
@ -1088,7 +1088,7 @@ isoApplet_set_security_env(sc_card_t *card,
|
||||||
LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported algorithm.");
|
LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported algorithm.");
|
||||||
}
|
}
|
||||||
|
|
||||||
*p++ = 0x80; /* algorithm reference */
|
*p++ = 0x80; /* algorithm reference */
|
||||||
*p++ = 0x01;
|
*p++ = 0x01;
|
||||||
*p++ = drvdata->sec_env_alg_ref;
|
*p++ = drvdata->sec_env_alg_ref;
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,9 +269,9 @@ isoApplet_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t
|
||||||
/*
|
/*
|
||||||
* @brief Get the curve parameters associated with the curve specified by an OID.
|
* @brief Get the curve parameters associated with the curve specified by an OID.
|
||||||
*
|
*
|
||||||
* @param[in] oid The DER encoded OID of the curve.
|
* @param[in] oid The DER encoded OID of the curve.
|
||||||
* @param[in] oid_len The length of oid.
|
* @param[in] oid_len The length of oid.
|
||||||
* @param[out] curve_out The ec_curve containing the set of parameters.
|
* @param[out] curve_out The ec_curve containing the set of parameters.
|
||||||
*
|
*
|
||||||
* @returns SC_SUCCESS: If the curve was found.
|
* @returns SC_SUCCESS: If the curve was found.
|
||||||
* SC_ERROR_INVALID_ARGUMENTS: If named_curve was null or the curve
|
* SC_ERROR_INVALID_ARGUMENTS: If named_curve was null or the curve
|
||||||
|
@ -305,13 +305,13 @@ isoApplet_get_curve(u8 *oid, size_t oid_len, const struct ec_curve **curve_out)
|
||||||
* A MANAGE SECURITY ENVIRONMENT apdu must have been sent before.
|
* A MANAGE SECURITY ENVIRONMENT apdu must have been sent before.
|
||||||
* This function uses card_ctl to access the card-isoApplet driver.
|
* This function uses card_ctl to access the card-isoApplet driver.
|
||||||
*
|
*
|
||||||
* @param[in] key_info
|
* @param[in] key_info
|
||||||
* @param[in] card
|
* @param[in] card
|
||||||
* @param[in] pubkey The public key of the generated key pair
|
* @param[in] pubkey The public key of the generated key pair
|
||||||
* returned by the card.
|
* returned by the card.
|
||||||
*
|
*
|
||||||
* @return SC_ERROR_INVALID_ARGURMENTS: Invalid key length.
|
* @return SC_ERROR_INVALID_ARGURMENTS: Invalid key length.
|
||||||
* SC_ERROR_OUT_OF_MEMORY
|
* SC_ERROR_OUT_OF_MEMORY
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_generate_key_rsa(sc_pkcs15_prkey_info_t *key_info, sc_card_t *card,
|
isoApplet_generate_key_rsa(sc_pkcs15_prkey_info_t *key_info, sc_card_t *card,
|
||||||
|
@ -333,7 +333,8 @@ isoApplet_generate_key_rsa(sc_pkcs15_prkey_info_t *key_info, sc_card_t *card,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate the key.
|
/* Generate the key.
|
||||||
* Note: key size is not explicitly passed to the card. It assumes 2048 along with the algorithm reference. */
|
* Note: key size is not explicitly passed to the card.
|
||||||
|
* It assumes 2048 along with the algorithm reference. */
|
||||||
memset(&args, 0, sizeof(args));
|
memset(&args, 0, sizeof(args));
|
||||||
args.algorithm_ref = SC_ISOAPPLET_ALG_REF_RSA_GEN_2048;
|
args.algorithm_ref = SC_ISOAPPLET_ALG_REF_RSA_GEN_2048;
|
||||||
args.priv_key_ref = key_info->key_reference;
|
args.priv_key_ref = key_info->key_reference;
|
||||||
|
@ -393,16 +394,16 @@ err:
|
||||||
* A MANAGE SECURITY ENVIRONMENT apdu must have been sent before.
|
* A MANAGE SECURITY ENVIRONMENT apdu must have been sent before.
|
||||||
* This function uses card_ctl to access the card-isoApplet driver.
|
* This function uses card_ctl to access the card-isoApplet driver.
|
||||||
*
|
*
|
||||||
* @param[in] key_info
|
* @param[in] key_info
|
||||||
* @param[in] card
|
* @param[in] card
|
||||||
* @param[in/out] pubkey The public key of the generated key pair
|
* @param[in/out] pubkey The public key of the generated key pair
|
||||||
* returned by the card.
|
* returned by the card.
|
||||||
*
|
*
|
||||||
* @return SC_ERROR_INVALID_ARGURMENTS: Invalid key length or curve.
|
* @return SC_ERROR_INVALID_ARGURMENTS: Invalid key length or curve.
|
||||||
* SC_ERROR_OUT_OF_MEMORY
|
* SC_ERROR_OUT_OF_MEMORY
|
||||||
* SC_ERROR_INCOMPATIBLE_KEY: The data returned by the card
|
* SC_ERROR_INCOMPATIBLE_KEY: The data returned by the card
|
||||||
* was unexpected and can not be
|
* was unexpected and can not be
|
||||||
* handled.
|
* handled.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
isoApplet_generate_key_ec(const sc_pkcs15_prkey_info_t *key_info, sc_card_t *card,
|
isoApplet_generate_key_ec(const sc_pkcs15_prkey_info_t *key_info, sc_card_t *card,
|
||||||
|
@ -434,7 +435,7 @@ isoApplet_generate_key_ec(const sc_pkcs15_prkey_info_t *key_info, sc_card_t *car
|
||||||
|
|
||||||
/* Generate the key.
|
/* Generate the key.
|
||||||
* Note: The field size is not explicitly passed to the card.
|
* Note: The field size is not explicitly passed to the card.
|
||||||
* As we only support FP curves, the field length can be calculated from any parameter. */
|
* As we only support FP curves, the field length can be calculated from any parameter. */
|
||||||
memset(&args, 0, sizeof(args));
|
memset(&args, 0, sizeof(args));
|
||||||
|
|
||||||
args.pubkey.ec.params.prime.value = curve->prime.value;
|
args.pubkey.ec.params.prime.value = curve->prime.value;
|
||||||
|
|
Loading…
Reference in New Issue