提交解析私钥
This commit is contained in:
parent
a4648fcb26
commit
daae04f327
@ -17,12 +17,14 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
String? authUserID; // 钥匙授权人ID
|
String? authUserID; // 钥匙授权人ID
|
||||||
int? nowTime;
|
int? nowTime;
|
||||||
int? needAuthor;
|
int? needAuthor;
|
||||||
|
List<int>? publicKeyData;
|
||||||
GetPrivateKeyCommand({
|
GetPrivateKeyCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.authUserID,
|
this.authUserID,
|
||||||
this.nowTime,
|
this.nowTime,
|
||||||
this.needAuthor,
|
this.needAuthor,
|
||||||
|
this.publicKeyData
|
||||||
}) : super(CommandType.getLockPrivateKey);
|
}) : super(CommandType.getLockPrivateKey);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -86,12 +88,15 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
authCodeData.add((d1 & 0xff00) >> 8);
|
authCodeData.add((d1 & 0xff00) >> 8);
|
||||||
authCodeData.add((d1 & 0xff));
|
authCodeData.add((d1 & 0xff));
|
||||||
|
|
||||||
var pubKey = Storage.getData("bluePublicKey");
|
// String pubKey = "";
|
||||||
|
// Storage.getData("bluePublicKey").then((res) => {
|
||||||
|
// pubKey = res
|
||||||
|
// });
|
||||||
// var pubKey = "ovOvAHuL5+dBCw7L3Qt7IQ==";
|
// var pubKey = "ovOvAHuL5+dBCw7L3Qt7IQ==";
|
||||||
print("pubKey:$pubKey");
|
// print("pubKey:$pubKey");
|
||||||
List<int> pubKeyData = base64.decode(pubKey.toString());
|
// List<int> pubKeyData = base64.decode(pubKey.toString());
|
||||||
print("pubKeyData:$pubKeyData");
|
// print("pubKeyData:$pubKeyData");
|
||||||
authCodeData.addAll(pubKeyData);
|
authCodeData.addAll(publicKeyData!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = a.md5.convert(authCodeData);
|
var authCode = a.md5.convert(authCodeData);
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class GetPublicKeyReply extends Reply {
|
|||||||
print('获取公钥成功 publickey:$stringEncoded');
|
print('获取公钥成功 publickey:$stringEncoded');
|
||||||
// 储存公钥
|
// 储存公钥
|
||||||
Storage.setData("bluePublicKey", stringEncoded);
|
Storage.setData("bluePublicKey", stringEncoded);
|
||||||
IoSenderManage.getPrivateKey("TMH_c3570480da8d", "1", "1", 1, 1);
|
IoSenderManage.getPrivateKey("TMH_c3570480da8d", "1", "1", 1, tokenData, 1);
|
||||||
break;
|
break;
|
||||||
case 0x07:
|
case 0x07:
|
||||||
//无权限
|
//无权限
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class CommandReciverManager {
|
|||||||
// oriDataList.add(data[12 + i]);
|
// oriDataList.add(data[12 + i]);
|
||||||
// }
|
// }
|
||||||
oriDataList = data.sublist(12, 12 + oriLen);
|
oriDataList = data.sublist(12, 12 + oriLen);
|
||||||
print("oriDataList:$oriDataList");
|
print("不加密 oriDataList:$oriDataList");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
//AES128
|
//AES128
|
||||||
@ -45,7 +45,8 @@ class CommandReciverManager {
|
|||||||
case 2:
|
case 2:
|
||||||
//SM4(事先约定密钥)
|
//SM4(事先约定密钥)
|
||||||
String key = SM4.createHexKey(key: 'TMH_c3570480da8d');
|
String key = SM4.createHexKey(key: 'TMH_c3570480da8d');
|
||||||
oriDataList = SM4.encrypt(data, key: key, mode: SM4CryptoMode.ECB);
|
oriDataList = SM4.decrypt(data, key: key, mode: SM4CryptoMode.ECB);
|
||||||
|
print("SM4 oriDataList:$oriDataList");
|
||||||
break;
|
break;
|
||||||
case 3: //SM4(设备指定密钥)
|
case 3: //SM4(设备指定密钥)
|
||||||
// for (var i = 0; i < dataLen ; i++) {
|
// for (var i = 0; i < dataLen ; i++) {
|
||||||
@ -77,7 +78,7 @@ class CommandReciverManager {
|
|||||||
var cmd = data[0] * 256 + data[1];
|
var cmd = data[0] * 256 + data[1];
|
||||||
CommandType commandType = ExtensionCommandType.getCommandType(cmd);
|
CommandType commandType = ExtensionCommandType.getCommandType(cmd);
|
||||||
// data.removeRange(0, 2);
|
// data.removeRange(0, 2);
|
||||||
print("111111data commandType:$commandType data:$data");
|
print("111111data cmd:$cmd commandType:$commandType data:$data");
|
||||||
var reply;
|
var reply;
|
||||||
switch(commandType) {
|
switch(commandType) {
|
||||||
case CommandType.getLockPublicKey:
|
case CommandType.getLockPublicKey:
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class CommandSenderManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandType lastCommandType = CommandType.readLockStatusInfo;
|
// CommandType lastCommandType = CommandType.readLockStatusInfo;
|
||||||
bool canSendControlCommand = false;
|
bool canSendControlCommand = false;
|
||||||
|
|
||||||
//TODO:发送常规数据
|
//TODO:发送常规数据
|
||||||
|
|||||||
@ -20,12 +20,14 @@ class IoSenderManage {
|
|||||||
String? keyID, // 钥匙ID
|
String? keyID, // 钥匙ID
|
||||||
String? authUserID,// 钥匙授权人ID
|
String? authUserID,// 钥匙授权人ID
|
||||||
int? nowTime,
|
int? nowTime,
|
||||||
|
List<int>? publicKeyData,
|
||||||
int? needAuthor, {CommandSendCallBack? callBack}) {
|
int? needAuthor, {CommandSendCallBack? callBack}) {
|
||||||
CommandSenderManager().managerSendData(command: GetPrivateKeyCommand(
|
CommandSenderManager().managerSendData(command: GetPrivateKeyCommand(
|
||||||
lockID: lockId,
|
lockID: lockId,
|
||||||
keyID: keyID,
|
keyID: keyID,
|
||||||
authUserID: authUserID,
|
authUserID: authUserID,
|
||||||
nowTime: nowTime,
|
nowTime: nowTime,
|
||||||
|
publicKeyData:publicKeyData,
|
||||||
needAuthor: needAuthor,
|
needAuthor: needAuthor,
|
||||||
), callBack:callBack);
|
), callBack:callBack);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,4 @@ class Storage{
|
|||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user