Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COER decoding fails with a specific item (USDOT SCMS protocol, 1609.2 related) #468

Open
nobodyguy opened this issue Nov 21, 2022 · 0 comments

Comments

@nobodyguy
Copy link

Hello,
I've come across a weird issue with COER decoding.
I have ScopedLocalPolicyFile PDU (XER version is here: https://github.com/nobodyguy/asn1c_sandbox_do_not_use/blob/main/fixtures/ScopedLocalPolicyFile.xml)
When I try to decode it from COER to text or any other encoding, it returns:

AD: Processing ./ScopedLocalPolicyFile.coer
AD: Decoding 1962 bytes
AD: decode(0) consumed 1+0b (1962), code 2
# I added asn_fprint trace with partially decoded struct here:
ScopedLocalPolicyFile ::= {
    version: 1
    content: LocalPolicyFile ::= {
        globalParameters: BasePolicyFile ::= {
            version: 1
            tbsData: ToBeSignedPolicyData ::= {
                policyID: 31 32
                generationTime: 445819815000000
                activeTime: 445819815000000
                policy: CustomPolicyData ::= {
                    requestingRaHostname: test.com
                    globalPolicy: GlobalPolicyData ::= {
                        temporalSeriesOfScmsVersion: temporalSeriesOfScmsVersion ::= {
                            initialScmsVersion: 1
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    scmsVersion: 1
                                }
                            }
                        }
                        temporalSeriesOfCertChainFileID: temporalSeriesOfCertChainFileID ::= {
                            initialGlobalCertChainFileID: 1
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    globalCertChainFileID: 1
                                }
                            }
                        }
                        temporalSeriesOfOverdueCrlTolerance: temporalSeriesOfOverdueCrlTolerance ::= {
                            initialOverdueCrlTolerance: 336
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    overdueCrlTolerance: 336
                                }
                            }
                        }
                        temporalSeriesOfIPeriod: temporalSeriesOfIPeriod ::= {
                            initialIPeriod: 168
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    iPeriod: 168
                                }
                            }
                        }
                        temporalSeriesOfMinCertsPerIPeriod: temporalSeriesOfMinCertsPerIPeriod ::= {
                            initialMinCertsPerIPeriod: 20
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    minCertsPerIPeriod: 20
                                }
                            }
                        }
                        temporalSeriesOfCertValidityModel: temporalSeriesOfCertValidityModel ::= {
                            initialCertValidityModel: 1 (concurrent)
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    certValidityModel: 1 (concurrent)
                                }
                            }
                        }
                        temporalSeriesOfMaxAvailableCertSupply: temporalSeriesOfMaxAvailableCertSupply ::= {
                            initialMaxAvailableCertSupply: 3360
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    maxAvailableCertSupply: 3360
                                }
                            }
                        }
                        temporalSeriesOfMaxCertRequestAge: temporalSeriesOfMaxCertRequestAge ::= {
                            initialMaxCertRequestAge: 48
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    maxCertRequestAge: 48
                                }
                            }
                        }
                        temporalSeriesOfShuffleThreshold: temporalSeriesOfShuffleThreshold ::= {
                            initialShuffleThreshold: 10000
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    shuffleThreshold: 10000
                                }
                            }
                        }
                        temporalSeriesOfHashOfRequestSize: temporalSeriesOfHashOfRequestSize ::= {
                            initialHashOfRequestSize: 32
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    hashOfRequestSize: 32
                                }
                            }
                        }
                        temporalSeriesOfMaxGpfGccfRetrievalInterval: temporalSeriesOfMaxGpfGccfRetrievalInterval ::= {
                            initialMaxGpfGccfRetrievalInterval: 1
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    maxGpfGccfRetrievalInterval: 1
                                }
                            }
                        }
                        temporalSeriesOfRseApplicationCertValidity: temporalSeriesOfRseApplicationCertValidity ::= {
                            initialRseApplicationCertValidity: 169
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    rseApplicationCertValidity: 169
                                }
                            }
                        }
                        temporalSeriesOfRseApplicationCertOVerlap: temporalSeriesOfRseApplicationCertOVerlap ::= {
                            initialRseApplicationCertOverlap: 1
                            intervals: intervals ::= {
                                SEQUENCE ::= {
                                    startTime: 445819815000000
                                    rseApplicationCertOverlap: 1
                                }
                            }
                        }
                    }
                }
            }
            signatures: signatures ::= {
            }
        }
        localParameters: BasePolicyFile ::= {
            version: 0
            tbsData: ToBeSignedPolicyData ::= {
                policyID: 
                generationTime: <absent>
                activeTime: <absent>
                policy: <absent>
            }
            signatures: signatures ::= {
            }
        }
    }
}
AD: Clean up partially decoded ScopedLocalPolicyFile
AD: ofp 1, no=1, oo=0, dbl=0
./ScopedLocalPolicyFile.coer: Decode failed past byte 1: Input processing error

I found out that it's caused by this element:

<temporalSeriesOfMaxCertRequestAge>
	<initialMaxCertRequestAge>
		<hours>48</hours>
	</initialMaxCertRequestAge>
	<intervals>
		<SEQUENCE>
			<startTime>445819815000000</startTime>
			<maxCertRequestAge>
				<hours>48</hours>
			</maxCertRequestAge>
		</SEQUENCE>
	</intervals>
</temporalSeriesOfMaxCertRequestAge>

When I remove it and try to decode it, it works as expected.
What's wrong with that?
temporalSeriesOfMaxCertRequestAge is defined as:

   MaxCertRequestAge ::= Duration  
   
    temporalSeriesOfMaxCertRequestAge SEQUENCE {
        initialMaxCertRequestAge MaxCertRequestAge,
        intervals SEQUENCE SIZE(0..MAX) OF SEQUENCE {
            startTime Time64,
            maxCertRequestAge MaxCertRequestAge
        }
    } OPTIONAL,

I thought that maybe there is something wrong with Time64 or Duration type, but there is also temporalSeriesOfMaxAvailableCertSupply element with the same definition that works.

   MaxAvailableCertSupply ::= Duration
   
    temporalSeriesOfMaxAvailableCertSupply SEQUENCE {
        initialMaxAvailableCertSupply MaxAvailableCertSupply,
        intervals SEQUENCE SIZE(0..MAX) OF SEQUENCE {
            startTime Time64,
            maxAvailableCertSupply MaxAvailableCertSupply
        }
    } OPTIONAL,

I tried the latest master and also latest mouse07410/vlm_master.
Sandbox is here: https://github.com/nobodyguy/asn1c_sandbox_do_not_use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant