Ind.ie is now Small Technology Foundation.
Commit 81aac27c authored by Stefan van den Oord's avatar Stefan van den Oord

`pod update` of PulseDiscoveryBrowser

parent c0a605da
platform :ios, '8.0'
platform :ios, '9.0'
use_frameworks!
target 'PulseDiscoveryBrowser' do
pod 'Pulse', :path => '../..'
pod 'OpenSSL-for-iOS', '~> 1.0.2.d.0'
end
......@@ -7,21 +7,24 @@ PODS:
- CocoaAsyncSocket/RunLoop
- CocoaAsyncSocket/GCD (7.4.3)
- CocoaAsyncSocket/RunLoop (7.4.3)
- IDZSwiftCommonCrypto (0.7.3)
- IGDigest (1.1.3)
- lz4 (128)
- NetUtils (1.3.2)
- OpenSSL-for-iOS (1.0.2.d.1)
- NetUtils (2.0.1)
- Pulse (0.0.1):
- Base32 (~> 1.0.2)
- CocoaAsyncSocket (~> 7.4)
- CocoaAsyncSocket (~> 7.4.0)
- IGDigest (~> 1.1.0)
- lz4 (~> 128)
- NetUtils (~> 1.0)
- NetUtils (~> 2.0)
- SelfSignedCert (~> 1.0)
- SwiftBytes (~> 0.2)
- SelfSignedCert (1.0.0):
- IDZSwiftCommonCrypto (~> 0.7)
- SwiftBytes (~> 0.2)
- SwiftBytes (0.3.1)
DEPENDENCIES:
- OpenSSL-for-iOS (~> 1.0.2.d.0)
- Pulse (from `../..`)
EXTERNAL SOURCES:
......@@ -31,13 +34,14 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Base32: 4e6b6d6c344b48da363c5268f9c391d37893401f
CocoaAsyncSocket: a18c75dca4b08723628a0bacca6e94803d90be91
IDZSwiftCommonCrypto: f4271e731bdeefa85832d425629134fc01efd659
IGDigest: b8e27edd36468bc87951645b841531229256019a
lz4: 5e066195ca751d552becaa026f8fe213ff738adf
NetUtils: 0e2985b5cbd56824b9304a26aea4784f0927f23c
OpenSSL-for-iOS: d7a30add88a1969b052135adbe48452af231ed32
Pulse: d46a429852b5603fadeffca899cd522231707a75
NetUtils: 5b2e30831df2e7db75962837324187a01a1c0c53
Pulse: 1808c136f235d6e18369fc968abaf010d06cc6fd
SelfSignedCert: eeb068ecdbccc68bfd5e8955f7b3df55394d656a
SwiftBytes: 262e08479bc103bbb4eccd296e8b8ffb2102f7c3
PODFILE CHECKSUM: 5d24f7a36957d14d9483c8797ba220cbf3b42e0a
PODFILE CHECKSUM: 3dfbf095233835677f743d56984788c180f4fbbc
COCOAPODS: 1.0.0.beta.8
COCOAPODS: 1.0.1
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator9.2.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator9.2.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.2.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.2.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator2.2.sdk/usr/include/CommonCrypto//CommonCrypto.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator2.2.sdk/usr/include/CommonCrypto//CommonRandom.h"
export *
}
//
// Crypto.swift
// IDZSwiftCommonCrypto
//
// This implements the API of https://github.com/soffes/Crypto
//
// Created by idz on 9/16/15.
// Copyright © 2015 iOSDeveloperZone.com. All rights reserved.
//
import Foundation
///
/// Implements a simplified API for calculating digests over single buffers
///
public protocol CryptoDigest {
/// Calculates a message digest
func digest(algorithm : Digest.Algorithm) -> Self
}
extension CryptoDigest {
/// An MD2 digest of this object
public var MD2: Self { return self.digest(.MD2) }
/// An MD4 digest of this object
public var MD4: Self { return self.digest(.MD4) }
/// An MD5 digest of this object
public var MD5: Self { return self.digest(.MD5) }
/// An SHA1 digest of this object
public var SHA1: Self { return self.digest(.SHA1) }
/// An SHA224 digest of this object
public var SHA224: Self { return self.digest(.SHA224) }
/// An SHA256 digest of this object
public var SHA256: Self { return self.digest(.SHA256) }
/// An SHA384 digest of this object
public var SHA384: Self { return self.digest(.SHA384) }
/// An SHA512 digest of this object
public var SHA512: Self { return self.digest(.SHA512) }
}
extension NSData : CryptoDigest {
///
/// Calculates the Message Digest for this data.
///
/// - parameter algorithm: the digest algorithm to use
/// - returns: an `NSData` object containing the message digest
///
public func digest(algorithm : Digest.Algorithm) -> Self {
// This force unwrap may look scary but for CommonCrypto this cannot fail.
// The API allows for optionals to support the OpenSSL implementation which can.
let result = (Digest(algorithm: algorithm).update(self)?.final())!
let data = self.dynamicType.init(bytes: result, length: result.count)
return data
}
}
extension String : CryptoDigest {
///
/// Calculates the Message Digest for this string.
/// The string is converted to raw data using UTF8.
///
/// - parameter algorithm: the digest algorithm to use
/// - returns: a hex string of the calculated digest
///
public func digest(algorithm : Digest.Algorithm) -> String {
// This force unwrap may look scary but for CommonCrypto this cannot fail.
// The API allows for optionals to support the OpenSSL implementation which can.
let result = (Digest(algorithm: algorithm).update(self as String)?.final())!
return hexStringFromArray(result)
}
}
//
// Cryptor.swift
// IDZSwiftCommonCrypto
//
// Created by idz on 9/23/14.
// Copyright (c) 2014 iOSDeveloperZone.com. All rights reserved.
//
import Foundation
/**
Encrypts or decrypts, accumulating result.
Useful for small in-memory buffers.
For large files or network streams use StreamCryptor.
*/
public class Cryptor : StreamCryptor, Updateable
{
var accumulator : [UInt8] = []
/**
Retrieves the encrypted or decrypted data.
- returns: the encrypted or decrypted data or nil if an error occured.
*/
public func final() -> [UInt8]?
{
let byteCount = Int(self.getOutputLength(0, isFinal: true))
var dataOut = Array<UInt8>(count:byteCount, repeatedValue:0)
var dataOutMoved = 0
(dataOutMoved, self.status) = final(&dataOut)
if(self.status != Status.Success) {
return nil
}
accumulator += dataOut[0..<Int(dataOutMoved)]
return accumulator
}
// MARK: - Low-level interface
/**
Upates the accumulated encrypted/decrypted data with the contents
of a raw byte buffer.
It is not envisaged the users of the framework will need to call this directly.
- returns: this Cryptor object or nil if an error occurs (for optional chaining)
*/
public func update(buffer: UnsafePointer<Void>, _ byteCount: Int) -> Self?
{
let outputLength = self.getOutputLength(byteCount, isFinal: false)
var dataOut = Array<UInt8>(count:outputLength, repeatedValue:0)
var dataOutMoved = 0
update(buffer, byteCountIn: byteCount, bufferOut: &dataOut, byteCapacityOut: dataOut.count, byteCountOut: &dataOutMoved)
if(self.status != Status.Success) {
return nil
}
accumulator += dataOut[0..<Int(dataOutMoved)]
return self
}
}
//
// Digest.swift
// SwiftCommonCrypto
//
// Created by idz on 9/19/14.
// Copyright (c) 2014 iOS Developer Zone. All rights reserved.
//
import Foundation
import CommonCrypto
// MARK: - Public Interface
/**
Public API for message digests.
Usage is straightforward
````
let s = "The quick brown fox jumps over the lazy dog."
var md5 : Digest = Digest(algorithm:.MD5)
md5.update(s)
let digest = md5.final()
````
*/
public class Digest : Updateable
{
///
/// The status of the Digest.
/// For CommonCrypto this will always be `.Success`.
/// It is here to provide for engines which can fail.
///
public var status = Status.Success
///
/// Enumerates available Digest algorithms
///
public enum Algorithm
{
/// Message Digest 2 See: http://en.wikipedia.org/wiki/MD2_(cryptography)
case MD2,
/// Message Digest 4
MD4,
/// Message Digest 5
MD5,
/// Secure Hash Algorithm 1
SHA1,
/// Secure Hash Algorithm 2 224-bit
SHA224,
/// Secure Hash Algorithm 2 256-bit
SHA256,
/// Secure Hash Algorithm 2 384-bit
SHA384,
/// Secure Hash Algorithm 2 512-bit
SHA512
}
var engine: DigestEngine
/**
Create an algorithm-specific digest calculator
- parameter alrgorithm: the desired message digest algorithm
*/
public init(algorithm: Algorithm)
{
switch algorithm {
case .MD2:
engine = DigestEngineCC<CC_MD2_CTX>(initializer:CC_MD2_Init, updater:CC_MD2_Update, finalizer:CC_MD2_Final, length:CC_MD2_DIGEST_LENGTH)
case .MD4:
engine = DigestEngineCC<CC_MD4_CTX>(initializer:CC_MD4_Init, updater:CC_MD4_Update, finalizer:CC_MD4_Final, length:CC_MD4_DIGEST_LENGTH)
case .MD5:
engine = DigestEngineCC<CC_MD5_CTX>(initializer:CC_MD5_Init, updater:CC_MD5_Update, finalizer:CC_MD5_Final, length:CC_MD5_DIGEST_LENGTH)
case .SHA1:
engine = DigestEngineCC<CC_SHA1_CTX>(initializer:CC_SHA1_Init, updater:CC_SHA1_Update, finalizer:CC_SHA1_Final, length:CC_SHA1_DIGEST_LENGTH)
case .SHA224:
engine = DigestEngineCC<CC_SHA256_CTX>(initializer:CC_SHA224_Init, updater:CC_SHA224_Update, finalizer:CC_SHA224_Final, length:CC_SHA224_DIGEST_LENGTH)
case .SHA256:
engine = DigestEngineCC<CC_SHA256_CTX>(initializer:CC_SHA256_Init, updater:CC_SHA256_Update, finalizer:CC_SHA256_Final, length:CC_SHA256_DIGEST_LENGTH)
case .SHA384:
engine = DigestEngineCC<CC_SHA512_CTX>(initializer:CC_SHA384_Init, updater:CC_SHA384_Update, finalizer:CC_SHA384_Final, length:CC_SHA384_DIGEST_LENGTH)
case .SHA512:
engine = DigestEngineCC<CC_SHA512_CTX>(initializer:CC_SHA512_Init, updater:CC_SHA512_Update, finalizer:CC_SHA512_Final, length:CC_SHA512_DIGEST_LENGTH)
}
}
/**
Low-level update routine. Updates the message digest calculation with
the contents of a byte buffer.
- parameter buffer: the buffer
- parameter the: number of bytes in buffer
- returns: this Digest object (for optional chaining)
*/
public func update(buffer: UnsafePointer<Void>, _ byteCount: size_t) -> Self?
{
engine.update(buffer, CC_LONG(byteCount))
return self
}
/**
Completes the calculate of the messge digest
- returns: the message digest
*/
public func final() -> [UInt8]
{
return engine.final()
}
}
// MARK: Internal Classes
/**
* Defines the interface between the Digest class and an
* algorithm specific DigestEngine
*/
protocol DigestEngine
{
func update(buffer: UnsafePointer<Void>, _ byteCount: CC_LONG)
func final() -> [UInt8]
}
/**
* Wraps the underlying algorithm specific structures and calls
* in a generic interface.
*/
class DigestEngineCC<C> : DigestEngine {
typealias Context = UnsafeMutablePointer<C>
typealias Buffer = UnsafePointer<Void>
typealias Digest = UnsafeMutablePointer<UInt8>
typealias Initializer = (Context) -> (Int32)
typealias Updater = (Context, Buffer, CC_LONG) -> (Int32)
typealias Finalizer = (Digest, Context) -> (Int32)
let context = Context.alloc(1)
var initializer : Initializer
var updater : Updater
var finalizer : Finalizer
var length : Int32
init(initializer : Initializer, updater : Updater, finalizer : Finalizer, length : Int32)
{
self.initializer = initializer
self.updater = updater
self.finalizer = finalizer
self.length = length
initializer(context)
}
deinit
{
context.dealloc(1)
}
func update(buffer: Buffer, _ byteCount: CC_LONG)
{
updater(context, buffer, byteCount)
}
func final() -> [UInt8]
{
let digestLength = Int(self.length)
var digest = Array<UInt8>(count:digestLength, repeatedValue: 0)
finalizer(&digest, context)
return digest
}
}
//
// HMAC.swift
// SwiftCommonCrypto
//
// Created by idz on 9/19/14.
// Copyright (c) 2014 iOS Developer Zone. All rights reserved.
//
import Foundation
import CommonCrypto
///
/// Calculates a cryptographic Hash-Based Message Authentication Code (HMAC).
///
public class HMAC : Updateable
{
///
/// Enumerates available algorithms.
///
public enum Algorithm
{
/// Message Digest 5
case MD5,
/// Secure Hash Algorithm 1
SHA1,
/// Secure Hash Algorithm 2 224-bit
SHA224,
/// Secure Hash Algorithm 2 256-bit
SHA256,
/// Secure Hash Algorithm 2 384-bit
SHA384,
/// Secure Hash Algorithm 2 512-bit
SHA512
static let fromNative : [CCHmacAlgorithm: Algorithm] = [
CCHmacAlgorithm(kCCHmacAlgSHA1):.SHA1,
CCHmacAlgorithm(kCCHmacAlgSHA1):.MD5,
CCHmacAlgorithm(kCCHmacAlgSHA256):.SHA256,
CCHmacAlgorithm(kCCHmacAlgSHA384):.SHA384,
CCHmacAlgorithm(kCCHmacAlgSHA512):.SHA512,
CCHmacAlgorithm(kCCHmacAlgSHA224):.SHA224 ]
func nativeValue() -> CCHmacAlgorithm {
switch self {
case .SHA1:
return CCHmacAlgorithm(kCCHmacAlgSHA1)
case .MD5:
return CCHmacAlgorithm(kCCHmacAlgMD5)
case .SHA224:
return CCHmacAlgorithm(kCCHmacAlgSHA224)
case .SHA256:
return CCHmacAlgorithm(kCCHmacAlgSHA256)
case .SHA384:
return CCHmacAlgorithm(kCCHmacAlgSHA384)
case .SHA512:
return CCHmacAlgorithm(kCCHmacAlgSHA512)
}
}
static func fromNativeValue(nativeAlg : CCHmacAlgorithm) -> Algorithm?
{
return fromNative[nativeAlg]
}
///
/// Obtains the digest length produced by this algorithm (in bytes).
///
public func digestLength() -> Int {
switch self {
case .SHA1:
return Int(CC_SHA1_DIGEST_LENGTH)
case .MD5:
return Int(CC_MD5_DIGEST_LENGTH)
case .SHA224:
return Int(CC_SHA224_DIGEST_LENGTH)
case .SHA256:
return Int(CC_SHA256_DIGEST_LENGTH)
case .SHA384:
return Int(CC_SHA384_DIGEST_LENGTH)
case .SHA512:
return Int(CC_SHA512_DIGEST_LENGTH)
}
}
}
typealias Context = UnsafeMutablePointer<CCHmacContext>
/// Status of the calculation
public var status : Status = .Success
let context = Context.alloc(1)
var algorithm : Algorithm
init(algorithm : Algorithm, keyBuffer: UnsafePointer<Void>, keyByteCount: Int)
{
self.algorithm = algorithm
CCHmacInit(context, algorithm.nativeValue(), keyBuffer, size_t(keyByteCount))
}
///
/// Creates a new HMAC instance with the specified algorithm and key.
///
/// - parameter algorithm: selects the algorithm
/// - parameter key: specifies the key
///
public init(algorithm : Algorithm, key : NSData)
{
self.algorithm = algorithm
CCHmacInit(context, algorithm.nativeValue(), key.bytes, size_t(key.length))
}
///
/// Creates a new HMAC instance with the specified algorithm and key.
///
/// - parameter algorithm: selects the algorithm
/// - parameter key: specifies the key
///
public init(algorithm : Algorithm, key : [UInt8])
{
self.algorithm = algorithm
CCHmacInit(context, algorithm.nativeValue(), key, size_t(key.count))
}
///
/// Creates a new HMAC instance with the specified algorithm and key string.
/// The key string is converted to bytes using UTF8 encoding.
///
/// - parameter algorithm: selects the algorithm
/// - parameter key: specifies the key
///
public init(algorithm : Algorithm, key : String)
{
self.algorithm = algorithm
CCHmacInit(context, algorithm.nativeValue(), key, size_t(key.lengthOfBytesUsingEncoding(NSUTF8StringEncoding)))
}
deinit {
context.dealloc(1)
}
///
/// Updates the calculation of the HMAC with the contents of a buffer.
///
/// - returns: the calculated HMAC
///
public func update(buffer : UnsafePointer<Void>, _ byteCount : size_t) -> Self?
{
CCHmacUpdate(context, buffer, byteCount)
return self
}
///
/// Finalizes the HMAC calculation
///
/// - returns: the calculated HMAC
///
public func final() -> [UInt8]
{
var hmac = Array<UInt8>(count:algorithm.digestLength(), repeatedValue:0)
CCHmacFinal(context, &hmac)
return hmac
}
}
//
// IDZSwiftCommonCrypto.h
// IDZSwiftCommonCrypto
//
// Created by idz on 9/20/14.
// Copyright (c) 2014 iOSDeveloperZone.com. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for IDZSwiftCommonCrypto.
FOUNDATION_EXPORT double IDZSwiftCommonCryptoVersionNumber;
//! Project version string for IDZSwiftCommonCrypto.
FOUNDATION_EXPORT const unsigned char IDZSwiftCommonCryptoVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <IDZSwiftCommonCrypto/PublicHeader.h>
//
// KeyDerivation.swift
// SwiftCommonCrypto
//
// Created by idz on 9/19/14.
// Copyright (c) 2014 iOS Developer Zone. All rights reserved.
//
import Foundation
import CommonCrypto
///
/// Derives key material from a password or passphrase.
///
public class PBKDF
{