summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-14 10:15:31 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-14 10:15:31 +0100
commitf1a08e7fb82e813ce6985460cc2606fc7b19ae13 (patch)
tree5b68ec0289b228cef09420fc985043ff33105951 /src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
parentssb non-standard signature encoding covered (decode only) (diff)
downloadUIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar
UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.gz
UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.bz2
UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.lz
UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.xz
UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.zst
UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java')
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java b/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
index 2ea4a51..48c8eaf 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
@@ -2,6 +2,7 @@ package org.uic.barcode.ssbFrame;
import org.uic.barcode.asn1.uper.BitBuffer;
import org.uic.barcode.asn1.uper.ByteBitBuffer;
+import org.uic.barcode.ticket.EncodingFormatException;
public class SsbHeader extends SsbTicketPart {
@@ -40,13 +41,28 @@ public class SsbHeader extends SsbTicketPart {
}
- public int encodeContent(byte[] bytes, int offset) {
+ public int encodeContent(byte[] bytes, int offset) throws EncodingFormatException {
BitBuffer bits = new ByteBitBuffer(bytes);
+ if (version < 0 || version > 15) {
+ throw new EncodingFormatException("SSB Version too big");
+ }
+
bits.putInteger(0, 4, version);
+
+ if (issuer < 0 || issuer > 9999) {
+ throw new EncodingFormatException("SSB Issuer code too big");
+ }
+
bits.putInteger(4, 14, issuer);
+
+ if (keyId < 0 || keyId > 15) {
+ throw new EncodingFormatException("SSB Key Id too big");
+ }
+
bits.putInteger(18, 4, keyId);
+
bits.putInteger(22, 5, ticketType.ordinal());
return 4 + 14 + 4 + 5;