OCTET STRING

The ASN.1 OCTET STRING type is mapped to the Go OctetString type defined within the ASN.1 run-time (asn1rt.OctetString). This is in turn mapped to a byte slice. For example:

ASN.1:

   MyOctStr ::= OCTET STRING

Generated Go code:

   type MyOctStr asn1rt.OctetString

Contents Constraint

It is possible to specify a contents constraint on an OCTET STRING type using the CONTAINING keyword. This indicates that the encoded contents of the specified type should be packed within the OCTET STRING container. An example of this type of constraint is as follows:

   ContainingOS ::= OCTET STRING (CONTAINING INTEGER)

ASN1C will generate a type definition that references the type that is within the containing constraint. In this case, that would be INTEGER; therefore, the Go type for INTEGER would be used, which is int64. This direct use of the containing type can be suppressed through the use of the -noContaining command-line argument. In that case, a normal OCTET STRING type will be used and it will be the user's responsibility to do the necessary packing and unpacking operations to encode and decode the variable correctly.