openssl - ASN1 parsing with swift -


i think basic idea behind asn.1 parsing. walk bytes, interpret them , useful them. alas stuck on implementation.

apple has no sample code (that find), security reasons. openssl not documented, can guess @ functions do. sample code in swift did find doesn't handle case 17 (the in-app purchases), 1 thing interested in.

i tried figuring out in data stream pointer located, same nonsensical result of 49.

    let receiptcontents = nsdata(contentsofurl: receiptlocation)!      let receiptbio = bio_new(bio_s_mem())     bio_write(receiptbio, receiptcontents.bytes, int32(receiptcontents.length))     contents = d2i_pkcs7_bio(receiptbio, nil)      //parsing     var currentindex    = unsafepointer<uint8>()     var endindex        = unsafepointer<uint8>()      let octets      = pkcs7_d_data(pkcs7_d_sign(self.contents).memory.contents)      var ptr = unsafepointer<uint8>(octets.memory.data)     let end = ptr.advancedby(int(octets.memory.length))     println(ptr.memory) //always 49 ???     println(end.memory) //always 0 ???     println(octets.memory.length) 

i tried parsing nsdata myself, well, type of binaire data?

    receiptcontents = nsdata(contentsofurl: receiptlocation)!      //get bytes     let count = receiptcontents.length / sizeof(uint8)     var bytes = [uint8](count: count, repeatedvalue: 0)     receiptcontents.getbytes(&bytes, length:count * sizeof(uint8))      //parsing     index in 0...5     {         let value = int(bytes[index])         println(value)     } 

i output: 48 130 21 57 6 9

but if understand asn.1 format correctly, it's supposed start value of 17 (set), 3 bytes length (int24?), value of 16 (first sequence), sequence length (1 byte), sequence type (1 byte), sequence payload, (repeat).

other types int32, int16 makes less sense me.

not sure how proceed here. suggestions?

from outset, suppose should disclaim saying i'm not familiar many of underlying technologies (swift, openssl, biometrics standards think you're working with).

that said, you're running afoul of ber's tagging rules. the wiki article on x.690 has introductory comments how ber tags constructed, you'll want consult annex of x.690 example encoding , x.680 §8 information tagging.

a set type can appear in several different forms; in case 49 = 0x31 = 0b00110001 = universal 17 (set, constructed). other forms may occur, 1 that's explicitly identified set tag itself: specification may use different tag set type.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -