adapted to changes of openpace ce89f8ee374d7926c3f4707b8c4d3ae3de506507
This commit is contained in:
@@ -211,60 +211,52 @@ int npa_translate_apdus(sc_card_t *card, FILE *input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int add_to_ASN1_AUXILIARY_DATA(
|
static int add_to_ASN1_AUXILIARY_DATA(
|
||||||
ASN1_AUXILIARY_DATA **templates,
|
ASN1_AUXILIARY_DATA **auxiliary_data,
|
||||||
int nid, const unsigned char *data, size_t data_len)
|
int nid, const unsigned char *data, size_t data_len)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
CVC_DISCRETIONARY_DATA_TEMPLATE **template;
|
CVC_DISCRETIONARY_DATA_TEMPLATE *template = NULL;
|
||||||
|
|
||||||
if (!templates) {
|
if (!auxiliary_data) {
|
||||||
r = SC_ERROR_INVALID_ARGUMENTS;
|
r = SC_ERROR_INVALID_ARGUMENTS;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*templates) {
|
if (!*auxiliary_data) {
|
||||||
*templates = ASN1_AUXILIARY_DATA_new();
|
*auxiliary_data = ASN1_AUXILIARY_DATA_new();
|
||||||
if (!*templates) {
|
if (!*auxiliary_data) {
|
||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*templates)->template1)
|
template = CVC_DISCRETIONARY_DATA_TEMPLATE_new();
|
||||||
template = &(*templates)->template1;
|
if (!template) {
|
||||||
else if (!(*templates)->template2)
|
|
||||||
template = &(*templates)->template2;
|
|
||||||
else if (!(*templates)->template3)
|
|
||||||
template = &(*templates)->template3;
|
|
||||||
else {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Choose at most three nPA operations.\n");
|
|
||||||
r = SC_ERROR_INVALID_ARGUMENTS;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
*template = CVC_DISCRETIONARY_DATA_TEMPLATE_new();
|
|
||||||
if (!*template) {
|
|
||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*template)->type = OBJ_nid2obj(nid);
|
template->type = OBJ_nid2obj(nid);
|
||||||
if (!(*template)->type) {
|
if (!template->type) {
|
||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && data_len) {
|
if (data && data_len) {
|
||||||
(*template)->discretionary_data3 = ASN1_OCTET_STRING_new();
|
template->discretionary_data3 = ASN1_OCTET_STRING_new();
|
||||||
if (!(*template)->discretionary_data3
|
if (!template->discretionary_data3
|
||||||
|| !M_ASN1_OCTET_STRING_set(
|
|| !M_ASN1_OCTET_STRING_set(
|
||||||
(*template)->discretionary_data3, data, data_len)) {
|
template->discretionary_data3, data, data_len)) {
|
||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sk_push((_STACK*) (*auxiliary_data), template)) {
|
||||||
|
r = SC_ERROR_INTERNAL;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
r = SC_SUCCESS;
|
r = SC_SUCCESS;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
|||||||
@@ -49,11 +49,12 @@
|
|||||||
* Auxiliary authenticated data */
|
* Auxiliary authenticated data */
|
||||||
ASN1_ITEM_TEMPLATE(ASN1_AUXILIARY_DATA) =
|
ASN1_ITEM_TEMPLATE(ASN1_AUXILIARY_DATA) =
|
||||||
ASN1_EX_TEMPLATE_TYPE(
|
ASN1_EX_TEMPLATE_TYPE(
|
||||||
ASN1_TFLG_IMPTAG|ASN1_TFLG_APPLICATION,
|
ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_IMPTAG|ASN1_TFLG_APPLICATION,
|
||||||
7, ASN1_AUXILIARY_DATA, CVC_DISCRETIONARY_DATA_TEMPLATES)
|
7, AuxiliaryAuthenticatedData, CVC_DISCRETIONARY_DATA_TEMPLATE)
|
||||||
ASN1_ITEM_TEMPLATE_END(ASN1_AUXILIARY_DATA)
|
ASN1_ITEM_TEMPLATE_END(ASN1_AUXILIARY_DATA)
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(ASN1_AUXILIARY_DATA)
|
IMPLEMENT_ASN1_FUNCTIONS(ASN1_AUXILIARY_DATA)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MSE:Set AT
|
* MSE:Set AT
|
||||||
*/
|
*/
|
||||||
@@ -73,7 +74,7 @@ typedef struct npa_mse_cd_st {
|
|||||||
*
|
*
|
||||||
* NPA_MSE_C->auxiliary_data = d2i_ASN1_AUXILIARY_DATA(...)
|
* NPA_MSE_C->auxiliary_data = d2i_ASN1_AUXILIARY_DATA(...)
|
||||||
*
|
*
|
||||||
* because they both use the same underlieing struct.
|
* because they both use the same underlying struct.
|
||||||
*
|
*
|
||||||
* See also openssl/crypto/asn1/tasn_dec.c:183
|
* See also openssl/crypto/asn1/tasn_dec.c:183
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +93,7 @@ ASN1_SEQUENCE(NPA_MSE_C) = {
|
|||||||
ASN1_IMP_OPT(NPA_MSE_C, eph_pub_key, ASN1_OCTET_STRING, 0x11),
|
ASN1_IMP_OPT(NPA_MSE_C, eph_pub_key, ASN1_OCTET_STRING, 0x11),
|
||||||
/* 0x67
|
/* 0x67
|
||||||
* Auxiliary authenticated data. See note above. */
|
* Auxiliary authenticated data. See note above. */
|
||||||
ASN1_APP_IMP_OPT(NPA_MSE_C, auxiliary_data, CVC_DISCRETIONARY_DATA_TEMPLATES, 7),
|
ASN1_APP_IMP_SEQUENCE_OF_OPT(NPA_MSE_C, auxiliary_data, CVC_DISCRETIONARY_DATA_TEMPLATE, 7),
|
||||||
/* Certificate Holder Authorization Template */
|
/* Certificate Holder Authorization Template */
|
||||||
ASN1_OPT(NPA_MSE_C, chat, CVC_CHAT),
|
ASN1_OPT(NPA_MSE_C, chat, CVC_CHAT),
|
||||||
} ASN1_SEQUENCE_END(NPA_MSE_C)
|
} ASN1_SEQUENCE_END(NPA_MSE_C)
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ int npa_reset_retry_counter(sc_card_t *card,
|
|||||||
extern char npa_default_flags;
|
extern char npa_default_flags;
|
||||||
|
|
||||||
/** @brief ASN.1 type for authenticated auxiliary data for terminal authentication */
|
/** @brief ASN.1 type for authenticated auxiliary data for terminal authentication */
|
||||||
typedef CVC_DISCRETIONARY_DATA_TEMPLATES ASN1_AUXILIARY_DATA;
|
typedef STACK_OF(CVC_DISCRETIONARY_DATA_TEMPLATE) ASN1_AUXILIARY_DATA;
|
||||||
DECLARE_ASN1_FUNCTIONS(ASN1_AUXILIARY_DATA)
|
DECLARE_ASN1_FUNCTIONS(ASN1_AUXILIARY_DATA)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user