南鑫林 6 роки тому
батько
коміт
3d3908a9bf
100 змінених файлів з 2256 додано та 6197 видалено
  1. 7 2
      RainbowPlanet/Podfile
  2. 40 29
      RainbowPlanet/Podfile.lock
  3. 1 1
      RainbowPlanet/Pods/Alamofire/Source/MultipartFormData.swift
  4. 22 0
      RainbowPlanet/Pods/Cache/LICENSE.md
  5. 429 0
      RainbowPlanet/Pods/Cache/README.md
  6. 36 0
      RainbowPlanet/Pods/Cache/Source/Shared/Configuration/DiskConfig.swift
  7. 20 0
      RainbowPlanet/Pods/Cache/Source/Shared/Configuration/MemoryConfig.swift
  8. 12 0
      RainbowPlanet/Pods/Cache/Source/Shared/Extensions/Date+Extensions.swift
  9. 42 0
      RainbowPlanet/Pods/Cache/Source/Shared/Extensions/JSONDecoder+Extensions.swift
  10. 25 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/DataSerializer.swift
  11. 17 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/Entry.swift
  12. 10 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/ExpirationMode.swift
  13. 31 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/Expiry.swift
  14. 32 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/ImageWrapper.swift
  15. 40 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/JSONArrayWrapper.swift
  16. 40 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/JSONDictionaryWrapper.swift
  17. 281 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/MD5.swift
  18. 20 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/MemoryCapsule.swift
  19. 11 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/ObservationToken.swift
  20. 11 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/Optional+Extension.swift
  21. 16 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/Result.swift
  22. 18 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/StorageError.swift
  23. 11 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/Transformer.swift
  24. 38 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/TransformerFactory.swift
  25. 14 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/TypeWrapper.swift
  26. 9 0
      RainbowPlanet/Pods/Cache/Source/Shared/Library/Types.swift
  27. 129 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/AsyncStorage.swift
  28. 268 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/DiskStorage.swift
  29. 167 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/HybridStorage.swift
  30. 50 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/KeyObservationRegistry.swift
  31. 65 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/MemoryStorage.swift
  32. 18 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/Storage+Transform.swift
  33. 110 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/Storage.swift
  34. 79 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/StorageAware.swift
  35. 42 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/StorageObservationRegistry.swift
  36. 60 0
      RainbowPlanet/Pods/Cache/Source/Shared/Storage/SyncStorage.swift
  37. 35 0
      RainbowPlanet/Pods/Cache/Source/iOS/UIImage+Extensions.swift
  38. 0 11
      RainbowPlanet/Pods/CryptoSwift/LICENSE
  39. 0 528
      RainbowPlanet/Pods/CryptoSwift/README.md
  40. 0 40
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AEAD/AEAD.swift
  41. 0 59
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AEAD/AEADChaCha20Poly1305.swift
  42. 0 35
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AES.Cryptors.swift
  43. 0 539
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AES.swift
  44. 0 148
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Array+Extension.swift
  45. 0 20
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Authenticator.swift
  46. 0 63
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BatchedCollection.swift
  47. 0 25
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Bit.swift
  48. 0 18
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockCipher.swift
  49. 0 85
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockDecryptor.swift
  50. 0 57
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockEncryptor.swift
  51. 0 24
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockMode.swift
  52. 0 27
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockModeOptions.swift
  53. 0 70
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CBC.swift
  54. 0 359
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CCM.swift
  55. 0 70
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CFB.swift
  56. 0 134
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CTR.swift
  57. 0 61
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CipherModeWorker.swift
  58. 0 51
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/ECB.swift
  59. 0 370
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/GCM.swift
  60. 0 70
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/OFB.swift
  61. 0 70
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/PCBC.swift
  62. 0 537
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Blowfish.swift
  63. 0 104
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/CBCMAC.swift
  64. 0 20
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/CMAC.swift
  65. 0 347
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift
  66. 0 193
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Checksum.swift
  67. 0 47
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Cipher.swift
  68. 0 45
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Collection+Extension.swift
  69. 0 23
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/CompactMap.swift
  70. 0 22
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Cryptor.swift
  71. 0 44
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Cryptors.swift
  72. 0 78
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Digest.swift
  73. 0 18
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/DigestType.swift
  74. 0 23
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/AES+Foundation.swift
  75. 0 32
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Array+Foundation.swift
  76. 0 23
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift
  77. 0 22
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/ChaCha20+Foundation.swift
  78. 0 95
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Data+Extension.swift
  79. 0 22
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/HMAC+Foundation.swift
  80. 0 26
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift
  81. 0 41
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/String+FoundationExtension.swift
  82. 0 27
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Utils+Foundation.swift
  83. 0 55
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Generics.swift
  84. 0 84
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/HKDF.swift
  85. 0 102
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/HMAC.swift
  86. 0 38
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Int+Extension.swift
  87. 0 165
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/MD5.swift
  88. 0 27
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/NoPadding.swift
  89. 0 32
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Operators.swift
  90. 0 87
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF1.swift
  91. 0 116
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF2.swift
  92. 0 22
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS5.swift
  93. 0 18
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7.swift
  94. 0 64
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7Padding.swift
  95. 0 49
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Padding.swift
  96. 0 165
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Poly1305.swift
  97. 0 217
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Rabbit.swift
  98. 0 50
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/RandomBytesSequence.swift
  99. 0 151
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/SHA1.swift
  100. 0 0
      RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/SHA2.swift

+ 7 - 2
RainbowPlanet/Podfile

@@ -14,6 +14,11 @@ target 'RainbowPlanet' do
   # json解析
   pod 'SwiftyJSON'
   pod 'ObjectMapper'
+  # MoyaMapper
+#  pod 'MoyaMapper'
+#  pod 'MoyaMapper/Rx'
+  pod 'MoyaMapper/MMCache'
+#  pod 'MoyaMapper/RxCache'
   # 图片加载
   pod 'Kingfisher'
 #  pod 'Nuke'
@@ -48,8 +53,8 @@ target 'RainbowPlanet' do
   # 存储数据Keychain
   pod 'KeychainAccess'
 
-  # 加密
-  pod 'CryptoSwift'
+  #
+  pod 'ReactorKit'
 
   #======================第三方平台===========
   #======================友盟===========

+ 40 - 29
RainbowPlanet/Podfile.lock

@@ -1,42 +1,50 @@
 PODS:
-  - Alamofire (4.8.1)
+  - Alamofire (4.8.2)
   - AMapFoundation (1.5.6)
   - AMapLocation (2.6.1):
     - AMapFoundation (~> 1.4)
   - BMKLocationKit (1.5.0)
-  - CryptoSwift (0.15.0)
-  - DeviceKit (1.12.0)
-  - EFQRCode (4.5.0):
-    - swift_qrcodejs (~> 1.0.1)
+  - Cache (5.2.0)
+  - DeviceKit (1.13.0)
+  - EFQRCode (5.0.0):
+    - swift_qrcodejs (~> 1.1.1)
   - FBRetainCycleDetector (0.1.4)
   - FSPagerView (0.8.2)
   - FWPopupView (4.0.1):
     - SnapKit
-  - IQKeyboardManagerSwift (6.2.0)
+  - IQKeyboardManagerSwift (6.2.1)
   - JXCategoryView (1.3.0)
-  - KeychainAccess (3.1.2)
+  - KeychainAccess (3.2.0)
   - Kingfisher (4.10.1)
   - LYEmptyView (1.2.3)
   - MBProgressHUD (1.1.0)
   - MJRefresh (3.1.16)
   - MLeaksFinder (1.0.0):
     - FBRetainCycleDetector
+  - Moya (12.0.1):
+    - Moya/Core (= 12.0.1)
   - Moya/Core (12.0.1):
     - Alamofire (~> 4.1)
     - Result (~> 4.0)
   - Moya/RxSwift (12.0.1):
     - Moya/Core
     - RxSwift (~> 4.0)
+  - MoyaMapper/Core (1.2.1):
+    - Moya (>= 11.0.0)
+    - SwiftyJSON
+  - MoyaMapper/MMCache (1.2.1):
+    - Cache
+    - MoyaMapper/Core
   - ObjectMapper (3.4.2)
-  - PPBadgeViewSwift (2.2.2)
+  - PPBadgeViewSwift (3.0.0)
+  - ReactorKit (1.2.1):
+    - RxSwift (>= 4.0.0)
   - Result (4.1.0)
-  - RxAtomic (4.4.2)
-  - RxCocoa (4.4.2):
+  - RxCocoa (4.5.0):
     - RxSwift (>= 4.4.2, ~> 4.4)
-  - RxSwift (4.4.2):
-    - RxAtomic (>= 4.4.2, ~> 4.4)
+  - RxSwift (4.5.0)
   - SnapKit (4.2.0)
-  - swift_qrcodejs (1.0.1)
+  - swift_qrcodejs (1.1.1)
   - SwiftyJSON (4.2.0)
   - SwiftyStarRatingView (1.0.4)
   - UMCAnalytics (6.0.3):
@@ -65,7 +73,6 @@ DEPENDENCIES:
   - Alamofire
   - AMapLocation
   - BMKLocationKit
-  - CryptoSwift
   - DeviceKit
   - EFQRCode
   - FSPagerView
@@ -79,8 +86,10 @@ DEPENDENCIES:
   - MJRefresh
   - MLeaksFinder
   - Moya/RxSwift
+  - MoyaMapper/MMCache
   - ObjectMapper
   - PPBadgeViewSwift
+  - ReactorKit
   - RxCocoa
   - RxSwift
   - SnapKit
@@ -102,7 +111,7 @@ SPEC REPOS:
     - AMapFoundation
     - AMapLocation
     - BMKLocationKit
-    - CryptoSwift
+    - Cache
     - DeviceKit
     - EFQRCode
     - FBRetainCycleDetector
@@ -117,10 +126,11 @@ SPEC REPOS:
     - MJRefresh
     - MLeaksFinder
     - Moya
+    - MoyaMapper
     - ObjectMapper
     - PPBadgeViewSwift
+    - ReactorKit
     - Result
-    - RxAtomic
     - RxCocoa
     - RxSwift
     - SnapKit
@@ -135,33 +145,34 @@ SPEC REPOS:
     - UMCShare
 
 SPEC CHECKSUMS:
-  Alamofire: 16ce2c353fb72865124ddae8a57c5942388f4f11
+  Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
   AMapFoundation: 20fce2a12cd152e1092afdd04379cdac21932185
   AMapLocation: cf024b53dc03663efb4ea4bcce27d4cce58bb97a
   BMKLocationKit: 40d267478acd8704ddebd0e9deaddc727b13df9f
-  CryptoSwift: 769f58a9e89f64e8796c2e59ce5f002dc81a2438
-  DeviceKit: f5dbd2e70cafd420d6a09379b8800cdf5fe92ba5
-  EFQRCode: 842f431e660da841f518993af8f4cbd275601d84
+  Cache: 807c5d86d01a177f06ede9865add3aea269bbfd4
+  DeviceKit: 5a4accdb2918ce0b69e62dc3bef6e4d2cc06e2e4
+  EFQRCode: 07437cfbce3a1e497397a4f3d766c980d8972608
   FBRetainCycleDetector: 46f8179bbb1c587deee3ea838a1a3ee02acf5015
   FSPagerView: 816a18842306973cc7cc6df8a5332272f7815c30
   FWPopupView: a463a17aab606b0ef222a68784dbf32accba4711
-  IQKeyboardManagerSwift: b07ccf9d8cafe993dcd6cb794eb4ba34611a0c4e
+  IQKeyboardManagerSwift: 0f0ae8935360b4003e6ea1ac7c19898f01e2f7c7
   JXCategoryView: b3bf1bedb51b5f98b63d51f0e31007a2ef80de14
-  KeychainAccess: b3816fddcf28aa29d94b10ec305cd52be14c472b
+  KeychainAccess: 3b1bf8a77eb4c6ea1ce9404c292e48f948954c6b
   Kingfisher: c148cd7b47ebde9989f6bc7c27dcaa79d81279a0
   LYEmptyView: ea5827f3f81fcbec427f990005501991477bdae8
   MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
   MJRefresh: 7798e16e53a5ef7f332dd05b27664db4e29530fd
   MLeaksFinder: 8c435bd2f6d070af18cff082b503b21adc130fc0
   Moya: cf730b3cd9e005401ef37a85143aa141a12fd38f
+  MoyaMapper: 18b9351707f53778d263a987e740252f039521ba
   ObjectMapper: 0d4402610f4e468903ae64629eec4784531e5c51
-  PPBadgeViewSwift: 96a41852df7437e9d948565a1bc894f757c29933
+  PPBadgeViewSwift: b769847e864f46115cb2cd0c6764b4e3eb04f73e
+  ReactorKit: 8be57f0527ad1ac2963cd5c338274a46a01e57a3
   Result: bd966fac789cc6c1563440b348ab2598cc24d5c7
-  RxAtomic: d00e97c10db88c6f08540e0bf2752fc5a2404167
-  RxCocoa: 477990dc3b4c3ff55fb0ac77e1cc06244e0aaec8
-  RxSwift: 74c29b693c8e42b0f64400e8b06564575742d649
+  RxCocoa: cbf70265dc65a981d4ac982e513c10cf23df24a0
+  RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
   SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a
-  swift_qrcodejs: c181fe5c849d30c699546a23762d7e3dd143ab37
+  swift_qrcodejs: 0bacbfe321a99954c7b8e04c75562007ea4e4f7c
   SwiftyJSON: c4bcba26dd9ec7a027fc8eade48e2c911f229e96
   SwiftyStarRatingView: a2b0057700e0adeb8e7442c55d99cb53b531d2f4
   UMCAnalytics: ff58714ada407682c4a07548156f94bcec92f055
@@ -171,6 +182,6 @@ SPEC CHECKSUMS:
   UMCSecurityPlugins: 0831a08f3988f3cea9f1d3a7626cd9bee4fef150
   UMCShare: 552b29753f1b4da87b51d96545ed19e6263df397
 
-PODFILE CHECKSUM: f05eb443e8bd560c9fbf7cdfad37835958e0c336
+PODFILE CHECKSUM: 53ec3d3118172c9efb758ca5d5a32e4f4ab6acaa
 
-COCOAPODS: 1.5.3
+COCOAPODS: 1.6.1

+ 1 - 1
RainbowPlanet/Pods/Alamofire/Source/MultipartFormData.swift

@@ -98,7 +98,7 @@ open class MultipartFormData {
     public var contentLength: UInt64 { return bodyParts.reduce(0) { $0 + $1.bodyContentLength } }
 
     /// The boundary used to separate the body parts in the encoded form data.
-    public let boundary: String
+    public var boundary: String
 
     private var bodyParts: [BodyPart]
     private var bodyPartError: AFError?

+ 22 - 0
RainbowPlanet/Pods/Cache/LICENSE.md

@@ -0,0 +1,22 @@
+Licensed under the **MIT** license
+
+> Copyright (c) 2015 Hyper Interaktiv AS
+>
+> Permission is hereby granted, free of charge, to any person obtaining
+> a copy of this software and associated documentation files (the
+> "Software"), to deal in the Software without restriction, including
+> without limitation the rights to use, copy, modify, merge, publish,
+> distribute, sublicense, and/or sell copies of the Software, and to
+> permit persons to whom the Software is furnished to do so, subject to
+> the following conditions:
+>
+> The above copyright notice and this permission notice shall be
+> included in all copies or substantial portions of the Software.
+>
+> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 429 - 0
RainbowPlanet/Pods/Cache/README.md

@@ -0,0 +1,429 @@
+![Cache](https://github.com/hyperoslo/Cache/blob/master/Resources/CachePresentation.png)
+
+[![CI Status](https://circleci.com/gh/hyperoslo/Cache.png)](https://circleci.com/gh/hyperoslo/Cache)
+[![Version](https://img.shields.io/cocoapods/v/Cache.svg?style=flat)](http://cocoadocs.org/docsets/Cache)
+[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
+[![License](https://img.shields.io/cocoapods/l/Cache.svg?style=flat)](http://cocoadocs.org/docsets/Cache)
+[![Platform](https://img.shields.io/cocoapods/p/Cache.svg?style=flat)](http://cocoadocs.org/docsets/Cache)
+[![Documentation](https://img.shields.io/cocoapods/metrics/doc-percent/Cache.svg?style=flat)](http://cocoadocs.org/docsets/Cache)
+![Swift](https://img.shields.io/badge/%20in-swift%204.0-orange.svg)
+
+## Table of Contents
+
+* [Description](#description)
+* [Key features](#key-features)
+* [Usage](#usage)
+  * [Storage](#storage)
+  * [Configuration](#configuration)
+  * [Sync APIs](#sync-apis)
+  * [Async APIS](#async-apis)
+  * [Expiry date](#expiry-date)
+* [Observations](#observations)
+  * [Storage observations](#storage-observations)
+  * [Key observations](#key-observations)
+* [Handling JSON response](#handling-json-response)
+* [What about images?](#what-about-images)
+* [Installation](#installation)
+* [Author](#author)
+* [Contributing](#contributing)
+* [License](#license)
+
+## Description
+
+<img src="https://github.com/hyperoslo/Cache/blob/master/Resources/CacheIcon.png" alt="Cache Icon" align="right" />
+
+**Cache** doesn't claim to be unique in this area, but it's not another monster
+library that gives you a god's power. It does nothing but caching, but it does it well. It offers a good public API
+with out-of-box implementations and great customization possibilities. `Cache` utilizes `Codable` in Swift 4 to perform serialization.
+
+Read the story here [Open Source Stories: From Cachable to Generic Storage in Cache](https://medium.com/hyperoslo/open-source-stories-from-cachable-to-generic-storage-in-cache-418d9a230d51)
+
+## Key features
+
+- [x] Work with Swift 4 `Codable`. Anything conforming to `Codable` will be saved and loaded easily by `Storage`.
+- [x] Hybrid with memory and disk storage.
+- [X] Many options via `DiskConfig` and `MemoryConfig`.
+- [x] Support `expiry` and clean up of expired objects.
+- [x] Thread safe. Operations can be accessed from any queue.
+- [x] Sync by default. Also support Async APIs.
+- [x] Extensive unit test coverage and great documentation.
+- [x] iOS, tvOS and macOS support.
+
+## Usage
+
+### Storage
+
+`Cache` is built based on [Chain-of-responsibility pattern](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern), in which there are many processing objects, each knows how to do 1 task and delegates to the next one, so can you compose Storages the way you like.
+
+For now the following Storage are supported
+
+- `MemoryStorage`: save object to memory.
+- `DiskStorage`: save object to disk.
+- `HybridStorage`: save object to memory and disk, so you get persistented object on disk, while fast access with in memory objects.
+- `SyncStorage`: blocking APIs, all read and write operations are scheduled in a serial queue, all sync manner.
+- `AsyncStorage`: non-blocking APIs, operations are scheduled in an internal queue for serial processing. No read and write should happen at the same time.
+
+Although you can use those Storage at your discretion, you don't have to. Because we also provide a convenient `Storage` which uses `HybridStorage` under the hood, while exposes sync and async APIs through `SyncStorage` and `AsyncStorage`.
+
+All you need to do is to specify the configuration you want with `DiskConfig` and `MemoryConfig`. The default configurations are good to go, but you can customise a lot.
+
+
+```swift
+let diskConfig = DiskConfig(name: "Floppy")
+let memoryConfig = MemoryConfig(expiry: .never, countLimit: 10, totalCostLimit: 10)
+
+let storage = try? Storage(
+  diskConfig: diskConfig,
+  memoryConfig: memoryConfig,
+  transformer: TransformerFactory.forCodable(ofType: User.self) // Storage<User>
+)
+```
+
+### Generic, Type safety and Transformer
+
+All `Storage` now are generic by default, so you can get a type safety experience. Once you create a Storage, it has a type constraint that you don't need to specify type for each operation afterwards.
+
+If you want to change the type, `Cache` offers `transform` functions, look for `Transformer` and `TransformerFactory` for built-in transformers.
+
+```swift
+let storage: Storage<User> = ...
+storage.setObject(superman, forKey: "user")
+
+let imageStorage = storage.transformImage() // Storage<UIImage>
+imageStorage.setObject(image, forKey: "image")
+
+let stringStorage = storage.transformCodable(ofType: String.self) // Storage<String>
+stringStorage.setObject("hello world", forKey: "string")
+```
+
+Each transformation allows you to work with a specific type, however the underlying caching mechanism remains the same, you're working with the same `Storage`, just with different type annotation. You can also create different `Storage` for each type if you want.
+
+`Transformer` is necessary because the need of serialising and deserialising objects to and from `Data` for disk persistency. `Cache` provides default `Transformer ` for `Data`, `Codable` and `UIImage/NSImage`
+
+#### Codable types
+
+`Storage` supports any objects that conform to [Codable](https://developer.apple.com/documentation/swift/codable) protocol. You can [make your own things conform to Codable](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types) so that can be saved and loaded from `Storage`.
+
+The supported types are
+
+- Primitives like `Int`, `Float`, `String`, `Bool`, ...
+- Array of primitives like `[Int]`, `[Float]`, `[Double]`, ...
+- Set of primitives like `Set<String>`, `Set<Int>`, ...
+- Simply dictionary like `[String: Int]`, `[String: String]`, ...
+- `Date`
+- `URL`
+- `Data`
+
+#### Error handling
+
+Error handling is done via `try catch`. `Storage` throws errors in terms of `StorageError`.
+
+```swift
+public enum StorageError: Error {
+  /// Object can not be found
+  case notFound
+  /// Object is found, but casting to requested type failed
+  case typeNotMatch
+  /// The file attributes are malformed
+  case malformedFileAttributes
+  /// Can't perform Decode
+  case decodingFailed
+  /// Can't perform Encode
+  case encodingFailed
+  /// The storage has been deallocated
+  case deallocated
+  /// Fail to perform transformation to or from Data
+  case transformerFail
+}
+```
+
+There can be errors because of disk problem or type mismatch when loading from storage, so if want to handle errors, you need to do `try catch`
+
+```swift
+do {
+  let storage = try Storage(diskConfig: diskConfig, memoryConfig: memoryConfig)
+} catch {
+  print(error)
+}
+```
+
+### Configuration
+
+Here is how you can play with many configuration options
+
+```swift
+let diskConfig = DiskConfig(
+  // The name of disk storage, this will be used as folder name within directory
+  name: "Floppy",
+  // Expiry date that will be applied by default for every added object
+  // if it's not overridden in the `setObject(forKey:expiry:)` method
+  expiry: .date(Date().addingTimeInterval(2*3600)),
+  // Maximum size of the disk cache storage (in bytes)
+  maxSize: 10000,
+  // Where to store the disk cache. If nil, it is placed in `cachesDirectory` directory.
+  directory: try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask,
+    appropriateFor: nil, create: true).appendingPathComponent("MyPreferences"),
+  // Data protection is used to store files in an encrypted format on disk and to decrypt them on demand
+  protectionType: .complete
+)
+```
+
+```swift
+let memoryConfig = MemoryConfig(
+  // Expiry date that will be applied by default for every added object
+  // if it's not overridden in the `setObject(forKey:expiry:)` method
+  expiry: .date(Date().addingTimeInterval(2*60)),
+  /// The maximum number of objects in memory the cache should hold
+  countLimit: 50,
+  /// The maximum total cost that the cache can hold before it starts evicting objects
+  totalCostLimit: 0
+)
+```
+
+On iOS, tvOS we can also specify `protectionType` on `DiskConfig` to add a level of security to files stored on disk by your app in the app’s container. For more information, see [FileProtectionType](https://developer.apple.com/documentation/foundation/fileprotectiontype)
+
+### Sync APIs
+
+`Storage` is sync by default and is `thread safe`, you can access it from any queues. All Sync functions are constrained by `StorageAware` protocol.
+
+```swift
+// Save to storage
+try? storage.setObject(10, forKey: "score")
+try? storage.setObject("Oslo", forKey: "my favorite city", expiry: .never)
+try? storage.setObject(["alert", "sounds", "badge"], forKey: "notifications")
+try? storage.setObject(data, forKey: "a bunch of bytes")
+try? storage.setObject(authorizeURL, forKey: "authorization URL")
+
+// Load from storage
+let score = try? storage.object(forKey: "score")
+let favoriteCharacter = try? storage.object(forKey: "my favorite city")
+
+// Check if an object exists
+let hasFavoriteCharacter = try? storage.existsObject(forKey: "my favorite city")
+
+// Remove an object in storage
+try? storage.removeObject(forKey: "my favorite city")
+
+// Remove all objects
+try? storage.removeAll()
+
+// Remove expired objects
+try? storage.removeExpiredObjects()
+```
+
+#### Entry
+
+There is time you want to get object together with its expiry information and meta data. You can use `Entry`
+
+```swift
+let entry = try? storage.entry(forKey: "my favorite city")
+print(entry?.object)
+print(entry?.expiry)
+print(entry?.meta)
+```
+
+`meta` may contain file information if the object was fetched from disk storage.
+
+#### Custom Codable
+
+`Codable` works for simple dictionary like `[String: Int]`, `[String: String]`, ... It does not work for `[String: Any]` as `Any` is not `Codable` conformance, it will raise `fatal error` at runtime. So when you get json from backend responses, you need to convert that to your custom `Codable` objects and save to `Storage` instead.
+
+```swift
+struct User: Codable {
+  let firstName: String
+  let lastName: String
+}
+
+let user = User(fistName: "John", lastName: "Snow")
+try? storage.setObject(user, forKey: "character")
+```
+
+### Async APIs
+
+In `async` fashion, you deal with `Result` instead of `try catch` because the result is delivered at a later time, in order to not block the current calling queue. In the completion block, you either have `value` or `error`.
+
+You access Async APIs via `storage.async`, it is also thread safe, and you can use Sync and Async APIs in any order you want. All Async functions are constrained by `AsyncStorageAware` protocol.
+
+```swift
+storage.async.setObject("Oslo", forKey: "my favorite city") { result in
+  switch result {
+    case .value:
+      print("saved successfully")
+    case .error(let error):
+      print(error)
+  }
+}
+
+storage.async.object(forKey: "my favorite city") { result in
+  switch result {
+    case .value(let city):
+      print("my favorite city is \(city)")
+    case .error(let error):
+      print(error)
+  }
+}
+
+storage.async.existsObject(forKey: "my favorite city") { result in
+  if case .value(let exists) = result, exists {
+    print("I have a favorite city")
+  }
+}
+
+storage.async.removeAll() { result in
+  switch result {
+    case .value:
+      print("removal completes")
+    case .error(let error):
+      print(error)
+  }
+}
+
+storage.async.removeExpiredObjects() { result in
+  switch result {
+    case .value:
+      print("removal completes")
+    case .error(let error):
+      print(error)
+  }
+}
+```
+
+### Expiry date
+
+By default, all saved objects have the same expiry as the expiry you specify in `DiskConfig` or `MemoryConfig`. You can overwrite this for a specific object by specifying `expiry` for `setObject`
+
+```swift
+// Default expiry date from configuration will be applied to the item
+try? storage.setObject("This is a string", forKey: "string")
+
+// A given expiry date will be applied to the item
+try? storage.setObject(
+  "This is a string",
+  forKey: "string"
+  expiry: .date(Date().addingTimeInterval(2 * 3600))
+)
+
+// Clear expired objects
+storage.removeExpiredObjects()
+```
+
+## Observations
+
+[Storage](#storage) allows you to observe changes in the cache layer, both on
+a store and a key levels. The API lets you pass any object as an observer,
+while also passing an observation closure. The observation closure will be
+removed automatically when the weakly captured observer has been deallocated.
+
+## Storage observations
+
+```swift
+// Add observer
+let token = storage.addStorageObserver(self) { observer, storage, change in
+  switch change {
+  case .add(let key):
+    print("Added \(key)")
+  case .remove(let key):
+    print("Removed \(key)")
+  case .removeAll:
+    print("Removed all")
+  case .removeExpired:
+    print("Removed expired")
+  }
+}
+
+// Remove observer
+token.cancel()
+
+// Remove all observers
+storage.removeAllStorageObservers()
+```
+
+## Key observations
+
+```swift
+let key = "user1"
+
+let token = storage.addObserver(self, forKey: key) { observer, storage, change in
+  switch change {
+  case .edit(let before, let after):
+    print("Changed object for \(key) from \(String(describing: before)) to \(after)")
+  case .remove:
+    print("Removed \(key)")
+  }
+}
+
+// Remove observer by token
+token.cancel()
+
+// Remove observer for key
+storage.removeObserver(forKey: key)
+
+// Remove all observers
+storage.removeAllKeyObservers()
+```
+
+## Handling JSON response
+
+Most of the time, our use case is to fetch some json from backend, display it while saving the json to storage for future uses. If you're using libraries like [Alamofire](https://github.com/Alamofire/Alamofire) or [Malibu](https://github.com/hyperoslo/Malibu), you mostly get json in the form of dictionary, string, or data.
+
+`Storage` can persist `String` or `Data`. You can even save json to `Storage` using `JSONArrayWrapper` and `JSONDictionaryWrapper`, but we prefer persisting the strong typed objects, since those are the objects that you will use to display in UI. Furthermore, if the json data can't be converted to strongly typed objects, what's the point of saving it ? 😉
+
+You can use these extensions on `JSONDecoder` to decode json dictionary, string or data to objects.
+
+```swift
+let user = JSONDecoder.decode(jsonString, to: User.self)
+let cities = JSONDecoder.decode(jsonDictionary, to: [City].self)
+let dragons = JSONDecoder.decode(jsonData, to: [Dragon].self)
+```
+
+This is how you perform object converting and saving with `Alamofire`
+
+```swift
+Alamofire.request("https://gameofthrones.org/mostFavoriteCharacter").responseString { response in
+  do {
+    let user = try JSONDecoder.decode(response.result.value, to: User.self)
+    try storage.setObject(user, forKey: "most favorite character")
+  } catch {
+    print(error)
+  }
+}
+```
+
+## What about images
+
+If you want to load image into `UIImageView` or `NSImageView`, then we also have a nice gift for you. It's called [Imaginary](https://github.com/hyperoslo/Imaginary) and uses `Cache` under the hood to make you life easier when it comes to working with remote images.
+
+## Installation
+
+### Cocoapods
+
+**Cache** is available through [CocoaPods](http://cocoapods.org). To install
+it, simply add the following line to your Podfile:
+
+```ruby
+pod 'Cache'
+```
+
+### Carthage
+
+**Cache** is also available through [Carthage](https://github.com/Carthage/Carthage).
+To install just write into your Cartfile:
+
+```ruby
+github "hyperoslo/Cache"
+```
+
+You also need to add `SwiftHash.framework` in your [copy-frameworks](https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos) script.
+
+## Author
+
+- [Hyper](http://hyper.no) made this with ❤️
+- Inline MD5 implementation from [SwiftHash](https://github.com/onmyway133/SwiftHash)
+
+## Contributing
+
+We would love you to contribute to **Cache**, check the [CONTRIBUTING](https://github.com/hyperoslo/Cache/blob/master/CONTRIBUTING.md) file for more info.
+
+## License
+
+**Cache** is available under the MIT license. See the [LICENSE](https://github.com/hyperoslo/Cache/blob/master/LICENSE.md) file for more info.

+ 36 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Configuration/DiskConfig.swift

@@ -0,0 +1,36 @@
+import Foundation
+
+public struct DiskConfig {
+  /// The name of disk storage, this will be used as folder name within directory
+  public let name: String
+  /// Expiry date that will be applied by default for every added object
+  /// if it's not overridden in the add(key: object: expiry: completion:) method
+  public let expiry: Expiry
+  /// Maximum size of the disk cache storage (in bytes)
+  public let maxSize: UInt
+  /// A folder to store the disk cache contents. Defaults to a prefixed directory in Caches if nil
+  public let directory: URL?
+  #if os(iOS) || os(tvOS)
+  /// Data protection is used to store files in an encrypted format on disk and to decrypt them on demand.
+  /// Support only on iOS and tvOS.
+  public let protectionType: FileProtectionType?
+
+  public init(name: String, expiry: Expiry = .never,
+              maxSize: UInt = 0, directory: URL? = nil,
+              protectionType: FileProtectionType? = nil) {
+    self.name = name
+    self.expiry = expiry
+    self.maxSize = maxSize
+    self.directory = directory
+    self.protectionType = protectionType
+  }
+  #else
+  public init(name: String, expiry: Expiry = .never,
+              maxSize: UInt = 0, directory: URL? = nil) {
+    self.name = name
+    self.expiry = expiry
+    self.maxSize = maxSize
+    self.directory = directory
+  }
+  #endif
+}

+ 20 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Configuration/MemoryConfig.swift

@@ -0,0 +1,20 @@
+import Foundation
+
+public struct MemoryConfig {
+  /// Expiry date that will be applied by default for every added object
+  /// if it's not overridden in the add(key: object: expiry: completion:) method
+  public let expiry: Expiry
+  /// The maximum number of objects in memory the cache should hold.
+  /// If 0, there is no count limit. The default value is 0.
+  public let countLimit: UInt
+
+  /// The maximum total cost that the cache can hold before it starts evicting objects.
+  /// If 0, there is no total cost limit. The default value is 0
+  public let totalCostLimit: UInt
+
+  public init(expiry: Expiry = .never, countLimit: UInt = 0, totalCostLimit: UInt = 0) {
+    self.expiry = expiry
+    self.countLimit = countLimit
+    self.totalCostLimit = totalCostLimit
+  }
+}

+ 12 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Extensions/Date+Extensions.swift

@@ -0,0 +1,12 @@
+import Foundation
+
+/**
+ Helper NSDate extension.
+ */
+extension Date {
+
+  /// Checks if the date is in the past.
+  var inThePast: Bool {
+    return timeIntervalSinceNow < 0
+  }
+}

+ 42 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Extensions/JSONDecoder+Extensions.swift

@@ -0,0 +1,42 @@
+import Foundation
+
+/// Convert json string, dictionary, data to Codable objects
+public extension JSONDecoder {
+  /// Convert json string to Codable object
+  ///
+  /// - Parameters:
+  ///   - string: Json string.
+  ///   - type: Type information.
+  /// - Returns: Codable object.
+  /// - Throws: Error if failed.
+  static func decode<T: Codable>(_ string: String, to type: T.Type) throws -> T {
+    guard let data = string.data(using: .utf8) else {
+      throw StorageError.decodingFailed
+    }
+
+    return try decode(data, to: type.self)
+  }
+
+  /// Convert json dictionary to Codable object
+  ///
+  /// - Parameters:
+  ///   - json: Json dictionary.
+  ///   - type: Type information.
+  /// - Returns: Codable object
+  /// - Throws: Error if failed
+  static func decode<T: Codable>(_ json: [String: Any], to type: T.Type) throws -> T {
+    let data = try JSONSerialization.data(withJSONObject: json, options: [])
+    return try decode(data, to: type)
+  }
+
+  /// Convert json data to Codable object
+  ///
+  /// - Parameters:
+  ///   - json: Json dictionary.
+  ///   - type: Type information.
+  /// - Returns: Codable object
+  /// - Throws: Error if failed
+  static func decode<T: Codable>(_ data: Data, to type: T.Type) throws -> T {
+    return try JSONDecoder().decode(T.self, from: data)
+  }
+}

+ 25 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/DataSerializer.swift

@@ -0,0 +1,25 @@
+import Foundation
+
+/// Convert to and from data
+class DataSerializer {
+
+  /// Convert object to data
+  ///
+  /// - Parameter object: The object to convert
+  /// - Returns: Data
+  /// - Throws: Encoder error if any
+  static func serialize<T: Encodable>(object: T) throws -> Data {
+    let encoder = JSONEncoder()
+    return try encoder.encode(object)
+  }
+
+  /// Convert data to object
+  ///
+  /// - Parameter data: The data to convert
+  /// - Returns: The object
+  /// - Throws: Decoder error if any
+  static func deserialize<T: Decodable>(data: Data) throws -> T {
+    let decoder = JSONDecoder()
+    return try decoder.decode(T.self, from: data)
+  }
+}

+ 17 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/Entry.swift

@@ -0,0 +1,17 @@
+import Foundation
+
+/// A wrapper around cached object and its expiry date.
+public struct Entry<T> {
+  /// Cached object
+  public let object: T
+  /// Expiry date
+  public let expiry: Expiry
+  /// File path to the cached object
+  public let filePath: String?
+
+  init(object: T, expiry: Expiry, filePath: String? = nil) {
+    self.object = object
+    self.expiry = expiry
+    self.filePath = filePath
+  }
+}

+ 10 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/ExpirationMode.swift

@@ -0,0 +1,10 @@
+/// Sets the expiration mode for the `CacheManager`. The default value is `.auto` which means that `Cache`
+/// will handle expiration internally. It will trigger cache clean up tasks depending on the events its receives
+/// from the application. If expiration mode is set to manual, it means that you manually have to invoke the clear
+/// cache methods yourself.
+///
+/// - auto: Automatic cleanup of expired objects (default).
+/// - manual: Manual means that you opt out from any automatic expiration handling.
+public enum ExpirationMode {
+  case auto, manual
+}

+ 31 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/Expiry.swift

@@ -0,0 +1,31 @@
+import Foundation
+
+/**
+ Helper enum to set the expiration date
+ */
+public enum Expiry {
+  /// Object will be expired in the nearest future
+  case never
+  /// Object will be expired in the specified amount of seconds
+  case seconds(TimeInterval)
+  /// Object will be expired on the specified date
+  case date(Date)
+
+  /// Returns the appropriate date object
+  public var date: Date {
+    switch self {
+    case .never:
+      // Ref: http://lists.apple.com/archives/cocoa-dev/2005/Apr/msg01833.html
+      return Date(timeIntervalSince1970: 60 * 60 * 24 * 365 * 68)
+    case .seconds(let seconds):
+      return Date().addingTimeInterval(seconds)
+    case .date(let date):
+      return date
+    }
+  }
+
+  /// Checks if cached object is expired according to expiration date
+  public var isExpired: Bool {
+    return date.inThePast
+  }
+}

+ 32 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/ImageWrapper.swift

@@ -0,0 +1,32 @@
+import Foundation
+
+public struct ImageWrapper: Codable {
+  public let image: Image
+
+  public enum CodingKeys: String, CodingKey {
+    case image
+  }
+
+  public init(image: Image) {
+    self.image = image
+  }
+
+  public init(from decoder: Decoder) throws {
+    let container = try decoder.container(keyedBy: CodingKeys.self)
+    let data = try container.decode(Data.self, forKey: CodingKeys.image)
+    guard let image = Image(data: data) else {
+      throw StorageError.decodingFailed
+    }
+
+    self.image = image
+  }
+
+  public func encode(to encoder: Encoder) throws {
+    var container = encoder.container(keyedBy: CodingKeys.self)
+    guard let data = image.cache_toData() else {
+        throw StorageError.encodingFailed
+    }
+
+    try container.encode(data, forKey: CodingKeys.image)
+  }
+}

+ 40 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/JSONArrayWrapper.swift

@@ -0,0 +1,40 @@
+import Foundation
+
+public typealias JSONArray = [JSONDictionary]
+
+public struct JSONArrayWrapper: Codable {
+  public let jsonArray: JSONArray
+
+  public enum CodingKeys: String, CodingKey {
+    case jsonArray
+  }
+
+  public init(jsonArray: JSONArray) {
+    self.jsonArray = jsonArray
+  }
+
+  public init(from decoder: Decoder) throws {
+    let container = try decoder.container(keyedBy: CodingKeys.self)
+    let data = try container.decode(Data.self, forKey: CodingKeys.jsonArray)
+    let object = try JSONSerialization.jsonObject(
+      with: data,
+      options: []
+    )
+
+    guard let jsonArray = object as? JSONArray else {
+      throw StorageError.decodingFailed
+    }
+
+    self.jsonArray = jsonArray
+  }
+
+  public func encode(to encoder: Encoder) throws {
+    var container = encoder.container(keyedBy: CodingKeys.self)
+    let data = try JSONSerialization.data(
+      withJSONObject: jsonArray,
+      options: []
+    )
+
+    try container.encode(data, forKey: CodingKeys.jsonArray)
+  }
+}

+ 40 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/JSONDictionaryWrapper.swift

@@ -0,0 +1,40 @@
+import Foundation
+
+public typealias JSONDictionary = [String: Any]
+
+public struct JSONDictionaryWrapper: Codable {
+  public let jsonDictionary: JSONDictionary
+
+  public enum CodingKeys: String, CodingKey {
+    case jsonDictionary
+  }
+
+  public init(jsonDictionary: JSONDictionary) {
+    self.jsonDictionary = jsonDictionary
+  }
+
+  public init(from decoder: Decoder) throws {
+    let container = try decoder.container(keyedBy: CodingKeys.self)
+    let data = try container.decode(Data.self, forKey: CodingKeys.jsonDictionary)
+    let object = try JSONSerialization.jsonObject(
+      with: data,
+      options: []
+    )
+
+    guard let jsonDictionary = object as? JSONDictionary else {
+      throw StorageError.decodingFailed
+    }
+
+    self.jsonDictionary = jsonDictionary
+  }
+
+  public func encode(to encoder: Encoder) throws {
+    var container = encoder.container(keyedBy: CodingKeys.self)
+    let data = try JSONSerialization.data(
+      withJSONObject: jsonDictionary,
+      options: []
+    )
+
+    try container.encode(data, forKey: CodingKeys.jsonDictionary)
+  }
+}

+ 281 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/MD5.swift

@@ -0,0 +1,281 @@
+// swiftlint:disable comma function_parameter_count variable_name syntactic_sugar function_body_length vertical_whitespace
+
+// https://github.com/onmyway133/SwiftHash/blob/master/Sources/MD5.swift
+
+/*
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for more info.
+ */
+
+/**
+ *  SwiftHash
+ *  Copyright (c) Khoa Pham 2017
+ *  Licensed under the MIT license. See LICENSE file.
+ */
+
+import Foundation
+
+// MARK: - Public
+
+public func MD5(_ input: String) -> String {
+  return hex_md5(input)
+}
+
+// MARK: - Functions
+
+func hex_md5(_ input: String) -> String {
+  return rstr2hex(rstr_md5(str2rstr_utf8(input)))
+}
+
+func str2rstr_utf8(_ input: String) -> [CUnsignedChar] {
+  return Array(input.utf8)
+}
+
+func rstr2tr(_ input: [CUnsignedChar]) -> String {
+  var output: String = ""
+
+  input.forEach {
+    output.append(String(UnicodeScalar($0)))
+  }
+
+  return output
+}
+
+/*
+ * Convert a raw string to a hex string
+ */
+func rstr2hex(_ input: [CUnsignedChar]) -> String {
+  let hexTab: [Character] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
+  var output: [Character] = []
+
+  for i in 0..<input.count {
+    let x = input[i]
+    let value1 = hexTab[Int((x >> 4) & 0x0F)]
+    let value2 = hexTab[Int(Int32(x) & 0x0F)]
+
+    output.append(value1)
+    output.append(value2)
+  }
+
+  return String(output)
+}
+
+/*
+ * Convert a raw string to an array of little-endian words
+ * Characters >255 have their high-byte silently ignored.
+ */
+func rstr2binl(_ input: [CUnsignedChar]) -> [Int32] {
+  var output: [Int: Int32] = [:]
+
+  for i in stride(from: 0, to: input.count * 8, by: 8) {
+    let value: Int32 = (Int32(input[i/8]) & 0xFF) << (Int32(i) % 32)
+
+    output[i >> 5] = unwrap(output[i >> 5]) | value
+  }
+
+  return dictionary2array(output)
+}
+
+/*
+ * Convert an array of little-endian words to a string
+ */
+func binl2rstr(_ input: [Int32]) -> [CUnsignedChar] {
+  var output: [CUnsignedChar] = []
+
+  for i in stride(from: 0, to: input.count * 32, by: 8) {
+    // [i>>5] >>>
+    let value: Int32 = zeroFillRightShift(input[i>>5], Int32(i % 32)) & 0xFF
+    output.append(CUnsignedChar(value))
+  }
+
+  return output
+}
+
+/*
+ * Calculate the MD5 of a raw string
+ */
+func rstr_md5(_ input: [CUnsignedChar]) -> [CUnsignedChar] {
+  return binl2rstr(binl_md5(rstr2binl(input), input.count * 8))
+}
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+func safe_add(_ x: Int32, _ y: Int32) -> Int32 {
+  let lsw = (x & 0xFFFF) + (y & 0xFFFF)
+  let msw = (x >> 16) + (y >> 16) + (lsw >> 16)
+  return (msw << 16) | (lsw & 0xFFFF)
+}
+
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+func bit_rol(_ num: Int32, _ cnt: Int32) -> Int32 {
+  // num >>>
+  return (num << cnt) | zeroFillRightShift(num, (32 - cnt))
+}
+
+
+/*
+ * These funcs implement the four basic operations the algorithm uses.
+ */
+func md5_cmn(_ q: Int32, _ a: Int32, _ b: Int32, _ x: Int32, _ s: Int32, _ t: Int32) -> Int32 {
+  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
+}
+
+func md5_ff(_ a: Int32, _ b: Int32, _ c: Int32, _ d: Int32, _ x: Int32, _ s: Int32, _ t: Int32) -> Int32 {
+  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t)
+}
+
+func md5_gg(_ a: Int32, _ b: Int32, _ c: Int32, _ d: Int32, _ x: Int32, _ s: Int32, _ t: Int32) -> Int32 {
+  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t)
+}
+
+func md5_hh(_ a: Int32, _ b: Int32, _ c: Int32, _ d: Int32, _ x: Int32, _ s: Int32, _ t: Int32) -> Int32 {
+  return md5_cmn(b ^ c ^ d, a, b, x, s, t)
+}
+
+func md5_ii(_ a: Int32, _ b: Int32, _ c: Int32, _ d: Int32, _ x: Int32, _ s: Int32, _ t: Int32) -> Int32 {
+  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t)
+}
+
+
+/*
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
+ */
+func binl_md5(_ input: [Int32], _ len: Int) -> [Int32] {
+  /* append padding */
+
+  var x: [Int: Int32] = [:]
+  for (index, value) in input.enumerated() {
+    x[index] = value
+  }
+
+  let value: Int32 = 0x80 << Int32((len) % 32)
+  x[len >> 5] = unwrap(x[len >> 5]) | value
+
+  // >>> 9
+  let index = (((len + 64) >> 9) << 4) + 14
+  x[index] = unwrap(x[index]) | Int32(len)
+
+  var a: Int32 =  1732584193
+  var b: Int32 = -271733879
+  var c: Int32 = -1732584194
+  var d: Int32 =  271733878
+
+  for i in stride(from: 0, to: length(x), by: 16) {
+    let olda: Int32 = a
+    let oldb: Int32 = b
+    let oldc: Int32 = c
+    let oldd: Int32 = d
+
+    a = md5_ff(a, b, c, d, unwrap(x[i + 0]), 7 , -680876936)
+    d = md5_ff(d, a, b, c, unwrap(x[i + 1]), 12, -389564586)
+    c = md5_ff(c, d, a, b, unwrap(x[i + 2]), 17,  606105819)
+    b = md5_ff(b, c, d, a, unwrap(x[i + 3]), 22, -1044525330)
+    a = md5_ff(a, b, c, d, unwrap(x[i + 4]), 7 , -176418897)
+    d = md5_ff(d, a, b, c, unwrap(x[i + 5]), 12,  1200080426)
+    c = md5_ff(c, d, a, b, unwrap(x[i + 6]), 17, -1473231341)
+    b = md5_ff(b, c, d, a, unwrap(x[i + 7]), 22, -45705983)
+    a = md5_ff(a, b, c, d, unwrap(x[i + 8]), 7 ,  1770035416)
+    d = md5_ff(d, a, b, c, unwrap(x[i + 9]), 12, -1958414417)
+    c = md5_ff(c, d, a, b, unwrap(x[i + 10]), 17, -42063)
+    b = md5_ff(b, c, d, a, unwrap(x[i + 11]), 22, -1990404162)
+    a = md5_ff(a, b, c, d, unwrap(x[i + 12]), 7 ,  1804603682)
+    d = md5_ff(d, a, b, c, unwrap(x[i + 13]), 12, -40341101)
+    c = md5_ff(c, d, a, b, unwrap(x[i + 14]), 17, -1502002290)
+    b = md5_ff(b, c, d, a, unwrap(x[i + 15]), 22,  1236535329)
+
+    a = md5_gg(a, b, c, d, unwrap(x[i + 1]), 5 , -165796510)
+    d = md5_gg(d, a, b, c, unwrap(x[i + 6]), 9 , -1069501632)
+    c = md5_gg(c, d, a, b, unwrap(x[i + 11]), 14,  643717713)
+    b = md5_gg(b, c, d, a, unwrap(x[i + 0]), 20, -373897302)
+    a = md5_gg(a, b, c, d, unwrap(x[i + 5]), 5 , -701558691)
+    d = md5_gg(d, a, b, c, unwrap(x[i + 10]), 9 ,  38016083)
+    c = md5_gg(c, d, a, b, unwrap(x[i + 15]), 14, -660478335)
+    b = md5_gg(b, c, d, a, unwrap(x[i + 4]), 20, -405537848)
+    a = md5_gg(a, b, c, d, unwrap(x[i + 9]), 5 ,  568446438)
+    d = md5_gg(d, a, b, c, unwrap(x[i + 14]), 9 , -1019803690)
+    c = md5_gg(c, d, a, b, unwrap(x[i + 3]), 14, -187363961)
+    b = md5_gg(b, c, d, a, unwrap(x[i + 8]), 20,  1163531501)
+    a = md5_gg(a, b, c, d, unwrap(x[i + 13]), 5 , -1444681467)
+    d = md5_gg(d, a, b, c, unwrap(x[i + 2]), 9 , -51403784)
+    c = md5_gg(c, d, a, b, unwrap(x[i + 7]), 14,  1735328473)
+    b = md5_gg(b, c, d, a, unwrap(x[i + 12]), 20, -1926607734)
+
+    a = md5_hh(a, b, c, d, unwrap(x[i + 5]), 4 , -378558)
+    d = md5_hh(d, a, b, c, unwrap(x[i + 8]), 11, -2022574463)
+    c = md5_hh(c, d, a, b, unwrap(x[i + 11]), 16,  1839030562)
+    b = md5_hh(b, c, d, a, unwrap(x[i + 14]), 23, -35309556)
+    a = md5_hh(a, b, c, d, unwrap(x[i + 1]), 4 , -1530992060)
+    d = md5_hh(d, a, b, c, unwrap(x[i + 4]), 11,  1272893353)
+    c = md5_hh(c, d, a, b, unwrap(x[i + 7]), 16, -155497632)
+    b = md5_hh(b, c, d, a, unwrap(x[i + 10]), 23, -1094730640)
+    a = md5_hh(a, b, c, d, unwrap(x[i + 13]), 4 ,  681279174)
+    d = md5_hh(d, a, b, c, unwrap(x[i + 0]), 11, -358537222)
+    c = md5_hh(c, d, a, b, unwrap(x[i + 3]), 16, -722521979)
+    b = md5_hh(b, c, d, a, unwrap(x[i + 6]), 23,  76029189)
+    a = md5_hh(a, b, c, d, unwrap(x[i + 9]), 4 , -640364487)
+    d = md5_hh(d, a, b, c, unwrap(x[i + 12]), 11, -421815835)
+    c = md5_hh(c, d, a, b, unwrap(x[i + 15]), 16,  530742520)
+    b = md5_hh(b, c, d, a, unwrap(x[i + 2]), 23, -995338651)
+
+    a = md5_ii(a, b, c, d, unwrap(x[i + 0]), 6 , -198630844)
+    d = md5_ii(d, a, b, c, unwrap(x[i + 7]), 10,  1126891415)
+    c = md5_ii(c, d, a, b, unwrap(x[i + 14]), 15, -1416354905)
+    b = md5_ii(b, c, d, a, unwrap(x[i + 5]), 21, -57434055)
+    a = md5_ii(a, b, c, d, unwrap(x[i + 12]), 6 ,  1700485571)
+    d = md5_ii(d, a, b, c, unwrap(x[i + 3]), 10, -1894986606)
+    c = md5_ii(c, d, a, b, unwrap(x[i + 10]), 15, -1051523)
+    b = md5_ii(b, c, d, a, unwrap(x[i + 1]), 21, -2054922799)
+    a = md5_ii(a, b, c, d, unwrap(x[i + 8]), 6 ,  1873313359)
+    d = md5_ii(d, a, b, c, unwrap(x[i + 15]), 10, -30611744)
+    c = md5_ii(c, d, a, b, unwrap(x[i + 6]), 15, -1560198380)
+    b = md5_ii(b, c, d, a, unwrap(x[i + 13]), 21,  1309151649)
+    a = md5_ii(a, b, c, d, unwrap(x[i + 4]), 6 , -145523070)
+    d = md5_ii(d, a, b, c, unwrap(x[i + 11]), 10, -1120210379)
+    c = md5_ii(c, d, a, b, unwrap(x[i + 2]), 15,  718787259)
+    b = md5_ii(b, c, d, a, unwrap(x[i + 9]), 21, -343485551)
+
+    a = safe_add(a, olda)
+    b = safe_add(b, oldb)
+    c = safe_add(c, oldc)
+    d = safe_add(d, oldd)
+  }
+
+  return [a, b, c, d]
+}
+
+// MARK: - Helper
+
+func length(_ dictionary: [Int: Int32]) -> Int {
+  return (dictionary.keys.max() ?? 0) + 1
+}
+
+func dictionary2array(_ dictionary: [Int: Int32]) -> [Int32] {
+  var array = Array<Int32>(repeating: 0, count: dictionary.keys.count)
+
+  for i in Array(dictionary.keys).sorted() {
+    array[i] = unwrap(dictionary[i])
+  }
+
+  return array
+}
+
+func unwrap(_ value: Int32?, _ fallback: Int32 = 0) -> Int32 {
+  if let value = value {
+    return value
+  }
+
+  return fallback
+}
+
+func zeroFillRightShift(_ num: Int32, _ count: Int32) -> Int32 {
+  let value = UInt32(bitPattern: num) >> UInt32(bitPattern: count)
+  return Int32(bitPattern: value)
+}

+ 20 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/MemoryCapsule.swift

@@ -0,0 +1,20 @@
+import Foundation
+
+/// Helper class to hold cached instance and expiry date.
+/// Used in memory storage to work with NSCache.
+class MemoryCapsule: NSObject {
+  /// Object to be cached
+  let object: Any
+  /// Expiration date
+  let expiry: Expiry
+
+  /**
+   Creates a new instance of Capsule.
+   - Parameter value: Object to be cached
+   - Parameter expiry: Expiration date
+   */
+  init(value: Any, expiry: Expiry) {
+    self.object = value
+    self.expiry = expiry
+  }
+}

+ 11 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/ObservationToken.swift

@@ -0,0 +1,11 @@
+public final class ObservationToken {
+  private let cancellationClosure: () -> Void
+
+  init(cancellationClosure: @escaping () -> Void) {
+    self.cancellationClosure = cancellationClosure
+  }
+
+  public func cancel() {
+    cancellationClosure()
+  }
+}

+ 11 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/Optional+Extension.swift

@@ -0,0 +1,11 @@
+import Foundation
+
+public extension Optional {
+  func unwrapOrThrow(error: Error) throws -> Wrapped {
+    if let value = self {
+      return value
+    } else {
+      throw error
+    }
+  }
+}

+ 16 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/Result.swift

@@ -0,0 +1,16 @@
+import Foundation
+
+/// Used for callback in async operations.
+public enum Result<T> {
+  case value(T)
+  case error(Error)
+
+  public func map<U>(_ transform: (T) -> U) -> Result<U> {
+    switch self {
+    case .value(let value):
+      return Result<U>.value(transform(value))
+    case .error(let error):
+      return Result<U>.error(error)
+    }
+  }
+}

+ 18 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/StorageError.swift

@@ -0,0 +1,18 @@
+import Foundation
+
+public enum StorageError: Error {
+  /// Object can not be found
+  case notFound
+  /// Object is found, but casting to requested type failed
+  case typeNotMatch
+  /// The file attributes are malformed
+  case malformedFileAttributes
+  /// Can't perform Decode
+  case decodingFailed
+  /// Can't perform Encode
+  case encodingFailed
+  /// The storage has been deallocated
+  case deallocated
+  /// Fail to perform transformation to or from Data
+  case transformerFail
+}

+ 11 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/Transformer.swift

@@ -0,0 +1,11 @@
+import Foundation
+
+public class Transformer<T> {
+  let toData: (T) throws -> Data
+  let fromData: (Data) throws -> T
+
+  public init(toData: @escaping (T) throws -> Data, fromData: @escaping (Data) throws -> T) {
+    self.toData = toData
+    self.fromData = fromData
+  }
+}

+ 38 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/TransformerFactory.swift

@@ -0,0 +1,38 @@
+import Foundation
+
+public class TransformerFactory {
+  public static func forData() -> Transformer<Data> {
+    let toData: (Data) throws -> Data = { $0 }
+
+    let fromData: (Data) throws -> Data = { $0 }
+
+    return Transformer<Data>(toData: toData, fromData: fromData)
+  }
+
+  public static func forImage() -> Transformer<Image> {
+    let toData: (Image) throws -> Data = { image in
+      return try image.cache_toData().unwrapOrThrow(error: StorageError.transformerFail)
+    }
+
+    let fromData: (Data) throws -> Image = { data in
+      return try Image(data: data).unwrapOrThrow(error: StorageError.transformerFail)
+    }
+
+    return Transformer<Image>(toData: toData, fromData: fromData)
+  }
+
+  public static func forCodable<U: Codable>(ofType: U.Type) -> Transformer<U> {
+    let toData: (U) throws -> Data = { object in
+      let wrapper = TypeWrapper<U>(object: object)
+      let encoder = JSONEncoder()
+      return try encoder.encode(wrapper)
+    }
+
+    let fromData: (Data) throws -> U = { data in
+      let decoder = JSONDecoder()
+      return try decoder.decode(TypeWrapper<U>.self, from: data).object
+    }
+
+    return Transformer<U>(toData: toData, fromData: fromData)
+  }
+}

+ 14 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/TypeWrapper.swift

@@ -0,0 +1,14 @@
+import Foundation
+
+/// Used to wrap Codable object
+public struct TypeWrapper<T: Codable>: Codable {
+  enum CodingKeys: String, CodingKey {
+    case object
+  }
+
+  public let object: T
+
+  public init(object: T) {
+    self.object = object
+  }
+}

+ 9 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Library/Types.swift

@@ -0,0 +1,9 @@
+#if os(iOS) || os(tvOS)
+  import UIKit
+  public typealias Image = UIImage
+#elseif os(watchOS)
+
+#elseif os(OSX)
+  import AppKit
+  public typealias Image = NSImage
+#endif

+ 129 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/AsyncStorage.swift

@@ -0,0 +1,129 @@
+import Foundation
+import Dispatch
+
+/// Manipulate storage in a "all async" manner.
+/// The completion closure will be called when operation completes.
+public class AsyncStorage<T> {
+  public let innerStorage: HybridStorage<T>
+  public let serialQueue: DispatchQueue
+
+  public init(storage: HybridStorage<T>, serialQueue: DispatchQueue) {
+    self.innerStorage = storage
+    self.serialQueue = serialQueue
+  }
+}
+
+extension AsyncStorage {
+  public func entry(forKey key: String, completion: @escaping (Result<Entry<T>>) -> Void) {
+    serialQueue.async { [weak self] in
+      guard let `self` = self else {
+        completion(Result.error(StorageError.deallocated))
+        return
+      }
+
+      do {
+        let anEntry = try self.innerStorage.entry(forKey: key)
+        completion(Result.value(anEntry))
+      } catch {
+        completion(Result.error(error))
+      }
+    }
+  }
+
+  public func removeObject(forKey key: String, completion: @escaping (Result<()>) -> Void) {
+    serialQueue.async { [weak self] in
+      guard let `self` = self else {
+        completion(Result.error(StorageError.deallocated))
+        return
+      }
+
+      do {
+        try self.innerStorage.removeObject(forKey: key)
+        completion(Result.value(()))
+      } catch {
+        completion(Result.error(error))
+      }
+    }
+  }
+
+  public func setObject(
+    _ object: T,
+    forKey key: String,
+    expiry: Expiry? = nil,
+    completion: @escaping (Result<()>) -> Void) {
+    serialQueue.async { [weak self] in
+      guard let `self` = self else {
+        completion(Result.error(StorageError.deallocated))
+        return
+      }
+
+      do {
+        try self.innerStorage.setObject(object, forKey: key, expiry: expiry)
+        completion(Result.value(()))
+      } catch {
+        completion(Result.error(error))
+      }
+    }
+  }
+
+  public func removeAll(completion: @escaping (Result<()>) -> Void) {
+    serialQueue.async { [weak self] in
+      guard let `self` = self else {
+        completion(Result.error(StorageError.deallocated))
+        return
+      }
+
+      do {
+        try self.innerStorage.removeAll()
+        completion(Result.value(()))
+      } catch {
+        completion(Result.error(error))
+      }
+    }
+  }
+
+  public func removeExpiredObjects(completion: @escaping (Result<()>) -> Void) {
+    serialQueue.async { [weak self] in
+      guard let `self` = self else {
+        completion(Result.error(StorageError.deallocated))
+        return
+      }
+
+      do {
+        try self.innerStorage.removeExpiredObjects()
+        completion(Result.value(()))
+      } catch {
+        completion(Result.error(error))
+      }
+    }
+  }
+
+  public func object(forKey key: String, completion: @escaping (Result<T>) -> Void) {
+    entry(forKey: key, completion: { (result: Result<Entry<T>>) in
+      completion(result.map({ entry in
+        return entry.object
+      }))
+    })
+  }
+
+  public func existsObject(
+    forKey key: String,
+    completion: @escaping (Result<Bool>) -> Void) {
+    object(forKey: key, completion: { (result: Result<T>) in
+      completion(result.map({ _ in
+        return true
+      }))
+    })
+  }
+}
+
+public extension AsyncStorage {
+  func transform<U>(transformer: Transformer<U>) -> AsyncStorage<U> {
+    let storage = AsyncStorage<U>(
+      storage: innerStorage.transform(transformer: transformer),
+      serialQueue: serialQueue
+    )
+
+    return storage
+  }
+}

+ 268 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/DiskStorage.swift

@@ -0,0 +1,268 @@
+import Foundation
+
+/// Save objects to file on disk
+final public class DiskStorage<T> {
+  enum Error: Swift.Error {
+    case fileEnumeratorFailed
+  }
+
+  /// File manager to read/write to the disk
+  public let fileManager: FileManager
+  /// Configuration
+  private let config: DiskConfig
+  /// The computed path `directory+name`
+  public let path: String
+  /// The closure to be called when single file has been removed
+  var onRemove: ((String) -> Void)?
+
+  private let transformer: Transformer<T>
+
+  // MARK: - Initialization
+  public convenience init(config: DiskConfig, fileManager: FileManager = FileManager.default, transformer: Transformer<T>) throws {
+    let url: URL
+    if let directory = config.directory {
+      url = directory
+    } else {
+      url = try fileManager.url(
+        for: .cachesDirectory,
+        in: .userDomainMask,
+        appropriateFor: nil,
+        create: true
+      )
+    }
+
+    // path
+    let path = url.appendingPathComponent(config.name, isDirectory: true).path
+
+    self.init(config: config, fileManager: fileManager, path: path, transformer: transformer)
+
+    try createDirectory()
+
+    // protection
+    #if os(iOS) || os(tvOS)
+    if let protectionType = config.protectionType {
+      try setDirectoryAttributes([
+        FileAttributeKey.protectionKey: protectionType
+      ])
+    }
+    #endif
+  }
+
+  public required init(config: DiskConfig, fileManager: FileManager = FileManager.default, path: String, transformer: Transformer<T>) {
+    self.config = config
+    self.fileManager = fileManager
+    self.path = path
+    self.transformer = transformer
+  }
+}
+
+extension DiskStorage: StorageAware {
+  public func entry(forKey key: String) throws -> Entry<T> {
+    let filePath = makeFilePath(for: key)
+    let data = try Data(contentsOf: URL(fileURLWithPath: filePath))
+    let attributes = try fileManager.attributesOfItem(atPath: filePath)
+    let object = try transformer.fromData(data)
+
+    guard let date = attributes[.modificationDate] as? Date else {
+      throw StorageError.malformedFileAttributes
+    }
+
+    return Entry(
+      object: object,
+      expiry: Expiry.date(date),
+      filePath: filePath
+    )
+  }
+
+  public func setObject(_ object: T, forKey key: String, expiry: Expiry? = nil) throws {
+    let expiry = expiry ?? config.expiry
+    let data = try transformer.toData(object)
+    let filePath = makeFilePath(for: key)
+    _ = fileManager.createFile(atPath: filePath, contents: data, attributes: nil)
+    try fileManager.setAttributes([.modificationDate: expiry.date], ofItemAtPath: filePath)
+  }
+
+  public func removeObject(forKey key: String) throws {
+    let filePath = makeFilePath(for: key)
+    try fileManager.removeItem(atPath: filePath)
+    onRemove?(filePath)
+  }
+
+  public func removeAll() throws {
+    try fileManager.removeItem(atPath: path)
+    try createDirectory()
+  }
+
+  public func removeExpiredObjects() throws {
+    let storageURL = URL(fileURLWithPath: path)
+    let resourceKeys: [URLResourceKey] = [
+      .isDirectoryKey,
+      .contentModificationDateKey,
+      .totalFileAllocatedSizeKey
+    ]
+    var resourceObjects = [ResourceObject]()
+    var filesToDelete = [URL]()
+    var totalSize: UInt = 0
+    let fileEnumerator = fileManager.enumerator(
+      at: storageURL,
+      includingPropertiesForKeys: resourceKeys,
+      options: .skipsHiddenFiles,
+      errorHandler: nil
+    )
+
+    guard let urlArray = fileEnumerator?.allObjects as? [URL] else {
+      throw Error.fileEnumeratorFailed
+    }
+
+    for url in urlArray {
+      let resourceValues = try url.resourceValues(forKeys: Set(resourceKeys))
+      guard resourceValues.isDirectory != true else {
+        continue
+      }
+
+      if let expiryDate = resourceValues.contentModificationDate, expiryDate.inThePast {
+        filesToDelete.append(url)
+        continue
+      }
+
+      if let fileSize = resourceValues.totalFileAllocatedSize {
+        totalSize += UInt(fileSize)
+        resourceObjects.append((url: url, resourceValues: resourceValues))
+      }
+    }
+
+    // Remove expired objects
+    for url in filesToDelete {
+      try fileManager.removeItem(at: url)
+      onRemove?(url.path)
+    }
+
+    // Remove objects if storage size exceeds max size
+    try removeResourceObjects(resourceObjects, totalSize: totalSize)
+  }
+}
+
+extension DiskStorage {
+  /**
+   Sets attributes on the disk cache folder.
+   - Parameter attributes: Directory attributes
+   */
+  func setDirectoryAttributes(_ attributes: [FileAttributeKey: Any]) throws {
+    try fileManager.setAttributes(attributes, ofItemAtPath: path)
+  }
+}
+
+typealias ResourceObject = (url: Foundation.URL, resourceValues: URLResourceValues)
+
+extension DiskStorage {
+  /**
+   Builds file name from the key.
+   - Parameter key: Unique key to identify the object in the cache
+   - Returns: A md5 string
+   */
+  func makeFileName(for key: String) -> String {
+    let fileExtension = URL(fileURLWithPath: key).pathExtension
+    let fileName = MD5(key)
+
+    switch fileExtension.isEmpty {
+    case true:
+      return fileName
+    case false:
+      return "\(fileName).\(fileExtension)"
+    }
+  }
+
+  /**
+   Builds file path from the key.
+   - Parameter key: Unique key to identify the object in the cache
+   - Returns: A string path based on key
+   */
+  func makeFilePath(for key: String) -> String {
+    return "\(path)/\(makeFileName(for: key))"
+  }
+
+  /// Calculates total disk cache size.
+  func totalSize() throws -> UInt64 {
+    var size: UInt64 = 0
+    let contents = try fileManager.contentsOfDirectory(atPath: path)
+    for pathComponent in contents {
+      let filePath = NSString(string: path).appendingPathComponent(pathComponent)
+      let attributes = try fileManager.attributesOfItem(atPath: filePath)
+      if let fileSize = attributes[.size] as? UInt64 {
+        size += fileSize
+      }
+    }
+    return size
+  }
+
+  func createDirectory() throws {
+    guard !fileManager.fileExists(atPath: path) else {
+      return
+    }
+
+    try fileManager.createDirectory(atPath: path, withIntermediateDirectories: true,
+                                    attributes: nil)
+  }
+
+  /**
+   Removes objects if storage size exceeds max size.
+   - Parameter objects: Resource objects to remove
+   - Parameter totalSize: Total size
+   */
+  func removeResourceObjects(_ objects: [ResourceObject], totalSize: UInt) throws {
+    guard config.maxSize > 0 && totalSize > config.maxSize else {
+      return
+    }
+
+    var totalSize = totalSize
+    let targetSize = config.maxSize / 2
+
+    let sortedFiles = objects.sorted {
+      if let time1 = $0.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate,
+        let time2 = $1.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate {
+        return time1 > time2
+      } else {
+        return false
+      }
+    }
+
+    for file in sortedFiles {
+      try fileManager.removeItem(at: file.url)
+      onRemove?(file.url.path)
+
+      if let fileSize = file.resourceValues.totalFileAllocatedSize {
+        totalSize -= UInt(fileSize)
+      }
+
+      if totalSize < targetSize {
+        break
+      }
+    }
+  }
+
+  /**
+   Removes the object from the cache if it's expired.
+   - Parameter key: Unique key to identify the object in the cache
+   */
+  func removeObjectIfExpired(forKey key: String) throws {
+    let filePath = makeFilePath(for: key)
+    let attributes = try fileManager.attributesOfItem(atPath: filePath)
+    if let expiryDate = attributes[.modificationDate] as? Date, expiryDate.inThePast {
+      try fileManager.removeItem(atPath: filePath)
+      onRemove?(filePath)
+    }
+  }
+}
+
+public extension DiskStorage {
+  func transform<U>(transformer: Transformer<U>) -> DiskStorage<U> {
+    let storage = DiskStorage<U>(
+      config: config,
+      fileManager: fileManager,
+      path: path,
+      transformer: transformer
+    )
+
+    return storage
+  }
+}

+ 167 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/HybridStorage.swift

@@ -0,0 +1,167 @@
+import Foundation
+
+/// Use both memory and disk storage. Try on memory first.
+public final class HybridStorage<T> {
+  public let memoryStorage: MemoryStorage<T>
+  public let diskStorage: DiskStorage<T>
+
+  private(set) var storageObservations = [UUID: (HybridStorage, StorageChange) -> Void]()
+  private(set) var keyObservations = [String: (HybridStorage, KeyChange<T>) -> Void]()
+
+  public init(memoryStorage: MemoryStorage<T>, diskStorage: DiskStorage<T>) {
+    self.memoryStorage = memoryStorage
+    self.diskStorage = diskStorage
+
+    diskStorage.onRemove = { [weak self] path in
+      self?.handleRemovedObject(at: path)
+    }
+  }
+
+  private func handleRemovedObject(at path: String) {
+    notifyObserver(about: .remove) { key in
+      let fileName = diskStorage.makeFileName(for: key)
+      return path.contains(fileName)
+    }
+  }
+}
+
+extension HybridStorage: StorageAware {
+  public func entry(forKey key: String) throws -> Entry<T> {
+    do {
+      return try memoryStorage.entry(forKey: key)
+    } catch {
+      let entry = try diskStorage.entry(forKey: key)
+      // set back to memoryStorage
+      memoryStorage.setObject(entry.object, forKey: key, expiry: entry.expiry)
+      return entry
+    }
+  }
+
+  public func removeObject(forKey key: String) throws {
+    memoryStorage.removeObject(forKey: key)
+    try diskStorage.removeObject(forKey: key)
+
+    notifyStorageObservers(about: .remove(key: key))
+  }
+
+  public func setObject(_ object: T, forKey key: String, expiry: Expiry? = nil) throws {
+    var keyChange: KeyChange<T>?
+
+    if keyObservations[key] != nil {
+      keyChange = .edit(before: try? self.object(forKey: key), after: object)
+    }
+
+    memoryStorage.setObject(object, forKey: key, expiry: expiry)
+    try diskStorage.setObject(object, forKey: key, expiry: expiry)
+
+    if let change = keyChange {
+      notifyObserver(forKey: key, about: change)
+    }
+
+    notifyStorageObservers(about: .add(key: key))
+  }
+
+  public func removeAll() throws {
+    memoryStorage.removeAll()
+    try diskStorage.removeAll()
+
+    notifyStorageObservers(about: .removeAll)
+    notifyKeyObservers(about: .remove)
+  }
+
+  public func removeExpiredObjects() throws {
+    memoryStorage.removeExpiredObjects()
+    try diskStorage.removeExpiredObjects()
+
+    notifyStorageObservers(about: .removeExpired)
+  }
+}
+
+public extension HybridStorage {
+  func transform<U>(transformer: Transformer<U>) -> HybridStorage<U> {
+    let storage = HybridStorage<U>(
+      memoryStorage: memoryStorage.transform(),
+      diskStorage: diskStorage.transform(transformer: transformer)
+    )
+
+    return storage
+  }
+}
+
+extension HybridStorage: StorageObservationRegistry {
+  @discardableResult
+  public func addStorageObserver<O: AnyObject>(
+    _ observer: O,
+    closure: @escaping (O, HybridStorage, StorageChange) -> Void
+  ) -> ObservationToken {
+    let id = UUID()
+
+    storageObservations[id] = { [weak self, weak observer] storage, change in
+      guard let observer = observer else {
+        self?.storageObservations.removeValue(forKey: id)
+        return
+      }
+
+      closure(observer, storage, change)
+    }
+
+    return ObservationToken { [weak self] in
+      self?.storageObservations.removeValue(forKey: id)
+    }
+  }
+
+  public func removeAllStorageObservers() {
+    storageObservations.removeAll()
+  }
+
+  private func notifyStorageObservers(about change: StorageChange) {
+    storageObservations.values.forEach { closure in
+      closure(self, change)
+    }
+  }
+}
+
+extension HybridStorage: KeyObservationRegistry {
+  @discardableResult
+  public func addObserver<O: AnyObject>(
+    _ observer: O,
+    forKey key: String,
+    closure: @escaping (O, HybridStorage, KeyChange<T>) -> Void
+  ) -> ObservationToken {
+    keyObservations[key] = { [weak self, weak observer] storage, change in
+      guard let observer = observer else {
+        self?.removeObserver(forKey: key)
+        return
+      }
+
+      closure(observer, storage, change)
+    }
+
+    return ObservationToken { [weak self] in
+      self?.keyObservations.removeValue(forKey: key)
+    }
+  }
+
+  public func removeObserver(forKey key: String) {
+    keyObservations.removeValue(forKey: key)
+  }
+
+  public func removeAllKeyObservers() {
+    keyObservations.removeAll()
+  }
+
+  private func notifyObserver(forKey key: String, about change: KeyChange<T>) {
+    keyObservations[key]?(self, change)
+  }
+
+  private func notifyObserver(about change: KeyChange<T>, whereKey closure: ((String) -> Bool)) {
+    let observation = keyObservations.first { key, _ in closure(key) }?.value
+    observation?(self, change)
+  }
+
+  private func notifyKeyObservers(about change: KeyChange<T>) {
+    keyObservations.values.forEach { closure in
+      closure(self, change)
+    }
+  }
+}

+ 50 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/KeyObservationRegistry.swift

@@ -0,0 +1,50 @@
+import Foundation
+
+/// A protocol used for adding and removing key observations
+public protocol KeyObservationRegistry {
+  associatedtype S: StorageAware
+
+  /**
+   Registers observation closure which will be removed automatically
+   when the weakly captured observer has been deallocated.
+   - Parameter observer: Any object that helps determine if the observation is still valid
+   - Parameter key: Unique key to identify the object in the cache
+   - Parameter closure: Observation closure
+   - Returns: Token used to cancel the observation and remove the observation closure
+   */
+  @discardableResult
+  func addObserver<O: AnyObject>(
+    _ observer: O,
+    forKey key: String,
+    closure: @escaping (O, S, KeyChange<S.T>) -> Void
+  ) -> ObservationToken
+
+  /**
+   Removes observer by the given key.
+   - Parameter key: Unique key to identify the object in the cache
+   */
+  func removeObserver(forKey key: String)
+
+  /// Removes all registered key observers
+  func removeAllKeyObservers()
+}
+
+// MARK: - KeyChange
+
+public enum KeyChange<T> {
+  case edit(before: T?, after: T)
+  case remove
+}
+
+extension KeyChange: Equatable where T: Equatable {
+  public static func == (lhs: KeyChange<T>, rhs: KeyChange<T>) -> Bool {
+    switch (lhs, rhs) {
+    case (.edit(let before1, let after1), .edit(let before2, let after2)):
+      return before1 == before2 && after1 == after2
+    case (.remove, .remove):
+      return true
+    default:
+      return false
+    }
+  }
+}

+ 65 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/MemoryStorage.swift

@@ -0,0 +1,65 @@
+import Foundation
+
+public class MemoryStorage<T>: StorageAware {
+  fileprivate let cache = NSCache<NSString, MemoryCapsule>()
+  // Memory cache keys
+  fileprivate var keys = Set<String>()
+  /// Configuration
+  fileprivate let config: MemoryConfig
+
+  public init(config: MemoryConfig) {
+    self.config = config
+    self.cache.countLimit = Int(config.countLimit)
+    self.cache.totalCostLimit = Int(config.totalCostLimit)
+  }
+}
+
+extension MemoryStorage {
+  public func setObject(_ object: T, forKey key: String, expiry: Expiry? = nil) {
+    let capsule = MemoryCapsule(value: object, expiry: .date(expiry?.date ?? config.expiry.date))
+    cache.setObject(capsule, forKey: NSString(string: key))
+    keys.insert(key)
+  }
+
+  public func removeAll() {
+    cache.removeAllObjects()
+    keys.removeAll()
+  }
+
+  public func removeExpiredObjects() {
+    let allKeys = keys
+    for key in allKeys {
+      removeObjectIfExpired(forKey: key)
+    }
+  }
+
+  public func removeObjectIfExpired(forKey key: String) {
+    if let capsule = cache.object(forKey: NSString(string: key)), capsule.expiry.isExpired {
+      removeObject(forKey: key)
+    }
+  }
+
+  public func removeObject(forKey key: String) {
+    cache.removeObject(forKey: NSString(string: key))
+    keys.remove(key)
+  }
+
+  public func entry(forKey key: String) throws -> Entry<T> {
+    guard let capsule = cache.object(forKey: NSString(string: key)) else {
+      throw StorageError.notFound
+    }
+
+    guard let object = capsule.object as? T else {
+      throw StorageError.typeNotMatch
+    }
+
+    return Entry(object: object, expiry: capsule.expiry)
+  }
+}
+
+public extension MemoryStorage {
+  func transform<U>() -> MemoryStorage<U> {
+    let storage = MemoryStorage<U>(config: config)
+    return storage
+  }
+}

+ 18 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/Storage+Transform.swift

@@ -0,0 +1,18 @@
+import Foundation
+
+public extension Storage {
+  func transformData() -> Storage<Data> {
+    let storage = transform(transformer: TransformerFactory.forData())
+    return storage
+  }
+
+  func transformImage() -> Storage<Image> {
+    let storage = transform(transformer: TransformerFactory.forImage())
+    return storage
+  }
+
+  func transformCodable<U: Codable>(ofType: U.Type) -> Storage<U> {
+    let storage = transform(transformer: TransformerFactory.forCodable(ofType: U.self))
+    return storage
+  }
+}

+ 110 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/Storage.swift

@@ -0,0 +1,110 @@
+import Foundation
+import Dispatch
+
+/// Manage storage. Use memory storage if specified.
+/// Synchronous by default. Use `async` for asynchronous operations.
+public final class Storage<T> {
+  /// Used for sync operations
+  private let syncStorage: SyncStorage<T>
+  private let asyncStorage: AsyncStorage<T>
+  private let hybridStorage: HybridStorage<T>
+
+  /// Initialize storage with configuration options.
+  ///
+  /// - Parameters:
+  ///   - diskConfig: Configuration for disk storage
+  ///   - memoryConfig: Optional. Pass config if you want memory cache
+  /// - Throws: Throw StorageError if any.
+  public convenience init(diskConfig: DiskConfig, memoryConfig: MemoryConfig, transformer: Transformer<T>) throws {
+    let disk = try DiskStorage(config: diskConfig, transformer: transformer)
+    let memory = MemoryStorage<T>(config: memoryConfig)
+    let hybridStorage = HybridStorage(memoryStorage: memory, diskStorage: disk)
+    self.init(hybridStorage: hybridStorage)
+  }
+
+  /// Initialise with sync and async storages
+  ///
+  /// - Parameter syncStorage: Synchronous storage
+  /// - Paraeter: asyncStorage: Asynchronous storage
+  public init(hybridStorage: HybridStorage<T>) {
+    self.hybridStorage = hybridStorage
+    self.syncStorage = SyncStorage(
+      storage: hybridStorage,
+      serialQueue: DispatchQueue(label: "Cache.SyncStorage.SerialQueue")
+    )
+    self.asyncStorage = AsyncStorage(
+      storage: hybridStorage,
+      serialQueue: DispatchQueue(label: "Cache.AsyncStorage.SerialQueue")
+    )
+  }
+
+  /// Used for async operations
+  public lazy var async = self.asyncStorage
+}
+
+extension Storage: StorageAware {
+  public func entry(forKey key: String) throws -> Entry<T> {
+    return try self.syncStorage.entry(forKey: key)
+  }
+
+  public func removeObject(forKey key: String) throws {
+    try self.syncStorage.removeObject(forKey: key)
+  }
+
+  public func setObject(_ object: T, forKey key: String, expiry: Expiry? = nil) throws {
+    try self.syncStorage.setObject(object, forKey: key, expiry: expiry)
+  }
+
+  public func removeAll() throws {
+    try self.syncStorage.removeAll()
+  }
+
+  public func removeExpiredObjects() throws {
+    try self.syncStorage.removeExpiredObjects()
+  }
+}
+
+public extension Storage {
+  func transform<U>(transformer: Transformer<U>) -> Storage<U> {
+    return Storage<U>(hybridStorage: hybridStorage.transform(transformer: transformer))
+  }
+}
+
+extension Storage: StorageObservationRegistry {
+  @discardableResult
+  public func addStorageObserver<O: AnyObject>(
+    _ observer: O,
+    closure: @escaping (O, Storage, StorageChange) -> Void
+  ) -> ObservationToken {
+    return hybridStorage.addStorageObserver(observer) { [weak self] observer, _, change in
+      guard let strongSelf = self else { return }
+      closure(observer, strongSelf, change)
+    }
+  }
+
+  public func removeAllStorageObservers() {
+    hybridStorage.removeAllStorageObservers()
+  }
+}
+
+extension Storage: KeyObservationRegistry {
+  @discardableResult
+  public func addObserver<O: AnyObject>(
+    _ observer: O,
+    forKey key: String,
+    closure: @escaping (O, Storage, KeyChange<T>) -> Void
+  ) -> ObservationToken {
+    return hybridStorage.addObserver(observer, forKey: key) { [weak self] observer, _, change in
+      guard let strongSelf = self else { return }
+      closure(observer, strongSelf, change)
+    }
+  }
+
+  public func removeObserver(forKey key: String) {
+    hybridStorage.removeObserver(forKey: key)
+  }
+
+  public func removeAllKeyObservers() {
+    hybridStorage.removeAllKeyObservers()
+  }
+}

+ 79 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/StorageAware.swift

@@ -0,0 +1,79 @@
+import Foundation
+
+/// A protocol used for saving and loading from storage
+public protocol StorageAware {
+  associatedtype T
+  /**
+   Tries to retrieve the object from the storage.
+   - Parameter key: Unique key to identify the object in the cache
+   - Returns: Cached object or nil if not found
+   */
+  func object(forKey key: String) throws -> T
+
+  /**
+   Get cache entry which includes object with metadata.
+   - Parameter key: Unique key to identify the object in the cache
+   - Returns: Object wrapper with metadata or nil if not found
+   */
+  func entry(forKey key: String) throws -> Entry<T>
+
+  /**
+   Removes the object by the given key.
+   - Parameter key: Unique key to identify the object.
+   */
+  func removeObject(forKey key: String) throws
+
+  /**
+   Saves passed object.
+   - Parameter key: Unique key to identify the object in the cache.
+   - Parameter object: Object that needs to be cached.
+   - Parameter expiry: Overwrite expiry for this object only.
+   */
+  func setObject(_ object: T, forKey key: String, expiry: Expiry?) throws
+
+  /**
+   Check if an object exist by the given key.
+   - Parameter key: Unique key to identify the object.
+   */
+  func existsObject(forKey key: String) throws -> Bool
+
+  /**
+   Removes all objects from the cache storage.
+   */
+  func removeAll() throws
+
+  /**
+   Clears all expired objects.
+   */
+  func removeExpiredObjects() throws
+
+  /**
+   Check if an expired object by the given key.
+   - Parameter key: Unique key to identify the object.
+   */
+  func isExpiredObject(forKey key: String) throws -> Bool
+}
+
+public extension StorageAware {
+  func object(forKey key: String) throws -> T {
+    return try entry(forKey: key).object
+  }
+
+  func existsObject(forKey key: String) throws -> Bool {
+    do {
+      let _: T = try object(forKey: key)
+      return true
+    } catch {
+      return false
+    }
+  }
+
+  func isExpiredObject(forKey key: String) throws -> Bool {
+    do {
+      let entry = try self.entry(forKey: key)
+      return entry.expiry.isExpired
+    } catch {
+      return true
+    }
+  }
+}

+ 42 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/StorageObservationRegistry.swift

@@ -0,0 +1,42 @@
+import Foundation
+
+/// A protocol used for adding and removing storage observations
+public protocol StorageObservationRegistry {
+  associatedtype S: StorageAware
+
+  /**
+   Registers observation closure which will be removed automatically
+   when the weakly captured observer has been deallocated.
+   - Parameter observer: Any object that helps determine if the observation is still valid
+   - Parameter closure: Observation closure
+   - Returns: Token used to cancel the observation and remove the observation closure
+   */
+  @discardableResult
+  func addStorageObserver<O: AnyObject>(
+    _ observer: O,
+    closure: @escaping (O, S, StorageChange) -> Void
+  ) -> ObservationToken
+
+  /// Removes all registered key observers
+  func removeAllStorageObservers()
+}
+
+// MARK: - StorageChange
+
+public enum StorageChange: Equatable {
+  case add(key: String)
+  case remove(key: String)
+  case removeAll
+  case removeExpired
+}
+
+public func == (lhs: StorageChange, rhs: StorageChange) -> Bool {
+  switch (lhs, rhs) {
+  case (.add(let key1), .add(let key2)), (.remove(let key1), .remove(let key2)):
+    return key1 == key2
+  case (.removeAll, .removeAll), (.removeExpired, .removeExpired):
+    return true
+  default:
+    return false
+  }
+}

+ 60 - 0
RainbowPlanet/Pods/Cache/Source/Shared/Storage/SyncStorage.swift

@@ -0,0 +1,60 @@
+import Foundation
+import Dispatch
+
+/// Manipulate storage in a "all sync" manner.
+/// Block the current queue until the operation completes.
+public class SyncStorage<T> {
+  public let innerStorage: HybridStorage<T>
+  public let serialQueue: DispatchQueue
+
+  public init(storage: HybridStorage<T>, serialQueue: DispatchQueue) {
+    self.innerStorage = storage
+    self.serialQueue = serialQueue
+  }
+}
+
+extension SyncStorage: StorageAware {
+  public func entry(forKey key: String) throws -> Entry<T> {
+    var entry: Entry<T>!
+    try serialQueue.sync {
+      entry = try innerStorage.entry(forKey: key)
+    }
+
+    return entry
+  }
+
+  public func removeObject(forKey key: String) throws {
+    try serialQueue.sync {
+      try self.innerStorage.removeObject(forKey: key)
+    }
+  }
+
+  public func setObject(_ object: T, forKey key: String, expiry: Expiry? = nil) throws {
+    try serialQueue.sync {
+      try innerStorage.setObject(object, forKey: key, expiry: expiry)
+    }
+  }
+
+  public func removeAll() throws {
+    try serialQueue.sync {
+      try innerStorage.removeAll()
+    }
+  }
+
+  public func removeExpiredObjects() throws {
+    try serialQueue.sync {
+      try innerStorage.removeExpiredObjects()
+    }
+  }
+}
+
+public extension SyncStorage {
+  func transform<U>(transformer: Transformer<U>) -> SyncStorage<U> {
+    let storage = SyncStorage<U>(
+      storage: innerStorage.transform(transformer: transformer),
+      serialQueue: serialQueue
+    )
+
+    return storage
+  }
+}

+ 35 - 0
RainbowPlanet/Pods/Cache/Source/iOS/UIImage+Extensions.swift

@@ -0,0 +1,35 @@
+import UIKit
+
+/// Helper UIImage extension.
+extension UIImage {
+  /// Checks if image has alpha component
+  var hasAlpha: Bool {
+    let result: Bool
+
+    guard let alpha = cgImage?.alphaInfo else {
+      return false
+    }
+
+    switch alpha {
+    case .none, .noneSkipFirst, .noneSkipLast:
+      result = false
+    default:
+      result = true
+    }
+
+    return result
+  }
+
+  /// Convert to data
+  func cache_toData() -> Data? {
+    #if swift(>=4.2)
+    return hasAlpha
+      ? pngData()
+      : jpegData(compressionQuality: 1.0)
+    #else
+    return hasAlpha
+      ? UIImagePNGRepresentation(self)
+      : UIImageJPEGRepresentation(self, 1.0)
+    #endif
+  }
+}

+ 0 - 11
RainbowPlanet/Pods/CryptoSwift/LICENSE

@@ -1,11 +0,0 @@
-Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin.krzyzanowski@gmail.com>
-This software is provided 'as-is', without any express or implied warranty. 
-
-In no event will the authors be held liable for any damages arising from the use of this software. 
-
-Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-
-- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-- This notice may not be removed or altered from any source or binary distribution.
-- Redistributions of any form whatsoever must retain the following acknowledgment: 'This product includes software developed by the "Marcin Krzyzanowski" (http://krzyzanowskim.com/).'

Різницю між файлами не показано, бо вона завелика
+ 0 - 528
RainbowPlanet/Pods/CryptoSwift/README.md


+ 0 - 40
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AEAD/AEAD.swift

@@ -1,40 +0,0 @@
-//
-//  AEAD.swift
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-//
-
-// https://www.iana.org/assignments/aead-parameters/aead-parameters.xhtml
-
-/// Authenticated Encryption with Associated Data (AEAD)
-public protocol AEAD {
-    static var kLen: Int { get } // key length
-    static var ivRange: Range<Int> { get } // nonce length
-}
-
-extension AEAD {
-    static func calculateAuthenticationTag(authenticator: Authenticator, cipherText: Array<UInt8>, authenticationHeader: Array<UInt8>) throws -> Array<UInt8> {
-        let headerPadding = ((16 - (authenticationHeader.count & 0xf)) & 0xf)
-        let cipherPadding = ((16 - (cipherText.count & 0xf)) & 0xf)
-
-        var mac = authenticationHeader
-        mac += Array<UInt8>(repeating: 0, count: headerPadding)
-        mac += cipherText
-        mac += Array<UInt8>(repeating: 0, count: cipherPadding)
-        mac += UInt64(bigEndian: UInt64(authenticationHeader.count)).bytes()
-        mac += UInt64(bigEndian: UInt64(cipherText.count)).bytes()
-
-        return try authenticator.authenticate(mac)
-    }
-}

+ 0 - 59
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AEAD/AEADChaCha20Poly1305.swift

@@ -1,59 +0,0 @@
-//
-//  ChaCha20Poly1305.swift
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-//
-//  https://tools.ietf.org/html/rfc7539#section-2.8.1
-
-/// AEAD_CHACHA20_POLY1305
-public final class AEADChaCha20Poly1305: AEAD {
-    public static let kLen = 32 // key length
-    public static var ivRange = Range<Int>(12...12)
-
-    /// Authenticated encryption
-    public static func encrypt(_ plainText: Array<UInt8>, key: Array<UInt8>, iv: Array<UInt8>, authenticationHeader: Array<UInt8>) throws -> (cipherText: Array<UInt8>, authenticationTag: Array<UInt8>) {
-        let cipher = try ChaCha20(key: key, iv: iv)
-
-        var polykey = Array<UInt8>(repeating: 0, count: kLen)
-        var toEncrypt = polykey
-        polykey = try cipher.encrypt(polykey)
-        toEncrypt += polykey
-        toEncrypt += plainText
-
-        let fullCipherText = try cipher.encrypt(toEncrypt)
-        let cipherText = Array(fullCipherText.dropFirst(64))
-
-        let tag = try calculateAuthenticationTag(authenticator: Poly1305(key: polykey), cipherText: cipherText, authenticationHeader: authenticationHeader)
-        return (cipherText, tag)
-    }
-
-    /// Authenticated decryption
-    public static func decrypt(_ cipherText: Array<UInt8>, key: Array<UInt8>, iv: Array<UInt8>, authenticationHeader: Array<UInt8>, authenticationTag: Array<UInt8>) throws -> (plainText: Array<UInt8>, success: Bool) {
-        let chacha = try ChaCha20(key: key, iv: iv)
-
-        let polykey = try chacha.encrypt(Array<UInt8>(repeating: 0, count: kLen))
-        let mac = try calculateAuthenticationTag(authenticator: Poly1305(key: polykey), cipherText: cipherText, authenticationHeader: authenticationHeader)
-        guard mac == authenticationTag else {
-            return (cipherText, false)
-        }
-
-        var toDecrypt = Array<UInt8>(reserveCapacity: cipherText.count + 64)
-        toDecrypt += polykey
-        toDecrypt += polykey
-        toDecrypt += cipherText
-        let fullPlainText = try chacha.decrypt(toDecrypt)
-        let plainText = Array(fullPlainText.dropFirst(64))
-        return (plainText, true)
-    }
-}

+ 0 - 35
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AES.Cryptors.swift

@@ -1,35 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-// MARK: Cryptors
-
-extension AES: Cryptors {
-    public func makeEncryptor() throws -> Cryptor & Updatable {
-        let worker = try blockMode.worker(blockSize: AES.blockSize, cipherOperation: encrypt)
-        if worker is StreamModeWorker {
-            return try StreamEncryptor(blockSize: AES.blockSize, padding: padding, worker)
-        }
-        return try BlockEncryptor(blockSize: AES.blockSize, padding: padding, worker)
-    }
-
-    public func makeDecryptor() throws -> Cryptor & Updatable {
-        let cipherOperation: CipherOperationOnBlock = blockMode.options.contains(.useEncryptToDecrypt) == true ? encrypt : decrypt
-        let worker = try blockMode.worker(blockSize: AES.blockSize, cipherOperation: cipherOperation)
-        if worker is StreamModeWorker {
-            return try StreamDecryptor(blockSize: AES.blockSize, padding: padding, worker)
-        }
-        return try BlockDecryptor(blockSize: AES.blockSize, padding: padding, worker)
-    }
-}

Різницю між файлами не показано, бо вона завелика
+ 0 - 539
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/AES.swift


+ 0 - 148
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Array+Extension.swift

@@ -1,148 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-extension Array {
-    public init(reserveCapacity: Int) {
-        self = Array<Element>()
-        self.reserveCapacity(reserveCapacity)
-    }
-
-    var slice: ArraySlice<Element> {
-        return self[self.startIndex ..< self.endIndex]
-    }
-}
-
-extension Array where Element == UInt8 {
-    public init(hex: String) {
-        self.init(reserveCapacity: hex.unicodeScalars.lazy.underestimatedCount)
-        var buffer: UInt8?
-        var skip = hex.hasPrefix("0x") ? 2 : 0
-        for char in hex.unicodeScalars.lazy {
-            guard skip == 0 else {
-                skip -= 1
-                continue
-            }
-            guard char.value >= 48 && char.value <= 102 else {
-                removeAll()
-                return
-            }
-            let v: UInt8
-            let c: UInt8 = UInt8(char.value)
-            switch c {
-            case let c where c <= 57:
-                v = c - 48
-            case let c where c >= 65 && c <= 70:
-                v = c - 55
-            case let c where c >= 97:
-                v = c - 87
-            default:
-                removeAll()
-                return
-            }
-            if let b = buffer {
-                append(b << 4 | v)
-                buffer = nil
-            } else {
-                buffer = v
-            }
-        }
-        if let b = buffer {
-            append(b)
-        }
-    }
-
-    public func toHexString() -> String {
-        return `lazy`.reduce("") {
-            var s = String($1, radix: 16)
-            if s.count == 1 {
-                s = "0" + s
-            }
-            return $0 + s
-        }
-    }
-}
-
-extension Array where Element == UInt8 {
-    /// split in chunks with given chunk size
-    @available(*, deprecated)
-    public func chunks(size chunksize: Int) -> Array<Array<Element>> {
-        var words = Array<Array<Element>>()
-        words.reserveCapacity(count / chunksize)
-        for idx in stride(from: chunksize, through: count, by: chunksize) {
-            words.append(Array(self[idx - chunksize ..< idx])) // slow for large table
-        }
-        let remainder = suffix(count % chunksize)
-        if !remainder.isEmpty {
-            words.append(Array(remainder))
-        }
-        return words
-    }
-
-    public func md5() -> [Element] {
-        return Digest.md5(self)
-    }
-
-    public func sha1() -> [Element] {
-        return Digest.sha1(self)
-    }
-
-    public func sha224() -> [Element] {
-        return Digest.sha224(self)
-    }
-
-    public func sha256() -> [Element] {
-        return Digest.sha256(self)
-    }
-
-    public func sha384() -> [Element] {
-        return Digest.sha384(self)
-    }
-
-    public func sha512() -> [Element] {
-        return Digest.sha512(self)
-    }
-
-    public func sha2(_ variant: SHA2.Variant) -> [Element] {
-        return Digest.sha2(self, variant: variant)
-    }
-
-    public func sha3(_ variant: SHA3.Variant) -> [Element] {
-        return Digest.sha3(self, variant: variant)
-    }
-
-    public func crc32(seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
-        return Checksum.crc32(self, seed: seed, reflect: reflect)
-    }
-
-    public func crc32c(seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
-        return Checksum.crc32c(self, seed: seed, reflect: reflect)
-    }
-
-    public func crc16(seed: UInt16? = nil) -> UInt16 {
-        return Checksum.crc16(self, seed: seed)
-    }
-
-    public func encrypt(cipher: Cipher) throws -> [Element] {
-        return try cipher.encrypt(slice)
-    }
-
-    public func decrypt(cipher: Cipher) throws -> [Element] {
-        return try cipher.decrypt(slice)
-    }
-
-    public func authenticate<A: Authenticator>(with authenticator: A) throws -> [Element] {
-        return try authenticator.authenticate(self)
-    }
-}

+ 0 - 20
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Authenticator.swift

@@ -1,20 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-/// Message authentication code.
-public protocol Authenticator {
-    /// Calculate Message Authentication Code (MAC) for message.
-    func authenticate(_ bytes: Array<UInt8>) throws -> Array<UInt8>
-}

+ 0 - 63
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BatchedCollection.swift

@@ -1,63 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-struct BatchedCollectionIndex<Base: Collection> {
-    let range: Range<Base.Index>
-}
-
-extension BatchedCollectionIndex: Comparable {
-    static func == <Base>(lhs: BatchedCollectionIndex<Base>, rhs: BatchedCollectionIndex<Base>) -> Bool {
-        return lhs.range.lowerBound == rhs.range.lowerBound
-    }
-
-    static func < <Base>(lhs: BatchedCollectionIndex<Base>, rhs: BatchedCollectionIndex<Base>) -> Bool {
-        return lhs.range.lowerBound < rhs.range.lowerBound
-    }
-}
-
-protocol BatchedCollectionType: Collection {
-    associatedtype Base: Collection
-}
-
-struct BatchedCollection<Base: Collection>: Collection {
-    let base: Base
-    let size: Int
-    typealias Index = BatchedCollectionIndex<Base>
-    private func nextBreak(after idx: Base.Index) -> Base.Index {
-        return base.index(idx, offsetBy: size, limitedBy: base.endIndex) ?? base.endIndex
-    }
-
-    var startIndex: Index {
-        return Index(range: base.startIndex..<nextBreak(after: base.startIndex))
-    }
-
-    var endIndex: Index {
-        return Index(range: base.endIndex..<base.endIndex)
-    }
-
-    func index(after idx: Index) -> Index {
-        return Index(range: idx.range.upperBound..<nextBreak(after: idx.range.upperBound))
-    }
-
-    subscript(idx: Index) -> Base.SubSequence {
-        return base[idx.range]
-    }
-}
-
-extension Collection {
-    func batched(by size: Int) -> BatchedCollection<Self> {
-        return BatchedCollection(base: self, size: size)
-    }
-}

+ 0 - 25
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Bit.swift

@@ -1,25 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public enum Bit: Int {
-    case zero
-    case one
-}
-
-extension Bit {
-    func inverted() -> Bit {
-        return self == .zero ? .one : .zero
-    }
-}

+ 0 - 18
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockCipher.swift

@@ -1,18 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-protocol BlockCipher: Cipher {
-    static var blockSize: Int { get }
-}

+ 0 - 85
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockDecryptor.swift

@@ -1,85 +0,0 @@
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2018 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public class BlockDecryptor: Cryptor, Updatable {
-    private let blockSize: Int
-    private let padding: Padding
-    private var worker: CipherModeWorker
-    private var accumulated = Array<UInt8>()
-
-    init(blockSize: Int, padding: Padding, _ worker: CipherModeWorker) throws {
-        self.blockSize = blockSize
-        self.padding = padding
-        self.worker = worker
-    }
-
-    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
-        accumulated += bytes
-
-        // If a worker (eg GCM) can combine ciphertext + tag
-        // we need to remove tag from the ciphertext.
-        if !isLast && accumulated.count < blockSize + worker.additionalBufferSize {
-            return []
-        }
-
-        let accumulatedWithoutSuffix: Array<UInt8>
-        if worker.additionalBufferSize > 0 {
-            // FIXME: how slow is that?
-            accumulatedWithoutSuffix = Array(accumulated.prefix(accumulated.count - worker.additionalBufferSize))
-        } else {
-            accumulatedWithoutSuffix = accumulated
-        }
-
-        var processedBytesCount = 0
-        var plaintext = Array<UInt8>(reserveCapacity: accumulatedWithoutSuffix.count)
-        // Processing in a block-size manner. It's good for block modes, but bad for stream modes.
-        for var chunk in accumulatedWithoutSuffix.batched(by: blockSize) {
-            if isLast || (accumulatedWithoutSuffix.count - processedBytesCount) >= blockSize {
-                let isLastChunk = processedBytesCount + chunk.count == accumulatedWithoutSuffix.count
-                
-                if isLast, isLastChunk, var finalizingWorker = worker as? FinalizingDecryptModeWorker {
-                    chunk = try finalizingWorker.willDecryptLast(bytes: chunk + accumulated.suffix(worker.additionalBufferSize)) // tag size
-                }
-
-                if !chunk.isEmpty {
-                    plaintext += worker.decrypt(block: chunk)
-                }
-
-                if isLast, isLastChunk, var finalizingWorker = worker as? FinalizingDecryptModeWorker {
-                    plaintext = Array(try finalizingWorker.didDecryptLast(bytes: plaintext.slice))
-                }
-
-                processedBytesCount += chunk.count
-            }
-        }
-        accumulated.removeFirst(processedBytesCount) // super-slow
-
-        if isLast {
-            plaintext = padding.remove(from: plaintext, blockSize: blockSize)
-        }
-
-        return plaintext
-    }
-
-    public func seek(to position: Int) throws {
-        guard var worker = self.worker as? SeekableModeWorker else {
-            fatalError("Not supported")
-        }
-
-        try worker.seek(to: position)
-        self.worker = worker
-
-        accumulated = []
-    }
-}

+ 0 - 57
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockEncryptor.swift

@@ -1,57 +0,0 @@
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2018 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-final class BlockEncryptor: Cryptor, Updatable {
-    private let blockSize: Int
-    private var worker: CipherModeWorker
-    private let padding: Padding
-    // Accumulated bytes. Not all processed bytes.
-    private var accumulated = Array<UInt8>(reserveCapacity: 16)
-
-    private var lastBlockRemainder = 0
-
-    init(blockSize: Int, padding: Padding, _ worker: CipherModeWorker) throws {
-        self.blockSize = blockSize
-        self.padding = padding
-        self.worker = worker
-    }
-
-    // MARK: Updatable
-    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool) throws -> Array<UInt8> {
-        accumulated += bytes
-
-        if isLast {
-            accumulated = padding.add(to: accumulated, blockSize: blockSize)
-        }
-
-        var encrypted = Array<UInt8>(reserveCapacity: accumulated.count)
-        for chunk in accumulated.batched(by: blockSize) {
-            if isLast || chunk.count == blockSize {
-                encrypted += worker.encrypt(block: chunk)
-            }
-        }
-
-        // Stream encrypts all, so it removes all elements
-        accumulated.removeFirst(encrypted.count)
-
-        if var finalizingWorker = worker as? FinalizingEncryptModeWorker, isLast == true {
-            encrypted = Array(try finalizingWorker.finalize(encrypt: encrypted.slice))
-        }
-
-        return encrypted
-    }
-
-    func seek(to: Int) throws {
-        fatalError("Not supported")
-    }
-}

+ 0 - 24
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockMode.swift

@@ -1,24 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public typealias CipherOperationOnBlock = (_ block: ArraySlice<UInt8>) -> Array<UInt8>?
-
-public protocol BlockMode {
-    var options: BlockModeOption { get }
-    //TODO: doesn't have to be public
-    func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker
-}
-
-typealias StreamMode = BlockMode

+ 0 - 27
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockModeOptions.swift

@@ -1,27 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public struct BlockModeOption: OptionSet {
-    public let rawValue: Int
-
-    public init(rawValue: Int) {
-        self.rawValue = rawValue
-    }
-
-    static let none = BlockModeOption(rawValue: 1 << 0)
-    static let initializationVectorRequired = BlockModeOption(rawValue: 1 << 1)
-    static let paddingRequired = BlockModeOption(rawValue: 1 << 2)
-    static let useEncryptToDecrypt = BlockModeOption(rawValue: 1 << 3)
-}

+ 0 - 70
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CBC.swift

@@ -1,70 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  Cipher-block chaining (CBC)
-//
-
-public struct CBC: BlockMode {
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .paddingRequired]
-    private let iv: Array<UInt8>
-
-    public init(iv: Array<UInt8>) {
-        self.iv = iv
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if iv.count != blockSize {
-            throw Error.invalidInitializationVector
-        }
-
-        return CBCModeWorker(blockSize: blockSize, iv: iv.slice, cipherOperation: cipherOperation)
-    }
-}
-
-struct CBCModeWorker: BlockModeWorker {
-    let cipherOperation: CipherOperationOnBlock
-    var blockSize: Int
-    let additionalBufferSize: Int = 0
-    private let iv: ArraySlice<UInt8>
-    private var prev: ArraySlice<UInt8>?
-
-    init(blockSize: Int, iv: ArraySlice<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.blockSize = blockSize
-        self.iv = iv
-        self.cipherOperation = cipherOperation
-    }
-
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let ciphertext = cipherOperation(xor(prev ?? iv, plaintext)) else {
-            return Array(plaintext)
-        }
-        prev = ciphertext.slice
-        return ciphertext
-    }
-
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let plaintext = cipherOperation(ciphertext) else {
-            return Array(ciphertext)
-        }
-        let result: Array<UInt8> = xor(prev ?? iv, plaintext)
-        prev = ciphertext
-        return result
-    }
-}

+ 0 - 359
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CCM.swift

@@ -1,359 +0,0 @@
-////  CryptoSwift
-//
-//  Copyright (C) 2014-2018 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-// CCM mode combines the well known CBC-MAC with the well known counter mode of encryption.
-// https://tools.ietf.org/html/rfc3610
-// https://csrc.nist.gov/publications/detail/sp/800-38c/final
-
-#if canImport(Darwin)
-import Darwin
-#else
-import Glibc
-#endif
-
-
-/// Counter with Cipher Block Chaining-Message Authentication Code
-public struct CCM: StreamMode {
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-        case invalidParameter
-        case fail
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .useEncryptToDecrypt]
-    private let nonce: Array<UInt8>
-    private let additionalAuthenticatedData: Array<UInt8>?
-    private let tagLength: Int
-    private let messageLength: Int // total message length. need to know in advance
-
-    // `authenticationTag` nil for encryption, known tag for decryption
-    /// For encryption, the value is set at the end of the encryption.
-    /// For decryption, this is a known Tag to validate against.
-    public var authenticationTag: Array<UInt8>?
-
-    /// Initialize CCM
-    ///
-    /// - Parameters:
-    ///   - iv: Initialization vector. Nonce. Valid length between 7 and 13 bytes.
-    ///   - tagLength: Authentication tag length, in bytes. Value of {4, 6, 8, 10, 12, 14, 16}.
-    ///   - messageLength: Plaintext message length (excluding tag if attached). Length have to be provided in advance.
-    ///   - additionalAuthenticatedData: Additional authenticated data.
-    public init(iv: Array<UInt8>, tagLength: Int, messageLength: Int, additionalAuthenticatedData: Array<UInt8>? = nil) {
-        self.nonce = iv
-        self.tagLength = tagLength
-        self.additionalAuthenticatedData = additionalAuthenticatedData
-        self.messageLength = messageLength // - tagLength
-    }
-
-    /// Initialize CCM
-    ///
-    /// - Parameters:
-    ///   - iv: Initialization vector. Nonce. Valid length between 7 and 13 bytes.
-    ///   - tagLength: Authentication tag length, in bytes. Value of {4, 6, 8, 10, 12, 14, 16}.
-    ///   - messageLength: Plaintext message length (excluding tag if attached). Length have to be provided in advance.
-    ///   - authenticationTag: Authentication Tag value if not concatenated to ciphertext.
-    ///   - additionalAuthenticatedData: Additional authenticated data.
-    public init(iv: Array<UInt8>, tagLength: Int, messageLength: Int, authenticationTag: Array<UInt8>, additionalAuthenticatedData: Array<UInt8>? = nil) {
-        self.init(iv: iv, tagLength: tagLength, messageLength: messageLength, additionalAuthenticatedData: additionalAuthenticatedData)
-        self.authenticationTag = authenticationTag
-    }
-
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if nonce.isEmpty {
-            throw Error.invalidInitializationVector
-        }
-
-        return CCMModeWorker(blockSize: blockSize, nonce: nonce.slice, messageLength: messageLength, additionalAuthenticatedData: additionalAuthenticatedData, tagLength: tagLength, cipherOperation: cipherOperation)
-    }
-}
-
-class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, FinalizingEncryptModeWorker, FinalizingDecryptModeWorker {
-    typealias Counter = Int
-    var counter = 0
-
-    let cipherOperation: CipherOperationOnBlock
-    let blockSize: Int
-    private let tagLength: Int
-    private let messageLength: Int // total message length. need to know in advance
-    private let q: UInt8
-
-    let additionalBufferSize: Int
-    private var keystreamPosIdx = 0
-    private let nonce: Array<UInt8>
-    private var last_y: ArraySlice<UInt8> = []
-    private var keystream: Array<UInt8> = []
-    // Known Tag used to validate during decryption
-    private var expectedTag: Array<UInt8>?
-
-    public enum Error: Swift.Error {
-        case invalidParameter
-    }
-
-    init(blockSize: Int, nonce: ArraySlice<UInt8>, messageLength: Int,  additionalAuthenticatedData: [UInt8]?, expectedTag: Array<UInt8>? = nil, tagLength: Int, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.blockSize = 16 // CCM is defined for 128 block size
-        self.tagLength = tagLength
-        self.additionalBufferSize = tagLength
-        self.messageLength = messageLength
-        self.expectedTag = expectedTag
-        self.cipherOperation = cipherOperation
-        self.nonce = Array(nonce)
-        self.q = UInt8(15 - nonce.count) // n = 15-q
-
-        let hasAssociatedData = additionalAuthenticatedData != nil && !additionalAuthenticatedData!.isEmpty
-        processControlInformation(nonce: self.nonce, tagLength: tagLength, hasAssociatedData: hasAssociatedData)
-
-        if let aad = additionalAuthenticatedData, hasAssociatedData {
-            process(aad: aad)
-        }
-    }
-
-    // For the very first time setup new IV (aka y0) from the block0
-    private func processControlInformation(nonce: [UInt8], tagLength: Int, hasAssociatedData: Bool) {
-        let block0 = try! format(nonce: nonce, Q: UInt32(messageLength), q: q, t: UInt8(tagLength), hasAssociatedData: hasAssociatedData).slice
-        let y0 = cipherOperation(block0)!.slice
-        last_y = y0
-    }
-
-    private func process(aad: [UInt8]) {
-        let encodedAAD = format(aad: aad)
-
-        for block_i in encodedAAD.batched(by: 16) {
-            let y_i = cipherOperation(xor(block_i, last_y))!.slice
-            last_y = y_i
-        }
-    }
-
-    private func S(i: Int) throws -> [UInt8] {
-        let ctr = try format(counter: i, nonce: nonce, q: q)
-        return cipherOperation(ctr.slice)!
-    }
-
-    func seek(to position: Int) throws {
-        self.counter = position
-        keystream = try S(i: position)
-        let offset = position % blockSize
-        keystreamPosIdx = offset
-    }
-
-    func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        var result = Array<UInt8>(reserveCapacity: plaintext.count)
-
-        var processed = 0
-        while processed < plaintext.count {
-            // Need a full block here to update keystream and do CBC
-            if keystream.isEmpty || keystreamPosIdx == blockSize {
-                // y[i], where i is the counter. Can encrypt 1 block at a time
-                counter += 1
-                guard let S = try? S(i: counter) else { return Array(plaintext) }
-                let plaintextP = addPadding(Array(plaintext), blockSize: blockSize)
-                guard let y = cipherOperation(xor(last_y, plaintextP)) else { return Array(plaintext) }
-                last_y = y.slice
-
-                keystream = S
-                keystreamPosIdx = 0
-            }
-
-            let xored: Array<UInt8> = xor(plaintext[plaintext.startIndex.advanced(by: processed)...], keystream[keystreamPosIdx...])
-            keystreamPosIdx += xored.count
-            processed += xored.count
-            result += xored
-        }
-        return result
-    }
-
-    func finalize(encrypt ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // concatenate T at the end
-        guard let S0 = try? S(i: 0) else { return ciphertext }
-
-        let computedTag = xor(last_y.prefix(tagLength), S0) as ArraySlice<UInt8>
-        return ciphertext + computedTag
-    }
-
-    // Decryption is stream
-    // CBC is block
-    private var accumulatedPlaintext: [UInt8] = []
-
-    func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        var output = Array<UInt8>(reserveCapacity: ciphertext.count)
-
-        do {
-            var currentCounter = counter
-            var processed = 0
-            while processed < ciphertext.count {
-                // Need a full block here to update keystream and do CBC
-                // New keystream for a new block
-                if keystream.isEmpty || keystreamPosIdx == blockSize {
-                    currentCounter += 1
-                    guard let S = try? S(i: currentCounter) else { return Array(ciphertext) }
-                    keystream = S
-                    keystreamPosIdx = 0
-                }
-
-                let xored: Array<UInt8> = xor(ciphertext[ciphertext.startIndex.advanced(by: processed)...], keystream[keystreamPosIdx...]) // plaintext
-                keystreamPosIdx += xored.count
-                processed += xored.count
-                output += xored
-                counter = currentCounter
-            }
-        }
-
-        // Accumulate plaintext for the MAC calculations at the end.
-        // It would be good to process it together though, here.
-        accumulatedPlaintext += output
-
-        // Shouldn't return plaintext until validate tag.
-        // With incremental update, can't validate tag until all block are processed.
-        return output
-    }
-
-    func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // concatenate T at the end
-        let computedTag = Array(last_y.prefix(tagLength))
-        guard let expectedTag = self.expectedTag, expectedTag == computedTag else {
-            throw CCM.Error.fail
-        }
-
-        return plaintext
-    }
-
-    @discardableResult
-    func willDecryptLast(bytes ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // get tag of additionalBufferSize size
-        // `ciphertext` contains at least additionalBufferSize bytes
-        // overwrite expectedTag property used later for verification
-        guard let S0 = try? S(i: 0) else { return ciphertext }
-        self.expectedTag = xor(ciphertext.suffix(tagLength), S0) as [UInt8]
-        return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength,ciphertext.count))]
-    }
-
-    func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-
-        // Calculate Tag, from the last CBC block, for accumulated plaintext.
-        var processed = 0
-        for block in accumulatedPlaintext.batched(by: blockSize) {
-            let blockP = addPadding(Array(block), blockSize: blockSize)
-            guard let y = cipherOperation(xor(last_y, blockP)) else { return plaintext }
-            last_y = y.slice
-            processed += block.count
-        }
-        accumulatedPlaintext.removeFirst(processed)
-        return plaintext
-    }
-}
-
-// Q - octet length of P
-// q - octet length of Q. Maximum length (in octets) of payload. An element of {2,3,4,5,6,7,8}
-// t - octet length of T (MAC length). An element of {4,6,8,10,12,14,16}
-private func format(nonce N: [UInt8], Q: UInt32, q: UInt8, t: UInt8, hasAssociatedData: Bool) throws -> [UInt8] {
-    var flags0: UInt8 = 0
-
-    if hasAssociatedData {
-        // 7 bit
-        flags0 |= (1 << 6)
-    }
-
-    // 6,5,4 bit is t in 3 bits
-    flags0 |= (((t-2)/2) & 0x07) << 3
-
-    // 3,2,1 bit is q in 3 bits
-    flags0 |= ((q-1) & 0x07) << 0
-
-    var block0: [UInt8] = Array<UInt8>(repeating: 0, count: 16)
-    block0[0] = flags0
-
-    // N in 1...(15-q) octets, n = 15-q
-    // n is an element of {7,8,9,10,11,12,13}
-    let n = 15-Int(q)
-    guard (n + Int(q)) == 15 else {
-        // n+q == 15
-        throw CCMModeWorker.Error.invalidParameter
-    }
-    block0[1...n] = N[0...(n-1)]
-
-    // Q in (16-q)...15 octets
-    block0[(16-Int(q))...15] = Q.bytes(totalBytes: Int(q)).slice
-
-    return block0
-}
-
-/// Formatting of the Counter Blocks. Ctr[i]
-/// The counter generation function.
-/// Q - octet length of P
-/// q - octet length of Q. Maximum length (in octets) of payload. An element of {2,3,4,5,6,7,8}
-private func format(counter i: Int, nonce N: [UInt8], q: UInt8) throws -> [UInt8] {
-    var flags0: UInt8 = 0
-
-    // bit 8,7 is Reserved
-    // bit 4,5,6 shall be set to 0
-    // 3,2,1 bit is q in 3 bits
-    flags0 |= ((q-1) & 0x07) << 0
-
-    var block = Array<UInt8>(repeating: 0, count: 16) // block[0]
-    block[0] = flags0
-
-    // N in 1...(15-q) octets, n = 15-q
-    // n is an element of {7,8,9,10,11,12,13}
-    let n = 15-Int(q)
-    guard (n + Int(q)) == 15 else {
-        // n+q == 15
-        throw CCMModeWorker.Error.invalidParameter
-    }
-    block[1...n] = N[0...(n-1)]
-
-    // [i]8q in (16-q)...15 octets
-    block[(16-Int(q))...15] = i.bytes(totalBytes: Int(q)).slice
-
-    return block
-}
-
-/// Resulting can be partitioned into 16-octet blocks
-private func format(aad: [UInt8]) -> [UInt8] {
-    let a = aad.count
-
-    switch Double(a) {
-    case 0..<65280: // 2^16-2^8
-        // [a]16
-        return addPadding(a.bytes(totalBytes: 2) + aad, blockSize: 16)
-    case 65280..<4_294_967_296: // 2^32
-        // [a]32
-        return addPadding([0xFF, 0xFE] + a.bytes(totalBytes: 4) + aad, blockSize: 16)
-    case 4_294_967_296..<pow(2,64): // 2^64
-        // [a]64
-        return addPadding([0xFF, 0xFF] + a.bytes(totalBytes: 8) + aad, blockSize: 16)
-    default:
-        // Reserved
-        return addPadding(aad, blockSize: 16)
-    }
-}
-
-// If data is not a multiple of block size bytes long then the remainder is zero padded
-// Note: It's similar to ZeroPadding, but it's not the same.
-private func addPadding(_ bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
-    if bytes.isEmpty {
-        return Array<UInt8>(repeating: 0, count: blockSize)
-    }
-
-    let remainder = bytes.count % blockSize
-    if remainder == 0 {
-        return bytes
-    }
-
-    let paddingCount = blockSize - remainder
-    if paddingCount > 0 {
-        return bytes + Array<UInt8>(repeating: 0, count: paddingCount)
-    }
-    return bytes
-}

+ 0 - 70
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CFB.swift

@@ -1,70 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  Cipher feedback (CFB)
-//
-
-public struct CFB: BlockMode {
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .useEncryptToDecrypt]
-    private let iv: Array<UInt8>
-
-    public init(iv: Array<UInt8>) {
-        self.iv = iv
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if iv.count != blockSize {
-            throw Error.invalidInitializationVector
-        }
-
-        return CFBModeWorker(blockSize: blockSize, iv: iv.slice, cipherOperation: cipherOperation)
-    }
-}
-
-struct CFBModeWorker: BlockModeWorker {
-    let cipherOperation: CipherOperationOnBlock
-    let blockSize: Int
-    let additionalBufferSize: Int = 0
-    private let iv: ArraySlice<UInt8>
-    private var prev: ArraySlice<UInt8>?
-
-    init(blockSize: Int, iv: ArraySlice<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.blockSize = blockSize
-        self.iv = iv
-        self.cipherOperation = cipherOperation
-    }
-
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let ciphertext = cipherOperation(prev ?? iv) else {
-            return Array(plaintext)
-        }
-        prev = xor(plaintext, ciphertext.slice)
-        return Array(prev ?? [])
-    }
-
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let plaintext = cipherOperation(prev ?? iv) else {
-            return Array(ciphertext)
-        }
-        let result: Array<UInt8> = xor(plaintext, ciphertext)
-        prev = ciphertext
-        return result
-    }
-}

+ 0 - 134
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CTR.swift

@@ -1,134 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  Counter (CTR)
-
-public struct CTR: StreamMode {
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .useEncryptToDecrypt]
-    private let iv: Array<UInt8>
-    private let counter: Int
-
-    public init(iv: Array<UInt8>, counter: Int = 0) {
-        self.iv = iv
-        self.counter = counter
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if iv.count != blockSize {
-            throw Error.invalidInitializationVector
-        }
-
-        return CTRModeWorker(blockSize: blockSize, iv: iv.slice, counter: counter, cipherOperation: cipherOperation)
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-struct CTRModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker {
-    typealias Counter = CTRCounter
-
-    final class CTRCounter {
-        private let constPrefix: Array<UInt8>
-        private var value: UInt64
-        //TODO: make it an updatable value, computing is too slow
-        var bytes: Array<UInt8> {
-            return constPrefix + value.bytes()
-        }
-
-        init(_ initialValue: Array<UInt8>) {
-            let halfIndex = initialValue.startIndex.advanced(by: initialValue.count / 2)
-            constPrefix = Array(initialValue[initialValue.startIndex..<halfIndex])
-
-            let suffixBytes = Array(initialValue[halfIndex...])
-            value = UInt64(bytes: suffixBytes)
-        }
-
-        convenience init(nonce: Array<UInt8>, startAt index: Int) {
-            self.init(buildCounterValue(nonce, counter: UInt64(index)))
-        }
-
-        static func +=(lhs: CTRCounter, rhs: Int) {
-            lhs.value += UInt64(rhs)
-        }
-    }
-
-    let cipherOperation: CipherOperationOnBlock
-    let additionalBufferSize: Int = 0
-    let iv: Array<UInt8>
-    var counter: CTRCounter
-
-    private let blockSize: Int
-
-    // The same keystream is used for the block length plaintext
-    // As new data is added, keystream suffix is used to xor operation.
-    private var keystream: Array<UInt8>
-    private var keystreamPosIdx = 0
-
-    init(blockSize: Int, iv: ArraySlice<UInt8>, counter: Int, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.cipherOperation = cipherOperation
-        self.blockSize = blockSize
-        self.iv = Array(iv)
-
-        // the first keystream is calculated from the nonce = initial value of counter
-        self.counter = CTRCounter(nonce: Array(iv), startAt: counter)
-        self.keystream = Array(cipherOperation(self.counter.bytes.slice)!)
-    }
-
-    mutating func seek(to position: Int) throws {
-        let offset = position % blockSize
-        counter = CTRCounter(nonce: iv, startAt: position / blockSize)
-        keystream = Array(cipherOperation(counter.bytes.slice)!)
-        keystreamPosIdx = offset
-    }
-
-    // plaintext is at most blockSize long
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        var result = Array<UInt8>(reserveCapacity: plaintext.count)
-
-        var processed = 0
-        while processed < plaintext.count {
-            // Update keystream
-            if keystreamPosIdx == blockSize {
-                counter += 1
-                keystream = Array(cipherOperation(counter.bytes.slice)!)
-                keystreamPosIdx = 0
-            }
-
-            let xored: Array<UInt8> = xor(plaintext[plaintext.startIndex.advanced(by: processed)...], keystream[keystreamPosIdx...])
-            keystreamPosIdx += xored.count
-            processed += xored.count
-            result += xored
-        }
-
-        return result
-    }
-
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        return encrypt(block: ciphertext)
-    }
-}
-
-private func buildCounterValue(_ iv: Array<UInt8>, counter: UInt64) -> Array<UInt8> {
-    let noncePartLen = iv.count / 2
-    let noncePrefix = iv[iv.startIndex..<iv.startIndex.advanced(by: noncePartLen)]
-    let nonceSuffix = iv[iv.startIndex.advanced(by: noncePartLen)..<iv.startIndex.advanced(by: iv.count)]
-    let c = UInt64(bytes: nonceSuffix) + counter
-    return noncePrefix + c.bytes()
-}

+ 0 - 61
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/CipherModeWorker.swift

@@ -1,61 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public protocol CipherModeWorker {
-    var cipherOperation: CipherOperationOnBlock { get }
-
-    // Additional space needed when incrementally process data
-    // eg. for GCM combined mode
-    var additionalBufferSize: Int { get }
-
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8>
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8>
-}
-
-/// Block workers use `BlockEncryptor`
-public protocol BlockModeWorker: CipherModeWorker {
-    var blockSize: Int { get }
-}
-
-public protocol CounterModeWorker: CipherModeWorker {
-    associatedtype Counter
-    var counter: Counter { get set }
-}
-
-public protocol SeekableModeWorker: CipherModeWorker {
-    mutating func seek(to position: Int) throws
-}
-
-/// Stream workers use `StreamEncryptor`
-public protocol StreamModeWorker: CipherModeWorker {
-}
-
-public protocol FinalizingEncryptModeWorker: CipherModeWorker {
-    // Any final calculations, eg. calculate tag
-    // Called after the last block is encrypted
-    mutating func finalize(encrypt ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
-}
-
-public protocol FinalizingDecryptModeWorker: CipherModeWorker {
-    // Called before decryption, hence input is ciphertext.
-    // ciphertext is either a last block, or a tag (for stream workers)
-    @discardableResult
-    mutating func willDecryptLast(bytes ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
-    // Called after decryption, hence input is ciphertext
-    mutating func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
-    // Any final calculations, eg. calculate tag
-    // Called after the last block is encrypted
-    mutating func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
-}

+ 0 - 51
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/ECB.swift

@@ -1,51 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  Electronic codebook (ECB)
-//
-
-public struct ECB: BlockMode {
-    public let options: BlockModeOption = .paddingRequired
-
-    public init() {
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        return ECBModeWorker(blockSize: blockSize, cipherOperation: cipherOperation)
-    }
-}
-
-struct ECBModeWorker: BlockModeWorker {
-    typealias Element = Array<UInt8>
-    let cipherOperation: CipherOperationOnBlock
-    let blockSize: Int
-    let additionalBufferSize: Int = 0
-
-    init(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.blockSize = blockSize
-        self.cipherOperation = cipherOperation
-    }
-
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let ciphertext = cipherOperation(plaintext) else {
-            return Array(plaintext)
-        }
-        return ciphertext
-    }
-
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        return encrypt(block: ciphertext)
-    }
-}

+ 0 - 370
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/GCM.swift

@@ -1,370 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  Galois/Counter Mode (GCM)
-//  https://csrc.nist.gov/publications/detail/sp/800-38d/final
-//  ref: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.694.695&rep=rep1&type=pdf
-//
-
-public final class GCM: BlockMode {
-    public enum Mode {
-        /// In combined mode, the authentication tag is directly appended to the encrypted message. This is usually what you want.
-        case combined
-        /// Some applications may need to store the authentication tag and the encrypted message at different locations.
-        case detached
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .useEncryptToDecrypt]
-
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-        /// Special symbol FAIL that indicates that the inputs are not authentic.
-        case fail
-    }
-
-    private let iv: Array<UInt8>
-    private let additionalAuthenticatedData: Array<UInt8>?
-    private let mode: Mode
-    
-    /// Length of authentication tag, in bytes.
-    /// For encryption, the value is given as init parameter.
-    /// For decryption, the lenght of given authentication tag is used.
-    private let tagLength: Int
-
-    // `authenticationTag` nil for encryption, known tag for decryption
-    /// For encryption, the value is set at the end of the encryption.
-    /// For decryption, this is a known Tag to validate against.
-    public var authenticationTag: Array<UInt8>?
-
-    // encrypt
-    /// Possible tag lengths: 4,8,12,13,14,15,16
-    public init(iv: Array<UInt8>, additionalAuthenticatedData: Array<UInt8>? = nil, tagLength: Int = 16, mode: Mode = .detached) {
-        self.iv = iv
-        self.additionalAuthenticatedData = additionalAuthenticatedData
-        self.mode = mode
-        self.tagLength = tagLength
-    }
-
-    // decrypt
-    public convenience init(iv: Array<UInt8>, authenticationTag: Array<UInt8>, additionalAuthenticatedData: Array<UInt8>? = nil, mode: Mode = .detached) {
-        self.init(iv: iv, additionalAuthenticatedData: additionalAuthenticatedData, tagLength: authenticationTag.count, mode: mode)
-        self.authenticationTag = authenticationTag
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if iv.isEmpty {
-            throw Error.invalidInitializationVector
-        }
-
-        let worker = GCMModeWorker(iv: iv.slice, aad: additionalAuthenticatedData?.slice, expectedTag: authenticationTag, tagLength: tagLength, mode: mode, cipherOperation: cipherOperation)
-        worker.didCalculateTag = { [weak self] tag in
-            self?.authenticationTag = tag
-        }
-        return worker
-    }
-}
-
-// MARK: - Worker
-
-final class GCMModeWorker: BlockModeWorker, FinalizingEncryptModeWorker, FinalizingDecryptModeWorker {
-    let cipherOperation: CipherOperationOnBlock
-
-    // Callback called when authenticationTag is ready
-    var didCalculateTag: ((Array<UInt8>) -> Void)?
-
-    private let tagLength: Int
-    // GCM nonce is 96-bits by default. It's the most effective length for the IV
-    private static let nonceSize = 12
-
-    // GCM is designed for 128-bit ciphers like AES (but not really for Blowfish). 64-bit mode is not implemented.
-    let blockSize = 16 // 128 bit
-    let additionalBufferSize: Int
-    private let iv: ArraySlice<UInt8>
-    private let mode: GCM.Mode
-    private var counter: UInt128
-    private let eky0: UInt128 // move to GF?
-    private let h: UInt128
-
-    // Additional authenticated data
-    private let aad: ArraySlice<UInt8>?
-    // Known Tag used to validate during decryption
-    private var expectedTag: Array<UInt8>?
-
-    // Note: need new worker to reset instance
-    // Use empty aad if not specified. AAD is optional.
-    private lazy var gf: GF = {
-        if let aad = aad {
-            return GF(aad: Array(aad), h: h, blockSize: blockSize)
-        }
-        return GF(aad: [UInt8](), h: h, blockSize: blockSize)
-    }()
-
-    init(iv: ArraySlice<UInt8>, aad: ArraySlice<UInt8>? = nil, expectedTag: Array<UInt8>? = nil, tagLength: Int, mode: GCM.Mode, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.cipherOperation = cipherOperation
-        self.iv = iv
-        self.mode = mode
-        self.aad = aad
-        self.expectedTag = expectedTag
-        self.tagLength = tagLength
-        h = UInt128(cipherOperation(Array<UInt8>(repeating: 0, count: blockSize).slice)!) // empty block
-
-        if mode == .combined {
-            self.additionalBufferSize = tagLength
-        } else {
-            self.additionalBufferSize = 0
-        }
-        
-        // Assume nonce is 12 bytes long, otherwise initial counter would be calulated from GHASH
-        // counter = GF.ghash(aad: [UInt8](), ciphertext: nonce)
-        if iv.count == GCMModeWorker.nonceSize {
-            counter = makeCounter(nonce: Array(self.iv))
-        } else {
-            counter = GF.ghash(h: h, aad: [UInt8](), ciphertext: Array(iv), blockSize: blockSize)
-        }
-
-        // Set constants
-        eky0 = UInt128(cipherOperation(counter.bytes.slice)!)
-    }
-
-    func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        counter = incrementCounter(counter)
-
-        guard let ekyN = cipherOperation(counter.bytes.slice) else {
-            return Array(plaintext)
-        }
-
-        // plaintext block ^ ek1
-        let ciphertext = xor(plaintext, ekyN) as Array<UInt8>
-
-        // update ghash incrementally
-        gf.ghashUpdate(block: ciphertext)
-
-        return Array(ciphertext)
-    }
-
-    func finalize(encrypt ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // Calculate MAC tag.
-        let ghash = gf.ghashFinish()
-        let tag = Array((ghash ^ eky0).bytes.prefix(tagLength))
-
-        // Notify handler
-        didCalculateTag?(tag)
-
-        switch mode {
-        case .combined:
-            return (ciphertext + tag).slice
-        case .detached:
-            return ciphertext
-        }
-    }
-
-    func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        counter = incrementCounter(counter)
-
-        // update ghash incrementally
-        gf.ghashUpdate(block: Array(ciphertext))
-
-        guard let ekN = cipherOperation(counter.bytes.slice) else {
-            return Array(ciphertext)
-        }
-
-        // ciphertext block ^ ek1
-        let plaintext = xor(ciphertext, ekN) as Array<UInt8>
-        return plaintext
-    }
-
-    // The authenticated decryption operation has five inputs: K, IV , C, A, and T. It has only a single
-    // output, either the plaintext value P or a special symbol FAIL that indicates that the inputs are not
-    // authentic.
-    @discardableResult
-    func willDecryptLast(bytes ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // Validate tag
-        switch mode {
-        case .combined:
-            // overwrite expectedTag property used later for verification
-            self.expectedTag = Array(ciphertext.suffix(tagLength))
-            return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength,ciphertext.count))]
-        case .detached:
-            return ciphertext
-        }
-    }
-
-    func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // Calculate MAC tag.
-        let ghash = gf.ghashFinish()
-        let computedTag = Array((ghash ^ eky0).bytes.prefix(tagLength))
-
-        // Validate tag
-        guard let expectedTag = self.expectedTag, computedTag == expectedTag else {
-            throw GCM.Error.fail
-        }
-
-        return plaintext
-    }
-
-    func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        // do nothing
-        return plaintext
-    }
-}
-
-// MARK: - Local utils
-
-private func makeCounter(nonce: Array<UInt8>) -> UInt128 {
-    return UInt128(nonce + [0, 0, 0, 1])
-}
-
-// Successive counter values are generated using the function incr(), which treats the rightmost 32
-// bits of its argument as a nonnegative integer with the least significant bit on the right
-private func incrementCounter(_ counter: UInt128) -> UInt128 {
-    let b = counter.i.b + 1
-    let a = (b == 0 ? counter.i.a + 1 : counter.i.a)
-    return UInt128((a, b))
-}
-
-// If data is not a multiple of block size bytes long then the remainder is zero padded
-// Note: It's similar to ZeroPadding, but it's not the same.
-private func addPadding(_ bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
-    if bytes.isEmpty {
-        return Array<UInt8>(repeating: 0, count: blockSize)
-    }
-
-    let remainder = bytes.count % blockSize
-    if remainder == 0 {
-        return bytes
-    }
-
-    let paddingCount = blockSize - remainder
-    if paddingCount > 0 {
-        return bytes + Array<UInt8>(repeating: 0, count: paddingCount)
-    }
-    return bytes
-}
-
-// MARK: - GF
-
-/// The Field GF(2^128)
-private final class GF {
-    static let r = UInt128(a: 0xE100000000000000, b: 0)
-
-    let blockSize: Int
-    let h: UInt128
-
-    // AAD won't change
-    let aadLength: Int
-
-    // Updated for every consumed block
-    var ciphertextLength: Int
-
-    // Start with 0
-    var x: UInt128
-
-    init(aad: [UInt8], h: UInt128, blockSize: Int) {
-        self.blockSize = blockSize
-        aadLength = aad.count
-        ciphertextLength = 0
-        self.h = h
-        x = 0
-
-        // Calculate for AAD at the begining
-        x = GF.calculateX(aad: aad, x: x, h: h, blockSize: blockSize)
-    }
-
-    @discardableResult
-    func ghashUpdate(block ciphertextBlock: Array<UInt8>) -> UInt128 {
-        ciphertextLength += ciphertextBlock.count
-        x = GF.calculateX(block: addPadding(ciphertextBlock, blockSize: blockSize), x: x, h: h, blockSize: blockSize)
-        return x
-    }
-
-    func ghashFinish() -> UInt128 {
-        // len(A) || len(C)
-        let len = UInt128(a: UInt64(aadLength * 8), b: UInt64(ciphertextLength * 8))
-        x = GF.multiply((x ^ len), h)
-        return x
-    }
-
-    // GHASH. One-time calculation
-    static func ghash(x startx: UInt128 = 0, h: UInt128, aad: Array<UInt8>, ciphertext: Array<UInt8>, blockSize: Int) -> UInt128 {
-        var x = calculateX(aad: aad, x: startx, h: h, blockSize: blockSize)
-        x = calculateX(ciphertext: ciphertext, x: x, h: h, blockSize: blockSize)
-
-        // len(aad) || len(ciphertext)
-        let len = UInt128(a: UInt64(aad.count * 8), b: UInt64(ciphertext.count * 8))
-        x = multiply((x ^ len), h)
-
-        return x
-    }
-
-    // Calculate Ciphertext part, for all blocks
-    // Not used with incremental calculation.
-    private static func calculateX(ciphertext: [UInt8], x startx: UInt128, h: UInt128, blockSize: Int) -> UInt128 {
-        let pciphertext = addPadding(ciphertext, blockSize: blockSize)
-        let blocksCount = pciphertext.count / blockSize
-
-        var x = startx
-        for i in 0..<blocksCount {
-            let cpos = i * blockSize
-            let block = pciphertext[pciphertext.startIndex.advanced(by: cpos)..<pciphertext.startIndex.advanced(by: cpos + blockSize)]
-            x = calculateX(block: Array(block), x: x, h: h, blockSize: blockSize)
-        }
-        return x
-    }
-
-    // block is expected to be padded with addPadding
-    private static func calculateX(block ciphertextBlock: Array<UInt8>, x: UInt128, h: UInt128, blockSize: Int) -> UInt128 {
-        let k = x ^ UInt128(ciphertextBlock)
-        return multiply(k, h)
-    }
-
-    // Calculate AAD part, for all blocks
-    private static func calculateX(aad: [UInt8], x startx: UInt128, h: UInt128, blockSize: Int) -> UInt128 {
-        let paad = addPadding(aad, blockSize: blockSize)
-        let blocksCount = paad.count / blockSize
-
-        var x = startx
-        for i in 0..<blocksCount {
-            let apos = i * blockSize
-            let k = x ^ UInt128(paad[paad.startIndex.advanced(by: apos)..<paad.startIndex.advanced(by: apos + blockSize)])
-            x = multiply(k, h)
-        }
-
-        return x
-    }
-
-    // Multiplication GF(2^128).
-    private static func multiply(_ x: UInt128, _ y: UInt128) -> UInt128 {
-        var z: UInt128 = 0
-        var v = x
-        var k = UInt128(a: 1 << 63, b: 0)
-
-        for _ in 0..<128 {
-            if y & k == k {
-                z = z ^ v
-            }
-
-            if v & 1 != 1 {
-                v = v >> 1
-            } else {
-                v = (v >> 1) ^ r
-            }
-
-            k = k >> 1
-        }
-
-        return z
-    }
-}

+ 0 - 70
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/OFB.swift

@@ -1,70 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-// Output Feedback (OFB)
-//
-
-public struct OFB: BlockMode {
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .useEncryptToDecrypt]
-    private let iv: Array<UInt8>
-
-    public init(iv: Array<UInt8>) {
-        self.iv = iv
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if iv.count != blockSize {
-            throw Error.invalidInitializationVector
-        }
-
-        return OFBModeWorker(blockSize: blockSize, iv: iv.slice, cipherOperation: cipherOperation)
-    }
-}
-
-struct OFBModeWorker: BlockModeWorker {
-    let cipherOperation: CipherOperationOnBlock
-    let blockSize: Int
-    let additionalBufferSize: Int = 0
-    private let iv: ArraySlice<UInt8>
-    private var prev: ArraySlice<UInt8>?
-
-    init(blockSize: Int, iv: ArraySlice<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.blockSize = blockSize
-        self.iv = iv
-        self.cipherOperation = cipherOperation
-    }
-
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let ciphertext = cipherOperation(prev ?? iv) else {
-            return Array(plaintext)
-        }
-        prev = ciphertext.slice
-        return xor(plaintext, ciphertext)
-    }
-
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let decrypted = cipherOperation(prev ?? iv) else {
-            return Array(ciphertext)
-        }
-        let plaintext: Array<UInt8> = xor(decrypted, ciphertext)
-        prev = decrypted.slice
-        return plaintext
-    }
-}

+ 0 - 70
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/BlockMode/PCBC.swift

@@ -1,70 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  Propagating Cipher Block Chaining (PCBC)
-//
-
-public struct PCBC: BlockMode {
-    public enum Error: Swift.Error {
-        /// Invalid IV
-        case invalidInitializationVector
-    }
-
-    public let options: BlockModeOption = [.initializationVectorRequired, .paddingRequired]
-    private let iv: Array<UInt8>
-
-    public init(iv: Array<UInt8>) {
-        self.iv = iv
-    }
-
-    public func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker {
-        if iv.count != blockSize {
-            throw Error.invalidInitializationVector
-        }
-
-        return PCBCModeWorker(blockSize: blockSize, iv: iv.slice, cipherOperation: cipherOperation)
-    }
-}
-
-struct PCBCModeWorker: BlockModeWorker {
-    let cipherOperation: CipherOperationOnBlock
-    var blockSize: Int
-    let additionalBufferSize: Int = 0
-    private let iv: ArraySlice<UInt8>
-    private var prev: ArraySlice<UInt8>?
-
-    init(blockSize: Int, iv: ArraySlice<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
-        self.blockSize = blockSize
-        self.iv = iv
-        self.cipherOperation = cipherOperation
-    }
-
-    mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let ciphertext = cipherOperation(xor(prev ?? iv, plaintext)) else {
-            return Array(plaintext)
-        }
-        prev = xor(plaintext, ciphertext.slice)
-        return ciphertext
-    }
-
-    mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
-        guard let plaintext = cipherOperation(ciphertext) else {
-            return Array(ciphertext)
-        }
-        let result: Array<UInt8> = xor(prev ?? iv, plaintext)
-        prev = xor(plaintext.slice, ciphertext)
-        return result
-    }
-}

+ 0 - 537
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Blowfish.swift

@@ -1,537 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  https://en.wikipedia.org/wiki/Blowfish_(cipher)
-//  Based on Paul Kocher implementation
-//
-
-public final class Blowfish {
-    public enum Error: Swift.Error {
-        /// Data padding is required
-        case dataPaddingRequired
-        /// Invalid key or IV
-        case invalidKeyOrInitializationVector
-        /// Invalid IV
-        case invalidInitializationVector
-        /// Invalid block mode
-        case invalidBlockMode
-    }
-
-    public static let blockSize: Int = 8 // 64 bit
-    public let keySize: Int
-
-    private let blockMode: BlockMode
-    private let padding: Padding
-    private var decryptWorker: CipherModeWorker!
-    private var encryptWorker: CipherModeWorker!
-
-    private let N = 16 // rounds
-    private var P: Array<UInt32>
-    private var S: Array<Array<UInt32>>
-    private let origP: Array<UInt32> = [
-        0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822,
-        0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377,
-        0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5,
-        0xb5470917, 0x9216d5d9, 0x8979fb1b,
-    ]
-
-    private let origS: Array<Array<UInt32>> = [
-        [
-            0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
-            0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
-            0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
-            0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
-            0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
-            0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
-            0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
-            0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
-            0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
-            0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
-            0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
-            0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
-            0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
-            0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
-            0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
-            0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
-            0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
-            0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
-            0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
-            0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
-            0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
-            0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
-            0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
-            0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
-            0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
-            0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
-            0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
-            0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
-            0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
-            0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
-            0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
-            0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
-            0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
-            0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
-            0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
-            0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
-            0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
-            0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
-            0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
-            0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
-            0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
-            0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
-            0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
-            0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
-            0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
-            0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
-            0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
-            0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
-            0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
-            0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
-            0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
-            0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
-            0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
-            0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
-            0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
-            0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
-            0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
-            0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
-            0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
-            0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
-            0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
-            0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
-            0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
-            0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
-        ],
-        [
-            0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
-            0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
-            0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
-            0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
-            0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
-            0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
-            0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
-            0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
-            0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
-            0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
-            0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
-            0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
-            0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
-            0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
-            0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
-            0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
-            0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
-            0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
-            0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
-            0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
-            0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
-            0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
-            0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
-            0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
-            0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
-            0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
-            0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
-            0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
-            0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
-            0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
-            0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
-            0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
-            0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
-            0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
-            0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
-            0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
-            0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
-            0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
-            0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
-            0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
-            0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
-            0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
-            0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
-            0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
-            0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
-            0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
-            0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
-            0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
-            0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
-            0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
-            0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
-            0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
-            0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
-            0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
-            0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
-            0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
-            0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
-            0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
-            0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
-            0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
-            0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
-            0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
-            0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
-            0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
-        ],
-        [
-            0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
-            0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
-            0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
-            0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
-            0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
-            0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
-            0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
-            0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
-            0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
-            0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
-            0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
-            0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
-            0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
-            0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
-            0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
-            0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
-            0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
-            0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
-            0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
-            0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
-            0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
-            0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
-            0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
-            0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
-            0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
-            0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
-            0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
-            0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
-            0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
-            0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
-            0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
-            0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
-            0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
-            0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
-            0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
-            0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
-            0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
-            0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
-            0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
-            0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
-            0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
-            0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
-            0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
-            0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
-            0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
-            0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
-            0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
-            0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
-            0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
-            0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
-            0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
-            0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
-            0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
-            0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
-            0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
-            0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
-            0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
-            0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
-            0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
-            0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
-            0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
-            0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
-            0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
-            0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
-        ],
-        [
-            0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
-            0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
-            0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
-            0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
-            0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
-            0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
-            0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
-            0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
-            0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
-            0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
-            0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
-            0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
-            0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
-            0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
-            0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
-            0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
-            0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
-            0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
-            0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
-            0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
-            0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
-            0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
-            0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
-            0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
-            0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
-            0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
-            0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
-            0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
-            0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
-            0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
-            0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
-            0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
-            0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
-            0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
-            0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
-            0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
-            0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
-            0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
-            0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
-            0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
-            0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
-            0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
-            0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
-            0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
-            0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
-            0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
-            0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
-            0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
-            0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
-            0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
-            0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
-            0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
-            0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
-            0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
-            0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
-            0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
-            0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
-            0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
-            0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
-            0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
-            0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
-            0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
-            0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
-            0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
-        ],
-    ]
-
-    public init(key: Array<UInt8>, blockMode: BlockMode = CBC(iv: Array<UInt8>(repeating: 0, count: Blowfish.blockSize)), padding: Padding) throws {
-        precondition(key.count >= 5 && key.count <= 56)
-
-        self.blockMode = blockMode
-        self.padding = padding
-        keySize = key.count
-
-        S = origS
-        P = origP
-
-        expandKey(key: key)
-        try setupBlockModeWorkers()
-    }
-
-    private func setupBlockModeWorkers() throws {
-        encryptWorker = try blockMode.worker(blockSize: Blowfish.blockSize, cipherOperation: encrypt)
-
-        if blockMode.options.contains(.useEncryptToDecrypt) {
-            decryptWorker = try blockMode.worker(blockSize: Blowfish.blockSize, cipherOperation: encrypt)
-        } else {
-            decryptWorker = try blockMode.worker(blockSize: Blowfish.blockSize, cipherOperation: decrypt)
-        }
-    }
-
-    private func reset() {
-        S = origS
-        P = origP
-        // todo expand key
-    }
-
-    private func expandKey(key: Array<UInt8>) {
-        var j = 0
-        for i in 0..<(N + 2) {
-            var data: UInt32 = 0x0
-            for _ in 0..<4 {
-                data = (data << 8) | UInt32(key[j])
-                j += 1
-                if j >= key.count {
-                    j = 0
-                }
-            }
-            P[i] ^= data
-        }
-
-        var datal: UInt32 = 0
-        var datar: UInt32 = 0
-
-        for i in stride(from: 0, to: N + 2, by: 2) {
-            encryptBlowfishBlock(l: &datal, r: &datar)
-            P[i] = datal
-            P[i + 1] = datar
-        }
-
-        for i in 0..<4 {
-            for j in stride(from: 0, to: 256, by: 2) {
-                encryptBlowfishBlock(l: &datal, r: &datar)
-                S[i][j] = datal
-                S[i][j + 1] = datar
-            }
-        }
-    }
-
-    fileprivate func encrypt(block: ArraySlice<UInt8>) -> Array<UInt8>? {
-        var result = Array<UInt8>()
-
-        var l = UInt32(bytes: block[block.startIndex..<block.startIndex.advanced(by: 4)])
-        var r = UInt32(bytes: block[block.startIndex.advanced(by: 4)..<block.startIndex.advanced(by: 8)])
-
-        encryptBlowfishBlock(l: &l, r: &r)
-
-        // because everything is too complex to be solved in reasonable time o_O
-        result += [
-            UInt8((l >> 24) & 0xff),
-            UInt8((l >> 16) & 0xff),
-        ]
-        result += [
-            UInt8((l >> 8) & 0xff),
-            UInt8((l >> 0) & 0xff),
-        ]
-        result += [
-            UInt8((r >> 24) & 0xff),
-            UInt8((r >> 16) & 0xff),
-        ]
-        result += [
-            UInt8((r >> 8) & 0xff),
-            UInt8((r >> 0) & 0xff),
-        ]
-
-        return result
-    }
-
-    fileprivate func decrypt(block: ArraySlice<UInt8>) -> Array<UInt8>? {
-        var result = Array<UInt8>()
-
-        var l = UInt32(bytes: block[block.startIndex..<block.startIndex.advanced(by: 4)])
-        var r = UInt32(bytes: block[block.startIndex.advanced(by: 4)..<block.startIndex.advanced(by: 8)])
-
-        decryptBlowfishBlock(l: &l, r: &r)
-
-        // because everything is too complex to be solved in reasonable time o_O
-        result += [
-            UInt8((l >> 24) & 0xff),
-            UInt8((l >> 16) & 0xff),
-        ]
-        result += [
-            UInt8((l >> 8) & 0xff),
-            UInt8((l >> 0) & 0xff),
-        ]
-        result += [
-            UInt8((r >> 24) & 0xff),
-            UInt8((r >> 16) & 0xff),
-        ]
-        result += [
-            UInt8((r >> 8) & 0xff),
-            UInt8((r >> 0) & 0xff),
-        ]
-        return result
-    }
-
-    /// Encrypts the 8-byte padded buffer
-    ///
-    /// - Parameters:
-    ///   - l: left half
-    ///   - r: right half
-    fileprivate func encryptBlowfishBlock(l: inout UInt32, r: inout UInt32) {
-        var Xl = l
-        var Xr = r
-
-        for i in 0..<N {
-            Xl = Xl ^ P[i]
-            Xr = F(x: Xl) ^ Xr
-
-            (Xl, Xr) = (Xr, Xl)
-        }
-
-        (Xl, Xr) = (Xr, Xl)
-
-        Xr = Xr ^ P[self.N]
-        Xl = Xl ^ P[self.N + 1]
-
-        l = Xl
-        r = Xr
-    }
-
-    /// Decrypts the 8-byte padded buffer
-    ///
-    /// - Parameters:
-    ///   - l: left half
-    ///   - r: right half
-    fileprivate func decryptBlowfishBlock(l: inout UInt32, r: inout UInt32) {
-        var Xl = l
-        var Xr = r
-
-        for i in (2...N + 1).reversed() {
-            Xl = Xl ^ P[i]
-            Xr = F(x: Xl) ^ Xr
-
-            (Xl, Xr) = (Xr, Xl)
-        }
-
-        (Xl, Xr) = (Xr, Xl)
-
-        Xr = Xr ^ P[1]
-        Xl = Xl ^ P[0]
-
-        l = Xl
-        r = Xr
-    }
-
-    private func F(x: UInt32) -> UInt32 {
-        let f1 = S[0][Int(x >> 24) & 0xff]
-        let f2 = S[1][Int(x >> 16) & 0xff]
-        let f3 = S[2][Int(x >> 8) & 0xff]
-        let f4 = S[3][Int(x & 0xff)]
-        return ((f1 &+ f2) ^ f3) &+ f4
-    }
-}
-
-extension Blowfish: Cipher {
-    /// Encrypt the 8-byte padded buffer, block by block. Note that for amounts of data larger than a block, it is not safe to just call encrypt() on successive blocks.
-    ///
-    /// - Parameter bytes: Plaintext data
-    /// - Returns: Encrypted data
-    public func encrypt<C: Collection>(_ bytes: C) throws -> Array<UInt8> where C.Element == UInt8, C.Index == Int {
-        let bytes = padding.add(to: Array(bytes), blockSize: Blowfish.blockSize) // FIXME: Array(bytes) copies
-
-        var out = Array<UInt8>()
-        out.reserveCapacity(bytes.count)
-
-        for chunk in bytes.batched(by: Blowfish.blockSize) {
-            out += encryptWorker.encrypt(block: chunk)
-        }
-
-        if blockMode.options.contains(.paddingRequired) && (out.count % Blowfish.blockSize != 0) {
-            throw Error.dataPaddingRequired
-        }
-
-        return out
-    }
-
-    /// Decrypt the 8-byte padded buffer
-    ///
-    /// - Parameter bytes: Ciphertext data
-    /// - Returns: Plaintext data
-    public func decrypt<C: Collection>(_ bytes: C) throws -> Array<UInt8> where C.Element == UInt8, C.Index == Int {
-        if blockMode.options.contains(.paddingRequired) && (bytes.count % Blowfish.blockSize != 0) {
-            throw Error.dataPaddingRequired
-        }
-
-        var out = Array<UInt8>()
-        out.reserveCapacity(bytes.count)
-
-        for chunk in Array(bytes).batched(by: Blowfish.blockSize) {
-            out += decryptWorker.decrypt(block: chunk) // FIXME: copying here is innefective
-        }
-
-        out = padding.remove(from: out, blockSize: Blowfish.blockSize)
-
-        return out
-    }
-}

+ 0 - 104
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/CBCMAC.swift

@@ -1,104 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public class CBCMAC: Authenticator {
-    public enum Error: Swift.Error {
-        case wrongKeyLength
-    }
-
-    private let key: SecureBytes
-
-    private static let BlockSize: Int = 16
-    private static let Zero: Array<UInt8> = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
-    private static let Rb: Array<UInt8> = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87]
-
-    public init(key: Array<UInt8>) throws {
-        if key.count != 16 {
-            throw Error.wrongKeyLength
-        }
-        self.key = SecureBytes(bytes: key)
-    }
-
-    // MARK: Authenticator
-
-    public func authenticate(_ bytes: Array<UInt8>) throws -> Array<UInt8> {
-        let aes = try AES(key: Array(key), blockMode: CBC(iv: CBCMAC.Zero), padding: .noPadding)
-
-        let l = try aes.encrypt(CBCMAC.Zero)
-        var subKey1 = leftShiftOneBit(l)
-        if (l[0] & 0x80) != 0 {
-            subKey1 = xor(CBCMAC.Rb, subKey1)
-        }
-        var subKey2 = leftShiftOneBit(subKey1)
-        if (subKey1[0] & 0x80) != 0 {
-            subKey2 = xor(CBCMAC.Rb, subKey2)
-        }
-
-        let lastBlockComplete: Bool
-        let blockCount = (bytes.count + CBCMAC.BlockSize - 1) / CBCMAC.BlockSize
-        if blockCount == 0 {
-            lastBlockComplete = false
-        } else {
-            lastBlockComplete = bytes.count % CBCMAC.BlockSize == 0
-        }
-        var paddedBytes = bytes
-        if !lastBlockComplete {
-            bitPadding(to: &paddedBytes, blockSize: CBCMAC.BlockSize)
-        }
-
-        var blocks = Array(paddedBytes.batched(by: CBCMAC.BlockSize))
-        var lastBlock = blocks.popLast()!
-        if lastBlockComplete {
-            lastBlock = xor(lastBlock, subKey1)
-        } else {
-            lastBlock = xor(lastBlock, subKey2)
-        }
-
-        var x = Array<UInt8>(repeating: 0x00, count: CBCMAC.BlockSize)
-        var y = Array<UInt8>(repeating: 0x00, count: CBCMAC.BlockSize)
-        for block in blocks {
-            y = xor(block, x)
-            x = try aes.encrypt(y)
-        }
-        // the difference between CMAC and CBC-MAC is that CMAC xors the final block with a secret value
-        y = process(lastBlock: lastBlock, with: x)
-        return try aes.encrypt(y)
-    }
-
-    func process(lastBlock: ArraySlice<UInt8>, with x: [UInt8]) -> [UInt8] {
-        return Array(lastBlock)
-    }
-
-    // MARK: Helper methods
-
-    /**
-     Performs left shift by one bit to the bit string aquired after concatenating al bytes in the byte array
-     - parameters:
-     - bytes: byte array
-     - returns: bit shifted bit string split again in array of bytes
-     */
-    private func leftShiftOneBit(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        var shifted = Array<UInt8>(repeating: 0x00, count: bytes.count)
-        let last = bytes.count - 1
-        for index in 0..<last {
-            shifted[index] = bytes[index] << 1
-            if (bytes[index + 1] & 0x80) != 0 {
-                shifted[index] += 0x01
-            }
-        }
-        shifted[last] = bytes[last] << 1
-        return shifted
-    }
-}

+ 0 - 20
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/CMAC.swift

@@ -1,20 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public final class CMAC: CBCMAC {
-    override func process(lastBlock: ArraySlice<UInt8>, with x: [UInt8]) -> [UInt8] {
-        return xor(lastBlock, x)
-    }
-}

+ 0 - 347
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift

@@ -1,347 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  https://tools.ietf.org/html/rfc7539
-//
-
-public final class ChaCha20: BlockCipher {
-    public enum Error: Swift.Error {
-        case invalidKeyOrInitializationVector
-        case notSupported
-    }
-
-    public static let blockSize = 64 // 512 / 8
-    public let keySize: Int
-
-    fileprivate let key: Key
-    fileprivate var counter: Array<UInt8>
-
-    public init(key: Array<UInt8>, iv nonce: Array<UInt8>) throws {
-        precondition(nonce.count == 12 || nonce.count == 8)
-
-        if key.count != 32 {
-            throw Error.invalidKeyOrInitializationVector
-        }
-
-        self.key = Key(bytes: key)
-        keySize = self.key.count
-
-        if nonce.count == 8 {
-            counter = [0, 0, 0, 0, 0, 0, 0, 0] + nonce
-        } else {
-            counter = [0, 0, 0, 0] + nonce
-        }
-
-        assert(counter.count == 16)
-    }
-
-    /// https://tools.ietf.org/html/rfc7539#section-2.3.
-    fileprivate func core(block: inout Array<UInt8>, counter: Array<UInt8>, key: Array<UInt8>) {
-        precondition(block.count == ChaCha20.blockSize)
-        precondition(counter.count == 16)
-        precondition(key.count == 32)
-
-        let j0: UInt32 = 0x61707865
-        let j1: UInt32 = 0x3320646e // 0x3620646e sigma/tau
-        let j2: UInt32 = 0x79622d32
-        let j3: UInt32 = 0x6b206574
-        let j4: UInt32 = UInt32(bytes: key[0..<4]).bigEndian
-        let j5: UInt32 = UInt32(bytes: key[4..<8]).bigEndian
-        let j6: UInt32 = UInt32(bytes: key[8..<12]).bigEndian
-        let j7: UInt32 = UInt32(bytes: key[12..<16]).bigEndian
-        let j8: UInt32 = UInt32(bytes: key[16..<20]).bigEndian
-        let j9: UInt32 = UInt32(bytes: key[20..<24]).bigEndian
-        let j10: UInt32 = UInt32(bytes: key[24..<28]).bigEndian
-        let j11: UInt32 = UInt32(bytes: key[28..<32]).bigEndian
-        let j12: UInt32 = UInt32(bytes: counter[0..<4]).bigEndian
-        let j13: UInt32 = UInt32(bytes: counter[4..<8]).bigEndian
-        let j14: UInt32 = UInt32(bytes: counter[8..<12]).bigEndian
-        let j15: UInt32 = UInt32(bytes: counter[12..<16]).bigEndian
-
-        var (x0, x1, x2, x3, x4, x5, x6, x7) = (j0, j1, j2, j3, j4, j5, j6, j7)
-        var (x8, x9, x10, x11, x12, x13, x14, x15) = (j8, j9, j10, j11, j12, j13, j14, j15)
-
-        for _ in 0..<10 { // 20 rounds
-            x0 = x0 &+ x4
-            x12 ^= x0
-            x12 = (x12 << 16) | (x12 >> 16)
-            x8 = x8 &+ x12
-            x4 ^= x8
-            x4 = (x4 << 12) | (x4 >> 20)
-            x0 = x0 &+ x4
-            x12 ^= x0
-            x12 = (x12 << 8) | (x12 >> 24)
-            x8 = x8 &+ x12
-            x4 ^= x8
-            x4 = (x4 << 7) | (x4 >> 25)
-            x1 = x1 &+ x5
-            x13 ^= x1
-            x13 = (x13 << 16) | (x13 >> 16)
-            x9 = x9 &+ x13
-            x5 ^= x9
-            x5 = (x5 << 12) | (x5 >> 20)
-            x1 = x1 &+ x5
-            x13 ^= x1
-            x13 = (x13 << 8) | (x13 >> 24)
-            x9 = x9 &+ x13
-            x5 ^= x9
-            x5 = (x5 << 7) | (x5 >> 25)
-            x2 = x2 &+ x6
-            x14 ^= x2
-            x14 = (x14 << 16) | (x14 >> 16)
-            x10 = x10 &+ x14
-            x6 ^= x10
-            x6 = (x6 << 12) | (x6 >> 20)
-            x2 = x2 &+ x6
-            x14 ^= x2
-            x14 = (x14 << 8) | (x14 >> 24)
-            x10 = x10 &+ x14
-            x6 ^= x10
-            x6 = (x6 << 7) | (x6 >> 25)
-            x3 = x3 &+ x7
-            x15 ^= x3
-            x15 = (x15 << 16) | (x15 >> 16)
-            x11 = x11 &+ x15
-            x7 ^= x11
-            x7 = (x7 << 12) | (x7 >> 20)
-            x3 = x3 &+ x7
-            x15 ^= x3
-            x15 = (x15 << 8) | (x15 >> 24)
-            x11 = x11 &+ x15
-            x7 ^= x11
-            x7 = (x7 << 7) | (x7 >> 25)
-            x0 = x0 &+ x5
-            x15 ^= x0
-            x15 = (x15 << 16) | (x15 >> 16)
-            x10 = x10 &+ x15
-            x5 ^= x10
-            x5 = (x5 << 12) | (x5 >> 20)
-            x0 = x0 &+ x5
-            x15 ^= x0
-            x15 = (x15 << 8) | (x15 >> 24)
-            x10 = x10 &+ x15
-            x5 ^= x10
-            x5 = (x5 << 7) | (x5 >> 25)
-            x1 = x1 &+ x6
-            x12 ^= x1
-            x12 = (x12 << 16) | (x12 >> 16)
-            x11 = x11 &+ x12
-            x6 ^= x11
-            x6 = (x6 << 12) | (x6 >> 20)
-            x1 = x1 &+ x6
-            x12 ^= x1
-            x12 = (x12 << 8) | (x12 >> 24)
-            x11 = x11 &+ x12
-            x6 ^= x11
-            x6 = (x6 << 7) | (x6 >> 25)
-            x2 = x2 &+ x7
-            x13 ^= x2
-            x13 = (x13 << 16) | (x13 >> 16)
-            x8 = x8 &+ x13
-            x7 ^= x8
-            x7 = (x7 << 12) | (x7 >> 20)
-            x2 = x2 &+ x7
-            x13 ^= x2
-            x13 = (x13 << 8) | (x13 >> 24)
-            x8 = x8 &+ x13
-            x7 ^= x8
-            x7 = (x7 << 7) | (x7 >> 25)
-            x3 = x3 &+ x4
-            x14 ^= x3
-            x14 = (x14 << 16) | (x14 >> 16)
-            x9 = x9 &+ x14
-            x4 ^= x9
-            x4 = (x4 << 12) | (x4 >> 20)
-            x3 = x3 &+ x4
-            x14 ^= x3
-            x14 = (x14 << 8) | (x14 >> 24)
-            x9 = x9 &+ x14
-            x4 ^= x9
-            x4 = (x4 << 7) | (x4 >> 25)
-        }
-
-        x0 = x0 &+ j0
-        x1 = x1 &+ j1
-        x2 = x2 &+ j2
-        x3 = x3 &+ j3
-        x4 = x4 &+ j4
-        x5 = x5 &+ j5
-        x6 = x6 &+ j6
-        x7 = x7 &+ j7
-        x8 = x8 &+ j8
-        x9 = x9 &+ j9
-        x10 = x10 &+ j10
-        x11 = x11 &+ j11
-        x12 = x12 &+ j12
-        x13 = x13 &+ j13
-        x14 = x14 &+ j14
-        x15 = x15 &+ j15
-
-        block.replaceSubrange(0..<4, with: x0.bigEndian.bytes())
-        block.replaceSubrange(4..<8, with: x1.bigEndian.bytes())
-        block.replaceSubrange(8..<12, with: x2.bigEndian.bytes())
-        block.replaceSubrange(12..<16, with: x3.bigEndian.bytes())
-        block.replaceSubrange(16..<20, with: x4.bigEndian.bytes())
-        block.replaceSubrange(20..<24, with: x5.bigEndian.bytes())
-        block.replaceSubrange(24..<28, with: x6.bigEndian.bytes())
-        block.replaceSubrange(28..<32, with: x7.bigEndian.bytes())
-        block.replaceSubrange(32..<36, with: x8.bigEndian.bytes())
-        block.replaceSubrange(36..<40, with: x9.bigEndian.bytes())
-        block.replaceSubrange(40..<44, with: x10.bigEndian.bytes())
-        block.replaceSubrange(44..<48, with: x11.bigEndian.bytes())
-        block.replaceSubrange(48..<52, with: x12.bigEndian.bytes())
-        block.replaceSubrange(52..<56, with: x13.bigEndian.bytes())
-        block.replaceSubrange(56..<60, with: x14.bigEndian.bytes())
-        block.replaceSubrange(60..<64, with: x15.bigEndian.bytes())
-    }
-
-    // XORKeyStream
-    func process(bytes: ArraySlice<UInt8>, counter: inout Array<UInt8>, key: Array<UInt8>) -> Array<UInt8> {
-        precondition(counter.count == 16)
-        precondition(key.count == 32)
-
-        var block = Array<UInt8>(repeating: 0, count: ChaCha20.blockSize)
-        var bytesSlice = bytes
-        var out = Array<UInt8>(reserveCapacity: bytesSlice.count)
-
-        while bytesSlice.count >= ChaCha20.blockSize {
-            core(block: &block, counter: counter, key: key)
-            for (i, x) in block.enumerated() {
-                out.append(bytesSlice[bytesSlice.startIndex + i] ^ x)
-            }
-            var u: UInt32 = 1
-            for i in 0..<4 {
-                u += UInt32(counter[i])
-                counter[i] = UInt8(u & 0xff)
-                u >>= 8
-            }
-            bytesSlice = bytesSlice[bytesSlice.startIndex + ChaCha20.blockSize..<bytesSlice.endIndex]
-        }
-
-        if bytesSlice.count > 0 {
-            core(block: &block, counter: counter, key: key)
-            for (i, v) in bytesSlice.enumerated() {
-                out.append(v ^ block[i])
-            }
-        }
-        return out
-    }
-}
-
-// MARK: Cipher
-
-extension ChaCha20: Cipher {
-    public func encrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
-        return process(bytes: bytes, counter: &counter, key: Array(key))
-    }
-
-    public func decrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
-        return try encrypt(bytes)
-    }
-}
-
-// MARK: Encryptor
-
-extension ChaCha20 {
-    public struct ChaChaEncryptor: Cryptor, Updatable {
-        private var accumulated = Array<UInt8>()
-        private let chacha: ChaCha20
-
-        init(chacha: ChaCha20) {
-            self.chacha = chacha
-        }
-
-        public mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
-            accumulated += bytes
-
-            var encrypted = Array<UInt8>()
-            encrypted.reserveCapacity(accumulated.count)
-            for chunk in accumulated.batched(by: ChaCha20.blockSize) {
-                if isLast || accumulated.count >= ChaCha20.blockSize {
-                    encrypted += try chacha.encrypt(chunk)
-                    accumulated.removeFirst(chunk.count) // TODO: improve performance
-                }
-            }
-            return encrypted
-        }
-
-        public func seek(to: Int) throws {
-            throw Error.notSupported
-        }
-    }
-}
-
-// MARK: Decryptor
-
-extension ChaCha20 {
-    public struct ChaChaDecryptor: Cryptor, Updatable {
-        private var accumulated = Array<UInt8>()
-
-        private var offset: Int = 0
-        private var offsetToRemove: Int = 0
-        private let chacha: ChaCha20
-
-        init(chacha: ChaCha20) {
-            self.chacha = chacha
-        }
-
-        public mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = true) throws -> Array<UInt8> {
-            // prepend "offset" number of bytes at the beginning
-            if offset > 0 {
-                accumulated += Array<UInt8>(repeating: 0, count: offset) + bytes
-                offsetToRemove = offset
-                offset = 0
-            } else {
-                accumulated += bytes
-            }
-
-            var plaintext = Array<UInt8>()
-            plaintext.reserveCapacity(accumulated.count)
-            for chunk in accumulated.batched(by: ChaCha20.blockSize) {
-                if isLast || accumulated.count >= ChaCha20.blockSize {
-                    plaintext += try chacha.decrypt(chunk)
-
-                    // remove "offset" from the beginning of first chunk
-                    if offsetToRemove > 0 {
-                        plaintext.removeFirst(offsetToRemove) // TODO: improve performance
-                        offsetToRemove = 0
-                    }
-
-                    accumulated.removeFirst(chunk.count)
-                }
-            }
-
-            return plaintext
-        }
-
-        public func seek(to: Int) throws {
-            throw Error.notSupported
-        }
-    }
-}
-
-// MARK: Cryptors
-
-extension ChaCha20: Cryptors {
-    //TODO: Use BlockEncryptor/BlockDecryptor
-    
-    public func makeEncryptor() -> Cryptor & Updatable {
-        return ChaCha20.ChaChaEncryptor(chacha: self)
-    }
-
-    public func makeDecryptor() -> Cryptor & Updatable {
-        return ChaCha20.ChaChaDecryptor(chacha: self)
-    }
-}

+ 0 - 193
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Checksum.swift

@@ -1,193 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-/// CRC - cyclic redundancy check code.
-public final class Checksum {
-    private static let table32: Array<UInt32> = [
-        0x0000_0000, 0x7707_3096, 0xEE0E_612C, 0x9909_51BA, 0x076D_C419, 0x706A_F48F, 0xE963_A535, 0x9E64_95A3,
-        0x0EDB_8832, 0x79DC_B8A4, 0xE0D5_E91E, 0x97D2_D988, 0x09B6_4C2B, 0x7EB1_7CBD, 0xE7B8_2D07, 0x90BF_1D91,
-        0x1DB7_1064, 0x6AB0_20F2, 0xF3B9_7148, 0x84BE_41DE, 0x1ADA_D47D, 0x6DDD_E4EB, 0xF4D4_B551, 0x83D3_85C7,
-        0x136C_9856, 0x646B_A8C0, 0xFD62_F97A, 0x8A65_C9EC, 0x1401_5C4F, 0x6306_6CD9, 0xFA0F_3D63, 0x8D08_0DF5,
-        0x3B6E_20C8, 0x4C69_105E, 0xD560_41E4, 0xA267_7172, 0x3C03_E4D1, 0x4B04_D447, 0xD20D_85FD, 0xA50A_B56B,
-        0x35B5_A8FA, 0x42B2_986C, 0xDBBB_C9D6, 0xACBC_F940, 0x32D8_6CE3, 0x45DF_5C75, 0xDCD6_0DCF, 0xABD1_3D59,
-        0x26D9_30AC, 0x51DE_003A, 0xC8D7_5180, 0xBFD0_6116, 0x21B4_F4B5, 0x56B3_C423, 0xCFBA_9599, 0xB8BD_A50F,
-        0x2802_B89E, 0x5F05_8808, 0xC60C_D9B2, 0xB10B_E924, 0x2F6F_7C87, 0x5868_4C11, 0xC161_1DAB, 0xB666_2D3D,
-        0x76DC_4190, 0x01DB_7106, 0x98D2_20BC, 0xEFD5_102A, 0x71B1_8589, 0x06B6_B51F, 0x9FBF_E4A5, 0xE8B8_D433,
-        0x7807_C9A2, 0x0F00_F934, 0x9609_A88E, 0xE10E_9818, 0x7F6A_0DBB, 0x086D_3D2D, 0x9164_6C97, 0xE663_5C01,
-        0x6B6B_51F4, 0x1C6C_6162, 0x8565_30D8, 0xF262_004E, 0x6C06_95ED, 0x1B01_A57B, 0x8208_F4C1, 0xF50F_C457,
-        0x65B0_D9C6, 0x12B7_E950, 0x8BBE_B8EA, 0xFCB9_887C, 0x62DD_1DDF, 0x15DA_2D49, 0x8CD3_7CF3, 0xFBD4_4C65,
-        0x4DB2_6158, 0x3AB5_51CE, 0xA3BC_0074, 0xD4BB_30E2, 0x4ADF_A541, 0x3DD8_95D7, 0xA4D1_C46D, 0xD3D6_F4FB,
-        0x4369_E96A, 0x346E_D9FC, 0xAD67_8846, 0xDA60_B8D0, 0x4404_2D73, 0x3303_1DE5, 0xAA0A_4C5F, 0xDD0D_7CC9,
-        0x5005_713C, 0x2702_41AA, 0xBE0B_1010, 0xC90C_2086, 0x5768_B525, 0x206F_85B3, 0xB966_D409, 0xCE61_E49F,
-        0x5EDE_F90E, 0x29D9_C998, 0xB0D0_9822, 0xC7D7_A8B4, 0x59B3_3D17, 0x2EB4_0D81, 0xB7BD_5C3B, 0xC0BA_6CAD,
-        0xEDB8_8320, 0x9ABF_B3B6, 0x03B6_E20C, 0x74B1_D29A, 0xEAD5_4739, 0x9DD2_77AF, 0x04DB_2615, 0x73DC_1683,
-        0xE363_0B12, 0x9464_3B84, 0x0D6D_6A3E, 0x7A6A_5AA8, 0xE40E_CF0B, 0x9309_FF9D, 0x0A00_AE27, 0x7D07_9EB1,
-        0xF00F_9344, 0x8708_A3D2, 0x1E01_F268, 0x6906_C2FE, 0xF762_575D, 0x8065_67CB, 0x196C_3671, 0x6E6B_06E7,
-        0xFED4_1B76, 0x89D3_2BE0, 0x10DA_7A5A, 0x67DD_4ACC, 0xF9B9_DF6F, 0x8EBE_EFF9, 0x17B7_BE43, 0x60B0_8ED5,
-        0xD6D6_A3E8, 0xA1D1_937E, 0x38D8_C2C4, 0x4FDF_F252, 0xD1BB_67F1, 0xA6BC_5767, 0x3FB5_06DD, 0x48B2_364B,
-        0xD80D_2BDA, 0xAF0A_1B4C, 0x3603_4AF6, 0x4104_7A60, 0xDF60_EFC3, 0xA867_DF55, 0x316E_8EEF, 0x4669_BE79,
-        0xCB61_B38C, 0xBC66_831A, 0x256F_D2A0, 0x5268_E236, 0xCC0C_7795, 0xBB0B_4703, 0x2202_16B9, 0x5505_262F,
-        0xC5BA_3BBE, 0xB2BD_0B28, 0x2BB4_5A92, 0x5CB3_6A04, 0xC2D7_FFA7, 0xB5D0_CF31, 0x2CD9_9E8B, 0x5BDE_AE1D,
-        0x9B64_C2B0, 0xEC63_F226, 0x756A_A39C, 0x026D_930A, 0x9C09_06A9, 0xEB0E_363F, 0x7207_6785, 0x0500_5713,
-        0x95BF_4A82, 0xE2B8_7A14, 0x7BB1_2BAE, 0x0CB6_1B38, 0x92D2_8E9B, 0xE5D5_BE0D, 0x7CDC_EFB7, 0x0BDB_DF21,
-        0x86D3_D2D4, 0xF1D4_E242, 0x68DD_B3F8, 0x1FDA_836E, 0x81BE_16CD, 0xF6B9_265B, 0x6FB0_77E1, 0x18B7_4777,
-        0x8808_5AE6, 0xFF0F_6A70, 0x6606_3BCA, 0x1101_0B5C, 0x8F65_9EFF, 0xF862_AE69, 0x616B_FFD3, 0x166C_CF45,
-        0xA00A_E278, 0xD70D_D2EE, 0x4E04_8354, 0x3903_B3C2, 0xA767_2661, 0xD060_16F7, 0x4969_474D, 0x3E6E_77DB,
-        0xAED1_6A4A, 0xD9D6_5ADC, 0x40DF_0B66, 0x37D8_3BF0, 0xA9BC_AE53, 0xDEBB_9EC5, 0x47B2_CF7F, 0x30B5_FFE9,
-        0xBDBD_F21C, 0xCABA_C28A, 0x53B3_9330, 0x24B4_A3A6, 0xBAD0_3605, 0xCDD7_0693, 0x54DE_5729, 0x23D9_67BF,
-        0xB366_7A2E, 0xC461_4AB8, 0x5D68_1B02, 0x2A6F_2B94, 0xB40B_BE37, 0xC30C_8EA1, 0x5A05_DF1B, 0x2D02_EF8D,
-    ]
-
-    private static let table32c: Array<UInt32> = [
-        0x0000_0000, 0xF26B_8303, 0xE13B_70F7, 0x1350_F3F4, 0xC79A_971F, 0x35F1_141C, 0x26A1_E7E8, 0xD4CA_64EB,
-        0x8AD9_58CF, 0x78B2_DBCC, 0x6BE2_2838, 0x9989_AB3B, 0x4D43_CFD0, 0xBF28_4CD3, 0xAC78_BF27, 0x5E13_3C24,
-        0x105E_C76F, 0xE235_446C, 0xF165_B798, 0x030E_349B, 0xD7C4_5070, 0x25AF_D373, 0x36FF_2087, 0xC494_A384,
-        0x9A87_9FA0, 0x68EC_1CA3, 0x7BBC_EF57, 0x89D7_6C54, 0x5D1D_08BF, 0xAF76_8BBC, 0xBC26_7848, 0x4E4D_FB4B,
-        0x20BD_8EDE, 0xD2D6_0DDD, 0xC186_FE29, 0x33ED_7D2A, 0xE727_19C1, 0x154C_9AC2, 0x061C_6936, 0xF477_EA35,
-        0xAA64_D611, 0x580F_5512, 0x4B5F_A6E6, 0xB934_25E5, 0x6DFE_410E, 0x9F95_C20D, 0x8CC5_31F9, 0x7EAE_B2FA,
-        0x30E3_49B1, 0xC288_CAB2, 0xD1D8_3946, 0x23B3_BA45, 0xF779_DEAE, 0x0512_5DAD, 0x1642_AE59, 0xE429_2D5A,
-        0xBA3A_117E, 0x4851_927D, 0x5B01_6189, 0xA96A_E28A, 0x7DA0_8661, 0x8FCB_0562, 0x9C9B_F696, 0x6EF0_7595,
-        0x417B_1DBC, 0xB310_9EBF, 0xA040_6D4B, 0x522B_EE48, 0x86E1_8AA3, 0x748A_09A0, 0x67DA_FA54, 0x95B1_7957,
-        0xCBA2_4573, 0x39C9_C670, 0x2A99_3584, 0xD8F2_B687, 0x0C38_D26C, 0xFE53_516F, 0xED03_A29B, 0x1F68_2198,
-        0x5125_DAD3, 0xA34E_59D0, 0xB01E_AA24, 0x4275_2927, 0x96BF_4DCC, 0x64D4_CECF, 0x7784_3D3B, 0x85EF_BE38,
-        0xDBFC_821C, 0x2997_011F, 0x3AC7_F2EB, 0xC8AC_71E8, 0x1C66_1503, 0xEE0D_9600, 0xFD5D_65F4, 0x0F36_E6F7,
-        0x61C6_9362, 0x93AD_1061, 0x80FD_E395, 0x7296_6096, 0xA65C_047D, 0x5437_877E, 0x4767_748A, 0xB50C_F789,
-        0xEB1F_CBAD, 0x1974_48AE, 0x0A24_BB5A, 0xF84F_3859, 0x2C85_5CB2, 0xDEEE_DFB1, 0xCDBE_2C45, 0x3FD5_AF46,
-        0x7198_540D, 0x83F3_D70E, 0x90A3_24FA, 0x62C8_A7F9, 0xB602_C312, 0x4469_4011, 0x5739_B3E5, 0xA552_30E6,
-        0xFB41_0CC2, 0x092A_8FC1, 0x1A7A_7C35, 0xE811_FF36, 0x3CDB_9BDD, 0xCEB0_18DE, 0xDDE0_EB2A, 0x2F8B_6829,
-        0x82F6_3B78, 0x709D_B87B, 0x63CD_4B8F, 0x91A6_C88C, 0x456C_AC67, 0xB707_2F64, 0xA457_DC90, 0x563C_5F93,
-        0x082F_63B7, 0xFA44_E0B4, 0xE914_1340, 0x1B7F_9043, 0xCFB5_F4A8, 0x3DDE_77AB, 0x2E8E_845F, 0xDCE5_075C,
-        0x92A8_FC17, 0x60C3_7F14, 0x7393_8CE0, 0x81F8_0FE3, 0x5532_6B08, 0xA759_E80B, 0xB409_1BFF, 0x4662_98FC,
-        0x1871_A4D8, 0xEA1A_27DB, 0xF94A_D42F, 0x0B21_572C, 0xDFEB_33C7, 0x2D80_B0C4, 0x3ED0_4330, 0xCCBB_C033,
-        0xA24B_B5A6, 0x5020_36A5, 0x4370_C551, 0xB11B_4652, 0x65D1_22B9, 0x97BA_A1BA, 0x84EA_524E, 0x7681_D14D,
-        0x2892_ED69, 0xDAF9_6E6A, 0xC9A9_9D9E, 0x3BC2_1E9D, 0xEF08_7A76, 0x1D63_F975, 0x0E33_0A81, 0xFC58_8982,
-        0xB215_72C9, 0x407E_F1CA, 0x532E_023E, 0xA145_813D, 0x758F_E5D6, 0x87E4_66D5, 0x94B4_9521, 0x66DF_1622,
-        0x38CC_2A06, 0xCAA7_A905, 0xD9F7_5AF1, 0x2B9C_D9F2, 0xFF56_BD19, 0x0D3D_3E1A, 0x1E6D_CDEE, 0xEC06_4EED,
-        0xC38D_26C4, 0x31E6_A5C7, 0x22B6_5633, 0xD0DD_D530, 0x0417_B1DB, 0xF67C_32D8, 0xE52C_C12C, 0x1747_422F,
-        0x4954_7E0B, 0xBB3F_FD08, 0xA86F_0EFC, 0x5A04_8DFF, 0x8ECE_E914, 0x7CA5_6A17, 0x6FF5_99E3, 0x9D9E_1AE0,
-        0xD3D3_E1AB, 0x21B8_62A8, 0x32E8_915C, 0xC083_125F, 0x1449_76B4, 0xE622_F5B7, 0xF572_0643, 0x0719_8540,
-        0x590A_B964, 0xAB61_3A67, 0xB831_C993, 0x4A5A_4A90, 0x9E90_2E7B, 0x6CFB_AD78, 0x7FAB_5E8C, 0x8DC0_DD8F,
-        0xE330_A81A, 0x115B_2B19, 0x020B_D8ED, 0xF060_5BEE, 0x24AA_3F05, 0xD6C1_BC06, 0xC591_4FF2, 0x37FA_CCF1,
-        0x69E9_F0D5, 0x9B82_73D6, 0x88D2_8022, 0x7AB9_0321, 0xAE73_67CA, 0x5C18_E4C9, 0x4F48_173D, 0xBD23_943E,
-        0xF36E_6F75, 0x0105_EC76, 0x1255_1F82, 0xE03E_9C81, 0x34F4_F86A, 0xC69F_7B69, 0xD5CF_889D, 0x27A4_0B9E,
-        0x79B7_37BA, 0x8BDC_B4B9, 0x988C_474D, 0x6AE7_C44E, 0xBE2D_A0A5, 0x4C46_23A6, 0x5F16_D052, 0xAD7D_5351,
-    ]
-
-    private static let table16: Array<UInt16> = [
-        0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
-        0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
-        0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
-        0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
-        0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
-        0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
-        0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
-        0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
-        0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
-        0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
-        0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
-        0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
-        0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
-        0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
-        0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
-        0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
-        0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
-        0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
-        0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
-        0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
-        0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
-        0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
-        0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
-        0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
-        0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
-        0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
-        0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
-        0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
-        0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
-        0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
-        0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
-        0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040,
-    ]
-
-    /// Polynomial: 0xEDB88320 (Reversed) - IEEE
-    func crc32(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
-        var crc: UInt32 = seed != nil ? seed! : 0xFFFF_FFFF
-        for chunk in message.batched(by: 256) {
-            for b in chunk {
-                let idx = Int((crc ^ UInt32(reflect ? b : reversed(b))) & 0xFF)
-                crc = (crc >> 8) ^ Checksum.table32[idx]
-            }
-        }
-        return (reflect ? crc : reversed(crc)) ^ 0xFFFF_FFFF
-    }
-
-    /// Polynomial: 0x82F63B78 (Reversed) - Castagnoli
-    func crc32c(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
-        var crc: UInt32 = seed != nil ? seed! : 0xFFFF_FFFF
-        for chunk in message.batched(by: 256) {
-            for b in chunk {
-                let idx = Int((crc ^ UInt32(reflect ? b : reversed(b))) & 0xFF)
-                crc = (crc >> 8) ^ Checksum.table32c[idx]
-            }
-        }
-        return (reflect ? crc : reversed(crc)) ^ 0xFFFF_FFFF
-    }
-
-    /// Polynomial: 0xA001 (Reversed) - IBM
-    func crc16(_ message: Array<UInt8>, seed: UInt16? = nil) -> UInt16 {
-        var crc: UInt16 = seed != nil ? seed! : 0x0000
-        for chunk in message.batched(by: 256) {
-            for b in chunk {
-                crc = (crc >> 8) ^ Checksum.table16[Int((crc ^ UInt16(b)) & 0xFF)]
-            }
-        }
-        return crc
-    }
-}
-
-// MARK: Public interface
-
-public extension Checksum {
-    /// Calculate CRC32.
-    ///
-    /// - parameter message: Message
-    /// - parameter seed:    Seed value (Optional)
-    /// - parameter reflect: is reflect (default true)
-    ///
-    /// - returns: Calculated code
-    static func crc32(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
-        return Checksum().crc32(message, seed: seed, reflect: reflect)
-    }
-
-    /// Calculate CRC32C
-    ///
-    /// - parameter message: Message
-    /// - parameter seed:    Seed value (Optional)
-    /// - parameter reflect: is reflect (default true)
-    ///
-    /// - returns: Calculated code
-    static func crc32c(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
-        return Checksum().crc32c(message, seed: seed, reflect: reflect)
-    }
-
-    /// Calculate CRC16
-    ///
-    /// - parameter message: Message
-    /// - parameter seed:    Seed value (Optional)
-    ///
-    /// - returns: Calculated code
-    static func crc16(_ message: Array<UInt8>, seed: UInt16? = nil) -> UInt16 {
-        return Checksum().crc16(message, seed: seed)
-    }
-}

+ 0 - 47
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Cipher.swift

@@ -1,47 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public enum CipherError: Error {
-    case encrypt
-    case decrypt
-}
-
-public protocol Cipher: class {
-    var keySize: Int { get }
-
-    /// Encrypt given bytes at once
-    ///
-    /// - parameter bytes: Plaintext data
-    /// - returns: Encrypted data
-    func encrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8>
-    func encrypt(_ bytes: Array<UInt8>) throws -> Array<UInt8>
-
-    /// Decrypt given bytes at once
-    ///
-    /// - parameter bytes: Ciphertext data
-    /// - returns: Plaintext data
-    func decrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8>
-    func decrypt(_ bytes: Array<UInt8>) throws -> Array<UInt8>
-}
-
-extension Cipher {
-    public func encrypt(_ bytes: Array<UInt8>) throws -> Array<UInt8> {
-        return try encrypt(bytes.slice)
-    }
-
-    public func decrypt(_ bytes: Array<UInt8>) throws -> Array<UInt8> {
-        return try decrypt(bytes.slice)
-    }
-}

+ 0 - 45
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Collection+Extension.swift

@@ -1,45 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-extension Collection where Self.Element == UInt8, Self.Index == Int {
-    // Big endian order
-    func toUInt32Array() -> Array<UInt32> {
-        if isEmpty {
-            return []
-        }
-
-        var result = Array<UInt32>(reserveCapacity: 16)
-        for idx in stride(from: startIndex, to: endIndex, by: 4) {
-            let val = UInt32(bytes: self, fromIndex: idx).bigEndian
-            result.append(val)
-        }
-
-        return result
-    }
-
-    // Big endian order
-    func toUInt64Array() -> Array<UInt64> {
-        if isEmpty {
-            return []
-        }
-
-        var result = Array<UInt64>(reserveCapacity: 32)
-        for idx in stride(from: startIndex, to: endIndex, by: 8) {
-            let val = UInt64(bytes: self, fromIndex: idx).bigEndian
-            result.append(val)
-        }
-
-        return result
-    }
-}

+ 0 - 23
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/CompactMap.swift

@@ -1,23 +0,0 @@
-////  CryptoSwift
-//
-//  Copyright (C) 2014-2018 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-#if swift(>=4.1)
-    // TODO: remove this file when Xcode 9.2 is no longer used
-#else
-    extension Sequence {
-        public func compactMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
-            return try flatMap(transform)
-        }
-    }
-#endif

+ 0 - 22
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Cryptor.swift

@@ -1,22 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-/// Cryptor (Encryptor or Decryptor)
-public protocol Cryptor {
-    /// Seek to position in file, if block mode allows random access.
-    ///
-    /// - parameter to: new value of counter
-    mutating func seek(to: Int) throws
-}

+ 0 - 44
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Cryptors.swift

@@ -1,44 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-#if canImport(Darwin)
-import Darwin
-#else
-import Glibc
-#endif
-
-/// Worker cryptor/decryptor of `Updatable` types
-public protocol Cryptors: class {
-
-    /// Cryptor suitable for encryption
-    func makeEncryptor() throws -> Cryptor & Updatable
-
-    /// Cryptor suitable for decryption
-    func makeDecryptor() throws -> Cryptor & Updatable
-
-    /// Generate array of random bytes. Helper function.
-    static func randomIV(_ blockSize: Int) -> Array<UInt8>
-}
-
-extension Cryptors {
-    public static func randomIV(_ blockSize: Int) -> Array<UInt8> {
-        var randomIV: Array<UInt8> = Array<UInt8>()
-        randomIV.reserveCapacity(blockSize)
-        for randomByte in RandomBytesSequence(size: blockSize) {
-            randomIV.append(randomByte)
-        }
-        return randomIV
-    }
-}

+ 0 - 78
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Digest.swift

@@ -1,78 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-@available(*, renamed: "Digest")
-public typealias Hash = Digest
-
-/// Hash functions to calculate Digest.
-public struct Digest {
-    /// Calculate MD5 Digest
-    /// - parameter bytes: input message
-    /// - returns: Digest bytes
-    public static func md5(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        return MD5().calculate(for: bytes)
-    }
-
-    /// Calculate SHA1 Digest
-    /// - parameter bytes: input message
-    /// - returns: Digest bytes
-    public static func sha1(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        return SHA1().calculate(for: bytes)
-    }
-
-    /// Calculate SHA2-224 Digest
-    /// - parameter bytes: input message
-    /// - returns: Digest bytes
-    public static func sha224(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        return sha2(bytes, variant: .sha224)
-    }
-
-    /// Calculate SHA2-256 Digest
-    /// - parameter bytes: input message
-    /// - returns: Digest bytes
-    public static func sha256(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        return sha2(bytes, variant: .sha256)
-    }
-
-    /// Calculate SHA2-384 Digest
-    /// - parameter bytes: input message
-    /// - returns: Digest bytes
-    public static func sha384(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        return sha2(bytes, variant: .sha384)
-    }
-
-    /// Calculate SHA2-512 Digest
-    /// - parameter bytes: input message
-    /// - returns: Digest bytes
-    public static func sha512(_ bytes: Array<UInt8>) -> Array<UInt8> {
-        return sha2(bytes, variant: .sha512)
-    }
-
-    /// Calculate SHA2 Digest
-    /// - parameter bytes: input message
-    /// - parameter variant: SHA-2 variant
-    /// - returns: Digest bytes
-    public static func sha2(_ bytes: Array<UInt8>, variant: SHA2.Variant) -> Array<UInt8> {
-        return SHA2(variant: variant).calculate(for: bytes)
-    }
-
-    /// Calculate SHA3 Digest
-    /// - parameter bytes: input message
-    /// - parameter variant: SHA-3 variant
-    /// - returns: Digest bytes
-    public static func sha3(_ bytes: Array<UInt8>, variant: SHA3.Variant) -> Array<UInt8> {
-        return SHA3(variant: variant).calculate(for: bytes)
-    }
-}

+ 0 - 18
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/DigestType.swift

@@ -1,18 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-internal protocol DigestType {
-    func calculate(for bytes: Array<UInt8>) -> Array<UInt8>
-}

+ 0 - 23
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/AES+Foundation.swift

@@ -1,23 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension AES {
-    /// Initialize with CBC block mode.
-    public convenience init(key: String, iv: String, padding: Padding = .pkcs7) throws {
-        try self.init(key: key.bytes, blockMode: CBC(iv: iv.bytes), padding: padding)
-    }
-}

+ 0 - 32
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Array+Foundation.swift

@@ -1,32 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-public extension Array where Element == UInt8 {
-    func toBase64() -> String? {
-        return Data( self).base64EncodedString()
-    }
-
-    init(base64: String) {
-        self.init()
-
-        guard let decodedData = Data(base64Encoded: base64) else {
-            return
-        }
-
-        append(contentsOf: decodedData.bytes)
-    }
-}

+ 0 - 23
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift

@@ -1,23 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension Blowfish {
-    /// Initialize with CBC block mode.
-    public convenience init(key: String, iv: String, padding: Padding = .pkcs7) throws {
-        try self.init(key: key.bytes, blockMode: CBC(iv: iv.bytes), padding: padding)
-    }
-}

+ 0 - 22
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/ChaCha20+Foundation.swift

@@ -1,22 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension ChaCha20 {
-    public convenience init(key: String, iv: String) throws {
-        try self.init(key: key.bytes, iv: iv.bytes)
-    }
-}

+ 0 - 95
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Data+Extension.swift

@@ -1,95 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension Data {
-    /// Two octet checksum as defined in RFC-4880. Sum of all octets, mod 65536
-    public func checksum() -> UInt16 {
-        var s: UInt32 = 0
-        var bytesArray = bytes
-        for i in 0 ..< bytesArray.count {
-            s = s + UInt32(bytesArray[i])
-        }
-        s = s % 65536
-        return UInt16(s)
-    }
-
-    public func md5() -> Data {
-        return Data( Digest.md5(bytes))
-    }
-
-    public func sha1() -> Data {
-        return Data( Digest.sha1(bytes))
-    }
-
-    public func sha224() -> Data {
-        return Data( Digest.sha224(bytes))
-    }
-
-    public func sha256() -> Data {
-        return Data( Digest.sha256(bytes))
-    }
-
-    public func sha384() -> Data {
-        return Data( Digest.sha384(bytes))
-    }
-
-    public func sha512() -> Data {
-        return Data( Digest.sha512(bytes))
-    }
-
-    public func sha3(_ variant: SHA3.Variant) -> Data {
-        return Data( Digest.sha3(bytes, variant: variant))
-    }
-
-    public func crc32(seed: UInt32? = nil, reflect: Bool = true) -> Data {
-        return Data( Checksum.crc32(bytes, seed: seed, reflect: reflect).bytes())
-    }
-
-    public func crc32c(seed: UInt32? = nil, reflect: Bool = true) -> Data {
-        return Data( Checksum.crc32c(bytes, seed: seed, reflect: reflect).bytes())
-    }
-
-    public func crc16(seed: UInt16? = nil) -> Data {
-        return Data( Checksum.crc16(bytes, seed: seed).bytes())
-    }
-
-    public func encrypt(cipher: Cipher) throws -> Data {
-        return Data( try cipher.encrypt(bytes.slice))
-    }
-
-    public func decrypt(cipher: Cipher) throws -> Data {
-        return Data( try cipher.decrypt(bytes.slice))
-    }
-
-    public func authenticate(with authenticator: Authenticator) throws -> Data {
-        return Data( try authenticator.authenticate(bytes))
-    }
-}
-
-extension Data {
-    public init(hex: String) {
-        self.init(bytes: Array<UInt8>(hex: hex))
-    }
-
-    public var bytes: Array<UInt8> {
-        return Array(self)
-    }
-
-    public func toHexString() -> String {
-        return bytes.toHexString()
-    }
-}

+ 0 - 22
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/HMAC+Foundation.swift

@@ -1,22 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension HMAC {
-    public convenience init(key: String, variant: HMAC.Variant = .md5) throws {
-        self.init(key: key.bytes, variant: variant)
-    }
-}

+ 0 - 26
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift

@@ -1,26 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension Rabbit {
-    public convenience init(key: String) throws {
-        try self.init(key: key.bytes)
-    }
-
-    public convenience init(key: String, iv: String) throws {
-        try self.init(key: key.bytes, iv: iv.bytes)
-    }
-}

+ 0 - 41
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/String+FoundationExtension.swift

@@ -1,41 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-extension String {
-    /// Return Base64 back to String
-    public func decryptBase64ToString(cipher: Cipher) throws -> String {
-        guard let decodedData = Data(base64Encoded: self, options: []) else {
-            throw CipherError.decrypt
-        }
-
-        let decrypted = try decodedData.decrypt(cipher: cipher)
-
-        if let decryptedString = String(data: decrypted, encoding: String.Encoding.utf8) {
-            return decryptedString
-        }
-
-        throw CipherError.decrypt
-    }
-
-    public func decryptBase64(cipher: Cipher) throws -> Array<UInt8> {
-        guard let decodedData = Data(base64Encoded: self, options: []) else {
-            throw CipherError.decrypt
-        }
-
-        return try decodedData.decrypt(cipher: cipher).bytes
-    }
-}

+ 0 - 27
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Foundation/Utils+Foundation.swift

@@ -1,27 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-import Foundation
-
-func perf(_ text: String, closure: () -> Void) {
-    let measurementStart = Date()
-
-    closure()
-
-    let measurementStop = Date()
-    let executionTime = measurementStop.timeIntervalSince(measurementStart)
-
-    print("\(text) \(executionTime)")
-}

+ 0 - 55
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Generics.swift

@@ -1,55 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-/** build bit pattern from array of bits */
-@_specialize(exported: true, where T == UInt8)
-func integerFrom<T: FixedWidthInteger>(_ bits: Array<Bit>) -> T {
-    var bitPattern: T = 0
-    for idx in bits.indices {
-        if bits[idx] == Bit.one {
-            let bit = T(UInt64(1) << UInt64(idx))
-            bitPattern = bitPattern | bit
-        }
-    }
-    return bitPattern
-}
-
-/// Array of bytes. Caution: don't use directly because generic is slow.
-///
-/// - parameter value: integer value
-/// - parameter length: length of output array. By default size of value type
-///
-/// - returns: Array of bytes
-@_specialize(exported: true, where T == Int)
-@_specialize(exported: true, where T == UInt)
-@_specialize(exported: true, where T == UInt8)
-@_specialize(exported: true, where T == UInt16)
-@_specialize(exported: true, where T == UInt32)
-@_specialize(exported: true, where T == UInt64)
-func arrayOfBytes<T: FixedWidthInteger>(value: T, length totalBytes: Int = MemoryLayout<T>.size) -> Array<UInt8> {
-    let valuePointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
-    valuePointer.pointee = value
-
-    let bytesPointer = UnsafeMutablePointer<UInt8>(OpaquePointer(valuePointer))
-    var bytes = Array<UInt8>(repeating: 0, count: totalBytes)
-    for j in 0..<min(MemoryLayout<T>.size, totalBytes) {
-        bytes[totalBytes - 1 - j] = (bytesPointer + j).pointee
-    }
-
-    valuePointer.deinitialize(count: 1)
-    valuePointer.deallocate()
-
-    return bytes
-}

+ 0 - 84
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/HKDF.swift

@@ -1,84 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  https://www.ietf.org/rfc/rfc5869.txt
-//
-
-#if canImport(Darwin)
-import Darwin
-#else
-import Glibc
-#endif
-
-/// A key derivation function.
-///
-/// HKDF   - HMAC-based Extract-and-Expand Key Derivation Function.
-public struct HKDF {
-    public enum Error: Swift.Error {
-        case invalidInput
-        case derivedKeyTooLong
-    }
-
-    private let numBlocks: Int // l
-    private let dkLen: Int
-    private let info: Array<UInt8>
-    fileprivate let prk: Array<UInt8>
-    fileprivate let variant: HMAC.Variant
-
-    /// - parameters:
-    ///   - variant: hash variant
-    ///   - salt: optional salt (if not provided, it is set to a sequence of variant.digestLength zeros)
-    ///   - info: optional context and application specific information
-    ///   - keyLength: intended length of derived key
-    public init(password: Array<UInt8>, salt: Array<UInt8>? = nil, info: Array<UInt8>? = nil, keyLength: Int? = nil /* dkLen */, variant: HMAC.Variant = .sha256) throws {
-        guard !password.isEmpty else {
-            throw Error.invalidInput
-        }
-
-        let dkLen = keyLength ?? variant.digestLength
-        let keyLengthFinal = Double(dkLen)
-        let hLen = Double(variant.digestLength)
-        let numBlocks = Int(ceil(keyLengthFinal / hLen)) // l = ceil(keyLength / hLen)
-        guard numBlocks <= 255 else {
-            throw Error.derivedKeyTooLong
-        }
-
-        /// HKDF-Extract(salt, password) -> PRK
-        ///  - PRK - a pseudo-random key; it is used by calculate()
-        prk = try HMAC(key: salt ?? [], variant: variant).authenticate(password)
-        self.info = info ?? []
-        self.variant = variant
-        self.dkLen = dkLen
-        self.numBlocks = numBlocks
-    }
-
-    public func calculate() throws -> Array<UInt8> {
-        let hmac = HMAC(key: prk, variant: variant)
-        var ret = Array<UInt8>()
-        ret.reserveCapacity(numBlocks * variant.digestLength)
-        var value = Array<UInt8>()
-        for i in 1...numBlocks {
-            value.append(contentsOf: info)
-            value.append(UInt8(i))
-
-            let bytes = try hmac.authenticate(value)
-            ret.append(contentsOf: bytes)
-
-            /// update value to use it as input for next iteration
-            value = bytes
-        }
-        return Array(ret.prefix(dkLen))
-    }
-}

+ 0 - 102
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/HMAC.swift

@@ -1,102 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public final class HMAC: Authenticator {
-    public enum Error: Swift.Error {
-        case authenticateError
-        case invalidInput
-    }
-
-    public enum Variant {
-        case sha1, sha256, sha384, sha512, md5
-
-        var digestLength: Int {
-            switch self {
-            case .sha1:
-                return SHA1.digestLength
-            case .sha256:
-                return SHA2.Variant.sha256.digestLength
-            case .sha384:
-                return SHA2.Variant.sha384.digestLength
-            case .sha512:
-                return SHA2.Variant.sha512.digestLength
-            case .md5:
-                return MD5.digestLength
-            }
-        }
-
-        func calculateHash(_ bytes: Array<UInt8>) -> Array<UInt8> {
-            switch self {
-            case .sha1:
-                return Digest.sha1(bytes)
-            case .sha256:
-                return Digest.sha256(bytes)
-            case .sha384:
-                return Digest.sha384(bytes)
-            case .sha512:
-                return Digest.sha512(bytes)
-            case .md5:
-                return Digest.md5(bytes)
-            }
-        }
-
-        func blockSize() -> Int {
-            switch self {
-            case .md5:
-                return MD5.blockSize
-            case .sha1, .sha256:
-                return 64
-            case .sha384, .sha512:
-                return 128
-            }
-        }
-    }
-
-    var key: Array<UInt8>
-    let variant: Variant
-
-    public init(key: Array<UInt8>, variant: HMAC.Variant = .md5) {
-        self.variant = variant
-        self.key = key
-
-        if key.count > variant.blockSize() {
-            let hash = variant.calculateHash(key)
-            self.key = hash
-        }
-
-        if key.count < variant.blockSize() {
-            self.key = ZeroPadding().add(to: key, blockSize: variant.blockSize())
-        }
-    }
-
-    // MARK: Authenticator
-
-    public func authenticate(_ bytes: Array<UInt8>) throws -> Array<UInt8> {
-        var opad = Array<UInt8>(repeating: 0x5c, count: variant.blockSize())
-        for idx in key.indices {
-            opad[idx] = key[idx] ^ opad[idx]
-        }
-        var ipad = Array<UInt8>(repeating: 0x36, count: variant.blockSize())
-        for idx in key.indices {
-            ipad[idx] = key[idx] ^ ipad[idx]
-        }
-
-        let ipadAndMessageHash = variant.calculateHash(ipad + bytes)
-        let result = variant.calculateHash(opad + ipadAndMessageHash)
-
-        // return Array(result[0..<10]) // 80 bits
-        return result
-    }
-}

+ 0 - 38
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Int+Extension.swift

@@ -1,38 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Created by Marcin Krzyzanowski on 12/08/14.
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-#if canImport(Darwin)
-import Darwin
-#else
-import Glibc
-#endif
-
-/* array of bits */
-extension Int {
-    init(bits: [Bit]) {
-        self.init(bitPattern: integerFrom(bits) as UInt)
-    }
-}
-
-extension FixedWidthInteger {
-    @_transparent
-    func bytes(totalBytes: Int = MemoryLayout<Self>.size) -> Array<UInt8> {
-        return arrayOfBytes(value: self.littleEndian, length: totalBytes)
-        // TODO: adjust bytes order
-        // var value = self.littleEndian
-        // return withUnsafeBytes(of: &value, Array.init).reversed()
-    }
-}

+ 0 - 165
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/MD5.swift

@@ -1,165 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public final class MD5: DigestType {
-    static let blockSize: Int = 64
-    static let digestLength: Int = 16 // 128 / 8
-    fileprivate static let hashInitialValue: Array<UInt32> = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476]
-
-    fileprivate var accumulated = Array<UInt8>()
-    fileprivate var processedBytesTotalCount: Int = 0
-    fileprivate var accumulatedHash: Array<UInt32> = MD5.hashInitialValue
-
-    /** specifies the per-round shift amounts */
-    private let s: Array<UInt32> = [
-        7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
-        5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
-        4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
-        6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,
-    ]
-
-    /** binary integer part of the sines of integers (Radians) */
-    private let k: Array<UInt32> = [
-        0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
-        0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
-        0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
-        0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
-        0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
-        0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
-        0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
-        0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
-        0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
-        0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
-        0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
-        0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
-        0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
-        0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
-        0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
-        0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
-    ]
-
-    public init() {
-    }
-
-    public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
-        do {
-            return try update(withBytes: bytes.slice, isLast: true)
-        } catch {
-            fatalError()
-        }
-    }
-
-    // mutating currentHash in place is way faster than returning new result
-    fileprivate func process(block chunk: ArraySlice<UInt8>, currentHash: inout Array<UInt32>) {
-        assert(chunk.count == 16 * 4)
-
-        // Initialize hash value for this chunk:
-        var A: UInt32 = currentHash[0]
-        var B: UInt32 = currentHash[1]
-        var C: UInt32 = currentHash[2]
-        var D: UInt32 = currentHash[3]
-
-        var dTemp: UInt32 = 0
-
-        // Main loop
-        for j in 0..<k.count {
-            var g = 0
-            var F: UInt32 = 0
-
-            switch j {
-            case 0...15:
-                F = (B & C) | ((~B) & D)
-                g = j
-                break
-            case 16...31:
-                F = (D & B) | (~D & C)
-                g = (5 * j + 1) % 16
-                break
-            case 32...47:
-                F = B ^ C ^ D
-                g = (3 * j + 5) % 16
-                break
-            case 48...63:
-                F = C ^ (B | (~D))
-                g = (7 * j) % 16
-                break
-            default:
-                break
-            }
-            dTemp = D
-            D = C
-            C = B
-
-            // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15 and get M[g] value
-            let gAdvanced = g << 2
-
-            var Mg = UInt32(chunk[chunk.startIndex &+ gAdvanced])
-            Mg |= UInt32(chunk[chunk.startIndex &+ gAdvanced &+ 1]) << 8
-            Mg |= UInt32(chunk[chunk.startIndex &+ gAdvanced &+ 2]) << 16
-            Mg |= UInt32(chunk[chunk.startIndex &+ gAdvanced &+ 3]) << 24
-
-            B = B &+ rotateLeft(A &+ F &+ k[j] &+ Mg, by: s[j])
-            A = dTemp
-        }
-
-        currentHash[0] = currentHash[0] &+ A
-        currentHash[1] = currentHash[1] &+ B
-        currentHash[2] = currentHash[2] &+ C
-        currentHash[3] = currentHash[3] &+ D
-    }
-}
-
-extension MD5: Updatable {
-    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
-        accumulated += bytes
-
-        if isLast {
-            let lengthInBits = (processedBytesTotalCount + accumulated.count) * 8
-            let lengthBytes = lengthInBits.bytes(totalBytes: 64 / 8) // A 64-bit representation of b
-
-            // Step 1. Append padding
-            bitPadding(to: &accumulated, blockSize: MD5.blockSize, allowance: 64 / 8)
-
-            // Step 2. Append Length a 64-bit representation of lengthInBits
-            accumulated += lengthBytes.reversed()
-        }
-
-        var processedBytes = 0
-        for chunk in accumulated.batched(by: MD5.blockSize) {
-            if isLast || (accumulated.count - processedBytes) >= MD5.blockSize {
-                process(block: chunk, currentHash: &accumulatedHash)
-                processedBytes += chunk.count
-            }
-        }
-        accumulated.removeFirst(processedBytes)
-        processedBytesTotalCount += processedBytes
-
-        // output current hash
-        var result = Array<UInt8>()
-        result.reserveCapacity(MD5.digestLength)
-
-        for hElement in accumulatedHash {
-            let hLE = hElement.littleEndian
-            result += Array<UInt8>(arrayLiteral: UInt8(hLE & 0xff), UInt8((hLE >> 8) & 0xff), UInt8((hLE >> 16) & 0xff), UInt8((hLE >> 24) & 0xff))
-        }
-
-        // reset hash value for instance
-        if isLast {
-            accumulatedHash = MD5.hashInitialValue
-        }
-
-        return result
-    }
-}

+ 0 - 27
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/NoPadding.swift

@@ -1,27 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-struct NoPadding: PaddingProtocol {
-    init() {
-    }
-
-    func add(to data: Array<UInt8>, blockSize _: Int) -> Array<UInt8> {
-        return data
-    }
-
-    func remove(from data: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
-        return data
-    }
-}

+ 0 - 32
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Operators.swift

@@ -1,32 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-/*
- Bit shifting with overflow protection using overflow operator "&".
- Approach is consistent with standard overflow operators &+, &-, &*, &/
- and introduce new overflow operators for shifting: &<<, &>>
-
- Note: Works with unsigned integers values only
-
- Usage
-
- var i = 1       // init
- var j = i &<< 2 //shift left
- j &<<= 2        //shift left and assign
-
- @see: https://medium.com/@krzyzanowskim/swiftly-shift-bits-and-protect-yourself-be33016ce071
-
- This fuctonality is now implemented as part of Swift 3, SE-0104 https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md
- */

+ 0 - 87
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF1.swift

@@ -1,87 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public extension PKCS5 {
-    /// A key derivation function.
-    ///
-    /// PBKDF1 is recommended only for compatibility with existing
-    /// applications since the keys it produces may not be large enough for
-    /// some applications.
-    struct PBKDF1 {
-        public enum Error: Swift.Error {
-            case invalidInput
-            case derivedKeyTooLong
-        }
-
-        public enum Variant {
-            case md5, sha1
-
-            var size: Int {
-                switch self {
-                case .md5:
-                    return MD5.digestLength
-                case .sha1:
-                    return SHA1.digestLength
-                }
-            }
-
-            fileprivate func calculateHash(_ bytes: Array<UInt8>) -> Array<UInt8> {
-                switch self {
-                case .sha1:
-                    return Digest.sha1(bytes)
-                case .md5:
-                    return Digest.md5(bytes)
-                }
-            }
-        }
-
-        private let iterations: Int // c
-        private let variant: Variant
-        private let keyLength: Int
-        private let t1: Array<UInt8>
-
-        /// - parameters:
-        ///   - salt: salt, an eight-bytes
-        ///   - variant: hash variant
-        ///   - iterations: iteration count, a positive integer
-        ///   - keyLength: intended length of derived key
-        public init(password: Array<UInt8>, salt: Array<UInt8>, variant: Variant = .sha1, iterations: Int = 4096 /* c */, keyLength: Int? = nil /* dkLen */ ) throws {
-            precondition(iterations > 0)
-            precondition(salt.count == 8)
-
-            let keyLength = keyLength ?? variant.size
-
-            if keyLength > variant.size {
-                throw Error.derivedKeyTooLong
-            }
-
-            let t1 = variant.calculateHash(password + salt)
-
-            self.iterations = iterations
-            self.variant = variant
-            self.keyLength = keyLength
-            self.t1 = t1
-        }
-
-        /// Apply the underlying hash function Hash for c iterations
-        public func calculate() -> Array<UInt8> {
-            var t = t1
-            for _ in 2...iterations {
-                t = variant.calculateHash(t)
-            }
-            return Array(t[0..<self.keyLength])
-        }
-    }
-}

+ 0 - 116
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF2.swift

@@ -1,116 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  https://www.ietf.org/rfc/rfc2898.txt
-//
-
-#if canImport(Darwin)
-import Darwin
-#else
-import Glibc
-#endif
-
-public extension PKCS5 {
-    /// A key derivation function.
-    ///
-    /// PBKDF2 - Password-Based Key Derivation Function 2. Key stretching technique.
-    ///          DK = PBKDF2(PRF, Password, Salt, c, dkLen)
-    struct PBKDF2 {
-        public enum Error: Swift.Error {
-            case invalidInput
-            case derivedKeyTooLong
-        }
-
-        private let salt: Array<UInt8> // S
-        fileprivate let iterations: Int // c
-        private let numBlocks: Int // l
-        private let dkLen: Int
-        fileprivate let prf: HMAC
-
-        /// - parameters:
-        ///   - salt: salt
-        ///   - variant: hash variant
-        ///   - iterations: iteration count, a positive integer
-        ///   - keyLength: intended length of derived key
-        ///   - variant: MAC variant. Defaults to SHA256
-        public init(password: Array<UInt8>, salt: Array<UInt8>, iterations: Int = 4096 /* c */, keyLength: Int? = nil /* dkLen */, variant: HMAC.Variant = .sha256) throws {
-            precondition(iterations > 0)
-
-            let prf = HMAC(key: password, variant: variant)
-
-            guard iterations > 0 && !salt.isEmpty else {
-                throw Error.invalidInput
-            }
-
-            dkLen = keyLength ?? variant.digestLength
-            let keyLengthFinal = Double(dkLen)
-            let hLen = Double(prf.variant.digestLength)
-            if keyLengthFinal > (pow(2, 32) - 1) * hLen {
-                throw Error.derivedKeyTooLong
-            }
-
-            self.salt = salt
-            self.iterations = iterations
-            self.prf = prf
-
-            numBlocks = Int(ceil(Double(keyLengthFinal) / hLen)) // l = ceil(keyLength / hLen)
-        }
-
-        public func calculate() throws -> Array<UInt8> {
-            var ret = Array<UInt8>()
-            ret.reserveCapacity(numBlocks * prf.variant.digestLength)
-            for i in 1...numBlocks {
-                // for each block T_i = U_1 ^ U_2 ^ ... ^ U_iter
-                if let value = try calculateBlock(self.salt, blockNum: i) {
-                    ret.append(contentsOf: value)
-                }
-            }
-            return Array(ret.prefix(dkLen))
-        }
-    }
-}
-
-fileprivate extension PKCS5.PBKDF2 {
-    func ARR(_ i: Int) -> Array<UInt8> {
-        var inti = Array<UInt8>(repeating: 0, count: 4)
-        inti[0] = UInt8((i >> 24) & 0xff)
-        inti[1] = UInt8((i >> 16) & 0xff)
-        inti[2] = UInt8((i >> 8) & 0xff)
-        inti[3] = UInt8(i & 0xff)
-        return inti
-    }
-
-    // F (P, S, c, i) = U_1 \xor U_2 \xor ... \xor U_c
-    // U_1 = PRF (P, S || INT (i))
-    func calculateBlock(_ salt: Array<UInt8>, blockNum: Int) throws -> Array<UInt8>? {
-        guard let u1 = try? prf.authenticate(salt + ARR(blockNum)) else { // blockNum.bytes() is slower
-            return nil
-        }
-
-        var u = u1
-        var ret = u
-        if iterations > 1 {
-            // U_2 = PRF (P, U_1) ,
-            // U_c = PRF (P, U_{c-1}) .
-            for _ in 2...iterations {
-                u = try prf.authenticate(u)
-                for x in 0..<ret.count {
-                    ret[x] = ret[x] ^ u[x]
-                }
-            }
-        }
-        return ret
-    }
-}

+ 0 - 22
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS5.swift

@@ -1,22 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  PKCS is a group of public-key cryptography standards devised
-//  and published by RSA Security Inc, starting in the early 1990s.
-//
-
-public enum PKCS5 {
-    typealias Padding = PKCS7Padding
-}

+ 0 - 18
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7.swift

@@ -1,18 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public enum PKCS7 {
-    typealias Padding = PKCS7Padding
-}

+ 0 - 64
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7Padding.swift

@@ -1,64 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  PKCS is a group of public-key cryptography standards devised
-//  and published by RSA Security Inc, starting in the early 1990s.
-//
-
-struct PKCS7Padding: PaddingProtocol {
-    enum Error: Swift.Error {
-        case invalidPaddingValue
-    }
-
-    init() {
-    }
-
-    func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
-        let padding = UInt8(blockSize - (bytes.count % blockSize))
-        var withPadding = bytes
-        if padding == 0 {
-            // If the original data is a multiple of N bytes, then an extra block of bytes with value N is added.
-            for _ in 0..<blockSize {
-                withPadding += Array<UInt8>(arrayLiteral: UInt8(blockSize))
-            }
-        } else {
-            // The value of each added byte is the number of bytes that are added
-            for _ in 0..<padding {
-                withPadding += Array<UInt8>(arrayLiteral: UInt8(padding))
-            }
-        }
-        return withPadding
-    }
-
-    func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
-        guard !bytes.isEmpty, let lastByte = bytes.last else {
-            return bytes
-        }
-
-        assert(!bytes.isEmpty, "Need bytes to remove padding")
-
-        let padding = Int(lastByte) // last byte
-        let finalLength = bytes.count - padding
-
-        if finalLength < 0 {
-            return bytes
-        }
-
-        if padding >= 1 {
-            return Array(bytes[0..<finalLength])
-        }
-        return bytes
-    }
-}

+ 0 - 49
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Padding.swift

@@ -1,49 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public protocol PaddingProtocol {
-    func add(to: Array<UInt8>, blockSize: Int) -> Array<UInt8>
-    func remove(from: Array<UInt8>, blockSize: Int?) -> Array<UInt8>
-}
-
-public enum Padding: PaddingProtocol {
-    case noPadding, zeroPadding, pkcs7, pkcs5
-
-    public func add(to: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
-        switch self {
-        case .noPadding:
-            return to // NoPadding().add(to: to, blockSize: blockSize)
-        case .zeroPadding:
-            return ZeroPadding().add(to: to, blockSize: blockSize)
-        case .pkcs7:
-            return PKCS7.Padding().add(to: to, blockSize: blockSize)
-        case .pkcs5:
-            return PKCS5.Padding().add(to: to, blockSize: blockSize)
-        }
-    }
-
-    public func remove(from: Array<UInt8>, blockSize: Int?) -> Array<UInt8> {
-        switch self {
-        case .noPadding:
-            return from //NoPadding().remove(from: from, blockSize: blockSize)
-        case .zeroPadding:
-            return ZeroPadding().remove(from: from, blockSize: blockSize)
-        case .pkcs7:
-            return PKCS7.Padding().remove(from: from, blockSize: blockSize)
-        case .pkcs5:
-            return PKCS5.Padding().remove(from: from, blockSize: blockSize)
-        }
-    }
-}

+ 0 - 165
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Poly1305.swift

@@ -1,165 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-//  http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-4
-//  nacl/crypto_onetimeauth/poly1305/ref/auth.c
-//
-///  Poly1305 takes a 32-byte, one-time key and a message and produces a 16-byte tag that authenticates the
-///  message such that an attacker has a negligible chance of producing a valid tag for an inauthentic message.
-
-public final class Poly1305: Authenticator {
-    public enum Error: Swift.Error {
-        case authenticateError
-    }
-
-    public static let blockSize: Int = 16
-
-    private let key: SecureBytes
-
-    /// - parameter key: 32-byte key
-    public init(key: Array<UInt8>) {
-        self.key = SecureBytes(bytes: key)
-    }
-
-    private func squeeze(h: inout Array<UInt32>) {
-        assert(h.count == 17)
-        var u: UInt32 = 0
-        for j in 0..<16 {
-            u = u &+ h[j]
-            h[j] = u & 255
-            u = u >> 8
-        }
-
-        u = u &+ h[16]
-        h[16] = u & 3
-        u = 5 * (u >> 2)
-
-        for j in 0..<16 {
-            u = u &+ h[j]
-            h[j] = u & 255
-            u = u >> 8
-        }
-
-        u = u &+ h[16]
-        h[16] = u
-    }
-
-    private func add(h: inout Array<UInt32>, c: Array<UInt32>) {
-        assert(h.count == 17 && c.count == 17)
-
-        var u: UInt32 = 0
-        for j in 0..<17 {
-            u = u &+ (h[j] &+ c[j])
-            h[j] = u & 255
-            u = u >> 8
-        }
-    }
-
-    private func mulmod(h: inout Array<UInt32>, r: Array<UInt32>) {
-        var hr = Array<UInt32>(repeating: 0, count: 17)
-        var u: UInt32 = 0
-        for i in 0..<17 {
-            u = 0
-            for j in 0...i {
-                u = u &+ (h[j] * r[i &- j])
-            }
-            for j in (i + 1)..<17 {
-                u = u &+ (320 * h[j] * r[i &+ 17 &- j])
-            }
-            hr[i] = u
-        }
-        h = hr
-        squeeze(h: &h)
-    }
-
-    private func freeze(h: inout Array<UInt32>) {
-        let horig = h
-        add(h: &h, c: [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252])
-        let negative = UInt32(bitPattern: -Int32(h[16] >> 7))
-        for j in 0..<17 {
-            h[j] ^= negative & (horig[j] ^ h[j])
-        }
-    }
-
-    /// the key is partitioned into two parts, called "r" and "s"
-    fileprivate func onetimeauth(message input: Array<UInt8>, key k: Array<UInt8>) -> Array<UInt8> {
-        // clamp
-        var r = Array<UInt32>(repeating: 0, count: 17)
-        var h = Array<UInt32>(repeating: 0, count: 17)
-        var c = Array<UInt32>(repeating: 0, count: 17)
-
-        r[0] = UInt32(k[0])
-        r[1] = UInt32(k[1])
-        r[2] = UInt32(k[2])
-        r[3] = UInt32(k[3] & 15)
-        r[4] = UInt32(k[4] & 252)
-        r[5] = UInt32(k[5])
-        r[6] = UInt32(k[6])
-        r[7] = UInt32(k[7] & 15)
-        r[8] = UInt32(k[8] & 252)
-        r[9] = UInt32(k[9])
-        r[10] = UInt32(k[10])
-        r[11] = UInt32(k[11] & 15)
-        r[12] = UInt32(k[12] & 252)
-        r[13] = UInt32(k[13])
-        r[14] = UInt32(k[14])
-        r[15] = UInt32(k[15] & 15)
-        r[16] = 0
-
-        var inlen = input.count
-        var inpos = 0
-        while inlen > 0 {
-            for j in 0..<c.count {
-                c[j] = 0
-            }
-
-            let maxj = min(inlen, 16)
-            for j in 0..<maxj {
-                c[j] = UInt32(input[inpos + j])
-            }
-            c[maxj] = 1
-            inpos = inpos + maxj
-            inlen = inlen - maxj
-            add(h: &h, c: c)
-            mulmod(h: &h, r: r)
-        }
-
-        freeze(h: &h)
-
-        for j in 0..<16 {
-            c[j] = UInt32(k[j + 16])
-        }
-        c[16] = 0
-        add(h: &h, c: c)
-
-        return h[0..<16].map {
-            UInt8($0 & 0xff)
-        }
-    }
-
-    // MARK: - Authenticator
-
-    /**
-     Calculate Message Authentication Code (MAC) for message.
-     Calculation context is discarder on instance deallocation.
-
-     - parameter bytes: Message
-
-     - returns: 16-byte tag that authenticates the message
-     */
-    public func authenticate(_ bytes: Array<UInt8>) throws -> Array<UInt8> {
-        return onetimeauth(message: bytes, key: Array(key))
-    }
-}

+ 0 - 217
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/Rabbit.swift

@@ -1,217 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public final class Rabbit: BlockCipher {
-    public enum Error: Swift.Error {
-        case invalidKeyOrInitializationVector
-    }
-
-    /// Size of IV in bytes
-    public static let ivSize = 64 / 8
-
-    /// Size of key in bytes
-    public static let keySize = 128 / 8
-
-    /// Size of block in bytes
-    public static let blockSize = 128 / 8
-
-    public var keySize: Int {
-        return key.count
-    }
-
-    /// Key
-    private let key: Key
-
-    /// IV (optional)
-    private let iv: Array<UInt8>?
-
-    /// State variables
-    private var x = Array<UInt32>(repeating: 0, count: 8)
-
-    /// Counter variables
-    private var c = Array<UInt32>(repeating: 0, count: 8)
-
-    /// Counter carry
-    private var p7: UInt32 = 0
-
-    /// 'a' constants
-    private var a: Array<UInt32> = [
-        0x4d34d34d,
-        0xd34d34d3,
-        0x34d34d34,
-        0x4d34d34d,
-        0xd34d34d3,
-        0x34d34d34,
-        0x4d34d34d,
-        0xd34d34d3,
-    ]
-
-    // MARK: - Initializers
-
-    public convenience init(key: Array<UInt8>) throws {
-        try self.init(key: key, iv: nil)
-    }
-
-    public init(key: Array<UInt8>, iv: Array<UInt8>?) throws {
-        self.key = Key(bytes: key)
-        self.iv = iv
-
-        guard key.count == Rabbit.keySize && (iv == nil || iv!.count == Rabbit.ivSize) else {
-            throw Error.invalidKeyOrInitializationVector
-        }
-    }
-
-    // MARK: -
-
-    fileprivate func setup() {
-        p7 = 0
-
-        // Key divided into 8 subkeys
-        var k = Array<UInt32>(repeating: 0, count: 8)
-        for j in 0..<8 {
-            k[j] = UInt32(key[Rabbit.blockSize - (2 * j + 1)]) | (UInt32(key[Rabbit.blockSize - (2 * j + 2)]) << 8)
-        }
-
-        // Initialize state and counter variables from subkeys
-        for j in 0..<8 {
-            if j % 2 == 0 {
-                x[j] = (k[(j + 1) % 8] << 16) | k[j]
-                c[j] = (k[(j + 4) % 8] << 16) | k[(j + 5) % 8]
-            } else {
-                x[j] = (k[(j + 5) % 8] << 16) | k[(j + 4) % 8]
-                c[j] = (k[j] << 16) | k[(j + 1) % 8]
-            }
-        }
-
-        // Iterate system four times
-        nextState()
-        nextState()
-        nextState()
-        nextState()
-
-        // Reinitialize counter variables
-        for j in 0..<8 {
-            c[j] = c[j] ^ x[(j + 4) % 8]
-        }
-
-        if let iv = iv {
-            setupIV(iv)
-        }
-    }
-
-    private func setupIV(_ iv: Array<UInt8>) {
-        // 63...56 55...48 47...40 39...32 31...24 23...16 15...8 7...0 IV bits
-        //    0       1       2       3       4       5       6     7   IV bytes in array
-        let iv0 = UInt32(bytes: [iv[4], iv[5], iv[6], iv[7]])
-        let iv1 = UInt32(bytes: [iv[0], iv[1], iv[4], iv[5]])
-        let iv2 = UInt32(bytes: [iv[0], iv[1], iv[2], iv[3]])
-        let iv3 = UInt32(bytes: [iv[2], iv[3], iv[6], iv[7]])
-
-        // Modify the counter state as function of the IV
-        c[0] = c[0] ^ iv0
-        c[1] = c[1] ^ iv1
-        c[2] = c[2] ^ iv2
-        c[3] = c[3] ^ iv3
-        c[4] = c[4] ^ iv0
-        c[5] = c[5] ^ iv1
-        c[6] = c[6] ^ iv2
-        c[7] = c[7] ^ iv3
-
-        // Iterate system four times
-        nextState()
-        nextState()
-        nextState()
-        nextState()
-    }
-
-    private func nextState() {
-        // Before an iteration the counters are incremented
-        var carry = p7
-        for j in 0..<8 {
-            let prev = c[j]
-            c[j] = prev &+ a[j] &+ carry
-            carry = prev > c[j] ? 1 : 0 // detect overflow
-        }
-        p7 = carry // save last carry bit
-
-        // Iteration of the system
-        var newX = Array<UInt32>(repeating: 0, count: 8)
-        newX[0] = g(0) &+ rotateLeft(g(7), by: 16) &+ rotateLeft(g(6), by: 16)
-        newX[1] = g(1) &+ rotateLeft(g(0), by: 8) &+ g(7)
-        newX[2] = g(2) &+ rotateLeft(g(1), by: 16) &+ rotateLeft(g(0), by: 16)
-        newX[3] = g(3) &+ rotateLeft(g(2), by: 8) &+ g(1)
-        newX[4] = g(4) &+ rotateLeft(g(3), by: 16) &+ rotateLeft(g(2), by: 16)
-        newX[5] = g(5) &+ rotateLeft(g(4), by: 8) &+ g(3)
-        newX[6] = g(6) &+ rotateLeft(g(5), by: 16) &+ rotateLeft(g(4), by: 16)
-        newX[7] = g(7) &+ rotateLeft(g(6), by: 8) &+ g(5)
-        x = newX
-    }
-
-    private func g(_ j: Int) -> UInt32 {
-        let sum = x[j] &+ c[j]
-        let square = UInt64(sum) * UInt64(sum)
-        return UInt32(truncatingIfNeeded: square ^ (square >> 32))
-    }
-
-    fileprivate func nextOutput() -> Array<UInt8> {
-        nextState()
-
-        var output16 = Array<UInt16>(repeating: 0, count: Rabbit.blockSize / 2)
-        output16[7] = UInt16(truncatingIfNeeded: x[0]) ^ UInt16(truncatingIfNeeded: x[5] >> 16)
-        output16[6] = UInt16(truncatingIfNeeded: x[0] >> 16) ^ UInt16(truncatingIfNeeded: x[3])
-        output16[5] = UInt16(truncatingIfNeeded: x[2]) ^ UInt16(truncatingIfNeeded: x[7] >> 16)
-        output16[4] = UInt16(truncatingIfNeeded: x[2] >> 16) ^ UInt16(truncatingIfNeeded: x[5])
-        output16[3] = UInt16(truncatingIfNeeded: x[4]) ^ UInt16(truncatingIfNeeded: x[1] >> 16)
-        output16[2] = UInt16(truncatingIfNeeded: x[4] >> 16) ^ UInt16(truncatingIfNeeded: x[7])
-        output16[1] = UInt16(truncatingIfNeeded: x[6]) ^ UInt16(truncatingIfNeeded: x[3] >> 16)
-        output16[0] = UInt16(truncatingIfNeeded: x[6] >> 16) ^ UInt16(truncatingIfNeeded: x[1])
-
-        var output8 = Array<UInt8>(repeating: 0, count: Rabbit.blockSize)
-        for j in 0..<output16.count {
-            output8[j * 2] = UInt8(truncatingIfNeeded: output16[j] >> 8)
-            output8[j * 2 + 1] = UInt8(truncatingIfNeeded: output16[j])
-        }
-        return output8
-    }
-}
-
-// MARK: Cipher
-
-extension Rabbit: Cipher {
-    public func encrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
-        setup()
-
-        var result = Array<UInt8>(repeating: 0, count: bytes.count)
-        var output = nextOutput()
-        var byteIdx = 0
-        var outputIdx = 0
-        while byteIdx < bytes.count {
-            if outputIdx == Rabbit.blockSize {
-                output = nextOutput()
-                outputIdx = 0
-            }
-
-            result[byteIdx] = bytes[byteIdx] ^ output[outputIdx]
-
-            byteIdx += 1
-            outputIdx += 1
-        }
-        return result
-    }
-
-    public func decrypt(_ bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
-        return try encrypt(bytes)
-    }
-}

+ 0 - 50
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/RandomBytesSequence.swift

@@ -1,50 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-#if canImport(Darwin)
-    import Darwin
-#else
-    import Glibc
-#endif
-
-struct RandomBytesSequence: Sequence {
-    let size: Int
-
-    func makeIterator() -> AnyIterator<UInt8> {
-        var count = 0
-        return AnyIterator<UInt8>.init { () -> UInt8? in
-            guard count < self.size else {
-                return nil
-            }
-            count = count + 1
-
-            #if os(Linux) || os(Android) || os(FreeBSD)
-                let fd = open("/dev/urandom", O_RDONLY)
-                if fd <= 0 {
-                    return nil
-                }
-
-                var value: UInt8 = 0
-                let result = read(fd, &value, MemoryLayout<UInt8>.size)
-                precondition(result == 1)
-
-                close(fd)
-                return value
-            #else
-                return UInt8(arc4random_uniform(UInt32(UInt8.max) + 1))
-            #endif
-        }
-    }
-}

+ 0 - 151
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/SHA1.swift

@@ -1,151 +0,0 @@
-//
-//  CryptoSwift
-//
-//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
-//  This software is provided 'as-is', without any express or implied warranty.
-//
-//  In no event will the authors be held liable for any damages arising from the use of this software.
-//
-//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-//
-//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
-//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-//  - This notice may not be removed or altered from any source or binary distribution.
-//
-
-public final class SHA1: DigestType {
-    static let digestLength: Int = 20 // 160 / 8
-    static let blockSize: Int = 64
-    fileprivate static let hashInitialValue: ContiguousArray<UInt32> = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]
-
-    fileprivate var accumulated = Array<UInt8>()
-    fileprivate var processedBytesTotalCount: Int = 0
-    fileprivate var accumulatedHash: ContiguousArray<UInt32> = SHA1.hashInitialValue
-
-    public init() {
-    }
-
-    public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
-        do {
-            return try update(withBytes: bytes.slice, isLast: true)
-        } catch {
-            return []
-        }
-    }
-
-    fileprivate func process(block chunk: ArraySlice<UInt8>, currentHash hh: inout ContiguousArray<UInt32>) {
-        // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15, big-endian
-        // Extend the sixteen 32-bit words into eighty 32-bit words:
-        let M = UnsafeMutablePointer<UInt32>.allocate(capacity: 80)
-        M.initialize(repeating: 0, count: 80)
-        defer {
-            M.deinitialize(count: 80)
-            M.deallocate()
-        }
-
-        for x in 0..<80 {
-            switch x {
-            case 0...15:
-                let start = chunk.startIndex.advanced(by: x * 4) // * MemoryLayout<UInt32>.size
-                M[x] = UInt32(bytes: chunk, fromIndex: start)
-                break
-            default:
-                M[x] = rotateLeft(M[x - 3] ^ M[x - 8] ^ M[x - 14] ^ M[x - 16], by: 1)
-                break
-            }
-        }
-
-        var A = hh[0]
-        var B = hh[1]
-        var C = hh[2]
-        var D = hh[3]
-        var E = hh[4]
-
-        // Main loop
-        for j in 0...79 {
-            var f: UInt32 = 0
-            var k: UInt32 = 0
-
-            switch j {
-            case 0...19:
-                f = (B & C) | ((~B) & D)
-                k = 0x5a827999
-                break
-            case 20...39:
-                f = B ^ C ^ D
-                k = 0x6ed9eba1
-                break
-            case 40...59:
-                f = (B & C) | (B & D) | (C & D)
-                k = 0x8f1bbcdc
-                break
-            case 60...79:
-                f = B ^ C ^ D
-                k = 0xca62c1d6
-                break
-            default:
-                break
-            }
-
-            let temp = rotateLeft(A, by: 5) &+ f &+ E &+ M[j] &+ k
-            E = D
-            D = C
-            C = rotateLeft(B, by: 30)
-            B = A
-            A = temp
-        }
-
-        hh[0] = hh[0] &+ A
-        hh[1] = hh[1] &+ B
-        hh[2] = hh[2] &+ C
-        hh[3] = hh[3] &+ D
-        hh[4] = hh[4] &+ E
-    }
-}
-
-extension SHA1: Updatable {
-    @discardableResult
-    public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
-        accumulated += bytes
-
-        if isLast {
-            let lengthInBits = (processedBytesTotalCount + accumulated.count) * 8
-            let lengthBytes = lengthInBits.bytes(totalBytes: 64 / 8) // A 64-bit representation of b
-
-            // Step 1. Append padding
-            bitPadding(to: &accumulated, blockSize: SHA1.blockSize, allowance: 64 / 8)
-
-            // Step 2. Append Length a 64-bit representation of lengthInBits
-            accumulated += lengthBytes
-        }
-
-        var processedBytes = 0
-        for chunk in accumulated.batched(by: SHA1.blockSize) {
-            if isLast || (accumulated.count - processedBytes) >= SHA1.blockSize {
-                process(block: chunk, currentHash: &accumulatedHash)
-                processedBytes += chunk.count
-            }
-        }
-        accumulated.removeFirst(processedBytes)
-        processedBytesTotalCount += processedBytes
-
-        // output current hash
-        var result = Array<UInt8>(repeating: 0, count: SHA1.digestLength)
-        var pos = 0
-        for idx in 0..<accumulatedHash.count {
-            let h = accumulatedHash[idx]
-            result[pos + 0] = UInt8((h >> 24) & 0xff)
-            result[pos + 1] = UInt8((h >> 16) & 0xff)
-            result[pos + 2] = UInt8((h >> 8) & 0xff)
-            result[pos + 3] = UInt8(h & 0xff)
-            pos += 4
-        }
-
-        // reset hash value for instance
-        if isLast {
-            accumulatedHash = SHA1.hashInitialValue
-        }
-
-        return result
-    }
-}

+ 0 - 0
RainbowPlanet/Pods/CryptoSwift/Sources/CryptoSwift/SHA2.swift


Деякі файли не було показано, через те що забагато файлів було змінено