这是飞天的最新一款智能卡产品,前短时间抽时间研究了一下,整体感觉还不错,实现了clr中有关文件操作(有些函数好像有些问题)、加密算法等指令。
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="图片_x0020_0" style="VISIBILITY: visible; WIDTH: 319.8pt; HEIGHT: 214.2pt; mso-wrap-style: square" alt="feitian002.jpg" type="#_x0000_t75" o:spid="_x0000_i1027"><imagedata o:title="feitian002" src="file:///D:%5CUsers%5Cv-hongfl%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image001.jpg"></imagedata></shape>
<shape id="图片_x0020_1" style="VISIBILITY: visible; WIDTH: 415.2pt; HEIGHT: 320.4pt; mso-wrap-style: square" alt="feitian001.jpg" type="#_x0000_t75" o:spid="_x0000_i1026"><imagedata o:title="feitian001" src="file:///D:%5CUsers%5Cv-hongfl%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image003.jpg"><font face="Calibri" color="#000000" size="3"></font></imagedata></shape>
由于我们这边的项目组开发的就是MF3.0的文件系统,所以对它们这个这么小的东东有CPU、有操作系统,支持clr,并且支持文件系统很感兴趣。
它的文件系统是FAT16(MF实现的是FAT32,这就要求存储空间至少有32.52M),通过PC上的一个程序可以实现上下传文件。此外该系统最大的特点就是可以执行.net程序。
<shape id="图片_x0020_2" style="VISIBILITY: visible; WIDTH: 415.2pt; HEIGHT: 310.2pt; mso-wrap-style: square" alt="feitian003.jpg" type="#_x0000_t75" o:spid="_x0000_i1025"><imagedata o:title="feitian003" src="file:///D:%5CUsers%5Cv-hongfl%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image005.jpg"><font color="#000000" size="3"></font></imagedata></shape>
下面是简单的程序,一个是运行在智能卡上(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();
}
}
}