Skip to content

Commit f08ba87

Browse files
Merge pull request #30 from VirgilSecurity/develop
Develop
2 parents 54599bc + 92e4f45 commit f08ba87

12 files changed

Lines changed: 63 additions & 22 deletions

.swiftlint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ opt_in_rules:
6767
- function_parameter_count
6868
- identical_operands
6969
- identifier_name
70-
- implicit_getter
71-
- implicit_return
7270
- inert_defer
7371
- is_disjoint
7472
- large_tuple

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
language: objective-c
2-
osx_image: xcode11.3
2+
osx_image: xcode11.4
33

44
env:
55
global:
66
- LC_CTYPE=en_US.UTF-8
77
- PROJECT=VirgilCrypto.xcodeproj
8-
- IOS_SDK=iphonesimulator13.2
8+
- IOS_SDK=iphonesimulator13.4
99
- MACOS_SDK=macosx10.15
10-
- TVOS_SDK=appletvsimulator13.2
11-
- WATCHOS_SDK=watchsimulator6.1
10+
- TVOS_SDK=appletvsimulator13.4
11+
- WATCHOS_SDK=watchsimulator6.2
1212
- CRYPTO_FRAMEWORK_NAME=VirgilCrypto
1313
- REPO=VirgilSecurity/virgil-crypto-x
1414
matrix:
1515
- DESTINATION="" PREFIX="" SDK="" BUILD="0" PUBLISH_CARTHAGE="YES" CARTHAGE_PLATFORM_NAME="Mac" PUBLISH_POD="YES" PUBLISH_DOCS="YES" SWIFT_LINT="NO"
16-
- DESTINATION="OS=13.3,name=iPhone 8" PREFIX="iOS" SDK="$IOS_SDK" BUILD="2" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="iOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
16+
- DESTINATION="OS=13.4,name=iPhone 8" PREFIX="iOS" SDK="$IOS_SDK" BUILD="2" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="iOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
1717
- DESTINATION="arch=x86_64" PREFIX="macOS" SDK="$MACOS_SDK" BUILD="2" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="Mac" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
18-
- DESTINATION="OS=13.2,name=Apple TV 4K" PREFIX="tvOS" SDK="$TVOS_SDK" BUILD="2" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="tvOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
19-
- DESTINATION="OS=6.1.1,name=Apple Watch Series 4 - 44mm" PREFIX="watchOS" SDK="$WATCHOS_SDK" BUILD="1" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="watchOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
18+
- DESTINATION="OS=13.4,name=Apple TV 4K" PREFIX="tvOS" SDK="$TVOS_SDK" BUILD="2" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="tvOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
19+
- DESTINATION="OS=6.2,name=Apple Watch Series 4 - 44mm" PREFIX="watchOS" SDK="$WATCHOS_SDK" BUILD="1" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="watchOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
2020

2121
before_install:
2222
- set -e

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "VirgilSecurity/virgil-cryptowrapper-x" ~> 0.12.0
1+
github "VirgilSecurity/virgil-cryptowrapper-x" ~> 0.14.0

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "VirgilSecurity/virgil-crypto-c" "v0.12.0"
2-
github "VirgilSecurity/virgil-cryptowrapper-x" "0.12.0"
1+
github "VirgilSecurity/virgil-crypto-c" "v0.14.0"
2+
github "VirgilSecurity/virgil-cryptowrapper-x" "0.14.0"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ To integrate VirgilCrypto into your Xcode project using CocoaPods, specify it in
112112
target '<Your Target Name>' do
113113
use_frameworks!
114114

115-
pod 'VirgilCrypto', '~> 5.3.0'
115+
pod 'VirgilCrypto', '~> 5.4.0'
116116
end
117117
```
118118

@@ -136,7 +136,7 @@ $ brew install carthage
136136
To integrate VirgilCrypto into your Xcode project using Carthage, create an empty file with name *Cartfile* in your project's root folder and add following lines to your *Cartfile*
137137

138138
```
139-
github "VirgilSecurity/virgil-crypto-x" ~> 5.3.0
139+
github "VirgilSecurity/virgil-crypto-x" ~> 5.4.0
140140
```
141141

142142
#### Linking against prebuilt binaries

Source/KeyPairType+Convert.swift

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ extension KeyPairType {
5959
return
6060
}
6161

62+
if keyInfo.isHybrid() {
63+
if keyInfo.hybridFirstKeyAlgId() == .curve25519 && keyInfo.hybridSecondKeyAlgId() == .round5Nd5kem5d {
64+
self = .curve25519Round5
65+
}
66+
else {
67+
throw VirgilCryptoError.unknownCompoundKey
68+
}
69+
70+
return
71+
}
72+
6273
let algId = keyInfo.algId()
6374

6475
if algId == .rsa {
@@ -88,22 +99,33 @@ extension KeyPairType {
8899
return .secp256r1
89100
case .rsa2048, .rsa4096, .rsa8192:
90101
return .rsa
91-
case .curve25519Round5Ed25519Falcon, .curve25519Ed25519:
102+
case .curve25519Round5Ed25519Falcon, .curve25519Ed25519, .curve25519Round5:
92103
throw VirgilCryptoError.compundKeyShouldBeGeneratedDirectly
93104
}
94105
}
95106

107+
internal var isHybrid: Bool {
108+
switch self {
109+
case .curve25519Ed25519, .curve25519Round5Ed25519Falcon, .curve25519Round5:
110+
return true
111+
case .curve25519, .ed25519, .rsa2048, .rsa4096, .rsa8192, .secp256r1:
112+
return false
113+
}
114+
}
115+
96116
internal var isCompound: Bool {
97117
switch self {
98118
case .curve25519Ed25519, .curve25519Round5Ed25519Falcon:
99119
return true
100-
case .curve25519, .ed25519, .rsa2048, .rsa4096, .rsa8192, .secp256r1:
120+
case .curve25519, .ed25519, .rsa2048, .rsa4096, .rsa8192, .secp256r1, .curve25519Round5:
101121
return false
102122
}
103123
}
104124

105125
internal func getSignerKeysAlgIds() throws -> (first: AlgId, second: AlgId) {
106126
switch self {
127+
case .curve25519Round5:
128+
return (.none, .none)
107129
case .curve25519Ed25519:
108130
return (.ed25519, .none)
109131
case .curve25519Round5Ed25519Falcon:
@@ -117,7 +139,7 @@ extension KeyPairType {
117139
switch self {
118140
case .curve25519Ed25519:
119141
return (.curve25519, .none)
120-
case .curve25519Round5Ed25519Falcon:
142+
case .curve25519Round5Ed25519Falcon, .curve25519Round5:
121143
return (.curve25519, .round5Nd5kem5d)
122144
case .curve25519, .ed25519, .rsa2048, .rsa4096, .rsa8192, .secp256r1:
123145
throw VirgilCryptoError.keyIsNotCompound

Source/KeyPairType+String.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extension KeyPairType {
4646
case rsa2048
4747
case rsa4096
4848
case rsa8192
49+
case curve25519Round5
4950
case curve25519Round5Ed25519Falcon
5051
case curve25519Ed25519
5152
}
@@ -67,11 +68,13 @@ extension KeyPairType {
6768
self = .rsa4096
6869
case KeyPairTypeStr.rsa8192.rawValue:
6970
self = .rsa8192
71+
case KeyPairTypeStr.curve25519Round5.rawValue:
72+
self = .curve25519Round5
7073
case KeyPairTypeStr.curve25519Round5Ed25519Falcon.rawValue:
7174
self = .curve25519Round5Ed25519Falcon
7275
case KeyPairTypeStr.curve25519Ed25519.rawValue:
7376
self = .curve25519Ed25519
74-
77+
7578
default:
7679
throw VirgilCryptoError.unknownKeyType
7780
}
@@ -92,6 +95,8 @@ extension KeyPairType {
9295
return KeyPairTypeStr.rsa4096.rawValue
9396
case .rsa8192:
9497
return KeyPairTypeStr.rsa8192.rawValue
98+
case .curve25519Round5:
99+
return KeyPairTypeStr.curve25519Round5.rawValue
95100
case .curve25519Round5Ed25519Falcon:
96101
return KeyPairTypeStr.curve25519Round5Ed25519Falcon.rawValue
97102
case .curve25519Ed25519:

Source/KeyPairType.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ import Foundation
4444
/// - rsa2048: rsa with 2048 length
4545
/// - rsa4096: rsa with 4096 length
4646
/// - rsa8192: rsa with 8192 length
47+
/// - curve25519Round5: curve25519 and round5
48+
/// - curve25519Round5Ed25519Falcon: ed25519 and falcon used for signing, curve25519 and round used for hybrid ECIES
49+
/// - curve25519Ed25519: ed25519 used for signing, curve25519 used for ECIES
4750
@objc(VSMKeyPairType) public enum KeyPairType: Int {
4851
case ed25519
4952
case curve25519
5053
case secp256r1
5154
case rsa2048
5255
case rsa4096
5356
case rsa8192
57+
case curve25519Round5
5458
case curve25519Round5Ed25519Falcon
5559
case curve25519Ed25519
5660
}

Source/VirgilCrypto/VirgilCrypto+KeyGeneration.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ extension VirgilCrypto {
6969
signerFirstKeyAlgId: signerKeysAlgIds.first,
7070
signerSecondKeyAlgId: signerKeysAlgIds.second)
7171
}
72+
else if type.isHybrid {
73+
let cipherKeysAlgIds = try type.getCipherKeysAlgIds()
74+
let signerKeysAlgIds = try type.getSignerKeysAlgIds()
75+
76+
var ids = cipherKeysAlgIds
77+
78+
if cipherKeysAlgIds.first == .none && cipherKeysAlgIds.second == .none {
79+
ids = signerKeysAlgIds
80+
}
81+
82+
privateKey = try keyProvider.generateHybridPrivateKey(firstKeyAlgId: ids.first, secondKeyAlgId: ids.second)
83+
}
7284
else {
7385
privateKey = try keyProvider.generatePrivateKey(algId: try type.getAlgId())
7486
}

Tests/VSM001_CryptoTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class VSM001_CryptoTests: XCTestCase {
5353
XCTAssert(keyPair.privateKey.identifier == keyPair.publicKey.identifier)
5454
}
5555

56-
private static let allKeyTypes: [KeyPairType] = [.curve25519, .ed25519, .secp256r1, .rsa2048, .curve25519Round5Ed25519Falcon, .curve25519Ed25519]
56+
private static let allKeyTypes: [KeyPairType] = [.curve25519, .ed25519, .secp256r1, .rsa2048, .curve25519Round5Ed25519Falcon, .curve25519Ed25519, .curve25519Round5]
5757
private static let signingKeyTypes: [KeyPairType] = [.ed25519, .secp256r1, .rsa2048, .curve25519Round5Ed25519Falcon, .curve25519Ed25519]
5858

5959
func test01__key_generation__generate_one_key__should_succeed() {

0 commit comments

Comments
 (0)