Skip to content

Commit

Permalink
EST
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Oct 24, 2024
1 parent f95b6d4 commit a7b3635
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
13 changes: 4 additions & 9 deletions priv/csr/EST.asn1
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
EST DEFINITIONS IMPLICIT TAGS ::= BEGIN

IMPORTS ATTRIBUTE FROM PKIX-CommonTypes-2009 ;

CsrAttrs ::= SEQUENCE SIZE (0..MAX) OF AttrOrOID
AttrOrOID ::= CHOICE { oid OBJECT IDENTIFIER, attribute Attribute }
Attribute ::= SEQUENCE {
type ATTRIBUTE.&id,
values SET SIZE(1..MAX) OF ATTRIBUTE.&Type }

ATTRIBUTE ::= TYPE-IDENTIFIER
CsrAttrs ::= SEQUENCE OF AttrOrOID
AttrOrOID ::= CHOICE { oid OBJECT IDENTIFIER, attribute Attribute }
Attribute ::= SEQUENCE { type ATTRIBUTE.&id, values SET OF OBJECT IDENTIFIER }
END
21 changes: 3 additions & 18 deletions src/EST.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-compile(nowarn_unused_vars).
-dialyzer(no_improper_lists).
-dialyzer(no_match).
-include_lib("ca/include/EST.hrl").
-include("EST.hrl").
-asn1_info([{vsn,'5.0.17'},
{module,'EST'},
{options,[warnings,ber,errors,
Expand Down Expand Up @@ -204,7 +204,7 @@ enc_Attribute_values(Val, TagIn) ->
{lists:reverse(AccBytes),AccLen};

'enc_Attribute_values_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_open_type(H, []),
{EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]),
'enc_Attribute_values_components'(T,[EncBytes|AccBytes], AccLen + EncLen).


Expand Down Expand Up @@ -240,7 +240,7 @@ Res1.
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[decode_open_type_as_binary(V1, []) || V1 <- Tlv1].
[decode_object_identifier(V1, [6]) || V1 <- Tlv1].



Expand All @@ -254,13 +254,6 @@ Tlv1 = match_tags(Tlv, TagIn),
ber_decode_nif(B) ->
asn1rt_nif:decode_ber_tlv(B).

ber_encode([Tlv]) ->
ber_encode(Tlv);
ber_encode(Tlv) when is_binary(Tlv) ->
Tlv;
ber_encode(Tlv) ->
asn1rt_nif:encode_ber_tlv(Tlv).

dec_subidentifiers(<<>>, _Av, Al) ->
lists:reverse(Al);
dec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al) ->
Expand All @@ -282,9 +275,6 @@ decode_object_identifier(Tlv, Tags) ->
end,
list_to_tuple([Val1, Val2 | ObjVals]).

decode_open_type_as_binary(Tlv, TagIn) ->
ber_encode(match_tags(Tlv, TagIn)).

e_object_identifier({'OBJECT IDENTIFIER', V}) ->
e_object_identifier(V);
e_object_identifier(V) when is_tuple(V) ->
Expand Down Expand Up @@ -314,11 +304,6 @@ encode_length(L) ->
encode_object_identifier(Val, TagIn) ->
encode_tags(TagIn, e_object_identifier(Val)).

encode_open_type(Val, T) when is_list(Val) ->
encode_open_type(list_to_binary(Val), T);
encode_open_type(Val, Tag) ->
encode_tags(Tag, Val, byte_size(Val)).

encode_tags(TagIn, {BytesSoFar, LenSoFar}) ->
encode_tags(TagIn, BytesSoFar, LenSoFar).

Expand Down

0 comments on commit a7b3635

Please sign in to comment.