Skip to content

Commit

Permalink
Merge pull request #12 from RUB-NDS/dependencyUpdate
Browse files Browse the repository at this point in the history
New ModifiableVariable Version
  • Loading branch information
ic0ns authored Sep 9, 2020
2 parents 49c9d80 + 107281e commit 2876865
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 86 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>de.rub.nds</groupId>
<artifactId>ModifiableVariable</artifactId>
<version>2.4</version>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
161 changes: 76 additions & 85 deletions src/main/java/de/rub/nds/asn1tool/Asn1Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import de.rub.nds.asn1tool.xmlparser.XmlParser;
import de.rub.nds.modifiablevariable.biginteger.*;
import de.rub.nds.modifiablevariable.bool.BooleanExplicitValueModification;
import de.rub.nds.modifiablevariable.bool.BooleanToogleModification;
import de.rub.nds.modifiablevariable.bool.ModifiableBoolean;
import de.rub.nds.modifiablevariable.bytearray.*;
import de.rub.nds.modifiablevariable.integer.*;
Expand Down Expand Up @@ -46,100 +45,92 @@ public static void main(final String[] args) {
byte[] encodedAsn1 = asn1Encoder.encode();

// Write result to file in args[1]
if(args.length < 3) {
if (args.length < 3) {
throw new RuntimeException("Expected argument 1: Output file directory\nExpected argument 2: Output file name");
}
HexFileWriter hexFileWriter = new HexFileWriter(args[1], args[2]);
hexFileWriter.write(encodedAsn1);
} catch(IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
} catch(ClassCastException e) {
} catch (ClassCastException e) {
throw new RuntimeException("An unknown object is found within the parsed ASN.1 structure! Did you use an unspecified element?", e);
}
}

public static Class[] getAsn1ToolJaxbClasses() {
return new Class[] {
// ModifiableVariables
ModifiableBigInteger.class,
BigIntegerAddModification.class,
BigIntegerExplicitValueModification.class,
BigIntegerInteractiveModification.class,
BigIntegerShiftLeftModification.class,
BigIntegerShiftRightModification.class,
BigIntegerSubtractModification.class,
BigIntegerXorModification.class,

ModifiableBoolean.class,
BooleanExplicitValueModification.class,

ModifiableByteArray.class,
ByteArrayDeleteModification.class,
ByteArrayDuplicateModification.class,
ByteArrayExplicitValueModification.class,
ByteArrayInsertModification.class,
ByteArrayPayloadModification.class,
ByteArrayShuffleModification.class,
ByteArrayXorModification.class,

ModifiableInteger.class,
IntegerAddModification.class,
IntegerExplicitValueModification.class,
IntegerShiftLeftModification.class,
IntegerShiftRightModification.class,
IntegerSubtractModification.class,
IntegerXorModification.class,

ModifiableLong.class,
LongAddModification.class,
LongExplicitValueModification.class,
LongSubtractModification.class,
LongXorModification.class,

ModifiableByte.class,
ByteAddModification.class,
ByteExplicitValueModification.class,
ByteSubtractModification.class,
ByteXorModification.class,

ModifiableString.class,
StringExplicitValueModification.class,

// ASN.1 classes
Asn1XmlContent.class,

Asn1Boolean.class,
Asn1ConstructedBitString.class,
Asn1ConstructedIa5String.class,
Asn1ConstructedOctetString.class,
Asn1ConstructedPrintableString.class,
Asn1ConstructedT61String.class,
Asn1ConstructedUtcTime.class,
Asn1ConstructedUtf8String.class,
Asn1Container.class,
Asn1EncapsulatingBitString.class,
Asn1EncapsulatingOctetString.class,
Asn1EndOfContent.class,
Asn1Enumerated.class,
Asn1Explicit.class,
Asn1Field.class,
Asn1Integer.class,
Asn1Null.class,
Asn1ObjectIdentifier.class,
Asn1PrimitiveBitString.class,
Asn1PrimitiveIa5String.class,
Asn1PrimitiveOctetString.class,
Asn1PrimitivePrintableString.class,
Asn1PrimitiveT61String.class,
Asn1PrimitiveUtcTime.class,
Asn1PrimitiveUtf8String.class,
Asn1RawField.class,
Asn1Sequence.class,
Asn1Set.class,
Asn1RawBytes.class,
Asn1Implicit.class

// Todo: Support all native ASN.1 types. So far, only the types relevant for X.509 are supported.
return new Class[]{
// ModifiableVariables
ModifiableBigInteger.class,
BigIntegerAddModification.class,
BigIntegerExplicitValueModification.class,
BigIntegerInteractiveModification.class,
BigIntegerShiftLeftModification.class,
BigIntegerShiftRightModification.class,
BigIntegerSubtractModification.class,
BigIntegerXorModification.class,
ModifiableBoolean.class,
BooleanExplicitValueModification.class,
ModifiableByteArray.class,
ByteArrayDeleteModification.class,
ByteArrayDuplicateModification.class,
ByteArrayExplicitValueModification.class,
ByteArrayInsertModification.class,
ByteArrayPayloadModification.class,
ByteArrayShuffleModification.class,
ByteArrayXorModification.class,
ModifiableInteger.class,
IntegerAddModification.class,
IntegerExplicitValueModification.class,
IntegerShiftLeftModification.class,
IntegerShiftRightModification.class,
IntegerSubtractModification.class,
IntegerXorModification.class,
ModifiableLong.class,
LongAddModification.class,
LongExplicitValueModification.class,
LongSubtractModification.class,
LongXorModification.class,
ModifiableByte.class,
ByteAddModification.class,
ByteExplicitValueModification.class,
ByteSubtractModification.class,
ByteXorModification.class,
ModifiableString.class,
StringExplicitValueModification.class,
// ASN.1 classes
Asn1XmlContent.class,
Asn1Boolean.class,
Asn1ConstructedBitString.class,
Asn1ConstructedIa5String.class,
Asn1ConstructedOctetString.class,
Asn1ConstructedPrintableString.class,
Asn1ConstructedT61String.class,
Asn1ConstructedUtcTime.class,
Asn1ConstructedUtf8String.class,
Asn1Container.class,
Asn1EncapsulatingBitString.class,
Asn1EncapsulatingOctetString.class,
Asn1EndOfContent.class,
Asn1Enumerated.class,
Asn1Explicit.class,
Asn1Field.class,
Asn1Integer.class,
Asn1Null.class,
Asn1ObjectIdentifier.class,
Asn1PrimitiveBitString.class,
Asn1PrimitiveIa5String.class,
Asn1PrimitiveOctetString.class,
Asn1PrimitivePrintableString.class,
Asn1PrimitiveT61String.class,
Asn1PrimitiveUtcTime.class,
Asn1PrimitiveUtf8String.class,
Asn1RawField.class,
Asn1Sequence.class,
Asn1Set.class,
Asn1RawBytes.class,
Asn1Implicit.class

// Todo: Support all native ASN.1 types. So far, only the types relevant for X.509 are supported.
};
}
}

0 comments on commit 2876865

Please sign in to comment.