function mToken(obj){ this.obj = obj; this.SAR_OK = 0; this.SAR_FALSE = 1; //分组加密算法标识 this.SGD_SM1_ECB = 0x00000101; this.SGD_SM1_CBC = 0x00000102; this.SGD_SM1_CFB = 0x00000104; this.SGD_SM1_OFB = 0x00000108; this.SGD_SM1_MAC = 0x00000110; this.SGD_SSF33_ECB = 0x00000201; this.SGD_SSF33_CBC = 0x00000202; this.SGD_SSF33_CFB = 0x00000204; this.SGD_SSF33_OFB = 0x00000208; this.SGD_SSF33_MAC = 0x00000210; this.SGD_SM4_ECB = 0x00000401; this.SGD_SM4_CBC = 0x00000402; this.SGD_SM4_CFB = 0x00000404; this.SGD_SM4_OFB = 0x00000408; this.SGD_SM4_MAC = 0x00000410; //非对称密码算法标识 this.SGD_RSA = 0x00010000; this.SGD_SM2_1 = 0x00020100; //ECC签名 this.SGD_SM2_2 = 0x00020200; //ECC密钥交换 this.SGD_SM2_3 = 0x00020400; //ECC加密 //密码杂凑算法标识 this.SGD_SM3 = 0x00000001; this.SGD_SHA1 = 0x00000002; this.SGD_SHA256 = 0x00000004; this.SGD_RAW = 0x00000080; this.SGD_MD5 = 0x00000081; this.SGD_SHA384 = 0x00000082; this.SGD_SHA512 = 0x00000083; this.SGD_CERT_VERSION = 0x00000001; this.SGD_CERT_SERIAL = 0x00000002; this.SGD_CERT_ISSUE = 0x00000005; this.SGD_CERT_VALID_TIME = 0x00000006; this.SGD_CERT_SUBJECT = 0x00000007; this.SGD_CERT_DER_PUBLIC_KEY = 0x00000008; this.SGD_CERT_DER_EXTENSIONS = 0x00000009; this.SGD_CERT_ISSUER_CN = 0x00000021; this.SGD_CERT_ISSUER_O = 0x00000022; this.SGD_CERT_ISSUER_OU = 0x00000023; this.SGD_CERT_SUBJECT_CN = 0x00000031; this.SGD_CERT_SUBJECT_O = 0x00000032; this.SGD_CERT_SUBJECT_OU = 0x00000033; this.SGD_CERT_SUBJECT_EMALL = 0x00000034; this.SGD_DEVICE_SORT = 0x00000201; this.SGD_DEVICE_TYPE = 0x00000202; this.SGD_DEVICE_NAME = 0x00000203; this.SGD_DEVICE_MANUFACTURER = 0x00000204; this.SGD_DEVICE_HARDWARE_VERSION = 0x00000205; this.SGD_DEVICE_SOFTWARE_VERSION = 0x00000206; this.SGD_DEVICE_STANDARD_VERSION = 0x00000207; this.SGD_DEVICE_SERIAL_NUMBER = 0x00000208; this.SGD_DEVICE_SUPPORT_SYM_ALG = 0x00000209; this.SGD_DEVICE_SUPPORT_ASYM_ALG = 0x0000020A; this.SGD_DEVICE_SUPPORT_HASH_ALG = 0x0000020B; this.SGD_DEVICE_SUPPORT_STORANGE_SPACE = 0x0000020C; this.SGD_DEVICE_SUPPORT_FREE_SAPCE = 0x0000020D; this.SGD_DEVICE_RUNTIME = 0x0000020E; this.SGD_DEVICE_USED_TIMES = 0x0000020F; this.SGD_DEVICE_LOCATION = 0x00000210; this.SGD_DEVICE_DESCRIPTION = 0x00000211; this.SGD_DEVICE_MANAGER_INFO = 0x00000212; this.SGD_DEVICE_MAX_DATA_SIZE = 0x00000213; this.TRUE = 1; this.FALSE = 0; this.GM3000 = 1; this.K7 = 2; this.K5 = 3; var g_mTokenPlugin = null; var g_deviceNames = null; this.SOF_GetLastError = function() { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_GetLastError(); } this.SOF_LoadLibrary = function(type) { var ret; g_mTokenPlugin = document.getElementById(obj); if(type == this.GM3000) { ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_gm3000.dll", "libgm3000.1.0.so", "libgm3000.1.0.dylib"); } else if(type == this.K7) { ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_k7.dll", "libk7.1.0.so", "libk7.1.0.dylib"); } else if(type == this.K5) { ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_k5.dll", "libk5.1.0.so", "libk5.1.0.dylib"); } else { return -1; } if(ret != 0) { g_mTokenPlugin = null; return -2; } return this.SAR_OK; }; this.SOF_EnumDevice = function() { if(g_mTokenPlugin == null) { return null; } var array = g_mTokenPlugin.SOF_EnumDevice(); if(array == null || array.length <= 0) { return null; } return array.split("||"); }; this.SOF_GetVersion = function() { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_GetVersion(); }; this.SOF_GetDeviceInstance = function(DeviceName, ApplicationName) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_GetDeviceInstance(DeviceName, ApplicationName); }; this.SOF_GetUserList = function() { if(g_mTokenPlugin == null) { return null; } var array = g_mTokenPlugin.SOF_GetUserList(); if(array == null || array.length <= 0) return null; var list = new Array(); var user = array.split("&&&"); var length = user.length; for(var i = 0; i < length; i++) { list[i] = user[i].split("||"); } return list; }; this.SOF_ExportUserCert = function(ContainerName, KeySpec) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_ExportUserCert(ContainerName, KeySpec); }; this.SOF_GetDeviceInfo = function(Type) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_GetDeviceInfo(Type); }; this.SOF_GetCertInfo = function(Base64EncodeCert, Type) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_GetCertInfo(Base64EncodeCert, Type); }; this.SOF_Login = function(PassWd) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_Login(PassWd); }; this.SOF_LogOut = function() { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_LogOut(); }; this.SOF_GetPinRetryCount = function() { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_GetPinRetryCount(); }; this.SOF_ChangePassWd = function(OldPassWd, NewPassWd) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_ChangePassWd(OldPassWd, NewPassWd); }; this.SOF_SetDigestMethod = function(DigestMethod) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_SetDigestMethod(DigestMethod); }; this.SOF_SetUserID = function(UserID) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_SetUserID(UserID); }; this.SOF_SetEncryptMethodAndIV = function(EncryptMethod, EncryptIV) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_SetEncryptMethodAndIV(EncryptMethod, EncryptIV); }; this.SOF_DigestData = function(ContainerName, nData, InDataLen) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_DigestData(ContainerName, nData, InDataLen); }; this.SOF_SignData = function(ContainerName, ulKeySpec, InData, InDataLen) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_SignData(ContainerName, ulKeySpec, InData, InDataLen); }; this.SOF_SignDataEx = function(ContainerName, ulKeySpec, InData, InDataLen) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_SignDataEx(ContainerName, ulKeySpec, InData, InDataLen); }; this.SOF_VerifySignedData = function(Base64EncodeCert, InData, SignedValue) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_VerifySignedDataEx(Base64EncodeCert, InData, SignedValue); }; this.SOF_VerifySignedDataEx = function(Base64EncodeCert, InData, SignedValue) { if(g_mTokenPlugin == null) { return -1; } return g_mTokenPlugin.SOF_VerifySignedDataEx(Base64EncodeCert, InData, SignedValue); }; this.SOF_EncryptData = function(Base64EncodeCert, InData, InDataLen) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_EncryptData(Base64EncodeCert, InData, InDataLen); }; this.SOF_DecryptData = function(ContainerName, ulKeySpec, InData) { if(g_mTokenPlugin == null) { return null; } return g_mTokenPlugin.SOF_DecryptData(ContainerName, ulKeySpec, InData); }; }