Skip to content

Commit

Permalink
Fix description field of MIHRSAPublicKey (fixes hohl#20) and added un…
Browse files Browse the repository at this point in the history
…it tests for that field.
  • Loading branch information
hohl committed Mar 1, 2015
1 parent 3021c62 commit e5ec04f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MIHCrypto/RSA/MIHRSAPublicKey.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ - (BOOL)verifySignatureWithSHA256:(NSData *)signature message:(NSData *)message

- (NSString *)description
{
return [[NSString alloc] initWithData:[self dataValue] encoding:NSUTF8StringEncoding];
return [[self dataValue] MIH_base64EncodedString];
}

@end
10 changes: 8 additions & 2 deletions MIHCryptoTests/RSA/MIHRSAKeyTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@interface MIHRSAKeyTests : XCTestCase
@property(strong) NSData *messageData;
@property(strong) NSData *inalidEncryptedData;
@property(strong) NSString *publicKeyString;
@property(strong) MIHRSAPublicKey *publicKey;
@property(strong) MIHRSAPrivateKey *privateKey;
@property(strong) NSData *pub;
Expand All @@ -35,9 +36,9 @@ @implementation MIHRSAKeyTests

- (void)setUp
{
NSString *pubString = @"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJma7iWHjLCpeiHHhkwf/IGVtJvrHVW/"
self.publicKeyString = @"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJma7iWHjLCpeiHHhkwf/IGVtJvrHVW/"
"F+te83hB85YiCuAOqvaG7Isy4dYbwBZKkuIq9x+FVZ+6SrsaRQuaFSkCAwEAAQ==";
self.pub = [NSData MIH_dataByBase64DecodingString:pubString];
self.pub = [NSData MIH_dataByBase64DecodingString:self.publicKeyString];
NSString *pemString = @"-----BEGIN PRIVATE KEY-----\n"
"MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAmZruJYeMsKl6IceG\n"
"TB/8gZW0m+sdVb8X617zeEHzliIK4A6q9obsizLh1hvAFkqS4ir3H4VVn7pKuxpF\n"
Expand Down Expand Up @@ -114,4 +115,9 @@ - (void)testDataExceedsModLen
XCTAssertNil(decryptedData);
}

- (void)testDescription
{
XCTAssertEqualObjects(self.publicKeyString, [self.publicKey description]);
}

@end

0 comments on commit e5ec04f

Please sign in to comment.