Hello !
Here is another patch for Erlang asn1 library -> UPER
The UPER encoding function for OCTETSTRING doesn't accept binaries in argument.
It's strange because
* BER function accept them
* The encoding function of UPER transforms the list passed in argument in a binary.
* it would be needlessly wastefull to wrap our data inside a list when it is already a binary
So it should directly accept binaries in argument too.
.diff file attached is a patch which adds this functionality.
It just modifies encode_octet_string function in
* asn1rt_uper_bin.erl
There is the same problem with APER (files asn1rt_per_bin.erl and asn1rt_per_bin_rt2ct.erl)
but it would take too much time to change it because it's more complicated in these files.
Best regards,
Aude.
[patch_binlist.diff]
--- /home/quintana/Bureau/new/asn1rt_uper_bin.erl 2009-08-17 19:32:53.000000000 +0200
+++ asn1rt_uper_bin.erl 2009-08-24 16:28:40.000000000 +0200
@@ -1086,22 +1086,24 @@
encode_octet_string(C,{_Name,Val}) ->
encode_octet_string(C,Val);
+encode_octet_string(C,Val) when is_list(Val) ->
+ encode_octet_string(C, list_to_binary(Val));
encode_octet_string(C,Val) ->
case get_constraint(C,'SizeConstraint') of
0 ->
<<>>;
1 ->
- list_to_binary(Val);
+ Val;
2 ->
- list_to_binary(Val);
- Sv when Sv =<65535, Sv == length(Val) -> % fixed length
- list_to_binary(Val);
+ Val;
+ Sv when Sv =<65535, Sv == size(Val) -> % fixed length
+ Val;
VR = {_,_} ->
- [encode_length(VR,length(Val)),list_to_binary(Val)];
+ [encode_length(VR,size(Val)),Val];
Sv when is_list(Sv) ->
- [encode_length({hd(Sv),lists:max(Sv)},length(Val)),list_to_binary(Val)];
+ [encode_length({hd(Sv),lists:max(Sv)},size(Val)),Val];
no ->
- [encode_length(undefined,length(Val)),list_to_binary(Val)]
+ [encode_length(undefined,size(Val)),Val]
end.
decode_octet_string(Bytes,C) ->
________________________________________________________________
erlang-patches mailing list. See
http://www.erlang.org/faq.htmlerlang-patches (at) erlang.org