Providing access to a smartcard within a remote session

Access to a redirected smart card can be provided to applications executing within a remote session. To enable this access, a smart card stub can be executed within the remote session and can function to intercept an application's API calls to access a smart card. A corresponding smart card proxy can also be executed within session 0 and can function to receive the intercepted API calls from the smart card stub. The smart card proxy can then execute the API calls. Because the smart card proxy is executing in session 0, the smart card resource manager service will not block access.

CROSS-REFERENCE TO RELATED APPLICATIONS

BACKGROUND

The present invention is generally directed to USB device redirection in a virtual desktop infrastructure (VDI) environment. USB device redirection generally refers to making a USB device that is connected to a client accessible within a virtual desktop as if the USB device had been physically connected to the virtual desktop. In other words, when USB device redirection is implemented, a user can connect a USB device to his or her client terminal and the USB device will function as if it had been connected to the server.

FIGS. 1 and 2and the following description will provide a general overview of how USB device redirection can be implemented in accordance with some embodiments of the present invention. InFIG. 1, a computing system100is depicted as including a number of client terminals102a-102n(referenced generally herein as client(s)102) in communication with a server104via a network106. Server104can be configured to support a remote session (e.g., a remote desktop session) wherein a user at a client102can remotely access applications and data at the server104from the client102. Such a connection may be established using any of several well-known techniques such as the Remote Desktop Protocol (RDP) and the Citrix® Independent Computing Architecture (ICA).

Client terminal102may represent a computer, a mobile phone (e.g., smart phone), a laptop computer, a thin client terminal, a personal digital assistant (PDA), a portable computing terminal, or a suitable terminal or device with a processor. Server104may represent a computer, a laptop computer, a computing terminal, a virtual machine (e.g., VMware® Virtual Machine), a desktop session (e.g., Microsoft Terminal Server), a published application (e.g., Microsoft Terminal Server) or a suitable terminal with a processor.

Client102may initiate a remote session with server104by sending a request for remote access and credentials (e.g., login name and password) to server104. If server104accepts the credentials from client102, then server104may establish a remote session, which allows a user at client102to access applications and data at server104. During the remote session, server104sends display data to client102over network106, which may include display data of a desktop and/or one or more applications running on server104. The desktop may include, for example, icons corresponding to different applications that can be launched on server104. The display data allows client102to locally display the desktop and/or applications running on server104.

During the remote session, client102may send user commands (e.g., inputted via a mouse or keyboard at client102) to server104over network106. Server104may process the user commands from client102similar to user commands received from an input device that is local to server104. For example, if the user commands include mouse movements, then server104may move a pointer on the desktop running on server104accordingly. When the display data of the desktop and/or application changes in response to the user commands, server104sends the updated display data to client102. Client102locally displays the updated display data so that the user at client102can view changes at server104in response to the user commands. Together, these aspects allow the user at client102to locally view and input commands to the desktop and/or application that is running remotely on server104. From the perspective of the client side, the desktop running on server104may represent a virtual desktop environment.

FIG. 2is a block diagram of a local device virtualization system200in accordance with embodiments of the present invention. System200may include client102in communication with server104over network106as illustrated inFIG. 1. Client102may include a proxy210, a stub driver220, and a bus driver230. Client102can be connected to a device240, as shown inFIG. 2. Server104may include an agent250and a virtual bus driver260.

In accordance with USB device redirection techniques, while device240is not locally or physically connected to server104and is remote to server104, device240appears to server104as if it is locally connected to server104, as discussed further below. Thus, device240appears to server104as a virtual device290.

By way of illustration and not limitation, device240may be any type of USB device including a machine-readable storage medium (e.g., flash storage device), a printer, a scanner, a camera, a facsimile machine, a phone, an audio device (e.g., a headset), a video device (e.g., a camera), a peripheral device, or other suitable device that can be connected to client102. Device240may be an external device (i.e., external to client102) or an internal device (i.e., internal to client102).

Bus driver230can be configured to allow the operating system and programs of client102to interact with device240. In one aspect, when device240is connected to client102(e.g., plugged into a port of client102), bus driver230may detect the presence of device240and read information regarding device240(“device information”) from device240. The device information may include features, characteristics and other information specific to device240such as a device descriptor (e.g., product ID, vendor ID and/or other information), a configuration descriptor, an interface descriptor, an endpoint descriptor and/or a string descriptor. Bus driver230may communicate with device240through a computer bus or other wired or wireless communications interface.

In accordance with USB device redirection techniques, device240may be accessed from server104as if the device were connected locally to server240. Device240may be accessed from server104when client102is connected to server104through a remote session running on server104. For example, device240may be accessible from the desktop running on server104(i.e., virtual desktop environment). To enable this, bus driver230may be configured to load stub driver220as the default driver for device240. Stub driver220may be configured to report the presence of device240to proxy210and to provide the device information (e.g., device descriptor) to proxy210. Proxy210may be configured to report the presence of device240, along with the device information, to agent250of server104over network106. Thus, stub driver220redirects device240to server104via proxy210.

Agent250may be configured to receive the report from proxy210that device240is connected to client102and the device information. Agent250may further be configured to associate with the report from proxy210one or more identifiers for client102and/or for a remote session through which client102is connected to server104, such as a session number or a session locally unique identifier (LUID). Agent250can provide notification of device240, along with the device information, to virtual bus driver260. Virtual bus driver260(which may be a TCX USB bus driver, or any other bus driver) may be configured to create and store in memory a record corresponding to device240, the record including at least part of the device information and session identifiers received from agent250. Virtual bus driver260may be configured to report to operating system170of server104that device240is connected and to provide the device information to the operating system. This allows the operating system of server104to recognize the presence of device240even though device240is connected to client102.

The operating system of server104may use the device information to find and load one or more appropriate device drivers for device240at server104. Each driver may have an associated device object (object(s)281a,281b, . . . ,281n, referred to generally as device object(s)281), as illustratively shown inFIG. 2. A device object281is a software implementation of a real device240or a virtualized (or conceptual) device290. Different device objects281layer over each other to provide the complete functionality. The different device objects281are associated with different device drivers (driver(s)282a,282b, . . .282n, referred to generally as device driver(s)282). In an example, a device240such as a USB flash drive may have associated device objects including objects corresponding to a USB driver, a storage driver, a volume manager driver, and a file system driver for the device. The device objects281corresponding to a same device240form a layered device stack280for device240. For example, for a USB device, a USB bus driver will create a device object281astating that a new device has been plugged in. Next, a plug-and-play (PNP) component of the operating system will search for and load the best driver for device240, which will create another device object281bthat is layered over the previous device object281a. The layering of device objects281will create device stack280.

Device objects281may be stored in a memory of the server104associated with virtual bus driver260. In particular, device objects281and resulting device stack280may be stored in random-access memory of server104. Different devices240/290can have device stacks having different device objects and different numbers of device objects. The device stack may be ordered, such that lower level device objects (corresponding to lower level device drivers) have lower numbers than higher level device objects (corresponding to higher level device drivers). The device stack may be traversed downwards by traversing the stack from higher level objects to lower level objects. For example, in the case of an illustrative device stack280corresponding to a USB flash drive, the ordered device stack may be traversed downwards from a high-level file system driver device object, to a volume manager driver device object, to a storage driver device object, to a USB driver device object, and finally to a low-level virtual bus driver device object. Different device stacks280can be layered over each other to provide the functionality of the devices240/290inside devices, like USB Headsets, or USB pen drives. A USB pen drive, for example, can create a USB device stack first, over which it can create a storage device stack, where each of the device stacks have two or more device objects.

Once one or more device object(s)281are loaded by operating system170of server104, each device object281can create a symbolic link (also referred to as a “device interface”) to device object281and associated device driver282. The symbolic link is used by applications running on server104to access device object281and device240/290. The symbolic link can be created by a call to a function such as IoCreateSymbolicLink( ) including such arguments as a name for the symbolic link, and a name of device object281or associated device240. In one example, for example, a symbolic link to a USB flash drive device240is created by a call from a device object281for device240to the function IoCreateSymbolicLink( ) including arguments “\\GLOBAL??\C:” (i.e., the name for the symbolic link) and “\Device\HarddiskVolume1” (i.e., a name of the device object).

The creation of a symbolic link results in an entry being created in an object manager namespace (OMN) of operating system170. The OMN stores information on symbolic links created for and used by operating system170, including symbolic links for devices240, virtualized devices290, and applications270running on server104.

As a result of the symbolic link creation process, a symbolic link to device240is enumerated in the OMN of server104. Once the presence of device240is reported to operating system170of server104, device240may be accessible from a remote session (and associated desktop) running on server104(i.e., virtual desktop environment). For example, device240may appear as an icon on the virtual desktop environment and/or may be accessed by applications running on server104.

An application270running on server104may access device240by sending a transaction request including the symbolic link for device240to operating system170. Operating system170may consult the Object Manager Namespace to retrieve an address or other identifier for the device itself240or for a device object281associated with device240. Using the retrieved address or identifier, operating system170forwards the transaction request for device240either directly, through a device object281of device stack280, and/or through virtual bus driver260. Virtual bus driver260may direct the transaction request to agent250, which sends the transaction request to proxy210over network106. Proxy210receives the transaction request from agent250, and directs the received transaction request to stub driver220. Stub driver220then directs the transaction request to device240through bus driver230.

Bus driver230receives the result of the transaction request from device240and sends the result of the transaction request to stub driver220. Stub driver220directs the result of the transaction request to proxy210, which sends the result of the transaction request to agent250over network106. Agent250directs the result of the transaction request to virtual bus driver260. Virtual bus driver260then directs the result of the transaction request to application270either directly or through a device object281of device stack280.

Thus, virtual bus driver260may receive transaction requests for device240from application270and send results of the transaction requests back to application270(either directly or through a device object281of device stack280). As such, application270may interact with virtual bus driver260in the same way as with a bus driver for a device that is connected locally to server104. Virtual bus driver260may hide the fact that it sends transaction requests to agent250and receives the results of the transaction requests from agent250instead of a device that is connected locally to server104. As a result, device240connected to client102may appear to application270as if the physical device240is connected locally to server104.

Smart card readers are a type of USB device that can be redirected in much the same manner as described above. However, due to security concerns, the Windows operating system places limits on how an application can access a smart card that has been inserted into a smart card reader. In particular, the Windows operating system does not allow an application executing within a remote session to access a smart card unless the smart card is mapped from the remote session. Using the above described redirection techniques, a redirected smart card will appear as if it was locally connected, and therefore it will not be accessible within the remote session.

FIG. 3Aprovides an example of how Windows applies these limits using the same general architecture of server104as described above. In this example, a smart card340is connected directly to server104(i.e., not over a remote session). For ease of illustration, smart card340can generally represent a smart card reader alone or a smart card reader and a smart card that has been inserted into the reader.

As is typical, operating system170will cause appropriate drivers to be loaded for smart card340as represented by smart card driver stack380. An application370can therefore access smart card340via the appropriate interfaces of operating system170. In the Windows operating system, an application can access a smart card via a cryptographic service provider (or CSP) and the WinSCard API. This CSP may be a vendor-specific CSP or a Windows-provided CSP (Basecsp.dll) which works in tandem with a vendor-provided smart card mini-driver. CSP170ais intended to represent either of these scenarios.

Via CSP170aand WinSCard API170b, application370can invoke functionality of the Smart Card Resource Manager service (or simply “resource manager”)170c. Resource manager170cthen interfaces with the smart card driver(s) for any smart card connected to server104whether physically or virtually.

Resource manager170cis the component of the Windows operating system that is configured to block access to a smart card from any application that is running in a remote session thus making a redirected smart card inaccessible within a remote session. The exact manner in which resource manager170cblocks access is beyond the scope of this discussion. Suffice it to say that the Windows smart card subsystem will only list mapped smart cards to applications executing within a remote session such that the smart cards, including redirected smart cards, will not be visible to such applications. For example,FIG. 3Billustrates a scenario where smart card340is connected to client102and redirected to server104via a remote session such that virtual smart card390appears on server104. To resource manager170c, smart card390will appear as a locally connected device.

In this scenario, the user may run application370for the purpose of accessing smart card340. However, because application370is executing within a remote session, resource manager170cwill block access to smart card340(since it believes smart card370is locally connected). In short, Windows is configured to prevent a smart card from being accessed within a remote session whether or not the smart card is locally connected or redirected over a remote session.

To enable a smart card to be accessed within a remote session, driver mapping techniques have been created.FIG. 3Cgenerally illustrates how this driver mapping can be implemented. To enable smart card access within a remote session, a driver mapping component385can be executed on server104and smart card driver stack380can be installed on client102. Driver mapping component385can generally represent any of the possible ways in which a driver can be mapped as is known in the art. For simplicity, it can be assumed that driver mapping component385intercepts smart card API calls that are directed towards smart card driver stack380installed on server104and routes these API calls to proxy210(or another component) via RPC. In essence, this bypasses the mechanisms in the Windows Smart Card Subsystem (i.e., resource manager170c) that would otherwise block the API calls due to application370being executed within a remote session. Proxy210can then invoke these API calls. Responses from smart card340can be returned in a similar manner.

Although this driver mapping technique works, it is not desirable or possible in many situations. For example, client102may not be compatible with the smart card driver(s) that will need to be loaded into smart card driver stack380in order to handle some or all of the mapped API calls. Specifically, a Linux operating system is employed on many thin clients and Windows-based smart card drivers are incompatible with Linux. Additionally, very few smart card providers have developed drivers that can be employed for driver mapping on non-Windows clients.

Further, to accommodate mismatches between the versions of the client operating system and the server operating system, current driver mapping solutions do not map all smart card APIs. For example, many smart card APIs that are available in Windows Server 2016 or Windows 10 (e.g., the SCardGetReaderDeviceInstanceId function) are not mapped and will therefore fail if invoked inside a remote session.

Finally, installing the smart card drivers on the client prevents the client from being “lightweight.” For example, many entities create computing environments in which their employees use thin or zero clients. It is oftentimes desirable to minimize the components on these clients to reduce cost. Requiring the installation of the smart card drivers in turn increases the hardware requirements for the client as well as requires additional management.

BRIEF SUMMARY

The present invention extends to methods, systems, and computer program products for enabling a redirected smart card to be accessed within a remote session. This can be accomplished without implementing driver mapping such that the smart card drivers do not need to be installed on the client. This also allows the full set of APIs to be available when the smart card is redirected.

To enable access to a smart card within a remote session, a smart card stub can be executed within the remote session and can function to intercept an application's API calls to access a smart card. A corresponding smart card proxy can also be executed within session 0 and can function to receive the intercepted API calls from the smart card stub. The smart card proxy can then execute the API calls. Because the smart card proxy is executing in session 0, the smart card resource manager service will not block access. When the smart card proxy receives a response, it can pass the response back to the smart card stub which in turn will return it to the calling application.

This same technique can be employed to enable a smart card to be accessed from a nested session even without redirecting the smart card to the nested session. In this nested session scenario, the smart card stub can be executed within the nested session and can be configured to pass intercepted API calls to the smart card proxy that is executing within session 0 on the client-side of the nested session. The smart card proxy can then handle the API call in the same manner as when the API call is received from a smart card stub executing on the same system.

In some embodiments, the smart card stub can be configured to perform a variable ATR buffering technique to eliminate the need to parse an ATR string to identify its length prior to passing an intercepted API call to the smart card proxy. The variable ATR buffering technique can include copying the ATR string into a fixed-length buffer regardless of the size of the ATR string. In this way, the smart card stub will always be able to specify the same length for the ATR string when passing an API call to the smart card proxy.

In one embodiment, the present invention is implemented as a method, performed by a server in a virtual desktop infrastructure, for enabling smart card access from within a remote session. A remote session can be established between a client and the server. Establishing the remote session can include redirecting a smart card that is connected to the client to the server. A smart card stub that executes within the remote session can intercept an API call for accessing the redirected smart card that was made by an application executing with the remote session. The smart card stub can pass the intercepted API call to a smart card proxy that is executing on the server within session 0. The smart card proxy can execute the API call to access the redirected smart card.

In another embodiment, the present invention is implemented as a method, performed by a server in a virtual desktop infrastructure, for enabling smart card access from within a remote session. As part of establishing a remote session for a client that has remotely connected to the server, a smart card stub can be loaded in the remote session and a smart card proxy can be loaded in session 0. Loading the smart card stub can include hooking operating-system-provided API calls for accessing smart cards. The smart card stub can intercept an API call for accessing the redirected smart card that was made by an application executing with the remote session. The smart card stub can pass the API call to the smart card proxy using a remote procedure call. The smart card proxy can then execute the API call to access the redirected smart card.

In another embodiment, the present invention is implemented as a virtual desktop infrastructure environment that includes: an agent that executes on a server and is configured to establish remote sessions with clients; a virtual USB bus driver that interfaces with the agent to redirect smart cards from the clients to the server; a smart card stub that is loaded in each remote session and is configured to intercept API calls to access the redirected smart cards; and a smart card proxy that is loaded in session 0 and is configured to receive the intercepted API calls from the smart card stub and to invoke the API calls

DETAILED DESCRIPTION

FIG. 4illustrates an example of the server-side architecture that can be employed to implement embodiments of the present invention. As shown, this server-side architecture includes each of the components of the Windows Smart Card Subsystem as addressed above, namely, CSP170a, WinSCard API170b, and resource manager170c. A number of applications410a-410care shown as employing either the Windows-provided base CSP or a vendor-specific CSP to interface with WinSCard API170b. As described above, WinSCard API170bprovides the functions for communicating smart card access requests to resource manager170cwhich will then pass the requests to the appropriate driver stack for the targeted smart card.FIG. 4represents that various smart cards are connected to server104including smart cards390,490a, and490b. Smart cards490aand490bcould represent smart cards that are either redirected or directly connected to server104. Even though the typical scenario would involve redirecting a smart card over a remote session and then accessing the smart card from within that same remote session, the techniques of the present invention could equally be employed to access a smart card that is directly connected to server104from within a remote session or to access a smart card that is redirected over a remote session from within a different remote session.

FIG. 4shows that resource manager170cis a trusted service that executes in session 0. As described in the background, resource manager170cis configured to prevent applications410a-410cfrom accessing a smart card if these applications are executing within a remote session. Therefore, if a user establishes a remote session with server104and executes any of applications410a-410cwithin the remote session for the purpose of accessing a redirected smart card, resource manager170cwill block the access.

To address this issue, the present invention employs a smart card stub401and a smart card proxy402in order to, in essence, cause resource manager170cto believe that applications410a-410care executing within session 0 rather than within a remote session. Smart card stub401comprises an executable component that is configured to intercept smart card API calls. For example, smart card stub401could be a DLL that hooks itself to each API call in WinSCard API170bthat can be employed to direct a request to a smart card. These API calls can include the SCardConnect function, the SCardBeginTransaction function, the SCardTransmit function, and the SCardGetReaderDeviceInstanceId function to name just a few. Accordingly, whenever any of the hooked functions are called, smart card stub401will be invoked to handle the call.

For any API call that it intercepts, smart card stub401can redirect the API call to smart card proxy402. For example, smart card stub401and smart card proxy402can communicate via remote procedure calls (RPC). In particular, whenever smart card stub401intercepts a smart card API call, it can employ an RPC routine to cause smart card proxy402to execute the intercepted call. Therefore, from the perspective of resource manager170c, the call will be viewed as having been made by smart card proxy402rather than one of applications410a-410c. Because smart card proxy402executes in session 0, resource manager170cwill not block the call but will instead direct it to the appropriate smart card. Once the call returns, smart card proxy402will use RPC techniques to return the response to smart card stub401and then onto the calling application.

FIG. 5represents the client/server architecture that can be employed to enable a redirected smart card to be accessed from within a remote session. As was described in the background, when a smart card is connected to a client that has established a remote session with a server, the virtual desktop infrastructure can redirect the smart card to the server to cause the smart card to appear as if it were physically connected to the server. In this scenario, the server will create a remote (or user) session in which any applications accessed by the client will be executed.

FIG. 5illustrates that a smart card application has been invoked by the client and is therefore running in a remote session. The smart card application is configured to use a CSP and the WinSCard DLL for purposes of making smart card API calls. In accordance with the techniques of the present invention, smart card stub401can also be loaded in the remote session in a manner that allows it to intercept the smart card application's smart card API calls.

When smart card stub401intercepts a smart card API call, it will use RPC to pass the API call to smart card proxy402which is executing in session 0. Smart card proxy402will then invoke the API call causing resource manager170cto believe that the call has originated within session 0. Resource manager170cwill perform its processing to cause the proper communications to be delivered to smart card driver stack380(e.g., causing suitable IRPs/URBs to be routed down to smart card driver stack380). After passing through smart card driver stack380, virtual USB bus driver260will receive the communications and can route them to proxy210via agent250. Proxy210can then deliver the communications to the smart card reader and/or smart card connected to the client. Any response generated by the smart card reader and/or smart card will then be routed back in a reverse manner.

In this way, any application that is executed in a remote session will be able to access a smart card including a smart card that is redirected from the client that established the remote session. A user will therefore be able to change a password or certificate of a smart card (or perform any other provided function) from a remote session without needing to employ driver mapping techniques.

The technique of employing a stub in the remote session and a proxy in session 0 enables this access without requiring any specific drivers to be loaded on the client. For example, as shown inFIG. 5, smart card driver stack380does not need to be loaded on the client to enable access to the redirected smart card from within the remote session. Accordingly, a thin client can remain lightweight even while allowing access to a redirected smart card. Also, because the Windows drivers do not need to be loaded on the client, the present invention can be implemented regardless of the client's operating system.

This technique also provides the advantage of being agnostic to the remoting protocol used to establish the remote session. For example, proxy210and agent250could employ RDP, ICA or any other remoting protocol to communicate without needing to alter the technique for the particular remoting protocol. The technique is also transparent to the calling applications. In particular, because smart card stub401intercepts calls to the standard WinSCard functions, applications can call those functions (including the latest non-mapped functions) without knowledge of the underlying technique.

In some embodiments of the present invention, the above described technique can be employed to allow a redirected smart card to be accessed from within a nested session. A nested session is a remote session that is established within a remote session. For example, a user of a client may establish a first remote session with a first server and may then establish a second remote session with a second server from within the first remote session. With reference toFIG. 5, a nested session could be created by executing VDI software within the remote session to establish a remote desktop or remote application connection with another server.

FIG. 6is based onFIG. 5and illustrates an example scenario in which the user of the client creates a nested session. For ease of illustration, the client to which the smart card reader and card are connected, is not shown inFIG. 6. However, in these nested session embodiments, agent250would communicate with proxy210in the same manner as described above including to cause the smart card reader and card to be redirected to server104.

As indicated, the user has interacted with appropriate components in the remote session on server104to cause a remote session to be created on server604. Because this remote session on server604is created from the remote session on server104, it is a nested session. Although not shown, server604would also include a session 0 within which resource manager170cwould execute for the purpose of managing access to smart cards connected to server604.

In this situation, the same techniques described above can be employed to allow an application executing within the nested session to access the smart card reader and/or card that are physically connected to the client. Additionally, this access can be enabled from within the nested session without redirecting the smart card to server604. Specifically, smart card stub401can be loaded in the nested session and can function in the same manner as described above to intercept API calls made by a smart card application executing within the nested session.

In the same manner as described above, smart card stub401executing within the nested session can employ RPC to cause smart card proxy402executing within session 0 on server104to invoke the call. Smart card proxy402can then return the response to smart card proxy401in the nested session. Due to the use of RPC, the smart card does not need to be redirected to server604. In particular, because the API calls will be passed to smart card proxy402on server104, smart card driver stack380on server104can be employed to handle the calls.

To enable the smart card stub within the nested session to pass API calls to the smart card proxy, the VDI infrastructure can be configured to identify when a remote session is a nested session. For example, although not shown, server104would include a proxy and server604would include an agent. As part of establishing a nested remote session, the proxy on server104can inform the agent on server604that the remote session is a nested session and can provide the information necessary for communicating with smart card proxy402via RPC (e.g., connection information for routing the RPC communications over a network and information identifying the availability of any smart card on server104). Then, as part of launching the smart card stub within the nested session, the agent can provide this information to the smart card stub to allow the smart card stub to generate appropriate RPC communications when it subsequently intercepts smart card API calls.

Many smart cards are configured to output an Answer To Reset (ATR) following an electrical reset of the card's chip by a card reader. This ATR conveys information about the communication parameters proposed by the card and the card's nature and state. The PC/SC specification (which governs smart card integration in computing environments) requires that smart cards be identifiable using attributes such as the ATR and device name. Therefore, the ATR is unique for each smart card. However, the ATR of a smart card is not constant. An application must know a card's ATR in order to communicate with it.

Various API calls exist that allow an application to search a smart card database using an ATR string. These API calls can receive an ATR string as input and can return a list of smart cards that match the ATR string. As is known in the art, to make an RPC to pass these API calls, it is required to identify the length of the ATR string. Microsoft has currently created a solution for parsing an ATR string to identify its length (e.g., for use in the driver mapping architecture shown inFIG. 3C). However, this solution is dependent on current specifications (or more specifically, on the current ATR string format) and therefore must be updated whenever the specifications change. For this reason, Microsoft does not support mapping of API calls that require ATR parsing. For example, the SCardListCards function is not redirected when called from a remote session. In contrast, this function will generate results from the remote computer (e.g., server104) rather than from the local computer (e.g., client102). The results of calling SCardListCards from within a remote session will therefore not include a redirected smart card.

Because smart card stub401employs RPC to route these API calls to smart card proxy402, it is also necessary that smart card stub401identify the length of the ATR string. In accordance with embodiments of the present invention, smart card stub401can be configured to implement a variable ATR buffering technique that does not require parsing the ATR string and will therefore enable applications executing in a remote session to access and list redirected smart cards.

API calls that employ an ATR string as input require that the address of the ATR string be passed as input. For example, the pbAtr input parameter of the SCardListCards function receives the address where the ATR string is stored. In order to pass this function via RPC, it is necessary to specify the length of the ATR string as part of the RPC. As mentioned above, the prior art driver mapping techniques employ a parsing algorithm to identity this length. The parsing algorithm will likely need to be updated any time the specifications change due to new/different formatting of the ATR string.

To eliminate this need to parse the ATR string, smart card stub401can perform the variable ATR buffering technique that is illustrated inFIG. 7. This variable ATR buffering process can typically be performed after an ATR string has been received from a smart card (e.g., in response to the smart card being reset) such that the ATR string can be used as an input when an application calls a smart card API function.

This process commences in response to smart card stub401intercepting an API call that includes an ATR string. As indicated above, smart card stub401will need to specify the length of the ATR string in order to employ an RPC. Rather than parsing the ATR string to identify the actual length, smart card stub401can allocate a buffer having a size corresponding to the maximum size of an ATR string. Currently the governing specifications define this maximum size as 36 bytes. This buffer will therefore be large enough to store any valid ATR string.

Once the buffer is allocated, smart card stub401can copy the ATR string from the intercepted API call into the buffer (e.g., using the memcpy function). This copy will succeed only if the ATR string is the same size as the buffer, i.e., only if the ATR string has the maximum size. In particular, the memcpy function requires identifying the number of bytes to copy from a source address to a destination address. Smart card stub401can specify the maximum ATR string size as the number of bytes to copy. Therefore, if the ATR string is the maximum size, the memcpy function will succeed. However, if the ATR string is less than the maximum size, the memcpy function will attempt to copy bytes beyond the ATR string boundary thereby raising a structured exception. For example, if the ATR string is 24 bytes and the count parameter of the memcpy function is 36, the 24 byte ATR string and the 12 bytes of data stored after the ATR string will be copied into the buffer.

By copying the ATR string into a buffer of maximum size, smart card stub401can consistently specify the length of the ATR string for RPC purposes as the maximum ATR string size (e.g., 36 bytes) thereby eliminating the need for smart card stub401to parse the ATR string prior to invoking the RPC. Smart card stub401can then pass the buffer containing the ATR string to smart card proxy402via RPC. Even though the buffer containing the ATR string may also include irrelevant data at the end of the buffer, the operating system will still be able to correctly parse the ATR string when handling the API call. More particularly, since the operating system's parsing function will know the format of an ATR string, it will therefore be able to identify where the ATR string ends and will ignore any extra bytes that may be present in the buffer.

FIG. 8provides a flowchart of an example method800for enabling smart card access from within a remote session. Method800can be implemented by server104or any computing device that can accept remote connections.

Method800includes an act801of establishing a remote session between a client and the server, including redirecting a smart card that is connected to the client to the server. For example, client102can establish a remote session with server104and can redirect smart card340over the remote session.

Method800includes an act802of intercepting, by a smart card stub that executes within the remote session, an API call for accessing the redirected smart card that was made by an application executing with the remote session. For example, smart card stub401can intercept a smart card API call.

Method800includes an act803of passing, by the smart card stub, the intercepted API call to a smart card proxy that is executing on the server within session 0. For example, smart card stub401can pass the intercepted API call to smart card proxy402.

Method800includes an act804of executing, by the smart card proxy, the API call to access the redirected smart card. For example smart card proxy402can execute an API call passed to it by smart card stub401so that resource manager170cwill allow the API call.