Bug in asn1 marshalObjectIdentifier()?

12 views
Skip to first unread message

kongsian

unread,
Jan 12, 2011, 2:19:05 AM1/12/11
to golang-nuts
Hi. I think I've come across a bug in asn1 marshalObjectIdentifier().

func marshalObjectIdentifier(out *forkableWriter, oid []int) (err
os.Error) {
if len(oid) < 2 || oid[0] > 6 || oid[1] >= 40 {
return StructuralError{"invalid object identifier"}
}

err = out.WriteByte(byte(oid[0]*40 + oid[1])) <------ BUG?
if err != nil {
return
}
for i := 2; i < len(oid); i++ {
err = marshalBase128Int(out, int64(oid[i]))
if err != nil {
return
}
}

return
}

The first subidentifier is written out as it is instead of being
marshalled like the rest. Shouldn't it be

err = marshalBase128Int(out,(oid[0]*40 + oid[1]))

Rgds.
Kong Sian

agl

unread,
Jan 14, 2011, 2:48:50 PM1/14/11
to golang-nuts
On Jan 12, 2:19 am, kongsian <kongs...@gmail.com> wrote:
> The first subidentifier is written out as it is instead of being
> marshalled like the rest.  Shouldn't it be
>
> err = marshalBase128Int(out,(oid[0]*40 + oid[1]))

I believe that the OID specification says that the first two
components of an OID are limited so that oid[0]*40 + oid[1] is
unambiguous and fits in a byte.

Do you have an example of an OID for which that's not true?


Cheers

AGL
Reply all
Reply to author
Forward
0 new messages