CGI-SE-Trusted-Services / c2c-common

http://pvendil.github.io/c2c-common/
GNU Affero General Public License v3.0
45 stars 18 forks source link

PsidGroupPermissions created incorrectly in ETSIAuthorityCertGenerator.java #16

Open siefm opened 3 years ago

siefm commented 3 years ago

Hello, I believe that following line: https://github.com/pvendil/c2c-common/blob/987d78f451ebf5e81a6e807482967845d78cf9b8/src/main/java/org/certificateservices/custom/c2x/etsits103097/v131/generator/ETSIAuthorityCertGenerator.java#L307

should be correctly called like this:

PsidGroupPermissions pgp =  new PsidGroupPermissions(sp, null, null, new EndEntityType(true, false)); 


Calling it with values 1 and 0 which are default values for minChainDepth and chainDepthRange produces invalid COER structure according to ITU-T X.696:

31 Canonical Octet Encoding Rules 31.9 In the encoding of a sequence or set type, each component that is marked DEFAULT shall be encoded as absent if its value is identical to the default value.


Using nulls is suggested also by documentation: https://github.com/pvendil/c2c-common/blob/987d78f451ebf5e81a6e807482967845d78cf9b8/src/main/java/org/certificateservices/custom/c2x/ieee1609dot2/datastructs/cert/PsidGroupPermissions.java#L76-L77

nickdurante commented 3 years ago

Hi @siefm, @pvendil.

I have been testing this bug and indeed changing the PsidGroupPermissions to the value indicated by @siefm produces a valid COER sequence, while the previous method didn't.