garden ::= SEQUENCE {
aLotOfFruit SET OF fruit
}
fruit ::= CHOICE {
apple INTEGER,
pear INTEGER
…
}
In version 2, I extend the CHOICE:
fruit ::= CHOICE {
apple INTEGER,
pear INTEGER,
…
orange INTEGER
}
My question would be: how version 1 decoder decode the data version 2 encoder generated?
I write code to test, but fail to pass check constraints, due to version 1 decoder don't support 'orange'. I'm a beginner of ASN1, I thought decoder should discard un-recognized data to keep compatibility? (Version 1 decoder could decode, with no error code return, but why check constraints failed? How could I extend a CHOICE in daily use…)
The version 2 encoded data like:
0x30, 0x0E,
0x31, 0x0C,
0xA0, 0x02, 0x01, 0x01,
0xA1, 0x02, 0x01, 0x02,
0xA2, 0x02, 0x01, 0x03
Thanks for reply.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In version 1, I define a CHOICE like:
garden ::= SEQUENCE {
aLotOfFruit SET OF fruit
}
fruit ::= CHOICE {
apple INTEGER,
pear INTEGER
…
}
In version 2, I extend the CHOICE:
fruit ::= CHOICE {
apple INTEGER,
pear INTEGER,
…
orange INTEGER
}
My question would be: how version 1 decoder decode the data version 2 encoder generated?
I write code to test, but fail to pass check constraints, due to version 1 decoder don't support 'orange'. I'm a beginner of ASN1, I thought decoder should discard un-recognized data to keep compatibility? (Version 1 decoder could decode, with no error code return, but why check constraints failed? How could I extend a CHOICE in daily use…)
The version 2 encoded data like:
0x30, 0x0E,
0x31, 0x0C,
0xA0, 0x02, 0x01, 0x01,
0xA1, 0x02, 0x01, 0x02,
0xA2, 0x02, 0x01, 0x03
Thanks for reply.