Giter VIP home page Giter VIP logo

binarynotes.net's Issues

Null reference exception when encoding SET OF INTEGER

Trying to encode this ASN.1 sequence

AuthorizationList ::= SEQUENCE {
    purpose [1] SET OF INTEGER OPTIONAL,
    algorithm [2] INTEGER OPTIONAL,
    keySize [3] INTEGER OPTIONAL,
    digest [5] SET OF INTEGER OPTIONAL,
    ecCurve [10] INTEGER OPTIONAL,
    noAuthRequired [503] NULL OPTIONAL,
    creationDateTime [701] INTEGER OPTIONAL,
    origin [702] INTEGER OPTIONAL,
    rootOfTrust [704] RootOfTrust OPTIONAL,
    osVersion [705] INTEGER OPTIONAL,
    osPatchLevel [706] INTEGER OPTIONAL,
    attestationApplicationId [709] OCTET STRING OPTIONAL,
    attestationIdSerial [713] OCTET STRING OPTIONAL,
    vendorPatchLevel [718] INTEGER OPTIONAL,
    bootPatchLevel [719] INTEGER OPTIONAL
}

I used the compiler to turn that into this class


//
// This file was generated by the BinaryNotes compiler (created by Abdulla Abdurakhmanov, modified by Sylvain Prevost).
// See http://bnotes.sourceforge.net 
// Any modifications to this file will be lost upon recompilation of the source ASN.1. 
//

using System;
using System.Numerics;

using org.bn.attributes;
using org.bn.attributes.constraints;
using org.bn.coders;
using org.bn.types;
using org.bn;

namespace Test
{


    [ASN1PreparedElement]
    [ASN1Sequence(Name = "AuthorizationList", IsSet = false)]
    public class AuthorizationList : IASN1PreparedElement
    {

        private ICollection<BigInteger> purpose_;

        private bool purpose_present = false;
        [ASN1Integer(Name = "")]

        [ASN1SequenceOf(Name = "purpose", IsSetOf = true)]

        [ASN1Element(Name = "purpose", IsOptional = true, HasTag = true, Tag = 1, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public ICollection<BigInteger> Purpose
        {
            get { return purpose_; }
            set { purpose_ = value; purpose_present = true; }
        }

        private BigInteger algorithm_;

        private bool algorithm_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "algorithm", IsOptional = true, HasTag = true, Tag = 2, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger Algorithm
        {
            get { return algorithm_; }
            set { algorithm_ = value; algorithm_present = true; }
        }

        private BigInteger keySize_;

        private bool keySize_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "keySize", IsOptional = true, HasTag = true, Tag = 3, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger KeySize
        {
            get { return keySize_; }
            set { keySize_ = value; keySize_present = true; }
        }

        private ICollection<BigInteger> digest_;

        private bool digest_present = false;
        [ASN1Integer(Name = "")]

        [ASN1SequenceOf(Name = "digest", IsSetOf = true)]

        [ASN1Element(Name = "digest", IsOptional = true, HasTag = true, Tag = 5, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public ICollection<BigInteger> Digest
        {
            get { return digest_; }
            set { digest_ = value; digest_present = true; }
        }

        private BigInteger ecCurve_;

        private bool ecCurve_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "ecCurve", IsOptional = true, HasTag = true, Tag = 10, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger EcCurve
        {
            get { return ecCurve_; }
            set { ecCurve_ = value; ecCurve_present = true; }
        }

        private NullObject noAuthRequired_;

        private bool noAuthRequired_present = false;

        [ASN1Null(Name = "noAuthRequired")]

        [ASN1Element(Name = "noAuthRequired", IsOptional = true, HasTag = true, Tag = 503, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public NullObject NoAuthRequired
        {
            get { return noAuthRequired_; }
            set { noAuthRequired_ = value; noAuthRequired_present = true; }
        }

        private BigInteger creationDateTime_;

        private bool creationDateTime_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "creationDateTime", IsOptional = true, HasTag = true, Tag = 701, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger CreationDateTime
        {
            get { return creationDateTime_; }
            set { creationDateTime_ = value; creationDateTime_present = true; }
        }

        private BigInteger origin_;

        private bool origin_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "origin", IsOptional = true, HasTag = true, Tag = 702, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger Origin
        {
            get { return origin_; }
            set { origin_ = value; origin_present = true; }
        }

        private RootOfTrust rootOfTrust_;

        private bool rootOfTrust_present = false;

        [ASN1Element(Name = "rootOfTrust", IsOptional = true, HasTag = true, Tag = 704, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public RootOfTrust RootOfTrust
        {
            get { return rootOfTrust_; }
            set { rootOfTrust_ = value; rootOfTrust_present = true; }
        }

        private BigInteger osVersion_;

        private bool osVersion_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "osVersion", IsOptional = true, HasTag = true, Tag = 705, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger OsVersion
        {
            get { return osVersion_; }
            set { osVersion_ = value; osVersion_present = true; }
        }

        private BigInteger osPatchLevel_;

        private bool osPatchLevel_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "osPatchLevel", IsOptional = true, HasTag = true, Tag = 706, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger OsPatchLevel
        {
            get { return osPatchLevel_; }
            set { osPatchLevel_ = value; osPatchLevel_present = true; }
        }

        private byte[] attestationApplicationId_;

        private bool attestationApplicationId_present = false;
        [ASN1OctetString(Name = "")]

        [ASN1Element(Name = "attestationApplicationId", IsOptional = true, HasTag = true, TagClass = TagClasses.ContextSpecific, Tag = 709, IsImplicitTag = false, HasDefaultValue = false)]
        public byte[] AttestationApplicationId
        {
            get { return attestationApplicationId_; }
            set { attestationApplicationId_ = value; attestationApplicationId_present = true; }
        }

        private byte[] attestationIdSerial_;

        private bool attestationIdSerial_present = false;
        [ASN1OctetString(Name = "")]

        [ASN1Element(Name = "attestationIdSerial", IsOptional = true, HasTag = true, Tag = 713, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public byte[] AttestationIdSerial
        {
            get { return attestationIdSerial_; }
            set { attestationIdSerial_ = value; attestationIdSerial_present = true; }
        }

        private BigInteger vendorPatchLevel_;

        private bool vendorPatchLevel_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "vendorPatchLevel", IsOptional = true, HasTag = true, Tag = 718, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger VendorPatchLevel
        {
            get { return vendorPatchLevel_; }
            set { vendorPatchLevel_ = value; vendorPatchLevel_present = true; }
        }

        private BigInteger bootPatchLevel_;

        private bool bootPatchLevel_present = false;
        [ASN1Integer(Name = "")]

        [ASN1Element(Name = "bootPatchLevel", IsOptional = true, HasTag = true, Tag = 719, TagClass = TagClasses.ContextSpecific, IsImplicitTag = false, HasDefaultValue = false)]
        public BigInteger BootPatchLevel
        {
            get { return bootPatchLevel_; }
            set { bootPatchLevel_ = value; bootPatchLevel_present = true; }
        }

        public bool isPurposePresent()
        {
            return purpose_present == true;
        }

        public bool isAlgorithmPresent()
        {
            return algorithm_present == true;
        }

        public bool isKeySizePresent()
        {
            return keySize_present == true;
        }

        public bool isDigestPresent()
        {
            return digest_present == true;
        }

        public bool isEcCurvePresent()
        {
            return ecCurve_present == true;
        }

        public bool isCreationDateTimePresent()
        {
            return creationDateTime_present == true;
        }

        public bool isOriginPresent()
        {
            return origin_present == true;
        }

        public bool isRootOfTrustPresent()
        {
            return rootOfTrust_present == true;
        }

        public bool isOsVersionPresent()
        {
            return osVersion_present == true;
        }

        public bool isOsPatchLevelPresent()
        {
            return osPatchLevel_present == true;
        }

        public bool isAttestationApplicationIdPresent()
        {
            return attestationApplicationId_present == true;
        }

        public bool isAttestationIdSerialPresent()
        {
            return attestationIdSerial_present == true;
        }

        public bool isVendorPatchLevelPresent()
        {
            return vendorPatchLevel_present == true;
        }

        public bool isBootPatchLevelPresent()
        {
            return bootPatchLevel_present == true;
        }


        public void initWithDefaults()
        {

        }

        private static IASN1PreparedElementData preparedData = CoderFactory.getInstance().newPreparedElementData(typeof(AuthorizationList));
        public IASN1PreparedElementData PreparedData
        {
            get { return preparedData; }
        }

    }

}

When I was trying to figure it out myself I debugged the project and saw that the null reference exception was happening on this line when trying to encode the Digest field.
Screenshot 2024-06-18 165117

I'm sure I'm just missing something small, but I would really appreciate some help or advice. Thanks!

Unable to compile example ans file

Hi,

I am unable to run the sample or test compiler application. The bncompiler does not generate classes. I understand that bncompiler is not your software.

Any ideas?

Running Windows 10

Java version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

Exception thrown
C:\Users\-----\Downloads\BinaryNotes.NET-master\BinaryNotes.NET-master\Tests>call ..\bncompiler\bnc.cmd -mp ..\cs_xsl_modules -o %OUTPUT_DIR% -ns test.org.bn.coders.test_asn -f test.asn BinaryNotes compiler v1.5.3 (c) 2006-2011 Abdulla G. Abdurakhmanov Current directory: C:\Users\-----\Downloads\BinaryNotes.NET-master\BinaryNotes.NET-master\Tests Compiling file: test.asn Exception in thread "main" java.lang.ExceptionInInitializerError at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:41) at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:128) at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:203) at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.<init>(SingleElementLeafProperty.java:45) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:87) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:112) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:373) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:228) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:124) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:132) at javax.xml.bind.ContextFinder.find(ContextFinder.java:299) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:358) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:323) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244) at org.bn.compiler.Main.createModel(Unknown Source) at org.bn.compiler.Main.startForModule(Unknown Source) at org.bn.compiler.Main.start(Unknown Source) at org.bn.compiler.Main.main(Unknown Source) Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @b4c966a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.