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

Help with RSA signature #34

Closed
Aleph72 opened this issue Nov 27, 2015 · 1 comment
Closed

Help with RSA signature #34

Aleph72 opened this issue Nov 27, 2015 · 1 comment

Comments

@Aleph72
Copy link

Aleph72 commented Nov 27, 2015

Hello,
I'm using this framework to generate the key pair and sign a message.
I'm creating the key pair with:
self.rsaKeyFactory = [[MIHRSAKeyFactory alloc] init];
self.rsaKeyFactory.preferedKeySize = MIHRSAKey1024;
self.keyPair = [self.rsaKeyFactory generateKeyPair];

and then sign with:
- (NSString *)signMessageData:(NSData *)data withKey:(MIHRSAPrivateKey *)privKey {
NSError *signingError = nil;
NSData *signatureData = [privKey signWithSHA256:data error:&signingError];
if (signingError != nil) {
NSLog(@"Error al firmar el mensaje: %@", signingError.localizedDescription);
}
NSString *signString = [signatureData MIH_base64EncodedString];
return signString;
}

For what I know, signing with a 1024 private key should give a 128byte signature, but I get just 86 bytes.
I've been told to generate a 128 bytes signature, so any help would be really apreciated.

Thanks.

@Aleph72
Copy link
Author

Aleph72 commented Nov 27, 2015

I'll answer myself this time.
The problem was the line "NSString *signString = [signatureData MIH_base64EncodedString];"
signatureData is exactly 128 byte, so I changed the method to return directly the NSData instead of converting it back to a NSString.

@hohl hohl closed this as completed Nov 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants