FreeRDP
|
#include <freerdp/config.h>
#include <winpr/wlog.h>
#include <winpr/stream.h>
#include <winpr/collections.h>
#include <freerdp/crypto/crypto.h>
#include <zlib.h>
#include "../../crypto/certificate.h"
#include "../../crypto/privatekey.h"
#include "smartcard_virtual_gids.h"
Functions | |
static void | vgids_ef_free (void *ptr) |
static vgidsEF * | vgids_ef_new (vgidsContext *ctx, USHORT id) |
static BOOL | vgids_write_tlv (wStream *s, UINT16 tag, const void *data, DWORD dataSize) |
static BOOL | vgids_ef_write_do (vgidsEF *ef, UINT16 doID, const void *data, DWORD dataSize) |
static BOOL | vgids_ef_read_do (vgidsEF *ef, UINT16 doID, BYTE **data, DWORD *dataSize) |
static BOOL | vgids_prepare_fstable (const vgidsFilesysTableEntry *fstable, DWORD numEntries, BYTE **outData, DWORD *outDataSize) |
static BOOL | vgids_prepare_certificate (const rdpCertificate *cert, BYTE **kxc, DWORD *kxcSize) |
static int | get_rsa_key_size (const rdpPrivateKey *privateKey) |
static BYTE | vgids_get_algid (vgidsContext *p_Ctx) |
static BOOL | vgids_prepare_keymap (vgidsContext *context, BYTE **outData, DWORD *outDataSize) |
static BOOL | vgids_parse_apdu_header (wStream *s, BYTE *cla, BYTE *ins, BYTE *p1, BYTE *p2, BYTE *lc, BYTE *le) |
static BOOL | vgids_create_response (UINT16 status, const BYTE *answer, DWORD answerSize, BYTE **outData, DWORD *outDataSize) |
static BOOL | vgids_read_do_fkt (void *data, size_t index, va_list ap) |
static void | vgids_read_do (vgidsContext *context, UINT16 efID, UINT16 doID) |
static void | vgids_reset_context_response (vgidsContext *context) |
static void | vgids_reset_context_command_data (vgidsContext *context) |
static BOOL | vgids_ins_select (vgidsContext *context, wStream *s, BYTE **response, DWORD *responseSize) |
static UINT16 | vgids_handle_chained_response (vgidsContext *context, const BYTE **response, DWORD *responseSize) |
static BOOL | vgids_get_public_key (vgidsContext *context, UINT16 doTag) |
static BOOL | vgids_ins_getdata (vgidsContext *context, wStream *s, BYTE **response, DWORD *responseSize) |
static BOOL | vgids_ins_manage_security_environment (vgidsContext *context, wStream *s, BYTE **response, DWORD *responseSize) |
static BOOL | vgids_perform_digital_signature (vgidsContext *context) |
static BOOL | vgids_perform_decrypt (vgidsContext *context) |
static BOOL | vgids_ins_perform_security_operation (vgidsContext *context, wStream *s, BYTE **response, DWORD *responseSize) |
static BOOL | vgids_ins_getresponse (vgidsContext *context, wStream *s, BYTE **response, DWORD *responseSize) |
static BOOL | vgids_ins_verify (vgidsContext *context, wStream *s, BYTE **response, DWORD *responseSize) |
vgidsContext * | vgids_new (void) |
BOOL | vgids_init (vgidsContext *ctx, const char *cert, const char *privateKey, const char *pin) |
BOOL | vgids_process_apdu (vgidsContext *context, const BYTE *data, DWORD dataSize, BYTE **response, DWORD *responseSize) |
void | vgids_free (vgidsContext *context) |
Variables | |
static const BYTE | g_PKCS1_SHA1 [] |
static const BYTE | g_PKCS1_SHA224 [] |
static const BYTE | g_PKCS1_SHA256 [] |
static const BYTE | g_PKCS1_SHA384 [] |
static const BYTE | g_PKCS1_SHA512 [] |
static const BYTE | g_PKCS1_SHA512_224 [] |
static const BYTE | g_PKCS1_SHA512_256 [] |
static const BYTE | g_MsGidsAID [] |
static const BYTE | g_GidsAppFCP [] = { 0x62, 0x08, 0x82, 0x01, 0x38, 0x8C, 0x03, 0x03, 0x30, 0x30 } |
static const BYTE | g_GidsAppFCI [] |
static const BYTE | g_CardCFContents [] = { 0x00, 0x00, 0x01, 0x00, 0x04, 0x00 } |
static const BYTE | g_CardAppsContents [] = { 0x6d, 0x73, 0x63, 0x70, 0x00, 0x00, 0x00, 0x00 } |
#define CONTAINER_MAP_DEFAULT_CONTAINER 2 |
#define CONTAINER_MAP_VALID_CONTAINER 1 |
#define ISO_AID_MAX_SIZE 16 |
#define ISO_FID_MF 0x3F00 |
#define ISO_INS_GETDATA 0xCB |
#define ISO_INS_GETRESPONSE 0xC0 |
#define ISO_INS_MSE 0x22 |
#define ISO_INS_PSO 0x2A |
#define ISO_INS_SELECT 0xA4 |
#define ISO_INS_VERIFY 0x20 |
#define ISO_STATUS_AUTHMETHODBLOCKED 0x6983 |
#define ISO_STATUS_COMMANDNOTALLOWED 0x6900 |
#define ISO_STATUS_FILENOTFOUND 0x6A82 |
#define ISO_STATUS_INVALIDCOMMANDDATA 0x6A80 |
#define ISO_STATUS_INVALIDLC 0x6A87 |
#define ISO_STATUS_INVALIDP1P2 0x6A86 |
#define ISO_STATUS_MORE_DATA 0x6100 |
#define ISO_STATUS_REFERENCEDATANOTFOUND 0x6A88 |
#define ISO_STATUS_SECURITYSTATUSNOTSATISFIED 0x6982 |
#define ISO_STATUS_SUCCESS 0x9000 |
#define ISO_STATUS_VERIFYFAILED 0x6300 |
#define ISO_STATUS_WRONGLC 0x6700 |
#define MAX_CONTAINER_NAME_LEN 39 |
#define TAG CHANNELS_TAG("smartcard.vgids") |
WinPR: Windows Portable Runtime Virtual GIDS implementation
Copyright 2021 Martin Fleisz marti Copyright 2023 Armin Novak n.fl eisz@ thin cast. comanova Copyright 2021,2023 Thincast Technologies GmbH k@th incas t.co m
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
#define VGIDS_ALGID_RSA_1024 0x06 |
#define VGIDS_ALGID_RSA_2048 0x07 |
#define VGIDS_ALGID_RSA_3072 0x08 |
#define VGIDS_ALGID_RSA_4096 0x09 |
#define VGIDS_CARDID_SIZE 16 |
#define VGIDS_DEFAULT_KEY_REF 0x81 |
#define VGIDS_DEFAULT_RETRY_COUNTER 3 |
#define VGIDS_DO_CARDAPPS 0xDF21 |
#define VGIDS_DO_CARDCF 0xDF22 |
#define VGIDS_DO_CARDID 0xDF20 |
#define VGIDS_DO_CMAPFILE 0xDF23 |
#define VGIDS_DO_FILESYSTEMTABLE 0xDF1F |
#define VGIDS_DO_KEYMAP 0xDF20 |
#define VGIDS_DO_KXC00 0xDF24 |
#define VGIDS_EFID_CARDAPPS VGIDS_EFID_COMMON |
#define VGIDS_EFID_CARDCF VGIDS_EFID_COMMON |
#define VGIDS_EFID_CARDID 0xA012 |
#define VGIDS_EFID_CMAPFILE VGIDS_EFID_COMMON |
#define VGIDS_EFID_COMMON 0xA010 |
#define VGIDS_EFID_CURRENTDF 0x3FFF |
#define VGIDS_EFID_KXC00 VGIDS_EFID_COMMON |
#define VGIDS_EFID_MASTER 0xA000 |
#define VGIDS_KEY_TYPE_KEYEXCHANGE 0x9A |
#define VGIDS_KEY_TYPE_SIGNATURE 0x9C |
#define VGIDS_MAX_DIGEST_INFO 7 |
#define VGIDS_MAX_PIN_SIZE 127 |
#define VGIDS_SE_ALGOID_CT_PAD_OAEP 0x80 |
#define VGIDS_SE_ALGOID_CT_PAD_PKCS1 0x40 |
#define VGIDS_SE_ALGOID_CT_RSA_1024 0x06 |
#define VGIDS_SE_ALGOID_CT_RSA_2048 0x07 |
#define VGIDS_SE_ALGOID_CT_RSA_3072 0x08 |
#define VGIDS_SE_ALGOID_CT_RSA_4096 0x09 |
#define VGIDS_SE_ALGOID_DST_ECDSA_P192 0x0A |
#define VGIDS_SE_ALGOID_DST_ECDSA_P224 0x0B |
#define VGIDS_SE_ALGOID_DST_ECDSA_P256 0x0C |
#define VGIDS_SE_ALGOID_DST_ECDSA_P384 0x0D |
#define VGIDS_SE_ALGOID_DST_ECDSA_P512 0x0E |
#define VGIDS_SE_ALGOID_DST_PAD_PKCS1 0x40 |
#define VGIDS_SE_ALGOID_DST_RSA_1024 0x06 |
#define VGIDS_SE_ALGOID_DST_RSA_2048 0x07 |
#define VGIDS_SE_ALGOID_DST_RSA_3072 0x08 |
#define VGIDS_SE_ALGOID_DST_RSA_4096 0x09 |
#define VGIDS_SE_CRT_AUTH 0xA4 |
#define VGIDS_SE_CRT_CONF 0xB8 |
#define VGIDS_SE_CRT_SIGN 0xB6 |
|
static |
|
static |
|
static |
|
static |
|
static |
void vgids_free | ( | vgidsContext * | context | ) |
|
static |
|
static |
|
static |
BOOL vgids_init | ( | vgidsContext * | ctx, |
const char * | cert, | ||
const char * | privateKey, | ||
const char * | pin | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
vgidsContext* vgids_new | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
BOOL vgids_process_apdu | ( | vgidsContext * | context, |
const BYTE * | data, | ||
DWORD | dataSize, | ||
BYTE ** | response, | ||
DWORD * | responseSize | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |