Optimize encrypt attachment

This commit is contained in:
Kay Lukas 2018-10-26 15:08:49 +02:00
parent 0456595f68
commit 9dfb46fe45
24 changed files with 726 additions and 94 deletions

Binary file not shown.

1
dist/iOS/Crypto.framework/Crypto vendored Symbolic link
View file

@ -0,0 +1 @@
Versions/Current/Crypto

1
dist/iOS/Crypto.framework/Headers vendored Symbolic link
View file

@ -0,0 +1 @@
Versions/Current/Headers

1
dist/iOS/Crypto.framework/Modules vendored Symbolic link
View file

@ -0,0 +1 @@
Versions/Current/Modules

1
dist/iOS/Crypto.framework/Resources vendored Symbolic link
View file

@ -0,0 +1 @@
Versions/Current/Resources

Binary file not shown.

View file

@ -0,0 +1,42 @@
// Objective-C API for talking to gitlab.com/ProtonMail/go-pm-crypto/armor Go package.
// gobind -lang=objc gitlab.com/ProtonMail/go-pm-crypto/armor
//
// File is generated by gobind. Do not edit.
#ifndef __Armor_H__
#define __Armor_H__
@import Foundation;
#include "Universe.objc.h"
#include "Models.objc.h"
FOUNDATION_EXPORT NSString* const ArmorARMOR_HEADER_COMMENT;
FOUNDATION_EXPORT NSString* const ArmorARMOR_HEADER_VERSION;
FOUNDATION_EXPORT NSString* const ArmorMESSAGE_HEADER;
FOUNDATION_EXPORT NSString* const ArmorPRIVATE_KEY_HEADER;
FOUNDATION_EXPORT NSString* const ArmorPUBLIC_KEY_HEADER;
/**
* ArmorKey make bytes input key to armor format
*/
FOUNDATION_EXPORT NSString* ArmorArmorKey(NSData* input, NSError** error);
/**
* ArmorWithType make bytes input to armor format
*/
FOUNDATION_EXPORT NSString* ArmorArmorWithType(NSData* input, NSString* armorType, NSError** error);
/**
* ReadClearSignedMessage read clear message from a clearsign package
*/
FOUNDATION_EXPORT NSString* ArmorReadClearSignedMessage(NSString* signedMessage, NSError** error);
FOUNDATION_EXPORT ModelsEncryptedSplit* ArmorSplitArmor(NSString* encrypted, NSError** error);
/**
* Unarmor an armored key to bytes key
*/
FOUNDATION_EXPORT NSData* ArmorUnarmor(NSString* input, NSError** error);
#endif

View file

@ -0,0 +1,15 @@
// Objective-C API for talking to gitlab.com/ProtonMail/go-pm-crypto/constants Go package.
// gobind -lang=objc gitlab.com/ProtonMail/go-pm-crypto/constants
//
// File is generated by gobind. Do not edit.
#ifndef __Constants_H__
#define __Constants_H__
@import Foundation;
#include "Universe.objc.h"
FOUNDATION_EXPORT NSString* const ConstantsVERSION;
#endif

View file

@ -0,0 +1,21 @@
// Objective-C API for talking to the following Go packages
//
// gitlab.com/ProtonMail/go-pm-crypto/crypto
// gitlab.com/ProtonMail/go-pm-crypto/armor
// gitlab.com/ProtonMail/go-pm-crypto/constants
// gitlab.com/ProtonMail/go-pm-crypto/key
// gitlab.com/ProtonMail/go-pm-crypto/models
//
// File is generated by gomobile bind. Do not edit.
#ifndef __Crypto_FRAMEWORK_H__
#define __Crypto_FRAMEWORK_H__
#include "Crypto.objc.h"
#include "Armor.objc.h"
#include "Constants.objc.h"
#include "Key.objc.h"
#include "Models.objc.h"
#include "universe.objc.h"
#endif

View file

@ -0,0 +1,166 @@
// Objective-C API for talking to gitlab.com/ProtonMail/go-pm-crypto/crypto Go package.
// gobind -lang=objc gitlab.com/ProtonMail/go-pm-crypto/crypto
//
// File is generated by gobind. Do not edit.
#ifndef __Crypto_H__
#define __Crypto_H__
@import Foundation;
#include "Universe.objc.h"
#include "Armor.objc.h"
#include "Models.objc.h"
@class CryptoPmCrypto;
@class CryptoSignatureCollector;
@protocol CryptoMIMECallbacks;
@class CryptoMIMECallbacks;
@protocol CryptoMIMECallbacks <NSObject>
- (void)onAttachment:(NSString*)headers data:(NSData*)data;
- (void)onBody:(NSString*)body mimetype:(NSString*)mimetype;
- (void)onEncryptedHeaders:(NSString*)headers;
- (void)onError:(NSError*)err;
- (void)onVerified:(long)verified;
@end
/**
* PmCrypto structure to manage multiple address keys and user keys
Called PGP crypto because it cannot have the same name as the package by gomobile's ridiculous rules.
*/
@interface CryptoPmCrypto : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (instancetype)init;
- (NSString*)checkKey:(NSString*)pubKey error:(NSError**)error;
- (NSData*)decryptAttachment:(NSData*)keyPacket dataPacket:(NSData*)dataPacket privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
- (NSData*)decryptAttachmentBinKey:(NSData*)keyPacket dataPacket:(NSData*)dataPacket privateKeys:(NSData*)privateKeys passphrase:(NSString*)passphrase error:(NSError**)error;
- (NSData*)decryptAttachmentWithPassword:(NSData*)keyPacket dataPacket:(NSData*)dataPacket password:(NSString*)password error:(NSError**)error;
- (void)decryptMIMEMessage:(NSString*)encryptedText verifierKey:(NSData*)verifierKey privateKeys:(NSData*)privateKeys passphrase:(NSString*)passphrase callbacks:(id<CryptoMIMECallbacks>)callbacks verifyTime:(int64_t)verifyTime;
- (NSString*)decryptMessage:(NSString*)encryptedText privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
- (NSString*)decryptMessageBinKey:(NSString*)encryptedText privateKey:(NSData*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
- (ModelsDecryptSignedVerify*)decryptMessageVerify:(NSString*)encryptedText verifierKey:(NSString*)verifierKey privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase verifyTime:(int64_t)verifyTime error:(NSError**)error;
- (ModelsDecryptSignedVerify*)decryptMessageVerifyBinKey:(NSString*)encryptedText verifierKey:(NSData*)verifierKey privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase verifyTime:(int64_t)verifyTime error:(NSError**)error;
- (ModelsDecryptSignedVerify*)decryptMessageVerifyBinKeyPrivBinKeys:(NSString*)encryptedText verifierKey:(NSData*)verifierKey privateKeys:(NSData*)privateKeys passphrase:(NSString*)passphrase verifyTime:(int64_t)verifyTime error:(NSError**)error;
- (ModelsDecryptSignedVerify*)decryptMessageVerifyPrivBinKeys:(NSString*)encryptedText verifierKey:(NSString*)verifierKey privateKeys:(NSData*)privateKeys passphrase:(NSString*)passphrase verifyTime:(int64_t)verifyTime error:(NSError**)error;
- (NSString*)decryptMessageWithPassword:(NSString*)encrypted password:(NSString*)password error:(NSError**)error;
- (ModelsEncryptedSplit*)encryptAttachment:(NSData*)plainData fileName:(NSString*)fileName publicKey:(NSString*)publicKey error:(NSError**)error;
- (ModelsEncryptedSplit*)encryptAttachmentBinKey:(NSData*)plainData fileName:(NSString*)fileName publicKey:(NSData*)publicKey error:(NSError**)error;
- (NSString*)encryptAttachmentWithPassword:(NSData*)plainData password:(NSString*)password error:(NSError**)error;
- (NSString*)encryptMessage:(NSString*)plainText publicKey:(NSString*)publicKey privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase trim:(BOOL)trim error:(NSError**)error;
- (NSString*)encryptMessageBinKey:(NSString*)plainText publicKey:(NSData*)publicKey privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase trim:(BOOL)trim error:(NSError**)error;
- (NSString*)encryptMessageWithPassword:(NSString*)plainText password:(NSString*)password error:(NSError**)error;
- (NSString*)generateKey:(NSString*)userName domain:(NSString*)domain passphrase:(NSString*)passphrase keyType:(NSString*)keyType bits:(long)bits error:(NSError**)error;
- (NSString*)generateRSAKeyWithPrimes:(NSString*)userName domain:(NSString*)domain passphrase:(NSString*)passphrase bits:(long)bits primeone:(NSData*)primeone primetwo:(NSData*)primetwo primethree:(NSData*)primethree primefour:(NSData*)primefour error:(NSError**)error;
/**
* GetSessionFromKeyPacket get session key no encoding in and out
*/
- (ModelsSessionSplit*)getSessionFromKeyPacket:(NSData*)keyPackage privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
/**
* GetSessionFromKeyPacketBinkeys get session key no encoding in and out
*/
- (ModelsSessionSplit*)getSessionFromKeyPacketBinkeys:(NSData*)keyPackage privateKey:(NSData*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
/**
* GetSessionFromSymmetricPacket ...
*/
- (ModelsSessionSplit*)getSessionFromSymmetricPacket:(NSData*)keyPackage password:(NSString*)password error:(NSError**)error;
/**
* GetTime get latest cached time
*/
- (int64_t)getTime;
- (BOOL)isKeyExpired:(NSString*)publicKey ret0_:(BOOL*)ret0_ error:(NSError**)error;
- (BOOL)isKeyExpiredBin:(NSData*)publicKey ret0_:(BOOL*)ret0_ error:(NSError**)error;
/**
* KeyPacketWithPublicKey ...
*/
- (NSData*)keyPacketWithPublicKey:(ModelsSessionSplit*)sessionSplit publicKey:(NSString*)publicKey error:(NSError**)error;
/**
* KeyPacketWithPublicKeyBin ...
*/
- (NSData*)keyPacketWithPublicKeyBin:(ModelsSessionSplit*)sessionSplit publicKey:(NSData*)publicKey error:(NSError**)error;
/**
* RandomToken ...
*/
- (NSData*)randomToken:(NSError**)error;
/**
* RandomTokenWith ...
*/
- (NSData*)randomTokenWith:(long)size error:(NSError**)error;
/**
* SignBinDetached sign bin data
*/
- (NSString*)signBinDetached:(NSData*)plainData privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
/**
* SignBinDetachedBinKey ...
*/
- (NSString*)signBinDetachedBinKey:(NSData*)plainData privateKey:(NSData*)privateKey passphrase:(NSString*)passphrase error:(NSError**)error;
/**
* SignTextDetached sign detached text type
*/
- (NSString*)signTextDetached:(NSString*)plainText privateKey:(NSString*)privateKey passphrase:(NSString*)passphrase trim:(BOOL)trim error:(NSError**)error;
/**
* SignTextDetachedBinKey ...
*/
- (NSString*)signTextDetachedBinKey:(NSString*)plainText privateKey:(NSData*)privateKey passphrase:(NSString*)passphrase trim:(BOOL)trim error:(NSError**)error;
/**
* SymmetricKeyPacketWithPassword ...
*/
- (NSData*)symmetricKeyPacketWithPassword:(ModelsSessionSplit*)sessionSplit password:(NSString*)password error:(NSError**)error;
- (NSString*)updatePrivateKeyPassphrase:(NSString*)privateKey oldPassphrase:(NSString*)oldPassphrase newPassphrase:(NSString*)newPassphrase error:(NSError**)error;
/**
* UpdateTime update cached time
*/
- (void)updateTime:(int64_t)newTime;
/**
* VerifyBinSignDetached ...
*/
- (BOOL)verifyBinSignDetached:(NSString*)signature plainData:(NSData*)plainData publicKey:(NSString*)publicKey verifyTime:(int64_t)verifyTime ret0_:(BOOL*)ret0_ error:(NSError**)error;
/**
* VerifyBinSignDetachedBinKey ...
*/
- (BOOL)verifyBinSignDetachedBinKey:(NSString*)signature plainData:(NSData*)plainData publicKey:(NSData*)publicKey verifyTime:(int64_t)verifyTime ret0_:(BOOL*)ret0_ error:(NSError**)error;
/**
* VerifyTextSignDetached ...
*/
- (BOOL)verifyTextSignDetached:(NSString*)signature plainText:(NSString*)plainText publicKey:(NSString*)publicKey verifyTime:(int64_t)verifyTime ret0_:(BOOL*)ret0_ error:(NSError**)error;
/**
* VerifyTextSignDetachedBinKey ...
*/
- (BOOL)verifyTextSignDetachedBinKey:(NSString*)signature plainText:(NSString*)plainText publicKey:(NSData*)publicKey verifyTime:(int64_t)verifyTime ret0_:(BOOL*)ret0_ error:(NSError**)error;
@end
@interface CryptoSignatureCollector : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (instancetype)init;
// skipped method SignatureCollector.Accept with unsupported parameter or return types
- (NSString*)getSignature;
@end
@class CryptoMIMECallbacks;
/**
* define call back interface
*/
@interface CryptoMIMECallbacks : NSObject <goSeqRefInterface, CryptoMIMECallbacks> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (void)onAttachment:(NSString*)headers data:(NSData*)data;
- (void)onBody:(NSString*)body mimetype:(NSString*)mimetype;
/**
* Encrypted headers can be an attachment and thus be placed at the end of the mime structure
*/
- (void)onEncryptedHeaders:(NSString*)headers;
- (void)onError:(NSError*)err;
- (void)onVerified:(long)verified;
@end
#endif

View file

@ -0,0 +1,39 @@
// Objective-C API for talking to gitlab.com/ProtonMail/go-pm-crypto/key Go package.
// gobind -lang=objc gitlab.com/ProtonMail/go-pm-crypto/key
//
// File is generated by gobind. Do not edit.
#ifndef __Key_H__
#define __Key_H__
@import Foundation;
#include "Universe.objc.h"
#include "Armor.objc.h"
/**
* CheckPassphrase check is private key passphrase ok
*/
FOUNDATION_EXPORT BOOL KeyCheckPassphrase(NSString* privateKey, NSString* passphrase);
/**
* GetFingerprint get a armored public key fingerprint
*/
FOUNDATION_EXPORT NSString* KeyGetFingerprint(NSString* publicKey, NSError** error);
/**
* GetFingerprintBinKey get a unarmored public key fingerprint
*/
FOUNDATION_EXPORT NSString* KeyGetFingerprintBinKey(NSData* publicKey, NSError** error);
/**
* PublicKey get a public key from a private key
*/
FOUNDATION_EXPORT NSString* KeyPublicKey(NSString* privateKey, NSError** error);
/**
* PublicKeyBinOut get a public key from a private key
*/
FOUNDATION_EXPORT NSData* KeyPublicKeyBinOut(NSString* privateKey, NSError** error);
#endif

View file

@ -0,0 +1,91 @@
// Objective-C API for talking to gitlab.com/ProtonMail/go-pm-crypto/models Go package.
// gobind -lang=objc gitlab.com/ProtonMail/go-pm-crypto/models
//
// File is generated by gobind. Do not edit.
#ifndef __Models_H__
#define __Models_H__
@import Foundation;
#include "Universe.objc.h"
@class ModelsDecryptSignedVerify;
@class ModelsEncryptedSigned;
@class ModelsEncryptedSplit;
@class ModelsSessionSplit;
/**
* DecryptSignedVerify decrypt_sign_verify
*/
@interface ModelsDecryptSignedVerify : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (instancetype)init;
/**
* clear text
*/
- (NSString*)plaintext;
- (void)setPlaintext:(NSString*)v;
/**
* bitmask verify status : 0
*/
- (long)verify;
- (void)setVerify:(long)v;
/**
* error message if verify failed
*/
- (NSString*)message;
- (void)setMessage:(NSString*)v;
@end
/**
* EncryptedSigned encrypt_sign_package
*/
@interface ModelsEncryptedSigned : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (instancetype)init;
- (NSString*)encrypted;
- (void)setEncrypted:(NSString*)v;
- (NSString*)signature;
- (void)setSignature:(NSString*)v;
@end
/**
* EncryptedSplit when encrypt attachemt
*/
@interface ModelsEncryptedSplit : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (instancetype)init;
- (NSData*)dataPacket;
- (void)setDataPacket:(NSData*)v;
- (NSData*)keyPacket;
- (void)setKeyPacket:(NSData*)v;
- (NSString*)algo;
- (void)setAlgo:(NSString*)v;
@end
/**
* SessionSplit split session
*/
@interface ModelsSessionSplit : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (instancetype)init;
- (NSData*)session;
- (void)setSession:(NSData*)v;
- (NSString*)algo;
- (void)setAlgo:(NSString*)v;
@end
#endif

View file

@ -0,0 +1,35 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef __GO_REF_HDR__
#define __GO_REF_HDR__
#include <Foundation/Foundation.h>
// GoSeqRef is an object tagged with an integer for passing back and
// forth across the language boundary. A GoSeqRef may represent either
// an instance of a Go object, or an Objective-C object passed to Go.
// The explicit allocation of a GoSeqRef is used to pin a Go object
// when it is passed to Objective-C. The Go seq package maintains a
// reference to the Go object in a map keyed by the refnum along with
// a reference count. When the reference count reaches zero, the Go
// seq package will clear the corresponding entry in the map.
@interface GoSeqRef : NSObject {
}
@property(readonly) int32_t refnum;
@property(strong) id obj; // NULL when representing a Go object.
// new GoSeqRef object to proxy a Go object. The refnum must be
// provided from Go side.
- (instancetype)initWithRefnum:(int32_t)refnum obj:(id)obj;
- (int32_t)incNum;
@end
@protocol goSeqRefInterface
-(GoSeqRef*) _ref;
@end
#endif

View file

@ -0,0 +1,28 @@
// Objective-C API for talking to Go package.
// gobind -lang=objc
//
// File is generated by gobind. Do not edit.
#ifndef __Universe_H__
#define __Universe_H__
@import Foundation;
@protocol Universeerror;
@class Universeerror;
@protocol Universeerror <NSObject>
- (NSString*)error;
@end
@class Universeerror;
@interface Universeerror : NSError <goSeqRefInterface, Universeerror> {
}
@property(strong, readonly) id _ref;
- (instancetype)initWithRef:(id)ref;
- (NSString*)error;
@end
#endif

View file

@ -0,0 +1,12 @@
framework module "Crypto" {
header "ref.h"
header "Crypto.objc.h"
header "Armor.objc.h"
header "Constants.objc.h"
header "Key.objc.h"
header "Models.objc.h"
header "universe.objc.h"
header "Crypto.h"
export *
}

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

View file

@ -0,0 +1 @@
A