feat: udpate swift lib
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import SwiftRs
|
||||
import AppKit
|
||||
import CryptoKit
|
||||
import LocalAuthentication
|
||||
|
||||
@@ -23,7 +22,7 @@ func generateSecureEnclaveP256KeyPair() -> SRString {
|
||||
return SRString("err:\(error.debugDescription)")
|
||||
}
|
||||
do {
|
||||
let privateKeyReference = try CryptoKit.SecureEnclave.P256.KeyAgreement.PrivateKey.init(
|
||||
let privateKeyReference = try SecureEnclave.P256.KeyAgreement.PrivateKey.init(
|
||||
accessControl: accessCtrl
|
||||
);
|
||||
let publicKeyBase64 = privateKeyReference.publicKey.x963Representation.base64EncodedString()
|
||||
@@ -36,7 +35,7 @@ func generateSecureEnclaveP256KeyPair() -> SRString {
|
||||
|
||||
@_cdecl("compute_secure_enclave_p256_ecdh")
|
||||
func computeSecureEnclaveP256Ecdh(privateKeyDataRepresentation: SRString, ephemeraPublicKey: SRString) -> SRString {
|
||||
guard let dataRepresentation = Data(
|
||||
guard let privateKeyDataRepresentation = Data(
|
||||
base64Encoded: privateKeyDataRepresentation.toString()
|
||||
) else {
|
||||
return SRString("err:private key base64 decode failed")
|
||||
@@ -49,11 +48,11 @@ func computeSecureEnclaveP256Ecdh(privateKeyDataRepresentation: SRString, epheme
|
||||
do {
|
||||
let context = LAContext();
|
||||
let p = try SecureEnclave.P256.KeyAgreement.PrivateKey(
|
||||
dataRepresentation: dataRepresentation,
|
||||
dataRepresentation: privateKeyDataRepresentation,
|
||||
authenticationContext: context
|
||||
)
|
||||
|
||||
let ephemeralPublicKey = try CryptoKit.P256.KeyAgreement.PublicKey.init(derRepresentation: ephemeralPublicKeyRepresentation)
|
||||
let ephemeralPublicKey = try P256.KeyAgreement.PublicKey.init(derRepresentation: ephemeralPublicKeyRepresentation)
|
||||
|
||||
let sharedSecret = try p.sharedSecretFromKeyAgreement(
|
||||
with: ephemeralPublicKey)
|
||||
|
||||
Reference in New Issue
Block a user