Skip to content

Commit

Permalink
Switching to v5 crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjoDeundiak committed Mar 14, 2019
1 parent 6d018a2 commit a17fd29
Show file tree
Hide file tree
Showing 26 changed files with 302 additions and 371 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1
4.0
89 changes: 37 additions & 52 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
language: swift
language: objective-c
osx_image: xcode10.1

env:
global:
- LC_CTYPE=en_US.UTF-8
- PROJECT=VirgilSDKKeyknox.xcodeproj
- IOS_FRAMEWORK_SCHEME="VirgilSDKKeyknox iOS"
- MACOS_FRAMEWORK_SCHEME="VirgilSDKKeyknox macOS"
- TVOS_FRAMEWORK_SCHEME="VirgilSDKKeyknox tvOS"
- WATCHOS_FRAMEWORK_SCHEME="VirgilSDKKeyknox watchOS"
- IOS_TEST_SCHEME="KeyknoxTestApp iOS"
- TVOS_TEST_SCHEME="KeyknoxTestApp tvOS"
- IOS_SDK=iphonesimulator12.1
- MACOS_SDK=macosx10.14
- TVOS_SDK=appletvsimulator12.1
- WATCHOS_SDK=watchsimulator5.1
- FRAMEWORK_NAME=VirgilSDKKeyknox
- REPO=VirgilSecurity/virgil-keyknox-x
- REPO_PATH=https://github.com/VirgilSecurity/virgil-keyknox-x.git

matrix:
- DESTINATION="OS=12.1,name=iPhone SE" ENABLE_BUILD="YES" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" TWO_STEP_BUILD_ENABLED="YES" RUN_TESTS="YES" ADDITIONAL_TESTS_SCHEME="$IOS_TEST_SCHEME" PUBLISH_DOCS="NO" PUBLISH_CARTHAGE="NO" POD_LIB_LINT="NO" SWIFT_LINT="NO"
- DESTINATION="arch=x86_64" ENABLE_BUILD="YES" SCHEME="$MACOS_FRAMEWORK_SCHEME" SDK="$MACOS_SDK" TWO_STEP_BUILD_ENABLED="YES" RUN_TESTS="YES" ADDITIONAL_TESTS_SCHEME="" PUBLISH_DOCS="NO" PUBLISH_CARTHAGE="NO" POD_LIB_LINT="NO" SWIFT_LINT="NO"
- DESTINATION="OS=12.1,name=Apple TV 4K" ENABLE_BUILD="YES" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" TWO_STEP_BUILD_ENABLED="YES" RUN_TESTS="YES" ADDITIONAL_TESTS_SCHEME="$TVOS_TEST_SCHEME" PUBLISH_DOCS="NO" PUBLISH_CARTHAGE="NO" POD_LIB_LINT="NO" SWIFT_LINT="NO"
- DESTINATION="OS=5.1,name=Apple Watch Series 4 - 44mm" ENABLE_BUILD="YES" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" TWO_STEP_BUILD_ENABLED="NO" RUN_TESTS="NO" ADDITIONAL_TESTS_SCHEME="" PUBLISH_DOCS="NO" PUBLISH_CARTHAGE="NO" POD_LIB_LINT="NO" SWIFT_LINT="NO"
- DESTINATION="" ENABLE_BUILD="NO" SCHEME="" SDK="" TWO_STEP_BUILD_ENABLED="" RUN_TESTS="YES" ADDITIONAL_TESTS_SCHEME="" PUBLISH_DOCS="YES" PUBLISH_CARTHAGE="YES" POD_LIB_LINT="YES" SWIFT_LINT="YES"
- DESTINATION="" PREFIX="" SDK="" BUILD="0" PUBLISH_CARTHAGE="YES" CARTHAGE_PLATFORM_NAME="Mac" PUBLISH_POD="NO" PUBLISH_DOCS="YES" SWIFT_LINT="YES"
- DESTINATION="OS=12.1,name=iPhone SE" PREFIX="iOS" SDK="$IOS_SDK" BUILD="2" PUBLISH_CARTHAGE="NO" CARTHAGE_PLATFORM_NAME="iOS" PUBLISH_POD="NO" PUBLISH_DOCS="NO" SWIFT_LINT="NO"
- 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"
- DESTINATION="OS=12.1,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"
- DESTINATION="OS=5.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"

before_install:
- set -e
- set -o pipefail
- brew update
- brew outdated carthage || brew upgrade carthage
- xcodebuild -version
- xcodebuild -showsdks

script:
- openssl aes-256-cbc -K $encrypted_25e20d2dd9dd_key -iv $encrypted_25e20d2dd9dd_iv -in config.tar.enc -out config.tar -d
Expand All @@ -45,70 +37,63 @@ script:
- carthage version
- carthage bootstrap
- carthage bootstrap --platform ${CARTHAGE_PLATFORM_NAME}

- |
if [ $SWIFT_LINT == "YES" ]; then
brew outdated swiftlint || brew upgrade swiftlint
swiftlint
fi
- SCHEME="VirgilSDKKeyknox ${PREFIX}"


- |
if [ $ENABLE_BUILD == "YES" ]; then
if [ $TWO_STEP_BUILD_ENABLED == "YES" ]; then
# Build Framework
xcodebuild -verbose -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release clean build | xcpretty;
# Build Framework in Release and Run Tests if specified
if [ $RUN_TESTS == "YES" ]; then
if [ -n "$ADDITIONAL_TESTS_SCHEME" ]; then
xcodebuild -verbose -project "$PROJECT" -scheme "$ADDITIONAL_TESTS_SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug clean test;
else
xcodebuild -verbose -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug clean test;
fi
fi
else
# Build Framework
xcodebuild -verbose -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release clean build | xcpretty;
fi
- |
if [ $BUILD == "2" ]; then
# Build Framework
xcodebuild -verbose -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug clean build-for-testing | xcpretty;
# Run Tests
xcodebuild -verbose -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug test-without-building | xcpretty;
elif [ $BUILD == "1" ]; then
# Build Framework
xcodebuild -verbose -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release clean build | xcpretty;
fi
# Build with carthage
- if [ $PUBLISH_CARTHAGE == "YES" ]; then
carthage build --no-skip-current;
carthage archive;
fi
# Check pod lib
- if [ -n "$TRAVIS_TAG" ] && [ $POD_LIB_LINT == "YES" ]; then
gem install cocoapods --pre;
pod repo update;
pod lib lint;
fi

before_deploy:
- carthage archive

after_success:
# Generate and publish docs
- if [ -n "${TRAVIS_TAG}" ] && [ $PUBLISH_DOCS == "YES" ]; then
# Generate and publish docs
- if [[ $PUBLISH_DOCS = "YES" && $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
./CI/publish-docs.sh;
fi
deploy:
# Upload framework to gh-releases for carthage
- provider: releases
api_key: $GITHUB_TOKEN
file: $FRAMEWORK_NAME.framework.zip
api_key: $GITHUB_ACCESS_TOKEN
file: "$FRAMEWORK_NAME.framework.zip"
skip_cleanup: true
on:
repo: VirgilSecurity/virgil-keyknox-x
repo: $REPO
tags: true
condition: $PUBLISH_CARTHAGE = "YES"

- provider: script
script: bash CI/publish-cocoapods.sh
on:
repo: $REPO
tags: true
condition: $PUBLISH_POD == "YES" && $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+

# Upload docs to gh-pages
- provider: pages
skip_cleanup: true
github-token: $GITHUB_TOKEN
github-token: $GITHUB_ACCESS_TOKEN
local_dir: "docs"
on:
repo: $REPO
tags: true
condition: $PUBLISH_DOCS = "YES"
condition: $PUBLISH_DOCS == "YES" && $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+
2 changes: 1 addition & 1 deletion CI/generate-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ jazzy \
--author_url "https://virgilsecurity.com/" \
--xcodebuild-arguments -scheme,"VirgilSDKKeyknox macOS" \
--module "VirgilSDKKeyknox" \
--output "${VIRGIL_SDK_HTML_PATH_DST}" \
--output "${OUTPUT}" \
--hide-documentation-coverage \
--theme apple
2 changes: 2 additions & 0 deletions CI/publish-cocoapods.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo gem install cocoapods --pre;
pod trunk push VirgilSDKKeyknox.podspec;
23 changes: 9 additions & 14 deletions CI/publish-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,18 @@
#

# Settings
REPO_PATH=https://github.com/VirgilSecurity/virgil-keyknox-x.git
HTML_PATH_DST="${TRAVIS_BUILD_DIR}/docs"
CHANGESET=$(git rev-parse --verify HEAD)

# Get a clean version of the HTML documentation repo.
rm -rf ${HTML_PATH_DST}
mkdir -p ${HTML_PATH_DST}
git clone -b gh-pages "${REPO_PATH}" --single-branch ${HTML_PATH_DST}
DOCS_DIR="${TRAVIS_BUILD_DIR}/docs"
mkdir -p ${DOCS_DIR}
git clone -b gh-pages "${REPO_PATH}" --single-branch ${DOCS_DIR}

INFOPLIST_FILE_PATH="${TRAVIS_BUILD_DIR}/VirgilSDKKeyknox/Info.plist"

# Define SDK versions
VIRGIL_SDK_VERSION="v"$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE_PATH}")
VIRGIL_SDK_HTML_PATH_DST="${HTML_PATH_DST}/${VIRGIL_SDK_VERSION}"
CURRENT_VERSION_DIR="${DOCS_DIR}/${VIRGIL_SDK_VERSION}"

# Generate the HTML documentation.
VIRGIL_SDK_HTML_PATH_DST=${VIRGIL_SDK_HTML_PATH_DST} ./CI/generate-docs.sh
OUTPUT="${CURRENT_VERSION_DIR}" ${TRAVIS_BUILD_DIR}/CI/generate-docs.sh

# Generate root HTML file
function get_dir_names {
Expand All @@ -64,7 +59,7 @@ function get_dir_names {
echo ${DIR_NAMES[*]}
}

cat >"${HTML_PATH_DST}/index.html" <<EOL
cat >"${DOCS_DIR}/index.html" <<EOL
<!DOCTYPE HTML>
<html>
<head>
Expand All @@ -76,11 +71,11 @@ cat >"${HTML_PATH_DST}/index.html" <<EOL
<ul>
EOL

for dir in `get_dir_names "${VIRGIL_SDK_HTML_PATH_DST}/.." "v*"`; do
echo "<li><p><a href=\"${dir}/index.html\">${dir}</a></p></li>" >> "${HTML_PATH_DST}/index.html"
for dir in `get_dir_names "${CURRENT_VERSION_DIR}/.." "v*"`; do
echo "<li><p><a href=\"${dir}/index.html\">${dir}</a></p></li>" >> "${DOCS_DIR}/index.html"
done

cat >>"${HTML_PATH_DST}/index.html" <<EOL
cat >>"${DOCS_DIR}/index.html" <<EOL
</ul>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "VirgilSecurity/virgil-sdk-x" ~> 5.7
github "VirgilSecurity/virgil-crypto-x" ~> 3.2
github "VirgilSecurity/virgil-crypto-x" "v5"
4 changes: 3 additions & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github "VirgilSecurity/virgil-crypto-x" "3.2.2"
github "VirgilSecurity/virgil-crypto-c" "v0.2.0"
github "VirgilSecurity/virgil-crypto-x" "c47e58f4b5b95dcb6d3fa5cd46ce322d7cc6c11a"
github "VirgilSecurity/virgil-cryptoapi-x" "1.0.4"
github "VirgilSecurity/virgil-cryptowrapper-x" "0.3.0"
github "VirgilSecurity/virgil-sdk-x" "5.7.0"
6 changes: 3 additions & 3 deletions Source/CloudKeyStorage/CloudKeyStorage+Obj-C.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//

import Foundation
import VirgilCryptoAPI
import VirgilCrypto

// MARK: - Obj-C extension
extension CloudKeyStorage {
Expand Down Expand Up @@ -136,8 +136,8 @@ extension CloudKeyStorage {
/// - newPublicKeys: New public keys
/// - newPrivateKey: New private key
/// - completion: Completion handler
@objc open func updateRecipients(newPublicKeys: [PublicKey]? = nil,
newPrivateKey: PrivateKey? = nil,
@objc open func updateRecipients(newPublicKeys: [VirgilPublicKey]? = nil,
newPrivateKey: VirgilPrivateKey? = nil,
completion: @escaping (Error?) -> Void) {
self.updateRecipients(newPublicKeys: newPublicKeys, newPrivateKey: newPrivateKey).start { _, error in
completion(error)
Expand Down
8 changes: 4 additions & 4 deletions Source/CloudKeyStorage/CloudKeyStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//

import Foundation
import VirgilCryptoAPI
import VirgilCrypto
import VirgilSDK

/// Class responsible for storing Keys in Cloud using E2EE
Expand Down Expand Up @@ -69,7 +69,7 @@ import VirgilSDK
/// - privateKey: Private key used for decryption and signature verification
/// - Throws: Rethrows from KeyknoxManager
@objc public convenience init(accessTokenProvider: AccessTokenProvider,
publicKeys: [PublicKey], privateKey: PrivateKey) throws {
publicKeys: [VirgilPublicKey], privateKey: VirgilPrivateKey) throws {
let keyknoxManager = try KeyknoxManager(accessTokenProvider: accessTokenProvider,
publicKeys: publicKeys,
privateKey: privateKey)
Expand Down Expand Up @@ -323,8 +323,8 @@ extension CloudKeyStorage: CloudKeyStorageProtocol {
/// - newPublicKeys: New public keys
/// - newPrivateKey: New private key
/// - Returns: GenericOperation<Void>
open func updateRecipients(newPublicKeys: [PublicKey]? = nil,
newPrivateKey: PrivateKey? = nil) -> GenericOperation<Void> {
open func updateRecipients(newPublicKeys: [VirgilPublicKey]? = nil,
newPrivateKey: VirgilPrivateKey? = nil) -> GenericOperation<Void> {
return CallbackOperation { _, completion in
self.queue.async {
do {
Expand Down
4 changes: 2 additions & 2 deletions Source/CloudKeyStorage/CloudKeyStorageProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

import Foundation
import VirgilSDK
import VirgilCryptoAPI
import VirgilCrypto

/// Cloud KeyStorage protocol
public protocol CloudKeyStorageProtocol {
Expand Down Expand Up @@ -112,5 +112,5 @@ public protocol CloudKeyStorageProtocol {
/// - newPublicKeys: New public keys
/// - newPrivateKey: New private key
/// - Returns: GenericOperation<Void>
func updateRecipients(newPublicKeys: [PublicKey]?, newPrivateKey: PrivateKey?) -> GenericOperation<Void>
func updateRecipients(newPublicKeys: [VirgilPublicKey]?, newPrivateKey: VirgilPrivateKey?) -> GenericOperation<Void>
}
Loading

0 comments on commit a17fd29

Please sign in to comment.