Hi Guys,
Recenlty I have been testing my code in iOS 9 with Xcode 7 Beta 5. In my app, I am using + (SecKeyRef) addPeerPublicKey:(NSString *) peerName withPublicKey:(NSData *) publicKey method to generate public key from exponent and modulus. It turns out that SecKeyRef generate is always nil in iOS 9 but works well in iOS 8. Is it bug for the Xcode 7 Beta 5 or There are several changing that i need to do in order to make it works in iOS 9?
Please help.
Thanks.
Best Regards,
Chris
Your public key is malformed. Consider this:
$ # I just put the hex dump into a file called "tmp.asn1".
$
$ hexdump -Cv tmp.asn1
00000000 30 81 88 02 81 80 d4 e7 f6 50 36 5c 80 bd 72 01 |0........P6\..r.|
00000010 42 96 84 10 74 c4 97 67 ab 23 53 9f c5 b4 a3 a2 |B...t..g.#S.....|
00000020 e1 42 99 fe 48 42 72 92 24 75 2a 76 a5 a7 3a 62 |.B..HBr.$u*v..:b|
00000030 65 f5 5d 81 80 66 48 9a e1 83 43 5a ed c4 0e ba |e.]..fH...CZ....|
00000040 48 e5 3b 1a 84 d8 48 9b 17 e1 fa 11 6a c5 c4 0e |H.;...H.....j...|
00000050 cb f0 fa 4f c7 3c cf 4c ea 79 86 7b 82 59 bc a6 |...O.<.L.y.{.Y..|
00000060 00 f7 80 5c 8f a8 02 8e 63 52 35 4c cd 4f 18 62 |...\....cR5L.O.b|
00000070 68 a8 f0 ae e6 92 bb 27 47 48 dc 35 00 ea c8 6f |h......'GH.5...o|
00000080 16 19 39 b2 c9 0f 02 03 01 00 01 |..9........|
0000008b
$
$ # Now let's dump that file.
$
$ dumpasn1 tmp.asn1
0 136: SEQUENCE {
3 128: INTEGER
: D4 E7 F6 50 36 5C 80 BD 72 01 42 96 84 10 74 C4
: 97 67 AB 23 53 9F C5 B4 A3 A2 E1 42 99 FE 48 42
: 72 92 24 75 2A 76 A5 A7 3A 62 65 F5 5D 81 80 66
: 48 9A E1 83 43 5A ED C4 0E BA 48 E5 3B 1A 84 D8
: 48 9B 17 E1 FA 11 6A C5 C4 0E CB F0 FA 4F C7 3C
: CF 4C EA 79 86 7B 82 59 BC A6 00 F7 80 5C 8F A8
: 02 8E 63 52 35 4C CD 4F 18 62 68 A8 F0 AE E6 92
: BB 27 47 48 DC 35 00 EA C8 6F 16 19 39 B2 C9 0F
: Error: Integer has a negative value.
134 3: INTEGER 65537
: }
0 warnings, 1 error.
Note If you’re monkeying with crypto stuff, I strongly recommend that you get to know the
dumpasn1
tool.
Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"