Skip to content

Latest commit

 

History

History
116 lines (78 loc) · 1.43 KB

asn_proto_mappings.md

File metadata and controls

116 lines (78 loc) · 1.43 KB

ASN.1 to Proto Mappings

Trivial Conversions

ENUMERATED

ENUMERATED type in ASN.1 can be converted to enum directly in protobuf. For example,

Fuel ::= ENUMERATED {
    solid(0),
    liquid(1),
    gas(2),
    hybrid(3)
}

to

enum Fuel {
        solid = 0;
        liquid = 1;
        gas = 2;
        hybrid = 3;
}

CHOICE OF

CHOICE OF type in ASN.1 can be converted to oneof in protobuf

For example

speed CHOICE {
        mph INTEGER,
        kmph INTEGER
    },

to

oneof speed  { 
          int32 mph = 4; 
          int32 kmph = 5;
        }  

SEQUENCE

SEQUENCE type in ASN.1 can be mapped to message in protobuf

RepeatedExample ::= SEQUENCE {
    repeated_field SEQUENCE OF INTEGER
}
message RepeatedExample {
   repeated int32 repeated_field = 1;

}

SEQUENCE OF

SEQUENCE OF type in ASN.1 to repeated in protobuf

RepeatedExample ::= SEQUENCE {
    repeated_field SEQUENCE OF INTEGER
}
message RepeatedExample {
   repeated int32 repeated_field = 1;

}

SEQUENCE OF SEQUENCE

SEQUENCE OF SEQUENCE type in ASN.1 can be mapped to map in protobuf

MapExample ::= SEQUENCE {
    my_map SEQUENCE OF SEQUENCE {
        key INTEGER,
        value UTF8String
    }
}
message MapExample {
  map<int32, string> my_map = 4;

}

Non Trivial Conversions