Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38a9061
Feature: Adapted the ESPProvision library to be compatible with Swift…
vikas-chandra-mnnit May 7, 2023
3a2faed
Merge branch 'feature/swift_package_support' into 'master'
shahpiyushv May 19, 2023
783e6b5
Bugfix: Corrected session check to avoid crash.
elanovasconcelos Aug 17, 2022
85179b3
Task: Added wpa3 constant to identify Wi-Fi authorization mode.
brunoro Jul 26, 2022
6b0ba3c
Merge branch 'bugfix/prov_method_fix' into 'master'
shahpiyushv Oct 9, 2023
2940297
Merge branch 'task/wpa3_constants' into 'master'
shahpiyushv Oct 9, 2023
838b02a
Task: Updated SwiftProtobuf library to version 1.22.0 in SDK.
vikas-chandra-mnnit Sep 25, 2023
a0d307a
Merge branch 'task/update_swiftprotobuf' into 'master'
shahpiyushv Oct 9, 2023
fd2e9cc
Bugfix: Started camera session on background thread to avoid main thr…
vikas-chandra-mnnit Sep 25, 2023
b38391a
Merge branch 'bugfix/bg_thread_scanner' into 'master'
shahpiyushv Oct 11, 2023
15159b3
Feature: Added support for provisioning thread devices.
ajay-gantayet Apr 30, 2024
09dbf1d
Merge branch 'feature/thread_device_provisioning_support' into 'master'
shahpiyushv Jul 22, 2024
41c2e0e
Bugfix: Fixed decryption of device response after network scan initia…
ajay-gantayet Aug 1, 2024
40344b2
Merge branch 'bugfix/start_scan_response_handling' into 'master'
shahpiyushv Aug 8, 2024
d5b3122
Bugfix: Fixed the issue of reading descriptors that lack read permiss…
ajay-gantayet Aug 19, 2024
5e9f558
Merge branch 'bugfix/read_descriptor_of_notify_characteristic' into '…
adwait-esp Oct 18, 2024
82f7e72
Feature: Optimized BLE service discovery using advertised UUIDs.
ajay-gantayet Feb 27, 2025
2d639d8
Bugfix: Implemented proper AES-GCM IV handling for Security2 scheme.
ajay-gantayet Feb 27, 2025
5d9ab19
Merge branch 'feature/filtered_service_discovery' into 'master'
shahpiyushv Mar 14, 2025
ff70c09
Merge branch 'bugfix/security2_aes_gcm_iv_handling' into 'master'
shahpiyushv Mar 14, 2025
bf68532
Bugfix: Security 2 username was shown in SDK Sample app settings even…
ajay-gantayet May 15, 2025
49d1b5f
Merge branch 'bugfix/settings_ui_fix' into 'master'
shahpiyushv May 23, 2025
2d60974
Feature: Added support for Reset Wi-Fi command in the SDK.
ajay-gantayet Dec 15, 2025
e607656
Feature: Added support for On-Network provisioning.
ajay-gantayet Dec 15, 2025
96d1904
Merge branch 'feature/wifi_reset_command' into 'master'
shahpiyushv Apr 23, 2026
00a33ce
Merge branch 'feature/on_network_provisioning' into 'master'
shahpiyushv Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ fastlane/screenshots/**/*.png
fastlane/test_output

EspressifProvision/EspressifProvision/proto/*.swift
Package.resolved
Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcworkspace/xcshareddata/swiftpm/Package.resolved
9 changes: 4 additions & 5 deletions ESPProvision.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "ESPProvision"
spec.version = "2.1.0"
spec.version = "3.1.0"
spec.summary = "ESP-IDF provisioning in Swift"
spec.description = "It provides mechanism to provide network credentials and/or custom data to an ESP32, ESP32-S2 or ESP8266 devices"
spec.homepage = "https://github.com/espressif/esp-idf-provisioning-ios"
Expand All @@ -23,14 +23,13 @@ Pod::Spec.new do |spec|

spec.author = "Espressif Systems"
spec.platform = :ios, "13.0"
spec.source = { :git => "https://github.com/espressif/esp-idf-provisioning-ios.git", :tag => "lib-#{spec.version}" }
spec.source = { :git => "https://github.com/espressif/esp-idf-provisioning-ios.git", :tag => "#{spec.version}" }

spec.source_files = "ESPProvision", "ESPProvision/**/*.{h,m,swift}"
spec.source_files = "ESPProvision", "ESPProvision/**/*.{swift}"


spec.subspec 'Core' do |cs|
cs.dependency "SwiftProtobuf", "~> 1.5.0"
cs.dependency "Curve25519", "~> 1.1.0"
cs.dependency "SwiftProtobuf", "~> 1.22.0"
end

spec.swift_versions = ['5.1', '5.2']
Expand Down
64 changes: 34 additions & 30 deletions ESPProvision.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions ESPProvision/Crypto/AESDecryptor.h

This file was deleted.

98 changes: 0 additions & 98 deletions ESPProvision/Crypto/AESDecryptor.m

This file was deleted.

123 changes: 123 additions & 0 deletions ESPProvision/Crypto/AESDecryptor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Copyright 2023 Espressif Systems
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// AppDelegate.swift
// ESPProvisionSample
//

import CommonCrypto
import Foundation

class AESDecryptor {
var cryptor: CCCryptorRef?
var ccStatus: CCCryptorStatus = 0

init(key: Data, iv: Data) {
cryptor = nil

ccStatus = CCCryptorCreateWithMode(
CCOperation(kCCEncrypt),
CCMode(kCCModeCTR),
CCAlgorithm(kCCAlgorithmAES),
CCPadding(ccNoPadding),
iv.bytes, key.bytes,
key.count,
nil, 0, 0, // tweak XTS mode, numRounds
CCModeOptions(kCCModeOptionCTR_BE),
&cryptor)
}


func cryptData(dataIn: Data,
operation: CCOperation, // kCC Encrypt, Decrypt
mode: CCMode, // kCCMode ECB, CBC, CFB, CTR, OFB, RC4, CFB8
algorithm: CCAlgorithm, // CCAlgorithm AES DES, 3DES, CAST, RC4, RC2, Blowfish
padding: CCPadding, // cc NoPadding, PKCS7Padding
keyLength: size_t, // kCCKeySizeAES 128, 192, 256
iv: Data, // CBC, CFB, CFB8, OFB, CTR
key: Data,
error: inout NSError?) -> Data?
{
// Check that the key length is correct
if (key.count != keyLength) {
if (error != nil) {
error = NSError(domain: "kArgumentError key length", code: key.count, userInfo: nil)
}
return nil
}

var dataOutMoved: size_t = 0
var dataOutMovedTotal: size_t = 0
var ccStatus: CCCryptorStatus = 0

// Get the output buffer size
let dataOutLength = CCCryptorGetOutputLength(cryptor, dataIn.count, true)
// Allocate the output buffer
var dataOut = NSMutableData(length: dataOutLength)!
let dataOutPointer = dataOut.mutableBytes.assumingMemoryBound(to: CChar.self)

// Encrypt or decrypt the input data
ccStatus = CCCryptorUpdate(
cryptor!,
dataIn.bytes, dataIn.count,
dataOutPointer, dataOutLength,
&dataOutMoved)
dataOutMovedTotal += dataOutMoved

if ccStatus != kCCSuccess {
if error != nil {
error = NSError(domain: "kUpdateError", code: Int(ccStatus), userInfo: nil)
}
CCCryptorRelease(cryptor!)
return nil
}

// Finalize the encryption or decryption
ccStatus = CCCryptorFinal(
cryptor!,
dataOutPointer + dataOutMoved, dataOutLength - dataOutMoved,
&dataOutMoved)
if ccStatus != kCCSuccess {
if error != nil {
error = NSError(domain: "kFinalError", code: Int(ccStatus), userInfo: nil)
}
CCCryptorRelease(cryptor!)
return nil
}

dataOutMovedTotal += dataOutMoved
dataOut.length = dataOutMovedTotal

return (dataOut as Data)
}

/**
Copies the contents of an array of elements starting at a specified index to an UnsafeMutableRawPointer.

- Parameters:
- to: An UnsafeMutableRawPointer to which the elements will be copied.
- from: An array of elements to copy.
- startIndexAtPointer: The starting index in bytes at which to copy the elements to the destination pointer.
*/
func copyMemoryStartingAtIndex<T>(to umrp: UnsafeMutableRawPointer, from arr: [T], startIndexAtPointer toIndex: Int) {
// Calculate the byte offset from the destination pointer based on the starting index.
let byteOffset = MemoryLayout<T>.stride * toIndex
// Calculate the total number of bytes that need to be copied based on the size of each element in the array.
let byteCount = MemoryLayout<T>.stride * arr.count

// Use the `copyMemory` method of the destination pointer to copy the bytes from the source array to the destination pointer.
// The `advanced(by:)` method is used to move the pointer to the correct starting index before copying.
umrp.advanced(by: byteOffset).copyMemory(from: arr, byteCount: byteCount)
}
}
4 changes: 2 additions & 2 deletions ESPProvision/Crypto/CryptoAES.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class CryptoAES {
public init(key: Data, iv: Data) {
self.key = key
self.iv = iv
decryptor = AESDecryptor(key: key, andIV: iv)
decryptor = AESDecryptor(key: key, iv: iv)
}

func encrypt(data: Data) -> Data? {
var returnData: Data?
var error: NSError?
returnData = decryptor.cryptData(data, operation: CCOperation(kCCEncrypt), mode: CCMode(kCCModeCTR), algorithm: CCAlgorithm(kCCAlgorithmAES), padding: CCPadding(ccNoPadding), keyLength: kCCKeySizeAES256, iv: iv, key: key, error: &error)
returnData = decryptor.cryptData(dataIn: data, operation: CCOperation(kCCEncrypt), mode: CCMode(kCCModeCTR), algorithm: CCAlgorithm(kCCAlgorithmAES), padding: CCPadding(ccNoPadding), keyLength: kCCKeySizeAES256, iv: iv, key: key, error: &error)
return returnData
}
}
6 changes: 3 additions & 3 deletions ESPProvision/Crypto/ESPSecurity0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ class ESPSecurity0: ESPCodeable {
ESPLog.log("Generating Step 0 request data...")

var request: Data?
var sessionData = Espressif_SessionData()
var sessionData = SessionData()
sessionData.secVer = .secScheme0
do {
try sessionData.sec0.sc.merge(serializedData: Espressif_S0SessionCmd().serializedData())
try sessionData.sec0.sc.merge(serializedData: S0SessionCmd().serializedData())
request = try? sessionData.serializedData()
} catch {
ESPLog.log("Serializing Step0 request throws error.")
Expand All @@ -116,7 +116,7 @@ class ESPSecurity0: ESPCodeable {
}

ESPLog.log("Serializing Step0 response.")
let sessionData = try Espressif_SessionData(serializedData: response)
let sessionData = try SessionData(serializedData: response)
if sessionData.secVer != .secScheme0 {
ESPLog.log("Security version mismatch.")
throw SecurityError.handshakeError("Security version mismatch")
Expand Down
Loading