Hello,

I still have some doubts with regard to the unrestricted INTEGER.
Say the protocol definition has

addr-type       INTEGER

So the native specification ( say C ) will convert it into

int addr-type

But then which specification says the INTEGER datatype of ASN should be
mapped to int in C and not to 'unsigned int' or 'short int' or 'long int'.

In short I mean to say is that is there any documented standard that
restricts the unrestricted INTEGER to the native language so that all
compilers restrict in the same fashion.

Also could anyone point me to some links that have ASN.1 definitions for
Kerberos protocol *_with_default_values_for_all_fields_* or sample values
for all fields defined seperately.  All I want to do is test my own DER
encoder for those values as I do not want to get into understanding the
field values for Kerberos protocol.

Ajay Dudani


 On Mon, 12 Mar 2001, Geoff Elgey wrote:

> However, the ASN.1 syntax does allow the value of an INTEGER to be
> restricted, using constraints, as follows:
>
> Byte ::= INTEGER(0..255)
> PortNum ::= INTEGER(0..16000)
> PublicKeyLength ::= INTEGER(128|256|512|1024|2048|4096)
> SerialNumber ::= INTEGER(0..MAX)
>
> In such cases, the compiler *should* generate a native representation
> that will be sufficient to contain the types, as follows:
>
> typedef uint8_t Byte;
> typedef uint16_t PortNum;
> typedef uint16_t PublicKeyLength;
> typedef BigInteger SerialNumber;
>
> Theoretically, if the protocol specifies an unrestricted INTEGER type,
> and the native type representation uses a type that does not cover the
> range of possible values, then the native type is incorrectly specified.
>
> > Also if it is for the compiler to decide this, then in the absence of any general 
>specification
> > for limiting the length, if there are two different compilers doing encoding and 
>decoding
> > at different ends and if the encoding and decoing follows different rules to limit 
>the
> > integer, then how would both sides decides out on this.
>
> The compiler does not "decide this" - see the above points about writing
> ASN.1 syntax such that the integer values can be constrained.
>
> Of course, the application designer may decide, even though the protocol
> uses the unrestricted type INTEGER, that values will be restricted to
> the range of the native C type 'int', and if the length of the received
> INTEGER value is more than 4 octets, that it is in error. This can be
> communicated to the compiler via pragma's. However, it is preferable to
> constrain the INTEGER type in the protocol specification.
>
> Hope this helps.
>
> Cheers,
> Geoff
>

______________________________________________________
Dudani, Ajay B.
Engineer Trainee - Wireless Infrastructure,
MOTOROLA INDIA ELECTRONICS LTD.,
No : 33-A, Ulsoor Road, Bangalore, INDIA. Pin - 560042
Phone : (91) (80) 5598615, Ext : 4202
EMail : [EMAIL PROTECTED]
______________________________________________________


Reply via email to