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

Checksum specification #222

Closed
treiher opened this issue May 7, 2020 · 2 comments · Fixed by #378
Closed

Checksum specification #222

treiher opened this issue May 7, 2020 · 2 comments · Fixed by #378
Assignees
Labels
specification Related to specification package (e.g., specification parsing)

Comments

@treiher
Copy link
Collaborator

treiher commented May 7, 2020

Checksum fields should be verified and generated.

Protocols with messages containing checksum fields:

TCP and UDP use also values of the underlying protocol layer (IP header) for checksum generation.

@treiher treiher added this to To do in RecordFlux 0.5 May 7, 2020
@senier
Copy link
Member

senier commented May 11, 2020

We need to think about the following aspects:

  • Specification
    • How to express fields covered by checksum
      • Start/End field for checksum (Start => F1, End => F8, Exclude => (F3, F4))
        (+) Can cover multiple paths between Start and End
        (+) Simple to specify
        (-) "holes" cannot be supported directly
        (-) checksums where start/end exist on multiple paths cannot be expresses
      • List of covered fields (F1, F2, F5, F6, F7, F8)
        (+) Holes are supported
        (-) Will be lengthy for some formats
        (-) No inherent support for multiple paths
      • List of covered slices ((F1'First .. F2'Last), (F5'First .. F8'Last))
        (+) Holes are supported
      • Function with message-specific parameter list
        (+) Holes are supported
        (+) Non-checksum input (e.g. Key ID in NTP) can be passed
        (-) Will be lengthy for some formats
        (-) No inherent support for multiple paths
    • Irregularities
      • Assumed values for checksum calculation, e.g. checksum field set to 0 for calculation
      • Support for state (e.g. key database in NTP) for functions
      • Holes or rearranged fields (e.g. virtual headers in TCP and UDP)
    • Syntax for checksums
      • Field aspect
        type Message is
        message
           F1 : T;
           F2 : T;
           F3 : T;
           FCS : U32
              with Checksum => (Start => F1, End => F4, Exclude => (F3, FCS));
           F4 : T;
        end message;
      • Checksum function
        type Message is
        message
           F1 : T;
           F2 : T;
           F3 : T;
           FCS : U32
              then F4
                 if FCS = Checksum (F1'First, F4'Last);
           F4 : T;
        end message;
      • Message aspect
        type Message is
        message
           F1 : T;
           F2 : T;
           F3 : T;
           FCS : U32;
           FCS2 : U32;
           F4 : T
              then null if FCS'Valid_Checksum and FCS2'Valid_Checksum;
        end message
            with Checksum => (FCS  => (F1'First, F4'Last),
                              FCS2 => (F2'First, F3'First));
      • Field aspect alternative
        type Message is
        message
           F1 : T;
           F2 : T;
           F3 : T;
           FCS : U32 is Checksum (FCS, F1'First, F4'Last);
           F4 : T
              then null if FCS'Valid_Checksum;
        end message;
  • Parsing
    • Is checksum checked automatically once all required inputs have been processed?
  • Generation
    • Is checksum generated automatically once all required inputs have been processed?
  • Verification
    • How do we add preconditions to checksum function?
    • Do checksum functions need post-conditions
  • SPARK
    • How are checksum functions provided to generated code
  • Python
    • How are checksum functions provided

@treiher
Copy link
Collaborator Author

treiher commented May 11, 2020

Just to summarize the result of our offline discussion:

  • Specification
    • How to express fields covered by checksum
      • List of parameters: indices, field values
    • Irregularities
      • Assumed values for checksum calculation
        • not covered by specification; should be realized in checksum function
      • Support for state (e.g. key database in NTP)
        • can be passed as parameter, but functionality should be covered in separate issue
    • Syntax for checksums
      • Message aspect
        type Message is
           message
              F1 : T;
              F2 : T;
              F3 : T;
              FCS : U32;
              FCS2 : U32;
              F4 : T
                 then null
                    if FCS'Valid_Checksum and FCS2'Valid_Checksum;
           end message
              with Checksum => (FCS  => (F1'First .. F2'Last, F4, F3'First .. F3'Last, F2),
                                FCS2 => (F2'First .. F3'First));
  • Parsing
    • Is checksum checked automatically once all required inputs have been processed?
      • Checksum is only checked by explicit condition.
  • Generation
    • Is checksum generated automatically once all required inputs have been processed?
      • SPARK: Checksum must be generated manually.
      • Python: Checksum is set automatically by _preset_fields method.
  • Verification
    • How do we add preconditions to checksum function?
      • Lemma function, if needed.
    • Do checksum functions need post-conditions?
      • Lemma function, if needed.
  • SPARK
    • How are checksum functions provided to generated code
      • Generic parameter
  • Python
    • How are checksum functions provided
      • Callable as parameter of MessageValue

@treiher treiher mentioned this issue May 14, 2020
3 tasks
@senier senier moved this from To do to In progress in RecordFlux 0.5 May 14, 2020
@treiher treiher changed the title Checksum fields Checksum specification May 14, 2020
@senier senier moved this from In progress to To do in RecordFlux 0.5 Jun 4, 2020
@treiher treiher added the specification Related to specification package (e.g., specification parsing) label Jul 2, 2020
@treiher treiher moved this from To do to In progress in RecordFlux 0.5 Jul 2, 2020
@treiher treiher moved this from In progress to Done in RecordFlux 0.5 Jul 23, 2020
@treiher treiher moved this from Ready to In progress in RecordFlux 0.5 Jul 29, 2020
treiher added a commit that referenced this issue Jul 30, 2020
@treiher treiher moved this from In progress to Ready in RecordFlux 0.5 Jul 30, 2020
treiher added a commit that referenced this issue Jul 30, 2020
RecordFlux 0.5 automation moved this from Ready to Merged Jul 30, 2020
treiher added a commit that referenced this issue Jul 30, 2020
treiher added a commit that referenced this issue Jul 30, 2020
@treiher treiher mentioned this issue Aug 4, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
specification Related to specification package (e.g., specification parsing)
Projects
No open projects
RecordFlux 0.5
  
Merged
Development

Successfully merging a pull request may close this issue.

2 participants