Objective-C-RSA icon indicating copy to clipboard operation
Objective-C-RSA copied to clipboard

Public Key

Open ddaddy opened this issue 10 years ago • 8 comments

Hi, I have a key from Java that looks like OpenSSLRSAPublicKey{modulus=3b11f044.....58df890,publicExponent=10001}

Do I just use the modulus string as the public key or would I need to somehow convert this whole key to another format to use?

Thanks

ddaddy avatar Apr 07 '15 10:04 ddaddy

I think i've managed to get a base64 encoded key from java now, however this code now pauses on line 108 - OSStatus status = SecItemAdd((__bridge CFDictionaryRef)publicKey, &persistKey); And when I click continue in the debugger it carries on as normal however the encoded string is NULL.

Is there an issue when trying with a new key? It's not crashing, just pausing.

ddaddy avatar Apr 07 '15 11:04 ddaddy

Ok, sorry about so many notes. It seems it's pausing with an Exception, as if I remove the exception breakpoint it runs just fine, however the encoded string is always NULL :(

ddaddy avatar Apr 07 '15 11:04 ddaddy

Is the public key string in the format of this form?

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEChqe80lJLTTkJD3X3Lyd7Fj+
zuOhDZkjuLNPog3YR20e5JcrdqI9IFzNbACY/GQVhbnbvBqYgyql8DfPCGXpn0+X
NSxELIUw9Vh32QuhGNr3/TBpechrVeVpFPLwyaYNEk1CawgHCeQqf5uaqiaoBDOT
qeox88Lc1ld7MsfggQIDAQAB
-----END PUBLIC KEY-----

ideawu avatar Apr 08 '15 03:04 ideawu

Yes, I can get it working fine if I setup a new iOS project. I was originally using an OSX project. I wonder if it's an issue to do with code signing as I don't have a valid OSX dev membership but do for iOS. For it to use the keychain would it require proper code signing?

ddaddy avatar Apr 08 '15 11:04 ddaddy

I have an OS X CLI project and i'm having the same issue.

108 - OSStatus status = SecItemAdd((__bridge CFDictionaryRef)publicKey, &persistKey); OSStatus = -25303 and return NULL encoded string.

The persistKey appears to be nil after the SecItemAdd.

cheizer avatar May 18 '15 18:05 cheizer

Hello. I wander how to encrype RSA by two parameters, "Mod“, ”Exp" ?

tomguan avatar Jul 26 '15 06:07 tomguan

iOS9 no worked。。。help

winwys avatar Aug 17 '15 12:08 winwys

@tomguan this link might help http://www.scriptscoop.com/t/b7214526ca56/ios-create-seckey-from-modulus-and-exponent-in-swift.html

btnguyen2k avatar Sep 26 '15 07:09 btnguyen2k