Skip to content

Commit

Permalink
Update to GPG Suite 2018.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Oct 24, 2018
1 parent 9082027 commit 1a7d138
Show file tree
Hide file tree
Showing 11 changed files with 328 additions and 10 deletions.
9 changes: 9 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Libmacgpg-free

Libmacgpg-free is a drop-in-replacement for [GPG Suite](https://gpgtools.org) Libmacgpg removing the paywall.

Tested with GPG-Suite 2018.4 and 2018.5

Build
-----
Expand All @@ -28,3 +29,11 @@ make
sudo cp ./build/Release/org.gpgtools.Libmacgpg.xpc/Contents/MacOS/org.gpgtools.Libmacgpg /Library/Application\ Support/GPGTools/org.gpgtools.Libmacgpg.xpc/Contents/MacOS
sudo chmod 755 /Library/Application\ Support/GPGTools/org.gpgtools.Libmacgpg.xpc/Contents/MacOS/org.gpgtools.Libmacgpg
```

Restart your computer or at least restart the XPC `org.gpgtools.Libmacgpg.xpc`:
```bash
sudo launchctl stop org.gpgtools.Libmacgpg.xpc
sudo launchctl start org.gpgtools.Libmacgpg.xpc
```

...or eventully kill the org.gpgtools.Libmacgpg.xpc process.
83 changes: 82 additions & 1 deletion Source/GPGController.m
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,76 @@ - (NSData *)decryptData:(NSData *)data {
return retVal;
}

- (GPGMemoryStream *)packetWithSignature:(GPGStream *)signature clearText:(NSData *)clearText {
GPGPacketParser *parser = [[[GPGPacketParser alloc] initWithStream:signature] autorelease];
GPGSignaturePacket *packet = (GPGSignaturePacket *)[parser nextPacket];

if (packet.tag != GPGSignaturePacketTag) {
return nil;
}

uint8 onePassSig[15];
onePassSig[0] = 0x90; // One-Pass Signature Packet. Tag 4.
onePassSig[1] = 0x0D; // Length.
onePassSig[2] = 0x03; // Version 3.
onePassSig[3] = (uint8)packet.type;
onePassSig[4] = (uint8)packet.hashAlgorithm;
onePassSig[5] = (uint8)packet.publicAlgorithm;
const char *keyID = packet.keyID.UTF8String;
onePassSig[6] = (uint8)hexToByte(keyID);
onePassSig[7] = (uint8)hexToByte(keyID+2);
onePassSig[8] = (uint8)hexToByte(keyID+4);
onePassSig[9] = (uint8)hexToByte(keyID+6);
onePassSig[10] = (uint8)hexToByte(keyID+8);
onePassSig[11] = (uint8)hexToByte(keyID+10);
onePassSig[12] = (uint8)hexToByte(keyID+12);
onePassSig[13] = (uint8)hexToByte(keyID+14);
onePassSig[14] = 1; // Last of this type.


uint8 literal[12];
NSUInteger length = clearText.length + 6;
literal[0] = 0xCB; // Literal Data Packet. Tag 11.
literal[1] = 0xFF; // Length encoded with 4 bytes.
literal[2] = (length >> 24) & 0xFF;
literal[3] = (length >> 16) & 0xFF;
literal[4] = (length >> 8) & 0xFF;
literal[5] = length & 0xFF;
literal[6] = packet.type == 1 ? 't' : 'b'; // Binary or text.
literal[7] = 0; // No filename.
literal[8] = 0; // No Date (4 bytes).
literal[9] = 0;
literal[10] = 0;
literal[11] = 0;


NSMutableData *packetData = [NSMutableData data];
[packetData appendBytes:onePassSig length:15];
[packetData appendBytes:literal length:12];
[packetData appendData:clearText];
[packetData appendData:signature.readAllData];

return [GPGMemoryStream memoryStreamForReading:packetData];
}

- (void)decryptTo:(GPGStream *)output data:(GPGStream *)input {
@try {
input = [GPGUnArmor unArmor:input];
NSData *clearText = nil;
input = [GPGUnArmor unArmor:input clearText:&clearText];

if (clearText != nil) {
// Build a new package for the clear-signed message.
// Other possible solutions:
// a. Do not unarmor clear-sigend messages. Drawback: Malformed messages can't be nadled.
// b. Call verify and set clearText as decrypted content. Verify if this is secure!
// c. Use this solution.

GPGStream *packet = [self packetWithSignature:input clearText:clearText];
if (packet) {
input = packet;
}
}


self.gpgTask = [GPGTask gpgTask];
[self addArgumentsForOptions];
Expand Down Expand Up @@ -724,6 +791,20 @@ - (NSString *)generateNewKeyWithName:(NSString *)name email:(NSString *)email co
}
}

if (comment.length == 0 && name.length > 1) {
NSRange firstBracket = [name rangeOfString:@"("];
NSRange lastBracket = [name rangeOfString:@")" options:NSBackwardsSearch];

if (firstBracket.location != NSNotFound && lastBracket.location != NSNotFound && firstBracket.location < lastBracket.location) {
// The Name contains a part between brackets. Append an empty comment so the brackets are not treated as a comment.
NSString *append = @"()";
if ([name characterAtIndex:name.length - 1] != ' ') {
append = @" ()";
}
name = [name stringByAppendingString:append];
}
}

if (name.length > 0) {
[cmdText appendFormat:@"Name-Real: %@\n", name];
}
Expand Down
5 changes: 5 additions & 0 deletions Source/GPGOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ - (void)setSpecialValue:(id)value forKey:(NSString *)key {

[self setValueInGPGAgentConf:defaultCacheTtl forKey:@"default-cache-ttl"];
[self setValueInGPGAgentConf:maxCacheTtl forKey:@"max-cache-ttl"];
[self setValueInGPGAgentConf:defaultCacheTtl forKey:@"default-cache-ttl-ssh"];
[self setValueInGPGAgentConf:maxCacheTtl forKey:@"max-cache-ttl-ssh"];
} else if ([key isEqualToString:@"keyserver"]) {
self.keyserver = value;
}
Expand Down Expand Up @@ -819,6 +821,9 @@ + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
affectingKey = @"trust-model";
} else if ([key isEqualToString:@"PassphraseCacheTime"]) {
affectingKey = @"default-cache-ttl";
affectingKey = @"default-cache-ttl-ssh";
affectingKey = @"max-cache-ttl";
affectingKey = @"max-cache-ttl-ssh";
}
}
if (affectingKey) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ FOUNDATION_EXPORT const unsigned char GSPaddleVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <GSPaddle/PublicHeader.h>
#import <Paddle/Paddle.h>
#import <GSPaddle/Paddle+CustomBundleIdentifier.h>
#import <GSPaddle/GSPaddleErrorCodes.h>
#import <GSPaddle/PADApi+GSPaddle.h>

// Recereate missing headers for PaddleAnalytics to disable Analytics.

@interface PaddleAnalyticsKit : NSObject

+ (void)disableTracking;
+ (BOOL)isOptedIn;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// GSPaddleErrorCodes.h
// GSPaddle
//
// Created by Lukas Pitschl on 27.09.18.
// Copyright © 2018 Lukas Pitschl. All rights reserved.
//

#ifndef GSPaddleErrorCodes_h
#define GSPaddleErrorCodes_h

typedef enum {
GSPaddleErrorCodeNetworkError = 99,
GSPaddleErrorCodeActivationCodeNotFound = 100,
GSPaddleErrorCodeActivationCodeAlreadyUsed = 104
} GSPaddleErrorCodes;

#endif /* GSPaddleErrorCodes_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// PADApi+GSPaddle.h
// GSPaddle
//
// Created by Lukas Pitschl on 27.09.18.
// Copyright © 2018 Lukas Pitschl. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface PADApi_GSPaddle : NSObject

@end

@interface Paddle (GSPaddleMore)

- (NSError *)activationErrorForActivationCode:(NSString *)activationCode;
- (void)setActivationError:(NSError *)error forActivationCode:(NSString *)activationCode;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?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>
<key>files</key>
<dict>
<key>Resources/Info.plist</key>
<data>
6Rq8gyvwJGgu6d+s0qoEM2vG/m8=
</data>
</dict>
<key>files2</key>
<dict>
<key>Headers/GSPaddle.h</key>
<dict>
<key>hash2</key>
<data>
b2CD6bKLNtrgsQF9xzXcPgpPzdA6uENGu3CTaXJbiJE=
</data>
</dict>
<key>Headers/GSPaddleErrorCodes.h</key>
<dict>
<key>hash2</key>
<data>
IzYJ7gTVtRFThhKibUhMMgvLKNqe7UbKs+lsfOYjq54=
</data>
</dict>
<key>Headers/PADApi+GSPaddle.h</key>
<dict>
<key>hash2</key>
<data>
GA1q/vOJ5pIEcJKTKNdbwkVIlYXwwAKoAcPuTPufLgQ=
</data>
</dict>
<key>Headers/Paddle+CustomBundleIdentifier.h</key>
<dict>
<key>hash2</key>
<data>
2y7lyvP3tidKNLwWVt7AkJsDleth6iu72yyjqktBqPo=
</data>
</dict>
<key>Modules/module.modulemap</key>
<dict>
<key>hash2</key>
<data>
ZSOiL3zrBK9vfTgXpOCNX5zsZRA7fEBLCKP8L9LAQGI=
</data>
</dict>
<key>Resources/Info.plist</key>
<dict>
<key>hash2</key>
<data>
bOd+8folBr1y6IRCZefTu9QysovrLJqH5kgwFuw/hmQ=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
Loading

0 comments on commit 1a7d138

Please sign in to comment.