[
https://issues.jboss.org/browse/ELY-618?page=com.atlassian.jira.plugin.sy...
]
Ilia Vassilev commented on ELY-618:
-----------------------------------
[~fjuma] Correct me if I'm wrong, but the whole logic in DEREncoder is designed for
tag numbers <= 30 (single octet). According to the spec [1], tag numbers > 30 needs
multiple octets and the implementation in {{DEREncoder.writeTag()}} method is intended to
do this. Unfortunately, the logic only works on single octet tags (tag number <= 30).
The good think is that all of the tags in {{ASN1.java}} are single octet and work fine
with the current implementation. The public methods {{startExplicit(int number),
startExplicit(int clazz, int number), encodeImplicit(int number), encodeImplicit(int
clazz, int number)}} take tag number but the implementation will only work on tags <=
30. If we decide to keep the current implementation (tag number <= 30), we can remove
some of the logic in {{DEREncoder.writeTag()}} method and add checks in the public
methods. To implement the full spec, some redesign is needed.
[1]
https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf (page 4)
Dead code in DEREncoder
-----------------------
Key: ELY-618
URL:
https://issues.jboss.org/browse/ELY-618
Project: WildFly Elytron
Issue Type: Bug
Affects Versions: 1.1.0.Beta7
Reporter: Ondrej Lukas
Assignee: Ilia Vassilev
Labels: static_analysis
There is an unintentional dead code in writeTag method of
org.wildfly.security.asn1.DEREncoder. Variable {{tagNumber}} can be assigned to 31 as its
maximal value from {{int tagNumber = tag & TAG_NUMBER_MASK;}} (because
{{TAG_NUMBER_MASK = 0x1f}}) on line 576 [1] which means that condition {{if (tagNumber
< 128)}} on line 582 is always true. It causes that else branch is never executed.
[1]
https://github.com/wildfly-security/wildfly-elytron/blob/4453ea40a7a617b6...
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)