File tree 2 files changed +15
-2
lines changed
Sources/CryptomatorCryptoLib
Tests/CryptomatorCryptoLibTests
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,27 @@ public class Masterkey {
44
44
return createFromRaw ( aesMasterKey: aesMasterKey, macMasterKey: macMasterKey)
45
45
}
46
46
47
+ /**
48
+ Creates masterkey from raw bytes.
49
+
50
+ - Parameter rawKey: Key combination of `aesMasterKey` (used for encryption of file specific keys) and `macMasterKey` (used for file authentication).
51
+ - Returns: New masterkey instance using the keys from the supplied raw bytes.
52
+ */
53
+ public static func createFromRaw( rawKey: [ UInt8 ] ) -> Masterkey {
54
+ assert ( rawKey. count == 2 * kCCKeySizeAES256)
55
+ let aesMasterkey = Array ( rawKey [ 0 ..< kCCKeySizeAES256] )
56
+ let macMasterKey = Array ( rawKey [ kCCKeySizeAES256... ] )
57
+ return createFromRaw ( aesMasterKey: aesMasterkey, macMasterKey: macMasterKey)
58
+ }
59
+
47
60
/**
48
61
Creates masterkey from raw bytes.
49
62
50
63
- Parameter aesMasterKey: Key used for encryption of file specific keys.
51
64
- Parameter macMasterKey: Key used for file authentication.
52
65
- Returns: New masterkey instance using the keys from the supplied raw bytes.
53
66
*/
54
- public static func createFromRaw( aesMasterKey: [ UInt8 ] , macMasterKey: [ UInt8 ] ) -> Masterkey {
67
+ static func createFromRaw( aesMasterKey: [ UInt8 ] , macMasterKey: [ UInt8 ] ) -> Masterkey {
55
68
assert ( aesMasterKey. count == kCCKeySizeAES256)
56
69
assert ( macMasterKey. count == kCCKeySizeAES256)
57
70
return Masterkey ( aesMasterKey: aesMasterKey, macMasterKey: macMasterKey)
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class MasterkeyTests: XCTestCase {
13
13
func testCreateFromRaw( ) throws {
14
14
let aesMasterKey = [ UInt8] ( repeating: 0x77 , count: 32 )
15
15
let macMasterKey = [ UInt8] ( repeating: 0x55 , count: 32 )
16
- let masterkey = Masterkey . createFromRaw ( aesMasterKey : aesMasterKey, macMasterKey : macMasterKey)
16
+ let masterkey = Masterkey . createFromRaw ( rawKey : aesMasterKey + macMasterKey)
17
17
XCTAssertEqual ( aesMasterKey, masterkey. aesMasterKey)
18
18
XCTAssertEqual ( macMasterKey, masterkey. macMasterKey)
19
19
}
You can’t perform that action at this time.
0 commit comments