refac #2

Open
wehack-dev wants to merge 9 commits from wehack-dev/ssh_protocol-ada:refac into main
Contributor
No description provided.
- #6: Empty_Byte_Array constant replaces 9 empty-array literals
- #7: Clear_All_Sensitive_Data shared by Send_Disconnect and Disconnected
- #10: named payload buffer constants replace magic numbers
- #5: Init_Transport_Ciphers reports failure via out OK; abort KEX with
  Key_Exchange_Failed instead of silently continuing with broken
  encryption; ephemeral DH material is cleared on success and failure
- tests: fake KEX backend + cipher-init-failure test (288 -> 301)
Promote the 8 remaining nested subprograms inside Transport_Process to
package-private level, parameterized explicitly instead of capturing
outer variables:

- Is_Guess_Right (Session) / Verify_Host_Key (Session) return Boolean
- Detect_Strict_KEX (Session in out)
- Is_Allowed_KEX_Message (Msg) / Handle_Incoming_Debug (Session, Payload)
- Handle_Global_Messages (signature unchanged, calls promoted helpers)
- Emit_KEXINIT (Session, Output, Output_Last, Status): locals Pl_Last/
  Pkt_Last/Buf_St internalized, all paths set Status explicitly,
  Output_Last initialized to Output'First-1 at entry (out param check)
- Store_Peer_KEXINIT (Session, Payload, Payload_Len)

Call sites updated: Emit_KEXINIT x4 simplified to check Status instead
of Buf_St, Store_Peer_KEXINIT x3, Verify_Host_Key x2, Detect_Strict_KEX
x2, Is_Guess_Right x3. Removed now-unused Pl_Last local.

External interface (.ads) unchanged; behavior preserved. All tests pass.
Split the Transport_Process state machine into 7 package-private
procedures, one per Transport_State, and reduce Transport_Process to
a thin dispatcher over Session.State:

- Process_Initial / Process_Kex_Init_Sent / Process_Kex_Init_Received /
  Process_Kex_DH / Process_Newkeys_Sent / Process_Authenticated /
  Process_Disconnected
- Each state procedure begins with the shared entry initialisation
  (Status := Disconnected; Output_Last := Output'First - 1) and declares
  only the locals it actually uses (Payload/Payload_Len/Pkt_Last/Buf_St/
  Peer_Cookie/Consumed/Follows)
- Process_Disconnected uses a reduced signature (no Input; Output is in
  mode); Process_Newkeys_Sent also takes Output in mode since it never
  writes output
- Behavior verified identical to the pre-split state machine via a
  semantic text comparison of every state body (whitespace-normalised);
  the only change is removal of a redundant Status assignment already
  performed at procedure entry

External interface (.ads) unchanged; all tests pass.
Move directional key accessors, Init_Transport_Ciphers and
Clear_All_Sensitive_Data out of the large transport body into a new
private child package SSH_Protocol.Transport.Key_Material.  The public
API and behaviour are unchanged.
Move Build_Packet, Parse_Packet and Decrypt_Packet_Length (RFC 4253
Section 6 binary packet protocol) into the private child package
SSH_Protocol.Transport.Packet_Framing.  The parent keeps thin wrappers
so the public API is unchanged.
Move KEXINIT emission/storage, algorithm-guess and strict-KEX detection,
global-message handling and the key-derivation finalisation sequence
(RFC 4253 Sections 7-9, RFC 4419, draft-ietf-sshm-strict-kex) into the
private child package SSH_Protocol.Transport.Kex_Machine.  The public
API and behaviour are unchanged.
Move the per-state Process_* handlers and the Transport_Process dispatch
case into the private child package SSH_Protocol.Transport.State_Handlers,
exposing a single Run entry point.  Transport_Process now delegates to it.
The public API and behaviour are unchanged.
Update the project structure tree and the package dependency graph to
include the new private child packages Key_Material, Packet_Framing,
Kex_Machine and State_Handlers under SSH_Protocol.Transport.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u refac:wehack-dev-refac
git switch wehack-dev-refac

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff wehack-dev-refac
git switch wehack-dev-refac
git rebase main
git switch main
git merge --ff-only wehack-dev-refac
git switch wehack-dev-refac
git rebase main
git switch main
git merge --no-ff wehack-dev-refac
git switch main
git merge --squash wehack-dev-refac
git switch main
git merge --ff-only wehack-dev-refac
git switch main
git merge wehack-dev-refac
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
vimacs/ssh_protocol-ada!2
No description provided.