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