diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:15:31 +0100 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:15:31 +0100 |
commit | f1a08e7fb82e813ce6985460cc2606fc7b19ae13 (patch) | |
tree | 5b68ec0289b228cef09420fc985043ff33105951 /src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java | |
parent | ssb non-standard signature encoding covered (decode only) (diff) | |
download | UIC-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.java | 18 |
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; |