Skip to content

Commit

Permalink
Add Frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzanowskim committed Jun 30, 2017
1 parent df3d9ac commit 5dbfaa1
Show file tree
Hide file tree
Showing 88 changed files with 2,754 additions and 0 deletions.
1 change: 1 addition & 0 deletions Frameworks/ios/ObjectivePGP.framework/Headers
1 change: 1 addition & 0 deletions Frameworks/ios/ObjectivePGP.framework/ObjectivePGP
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
//
// ObjectivePGP.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 03/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//

#import "PGPFoundation.h"
#import "PGPKey.h"

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// ObjectivePGP main class.
@interface ObjectivePGP : NSObject

/// Imported keys.
@property (strong, nonatomic, readonly) NSSet<PGPKey *> *keys;

/**
Import keys from the file. `keys` property is updated after successfull import.
@param path Path to the file with the keys.
@return Array of loaded keys.
*/
- (NSSet<PGPKey *> *)importKeysFromFile:(NSString *)path;

/**
Import keys from the data. `keys` property is updated after successfull import.
@param data Keys data.
@return Array of loaded keys.
*/
- (NSSet<PGPKey *> *)importKeysFromData:(NSData *)data;

/**
Import key with given identifier
@param shortKeyStringIdentifier Short (8 characters) key identifier to load.
@param path Path to the file with the keys.
@return YES on success.
*/
- (BOOL)importKey:(NSString *)shortKeyStringIdentifier fromFile:(NSString *)path;

/**
Read keys from the data. Does not import the keys.
@param fileData Keys data.
@return Array of parsed keys.
*/
- (NSSet<PGPKey *> *)keysFromData:(NSData *)fileData;

/**
Read keys from the file. Does not import the keys.
@param path Path to the keys file.
@return Array of parsed keys.
*/
- (NSSet<PGPKey *> *)keysFromFile:(NSString *)path;

/**
Save keys of given type (public or private) to the file.
@param type Keys type.
@param path Full path to the destination file.
@param error Error.
@return YES on success.
*/
- (BOOL)exportKeysOfType:(PGPPartialKeyType)type toFile:(NSString *)path error:(NSError *__autoreleasing _Nullable *)error;

/**
Export key data.
@param key Key to export.
@param armored Choose the format. Binary or Armored (armored is a string based format)
@return Data or `nil` if can't export key.
*/
- (nullable NSData *)exportKey:(PGPKey *)key armored:(BOOL)armored;

/**
Search for string based key identifier.
@param keyIdentifier Key identifier. Short (8 characters, e.g: 4EF122E5) or long (16 characters, e.g: 71180E514EF122E5) identifier.
@return Key instance, or `nil` if not found.
*/
- (nullable PGPKey *)findKeyForIdentifier:(NSString *)keyIdentifier;

/**
Search for key id.
@param keyID Key identifier.
@return Key instance or `nil` if not found.
*/
- (nullable PGPKey *)findKeyForKeyID:(PGPKeyID *)keyID;

/**
Search for keys for given user id.
@param userID A string based identifier (usually name with the e-mail address).
@return Array of found keys, or empty array if not found.
*/
- (NSSet<PGPKey *> *)findKeysForUserID:(NSString *)userID;

/**
Sign data using a key.
@param dataToSign Data to sign.
@param key Key to be used to sign.
@param passphrase Optional. Passphrase for the key.
@param detached whether output detached signature.
@param error Error.
@return Signed data, or `nil` if fail.
*/
- (nullable NSData *)signData:(NSData *)dataToSign usingKey:(PGPKey *)key passphrase:(nullable NSString *)passphrase detached:(BOOL)detached error:(NSError *__autoreleasing _Nullable *)error;

/**
Verify signed data. Validates with the imported keys.
@param signedData Signed data.
@param error Error
@return YES on success.
*/
- (BOOL)verifyData:(NSData *)signedData error:(NSError *__autoreleasing _Nullable *)error;

/**
Verify signed data, with detached signature data.
@param signedData Signed data.
@param signatureData Detached signature data.
@param error Error
@return YES on success.
*/
- (BOOL)verifyData:(NSData *)signedData withSignature:(NSData *)signatureData error:(NSError *__autoreleasing _Nullable *)error;

/**
Verify signed data using given key.
@param signedData Signed data.
@param signatureData Detached signature data.
@param key Key to use.
@param error Error.
@return YES on success.
*/
- (BOOL)verifyData:(NSData *)signedData withSignature:(NSData *)signatureData usingKey:(PGPKey *)key error:(NSError *__autoreleasing _Nullable *)error;

- (nullable NSData *)encryptData:(NSData *)dataToEncrypt usingKeys:(NSArray<PGPKey *> *)keys armored:(BOOL)armored error:(NSError *__autoreleasing _Nullable *)error;
- (nullable NSData *)encryptData:(NSData *)dataToEncrypt usingKeys:(NSArray<PGPKey *> *)keys signWithKey:(nullable PGPKey *)signKey passphrase:(nullable NSString *)passphrase armored:(BOOL)armored error:(NSError *__autoreleasing _Nullable *)error;

- (nullable NSData *)decryptData:(NSData *)messageDataToDecrypt passphrase:(nullable NSString *)passphrase error:(NSError *__autoreleasing _Nullable *)error;
- (nullable NSData *)decryptData:(NSData *)messageDataToDecrypt passphrase:(nullable NSString *)passphrase verifyWithKey:(nullable PGPKey *)key signed:(nullable BOOL *)isSigned valid:(nullable BOOL *)isValid integrityProtected:(nullable BOOL *)isIntegrityProtected error:(NSError *__autoreleasing _Nullable *)error;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// PGPArmor.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 18/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, PGPArmorType) {
PGPArmorTypeMessage = 1,
PGPArmorTypePublicKey = 2,
PGPArmorTypeSecretKey = 3,
PGPArmorTypeMultipartMessagePartXOfY = 4,
PGPArmorTypeMultipartMessagePartX = 5,
PGPArmorTypeSignature = 6,
PGPArmorCleartextSignedMessage = 7, // TODO: -----BEGIN PGP SIGNED MESSAGE-----
};

@interface PGPArmor : NSObject

+ (NSData *)armoredData:(NSData *)dataToArmor as:(PGPArmorType)armorType part:(NSUInteger)part of:(NSUInteger)ofParts;
+ (NSData *)armoredData:(NSData *)dataToArmor as:(PGPArmorType)armorType;

+ (NSData *)readArmoredData:(NSString *)armoredString error:(NSError *__autoreleasing *)error;

+ (BOOL)isArmoredData:(NSData *)data;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// PGPBigNum.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 26/06/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface PGPBigNum : NSObject

@property (nonatomic, readonly) int bitsCount;
@property (nonatomic, readonly) int bytesCount;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// PGPCompressedPacket.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 02/06/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//

#import "PGPPacket.h"

// 9.3. Compression Algorithms
typedef NS_ENUM(UInt8, PGPCompressionAlgorithm) {
PGPCompressionUncompressed = 0,
PGPCompressionZIP = 1, // TODO: Unsupported
PGPCompressionZLIB = 2,
PGPCompressionBZIP2 = 3
};

@interface PGPCompressedPacket : PGPPacket
@property (nonatomic, readonly) PGPCompressionAlgorithm compressionType;
@property (nonatomic) NSData *decompressedData;

- (instancetype)initWithData:(NSData *)dataToCompress type:(PGPCompressionAlgorithm)type;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// PGPCryptoCFB.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 05/06/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//

#import "PGPS2K.h"
#import "PGPTypes.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface PGPCryptoCFB : NSObject

+ (nullable NSData *)decryptData:(NSData *)encryptedData
sessionKeyData:(NSData *)sessionKeyData // s2k produceSessionKeyWithPassphrase
symmetricAlgorithm:(PGPSymmetricAlgorithm)symmetricAlgorithm
iv:(NSData *)ivData;

+ (nullable NSData *)encryptData:(NSData *)encryptedData
sessionKeyData:(NSData *)sessionKeyData // s2k produceSessionKeyWithPassphrase
symmetricAlgorithm:(PGPSymmetricAlgorithm)symmetricAlgorithm
iv:(NSData *)ivData;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// PGPExportableProtocol.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 11/06/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol PGPExportable <NSObject>

- (nullable NSData *)export:(NSError *_Nullable __autoreleasing *)error;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// PGPFingerprint.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 14/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface PGPFingerprint : NSObject
@property (nonatomic, copy) NSData *hashedData;
@property (nonatomic, copy) NSData *keyData;

- (instancetype)initWithData:(NSData *)data;
- (NSString *)description;
- (NSUInteger)hashLength;

- (BOOL)isEqualToFingerprint:(PGPFingerprint *)fingerprint;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

//
// PGPFoundation.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 31/05/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

#define PGPCast(obj, c) ((c * _Nullable) _pgp__cast(obj, c.class))

id _Nullable _pgp__cast(id _Nullable obj, Class objClass);

@interface PGPFoundation : NSObject

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// PGPKey+Private.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 10/06/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//

#import "PGPKey.h"
#import "PGPPartialKey.h"

NS_ASSUME_NONNULL_BEGIN

@interface PGPKey ()

@property (nonatomic, nullable, readwrite) PGPPartialKey *secretKey;
@property (nonatomic, nullable, readwrite) PGPPartialKey *publicKey;

@end

NS_ASSUME_NONNULL_END
35 changes: 35 additions & 0 deletions Frameworks/ios/ObjectivePGP.framework/Versions/A/Headers/PGPKey.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// PGPKey.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 31/05/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//

#import "PGPPacket.h"
#import "PGPPartialKey.h"
#import "PGPTypes.h"

#import "PGPExportableProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// Public + Private key with the same ID.
@interface PGPKey : NSObject <PGPExportable>

PGP_EMPTY_INIT_UNAVAILABLE;

@property (nonatomic, nullable, readonly) PGPPartialKey *secretKey;
@property (nonatomic, nullable, readonly) PGPPartialKey *publicKey;

@property (nonatomic, readonly) BOOL isSecret;
@property (nonatomic, readonly) BOOL isPublic;

@property (nonatomic, nullable, readonly) PGPSecretKeyPacket *signingSecretKey;

- (instancetype)initWithSecretKey:(nullable PGPPartialKey *)secretKey publicKey:(nullable PGPPartialKey *)publicKey NS_DESIGNATED_INITIALIZER;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 5dbfaa1

Please sign in to comment.