Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/arne.welzel/ldap-asn1-fixes'
Browse files Browse the repository at this point in the history
* origin/topic/arne.welzel/ldap-asn1-fixes:
  performance improvements for the LDAP ASN.1 analyzer
  • Loading branch information
awelzel committed Oct 18, 2023
2 parents 4d4792b + 2bef110 commit 9dc0535
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions analyzer/asn1.spicy
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,29 @@ type ASN1ObjectIdentifierNibble = unit {
} &convert=self.data;

type ASN1ObjectIdentifier = unit(len: uint64) {
var oid: vector<uint64>;
var oidbytes: bytes;
var temp: uint64;
var oidstring: string;

: uint8 if ( len >= 1 ) {
self.temp = $$ / 40;
self.oid.push_back( self.temp );
self.oidstring = "%d" % (self.temp);
self.oidbytes += ("%d" % (self.temp)).encode();
self.temp = $$ % 40;
self.oid.push_back( self.temp );
self.oidstring = self.oidstring + ".%d" % (self.temp);
self.oidbytes += (".%d" % (self.temp)).encode();
self.temp = 0;
}

sublist: ASN1ObjectIdentifierNibble[len - 1] foreach {
self.temp = ( self.temp<<7 ) | $$.num;
if ( $$.more != 1 ) {
self.oid.push_back(self.temp);
self.oidstring = self.oidstring + ".%d" % (self.temp);
self.oidbytes += (".%d" % (self.temp)).encode();
self.temp = 0;
}
}

on %done {
self.oidstring = self.oidbytes.decode();
}
};


Expand Down

0 comments on commit 9dc0535

Please sign in to comment.