generated from ali/HarmonyTemplate
T5 review: HostKeyStatus/HostKeyDecision as string enums (ArkTS subset), Kex.parseExtInfo export + diag EXT_INFO reuse
This commit is contained in:
@@ -16,11 +16,10 @@ import { DerUtils, RsaPublicKeyParts, EcdsaParts } from '../ssh/crypto/DerUtils'
|
||||
import { buildPublicKeyBlob, verifyHostKeySignature, PublicKeyMaterial } from '../ssh/crypto/KeyImport';
|
||||
import { SshVersion, SshMsg } from '../ssh/SshTypes';
|
||||
import { ClientProposals } from '../ssh/Algorithms';
|
||||
import { KexEngine, KexResult } from '../ssh/Kex';
|
||||
import { KexEngine, KexResult, parseExtInfo } from '../ssh/Kex';
|
||||
import { verifyHostKeyTofu, InMemoryKnownHostStore, HostKeyDecider, HostKeyPrompt,
|
||||
HostKeyDecision } from '../ssh/HostKeyVerifier';
|
||||
import { bytesToUtf8, utf8ToBytes, hexToBytes, bytesToHex, bytesEqual, concatBytes, SshWriter,
|
||||
SshReader } from '../ssh/SshWire';
|
||||
HostKeyDecision, HostKeyStatus } from '../ssh/HostKeyVerifier';
|
||||
import { bytesToUtf8, utf8ToBytes, hexToBytes, bytesToHex, bytesEqual, concatBytes, SshWriter } from '../ssh/SshWire';
|
||||
import { cryptoFramework } from '@kit.CryptoArchitectureKit';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
@@ -703,12 +702,12 @@ struct DiagPage {
|
||||
decide: async (prompt: HostKeyPrompt): Promise<HostKeyDecision> => {
|
||||
this.log('INFO', `主机密钥 [${prompt.status}] ${prompt.hostPort} (${prompt.keyAlgo})`);
|
||||
this.log('INFO', `本次指纹: ${prompt.fingerprint}`);
|
||||
if (prompt.status === 'changed') {
|
||||
if (prompt.status === HostKeyStatus.CHANGED) {
|
||||
for (let i = 0; i < prompt.knownFingerprints.length; i++) {
|
||||
this.log('INFO', `已知指纹 ${i + 1}: ${prompt.knownFingerprints[i]}`);
|
||||
}
|
||||
}
|
||||
return 'accept-once';
|
||||
return HostKeyDecision.ACCEPT_ONCE;
|
||||
}
|
||||
};
|
||||
const engine: KexEngine = new KexEngine(transport,
|
||||
@@ -735,15 +734,11 @@ struct DiagPage {
|
||||
try {
|
||||
const p: Uint8Array = await transport.waitPacket(2000);
|
||||
if (p[0] === SshMsg.EXT_INFO) {
|
||||
const er: SshReader = new SshReader(p);
|
||||
er.readByte();
|
||||
const count: number = er.readUint32();
|
||||
this.log('INFO', `EXT_INFO (${count} 项扩展):`);
|
||||
for (let i = 0; i < count; i++) {
|
||||
const name: string = er.readString();
|
||||
const value: string = er.readString();
|
||||
const ext: Map<string, string> = parseExtInfo(p);
|
||||
this.log('INFO', `EXT_INFO (${ext.size} 项扩展):`);
|
||||
ext.forEach((value: string, name: string): void => {
|
||||
this.log('INFO', ` ${name} = ${this.trunc(value, 80)}`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.log('INFO', `KEX 后消息 ${p[0]} 忽略`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user