Skip to content
Snippets Groups Projects
Commit 33c8050b authored by Oliver Wiese's avatar Oliver Wiese
Browse files

add objectivePGP

parent 8755d810
Branches
Tags
No related merge requests found
Showing
with 751 additions and 0 deletions
//
// ObjectivePGP
//
// Copyright © Marcin Krzyżanowski. All rights reserved.
//
// DO NOT MODIFY. FILE GENERATED AUTOMATICALLY.
#import <Foundation/Foundation.h>
//! Project version number for ObjectivePGP.
FOUNDATION_EXPORT double ObjectivePGPVersionNumber;
//! Project version string for ObjectivePGP.
FOUNDATION_EXPORT const unsigned char ObjectivePGPVersionString[];
#import <ObjectivePGP/PGPMacros.h>
#import <ObjectivePGP/PGPTypes.h>
#import <ObjectivePGP/ObjectivePGPObject.h>
#import <ObjectivePGP/PGPKeyGenerator.h>
#import <ObjectivePGP/PGPKeyring.h>
#import <ObjectivePGP/PGPFingerprint.h>
#import <ObjectivePGP/PGPKeyID.h>
#import <ObjectivePGP/PGPUser.h>
#import <ObjectivePGP/PGPPartialSubKey.h>
#import <ObjectivePGP/PGPPartialKey.h>
#import <ObjectivePGP/PGPKey.h>
#import <ObjectivePGP/PGPExportableProtocol.h>
#import <ObjectivePGP/PGPArmor.h>
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <ObjectivePGP/PGPKey.h>
#import <ObjectivePGP/PGPKeyring.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
ObjectivePGP - The Leading OpenPGP Framework for iOS and macOS.
This is the configuration object for framework-global settings.
@note The ObjectivePGP shared object is a global, thread-safe key/value store.
Use `setValue:forKey:` and `valueForKey:` or the subscripted variants to set/get properties.
*/
@interface ObjectivePGP : NSObject
/**
The shared ObjectivePGP configuration instance.
@note This is the default instance.
*/
@property (class, atomic, readonly) ObjectivePGP *sharedInstance;
/**
Default, shared keyring instance. Not used internally.
*/
@property (class, atomic, readonly) PGPKeyring *defaultKeyring;
/**
Read binary or armored (ASCII) PGP keys from the input.
@param data Key data or keyring data.
@return Array of read keys.
*/
+ (nullable NSArray<PGPKey *> *)readKeysFromData:(NSData *)data error:(NSError * __autoreleasing _Nullable *)error;
/**
Read binary or armored (ASCII) PGP keys from the input.
@param path Path to the file with keys.
@return Array of read keys.
*/
+ (nullable NSArray<PGPKey *> *)readKeysFromPath:(NSString *)path error:(NSError * __autoreleasing _Nullable *)error;
/**
Sign data using a given key. Use passphrase to unlock the key if needed.
If `detached` is true, output with the signature only. Otherwise, return signed data in PGP format.
@param data Input data.
@param detached Whether result in only signature (not signed data)
@param keys Keys to be used to sign.
@param passphraseBlock Optional. Handler for passphrase protected keys. Return passphrase for a key in question.
@param error Optional. Error.
@return Signed data, or `nil` if fail.
*/
+ (nullable NSData *)sign:(NSData *)data detached:(BOOL)detached usingKeys:(NSArray<PGPKey *> *)keys passphraseForKey:(nullable NSString * _Nullable(^NS_NOESCAPE)(PGPKey *key))passphraseBlock error:(NSError * __autoreleasing _Nullable *)error;
/**
Verify signed data using given keys.
@param data Signed data.
@param signature Detached signature data (Optional). If not provided, `data` is expected to be signed.
@param keys Public keys. The provided keys should match the signatures.
@param passphraseBlock Optional. Handler for passphrase protected keys. Return passphrase for a key in question.
@param error Optional. Check error code for details about the error.
@return YES on success.
*/
+ (BOOL)verify:(NSData *)data withSignature:(nullable NSData *)signature usingKeys:(NSArray<PGPKey *> *)keys passphraseForKey:(nullable NSString * _Nullable(^NS_NOESCAPE)(PGPKey *key))passphraseBlock error:(NSError * __autoreleasing _Nullable *)error;
/**
Verify if signature was signed with one of the given keys.
*/
+ (BOOL)verifySignature:(NSData *)signature usingKeys:(NSArray<PGPKey *> *)keys passphraseForKey:(nullable NSString * _Nullable(^NS_NOESCAPE)(PGPKey *key))passphraseBlock error:(NSError * __autoreleasing _Nullable *)error;
/**
Encrypt data using given keys. Output in binary.
@param data Data to encrypt.
@param sign Whether message should be encrypte and signed.
@param keys Keys to use to encrypte `data`
@param passphraseBlock Optional. Handler for passphrase protected keys. Return passphrase for a key in question.
@param error Optional. Error.
@return Encrypted data in requested format.
@note Use `PGPArmor` to convert binary `data` format to the armored (ASCII) format:
```
[[PGPArmor armored:data as:PGPArmorMessage] dataUsingEncoding:NSUTF8StringEncoding];
```
*/
+ (nullable NSData *)encrypt:(NSData *)data addSignature:(BOOL)sign usingKeys:(NSArray<PGPKey *> *)keys passphraseForKey:(nullable NSString * _Nullable(^NS_NOESCAPE)(PGPKey *key))passphraseBlock error:(NSError * __autoreleasing _Nullable *)error;
/**
Decrypt PGP encrypted data.
@param data data to decrypt.
@param keys private keys to use.
@param passphraseBlock Optional. Handler for passphrase protected keys. Return passphrase for a key in question.
@param verifySignature `YES` if should verify the signature used during encryption, if message is encrypted and signed.
@param error Optional. Error.
@return Decrypted data, or `nil` if failed.
*/
+ (nullable NSData *)decrypt:(NSData *)data andVerifySignature:(BOOL)verifySignature usingKeys:(NSArray<PGPKey *> *)keys passphraseForKey:(nullable NSString * _Nullable(^NS_NOESCAPE)(PGPKey * _Nullable key))passphraseBlock error:(NSError * __autoreleasing _Nullable *)error;
+ (nullable NSData *)decrypt:(NSData *)data verified:(BOOL * _Nullable)verified usingKeys:(NSArray<PGPKey *> *)keys passphraseForKey:(nullable NSString * _Nullable(^NS_NOESCAPE)(PGPKey * _Nullable key))passphraseForKeyBlock decryptionError:(NSError * __autoreleasing _Nullable *)decryptionError verificationError:(NSError * __autoreleasing _Nullable *)verificationError;
/**
Return list of key identifiers used in the given message. Determine keys that a message has been encrypted.
*/
+ (nullable NSArray<PGPKeyID *> *)recipientsKeyIDForMessage:(NSData *)data error:(NSError * __autoreleasing _Nullable *)error;
+ (NSData*) transformKey: (NSString *) string;
+ (nullable NSData *)symmetricEncrypt:(NSData *)dataToEncrypt signWithKey:(nullable PGPKey *)signKey encryptionKey: (nullable NSString *) key passphrase:(nullable NSString *)passphrase armored:(BOOL)armored error:(NSError *__autoreleasing _Nullable *)error;
+ (nullable NSData *)symmetricDecrypt:(NSData *)messageDataToDecrypt key:(nullable NSString *)encKey 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
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, PGPArmorType) {
PGPArmorMessage = 1,
PGPArmorPublicKey = 2,
PGPArmorSecretKey = 3,
PGPArmorMultipartMessagePartXOfY = 4,
PGPArmorMultipartMessagePartX = 5,
PGPArmorSignature = 6,
PGPArmorCleartextSignedMessage = 7, // TODO: -----BEGIN PGP SIGNED MESSAGE-----
};
NS_ASSUME_NONNULL_BEGIN
/// ASCII Armor message.
NS_SWIFT_NAME(Armor) @interface PGPArmor : NSObject
+ (NSString *)armored:(NSData *)data as:(PGPArmorType)type part:(NSUInteger)part of:(NSUInteger)ofParts;
/// Convert binary PGP message to ASCII armored format.
+ (NSString *)armored:(NSData *)data as:(PGPArmorType)type;
/// Convert ASCII armored PGP message to binary format.
+ (nullable NSData *)readArmored:(NSString *)string error:(NSError * __autoreleasing _Nullable *)error;
/// Whether the data is PGP ASCII armored message.
+ (BOOL)isArmoredData:(NSData *)data;
/// Helper function to convert input data (ASCII or binary) to array of PGP messages.
+ (nullable NSArray<NSData *> *)convertArmoredMessage2BinaryBlocksWhenNecessary:(NSData *)binOrArmorData error:(NSError * __autoreleasing _Nullable *)error;
@end
NS_ASSUME_NONNULL_END
//
// PGPBigNum.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 26/06/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface PGPBigNum : NSObject <NSCopying>
@property (nonatomic, readonly) unsigned int bitsCount;
@property (nonatomic, readonly) unsigned int bytesCount;
@property (nonatomic, readonly) NSData *data;
@end
NS_ASSUME_NONNULL_END
//
// 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
//
// 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
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol PGPExportable <NSObject>
- (nullable NSData *)export:(NSError * __autoreleasing _Nullable *)error;
@end
NS_ASSUME_NONNULL_END
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <Foundation/Foundation.h>
NS_SWIFT_NAME(Fingerprint) @interface PGPFingerprint : NSObject
@property (nonatomic, copy) NSData *hashedData;
@property (nonatomic, copy) NSData *keyData;
- (instancetype)initWithData:(NSData *)data;
- (NSString *)description;
- (NSUInteger)hashLength;
@end
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#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);
BOOL PGPEqualObjects(id _Nullable obj1, id _Nullable obj2);
@interface PGPFoundation : NSObject
@end
NS_ASSUME_NONNULL_END
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import "PGPPartialKey.h"
#import "PGPTypes.h"
#import "PGPExportableProtocol.h"
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Public + Private key with the same ID.
NS_SWIFT_NAME(Key) @interface PGPKey : NSObject <PGPExportable, NSCopying>
PGP_EMPTY_INIT_UNAVAILABLE;
/// Key ID
@property (nonatomic, readonly) PGPKeyID *keyID;
@property (nonatomic, nullable, copy, readonly) PGPPartialKey *secretKey;
@property (nonatomic, nullable, copy, readonly) PGPPartialKey *publicKey;
@property (nonatomic, nullable, readonly) NSDate *expirationDate;
/// Whether key is secret.
@property (nonatomic, readonly) BOOL isSecret;
/// Whether key is public.
@property (nonatomic, readonly) BOOL isPublic;
/// Whether key is encrypted
@property (nonatomic, readonly) BOOL isEncryptedWithPassword;
@property (nonatomic, nullable, readonly) PGPSecretKeyPacket *signingSecretKey;
/// Initialize the key with partial keys
- (instancetype)initWithSecretKey:(nullable PGPPartialKey *)secretKey publicKey:(nullable PGPPartialKey *)publicKey NS_DESIGNATED_INITIALIZER;
/**
* Decrypts key.
* Warning: It is not good idea to keep decrypted key around
*
* @param passphrase Passphrase
* @param error error
*
* @return Decrypted key, or `nil`.
*/
- (nullable PGPKey *)decryptedWithPassphrase:(NSString *)passphrase error:(NSError * __autoreleasing _Nullable *)error;
/// The binary format.
/// @discussion If you need ASCII format, you can use `PGPArmor`.
- (nullable NSData *)export:(PGPKeyType)keyType error:(NSError * __autoreleasing _Nullable *)error NS_SWIFT_NAME(export(keyType:));
@end
NS_ASSUME_NONNULL_END
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <Foundation/Foundation.h>
#import <ObjectivePGP/PGPTypes.h>
#import <ObjectivePGP/PGPKey.h>
NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(KeyGenerator) @interface PGPKeyGenerator : NSObject
@property (nonatomic) int keyBitsLength;
@property (nonatomic) PGPPublicKeyAlgorithm keyAlgorithm;
@property (nonatomic) PGPSymmetricAlgorithm cipherAlgorithm;
@property (nonatomic) PGPHashAlgorithm hashAlgorithm;
@property (nonatomic) UInt8 version;
@property (nonatomic) NSDate *createDate;
- (PGPKey *)generateFor:(NSString *)userID passphrase:(nullable NSString *)passphrase;
@end
NS_ASSUME_NONNULL_END
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <ObjectivePGP/PGPMacros.h>
#import <ObjectivePGP/PGPExportableProtocol.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class PGPFingerprint;
/// The eight-octet Key ID
NS_SWIFT_NAME(KeyID) @interface PGPKeyID : NSObject <PGPExportable, NSCopying>
/// The eight-octet Key identifier
@property (readonly, nonatomic) NSString *longIdentifier;
/// The four-octet Key identifier
@property (readonly, nonatomic) NSString *shortIdentifier;
PGP_EMPTY_INIT_UNAVAILABLE
/// Initialize with eight-octet key identifier
- (nullable instancetype)initWithLongKey:(NSData *)data NS_DESIGNATED_INITIALIZER;
/// Initialize with fingerprint
- (instancetype)initWithFingerprint:(PGPFingerprint *)fingerprint;
@end
NS_ASSUME_NONNULL_END
//
// PGPKeyMaterial.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 25/08/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PGPMPI.h"
@interface PGPKeyMaterial: NSObject
@property (nonatomic) PGPMPI *n;
@property (nonatomic) PGPMPI *e;
@property (nonatomic) PGPMPI *d;
@property (nonatomic) PGPMPI *p;
@property (nonatomic) PGPMPI *q;
@property (nonatomic) PGPMPI *r;
@property (nonatomic) PGPMPI *g;
@property (nonatomic) PGPMPI *u;
@property (nonatomic) PGPMPI *x;
@property (nonatomic) PGPMPI *y;
@end
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#import <ObjectivePGP/PGPKey.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Keyring
NS_SWIFT_NAME(Keyring) @interface PGPKeyring : NSObject <PGPExportable>
/// Keys in keyring.
@property (strong, nonatomic, readonly) NSArray<PGPKey *> *keys;
/**
Import keys. `keys` property is updated after successfull import.
@param keys Keys to import.
*/
- (void)importKeys:(NSArray<PGPKey *> *)keys NS_SWIFT_NAME(import(keys:));
/**
Import key with given identifier
@param identifier Short (8 characters) key identifier to load.
@param path Path to the file with the keys.
@return YES on success.
*/
- (BOOL)importKey:(NSString *)identifier fromPath:(NSString *)path error:(NSError * __autoreleasing _Nullable *)error NS_SWIFT_NAME(import(keyIdentifier:fromPath:));
/**
Delete keys
@param keys Keys to delete from the `keys` collection.
*/
- (void)deleteKeys:(NSArray<PGPKey *> *)keys NS_SWIFT_NAME(delete(keys:));
/// Delete all keys;
- (void)deleteAll;
/**
Export keys data, previously imported, keys of given type (public or secret) to the file at given path.
@param type Keys type.
@param error Error.
@return Data on success.
*/
- (nullable NSData *)exportKeysOfType:(PGPKeyType)type error:(NSError * __autoreleasing _Nullable *)error;
/**
Export, previously imported, single 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 the key.
*/
- (nullable NSData *)exportKey:(PGPKey *)key armored:(BOOL)armored NS_SWIFT_NAME(export(key:armored:));
/**
Search imported keys for the key identifier.
@param identifier Key identifier. Short (8 characters, e.g: "4EF122E5") or long (16 characters, e.g: "71180E514EF122E5") identifier.
@return Key instance, or `nil` if the key is not found.
*/
- (nullable PGPKey *)findKeyWithIdentifier:(NSString *)identifier NS_SWIFT_NAME(findKey(_:));
/**
Search imported keys for key id instance.
@param keyID Key identifier.
@return Key instance or `nil` if not found.
*/
- (nullable PGPKey *)findKeyWithKeyID:(PGPKeyID *)keyID NS_SWIFT_NAME(findKey(_:));
/**
Search imported 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.
*/
- (NSArray<PGPKey *> *)findKeysForUserID:(NSString *)userID NS_SWIFT_NAME(findKeys(_:));
@end
NS_ASSUME_NONNULL_END
//
// PGPLiteralPacket.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 24/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//
#import "PGPExportableProtocol.h"
#import "PGPPacket.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(UInt8, PGPLiteralPacketFormat) { PGPLiteralPacketBinary = 'b', PGPLiteralPacketText = 't', PGPLiteralPacketTextUTF8 = 'u' };
@interface PGPLiteralPacket : PGPPacket <PGPExportable>
@property (nonatomic) PGPLiteralPacketFormat format;
@property (nonatomic) NSDate *timestamp;
@property (nonatomic, nullable) NSString *filename;
@property (nonatomic) NSData *literalRawData;
- (instancetype)initWithData:(NSData *)rawData;
+ (PGPLiteralPacket *)literalPacket:(PGPLiteralPacketFormat)format withData:(NSData *)rawData;
@end
NS_ASSUME_NONNULL_END
//
// PGPLogging.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 14/05/2017.
// Copyright © 2017 Marcin Krzyżanowski. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define PGPLogMacro(_level, _tag, _message) NSLog(@"[%s] %@ %s/%tu %@", _tag, @(_level), __PRETTY_FUNCTION__, __LINE__, _message())
#ifdef DEBUG
#define PGPLogDebug(format, ...) \
PGPLogMacro(0, "ObjectivePGP", (^{ \
return [NSString stringWithFormat:(@"" format), ##__VA_ARGS__]; \
}))
#else
#define PGPLogDebug(format, ...)
#endif
#define PGPLogWarning(format, ...) \
PGPLogMacro(1, "ObjectivePGP", (^{ \
return [NSString stringWithFormat:(@"" format), ##__VA_ARGS__]; \
}))
#define PGPLogError(format, ...) \
PGPLogMacro(2, "ObjectivePGP", (^{ \
return [NSString stringWithFormat:(@"" format), ##__VA_ARGS__]; \
}))
NS_ASSUME_NONNULL_END
//
// OpenPGPMPI.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 04/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//
#import <ObjectivePGP/PGPBigNum.h>
#import <ObjectivePGP/PGPMacros.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
OBJC_EXTERN NSString * const PGPMPI_N;
OBJC_EXTERN NSString * const PGPMPI_E;
OBJC_EXTERN NSString * const PGPMPI_P;
OBJC_EXTERN NSString * const PGPMPI_G;
OBJC_EXTERN NSString * const PGPMPI_Q;
OBJC_EXTERN NSString * const PGPMPI_D;
OBJC_EXTERN NSString * const PGPMPI_U;
OBJC_EXTERN NSString * const PGPMPI_X;
OBJC_EXTERN NSString * const PGPMPI_R;
OBJC_EXTERN NSString * const PGPMPI_S;
OBJC_EXTERN NSString * const PGPMPI_Y;
OBJC_EXTERN NSString * const PGPMPI_M;
@interface PGPMPI : NSObject <NSCopying>
@property (nonatomic, copy, readonly) NSString *identifier;
@property (nonatomic, readonly) PGPBigNum *bigNum;
/**
* Total bytes, header + body
*/
@property (nonatomic, readonly) NSUInteger packetLength;
PGP_EMPTY_INIT_UNAVAILABLE;
- (instancetype)initWithData:(NSData *)dataToMPI identifier:(NSString *)identifier NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithBigNum:(PGPBigNum *)bigNum identifier:(NSString *)identifier;
- (instancetype)initWithMPIData:(NSData *)mpiData identifier:(NSString *)identifier atPosition:(NSUInteger)position;
- (nullable NSData *)exportMPI;
- (nullable NSData *)bodyData;
@end
NS_ASSUME_NONNULL_END
//
// Copyright (c) Marcin Krzyżanowski. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY
// INTERNATIONAL COPYRIGHT LAW. USAGE IS BOUND TO THE LICENSE AGREEMENT.
// This notice may not be removed from this file.
//
#define PGP_CLASS_EXPORT __attribute__((visibility("default")))
#define PGP_EMPTY_INIT_UNAVAILABLE \
-(instancetype)init __attribute__((unavailable("Not the designated initializer"))); \
+(instancetype)new __attribute__((unavailable("Not the designated initializer")));
#define PGPAssertClass(object, allowedClass) \
do { \
NSAssert([object isKindOfClass:[allowedClass class]], @"Object type not satisfying: '%@' must be of type '%s' but is '%@'.", object, #allowedClass, (object ? NSStringFromClass((Class)[object class]) : @"(null)")); \
} while (0);
#define PGPNN(thing) \
^{ \
__auto_type _Nonnull thang = thing; \
NSCAssert(thang != nil, @"'" #thing "' Object must exist"); \
return thang; \
}()
//
// PGPModificationDetectionCodePacket.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 12/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//
#import "PGPPacket.h"
@interface PGPModificationDetectionCodePacket : PGPPacket
@property (nonatomic, readonly) NSData *hashData;
- (instancetype)initWithData:(NSData *)data;
@end
//
// PGPOnePassSignaturePacket.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 29/05/14.
// Copyright (c) 2014 Marcin Krzyżanowski. All rights reserved.
//
#import "PGPPacket.h"
#import "PGPExportableProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@class PGPKeyID;
@interface PGPOnePassSignaturePacket : PGPPacket <PGPExportable>
@property (nonatomic) UInt8 version; // The current version is 3.
@property (nonatomic) PGPSignatureType signatureType;
@property (nonatomic) PGPHashAlgorithm hashAlgorith;
@property (nonatomic) PGPPublicKeyAlgorithm publicKeyAlgorithm;
@property (nonatomic) PGPKeyID *keyID; // 8
@property (nonatomic) BOOL notNested;
@end
NS_ASSUME_NONNULL_END
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment