

If I add this prefix to the raw bytes, and then base64 encode it, I get something like this:Ĭode Block MIIBMTCB6gYHKoZIzj0CATCB3gIBATArBgcqhkjOPQEBAiB/////////////////////////////////////////7TBEBCAqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqYSRShRAQge0Je0Je0Je0Je0Je0Je0Je0Je0Je0Je0JgtenHcQyGQEQQQqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0kWiCuGaG4oIa04B7dLHdI0UySPU1+bXxhsinpxaJ+ztPZAiAQAAAAAAAAAAAAAAAAAAAAFN753q元nNZYEmMaXPXT7QIBCANCALG4aNI0Dxlyo1FqE+EUPCzIiSIYcchBQSjdzazH7eI6 The server is expecting something similar to this (I got this from the hex of the given server public key's data)Ĭode Block Data() Somehow, the suggested prefix is not working with the server. Quinn “The Eskimo!” Developer Technical Support Apple IMPORTANT This only works because you know you’re working with a Curve 25519 key and that key’s raw bytes is of a fixed length. : EE AE F8 87 DE C4 DB 7C D5 B1 02 2F C5 04 18 5C Apples new headquarters is a sign that the company will continue to invest in creating content for Apple TV+, its streaming service that costs 4. If you put those bytes into a file and then dump the ASN.1, you’ll see this:Ĥ 3: OBJECT IDENTIFIER curveX25519 (1 3 101 110) Let subjectPublicKeyInfo = prefix + rawKeyBytes To continue the above example,Ĭode Block let prefix = Data() In this case, however, you can get away with prepending a fixed header on to your 32-byte raw key data. Unfortunately, iOS does not have an API for this, and the third-party libraries out there are quite hard to integrate. The correct way to render and parse ASN.1 is with an ASN.1 library.

I’m presuming that you can handle steps 2 and 3, so I’m going to focus on step 1.

You first have to wrap the raw key in an ASN.1 SubjectPublicKeyInfo structure.įinally, you add the header and trailer strings. The PEM you’re trying to create needs three levels of wrapping: subject:/CUS/STCalifornia/LCupertino/OApple Inc./OUSecurity. Let rawKeyBytes = publicKey.rawRepresentation For example, this:Ĭode Block let privateKey = () As I’ve discussed on your other thread, the rawRepresentation of a Curve25519 key is simply the 32-byte raw key.
