Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objective pgp2 #234

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0543677
clean. fresh start.
krzyzanowskim Jan 17, 2015
f44efc7
Initials reading headers. Remove cocoapods
krzyzanowskim Jan 17, 2015
a69aa73
Add test target
krzyzanowskim Jan 17, 2015
fe3746f
Tests for parsing header data
krzyzanowskim Jan 17, 2015
1a0dc0f
fix Two-Octet Lengths
krzyzanowskim Jan 17, 2015
b701615
Rework header api
krzyzanowskim Jan 18, 2015
f6a838d
read PGPPublicKeyPacket
krzyzanowskim Jan 18, 2015
f74c0c3
PGPUserIDPacket. Fix reading ints from stream (BE->LE is already done)
krzyzanowskim Jan 19, 2015
55a4384
Signature initials
krzyzanowskim Jan 19, 2015
98e898f
work on reading signature packet
krzyzanowskim Jan 20, 2015
c16155a
Signature packet and subpackets - not done yet
krzyzanowskim Jan 21, 2015
93f569d
subpackets
krzyzanowskim Jan 21, 2015
cd0c818
fix parsing subpackets. Intorduce PGPFunctions
krzyzanowskim Jan 21, 2015
20bef31
minor, error checking
krzyzanowskim Jan 21, 2015
17493d7
proper key data for test
krzyzanowskim Jan 21, 2015
2423a8d
PGPSignaturePacket valueOfSubacketOfType
krzyzanowskim Jan 21, 2015
ed3d63a
read bytes to buffer
krzyzanowskim Jan 29, 2015
6f3c0f6
eadUInt32BytesAppendTo:
krzyzanowskim Jan 29, 2015
0be6190
fix 32
krzyzanowskim Jan 29, 2015
40d5698
Store hashed data of signature
krzyzanowskim Jan 30, 2015
ac40526
hashedData is not public
krzyzanowskim Jan 30, 2015
aa91e6f
pgpNumBits
krzyzanowskim Feb 2, 2015
4ab03ee
Whole a lot a things. Signature. PGPMPI. PacketHeader refactoring and…
krzyzanowskim Feb 3, 2015
8ec518b
partial and indeterminate length of headers
krzyzanowskim Feb 4, 2015
df0e8f2
Write public key packet
krzyzanowskim Feb 5, 2015
f7a65db
write user id packet
krzyzanowskim Feb 5, 2015
e56622a
Initial work to output signature packet
krzyzanowskim Feb 13, 2015
bd80f1d
write Big Endian. Refactor method names for clear BE->LE->BE conversion.
krzyzanowskim Feb 17, 2015
db58f1e
Read and Write all known subpacket types. Not supported marked as TODO
krzyzanowskim Feb 17, 2015
8c2b49e
Fix exporting signature + test
krzyzanowskim Feb 17, 2015
a6d82ca
buildData with NSData
krzyzanowskim Feb 17, 2015
f37ddd5
more build data
krzyzanowskim Feb 17, 2015
25ba5f2
MPI buildData
krzyzanowskim Feb 17, 2015
a6ada3a
computeSignatureHashOverKey
krzyzanowskim Feb 17, 2015
c6a067c
Refactor signature calculation (in progress)
krzyzanowskim Feb 18, 2015
effe729
MPI order matter. buildDataToSign is a function.
krzyzanowskim Feb 19, 2015
1a6d6c0
Calculate fingerprint and key ids
krzyzanowskim Feb 19, 2015
39e362d
mpiForIdentifier and key id v3
krzyzanowskim Feb 20, 2015
c148211
jefferyq2 Jun 6, 2024
41df2f3
jefferyq2 Jun 10, 2024
e645d73
jefferyq2 Jun 6, 2024
ea04722
jefferyq2 Jun 10, 2024
1d4b799
jefferyq2 Jun 10, 2024
57ce04a
jefferyq2 Jun 10, 2024
c3fe7ad
jefferyq2 Jun 10, 2024
39452fe
jefferyq2 Jun 10, 2024
cd2ee16
jefferyq2 Jun 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,179 changes: 278 additions & 901 deletions ObjectivePGP.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
<string>ObjectivePGP</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>E87A640A-257A-4EA9-8911-A3A876F28D8B</key>
<string>ssh://bitbucket.org/krzyzanowskim/objectivepgp.git</string>
<key>4858D38B24AED68A4237F0D24D6AD46EA9025A89</key>
<string>bitbucket.org:krzyzanowskim/objectivepgp.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>ObjectivePGP.xcodeproj/project.xcworkspace</string>
<string>ObjectivePGP.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>E87A640A-257A-4EA9-8911-A3A876F28D8B</key>
<key>4858D38B24AED68A4237F0D24D6AD46EA9025A89</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://bitbucket.org/krzyzanowskim/objectivepgp.git</string>
<string>bitbucket.org:krzyzanowskim/objectivepgp.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>E87A640A-257A-4EA9-8911-A3A876F28D8B</string>
<string>4858D38B24AED68A4237F0D24D6AD46EA9025A89</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>E87A640A-257A-4EA9-8911-A3A876F28D8B</string>
<string>4858D38B24AED68A4237F0D24D6AD46EA9025A89</string>
<key>IDESourceControlWCCName</key>
<string>OpenPGPKeyring</string>
<string>objectivepgp</string>
</dict>
</array>
</dict>
Expand Down
11 changes: 10 additions & 1 deletion ObjectivePGP.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 0 additions & 41 deletions ObjectivePGP.xcworkspace/xcshareddata/ObjectivePGP.xccheckout

This file was deleted.

14 changes: 14 additions & 0 deletions ObjectivePGP/Categories/NSData+PGP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// NSData+PGP.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 17/02/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSData (PGP)
- (UInt16) readUInt16BE:(NSRange)range;
- (UInt32) readUInt32BE:(NSRange)range;
@end
27 changes: 27 additions & 0 deletions ObjectivePGP/Categories/NSData+PGP.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// NSData+PGP.m
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 17/02/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import "NSData+PGP.h"

@implementation NSData (PGP)
- (UInt16) readUInt16BE:(NSRange)range
{
NSAssert(range.length == 2, @"Invalid length");
UInt16 value = 0;
[self getBytes:&value range:range];
return CFSwapInt16BigToHost(value);
}

- (UInt32) readUInt32BE:(NSRange)range
{
NSAssert(range.length == 4, @"Invalid length");
UInt32 value = 0;
[self getBytes:&value range:range];
return CFSwapInt32BigToHost(value);
}
@end
22 changes: 22 additions & 0 deletions ObjectivePGP/Categories/NSInputStream+PGP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// NSInputStream+PGP.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 18/01/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSInputStream (PGP)
- (UInt8) readUInt8; // BE->LE
- (UInt8) readUInt8:(UInt8 *)bytes;
- (UInt8) readUInt8BytesAppendTo:(NSMutableData *)data;
- (UInt16) readUInt16BE; // BE->LE
- (UInt16) readUInt16BE:(UInt8 *)readBytes;
- (UInt16) readUInt16BEBytesAppendTo:(NSMutableData *)data;
- (UInt32) readUInt32BE; // BE->LE
- (UInt32) readUInt32BE:(UInt8 *)readBytes;
- (UInt32) readUInt32BytesAppendTo:(NSMutableData *)data;
- (NSData *) readDataLength:(NSUInteger)length;
@end
115 changes: 115 additions & 0 deletions ObjectivePGP/Categories/NSInputStream+PGP.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// NSInputStream+PGP.m
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 18/01/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import "NSInputStream+PGP.h"

@implementation NSInputStream (PGP)

- (UInt8) readUInt8
{
return [self readUInt8:nil];
}

- (UInt8) readUInt8BytesAppendTo:(NSMutableData *)data
{
NSParameterAssert(data);

UInt8 result;
UInt8 byte;
result = [self readUInt8:&byte];
[data appendBytes:&byte length:1];
return result;
}

- (UInt8) readUInt8:(UInt8 *)readBytes
{
UInt8 result = 0;
[self read:&result maxLength:1];

if (readBytes) {
*readBytes = result;
}
return result;
}

- (UInt16) readUInt16BE
{
return [self readUInt16BE:nil];
}

- (UInt16) readUInt16BEBytesAppendTo:(NSMutableData *)data
{
NSParameterAssert(data);

UInt16 result;
UInt8 bytes[2];
result = [self readUInt16BE:bytes];
[data appendBytes:bytes length:sizeof(bytes)];
return result;
}

- (UInt16) readUInt16BE:(UInt8 *)readBytes
{
UInt8 bytes[2];
if ([self read:bytes maxLength:sizeof(bytes)] > 0) {
if (readBytes) {
bcopy(bytes, readBytes, sizeof(bytes));
}
UInt16 value = 0;
bcopy(bytes, &value, sizeof(bytes));
return CFSwapInt16BigToHost(value);
}
NSAssert(false,@"readUInt16 failed");
return 0;
}

- (UInt32) readUInt32BE
{
return [self readUInt32BE:nil];
}

- (UInt32) readUInt32BytesAppendTo:(NSMutableData *)data
{
NSParameterAssert(data);

UInt32 result;
UInt8 bytes[4];
result = [self readUInt32BE:bytes];
[data appendBytes:bytes length:sizeof(bytes)];
return result;
}


- (UInt32) readUInt32BE:(UInt8 *)readBytes
{
UInt8 bytes[4];
if ([self read:bytes maxLength:sizeof(bytes)] > 0) {
if (readBytes) {
bcopy(bytes, readBytes, sizeof(bytes));
}
UInt32 value;
bcopy(bytes, &value, sizeof(bytes));
return CFSwapInt32BigToHost(value);
}
NSAssert(false,@"readUInt32 failed");
return 0;
}

- (NSData *) readDataLength:(NSUInteger)length
{
NSData *output = nil;
UInt8 buffer[length];
NSInteger readResult = [self read:buffer maxLength:length];
if (readResult > 0) {
output = [NSData dataWithBytes:buffer length:readResult]; // 8 bytes long
}
free(buffer);
return output;
}

@end
16 changes: 16 additions & 0 deletions ObjectivePGP/Categories/NSOutputStream+PGP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// NSOutputStream+PGP.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 05/02/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSOutputStream (PGP)
- (BOOL) writeUInt8:(UInt8)value;
- (BOOL) writeUInt16BE:(UInt16)value;
- (BOOL) writeUInt32BE:(UInt32)value;
- (BOOL) writeData:(NSData *)data;
@end
55 changes: 55 additions & 0 deletions ObjectivePGP/Categories/NSOutputStream+PGP.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// NSOutputStream+PGP.m
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 05/02/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import "NSOutputStream+PGP.h"

@implementation NSOutputStream (PGP)

- (BOOL) writeUInt8:(UInt8)value
{
UInt8 bytes[1];
bcopy(&value, bytes, sizeof(bytes));
if ([self write:bytes maxLength:sizeof(bytes)] == -1) {
return NO;
}
return YES;

}

- (BOOL) writeUInt16BE:(UInt16)value
{
UInt16 valueBE = CFSwapInt16HostToBig(value);
UInt8 bytes[2];
bcopy(&valueBE, bytes, sizeof(bytes));
if ([self write:bytes maxLength:sizeof(bytes)] == -1) {
return NO;
}
return YES;
}


- (BOOL) writeUInt32BE:(UInt32)value
{
UInt32 valueBE = CFSwapInt32BigToHost(value);
UInt8 bytes[4];
bcopy(&valueBE, bytes, sizeof(bytes));
if ([self write:bytes maxLength:sizeof(bytes)] == -1) {
return NO;
}
return YES;
}

- (BOOL) writeData:(NSData *)data
{
if ([self write:data.bytes maxLength:data.length] == -1) {
return NO;
}
return YES;
}

@end
24 changes: 24 additions & 0 deletions ObjectivePGP/Helpers/PGPFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// PGPFunctions.h
// ObjectivePGP
//
// Created by Marcin Krzyzanowski on 21/01/15.
// Copyright (c) 2015 Marcin Krzyżanowski. All rights reserved.
//

#import <Foundation/Foundation.h>

#pragma once

NSData *pgpCalculateSHA512(const void *bytes, unsigned int length);
UInt8 *pgpCalculateSHA384(const void *bytes, unsigned int length);
UInt8 *pgpCalculateSHA256(const void *bytes, unsigned int length);
UInt8 *pgpCalculateSHA224(const void *bytes, unsigned int length);
NSData *pgpCalculateSHA1(const void *bytes, unsigned int length);
NSData *pgpCalculateMD5(const void *bytes, unsigned int length);
NSUInteger pgpNumBits(Byte *bytes, NSUInteger maxLength);
NSInteger isPowerOfTwo (NSUInteger x);
NSData *buildNewFormatLengthBytesForData(NSData *bodyData);
NSData *buildOldFormatLengthBytesForData(NSData *bodyData);


Loading