Skip to content

Commit c4547d9

Browse files
committed
FEAT: included codec for Apple's Provision Profile files
1 parent 31dae91 commit c4547d9

File tree

4 files changed

+65
-20
lines changed

4 files changed

+65
-20
lines changed

src/mezz/codec-der.reb

+2-15
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ register-codec [
310310
|
311311
#{2B060105050703} (main: "PKIX key purpose") [
312312
#"^(01)" (name: 'serverAuth)
313-
#"^(02)" (name: 'clientAuth)
313+
| #"^(02)" (name: 'clientAuth)
314314
| #"^(03)" (name: 'codeSigning)
315315
] end
316316
|
@@ -319,6 +319,7 @@ register-codec [
319319
] end
320320
|
321321
#{0992268993F22C6401} (main: "Attribute") [
322+
; http://oid-info.com/cgi-bin/display?tree=0.9.2342.19200300.100.1.1
322323
#"^(01)" (name: 'uid)
323324
] end
324325
]
@@ -335,17 +336,3 @@ register-codec [
335336

336337
verbose: 0
337338
]
338-
339-
register-codec [
340-
name: 'mobileprovision
341-
type: 'cryptography
342-
title: "Apple's mobileprovision file"
343-
suffixes: [%.mobileprovision]
344-
decode: function[data [binary!]][
345-
try [
346-
der: codecs/DER/decode data
347-
result: to string! der/sequence/cs0/sequence/sequence/cs0/2
348-
]
349-
result
350-
]
351-
]

src/mezz/codec-plist.reb

+53-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ REBOL [
22
name: plist
33
type: module
44
options: [delay]
5-
version: 0.0.1
6-
title: "REBOL 3 codec for PLIST files"
5+
version: 1.0.0
6+
title: "PLIST codec"
77
file: https://raw.githubusercontent.com/Oldes/Rebol3/master/src/mezz/codec-plist.reb
88
author: "Oldes"
99
history: [
10-
07-Apr-2022 "Oldes" {Initial version of the PLIST decoder}
10+
07-Apr-2022 "Oldes" {Initial version of the PLIST and Provisioning Profile decoder}
1111
]
12-
References: [
12+
references: [
1313
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html
1414
https://medium.com/@karaiskc/understanding-apples-binary-property-list-format-281e6da00dbd
1515
]
1616
todo: {
1717
* Support binary PLIST version
1818
* PLIST encoder
19+
* Provision profile data validation?
1920
}
2021
]
2122

@@ -113,7 +114,7 @@ register-codec [
113114
change/only v compose [
114115
commonName: (crt/subject/commonName)
115116
valid-to: (crt/valid-to)
116-
fingerprint: (crt/fingerprint)
117+
fingerprint: (select crt 'fingerprint)
117118
]
118119
]
119120
]
@@ -140,3 +141,50 @@ register-codec [
140141
]
141142
]
142143
]
144+
145+
register-codec [
146+
name: 'provision
147+
type: 'cryptography
148+
title: "Apple's Provisioning Profile File Format"
149+
suffixes: [%.provisionprofile %.mobileprovision]
150+
151+
decode: function [
152+
{Extract PLIST data from a provision profile}
153+
data [binary! file! url!]
154+
;return: [map!]
155+
] [
156+
unless binary? data [ data: read data ]
157+
158+
der: codecs/der/decode data
159+
parse der [
160+
'SEQUENCE into [
161+
'OBJECT_IDENTIFIER #{2A864886F70D010702} 'CS0 into [
162+
'SEQUENCE into [
163+
'INTEGER set version: binary!
164+
'SET into [
165+
'SEQUENCE into [
166+
'OBJECT_IDENTIFIER set oid: binary! (
167+
hash-alg: codecs/der/decode-oid oid
168+
)
169+
to end
170+
]
171+
]
172+
'SEQUENCE into [
173+
'OBJECT_IDENTIFIER #{2A864886F70D010701} 'CS0 into [
174+
'OCTET_STRING set plist: binary!
175+
]
176+
]
177+
; follows certificates used to sign the data..
178+
; validation is not implemented!
179+
to end
180+
]
181+
to end
182+
]
183+
to end
184+
]
185+
]
186+
either binary? plist [
187+
codecs/plist/decode plist
188+
][ none ]
189+
]
190+
]

src/tests/units/codecs-test.r3

+10
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,16 @@ if find codecs 'plist [
546546
--assert map? data: load %units/files/Some.plist
547547
--assert data/AppIDName = "Test Application"
548548
--assert data/UUID = "bba91992-3a72-46b3-bc5f-f7b59aa49236"
549+
550+
--test-- "Load mobileprovision file"
551+
--assert all [
552+
map? data: load %units/files/Some.mobileprovision
553+
data/AppIDName = "Samorost 1"
554+
data/UUID = "be387546-d90d-40cd-83e6-95eb6f5f0861"
555+
block? data/ProvisionedDevices
556+
block? data/DeveloperCertificates
557+
object? decode 'crt data/DeveloperCertificates/1
558+
]
549559
===end-group===
550560
]
551561

11.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)