Just a note to say to people to be careful with this piece of code.
I just gave a quick look at the code, and there is at least one buggy
function.
The encoding of integers in ASN.1 format is wrongly coded :
- it does not respect the format specified for negative values,
- it does not encode correctly values when a "zero byte" appears
in the middle of the value (e.g. 0x1100FFFF for example).
I also suspect the decoding of integers to not be working properly.
If I have some time, I will try to correct the script, right now,
I will just switch languages.
*EDIT:
Maybe not perfect, but this should decode/encode correctly integer
values.
Any comments are welcome, i am not a good rebol coder so there should
be a better way to do this.
*EDIT2: little precision, I just manage the data here, not the length
nor the identifier
ber: context [
encode-integer: func [int [integer!]] [
b: debase/base to-hex int 16
repeat index len: length? b [
if all [index = len] [break] ; we must at least send one
byte
if all [b/1 <> 0 b/1 <> 255] [break] ; nor 0x00, nor
0xFF, cool
if all [b/1 = 0 b/2 >= 128] [break] ; we don't have nine 0s
in a row
if all [b/1 = 255 b/2 < 128] [break] ; we don't have nine 1s
in a row
b: next b
]
b
]
decode-integer: func [bin [binary!]] [
padding: either all [128 > to-integer bin/1] [#{00}][#{FF}]
repeat index subtract 4 length? bin [insert bin padding]
to-integer bin
]
]
2 msnathan 25-Sep-2008 12:45
Hi all,
I am new to rebol, and i am working with the ldap protocol stuff.
I dont know how to Send a BIND and search the results to Ldap server.
Please Help me to find out the BER encoding/decoding with BIND, SEARCH,
UNBIND stuffs.
3 jackslesly19 14-Apr 19:53
This may possibly be quite helpful for some within your work opportunities I plan to never only with my website. I’m sure they’ll be benefited from this site.