这是飞天的最新一款智能卡产品,前短时间抽时间研究了一下,整体感觉还不错,实现了clr中有关文件操作(有些函数好像有些问题)、加密算法等指令。
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
由于我们这边的项目组开发的就是MF3.0的文件系统,所以对它们这个这么小的东东有CPU、有操作系统,支持clr,并且支持文件系统很感兴趣。
它的文件系统是FAT16(MF实现的是FAT32,这就要求存储空间至少有32.52M),通过PC上的一个程序可以实现上下传文件。此外该系统最大的特点就是可以执行.net程序。
下面是简单的程序,一个是运行在智能卡上(server),一个运行在普通PC上。
//服务端程序,需要用上面的工具(load file)把编译好的程序上传到智能卡上,然后在设置运行即可。
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using SmartCard.Runtime.Remoting.Channels.APDU;
namespace MyCompany.MyOnCardApp
{
///< Abstract >
/// MyServer Abstract .
///</ Abstract >
public class MyServer
{
///< Abstract >
///URI of remote object to be exposed
///</ Abstract >
private const string REMOTE_OBJECT_URI = "MyService.uri";
///< Abstract >
///Register Card Service
///</ Abstract >
///<returns></returns>
public static int Main()
{
//Register communication channel for server to start listening
ChannelServices.RegisterChannel(new APDUServerChannel());
//Register application as a service
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService), REMOTE_OBJECT_URI, WellKnownObjectMode.Singleton);
return 0;
}
}
}
//客户端程序,在PC机上运行,可以远程执行服务端上的函数有点DCOM的感觉。
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using SmartCard.Runtime.Remoting.Channels.APDU;
using System.Text;
using MyCompany.MyOnCardApp;
// Make sure the stub of the server application bas been added as reference or its interface has been declared
// stub file is automatically generated in [Server Project Output]/Stub when compiling server application
namespace MyCompany.MyClientApp
{
public class MyClient
{
private const string URL = "apdu://selfdiscover/MyService.uri";
public static void Main()
{
// Create and register a communication channel
APDUClientChannel channel = new APDUClientChannel();
ChannelServices.RegisterChannel(channel);
// Get reference to remote object
MyService service = (MyService)Activator.GetObject(typeof(MyService), URL);
// Call remote method
service.FileOperation();
// Unregister communication channel
ChannelServices.UnregisterChannel(channel);
channel.Dispose();
}
}
}