File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Numerics ;
4+
5+ namespace SysadminsLV . Asn1Parser . Utils ;
6+ static class OidUtils {
7+ public static IEnumerable < Byte > EncodeOidArc ( BigInteger arcValue ) {
8+ List < Byte > rawOid = [ ] ;
9+ BigInteger temp = arcValue ;
10+ // calculate how many bits are occupied by the current integer value
11+ Int16 bitLength = 0 ;
12+ do {
13+ temp = ( BigInteger ) Math . Floor ( ( Double ) temp / 2 ) ;
14+ bitLength ++ ;
15+ } while ( temp > 0 ) ;
16+ // calculate how many additional bytes are required and encode each integer in a 7 bit.
17+ // 8th bit of the integer is shifted to the left and 8th bit is set to 1 to indicate that
18+ // additional bytes are related to the current OID arc. Details:
19+ // http://msdn.microsoft.com/en-us/library/bb540809(v=vs.85).aspx
20+ // loop may not execute if arc value is less than 128.
21+ for ( Int32 index = ( bitLength - 1 ) / 7 ; index > 0 ; index -- ) {
22+ rawOid . Add ( ( Byte ) ( 0x80 | ( ( arcValue >> ( index * 7 ) ) & 0x7f ) ) ) ;
23+ }
24+ rawOid . Add ( ( Byte ) ( arcValue & 0x7f ) ) ;
25+
26+ return rawOid ;
27+ }
28+ public static String DecodeOidArc ( IEnumerable < Byte > rawData ) {
29+ throw new NotImplementedException ( ) ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments