Fix CHOICE DER support

This commit is contained in:
2025-02-25 21:58:39 +00:00
parent 18541786e1
commit 10560371ab
2 changed files with 6 additions and 5 deletions

View File

@@ -48,7 +48,7 @@ namespace StudySystemClient.Der {
private static Datum decode_datum(uint8 type, uint8[] content)
throws DecodeError {
if ((type & 0xc0) == Choice.BASE_TYPE)
if ((type & ~Choice.ID_MASK) == Choice.BASE_TYPE)
return new Choice.from_content(type, content);
switch (type) {
case Boolean.TYPE:
@@ -266,7 +266,8 @@ namespace StudySystemClient.Der {
}
public class Choice : Datum {
internal const uint8 BASE_TYPE = 0x80;
internal const uint8 BASE_TYPE = 0xa0;
internal const uint8 ID_MASK = 0x1f;
public int id { get; private set; }
public Datum value { get; private set; }
@@ -282,7 +283,7 @@ namespace StudySystemClient.Der {
throws DecodeError {
this.type = type;
content = bytes;
id = type & 0x3f;
id = type & ID_MASK;
value = decode(bytes);
}
}