discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementation of CommonCrypto?


From: Amr Aboelela
Subject: Re: Implementation of CommonCrypto?
Date: Thu, 9 Jun 2016 18:44:07 -0700

Hi Neils,

I tried your CommonCrypto in Ubuntu:

- (void)testEncryptAndDecrypt
{
    NSString *key = @"dict1";
    NSString *dataString = @"data to encrypt";
    NSData *data = "" dataUsingEncoding:NSASCIIStringEncoding];
    NSString *plainText = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    XCTAssertEqualObjects(dataString, plainText, @"converting from NSData should give same text");
    NSError *error = nil;
    NSData *encryptedData = [data AES256EncryptedDataUsingKey:key error:&error];
    if (error) {
        DLog(@"error: %@", error);
    }
    DLog(@"encryptedData: %@", encryptedData);
    XCTAssertNil(error, @"Got error in AES256EncryptedDataUsingKey:key method");    
    NSString *encryptedString = [[NSString alloc] initWithData:encryptedData encoding:NSASCIIStringEncoding];
    DLog(@"encryptedString: %@", encryptedString);
    NSData *decryptedData = [encryptedData decryptedAES256DataUsingKey:key error:&error];
    XCTAssertNil(error, @"Got error in decryptedAES256DataUsingKey:key method");
    DLog(@"decryptedData: %@", decryptedData);
    NSString *decryptedString = [[NSString alloc] initWithData:decryptedData encoding:NSASCIIStringEncoding];
    DLog(@"decryptedString: %@", decryptedString);
    XCTAssertEqualObjects(decryptedString, dataString, @"After decryption should return same text");
}

and got this:


============================ Running RengoTests (debug) =================================
2016-06-09 18:38:47.328 RengoTests[25595:25595] Test Suite 'NSDataTests' started.
2016-06-09 18:38:47.332 RengoTests[25595:25595] Test Case 'testEncryptAndDecrypt' started.
2016-06-09 18:38:47.333 RengoTests[25595:25595] -[NSDataTests testEncryptAndDecrypt] [Line 33] encryptedData: <88d505dd d097b09b 66132c3c dc888c9f>
2016-06-09 18:38:47.333 RengoTests[25595:25595] -[NSDataTests testEncryptAndDecrypt] [Line 36] encryptedString: (null)
/home/amr/myos/sdk/run_debug: line 41: 25595 Segmentation fault      (core dumped) ./${TARGET}



And in case of hardcoding encryptedString:

- (void)testEncryptAndDecrypt
{
    NSString *key = @"dict1";
    NSString *dataString = @"data to encrypt";
    NSData *data = "" dataUsingEncoding:NSASCIIStringEncoding];
    NSString *plainText = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    XCTAssertEqualObjects(dataString, plainText, @"converting from NSData should give same text");
    NSError *error = nil;
    NSData *encryptedData = [data AES256EncryptedDataUsingKey:key error:&error];
    if (error) {
        DLog(@"error: %@", error);
    }
    DLog(@"encryptedData: %@", encryptedData);
    XCTAssertNil(error, @"Got error in AES256EncryptedDataUsingKey:key method");    
    NSString *encryptedString = @"Õ^EÝÐ<97>°<9b>f^S,<Ü";
    DLog(@"encryptedString: %@", encryptedString);
    NSData *decryptedData = [encryptedData decryptedAES256DataUsingKey:key error:&error];
    XCTAssertNil(error, @"Got error in decryptedAES256DataUsingKey:key method");
    DLog(@"decryptedData: %@", decryptedData);
    NSString *decryptedString = [[NSString alloc] initWithData:decryptedData encoding:NSASCIIStringEncoding];
    DLog(@"decryptedString: %@", decryptedString);
    XCTAssertEqualObjects(decryptedString, dataString, @"After decryption should return same text");
}


============================ Running RengoTests (debug) =================================
2016-06-09 18:35:46.300 RengoTests[25569:25569] Test Suite 'NSDataTests' started.
2016-06-09 18:35:46.308 RengoTests[25569:25569] Test Case 'testEncryptAndDecrypt' started.
2016-06-09 18:35:46.309 RengoTests[25569:25569] -[NSDataTests testEncryptAndDecrypt] [Line 33] encryptedData: <88d505dd d097b09b 66132c3c dc888c9f>
2016-06-09 18:35:46.310 RengoTests[25569:25569] -[NSDataTests testEncryptAndDecrypt] [Line 36] encryptedString: Õ^EÝÐ<97>°<9b>f^S,<Ü
/home/amr/myos/sdk/run_debug: line 41: 25569 Segmentation fault      (core dumped) ./${TARGET}


On Mar 7, 2012, at 9:58 PM, Niels Grewe <niels.grewe@halbordnung.de> wrote:

Hi Jon,

On Sat, Jun 25, 2011 at 11:32:02PM -0500, Jonathan Bartlett wrote:
Has anyone worked on getting an implementaiton of CommonCrypto for GNUstep?

you've probably long forgotten about this, but in case you're still
interested: I just got around cleaning up my work on making CommonCrypto
work on non-Darwin platforms. You can get the tarball here [0]. I'm also
experimenting with DVCSs again, so this time ongoing work is available
via fossil [1], but I don't have much time at my hands right now, so it
will probably stay equivalent with the tarball for a while.
The catch with this is that it requires clang to compile at the moment
because clang is more forgiving with respect to interpreting the CPU
specific assembly in there (which was a bit of a pain to rewrite
already). Also, the CommonCrypto version is a bit old-ish by now, but
I'll try to forward-port my changes once I can connect to
opensource.apple.com again.

Cheers,

Niels



[0] http://www.halbordnung.de/~niels.grewe/gnustep/gs-commoncrypto.tar.bz2
[1] https://chiselapp.com/user/thebeing/repository/GS-CommonCrypto

_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep


reply via email to

[Prev in Thread] Current Thread [Next in Thread]