From 35ba0eb61c41e090d161d6018c5f8ee00e4987aa Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Tue, 29 Apr 2025 01:07:47 +0800 Subject: [PATCH] feat: updates --- swift-secure-enclave-tool-v2.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/swift-secure-enclave-tool-v2.swift b/swift-secure-enclave-tool-v2.swift index 238faf7..3f39653 100644 --- a/swift-secure-enclave-tool-v2.swift +++ b/swift-secure-enclave-tool-v2.swift @@ -244,7 +244,7 @@ struct ComputeSecureEnclaveP256EcsignResponse: Codable { struct ComputeSecureEnclaveP256EcdhResponse: Codable { var success: Bool - var shared_secret: String + var shared_secret_hex: String } struct ExternalSpecResponse: Codable { @@ -437,9 +437,18 @@ func computeSecureEnclaveP256Ecdh(request: ComputeP256EcdhRequest) -> ComputeSec let sharedSecret = try p.sharedSecretFromKeyAgreement( with: ephemeralPublicKey) + var shared_secret_hex: String + if sharedSecret.description.starts(with: "SharedSecret: ") { + let str = sharedSecret.description + let startIndex = str.index(str.startIndex, offsetBy: "SharedSecret: ".count) + shared_secret_hex = String(str[startIndex...]) + } else { + shared_secret_hex = sharedSecret.description + } + return ComputeSecureEnclaveP256EcdhResponse( success: true, - shared_secret: sharedSecret.description + shared_secret_hex: shared_secret_hex ) } catch { exitError("\(error)")