Skip to content

Commit 887e54b

Browse files
bitwarden/sdk-internal@745287f 1.0.0-2397-745287f - [PM-24683] Add updateKdf function (bitwarden/sdk-internal#383)
1 parent c18afa1 commit 887e54b

File tree

6 files changed

+347
-15
lines changed

6 files changed

+347
-15
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let package = Package(
3030
dependencies: ["BitwardenSdk"]),
3131
.binaryTarget(
3232
name: "BitwardenFFI",
33-
url: "https://github.com/bitwarden/sdk-swift/releases/download/v1.0.0-2394-72f4866/BitwardenFFI-1.0.0-72f4866.xcframework.zip",
34-
checksum: "52809b7bd3057a68b70ecefa99646fece101148d5e24000b004d0430989dbf96")
33+
url: "https://github.com/bitwarden/sdk-swift/releases/download/v1.0.0-2397-745287f/BitwardenFFI-1.0.0-745287f.xcframework.zip",
34+
checksum: "3c2525830ca470f0a1afe6049095b2da88759e63a3e18d0677c44bffffd882ac")
3535
]
3636
)

Sources/BitwardenSdk/BitwardenCore.swift

Lines changed: 280 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,87 @@ public func FfiConverterTypeMakeKeyPairResponse_lower(_ value: MakeKeyPairRespon
15321532
}
15331533

15341534

1535+
/**
1536+
* Represents the data required to authenticate with the master password.
1537+
*/
1538+
public struct MasterPasswordAuthenticationData {
1539+
public let kdf: Kdf
1540+
public let salt: String
1541+
public let masterPasswordAuthenticationHash: B64
1542+
1543+
// Default memberwise initializers are never public by default, so we
1544+
// declare one manually.
1545+
public init(kdf: Kdf, salt: String, masterPasswordAuthenticationHash: B64) {
1546+
self.kdf = kdf
1547+
self.salt = salt
1548+
self.masterPasswordAuthenticationHash = masterPasswordAuthenticationHash
1549+
}
1550+
}
1551+
1552+
#if compiler(>=6)
1553+
extension MasterPasswordAuthenticationData: Sendable {}
1554+
#endif
1555+
1556+
1557+
extension MasterPasswordAuthenticationData: Equatable, Hashable {
1558+
public static func ==(lhs: MasterPasswordAuthenticationData, rhs: MasterPasswordAuthenticationData) -> Bool {
1559+
if lhs.kdf != rhs.kdf {
1560+
return false
1561+
}
1562+
if lhs.salt != rhs.salt {
1563+
return false
1564+
}
1565+
if lhs.masterPasswordAuthenticationHash != rhs.masterPasswordAuthenticationHash {
1566+
return false
1567+
}
1568+
return true
1569+
}
1570+
1571+
public func hash(into hasher: inout Hasher) {
1572+
hasher.combine(kdf)
1573+
hasher.combine(salt)
1574+
hasher.combine(masterPasswordAuthenticationHash)
1575+
}
1576+
}
1577+
1578+
1579+
1580+
#if swift(>=5.8)
1581+
@_documentation(visibility: private)
1582+
#endif
1583+
public struct FfiConverterTypeMasterPasswordAuthenticationData: FfiConverterRustBuffer {
1584+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MasterPasswordAuthenticationData {
1585+
return
1586+
try MasterPasswordAuthenticationData(
1587+
kdf: FfiConverterTypeKdf.read(from: &buf),
1588+
salt: FfiConverterString.read(from: &buf),
1589+
masterPasswordAuthenticationHash: FfiConverterTypeB64.read(from: &buf)
1590+
)
1591+
}
1592+
1593+
public static func write(_ value: MasterPasswordAuthenticationData, into buf: inout [UInt8]) {
1594+
FfiConverterTypeKdf.write(value.kdf, into: &buf)
1595+
FfiConverterString.write(value.salt, into: &buf)
1596+
FfiConverterTypeB64.write(value.masterPasswordAuthenticationHash, into: &buf)
1597+
}
1598+
}
1599+
1600+
1601+
#if swift(>=5.8)
1602+
@_documentation(visibility: private)
1603+
#endif
1604+
public func FfiConverterTypeMasterPasswordAuthenticationData_lift(_ buf: RustBuffer) throws -> MasterPasswordAuthenticationData {
1605+
return try FfiConverterTypeMasterPasswordAuthenticationData.lift(buf)
1606+
}
1607+
1608+
#if swift(>=5.8)
1609+
@_documentation(visibility: private)
1610+
#endif
1611+
public func FfiConverterTypeMasterPasswordAuthenticationData_lower(_ value: MasterPasswordAuthenticationData) -> RustBuffer {
1612+
return FfiConverterTypeMasterPasswordAuthenticationData.lower(value)
1613+
}
1614+
1615+
15351616
public struct MasterPasswordPolicyOptions {
15361617
public let minComplexity: UInt8
15371618
public let minLength: UInt8
@@ -1652,6 +1733,105 @@ public func FfiConverterTypeMasterPasswordPolicyOptions_lower(_ value: MasterPas
16521733
}
16531734

16541735

1736+
/**
1737+
* Represents the data required to unlock with the master password.
1738+
*/
1739+
public struct MasterPasswordUnlockData {
1740+
/**
1741+
* The key derivation function used to derive the master key
1742+
*/
1743+
public let kdf: Kdf
1744+
/**
1745+
* The master key wrapped user key
1746+
*/
1747+
public let masterKeyWrappedUserKey: EncString
1748+
/**
1749+
* The salt used in the KDF, typically the user's email
1750+
*/
1751+
public let salt: String
1752+
1753+
// Default memberwise initializers are never public by default, so we
1754+
// declare one manually.
1755+
public init(
1756+
/**
1757+
* The key derivation function used to derive the master key
1758+
*/kdf: Kdf,
1759+
/**
1760+
* The master key wrapped user key
1761+
*/masterKeyWrappedUserKey: EncString,
1762+
/**
1763+
* The salt used in the KDF, typically the user's email
1764+
*/salt: String) {
1765+
self.kdf = kdf
1766+
self.masterKeyWrappedUserKey = masterKeyWrappedUserKey
1767+
self.salt = salt
1768+
}
1769+
}
1770+
1771+
#if compiler(>=6)
1772+
extension MasterPasswordUnlockData: Sendable {}
1773+
#endif
1774+
1775+
1776+
extension MasterPasswordUnlockData: Equatable, Hashable {
1777+
public static func ==(lhs: MasterPasswordUnlockData, rhs: MasterPasswordUnlockData) -> Bool {
1778+
if lhs.kdf != rhs.kdf {
1779+
return false
1780+
}
1781+
if lhs.masterKeyWrappedUserKey != rhs.masterKeyWrappedUserKey {
1782+
return false
1783+
}
1784+
if lhs.salt != rhs.salt {
1785+
return false
1786+
}
1787+
return true
1788+
}
1789+
1790+
public func hash(into hasher: inout Hasher) {
1791+
hasher.combine(kdf)
1792+
hasher.combine(masterKeyWrappedUserKey)
1793+
hasher.combine(salt)
1794+
}
1795+
}
1796+
1797+
1798+
1799+
#if swift(>=5.8)
1800+
@_documentation(visibility: private)
1801+
#endif
1802+
public struct FfiConverterTypeMasterPasswordUnlockData: FfiConverterRustBuffer {
1803+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MasterPasswordUnlockData {
1804+
return
1805+
try MasterPasswordUnlockData(
1806+
kdf: FfiConverterTypeKdf.read(from: &buf),
1807+
masterKeyWrappedUserKey: FfiConverterTypeEncString.read(from: &buf),
1808+
salt: FfiConverterString.read(from: &buf)
1809+
)
1810+
}
1811+
1812+
public static func write(_ value: MasterPasswordUnlockData, into buf: inout [UInt8]) {
1813+
FfiConverterTypeKdf.write(value.kdf, into: &buf)
1814+
FfiConverterTypeEncString.write(value.masterKeyWrappedUserKey, into: &buf)
1815+
FfiConverterString.write(value.salt, into: &buf)
1816+
}
1817+
}
1818+
1819+
1820+
#if swift(>=5.8)
1821+
@_documentation(visibility: private)
1822+
#endif
1823+
public func FfiConverterTypeMasterPasswordUnlockData_lift(_ buf: RustBuffer) throws -> MasterPasswordUnlockData {
1824+
return try FfiConverterTypeMasterPasswordUnlockData.lift(buf)
1825+
}
1826+
1827+
#if swift(>=5.8)
1828+
@_documentation(visibility: private)
1829+
#endif
1830+
public func FfiConverterTypeMasterPasswordUnlockData_lower(_ value: MasterPasswordUnlockData) -> RustBuffer {
1831+
return FfiConverterTypeMasterPasswordUnlockData.lower(value)
1832+
}
1833+
1834+
16551835
public struct RegisterKeyResponse {
16561836
public let masterPasswordHash: B64
16571837
public let encryptedUserKey: EncString
@@ -1886,6 +2066,105 @@ public func FfiConverterTypeUniffiConverterDummyRecord_lower(_ value: UniffiConv
18862066
}
18872067

18882068

2069+
/**
2070+
* Response from the `update_kdf` function
2071+
*/
2072+
public struct UpdateKdfResponse {
2073+
/**
2074+
* The authentication data for the new KDF setting
2075+
*/
2076+
public let masterPasswordAuthenticationData: MasterPasswordAuthenticationData
2077+
/**
2078+
* The unlock data for the new KDF setting
2079+
*/
2080+
public let masterPasswordUnlockData: MasterPasswordUnlockData
2081+
/**
2082+
* The authentication data for the KDF setting prior to the change
2083+
*/
2084+
public let oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData
2085+
2086+
// Default memberwise initializers are never public by default, so we
2087+
// declare one manually.
2088+
public init(
2089+
/**
2090+
* The authentication data for the new KDF setting
2091+
*/masterPasswordAuthenticationData: MasterPasswordAuthenticationData,
2092+
/**
2093+
* The unlock data for the new KDF setting
2094+
*/masterPasswordUnlockData: MasterPasswordUnlockData,
2095+
/**
2096+
* The authentication data for the KDF setting prior to the change
2097+
*/oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData) {
2098+
self.masterPasswordAuthenticationData = masterPasswordAuthenticationData
2099+
self.masterPasswordUnlockData = masterPasswordUnlockData
2100+
self.oldMasterPasswordAuthenticationData = oldMasterPasswordAuthenticationData
2101+
}
2102+
}
2103+
2104+
#if compiler(>=6)
2105+
extension UpdateKdfResponse: Sendable {}
2106+
#endif
2107+
2108+
2109+
extension UpdateKdfResponse: Equatable, Hashable {
2110+
public static func ==(lhs: UpdateKdfResponse, rhs: UpdateKdfResponse) -> Bool {
2111+
if lhs.masterPasswordAuthenticationData != rhs.masterPasswordAuthenticationData {
2112+
return false
2113+
}
2114+
if lhs.masterPasswordUnlockData != rhs.masterPasswordUnlockData {
2115+
return false
2116+
}
2117+
if lhs.oldMasterPasswordAuthenticationData != rhs.oldMasterPasswordAuthenticationData {
2118+
return false
2119+
}
2120+
return true
2121+
}
2122+
2123+
public func hash(into hasher: inout Hasher) {
2124+
hasher.combine(masterPasswordAuthenticationData)
2125+
hasher.combine(masterPasswordUnlockData)
2126+
hasher.combine(oldMasterPasswordAuthenticationData)
2127+
}
2128+
}
2129+
2130+
2131+
2132+
#if swift(>=5.8)
2133+
@_documentation(visibility: private)
2134+
#endif
2135+
public struct FfiConverterTypeUpdateKdfResponse: FfiConverterRustBuffer {
2136+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UpdateKdfResponse {
2137+
return
2138+
try UpdateKdfResponse(
2139+
masterPasswordAuthenticationData: FfiConverterTypeMasterPasswordAuthenticationData.read(from: &buf),
2140+
masterPasswordUnlockData: FfiConverterTypeMasterPasswordUnlockData.read(from: &buf),
2141+
oldMasterPasswordAuthenticationData: FfiConverterTypeMasterPasswordAuthenticationData.read(from: &buf)
2142+
)
2143+
}
2144+
2145+
public static func write(_ value: UpdateKdfResponse, into buf: inout [UInt8]) {
2146+
FfiConverterTypeMasterPasswordAuthenticationData.write(value.masterPasswordAuthenticationData, into: &buf)
2147+
FfiConverterTypeMasterPasswordUnlockData.write(value.masterPasswordUnlockData, into: &buf)
2148+
FfiConverterTypeMasterPasswordAuthenticationData.write(value.oldMasterPasswordAuthenticationData, into: &buf)
2149+
}
2150+
}
2151+
2152+
2153+
#if swift(>=5.8)
2154+
@_documentation(visibility: private)
2155+
#endif
2156+
public func FfiConverterTypeUpdateKdfResponse_lift(_ buf: RustBuffer) throws -> UpdateKdfResponse {
2157+
return try FfiConverterTypeUpdateKdfResponse.lift(buf)
2158+
}
2159+
2160+
#if swift(>=5.8)
2161+
@_documentation(visibility: private)
2162+
#endif
2163+
public func FfiConverterTypeUpdateKdfResponse_lower(_ value: UpdateKdfResponse) -> RustBuffer {
2164+
return FfiConverterTypeUpdateKdfResponse.lower(value)
2165+
}
2166+
2167+
18892168
/**
18902169
* Response from the `update_password` function
18912170
*/
@@ -3249,8 +3528,8 @@ private let initializationResult: InitializationResult = {
32493528
return InitializationResult.contractVersionMismatch
32503529
}
32513530

3252-
uniffiEnsureBitwardenEncodingInitialized()
32533531
uniffiEnsureBitwardenCryptoInitialized()
3532+
uniffiEnsureBitwardenEncodingInitialized()
32543533
return InitializationResult.ok
32553534
}()
32563535

Sources/BitwardenSdk/BitwardenFido.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2684,8 +2684,8 @@ private let initializationResult: InitializationResult = {
26842684
return InitializationResult.contractVersionMismatch
26852685
}
26862686

2687-
uniffiEnsureBitwardenVaultInitialized()
26882687
uniffiEnsureBitwardenCoreInitialized()
2688+
uniffiEnsureBitwardenVaultInitialized()
26892689
return InitializationResult.ok
26902690
}()
26912691

0 commit comments

Comments
 (0)