Coverage Report

Created: 2025-07-01 06:46

/src/FreeRDP/client/common/smartcard_cli.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 * Smartcard client functions
4
 *
5
 * Copyright 2021 David Fort <contact@hardening-consulting.com>
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
20
#include <winpr/assert.h>
21
22
#include <freerdp/client/utils/smartcard_cli.h>
23
#include <freerdp/utils/smartcardlogon.h>
24
25
BOOL freerdp_smartcard_list(const rdpSettings* settings)
26
0
{
27
0
  SmartcardCertInfo** certs = NULL;
28
0
  size_t count = 0;
29
30
0
  if (!smartcard_enumerateCerts(settings, &certs, &count, FALSE))
31
0
    return FALSE;
32
33
0
  printf("smartcard reader detected, listing %" PRIuz " certificates:\n", count);
34
0
  for (size_t i = 0; i < count; i++)
35
0
  {
36
0
    const SmartcardCertInfo* info = certs[i];
37
0
    char asciiStr[256] = { 0 };
38
39
0
    WINPR_ASSERT(info);
40
41
0
    printf("%" PRIuz ": %s\n", i, info->subject);
42
43
0
    if (ConvertWCharToUtf8(info->csp, asciiStr, ARRAYSIZE(asciiStr)))
44
0
      printf("\t* CSP: %s\n", asciiStr);
45
46
0
    if (ConvertWCharToUtf8(info->reader, asciiStr, ARRAYSIZE(asciiStr)))
47
0
      printf("\t* reader: %s\n", asciiStr);
48
0
#ifndef _WIN32
49
0
    printf("\t* slotId: %" PRIu32 "\n", info->slotId);
50
0
    printf("\t* pkinitArgs: %s\n", info->pkinitArgs);
51
0
#endif
52
0
    if (ConvertWCharToUtf8(info->containerName, asciiStr, ARRAYSIZE(asciiStr)))
53
0
      printf("\t* containerName: %s\n", asciiStr);
54
0
    if (info->upn)
55
0
      printf("\t* UPN: %s\n", info->upn);
56
0
  }
57
0
  smartcardCertList_Free(certs, count);
58
59
0
  return TRUE;
60
0
}