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

remove files

parent 693ac87e
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 906 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 key.
@param data Signed data.
@param detached 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 *)detached 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;
/**
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
//
// 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 "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>
NS_ASSUME_NONNULL_BEGIN
@class PGPKey;
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
//
// 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
//
// 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; \
}()
//
// 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 "PGPExportableProtocol.h"
#import "PGPKeyID.h"
#import "PGPTypes.h"
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, PGPKeyType) {
PGPKeyTypeUnknown = 0,
PGPKeyTypeSecret = 1,
PGPKeyTypePublic = 2
};
@class PGPPacket, PGPSignaturePacket, PGPUser, PGPSecretKeyPacket, PGPPartialSubKey;
/// Single Private or Public key.
NS_SWIFT_NAME(PartialKey) @interface PGPPartialKey : NSObject <PGPExportable, NSCopying>
@property (nonatomic, readonly) PGPKeyType type;
@property (nonatomic, copy) PGPPacket *primaryKeyPacket;
@property (nonatomic, copy) NSArray<PGPUser *> *users;
@property (nonatomic, copy, readonly) NSArray<PGPPartialSubKey *> *subKeys;
@property (nonatomic, copy, readonly) NSArray<PGPSignaturePacket *> *directSignatures;
@property (nonatomic, nullable, copy, readonly) PGPSignaturePacket *revocationSignature;
@property (nonatomic, readonly) BOOL isEncryptedWithPassword; // calculated
@property (nonatomic, nullable, readonly) NSDate *expirationDate; // calculated
@property (nonatomic, readonly) PGPKeyID *keyID; // calculated
@property (nonatomic, readonly) PGPFingerprint *fingerprint; // calculated
PGP_EMPTY_INIT_UNAVAILABLE;
- (instancetype)initWithPackets:(NSArray<PGPPacket *> *)packets NS_DESIGNATED_INITIALIZER;
/**
* Decrypts all secret key and subkey packets
* Warning: It is not good idea to keep decrypted key around
*
* @param passphrase Passphrase
* @param error error
*
* @return Decrypted key, or `nil`.
*/
- (nullable PGPPartialKey *)decryptedWithPassphrase:(NSString *)passphrase error:(NSError * __autoreleasing _Nullable *)error;
/**
* Signing key packet
*
* @return PGPSecureKeyPacket that can be used to signing
*/
@property (nonatomic, nullable, readonly) PGPPacket *signingKeyPacket;
- (nullable PGPPacket *)signingKeyPacketWithKeyID:(PGPKeyID *)keyID;
- (nullable PGPPacket *)encryptionKeyPacket:(NSError * __autoreleasing *)error;
- (nullable PGPSecretKeyPacket *)decryptionPacketForKeyID:(PGPKeyID *)keyID error:(NSError * __autoreleasing *)error;
- (NSArray<PGPPacket *> *)allKeyPackets;
- (PGPSymmetricAlgorithm)preferredSymmetricAlgorithm;
+ (PGPSymmetricAlgorithm)preferredSymmetricAlgorithmForKeys:(NSArray<PGPPartialKey *> *)keys;
-(instancetype)copyWithZone:(nullable NSZone *)zone NS_REQUIRES_SUPER;
@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/PGPPartialKey.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface PGPPartialSubKey : PGPPartialKey <NSCopying>
PGP_EMPTY_INIT_UNAVAILABLE
- (instancetype)initWithPackets:(NSArray<PGPPacket *> *)packets __attribute__((unavailable("Not the designated initializer")));
- (instancetype)initWithPacket:(PGPPacket *)packet NS_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly) PGPKeyID *keyID;
- (NSArray<PGPPacket *> *)allPackets;
@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>
#ifndef NS_DESIGNATED_INITIALIZER
#define NS_DESIGNATED_INITIALIZER
#endif
#define PGP_NOESCAPE __attribute__((noescape))
static const UInt32 PGPUnknownLength = UINT32_MAX;
static NSString *const PGPErrorDomain = @"com.objectivepgp";
typedef NS_ERROR_ENUM(PGPErrorDomain, PGPErrorCode) {
PGPErrorGeneral = -1,
PGPErrorPassphraseRequired = 5,
PGPErrorPassphraseInvalid = 6,
/// Invalid signature. Signature is invalid or cannot be verified (eg. missing key)
PGPErrorInvalidSignature = 7,
/// The message is not signed.
PGPErrorNotSigned = 8,
/// Invalid PGP message. Invalid or corrupted data that can't be processed.
PGPErrorInvalidMessage = 9,
PGPErrorMissingSignature = 10,
PGPErrorNotFound = 11
};
typedef NS_ENUM(NSInteger, PGPFormatType) {
PGPFormatUnknown = 0,
PGPFormatOld = 1,
PGPFormatNew = 2
};
typedef NS_ENUM(NSUInteger, PGPHeaderPacketTag) {
PGPHeaderPacketTagNewFormat = 0x40,
PGPHeaderPacketTagAllwaysSet = 0x80
};
typedef NS_ENUM(UInt8, PGPPacketTag) {
PGPInvalidPacketTag = 0,
PGPPublicKeyEncryptedSessionKeyPacketTag = 1,
PGPSignaturePacketTag = 2,
PGPSymetricKeyEncryptedSessionKeyPacketTag = 3,
PGPOnePassSignaturePacketTag = 4,
PGPSecretKeyPacketTag = 5,
PGPPublicKeyPacketTag = 6,
PGPSecretSubkeyPacketTag = 7,
PGPCompressedDataPacketTag = 8,
PGPSymmetricallyEncryptedDataPacketTag = 9,
PGPMarkerPacketTag = 10, // Ignored (Obsolete Literal Packet)
PGPLiteralDataPacketTag = 11,
PGPTrustPacketTag = 12,
PGPUserIDPacketTag = 13,
PGPPublicSubkeyPacketTag = 14,
PGPUserAttributePacketTag = 17,
PGPSymmetricallyEncryptedIntegrityProtectedDataPacketTag = 18,
PGPModificationDetectionCodePacketTag = 19,
};
typedef NS_ENUM(UInt8, PGPUserAttributeSubpacketType) {
PGPUserAttributeSubpacketImage = 0x01 // The only currently defined subpacket type is 1, signifying an image.
};
// 9.1. Public-Key Algorithms
typedef NS_ENUM(UInt8, PGPPublicKeyAlgorithm) {
PGPPublicKeyAlgorithmRSA = 1,
PGPPublicKeyAlgorithmRSAEncryptOnly = 2,
PGPPublicKeyAlgorithmRSASignOnly = 3,
PGPPublicKeyAlgorithmElgamal = 16, // Elgamal (Encrypt-Only)
PGPPublicKeyAlgorithmDSA = 17,
PGPPublicKeyAlgorithmElliptic = 18,
PGPPublicKeyAlgorithmECDSA = 19,
PGPPublicKeyAlgorithmElgamalEncryptorSign = 20, // Deprecated ?
PGPPublicKeyAlgorithmDiffieHellman = 21, // TODO: Deprecated?
PGPPublicKeyAlgorithmPrivate1 = 100,
PGPPublicKeyAlgorithmPrivate2 = 101,
PGPPublicKeyAlgorithmPrivate3 = 102,
PGPPublicKeyAlgorithmPrivate4 = 103,
PGPPublicKeyAlgorithmPrivate5 = 104,
PGPPublicKeyAlgorithmPrivate6 = 105,
PGPPublicKeyAlgorithmPrivate7 = 106,
PGPPublicKeyAlgorithmPrivate8 = 107,
PGPPublicKeyAlgorithmPrivate9 = 108,
PGPPublicKeyAlgorithmPrivate10 = 109,
PGPPublicKeyAlgorithmPrivate11 = 110
};
// 9.2. Symmetric-Key Algorithms
typedef NS_ENUM(UInt8, PGPSymmetricAlgorithm) {
PGPSymmetricPlaintext = 0,
PGPSymmetricIDEA = 1, // 8 bytes (64-bit) block size, key length: 2 bytes (16 bit)
PGPSymmetricTripleDES = 2, // 8 bytes (64-bit) block size
PGPSymmetricCAST5 = 3, // aka CAST-128 is a symmetric block cipher with a block-size of 8 bytes (64bit) and a variable key-size of up to 16 bytes (128 bits).
PGPSymmetricBlowfish = 4, // 8 bytes (64 bit) block size, key length: 16 bits (4-56 bits)
PGPSymmetricAES128 = 7, // 16 bytes (128 bit), key length 128 bit
PGPSymmetricAES192 = 8, // 16 bytes (128 bit), key length 192 bit
PGPSymmetricAES256 = 9, // 16 bytes (128 bit), key length 256 bit
PGPSymmetricTwofish256 = 10, // 16 bytes (128 bit)
PGPSymmetricMax
};
// 9.4. Hash Algorithms
typedef NS_ENUM(UInt8, PGPHashAlgorithm) {
PGPHashUnknown = 0,
PGPHashMD5 = 1, // MD5 - deprecated
PGPHashSHA1 = 2, // SHA1 - required
PGPHashRIPEMD160 = 3, // RIPEMD160
PGPHashSHA256 = 8, // SHA256
PGPHashSHA384 = 9, // SHA384
PGPHashSHA512 = 10, // SHA512
PGPHashSHA224 = 11 // SHA224
};
typedef NS_ENUM(UInt8, PGPSignatureType) {
PGPSignatureBinaryDocument = 0x00,
PGPSignatureCanonicalTextDocument = 0x01,
PGPSignatureStandalone = 0x02,
PGPSignatureGenericCertificationUserIDandPublicKey = 0x10, // Self-Signature
PGPSignaturePersonalCertificationUserIDandPublicKey = 0x11, // Self-Signature
PGPSignatureCasualCertificationUserIDandPublicKey = 0x12, // Self-Signature
PGPSignaturePositiveCertificationUserIDandPublicKey = 0x13, // Self-Signature
PGPSignatureSubkeyBinding = 0x18, // Self-Signature
PGPSignaturePrimaryKeyBinding = 0x19,
PGPSignatureDirectlyOnKey = 0x1F, // 0x1F: Signature directly on a key (key) - Self-Signature
PGPSignatureKeyRevocation = 0x20, // 0x20: Key revocation signature (key_revocation)
PGPSignatureSubkeyRevocation = 0x28, // 0x28: Subkey revocation signature (subkey_revocation)
PGPSignatureCertificationRevocation = 0x30, // 0x30: Certification revocation signature (cert_revocation)
PGPSignatureTimestamp = 0x40,
PGPSignature3PartyConfirmation = 0x50,
PGPSignatureUnknown = 0xFF
};
typedef NS_ENUM(UInt8, PGPSignatureSubpacketType) {
PGPSignatureSubpacketTypeUnknown = 0, // Unknown
PGPSignatureSubpacketTypeSignatureCreationTime = 2,
PGPSignatureSubpacketTypeSignatureExpirationTime = 3,
PGPSignatureSubpacketTypeExportableCertification = 4,
PGPSignatureSubpacketTypeTrustSignature = 5, // TODO
PGPSignatureSubpacketTypeRegularExpression = 6, // TODO
PGPSignatureSubpacketTypeRevocable = 7, // TODO
PGPSignatureSubpacketTypeKeyExpirationTime = 9,
PGPSignatureSubpacketTypePreferredSymetricAlgorithm = 11,
PGPSignatureSubpacketTypeRevocationKey = 12, // TODO
PGPSignatureSubpacketTypeIssuerKeyID = 16,
PGPSignatureSubpacketTypeNotationData = 20, // TODO
PGPSignatureSubpacketTypePreferredHashAlgorithm = 21,
PGPSignatureSubpacketTypePreferredCompressionAlgorithm = 22,
PGPSignatureSubpacketTypeKeyServerPreference = 23,
PGPSignatureSubpacketTypePreferredKeyServer = 24,
PGPSignatureSubpacketTypePrimaryUserID = 25,
PGPSignatureSubpacketTypePolicyURI = 26,
PGPSignatureSubpacketTypeKeyFlags = 27,
PGPSignatureSubpacketTypeSignerUserID = 28,
PGPSignatureSubpacketTypeReasonForRevocation = 29,
PGPSignatureSubpacketTypeFeatures = 30,
PGPSignatureSubpacketTypeSignatureTarget = 31, // Seems unused at all
PGPSignatureSubpacketTypeEmbeddedSignature = 32,
PGPSignatureSubpacketTypeIssuerFingerprint = 33 // TODO: Experimental: Issuer fingerprint
};
// 5.2.3.21. Key Flags
typedef NS_ENUM(UInt8, PGPSignatureFlags) {
PGPSignatureFlagUnknown = 0x00,
PGPSignatureFlagAllowCertifyOtherKeys = 0x01, // indicates that this key may be used to certify other keys
PGPSignatureFlagAllowSignData = 0x02, // indicates that this key may be used to sign data.
PGPSignatureFlagAllowEncryptCommunications = 0x04, // indicates that this key may be used to encrypt communication.
PGPSignatureFlagAllowEncryptStorage = 0x08, // indicates that this key may be used to encrypt storage.
PGPSignatureFlagSecretComponentMayBeSplit = 0x10, // indicates that the secret components of this key may have been split using a secret-sharing mechanism.
PGPSignatureFlagAllowAuthentication = 0x20, // indicates that this key may be used for authentication.
PGPSignatureFlagPrivateKeyMayBeInThePossesionOfManyPersons = 0x80 // indicates that the secret components of this key may be in the possession of more than one person.
};
// 5.2.3.17. Key Server Preferences
typedef NS_ENUM(UInt8, PGPKeyServerPreferenceFlags) {
PGPKeyServerPreferenceUnknown = 0x00,
PGPKeyServerPreferenceNoModify = 0x80 // No-modify
};
// 5.2.3.24. Features
typedef NS_ENUM(UInt8, PGPFeature) {
PGPFeatureModificationUnknown = 0x00,
PGPFeatureModificationDetection = 0x01 // Modification Detection (packets 18 and 19)
};
// 3.7.1. String-to-Key (S2K) Specifier Types
typedef NS_ENUM(UInt8, PGPS2KSpecifier) {
PGPS2KSpecifierSimple = 0,
PGPS2KSpecifierSalted = 1,
PGPS2KSpecifierIteratedAndSalted = 3,
// GNU extensions to the S2K algorithm.
// see: https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=8ead6a8f5250656f72aea99042f392cb6749b8ff;hb=refs/heads/master#l1309
// The "gnu-dummy S2K" is the marker which will tell that this file does *not* actually contain the secret key.
PGPS2KSpecifierGnuDummy = 101,
// TODO: gnu-divert-to-card S2K
PGPS2KSpecifierDivertToCard = 102
};
typedef NS_ENUM(UInt8, PGPS2KUsage) {
PGPS2KUsageNonEncrypted = 0, // no passphrase
PGPS2KUsageEncryptedAndHashed = 254,
PGPS2KUsageEncrypted = 255
};
// 9.3. Compression Algorithms
typedef NS_ENUM(UInt8, PGPCompressionAlgorithm) {
PGPCompressionUncompressed = 0,
PGPCompressionZIP = 1,
PGPCompressionZLIB = 2,
PGPCompressionBZIP2 = 3
};
//
// 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 <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(User) @interface PGPUser : NSObject <NSCopying>
@property (nonatomic, copy) NSString *userID;
@property (nonatomic, nullable) NSData *image;
PGP_EMPTY_INIT_UNAVAILABLE
@end
NS_ASSUME_NONNULL_END
File deleted
The ObjectivePGP stays under a dual license:
====================================================================
Free for non-commercial use:
Copyright (C) 2014-2017, Marcin Krzyżanowski All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================
Paid for commercial use:
Commercial-use license to use in commercial products. Please contact me via email (marcin@krzyzanowskim.com) for details.
\ No newline at end of file
framework module ObjectivePGP {
umbrella header "ObjectivePGP.h"
export *
module * { export * }
}
File deleted
//
// 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
@interface NSMutableArray <ObjectType> (PGPUtils)
- (void)pgp_addObject:(nullable ObjectType)anObject;
@end
@interface NSArray <ObjectType> (PGPUtils)
- (NSArray<ObjectType> *)pgp_objectsPassingTest:(BOOL (^)(ObjectType obj, BOOL *stop))predicate;
@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 "PGPTypes.h"
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSData (PGPUtils)
- (UInt16)pgp_Checksum;
- (UInt32)pgp_CRC24;
- (NSData *)pgp_MD5;
- (NSData *)pgp_SHA1;
- (NSData *)pgp_SHA224;
- (NSData *)pgp_SHA256;
- (NSData *)pgp_SHA384;
- (NSData *)pgp_SHA512;
- (NSData *)pgp_RIPEMD160;
+ (NSData *)xor:(NSData *)d1 d2:(NSData *)d2;
+ (NSData *)dataWithValue:(NSValue *)value;
- (NSData *)pgp_HashedWithAlgorithm:(PGPHashAlgorithm)hashAlgorithm;
@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