diff --git a/MIHCrypto/RSA/MIHRSAPublicKey.m b/MIHCrypto/RSA/MIHRSAPublicKey.m index 4e69372..44773bb 100644 --- a/MIHCrypto/RSA/MIHRSAPublicKey.m +++ b/MIHCrypto/RSA/MIHRSAPublicKey.m @@ -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 \ No newline at end of file diff --git a/MIHCryptoTests/RSA/MIHRSAKeyTests.m b/MIHCryptoTests/RSA/MIHRSAKeyTests.m index b89558a..83e9e42 100644 --- a/MIHCryptoTests/RSA/MIHRSAKeyTests.m +++ b/MIHCryptoTests/RSA/MIHRSAKeyTests.m @@ -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; @@ -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" @@ -114,4 +115,9 @@ - (void)testDataExceedsModLen XCTAssertNil(decryptedData); } +- (void)testDescription +{ + XCTAssertEqualObjects(self.publicKeyString, [self.publicKey description]); +} + @end \ No newline at end of file