forked from OpenSC/OpenSC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dell reader cannot handle PIN without padding
- Loading branch information
Javier Serrano Polo
committed
Jan 18, 2014
1 parent
9f90cfa
commit 83142d4
Showing
9 changed files
with
200 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* quirks-reader.c: Reader quirks | ||
* | ||
* Copyright (C) 2014 Javier Serrano Polo <javier@jasp.net> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include <string.h> | ||
|
||
#include "log.h" | ||
#include "opensc.h" | ||
#include "pkcs15.h" | ||
#include "quirks-reader.h" | ||
|
||
static int _vendor_specific_problem(struct sc_reader *reader, | ||
struct sc_pkcs15_auth_info *pkcs15_pin_info) | ||
{ | ||
int id_vendor; | ||
int id_product; | ||
|
||
if (!reader->ops || !reader->ops->get_vendor_product) | ||
return 0; | ||
|
||
if (reader->ops->get_vendor_product(reader, &id_vendor, &id_product) != SC_SUCCESS) | ||
return 0; | ||
|
||
/* Dell Smart Card Reader Keyboard */ | ||
if (id_vendor == 0x413c && id_product == 0x2101 | ||
&& !(pkcs15_pin_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_NEEDS_PADDING)) | ||
return 1; | ||
|
||
return 0; | ||
} | ||
|
||
int sc_reader_can_handle_pin(struct sc_reader *reader, | ||
struct sc_pkcs15_auth_info *pkcs15_pin_info) | ||
{ | ||
struct sc_context *ctx = reader->ctx; | ||
|
||
if (!(reader->capabilities & SC_READER_CAP_PIN_PAD)) | ||
return 0; | ||
|
||
if (!(reader->flags & SC_READER_AUTO_PIN_PAD)) | ||
return 1; | ||
|
||
if (!pkcs15_pin_info) | ||
return 1; | ||
|
||
if (pkcs15_pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN) | ||
return 1; | ||
|
||
if (_vendor_specific_problem(reader, pkcs15_pin_info)) { | ||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "reader cannot handle this PIN"); | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* quirks-reader.h: Reader quirks header file | ||
* | ||
* Copyright (C) 2014 Javier Serrano Polo <javier@jasp.net> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#ifndef _OPENSC_QUIRKS_READER_H | ||
#define _OPENSC_QUIRKS_READER_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
struct sc_pkcs15_auth_info; | ||
struct sc_reader; | ||
|
||
int sc_reader_can_handle_pin(struct sc_reader *reader, | ||
struct sc_pkcs15_auth_info *pkcs15_pin_info); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters