Obtaining Smart Card serial number

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Obtaining Smart Card serial number

Douglas de Oliveira Mendes-2
    Is there a way of obtaining the smart card serial number with
libp11? There should be an ATR parser at the lib. I believe it would be
very usefull.

Douglas

       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number

Stef Hoeben
Douglas de Oliveira Mendes schreef:

>    Is there a way of obtaining the smart card serial number with
>libp11? There should be an ATR parser at the lib. I believe it would be
>very usefull.
>
>Douglas
>

Serialnr would indeed be interesting.

Could you try the attached patch (I didn't:-)

Cheers,
Stef


Index: p11_slot.c
===================================================================
--- p11_slot.c (revision 2444)
+++ p11_slot.c (working copy)
@@ -377,6 +377,7 @@
  token->label = PKCS11_DUP(info.label);
  token->manufacturer = PKCS11_DUP(info.manufacturerID);
  token->model = PKCS11_DUP(info.model);
+ token->serialnr = PKCS11_DUP(info.serialNumber);
  token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0;
  token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0;
  token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0;
@@ -393,6 +394,7 @@
  OPENSSL_free(token->label);
  OPENSSL_free(token->manufacturer);
  OPENSSL_free(token->model);
+ OPENSSL_free(token->serialnr);
  OPENSSL_free(token->_private);
  memset(token, 0, sizeof(*token));
 }
Index: libp11.h
===================================================================
--- libp11.h (revision 2444)
+++ libp11.h (working copy)
@@ -109,6 +109,7 @@
  char *label;
  char *manufacturer;
  char *model;
+ char *serialnr;
  unsigned char initialized;
  unsigned char loginRequired;
  unsigned char secureLogin;

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number

Nils Larsch
Stef Hoeben wrote:

> Douglas de Oliveira Mendes schreef:
>
>>    Is there a way of obtaining the smart card serial number with
>> libp11? There should be an ATR parser at the lib. I believe it would be
>> very usefull.
>>
>> Douglas
>>
>
> Serialnr would indeed be interesting.
>
> Could you try the attached patch (I didn't:-)
>
> Cheers,
> Stef
>
>
> ------------------------------------------------------------------------
>
> Index: p11_slot.c
> ===================================================================
> --- p11_slot.c (revision 2444)
> +++ p11_slot.c (working copy)
> @@ -377,6 +377,7 @@
>   token->label = PKCS11_DUP(info.label);
>   token->manufacturer = PKCS11_DUP(info.manufacturerID);
>   token->model = PKCS11_DUP(info.model);
> + token->serialnr = PKCS11_DUP(info.serialNumber);
>   token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0;
>   token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0;
>   token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0;
> @@ -393,6 +394,7 @@
>   OPENSSL_free(token->label);
>   OPENSSL_free(token->manufacturer);
>   OPENSSL_free(token->model);
> + OPENSSL_free(token->serialnr);
>   OPENSSL_free(token->_private);
>   memset(token, 0, sizeof(*token));
>  }
> Index: libp11.h
> ===================================================================
> --- libp11.h (revision 2444)
> +++ libp11.h (working copy)
> @@ -109,6 +109,7 @@
>   char *label;
>   char *manufacturer;
>   char *model;
> + char *serialnr;
>   unsigned char initialized;
>   unsigned char loginRequired;
>   unsigned char secureLogin;
>

I would strongly recommend to supply functions to access this
kind information and not let the user access the data structures
directly (and consequently hide the definition of the structures
in internal header files).

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Andreas Jellinghaus-2
On Friday 22 July 2005 19:39, Nils Larsch wrote:
> I would strongly recommend to supply functions to access this
> kind information and not let the user access the data structures
> directly (and consequently hide the definition of the structures
> in internal header files).

currently all structures are split into a public and a private
part, where the public part can be accessed directly, but the
private part is limited to internal functions. is that enough?

or do you suggest to make all structures anonymous, and provide
get functions for each attribute (the user is not supposed
to change anything I guess)?

Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Nils Larsch
Andreas Jellinghaus [c] wrote:

> On Friday 22 July 2005 19:39, Nils Larsch wrote:
>
>>I would strongly recommend to supply functions to access this
>>kind information and not let the user access the data structures
>>directly (and consequently hide the definition of the structures
>>in internal header files).
>
>
> currently all structures are split into a public and a private
> part, where the public part can be accessed directly, but the
> private part is limited to internal functions. is that enough?
>
> or do you suggest to make all structures anonymous, and provide
> get functions for each attribute (the user is not supposed
> to change anything I guess)?

for example Stef patch would break the api as it changes the
offset of "initialized" within the PKCS11_TOKEN structure. I
think get functions offer the best possibility to have a somewhat
stable api.

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Stef Hoeben
Nils Larsch schreef:

> Andreas Jellinghaus [c] wrote:
>
>> On Friday 22 July 2005 19:39, Nils Larsch wrote:
>>
>>> I would strongly recommend to supply functions to access this
>>> kind information and not let the user access the data structures
>>> directly (and consequently hide the definition of the structures
>>> in internal header files).
>>
>>
>>
>> currently all structures are split into a public and a private
>> part, where the public part can be accessed directly, but the
>> private part is limited to internal functions. is that enough?
>>
>> or do you suggest to make all structures anonymous, and provide
>> get functions for each attribute (the user is not supposed
>> to change anything I guess)?
>
>
> for example Stef patch would break the api as it changes the
> offset of "initialized" within the PKCS11_TOKEN structure. I
> think get functions offer the best possibility to have a somewhat
> stable api.


I'd propose to add get-ers and set-ers without hiding the struct itself
and work with handles. That way developers can then choose between
the simply way with a risk on incompatible BAPI, or the more involved
way with handles and get/set-ers.

(Setters would indeed be needed sometimes, e.g. for PKCS11_init_pin()
PKCS11_generate_key(), ...)

Cheers,
Stef

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Nils Larsch
Stef Hoeben wrote:
...

>>> currently all structures are split into a public and a private
>>> part, where the public part can be accessed directly, but the
>>> private part is limited to internal functions. is that enough?
>>>
>>> or do you suggest to make all structures anonymous, and provide
>>> get functions for each attribute (the user is not supposed
>>> to change anything I guess)?
>>
>>
>>
>> for example Stef patch would break the api as it changes the
>> offset of "initialized" within the PKCS11_TOKEN structure. I
>> think get functions offer the best possibility to have a somewhat
>> stable api.
>
>
>
> I'd propose to add get-ers and set-ers without hiding the struct itself
> and work with handles. That way developers can then choose between
> the simply way with a risk on incompatible BAPI, or the more involved
> way with handles and get/set-ers.

if we allow both possibilities we must assume that developers choose
the direct structure access, and hence any modification will cause
an api change. What's the advantage of giving application developers
access to the structure elements ?

> (Setters would indeed be needed sometimes, e.g. for PKCS11_init_pin()
> PKCS11_generate_key(), ...)

and both functions are trivial to implement (even if we want to
include some input checking for set-functions).

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Stef Hoeben
Nils Larsch schreef:

> Stef Hoeben wrote:
> ...
>
>>>> currently all structures are split into a public and a private
>>>> part, where the public part can be accessed directly, but the
>>>> private part is limited to internal functions. is that enough?
>>>>
>>>> or do you suggest to make all structures anonymous, and provide
>>>> get functions for each attribute (the user is not supposed
>>>> to change anything I guess)?
>>>
>>>
>>>
>>>
>>> for example Stef patch would break the api as it changes the
>>> offset of "initialized" within the PKCS11_TOKEN structure. I
>>> think get functions offer the best possibility to have a somewhat
>>> stable api.
>>
>>
>>
>>
>> I'd propose to add get-ers and set-ers without hiding the struct itself
>> and work with handles. That way developers can then choose between
>> the simply way with a risk on incompatible BAPI, or the more involved
>> way with handles and get/set-ers.
>
>
> if we allow both possibilities we must assume that developers choose
> the direct structure access, and hence any modification will cause
> an api change. What's the advantage of giving application developers
> access to the structure elements ?

Just that it's easier. For example instead of being able to write

    if (!strcmp(p11_token->serialnr, ...) || !strcmp(p11_token->
serialnr, ...))

the app dev-er has to write

    const char *serial;
     ...
     serial = get_serialnr(p11_token);
    if (!strcmp(p11_token->serial, ...) || !strcmp(p11_token-> serial, ...))

The downside is that you have to recompile if libp11.h changes, which
may be acceptable in some cases.

Not that it matters that much, but because the purpose of this lib is to
simplify the pkcs11 API...

Cheers,
Stef


_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Andreas Jellinghaus-2
Distributions hate api changes. everytime someone does that, the soname needs
to be changes, and debian for example then creates a new package with the new
version, and sometimes they keep packages for the old version for a while,
too.

api changes are bad, they cause people a lot of headake, thus we should
change the api only if necessary. we should also design our api so we
can extend it, which is a lot less of a problem, as the soname can
stay the same and people can simply require version >= newversion
in their packages.

so I'm for hiding all structure definitions and creating explicit
get functions. and set functions for the cases where we allow that.

also we need to document: can people only get or also set some value?
if they get a value, do they need to free it? if not, the value is
invalidated when?

douglas suggested javadoc/doxygen for libp11 documentation.
I guess I will give it a try?

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Nils Larsch
Andreas Jellinghaus [c] wrote:

> Distributions hate api changes. everytime someone does that, the soname needs
> to be changes, and debian for example then creates a new package with the new
> version, and sometimes they keep packages for the old version for a while,
> too.
>
> api changes are bad, they cause people a lot of headake, thus we should
> change the api only if necessary. we should also design our api so we
> can extend it, which is a lot less of a problem, as the soname can
> stay the same and people can simply require version >= newversion
> in their packages.
>
> so I'm for hiding all structure definitions and creating explicit
> get functions. and set functions for the cases where we allow that.
>
> also we need to document: can people only get or also set some value?
> if they get a value, do they need to free it? if not, the value is
> invalidated when?

good point. If a function returns a 'const' value it should be
obvious that one shouldn't modify or free the value. Btw: in
openssl we have foo_get0_bar() and foo_get1_bar() functions to
indicate that in case of get0 the returned value must not be freed
and get1 otherwise. I guess something like

int PKCS11_get_serialnr(*, char *ret, size_t len)
{
        char *p;
        if (len < strlen(token->serialnr) + 1)
                return needed_length;
        p = strcpy(ret, token->serialnr);
        if (p == NULL)
                return error_value;
        return ok;
}

is even better from an api point of view (or a variant which
allocates the neccessary memory itself) as this hides information
about the internal representation of the data.

> douglas suggested javadoc/doxygen for libp11 documentation.

I would prefer doxygen

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Wouter Verhelst-2
In reply to this post by Andreas Jellinghaus-2
On Sat, Jul 23, 2005 at 11:37:52PM +0200, Andreas Jellinghaus [c] wrote:
> Distributions hate api changes. everytime someone does that, the soname needs
> to be changes, and debian for example then creates a new package with the new
> version, and sometimes they keep packages for the old version for a while,
> too.

You're actually talking about ABI changes here. They're not the same,
even if changing one usually (but not always) implies the other.

Changing the API without changing the ABI is no problem. You change
build-time dependencies, but not run-time dependencies. Distributions
usually don't mind; Debian doesn't create a new package in such a case
(instead, packages requiring the new API just need to declare a
versioned build-depends on a -dev package of a sufficiently high
version).

Of course, whether it's going to be possible to make an API change
without an ABI one is a different matter; it depends on the specific
change one wants to make.

That being said, of course I agree with the rest of your mail :)

--
The amount of time between slipping on the peel and landing on the
pavement is precisely one bananosecond
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Douglas de Oliveira Mendes-2
In reply to this post by Nils Larsch
    I meant the use of doxygen, but writing like javadoc style. For
instance:

/**
* Increments an integer.
* @param a An integer that will be incremented
* @return The integer incremented by 1.
*/
int increment(int a);

>
>> douglas suggested javadoc/doxygen for libp11 documentation.
>
>
> I would prefer doxygen
>
> Nils
> _______________________________________________
> opensc-devel mailing list
> [hidden email]
> http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
>


       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Douglas de Oliveira Mendes-2
    My suggestion of using doxygen is because it's easier for the
developers to update the documentation, as it is directly at the code.
And who better knows what the functions do but the developers?

Douglas

Douglas de Oliveira Mendes wrote:

>    I meant the use of doxygen, but writing like javadoc style. For
> instance:
>
> /**
> * Increments an integer.
> * @param a An integer that will be incremented
> * @return The integer incremented by 1.
> */
> int increment(int a);
>
>>
>>> douglas suggested javadoc/doxygen for libp11 documentation.
>>
>>
>>
>> I would prefer doxygen
>>
>> Nils
>> _______________________________________________
>> opensc-devel mailing list
>> [hidden email]
>> http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
>>
>
>
>    
>    
>        
> _______________________________________________________ Yahoo! Acesso
> Grátis - Internet rápida e grátis. Instale o discador agora!
> http://br.acesso.yahoo.com/
> _______________________________________________
> opensc-devel mailing list
> [hidden email]
> http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
>

       
       
               
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number

Douglas de Oliveira Mendes-2
In reply to this post by Stef Hoeben
    I tested the patch. I don't know if I did something wrong but it didn't work well.. slot->token->serialnr is returning 0000.

Stef Hoeben escreveu:
Douglas de Oliveira Mendes schreef:

   Is there a way of obtaining the smart card serial number with
libp11? There should be an ATR parser at the lib. I believe it would be
very usefull.

Douglas


Serialnr would indeed be interesting.

Could you try the attached patch (I didn't:-)

Cheers,
Stef


Index: p11_slot.c =================================================================== --- p11_slot.c (revision 2444) +++ p11_slot.c (working copy) @@ -377,6 +377,7 @@ token->label = PKCS11_DUP(info.label); token->manufacturer = PKCS11_DUP(info.manufacturerID); token->model = PKCS11_DUP(info.model); + token->serialnr = PKCS11_DUP(info.serialNumber); token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0; token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0; token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0; @@ -393,6 +394,7 @@ OPENSSL_free(token->label); OPENSSL_free(token->manufacturer); OPENSSL_free(token->model); + OPENSSL_free(token->serialnr); OPENSSL_free(token->_private); memset(token, 0, sizeof(*token)); } Index: libp11.h =================================================================== --- libp11.h (revision 2444) +++ libp11.h (working copy) @@ -109,6 +109,7 @@ char *label; char *manufacturer; char *model; + char *serialnr; unsigned char initialized; unsigned char loginRequired; unsigned char secureLogin;

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number

Douglas de Oliveira Mendes-2
    Oh, nevermind! It worked! My card was really 0000. I got another smart card that had another serial number. So, please, apply the attached patch.

Douglas

Douglas de Oliveira Mendes escreveu:
    I tested the patch. I don't know if I did something wrong but it didn't work well.. slot->token->serialnr is returning 0000.

Stef Hoeben escreveu:
Douglas de Oliveira Mendes schreef:

   Is there a way of obtaining the smart card serial number with
libp11? There should be an ATR parser at the lib. I believe it would be
very usefull.

Douglas


Serialnr would indeed be interesting.

Could you try the attached patch (I didn't:-)

Cheers,
Stef


Index: p11_slot.c =================================================================== --- p11_slot.c (revision 2444) +++ p11_slot.c (working copy) @@ -377,6 +377,7 @@ token->label = PKCS11_DUP(info.label); token->manufacturer = PKCS11_DUP(info.manufacturerID); token->model = PKCS11_DUP(info.model); + token->serialnr = PKCS11_DUP(info.serialNumber); token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0; token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0; token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0; @@ -393,6 +394,7 @@ OPENSSL_free(token->label); OPENSSL_free(token->manufacturer); OPENSSL_free(token->model); + OPENSSL_free(token->serialnr); OPENSSL_free(token->_private); memset(token, 0, sizeof(*token)); } Index: libp11.h =================================================================== --- libp11.h (revision 2444) +++ libp11.h (working copy) @@ -109,6 +109,7 @@ char *label; char *manufacturer; char *model; + char *serialnr; unsigned char initialized; unsigned char loginRequired; unsigned char secureLogin;

Index: p11_slot.c
===================================================================
--- p11_slot.c (revision 2444)
+++ p11_slot.c (working copy)
@@ -377,6 +377,7 @@
  token->label = PKCS11_DUP(info.label);
  token->manufacturer = PKCS11_DUP(info.manufacturerID);
  token->model = PKCS11_DUP(info.model);
+ token->serialnr = PKCS11_DUP(info.serialNumber);
  token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0;
  token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0;
  token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0;
@@ -393,6 +394,7 @@
  OPENSSL_free(token->label);
  OPENSSL_free(token->manufacturer);
  OPENSSL_free(token->model);
+ OPENSSL_free(token->serialnr);
  OPENSSL_free(token->_private);
  memset(token, 0, sizeof(*token));
 }
Index: libp11.h
===================================================================
--- libp11.h (revision 2444)
+++ libp11.h (working copy)
@@ -109,6 +109,7 @@
  char *label;
  char *manufacturer;
  char *model;
+ char *serialnr;
  unsigned char initialized;
  unsigned char loginRequired;
  unsigned char secureLogin;

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number

Douglas de Oliveira Mendes-2
In reply to this post by Douglas de Oliveira Mendes-2
    I tested the attached patch and it worked! I could get the smart card serial number by: slot->token->serialnr

Douglas


Stef Hoeben escreveu:
Douglas de Oliveira Mendes schreef:

   Is there a way of obtaining the smart card serial number with
libp11? There should be an ATR parser at the lib. I believe it would be
very usefull.

Douglas


Serialnr would indeed be interesting.

Could you try the attached patch (I didn't:-)

Cheers,
Stef


Index: p11_slot.c =================================================================== --- p11_slot.c (revision 2444) +++ p11_slot.c (working copy) @@ -377,6 +377,7 @@ token->label = PKCS11_DUP(info.label); token->manufacturer = PKCS11_DUP(info.manufacturerID); token->model = PKCS11_DUP(info.model); + token->serialnr = PKCS11_DUP(info.serialNumber); token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0; token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0; token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0; @@ -393,6 +394,7 @@ OPENSSL_free(token->label); OPENSSL_free(token->manufacturer); OPENSSL_free(token->model); + OPENSSL_free(token->serialnr); OPENSSL_free(token->_private); memset(token, 0, sizeof(*token)); } Index: libp11.h =================================================================== --- libp11.h (revision 2444) +++ libp11.h (working copy) @@ -109,6 +109,7 @@ char *label; char *manufacturer; char *model; + char *serialnr; unsigned char initialized; unsigned char loginRequired; unsigned char secureLogin;

Index: p11_slot.c
===================================================================
--- p11_slot.c (revision 2444)
+++ p11_slot.c (working copy)
@@ -377,6 +377,7 @@
  token->label = PKCS11_DUP(info.label);
  token->manufacturer = PKCS11_DUP(info.manufacturerID);
  token->model = PKCS11_DUP(info.model);
+ token->serialnr = PKCS11_DUP(info.serialNumber);
  token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0;
  token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0;
  token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0;
@@ -393,6 +394,7 @@
  OPENSSL_free(token->label);
  OPENSSL_free(token->manufacturer);
  OPENSSL_free(token->model);
+ OPENSSL_free(token->serialnr);
  OPENSSL_free(token->_private);
  memset(token, 0, sizeof(*token));
 }
Index: libp11.h
===================================================================
--- libp11.h (revision 2444)
+++ libp11.h (working copy)
@@ -109,6 +109,7 @@
  char *label;
  char *manufacturer;
  char *model;
+ char *serialnr;
  unsigned char initialized;
  unsigned char loginRequired;
  unsigned char secureLogin;


_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number

Stef Hoeben
Hi,

there's a common agreement on working with get-and set functions,
but if non-one objects, I will commit this patch already (which must
be done anyway, regardless of whether we'll use get/setters.

Stef

Douglas de Oliveira Mendes wrote:

>     I tested the attached patch and it worked! I could get the smart
> card serial number by: slot->token->serialnr
>
> Douglas
>
>>
>>
>> Stef Hoeben escreveu:
>>
>>> Douglas de Oliveira Mendes schreef:
>>>
>>>>    Is there a way of obtaining the smart card serial number with
>>>> libp11? There should be an ATR parser at the lib. I believe it
>>>> would be
>>>> very usefull.
>>>>
>>>> Douglas
>>>>
>>>
>>> Serialnr would indeed be interesting.
>>>
>>> Could you try the attached patch (I didn't:-)
>>>
>>> Cheers,
>>> Stef
>>>
>>>------------------------------------------------------------------------
>>>
>>>Index: p11_slot.c
>>>===================================================================
>>>--- p11_slot.c (revision 2444)
>>>+++ p11_slot.c (working copy)
>>>@@ -377,6 +377,7 @@
>>> token->label = PKCS11_DUP(info.label);
>>> token->manufacturer = PKCS11_DUP(info.manufacturerID);
>>> token->model = PKCS11_DUP(info.model);
>>>+ token->serialnr = PKCS11_DUP(info.serialNumber);
>>> token->initialized = (info.flags & CKF_TOKEN_INITIALIZED) ? 1 : 0;
>>> token->loginRequired = (info.flags & CKF_LOGIN_REQUIRED) ? 1 : 0;
>>> token->secureLogin = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) ? 1 : 0;
>>>@@ -393,6 +394,7 @@
>>> OPENSSL_free(token->label);
>>> OPENSSL_free(token->manufacturer);
>>> OPENSSL_free(token->model);
>>>+ OPENSSL_free(token->serialnr);
>>> OPENSSL_free(token->_private);
>>> memset(token, 0, sizeof(*token));
>>> }
>>>Index: libp11.h
>>>===================================================================
>>>--- libp11.h (revision 2444)
>>>+++ libp11.h (working copy)
>>>@@ -109,6 +109,7 @@
>>> char *label;
>>> char *manufacturer;
>>> char *model;
>>>+ char *serialnr;
>>> unsigned char initialized;
>>> unsigned char loginRequired;
>>> unsigned char secureLogin;
>>>  
>>>
>------------------------------------------------------------------------
>
>_______________________________________________
>opensc-devel mailing list
>[hidden email]
>http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
>

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card serial number [u]

Andreas Jellinghaus-2
On Friday 26 August 2005 09:15, Stef Hoeben wrote:
> but if non-one objects, I will commit this patch already (which must
> be done anyway, regardless of whether we'll use get/setters.

already done in libp11 repository.
please don't make any further changes to libp11 in opensc repository.

sorry, with all the small details and small changes I had forgotten
to follow up on that post.

Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel