From ce2b3e7fc06bbe22f2ecb1f7dd56acfbbf7db7af Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:11:08 +0000 Subject: [PATCH 01/18] OFB final functions on x86-64 for Blowfish, Camellia, CAST5, IDEA, SEED, SM4 and Triple DES (WIP: crates to come) vg__ofb_final: the generic fbFinal with OFB's step, as #4394's CFB finals, whose tail leaves O_n in the IV; the target-independent OFB lemmas in Proof/Modes/FbFinal.lean and CfbFinalScratch.lean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/BlowfishOfb/X86_64.lean | 8 +- .../Artifacts/CamelliaOfb/X86_64.lean | 8 +- .../Artifacts/Cast5Ofb/X86_64.lean | 8 +- .../Artifacts/IdeaOfb/X86_64.lean | 8 +- .../Artifacts/SeedOfb/X86_64.lean | 8 +- .../Artifacts/Sm4Ofb/X86_64.lean | 8 +- .../Artifacts/TripleDesOfb/X86_64.lean | 8 +- .../Impl/Blowfish/X86_64/FbFinal.lean | 13 ++- .../Impl/Camellia/X86_64/FbFinal.lean | 15 ++- .../Impl/Cast5/X86_64/FbFinal.lean | 15 ++- .../Impl/Idea/X86_64/FbFinal.lean | 14 ++- .../Impl/Seed/X86_64/FbFinal.lean | 13 ++- .../Impl/Sm4/X86_64/FbFinal.lean | 13 ++- .../Impl/TripleDes/X86_64/FbFinal.lean | 16 ++- .../Proof/Blowfish/X86_64/FbFinalLit.lean | 3 +- .../Blowfish/X86_64/FbFinalVerified.lean | 55 +++++++-- .../Proof/Camellia/CfbFinalScratch.lean | 110 +++++++++++++++++- .../Proof/Camellia/X86_64/FbFinalLit.lean | 3 +- .../Camellia/X86_64/FbFinalVerified.lean | 59 +++++++++- .../VerifiedGarbage/Proof/Cast5/CfbFinal.lean | 99 +++++++++++++++- .../Proof/Cast5/X86_64/FbFinalLit.lean | 3 +- .../Proof/Cast5/X86_64/FbFinalVerified.lean | 56 +++++++-- .../Proof/Idea/X86_64/FbFinalLit.lean | 3 +- .../Proof/Idea/X86_64/FbFinalVerified.lean | 58 +++++++-- .../Proof/Modes/CfbFinalScratch.lean | 62 +++++++++- lean/VerifiedGarbage/Proof/Modes/FbFinal.lean | 72 +++++++++++- .../Proof/Seed/X86_64/FbFinalLit.lean | 3 +- .../Proof/Seed/X86_64/FbFinalVerified.lean | 62 ++++++++-- .../Proof/Sm4/X86_64/FbFinalLit.lean | 3 +- .../Proof/Sm4/X86_64/FbFinalVerified.lean | 61 ++++++++-- .../Proof/TripleDes/X86_64/FbFinalLit.lean | 2 + .../TripleDes/X86_64/FbFinalVerified.lean | 87 ++++++++++++-- 32 files changed, 837 insertions(+), 119 deletions(-) diff --git a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86_64.lean index 8a65ccc5464..bce6408adf6 100644 --- a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86_64.lean @@ -1,7 +1,9 @@ module public import VerifiedGarbage.Proof.Blowfish.X86_64.FbVerified +public import VerifiedGarbage.Proof.Blowfish.X86_64.FbFinalVerified import VerifiedGarbage.Proof.Blowfish.X86_64.ModesLit +import VerifiedGarbage.Proof.Blowfish.X86_64.FbFinalLit public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Blowfish.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 96 .r8 11 Impl.Blowfish.X86_64.ofb stack := 96 - verified := Proof.Blowfish.X86_64.ofb_framed }] + verified := Proof.Blowfish.X86_64.ofb_framed }, + Spec.Blowfish.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 96 .r8 11 Impl.Blowfish.X86_64.ofbFinal + stack := 96 + verified := Proof.Blowfish.X86_64.ofbFinal_framed }] end VG.Artifacts.BlowfishOfb.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86_64.lean index 31ceb053bd7..97a6e929bab 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86_64.lean @@ -1,8 +1,10 @@ module public import VerifiedGarbage.Proof.Camellia.X86_64.FbVerified +public import VerifiedGarbage.Proof.Camellia.X86_64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print +import VerifiedGarbage.Proof.Camellia.X86_64.FbFinalLit /-! # Camellia-OFB artifacts on baseline x86-64 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 3280 .r9 409 Impl.Camellia.X86_64.ofb stack := 3288 - verified := Proof.Camellia.X86_64.ofb_framed }] + verified := Proof.Camellia.X86_64.ofb_framed }, + Spec.Camellia.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 3280 .r9 409 Impl.Camellia.X86_64.ofbFinal + stack := 3288 + verified := Proof.Camellia.X86_64.ofbFinal_framed }] end VG.Artifacts.CamelliaOfb.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86_64.lean index 76027a2498a..737e3fe7bad 100644 --- a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86_64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Cast5.X86_64.FbVerified +public import VerifiedGarbage.Proof.Cast5.X86_64.FbFinalVerified import VerifiedGarbage.Proof.Cast5.X86_64.ModesLit public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print +import VerifiedGarbage.Proof.Cast5.X86_64.FbFinalLit /-! # CAST5-OFB artifacts on baseline x86-64 -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Cast5.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 240 .r9 29 Impl.Cast5.X86_64.ofb stack := 240 - verified := Proof.Cast5.ofb_keyed Proof.Cast5.X86_64.ofb_framed }] + verified := Proof.Cast5.ofb_keyed Proof.Cast5.X86_64.ofb_framed }, + Spec.Cast5.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 240 .r9 29 Impl.Cast5.X86_64.ofbFinal + stack := 240 + verified := Proof.Cast5.ofbFinal_keyed Proof.Cast5.X86_64.ofbFinal_framed }] end VG.Artifacts.Cast5Ofb.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86_64.lean index 08e289b5ddb..661d20d9e0c 100644 --- a/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86_64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Idea.X86_64.FbVerified +public import VerifiedGarbage.Proof.Idea.X86_64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print import VerifiedGarbage.Proof.Idea.X86_64.ModesLit +import VerifiedGarbage.Proof.Idea.X86_64.FbFinalLit /-! # IDEA-OFB artifacts on baseline x86-64 -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Idea.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 184 .r8 22 Impl.Idea.X86_64.ofb stack := 184 - verified := Proof.Idea.X86_64.ofb_framed }] + verified := Proof.Idea.X86_64.ofb_framed }, + Spec.Idea.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 184 .r8 22 Impl.Idea.X86_64.ofbFinal + stack := 184 + verified := Proof.Idea.X86_64.ofbFinal_framed }] end VG.Artifacts.IdeaOfb.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/SeedOfb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/SeedOfb/X86_64.lean index 7ce7d87413f..c7311acaaed 100644 --- a/lean/VerifiedGarbage/Artifacts/SeedOfb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/SeedOfb/X86_64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Seed.X86_64.FbVerified +public import VerifiedGarbage.Proof.Seed.X86_64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print import VerifiedGarbage.Proof.Seed.X86_64.ModesLit +import VerifiedGarbage.Proof.Seed.X86_64.FbFinalLit /-! # SEED-OFB artifacts on baseline x86-64 -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Seed.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 1544 .r8 192 Impl.Seed.X86_64.ofb stack := 1552 - verified := Proof.Seed.X86_64.ofb_framed }] + verified := Proof.Seed.X86_64.ofb_framed }, + Spec.Seed.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 1544 .r8 192 Impl.Seed.X86_64.ofbFinal + stack := 1552 + verified := Proof.Seed.X86_64.ofbFinal_framed }] end VG.Artifacts.SeedOfb.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86_64.lean index b5807c4d1fc..d5a35ea3705 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86_64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Sm4.X86_64.FbVerified +public import VerifiedGarbage.Proof.Sm4.X86_64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit +import VerifiedGarbage.Proof.Sm4.X86_64.FbFinalLit /-! # SM4-OFB artifacts on baseline x86-64 -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 3208 .r8 400 Impl.Sm4.X86_64.ofb stack := 3216 - verified := Proof.Sm4.X86_64.ofb_framed }] + verified := Proof.Sm4.X86_64.ofb_framed }, + Spec.Sm4.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 3208 .r8 400 Impl.Sm4.X86_64.ofbFinal + stack := 3216 + verified := Proof.Sm4.X86_64.ofbFinal_framed }] end VG.Artifacts.Sm4Ofb.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86_64.lean b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86_64.lean index 242771b3248..8fff47f55e3 100644 --- a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86_64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.TripleDes.X86_64.FbVerified +public import VerifiedGarbage.Proof.TripleDes.X86_64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print import VerifiedGarbage.Proof.TripleDes.X86_64.FbLit +import VerifiedGarbage.Proof.TripleDes.X86_64.FbFinalLit /-! # Triple DES-OFB artifacts on baseline x86-64 -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.TripleDes.ofbApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 976 .r8 121 Impl.TripleDes.X86_64.ofb stack := 984 - verified := Proof.TripleDes.X86_64.ofb_framed }] + verified := Proof.TripleDes.X86_64.ofb_framed }, + Spec.TripleDes.ofbFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 976 .r8 121 Impl.TripleDes.X86_64.ofbFinal + stack := 984 + verified := Proof.TripleDes.X86_64.ofbFinal_framed }] end VG.Artifacts.TripleDesOfb.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Blowfish/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Blowfish/X86_64/FbFinal.lean index e7d3ac93280..f32878e1ba6 100644 --- a/lean/VerifiedGarbage/Impl/Blowfish/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Blowfish/X86_64/FbFinal.lean @@ -4,12 +4,12 @@ public import VerifiedGarbage.Impl.Blowfish.X86_64.Modes public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# Blowfish-CFB64 of a message's last piece on x86-64 +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal`: the modes' CFB over a message's -last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over -Blowfish's core, with the arguments of `cfbEncrypt` but the data's length -in bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal`: the modes' CFB and OFB +over a message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), +over Blowfish's core, with the arguments of `cfbEncrypt` (and `ofb`) but the +data's length in bytes. -/ @[expose] public section @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).fbFinal .cfbEnc modeRegs /-- `vg_blowfish_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).fbFinal .cfbDec modeRegs +/-- `vg_blowfish_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).fbFinal .ofb modeRegs + end VG.Impl.Blowfish.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Camellia/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/X86_64/FbFinal.lean index f67ed48cf16..3e387dd5790 100644 --- a/lean/VerifiedGarbage/Impl/Camellia/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Camellia/X86_64/FbFinal.lean @@ -4,13 +4,13 @@ public import VerifiedGarbage.Impl.Camellia.X86_64.Fb public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# Camellia-CFB128 of a message's last piece on x86-64 +# Camellia-CFB128 and Camellia-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = rdi, rounds = rsi, -iv = rdx, data = rcx, len = r8, scratch = r9): the modes' CFB over a -message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over -Camellia's core, with the arguments of `cfbEncrypt` but the data's length in -bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = rdi, rounds = +rsi, iv = rdx, data = rcx, len = r8, scratch = r9): the modes' CFB and OFB +over a message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), +over Camellia's core, with the arguments of `cfbEncrypt` (and `ofb`) but the +data's length in bytes. -/ @[expose] public section @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbEnc ⟨.rdx, .r /-- `vg_camellia_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbDec ⟨.rdx, .rcx, .r8, .r9⟩ +/-- `vg_camellia_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).fbFinal .ofb ⟨.rdx, .rcx, .r8, .r9⟩ + end VG.Impl.Camellia.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Cast5/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Cast5/X86_64/FbFinal.lean index a041bc18aec..5b12e1868fd 100644 --- a/lean/VerifiedGarbage/Impl/Cast5/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Cast5/X86_64/FbFinal.lean @@ -4,13 +4,13 @@ public import VerifiedGarbage.Impl.Cast5.X86_64.Modes public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# CAST5-CFB64 of a message's last piece on x86-64 +# CAST5-CFB64 and CAST5-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = rdi, rounds = rsi, -iv = rdx, data = rcx, len = r8, scratch = r9): the modes' CFB over a -message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over -CAST5's core, with the arguments of `cfbEncrypt` but the data's length in -bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = rdi, rounds = +rsi, iv = rdx, data = rcx, len = r8, scratch = r9): the modes' CFB and OFB +over a message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), +over CAST5's core, with the arguments of `cfbEncrypt` (and `ofb`) but the +data's length in bytes. -/ @[expose] public section @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).fbFinal .cfbEnc modeRegs /-- `vg_cast5_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).fbFinal .cfbDec modeRegs +/-- `vg_cast5_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).fbFinal .ofb modeRegs + end VG.Impl.Cast5.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Idea/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Idea/X86_64/FbFinal.lean index a8c50190cb5..14b118cb1eb 100644 --- a/lean/VerifiedGarbage/Impl/Idea/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Idea/X86_64/FbFinal.lean @@ -4,12 +4,13 @@ public import VerifiedGarbage.Impl.Idea.X86_64.Modes public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# IDEA-CFB64 of a message's last piece on x86-64 +# IDEA-CFB64 and IDEA-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = rdi, iv = rsi, -data = rdx, len = rcx, scratch = r8): the modes' CFB over a message's last -piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over IDEA's core, -with the arguments of `cfbEncrypt` but the data's length in bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = rdi, iv = rsi, +data = rdx, len = rcx, scratch = r8): the modes' CFB and OFB over a message's +last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over IDEA's +core, with the arguments of `cfbEncrypt` (and `ofb`) but the data's length in +bytes. -/ @[expose] public section @@ -24,4 +25,7 @@ def cfbEncryptFinal : Prog isa := modeCore.fbFinal .cfbEnc modeRegs /-- `vg_idea_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := modeCore.fbFinal .cfbDec modeRegs +/-- `vg_idea_ofb_final`. -/ +def ofbFinal : Prog isa := modeCore.fbFinal .ofb modeRegs + end VG.Impl.Idea.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Seed/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Seed/X86_64/FbFinal.lean index 048f4f460eb..b48f8302c35 100644 --- a/lean/VerifiedGarbage/Impl/Seed/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Seed/X86_64/FbFinal.lean @@ -4,12 +4,12 @@ public import VerifiedGarbage.Impl.Seed.X86_64.Modes public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# SEED-CFB128 of a message's last piece on x86-64 +# SEED-CFB128 and SEED-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal`: the modes' CFB over a message's -last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over -SEED's core, with the arguments of `cfbEncrypt` but the data's length -in bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal`: the modes' CFB and OFB +over a message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), +over SEED's core, with the arguments of `cfbEncrypt` (and `ofb`) but the +data's length in bytes. -/ @[expose] public section @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbEnc modeRegs /-- `vg_seed_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbDec modeRegs +/-- `vg_seed_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).fbFinal .ofb modeRegs + end VG.Impl.Seed.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Sm4/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/X86_64/FbFinal.lean index b1e63ae2514..947f0c07159 100644 --- a/lean/VerifiedGarbage/Impl/Sm4/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Sm4/X86_64/FbFinal.lean @@ -4,12 +4,12 @@ public import VerifiedGarbage.Impl.Sm4.X86_64.Fb public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# SM4-CFB128 of a message's last piece on x86-64 +# SM4-CFB128 and SM4-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal`: the modes' CFB over a message's -last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over -SM4's core, with the arguments of `cfbEncrypt` but the data's length -in bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal`: the modes' CFB and OFB +over a message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), +over SM4's core, with the arguments of `cfbEncrypt` (and `ofb`) but the data's +length in bytes. -/ @[expose] public section @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbEnc ⟨.rsi, .r /-- `vg_sm4_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbDec ⟨.rsi, .rdx, .rcx, .r8⟩ +/-- `vg_sm4_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).fbFinal .ofb ⟨.rsi, .rdx, .rcx, .r8⟩ + end VG.Impl.Sm4.X86_64 diff --git a/lean/VerifiedGarbage/Impl/TripleDes/X86_64/FbFinal.lean b/lean/VerifiedGarbage/Impl/TripleDes/X86_64/FbFinal.lean index 3940f81e9f7..be831db9a5c 100644 --- a/lean/VerifiedGarbage/Impl/TripleDes/X86_64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/TripleDes/X86_64/FbFinal.lean @@ -4,12 +4,12 @@ public import VerifiedGarbage.Impl.TripleDes.X86_64.Fb public import VerifiedGarbage.Impl.Modes.X86_64.FbFinal /-! -# Triple DES-CFB64 of a message's last piece on x86-64 +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on x86-64 -`cfbEncryptFinal` and `cfbDecryptFinal`: the modes' CFB over a message's -last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), over -CBC encryption's core (`callCore .encrypt`, calling the block function), with the arguments of `cfbEncrypt` but the data's length -in bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal`: the modes' CFB and OFB +over a message's last piece, of any length (`Impl/Modes/X86_64/FbFinal.lean`), +over CBC encryption's core (`callCore .encrypt`, calling the block function), +with the arguments of `cfbEncrypt` (and `ofb`) but the data's length in bytes. -/ @[expose] public section @@ -30,4 +30,10 @@ def cfbDecryptFinal : Prog isa := (callCore .encrypt).fbFinal .cfbDec fbRegs /-- `cfbDecryptFinal` with the block function inlined. -/ def cfbDecryptFinalI : Prog isa := (dirCore .encrypt).fbFinal .cfbDec fbRegs +/-- `vg_triple_des_ofb_final`. -/ +def ofbFinal : Prog isa := (callCore .encrypt).fbFinal .ofb fbRegs + +/-- `ofbFinal` with the block function inlined. -/ +def ofbFinalI : Prog isa := (dirCore .encrypt).fbFinal .ofb fbRegs + end VG.Impl.TripleDes.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalLit.lean index 5f58d9bc423..3d5993ce333 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Blowfish.X86_64.ModesLit meta import VerifiedGarbage.Proof.Framework.X86_64.Lit -/-! # Blowfish-CFB64's final functions' x86-64 code as literals, for kernel-evaluated checks -/ +/-! # Blowfish-CFB64's and Blowfish-OFB's final functions' x86-64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Blowfish.X86_64.cfbEncryptFinal materialize_code Impl.Blowfish.X86_64.cfbDecryptFinal +materialize_code Impl.Blowfish.X86_64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalVerified.lean index 8b567546263..e990df59eff 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/X86_64/FbFinalVerified.lean @@ -8,6 +8,7 @@ import VerifiedGarbage.Proof.Blowfish.X86_64.ModesLit public import VerifiedGarbage.Impl.Blowfish.X86_64.FbFinal public import VerifiedGarbage.Proof.Framework.X86_64.Abi public import VerifiedGarbage.Spec.Blowfish.CfbFinal +public import VerifiedGarbage.Spec.Blowfish.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -24,6 +25,7 @@ meta import VerifiedGarbage.Proof.Blowfish.X86_64.ModesLit meta import VerifiedGarbage.Impl.Blowfish.X86_64.FbFinal meta import VerifiedGarbage.Proof.Framework.X86_64.Abi meta import VerifiedGarbage.Spec.Blowfish.CfbFinal +meta import VerifiedGarbage.Spec.Blowfish.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -34,15 +36,16 @@ meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratchWipe meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratch /-! -# Blowfish-CFB64 of a message's last piece on x86-64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over Blowfish's core -(`dirCoreSpec true`), with the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: -each is correct and constant time, by the taint analysis, as the -whole-block functions are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … -run them with their working space on the stack, zeroed on return. +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on x86-64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over +Blowfish's core (`dirCoreSpec true`), with the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). +`cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint +analysis, as the whole-block functions are (`FbVerified.lean`); +`cfbEncryptFinal_framed`, … run them with their working space on the stack, +zeroed on return. -/ @[expose] public section @@ -104,6 +107,12 @@ def cfbDecFinalX86_64 : Contract isa where post s s' := Spec.Cfb.DecryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (finalLen s) pub := fbPub +/-- The final OFB function's contract on x86-64. -/ +def ofbFinalX86_64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (finalLen s) + pub := fbPub + theorem cfbEncryptFinal_wp {s₀ : State} (hp : cfbEncFinalX86_64.pre s₀) : WP isa cfbEncryptFinal s₀ fun s' => gprPreserved s₀ s' ∧ cfbEncFinalX86_64.post s₀ s' := WP.mono (fbFinal_wp' .cfbEnc hp) fun s' ⟨hg, hd, hv⟩ => by @@ -116,6 +125,12 @@ theorem cfbDecryptFinal_wp {s₀ : State} (hp : cfbDecFinalX86_64.pre s₀) : obtain ⟨h1, h2⟩ := Modes.cfbDecFinal_of_bytes (by decide) (cipher_length _) hd exact ⟨hg, h1, hv.trans h2⟩ +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX86_64.pre s₀) : + WP isa ofbFinal s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX86_64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + /-! ## Verified -/ theorem finalLen_congr : ∀ s t : State, s.gpr .rcx = t.gpr .rcx → finalLen s = finalLen t := fun _ _ h => by @@ -161,6 +176,17 @@ theorem cfbDecryptFinal_verified : Proof.Modes.decFinalPost, cfbDecFinalX86_64, fbPre, fbPub, X86_64.abi, X86_64.argRegs] [finalSat] using finalSat) +theorem ofbFinal_verified : + Verified X86_64.target ofbFinal (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 11 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalX86_64) (fun s hs => by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinal) (by lit_decide) he hg, hpost⟩) + (VG.Taint.constantTime (A := taint) fbTaint (fbTaint_agree finalLen_congr) (by taint_decide)) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalX86_64, fbPre, fbPub, X86_64.abi, X86_64.argRegs] [finalSat] + using finalSat) + /-- The final CFB64 encryption with its working space on the stack. -/ theorem cfbEncryptFinal_framed : Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 96 .r8 11 cfbEncryptFinal) @@ -183,4 +209,15 @@ theorem cfbDecryptFinal_framed : (Proof.Modes.decFinalPost_local _) (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 96 .r8 11 ofbFinal) + (Spec.Blowfish.ofbFinalContract X86_64.abi 96) := + X86_64.Verified.stackScratchWiped (sig := Spec.Blowfish.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 11) (post := Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 96) ofbFinal_verified (by decide) (by decide) (by decide) + (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) + (Proof.Modes.ofbFinalPost_local _) + (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) + end VG.Proof.Blowfish.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Camellia/CfbFinalScratch.lean b/lean/VerifiedGarbage/Proof/Camellia/CfbFinalScratch.lean index f5d64081f89..fd0a81547a3 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/CfbFinalScratch.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/CfbFinalScratch.lean @@ -1,13 +1,14 @@ module public import VerifiedGarbage.Spec.Camellia.CfbFinal +public import VerifiedGarbage.Spec.Camellia.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Camellia.Scratch import VerifiedGarbage.Proof.Framework.AddrArith import VerifiedGarbage.Proof.Framework.Mem /-! -# Camellia-CFB128 of a message's last piece with its working space as an argument +# Camellia-CFB128 and Camellia-OFB of a message's last piece with its working space as an argument `cfbEncFinalScratchContract n` and `cfbDecFinalScratchContract n` are the final functions' contracts on the subkeys at `schedule` (`cfbEncryptFinalPostSk`, @@ -17,6 +18,8 @@ read the memory on return only within the function's buffers (`cfbEncryptFinalPostOut_local`, …), and, for 32-bit x86's frame, the memory on entry likewise (`cfbEncryptFinalPost_local`, …, and `cfbFinalPre_local`); `cfbEncryptFinal_of_sk`, … give the specification's contracts, on every key whose subkeys those are. +`ofbFinalScratchContract n`, `ofbFinalPostOut_local`, …, `ofbFinal_of_sk` are +the same for the final OFB function. -/ @[expose] public section @@ -226,4 +229,109 @@ theorem cfbDecryptFinal_of_sk {T : Target} {c : Prog T.isa} {A : Abi T.isa} {sta (h : Verified T c (cfbDecryptFinalContractSk A stack)) : Verified T c (cfbDecryptFinalContract A stack) := verified_of_post h (cfbDecryptFinalPost_of_sk A.ptrBits) +/-! ## OFB of a message's last piece -/ + +/-- `ofbFinalContract`'s postcondition on the subkeys at `schedule`, for +`rounds` of 18 or 24. -/ +def ofbFinalPostSk (pb : Nat) : ofbFinalSig.Post pb := fun schedule rounds iv data len m m' _ => + (rounds.toNat = 18 ∨ rounds.toNat = 24) → + Spec.Ofb.CryptFinal (cipher (subkeysAt m schedule rounds.toNat)) 16 m m' iv data len.toNat + +/-- `ofbFinalContract` with `ofbFinalPostSk`. -/ +def ofbFinalContractSk {M : ISA} (A : Abi M) (stack : Nat := 0) : Contract M := + ofbFinalSig.contract A (pre := ofbFinalPre A.ptrBits) (post := ofbFinalPostSk A.ptrBits) (writeArgs := true) + (stack := stack) + +/-- `ofbFinalContractSk`, whatever the appended `scratch` is. -/ +abbrev ofbFinalScratchContract {M : ISA} (A : Abi M) (n : Nat) (stack : Nat := 0) : Contract M := + Sig.scratchContract A ofbFinalSig "scratch" .u64 n (ofbFinalPre A.ptrBits) (ofbFinalPostSk A.ptrBits) true stack + +/-- `ofbFinalPre` reads no memory. -/ +theorem ofbFinalPre_local : ∀ vs m₁ m₂, vs.length = (ofbFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ofbFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPre pb) vs m₁ → Curry.apply (ofbFinalSig.words pb) (ofbFinalPre pb) vs m₂ := by + intro vs _ _ hlen _ h + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one (n := 4) hlen + replace hlen := Nat.succ.inj hlen + iterate 4 + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain rfl := List.eq_nil_of_length_eq_zero hlen + exact h + +/-- `ofbFinalPostSk` reads the memory on entry only within the function's +buffers. -/ +theorem ofbFinalPost_local : ∀ vs m₁ m₂ m' r, vs.length = (ofbFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ofbFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPostSk pb) vs m₁ m' r → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPostSk pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one (n := 4) hlen + replace hlen := Nat.succ.inj hlen + iterate 2 + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨data, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨n, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain rfl := List.eq_nil_of_length_eq_zero hlen + simp only [ofbFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hs := agree_of hb.1 + have hd := agree_of hb.2.2 + have hv := agree_of hb.2.1 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPostSk pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPostSk pb) _ m₂ m' r + dsimp only [Curry.apply, ofbFinalPostSk, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + have := Nat.mod_le n.toNat (2 ^ pb) + intro hR + rw [subkeysAt_congr (by simp only [scheduleLength]; omega) fun i hi => hs i (by omega), + bytesAt_congr' (k := (n.setWidth pb).toNat) fun i hi => hd i (by + rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hv] + exact h hR + +theorem ofbFinalPostOut_local : ∀ vs m m₁ m₂ r, vs.length = (ofbFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ofbFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPostSk pb) vs m m₁ r → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPostSk pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one (n := 4) hlen + replace hlen := Nat.succ.inj hlen + iterate 2 + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨data, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨n, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain rfl := List.eq_nil_of_length_eq_zero hlen + simp only [ofbFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hd := agree_of hb.2.2 + have hv := agree_of hb.2.1 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPostSk pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPostSk pb) _ m m₂ r + dsimp only [Curry.apply, ofbFinalPostSk, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + have := Nat.mod_le n.toNat (2 ^ pb) + intro hR + rw [bytesAt_congr' (k := (n.setWidth pb).toNat) fun i hi => hd i (by + rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hv] + exact h hR + +theorem ofbFinalPost_of_sk : Curry.Imp _ (ofbFinalPostSk pb) (fun schedule rounds iv data len m m' _ => + ∀ key, KeySchedule m schedule rounds.toNat key → + Spec.Ofb.CryptFinal (cipher (expandKey key)) 16 m m' iv data len.toNat : ofbFinalSig.Post pb) := by + intro _ _ _ _ _ _ _ _ h key hk + rw [← subkeysAt_of_keySchedule hk] + exact h (rounds_of_keySchedule hk) + +theorem ofbFinal_of_sk {T : Target} {c : Prog T.isa} {A : Abi T.isa} {stack : Nat} + (h : Verified T c (ofbFinalContractSk A stack)) : Verified T c (ofbFinalContract A stack) := + verified_of_post h (ofbFinalPost_of_sk A.ptrBits) + end VG.Proof.Camellia diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalLit.lean index 3fb11b6db5d..70abd6b27f6 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Camellia.X86_64.ModesLit meta import VerifiedGarbage.Proof.Framework.X86_64.Lit -/-! # Camellia-CFB128's final functions' x86-64 code as literals, for kernel-evaluated checks -/ +/-! # Camellia-CFB128's and Camellia-OFB's final functions' x86-64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Camellia.X86_64.cfbEncryptFinal materialize_code Impl.Camellia.X86_64.cfbDecryptFinal +materialize_code Impl.Camellia.X86_64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalVerified.lean index 8ad72624bf7..6ac6e403778 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/X86_64/FbFinalVerified.lean @@ -8,6 +8,7 @@ import VerifiedGarbage.Proof.Camellia.X86_64.ModesLit public import VerifiedGarbage.Impl.Camellia.X86_64.FbFinal public import VerifiedGarbage.Proof.Framework.X86_64.Abi public import VerifiedGarbage.Spec.Camellia.CfbFinal +public import VerifiedGarbage.Spec.Camellia.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Camellia.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -25,6 +26,7 @@ meta import VerifiedGarbage.Proof.Camellia.X86_64.ModesLit meta import VerifiedGarbage.Impl.Camellia.X86_64.FbFinal meta import VerifiedGarbage.Proof.Framework.X86_64.Abi meta import VerifiedGarbage.Spec.Camellia.CfbFinal +meta import VerifiedGarbage.Spec.Camellia.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Camellia.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -36,13 +38,14 @@ meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratch meta import VerifiedGarbage.Proof.Framework.Offset /-! -# Camellia-CFB128 of a message's last piece on x86-64 meets its contracts +# Camellia-CFB128 and Camellia-OFB of a message's last piece on x86-64 meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over Camellia's core, with the -specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …). -`cfbEncryptFinal_verified`, …: each is correct and constant time, by the -taint analysis, as the whole-block functions are (`FbVerified.lean`); +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over +Camellia's core, with the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). +`cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint +analysis, as the whole-block functions are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … run them with their working space on the stack, zeroed on return, and give the specification's contracts on every key whose subkeys are at `schedule` (`Proof.Camellia.cfbEncryptFinal_of_sk`, …). @@ -215,4 +218,48 @@ theorem cfbDecryptFinal_framed : (by decide) (by decide) (by decide) (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) (Proof.Camellia.cfbDecryptFinalPostOut_local _) cfbDecryptFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on x86-64: the data `len = r8` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX86_64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 16 s.mem s'.mem (s.gpr .rdx) (s.gpr .rcx) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX86_64.pre s₀) : + WP isa ofbFinal s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX86_64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length s₀) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_ct : ConstantTime isa ofbFinalX86_64.pre ofbFinalX86_64.pub ofbFinal := + VG.Taint.constantTime (A := taint) fbTaint (fbTaint_agree finalLen_congr) (by taint_decide) + +theorem ofbFinal_verified : + Verified X86_64.target ofbFinal (Proof.Camellia.ofbFinalScratchContract X86_64.abi 409 8) := + Verified.of_correct (k := ofbFinalX86_64) (fun s hs => by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinal) (by lit_decide) he hg, hpost⟩) + ofbFinal_ct (by + sig_implies [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, Proof.Camellia.ofbFinalPostSk, ofbFinalX86_64, fbPre, + fbPub, X86_64.abi, X86_64.argRegs, slots, tailSlot, endSlot, keySlot] [finalSat] using finalSat) + +theorem ofbFinalFrameSat_pre : ∃ s, (Proof.Camellia.ofbFinalContractSk X86_64.abi 3288).pre s := by + implies_sat [Proof.Camellia.ofbFinalContractSk, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, + Proof.Camellia.ofbFinalPostSk, X86_64.abi, X86_64.argRegs] [finalFrameSat] using finalFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 3280 .r9 409 ofbFinal) + (Spec.Camellia.ofbFinalContract X86_64.abi 3288) := + Proof.Camellia.ofbFinal_of_sk <| + X86_64.Verified.stackScratchWiped (sig := Spec.Camellia.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 409) (pre := Spec.Camellia.ofbFinalPre X86_64.abi.ptrBits) + (post := Proof.Camellia.ofbFinalPostSk X86_64.abi.ptrBits) (wa := true) (stack := 8) + (bytes := 3280) ofbFinal_verified + (by decide) (by decide) (by decide) (Code.all_of_allInstrs (by lit_decide)) + (by lit_decide) (by decide) (Proof.Camellia.ofbFinalPostOut_local _) ofbFinalFrameSat_pre + end VG.Proof.Camellia.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Cast5/CfbFinal.lean b/lean/VerifiedGarbage/Proof/Cast5/CfbFinal.lean index aedf0ab39ae..767625e32fc 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/CfbFinal.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/CfbFinal.lean @@ -1,13 +1,14 @@ module public import VerifiedGarbage.Spec.Cast5.CfbFinal +public import VerifiedGarbage.Spec.Cast5.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Framework.PostMono import VerifiedGarbage.Proof.Framework.Offset import VerifiedGarbage.Proof.Cast5.ModeScratch /-! -# CAST5-CFB64 of a message's last piece on the subkeys at `schedule` +# CAST5-CFB64 and CAST5-OFB of a message's last piece on the subkeys at `schedule` `cfbEncFinalPost`, `cfbDecFinalPost`: the final functions' postconditions on the subkeys at `schedule` and `rounds` rounds, which read the memory on @@ -17,6 +18,8 @@ as the frame that keeps a scratch buffer on the stack needs on entry (ARMv7), the precondition and the postconditions the memory on entry only within them too (`cfbFinalPre_local`, `cfbEncFinalPost_local`, …); `cfbEncryptFinal_keyed`, … give the specification's contracts, on every key whose subkeys those are. +`ofbFinalPost`, `ofbFinalPostOut_local`, …, `ofbFinal_keyed` are the same for +the final OFB function. -/ @[expose] public section @@ -213,4 +216,98 @@ theorem cfbDecFinalPostOut_local (pb : Nat) : ∀ vs m m₁ m₂ r, vs.length = rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hv] exact h +/-! ## OFB of a message's last piece -/ + +/-- `ofbFinalContract`'s postcondition on the subkeys at `schedule`, with +`rounds` rounds. -/ +def ofbFinalPost (pb : Nat) : ofbFinalSig.Post pb := fun schedule rounds iv data len m m' _ => + Spec.Ofb.CryptFinal (cipher (scheduleAt m schedule) rounds.toNat) 8 m m' iv data len.toNat + +/-- For `rounds` of 12 or 16, with the subkeys at `schedule`: the final +encryption (`ofbFinalPost`). -/ +def ofbFinalRoundsContract {M : ISA} (A : Abi M) (stack : Nat := 0) : Contract M := + ofbFinalSig.contract A (pre := ofbFinalPre A.ptrBits) (post := ofbFinalPost A.ptrBits) (writeArgs := true) + (stack := stack) + +/-- `Spec.Cast5.ofbFinalContract` from `ofbFinalRoundsContract`. -/ +theorem ofbFinal_keyed {T : Target} {c : Prog T.isa} {A : Abi T.isa} {stack : Nat} + (h : Verified T c (ofbFinalRoundsContract A stack)) : Verified T c (Spec.Cast5.ofbFinalContract A stack) := + h.post_mono fun _ _ _ _ _ _ _ _ hp key ⟨_, hr, hw⟩ => by + unfold ofbFinalPost at hp + rw [hw, hr] at hp + exact hp + +/-- `ofbFinalPre` reads no memory. -/ +theorem ofbFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (ofbFinalSig.words pb).length → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPre pb) vs m₁ → Curry.apply (ofbFinalSig.words pb) (ofbFinalPre pb) vs m₂ := by + intro vs _ _ hlen h + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one (n := 4) hlen + replace hlen := Nat.succ.inj hlen + iterate 4 + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain rfl := List.eq_nil_of_length_eq_zero hlen + exact h + +/-- `ofbFinalPost` reads the memory on entry only within the functions' +buffers. -/ +theorem ofbFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (ofbFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ofbFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPost pb) vs m₁ m' r → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one (n := 4) hlen + replace hlen := Nat.succ.inj hlen + iterate 2 + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨data, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨n, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain rfl := List.eq_nil_of_length_eq_zero hlen + simp only [ofbFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hs := agree_of hb.1 + have hv := agree_of hb.2.1 + have hd := agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPost pb) _ m₂ m' r + dsimp only [Curry.apply, ofbFinalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + have := Nat.mod_le n.toNat (2 ^ pb) + rw [scheduleAt_congr hs, bytesAt_congr' (k := (n.setWidth pb).toNat) fun i hi => hd i (by + rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hv] + exact h + +theorem ofbFinalPostOut_local (pb : Nat) : ∀ vs m m₁ m₂ r, vs.length = (ofbFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ofbFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPost pb) vs m m₁ r → + Curry.apply (ofbFinalSig.words pb) (ofbFinalPost pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one (n := 4) hlen + replace hlen := Nat.succ.inj hlen + iterate 2 + obtain ⟨_, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨data, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain ⟨n, vs, rfl⟩ := List.exists_cons_of_length_eq_add_one hlen + replace hlen := Nat.succ.inj hlen + obtain rfl := List.eq_nil_of_length_eq_zero hlen + simp only [ofbFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hv := agree_of hb.2.1 + have hd := agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPost pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ofbFinalPost pb) _ m m₂ r + dsimp only [Curry.apply, ofbFinalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + have := Nat.mod_le n.toNat (2 ^ pb) + rw [bytesAt_congr' (k := (n.setWidth pb).toNat) fun i hi => hd i (by + rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hv] + exact h + end VG.Proof.Cast5 diff --git a/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalLit.lean index 642fe45c455..0dea636c104 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Cast5.X86_64.ModesLit meta import VerifiedGarbage.Proof.Framework.X86_64.Lit -/-! # CAST5-CFB64's final functions' x86-64 code as literals, for kernel-evaluated checks -/ +/-! # CAST5-CFB64's and CAST5-OFB's final functions' x86-64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Cast5.X86_64.cfbEncryptFinal materialize_code Impl.Cast5.X86_64.cfbDecryptFinal +materialize_code Impl.Cast5.X86_64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalVerified.lean index 9382cd18572..2886a8b53bb 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/X86_64/FbFinalVerified.lean @@ -34,15 +34,15 @@ meta import VerifiedGarbage.Proof.Framework.X86_64.RegUpd meta import VerifiedGarbage.Proof.Framework.Contract /-! -# CAST5-CFB64 of a message's last piece on x86-64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over CAST5's core, with the -specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …). -`cfbEncryptFinal_verified`, …: each is correct and constant time, by the -taint analysis, as the whole-block functions are (`FbVerified.lean`); -`cfbEncryptFinal_framed`, … run them with their working space on the stack, -zeroed on return. +# CAST5-CFB64 and CAST5-OFB of a message's last piece on x86-64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over CAST5's +core, with the specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is +correct and constant time, by the taint analysis, as the whole-block functions +are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … run them with their +working space on the stack, zeroed on return. -/ @[expose] public section @@ -249,4 +249,42 @@ theorem cfbDecryptFinal_framed : cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) (Proof.Cast5.cfbDecFinalPostOut_local _) (finalFrame_sat _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on x86-64: the data `len = r8` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX : Contract isa where + pre := FPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .rdx) (s.gpr .rcx) (finalLen s) + pub := cbcPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX.pre s₀) : + WP isa ofbFinal s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length s₀) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_ct : ConstantTime isa ofbFinalX.pre ofbFinalX.pub ofbFinal := + VG.Taint.constantTime (A := taintSym [s1234Sym]) fbTaint (fbTaint_agree finalLen_congr) (by taint_decide) + +theorem ofbFinal_verified : + Verified X86_64.target ofbFinal (finalK (Proof.Cast5.ofbFinalPost X86_64.abi.ptrBits)) := + Verified.of_correct (fun s hs => by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinal) (by lit_decide) he hg, hpost⟩) + ofbFinal_ct (final_implies (post := Proof.Cast5.ofbFinalPost X86_64.abi.ptrBits) fun s s' h => by + sig_post [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Spec.Cast5.ofbFinalSig, + Proof.Cast5.ofbFinalPost, X86_64.abi, X86_64.argRegs, ecbConsts_eq, Abi.withConsts, Curry.withScratch] + exact h) + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 240 .r9 29 ofbFinal) + (Proof.Cast5.ofbFinalRoundsContract (X86_64.abi.withConsts ecbConsts) 240) := + X86_64.Verified.stackScratchWipedC (c₀ := (s1234Sym, s1234)) (cs := []) (sig := Spec.Cast5.ofbFinalSig) + (nm := "scratch") (e := .u64) (n := 29) (pre := Spec.Cast5.ofbFinalPre X86_64.abi.ptrBits) + (post := Proof.Cast5.ofbFinalPost X86_64.abi.ptrBits) (wa := true) (stack := 0) (bytes := 240) + ofbFinal_verified (by decide) (by decide) (by decide) (Code.all_of_allInstrs (by lit_decide)) + (by lit_decide) (by decide) (Proof.Cast5.ofbFinalPostOut_local _) (finalFrame_sat _) + end VG.Proof.Cast5.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalLit.lean index a956c436a2a..f5f375d84c4 100644 --- a/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Idea.X86_64.ModesLit meta import VerifiedGarbage.Proof.Framework.X86_64.Lit -/-! # IDEA-CFB64's final functions' x86-64 code as literals, for kernel-evaluated checks -/ +/-! # IDEA-CFB64's and IDEA-OFB's final functions' x86-64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Idea.X86_64.cfbEncryptFinal materialize_code Impl.Idea.X86_64.cfbDecryptFinal +materialize_code Impl.Idea.X86_64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalVerified.lean index 5741bc13a2c..8aeeb852678 100644 --- a/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Idea/X86_64/FbFinalVerified.lean @@ -8,6 +8,7 @@ import VerifiedGarbage.Proof.Idea.X86_64.ModesLit public import VerifiedGarbage.Impl.Idea.X86_64.FbFinal public import VerifiedGarbage.Proof.Framework.X86_64.Abi public import VerifiedGarbage.Spec.Idea.CfbFinal +public import VerifiedGarbage.Spec.Idea.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -24,6 +25,7 @@ meta import VerifiedGarbage.Proof.Idea.X86_64.ModesLit meta import VerifiedGarbage.Impl.Idea.X86_64.FbFinal meta import VerifiedGarbage.Proof.Framework.X86_64.Abi meta import VerifiedGarbage.Spec.Idea.CfbFinal +meta import VerifiedGarbage.Spec.Idea.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -34,15 +36,16 @@ meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratchWipe meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratch /-! -# IDEA-CFB64 of a message's last piece on x86-64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over IDEA's core -(`modeCoreSpec`), with the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: -each is correct and constant time, by the taint analysis, as the -whole-block functions are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … -run them with their working space on the stack, zeroed on return. +# IDEA-CFB64 and IDEA-OFB of a message's last piece on x86-64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over IDEA's +core (`modeCoreSpec`), with the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). +`cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint +analysis, as the whole-block functions are (`FbVerified.lean`); +`cfbEncryptFinal_framed`, … run them with their working space on the stack, +zeroed on return. -/ @[expose] public section @@ -178,4 +181,41 @@ theorem cfbDecryptFinal_framed : (Proof.Modes.decFinalPost_local _) (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on x86-64: the data `len = rcx` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX86_64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX86_64.pre s₀) : + WP isa ofbFinal s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX86_64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_verified : + Verified X86_64.target ofbFinal (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 22 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalX86_64) (fun s hs => by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinal) (by lit_decide) he hg, hpost⟩) + (VG.Taint.constantTime (A := taint) fbTaint (fbTaint_agree finalLen_congr) (by taint_decide)) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalX86_64, fbPre, fbPub, X86_64.abi, X86_64.argRegs] [finalSat] + using finalSat) + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 184 .r8 22 ofbFinal) + (Spec.Idea.ofbFinalContract X86_64.abi 184) := + X86_64.Verified.stackScratchWiped (sig := Spec.Idea.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 22) (post := Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 184) ofbFinal_verified (by decide) (by decide) (by decide) + (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) + (Proof.Modes.ofbFinalPost_local _) + (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) + end VG.Proof.Idea.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Modes/CfbFinalScratch.lean b/lean/VerifiedGarbage/Proof/Modes/CfbFinalScratch.lean index 6de772e06d2..4855319e582 100644 --- a/lean/VerifiedGarbage/Proof/Modes/CfbFinalScratch.lean +++ b/lean/VerifiedGarbage/Proof/Modes/CfbFinalScratch.lean @@ -1,18 +1,20 @@ module public import VerifiedGarbage.Spec.Cfb.Final +public import VerifiedGarbage.Spec.Ofb.Final import VerifiedGarbage.Proof.Framework.Offset /-! -# CFB of a message's last piece, with its working space as an argument +# CFB and OFB of a message's last piece, with its working space as an argument A final function's signature (`finalSig`): a key schedule, the block at `iv` and the `len` bytes at `data`, the same for every block cipher but their names and sizes, and its postconditions on it (`encFinalPost`, -`decFinalPost`), which read the memory on return only within the function's -buffers (`encFinalPost_local`, `decFinalPost_local`), and the memory on entry -likewise for a cipher that reads only the schedule (`encFinalPost_inLocal`, -`decFinalPost_inLocal`, which 32-bit x86's frame needs too), as the frame that +`decFinalPost`, and OFB's `ofbFinalPost`), which read the memory on return +only within the function's buffers (`encFinalPost_local`, `decFinalPost_local`, +`ofbFinalPost_local`), and the memory on entry likewise for a cipher that +reads only the schedule (`encFinalPost_inLocal`, `decFinalPost_inLocal`, +`ofbFinalPost_inLocal`, which 32-bit x86's frame needs too), as the frame that keeps a scratch buffer on the stack needs (`Verified.stackScratchWiped`). Nothing here depends on a cipher or a target. -/ @@ -39,6 +41,10 @@ def encFinalPost (ciph : Mem → Addr → Spec.Cbc.Cipher) (b pb : Nat) : (final def decFinalPost (ciph : Mem → Addr → Spec.Cbc.Cipher) (b pb : Nat) : (finalSig nk ek nkLen b).Post pb := fun k iv data len m m' _ => Spec.Cfb.DecryptFinal (ciph m k) b m m' iv data len.toNat +/-- The final OFB function's postcondition. -/ +def ofbFinalPost (ciph : Mem → Addr → Spec.Cbc.Cipher) (b pb : Nat) : (finalSig nk ek nkLen b).Post pb := + fun k iv data len m m' _ => Spec.Ofb.CryptFinal (ciph m k) b m m' iv data len.toNat + section variable {m₁ m₂ : Mem} {p : Addr} @@ -205,4 +211,50 @@ theorem decFinalPostIn_local {ciph : Mem → Addr → Spec.Cbc.Cipher} {b : Nat} rw [hc hk, hv, hd] exact h +theorem ofbFinalPost_local {ciph : Mem → Addr → Spec.Cbc.Cipher} {b : Nat} : + ∀ vs m m₁ m₂ r, vs.length = ((finalSig nk ek nkLen b).words pb).length → + (∀ r ∈ Sig.bufs (finalSig nk ek nkLen b).params vs, ∀ a, r.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply ((finalSig nk ek nkLen b).words pb) (ofbFinalPost ciph b pb) vs m m₁ r → + Curry.apply ((finalSig nk ek nkLen b).words pb) (ofbFinalPost ciph b pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + obtain ⟨k, iv, data, len, rfl, hv, hd⟩ := final_bufs (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] (ofbFinalPost ciph b pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] (ofbFinalPost ciph b pb) _ m m₂ r + dsimp only [Curry.apply, ofbFinalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + rw [hv, hd] + exact h + +/-- `ofbFinalPost` reads the memory on entry only within the function's +buffers, for a cipher that reads only the schedule (`hc`). -/ +theorem ofbFinalPost_inLocal {ciph : Mem → Addr → Spec.Cbc.Cipher} {b : Nat} + (hc : ∀ m₁ m₂ k, (∀ i < nkLen, m₂ (k + BitVec.ofNat 64 i) = m₁ (k + BitVec.ofNat 64 i)) → ciph m₂ k = ciph m₁ k) : + ∀ vs m₁ m₂ m' r, vs.length = ((finalSig nk .u8 nkLen b).words pb).length → + (∀ r ∈ Sig.bufs (finalSig nk .u8 nkLen b).params vs, ∀ a, r.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply ((finalSig nk .u8 nkLen b).words pb) (ofbFinalPost ciph b pb) vs m₁ m' r → + Curry.apply ((finalSig nk .u8 nkLen b).words pb) (ofbFinalPost ciph b pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + obtain ⟨k, iv, data, len, rfl, hk, hv, hd⟩ := final_bufsIn (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] (ofbFinalPost ciph b pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] (ofbFinalPost ciph b pb) _ m₂ m' r + dsimp only [Curry.apply, ofbFinalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + rw [hc m₁ m₂ _ hk, hv, hd] + exact h + +/-- `ofbFinalPost_local` for the memory on entry, for a cipher that reads +only the schedule's bytes. -/ +theorem ofbFinalPostIn_local {ciph : Mem → Addr → Spec.Cbc.Cipher} {b : Nat} + (hc : ∀ {m₁ m₂ : Mem} {k : Addr}, (∀ i < nkLen * ek.size, m₂ (k + BitVec.ofNat 64 i) = m₁ (k + BitVec.ofNat 64 i)) → + ciph m₂ k = ciph m₁ k) : + ∀ vs m₁ m₂ m' r, vs.length = ((finalSig nk ek nkLen b).words pb).length → + (∀ r ∈ Sig.bufs (finalSig nk ek nkLen b).params vs, ∀ a, r.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply ((finalSig nk ek nkLen b).words pb) (ofbFinalPost ciph b pb) vs m₁ m' r → + Curry.apply ((finalSig nk ek nkLen b).words pb) (ofbFinalPost ciph b pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + obtain ⟨k, iv, data, len, rfl, hk, hv, hd⟩ := final_bufs3 (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] (ofbFinalPost ciph b pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] (ofbFinalPost ciph b pb) _ m₂ m' r + dsimp only [Curry.apply, ofbFinalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + rw [hc hk, hv, hd] + exact h + end VG.Proof.Modes diff --git a/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean b/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean index 599f00c8309..7cb487ee7e9 100644 --- a/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean @@ -2,8 +2,11 @@ module public import VerifiedGarbage.Proof.Modes.Ctr public import VerifiedGarbage.Spec.Cfb.Final +public import VerifiedGarbage.Spec.Ofb.Final public import VerifiedGarbage.Proof.Modes.Fb import VerifiedGarbage.Proof.Modes.Cbc +import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.Modes.CbcEnc import VerifiedGarbage.Proof.Framework.AddrArith /-! @@ -15,8 +18,10 @@ segments of a block of `L` bytes the last of which may be partial block, and leaves the block to continue from, `fbNextF`: the input block after the whole blocks, or the partial segment's output block. When it has, the data and the block are `Spec.Cfb.encryptFinal`'s and -`encryptFinalNext`'s (`cfbEncFinal_of_bytes`), or `decryptFinal`'s and -`decryptFinalNext`'s (`cfbDecFinal_of_bytes`). Nothing here depends on a +`encryptFinalNext`'s (`cfbEncFinal_of_bytes`), `decryptFinal`'s and +`decryptFinalNext`'s (`cfbDecFinal_of_bytes`), or, for OFB, +`Spec.Ofb.cryptFinal`'s and the last output block used, `Spec.Ofb.next` +after `⌈len / L⌉` blocks (`ofbFinal_of_bytes`). Nothing here depends on a cipher or a target. -/ @@ -218,4 +223,67 @@ theorem cfbDecFinal_of_bytes {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc · rw [fbFinal_tail hL hc h, hn] · rw [fbNextF, hn]; exact cfbDecFinalNext_of ciph m₀ D iv len +/-! ## OFB of a message's last piece -/ + +/-- The number of blocks of `len` bytes, the last possibly partial: +`len / L`, and one more if `len % L ≠ 0`. -/ +theorem blockCount_eq {L : Nat} (hL : 0 < L) (len : Nat) : + Spec.Ofb.blockCount L len = if len % L = 0 then len / L else len / L + 1 := by + have hd := Nat.div_add_mod len L + have hr := Nat.mod_lt len hL + unfold Spec.Ofb.blockCount + generalize len / L = n at hd + generalize len % L = r at hd hr + subst hd + split + · subst r + rw [Nat.add_zero, Nat.add_sub_assoc (by omega), Nat.mul_add_div hL, Nat.div_eq_of_lt (by omega), Nat.add_zero] + · rw [Nat.add_assoc, Nat.add_sub_assoc (by omega), Nat.mul_add_div hL, + Nat.div_eq_of_lt_le (k := 1) (by omega) (by omega)] + +theorem length_flatten_outputs {L : Nat} {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) : + ∀ (n : Nat) (iv : List Byte), (Spec.Ofb.outputs ciph iv n).flatten.length = L * n + | 0, _ => rfl + | n + 1, iv => by + rw [outputs_succ, List.flatten_cons, List.length_append, hc, length_flatten_outputs hc n, Nat.mul_succ, + Nat.add_comm] + +/-- XORing `n` blocks with OFB's `n` output blocks, all at once. -/ +theorem xor_flatten_outputs {L : Nat} {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) (m₀ : Mem) : + ∀ (n : Nat) (D : Addr) (iv : List Byte), + Spec.Cbc.xor (blocksOf L m₀ D n).flatten (Spec.Ofb.outputs ciph iv n).flatten = + (List.zipWith Spec.Cbc.xor (blocksOf L m₀ D n) (Spec.Ofb.outputs ciph iv n)).flatten + | 0, _, _ => rfl + | n + 1, D, iv => by + rw [blocksOf_succ, outputs_succ, List.flatten_cons, List.flatten_cons, List.zipWith_cons_cons, + List.flatten_cons, ← xor_flatten_outputs hc m₀ n] + exact List.zipWith_append (by rw [hc, bytesAt_length]) + +/-- OFB of the `len` bytes at `D`, from the bytes and the block a final +function leaves: `Spec.Ofb.cryptFinal`, and the last output block used, +`Spec.Ofb.next` after `⌈len / L⌉` blocks. -/ +theorem ofbFinal_of_bytes {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + {m₀ m' : Mem} {D : Addr} {iv : List Byte} {len : Nat} + (h : ∀ i < len, m' (D + BitVec.ofNat 64 i) = (fbOut .ofb L ciph m₀ D iv (i / L)).getD (i % L) 0) : + bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) ∧ + fbNextF .ofb L ciph m₀ D iv len = Spec.Ofb.next ciph iv (Spec.Ofb.blockCount L len) := by + obtain ⟨hb, hn⟩ := ofb_of L ciph m₀ D iv (len / L) + have hx := xor_flatten_outputs hc m₀ (len / L) D iv + have hT := fbFinal_tail hL hc h + rw [hn] at hT + have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] + refine ⟨?_, ?_⟩ + · rw [bytesAt_blocks_tail L m' D len, fbFinal_blocks hc h, hb, hT, Spec.Ofb.cryptFinal, bytesAt_length, + blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] + split + · rename_i h0 + rw [h0, ← hx] + simp [bytesAt, Spec.Cbc.xor] + · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] + exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm + · rw [fbNextF, hn, blockCount_eq hL] + split + · rfl + · exact (AesOfb.next_succ ciph iv _).symm + end VG.Proof.Modes diff --git a/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalLit.lean index cc68e7908e2..faa1e7988e7 100644 --- a/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Seed.X86_64.ModesLit meta import VerifiedGarbage.Proof.Framework.X86_64.Lit -/-! # SEED-CFB128's final functions' x86-64 code as literals, for kernel-evaluated checks -/ +/-! # SEED-CFB128's and SEED-OFB's final functions' x86-64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Seed.X86_64.cfbEncryptFinal materialize_code Impl.Seed.X86_64.cfbDecryptFinal +materialize_code Impl.Seed.X86_64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalVerified.lean index 391b1f7dd10..b22810b967a 100644 --- a/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Seed/X86_64/FbFinalVerified.lean @@ -8,6 +8,7 @@ import VerifiedGarbage.Proof.Seed.X86_64.ModesLit public import VerifiedGarbage.Impl.Seed.X86_64.FbFinal public import VerifiedGarbage.Proof.Framework.X86_64.Abi public import VerifiedGarbage.Spec.Seed.CfbFinal +public import VerifiedGarbage.Spec.Seed.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -27,6 +28,7 @@ meta import VerifiedGarbage.Proof.Seed.X86_64.ModesLit meta import VerifiedGarbage.Impl.Seed.X86_64.FbFinal meta import VerifiedGarbage.Proof.Framework.X86_64.Abi meta import VerifiedGarbage.Spec.Seed.CfbFinal +meta import VerifiedGarbage.Spec.Seed.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -40,15 +42,16 @@ meta import VerifiedGarbage.Proof.Framework.X86_64.TaintMono meta import VerifiedGarbage.Proof.Seed.X86_64.Lit /-! -# SEED-CFB128 of a message's last piece on x86-64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over SEED's core -(`dirCoreSpec .encrypt`), with the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: -each is correct and constant time, by the taint analysis, as the -whole-block functions are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … -run them with their working space on the stack, zeroed on return. +# SEED-CFB128 and SEED-OFB of a message's last piece on x86-64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over SEED's +core (`dirCoreSpec .encrypt`), with the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). +`cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint +analysis, as the whole-block functions are (`FbVerified.lean`); +`cfbEncryptFinal_framed`, … run them with their working space on the stack, +zeroed on return. -/ @[expose] public section @@ -190,4 +193,45 @@ theorem cfbDecryptFinal_framed : (Proof.Modes.decFinalPost_local _) (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on x86-64: the data `len = rcx` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX86_64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 16 s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX86_64.pre s₀) : + WP isa ofbFinal s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX86_64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_ct : ConstantTime isa ofbFinalX86_64.pre ofbFinalX86_64.pub ofbFinal := + let ⟨_, h⟩ := (by taint_decide_sum [fbRoundSum] : ∃ h, (taintS.check fbTaint ofbFinal h).isSome = true) + VG.Taint.constantTime (A := taintS) fbTaint (fbTaint_agree finalLen_congr) h + +theorem ofbFinal_verified : + Verified X86_64.target ofbFinal (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 192 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 16 X86_64.abi.ptrBits) true 8) := + Verified.of_correct (k := ofbFinalX86_64) (fun s hs => by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinal) (by lit_decide) he hg, hpost⟩) + ofbFinal_ct (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalX86_64, fbPre, fbPub, X86_64.abi, X86_64.argRegs] [finalSat] + using finalSat) + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 1544 .r8 192 ofbFinal) + (Spec.Seed.ofbFinalContract X86_64.abi 1552) := + X86_64.Verified.stackScratchWiped (sig := Spec.Seed.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 192) (post := Proof.Modes.ofbFinalPost ciphAt 16 X86_64.abi.ptrBits) (wa := true) (stack := 8) + (bytes := 1544) ofbFinal_verified (by decide) (by decide) (by decide) + (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) + (Proof.Modes.ofbFinalPost_local _) + (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) + end VG.Proof.Seed.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalLit.lean index 3489ad994ed..0237df49398 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit meta import VerifiedGarbage.Proof.Framework.X86_64.Lit -/-! # SM4-CFB128's final functions' x86-64 code as literals, for kernel-evaluated checks -/ +/-! # SM4-CFB128's and SM4-OFB's final functions' x86-64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Sm4.X86_64.cfbEncryptFinal materialize_code Impl.Sm4.X86_64.cfbDecryptFinal +materialize_code Impl.Sm4.X86_64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalVerified.lean index b93c8930a83..df136f6e043 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/X86_64/FbFinalVerified.lean @@ -8,6 +8,7 @@ import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit public import VerifiedGarbage.Impl.Sm4.X86_64.FbFinal public import VerifiedGarbage.Proof.Framework.X86_64.Abi public import VerifiedGarbage.Spec.Sm4.CfbFinal +public import VerifiedGarbage.Spec.Sm4.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -25,6 +26,7 @@ meta import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit meta import VerifiedGarbage.Impl.Sm4.X86_64.FbFinal meta import VerifiedGarbage.Proof.Framework.X86_64.Abi meta import VerifiedGarbage.Spec.Sm4.CfbFinal +meta import VerifiedGarbage.Spec.Sm4.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -36,15 +38,16 @@ meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratch meta import VerifiedGarbage.Proof.Framework.Offset /-! -# SM4-CFB128 of a message's last piece on x86-64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over SM4's core -(`dirCoreSpec .encrypt`), with the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: -each is correct and constant time, by the taint analysis, as the -whole-block functions are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … -run them with their working space on the stack, zeroed on return. +# SM4-CFB128 and SM4-OFB of a message's last piece on x86-64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over SM4's +core (`dirCoreSpec .encrypt`), with the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). +`cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint +analysis, as the whole-block functions are (`FbVerified.lean`); +`cfbEncryptFinal_framed`, … run them with their working space on the stack, +zeroed on return. -/ @[expose] public section @@ -195,4 +198,44 @@ theorem cfbDecryptFinal_framed : (Proof.Modes.decFinalPost_local _) (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on x86-64: the data `len = rcx` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX86_64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 16 s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX86_64.pre s₀) : + WP isa ofbFinal s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX86_64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_ct : ConstantTime isa ofbFinalX86_64.pre ofbFinalX86_64.pub ofbFinal := + (VG.Taint.constantTime (A := taint) fbTaint (fbTaint_agree finalLen_congr) (by taint_decide)) + +theorem ofbFinal_verified : + Verified X86_64.target ofbFinal (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 400 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 16 X86_64.abi.ptrBits) true 8) := + Verified.of_correct (k := ofbFinalX86_64) (fun s hs => by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinal) (by lit_decide) he hg, hpost⟩) + ofbFinal_ct (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalX86_64, fbPre, fbPub, X86_64.abi, X86_64.argRegs, slots, savedSlot, tableEnd, tableSlot] [finalSat] + using finalSat) + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 3208 .r8 400 ofbFinal) + (Spec.Sm4.ofbFinalContract X86_64.abi 3216) := + X86_64.Verified.stackScratchWiped (sig := Spec.Sm4.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 400) (post := Proof.Modes.ofbFinalPost ciphAt 16 X86_64.abi.ptrBits) (wa := true) (stack := 8) + (bytes := 3208) ofbFinal_verified (by decide) (by decide) (by decide) + (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) + (Proof.Modes.ofbFinalPost_local _) + (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) + end VG.Proof.Sm4.X86_64 diff --git a/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalLit.lean index 1545b728521..13d85cbc1c2 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalLit.lean @@ -16,7 +16,9 @@ namespace VG materialize_code Impl.TripleDes.X86_64.cfbEncryptFinal materialize_code Impl.TripleDes.X86_64.cfbDecryptFinal +materialize_code Impl.TripleDes.X86_64.ofbFinal materialize_code Impl.TripleDes.X86_64.cfbEncryptFinalI materialize_code Impl.TripleDes.X86_64.cfbDecryptFinalI +materialize_code Impl.TripleDes.X86_64.ofbFinalI end VG diff --git a/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalVerified.lean index 36d76ff0c82..89a98efc2ff 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/X86_64/FbFinalVerified.lean @@ -8,6 +8,7 @@ import VerifiedGarbage.Proof.TripleDes.X86_64.FbLit public import VerifiedGarbage.Impl.TripleDes.X86_64.FbFinal public import VerifiedGarbage.Proof.Framework.X86_64.Abi public import VerifiedGarbage.Spec.TripleDes.CfbFinal +public import VerifiedGarbage.Spec.TripleDes.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -30,6 +31,7 @@ meta import VerifiedGarbage.Proof.TripleDes.X86_64.FbLit meta import VerifiedGarbage.Impl.TripleDes.X86_64.FbFinal meta import VerifiedGarbage.Proof.Framework.X86_64.Abi meta import VerifiedGarbage.Spec.TripleDes.CfbFinal +meta import VerifiedGarbage.Spec.TripleDes.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -46,15 +48,16 @@ meta import VerifiedGarbage.Proof.TripleDes.X86_64.BlockSum meta import VerifiedGarbage.Proof.TripleDes.X86_64.ConstantTime /-! -# Triple DES-CFB64 of a message's last piece on x86-64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86_64.fbFinal_wp`) over Triple DES's core -(`dirCoreSpec .encrypt`), with the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: -each is correct and constant time, by the taint analysis, as the -whole-block functions are (`FbVerified.lean`); `cfbEncryptFinal_framed`, … -run them with their working space on the stack, zeroed on return. +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on x86-64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.X86_64.fbFinal_wp`) over Triple +DES's core (`dirCoreSpec .encrypt`), with the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). +`cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint +analysis, as the whole-block functions are (`FbVerified.lean`); +`cfbEncryptFinal_framed`, … run them with their working space on the stack, +zeroed on return. -/ @[expose] public section @@ -252,4 +255,70 @@ theorem cfbDecryptFinal_framed : (Proof.Modes.decFinalPost_local _) (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on x86-64: the data `len = rcx` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX86_64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX86_64.pre s₀) : + WP isa ofbFinalI s₀ fun s' => gprPreserved s₀ s' ∧ ofbFinalX86_64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_correct (s : State) (hs : ofbFinalX86_64.pre s) : + ∃ t s', Exec isa ofbFinalI s t s' ∧ abiPreserved s s' ∧ ofbFinalX86_64.post s s' := by + obtain ⟨t, s', he, hg, hpost⟩ := ofbFinal_wp hs + exact ⟨t, s', he, abiPreserved_of_exec (c := ofbFinalI) (by lit_decide) he hg, hpost⟩ + +theorem ofbFinal_ct : ConstantTime isa ofbFinalX86_64.pre ofbFinalX86_64.pub ofbFinal := by + obtain ⟨_, h⟩ : ∃ h, (taintS.check fbTaint ofbFinal h).isSome = true := + by taint_decide_sum [encSum] + exact VG.Taint.constantTime (A := taintS) fbTaint (fbTaint_agree finalLen_congr) h + +theorem ofbFinal_implies : ofbFinalX86_64.Implies (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 121 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) true 0) := by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalX86_64, fbPre, fbPub, X86_64.abi, X86_64.argRegs] [finalSat] using finalSat + +theorem ofbFinal_implies8 : ofbFinalX86_64.Implies (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 121 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) true 8) := + ofbFinal_implies.stack8_abi (by + sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + X86_64.abi, X86_64.argRegs, finalSat] [finalSat] using finalSat) + +/-- The data and the IV are apart from the call's return address. -/ +theorem ofbFinal_patch (s b : State) (hv : Mem) (u : Nat → BitVec 64) + (hs : (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 121 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) true 8).pre s) (hp : ofbFinalX86_64.post s b) : + ofbFinalX86_64.post s (b.patch (hole (s.gpr .rsp)) hv u) := by + obtain ⟨-, hwr, -, -, -, -, -, -, -, -, -, -, fitI, fitD, -⟩ := ofbFinal_implies8.pre s hs + have hbD := Clear.wr_bytes (Sig.clear_of_pre hs) (p := s.gpr .rdx) (n := finalLen s) + (by rw [hwr]; simp) (by omega) + have hbI := Clear.wr_bytes (Sig.clear_of_pre hs) (p := s.gpr .rsi) (n := 8) (by rw [hwr]; simp) (by omega) + obtain ⟨h₁, h₂⟩ := hp + exact ⟨by rw [aesBytesAt_congr (patch_mem hbD)]; exact h₁, by rw [aesBytesAt_congr (patch_mem hbI)]; exact h₂⟩ + +theorem ofbFinal_inline : ofbFinal.inline = ofbFinalI := rfl + +theorem ofbFinal_verified : Verified X86_64.target ofbFinal (Sig.scratchContract X86_64.abi finalSig "scratch" .u64 121 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) true 8) := + Verified.of_inline_ct (by lit_decide) (fun s hs => by rw [ofbFinal_inline]; exact ofbFinal_correct s hs) + ofbFinal_ct ofbFinal_implies8 (fun _ h => Sig.clear_of_pre h) ofbFinal_patch + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 976 .r8 121 ofbFinal) + (Spec.TripleDes.ofbFinalContract X86_64.abi 984) := + X86_64.Verified.stackScratchWiped (sig := Spec.TripleDes.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 121) (post := Proof.Modes.ofbFinalPost ciphAt 8 X86_64.abi.ptrBits) (wa := true) (stack := 8) + (bytes := 976) ofbFinal_verified (by decide) (by decide) (by decide) + (Code.all_of_allInstrs (by lit_decide)) (by lit_decide) (by decide) + (Proof.Modes.ofbFinalPost_local _) + (X86_64.sat_regs (by decide) (by decide) (by decide +kernel) (by rw [Curry.apply_const]; trivial)) + end VG.Proof.TripleDes.X86_64 From 1dcf6b0ee1d87151f78e1f24e9ba30527d4744d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:19:04 +0000 Subject: [PATCH 02/18] OFB final functions on AArch64 for Blowfish, Camellia, CAST5, IDEA, SEED, SM4 and Triple DES (WIP: crates to come) As on x86-64: the generic fbFinal with OFB's step. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/BlowfishOfb/AArch64.lean | 9 ++- .../Artifacts/CamelliaOfb/AArch64.lean | 9 ++- .../Artifacts/Cast5Ofb/AArch64.lean | 9 ++- .../Artifacts/IdeaOfb/AArch64.lean | 9 ++- .../Artifacts/SeedOfb/AArch64.lean | 9 ++- .../Artifacts/Sm4Ofb/AArch64.lean | 9 ++- .../Artifacts/TripleDesOfb/AArch64.lean | 9 ++- .../Impl/Blowfish/AArch64/FbFinal.lean | 18 +++-- .../Impl/Camellia/AArch64/FbFinal.lean | 9 ++- .../Impl/Cast5/AArch64/FbFinal.lean | 9 ++- .../Impl/Idea/AArch64/FbFinal.lean | 9 ++- .../Impl/Seed/AArch64/FbFinal.lean | 9 ++- .../Impl/Sm4/AArch64/FbFinal.lean | 9 ++- .../Impl/TripleDes/AArch64/FbFinal.lean | 9 ++- .../Proof/Blowfish/AArch64/FbFinalLit.lean | 3 +- .../Blowfish/AArch64/FbFinalVerified.lean | 50 ++++++++++++- .../Proof/Camellia/AArch64/FbFinalLit.lean | 3 +- .../Camellia/AArch64/FbFinalVerified.lean | 75 +++++++++++++++---- .../Proof/Cast5/AArch64/FbFinalLit.lean | 3 +- .../Proof/Cast5/AArch64/FbFinalVerified.lean | 64 +++++++++++++--- .../Proof/Idea/AArch64/FbFinalLit.lean | 3 +- .../Proof/Idea/AArch64/FbFinalVerified.lean | 55 ++++++++++++-- .../Proof/Seed/AArch64/FbFinalLit.lean | 3 +- .../Proof/Seed/AArch64/FbFinalVerified.lean | 59 +++++++++++++-- .../Proof/Sm4/AArch64/FbFinalLit.lean | 3 +- .../Proof/Sm4/AArch64/FbFinalVerified.lean | 61 +++++++++++++-- .../Proof/TripleDes/AArch64/FbFinalLit.lean | 3 +- .../TripleDes/AArch64/FbFinalVerified.lean | 61 +++++++++++++-- 28 files changed, 485 insertions(+), 96 deletions(-) diff --git a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/AArch64.lean index 1fddd138a60..4c55a62d2a7 100644 --- a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/AArch64.lean @@ -1,8 +1,11 @@ module public import VerifiedGarbage.Proof.Blowfish.AArch64.FbVerified +public import VerifiedGarbage.Proof.Blowfish.AArch64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Blowfish.AArch64.ModesLit +import VerifiedGarbage.Proof.Blowfish.AArch64.FbFinalLit /-! # Blowfish-OFB artifacts on baseline AArch64 -/ @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Blowfish.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 224 .x4 28 Impl.Blowfish.AArch64.ofb stack := 224 - verified := Proof.Blowfish.AArch64.ofb_framed }] + verified := Proof.Blowfish.AArch64.ofb_framed }, + Spec.Blowfish.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 224 .x4 28 Impl.Blowfish.AArch64.ofbFinal + stack := 224 + verified := Proof.Blowfish.AArch64.ofbFinal_framed }] end VG.Artifacts.BlowfishOfb.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/AArch64.lean index e7dfa68cdf4..8ce942672bc 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/AArch64.lean @@ -1,8 +1,11 @@ module public import VerifiedGarbage.Proof.Camellia.AArch64.FbVerified +public import VerifiedGarbage.Proof.Camellia.AArch64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Camellia.AArch64.FbLit +import VerifiedGarbage.Proof.Camellia.AArch64.FbFinalLit /-! # Camellia-OFB artifacts on baseline AArch64 -/ @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 3344 .x5 418 Impl.Camellia.AArch64.ofb stack := 3344 - verified := Proof.Camellia.AArch64.ofb_framed }] + verified := Proof.Camellia.AArch64.ofb_framed }, + Spec.Camellia.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 3344 .x5 418 Impl.Camellia.AArch64.ofbFinal + stack := 3344 + verified := Proof.Camellia.AArch64.ofbFinal_framed }] end VG.Artifacts.CamelliaOfb.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/AArch64.lean index 7ee52f3cb74..f19f8ece099 100644 --- a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/AArch64.lean @@ -1,6 +1,9 @@ module public import VerifiedGarbage.Proof.Cast5.AArch64.FbVerified +public import VerifiedGarbage.Proof.Cast5.AArch64.FbFinalVerified +import VerifiedGarbage.Proof.Cast5.AArch64.ModesLit +import VerifiedGarbage.Proof.Cast5.AArch64.FbFinalLit public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Cast5.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 112 .x5 13 Impl.Cast5.AArch64.ofb stack := 112 - verified := Proof.Cast5.ofb_keyed Proof.Cast5.AArch64.ofb_framed }] + verified := Proof.Cast5.ofb_keyed Proof.Cast5.AArch64.ofb_framed }, + Spec.Cast5.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 112 .x5 13 Impl.Cast5.AArch64.ofbFinal + stack := 112 + verified := Proof.Cast5.ofbFinal_keyed Proof.Cast5.AArch64.ofbFinal_framed }] end VG.Artifacts.Cast5Ofb.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/IdeaOfb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/IdeaOfb/AArch64.lean index 45cca907f6a..abaf8f49a7f 100644 --- a/lean/VerifiedGarbage/Artifacts/IdeaOfb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/IdeaOfb/AArch64.lean @@ -1,8 +1,11 @@ module public import VerifiedGarbage.Proof.Idea.AArch64.FbVerified +public import VerifiedGarbage.Proof.Idea.AArch64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Idea.AArch64.ModesLit +import VerifiedGarbage.Proof.Idea.AArch64.FbFinalLit /-! # IDEA-OFB artifacts on baseline AArch64 -/ @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Idea.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 208 .x4 26 Impl.Idea.AArch64.ofb stack := 208 - verified := Proof.Idea.AArch64.ofb_framed }] + verified := Proof.Idea.AArch64.ofb_framed }, + Spec.Idea.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 208 .x4 26 Impl.Idea.AArch64.ofbFinal + stack := 208 + verified := Proof.Idea.AArch64.ofbFinal_framed }] end VG.Artifacts.IdeaOfb.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/SeedOfb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/SeedOfb/AArch64.lean index d73006ad6c4..b62f5b2de7d 100644 --- a/lean/VerifiedGarbage/Artifacts/SeedOfb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/SeedOfb/AArch64.lean @@ -1,8 +1,11 @@ module public import VerifiedGarbage.Proof.Seed.AArch64.FbVerified +public import VerifiedGarbage.Proof.Seed.AArch64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Seed.AArch64.ModesLit +import VerifiedGarbage.Proof.Seed.AArch64.FbFinalLit /-! # SEED-OFB artifacts on baseline AArch64 -/ @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Seed.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 1456 .x4 182 Impl.Seed.AArch64.ofb stack := 1456 - verified := Proof.Seed.AArch64.ofb_framed }] + verified := Proof.Seed.AArch64.ofb_framed }, + Spec.Seed.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 1456 .x4 182 Impl.Seed.AArch64.ofbFinal + stack := 1456 + verified := Proof.Seed.AArch64.ofbFinal_framed }] end VG.Artifacts.SeedOfb.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/AArch64.lean index 0a2dbd89e0e..850039c492b 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/AArch64.lean @@ -1,8 +1,11 @@ module public import VerifiedGarbage.Proof.Sm4.AArch64.FbVerified +public import VerifiedGarbage.Proof.Sm4.AArch64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Sm4.AArch64.FbLit +import VerifiedGarbage.Proof.Sm4.AArch64.FbFinalLit /-! # SM4-OFB artifacts on baseline AArch64 -/ @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 3264 .x4 408 Impl.Sm4.AArch64.ofb stack := 3264 - verified := Proof.Sm4.AArch64.ofb_framed }] + verified := Proof.Sm4.AArch64.ofb_framed }, + Spec.Sm4.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 3264 .x4 408 Impl.Sm4.AArch64.ofbFinal + stack := 3264 + verified := Proof.Sm4.AArch64.ofbFinal_framed }] end VG.Artifacts.Sm4Ofb.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/AArch64.lean b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/AArch64.lean index fae0a14950a..870ada8b7b3 100644 --- a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/AArch64.lean @@ -1,8 +1,11 @@ module public import VerifiedGarbage.Proof.TripleDes.AArch64.FbVerified +public import VerifiedGarbage.Proof.TripleDes.AArch64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.TripleDes.AArch64.FbLit +import VerifiedGarbage.Proof.TripleDes.AArch64.FbFinalLit /-! # Triple DES-OFB artifacts on baseline AArch64 -/ @@ -14,6 +17,10 @@ def artifacts : List Artifact := [ Spec.TripleDes.ofbApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 1008 .x4 125 Impl.TripleDes.AArch64.ofb stack := 1008 - verified := Proof.TripleDes.AArch64.ofb_framed }] + verified := Proof.TripleDes.AArch64.ofb_framed }, + Spec.TripleDes.ofbFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 1008 .x4 125 Impl.TripleDes.AArch64.ofbFinal + stack := 1008 + verified := Proof.TripleDes.AArch64.ofbFinal_framed }] end VG.Artifacts.TripleDesOfb.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Blowfish/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Blowfish/AArch64/FbFinal.lean index c7dad042dd0..f9f84facf0f 100644 --- a/lean/VerifiedGarbage/Impl/Blowfish/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Blowfish/AArch64/FbFinal.lean @@ -4,13 +4,14 @@ public import VerifiedGarbage.Impl.Blowfish.AArch64.Modes public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# Blowfish-CFB64 of a message's last piece on AArch64 - -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, iv = x1, -data = x2, len = x3, scratch = x4): the modes' CFB over a message's last -piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over Blowfish's -encryption core, with the arguments of `cfbEncrypt` but the data's length -in bytes, and the IV's address kept in `x25`, as there. +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on AArch64 + +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, +iv = x1, data = x2, len = x3, scratch = x4): the modes' CFB and OFB over a +message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), +over Blowfish's encryption core, with the arguments of `cfbEncrypt` (and +`ofb`) but the data's length in bytes, and the IV's address kept in `x25`, +as there. -/ @[expose] public section @@ -25,4 +26,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).fbFinal .cfbEnc modeRegs .x25 /-- `vg_blowfish_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).fbFinal .cfbDec modeRegs .x25 +/-- `vg_blowfish_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).fbFinal .ofb modeRegs .x25 + end VG.Impl.Blowfish.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Camellia/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/AArch64/FbFinal.lean index e6093c3f171..bd1a2c827c4 100644 --- a/lean/VerifiedGarbage/Impl/Camellia/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Camellia/AArch64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Camellia.AArch64.Fb public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# Camellia-CFB128 of a message's last piece on AArch64 +# Camellia-CFB128 and Camellia-OFB of a message's last piece on AArch64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, rounds = x1, -iv = x2, data = x3, len = x4, scratch = x5): the modes' CFB over a message's +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, rounds = x1, +iv = x2, data = x3, len = x4, scratch = x5): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over the serial encryption core of `ofb` and `cfbEncrypt`, with their arguments but the data's length in bytes, and the IV's address kept in `x19`, as there. @@ -26,4 +26,7 @@ def cfbEncryptFinal : Prog isa := fbCore.fbFinal .cfbEnc ⟨.x2, .x3, .x4, .x5 /-- `vg_camellia_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := fbCore.fbFinal .cfbDec ⟨.x2, .x3, .x4, .x5⟩ .x19 +/-- `vg_camellia_ofb_final`. -/ +def ofbFinal : Prog isa := fbCore.fbFinal .ofb ⟨.x2, .x3, .x4, .x5⟩ .x19 + end VG.Impl.Camellia.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Cast5/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Cast5/AArch64/FbFinal.lean index 76ba26427a5..595890a8696 100644 --- a/lean/VerifiedGarbage/Impl/Cast5/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Cast5/AArch64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Cast5.AArch64.Modes public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# CAST5-CFB64 of a message's last piece on AArch64 +# CAST5-CFB64 and CAST5-OFB of a message's last piece on AArch64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, rounds = x1, -iv = x2, data = x3, len = x4, scratch = x5): the modes' CFB over a message's +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, rounds = x1, +iv = x2, data = x3, len = x4, scratch = x5): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over CAST5's encryption core, with the arguments of `cfbEncrypt` but the data's length in bytes, and the IV's address kept in `x25`, as there. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).fbFinal .cfbEnc modeRegs .x25 /-- `vg_cast5_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).fbFinal .cfbDec modeRegs .x25 +/-- `vg_cast5_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).fbFinal .ofb modeRegs .x25 + end VG.Impl.Cast5.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Idea/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Idea/AArch64/FbFinal.lean index 868ac5a20fe..e4a554bd14f 100644 --- a/lean/VerifiedGarbage/Impl/Idea/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Idea/AArch64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Idea.AArch64.Modes public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# IDEA-CFB64 of a message's last piece on AArch64 +# IDEA-CFB64 and IDEA-OFB of a message's last piece on AArch64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, iv = x1, -data = x2, len = x3, scratch = x4): the modes' CFB over a message's last +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, iv = x1, +data = x2, len = x3, scratch = x4): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over IDEA's core, with the arguments of `cfbEncrypt` but the data's length in bytes, and the IV's address kept in `x25`, as there. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := modeCore.fbFinal .cfbEnc modeRegs .x25 /-- `vg_idea_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := modeCore.fbFinal .cfbDec modeRegs .x25 +/-- `vg_idea_ofb_final`. -/ +def ofbFinal : Prog isa := modeCore.fbFinal .ofb modeRegs .x25 + end VG.Impl.Idea.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Seed/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Seed/AArch64/FbFinal.lean index 4fce1619169..4263f666ea8 100644 --- a/lean/VerifiedGarbage/Impl/Seed/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Seed/AArch64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Seed.AArch64.Modes public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# SEED-CFB128 of a message's last piece on AArch64 +# SEED-CFB128 and SEED-OFB of a message's last piece on AArch64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, iv = x1, -data = x2, len = x3, scratch = x4): the modes' CFB over a message's last +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, iv = x1, +data = x2, len = x3, scratch = x4): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over SEED encryption's core, with the arguments of `cfbEncrypt` but the data's length in bytes, and the IV's address kept in `x25` (in `v31` around the core), as @@ -26,4 +26,7 @@ def cfbEncryptFinal : Prog isa := fbCore.fbFinal .cfbEnc modeRegs .x25 /-- `vg_seed_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := fbCore.fbFinal .cfbDec modeRegs .x25 +/-- `vg_seed_ofb_final`. -/ +def ofbFinal : Prog isa := fbCore.fbFinal .ofb modeRegs .x25 + end VG.Impl.Seed.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Sm4/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/AArch64/FbFinal.lean index dba4e360125..e5ddd7e9b36 100644 --- a/lean/VerifiedGarbage/Impl/Sm4/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Sm4/AArch64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Sm4.AArch64.Fb public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# SM4-CFB128 of a message's last piece on AArch64 +# SM4-CFB128 and SM4-OFB of a message's last piece on AArch64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, iv = x1, -data = x2, len = x3, scratch = x4): the modes' CFB over a message's last +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, iv = x1, +data = x2, len = x3, scratch = x4): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over the serial encryption core of `ofb` and `cfbEncrypt`, with their arguments but the data's length in bytes, and the IV's address kept in `x19`, as there. @@ -26,4 +26,7 @@ def cfbEncryptFinal : Prog isa := fbCore.fbFinal .cfbEnc ⟨.x1, .x2, .x3, .x4 /-- `vg_sm4_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := fbCore.fbFinal .cfbDec ⟨.x1, .x2, .x3, .x4⟩ .x19 +/-- `vg_sm4_ofb_final`. -/ +def ofbFinal : Prog isa := fbCore.fbFinal .ofb ⟨.x1, .x2, .x3, .x4⟩ .x19 + end VG.Impl.Sm4.AArch64 diff --git a/lean/VerifiedGarbage/Impl/TripleDes/AArch64/FbFinal.lean b/lean/VerifiedGarbage/Impl/TripleDes/AArch64/FbFinal.lean index 74100a6c523..22a32e24b92 100644 --- a/lean/VerifiedGarbage/Impl/TripleDes/AArch64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/TripleDes/AArch64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.TripleDes.AArch64.Fb public import VerifiedGarbage.Impl.Modes.AArch64.FbFinal /-! -# Triple DES-CFB64 of a message's last piece on AArch64 +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on AArch64 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = x0, iv = x1, -data = x2, len = x3, scratch = x4): the modes' CFB over a message's last +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = x0, iv = x1, +data = x2, len = x3, scratch = x4): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/AArch64/FbFinal.lean`), over CBC encryption's core, with the arguments of `cfbEncrypt` but the data's length in bytes, and the IV's address kept in `x25`, as there. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbEnc fbRegs .x25 /-- `vg_triple_des_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).fbFinal .cfbDec fbRegs .x25 +/-- `vg_triple_des_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).fbFinal .ofb fbRegs .x25 + end VG.Impl.TripleDes.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalLit.lean index fdbf99bd4fb..adf98f010ba 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Blowfish.AArch64.ModesLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # Blowfish-CFB64's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # Blowfish-CFB64's and Blowfish-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Blowfish.AArch64.cfbEncryptFinal materialize_code Impl.Blowfish.AArch64.cfbDecryptFinal +materialize_code Impl.Blowfish.AArch64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalVerified.lean index 64451b50e74..b01a834ee7b 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/AArch64/FbFinalVerified.lean @@ -7,6 +7,7 @@ import VerifiedGarbage.Proof.Blowfish.AArch64.FbFinalLit import VerifiedGarbage.Proof.Blowfish.AArch64.ModesLit public import VerifiedGarbage.Impl.Blowfish.AArch64.FbFinal public import VerifiedGarbage.Spec.Blowfish.CfbFinal +public import VerifiedGarbage.Spec.Blowfish.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -21,6 +22,7 @@ meta import VerifiedGarbage.Proof.Blowfish.AArch64.FbFinalLit meta import VerifiedGarbage.Proof.Blowfish.AArch64.ModesLit meta import VerifiedGarbage.Impl.Blowfish.AArch64.FbFinal meta import VerifiedGarbage.Spec.Blowfish.CfbFinal +meta import VerifiedGarbage.Spec.Blowfish.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -30,13 +32,14 @@ meta import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe meta import VerifiedGarbage.Proof.Framework.AArch64.Exec /-! -# Blowfish-CFB64 of a message's last piece on AArch64 meets its contracts +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on AArch64 meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over Blowfish's encryption +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over Blowfish's encryption core (`dirCoreSpec true`), with the IV's address in `x25`, as for the whole-block functions (`FbVerified.lean`), and the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). The low halves of `v8`–`v15` are +(`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). The low halves of `v8`–`v15` are kept as there: the modes' code writes no vector register and every run of `crypt` keeps them. `cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint analysis, as the whole-block functions are; @@ -98,6 +101,12 @@ def cfbDecFinalAArch64 : Contract isa where post s s' := Spec.Cfb.DecryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (finalLen s) pub := fbPub +/-- The final OFB function's contract on AArch64. -/ +def ofbFinalAArch64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (finalLen s) + pub := fbPub + theorem cfbEncryptFinal_wp {s₀ : State} (hp : cfbEncFinalAArch64.pre s₀) : WP isa cfbEncryptFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ cfbEncFinalAArch64.post s₀ s' := @@ -112,6 +121,13 @@ theorem cfbDecryptFinal_wp {s₀ : State} (hp : cfbDecFinalAArch64.pre s₀) : obtain ⟨h1, h2⟩ := Modes.cfbDecFinal_of_bytes (by decide) (cipher_length _) hd exact ⟨hg, h1, hv.trans h2⟩ +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalAArch64.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalAArch64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + /-- Every instruction keeps `v8`–`v15`, but in `crypt`. -/ theorem fbFinal_vSafe (mo : Impl.Modes.FbMode) : VSafeBut (dirCore true).crypt ((dirCore true).fbFinal mo modeRegs .x25) := by @@ -179,6 +195,19 @@ theorem cfbDecryptFinal_verified : Proof.Modes.decFinalPost, cfbDecFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs] [finalSat] using finalSat) +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (Sig.scratchContract AArch64.abi finalSig "scratch" .u64 28 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 AArch64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalAArch64) (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs (rs := [.x30]) (ofbFinal_wp hs) (by lit_decide) + (by lit_decide) + exact ⟨t, s', he, finalAbi_of he h₁ h₃, h₂⟩) + (VG.Taint.constantTime (A := taint) (Taint.ofRegs [.x0, .x1, .x2, .x3, .x4]) fbTaint_agree + (by taint_decide)) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs] [finalSat] + using finalSat) + theorem cfbEncFinalFrameSat_pre : ∃ s, (Spec.Blowfish.cfbEncryptFinalContract AArch64.abi 224).pre s := by implies_sat [Spec.Blowfish.cfbEncryptFinalContract, Spec.Blowfish.cfbFinalSig, AArch64.abi, AArch64.argRegs] [finalFrameSat] using finalFrameSat @@ -187,6 +216,10 @@ theorem cfbDecFinalFrameSat_pre : ∃ s, (Spec.Blowfish.cfbDecryptFinalContract implies_sat [Spec.Blowfish.cfbDecryptFinalContract, Spec.Blowfish.cfbFinalSig, AArch64.abi, AArch64.argRegs] [finalFrameSat] using finalFrameSat +theorem ofbFinalFrameSat_pre : ∃ s, (Spec.Blowfish.ofbFinalContract AArch64.abi 224).pre s := by + implies_sat [Spec.Blowfish.ofbFinalContract, Spec.Blowfish.ofbFinalSig, AArch64.abi, AArch64.argRegs] + [finalFrameSat] using finalFrameSat + /-- The final CFB64 encryption with its working space on the stack. -/ theorem cfbEncryptFinal_framed : Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 224 .x4 28 cfbEncryptFinal) @@ -205,4 +238,13 @@ theorem cfbDecryptFinal_framed : (bytes := 224) cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Modes.decFinalPost_local _) cfbDecFinalFrameSat_pre +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 224 .x4 28 ofbFinal) + (Spec.Blowfish.ofbFinalContract AArch64.abi 224) := + AArch64.Verified.stackScratchWiped (sig := Spec.Blowfish.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 28) (post := Proof.Modes.ofbFinalPost ciphAt 8 AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 224) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat_pre + end VG.Proof.Blowfish.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalLit.lean index 4deb8ebf400..8c76eb23c4f 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Camellia.AArch64.FbLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # Camellia-CFB128's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # Camellia-CFB128's and Camellia-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG.Proof.Camellia.AArch64 materialize_code cfbEncryptFinalCode := Impl.Camellia.AArch64.cfbEncryptFinal materialize_code cfbDecryptFinalCode := Impl.Camellia.AArch64.cfbDecryptFinal +materialize_code ofbFinalCode := Impl.Camellia.AArch64.ofbFinal end VG.Proof.Camellia.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalVerified.lean index 5f02ed04158..1b00ad10d3f 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/AArch64/FbFinalVerified.lean @@ -7,6 +7,7 @@ import VerifiedGarbage.Proof.Camellia.AArch64.FbFinalLit import VerifiedGarbage.Proof.Camellia.AArch64.FbLit public import VerifiedGarbage.Impl.Camellia.AArch64.FbFinal public import VerifiedGarbage.Spec.Camellia.CfbFinal +public import VerifiedGarbage.Spec.Camellia.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Camellia.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -22,6 +23,7 @@ meta import VerifiedGarbage.Proof.Camellia.AArch64.FbFinalLit meta import VerifiedGarbage.Proof.Camellia.AArch64.FbLit meta import VerifiedGarbage.Impl.Camellia.AArch64.FbFinal meta import VerifiedGarbage.Spec.Camellia.CfbFinal +meta import VerifiedGarbage.Spec.Camellia.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Camellia.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -32,20 +34,20 @@ meta import VerifiedGarbage.Proof.Framework.AArch64.VectorTaint meta import VerifiedGarbage.Proof.Framework.AArch64.Lit /-! -# Camellia-CFB128 of a message's last piece on AArch64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over Camellia's serial -encryption core (`fbCoreSpec`), with the IV's address in `x19`, as for OFB -and CFB encryption of whole blocks (`FbVerified.lean`), and the -specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …). -`cfbEncryptFinal_verified`, …: each is correct and constant time, by the -taint analysis, as the whole-block functions are, for the subkeys at -`schedule` (`Proof.Camellia.cfbEncFinalScratchContract`); -`cfbEncryptFinal_framed`, … run them with their working space on the stack, -zeroed on return: 3344 bytes, the 418 words of the scratch buffer, and meet -the contracts for every key whose subkeys those are -(`Proof.Camellia.cfbEncryptFinal_of_sk`). +# Camellia-CFB128 and Camellia-OFB of a message's last piece on AArch64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over +Camellia's serial encryption core (`fbCoreSpec`), with the IV's address in +`x19`, as for OFB and CFB encryption of whole blocks (`FbVerified.lean`), and +the specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is +correct and constant time, by the taint analysis, as the whole-block +functions are, for the subkeys at `schedule` +(`Proof.Camellia.cfbEncFinalScratchContract`); `cfbEncryptFinal_framed`, … +run them with their working space on the stack, zeroed on return: 3344 +bytes, the 418 words of the scratch buffer, and meet the contracts for every +key whose subkeys those are (`Proof.Camellia.cfbEncryptFinal_of_sk`). -/ @[expose] public section @@ -192,4 +194,49 @@ theorem cfbDecryptFinal_framed : (bytes := 3344) cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Camellia.cfbDecryptFinalPostOut_local _) cfbDecryptFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on AArch64: the data `len = x4` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalAArch64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 16 s.mem s'.mem (s.gpr .x2) (s.gpr .x3) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalAArch64.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalAArch64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length s₀) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_keeps_x30 : Modes.AArch64.KeepsReg .x30 ofbFinal := by camellia_keeps_x30 + +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (Proof.Camellia.ofbFinalScratchContract AArch64.abi (slots + 12)) := + Verified.of_correct (k := ofbFinalAArch64) (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs' ofbFinal_keeps_x30 (ofbFinal_wp hs) + exact ⟨t, s', he, abi_of he h₁ h₃ (by lit_decide), h₂⟩) + (VG.Taint.constantTime (A := VectorTaint.taint) (VectorTaint.ofRegs [.x0, .x1, .x2, .x3, .x4, .x5]) + fbTaint_agree (by taint_decide)) (by + sig_implies [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, + Curry.withScratch, Curry.app, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, + Proof.Camellia.ofbFinalPostSk, ofbFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs, slots, + tailSlot, savedSlot, endSlot, keySlot] [finalSat] using finalSat) + +theorem ofbFinalFrameSat_pre : ∃ s, (Proof.Camellia.ofbFinalContractSk AArch64.abi 3344).pre s := by + implies_sat [Proof.Camellia.ofbFinalContractSk, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, + Proof.Camellia.ofbFinalPostSk, AArch64.abi, AArch64.argRegs] [finalFrameSat] using finalFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 3344 .x5 418 ofbFinal) + (Spec.Camellia.ofbFinalContract AArch64.abi 3344) := + Proof.Camellia.ofbFinal_of_sk <| + AArch64.Verified.stackScratchWiped (sig := Spec.Camellia.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 418) (pre := Spec.Camellia.ofbFinalPre AArch64.abi.ptrBits) + (post := Proof.Camellia.ofbFinalPostSk AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 3344) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Camellia.ofbFinalPostOut_local _) ofbFinalFrameSat_pre + end VG.Proof.Camellia.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalLit.lean index 325325e3b65..5c931429139 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Cast5.AArch64.ModesLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # CAST5-CFB64's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # CAST5-CFB64's and CAST5-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Cast5.AArch64.cfbEncryptFinal materialize_code Impl.Cast5.AArch64.cfbDecryptFinal +materialize_code Impl.Cast5.AArch64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalVerified.lean index 99c64d7595a..78634706546 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/AArch64/FbFinalVerified.lean @@ -34,18 +34,18 @@ meta import VerifiedGarbage.Proof.Framework.AArch64.Exec meta import VerifiedGarbage.Proof.Framework.Contract /-! -# CAST5-CFB64 of a message's last piece on AArch64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over CAST5's core -(`Mode.dirCoreSpec true`), with the IV's address in `x25`, as for the -whole-block functions (`FbVerified.lean`), and the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: -each is correct and constant time, by the taint analysis, as the -whole-block functions are, for the subkeys at `schedule` -(`Proof.Cast5.cfbEncFinalPost`); `cfbEncryptFinal_framed`, … run them with -their working space on the stack, zeroed on return: 112 bytes, the 13 words -of the scratch buffer and 8 more. +# CAST5-CFB64 and CAST5-OFB of a message's last piece on AArch64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over +CAST5's core (`Mode.dirCoreSpec true`), with the IV's address in `x25`, as +for the whole-block functions (`FbVerified.lean`), and the specification's +results (`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is +correct and constant time, by the taint analysis, as the whole-block +functions are, for the subkeys at `schedule` (`Proof.Cast5.cfbEncFinalPost`); +`cfbEncryptFinal_framed`, … run them with their working space on the stack, +zeroed on return: 112 bytes, the 13 words of the scratch buffer and 8 more. -/ @[expose] public section @@ -241,4 +241,44 @@ theorem cfbDecryptFinal_framed : cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Cast5.cfbDecFinalPostOut_local _) (finalFrame_sat _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on AArch64: the data `len = x4` bytes +long, and the data and the IV as `Spec.Ofb.CryptFinal` says. -/ +def ofbFinalX : Contract isa where + pre := FPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .x2) (s.gpr .x3) (finalLen s) + pub := cbcPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalX.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalX.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length s₀) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_ct : ConstantTime isa ofbFinalX.pre ofbFinalX.pub ofbFinal := + VG.Taint.constantTime (A := taintS [s1234Sym]) (Taint.ofRegs modePub) fbTaint_agree (by taint_decide) + +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (finalK (Proof.Cast5.ofbFinalPost AArch64.abi.ptrBits)) := + Verified.of_correct (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs (rs := [.x30]) (ofbFinal_wp hs) (by lit_decide) + (by lit_decide) + exact ⟨t, s', he, abi_of he h₁ h₃ (by lit_decide), h₂⟩) + ofbFinal_ct (final_implies (post := Proof.Cast5.ofbFinalPost AArch64.abi.ptrBits) fun s s' h => by + sig_post [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Spec.Cast5.ofbFinalSig, + Proof.Cast5.ofbFinalPost, AArch64.abi, AArch64.argRegs, ecbConsts_eq, Abi.withConsts, Curry.withScratch] + exact h) + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 112 .x5 13 ofbFinal) + (Proof.Cast5.ofbFinalRoundsContract (AArch64.abi.withConsts ecbConsts) 112) := + AArch64.Verified.stackScratchWipedC (c₀ := (s1234Sym, s1234)) (cs := []) (sig := Spec.Cast5.ofbFinalSig) + (nm := "scratch") (e := .u64) (n := 13) (pre := Spec.Cast5.ofbFinalPre AArch64.abi.ptrBits) + (post := Proof.Cast5.ofbFinalPost AArch64.abi.ptrBits) (wa := true) (stack := 0) (bytes := 112) + ofbFinal_verified (by decide) (by decide) (by decide) (Proof.Cast5.ofbFinalPostOut_local _) + (finalFrame_sat _) + end VG.Proof.Cast5.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalLit.lean index 4b9b50bc8e2..55028b70bfa 100644 --- a/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Idea.AArch64.ModesLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # IDEA-CFB64's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # IDEA-CFB64's and IDEA-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Idea.AArch64.cfbEncryptFinal materialize_code Impl.Idea.AArch64.cfbDecryptFinal +materialize_code Impl.Idea.AArch64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalVerified.lean index 72056b2a77d..f212892a76b 100644 --- a/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Idea/AArch64/FbFinalVerified.lean @@ -7,6 +7,7 @@ import VerifiedGarbage.Proof.Idea.AArch64.FbFinalLit import VerifiedGarbage.Proof.Idea.AArch64.ModesLit public import VerifiedGarbage.Impl.Idea.AArch64.FbFinal public import VerifiedGarbage.Spec.Idea.CfbFinal +public import VerifiedGarbage.Spec.Idea.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -20,6 +21,7 @@ meta import VerifiedGarbage.Proof.Idea.AArch64.FbFinalLit meta import VerifiedGarbage.Proof.Idea.AArch64.ModesLit meta import VerifiedGarbage.Impl.Idea.AArch64.FbFinal meta import VerifiedGarbage.Spec.Idea.CfbFinal +meta import VerifiedGarbage.Spec.Idea.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -28,13 +30,13 @@ meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe /-! -# IDEA-CFB64 of a message's last piece on AArch64 meets its contracts +# IDEA-CFB64 and IDEA-OFB of a message's last piece on AArch64 meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over IDEA's core -(`modeCoreSpec`), with the IV's address in `x25`, as for the whole-block -functions (`FbVerified.lean`), and the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over +IDEA's core (`modeCoreSpec`), with the IV's address in `x25`, as for the +whole-block functions (`FbVerified.lean`), and the specification's results +(`Proof.Modes.cfbEncFinal_of_bytes`, …, `Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint analysis, as the whole-block functions are; `cfbEncryptFinal_framed`, … run them with their working space on the stack, zeroed on return: 208 bytes, the 26 words of the @@ -182,4 +184,45 @@ theorem cfbDecryptFinal_framed : (bytes := 208) cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Modes.decFinalPost_local _) cfbDecFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on AArch64. -/ +def ofbFinalAArch64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalAArch64.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalAArch64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (Sig.scratchContract AArch64.abi finalSig "scratch" .u64 26 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 AArch64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalAArch64) (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs (rs := [.x30]) (ofbFinal_wp hs) (by lit_decide) + (by lit_decide) + exact ⟨t, s', he, abi_of he h₁ h₃ (by lit_decide), h₂⟩) + (VG.Taint.constantTime (A := taint) (Taint.ofRegs [.x0, .x1, .x2, .x3, .x4]) fbTaint_agree + (by taint_decide)) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs] [finalSat] + using finalSat) + +theorem ofbFinalFrameSat_pre : ∃ s, (Spec.Idea.ofbFinalContract AArch64.abi 208).pre s := by + implies_sat [Spec.Idea.ofbFinalContract, Spec.Idea.ofbFinalSig, AArch64.abi, AArch64.argRegs] + [finalFrameSat] using finalFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 208 .x4 26 ofbFinal) + (Spec.Idea.ofbFinalContract AArch64.abi 208) := + AArch64.Verified.stackScratchWiped (sig := Spec.Idea.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 26) (post := Proof.Modes.ofbFinalPost ciphAt 8 AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 208) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat_pre + end VG.Proof.Idea.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalLit.lean index 08ae07ba10a..3eb0dceee19 100644 --- a/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Seed.AArch64.ModesLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # Seed-CFB128's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # Seed-CFB128's and SEED-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.Seed.AArch64.cfbEncryptFinal materialize_code Impl.Seed.AArch64.cfbDecryptFinal +materialize_code Impl.Seed.AArch64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalVerified.lean index 4d8d6f4e21f..4ecfda2cf7a 100644 --- a/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Seed/AArch64/FbFinalVerified.lean @@ -7,6 +7,7 @@ import VerifiedGarbage.Proof.Seed.AArch64.FbFinalLit import VerifiedGarbage.Proof.Seed.AArch64.ModesLit public import VerifiedGarbage.Impl.Seed.AArch64.FbFinal public import VerifiedGarbage.Spec.Seed.CfbFinal +public import VerifiedGarbage.Spec.Seed.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -22,6 +23,7 @@ meta import VerifiedGarbage.Proof.Seed.AArch64.FbFinalLit meta import VerifiedGarbage.Proof.Seed.AArch64.ModesLit meta import VerifiedGarbage.Impl.Seed.AArch64.FbFinal meta import VerifiedGarbage.Spec.Seed.CfbFinal +meta import VerifiedGarbage.Spec.Seed.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -32,13 +34,14 @@ meta import VerifiedGarbage.Proof.Framework.AArch64.VectorTaint meta import VerifiedGarbage.Proof.Framework.AArch64.Lit /-! -# SEED-CFB128 of a message's last piece on AArch64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over SEED encryption's core -(`fbCoreSpec`), with the IV's address in `x25`, kept in `v31` around the -core, as for the whole-block functions (`FbVerified.lean`), and the -specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …). +# SEED-CFB128 and SEED-OFB of a message's last piece on AArch64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over SEED +encryption's core (`fbCoreSpec`), with the IV's address in `x25`, kept in +`v31` around the core, as for the whole-block functions (`FbVerified.lean`), +and the specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint analysis, as the whole-block functions are; `cfbEncryptFinal_framed`, … run them with their working space on the stack, zeroed on return: 1456 @@ -187,4 +190,46 @@ theorem cfbDecryptFinal_framed : (bytes := 1456) cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Modes.decFinalPost_local _) cfbDecFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on AArch64. -/ +def ofbFinalAArch64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 16 s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalAArch64.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalAArch64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_keeps_x30 : Modes.AArch64.KeepsReg .x30 ofbFinal := by keeps_x30 + +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (Sig.scratchContract AArch64.abi finalSig "scratch" .u64 182 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 16 AArch64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalAArch64) (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs' ofbFinal_keeps_x30 (ofbFinal_wp hs) + exact ⟨t, s', he, modeAbi_of he h₁ h₃ (by lit_decide), h₂⟩) + (VG.Taint.constantTime (A := VectorTaint.taint) (VectorTaint.ofRegs [.x0, .x1, .x2, .x3, .x4]) fbTaint_agree + (by taint_decide)) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs] [finalSat] + using finalSat) + +theorem ofbFinalFrameSat_pre : ∃ s, (Spec.Seed.ofbFinalContract AArch64.abi 1456).pre s := by + implies_sat [Spec.Seed.ofbFinalContract, Spec.Seed.ofbFinalSig, AArch64.abi, AArch64.argRegs] + [finalFrameSat] using finalFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 1456 .x4 182 ofbFinal) + (Spec.Seed.ofbFinalContract AArch64.abi 1456) := + AArch64.Verified.stackScratchWiped (sig := Spec.Seed.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 182) (post := Proof.Modes.ofbFinalPost ciphAt 16 AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 1456) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat_pre + end VG.Proof.Seed.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalLit.lean index 2d5f308cd69..c5d7d1972d8 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Sm4.AArch64.FbLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # SM4-CFB128's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # SM4-CFB128's and SM4-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG.Proof.Sm4.AArch64 materialize_code cfbEncryptFinalCode := Impl.Sm4.AArch64.cfbEncryptFinal materialize_code cfbDecryptFinalCode := Impl.Sm4.AArch64.cfbDecryptFinal +materialize_code ofbFinalCode := Impl.Sm4.AArch64.ofbFinal end VG.Proof.Sm4.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalVerified.lean index 0b8dd5e9d40..c3a6c4c63c2 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/AArch64/FbFinalVerified.lean @@ -7,6 +7,7 @@ import VerifiedGarbage.Proof.Sm4.AArch64.FbFinalLit import VerifiedGarbage.Proof.Sm4.AArch64.FbLit public import VerifiedGarbage.Impl.Sm4.AArch64.FbFinal public import VerifiedGarbage.Spec.Sm4.CfbFinal +public import VerifiedGarbage.Spec.Sm4.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -22,6 +23,7 @@ meta import VerifiedGarbage.Proof.Sm4.AArch64.FbFinalLit meta import VerifiedGarbage.Proof.Sm4.AArch64.FbLit meta import VerifiedGarbage.Impl.Sm4.AArch64.FbFinal meta import VerifiedGarbage.Spec.Sm4.CfbFinal +meta import VerifiedGarbage.Spec.Sm4.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -32,13 +34,14 @@ meta import VerifiedGarbage.Proof.Framework.AArch64.VectorTaint meta import VerifiedGarbage.Proof.Framework.AArch64.Lit /-! -# SM4-CFB128 of a message's last piece on AArch64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over SM4's serial encryption -core (`fbCoreSpec`), with the IV's address in `x19`, as for OFB and CFB -encryption of whole blocks (`FbVerified.lean`), and the specification's -results (`Proof.Modes.cfbEncFinal_of_bytes`, …). +# SM4-CFB128 and SM4-OFB of a message's last piece on AArch64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over SM4's +serial encryption core (`fbCoreSpec`), with the IV's address in `x19`, as for +OFB and CFB encryption of whole blocks (`FbVerified.lean`), and the +specification's results (`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint analysis, as the whole-block functions are; `cfbEncryptFinal_framed`, … run them with their working space on the stack, zeroed on return: 3264 @@ -191,4 +194,48 @@ theorem cfbDecryptFinal_framed : (bytes := 3264) cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Modes.decFinalPost_local _) cfbDecFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on AArch64. -/ +def ofbFinalAArch64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 16 s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalAArch64.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalAArch64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_keeps_x30 : Modes.AArch64.KeepsReg .x30 ofbFinal := by sm4_keeps_x30 + +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (Sig.scratchContract AArch64.abi finalSig "scratch" .u64 + (slots + 12) (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 16 AArch64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalAArch64) (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs' ofbFinal_keeps_x30 (ofbFinal_wp hs) + exact ⟨t, s', he, modeAbi_of he h₁ h₃ (by lit_decide), h₂⟩) + (VG.Taint.constantTime_of_exists (A := VectorTaint.taint) + (VectorTaint.ofRegs [.x0, .x1, .x2, .x3, .x4]) fbTaint_agree + (by taint_decide_sum [cryptSum])) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs, slots, + tableEnd, tableSlot] [finalSat] + using finalSat) + +theorem ofbFinalFrameSat_pre : ∃ s, (Spec.Sm4.ofbFinalContract AArch64.abi 3264).pre s := by + implies_sat [Spec.Sm4.ofbFinalContract, Spec.Sm4.ofbFinalSig, AArch64.abi, AArch64.argRegs] + [finalFrameSat] using finalFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 3264 .x4 408 ofbFinal) + (Spec.Sm4.ofbFinalContract AArch64.abi 3264) := + AArch64.Verified.stackScratchWiped (sig := Spec.Sm4.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 408) (post := Proof.Modes.ofbFinalPost ciphAt 16 AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 3264) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat_pre + end VG.Proof.Sm4.AArch64 diff --git a/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalLit.lean index 326341fba45..d9d3a387cf5 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalLit.lean @@ -8,7 +8,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.TripleDes.AArch64.FbLit meta import VerifiedGarbage.Proof.Framework.AArch64.Lit -/-! # Triple DES-CFB64's final functions' AArch64 code as literals, for kernel-evaluated checks -/ +/-! # Triple DES-CFB64's and Triple DES-OFB's final functions' AArch64 code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -16,5 +16,6 @@ namespace VG materialize_code Impl.TripleDes.AArch64.cfbEncryptFinal materialize_code Impl.TripleDes.AArch64.cfbDecryptFinal +materialize_code Impl.TripleDes.AArch64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalVerified.lean index 10f7b2b7655..a2efa6410f3 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/AArch64/FbFinalVerified.lean @@ -9,6 +9,7 @@ import VerifiedGarbage.Proof.TripleDes.AArch64.FbFinalLit import VerifiedGarbage.Proof.TripleDes.AArch64.FbLit public import VerifiedGarbage.Impl.TripleDes.AArch64.FbFinal public import VerifiedGarbage.Spec.TripleDes.CfbFinal +public import VerifiedGarbage.Spec.TripleDes.OfbFinal public import VerifiedGarbage.Proof.Modes.FbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch @@ -27,6 +28,7 @@ meta import VerifiedGarbage.Proof.TripleDes.AArch64.FbFinalLit meta import VerifiedGarbage.Proof.TripleDes.AArch64.FbLit meta import VerifiedGarbage.Impl.TripleDes.AArch64.FbFinal meta import VerifiedGarbage.Spec.TripleDes.CfbFinal +meta import VerifiedGarbage.Spec.TripleDes.OfbFinal meta import VerifiedGarbage.Proof.Modes.FbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch @@ -38,13 +40,14 @@ meta import VerifiedGarbage.Proof.Framework.AArch64.VectorTaint meta import VerifiedGarbage.Proof.Framework.AArch64.Lit /-! -# Triple DES-CFB64 of a message's last piece on AArch64 meets its contracts - -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.AArch64.fbFinal_wp`) over CBC encryption's core -(`dirCoreSpec .encrypt`), with the IV's address in `x25`, as for the -whole-block functions (`FbVerified.lean`), and the specification's results -(`Proof.Modes.cfbEncFinal_of_bytes`, …). `cfbEncryptFinal_verified`, …: +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on AArch64 meet their contracts + +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB and +OFB over a message's last piece (`Proof.Modes.AArch64.fbFinal_wp`) over CBC +encryption's core (`dirCoreSpec .encrypt`), with the IV's address in `x25`, +as for the whole-block functions (`FbVerified.lean`), and the specification's +results (`Proof.Modes.cfbEncFinal_of_bytes`, …, +`Proof.Modes.ofbFinal_of_bytes`). `cfbEncryptFinal_verified`, …: each is correct and constant time, by the taint analysis with the core's summary (`encSum`), as the whole-block functions are; `cfbEncryptFinal_framed`, … run them with their working space on the stack, @@ -198,4 +201,48 @@ theorem cfbDecryptFinal_framed : (bytes := 1008) cfbDecryptFinal_verified (by decide) (by decide) (by decide) (Proof.Modes.decFinalPost_local _) cfbDecFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's contract on AArch64. -/ +def ofbFinalAArch64 : Contract isa where + pre := fbPre finalLen + post s s' := Spec.Ofb.CryptFinal (ciphOf s) 8 s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (finalLen s) + pub := fbPub + +theorem ofbFinal_wp {s₀ : State} (hp : ofbFinalAArch64.pre s₀) : + WP isa ofbFinal s₀ fun s' => (∀ i < 10, s'.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19) = + s₀.gpr (Impl.Modes.AArch64.Core.savedRegs.getD i .x19)) ∧ ofbFinalAArch64.post s₀ s' := + WP.mono (fbFinal_wp' .ofb hp) fun s' ⟨hg, hd, hv⟩ => by + obtain ⟨h1, h2⟩ := Modes.ofbFinal_of_bytes (by decide) (cipher_length _) hd + exact ⟨hg, h1, hv.trans h2⟩ + +theorem ofbFinal_keeps_x30 : Modes.AArch64.KeepsReg .x30 ofbFinal := by keeps_x30 + +theorem ofbFinal_verified : + Verified AArch64.target ofbFinal (Sig.scratchContract AArch64.abi finalSig "scratch" .u64 125 + (Curry.const (fun _ => True) _) (Proof.Modes.ofbFinalPost ciphAt 8 AArch64.abi.ptrBits) true 0) := + Verified.of_correct (k := ofbFinalAArch64) (fun s hs => by + obtain ⟨t, s', he, ⟨h₁, h₂⟩, h₃⟩ := WP.gprs' ofbFinal_keeps_x30 (ofbFinal_wp hs) + exact ⟨t, s', he, abi_of he h₁ h₃ (by lit_decide), h₂⟩) + (VG.Taint.constantTime_of_exists (A := VectorTaint.taint) + (VectorTaint.ofRegs [.x0, .x1, .x2, .x3, .x4]) + (fun s₁ s₂ h₁ h₂ hp => ⟨fbTaint_agree s₁ s₂ h₁ h₂ hp, fun v hv => by + simp [VectorTaint.ofRegs, RegSet.mem_ofList] at hv⟩) (by taint_decide_sum [encSum])) (by + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, ofbFinalAArch64, fbPre, fbPub, AArch64.abi, AArch64.argRegs] [finalSat] + using finalSat) + +theorem ofbFinalFrameSat_pre : ∃ s, (Spec.TripleDes.ofbFinalContract AArch64.abi 1008).pre s := by + implies_sat [Spec.TripleDes.ofbFinalContract, Spec.TripleDes.ofbFinalSig, AArch64.abi, AArch64.argRegs] + [finalFrameSat] using finalFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 1008 .x4 125 ofbFinal) + (Spec.TripleDes.ofbFinalContract AArch64.abi 1008) := + AArch64.Verified.stackScratchWiped (sig := Spec.TripleDes.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 125) (post := Proof.Modes.ofbFinalPost ciphAt 8 AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 1008) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat_pre + end VG.Proof.TripleDes.AArch64 From b496dfa375e6ed4d736c7b9e0c31b50deece4d62 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:22:11 +0000 Subject: [PATCH 03/18] OFB final functions on x86 for Blowfish, Camellia, CAST5, IDEA, SEED, SM4 and Triple DES (WIP: crates to come) x86's seqFinal with OFB's mode; its proof (ofbFinal_wp) in Proof/Modes/X86/SeqFinal.lean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/BlowfishOfb/X86.lean | 8 +- .../Artifacts/CamelliaOfb/X86.lean | 8 +- .../Artifacts/Cast5Ofb/X86.lean | 8 +- .../Artifacts/IdeaOfb/X86.lean | 8 +- .../Artifacts/SeedOfb/X86.lean | 8 +- .../VerifiedGarbage/Artifacts/Sm4Ofb/X86.lean | 8 +- .../Artifacts/TripleDesOfb/X86.lean | 8 +- .../Impl/Blowfish/X86/FbFinal.lean | 9 ++- .../Impl/Camellia/X86/FbFinal.lean | 9 ++- .../Impl/Cast5/X86/FbFinal.lean | 9 ++- .../Impl/Idea/X86/FbFinal.lean | 9 ++- .../Impl/Seed/X86/FbFinal.lean | 9 ++- .../VerifiedGarbage/Impl/Sm4/X86/FbFinal.lean | 9 ++- .../Impl/TripleDes/X86/FbFinal.lean | 9 ++- .../Proof/Blowfish/X86/FbFinalLit.lean | 3 +- .../Proof/Blowfish/X86/FbFinalVerified.lean | 72 +++++++++++++++++- .../Proof/Camellia/X86/FbFinalLit.lean | 3 +- .../Proof/Camellia/X86/FbFinalVerified.lean | 71 ++++++++++++++++- .../Proof/Cast5/X86/FbFinalLit.lean | 3 +- .../Proof/Cast5/X86/FbFinalVerified.lean | 43 ++++++++++- .../Proof/Idea/X86/FbFinalLit.lean | 3 +- .../Proof/Idea/X86/FbFinalVerified.lean | 72 +++++++++++++++++- .../Proof/Modes/X86/SeqFinal.lean | 56 +++++++++++++- .../Proof/Seed/X86/FbFinalLit.lean | 3 +- .../Proof/Seed/X86/FbFinalVerified.lean | 73 +++++++++++++++++- .../Proof/Sm4/X86/FbFinalLit.lean | 3 +- .../Proof/Sm4/X86/FbFinalVerified.lean | 74 +++++++++++++++++- .../Proof/TripleDes/X86/FbFinalLit.lean | 3 +- .../Proof/TripleDes/X86/FbFinalVerified.lean | 76 ++++++++++++++++++- 29 files changed, 620 insertions(+), 57 deletions(-) diff --git a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86.lean b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86.lean index 42fb414a176..342bf80a733 100644 --- a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/X86.lean @@ -2,8 +2,10 @@ module public import VerifiedGarbage.Proof.Blowfish.X86.FbVerified import VerifiedGarbage.Proof.Blowfish.X86.ModesLit +public import VerifiedGarbage.Proof.Blowfish.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print +import VerifiedGarbage.Proof.Blowfish.X86.FbFinalLit /-! # Blowfish-OFB artifacts on baseline x86 (32-bit) -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Blowfish.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 112 4 22 Impl.Blowfish.X86.ofb stack := 112 - verified := Proof.Blowfish.X86.Fb.ofb_framed }] + verified := Proof.Blowfish.X86.Fb.ofb_framed }, + Spec.Blowfish.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 112 4 22 Impl.Blowfish.X86.ofbFinal + stack := 112 + verified := Proof.Blowfish.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.BlowfishOfb.X86 diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86.lean b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86.lean index 1a4b4b35ff5..babfc0e482f 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/X86.lean @@ -2,8 +2,10 @@ module public import VerifiedGarbage.Proof.Camellia.X86.FbVerified import VerifiedGarbage.Proof.Camellia.X86.FbLit +public import VerifiedGarbage.Proof.Camellia.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print +import VerifiedGarbage.Proof.Camellia.X86.FbFinalLit /-! # Camellia-OFB artifacts on baseline x86 (32-bit) -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 2756 5 682 Impl.Camellia.X86.ofb stack := 2772 - verified := Proof.Camellia.X86.Fb.ofb_framed }] + verified := Proof.Camellia.X86.Fb.ofb_framed }, + Spec.Camellia.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 2756 5 682 Impl.Camellia.X86.ofbFinal + stack := 2772 + verified := Proof.Camellia.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.CamelliaOfb.X86 diff --git a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86.lean b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86.lean index de0a2276fe2..25a4e1406f5 100644 --- a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/X86.lean @@ -2,8 +2,10 @@ module public import VerifiedGarbage.Proof.Cast5.X86.ModesVerified import VerifiedGarbage.Proof.Cast5.X86.ModesLit +public import VerifiedGarbage.Proof.Cast5.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print +import VerifiedGarbage.Proof.Cast5.X86.FbFinalLit /-! # CAST5-OFB artifacts on baseline x86 (32-bit) -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Cast5.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 332 5 76 Impl.Cast5.X86.Modes.ofb stack := 336 - verified := Proof.Cast5.ofb_keyed Proof.Cast5.X86.ModeFns.ofb_framed }] + verified := Proof.Cast5.ofb_keyed Proof.Cast5.X86.ModeFns.ofb_framed }, + Spec.Cast5.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 332 5 76 Impl.Cast5.X86.Modes.ofbFinal + stack := 336 + verified := Proof.Cast5.ofbFinal_keyed Proof.Cast5.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.Cast5Ofb.X86 diff --git a/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86.lean b/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86.lean index 3a164205656..b9ff2c6b73a 100644 --- a/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/IdeaOfb/X86.lean @@ -4,9 +4,11 @@ public import VerifiedGarbage.Proof.Idea.X86.FbVerified import Mathlib.Data.Finset.Attr import Mathlib.Tactic.Finiteness.Attr import Mathlib.Tactic.SetLike +public import VerifiedGarbage.Proof.Idea.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print import VerifiedGarbage.Proof.Idea.X86.ModesLit +import VerifiedGarbage.Proof.Idea.X86.FbFinalLit /-! # IDEA-OFB artifacts on baseline x86 (32-bit) -/ @@ -18,6 +20,10 @@ def artifacts : List Artifact := [ Spec.Idea.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 208 4 46 Impl.Idea.X86.ofb stack := 208 - verified := Proof.Idea.X86.Fb.ofb_framed }] + verified := Proof.Idea.X86.Fb.ofb_framed }, + Spec.Idea.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 208 4 46 Impl.Idea.X86.ofbFinal + stack := 208 + verified := Proof.Idea.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.IdeaOfb.X86 diff --git a/lean/VerifiedGarbage/Artifacts/SeedOfb/X86.lean b/lean/VerifiedGarbage/Artifacts/SeedOfb/X86.lean index 7d33e814fb2..92449d73056 100644 --- a/lean/VerifiedGarbage/Artifacts/SeedOfb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/SeedOfb/X86.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Seed.X86.FbVerified +public import VerifiedGarbage.Proof.Seed.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print import VerifiedGarbage.Proof.Seed.X86.FbLit +import VerifiedGarbage.Proof.Seed.X86.FbFinalLit /-! # SEED-OFB artifacts on baseline x86 (32-bit) -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Seed.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 1168 4 286 Impl.Seed.X86.ofb stack := 1188 - verified := Proof.Seed.X86.Fb.ofb_framed }] + verified := Proof.Seed.X86.Fb.ofb_framed }, + Spec.Seed.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 1168 4 286 Impl.Seed.X86.ofbFinal + stack := 1188 + verified := Proof.Seed.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.SeedOfb.X86 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86.lean index 492f7671a28..e7313aeff7b 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/X86.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Sm4.X86.FbVerified +public import VerifiedGarbage.Proof.Sm4.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print import VerifiedGarbage.Proof.Sm4.X86.FbLit +import VerifiedGarbage.Proof.Sm4.X86.FbFinalLit /-! # SM4-OFB artifacts on baseline x86 (32-bit) -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 1496 4 368 Impl.Sm4.X86.ofb stack := 1516 - verified := Proof.Sm4.X86.Fb.ofb_framed }] + verified := Proof.Sm4.X86.Fb.ofb_framed }, + Spec.Sm4.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 1496 4 368 Impl.Sm4.X86.ofbFinal + stack := 1516 + verified := Proof.Sm4.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.Sm4Ofb.X86 diff --git a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86.lean b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86.lean index 77fdbc4b6ee..ef2156cf21c 100644 --- a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/X86.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.TripleDes.X86.FbVerified +public import VerifiedGarbage.Proof.TripleDes.X86.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print import VerifiedGarbage.Proof.TripleDes.X86.FbLit +import VerifiedGarbage.Proof.TripleDes.X86.FbFinalLit /-! # Triple DES-OFB artifacts on baseline x86 (32-bit) -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.TripleDes.ofbApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 968 4 236 Impl.TripleDes.X86.ofb stack := 984 - verified := Proof.TripleDes.X86.Fb.ofb_framed }] + verified := Proof.TripleDes.X86.Fb.ofb_framed }, + Spec.TripleDes.ofbFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 968 4 236 Impl.TripleDes.X86.ofbFinal + stack := 984 + verified := Proof.TripleDes.X86.FbFinal.ofbFinal_framed }] end VG.Artifacts.TripleDesOfb.X86 diff --git a/lean/VerifiedGarbage/Impl/Blowfish/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/Blowfish/X86/FbFinal.lean index b569b88208c..188fc5bfb55 100644 --- a/lean/VerifiedGarbage/Impl/Blowfish/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Blowfish/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Blowfish.X86.Modes public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# Blowfish-CFB64 of a message's last piece on x86 (32-bit) +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, iv, data, len, -scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, iv, data, len, +scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over Blowfish's encrypting core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.cfbEnc 2) /-- `vg_blowfish_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_blowfish_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Blowfish.X86 diff --git a/lean/VerifiedGarbage/Impl/Camellia/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/X86/FbFinal.lean index d08c38a5745..d78c8e427e8 100644 --- a/lean/VerifiedGarbage/Impl/Camellia/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Camellia/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Camellia.X86.Modes public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# Camellia-CFB128 of a message's last piece on x86 (32-bit) +# Camellia-CFB128 and Camellia-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, rounds, iv, data, len, -scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, rounds, iv, data, len, +scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over Camellia's core in the encryption direction, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_camellia_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_camellia_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Camellia.X86 diff --git a/lean/VerifiedGarbage/Impl/Cast5/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/Cast5/X86/FbFinal.lean index 2db55dfd4a5..f9961182a1e 100644 --- a/lean/VerifiedGarbage/Impl/Cast5/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Cast5/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Cast5.X86.Modes public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# CAST5-CFB64 of a message's last piece on x86 (32-bit) +# CAST5-CFB64 and CAST5-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, rounds, iv, data, -len, scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, rounds, iv, data, +len, scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over CAST5's encrypting core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).seqFinal (Impl.Modes.Mode.cfbEn /-- `vg_cast5_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).seqFinal (Impl.Modes.Mode.cfbDec 2) +/-- `vg_cast5_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).seqFinal (Impl.Modes.Mode.ofb 2) + end VG.Impl.Cast5.X86.Modes diff --git a/lean/VerifiedGarbage/Impl/Idea/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/Idea/X86/FbFinal.lean index 8679d240a65..9aad8ac0d5b 100644 --- a/lean/VerifiedGarbage/Impl/Idea/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Idea/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Idea.X86.Modes public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# IDEA-CFB64 of a message's last piece on x86 (32-bit) +# IDEA-CFB64 and IDEA-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, iv, data, len, -scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, iv, data, len, +scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over IDEA's core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := modeCore.seqFinal (Modes.Mode.cfbEnc 2) /-- `vg_idea_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := modeCore.seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_idea_ofb_final`. -/ +def ofbFinal : Prog isa := modeCore.seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Idea.X86 diff --git a/lean/VerifiedGarbage/Impl/Seed/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/Seed/X86/FbFinal.lean index 3aa62141fee..3a15e0e447a 100644 --- a/lean/VerifiedGarbage/Impl/Seed/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Seed/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Seed.X86.Modes public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# SEED-CFB128 of a message's last piece on x86 (32-bit) +# SEED-CFB128 and SEED-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, iv, data, len, -scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, iv, data, len, +scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over SEED's core in the encryption direction, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_seed_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_seed_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Seed.X86 diff --git a/lean/VerifiedGarbage/Impl/Sm4/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/X86/FbFinal.lean index 799fe3515d6..8f3a8c23dc7 100644 --- a/lean/VerifiedGarbage/Impl/Sm4/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Sm4/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Sm4.X86.Fb public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# SM4-CFB128 of a message's last piece on x86 (32-bit) +# SM4-CFB128 and SM4-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, iv, data, len, -scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, iv, data, len, +scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over SM4's core in the encryption direction, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_sm4_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_sm4_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Sm4.X86 diff --git a/lean/VerifiedGarbage/Impl/TripleDes/X86/FbFinal.lean b/lean/VerifiedGarbage/Impl/TripleDes/X86/FbFinal.lean index 01077327ee2..251e1ea13bf 100644 --- a/lean/VerifiedGarbage/Impl/TripleDes/X86/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/TripleDes/X86/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.TripleDes.X86.Fb public import VerifiedGarbage.Impl.Modes.X86.SeqFinal /-! -# Triple DES-CFB64 of a message's last piece on x86 (32-bit) +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on x86 (32-bit) -`cfbEncryptFinal` and `cfbDecryptFinal` (cdecl: schedule, iv, data, len, -scratch): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (cdecl: schedule, iv, data, len, +scratch): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/X86/SeqFinal.lean`), over Triple DES's core in the encryption direction, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_triple_des_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_triple_des_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.TripleDes.X86 diff --git a/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalLit.lean index 67359dd64e2..1223a6cff54 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit -/-! # Blowfish-CFB64's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ +/-! # Blowfish-CFB64's and Blowfish-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Proof.Blowfish.X86 materialize_flat_code cfbEncryptFinalCode := Impl.Blowfish.X86.cfbEncryptFinal materialize_flat_code cfbDecryptFinalCode := Impl.Blowfish.X86.cfbDecryptFinal +materialize_flat_code ofbFinalCode := Impl.Blowfish.X86.ofbFinal end VG.Proof.Blowfish.X86 diff --git a/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalVerified.lean index 6d44f672355..e20bdc76aa6 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.Blowfish.X86.FbVerified public import VerifiedGarbage.Impl.Blowfish.X86.FbFinal public import VerifiedGarbage.Spec.Blowfish.CfbFinal +public import VerifiedGarbage.Spec.Blowfish.OfbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -13,6 +14,7 @@ import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe meta import VerifiedGarbage.Proof.Blowfish.X86.FbVerified meta import VerifiedGarbage.Impl.Blowfish.X86.FbFinal meta import VerifiedGarbage.Spec.Blowfish.CfbFinal +meta import VerifiedGarbage.Spec.Blowfish.OfbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -26,10 +28,11 @@ public import VerifiedGarbage.Proof.Framework.Contract public import VerifiedGarbage.Proof.Framework.TacticTemplate /-! -# Blowfish-CFB64 of a message's last piece on x86 (32-bit) meets its contracts +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on x86 (32-bit) meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over Blowfish's +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over Blowfish's encrypting core (`dirCoreSpec true`), with the working space as a fifth argument (`finalX86`), as the whole-block functions are (`FbVerified.lean`), but the data `len` bytes. Each is correct and constant time, by the taint analysis @@ -352,4 +355,67 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem ((arg s 1).setWidth 64) ((arg s 2).setWidth 64) (arg s 3).toNat + +theorem ofbFinal_wp {s₀ : State} (hp : (finalX86 ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (finalX86 ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp (dirCoreSpec true) (seqPre_of hp) rfl rfl (keyArgs_of hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (finalX86 ofbPost).pre (finalX86 ofbPost).pub ofbFinal := + VG.Taint.constantTime (A := VG.X86.taint) fbTaint (fun _ _ h₁ h₂ hp => fbTaint_agree h₁ h₂ hp) + (by taint_decide) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract X86.abi finalSig "scratch" .u64 11 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 X86.abi.ptrBits) true 0 + +theorem wide_implies_ofb : (wideContract ofbPost).Implies ofbScratch := by + refine { pre := ?_, post := ?_, pub := ?_, sat := ?_ } + · intro s h + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, + ofbPost] at h + sig_split h + sig_reduce [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + | (simp only [Nat.mul_comm] at *; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + · sig_implies_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost, + ciph, ciphAt] + · sig_implies_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + · sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + [satState, arg, argAddr, Mem.readW, Mem.read] using satState + +theorem ofbFinal_verified : Verified X86.target ofbFinal ofbScratch := + final_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun _ _ _ _ _ _ h => h) wide_implies_ofb + +theorem ofbFrameSat_pre (post : Spec.Blowfish.ofbFinalSig.Post X86.abi.ptrBits) : + ∃ s, (Spec.Blowfish.ofbFinalSig.contract X86.abi (post := post) (writeArgs := true) (stack := 112)).pre s := by + implies_sat [Spec.Blowfish.ofbFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using frameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 112 4 22 ofbFinal) + (Spec.Blowfish.ofbFinalContract X86.abi 112) := + X86.Verified.stackScratchWiped (sig := Spec.Blowfish.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 11) (post := Proof.Modes.ofbFinalPost ciphAt 8 X86.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 112) ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Blowfish.X86.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalLit.lean index 501596e155d..b56cf247b19 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit -/-! # Camellia-CFB128's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ +/-! # Camellia-CFB128's and Camellia-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Proof.Camellia.X86 materialize_flat_code cfbEncryptFinalCode := Impl.Camellia.X86.cfbEncryptFinal materialize_flat_code cfbDecryptFinalCode := Impl.Camellia.X86.cfbDecryptFinal +materialize_flat_code ofbFinalCode := Impl.Camellia.X86.ofbFinal end VG.Proof.Camellia.X86 diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalVerified.lean index 4764bea84ce..147203641fb 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.Camellia.X86.FbVerified public import VerifiedGarbage.Impl.Camellia.X86.FbFinal public import VerifiedGarbage.Spec.Camellia.CfbFinal +public import VerifiedGarbage.Spec.Camellia.OfbFinal public import VerifiedGarbage.Proof.Camellia.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -18,6 +19,7 @@ import VerifiedGarbage.Proof.Framework.X86.NativeHintData meta import VerifiedGarbage.Proof.Camellia.X86.FbVerified meta import VerifiedGarbage.Impl.Camellia.X86.FbFinal meta import VerifiedGarbage.Spec.Camellia.CfbFinal +meta import VerifiedGarbage.Spec.Camellia.OfbFinal meta import VerifiedGarbage.Proof.Camellia.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -32,10 +34,11 @@ meta import VerifiedGarbage.Proof.Framework.Offset meta import VerifiedGarbage.Proof.Framework.X86.NativeHintData /-! -# Camellia-CFB128 of a message's last piece on x86 (32-bit) meets its contracts +# Camellia-CFB128 and Camellia-OFB of a message's last piece on x86 (32-bit) meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over Camellia's core in the encryption direction (`dirCoreSpec .encrypt`), with the working space as a sixth argument (`finalX86`), as the whole-block functions are (`FbVerified.lean`), but the data `len` bytes. Each is correct and @@ -377,4 +380,66 @@ theorem cfbDecryptFinal_framed : (Proof.Camellia.cfbFinalPre_local _) (Proof.Camellia.cfbDecryptFinalPost_local _) (Proof.Camellia.cfbDecryptFinalPostOut_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem ((arg s 2).setWidth 64) ((arg s 3).setWidth 64) (arg s 4).toNat + +theorem ofbFinal_wp {s₀ : State} (hp : (finalX86 ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (finalX86 ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hp) rfl rfl (keyArgs_of hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, by show ofbPost _ _; rw [ofbPost, ← Fb.cipher_eq]; exact h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (finalX86 ofbPost).pre (finalX86 ofbPost).pub ofbFinal := + let ⟨_, h⟩ := (by native_taint_decide_sum [cryptCallSum] : + ∃ h, (VG.X86.taint.check fbTaint ofbFinal h).isSome = true) + VG.Taint.constantTime (A := VG.X86.taint) fbTaint (fun _ _ h₁ h₂ hp => fbTaint_agree h₁ h₂ hp) h + +theorem wide_implies_ofb : (wideContract ofbPost).Implies (Proof.Camellia.ofbFinalScratchContract X86.abi 341 16) := by + refine { pre := ?_, post := ?_, pub := ?_, sat := ?_ } + · intro s h + sig_pre [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Proof.Camellia.ofbFinalPostSk, Spec.Camellia.ofbFinalPre, X86.abi, + X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] at h + sig_split h + sig_reduce [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Proof.Camellia.ofbFinalPostSk, Spec.Camellia.ofbFinalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + | (simp only [Nat.mul_comm] at *; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + · sig_implies_post [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Proof.Camellia.ofbFinalPostSk, Spec.Camellia.ofbFinalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost, + ciph] + · sig_implies_pub [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Proof.Camellia.ofbFinalPostSk, Spec.Camellia.ofbFinalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + · sig_implies_sat [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Proof.Camellia.ofbFinalPostSk, Spec.Camellia.ofbFinalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + [satState, arg, argAddr, Mem.readW, Mem.read] using satState + +theorem ofbFinal_verified : Verified X86.target ofbFinal (Proof.Camellia.ofbFinalScratchContract X86.abi 341 16) := + final_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun _ _ _ _ _ _ h => h) wide_implies_ofb + +theorem ofbFrameSat_pre (post : Spec.Camellia.ofbFinalSig.Post X86.abi.ptrBits) : + ∃ s, (Spec.Camellia.ofbFinalSig.contract X86.abi (pre := Spec.Camellia.ofbFinalPre X86.abi.ptrBits) (post := post) + (writeArgs := true) (stack := 2772)).pre s := by + implies_sat [Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using frameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 2756 5 682 ofbFinal) + (Spec.Camellia.ofbFinalContract X86.abi 2772) := + Proof.Camellia.ofbFinal_of_sk <| + X86.Verified.stackScratchWiped (sig := Spec.Camellia.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 341) (pre := Spec.Camellia.ofbFinalPre X86.abi.ptrBits) + (post := Proof.Camellia.ofbFinalPostSk X86.abi.ptrBits) (wa := true) (stack := 16) + (bytes := 2756) ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (Proof.Camellia.ofbFinalPre_local _) + (Proof.Camellia.ofbFinalPost_local _) (Proof.Camellia.ofbFinalPostOut_local _) (ofbFrameSat_pre _) + end VG.Proof.Camellia.X86.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalLit.lean index de1d7fc91d0..6c2396d0697 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit -/-! # CAST5-CFB64's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ +/-! # CAST5-CFB64's and CAST5-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Proof.Cast5.X86 materialize_flat_code cfbEncryptFinalCode := Impl.Cast5.X86.Modes.cfbEncryptFinal materialize_flat_code cfbDecryptFinalCode := Impl.Cast5.X86.Modes.cfbDecryptFinal +materialize_flat_code ofbFinalCode := Impl.Cast5.X86.Modes.ofbFinal end VG.Proof.Cast5.X86 diff --git a/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalVerified.lean index 73a5fcf1afc..5a98d8be00b 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.Cast5.X86.ModesVerified public import VerifiedGarbage.Impl.Cast5.X86.FbFinal public import VerifiedGarbage.Spec.Cast5.CfbFinal +public import VerifiedGarbage.Spec.Cast5.OfbFinal public import VerifiedGarbage.Proof.Cast5.CfbFinal public import VerifiedGarbage.Proof.Modes.X86.SeqFinal public import VerifiedGarbage.Proof.Framework.Contract @@ -18,6 +19,7 @@ import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe meta import VerifiedGarbage.Proof.Cast5.X86.ModesVerified meta import VerifiedGarbage.Impl.Cast5.X86.FbFinal meta import VerifiedGarbage.Spec.Cast5.CfbFinal +meta import VerifiedGarbage.Spec.Cast5.OfbFinal meta import VerifiedGarbage.Proof.Cast5.CfbFinal meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal meta import VerifiedGarbage.Proof.Framework.Contract @@ -32,10 +34,11 @@ meta import VerifiedGarbage.Proof.Framework.X86.StackScratchConsts meta import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe /-! -# CAST5-CFB64 of a message's last piece on x86 (32-bit): correctness and contracts +# CAST5-CFB64 and CAST5-OFB of a message's last piece on x86 (32-bit): correctness and contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over CAST5's +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over CAST5's encrypting core (`Mode.dirCoreSpec true`), with the working space as a sixth argument (`finalX`: `ModeFns.modeX true` but the data `len` bytes). The table of S-boxes is readable, where the static `VG_CAST5_S1234` puts it, and holds @@ -415,4 +418,38 @@ theorem cfbDecryptFinal_framed : (fun vs m₁ m₂ hl _ h => Proof.Cast5.cfbFinalPre_local _ vs m₁ m₂ hl h) (Proof.Cast5.cfbDecFinalPost_local _) (Proof.Cast5.cfbDecFinalPostOut_local _) (final_frameSat _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem ((arg s 2).setWidth 64) ((arg s 3).setWidth 64) (arg s 4).toNat + +theorem ofbFinal_wp {s₀ : State} (hp : (finalX ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (finalX ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp (dirCoreSpec true) (seqPre_of hp) rfl rfl (keyArgs_of hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (finalX ofbPost).pre (finalX ofbPost).pub ofbFinal := + VG.Taint.constantTime (A := taintSym [s1234Sym]) τFb (fun _ _ h₁ h₂ hp => τFb_agree h₁ h₂ hp) + (by taint_decide) + +theorem ofbFinal_verified : + Verified X86.target ofbFinal + (fbK Spec.Cast5.ofbFinalSig (Spec.Cast5.ofbFinalPre X86.abi.ptrBits) (Proof.Cast5.ofbFinalPost X86.abi.ptrBits)) := + finalK_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun s s' _ h => by + sig_post [Sig.scratchContract, Sig.withScratch, Spec.Cast5.ofbFinalSig, Proof.Cast5.ofbFinalPost, X86.abi, + X86.argSlots, X86.argVal, X86.argBytes, ecbConsts_eq, Abi.withConsts, Curry.withScratch] + exact h) ⟨_, final_sat⟩ + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 332 5 76 ofbFinal) + (Proof.Cast5.ofbFinalRoundsContract (X86.abi.withConsts ecbConsts) 336) := + X86.Verified.stackScratchWipedC (c₀ := (s1234Sym, s1234)) (cs := []) (sig := Spec.Cast5.ofbFinalSig) + (nm := "scratch") (e := .u64) (n := 38) (pre := Spec.Cast5.ofbFinalPre X86.abi.ptrBits) + (post := Proof.Cast5.ofbFinalPost X86.abi.ptrBits) (wa := true) (stack := 4) (bytes := 332) + ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (fun vs m₁ m₂ hl _ h => Proof.Cast5.ofbFinalPre_local _ vs m₁ m₂ hl h) + (Proof.Cast5.ofbFinalPost_local _) (Proof.Cast5.ofbFinalPostOut_local _) (final_frameSat _) + end VG.Proof.Cast5.X86.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalLit.lean index 01642b091c8..0373ad19cc3 100644 --- a/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit -/-! # IDEA-CFB64's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ +/-! # IDEA-CFB64's and IDEA-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Proof.Idea.X86 materialize_flat_code cfbEncryptFinalCode := Impl.Idea.X86.cfbEncryptFinal materialize_flat_code cfbDecryptFinalCode := Impl.Idea.X86.cfbDecryptFinal +materialize_flat_code ofbFinalCode := Impl.Idea.X86.ofbFinal end VG.Proof.Idea.X86 diff --git a/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalVerified.lean index a40ab287032..4823d4f6dd0 100644 --- a/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Idea/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.Idea.X86.FbVerified public import VerifiedGarbage.Impl.Idea.X86.FbFinal public import VerifiedGarbage.Spec.Idea.CfbFinal +public import VerifiedGarbage.Spec.Idea.OfbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -13,6 +14,7 @@ import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe meta import VerifiedGarbage.Proof.Idea.X86.FbVerified meta import VerifiedGarbage.Impl.Idea.X86.FbFinal meta import VerifiedGarbage.Spec.Idea.CfbFinal +meta import VerifiedGarbage.Spec.Idea.OfbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -26,10 +28,11 @@ public import VerifiedGarbage.Proof.Framework.Contract public import VerifiedGarbage.Proof.Framework.TacticTemplate /-! -# IDEA-CFB64 of a message's last piece on x86 (32-bit) meets its contracts +# IDEA-CFB64 and IDEA-OFB of a message's last piece on x86 (32-bit) meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over IDEA's +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over IDEA's core (`modeCoreSpec`), with the working space as a fifth argument (`finalX86`), as the whole-block functions are (`FbVerified.lean`), but the data `len` bytes. Each is correct and constant time, by the taint analysis @@ -348,4 +351,67 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem ((arg s 1).setWidth 64) ((arg s 2).setWidth 64) (arg s 3).toNat + +theorem ofbFinal_wp {s₀ : State} (hp : (finalX86 ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (finalX86 ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp modeCoreSpec (seqPre_of hp) rfl rfl (keyArgs_of hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (finalX86 ofbPost).pre (finalX86 ofbPost).pub ofbFinal := + VG.Taint.constantTime (A := VG.X86.taint) fbTaint (fun _ _ h₁ h₂ hp => fbTaint_agree h₁ h₂ hp) + (by taint_decide) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract X86.abi finalSig "scratch" .u64 23 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 X86.abi.ptrBits) true 0 + +theorem wide_implies_ofb : (wideContract ofbPost).Implies ofbScratch := by + refine { pre := ?_, post := ?_, pub := ?_, sat := ?_ } + · intro s h + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, + ofbPost] at h + sig_split h + sig_reduce [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + | (simp only [Nat.mul_comm] at *; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + · sig_implies_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost, + ciph, ciphAt] + · sig_implies_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + · sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + [satState, arg, argAddr, Mem.readW, Mem.read] using satState + +theorem ofbFinal_verified : Verified X86.target ofbFinal ofbScratch := + final_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun _ _ _ _ _ _ h => h) wide_implies_ofb + +theorem ofbFrameSat_pre (post : Spec.Idea.ofbFinalSig.Post X86.abi.ptrBits) : + ∃ s, (Spec.Idea.ofbFinalSig.contract X86.abi (post := post) (writeArgs := true) (stack := 208)).pre s := by + implies_sat [Spec.Idea.ofbFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using frameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 208 4 46 ofbFinal) + (Spec.Idea.ofbFinalContract X86.abi 208) := + X86.Verified.stackScratchWiped (sig := Spec.Idea.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 23) (post := Proof.Modes.ofbFinalPost ciphAt 8 X86.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 208) ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Idea.X86.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean index 2ebeeeb7ed3..fb6965507c6 100644 --- a/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean @@ -9,6 +9,7 @@ import VerifiedGarbage.Proof.Framework.Omega import VerifiedGarbage.Proof.Framework.AddrArith import VerifiedGarbage.Proof.Framework.Offset import VerifiedGarbage.Proof.Framework.X86.Syms +import VerifiedGarbage.Proof.AesOfb.Spec /-! # OFB and CFB of a message's last piece on x86 (32-bit), for any core @@ -22,7 +23,8 @@ IV, XORs the `r = len % L` bytes after them with the first bytes of `CIPH_K` of the chaining value after them, and replaces the IV with that chaining value if `r = 0` and with its encryption otherwise; it keeps the callee-saved registers and the return address. `cfbEncFinal_wp` and -`cfbDecFinal_wp` state these as CFB's (`Spec.Cfb.EncryptFinal`, …). +`cfbDecFinal_wp` state these as CFB's (`Spec.Cfb.EncryptFinal`, …), and +`ofbFinal_wp` as OFB's (`Spec.Ofb.CryptFinal`, by `ofbFinal_of`). The loop over segments (`seg_wp`) is `seq`'s step (`Step.lean`: `regs`, `areasOk`, `crypt_step`), the bytes left in `nSlot`, with the partial @@ -1155,4 +1157,56 @@ theorem cfbDecFinal_wp (cs : CoreSpec c) {M' : Mode} {s₀ : State} {k : cs.Key} rw [← e2] at h4 exact h4.trans (cfbDecFinalNext_of (cs.cipher k) s₀.mem _ _ _) +/-! ## OFB -/ + +theorem ofb_post_inBounds (c : Core) : ∀ o ∈ (Mode.ofb c.bw).post, o.InBounds (lens c (4 * c.bw)) := + fun o ho => (List.mem_append.mp ho).elim + (copyBlk_inBounds (by simp [lens]) (by simp [lens]) o) + (xorBlk_inBounds (by simp [lens]) (by simp [lens]) (by simp [lens]) o) + +/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` +whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last +`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block +(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ +theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) + (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) + (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = + Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) + (ciph (Spec.Ofb.next ciph iv (len / L)))) : + bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by + have hx := xor_flatten_outputs hc m₀ (len / L) D iv + have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] + rw [bytesAt_blocks_tail L m' D len, hblocks, htail, Spec.Ofb.cryptFinal, bytesAt_length, + blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] + split + · rename_i h0 + rw [h0, ← hx] + simp [bytesAt, Spec.Cbc.xor] + · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] + exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm + +/-- OFB of a message's last piece: `seqFinal`'s results as +`Spec.Ofb.CryptFinal`'s, for the `len` bytes at the data. -/ +theorem ofbFinal_wp (cs : CoreSpec c) {M' : Mode} {s₀ : State} {k : cs.Key} (hp : SeqPre c M' s₀) + (hst : M'.step = 1) (hiv : M'.ivOut = true) (hk : cs.KeyArgs s₀ [scrR s₀ c] k) : + WP isa (c.seqFinal (Mode.ofb c.bw)) s₀ fun s' => abiPreserved s₀ s' ∧ + Spec.Ofb.CryptFinal (cs.cipher k) (4 * c.bw) s₀.mem s'.mem ((P s₀ c).setWidth 64) ((Dp s₀ c).setWidth 64) + (N s₀ c) := by + have hL0 : 0 < 4 * c.bw := Nat.mul_pos (by decide) hp.layout.bw_pos + have hxs : (wb0 c s₀).length = N s₀ c / (4 * c.bw) := chunksAt_length _ _ _ _ + refine WP.mono (seqFinal_wp cs hp hst hiv rfl rfl (ofb_post_inBounds c) (ofb_computes (cs.cipher_len k)) hk) + fun s' ⟨h1, h2, h3, h4⟩ => ⟨h1, ?_, ?_⟩ + · obtain ⟨e1, e2⟩ := ofb_run (cs.cipher k) (iv0 c s₀) (wb0 c s₀) + rw [← e1] at h2 + rw [← e2, hxs] at h3 + exact ofbFinal_of hL0 (cs.cipher_len k) s₀.mem s'.mem _ _ _ h2 h3 + · obtain ⟨-, e2⟩ := ofb_run (cs.cipher k) (iv0 c s₀) (wb0 c s₀) + rw [← e2, hxs] at h4 + refine h4.trans ?_ + rw [blockCount_eq hL0] + split + · rfl + · exact (AesOfb.next_succ _ _ _).symm + end VG.Proof.Modes.X86 diff --git a/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalLit.lean index f7ca31c5caf..0094bb51ce8 100644 --- a/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit -/-! # SEED-CFB128's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ +/-! # SEED-CFB128's and SEED-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Proof.Seed.X86 materialize_code cfbEncryptFinalCode := Impl.Seed.X86.cfbEncryptFinal materialize_code cfbDecryptFinalCode := Impl.Seed.X86.cfbDecryptFinal +materialize_code ofbFinalCode := Impl.Seed.X86.ofbFinal end VG.Proof.Seed.X86 diff --git a/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalVerified.lean index e36cde13b7b..116980cac55 100644 --- a/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Seed/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.Seed.X86.FbVerified public import VerifiedGarbage.Impl.Seed.X86.FbFinal public import VerifiedGarbage.Spec.Seed.CfbFinal +public import VerifiedGarbage.Spec.Seed.OfbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -15,6 +16,7 @@ import VerifiedGarbage.Proof.Framework.X86.NativeHintData meta import VerifiedGarbage.Proof.Seed.X86.FbVerified meta import VerifiedGarbage.Impl.Seed.X86.FbFinal meta import VerifiedGarbage.Spec.Seed.CfbFinal +meta import VerifiedGarbage.Spec.Seed.OfbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -30,10 +32,11 @@ public import VerifiedGarbage.Proof.Framework.TacticTemplate meta import VerifiedGarbage.Proof.Framework.X86.NativeHintData /-! -# SEED-CFB128 of a message's last piece on x86 (32-bit) meets its contracts +# SEED-CFB128 and SEED-OFB of a message's last piece on x86 (32-bit) meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over SEED's +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over SEED's core in the encryption direction (`dirCoreSpec .encrypt`), with the working space as a fifth argument (`finalX86`), as the whole-block functions are (`FbVerified.lean`), but the data `len` bytes. Each is correct and constant @@ -388,4 +391,68 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem ((arg s 1).setWidth 64) ((arg s 2).setWidth 64) (arg s 3).toNat + +attribute [local irreducible] Spec.Seed.cipher in +theorem ofbFinal_wp {s₀ : State} (hp : (finalX86 ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (finalX86 ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hp) rfl rfl (keyArgs_of hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (finalX86 ofbPost).pre (finalX86 ofbPost).pub ofbFinal := + VG.Taint.constantTime (A := VG.X86.taint) fbTaint (fun _ _ h₁ h₂ hp => fbTaint_agree h₁ h₂ hp) + (by native_taint_decide) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract X86.abi finalSig "scratch" .u64 143 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 X86.abi.ptrBits) true 20 + +theorem wide_implies_ofb : (wideContract ofbPost).Implies ofbScratch := by + refine { pre := ?_, post := ?_, pub := ?_, sat := ?_ } + · intro s h + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, + ofbPost] at h + sig_split h + sig_reduce [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + | (simp only [Nat.mul_comm] at *; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + · sig_implies_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost, + ciph, ciphAt] + · sig_implies_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + · sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, ofbPost] + [satState, arg, argAddr, Mem.readW, Mem.read] using satState + +theorem ofbFinal_verified : Verified X86.target ofbFinal ofbScratch := + final_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun _ _ _ _ _ _ h => h) wide_implies_ofb + +theorem ofbFrameSat_pre (post : Spec.Seed.ofbFinalSig.Post X86.abi.ptrBits) : + ∃ s, (Spec.Seed.ofbFinalSig.contract X86.abi (post := post) (writeArgs := true) (stack := 1188)).pre s := by + implies_sat [Spec.Seed.ofbFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using frameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 1168 4 286 ofbFinal) + (Spec.Seed.ofbFinalContract X86.abi 1188) := + X86.Verified.stackScratchWiped (sig := Spec.Seed.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 143) (post := Proof.Modes.ofbFinalPost ciphAt 16 X86.abi.ptrBits) (wa := true) (stack := 20) + (bytes := 1168) ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Seed.X86.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalLit.lean index 9b324dd32df..45fce9de912 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit -/-! # SM4-CFB128's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ +/-! # SM4-CFB128's and SM4-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Proof.Sm4.X86 materialize_flat_code cfbEncryptFinalCode := Impl.Sm4.X86.cfbEncryptFinal materialize_flat_code cfbDecryptFinalCode := Impl.Sm4.X86.cfbDecryptFinal +materialize_flat_code ofbFinalCode := Impl.Sm4.X86.ofbFinal end VG.Proof.Sm4.X86 diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalVerified.lean index ff19bceb01a..34aa475a4f0 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.Sm4.X86.FbVerified public import VerifiedGarbage.Impl.Sm4.X86.FbFinal public import VerifiedGarbage.Spec.Sm4.CfbFinal +public import VerifiedGarbage.Spec.Sm4.OfbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -19,6 +20,7 @@ import VerifiedGarbage.Proof.Framework.X86.Lit meta import VerifiedGarbage.Proof.Sm4.X86.FbVerified meta import VerifiedGarbage.Impl.Sm4.X86.FbFinal meta import VerifiedGarbage.Spec.Sm4.CfbFinal +meta import VerifiedGarbage.Spec.Sm4.OfbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -34,10 +36,11 @@ meta import VerifiedGarbage.Proof.Framework.Offset meta import VerifiedGarbage.Proof.Framework.X86.Lit /-! -# SM4-CFB128 of a message's last piece on x86 (32-bit) meets its contracts +# SM4-CFB128 and SM4-OFB of a message's last piece on x86 (32-bit) meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over SM4's +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over SM4's core in the encryption direction (`dirCoreSpec .encrypt`), with the working space as a fifth argument (`finalX86`), as the whole-block functions are (`FbVerified.lean`), but the data `len` bytes. Each is correct and constant @@ -390,4 +393,69 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem ((arg s 1).setWidth 64) ((arg s 2).setWidth 64) (arg s 3).toNat + +theorem ofbFinal_wp {s₀ : State} (hp : (finalX86 ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (finalX86 ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hp) rfl rfl (keyArgs_of hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, by show ofbPost _ _; rw [ofbPost, ← Fb.cipher_eq]; exact h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (finalX86 ofbPost).pre (finalX86 ofbPost).pub ofbFinal := + VG.Taint.constantTime_of_exists (A := VG.X86.taint) fbTaint (fun _ _ h₁ h₂ hp => fbTaint_agree h₁ h₂ hp) + (by taint_decide_sum [prepSum, cryptSum]) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract X86.abi finalSig "scratch" .u64 184 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 X86.abi.ptrBits) true 20 + +theorem wide_implies_ofb : (wideContract ofbPost).Implies ofbScratch := by + refine { pre := ?_, post := ?_, pub := ?_, sat := ?_ } + · intro s h + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, below, + ofbPost] at h + sig_split h + sig_reduce [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, below, ofbPost] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + | (rw [VG.X86.Taint.sub_setWidth (by omega_arith)]; try simp only [Nat.mul_comm] at * + first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + | (simp only [Nat.mul_comm] at *; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + · sig_implies_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, below, ofbPost, + ciph, ciphAt] + · sig_implies_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, below, ofbPost] + · sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, finalX86, below, ofbPost] + [satState, arg, argAddr, Mem.readW, Mem.read] using satState + +theorem ofbFinal_verified : Verified X86.target ofbFinal ofbScratch := + final_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun _ _ _ _ _ _ h => h) wide_implies_ofb + +theorem ofbFrameSat_pre (post : Spec.Sm4.ofbFinalSig.Post X86.abi.ptrBits) : + ∃ s, (Spec.Sm4.ofbFinalSig.contract X86.abi (post := post) (writeArgs := true) (stack := 1516)).pre s := by + implies_sat [Spec.Sm4.ofbFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using frameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 1496 4 368 ofbFinal) + (Spec.Sm4.ofbFinalContract X86.abi 1516) := + X86.Verified.stackScratchWiped (sig := Spec.Sm4.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 184) (post := Proof.Modes.ofbFinalPost ciphAt 16 X86.abi.ptrBits) (wa := true) (stack := 20) + (bytes := 1496) ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Sm4.X86.FbFinal diff --git a/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalLit.lean index 00ed51121fc..31f59956103 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalLit.lean @@ -15,7 +15,7 @@ meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.X86.Lit /-! -# Triple DES-CFB64's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks +# Triple DES-CFB64's and Triple DES-OFB's final functions' x86 (32-bit) code as literals, for kernel-evaluated checks They read the literals of the block function's parts (`FunctionsLit.lean`), as `FbLit.lean` does. @@ -27,5 +27,6 @@ namespace VG materialize_code Impl.TripleDes.X86.cfbEncryptFinal materialize_code Impl.TripleDes.X86.cfbDecryptFinal +materialize_code Impl.TripleDes.X86.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalVerified.lean index e608c4cf7da..7a8ca7ff694 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/X86/FbFinalVerified.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Proof.TripleDes.X86.FbVerified public import VerifiedGarbage.Impl.TripleDes.X86.FbFinal public import VerifiedGarbage.Spec.TripleDes.CfbFinal +public import VerifiedGarbage.Spec.TripleDes.OfbFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Proof.Framework.Scratch public import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -15,6 +16,7 @@ import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe meta import VerifiedGarbage.Proof.TripleDes.X86.FbVerified meta import VerifiedGarbage.Impl.TripleDes.X86.FbFinal meta import VerifiedGarbage.Spec.TripleDes.CfbFinal +meta import VerifiedGarbage.Spec.TripleDes.OfbFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal @@ -26,10 +28,11 @@ meta import VerifiedGarbage.Proof.Framework.Sig meta import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe /-! -# Triple DES-CFB64 of a message's last piece on x86 (32-bit) meets its contracts +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on x86 (32-bit) meet their contracts -`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`: the modes' CFB over a message's -last piece (`Proof.Modes.X86.cfbEncFinal_wp`, `cfbDecFinal_wp`) over Triple +`cfbEncryptFinal_wp`, `cfbDecryptFinal_wp`, `ofbFinal_wp`: the modes' CFB +and OFB over a message's last piece (`Proof.Modes.X86.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over Triple DES's core in the encryption direction (`Mode.dirCoreSpec .encrypt`), with the working space as a fifth argument: `Fb.fbX86` with steps of a byte, as CFB8's, the data `len` bytes. Each is correct and constant time, by the taint @@ -197,4 +200,71 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem ((arg s 1).setWidth 64) ((arg s 2).setWidth 64) (arg s 3).toNat + +theorem ofbFinal_wp {s₀ : State} (hp : (fbX86 1 ofbPost).pre s₀) : + WP isa ofbFinal s₀ fun s' => abiPreserved s₀ s' ∧ (fbX86 1 ofbPost).post s₀ s' := + WP.mono (Proof.Modes.X86.ofbFinal_wp (dirCoreSpec .encrypt) + (seqPre_of (M := byteMode) .encrypt rfl (by decide) (by decide) hp) rfl rfl (keyArgs_of .encrypt hp)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_ct : ConstantTime isa (fbX86 1 ofbPost).pre (fbX86 1 ofbPost).pub ofbFinal := by + obtain ⟨_, h⟩ : ∃ h, (VG.X86.taint.check fbTaint ofbFinal h).isSome = true := + by taint_decide_sum [encSum] + exact VG.Taint.constantTime (A := VG.X86.taint) fbTaint (fun _ _ h₁ h₂ hp => fbTaint_agree h₁ h₂ hp) h + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract X86.abi finalSig "scratch" .u64 118 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 X86.abi.ptrBits) true 16 + +theorem wide_implies_ofb : (wideContract 1 ofbPost).Implies ofbScratch := by + refine { pre := ?_, post := ?_, pub := ?_, sat := ?_ } + · intro s h + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, fbX86, below, + ofbPost] at h + sig_split h + sig_reduce [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, fbX86, below, ofbPost] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + | (rw [VG.X86.Taint.sub_setWidth (by omega_arith)]; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + | (simp only [Nat.one_mul] at *; first | with_reducible assumption | with_reducible exact Region.Disjoint.symm ‹_›) + | (rw [VG.X86.Taint.sub_setWidth (by omega_arith)]; simp only [Nat.one_mul] at *; with_reducible assumption) + · sig_implies_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, fbX86, below, ofbPost, + ciph, ciphAt] + · sig_implies_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, fbX86, below, ofbPost] + · sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideContract, fbX86, below, ofbPost] + [satState, arg, argAddr, Mem.readW, Mem.read] using satState + +theorem ofbFinal_verified : Verified X86.target ofbFinal ofbScratch := + fb_verified (fun _ hs => ofbFinal_wp hs) ofbFinal_ct (fun _ _ _ _ _ _ h => h) wide_implies_ofb + +theorem ofbFrameSat_pre (post : Spec.TripleDes.ofbFinalSig.Post X86.abi.ptrBits) : + ∃ s, (Spec.TripleDes.ofbFinalSig.contract X86.abi (post := post) (writeArgs := true) (stack := 984)).pre s := by + implies_sat [Spec.TripleDes.ofbFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using frameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 968 4 236 ofbFinal) + (Spec.TripleDes.ofbFinalContract X86.abi 984) := + X86.Verified.stackScratchWiped (sig := Spec.TripleDes.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 118) (post := Proof.Modes.ofbFinalPost ciphAt 8 X86.abi.ptrBits) (wa := true) (stack := 16) + (bytes := 968) ofbFinal_verified (by decide) (by lit_decide) (by lit_decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPost_inLocal _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.TripleDes.X86.FbFinal From 7a3864b7df0faf7e3743e8f434e793d8025314f2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:28:15 +0000 Subject: [PATCH 04/18] OFB final functions on ARMv7 for Blowfish, Camellia, CAST5, IDEA, SEED, SM4 and Triple DES (WIP: crates to come) Arm's seqFinal with seq's OFB mode; its final-segment obligation (ofb_finalOk) and postcondition in Proof/Modes/Arm/SeqFinal.lean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/BlowfishOfb/Arm.lean | 8 +- .../Artifacts/CamelliaOfb/Arm.lean | 8 +- .../Artifacts/Cast5Ofb/Arm.lean | 8 +- .../Artifacts/IdeaOfb/Arm.lean | 8 +- .../Artifacts/SeedOfb/Arm.lean | 8 +- .../VerifiedGarbage/Artifacts/Sm4Ofb/Arm.lean | 8 +- .../Artifacts/TripleDesOfb/Arm.lean | 8 +- .../Impl/Blowfish/Arm/FbFinal.lean | 14 ++- .../Impl/Camellia/Arm/FbFinal.lean | 11 +- .../Impl/Cast5/Arm/FbFinal.lean | 11 +- .../Impl/Idea/Arm/FbFinal.lean | 9 +- .../Impl/Seed/Arm/FbFinal.lean | 9 +- .../VerifiedGarbage/Impl/Sm4/Arm/FbFinal.lean | 9 +- .../Impl/TripleDes/Arm/FbFinal.lean | 9 +- .../Proof/Blowfish/Arm/FbFinalVerified.lean | 62 ++++++++++- .../Proof/Camellia/Arm/FbFinalVerified.lean | 65 ++++++++++- .../Proof/Cast5/Arm/FbFinalVerified.lean | 102 +++++++++++++++++- .../Proof/Idea/Arm/FbFinalVerified.lean | 62 ++++++++++- .../Proof/Modes/Arm/SeqFinal.lean | 57 +++++++++- .../Proof/Seed/Arm/FbFinalVerified.lean | 62 ++++++++++- .../Proof/Sm4/Arm/FbFinalVerified.lean | 62 ++++++++++- .../Proof/TripleDes/Arm/FbFinalVerified.lean | 62 ++++++++++- 22 files changed, 600 insertions(+), 62 deletions(-) diff --git a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/Arm.lean b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/Arm.lean index ca896e369d4..17355acf08e 100644 --- a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/Arm.lean @@ -3,6 +3,8 @@ module public import VerifiedGarbage.Proof.Blowfish.Arm.FbVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.Blowfish.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.Blowfish.Arm.FbFinal /-! # Blowfish-OFB artifacts on baseline ARMv7 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Blowfish.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.Blowfish.Arm.ofb stack := 320 - verified := Proof.Blowfish.Arm.ofb_framed }] + verified := Proof.Blowfish.Arm.ofb_framed }, + Spec.Blowfish.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.Blowfish.Arm.ofbFinal + stack := 320 + verified := Proof.Blowfish.Arm.ofbFinal_framed }] end VG.Artifacts.BlowfishOfb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/Arm.lean b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/Arm.lean index 04252787091..6ab34102414 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/Arm.lean @@ -3,6 +3,8 @@ module public import VerifiedGarbage.Proof.Camellia.Arm.FbVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.Camellia.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.Camellia.Arm.FbFinal /-! # Camellia-OFB artifacts on baseline ARMv7 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 88 1 18 Impl.Camellia.Arm.ofb stack := 2904 - verified := Proof.Camellia.Arm.ofb_framed }] + verified := Proof.Camellia.Arm.ofb_framed }, + Spec.Camellia.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 88 1 18 Impl.Camellia.Arm.ofbFinal + stack := 2904 + verified := Proof.Camellia.Arm.ofbFinal_framed }] end VG.Artifacts.CamelliaOfb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/Arm.lean b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/Arm.lean index f033c2f28ba..e0bbb51cea8 100644 --- a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/Arm.lean @@ -3,6 +3,8 @@ module public import VerifiedGarbage.Proof.Cast5.Arm.ModesVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.Cast5.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.Cast5.Arm.FbFinal /-! # CAST5-OFB artifacts on baseline ARMv7 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Cast5.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 328 1 78 Impl.Cast5.Arm.ofb stack := 336 - verified := Proof.Cast5.ofb_keyed Proof.Cast5.Arm.ofb_framed }] + verified := Proof.Cast5.ofb_keyed Proof.Cast5.Arm.ofb_framed }, + Spec.Cast5.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 328 1 78 Impl.Cast5.Arm.ofbFinal + stack := 336 + verified := Proof.Cast5.ofbFinal_keyed Proof.Cast5.Arm.ofbFinal_framed }] end VG.Artifacts.Cast5Ofb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/IdeaOfb/Arm.lean b/lean/VerifiedGarbage/Artifacts/IdeaOfb/Arm.lean index 6005b6b14a2..84aee45ade5 100644 --- a/lean/VerifiedGarbage/Artifacts/IdeaOfb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/IdeaOfb/Arm.lean @@ -6,6 +6,8 @@ import Mathlib.Tactic.Finiteness.Attr import Mathlib.Tactic.SetLike public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.Idea.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.Idea.Arm.FbFinal /-! # IDEA-OFB artifacts on baseline ARMv7 -/ @@ -17,6 +19,10 @@ def artifacts : List Artifact := [ Spec.Idea.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.Idea.Arm.ofb stack := 96 - verified := Proof.Idea.Arm.ofb_framed }] + verified := Proof.Idea.Arm.ofb_framed }, + Spec.Idea.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.Idea.Arm.ofbFinal + stack := 96 + verified := Proof.Idea.Arm.ofbFinal_framed }] end VG.Artifacts.IdeaOfb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/SeedOfb/Arm.lean b/lean/VerifiedGarbage/Artifacts/SeedOfb/Arm.lean index d9c53226487..6c85bfbfa29 100644 --- a/lean/VerifiedGarbage/Artifacts/SeedOfb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/SeedOfb/Arm.lean @@ -3,6 +3,8 @@ module public import VerifiedGarbage.Proof.Seed.Arm.FbVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.Seed.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.Seed.Arm.FbFinal /-! # SEED-OFB artifacts on baseline ARMv7 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Seed.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 80 0 18 Impl.Seed.Arm.ofb stack := 832 - verified := Proof.Seed.Arm.ofb_framed }] + verified := Proof.Seed.Arm.ofb_framed }, + Spec.Seed.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 80 0 18 Impl.Seed.Arm.ofbFinal + stack := 832 + verified := Proof.Seed.Arm.ofbFinal_framed }] end VG.Artifacts.SeedOfb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/Arm.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/Arm.lean index ea51b0951cf..a87463df592 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/Arm.lean @@ -3,6 +3,8 @@ module public import VerifiedGarbage.Proof.Sm4.Arm.SerialOfbVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.Sm4.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.Sm4.Arm.FbFinal /-! # SM4-OFB artifacts on baseline ARMv7 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 1520 0 378 Impl.Sm4.Arm.SerialOfb.crypt stack := 1520 - verified := Proof.Sm4.Arm.SerialOfbVerified.framed }] + verified := Proof.Sm4.Arm.SerialOfbVerified.framed }, + Spec.Sm4.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 80 0 18 Impl.Sm4.Arm.ofbFinal + stack := 1560 + verified := Proof.Sm4.Arm.ofbFinal_framed }] end VG.Artifacts.Sm4Ofb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/Arm.lean b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/Arm.lean index 111a8b52148..01f447bce81 100644 --- a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/Arm.lean @@ -3,6 +3,8 @@ module public import VerifiedGarbage.Proof.TripleDes.Arm.FbVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print +public import VerifiedGarbage.Proof.TripleDes.Arm.FbFinalVerified +public import VerifiedGarbage.Impl.TripleDes.Arm.FbFinal /-! # Triple DES-OFB artifacts on baseline ARMv7 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.TripleDes.ofbApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.TripleDes.Arm.ofb stack := 1088 - verified := Proof.TripleDes.Arm.ofb_framed }] + verified := Proof.TripleDes.Arm.ofb_framed }, + Spec.TripleDes.ofbFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.TripleDes.Arm.ofbFinal + stack := 1088 + verified := Proof.TripleDes.Arm.ofbFinal_framed }] end VG.Artifacts.TripleDesOfb.Arm diff --git a/lean/VerifiedGarbage/Impl/Blowfish/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/Blowfish/Arm/FbFinal.lean index 71975959e98..1519c80c511 100644 --- a/lean/VerifiedGarbage/Impl/Blowfish/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Blowfish/Arm/FbFinal.lean @@ -4,12 +4,13 @@ public import VerifiedGarbage.Impl.Blowfish.Arm.Modes public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# Blowfish-CFB64 of a message's last piece on ARMv7 +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, iv = r1, data = r2, -len = r3, scratch = [sp]): the generic CFB over a message's last piece, of -any length (`Impl/Modes/Arm/SeqFinal.lean`), over Blowfish's ECB function, with -the arguments of `cfbEncrypt` but the data's length in bytes. +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, iv = r1, +data = r2, len = r3, scratch = [sp]): the generic CFB and OFB over a +message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over +Blowfish's ECB function, with the arguments of `cfbEncrypt` (and `ofb`) but +the data's length in bytes. -/ @[expose] public section @@ -24,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (ecbCore true).seqFinal cfbEnc /-- `vg_blowfish_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (ecbCore true).seqFinal cfbDecF +/-- `vg_blowfish_ofb_final`. -/ +def ofbFinal : Prog isa := (ecbCore true).seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.Blowfish.Arm diff --git a/lean/VerifiedGarbage/Impl/Camellia/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/Arm/FbFinal.lean index 5c1330235bc..2da75e80a8b 100644 --- a/lean/VerifiedGarbage/Impl/Camellia/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Camellia/Arm/FbFinal.lean @@ -4,12 +4,12 @@ public import VerifiedGarbage.Impl.Camellia.Arm.Fb public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# Camellia-CFB128 of a message's last piece on ARMv7 +# Camellia-CFB128 and Camellia-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, rounds = r1, -iv = r2, data = r3, len = [sp], scratch = [sp + 4]): the generic CFB over a +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, rounds = r1, +iv = r2, data = r3, len = [sp], scratch = [sp + 4]): the generic CFB and OFB over a message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over -Camellia's ECB encryption, with the arguments of `cfbEncrypt` but the data's +Camellia's ECB encryption, with the arguments of `cfbEncrypt` (and `ofb`) but the data's length in bytes. -/ @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbEnc /-- `vg_camellia_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbDecF +/-- `vg_camellia_ofb_final`. -/ +def ofbFinal : Prog isa := (ecbCore .encrypt).seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.Camellia.Arm diff --git a/lean/VerifiedGarbage/Impl/Cast5/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/Cast5/Arm/FbFinal.lean index bb9491d451e..5f603c1a489 100644 --- a/lean/VerifiedGarbage/Impl/Cast5/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Cast5/Arm/FbFinal.lean @@ -4,12 +4,12 @@ public import VerifiedGarbage.Impl.Cast5.Arm.Modes public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# CAST5-CFB64 of a message's last piece on ARMv7 +# CAST5-CFB64 and CAST5-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, rounds = r1, -iv = r2, data = r3, len = [sp], scratch = [sp + 4]): the generic CFB over a +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, rounds = r1, +iv = r2, data = r3, len = [sp], scratch = [sp + 4]): the generic CFB and OFB over a message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over -CAST5's ECB encryption, with the arguments of `cfbEncrypt` but the data's +CAST5's ECB encryption, with the arguments of `cfbEncrypt` (and `ofb`) but the data's length in bytes. -/ @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := (ecbCore true).seqFinal cfbEnc /-- `vg_cast5_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (ecbCore true).seqFinal cfbDecF +/-- `vg_cast5_ofb_final`. -/ +def ofbFinal : Prog isa := (ecbCore true).seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.Cast5.Arm diff --git a/lean/VerifiedGarbage/Impl/Idea/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/Idea/Arm/FbFinal.lean index f06750ae5da..b8f2f946dfa 100644 --- a/lean/VerifiedGarbage/Impl/Idea/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Idea/Arm/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Idea.Arm.Modes public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# IDEA-CFB64 of a message's last piece on ARMv7 +# IDEA-CFB64 and IDEA-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, iv = r1, data = r2, -len = r3, scratch = [sp]): the generic CFB over a message's last piece, of +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, iv = r1, data = r2, +len = r3, scratch = [sp]): the generic CFB and OFB over a message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over IDEA's ECB function, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := ecbCore.seqFinal cfbEnc /-- `vg_idea_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := ecbCore.seqFinal cfbDecF +/-- `vg_idea_ofb_final`. -/ +def ofbFinal : Prog isa := ecbCore.seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.Idea.Arm diff --git a/lean/VerifiedGarbage/Impl/Seed/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/Seed/Arm/FbFinal.lean index 6809ded5e87..f87c41c5159 100644 --- a/lean/VerifiedGarbage/Impl/Seed/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Seed/Arm/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Seed.Arm.Modes public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# SEED-CFB128 of a message's last piece on ARMv7 +# SEED-CFB128 and SEED-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, iv = r1, data = r2, -len = r3, scratch = [sp]): the generic CFB over a message's last piece, of +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, iv = r1, data = r2, +len = r3, scratch = [sp]): the generic CFB and OFB over a message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over SEED's ECB function, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbEnc /-- `vg_seed_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbDecF +/-- `vg_seed_ofb_final`. -/ +def ofbFinal : Prog isa := (ecbCore .encrypt).seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.Seed.Arm diff --git a/lean/VerifiedGarbage/Impl/Sm4/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/Arm/FbFinal.lean index eab2c2bfeae..3c6afc07864 100644 --- a/lean/VerifiedGarbage/Impl/Sm4/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Sm4/Arm/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Sm4.Arm.Cbc public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# SM4-CFB128 of a message's last piece on ARMv7 +# SM4-CFB128 and SM4-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, iv = r1, data = r2, -len = r3, scratch = [sp]): the generic CFB over a message's last piece, of +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, iv = r1, data = r2, +len = r3, scratch = [sp]): the generic CFB and OFB over a message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over Sm4's ECB function, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -32,4 +32,7 @@ def cfbEncryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbEnc /-- `vg_sm4_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbDecF +/-- `vg_sm4_ofb_final`. -/ +def ofbFinal : Prog isa := (ecbCore .encrypt).seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.Sm4.Arm diff --git a/lean/VerifiedGarbage/Impl/TripleDes/Arm/FbFinal.lean b/lean/VerifiedGarbage/Impl/TripleDes/Arm/FbFinal.lean index 32d64ce07bb..be9360e916d 100644 --- a/lean/VerifiedGarbage/Impl/TripleDes/Arm/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/TripleDes/Arm/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.TripleDes.Arm.Fb public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal /-! -# Triple DES-CFB64 of a message's last piece on ARMv7 +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on ARMv7 -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r0, iv = r1, data = r2, -len = r3, scratch = [sp]): the generic CFB over a message's last piece, of +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r0, iv = r1, data = r2, +len = r3, scratch = [sp]): the generic CFB and OFB over a message's last piece, of any length (`Impl/Modes/Arm/SeqFinal.lean`), over Triple DES's ECB function, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbEnc /-- `vg_triple_des_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (ecbCore .encrypt).seqFinal cfbDecF +/-- `vg_tripledes_ofb_final`. -/ +def ofbFinal : Prog isa := (ecbCore .encrypt).seqFinal VG.Impl.Modes.Arm.ofb + end VG.Impl.TripleDes.Arm diff --git a/lean/VerifiedGarbage/Proof/Blowfish/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Blowfish/Arm/FbFinalVerified.lean index 971d6959101..f483f493030 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/Arm/FbFinalVerified.lean @@ -5,6 +5,7 @@ public import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Blowfish.Arm.FbFinal public import VerifiedGarbage.Spec.Blowfish.CfbFinal +public import VerifiedGarbage.Spec.Blowfish.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Modes.Arm.OfbCfb import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -17,6 +18,7 @@ meta import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Blowfish.Arm.FbFinal meta import VerifiedGarbage.Spec.Blowfish.CfbFinal +meta import VerifiedGarbage.Spec.Blowfish.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.Arm.OfbCfb meta import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -26,12 +28,13 @@ meta import VerifiedGarbage.Proof.Framework.Arm.Contract meta import VerifiedGarbage.Proof.Framework.Contract /-! -# Blowfish-CFB64 of a message's last piece on ARMv7 meets its contracts +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) -over Blowfish's ECB function (`ecbSpec true`) meets the contracts with a scratch +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +over Blowfish's ECB function (`ecbSpec true`) meet the contracts with a scratch buffer of 7 words, as the whole-block functions do (`FbVerified.lean`), with -the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the +the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 64 bytes more. -/ @@ -147,4 +150,55 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) cfbDecryptFinalFrameSat +/-! ## OFB of a message's last piece -/ + +theorem ofbFinalTaint : FinalTaint (ecbCore true) VG.Impl.Modes.Arm.ofb := + ⟨ofbTaint.pro, ⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩, ofbTaint.epi⟩ + +theorem ofbFinal_implies : (seqFinalArm (ecbCore true) (ecbSpec true) VG.Impl.Modes.Arm.ofb).Implies + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) true 256) where + pre s h := seqArm_pre_rw (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) (by + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact h) + post s s' _ h := by + sig_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + have e := ofbFinal_post h fun b => by + simp only [ecbSpec, dirCipher, ↓reduceIte] + simp [Spec.Blowfish.cipher]; rfl + obtain ⟨e1, e2, e3, -, -⟩ := args_plain (c := (ecbCore true)) rfl s + simp only [show (ecbCore true).bs = 8 from rfl, e1, e2, e3] at e + simp only [ecbSpec, dirCipher, State.addr, ↓reduceIte] at e + exact e + pub s₁ s₂ _ _ h := by + sig_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pub (M := byteMode) rfl h + sat := by + sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbSat, stackArg, stackArgAddr, Mem.readW, + Mem.read] using fbSat 1 + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) true 256) := + seqFinal_verified (ecbSpec true) (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +theorem ofbFinalFrameSat : ∃ s, (Spec.Blowfish.ofbFinalContract Arm.abi 320).pre s := by + implies_sat [Spec.Blowfish.ofbFinalContract, Spec.Blowfish.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val, Arm.State.addr] [fbFrameSat, fbSat] using fbFrameSat 1 + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 ofbFinal) + (Spec.Blowfish.ofbFinalContract Arm.abi 320) := + Arm.Verified.stackScratchWiped (sig := Spec.Blowfish.ofbFinalSig) (nm := "scratch") (e := .u64) (n := 7) + (post := Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) (wa := true) (stack := 256) (m := 0) (bytes := 64) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) + (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat + end VG.Proof.Blowfish.Arm diff --git a/lean/VerifiedGarbage/Proof/Camellia/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Camellia/Arm/FbFinalVerified.lean index db3896cc0c2..92240ea6f20 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/Arm/FbFinalVerified.lean @@ -23,14 +23,15 @@ meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Arm.NativeHintData /-! -# Camellia-CFB128 of a message's last piece on ARMv7 meets its contracts +# Camellia-CFB128 and Camellia-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) over Camellia's ECB encryption (`ecbSpec .encrypt`, a core taking the number -of rounds) meets the contracts on the subkeys at the schedule +of rounds) meet the contracts on the subkeys at the schedule (`Proof.Camellia.cfbEncFinalScratchContract`, …) with a scratch buffer of 9 words, as the whole-block functions do (`FbVerified.lean`), with the -specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the +specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 88 bytes more, and give the specification's contracts (`cfbEncryptFinal_of_sk`, …). -/ @@ -145,4 +146,60 @@ theorem cfbDecryptFinal_framed : (Proof.Camellia.cfbFinalPre_local _) (Proof.Camellia.cfbDecryptFinalPost_local _) (Proof.Camellia.cfbDecryptFinalPostOut_local _) cfbDecryptFinalFrameSat +/-! ## OFB of a message's last piece -/ + +theorem ofbFinalTaint : FinalTaint (ecbCore .encrypt) VG.Impl.Modes.Arm.ofb := + ⟨ofbTaint.pro, ⟨_, by native_taint_decide⟩, ⟨_, by native_taint_decide⟩, ofbTaint.epi⟩ + +theorem ofbFinal_implies : (seqFinalArm (ecbCore .encrypt) (ecbSpec .encrypt) VG.Impl.Modes.Arm.ofb).Implies + (Proof.Camellia.ofbFinalScratchContract Arm.abi 9 2816) where + pre s h := seqArm_pre_rwR (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) (by + sig_pre [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val] at h + exact h) + post s s' _ h := by + sig_post [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Proof.Camellia.ofbFinalPostSk, Arm.abi, Arm.argRegs, + Arm.reduceClassify, Arm.Loc.val] + intro hR + have e := ofbFinal_post h fun b => by + show _ = 16 + simp [ecbSpec, dirCipher, Spec.Camellia.cipher] + obtain ⟨e1, e2, e3, -, -⟩ := args_rounds (c := ecbCore .encrypt) rfl s + simp only [show (ecbCore .encrypt).bs = 16 from rfl, e1, e2, e3] at e + simp only [ecbSpec, dirCipher, rsel_eq hR, State.addr] at e + exact e + pub s₁ s₂ _ _ h := by + sig_pub [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pubR (M := byteMode) h + sat := by + sig_implies_sat [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, + Curry.withScratch, Curry.app, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, Arm.abi, Arm.argRegs, + Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbSat, stackArg, stackArgAddr, Mem.readW, Mem.read] + using fbSat 0 + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Proof.Camellia.ofbFinalScratchContract Arm.abi 9 2816) := + seqFinal_verified (ecbSpec .encrypt) (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +theorem ofbFinalFrameSat : ∃ s, (Proof.Camellia.ofbFinalContractSk Arm.abi 2904).pre s := by + implies_sat [Proof.Camellia.ofbFinalContractSk, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, + Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbFrameSat, fbSat, stackArg, + stackArgAddr, Mem.readW, Mem.read] using fbFrameSat 0 + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 88 1 18 ofbFinal) + (Spec.Camellia.ofbFinalContract Arm.abi 2904) := + Proof.Camellia.ofbFinal_of_sk <| + Arm.Verified.stackScratchWiped (sig := Spec.Camellia.ofbFinalSig) (nm := "scratch") (e := .u64) (n := 9) + (pre := Spec.Camellia.ofbFinalPre Arm.abi.ptrBits) (post := Proof.Camellia.ofbFinalPostSk Arm.abi.ptrBits) + (wa := true) (stack := 2816) (m := 1) (bytes := 88) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (Proof.Camellia.ofbFinalPre_local _) (Proof.Camellia.ofbFinalPost_local _) + (Proof.Camellia.ofbFinalPostOut_local _) ofbFinalFrameSat + end VG.Proof.Camellia.Arm diff --git a/lean/VerifiedGarbage/Proof/Cast5/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Cast5/Arm/FbFinalVerified.lean index c477c391e11..eb75462e2d0 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/Arm/FbFinalVerified.lean @@ -25,15 +25,16 @@ meta import VerifiedGarbage.Proof.Framework.Arm.Contract meta import VerifiedGarbage.Proof.Framework.Contract /-! -# CAST5-CFB64 of a message's last piece on ARMv7 meets its contracts +# CAST5-CFB64 and CAST5-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) over CAST5's ECB encryption (`ecbSpec true`, a core taking the number of rounds and its working space as a stack argument, and reading the table -`VG_CAST5_S1234`) meets the contracts on the subkeys at the schedule +`VG_CAST5_S1234`) meet the contracts on the subkeys at the schedule (`Proof.Cast5.cfbEncFinalPost`, …) with a scratch buffer of 39 words, as the whole-block functions do (`ModesVerified.lean`), with the specification's -results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the `_framed` theorems keep +results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 328 bytes more. -/ @@ -182,4 +183,97 @@ theorem cfbDecryptFinal_framed : (fun vs m₁ m₂ hl _ h => Proof.Cast5.cfbFinalPre_local _ vs m₁ m₂ hl h) (Proof.Cast5.cfbDecFinalPost_local _) (Proof.Cast5.cfbDecFinalPostOut_local _) (cfbFinalFrame_sat _) +/-! ## OFB of a message's last piece -/ + +theorem ofbFinal_sat (post : Spec.Cast5.ofbFinalSig.Post Arm.abi.ptrBits) : + ∃ s, (Proof.Cast5.modeScratchContract (Arm.abi.withConsts ecbConsts) Spec.Cast5.ofbFinalSig 39 + (Spec.Cast5.ofbFinalPre Arm.abi.ptrBits) post 8).pre s := by + refine ⟨modeSatC true, ?_⟩ + have a0 := modeSatC_arg true (i := 0) (by decide) + have a1 := modeSatC_arg true (i := 1) (by decide) + have held := modeSatMem_held + generalize e : modeSatC true = s at a0 a1 + sig_pre [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, ecbConsts_eq, + Abi.withConsts, Abi.constRegions, Abi.constsHeld, stackBelow, s1234_length] + subst e + rw [a0, a1] + refine ⟨by decide, by decide, by decide, fun i hi => held i (by rw [s1234_length]; exact hi), by decide, ?_, ?_⟩ + · intro r hr + change r ∈ ([⟨0x2000, 8⟩, ⟨0x3000, 0⟩, ⟨0, 312⟩] : List Region) at hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl <;> exact Region.disjoint_of_sep (by decide) + · repeat' apply And.intro + all_goals first | exact Region.disjoint_of_sep (by decide) | decide | rfl | exact Or.inl rfl + +theorem ofbFinalFrame_sat (post : Spec.Cast5.ofbFinalSig.Post Arm.abi.ptrBits) : + ∃ s, (Spec.Cast5.ofbFinalSig.contract (Arm.abi.withConsts ecbConsts) (Spec.Cast5.ofbFinalPre Arm.abi.ptrBits) post + true (8 + 328)).pre s := by + refine ⟨frameSatC true, ?_⟩ + have a0 := frameSatC_arg true (i := 0) (by decide) + have held := modeSatMem_held + generalize e : frameSatC true = s at a0 + sig_pre [Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, + ecbConsts_eq, Abi.withConsts, Abi.constRegions, Abi.constsHeld, stackBelow, s1234_length] + subst e + rw [a0] + refine ⟨by decide, by decide, by decide, fun i hi => held i (by rw [s1234_length]; exact hi), by decide, ?_, ?_⟩ + · intro r hr + change r ∈ ([⟨0x2000, 8⟩, ⟨0x3000, 0⟩] : List Region) at hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl <;> exact Region.disjoint_of_sep (by decide) + · repeat' apply And.intro + all_goals first | exact Region.disjoint_of_sep (by decide) | decide | rfl | exact Or.inl rfl + +theorem ofbFinalTaint : FinalTaint (ecbCore true) VG.Impl.Modes.Arm.ofb := + ⟨ofbTaint.pro, ⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩, ofbTaint.epi⟩ + +theorem ofbFinal_implies : (seqFinalArm (ecbCore true) (ecbSpec true) VG.Impl.Modes.Arm.ofb).Implies + (Proof.Cast5.modeScratchContract (Arm.abi.withConsts ecbConsts) Spec.Cast5.ofbFinalSig 39 + (Spec.Cast5.ofbFinalPre Arm.abi.ptrBits) (Proof.Cast5.ofbFinalPost Arm.abi.ptrBits) 8) where + pre s h := by + unfold Proof.Cast5.modeScratchContract Sig.scratchContract at h + obtain ⟨h1, hk⟩ := pre_consts.mp h + refine seqArm_pre_rwR' (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) + (rd' := (stripConsts ecbConsts s).rd) ?_ (fun r hr => stripConsts_rd_mem hr) (tabsOk_of hk (by decide)) + sig_pre [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h1 + exact h1 + post s s' _ h := by + unfold Proof.Cast5.modeScratchContract Sig.scratchContract + refine post_consts.mpr ?_ + sig_post [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Proof.Cast5.ofbFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + have e := ofbFinal_post h fun b => by + show _ = 8 + simp [ecbSpec, Proof.Cast5.dirCipher, Spec.Cast5.cipher] + obtain ⟨e1, e2, e3, -, -⟩ := args_rounds (c := ecbCore true) rfl s + simp only [show (ecbCore true).bs = 8 from rfl, e1, e2, e3] at e + simp only [ecbSpec, Proof.Cast5.dirCipher, ↓reduceIte, State.addr] at e + exact e + pub s₁ s₂ _ _ h := by + unfold Proof.Cast5.modeScratchContract Sig.scratchContract at h + obtain ⟨h, hsy⟩ := pub_consts.mp h + sig_pub [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pubR (M := byteMode) h fun x hx => symAddr_eq_iff.mp (hsy x hx) + sat := ofbFinal_sat _ + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Proof.Cast5.modeScratchContract (Arm.abi.withConsts ecbConsts) Spec.Cast5.ofbFinalSig 39 + (Spec.Cast5.ofbFinalPre Arm.abi.ptrBits) (Proof.Cast5.ofbFinalPost Arm.abi.ptrBits) 8) := + seqFinal_verified (ecbSpec true) (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 328 1 78 ofbFinal) + (Proof.Cast5.ofbFinalRoundsContract (Arm.abi.withConsts ecbConsts) 336) := + Arm.Verified.stackScratchWipedC (c₀ := (s1234Sym, s1234)) (cs := []) (sig := Spec.Cast5.ofbFinalSig) + (nm := "scratch") (e := .u64) (n := 39) (pre := Spec.Cast5.ofbFinalPre Arm.abi.ptrBits) + (post := Proof.Cast5.ofbFinalPost Arm.abi.ptrBits) (wa := true) (stack := 8) (m := 1) (bytes := 328) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun vs m₁ m₂ hl _ h => Proof.Cast5.ofbFinalPre_local _ vs m₁ m₂ hl h) (Proof.Cast5.ofbFinalPost_local _) + (Proof.Cast5.ofbFinalPostOut_local _) (ofbFinalFrame_sat _) + end VG.Proof.Cast5.Arm diff --git a/lean/VerifiedGarbage/Proof/Idea/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Idea/Arm/FbFinalVerified.lean index f935c2fce27..e6bdb526e58 100644 --- a/lean/VerifiedGarbage/Proof/Idea/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Idea/Arm/FbFinalVerified.lean @@ -5,6 +5,7 @@ public import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Idea.Arm.FbFinal public import VerifiedGarbage.Spec.Idea.CfbFinal +public import VerifiedGarbage.Spec.Idea.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Modes.Arm.OfbCfb import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -17,6 +18,7 @@ meta import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Idea.Arm.FbFinal meta import VerifiedGarbage.Spec.Idea.CfbFinal +meta import VerifiedGarbage.Spec.Idea.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.Arm.OfbCfb meta import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -26,12 +28,13 @@ meta import VerifiedGarbage.Proof.Framework.Arm.Contract meta import VerifiedGarbage.Proof.Framework.Contract /-! -# IDEA-CFB64 of a message's last piece on ARMv7 meets its contracts +# IDEA-CFB64 and IDEA-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) -over IDEA's ECB function (`ecbSpec`) meets the contracts with a scratch +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +over IDEA's ECB function (`ecbSpec`) meet the contracts with a scratch buffer of 7 words, as the whole-block functions do (`FbVerified.lean`), with -the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the +the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 64 bytes more. -/ @@ -147,4 +150,55 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) cfbDecryptFinalFrameSat +/-! ## OFB of a message's last piece -/ + +theorem ofbFinalTaint : FinalTaint ecbCore VG.Impl.Modes.Arm.ofb := + ⟨ofbTaint.pro, ⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩, ofbTaint.epi⟩ + +theorem ofbFinal_implies : (seqFinalArm ecbCore ecbSpec VG.Impl.Modes.Arm.ofb).Implies + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) true 32) where + pre s h := seqArm_pre_rw (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) (by + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact h) + post s s' _ h := by + sig_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + have e := ofbFinal_post h fun b => by + show _ = 8 + simp [ecbSpec, Spec.Idea.cipher] + obtain ⟨e1, e2, e3, -, -⟩ := args_plain (c := ecbCore) rfl s + simp only [show ecbCore.bs = 8 from rfl, e1, e2, e3] at e + simp only [ecbSpec, State.addr] at e + exact e + pub s₁ s₂ _ _ h := by + sig_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pub (M := byteMode) rfl h + sat := by + sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbSat, stackArg, stackArgAddr, Mem.readW, + Mem.read] using fbSat 1 + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) true 32) := + seqFinal_verified ecbSpec (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +theorem ofbFinalFrameSat : ∃ s, (Spec.Idea.ofbFinalContract Arm.abi 96).pre s := by + implies_sat [Spec.Idea.ofbFinalContract, Spec.Idea.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val, Arm.State.addr] [fbFrameSat, fbSat] using fbFrameSat 1 + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 ofbFinal) + (Spec.Idea.ofbFinalContract Arm.abi 96) := + Arm.Verified.stackScratchWiped (sig := Spec.Idea.ofbFinalSig) (nm := "scratch") (e := .u64) (n := 7) + (post := Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) (wa := true) (stack := 32) (m := 0) (bytes := 64) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) + (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat + end VG.Proof.Idea.Arm diff --git a/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean index 2f71aaec199..400f4f19702 100644 --- a/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean @@ -3,9 +3,11 @@ module public import VerifiedGarbage.Impl.Modes.Arm.SeqFinal public import VerifiedGarbage.Proof.Modes.Arm.SeqBody public import VerifiedGarbage.Spec.Cfb.Final +public import VerifiedGarbage.Spec.Ofb.Final import VerifiedGarbage.Proof.Modes.Arm.SeqLoop import VerifiedGarbage.Proof.Modes.Arm.OfbCfb import VerifiedGarbage.Proof.Modes.FbFinal +import VerifiedGarbage.Proof.AesOfb.Spec import VerifiedGarbage.Proof.Modes.Addr import VerifiedGarbage.Proof.CmacAes.Arm.Words import VerifiedGarbage.Proof.Framework.Arm.Syms @@ -17,7 +19,7 @@ import VerifiedGarbage.Proof.Framework.Arm.Contract import VerifiedGarbage.Proof.Framework.Contract /-! -# CFB of a message's last piece on ARMv7: the contract and its proof +# CFB and OFB of a message's last piece on ARMv7: the contract and its proof `seqFinalArm c S M`: the contract `Core.seqFinal c M` meets, for any core `c` (with `S : CoreSpec c`) and mode `M` whose operations are all after a @@ -29,7 +31,8 @@ first bytes of `CIPH_K` of the chaining block `runSeq` leaves, and the IV becomes that chaining block if `r = 0`, and its image under the cipher otherwise (`seqFinal_wp`). `cfbEncFinal_post` and `cfbDecFinal_post` state this as the specification's (`Spec.Cfb.EncryptFinal`, `DecryptFinal`) for -`cfbEnc` and `cfbDecF`. +`cfbEnc` and `cfbDecF`, and `ofbFinal_post` as `Spec.Ofb.CryptFinal` for +`ofb`. The prologue is `seq`'s (`prologue_wp`), and its invariant for no element gives the loop's for no whole block (`FInv`): the registers hold the @@ -1064,4 +1067,54 @@ theorem cfbEnc_finalOk (c : Core) (h1 : 1 ≤ c.lg) (h31 : c.lg ≤ 31) (hl : 2 theorem cfbDecF_finalOk (c : Core) (h1 : 1 ≤ c.lg) (h31 : c.lg ≤ 31) (hl : 2 ^ c.lg = c.bs) : FinalOk c cfbDecF := ⟨rfl, rfl, rfl, rfl, rfl, hl, h1, h31⟩ +/-! ## OFB -/ + +/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` +whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last +`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block +(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ +theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) + (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) + (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = + Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) + (ciph (Spec.Ofb.next ciph iv (len / L)))) : + bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by + have hx := VG.Proof.Modes.xor_flatten_outputs hc m₀ (len / L) D iv + have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] + rw [VG.Proof.Modes.bytesAt_blocks_tail L m' D len, hblocks, htail, Spec.Ofb.cryptFinal, + VG.Proof.Modes.bytesAt_length, VG.Proof.Modes.blockCount_eq hL, VG.Proof.Modes.bytesAt_blocks_tail L m₀ D len, + Spec.Ofb.crypt, hnB] + split + · rename_i h0 + rw [h0, ← hx] + simp [bytesAt, Spec.Cbc.xor] + · rw [VG.Proof.AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] + exact (List.zipWith_append (by + rw [← VG.Proof.Modes.bytesAt_mul, VG.Proof.Modes.bytesAt_length, + VG.Proof.Modes.length_flatten_outputs hc])).symm + +/-- The final function with `ofb` encrypts and decrypts as +`Spec.Ofb.CryptFinal` says, for a cipher whose every output is a block. -/ +theorem ofbFinal_post {c : Core} {S : CoreSpec c} {s s' : State} (h : (seqFinalArm c S ofb).post s s') + (hc : ∀ b, (S.ciphAt s.mem (State.addr (s.gpr .r0)) (s.gpr .r1) b).length = c.bs) : + Spec.Ofb.CryptFinal (S.ciphAt s.mem (State.addr (s.gpr .r0)) (s.gpr .r1)) c.bs s.mem s'.mem + (State.addr (ivArg c s)) (State.addr (dArg c s)) (nArg c s).toNat := by + obtain ⟨h1, h2, h3⟩ := h + have hL : 0 < c.bs := Nat.mul_pos (by decide) S.bw_pos + have e := runSeq_ofb (S.ciphAt s.mem (State.addr (s.gpr .r0)) (s.gpr .r1)) ⟨[], bytesAt s.mem + (State.addr (ivArg c s)) c.bs, bytesAt s.mem (State.addr (scArg c s) + BitVec.ofNat 64 (oOff + c.bs)) c.bs⟩ + (blocksOf c.bs s.mem (State.addr (dArg c s)) ((nArg c s).toNat / c.bs)) + rw [length_blocksOf] at e + rw [e.1] at h1 + rw [e.2] at h2 h3 + refine ⟨ofbFinal_of hL hc s.mem s'.mem _ _ _ h1 h2, h3.trans ?_⟩ + rw [VG.Proof.Modes.blockCount_eq hL] + split + · rfl + · exact (VG.Proof.AesOfb.next_succ _ _ _).symm + +theorem ofb_finalOk (c : Core) (h1 : 1 ≤ c.lg) (h31 : c.lg ≤ 31) (hl : 2 ^ c.lg = c.bs) : FinalOk c ofb := + ⟨rfl, rfl, rfl, rfl, rfl, hl, h1, h31⟩ + end VG.Proof.Modes.Arm diff --git a/lean/VerifiedGarbage/Proof/Seed/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Seed/Arm/FbFinalVerified.lean index 05cf18d8cd5..5767edb89eb 100644 --- a/lean/VerifiedGarbage/Proof/Seed/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Seed/Arm/FbFinalVerified.lean @@ -5,6 +5,7 @@ public import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Seed.Arm.FbFinal public import VerifiedGarbage.Spec.Seed.CfbFinal +public import VerifiedGarbage.Spec.Seed.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Modes.Arm.OfbCfb import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -17,6 +18,7 @@ meta import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Seed.Arm.FbFinal meta import VerifiedGarbage.Spec.Seed.CfbFinal +meta import VerifiedGarbage.Spec.Seed.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.Arm.OfbCfb meta import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -29,12 +31,13 @@ meta import VerifiedGarbage.Proof.Framework.NativeTaintCore meta import VerifiedGarbage.Proof.Framework.Arm.NativeHintData /-! -# SEED-CFB128 of a message's last piece on ARMv7 meets its contracts +# SEED-CFB128 and SEED-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) -over SEED's ECB function (`ecbSpec .encrypt`) meets the contracts with a scratch +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +over SEED's ECB function (`ecbSpec .encrypt`) meet the contracts with a scratch buffer of 9 words, as the whole-block functions do (`FbVerified.lean`), with -the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the +the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 80 bytes more. -/ @@ -150,4 +153,55 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) cfbDecryptFinalFrameSat +/-! ## OFB of a message's last piece -/ + +theorem ofbFinalTaint : FinalTaint (ecbCore .encrypt) VG.Impl.Modes.Arm.ofb := + ⟨ofbTaint.pro, ⟨_, by native_taint_decide⟩, ⟨_, by native_taint_decide⟩, ofbTaint.epi⟩ + +theorem ofbFinal_implies : (seqFinalArm (ecbCore .encrypt) (ecbSpec .encrypt) VG.Impl.Modes.Arm.ofb).Implies + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 9 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 Arm.abi.ptrBits) true 752) where + pre s h := seqArm_pre_rw (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) (by + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact h) + post s s' _ h := by + sig_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + have e := ofbFinal_post h fun b => by + show _ = 16 + simp [ecbSpec, dirCipher, Spec.Seed.cipher] + obtain ⟨e1, e2, e3, -, -⟩ := args_plain (c := (ecbCore .encrypt)) rfl s + simp only [show (ecbCore .encrypt).bs = 16 from rfl, e1, e2, e3] at e + simp only [ecbSpec, dirCipher, State.addr] at e + exact e + pub s₁ s₂ _ _ h := by + sig_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pub (M := byteMode) rfl h + sat := by + sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbSat, stackArg, stackArgAddr, Mem.readW, + Mem.read] using fbSat 1 + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 9 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 Arm.abi.ptrBits) true 752) := + seqFinal_verified (ecbSpec .encrypt) (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +theorem ofbFinalFrameSat : ∃ s, (Spec.Seed.ofbFinalContract Arm.abi 832).pre s := by + implies_sat [Spec.Seed.ofbFinalContract, Spec.Seed.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val, Arm.State.addr] [fbFrameSat, fbSat] using fbFrameSat 1 + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 80 0 18 ofbFinal) + (Spec.Seed.ofbFinalContract Arm.abi 832) := + Arm.Verified.stackScratchWiped (sig := Spec.Seed.ofbFinalSig) (nm := "scratch") (e := .u64) (n := 9) + (post := Proof.Modes.ofbFinalPost ciphAt 16 Arm.abi.ptrBits) (wa := true) (stack := 752) (m := 0) (bytes := 80) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) + (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat + end VG.Proof.Seed.Arm diff --git a/lean/VerifiedGarbage/Proof/Sm4/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Sm4/Arm/FbFinalVerified.lean index 0eb4d4027b4..85d1d58f74e 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/Arm/FbFinalVerified.lean @@ -10,6 +10,7 @@ public import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Sm4.Arm.FbFinal public import VerifiedGarbage.Spec.Sm4.CfbFinal +public import VerifiedGarbage.Spec.Sm4.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Modes.Arm.OfbCfb import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -27,6 +28,7 @@ meta import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Sm4.Arm.FbFinal meta import VerifiedGarbage.Spec.Sm4.CfbFinal +meta import VerifiedGarbage.Spec.Sm4.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.Arm.OfbCfb meta import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -36,12 +38,13 @@ meta import VerifiedGarbage.Proof.Framework.Arm.Contract meta import VerifiedGarbage.Proof.Framework.Contract /-! -# SM4-CFB128 of a message's last piece on ARMv7 meets its contracts +# SM4-CFB128 and SM4-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) -over Sm4's ECB function (`ecbSpec .encrypt`) meets the contracts with a scratch +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +over Sm4's ECB function (`ecbSpec .encrypt`) meet the contracts with a scratch buffer of 9 words, with the 1480 bytes of stack the ECB function uses, with -the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the +the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 80 bytes more. -/ @@ -241,4 +244,55 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) cfbDecryptFinalFrameSat +/-! ## OFB of a message's last piece -/ + +theorem ofbFinalTaint : FinalTaint (ecbCore .encrypt) VG.Impl.Modes.Arm.ofb := + ⟨⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩⟩ + +theorem ofbFinal_implies : (seqFinalArm (ecbCore .encrypt) (ecbSpec .encrypt) VG.Impl.Modes.Arm.ofb).Implies + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 9 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 Arm.abi.ptrBits) true 1480) where + pre s h := seqArm_pre_rw (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) (by + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact h) + post s s' _ h := by + sig_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + have e := ofbFinal_post h fun b => by + show _ = 16 + simp [ecbSpec, dirCipher, Spec.Sm4.cipher] + obtain ⟨e1, e2, e3, -, -⟩ := args_plain (c := (ecbCore .encrypt)) rfl s + simp only [show (ecbCore .encrypt).bs = 16 from rfl, e1, e2, e3] at e + simp only [ecbSpec, dirCipher, State.addr] at e + exact e + pub s₁ s₂ _ _ h := by + sig_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pub (M := byteMode) rfl h + sat := by + sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbSat, stackArg, stackArgAddr, Mem.readW, + Mem.read] using fbSat 1 + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 9 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 Arm.abi.ptrBits) true 1480) := + seqFinal_verified (ecbSpec .encrypt) (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +theorem ofbFinalFrameSat : ∃ s, (Spec.Sm4.ofbFinalContract Arm.abi 1560).pre s := by + implies_sat [Spec.Sm4.ofbFinalContract, Spec.Sm4.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val, Arm.State.addr] [fbFrameSat, fbSat] using fbFrameSat 1 + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 80 0 18 ofbFinal) + (Spec.Sm4.ofbFinalContract Arm.abi 1560) := + Arm.Verified.stackScratchWiped (sig := Spec.Sm4.ofbFinalSig) (nm := "scratch") (e := .u64) (n := 9) + (post := Proof.Modes.ofbFinalPost ciphAt 16 Arm.abi.ptrBits) (wa := true) (stack := 1480) (m := 0) (bytes := 80) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) + (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat + end VG.Proof.Sm4.Arm diff --git a/lean/VerifiedGarbage/Proof/TripleDes/Arm/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/TripleDes/Arm/FbFinalVerified.lean index 07e3acf8c0a..99ffa40759c 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/Arm/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/Arm/FbFinalVerified.lean @@ -5,6 +5,7 @@ public import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.TripleDes.Arm.FbFinal public import VerifiedGarbage.Spec.TripleDes.CfbFinal +public import VerifiedGarbage.Spec.TripleDes.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Modes.Arm.OfbCfb import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -17,6 +18,7 @@ meta import VerifiedGarbage.Proof.Modes.Arm.SeqFinalCT meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.TripleDes.Arm.FbFinal meta import VerifiedGarbage.Spec.TripleDes.CfbFinal +meta import VerifiedGarbage.Spec.TripleDes.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Modes.Arm.OfbCfb meta import VerifiedGarbage.Proof.Modes.Arm.Cbc @@ -26,12 +28,13 @@ meta import VerifiedGarbage.Proof.Framework.Arm.Contract meta import VerifiedGarbage.Proof.Framework.Contract /-! -# Triple DES-CFB64 of a message's last piece on ARMv7 meets its contracts +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on ARMv7 meet their contracts -The generic CFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) -over Triple DES's ECB function (`ecbSpec .encrypt`) meets the contracts with a scratch +The generic CFB and OFB over a message's last piece (`Proof.Modes.Arm.seqFinal_verified`) +over Triple DES's ECB function (`ecbSpec .encrypt`) meet the contracts with a scratch buffer of 7 words, as the whole-block functions do (`FbVerified.lean`), with -the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …); the +the specification's results (`Proof.Modes.Arm.cfbEncFinal_post`, …, +`Proof.Modes.Arm.ofbFinal_post`); the `_framed` theorems keep the buffer on the stack, zeroed on return: 64 bytes more. -/ @@ -147,4 +150,55 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) cfbDecryptFinalFrameSat +/-! ## OFB of a message's last piece -/ + +theorem ofbFinalTaint : FinalTaint (ecbCore .encrypt) VG.Impl.Modes.Arm.ofb := + ⟨ofbTaint.pro, ⟨_, by taint_decide⟩, ⟨_, by taint_decide⟩, ofbTaint.epi⟩ + +theorem ofbFinal_implies : (seqFinalArm (ecbCore .encrypt) (ecbSpec .encrypt) VG.Impl.Modes.Arm.ofb).Implies + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) true 1024) where + pre s h := seqArm_pre_rw (M := byteMode) rfl (len := fun n => n) (fun n => (Nat.mul_one n).symm) (by + sig_pre [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact h) + post s s' _ h := by + sig_post [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + have e := ofbFinal_post h fun b => by + show _ = 8 + simp [ecbSpec, dirCipher, Spec.TripleDes.cipher] + obtain ⟨e1, e2, e3, -, -⟩ := args_plain (c := (ecbCore .encrypt)) rfl s + simp only [show (ecbCore .encrypt).bs = 8 from rfl, e1, e2, e3] at e + simp only [ecbSpec, dirCipher, State.addr] at e + exact e + pub s₁ s₂ _ _ h := by + sig_pub [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at h + exact seqArm_pub (M := byteMode) rfl h + sat := by + sig_implies_sat [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [fbSat, stackArg, stackArgAddr, Mem.readW, + Mem.read] using fbSat 1 + +theorem ofbFinal_verified : Verified Arm.target ofbFinal + (Sig.scratchContract Arm.abi finalSig "scratch" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) true 1024) := + seqFinal_verified (ecbSpec .encrypt) (ofb_finalOk _ (by decide) (by decide) (by decide)) ofbFinalTaint + ofbFinal_implies + +theorem ofbFinalFrameSat : ∃ s, (Spec.TripleDes.ofbFinalContract Arm.abi 1088).pre s := by + implies_sat [Spec.TripleDes.ofbFinalContract, Spec.TripleDes.ofbFinalSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val, Arm.State.addr] [fbFrameSat, fbSat] using fbFrameSat 1 + +/-- `ofbFinal`, with its scratch buffer on the stack (zeroed on return). -/ +theorem ofbFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 ofbFinal) + (Spec.TripleDes.ofbFinalContract Arm.abi 1088) := + Arm.Verified.stackScratchWiped (sig := Spec.TripleDes.ofbFinalSig) (nm := "scratch") (e := .u64) (n := 7) + (post := Proof.Modes.ofbFinalPost ciphAt 8 Arm.abi.ptrBits) (wa := true) (stack := 1024) (m := 0) (bytes := 64) + ofbFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) + (Proof.Modes.ofbFinalPost_local _) ofbFinalFrameSat + end VG.Proof.TripleDes.Arm From 3d79a2518e88368ed6a74060b15365c443724abd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:30:33 +0000 Subject: [PATCH 05/18] OFB final functions on PPC64LE for Blowfish, Camellia, CAST5, IDEA, SEED, SM4 and Triple DES (WIP: crates to come) PPC64LE's seqFinal with OFB's mode; its proof (ofbFinal_wp) in Proof/Modes/PPC64LE/SeqFinal.lean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/BlowfishOfb/PPC64LE.lean | 8 +- .../Artifacts/CamelliaOfb/PPC64LE.lean | 8 +- .../Artifacts/Cast5Ofb/PPC64LE.lean | 8 +- .../Artifacts/IdeaOfb/PPC64LE.lean | 8 +- .../Artifacts/SeedOfb/PPC64LE.lean | 8 +- .../Artifacts/Sm4Ofb/PPC64LE.lean | 8 +- .../Artifacts/TripleDesOfb/PPC64LE.lean | 8 +- .../Impl/Blowfish/PPC64LE/FbFinal.lean | 9 +- .../Impl/Camellia/PPC64LE/FbFinal.lean | 9 +- .../Impl/Cast5/PPC64LE/FbFinal.lean | 9 +- .../Impl/Idea/PPC64LE/FbFinal.lean | 9 +- .../Impl/Seed/PPC64LE/FbFinal.lean | 9 +- .../Impl/Sm4/PPC64LE/FbFinal.lean | 9 +- .../Impl/TripleDes/PPC64LE/FbFinal.lean | 9 +- .../Proof/Blowfish/PPC64LE/FbFinalLit.lean | 3 +- .../Blowfish/PPC64LE/FbFinalVerified.lean | 50 ++++++- .../Proof/Camellia/PPC64LE/FbFinalLit.lean | 3 +- .../Camellia/PPC64LE/FbFinalVerified.lean | 60 ++++++++- .../Proof/Cast5/PPC64LE/FbFinalLit.lean | 3 +- .../Proof/Cast5/PPC64LE/FbFinalVerified.lean | 124 ++++++++++++++++-- .../Proof/Idea/PPC64LE/FbFinalLit.lean | 3 +- .../Proof/Idea/PPC64LE/FbFinalVerified.lean | 48 ++++++- .../Proof/Modes/PPC64LE/SeqFinal.lean | 64 ++++++++- .../Proof/Seed/PPC64LE/FbFinalLit.lean | 3 +- .../Proof/Seed/PPC64LE/FbFinalVerified.lean | 50 ++++++- .../Proof/Sm4/PPC64LE/FbFinalLit.lean | 3 +- .../Proof/Sm4/PPC64LE/FbFinalVerified.lean | 51 ++++++- .../Proof/TripleDes/PPC64LE/FbFinalLit.lean | 3 +- .../TripleDes/PPC64LE/FbFinalVerified.lean | 50 ++++++- 29 files changed, 571 insertions(+), 66 deletions(-) diff --git a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/PPC64LE.lean index 23f3f955ec0..0150e1a781a 100644 --- a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/PPC64LE.lean @@ -2,9 +2,11 @@ module public import VerifiedGarbage.Proof.Blowfish.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.Blowfish.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Blowfish.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Blowfish.PPC64LE.ModesLit +import VerifiedGarbage.Proof.Blowfish.PPC64LE.FbFinalLit /-! # Blowfish-OFB artifacts on baseline PPC64LE -/ @@ -16,6 +18,10 @@ def artifacts : List Artifact := [ Spec.Blowfish.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 128 .r7 12 Impl.Blowfish.PPC64LE.ofb stack := 128 - verified := Proof.Blowfish.PPC64LE.ofb_framed Proof.Blowfish.PPC64LE.Modes.ofb_verified }] + verified := Proof.Blowfish.PPC64LE.ofb_framed Proof.Blowfish.PPC64LE.Modes.ofb_verified }, + Spec.Blowfish.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 128 .r7 12 Impl.Blowfish.PPC64LE.ofbFinal + stack := 128 + verified := Proof.Blowfish.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.BlowfishOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/PPC64LE.lean index dcd2d8ed6a0..aec710a5ee0 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/PPC64LE.lean @@ -2,10 +2,12 @@ module public import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Camellia.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesLit import VerifiedGarbage.Proof.Camellia.PPC64LE.Lit +import VerifiedGarbage.Proof.Camellia.PPC64LE.FbFinalLit /-! # Camellia-OFB artifacts on baseline PPC64LE -/ @@ -17,6 +19,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 3408 .r8 422 Impl.Camellia.PPC64LE.ofb stack := 3408 - verified := Proof.Camellia.PPC64LE.ofb_framed Proof.Camellia.PPC64LE.Modes.ofb_verified }] + verified := Proof.Camellia.PPC64LE.ofb_framed Proof.Camellia.PPC64LE.Modes.ofb_verified }, + Spec.Camellia.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 3408 .r8 422 Impl.Camellia.PPC64LE.ofbFinal + stack := 3408 + verified := Proof.Camellia.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.CamelliaOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/PPC64LE.lean index 074231841c0..ae479af3662 100644 --- a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/PPC64LE.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Cast5.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Cast5.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Cast5.PPC64LE.ModesLit +import VerifiedGarbage.Proof.Cast5.PPC64LE.FbFinalLit /-! # CAST5-OFB artifacts on baseline PPC64LE -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Cast5.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 208 .r8 22 Impl.Cast5.PPC64LE.ofb stack := 208 - verified := Proof.Cast5.ofb_keyed Proof.Cast5.PPC64LE.Modes.ofb_framed }] + verified := Proof.Cast5.ofb_keyed Proof.Cast5.PPC64LE.Modes.ofb_framed }, + Spec.Cast5.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 208 .r8 22 Impl.Cast5.PPC64LE.ofbFinal + stack := 208 + verified := Proof.Cast5.ofbFinal_keyed Proof.Cast5.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.Cast5Ofb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/IdeaOfb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/IdeaOfb/PPC64LE.lean index 9dbe7efb35d..16a8a3661dc 100644 --- a/lean/VerifiedGarbage/Artifacts/IdeaOfb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/IdeaOfb/PPC64LE.lean @@ -2,9 +2,11 @@ module public import VerifiedGarbage.Proof.Idea.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.Idea.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Idea.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Idea.PPC64LE.ModesLit +import VerifiedGarbage.Proof.Idea.PPC64LE.FbFinalLit /-! # IDEA-OFB artifacts on baseline PPC64LE -/ @@ -16,6 +18,10 @@ def artifacts : List Artifact := [ Spec.Idea.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 96 .r7 8 Impl.Idea.PPC64LE.ofb stack := 96 - verified := Proof.Idea.PPC64LE.ofb_framed Proof.Idea.PPC64LE.Modes.ofb_verified }] + verified := Proof.Idea.PPC64LE.ofb_framed Proof.Idea.PPC64LE.Modes.ofb_verified }, + Spec.Idea.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 96 .r7 8 Impl.Idea.PPC64LE.ofbFinal + stack := 96 + verified := Proof.Idea.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.IdeaOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/SeedOfb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/SeedOfb/PPC64LE.lean index 21045406f27..ff9add31f0f 100644 --- a/lean/VerifiedGarbage/Artifacts/SeedOfb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/SeedOfb/PPC64LE.lean @@ -2,9 +2,11 @@ module public import VerifiedGarbage.Proof.Seed.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.Seed.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Seed.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Seed.PPC64LE.ModesLit +import VerifiedGarbage.Proof.Seed.PPC64LE.FbFinalLit /-! # SEED-OFB artifacts on baseline PPC64LE -/ @@ -16,6 +18,10 @@ def artifacts : List Artifact := [ Spec.Seed.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 1184 .r7 144 Impl.Seed.PPC64LE.ofb stack := 1184 - verified := Proof.Seed.PPC64LE.ofb_framed Proof.Seed.PPC64LE.Modes.ofb_verified }] + verified := Proof.Seed.PPC64LE.ofb_framed Proof.Seed.PPC64LE.Modes.ofb_verified }, + Spec.Seed.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 1184 .r7 144 Impl.Seed.PPC64LE.ofbFinal + stack := 1184 + verified := Proof.Seed.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.SeedOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/PPC64LE.lean index 94945e4ad8f..2384bb2a9b9 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/PPC64LE.lean @@ -2,9 +2,11 @@ module public import VerifiedGarbage.Proof.Sm4.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.Sm4.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Sm4.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Sm4.PPC64LE.ModesLit +import VerifiedGarbage.Proof.Sm4.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Sm4.PPC64LE.Lit /-! # SM4-OFB artifacts on baseline PPC64LE -/ @@ -17,6 +19,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 3296 .r7 408 Impl.Sm4.PPC64LE.ofb stack := 3296 - verified := Proof.Sm4.PPC64LE.ofb_framed Proof.Sm4.PPC64LE.Modes.ofb_verified }] + verified := Proof.Sm4.PPC64LE.ofb_framed Proof.Sm4.PPC64LE.Modes.ofb_verified }, + Spec.Sm4.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 3296 .r7 408 Impl.Sm4.PPC64LE.ofbFinal + stack := 3296 + verified := Proof.Sm4.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.Sm4Ofb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/PPC64LE.lean index 602aba8be78..7c535f1f05a 100644 --- a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/PPC64LE.lean @@ -2,9 +2,11 @@ module public import VerifiedGarbage.Proof.TripleDes.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.TripleDes.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.TripleDes.PPC64LE.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.TripleDes.PPC64LE.ModesLit +import VerifiedGarbage.Proof.TripleDes.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.TripleDes.PPC64LE.FunctionsLit /-! # Triple DES-OFB artifacts on baseline PPC64LE -/ @@ -17,6 +19,10 @@ def artifacts : List Artifact := [ Spec.TripleDes.ofbApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 608 .r7 72 Impl.TripleDes.PPC64LE.ofb stack := 608 - verified := Proof.TripleDes.PPC64LE.ofb_framed Proof.TripleDes.PPC64LE.Modes.ofb_verified }] + verified := Proof.TripleDes.PPC64LE.ofb_framed Proof.TripleDes.PPC64LE.Modes.ofb_verified }, + Spec.TripleDes.ofbFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 608 .r7 72 Impl.TripleDes.PPC64LE.ofbFinal + stack := 608 + verified := Proof.TripleDes.PPC64LE.FbFinal.ofbFinal_framed }] end VG.Artifacts.TripleDesOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Blowfish/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/Blowfish/PPC64LE/FbFinal.lean index d2d812fb72f..ea214e03e7c 100644 --- a/lean/VerifiedGarbage/Impl/Blowfish/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Blowfish/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Blowfish.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# Blowfish-CFB64 of a message's last piece on PPC64LE +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, iv = r4, data = r5, -len = r6, scratch = r7): the modes' CFB over a message's last piece, of any +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, iv = r4, +data = r5, len = r6, scratch = r7): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over Blowfish's core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.cfbEnc 2) /-- `vg_blowfish_cfb64_decrypt_final`, with its scratch buffer as the fifth argument. -/ def cfbDecryptFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_blowfish_ofb_final`, with its scratch buffer as the fifth argument. -/ +def ofbFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Blowfish.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/FbFinal.lean index 256e5e7a65a..f954ce33efe 100644 --- a/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Camellia.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# Camellia-CFB128 of a message's last piece on PPC64LE +# Camellia-CFB128 and Camellia-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, rounds = r4, iv = -r5, data = r6, len = r7, scratch = r8): the modes' CFB over a message's last +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, rounds = +r4, iv = r5, data = r6, len = r7, scratch = r8): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over Camellia's core, wrapped for the two key arguments (`wrap`) as `cfbEncrypt` is, with its arguments but the data's length in bytes. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := wrap ((dirCore .encrypt).seqFinal (Modes.Mode. /-- `vg_camellia_cfb128_decrypt_final`, with its scratch buffer as the sixth argument. -/ def cfbDecryptFinal : Prog isa := wrap ((dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4)) +/-- `vg_camellia_ofb_final`, with its scratch buffer as the sixth argument. -/ +def ofbFinal : Prog isa := wrap ((dirCore .encrypt).seqFinal (Modes.Mode.ofb 4)) + end VG.Impl.Camellia.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Cast5/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/Cast5/PPC64LE/FbFinal.lean index 654da1e68c0..84e16b69ac8 100644 --- a/lean/VerifiedGarbage/Impl/Cast5/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Cast5/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Cast5.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# CAST5-CFB64 of a message's last piece on PPC64LE +# CAST5-CFB64 and CAST5-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, rounds = r4, iv = -r5, data = r6, len = r7, scratch = r8): the modes' CFB over a message's last +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, rounds = +r4, iv = r5, data = r6, len = r7, scratch = r8): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over CAST5's core with the count of rounds `rounds` says (`modeFn`), as `cfbEncrypt` is, with its arguments but the data's length in bytes. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := modeFn fun n => (dirCore true n).seqFinal (Mod /-- `vg_cast5_cfb64_decrypt_final`, with its scratch buffer as the sixth argument. -/ def cfbDecryptFinal : Prog isa := modeFn fun n => (dirCore true n).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_cast5_ofb_final`, with its scratch buffer as the sixth argument. -/ +def ofbFinal : Prog isa := modeFn fun n => (dirCore true n).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Cast5.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Idea/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/Idea/PPC64LE/FbFinal.lean index a6d75081da5..d3eb62e281e 100644 --- a/lean/VerifiedGarbage/Impl/Idea/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Idea/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Idea.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# IDEA-CFB64 of a message's last piece on PPC64LE +# IDEA-CFB64 and IDEA-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, iv = r4, data = r5, -len = r6, scratch = r7): the modes' CFB over a message's last piece, of any +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, iv = r4, data = r5, +len = r6, scratch = r7): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over IDEA's core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := core.seqFinal (Modes.Mode.cfbEnc 2) /-- `vg_idea_cfb64_decrypt_final`, with its scratch buffer as the fifth argument. -/ def cfbDecryptFinal : Prog isa := core.seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_idea_ofb_final`, with its scratch buffer as the fifth argument. -/ +def ofbFinal : Prog isa := core.seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Idea.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Seed/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/Seed/PPC64LE/FbFinal.lean index e86a260888b..e7f0efc3476 100644 --- a/lean/VerifiedGarbage/Impl/Seed/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Seed/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Seed.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# SEED-CFB128 of a message's last piece on PPC64LE +# SEED-CFB128 and SEED-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, iv = r4, data = r5, -len = r6, scratch = r7): the modes' CFB over a message's last piece, of any +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, iv = r4, data = r5, +len = r6, scratch = r7): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over SEED's core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_seed_cfb128_decrypt_final`, with its scratch buffer as the fifth argument. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_seed_ofb_final`, with its scratch buffer as the fifth argument. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Seed.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/FbFinal.lean index 2bb10690491..30a4c44333e 100644 --- a/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Sm4.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# SM4-CFB128 of a message's last piece on PPC64LE +# SM4-CFB128 and SM4-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, iv = r4, data = r5, -len = r6, scratch = r7): the modes' CFB over a message's last piece, of any +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, iv = r4, data = r5, +len = r6, scratch = r7): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over SM4's core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_sm4_cfb128_decrypt_final`, with its scratch buffer as the fifth argument. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_sm4_ofb_final`, with its scratch buffer as the fifth argument. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Sm4.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/TripleDes/PPC64LE/FbFinal.lean b/lean/VerifiedGarbage/Impl/TripleDes/PPC64LE/FbFinal.lean index 51e2ef5ee92..c3164750ac3 100644 --- a/lean/VerifiedGarbage/Impl/TripleDes/PPC64LE/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/TripleDes/PPC64LE/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.TripleDes.PPC64LE.Modes public import VerifiedGarbage.Impl.Modes.PPC64LE.SeqFinal /-! -# Triple DES-CFB64 of a message's last piece on PPC64LE +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on PPC64LE -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = r3, iv = r4, data = r5, -len = r6, scratch = r7): the modes' CFB over a message's last piece, of any +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = r3, iv = r4, data = r5, +len = r6, scratch = r7): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/PPC64LE/SeqFinal.lean`), over Triple DES's core, with the arguments of `cfbEncrypt` but the data's length in bytes. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_triple_des_cfb64_decrypt_final`, with its scratch buffer as the fifth argument. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_triple_des_ofb_final`, with its scratch buffer as the fifth argument. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.TripleDes.PPC64LE diff --git a/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalLit.lean index 21aed5641b6..1119f038279 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Blowfish.PPC64LE.ModesLit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # Blowfish's final CFB functions on PPC64LE, evaluated once -/ +/-! # Blowfish's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Blowfish.PPC64LE.cfbEncryptFinal materialize_code Impl.Blowfish.PPC64LE.cfbDecryptFinal +materialize_code Impl.Blowfish.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalVerified.lean index dd7bcf86e32..69b042c58dd 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Blowfish.PPC64LE.FbFinal public import VerifiedGarbage.Spec.Blowfish.CfbFinal +public import VerifiedGarbage.Spec.Blowfish.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Blowfish.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Blowfish.Schedule @@ -20,6 +21,7 @@ meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Blowfish.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.Blowfish.CfbFinal +meta import VerifiedGarbage.Spec.Blowfish.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.PPC64LE.Taint @@ -28,10 +30,11 @@ meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# Blowfish-CFB64 of a message's last piece on PPC64LE meets its contracts +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on PPC64LE meet their contracts -`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`: the modes' CFB over -a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over +`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`, `ofbFinal_verified`: +the modes' CFB and OFB over a message's last piece +(`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, `ofbFinal_wp`) over Blowfish's core (`Mode.dirCoreSpec`), with the working space as a fifth argument (`finalContract`), as the whole-block functions are (`ModesVerified.lean`), but the data `len` bytes. Each is constant time by the @@ -179,4 +182,45 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .r4) (s.gpr .r5) (s.gpr .r6).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbPost).post s s' := + WP.mono (Proof.Modes.PPC64LE.ofbFinal_wp (dirCoreSpec true) (seqPre_of hs) (keyArgs_of hs)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract PPC64LE.abi finalSig "scratch" .u64 12 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 PPC64LE.abi.ptrBits) true 0 + +theorem ofbFinal_verified : Verified target ofbFinal ofbScratch := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, abi, argRegs, finalContract, ofbPost, ciph, ciphAt, modePub_iff] [modeSat] + using modeSat + +theorem ofbFrameSat_pre (post : Spec.Blowfish.ofbFinalSig.Post PPC64LE.abi.ptrBits) : + ∃ s, (Spec.Blowfish.ofbFinalSig.contract PPC64LE.abi (post := post) (writeArgs := true) + (stack := 0 + 128)).pre s := by + implies_sat [Spec.Blowfish.ofbFinalSig, PPC64LE.abi, PPC64LE.argRegs] [modeFrameSat] using modeFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 128 .r7 12 ofbFinal) + (Spec.Blowfish.ofbFinalContract PPC64LE.abi 128) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Blowfish.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 12) (post := Proof.Modes.ofbFinalPost ciphAt 8 PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 128) (words := 12) ofbFinal_verified (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Blowfish.PPC64LE.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalLit.lean index 82a03e1459b..b5cdd654660 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Camellia.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # Camellia's final CFB functions on PPC64LE, evaluated once -/ +/-! # Camellia's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG materialize_code Impl.Camellia.PPC64LE.cfbEncryptFinal materialize_code Impl.Camellia.PPC64LE.cfbDecryptFinal +materialize_code Impl.Camellia.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalVerified.lean index f3ded8d9e18..dabb27e3b6a 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Camellia.CfbFinalScratch public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Impl.Camellia.PPC64LE.FbFinal public import VerifiedGarbage.Spec.Camellia.CfbFinal +public import VerifiedGarbage.Spec.Camellia.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Camellia.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Camellia.PPC64LE.Lit @@ -26,6 +27,7 @@ meta import VerifiedGarbage.Proof.Camellia.CfbFinalScratch meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Impl.Camellia.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.Camellia.CfbFinal +meta import VerifiedGarbage.Spec.Camellia.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.PPC64LE.SlotTaint @@ -37,19 +39,20 @@ meta import VerifiedGarbage.Proof.Modes.Addr meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# Camellia-CFB128 of a message's last piece on PPC64LE meets its contracts +# Camellia-CFB128 and Camellia-OFB of a message's last piece on PPC64LE meet their contracts -`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`: the modes' CFB over -a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over +`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`, `ofbFinal_verified`: +the modes' CFB and OFB over a message's last piece +(`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, `ofbFinal_wp`) over Camellia's core (`Mode.dirCoreSpec`), run from the state `wrap` makes of the arguments (`entry`, `wrap_wp`), with the working space as the sixth argument (`finalContract`), as the whole-block functions are (`ModesVerified.lean`), but the data `len` bytes, meet the contracts on the subkeys at the schedule -(`Proof.Camellia.cfbEncFinalScratchContract`, …) with a scratch buffer of 422 +(`Proof.Camellia.cfbEncFinalScratchContract`, …, `ofbFinalScratchContract`) with a scratch buffer of 422 words. Each is constant time by the slot taint analysis with the prepared function's summary, as theirs are; the `_framed` theorems run them with their working space on the stack, zeroed on return, and give the specification's -contracts (`cfbEncryptFinal_of_sk`, …). +contracts (`cfbEncryptFinal_of_sk`, …, `ofbFinal_of_sk`). -/ @[expose] public section @@ -314,4 +317,51 @@ theorem cfbDecryptFinal_framed : (Proof.Camellia.cfbDecryptFinalPost_local _) (Proof.Camellia.cfbDecryptFinalPostOut_local _) cfbDecFinalFrameSat_pre +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .r5) (s.gpr .r6) (s.gpr .r7).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbPost).post s s' := by + have hw := Proof.Modes.PPC64LE.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hs) (keyArgs_of hs) + have hc := Proof.Modes.PPC64LE.ofbFinal_changes (dirCoreSpec .encrypt) (seqPre_of hs) (keyArgs_of hs) + obtain ⟨eP, eD, eN⟩ := entry_args s + rw [eP, eD, eN] at hw + refine WP.mono (run_wrapped hs hw hc) fun s' ⟨abi, s₂, hm, h⟩ => ⟨abi, ?_⟩ + rw [show 4 * (dirCore Dir.encrypt).bw = 16 from rfl, cipher_enc, hm] at h + obtain ⟨h1, h2⟩ := h + rw [iv_entry hs, data_entry hs] at h1 + rw [iv_entry hs] at h2 + exact ⟨h1, h2⟩ + +theorem ofbFinal_constantTime {post : State → State → Prop} : + ConstantTime isa (finalContract post).pre modePub ofbFinal := + VG.Taint.constantTime_of_exists (A := slotTaint) modeTaint final_agree (by taint_decide_sum [cryptSum]) + +theorem ofbFinal_verified : + Verified target ofbFinal (Proof.Camellia.ofbFinalScratchContract abi 422) := by + refine Verified.of_correct ofbFinal_correct ofbFinal_constantTime ?_ + sig_implies [Proof.Camellia.ofbFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Curry.app, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, Proof.Camellia.ofbFinalPostSk, abi, + argRegs, finalContract, ofbPost, modePub_iff, modeSlots_eq] [modeSat] using modeSat + +theorem ofbFinalFrameSat_pre : ∃ s, (Proof.Camellia.ofbFinalContractSk PPC64LE.abi (0 + 3408)).pre s := by + implies_sat [Proof.Camellia.ofbFinalContractSk, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, + Proof.Camellia.ofbFinalPostSk, PPC64LE.abi, PPC64LE.argRegs] [modeFrameSat] using modeFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 3408 .r8 422 ofbFinal) + (Spec.Camellia.ofbFinalContract PPC64LE.abi 3408) := + Proof.Camellia.ofbFinal_of_sk <| + PPC64LE.Verified.stackScratchWiped (sig := Spec.Camellia.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 422) (pre := Spec.Camellia.ofbFinalPre PPC64LE.abi.ptrBits) + (post := Proof.Camellia.ofbFinalPostSk PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 3408) (words := 422) ofbFinal_verified + (by decide) (by decide) (by decide) (Proof.Camellia.ofbFinalPre_local _) + (Proof.Camellia.ofbFinalPost_local _) (Proof.Camellia.ofbFinalPostOut_local _) + ofbFinalFrameSat_pre + end VG.Proof.Camellia.PPC64LE.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalLit.lean index 340bdd9a1a6..babaec9b55d 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Cast5.PPC64LE.ModesLit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # CAST5's final CFB functions on PPC64LE, evaluated once -/ +/-! # CAST5's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Cast5.PPC64LE.cfbEncryptFinal materialize_code Impl.Cast5.PPC64LE.cfbDecryptFinal +materialize_code Impl.Cast5.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalVerified.lean index 1ab51831cab..a71348a909d 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Cast5.CfbFinal public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Impl.Cast5.PPC64LE.FbFinal public import VerifiedGarbage.Spec.Cast5.CfbFinal +public import VerifiedGarbage.Spec.Cast5.OfbFinal import VerifiedGarbage.Proof.Cast5.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Cast5.ModeMem import VerifiedGarbage.Proof.Framework.PPC64LE.Lit @@ -20,6 +21,7 @@ meta import VerifiedGarbage.Proof.Cast5.CfbFinal meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Impl.Cast5.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.Cast5.CfbFinal +meta import VerifiedGarbage.Spec.Cast5.OfbFinal meta import VerifiedGarbage.Proof.Cast5.ModeMem meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.PPC64LE.TaintSym @@ -29,11 +31,12 @@ meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# CAST5-CFB64 of a message's last piece on PPC64LE meets its contracts +# CAST5-CFB64 and CAST5-OFB of a message's last piece on PPC64LE meet their contracts `modeFn m` moves the arguments to the modes' registers and runs `m n` for the count of rounds `n` (`modeFn_wp`), and each `m n` is here the modes' CFB -over a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over +or OFB over a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, +`ofbFinal_wp`) over CAST5's core with `n` rounds (`Mode.dirCoreSpec`). With the working space as the sixth argument (`finalP`, under the calling convention with the table: `finalPC`), as the whole-block functions are (`ModesVerified.lean`), but the @@ -190,14 +193,12 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p /-- The final functions' scratch contract with the table, from `finalP`'s implying it without. -/ -theorem implies_consts {post : State → State → Prop} {post' : Spec.Cast5.cfbFinalSig.Post abi.ptrBits} - (h : (finalP post).Implies (Proof.Cast5.modeScratchContract abi Spec.Cast5.cfbFinalSig 22 - (Spec.Cast5.cfbFinalPre abi.ptrBits) post')) +theorem implies_consts {sig : Sig} {pre : Curry (sig.words abi.ptrBits) (Mem → Prop)} + {post : State → State → Prop} {post' : sig.Post abi.ptrBits} + (h : (finalP post).Implies (Proof.Cast5.modeScratchContract abi sig 22 pre post')) (hpost : ∀ s s', post s s' → post (stripConsts ecbConsts s) s') - (hsat : ∃ s, (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) Spec.Cast5.cfbFinalSig 22 - (Spec.Cast5.cfbFinalPre abi.ptrBits) post').pre s) : - (finalPC post).Implies (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) Spec.Cast5.cfbFinalSig 22 - (Spec.Cast5.cfbFinalPre abi.ptrBits) post') where + (hsat : ∃ s, (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) sig 22 pre post').pre s) : + (finalPC post).Implies (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) sig 22 pre post') where pre s hs := by unfold Proof.Cast5.modeScratchContract Sig.scratchContract at hs exact ⟨h.pre _ (pre_consts.mp hs).1, (pre_consts.mp hs).2⟩ @@ -323,4 +324,109 @@ theorem cfbDecryptFinal_framed : (fun vs m₁ m₂ hl _ h => Proof.Cast5.cfbFinalPre_local _ vs m₁ m₂ hl h) (Proof.Cast5.cfbDecFinalPost_local _) (Proof.Cast5.cfbDecFinalPostOut_local _) (frame_sat _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (Spec.Cast5.cipher (keyOf s) (rounds s)) 8 s.mem s'.mem (s.gpr .r5) (s.gpr .r6) + (s.gpr .r7).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalPC ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ ofbPost s s' := by + refine modeFn_wp (rounds_of hs) fun s₁ h₁ => WP.mono (Proof.Modes.PPC64LE.ofbFinal_wp + (dirCoreSpec true _ (rounds_of hs)) (seqPre_of hs h₁ true) (keyArgs_of hs h₁ true)) + fun s' ⟨h1, h2⟩ => ⟨h₁.abi h1, ?_⟩ + obtain ⟨eP, eD, eN⟩ := args_eq h₁ + simp only [dirCore, dirCoreSpec, Proof.Cast5.dirCipher, ↓reduceIte, eP, eD, eN, h₁.mem] at h2 + exact h2 + +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taintSym [s1234Sym]) (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7, .r8]) + (fun _ _ _ _ hp => modes_agree _ _ hp) (by taint_decide) + +/-- `finalP`'s precondition, public data and witness are the OFB scratch +contract's under `abi`, for any postcondition it implies. -/ +theorem ofbFinalP_implies {post : State → State → Prop} {post' : Spec.Cast5.ofbFinalSig.Post abi.ptrBits} + (hpost : ∀ s s', post s s' → (Proof.Cast5.modeScratchContract abi Spec.Cast5.ofbFinalSig 22 + (Spec.Cast5.ofbFinalPre abi.ptrBits) post').post s s') : + (finalP post).Implies (Proof.Cast5.modeScratchContract abi Spec.Cast5.ofbFinalSig 22 + (Spec.Cast5.ofbFinalPre abi.ptrBits) post') where + pre s h := by + sig_pre [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, abi, argRegs, stackBelow] at h + simp only [Curry.app] at h + exact h + post s s' _ hp := hpost s s' hp + pub s₁ s₂ _ _ h := by + sig_pub [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, abi, argRegs] at h + obtain ⟨hsp, h3, h4, h5, h6, h7, h8⟩ := h + exact ⟨hsp, by simp [h3, h4, h5, h6, h7, h8]⟩ + sat := ⟨modeSat, by + sig_pre [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, abi, argRegs, stackBelow] + simp only [Curry.app] + repeat' apply And.intro + all_goals first | rfl | decide | exact Or.inr rfl | exact Region.disjoint_of_sep (by decide)⟩ + +theorem ofbFinal_sat (post : Spec.Cast5.ofbFinalSig.Post abi.ptrBits) : + ∃ s, (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) Spec.Cast5.ofbFinalSig 22 + (Spec.Cast5.ofbFinalPre abi.ptrBits) post).pre s := by + refine ⟨modeSatC, ?_⟩ + have hl : s1234.length = 512 := by rw [Impl.Cast5.s1234, table_length] + have held := ecbSatMem_held + generalize e : modeSatC = s + sig_pre [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, abi, argRegs, ecbConsts_eq, Abi.withConsts, + Abi.constRegions, Abi.constsHeld, stackBelow, Proof.Cast5.s1234_length] + subst e + simp only [Curry.app] + refine ⟨rfl, fun i hi => held i (by rw [hl]; exact hi), by decide, fun r hr => ?_, ?_⟩ + · change r ∈ [(⟨0x2000, 8⟩ : Region), ⟨0x3000, 0⟩, ⟨0x4000, 176⟩] at hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl <;> exact Region.disjoint_of_sep (by decide) + · repeat' apply And.intro + all_goals first | rfl | decide | exact Or.inr rfl | exact Region.disjoint_of_sep (by decide) + +theorem ofb_implies : (finalPC ofbPost).Implies (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) + Spec.Cast5.ofbFinalSig 22 (Spec.Cast5.ofbFinalPre abi.ptrBits) (Proof.Cast5.ofbFinalPost abi.ptrBits)) := + implies_consts (ofbFinalP_implies fun s s' hp => by + sig_post [Proof.Cast5.modeScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, + Spec.Cast5.ofbFinalSig, Proof.Cast5.ofbFinalPost, abi, argRegs] + simp only [Curry.app] + exact hp) (fun _ _ h => h) (ofbFinal_sat _) + +theorem ofbFinal_verified : Verified target ofbFinal + (Proof.Cast5.modeScratchContract (abi.withConsts ecbConsts) Spec.Cast5.ofbFinalSig 22 + (Spec.Cast5.ofbFinalPre abi.ptrBits) (Proof.Cast5.ofbFinalPost abi.ptrBits)) := + Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ofb_implies + +theorem ofbFrame_sat (post : Spec.Cast5.ofbFinalSig.Post abi.ptrBits) : + ∃ s, (Spec.Cast5.ofbFinalSig.contract (abi.withConsts ecbConsts) (Spec.Cast5.ofbFinalPre abi.ptrBits) + post true (0 + 208)).pre s := by + refine ⟨frameSatC, ?_⟩ + have held := ecbSatMem_held + have hl := Proof.Cast5.s1234_length + generalize e : frameSatC = s + sig_pre [Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, abi, argRegs, ecbConsts_eq, Abi.withConsts, + Abi.constRegions, Abi.constsHeld, stackBelow, Proof.Cast5.s1234_length] + subst e + refine ⟨by decide, rfl, fun i hi => held i (by rw [hl]; exact hi), by decide, fun r hr => ?_, ?_⟩ + · change r ∈ [(⟨0x2000, 8⟩ : Region), ⟨0x3000, 0⟩] at hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl <;> exact Region.disjoint_of_sep (by decide) + · repeat' apply And.intro + all_goals first | rfl | decide | exact Or.inr rfl | exact Region.disjoint_of_sep (by decide) + +/-- `ofbFinal` with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified target (Impl.StackScratch.PPC64LE.withStackScratchWiped 208 .r8 22 ofbFinal) + (Proof.Cast5.ofbFinalRoundsContract (abi.withConsts ecbConsts) 208) := + PPC64LE.Verified.stackScratchWipedC (c₀ := (s1234Sym, s1234)) (cs := []) (sig := Spec.Cast5.ofbFinalSig) + (nm := "scratch") (e := .u64) (n := 22) (pre := Spec.Cast5.ofbFinalPre abi.ptrBits) + (post := Proof.Cast5.ofbFinalPost abi.ptrBits) (wa := true) (stack := 0) (bytes := 208) (words := 22) + ofbFinal_verified (by decide) (by decide) (by decide) + (fun vs m₁ m₂ hl _ h => Proof.Cast5.ofbFinalPre_local _ vs m₁ m₂ hl h) + (Proof.Cast5.ofbFinalPost_local _) (Proof.Cast5.ofbFinalPostOut_local _) (ofbFrame_sat _) + end VG.Proof.Cast5.PPC64LE.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalLit.lean index 64d2c6fdc30..2a8224c0b9b 100644 --- a/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Idea.PPC64LE.ModesLit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # IDEA's final CFB functions on PPC64LE, evaluated once -/ +/-! # IDEA's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Idea.PPC64LE.cfbEncryptFinal materialize_code Impl.Idea.PPC64LE.cfbDecryptFinal +materialize_code Impl.Idea.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalVerified.lean index 807a2923bd5..d8aa5a12427 100644 --- a/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Idea/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Idea.PPC64LE.FbFinal public import VerifiedGarbage.Spec.Idea.CfbFinal +public import VerifiedGarbage.Spec.Idea.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Idea.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Idea.Arith @@ -19,6 +20,7 @@ meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Idea.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.Idea.CfbFinal +meta import VerifiedGarbage.Spec.Idea.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Idea.Arith meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit @@ -28,10 +30,11 @@ meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# IDEA-CFB64 of a message's last piece on PPC64LE meets its contracts +# IDEA-CFB64 and IDEA-OFB of a message's last piece on PPC64LE meet their contracts -`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`: the modes' CFB over -a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over IDEA's +`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`, `ofbFinal_verified`: +the modes' CFB and OFB over a message's last piece +(`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, `ofbFinal_wp`) over IDEA's core (`Mode.coreSpec`), with the working space as a fifth argument (`finalContract`), as the whole-block functions are (`ModesVerified.lean`), but the data `len` bytes. Each is constant time by the taint analysis from @@ -172,4 +175,43 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .r4) (s.gpr .r5) (s.gpr .r6).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbPost).post s s' := + WP.mono (Proof.Modes.PPC64LE.ofbFinal_wp coreSpec (seqPre_of hs) (keyArgs_of hs)) fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract PPC64LE.abi finalSig "scratch" .u64 8 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 PPC64LE.abi.ptrBits) true 0 + +theorem ofbFinal_verified : Verified target ofbFinal ofbScratch := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, abi, argRegs, finalContract, ofbPost, ciph, ciphAt, modePub_iff] [modeSat] + using modeSat + +theorem ofbFrameSat_pre (post : Spec.Idea.ofbFinalSig.Post PPC64LE.abi.ptrBits) : + ∃ s, (Spec.Idea.ofbFinalSig.contract PPC64LE.abi (post := post) (writeArgs := true) (stack := 0 + 96)).pre s := by + implies_sat [Spec.Idea.ofbFinalSig, PPC64LE.abi, PPC64LE.argRegs] [modeFrameSat] using modeFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 96 .r7 8 ofbFinal) + (Spec.Idea.ofbFinalContract PPC64LE.abi 96) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Idea.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 8) (post := Proof.Modes.ofbFinalPost ciphAt 8 PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 96) (words := 8) ofbFinal_verified (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Idea.PPC64LE.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean index 17cee3b281a..6739dc07ba1 100644 --- a/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean @@ -11,9 +11,10 @@ import VerifiedGarbage.Proof.Framework.PPC64LE.Exec import VerifiedGarbage.Proof.Framework.PPC64LE.ByteStep import VerifiedGarbage.Proof.Framework.PPC64LE.Syms import VerifiedGarbage.Proof.Modes.Ctr +import VerifiedGarbage.Proof.AesOfb.Spec /-! -# CFB of a message's last piece on PPC64LE, for any core +# CFB and OFB of a message's last piece on PPC64LE, for any core `seqFinal_wp`: `c.seqFinal M`, for a core `c` with `CoreSpec c` and a mode `M` whose `pre` copies the chaining value to the buffer and whose @@ -25,7 +26,8 @@ first bytes of `CIPH_K` of the chaining value after them, and replaces the IV with that chaining value if `r = 0` and with its encryption otherwise; it keeps the registers the caller expects preserved, the stack pointer and the return address. `cfbEncFinal_wp` and `cfbDecFinal_wp` state these as CFB's -(`Spec.Cfb.EncryptFinal`, …). +(`Spec.Cfb.EncryptFinal`, …), and `ofbFinal_wp` as OFB's +(`Spec.Ofb.CryptFinal`, by `ofbFinal_of`). The loop over segments (`seg_wp`) is `seq`'s step (`Step.lean`: `regs`, `cont`, `cryptBuf`), with the data's area within the `len` bytes @@ -1164,4 +1166,62 @@ theorem cfbDecFinal_changes (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : WP.mono (seqFinal_changes_wp cs hp rfl rfl (cfbDec_post_inBounds c) (cfbDec_computes (cs.cipher_len k)) hk) fun _ h => h.2.2.2.2 +/-! ## OFB -/ + +theorem ofb_post_inBounds (c : Core) : ∀ o ∈ (Mode.ofb c.bw).post, o.InBounds (lens c (4 * c.bw)) := + fun o ho => (List.mem_append.mp ho).elim + (copyBlk_inBounds (by simp [lens]) (by simp [lens]) o) + (xorBlk_inBounds (by simp [lens]) (by simp [lens]) (by simp [lens]) o) + +/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` +whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last +`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block +(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ +theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) + (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) + (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = + Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) + (ciph (Spec.Ofb.next ciph iv (len / L)))) : + bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by + have hx := xor_flatten_outputs hc m₀ (len / L) D iv + have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] + rw [bytesAt_blocks_tail L m' D len, hblocks, htail, Spec.Ofb.cryptFinal, bytesAt_length, + blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] + split + · rename_i h0 + rw [h0, ← hx] + simp [bytesAt, Spec.Cbc.xor] + · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] + exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm + +/-- OFB of a message's last piece: `seqFinal`'s results as +`Spec.Ofb.CryptFinal`'s, for the `len` bytes at the data. -/ +theorem ofbFinal_wp (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : SeqPre c byteMode s₀) + (hk : cs.KeyArgs s₀ (wrs0 c byteMode s₀) k) : + WP isa (c.seqFinal (Mode.ofb c.bw)) s₀ fun s' => abiPreserved s₀ s' ∧ + Spec.Ofb.CryptFinal (cs.cipher k) (4 * c.bw) s₀.mem s'.mem (P s₀) (Dp s₀) (N s₀) := by + have hL0 : 0 < 4 * c.bw := Nat.mul_pos (by decide) hp.layout.bw_pos + have hxs : (wb0 c s₀).length = N s₀ / (4 * c.bw) := chunksAt_length _ _ _ _ + refine WP.mono (seqFinal_wp cs hp rfl rfl (ofb_post_inBounds c) (ofb_computes (cs.cipher_len k)) hk) + fun s' ⟨h1, h2, h3, h4⟩ => ⟨h1, ?_, ?_⟩ + · obtain ⟨e1, e2⟩ := ofb_run (cs.cipher k) (iv0 c s₀) (wb0 c s₀) + rw [← e1] at h2 + rw [← e2, hxs] at h3 + exact ofbFinal_of hL0 (cs.cipher_len k) s₀.mem s'.mem _ _ _ h2 h3 + · obtain ⟨-, e2⟩ := ofb_run (cs.cipher k) (iv0 c s₀) (wb0 c s₀) + rw [← e2, hxs] at h4 + refine h4.trans ?_ + rw [blockCount_eq hL0] + split + · rfl + · exact (AesOfb.next_succ _ _ _).symm + +/-- What OFB of a message's last piece changes. -/ +theorem ofbFinal_changes (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : SeqPre c byteMode s₀) + (hk : cs.KeyArgs s₀ (wrs0 c byteMode s₀) k) : + WP isa (c.seqFinal (Mode.ofb c.bw)) s₀ (Changes c byteMode s₀) := + WP.mono (seqFinal_changes_wp cs hp rfl rfl (ofb_post_inBounds c) (ofb_computes (cs.cipher_len k)) hk) + fun _ h => h.2.2.2.2 + end VG.Proof.Modes.PPC64LE diff --git a/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalLit.lean index de854d95c27..25a29047878 100644 --- a/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Seed.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # SEED's final CFB functions on PPC64LE, evaluated once -/ +/-! # SEED's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG materialize_code Impl.Seed.PPC64LE.cfbEncryptFinal materialize_code Impl.Seed.PPC64LE.cfbDecryptFinal +materialize_code Impl.Seed.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalVerified.lean index df4067b8776..ba4061d4af6 100644 --- a/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Seed/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Seed.PPC64LE.FbFinal public import VerifiedGarbage.Spec.Seed.CfbFinal +public import VerifiedGarbage.Spec.Seed.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Seed.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Seed.PPC64LE.Lit @@ -25,6 +26,7 @@ meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Seed.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.Seed.CfbFinal +meta import VerifiedGarbage.Spec.Seed.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.PPC64LE.SlotTaint @@ -35,10 +37,11 @@ meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# SEED-CFB128 of a message's last piece on PPC64LE meets its contracts +# SEED-CFB128 and SEED-OFB of a message's last piece on PPC64LE meet their contracts -`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`: the modes' CFB over -a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over +`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`, `ofbFinal_verified`: +the modes' CFB and OFB over a message's last piece +(`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, `ofbFinal_wp`) over SEED's core (`Mode.dirCoreSpec`), with the working space as a fifth argument (`finalContract`), as the whole-block functions are (`ModesVerified.lean`), but the data `len` bytes. Each is constant time by the @@ -218,4 +221,45 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .r4) (s.gpr .r5) (s.gpr .r6).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbPost).post s s' := + WP.mono (Proof.Modes.PPC64LE.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hs) (keyArgs_of hs)) + fun _ ⟨h1, h2⟩ => by simp only [cipher_enc] at h2; exact ⟨h1, h2⟩ + +theorem ofbFinal_constantTime {post : State → State → Prop} : + ConstantTime isa (finalContract post).pre modePub ofbFinal := + VG.Taint.constantTime_of_exists (A := slotTaint) modeTaint final_agree (by taint_decide_sum [encryptSum]) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract PPC64LE.abi finalSig "scratch" .u64 144 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 PPC64LE.abi.ptrBits) true 0 + +theorem ofbFinal_verified : Verified target ofbFinal ofbScratch := by + refine Verified.of_correct ofbFinal_correct ofbFinal_constantTime ?_ + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, abi, argRegs, finalContract, ofbPost, ciph, ciphAt, modePub_iff] [modeSat] + using modeSat + +theorem ofbFrameSat_pre (post : Spec.Seed.ofbFinalSig.Post PPC64LE.abi.ptrBits) : + ∃ s, (Spec.Seed.ofbFinalSig.contract PPC64LE.abi (post := post) (writeArgs := true) + (stack := 0 + 1184)).pre s := by + implies_sat [Spec.Seed.ofbFinalSig, PPC64LE.abi, PPC64LE.argRegs] [modeFrameSat] using modeFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 1184 .r7 144 ofbFinal) + (Spec.Seed.ofbFinalContract PPC64LE.abi 1184) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Seed.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 144) (post := Proof.Modes.ofbFinalPost ciphAt 16 PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 1184) (words := 144) ofbFinal_verified (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Seed.PPC64LE.FbFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalLit.lean index 5712aa3bf43..6a8d867b2b3 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Sm4.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # SM4's final CFB functions on PPC64LE, evaluated once -/ +/-! # SM4's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG materialize_code Impl.Sm4.PPC64LE.cfbEncryptFinal materialize_code Impl.Sm4.PPC64LE.cfbDecryptFinal +materialize_code Impl.Sm4.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalVerified.lean index c873df2097b..3d7454e66c2 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.Sm4.PPC64LE.FbFinal public import VerifiedGarbage.Spec.Sm4.CfbFinal +public import VerifiedGarbage.Spec.Sm4.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Sm4.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.Sm4.PPC64LE.Lit @@ -25,6 +26,7 @@ meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.Sm4.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.Sm4.CfbFinal +meta import VerifiedGarbage.Spec.Sm4.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.PPC64LE.SlotTaint @@ -35,10 +37,11 @@ meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# SM4-CFB128 of a message's last piece on PPC64LE meets its contracts +# SM4-CFB128 and SM4-OFB of a message's last piece on PPC64LE meet their contracts -`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`: the modes' CFB over -a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over +`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`, `ofbFinal_verified`: +the modes' CFB and OFB over a message's last piece +(`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, `ofbFinal_wp`) over SM4's core (`Mode.dirCoreSpec`), with the working space as a fifth argument (`finalContract`), as the whole-block functions are (`ModesVerified.lean`), but the data `len` bytes. Each is constant time by the @@ -177,4 +180,46 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .r4) (s.gpr .r5) (s.gpr .r6).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbPost).post s s' := + WP.mono (Proof.Modes.PPC64LE.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hs) (keyArgs_of hs)) + fun _ ⟨h1, h2⟩ => by simp only [cipher_enc] at h2; exact ⟨h1, h2⟩ + +theorem ofbFinal_constantTime {post : State → State → Prop} : + ConstantTime isa (finalContract post).pre modePub ofbFinal := + VG.Taint.constantTime_of_exists (A := slotTaint) modeTaint modes_agree + (by taint_decide_sum [prepSum, cryptSum]) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract PPC64LE.abi finalSig "scratch" .u64 408 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 16 PPC64LE.abi.ptrBits) true 0 + +theorem ofbFinal_verified : Verified target ofbFinal ofbScratch := by + refine Verified.of_correct ofbFinal_correct ofbFinal_constantTime ?_ + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, abi, argRegs, finalContract, modeContract, ofbPost, ciph, ciphAt, modePub_iff, slots_eq, Nat.one_mul] [modeSat] + using modeSat + +theorem ofbFrameSat_pre (post : Spec.Sm4.ofbFinalSig.Post PPC64LE.abi.ptrBits) : + ∃ s, (Spec.Sm4.ofbFinalSig.contract PPC64LE.abi (post := post) (writeArgs := true) + (stack := 0 + 3296)).pre s := by + implies_sat [Spec.Sm4.ofbFinalSig, PPC64LE.abi, PPC64LE.argRegs] [modeFrameSat] using modeFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 3296 .r7 408 ofbFinal) + (Spec.Sm4.ofbFinalContract PPC64LE.abi 3296) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Sm4.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 408) (post := Proof.Modes.ofbFinalPost ciphAt 16 PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 3296) (words := 408) ofbFinal_verified (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.Sm4.PPC64LE.FbFinal diff --git a/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalLit.lean index 76cccbe8bc0..70f3b4f6644 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.TripleDes.PPC64LE.FunctionsLit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit -/-! # Triple DES's final CFB functions on PPC64LE, evaluated once -/ +/-! # Triple DES's final CFB and OFB functions on PPC64LE, evaluated once -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG materialize_code Impl.TripleDes.PPC64LE.cfbEncryptFinal materialize_code Impl.TripleDes.PPC64LE.cfbDecryptFinal +materialize_code Impl.TripleDes.PPC64LE.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalVerified.lean index 3c625451a03..e29ddd6edee 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/PPC64LE/FbFinalVerified.lean @@ -6,6 +6,7 @@ public import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal public import VerifiedGarbage.Proof.Modes.CfbFinalScratch public import VerifiedGarbage.Impl.TripleDes.PPC64LE.FbFinal public import VerifiedGarbage.Spec.TripleDes.CfbFinal +public import VerifiedGarbage.Spec.TripleDes.OfbFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.TripleDes.PPC64LE.FbFinalLit import VerifiedGarbage.Proof.TripleDes.PPC64LE.FunctionsLit @@ -22,6 +23,7 @@ meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal meta import VerifiedGarbage.Proof.Modes.CfbFinalScratch meta import VerifiedGarbage.Impl.TripleDes.PPC64LE.FbFinal meta import VerifiedGarbage.Spec.TripleDes.CfbFinal +meta import VerifiedGarbage.Spec.TripleDes.OfbFinal meta import VerifiedGarbage.Proof.Framework.Scratch meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit meta import VerifiedGarbage.Proof.Framework.PPC64LE.Taint @@ -30,10 +32,11 @@ meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.RegSet /-! -# Triple DES-CFB64 of a message's last piece on PPC64LE meets its contracts +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on PPC64LE meet their contracts -`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`: the modes' CFB over -a message's last piece (`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …) over +`cfbEncryptFinal_verified`, `cfbDecryptFinal_verified`, `ofbFinal_verified`: +the modes' CFB and OFB over a message's last piece +(`Proof.Modes.PPC64LE.cfbEncFinal_wp`, …, `ofbFinal_wp`) over Triple DES's core (`Mode.dirCoreSpec`), with the working space as a fifth argument (`finalContract`), as the whole-block functions are (`ModesVerified.lean`), but the data `len` bytes. Each is constant time by the @@ -181,4 +184,45 @@ theorem cfbDecryptFinal_framed : (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (Proof.Modes.decFinalPostIn_local _ ciphAt_congr) (Proof.Modes.decFinalPost_local _) (frameSat_pre _) +/-! ## OFB of a message's last piece -/ + +/-- The final OFB function's postcondition. -/ +def ofbPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .r4) (s.gpr .r5) (s.gpr .r6).toNat + +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbPost).post s s' := + WP.mono (Proof.Modes.PPC64LE.ofbFinal_wp (dirCoreSpec .encrypt) (seqPre_of hs) (keyArgs_of hs)) + fun _ ⟨h1, h2⟩ => ⟨h1, h2⟩ + +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + +/-- The final OFB function's contract with the working space as an argument. -/ +abbrev ofbScratch : Contract isa := + Sig.scratchContract PPC64LE.abi finalSig "scratch" .u64 72 (Curry.const (fun _ => True) _) + (Proof.Modes.ofbFinalPost ciphAt 8 PPC64LE.abi.ptrBits) true 0 + +theorem ofbFinal_verified : Verified target ofbFinal ofbScratch := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + sig_implies [Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, Proof.Modes.finalSig, + Proof.Modes.ofbFinalPost, abi, argRegs, finalContract, ofbPost, ciph, ciphAt, modePub_iff] [modeSat] + using modeSat + +theorem ofbFrameSat_pre (post : Spec.TripleDes.ofbFinalSig.Post PPC64LE.abi.ptrBits) : + ∃ s, (Spec.TripleDes.ofbFinalSig.contract PPC64LE.abi (post := post) (writeArgs := true) + (stack := 0 + 608)).pre s := by + implies_sat [Spec.TripleDes.ofbFinalSig, PPC64LE.abi, PPC64LE.argRegs] [modeFrameSat] using modeFrameSat + +/-- The final OFB function with its working space on the stack. -/ +theorem ofbFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 608 .r7 72 ofbFinal) + (Spec.TripleDes.ofbFinalContract PPC64LE.abi 608) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.TripleDes.ofbFinalSig) (nm := "scratch") (e := .u64) + (n := 72) (post := Proof.Modes.ofbFinalPost ciphAt 8 PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 608) (words := 72) ofbFinal_verified (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) + (Proof.Modes.ofbFinalPostIn_local _ ciphAt_congr) (Proof.Modes.ofbFinalPost_local _) (ofbFrameSat_pre _) + end VG.Proof.TripleDes.PPC64LE.FbFinal From 80fec1fbd87d8418f6e86c0526e34f40e5957d4e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:35:19 +0000 Subject: [PATCH 06/18] OFB final functions on RISC-V for Blowfish, Camellia, CAST5, IDEA, SEED, SM4 and Triple DES (WIP: crates to come) RISC-V's seqFinal with OFB's mode; its proof (ofbFinal_wp) in Proof/Modes/RISCV64/SeqFinal.lean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/BlowfishOfb/RISCV64.lean | 8 ++- .../Artifacts/CamelliaOfb/RISCV64.lean | 8 ++- .../Artifacts/Cast5Ofb/RISCV64.lean | 8 ++- .../Artifacts/IdeaOfb/RISCV64.lean | 8 ++- .../Artifacts/SeedOfb/RISCV64.lean | 8 ++- .../Artifacts/Sm4Ofb/RISCV64.lean | 8 ++- .../Artifacts/TripleDesOfb/RISCV64.lean | 8 ++- .../Impl/Blowfish/RISCV64/FbFinal.lean | 9 ++- .../Impl/Camellia/RISCV64/FbFinal.lean | 9 ++- .../Impl/Cast5/RISCV64/FbFinal.lean | 9 ++- .../Impl/Idea/RISCV64/FbFinal.lean | 9 ++- .../Impl/Seed/RISCV64/FbFinal.lean | 9 ++- .../Impl/Sm4/RISCV64/FbFinal.lean | 9 ++- .../Impl/TripleDes/RISCV64/FbFinal.lean | 9 ++- .../Proof/Blowfish/RISCV64/FbFinalLit.lean | 3 +- .../Blowfish/RISCV64/FbFinalVerified.lean | 25 ++++++++- .../Proof/Camellia/RISCV64/FbFinalLit.lean | 3 +- .../Camellia/RISCV64/FbFinalVerified.lean | 36 ++++++++++-- .../Proof/Cast5/RISCV64/FbFinalLit.lean | 3 +- .../Proof/Cast5/RISCV64/FbFinalVerified.lean | 39 +++++++++++-- .../Proof/Idea/RISCV64/FbFinalLit.lean | 3 +- .../Proof/Idea/RISCV64/FbFinalVerified.lean | 25 ++++++++- .../Proof/Modes/RISCV64/SeqFinal.lean | 55 ++++++++++++++++++- .../Proof/Seed/RISCV64/FbFinalLit.lean | 3 +- .../Proof/Seed/RISCV64/FbFinalVerified.lean | 25 ++++++++- .../Proof/Sm4/RISCV64/FbFinalLit.lean | 3 +- .../Proof/Sm4/RISCV64/FbFinalVerified.lean | 25 ++++++++- .../Proof/TripleDes/RISCV64/FbFinalLit.lean | 3 +- .../TripleDes/RISCV64/FbFinalVerified.lean | 25 ++++++++- 29 files changed, 334 insertions(+), 61 deletions(-) diff --git a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/RISCV64.lean index ec00c546705..69735c16e1c 100644 --- a/lean/VerifiedGarbage/Artifacts/BlowfishOfb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/BlowfishOfb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Blowfish.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Blowfish.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Blowfish.RISCV64.ModesLit +import VerifiedGarbage.Proof.Blowfish.RISCV64.FbFinalLit /-! # Blowfish-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Blowfish.ofbApi.artifact RISCV64.target { code := Impl.Blowfish.RISCV64.ofb stack := 4224 - verified := Proof.Blowfish.RISCV64.Modes.ofb_verified }] + verified := Proof.Blowfish.RISCV64.Modes.ofb_verified }, + Spec.Blowfish.ofbFinalApi.artifact RISCV64.target { + code := Impl.Blowfish.RISCV64.ofbFinal + stack := 4224 + verified := Proof.Blowfish.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.BlowfishOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/RISCV64.lean index ce47cb1f638..3c77bdef0cb 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaOfb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaOfb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Camellia.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Camellia.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Camellia.RISCV64.ModesLit +import VerifiedGarbage.Proof.Camellia.RISCV64.FbFinalLit /-! # Camellia-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ofbApi.artifact RISCV64.target { code := Impl.Camellia.RISCV64.ofb stack := 3248 - verified := Proof.Camellia.RISCV64.Modes.ofb_verified }] + verified := Proof.Camellia.RISCV64.Modes.ofb_verified }, + Spec.Camellia.ofbFinalApi.artifact RISCV64.target { + code := Impl.Camellia.RISCV64.ofbFinal + stack := 3248 + verified := Proof.Camellia.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.CamelliaOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/RISCV64.lean index 80088746ff7..1b65e4575d3 100644 --- a/lean/VerifiedGarbage/Artifacts/Cast5Ofb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/Cast5Ofb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Cast5.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Cast5.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Cast5.RISCV64.ModesLit +import VerifiedGarbage.Proof.Cast5.RISCV64.FbFinalLit /-! # CAST5-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Cast5.ofbApi.artifact RISCV64.target { code := Impl.Cast5.RISCV64.ofb stack := 128 - verified := Proof.Cast5.ofb_keyed Proof.Cast5.RISCV64.Modes.ofb_verified }] + verified := Proof.Cast5.ofb_keyed Proof.Cast5.RISCV64.Modes.ofb_verified }, + Spec.Cast5.ofbFinalApi.artifact RISCV64.target { + code := Impl.Cast5.RISCV64.ofbFinal + stack := 128 + verified := Proof.Cast5.ofbFinal_keyed Proof.Cast5.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.Cast5Ofb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/IdeaOfb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/IdeaOfb/RISCV64.lean index 0474d8a654e..28883eebe45 100644 --- a/lean/VerifiedGarbage/Artifacts/IdeaOfb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/IdeaOfb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Idea.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Idea.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Idea.RISCV64.ModesLit +import VerifiedGarbage.Proof.Idea.RISCV64.FbFinalLit /-! # IDEA-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Idea.ofbApi.artifact RISCV64.target { code := Impl.Idea.RISCV64.ofb stack := 64 - verified := Proof.Idea.RISCV64.Modes.ofb_verified }] + verified := Proof.Idea.RISCV64.Modes.ofb_verified }, + Spec.Idea.ofbFinalApi.artifact RISCV64.target { + code := Impl.Idea.RISCV64.ofbFinal + stack := 64 + verified := Proof.Idea.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.IdeaOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/SeedOfb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/SeedOfb/RISCV64.lean index 38084a03089..c3e86c053fd 100644 --- a/lean/VerifiedGarbage/Artifacts/SeedOfb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/SeedOfb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Seed.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Seed.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Seed.RISCV64.ModesLit +import VerifiedGarbage.Proof.Seed.RISCV64.FbFinalLit /-! # SEED-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Seed.ofbApi.artifact RISCV64.target { code := Impl.Seed.RISCV64.ofb stack := 1104 - verified := Proof.Seed.RISCV64.Modes.ofb_verified }] + verified := Proof.Seed.RISCV64.Modes.ofb_verified }, + Spec.Seed.ofbFinalApi.artifact RISCV64.target { + code := Impl.Seed.RISCV64.ofbFinal + stack := 1104 + verified := Proof.Seed.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.SeedOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/RISCV64.lean index 1fde9f55512..fd16be39252 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ofb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ofb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.Sm4.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Sm4.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Sm4.RISCV64.ModesLit +import VerifiedGarbage.Proof.Sm4.RISCV64.FbFinalLit /-! # SM4-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ofbApi.artifact RISCV64.target { code := Impl.Sm4.RISCV64.ofb stack := 3232 - verified := Proof.Sm4.RISCV64.Modes.ofb_verified }] + verified := Proof.Sm4.RISCV64.Modes.ofb_verified }, + Spec.Sm4.ofbFinalApi.artifact RISCV64.target { + code := Impl.Sm4.RISCV64.ofbFinal + stack := 3232 + verified := Proof.Sm4.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.Sm4Ofb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/RISCV64.lean index e9d91fe1f81..105ea12f70d 100644 --- a/lean/VerifiedGarbage/Artifacts/TripleDesOfb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/TripleDesOfb/RISCV64.lean @@ -1,9 +1,11 @@ module public import VerifiedGarbage.Proof.TripleDes.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.TripleDes.RISCV64.FbFinalVerified public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.TripleDes.RISCV64.ModesLit +import VerifiedGarbage.Proof.TripleDes.RISCV64.FbFinalLit /-! # Triple DES-OFB artifacts on baseline RISC-V -/ @@ -15,6 +17,10 @@ def artifacts : List Artifact := [ Spec.TripleDes.ofbApi.artifact RISCV64.target { code := Impl.TripleDes.RISCV64.ofb stack := 944 - verified := Proof.TripleDes.RISCV64.Modes.ofb_verified }] + verified := Proof.TripleDes.RISCV64.Modes.ofb_verified }, + Spec.TripleDes.ofbFinalApi.artifact RISCV64.target { + code := Impl.TripleDes.RISCV64.ofbFinal + stack := 944 + verified := Proof.TripleDes.RISCV64.Modes.ofbFinal_verified }] end VG.Artifacts.TripleDesOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Blowfish/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Blowfish/RISCV64/FbFinal.lean index 2aadf6a7d13..737b752f509 100644 --- a/lean/VerifiedGarbage/Impl/Blowfish/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Blowfish/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Blowfish.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# Blowfish-CFB64 of a message's last piece on RISC-V +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, iv = a1, data = a2, -len = a3): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, iv = a1, data = a2, +len = a3): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over Blowfish's one-block encryption core (`Modes.lean`), in its frame. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.cfbEnc 2) /-- `vg_blowfish_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_blowfish_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore true).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Blowfish.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Camellia/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/RISCV64/FbFinal.lean index f84b1607fe8..3cd7f1b1e78 100644 --- a/lean/VerifiedGarbage/Impl/Camellia/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Camellia/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Camellia.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# Camellia-CFB128 of a message's last piece on RISC-V +# Camellia-CFB128 and Camellia-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, rounds = a1, -iv = a2, data = a3, len = a4): `modeFn` of the modes' CFB over a message's +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, rounds = a1, +iv = a2, data = a3, len = a4): `modeFn` of the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over Camellia's encryption core with the rounds `rounds` says (`Modes.lean`), in its frame. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := modeFn fun R => (dirCore .encrypt R).seqFinal /-- `vg_camellia_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := modeFn fun R => (dirCore .encrypt R).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_camellia_ofb_final`. -/ +def ofbFinal : Prog isa := modeFn fun R => (dirCore .encrypt R).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Camellia.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Cast5/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Cast5/RISCV64/FbFinal.lean index 6f6e7f622a9..8a230cc3668 100644 --- a/lean/VerifiedGarbage/Impl/Cast5/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Cast5/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Cast5.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# CAST5-CFB64 of a message's last piece on RISC-V +# CAST5-CFB64 and CAST5-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, rounds = a1, -iv = a2, data = a3, len = a4): `modeFn` of the modes' CFB over a message's +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, rounds = a1, +iv = a2, data = a3, len = a4): `modeFn` of the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over CAST5's encryption core with the rounds `rounds` says (`Modes.lean`), in its frame. @@ -25,4 +25,7 @@ def cfbEncryptFinal : Prog isa := modeFn fun n => (dirCore true n).seqFinal (Mod /-- `vg_cast5_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := modeFn fun n => (dirCore true n).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_cast5_ofb_final`. -/ +def ofbFinal : Prog isa := modeFn fun n => (dirCore true n).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Cast5.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Idea/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Idea/RISCV64/FbFinal.lean index b8970410505..e5b0f7e3ae1 100644 --- a/lean/VerifiedGarbage/Impl/Idea/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Idea/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Idea.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# IDEA-CFB64 of a message's last piece on RISC-V +# IDEA-CFB64 and IDEA-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, iv = a1, data = a2, -len = a3): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, iv = a1, data = a2, +len = a3): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over IDEA's core (`Modes.lean`), in the whole-block functions' frame. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := core.seqFinal (Modes.Mode.cfbEnc 2) /-- `vg_idea_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := core.seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_idea_ofb_final`. -/ +def ofbFinal : Prog isa := core.seqFinal (Modes.Mode.ofb 2) + end VG.Impl.Idea.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Seed/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Seed/RISCV64/FbFinal.lean index 03deb0baaa5..8d7bd7382f0 100644 --- a/lean/VerifiedGarbage/Impl/Seed/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Seed/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Seed.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# SEED-CFB128 of a message's last piece on RISC-V +# SEED-CFB128 and SEED-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, iv = a1, data = a2, -len = a3): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, iv = a1, data = a2, +len = a3): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over Seed's one-block encryption core (`Modes.lean`), in its frame. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt 1).seqFinal (Modes.Mode.cfbE /-- `vg_seed_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt 1).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_seed_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt 1).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Seed.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Sm4/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/RISCV64/FbFinal.lean index e3933eee708..244face5e45 100644 --- a/lean/VerifiedGarbage/Impl/Sm4/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/Sm4/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.Sm4.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# SM4-CFB128 of a message's last piece on RISC-V +# SM4-CFB128 and SM4-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, iv = a1, data = a2, -len = a3): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, iv = a1, data = a2, +len = a3): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over Sm4's one-block encryption core (`Modes.lean`), in its frame. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_sm4_cfb128_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 4) +/-- `vg_sm4_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 4) + end VG.Impl.Sm4.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/TripleDes/RISCV64/FbFinal.lean b/lean/VerifiedGarbage/Impl/TripleDes/RISCV64/FbFinal.lean index 082c002d1fd..d9a0e4e01a8 100644 --- a/lean/VerifiedGarbage/Impl/TripleDes/RISCV64/FbFinal.lean +++ b/lean/VerifiedGarbage/Impl/TripleDes/RISCV64/FbFinal.lean @@ -4,10 +4,10 @@ public import VerifiedGarbage.Impl.TripleDes.RISCV64.Modes public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal /-! -# Triple DES-CFB64 of a message's last piece on RISC-V +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on RISC-V -`cfbEncryptFinal` and `cfbDecryptFinal` (schedule = a0, iv = a1, data = a2, -len = a3): the modes' CFB over a message's last piece, of any length +`cfbEncryptFinal`, `cfbDecryptFinal` and `ofbFinal` (schedule = a0, iv = a1, data = a2, +len = a3): the modes' CFB and OFB over a message's last piece, of any length (`Impl/Modes/RISCV64/SeqFinal.lean`), over TripleDes's one-block encryption core (`Modes.lean`), in its frame. -/ @@ -24,4 +24,7 @@ def cfbEncryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbEnc /-- `vg_triple_des_cfb64_decrypt_final`. -/ def cfbDecryptFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.cfbDec 2) +/-- `vg_triple_des_ofb_final`. -/ +def ofbFinal : Prog isa := (dirCore .encrypt).seqFinal (Modes.Mode.ofb 2) + end VG.Impl.TripleDes.RISCV64 diff --git a/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalLit.lean index a1353526b49..9f3b38c67d4 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit -/-! # Blowfish's final CFB functions on RISC-V, evaluated once -/ +/-! # Blowfish's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG materialize_code Impl.Blowfish.RISCV64.cfbEncryptFinal materialize_code Impl.Blowfish.RISCV64.cfbDecryptFinal +materialize_code Impl.Blowfish.RISCV64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalVerified.lean index feab9f2e42b..6f92f3407ed 100644 --- a/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Blowfish/RISCV64/FbFinalVerified.lean @@ -4,6 +4,7 @@ public import VerifiedGarbage.Proof.Blowfish.RISCV64.ModesVerified public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.Blowfish.RISCV64.FbFinal public import VerifiedGarbage.Spec.Blowfish.CfbFinal +public import VerifiedGarbage.Spec.Blowfish.OfbFinal import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint import VerifiedGarbage.Proof.Framework.Lit @@ -12,16 +13,17 @@ meta import VerifiedGarbage.Proof.Blowfish.RISCV64.ModesVerified meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.Blowfish.RISCV64.FbFinal meta import VerifiedGarbage.Spec.Blowfish.CfbFinal +meta import VerifiedGarbage.Spec.Blowfish.OfbFinal meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Blowfish.RISCV64.FbFinalLit /-! -# Blowfish-CFB64 of a message's last piece on RISC-V meets its contracts +# Blowfish-CFB64 and Blowfish-OFB of a message's last piece on RISC-V meet their contracts -The modes' CFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, -`cfbDecFinal_wp`) over Blowfish's one-block encryption core meets the contracts, +The modes' CFB and OFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over Blowfish's one-block encryption core meet the contracts, with `stack := 4224`, that core's frame (`ModesVerified.lean`), whose precondition, with the data `len` bytes, is `seq`'s for the data a byte at a time (`byteMode`). Constant time as the whole-block functions. @@ -41,6 +43,8 @@ def encFinalPost (s s' : State) : Prop := Spec.Cfb.EncryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat /-- A final function on RISC-V, with its frame below the stack pointer, the data `len` bytes, and the postcondition `post`. -/ @@ -93,6 +97,11 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalContract decFinalPost).p WP.mono (Proof.Modes.RISCV64.cfbDecFinal_wp (dirCoreSpec true) (seqPreF_of hs) (keyArgsF_of hs)) fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbFinalPost).post s s' := + WP.mono (Proof.Modes.RISCV64.ofbFinal_wp (dirCoreSpec true) (seqPreF_of hs) (keyArgsF_of hs)) + fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -103,6 +112,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + /-! ## The contracts -/ theorem cfbEncryptFinal_verified : @@ -117,4 +130,10 @@ theorem cfbDecryptFinal_verified : contract_implies [Spec.Blowfish.cfbDecryptFinalContract, Spec.Blowfish.cfbFinalSig, RISCV64.abi, RISCV64.argRegs, finalContract, decFinalPost, modePub_iff] [modeSat] using modeSat +theorem ofbFinal_verified : + Verified RISCV64.target ofbFinal (Spec.Blowfish.ofbFinalContract RISCV64.abi (frameBytes)) := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + contract_implies [Spec.Blowfish.ofbFinalContract, Spec.Blowfish.ofbFinalSig, RISCV64.abi, + RISCV64.argRegs, finalContract, ofbFinalPost, modePub_iff] [modeSat] using modeSat + end VG.Proof.Blowfish.RISCV64.Modes diff --git a/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalLit.lean index 9c658a9172e..e578c39af5f 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit meta import VerifiedGarbage.Proof.Camellia.RISCV64.ModesLit -/-! # Camellia's final CFB functions on RISC-V, evaluated once -/ +/-! # Camellia's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Camellia.RISCV64.cfbEncryptFinal materialize_code Impl.Camellia.RISCV64.cfbDecryptFinal +materialize_code Impl.Camellia.RISCV64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalVerified.lean index d0c1781f4a8..8940815f014 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/RISCV64/FbFinalVerified.lean @@ -4,6 +4,7 @@ public import VerifiedGarbage.Proof.Camellia.RISCV64.ModesVerified public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.Camellia.RISCV64.FbFinal public import VerifiedGarbage.Spec.Camellia.CfbFinal +public import VerifiedGarbage.Spec.Camellia.OfbFinal import VerifiedGarbage.Proof.Camellia.CfbFinalScratch import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint @@ -13,6 +14,7 @@ meta import VerifiedGarbage.Proof.Camellia.RISCV64.ModesVerified meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.Camellia.RISCV64.FbFinal meta import VerifiedGarbage.Spec.Camellia.CfbFinal +meta import VerifiedGarbage.Spec.Camellia.OfbFinal meta import VerifiedGarbage.Proof.Camellia.CfbFinalScratch meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint @@ -20,12 +22,13 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Camellia.RISCV64.FbFinalLit /-! -# Camellia-CFB128 of a message's last piece on RISC-V meets its contracts +# Camellia-CFB128 and Camellia-OFB of a message's last piece on RISC-V meet their contracts -`modeFn` (`ModesVerified.lean`) of the modes' CFB over a message's last -piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, `cfbDecFinal_wp`) over -Camellia's encryption core (`Mode.dirCoreSpec`) meets the contracts on the -subkeys, and so the specification's (`Proof.Camellia.cfbEncryptFinal_of_sk`), +`modeFn` (`ModesVerified.lean`) of the modes' CFB and OFB over a message's +last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, `cfbDecFinal_wp`, +`ofbFinal_wp`) over Camellia's encryption core (`Mode.dirCoreSpec`) meet the +contracts on the subkeys, and so the specification's +(`Proof.Camellia.cfbEncryptFinal_of_sk`, …, `Proof.Camellia.ofbFinal_of_sk`), with `stack := 3248`, the whole-block functions' frame, whose precondition, with the data `len` bytes, is `seq`'s for the data a byte at a time (`byteMode`). Constant time as the whole-block functions. @@ -46,6 +49,8 @@ def encFinalPost (s s' : State) : Prop := Spec.Cfb.EncryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a2) (s.gpr .a3) (s.gpr .a4).toNat def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a2) (s.gpr .a3) (s.gpr .a4).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a2) (s.gpr .a3) (s.gpr .a4).toNat /-- A final function on RISC-V, with its frame below the stack pointer, the data `len` bytes, and the postcondition `post`. -/ @@ -136,6 +141,15 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalContract decFinalPost).p rw [bw_eq, cipher_enc, e1, e2, e3, h₁.mem] at h2 exact h2 +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbFinalPost).post s s' := by + refine modeFn_wp (roundsF_of hs) fun s₁ h₁ => WP.mono (Proof.Modes.RISCV64.ofbFinal_wp + (dirCoreSpec .encrypt _ (roundsF_of hs)) (seqPreF_of hs h₁ .encrypt _) (keyArgsF_of hs h₁ .encrypt _)) + fun s' ⟨h1, h2, _⟩ => ⟨h₁.abi h1, fun _ => ?_⟩ + obtain ⟨e1, e2, e3⟩ := argsF_eq h₁ + rw [bw_eq, cipher_enc, e1, e2, e3, h₁.mem] at h2 + exact h2 + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -146,6 +160,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4]) (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + /-! ## The contracts -/ theorem cfbEncryptFinal_verified : @@ -164,4 +182,12 @@ theorem cfbDecryptFinal_verified : Proof.Camellia.cfbDecryptFinalPostSk, RISCV64.abi, RISCV64.argRegs, finalContract, decFinalPost, modePub_iff] [modeSat] using modeSat +theorem ofbFinal_verified : + Verified RISCV64.target ofbFinal (Spec.Camellia.ofbFinalContract RISCV64.abi frameBytes) := + Proof.Camellia.ofbFinal_of_sk <| by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + contract_implies [Proof.Camellia.ofbFinalContractSk, Spec.Camellia.ofbFinalSig, Spec.Camellia.ofbFinalPre, + Proof.Camellia.ofbFinalPostSk, RISCV64.abi, RISCV64.argRegs, finalContract, ofbFinalPost, modePub_iff] + [modeSat] using modeSat + end VG.Proof.Camellia.RISCV64.Modes diff --git a/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalLit.lean index b91affc84a4..646db351be7 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalLit.lean @@ -12,7 +12,7 @@ meta import VerifiedGarbage.Proof.Framework.RegionsSub meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit -/-! # CAST5's final CFB functions on RISC-V, evaluated once -/ +/-! # CAST5's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -20,5 +20,6 @@ namespace VG.Impl.Cast5.RISCV64 materialize_code cfbEncryptFinal materialize_code cfbDecryptFinal +materialize_code ofbFinal end VG.Impl.Cast5.RISCV64 diff --git a/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalVerified.lean index d70608f00d6..d23b7f0669c 100644 --- a/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Cast5/RISCV64/FbFinalVerified.lean @@ -5,6 +5,7 @@ public import VerifiedGarbage.Proof.Cast5.CfbFinal public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.Cast5.RISCV64.FbFinal public import VerifiedGarbage.Spec.Cast5.CfbFinal +public import VerifiedGarbage.Spec.Cast5.OfbFinal import VerifiedGarbage.Proof.Cast5.Table import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint @@ -15,6 +16,7 @@ meta import VerifiedGarbage.Proof.Cast5.CfbFinal meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.Cast5.RISCV64.FbFinal meta import VerifiedGarbage.Spec.Cast5.CfbFinal +meta import VerifiedGarbage.Spec.Cast5.OfbFinal meta import VerifiedGarbage.Proof.Cast5.Table meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint @@ -22,12 +24,13 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Cast5.RISCV64.FbFinalLit /-! -# CAST5-CFB64 of a message's last piece on RISC-V meets its contracts +# CAST5-CFB64 and CAST5-OFB of a message's last piece on RISC-V meet their contracts -`modeFn` (`ModesVerified.lean`) of the modes' CFB over a message's last -piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, `cfbDecFinal_wp`) over CAST5's -encryption core (`Mode.dirCoreSpec`) meets the contracts with the count of -rounds (`Proof.Cast5.cfbEncryptFinalRoundsContract`, …) with `stack := 128`, +`modeFn` (`ModesVerified.lean`) of the modes' CFB and OFB over a message's +last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, `cfbDecFinal_wp`, +`ofbFinal_wp`) over CAST5's encryption core (`Mode.dirCoreSpec`) meet the +contracts with the count of rounds (`Proof.Cast5.cfbEncryptFinalRoundsContract`, +…, `Proof.Cast5.ofbFinalRoundsContract`) with `stack := 128`, the whole-block functions' frame, under the calling convention with the table, as the whole-block functions do: the proof's contract (`finalPC`) is `finalP` for the state without the table's region, whose precondition, with @@ -75,6 +78,9 @@ def encFinalPost (s s' : State) : Prop := def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (Spec.Cast5.cipher (keyOf s) (rounds s)) 8 s.mem s'.mem (s.gpr .a2) (s.gpr .a3) (s.gpr .a4).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (Spec.Cast5.cipher (keyOf s) (rounds s)) 8 s.mem s'.mem (s.gpr .a2) (s.gpr .a3) + (s.gpr .a4).toNat section variable {post : State → State → Prop} {s s₁ : State} (hs : (finalPC post).pre s) (h₁ : Shifted s s₁) @@ -168,6 +174,16 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalPC decFinalPost).pre s) rw [e1, e2, e3, h₁.mem] at h2 exact h2 +theorem ofbFinal_correct (s : State) (hs : (finalPC ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ ofbFinalPost s s' := by + refine modeFn_wp (roundsF_of hs) fun s₁ h₁ => WP.mono (Proof.Modes.RISCV64.ofbFinal_wp + (dirCoreSpec true _ (roundsF_of hs)) (seqPreF_of hs h₁ true) (keyArgsF_of hs h₁ true)) + fun s' ⟨h1, h2, _⟩ => ⟨h₁.abi h1, ?_⟩ + obtain ⟨e1, e2, e3⟩ := argsF_eq h₁ + simp only [dirCore, dirCoreSpec, Proof.Cast5.dirCipher, ↓reduceIte] at h2 + rw [e1, e2, e3, h₁.mem] at h2 + exact h2 + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -178,6 +194,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taintSym [s1234Sym]) (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4]) (fun _ _ _ _ hp => modes_agree _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taintSym [s1234Sym]) (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4]) + (fun _ _ _ _ hp => modes_agree _ _ hp) (by taint_decide) + /-! ## The contracts -/ section @@ -249,6 +269,11 @@ theorem cfbDecFinal_implies : (finalPC decFinalPost).Implies final_implies [Proof.Cast5.cfbDecryptFinalRoundsContract, Spec.Cast5.cfbFinalSig, Spec.Cast5.cfbFinalPre, Proof.Cast5.cfbDecFinalPost, decFinalPost] +theorem ofbFinal_implies : (finalPC ofbFinalPost).Implies + (Proof.Cast5.ofbFinalRoundsContract (abi.withConsts ecbConsts) frameBytes) := by + final_implies [Proof.Cast5.ofbFinalRoundsContract, Spec.Cast5.ofbFinalSig, Spec.Cast5.ofbFinalPre, + Proof.Cast5.ofbFinalPost, ofbFinalPost] + /-! ## Verified -/ theorem cfbEncryptFinal_verified : Verified target cfbEncryptFinal @@ -259,4 +284,8 @@ theorem cfbDecryptFinal_verified : Verified target cfbDecryptFinal (Proof.Cast5.cfbDecryptFinalRoundsContract (abi.withConsts ecbConsts) frameBytes) := Verified.of_correct cfbDecryptFinal_correct (cfbDecryptFinal_constantTime _) cfbDecFinal_implies +theorem ofbFinal_verified : Verified target ofbFinal + (Proof.Cast5.ofbFinalRoundsContract (abi.withConsts ecbConsts) frameBytes) := + Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ofbFinal_implies + end VG.Proof.Cast5.RISCV64.Modes diff --git a/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalLit.lean index d02673d35cc..bae6354eba0 100644 --- a/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit -/-! # IDEA's final CFB functions on RISC-V, evaluated once -/ +/-! # IDEA's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Idea.RISCV64.cfbEncryptFinal materialize_code Impl.Idea.RISCV64.cfbDecryptFinal +materialize_code Impl.Idea.RISCV64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalVerified.lean index 55560dfb841..691096e59f1 100644 --- a/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Idea/RISCV64/FbFinalVerified.lean @@ -4,6 +4,7 @@ public import VerifiedGarbage.Proof.Idea.RISCV64.ModesVerified public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.Idea.RISCV64.FbFinal public import VerifiedGarbage.Spec.Idea.CfbFinal +public import VerifiedGarbage.Spec.Idea.OfbFinal import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint import VerifiedGarbage.Proof.Framework.Lit @@ -12,16 +13,17 @@ meta import VerifiedGarbage.Proof.Idea.RISCV64.ModesVerified meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.Idea.RISCV64.FbFinal meta import VerifiedGarbage.Spec.Idea.CfbFinal +meta import VerifiedGarbage.Spec.Idea.OfbFinal meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Idea.RISCV64.FbFinalLit /-! -# IDEA-CFB64 of a message's last piece on RISC-V meets its contracts +# IDEA-CFB64 and IDEA-OFB of a message's last piece on RISC-V meet their contracts -The modes' CFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, -`cfbDecFinal_wp`) over IDEA's core (`Mode.coreSpec`) meets the contracts, +The modes' CFB and OFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over IDEA's core (`Mode.coreSpec`) meet the contracts, with `stack := 64`, the frame of the whole-block functions (`ModesVerified.lean`), whose precondition, with the data `len` bytes, is `seq`'s for the data a byte at a time (`byteMode`). Constant time as the whole-block functions. @@ -41,6 +43,8 @@ def encFinalPost (s s' : State) : Prop := Spec.Cfb.EncryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat /-- A final function on RISC-V, with its frame below the stack pointer, the data `len` bytes, and the postcondition `post`. -/ @@ -92,6 +96,11 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalContract decFinalPost).p WP.mono (Proof.Modes.RISCV64.cfbDecFinal_wp coreSpec (seqPreF_of hs) (keyArgsF_of hs)) fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbFinalPost).post s s' := + WP.mono (Proof.Modes.RISCV64.ofbFinal_wp coreSpec (seqPreF_of hs) (keyArgsF_of hs)) + fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -102,6 +111,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + /-! ## The contracts -/ theorem cfbEncryptFinal_verified : @@ -116,4 +129,10 @@ theorem cfbDecryptFinal_verified : contract_implies [Spec.Idea.cfbDecryptFinalContract, Spec.Idea.cfbFinalSig, RISCV64.abi, RISCV64.argRegs, finalContract, decFinalPost, modePub_iff] [modeSat] using modeSat +theorem ofbFinal_verified : + Verified RISCV64.target ofbFinal (Spec.Idea.ofbFinalContract RISCV64.abi frameBytes) := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + contract_implies [Spec.Idea.ofbFinalContract, Spec.Idea.ofbFinalSig, RISCV64.abi, + RISCV64.argRegs, finalContract, ofbFinalPost, modePub_iff] [modeSat] using modeSat + end VG.Proof.Idea.RISCV64.Modes diff --git a/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean index cfb660345c2..057b88ee8c4 100644 --- a/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean @@ -3,7 +3,9 @@ module public import VerifiedGarbage.Proof.Modes.RISCV64.Seq public import VerifiedGarbage.Impl.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Spec.Cfb.Final +public import VerifiedGarbage.Spec.Ofb.Final import VerifiedGarbage.Proof.Modes.FbFinal +import VerifiedGarbage.Proof.AesOfb.Spec import VerifiedGarbage.Proof.Modes.RISCV64.Modes public import VerifiedGarbage.Proof.Modes.Words import VerifiedGarbage.Proof.Framework.Omega @@ -25,7 +27,8 @@ the IV, the `r` bytes are XORed with the first bytes of `CIPH_K` of the chaining value `F` leaves, and the IV becomes that chaining value if `r = 0`, its image under the cipher otherwise (`finalOut`, `finalNext`). `cfbEncFinal_wp` and `cfbDecFinal_wp` state this as the specification's -(`Spec.Cfb.encryptFinal`, `decryptFinal`) for `cfbEnc` and `cfbDec`. +(`Spec.Cfb.encryptFinal`, `decryptFinal`) for `cfbEnc` and `cfbDec`, and +`ofbFinal_wp` as `Spec.Ofb.CryptFinal` for `ofb` (`ofbFinal_out`). The function is `seq`'s around other loops (`seqWith_changesO_wp`), which start from `seq`'s invariant for no step (`Inv`, a byte at a time), which @@ -737,4 +740,54 @@ theorem cfbDecFinal_wp (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : SeqPr rw [h3, ← Proof.Modes.cfbDecFinalNext_of, finalNext, ← (cfbDec_run _ _ _).2]; rfl⟩, h4⟩ +/-! ## OFB -/ + +theorem ofb_finalOk (c : Core) : FinalOk c (Mode.ofb c.bw) := + ⟨rfl, rfl, fun o ho => by + have b := blk_bounds (c := c) (st := (Mode.ofb c.bw).step) rfl + exact append_ok (copyBlk_inBounds (b _) (b _)) (xorBlk_inBounds (b _) (b _) (b _)) o ho, + append_ok (copyBlk_wordAl _ _ _) (xorBlk_wordAl _ _ _ _)⟩ + +/-- OFB of the `len` bytes at `D`, as a final function leaves them: its +`n = len / L` whole blocks as `Spec.Ofb.crypt`'s from `iv`, then its last +`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block +(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ +theorem ofbFinal_out {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + (m₀ : Mem) (D : Addr) (iv : List Byte) (len : Nat) : + (Spec.Ofb.crypt ciph iv (chunksAt L m₀ D (len / L))).flatten ++ + Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) + (ciph (Spec.Ofb.next ciph iv (len / L))) = + Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by + rw [show chunksAt L m₀ D (len / L) = Proof.Modes.blocksOf L m₀ D (len / L) from rfl] + have hx := Proof.Modes.xor_flatten_outputs hc m₀ (len / L) D iv + have hnB : (Proof.Modes.blocksOf L m₀ D (len / L)).length = len / L := by simp [Proof.Modes.blocksOf] + rw [Spec.Ofb.cryptFinal, Proof.Modes.bytesAt_length, Proof.Modes.blockCount_eq hL, + Proof.Modes.bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] + split + · rename_i h0 + rw [h0, ← hx] + simp [bytesAt, Spec.Cbc.xor] + · rw [Proof.AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] + exact (List.zipWith_append (by + rw [← Proof.Modes.bytesAt_mul, Proof.Modes.bytesAt_length, Proof.Modes.length_flatten_outputs hc])).symm + +/-- OFB of a message's last piece, as the specification's. -/ +theorem ofbFinal_wp (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : SeqPre c byteMode s₀) + (hk : cs.KeyArgs s₀ (wrs0 c byteMode s₀) k) : + WP isa (c.seqFinal (Mode.ofb c.bw)) s₀ fun s' => abiPreserved s₀ s' ∧ + Spec.Ofb.CryptFinal (cs.cipher k) (4 * c.bw) s₀.mem s'.mem (P s₀) (Dp s₀) (N s₀) ∧ + Changes c byteMode s₀ s' := + WP.mono (seqFinal_wp cs (ofb_finalOk c) (ofb_computes (cs.cipher_len k)) hp hk) + fun s' ⟨h1, h2, h3, h4⟩ => by + have hL0 : 0 < 4 * c.bw := by rcases hp.layout.bw with h | h <;> omega + obtain ⟨e1, e2⟩ := ofb_run (cs.cipher k) (iv0 c s₀) (xsF c s₀) + rw [chunksAt_length] at e2 + refine ⟨h1, ⟨?_, ?_⟩, h4⟩ + · rw [h2, finalOut, ← e1, ← e2] + exact ofbFinal_out hL0 (cs.cipher_len k) s₀.mem (Dp s₀) (iv0 c s₀) (N s₀) + · rw [h3, finalNext, ← e2, Proof.Modes.blockCount_eq hL0] + split + · rfl + · exact (Proof.AesOfb.next_succ _ _ _).symm + end VG.Proof.Modes.RISCV64 diff --git a/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalLit.lean index e0e95fc06d4..12c57353ccb 100644 --- a/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit -/-! # Seed's final CFB functions on RISC-V, evaluated once -/ +/-! # Seed's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Seed.RISCV64.cfbEncryptFinal materialize_code Impl.Seed.RISCV64.cfbDecryptFinal +materialize_code Impl.Seed.RISCV64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalVerified.lean index 18780f246ad..6227ac5b878 100644 --- a/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Seed/RISCV64/FbFinalVerified.lean @@ -4,6 +4,7 @@ public import VerifiedGarbage.Proof.Seed.RISCV64.ModesVerified public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.Seed.RISCV64.FbFinal public import VerifiedGarbage.Spec.Seed.CfbFinal +public import VerifiedGarbage.Spec.Seed.OfbFinal import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint import VerifiedGarbage.Proof.Framework.Lit @@ -12,16 +13,17 @@ meta import VerifiedGarbage.Proof.Seed.RISCV64.ModesVerified meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.Seed.RISCV64.FbFinal meta import VerifiedGarbage.Spec.Seed.CfbFinal +meta import VerifiedGarbage.Spec.Seed.OfbFinal meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Seed.RISCV64.FbFinalLit /-! -# SEED-CFB128 of a message's last piece on RISC-V meets its contracts +# SEED-CFB128 and SEED-OFB of a message's last piece on RISC-V meet their contracts -The modes' CFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, -`cfbDecFinal_wp`) over Seed's one-block encryption core meets the contracts, +The modes' CFB and OFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over Seed's one-block encryption core meet the contracts, with `stack := 1104`, that core's frame (`ModesVerified.lean`), whose precondition, with the data `len` bytes, is `seq`'s for the data a byte at a time (`byteMode`). Constant time as the whole-block functions. @@ -41,6 +43,8 @@ def encFinalPost (s s' : State) : Prop := Spec.Cfb.EncryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat /-- A final function on RISC-V, with its frame below the stack pointer, the data `len` bytes, and the postcondition `post`. -/ @@ -93,6 +97,11 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalContract decFinalPost).p WP.mono (Proof.Modes.RISCV64.cfbDecFinal_wp (dirCoreSpec .encrypt 1 (by decide) (by decide)) (seqPreF_of hs) (keyArgsF_of hs)) fun _ ⟨h1, h2, _⟩ => by simp only [cipher_enc] at h2; exact ⟨h1, h2⟩ +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbFinalPost).post s s' := + WP.mono (Proof.Modes.RISCV64.ofbFinal_wp (dirCoreSpec .encrypt 1 (by decide) (by decide)) (seqPreF_of hs) (keyArgsF_of hs)) + fun _ ⟨h1, h2, _⟩ => by simp only [cipher_enc] at h2; exact ⟨h1, h2⟩ + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -103,6 +112,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + /-! ## The contracts -/ theorem cfbEncryptFinal_verified : @@ -117,4 +130,10 @@ theorem cfbDecryptFinal_verified : contract_implies [Spec.Seed.cfbDecryptFinalContract, Spec.Seed.cfbFinalSig, RISCV64.abi, RISCV64.argRegs, finalContract, decFinalPost, modePub_iff] [modeSat] using modeSat +theorem ofbFinal_verified : + Verified RISCV64.target ofbFinal (Spec.Seed.ofbFinalContract RISCV64.abi (frameBytes 1)) := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + contract_implies [Spec.Seed.ofbFinalContract, Spec.Seed.ofbFinalSig, RISCV64.abi, + RISCV64.argRegs, finalContract, ofbFinalPost, modePub_iff] [modeSat] using modeSat + end VG.Proof.Seed.RISCV64.Modes diff --git a/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalLit.lean index c9a12eaa8f2..7b9c36890e4 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalLit.lean @@ -10,7 +10,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit -/-! # Sm4's final CFB functions on RISC-V, evaluated once -/ +/-! # Sm4's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -18,5 +18,6 @@ namespace VG materialize_code Impl.Sm4.RISCV64.cfbEncryptFinal materialize_code Impl.Sm4.RISCV64.cfbDecryptFinal +materialize_code Impl.Sm4.RISCV64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalVerified.lean index d6ba9e0bc44..66ad028e9f8 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/RISCV64/FbFinalVerified.lean @@ -4,6 +4,7 @@ public import VerifiedGarbage.Proof.Sm4.RISCV64.ModesVerified public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.Sm4.RISCV64.FbFinal public import VerifiedGarbage.Spec.Sm4.CfbFinal +public import VerifiedGarbage.Spec.Sm4.OfbFinal import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint import VerifiedGarbage.Proof.Framework.Lit @@ -12,16 +13,17 @@ meta import VerifiedGarbage.Proof.Sm4.RISCV64.ModesVerified meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.Sm4.RISCV64.FbFinal meta import VerifiedGarbage.Spec.Sm4.CfbFinal +meta import VerifiedGarbage.Spec.Sm4.OfbFinal meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Sm4.RISCV64.FbFinalLit /-! -# SM4-CFB128 of a message's last piece on RISC-V meets its contracts +# SM4-CFB128 and SM4-OFB of a message's last piece on RISC-V meet their contracts -The modes' CFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, -`cfbDecFinal_wp`) over Sm4's one-block encryption core meets the contracts, +The modes' CFB and OFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over Sm4's one-block encryption core meet the contracts, with `stack := 3232`, that core's frame (`ModesVerified.lean`), whose precondition, with the data `len` bytes, is `seq`'s for the data a byte at a time (`byteMode`). Constant time as the whole-block functions. @@ -41,6 +43,8 @@ def encFinalPost (s s' : State) : Prop := Spec.Cfb.EncryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 16 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat /-- A final function on RISC-V, with its frame below the stack pointer, the data `len` bytes, and the postcondition `post`. -/ @@ -94,6 +98,11 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalContract decFinalPost).p WP.mono (Proof.Modes.RISCV64.cfbDecFinal_wp (dirCoreSpec .encrypt) (seqPreF_of hs) (keyArgsF_of hs)) fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbFinalPost).post s s' := + WP.mono (Proof.Modes.RISCV64.ofbFinal_wp (dirCoreSpec .encrypt) (seqPreF_of hs) (keyArgsF_of hs)) + fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -104,6 +113,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + /-! ## The contracts -/ theorem cfbEncryptFinal_verified : @@ -118,4 +131,10 @@ theorem cfbDecryptFinal_verified : contract_implies [Spec.Sm4.cfbDecryptFinalContract, Spec.Sm4.cfbFinalSig, RISCV64.abi, RISCV64.argRegs, finalContract, decFinalPost, modePub_iff] [modeSat] using modeSat +theorem ofbFinal_verified : + Verified RISCV64.target ofbFinal (Spec.Sm4.ofbFinalContract RISCV64.abi (frameBytes)) := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + contract_implies [Spec.Sm4.ofbFinalContract, Spec.Sm4.ofbFinalSig, RISCV64.abi, + RISCV64.argRegs, finalContract, ofbFinalPost, modePub_iff] [modeSat] using modeSat + end VG.Proof.Sm4.RISCV64.Modes diff --git a/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalLit.lean b/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalLit.lean index 5b0ec795879..7a47ebac74a 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalLit.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalLit.lean @@ -14,7 +14,7 @@ meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit -/-! # TripleDes's final CFB functions on RISC-V, evaluated once -/ +/-! # TripleDes's final CFB and OFB functions on RISC-V, evaluated once -/ @[expose] public section @@ -22,5 +22,6 @@ namespace VG materialize_code Impl.TripleDes.RISCV64.cfbEncryptFinal materialize_code Impl.TripleDes.RISCV64.cfbDecryptFinal +materialize_code Impl.TripleDes.RISCV64.ofbFinal end VG diff --git a/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalVerified.lean b/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalVerified.lean index 1c846809eb7..a48f7a3a56a 100644 --- a/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalVerified.lean +++ b/lean/VerifiedGarbage/Proof/TripleDes/RISCV64/FbFinalVerified.lean @@ -4,6 +4,7 @@ public import VerifiedGarbage.Proof.TripleDes.RISCV64.ModesVerified public import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal public import VerifiedGarbage.Impl.TripleDes.RISCV64.FbFinal public import VerifiedGarbage.Spec.TripleDes.CfbFinal +public import VerifiedGarbage.Spec.TripleDes.OfbFinal import VerifiedGarbage.Proof.Framework.Contract import VerifiedGarbage.Proof.Framework.Taint import VerifiedGarbage.Proof.Framework.Lit @@ -12,16 +13,17 @@ meta import VerifiedGarbage.Proof.TripleDes.RISCV64.ModesVerified meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal meta import VerifiedGarbage.Impl.TripleDes.RISCV64.FbFinal meta import VerifiedGarbage.Spec.TripleDes.CfbFinal +meta import VerifiedGarbage.Spec.TripleDes.OfbFinal meta import VerifiedGarbage.Proof.Framework.Contract meta import VerifiedGarbage.Proof.Framework.Taint meta import VerifiedGarbage.Proof.Framework.Lit meta import VerifiedGarbage.Proof.TripleDes.RISCV64.FbFinalLit /-! -# Triple DES-CFB64 of a message's last piece on RISC-V meets its contracts +# Triple DES-CFB64 and Triple DES-OFB of a message's last piece on RISC-V meet their contracts -The modes' CFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, -`cfbDecFinal_wp`) over TripleDes's one-block encryption core meets the contracts, +The modes' CFB and OFB over a message's last piece (`Proof.Modes.RISCV64.cfbEncFinal_wp`, +`cfbDecFinal_wp`, `ofbFinal_wp`) over TripleDes's one-block encryption core meet the contracts, with `stack := 944`, that core's frame (`ModesVerified.lean`), whose precondition, with the data `len` bytes, is `seq`'s for the data a byte at a time (`byteMode`). Constant time as the whole-block functions. @@ -41,6 +43,8 @@ def encFinalPost (s s' : State) : Prop := Spec.Cfb.EncryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat def decFinalPost (s s' : State) : Prop := Spec.Cfb.DecryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat +def ofbFinalPost (s s' : State) : Prop := + Spec.Ofb.CryptFinal (ciph s) 8 s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat /-- A final function on RISC-V, with its frame below the stack pointer, the data `len` bytes, and the postcondition `post`. -/ @@ -93,6 +97,11 @@ theorem cfbDecryptFinal_correct (s : State) (hs : (finalContract decFinalPost).p WP.mono (Proof.Modes.RISCV64.cfbDecFinal_wp (dirCoreSpec .encrypt) (seqPreF_of hs) (keyArgsF_of hs)) fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ +theorem ofbFinal_correct (s : State) (hs : (finalContract ofbFinalPost).pre s) : + ∃ t s', Exec isa ofbFinal s t s' ∧ abiPreserved s s' ∧ (finalContract ofbFinalPost).post s s' := + WP.mono (Proof.Modes.RISCV64.ofbFinal_wp (dirCoreSpec .encrypt) (seqPreF_of hs) (keyArgsF_of hs)) + fun _ ⟨h1, h2, _⟩ => ⟨h1, h2⟩ + /-! ## Constant time -/ theorem cfbEncryptFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub cfbEncryptFinal := @@ -103,6 +112,10 @@ theorem cfbDecryptFinal_constantTime (pre : State → Prop) : ConstantTime isa p VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) +theorem ofbFinal_constantTime (pre : State → Prop) : ConstantTime isa pre modePub ofbFinal := + VG.Taint.constantTime (A := taint) (Taint.ofRegs [.a0, .a1, .a2, .a3]) + (fun _ _ _ _ hp => modes_ofRegs _ _ hp) (by taint_decide) + /-! ## The contracts -/ theorem cfbEncryptFinal_verified : @@ -117,4 +130,10 @@ theorem cfbDecryptFinal_verified : contract_implies [Spec.TripleDes.cfbDecryptFinalContract, Spec.TripleDes.cfbFinalSig, RISCV64.abi, RISCV64.argRegs, finalContract, decFinalPost, modePub_iff] [modeSat] using modeSat +theorem ofbFinal_verified : + Verified RISCV64.target ofbFinal (Spec.TripleDes.ofbFinalContract RISCV64.abi (frameBytes)) := by + refine Verified.of_correct ofbFinal_correct (ofbFinal_constantTime _) ?_ + contract_implies [Spec.TripleDes.ofbFinalContract, Spec.TripleDes.ofbFinalSig, RISCV64.abi, + RISCV64.argRegs, finalContract, ofbFinalPost, modePub_iff] [modeSat] using modeSat + end VG.Proof.TripleDes.RISCV64.Modes From cdeb13188a137b2e4a1bba162d87e86e0d704c08 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:36:20 +0000 Subject: [PATCH 07/18] OFB of seven ciphers: a partial last block by the final functions (WIP: needs the regenerated crates) Whole blocks stay with the whole-block functions; only the bytes after them go to vg__ofb_final. The Rust code that ran OFB on the padded last bytes, and its comment, are deleted. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- src/cipher/blowfish/ofb.rs | 35 +++++++++++++++-------------- src/cipher/camellia/ofb.rs | 43 ++++++++++++++++++++++-------------- src/cipher/cast5/ofb.rs | 43 ++++++++++++++++++++++-------------- src/cipher/idea/ofb.rs | 35 +++++++++++++++-------------- src/cipher/seed/ofb.rs | 35 +++++++++++++++-------------- src/cipher/sm4/ofb.rs | 35 +++++++++++++++-------------- src/cipher/triple_des/ofb.rs | 35 +++++++++++++++-------------- 7 files changed, 149 insertions(+), 112 deletions(-) diff --git a/src/cipher/blowfish/ofb.rs b/src/cipher/blowfish/ofb.rs index b98f723928b..b9c3b637fea 100644 --- a/src/cipher/blowfish/ofb.rs +++ b/src/cipher/blowfish/ofb.rs @@ -11,7 +11,7 @@ ))] use crate::arch::blowfish::vg_blowfish_expand_key; -use crate::arch::blowfish_ofb::vg_blowfish_ofb; +use crate::arch::blowfish_ofb::{vg_blowfish_ofb, vg_blowfish_ofb_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -63,7 +63,7 @@ impl BlowfishOfb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -88,23 +88,26 @@ impl Key { Ok(Self { schedule }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of eight bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { - let whole = buffer.len() / 8 * 8; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 8, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 8 * 8); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 8]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { vg_blowfish_ofb_final(&self.schedule, iv, rest.as_mut_ptr(), rest.len()) }; } } diff --git a/src/cipher/camellia/ofb.rs b/src/cipher/camellia/ofb.rs index f50fb7f6497..53012c0097e 100644 --- a/src/cipher/camellia/ofb.rs +++ b/src/cipher/camellia/ofb.rs @@ -11,7 +11,7 @@ ))] use crate::arch::camellia::vg_camellia_expand_key; -use crate::arch::camellia_ofb::vg_camellia_ofb; +use crate::arch::camellia_ofb::{vg_camellia_ofb, vg_camellia_ofb_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -65,7 +65,7 @@ impl CamelliaOfb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -91,23 +91,34 @@ impl Key { Ok(Self { schedule, rounds }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of 16 bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { + vg_camellia_ofb_final( + &self.schedule, + self.rounds, + iv, + rest.as_mut_ptr(), + rest.len(), + ) + }; } } diff --git a/src/cipher/cast5/ofb.rs b/src/cipher/cast5/ofb.rs index 6437ee47d11..3958527d0cd 100644 --- a/src/cipher/cast5/ofb.rs +++ b/src/cipher/cast5/ofb.rs @@ -10,7 +10,7 @@ ))] use super::Cast5Ecb; -use crate::arch::cast5_ofb::vg_cast5_ofb; +use crate::arch::cast5_ofb::{vg_cast5_ofb, vg_cast5_ofb_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -60,7 +60,7 @@ impl Cast5Ofb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -79,23 +79,34 @@ impl Key { }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of 8 bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { - let whole = buffer.len() / 8 * 8; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 8, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 8 * 8); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 8]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { + vg_cast5_ofb_final( + self.key.schedule(), + self.key.rounds(), + iv, + rest.as_mut_ptr(), + rest.len(), + ) + }; } } diff --git a/src/cipher/idea/ofb.rs b/src/cipher/idea/ofb.rs index e055190708d..3e3c075f0a3 100644 --- a/src/cipher/idea/ofb.rs +++ b/src/cipher/idea/ofb.rs @@ -10,7 +10,7 @@ ))] use crate::arch::idea::vg_idea_expand_key; -use crate::arch::idea_ofb::vg_idea_ofb; +use crate::arch::idea_ofb::{vg_idea_ofb, vg_idea_ofb_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -61,7 +61,7 @@ impl IdeaOfb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -83,23 +83,26 @@ impl Key { Ok(Self { schedule }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of eight bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { - let whole = buffer.len() / 8 * 8; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 8, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 8 * 8); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 8]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { vg_idea_ofb_final(&self.schedule, iv, rest.as_mut_ptr(), rest.len()) }; } } diff --git a/src/cipher/seed/ofb.rs b/src/cipher/seed/ofb.rs index 6f32c621f50..723b12f938a 100644 --- a/src/cipher/seed/ofb.rs +++ b/src/cipher/seed/ofb.rs @@ -10,7 +10,7 @@ ))] use crate::arch::seed::vg_seed_expand_key; -use crate::arch::seed_ofb::vg_seed_ofb; +use crate::arch::seed_ofb::{vg_seed_ofb, vg_seed_ofb_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -61,7 +61,7 @@ impl SeedOfb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -83,23 +83,26 @@ impl Key { Ok(Self { schedule }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of 16 bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { vg_seed_ofb_final(&self.schedule, iv, rest.as_mut_ptr(), rest.len()) }; } } diff --git a/src/cipher/sm4/ofb.rs b/src/cipher/sm4/ofb.rs index ed1c979bae1..22cc46463ad 100644 --- a/src/cipher/sm4/ofb.rs +++ b/src/cipher/sm4/ofb.rs @@ -11,7 +11,7 @@ ))] use crate::arch::sm4::vg_sm4_expand_key; -use crate::arch::sm4_ofb::vg_sm4_ofb; +use crate::arch::sm4_ofb::{vg_sm4_ofb, vg_sm4_ofb_final}; use crate::error::IncompleteBlock; use crate::zeroize::zeroize; @@ -62,7 +62,7 @@ impl Sm4Ofb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -83,23 +83,26 @@ impl Key { Self { schedule } } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of 16 bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { vg_sm4_ofb_final(&self.schedule, iv, rest.as_mut_ptr(), rest.len()) }; } } diff --git a/src/cipher/triple_des/ofb.rs b/src/cipher/triple_des/ofb.rs index 6b9bd329253..89c3ef0ad4e 100644 --- a/src/cipher/triple_des/ofb.rs +++ b/src/cipher/triple_des/ofb.rs @@ -10,7 +10,7 @@ ))] use crate::arch::triple_des::vg_triple_des_expand_key; -use crate::arch::triple_des_ofb::vg_triple_des_ofb; +use crate::arch::triple_des_ofb::{vg_triple_des_ofb, vg_triple_des_ofb_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -63,7 +63,7 @@ impl TripleDesOfb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -87,23 +87,26 @@ impl Key { Ok(Self { schedule }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of eight bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { - let whole = buffer.len() / 8 * 8; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 8, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 8], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 8 * 8); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 8]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: `rest` is valid for `len` bytes, and it, the block at + // `iv` and the schedule are separate valid objects of the sizes of + // the signature, none of them on the callee's stack. + unsafe { vg_triple_des_ofb_final(&self.schedule, iv, rest.as_mut_ptr(), rest.len()) }; } } From a7618a43c31c6126851858c1f148407f96f97c48 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:50:10 +0000 Subject: [PATCH 08/18] AES-OFB final and CTR finals (AES, Camellia, SM4) on x86-64 (WIP: crates to come) vg_aes_ofb_final: AES-CFB's final caller around the whole-block AES-OFB function, whose tail (the block function on the IV) is OFB's. vg__ctr_final: a call of the whole-block CTR function on the whole blocks, then one on a zeroed block in a wiped stack frame, whose first bytes are XORed into the tail; the counter is left at T_{n+1}. AES's for every variant; target-independent lemmas in Proof/Modes/CtrFinal.lean, Proof/AesOfb/Final.lean and Proof/AesCtr/Final.lean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/CamelliaCtr/X86_64.lean | 8 +- .../Artifacts/Sm4Ctr/X86_64.lean | 7 +- .../Generic/AesBlocks/X86_64/AesOfb.lean | 8 + .../Generic/AesCtr32/X86_64/AesCtr.lean | 8 + .../Impl/AesCtr/X86_64/Final.lean | 82 ++ .../Impl/AesOfb/X86_64/Final.lean | 44 + .../Impl/Camellia/X86_64/CtrFinal.lean | 85 ++ .../Impl/Sm4/X86_64/CtrFinal.lean | 85 ++ .../Proof/AesCfb/X86_64/Final.lean | 58 +- lean/VerifiedGarbage/Proof/AesCtr/Final.lean | 170 +++ .../Proof/AesCtr/X86_64/Final.lean | 1120 +++++++++++++++++ lean/VerifiedGarbage/Proof/AesOfb/Final.lean | 232 ++++ .../Proof/AesOfb/X86_64/Final.lean | 181 +++ .../Proof/Camellia/CtrFinal.lean | 79 ++ .../Proof/Camellia/X86_64/CtrFinal.lean | 1067 ++++++++++++++++ .../VerifiedGarbage/Proof/Modes/CtrFinal.lean | 160 +++ lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean | 71 ++ .../Proof/Sm4/X86_64/CtrFinal.lean | 1042 +++++++++++++++ 18 files changed, 4476 insertions(+), 31 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/AesCtr/X86_64/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/AesOfb/X86_64/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/Camellia/X86_64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Impl/Sm4/X86_64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/X86_64/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/X86_64/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Modes/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/X86_64/CtrFinal.lean diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86_64.lean b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86_64.lean index 61404215227..99ab2ec2c8d 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86_64.lean @@ -1,8 +1,10 @@ module public import VerifiedGarbage.Proof.Camellia.X86_64.CtrVerified +public import VerifiedGarbage.Proof.Camellia.X86_64.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print +import VerifiedGarbage.Proof.Camellia.X86_64.ModesLit /-! # Camellia-CTR artifacts on baseline x86-64 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ctrApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 3280 .r9 409 Impl.Camellia.X86_64.ctr stack := 3288 - verified := Proof.Camellia.X86_64.ctr_framed }] + verified := Proof.Camellia.X86_64.ctr_framed }, + Spec.Camellia.ctrFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 72 .r9 8 Impl.Camellia.X86_64.ctrFinal + stack := 3368 + verified := Proof.Camellia.X86_64.ctrFinal_framed }] end VG.Artifacts.CamelliaCtr.X86_64 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86_64.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86_64.lean index 6110626b982..767a5029387 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86_64.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86_64.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Sm4.X86_64.CtrVerified +public import VerifiedGarbage.Proof.Sm4.X86_64.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit @@ -15,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ctrApi.artifact X86_64.target { code := Impl.StackScratch.X86_64.withStackScratchWiped 3208 .r8 400 Impl.Sm4.X86_64.ctr stack := 3216 - verified := Proof.Sm4.X86_64.ctr_framed }] + verified := Proof.Sm4.X86_64.ctr_framed }, + Spec.Sm4.ctrFinalApi.artifact X86_64.target { + code := Impl.StackScratch.X86_64.withStackScratchWiped 72 .r8 8 Impl.Sm4.X86_64.ctrFinal + stack := 3296 + verified := Proof.Sm4.X86_64.ctrFinal_framed }] end VG.Artifacts.Sm4Ctr.X86_64 diff --git a/lean/VerifiedGarbage/Generic/AesBlocks/X86_64/AesOfb.lean b/lean/VerifiedGarbage/Generic/AesBlocks/X86_64/AesOfb.lean index 0d049531014..d4bd3d252fc 100644 --- a/lean/VerifiedGarbage/Generic/AesBlocks/X86_64/AesOfb.lean +++ b/lean/VerifiedGarbage/Generic/AesBlocks/X86_64/AesOfb.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesOfb.X86_64.Verified +public import VerifiedGarbage.Proof.AesOfb.X86_64.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print @@ -19,6 +20,13 @@ def artifacts (v : Proof.Aes.X86_64.BlocksImpl) : List Artifact := [ stack := 8 verified := Proof.AesOfb.keyed (crypt_verified v) spSafe := crypt_spSafe v + features := v.features }, + Spec.Ofb.aesFinalApi.artifact X86_64.target { + suffix := v.suffix + code := Impl.StackScratch.X86_64.withStackArgScratchWiped 64 0 6 (Impl.AesOfb.X86_64.cryptFinal v.enc v.suffix) + stack := 80 + verified := Proof.AesOfb.final_keyed (cryptFinal_framed v) + spSafe := cryptFinal_framed_spSafe v features := v.features }] end VG.Generic.AesBlocks.X86_64.AesOfb diff --git a/lean/VerifiedGarbage/Generic/AesCtr32/X86_64/AesCtr.lean b/lean/VerifiedGarbage/Generic/AesCtr32/X86_64/AesCtr.lean index 1aea94c88a6..9dea0426d50 100644 --- a/lean/VerifiedGarbage/Generic/AesCtr32/X86_64/AesCtr.lean +++ b/lean/VerifiedGarbage/Generic/AesCtr32/X86_64/AesCtr.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesCtr.X86_64.Verified +public import VerifiedGarbage.Proof.AesCtr.X86_64.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86_64.Print @@ -19,6 +20,13 @@ def artifacts (v : Proof.Aes.X86_64.Ctr32Impl) : List Artifact := [ stack := 8 verified := Proof.AesCtr.keyed (crypt_verified v) spSafe := crypt_spSafe v + features := v.features }, + Spec.Ctr.aesFinalApi.artifact X86_64.target { + suffix := v.suffix + code := Impl.StackScratch.X86_64.withStackArgScratchWiped 80 0 8 (Impl.AesCtr.X86_64.cryptFinal v.callee v.suffix) + stack := 96 + verified := Proof.AesCtr.final_keyed (cryptFinal_framed v) + spSafe := cryptFinal_framed_spSafe v features := v.features }] end VG.Generic.AesCtr32.X86_64.AesCtr diff --git a/lean/VerifiedGarbage/Impl/AesCtr/X86_64/Final.lean b/lean/VerifiedGarbage/Impl/AesCtr/X86_64/Final.lean new file mode 100644 index 00000000000..8dca9a3e2e0 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesCtr/X86_64/Final.lean @@ -0,0 +1,82 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.X86_64 +public import VerifiedGarbage.Impl.AesCfb.X86_64.Final + +/-! +# AES-CTR of a message's last piece: x86-64 implementation + +`cryptFinal c sfx` (schedule = rdi, rounds = rsi, ctr = rdx, data = rcx, +len = r8, scratch = r9, save = `[rsp + 8]`): the code of `vg_aes_ctr_final`, +whose registration frames it with a buffer of its own on the stack, `save`, +the seventh argument, of 64 bytes: the caller's callee-saved registers, then +a block of the code's own. It is generic over the implementation of +`vg_aes_ctr32` that the whole-block function calls (`c`, whose callers' +names end in `sfx`, e.g. `_aesni`): + +1. the registers saved in `save`, and the arguments kept in `rbx` + (schedule), `rbp` (rounds), `r12` (ctr), `r13` (the data after its whole + blocks), `r14` (`u = len mod 16`, the bytes after them) and `r15` + (scratch), as AES-CFB's final functions do + (`Impl/AesCfb/X86_64/Final.lean`); +2. a call of the whole-block function of the same implementation + (`vg_aes_ctr` and its variants, `Impl/AesCtr/X86_64.lean`) on the + `len / 16` whole blocks, which leaves `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of the + same function on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time (the modes' `xorByte`); +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds`, `len` and the last 32 bits of the counter block +can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesCtr.X86_64 + +open VG.X86_64 +open VG.Impl.Aes.X86_64 (Ctr32) +open VG.Impl.AesCfb.X86_64 (loadSave finalSetup finalRestore) +open VG.Impl.Modes.X86_64 (xorByte) + +/-- The two quadwords of the block after the registers in `save`, each +zeroed from `r10`. -/ +def zeroSlots : List (Reg × Nat) := [(.r10, 48), (.r10, 56)] + +/-- The arguments of the whole-block function on that block: the schedule, +the rounds, the counter block, the block, `n = 1`, and the working space. -/ +def tailMoves : List Instr := + [.mov .rdi (.reg .rbx), .mov .rsi (.reg .rbp), .mov .rdx (.reg .r12), .mov .rcx (.reg .rax), + .alu .add .rcx (.imm 48), .mov32 .r8 (.imm 1), .mov .r9 (.reg .r15)] + +/-- The block, from `save` in `rax`, zeroed, and the arguments of the +whole-block function on it. -/ +def tailArgs : List Instr := + .mov32 .r10 (.imm 0) :: (zeroSlots.map fun p => .store { base := .rax, disp := p.2 } p.1) ++ tailMoves + +/-- The block's address, from `save` in `rax`. -/ +def tailKey : List Instr := [.alu .add .rax (.imm 48)] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, by a call of the whole-block function `name`, `whole`, on it, and its +first `u` bytes XORed into the data. -/ +def finalTail (name : String) (whole : Prog isa) : Prog isa := + .seq (.block loadSave) (.seq (.block tailArgs) (.seq (.call name whole) + (.seq (.block loadSave) (.seq (.block tailKey) (.loop (.block (xorByte .r13 .r14)) .ne))))) + +/-- The whole function, around calls of the whole-block function `name`, +`whole`. -/ +def final (name : String) (whole : Prog isa) : Prog isa := + .seq (.block loadSave) (.seq (.block finalSetup) (.seq (.call name whole) + (.seq (.block [.alu .test .r14 (.reg .r14)]) (.seq (.ite .e (.block []) (finalTail name whole)) + (.seq (.block loadSave) (.block finalRestore)))))) + +/-- `vg_aes_ctr_final`, calling `vg_aes_ctr` with `vg_aes_ctr32`'s +implementation `c`, whose callers' names end in `sfx`. -/ +def cryptFinal (c : Ctr32) (sfx : String) : Prog isa := final ("vg_aes_ctr" ++ sfx) (crypt c) + +end VG.Impl.AesCtr.X86_64 diff --git a/lean/VerifiedGarbage/Impl/AesOfb/X86_64/Final.lean b/lean/VerifiedGarbage/Impl/AesOfb/X86_64/Final.lean new file mode 100644 index 00000000000..3b9960c5d3e --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesOfb/X86_64/Final.lean @@ -0,0 +1,44 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.X86_64 +public import VerifiedGarbage.Impl.AesCfb.X86_64.Final + +/-! +# AES-OFB of a message's last piece: x86-64 implementation + +`cryptFinal b sfx` (schedule = rdi, rounds = rsi, iv = rdx, data = rcx, +len = r8, scratch = r9, save = `[rsp + 8]`): the code of `vg_aes_ofb_final`, +whose registration frames it with a buffer of its own on the stack, `save`, +the seventh argument, where the code keeps its caller's callee-saved +registers. It is AES-CFB's final function (`Impl.AesCfb.X86_64.final`) +around a call of the whole-block AES-OFB function of the same +implementation of the block functions (`b`, whose callers' names end in +`sfx`, e.g. `_aesni`): + +1. the registers saved in `save`, and the arguments kept in callee-saved + registers; +2. a call of `vg_aes_ofb` (and its variants, `Impl/AesOfb/X86_64.lean`) on + the `len / 16` whole blocks, which leaves the last output block `Oₙ` in + `iv`; +3. if `u = len mod 16 ≠ 0`, a call of the block function on the block at + `iv` in place, which leaves `Oₙ₊₁ = CIPH_K(Oₙ)` there, the last output + block used, and its first `u` bytes XORed into the `u` bytes left, a + byte at a time; +4. the registers restored. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesOfb.X86_64 + +open VG.X86_64 +open VG.Impl.Aes.X86_64 (Blocks) + +/-- `vg_aes_ofb_final`, calling `vg_aes_ofb` with the block function `b`, +whose callers' names end in `sfx`. -/ +def cryptFinal (b : Blocks) (sfx : String) : Prog isa := + Impl.AesCfb.X86_64.final ("vg_aes_ofb" ++ sfx) (crypt b) b + +end VG.Impl.AesOfb.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Camellia/X86_64/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/X86_64/CtrFinal.lean new file mode 100644 index 00000000000..1e5fe993fe0 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Camellia/X86_64/CtrFinal.lean @@ -0,0 +1,85 @@ +module + +public import VerifiedGarbage.Impl.Camellia.X86_64.Ctr +public import VerifiedGarbage.Impl.AesCtr.X86_64.Final +public import VerifiedGarbage.Impl.StackScratch.X86_64 + +/-! +# Camellia-CTR of a message's last piece: x86-64 implementation + +`ctrFinal` (schedule = rdi, rounds = rsi, ctr = rdx, data = rcx, len = r8, +save = r9): the code of `vg_camellia_ctr_final`, whose registration frames it +with a buffer of its own on the stack, `save`, of 64 bytes, passed in `r9`: +the caller's callee-saved registers, then a block of the code's own. It is +AES-CTR's final function's (`Impl/AesCtr/X86_64/Final.lean`) with +Camellia's arguments, around calls of `vg_camellia_ctr`, framed by its own +working space on the stack (`ctrFramed`): + +1. the registers saved in `save`, and the arguments kept in `rbx` + (schedule), `rbp` (rounds), `r12` (ctr), `r13` (the data after its whole + blocks), `r14` (`u = len mod 16`, the bytes after them) and `r15` + (`save`); +2. a call of `vg_camellia_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_camellia_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Camellia.X86_64 + +open VG.X86_64 +open VG.Impl.AesCfb.X86_64 (finalSave finalRestore) +open VG.Impl.AesCtr.X86_64 (zeroSlots tailKey) +open VG.Impl.Modes.X86_64 (xorByte) + +/-- `vg_camellia_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.X86_64.withStackScratchWiped 3280 .r9 409 ctr + +/-- The arguments to their registers, `r13` and `r14` the data after the +whole blocks and its length, `r15` `save`, and `r8` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [.mov .rbx (.reg .rdi), .mov .rbp (.reg .rsi), .mov .r12 (.reg .rdx), .mov .r15 (.reg .rax), + .mov .r14 (.reg .r8), .alu .and .r14 (.imm 15), .mov .r13 (.reg .r8), .alu .sub .r13 (.reg .r14), + .alu .add .r13 (.reg .rcx), .shift .shr .r8 4] + +/-- The registers saved in `save`, at `rax`; the arguments to their +registers. -/ +def ctrFinalSetup : List Instr := finalSave ++ ctrFinalMoves + +/-- `save`, kept in `r15`, to `rax`. -/ +def ctrFinalLoad : List Instr := [.mov .rax (.reg .r15)] + +/-- The arguments of `vg_camellia_ctr` on the block after the registers: +the schedule, the rounds, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [.mov .rdi (.reg .rbx), .mov .rsi (.reg .rbp), .mov .rdx (.reg .r12), .mov .rcx (.reg .rax), + .alu .add .rcx (.imm 48), .mov32 .r8 (.imm 1)] + +/-- The block, from `save` in `rax`, zeroed, and the arguments of +`vg_camellia_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .mov32 .r10 (.imm 0) :: (zeroSlots.map fun p => .store { base := .rax, disp := p.2 } p.1) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalLoad) (.seq (.block ctrFinalTailArgs) (.seq (.call "vg_camellia_ctr" ctrFramed) + (.seq (.block ctrFinalLoad) (.seq (.block tailKey) (.loop (.block (xorByte .r13 .r14)) .ne))))) + +/-- `vg_camellia_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block [.mov .rax (.reg .r9)]) (.seq (.block ctrFinalSetup) (.seq (.call "vg_camellia_ctr" ctrFramed) + (.seq (.block [.alu .test .r14 (.reg .r14)]) (.seq (.ite .e (.block []) ctrFinalTail) + (.seq (.block ctrFinalLoad) (.block finalRestore)))))) + +end VG.Impl.Camellia.X86_64 diff --git a/lean/VerifiedGarbage/Impl/Sm4/X86_64/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/X86_64/CtrFinal.lean new file mode 100644 index 00000000000..a3acebff7cf --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Sm4/X86_64/CtrFinal.lean @@ -0,0 +1,85 @@ +module + +public import VerifiedGarbage.Impl.Sm4.X86_64.Ctr +public import VerifiedGarbage.Impl.AesCtr.X86_64.Final +public import VerifiedGarbage.Impl.StackScratch.X86_64 + +/-! +# SM4-CTR of a message's last piece: x86-64 implementation + +`ctrFinal` (schedule = rdi, ctr = rsi, data = rdx, len = rcx, save = r8): the +code of `vg_sm4_ctr_final`, whose registration frames it with a buffer of its +own on the stack, `save`, of 64 bytes, passed in `r8`: +the caller's callee-saved registers, then a block of the code's own. It is +AES-CTR's final function's (`Impl/AesCtr/X86_64/Final.lean`) with SM4's +arguments, around calls of `vg_sm4_ctr`, framed by its own working space on +the stack (`ctrFramed`): + +1. the registers saved in `save`, and the arguments kept in `rbx` + (schedule), `r12` (ctr), `r13` (the data after its whole + blocks), `r14` (`u = len mod 16`, the bytes after them) and `r15` + (`save`); +2. a call of `vg_sm4_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_sm4_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Sm4.X86_64 + +open VG.X86_64 +open VG.Impl.AesCfb.X86_64 (finalSave finalRestore) +open VG.Impl.AesCtr.X86_64 (zeroSlots tailKey) +open VG.Impl.Modes.X86_64 (xorByte) + +/-- `vg_sm4_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.X86_64.withStackScratchWiped 3208 .r8 400 ctr + +/-- The arguments to their registers, `r13` and `r14` the data after the +whole blocks and its length, `r15` `save`, and `rcx` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [.mov .rbx (.reg .rdi), .mov .r12 (.reg .rsi), .mov .r15 (.reg .rax), + .mov .r14 (.reg .rcx), .alu .and .r14 (.imm 15), .mov .r13 (.reg .rcx), .alu .sub .r13 (.reg .r14), + .alu .add .r13 (.reg .rdx), .shift .shr .rcx 4] + +/-- The registers saved in `save`, at `rax`; the arguments to their +registers. -/ +def ctrFinalSetup : List Instr := finalSave ++ ctrFinalMoves + +/-- `save`, kept in `r15`, to `rax`. -/ +def ctrFinalLoad : List Instr := [.mov .rax (.reg .r15)] + +/-- The arguments of `vg_sm4_ctr` on the block after the registers: +the schedule, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [.mov .rdi (.reg .rbx), .mov .rsi (.reg .r12), .mov .rdx (.reg .rax), .alu .add .rdx (.imm 48), + .mov32 .rcx (.imm 1)] + +/-- The block, from `save` in `rax`, zeroed, and the arguments of +`vg_sm4_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .mov32 .r10 (.imm 0) :: (zeroSlots.map fun p => .store { base := .rax, disp := p.2 } p.1) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalLoad) (.seq (.block ctrFinalTailArgs) (.seq (.call "vg_sm4_ctr" ctrFramed) + (.seq (.block ctrFinalLoad) (.seq (.block tailKey) (.loop (.block (xorByte .r13 .r14)) .ne))))) + +/-- `vg_sm4_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block [.mov .rax (.reg .r8)]) (.seq (.block ctrFinalSetup) (.seq (.call "vg_sm4_ctr" ctrFramed) + (.seq (.block [.alu .test .r14 (.reg .r14)]) (.seq (.ite .e (.block []) ctrFinalTail) + (.seq (.block ctrFinalLoad) (.block finalRestore)))))) + +end VG.Impl.Sm4.X86_64 diff --git a/lean/VerifiedGarbage/Proof/AesCfb/X86_64/Final.lean b/lean/VerifiedGarbage/Proof/AesCfb/X86_64/Final.lean index 27545bfe9bf..8b99582ba0f 100644 --- a/lean/VerifiedGarbage/Proof/AesCfb/X86_64/Final.lean +++ b/lean/VerifiedGarbage/Proof/AesCfb/X86_64/Final.lean @@ -943,10 +943,10 @@ theorem decryptFinal_xdepth (v : BlocksImpl) : (decryptFinal v.enc v.suffix).x86 /-! ## Constant time -/ -theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeX86_64 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86_64 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeX86_64 (cfbMode enc)).pre (modeX86_64 (cfbMode enc)).pub whole) +theorem final_rel {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86_64 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86_64 M).post s s') + (hct : ConstantTime isa (modeX86_64 M).pre (modeX86_64 M).pub whole) (hsp : NoSp whole) (hd : whole.depth = 1) (v : BlocksImpl) {s₀ s₀' : State} (h0 : (finalX86_64 enc).pre s₀) (h0' : (finalX86_64 enc).pre s₀') (hq : (finalX86_64 enc).pub s₀ s₀') : RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole v.enc) fun _ _ => True := by @@ -979,10 +979,10 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} (F₁ := Setup s₀) (F₂ := Setup s₀') fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩ -- The whole blocks. - have r₃ := (RelCT.callEx (k := modeX86_64 (cfbMode enc)) (n := name) hv hct + have r₃ := (RelCT.callEx (k := modeX86_64 M) (n := name) hv hct (P := fun a b => Setup s₀ a ∧ Setup s₀' b) fun a b ⟨ha, hb⟩ => by - obtain ⟨pa, ca, wa⟩ := whole_pre (M := cfbMode enc) hp ha - obtain ⟨pb, cb, wb⟩ := whole_pre (M := cfbMode enc) hp' hb + obtain ⟨pa, ca, wa⟩ := whole_pre (M := M) hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre (M := M) hp' hb refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ simp only [modeX86_64, State.withRegions_gpr, State.callEntry_rsp, State.callEntry_gpr _ (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.rsi ≠ .rsp), @@ -991,17 +991,17 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} ha.rdi, ha.rsi, ha.rdx, ha.rcx, ha.r8, ha.r9, ha.rsp, hb.rdi, hb.rsi, hb.rdx, hb.rcx, hb.r8, hb.r9, hb.rsp] rw [fW, fW, fIv, fIv, fD, fD, fS, fS, fSp, fSp, qW, qR, qIv, qD, qS, qSp, qN] exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩).wp - (F₁ := Whole (cfbMode enc) s₀) (F₂ := Whole (cfbMode enc) s₀') + (F₁ := Whole M s₀) (F₂ := Whole M s₀') fun a b h => ⟨whole_wp hv hsp hd hp h.1, whole_wp hv hsp hd hp' h.2⟩ -- The test. obtain ⟨_, t₄⟩ : ∃ h, (taint.check (Taint.ofRegs [.r14]) (.block [.alu .test .r14 (.reg .r14)]) h).isSome = true := ⟨_, by taint_decide⟩ have r₄ := (RelCT.taint (A := taint) - (P := fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) _ + (P := fun a b => Whole M s₀ a ∧ Whole M s₀' b) _ (fun a b h => Taint.agree_ofRegs fun r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r14, h.2.r14, qU]) t₄).wp - (F₁ := fun (s : State) => Whole (cfbMode enc) s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) - (F₂ := fun (s : State) => Whole (cfbMode enc) s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) + (F₁ := fun (s : State) => Whole M s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => Whole M s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) fun a b h => ⟨final_test_wp h.1, final_test_wp h.2⟩ -- The partial last segment. obtain ⟨_, t₅⟩ : ∃ h, (taint.check (Taint.ofRegs [.rbx, .rbp, .r12, .r15, .rsp]) @@ -1009,11 +1009,11 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} obtain ⟨_, t₆⟩ : ∃ h, (taint.check (Taint.ofRegs [.r12, .r13, .r14]) (.seq (.block [.mov .rax (.reg .r12)]) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) h).isSome = true := ⟨_, by taint_decide⟩ - have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) - (finalTail v.enc) fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b := by + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) + (finalTail v.enc) fun a b => Done M s₀ a ∧ Done M s₀' b := by have hu' : fU s₀' ≠ 0 := qU ▸ hu have a₅ := (RelCT.taint (A := taint) - (P := fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) _ + (P := fun a b => Whole M s₀ a ∧ Whole M s₀' b) _ (fun a b h => Taint.agree_ofRegs fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl | rfl | rfl @@ -1022,12 +1022,12 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} · rw [h.1.r12, h.2.r12, fIv, fIv, qIv] · rw [h.1.r15, h.2.r15, fS, fS, qS] · rw [h.1.rsp, h.2.rsp, fSp, fSp, qSp]) t₅).wp - (F₁ := fun (s : State) => Whole (cfbMode enc) s₀ s ∧ CallPre s (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) - (F₂ := fun (s : State) => Whole (cfbMode enc) s₀' s ∧ CallPre s (fW s₀') (fIv s₀') (fS s₀') (fR s₀')) + (F₁ := fun (s : State) => Whole M s₀ s ∧ CallPre s (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) + (F₂ := fun (s : State) => Whole M s₀' s ∧ CallPre s (fW s₀') (fIv s₀') (fS s₀') (fR s₀')) fun a b h => ⟨final_ivArgs_wp hp h.1, final_ivArgs_wp hp' h.2⟩ have a₆ := (AesCbc.X86_64.blk_rel (b := v.enc) v.encOk v.encCt - (P := fun a b => (Whole (cfbMode enc) s₀ a ∧ CallPre a (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) ∧ - (Whole (cfbMode enc) s₀' b ∧ CallPre b (fW s₀') (fIv s₀') (fS s₀') (fR s₀'))) + (P := fun a b => (Whole M s₀ a ∧ CallPre a (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) ∧ + (Whole M s₀' b ∧ CallPre b (fW s₀') (fIv s₀') (fS s₀') (fR s₀'))) fun a b h => by have e₂ := h.2.2 have eW : fW s₀' = fW s₀ := qW.symm @@ -1036,24 +1036,24 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} have eR : fR s₀' = fR s₀ := by simp only [fR, qR] rw [eW, eIv, eS, eR] at e₂ exact ⟨_, _, _, _, h.1.2, e₂, by rw [h.1.1.rsp, h.2.1.rsp, fSp, fSp, qSp]⟩).wp - (F₁ := Ciph (cfbMode enc) s₀) (F₂ := Ciph (cfbMode enc) s₀') + (F₁ := Ciph M s₀) (F₂ := Ciph M s₀') fun a b h => ⟨final_ciph_wp v hp h.1, final_ciph_wp v hp' h.2⟩ have a₇ := (RelCT.taint (A := taint) - (P := fun a b => Ciph (cfbMode enc) s₀ a ∧ Ciph (cfbMode enc) s₀' b) _ + (P := fun a b => Ciph M s₀ a ∧ Ciph M s₀' b) _ (fun a b h => Taint.agree_ofRegs fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl · rw [h.1.r12, h.2.r12, fIv, fIv, qIv] · rw [h.1.r13, h.2.r13, qT] · rw [h.1.r14, h.2.r14, qU]) t₆).wp - (F₁ := Done (cfbMode enc) s₀) (F₂ := Done (cfbMode enc) s₀') + (F₁ := Done M s₀) (F₂ := Done M s₀') fun a b h => ⟨final_xor_wp hp h.1 hu, final_xor_wp hp' h.2 hu'⟩ exact (a₅.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((a₆.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₇.mono (fun _ _ h => h) fun _ _ h => h.2)) - have r₅ : RelCT isa (fun a b => (Whole (cfbMode enc) s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ - (Whole (cfbMode enc) s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) + have r₅ : RelCT isa (fun a b => (Whole M s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (Whole M s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) (.ite .e (.block []) (finalTail v.enc)) - (fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) := by + (fun a b => Done M s₀ a ∧ Done M s₀' b) := by refine RelCT.ite (fun a b h => ?_) ?_ ?_ · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] · refine RelCT.block_nil fun a b h => ?_ @@ -1065,7 +1065,7 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this -- `save` to `rax`, and the registers restored. have r₆ := (RelCT.taint (A := taint) - (P := fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) _ + (P := fun a b => Done M s₀ a ∧ Done M s₀' b) _ (fun a b h => Taint.agree_ofRegs fun r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.rsp, h.2.rsp, fSp, fSp, qSp]) t₁).wp (F₁ := fun (s : State) => s.gpr .rax = fV s₀) (F₂ := fun (s : State) => s.gpr .rax = fV s₀') @@ -1080,10 +1080,10 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} ((r₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₄.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₅.seq (r₆.seq r₇))))) -theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeX86_64 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86_64 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeX86_64 (cfbMode enc)).pre (modeX86_64 (cfbMode enc)).pub whole) +theorem final_ct {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86_64 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86_64 M).post s s') + (hct : ConstantTime isa (modeX86_64 M).pre (modeX86_64 M).pub whole) (hsp : NoSp whole) (hd : whole.depth = 1) (v : BlocksImpl) : ConstantTime isa (finalX86_64 enc).pre (finalX86_64 enc).pub (final name whole v.enc) := fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct hsp hd v h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 diff --git a/lean/VerifiedGarbage/Proof/AesCtr/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/Final.lean new file mode 100644 index 00000000000..0a606bb611f --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/Final.lean @@ -0,0 +1,170 @@ +module + +public import VerifiedGarbage.Spec.Ctr.Final +public import VerifiedGarbage.Proof.Framework.PostMono +public import VerifiedGarbage.Proof.Framework.Scratch +import VerifiedGarbage.Proof.Framework.Offset + +-- separate module: shared by the final functions' proofs of every target. + +/-! +# AES-CTR of a message's last piece: the contract on the key schedule it is given + +Not trusted, and the same on every target. `finalRoundsContract`: the +contract of `vg_aes_ctr_final` for the key schedule and the number of rounds +it is given, as `Rounds.lean`'s for the whole-block function, from which the +shared contract of `Spec/Ctr/Final.lean` follows (`final_keyed`). Its +postcondition reads the memory, on entry and on return, and its leak, only +within the function's buffers (`finalPost_local`, `finalPost_localOut`, +`finalLeak_local`), as a frame that keeps more working space on the stack +needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by +`Proof.Modes.CtrFinal.cryptFinal_of`, for any cipher. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr + +open VG +open VG.Spec.Aes (bytesAt) + +theorem aesWith_length (nr : Nat) (w : List Byte) (b : List Byte) : (Spec.Cbc.aesWith nr w b).length = 16 := by + simp [Spec.Cbc.aesWith] + +/-! ## The contract -/ + +open VG.Spec.Ctr + +/-- The final function's precondition: 10, 12 or 14 rounds. -/ +def finalPre (pb : Nat) : Curry (aesFinalSig.words pb) (Mem → Prop) := + fun _schedule rounds _iv _data _len _scratch _ => rounds.toNat = 10 ∨ rounds.toNat = 12 ∨ rounds.toNat = 14 + +/-- AES with the key schedule in the first `16 (rounds + 1)` bytes at +`schedule`. -/ +abbrev ciphAt (m : Mem) (schedule : Addr) (rounds : Nat) : Spec.Cbc.Cipher := + Spec.Cbc.aesWith rounds (bytesAt m schedule (16 * (rounds + 1))) + +/-- The final function's postcondition, by AES with the key schedule it is +given, for 10, 12 or 14 rounds (so that it reads only the schedule's 240 +bytes). -/ +def finalPost (pb : Nat) : aesFinalSig.Post pb := + fun schedule rounds iv data len _scratch m m' _ => + (rounds.toNat = 10 ∨ rounds.toNat = 12 ∨ rounds.toNat = 14) → + CryptFinal (ciphAt m schedule rounds.toNat) m m' iv data len.toNat + +/-- What the final function's timing may depend on, besides its public +arguments: the counter block's last four bytes. -/ +def finalLeak (pb : Nat) : Curry (aesFinalSig.words pb) (Mem → List Nat) := + fun _schedule _rounds ctr _data _len _scratch m => ctrLeak m ctr + +/-- For `rounds` of 10, 12 or 14, with the key schedule `w` in the first +`16 (rounds + 1)` bytes at `schedule`: replaces the `len` bytes at `data` +with their CTR encryption or decryption by AES with `w`, a partial last +block included, from the counter block at `iv`, and that block with `Tₙ₊₁` +(`Spec.Ctr.CryptFinal`). Its timing may depend on the counter block's last +four bytes (`Spec.Ctr.ctrLeak`). -/ +def finalRoundsContract {M : ISA} (A : Abi M) (stack : Nat := 0) : Contract M := + aesFinalSig.contract A (pre := finalPre A.ptrBits) (post := finalPost A.ptrBits) + (leak := some (finalLeak A.ptrBits)) (stack := stack) + +/-- `Spec.Ctr.aesFinalContract` from `finalRoundsContract`. -/ +theorem final_keyed {T : Target} {c : Prog T.isa} {A : Abi T.isa} {stack : Nat} + (h : Verified T c (finalRoundsContract A stack)) : + Verified T c (Spec.Ctr.aesFinalContract A stack) := + h.post_mono fun _ _ _ _ _ _ _ _ _ hp key ⟨hk, hr, hw⟩ => by + dsimp only [finalPost, ciphAt] at hp + have h' := hp (by rw [hr]; rcases hk with h | h | h <;> rw [h] <;> decide) + rw [hw, hr] at h' + exact h' + +/-! ## Locality -/ + +section +variable {m₁ m₂ : Mem} {p : Addr} + +private theorem bytesAt_congr {n : Nat} (h : ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + bytesAt m₂ p n = bytesAt m₁ p n := + List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +private theorem agree_of {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : + ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by + intro i hi + refine (h _ ?_).symm + by_cases hw : i < 2 ^ 64 + · exact Offset.contains_base _ (by omega) hw + · simp only [Region.Contains] + have := (p + BitVec.ofNat 64 i - p).isLt + omega + +/-- Memories that agree within the final function's buffers agree on the +schedule, the block and the data. -/ +private theorem final_bufs {pb : Nat} {vs : List (BitVec 64)} (hlen : vs.length = 6) + (hb : ∀ r ∈ Sig.bufs aesFinalSig.params vs, ∀ a, r.1.Contains a 1 → m₁ a = m₂ a) : + ∃ k rounds iv data len scr, vs = [k, rounds, iv, data, len, scr] ∧ + (∀ n ≤ 240, bytesAt m₂ k n = bytesAt m₁ k n) ∧ + bytesAt m₂ iv 16 = bytesAt m₁ iv 16 ∧ + bytesAt m₂ data (len.setWidth pb).toNat = bytesAt m₁ data (len.setWidth pb).toNat := by + match vs, hlen with + | [k, rounds, iv, data, len, scr], _ => + simp only [aesFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hk := agree_of hb.1 + have hv := agree_of hb.2.1 + have hd := agree_of hb.2.2.1 + have := Nat.mod_le len.toNat (2 ^ pb) + exact ⟨k, rounds, iv, data, len, scr, rfl, fun n hn => bytesAt_congr fun i hi => hk i (by omega), + bytesAt_congr hv, bytesAt_congr fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega)⟩ + +end + +variable (pb : Nat) + +theorem finalPre_local : ∀ vs m₁ m₂, vs.length = (aesFinalSig.words pb).length → + (∀ b ∈ Sig.bufs aesFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (aesFinalSig.words pb) (finalPre pb) vs m₁ → Curry.apply (aesFinalSig.words pb) (finalPre pb) vs m₂ := by + intro vs m₁ m₂ hlen _ h + match vs, hlen with + | [_, _, _, _, _, _], _ => exact h + +/-- `finalPost` reads the memory on entry only within the buffers. -/ +theorem finalPost_local : ∀ vs m₁ m₂ m' r, vs.length = (aesFinalSig.words pb).length → + (∀ b ∈ Sig.bufs aesFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m₁ m' r → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + obtain ⟨k, rounds, iv, data, len, scr, rfl, hk, hv, hd⟩ := final_bufs (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m₂ m' r + dsimp only [Curry.apply, finalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal, ciphAt] at h ⊢ + intro hr + obtain ⟨h1, h2⟩ := h hr + rw [hk _ (by rcases hr with h | h | h <;> omega), hv, hd] + exact ⟨h1, h2⟩ + +/-- `finalPost` reads the memory on return only within the buffers. -/ +theorem finalPost_localOut : ∀ vs m m₁ m₂ r, vs.length = (aesFinalSig.words pb).length → + (∀ b ∈ Sig.bufs aesFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m m₁ r → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + obtain ⟨k, rounds, iv, data, len, scr, rfl, -, hv, hd⟩ := final_bufs (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m m₂ r + dsimp only [Curry.apply, finalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + intro hr + rw [hv, hd] + exact h hr + +/-- The leak, `Spec.Ctr.ctrLeak`, reads the memory only within the +buffers. -/ +theorem finalLeak_local : Sig.LeakLocal pb aesFinalSig (some (finalLeak pb)) := by + intro vs m₁ m₂ hlen hb + obtain ⟨k, rounds, iv, data, len, scr, rfl, -, hv, -⟩ := final_bufs (pb := pb) hlen hb + change ctrLeak m₁ iv = ctrLeak m₂ iv + simp only [ctrLeak, hv] + +end VG.Proof.AesCtr diff --git a/lean/VerifiedGarbage/Proof/AesCtr/X86_64/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/X86_64/Final.lean new file mode 100644 index 00000000000..0e1792316b4 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/X86_64/Final.lean @@ -0,0 +1,1120 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.X86_64.Final +public import VerifiedGarbage.Proof.AesCtr.Final +public import VerifiedGarbage.Proof.AesCtr.X86_64.Verified +public import VerifiedGarbage.Proof.AesCfb.X86_64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.X86_64.Spill +public import VerifiedGarbage.Impl.StackScratch.X86_64 +public import VerifiedGarbage.Proof.AesCtr.X86_64.CT +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCtr.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.X86_64.FbFinal +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86_64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.X86_64.RegUpd +import VerifiedGarbage.Proof.Framework.X86_64.Exec +import VerifiedGarbage.Proof.Framework.X86_64.Reduce +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.Framework.X86_64.StackArgScratchWipe +meta import VerifiedGarbage.Impl.AesCtr.X86_64.Final +meta import VerifiedGarbage.Proof.AesCtr.Final +meta import VerifiedGarbage.Proof.AesCtr.X86_64.Verified +meta import VerifiedGarbage.Proof.AesCfb.X86_64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.X86_64.Spill +meta import VerifiedGarbage.Impl.StackScratch.X86_64 +meta import VerifiedGarbage.Proof.AesCtr.X86_64.CT +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCtr.Spec +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.X86_64.FbFinal +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.X86_64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.X86_64.RegUpd +meta import VerifiedGarbage.Proof.Framework.X86_64.Exec +meta import VerifiedGarbage.Proof.Framework.X86_64.Reduce +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.Framework.X86_64.StackArgScratchWipe + +/-! +# AES-CTR of a message's last piece on x86-64 + +`cryptFinal_framed`: `vg_aes_ctr_final` (`Impl/AesCtr/X86_64/Final.lean`), for +any implementation `v` of `vg_aes_ctr32` (`Ctr32Impl`), meets +`Proof.AesCtr.finalRoundsContract`, from which the shared contract follows +(`Proof.AesCtr.final_keyed`). + +The code is proven against `ctrFinalX86_64`, with a seventh argument `save` +of 64 bytes on the stack, for its caller's registers and a block of its own +(`final_implies`: the shared contract with it, `finalScratchContract`), as a +caller of the whole-block function, through its contract +(`modeX86_64 ctrMode`, with `ctrPub`). It shares AES-CFB's final functions' +setup and restore (`Proof/AesCfb/X86_64/Final.lean`: `Setup`, `Whole`): + +* `final_setup_wp`, `whole_wp`: the registers saved, and the whole-block + function on the `n = len / 16` whole blocks (`Whole`); +* `final_mid_wp`: if `u = len % 16` bytes are left, the block after the + registers in `save` zeroed and the whole-block function on it + (`tail_args_wp`, `tail_call_wp`), which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed into them + (`Modes.X86_64.xorLoop_wp`, `tail_xor_wp`); what is left before the + registers are restored is `Done`; +* `final_end_wp`: the registers restored; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the whole-block function's constant time, whose public data, the last 32 +bits of the counter block, agree in both runs at both calls: they do on +entry (the contract's leak), and after `n` blocks they are those on entry +plus `n` modulo `2³²`. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr.X86_64 + +open VG VG.X86_64 +open VG.Spec.Aes (bytesAt) +open VG.X86_64.RegUpd +open VG.Impl.AesCtr.X86_64 (tailArgs tailMoves tailKey zeroSlots finalTail final cryptFinal crypt) +open VG.Impl.AesCfb.X86_64 (loadSave finalSetup finalRestore finalSaved finalMoves) +open VG.Proof.AesCfb.X86_64 (fW fR fIv fD fL fS fV fSp fN fU fT fSch fIvR fData fBlk fTail fScr fSv fArg fStk + fWk fIv0 fBlks fG svMem Setup Whole) +open VG.Proof.AesCbc (Mode) +open VG.Proof.AesCbc.X86_64 (modeX86_64 callEntry_frame bytesAt_frame) +open VG.Proof.Aes.X86_64 (Ctr32Impl) + +/-- The code's contract, with the arguments `(schedule = rdi, rounds = rsi, +ctr = rdx, data = rcx, len = r8, scratch = r9, save = [rsp + 8])`, `save` of +64 bytes: the data and the counter block as `Spec.Ctr.CryptFinal` says, by +AES with the key schedule it is given; the counter block's last four bytes +are public. -/ +def ctrFinalX86_64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .rdi, 240⟩ + let iv : Region := ⟨s.gpr .rdx, 16⟩ + let data : Region := ⟨s.gpr .rcx, (s.gpr .r8).toNat⟩ + let scr : Region := ⟨s.gpr .r9, 2176⟩ + let sv : Region := ⟨stackArg s 0, 64⟩ + let args : Region := ⟨stackArgAddr s 0, 8⟩ + let ret : Region := ⟨s.gpr .rsp, 8⟩ + let stack := below (s.gpr .rsp) 16 + 16 ≤ (s.gpr .rsp).toNat ∧ (s.gpr .rsp).toNat + 16 ≤ 2 ^ 64 ∧ + s.rd = [sched, args] ∧ s.wr = [iv, data, scr, sv] ∧ + sched.Disjoint iv ∧ sched.Disjoint data ∧ sched.Disjoint scr ∧ sched.Disjoint sv ∧ + iv.Disjoint data ∧ iv.Disjoint scr ∧ iv.Disjoint sv ∧ iv.Disjoint args ∧ + data.Disjoint scr ∧ data.Disjoint sv ∧ data.Disjoint args ∧ + scr.Disjoint sv ∧ scr.Disjoint args ∧ sv.Disjoint args ∧ + ret.Disjoint sched ∧ ret.Disjoint iv ∧ ret.Disjoint data ∧ ret.Disjoint scr ∧ ret.Disjoint sv ∧ + ret.Disjoint args ∧ + stack.Disjoint sched ∧ stack.Disjoint iv ∧ stack.Disjoint data ∧ stack.Disjoint scr ∧ + stack.Disjoint sv ∧ stack.Disjoint args ∧ + (s.gpr .rdi).toNat + 240 ≤ 2 ^ 64 ∧ (s.gpr .rdx).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .rcx).toNat + (s.gpr .r8).toNat ≤ 2 ^ 64 ∧ (s.gpr .r9).toNat + 2176 ≤ 2 ^ 64 ∧ + (stackArg s 0).toNat + 64 ≤ 2 ^ 64 ∧ + ((s.gpr .rsi).toNat = 10 ∨ (s.gpr .rsi).toNat = 12 ∨ (s.gpr .rsi).toNat = 14) + post s s' := + Spec.Ctr.CryptFinal (ciphAt s.mem (s.gpr .rdi) (s.gpr .rsi).toNat) s.mem s'.mem (s.gpr .rdx) (s.gpr .rcx) + (s.gpr .r8).toNat + pub s₁ s₂ := + (s₁.gpr .rdi = s₂.gpr .rdi ∧ s₁.gpr .rsi = s₂.gpr .rsi ∧ s₁.gpr .rdx = s₂.gpr .rdx ∧ + s₁.gpr .rcx = s₂.gpr .rcx ∧ s₁.gpr .r8 = s₂.gpr .r8 ∧ s₁.gpr .r9 = s₂.gpr .r9 ∧ + s₁.gpr .rsp = s₂.gpr .rsp ∧ stackArg s₁ 0 = stackArg s₂ 0) ∧ + Spec.Ctr.ctrLeak s₁.mem (s₁.gpr .rdx) = Spec.Ctr.ctrLeak s₂.mem (s₂.gpr .rdx) + +/-- The contract the frame needs: the shared one, with `save`, 64 bytes, as +a seventh argument, and 16 bytes of stack (the return addresses of the +whole-block function and of `vg_aes_ctr32`, which it calls). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract X86_64.abi Spec.Ctr.aesFinalSig "save" .u64 8 (finalPre X86_64.abi.ptrBits) + (finalPost X86_64.abi.ptrBits) false 16 (some (finalLeak X86_64.abi.ptrBits)) + +def ctrSatState : State := { AesCfb.X86_64.finalSatState with + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩, ⟨0x6000, 64⟩] } + +theorem final_implies : ctrFinalX86_64.Implies finalScratchContract where + pre := by + intro s h + sig_pre [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, abi, argRegs, ctrFinalX86_64, + AesCfb.X86_64.args_getD, AesCfb.X86_64.stackArgs_one, List.append_eq] at h + sig_pre [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, abi, argRegs, ctrFinalX86_64, + AesCfb.X86_64.args_getD, AesCfb.X86_64.stackArgs_one, List.append_eq] at h + sig_split h + sig_reduce [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, abi, argRegs, ctrFinalX86_64, + AesCfb.X86_64.args_getD, AesCfb.X86_64.stackArgs_one, List.append_eq] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + post := by + sig_implies_post [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, abi, argRegs, ctrFinalX86_64, + AesCfb.X86_64.args_getD, AesCfb.X86_64.stackArgs_one, List.append_eq] + pub := by + rintro s₁ s₂ - - h + sig_pub [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, abi, argRegs, ctrFinalX86_64, + AesCfb.X86_64.args_getD, AesCfb.X86_64.stackArgs_one, List.append_eq] at h + simp only [List.getD_cons_succ, List.getD_cons_zero] at h + sig_split h + rename_i h1 h2 h3 h4 h5 h6 h7 h8 + exact ⟨⟨h3, h4, h5, h6, h7, h8, h1, h⟩, h2⟩ + sat := by + sig_implies_sat [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, abi, argRegs, ctrFinalX86_64, + AesCfb.X86_64.args_getD, AesCfb.X86_64.stackArgs_one, List.append_eq] + [ctrSatState, AesCfb.X86_64.finalSatState, stackArg, stackArgAddr, Mem.readW, Mem.read] + using ctrSatState + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`, the registers then the block. -/ +abbrev cSv : Region := ⟨fV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev cBk : Addr := fV s₀ + BitVec.ofNat 64 48 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ +/-- The counter block on entry. -/ +abbrev cT : List Byte := bytesAt s₀.mem (fIv s₀) 16 + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + sp_lo : 16 ≤ (fSp s₀).toNat + sp_hi : (fSp s₀).toNat + 16 ≤ 2 ^ 64 + rd : s₀.rd = [fSch s₀, fArg s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_scr : (fSch s₀).Disjoint (fScr s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_scr : (fIvR s₀).Disjoint (fScr s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + iv_arg : (fIvR s₀).Disjoint (fArg s₀) + data_scr : (fData s₀).Disjoint (fScr s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_arg : (fData s₀).Disjoint (fArg s₀) + scr_sv : (fScr s₀).Disjoint (cSv s₀) + scr_arg : (fScr s₀).Disjoint (fArg s₀) + sv_arg : (cSv s₀).Disjoint (fArg s₀) + ret_sch : (⟨fSp s₀, 8⟩ : Region).Disjoint (fSch s₀) + ret_iv : (⟨fSp s₀, 8⟩ : Region).Disjoint (fIvR s₀) + ret_data : (⟨fSp s₀, 8⟩ : Region).Disjoint (fData s₀) + ret_scr : (⟨fSp s₀, 8⟩ : Region).Disjoint (fScr s₀) + ret_sv : (⟨fSp s₀, 8⟩ : Region).Disjoint (cSv s₀) + ret_arg : (⟨fSp s₀, 8⟩ : Region).Disjoint (fArg s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_iv : (fStk s₀).Disjoint (fIvR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_scr : (fStk s₀).Disjoint (fScr s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + stk_arg : (fStk s₀).Disjoint (fArg s₀) + sch_wrap : (fW s₀).toNat + 240 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + scr_wrap : (fS s₀).toNat + 2176 ≤ 2 ^ 64 + sv_wrap : (fV s₀).toNat + 64 ≤ 2 ^ 64 + rounds : fR s₀ = 10 ∨ fR s₀ = 12 ∨ fR s₀ = 14 + +theorem CPre.of {s₀ : State} (h : ctrFinalX86_64.pre s₀) : CPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36⟩ + +/-! ## Regions -/ + +theorem sv48_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.sched_sub : Region.Sub ⟨fW s₀, 16 * (fR s₀ + 1)⟩ (fSch s₀) := + Region.sub_prefix (by rcases hp.rounds with h | h | h <;> omega) + +theorem CPre.sched_len : 16 * (fR s₀ + 1) ≤ 2 ^ 64 := by + rcases hp.rounds with h | h | h <;> omega + +theorem CPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [AesCfb.X86_64.fN_eq]; omega + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [AesCfb.X86_64.fN_eq, AesCfb.X86_64.fU_eq]; omega) + +omit hp in +/-- The slots of the registers miss the block. -/ +theorem slot_blk : ∀ p ∈ finalSaved, Region.Disjoint ⟨Spill.slot (fV s₀) p.2, 8⟩ (cBlk s₀) := by + intro p hp' + have := AesCfb.X86_64.saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +end + +/-! ## Saving the registers, and the whole blocks -/ + +theorem final_load_wp {s₀ : State} (hp : CPre s₀) : + WP isa (.block loadSave) s₀ (· = s₀.setReg .rax (fV s₀)) := + WP.of_runBlock ⟨_, AesCfb.X86_64.loadSave_ok s₀ (by rw [hp.rd, hp.wr]; exact ⟨fArg s₀, by simp, + Region.contains_self _ _⟩), rfl⟩ + +theorem final_setup_wp {s₀ : State} (hp : CPre s₀) : + WP isa (.block finalSetup) (s₀.setReg .rax (fV s₀)) (Setup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions (s₀.setReg .rax (fV s₀)).wr + (Spill.slot ((s₀.setReg .rax (fV s₀)).gpr .rax) p.2) 8 := by + intro p hp' + rw [wr_setReg, gpr_setReg_self, hp.wr] + have := AesCfb.X86_64.saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .rax finalSaved ++ finalMoves)) _ _ + refine Spill.save_then .rax finalSaved hw ?_ + refine WP.mono (WP.of_runBlock (AesCfb.X86_64.moves_ok _)) + fun s' ⟨rbx, rbp, r12, r15, r14, r13, r8, rdi, rsi, rdx, rcx, r9, rsp, _, mem, rd, wr⟩ => ?_ + simp only [gpr_setReg, reduceCtorEq, ↓reduceIte] at rbx rbp r12 r15 r14 r13 r8 rdi rsi rdx rcx r9 rsp + exact ⟨rbx, rbp, r12, by rw [r13, AesCfb.X86_64.and15, AesCfb.X86_64.tail_addr], + by rw [r14, AesCfb.X86_64.and15], r15, rdi, rsi, rdx, rcx, + by rw [r8, AesCfb.X86_64.shr4], r9, rsp, by rw [mem, mem_setReg, gpr_setReg_self], by rw [rd, rd_setReg], + by rw [wr, wr_setReg]⟩ + +theorem crypt_noSp (v : Ctr32Impl) : NoSp (crypt v.callee) := + AesCfb.X86_64.noSp_of_all (by + simp only [crypt, Impl.AesCtr.X86_64.body, Code.allInstrs, AesCfb.X86_64.all_of_noSp v.nosp] + decide +kernel) + +theorem crypt_depth (v : Ctr32Impl) : (crypt v.callee).depth = 1 := by + simp only [crypt, Impl.AesCtr.X86_64.body, Code.depth, v.depth] + decide + +/-- The whole-block function's contract: `modeX86_64 ctrMode`, with the last +32 bits of the counter block public. -/ +abbrev wholeK : Contract isa := { modeX86_64 AesCtr.ctrMode with pub := ctrPub } + +theorem whole_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, fBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, fBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, fBlk s₀, fScr s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [modeX86_64, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + State.callEntry_rsp, State.callEntry_gpr s (by decide : Reg.rdi ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rsi ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rdx ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rcx ≠ .rsp), State.callEntry_gpr s (by decide : Reg.r8 ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.r9 ≠ .rsp), h.rdi, h.rsi, h.rdx, h.rcx, h.r8, h.r9, h.rsp, + AesCfb.X86_64.toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (AesCfb.X86_64.blk_sub s₀), hp.sch_scr, + hp.iv_data.sub_right (AesCfb.X86_64.blk_sub s₀), hp.iv_scr, hp.data_scr.sub_left (AesCfb.X86_64.blk_sub s₀), + hp.stk_iv.sub_left (AesCfb.X86_64.ret8_sub _), + (hp.stk_data.sub_left (AesCfb.X86_64.ret8_sub _)).sub_right (AesCfb.X86_64.blk_sub s₀), + hp.stk_scr.sub_left (AesCfb.X86_64.ret8_sub _), hp.stk_sch.sub_left (AesCfb.X86_64.callee8_sub _), + hp.stk_iv.sub_left (AesCfb.X86_64.callee8_sub _), + (hp.stk_data.sub_left (AesCfb.X86_64.callee8_sub _)).sub_right (AesCfb.X86_64.blk_sub s₀), + hp.stk_scr.sub_left (AesCfb.X86_64.callee8_sub _), hp.iv_wrap, hp.blk_wrap, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- The schedule, the counter block and the whole blocks at the call, as on +entry. -/ +theorem entry_bytes {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + bytesAt s.callEntry.mem (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ ∧ bytesAt s.callEntry.mem (fIv s₀) 16 = fIv0 s₀ ∧ + Spec.Cbc.blocksAt s.callEntry.mem (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := AesCfb.X86_64.entry_frame h.mem h.rsp + refine ⟨bytesAt_frame ef (fun r hr => ?_) hp.sched_len, bytesAt_frame ef (fun r hr => ?_) (by decide), + AesCfb.X86_64.blocksAt_frame' ef fun r hr => ?_⟩ <;> + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr <;> rcases hr with rfl | rfl + · exact (hp.sch_sv.sub_left hp.sched_sub).sub_right (sv48_sub s₀) + · exact hp.stk_sch.symm.sub_left hp.sched_sub + · exact hp.iv_sv.sub_right (sv48_sub s₀) + · exact hp.stk_iv.symm + · exact (hp.data_sv.sub_left (AesCfb.X86_64.blk_sub s₀)).sub_right (sv48_sub s₀) + · exact hp.stk_data.symm.sub_left (AesCfb.X86_64.blk_sub s₀) + +theorem whole_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WP isa (.call ("vg_aes_ctr" ++ v.suffix) (crypt v.callee)) s (Whole AesCtr.ctrMode s₀) := by + obtain ⟨eW, eIv, eB⟩ := entry_bytes hp h + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.call (k := wholeK) (crypt_correct v) (crypt_noSp v) (by rw [crypt_depth v]; decide) (rd := [fSch s₀]) + (wr := [fIvR s₀, fBlk s₀, fScr s₀]) hpre hc hw ?_ + intro s' rd' wr' cs' fr' _ ⟨s₂, mem₂, _, post₂⟩ + rw [crypt_depth v, h.rsp, h.mem] at fr' + simp only [modeX86_64, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_gpr s (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rsi ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rdx ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rcx ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.r8 ≠ .rsp), h.rdi, h.rsi, h.rdx, h.rcx, h.r8, + AesCfb.X86_64.toNat_n, mem₂, eW, eIv, eB] at post₂ + exact ⟨by rw [cs' .rbx (by simp [calleeSaved]), h.rbx], by rw [cs' .rbp (by simp [calleeSaved]), h.rbp], + by rw [cs' .r12 (by simp [calleeSaved]), h.r12], by rw [cs' .r13 (by simp [calleeSaved]), h.r13], + by rw [cs' .r14 (by simp [calleeSaved]), h.r14], by rw [cs' .r15 (by simp [calleeSaved]), h.r15], + by rw [cs' .rsp (by simp [calleeSaved]), h.rsp], by rw [rd', h.rd], by rw [wr', h.wr], fr', post₂.1, + post₂.2⟩ + +/-! ## The partial last block: its arguments -/ + +/-- Two zeroed quadwords make 16 zero bytes. -/ +theorem zero_bytes (m : Mem) (B : Addr) : + bytesAt ((m.writeW B (0 : BitVec 64)).writeW (B + BitVec.ofNat 64 8) (0 : BitVec 64)) B 16 = + List.replicate 16 0 := by + apply List.ext_getElem (by simp [bytesAt]) + intro i h₁ _ + have hi : i < 16 := by simpa [bytesAt] using h₁ + simp only [bytesAt, List.getElem_map, List.getElem_range, List.getElem_replicate, Mem.writeW, Mem.write, + Mem.sub_ofNat_toNat B (show i < 2 ^ 64 by omega), Offset.sub_toNat' B (show 8 < 2 ^ 64 by decide) + (show i < 2 ^ 64 by omega)] + by_cases h8 : 8 ≤ i + · rw [ite_eq_left h8, ite_eq_left (by omega)]; simp + · rw [ite_eq_right h8, ite_eq_right (by omega), ite_eq_left (by omega)]; simp + +theorem tailMoves_ok (s : State) : + ∃ s', runBlock isa tailMoves s = some s' ∧ + s'.gpr .rdi = s.gpr .rbx ∧ s'.gpr .rsi = s.gpr .rbp ∧ s'.gpr .rdx = s.gpr .r12 ∧ + s'.gpr .rcx = s.gpr .rax + BitVec.ofNat 64 48 ∧ s'.gpr .r8 = 1 ∧ s'.gpr .r9 = s.gpr .r15 ∧ + (∀ r ∈ calleeSaved, s'.gpr r = s.gpr r) ∧ s'.gpr .r13 = s.gpr .r13 ∧ s'.gpr .r14 = s.gpr .r14 ∧ + s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [tailMoves, runBlock_cons, runStep_some, reduceExec, execAlu, readSrc, Option.bind_some, + Option.map_some] + rfl, ?_⟩ + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> + try simp [gpr_setReg, State.setReg32, mem_arithFlags, rd_arithFlags, wr_arithFlags, mem_setReg, rd_setReg, + wr_setReg] + intro r hr + simp only [calleeSaved, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp + +theorem zero_ok (s : State) : + ∃ s', runBlock isa [.mov32 .r10 (.imm 0)] s = some s' ∧ s'.gpr .r10 = 0 ∧ + (∀ r, r ≠ .r10 → s'.gpr r = s.gpr r) ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [runBlock_cons, reduceExec] + rfl, ?_⟩ + refine ⟨?_, fun r hr => ?_, rfl, rfl, rfl⟩ + · simp [gpr_setReg, State.setReg32] + · simp [gpr_setReg, State.setReg32, hr] + +/-! ## Frames -/ + +section +variable (s₀ : State) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, fScr s₀, cBlk s₀, fStk s₀] +/-- What the function writes after saving the registers. -/ +abbrev cW : List Region := [fIvR s₀, fData s₀, fScr s₀, cBlk s₀, fStk s₀] +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] + +end + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, AesCfb.X86_64.blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem whole_cW1 {M : Mode} {s₀ s : State} (h : Whole M s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h | h <;> simp [h] + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((AesCfb.X86_64.svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv48_sub s₀⟩).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +/-- `save`'s address, on the stack, is unchanged. -/ +theorem arg_keep {s₀ : State} (hp : CPre s₀) {s : State} (hsp : s.gpr .rsp = fSp s₀) + (hf : Frame (cBig s₀) s₀.mem s.mem) : stackArgAddr s 0 = stackArgAddr s₀ 0 ∧ stackArg s 0 = fV s₀ := by + have hA : stackArgAddr s 0 = stackArgAddr s₀ 0 := by simp only [stackArgAddr, hsp] + refine ⟨hA, ?_⟩ + show s.mem.readW (stackArgAddr s 0) 64 = s₀.mem.readW (stackArgAddr s₀ 0) 64 + rw [hA] + refine hf.readW (r := fArg s₀) (Region.contains_self _ _) (fun r hr => ?_) (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.iv_arg.symm + · exact hp.data_arg.symm + · exact hp.scr_arg.symm + · exact hp.sv_arg.symm + · exact hp.stk_arg.symm + +/-- `save` to `rax`, from a state whose stack pointer and argument slot are +as on entry. -/ +theorem load_ok {s₀ : State} (hp : CPre s₀) {s : State} (hsp : s.gpr .rsp = fSp s₀) (hrd : s.rd = s₀.rd) + (hwr : s.wr = s₀.wr) (hf : Frame (cBig s₀) s₀.mem s.mem) : + runBlock isa loadSave s = some (s.setReg .rax (fV s₀)) := by + obtain ⟨hA, hV⟩ := arg_keep hp hsp hf + rw [← hV] + exact AesCfb.X86_64.loadSave_ok s (by rw [hrd, hwr, hp.rd, hp.wr, hA]; exact ⟨fArg s₀, by simp, + Region.contains_self _ _⟩) + +/-! ## The partial last block -/ + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + rdi : s.gpr .rdi = fW s₀ + rsi : s.gpr .rsi = s₀.gpr .rsi + rdx : s.gpr .rdx = fIv s₀ + rcx : s.gpr .rcx = cBk s₀ + r8 : s.gpr .r8 = 1 + r9 : s.gpr .r9 = fS s₀ + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [cBlk s₀] m (Spill.saveMem m (fV s₀) g zeroSlots) := + Spill.saveMem_frame m _ g zeroSlots fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + +/-- `save` to `rax`, from a state `F` describes. -/ +abbrev Loaded (F : State → Prop) (s₀ s : State) : Prop := ∃ w, F w ∧ s = w.setReg .rax (fV s₀) + +theorem tail_load_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block loadSave) s (Loaded (Whole AesCtr.ctrMode s₀) s₀) := + WP.of_runBlock ⟨_, load_ok hp h.rsp h.rd h.wr (big_of (cW1_cW (whole_cW1 h))), s, h, rfl⟩ + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block tailArgs) (s.setReg .rax (fV s₀)) (TArgs s₀) := by + have f₁ := whole_cW1 h + obtain ⟨s₂, r₂, z₂, k₂, m₂, rd₂, wr₂⟩ := zero_ok (s.setReg .rax (fV s₀)) + show WP isa (.block ([.mov32 .r10 (.imm 0)] ++ (Spill.saveCode .rax zeroSlots ++ tailMoves))) _ _ + refine WP.block_append_iff.mpr (WP.of_runBlock ⟨s₂, r₂, ?_⟩) + have k₂' : ∀ r, r ≠ .r10 → r ≠ .rax → s₂.gpr r = s.gpr r := fun r h₁ h₂ => by + rw [k₂ r h₁, gpr_setReg_of_ne _ _ h₂] + have hrax : s₂.gpr .rax = fV s₀ := by rw [k₂ _ (by decide), gpr_setReg_self] + have hw : ∀ p ∈ zeroSlots, InRegions s₂.wr (Spill.slot (s₂.gpr .rax) p.2) 8 := by + intro p hp' + rw [wr₂, wr_setReg, h.wr, hp.wr, hrax] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + refine Spill.save_then .rax zeroSlots hw ?_ + refine WP.mono (WP.of_runBlock (tailMoves_ok _)) + fun s' ⟨rdi, rsi, rdx, rcx, r8, r9, cs, r13, r14, mem, rd, wr⟩ => ?_ + have e : ∀ r, ({ s₂ with mem := Spill.saveMem s₂.mem (s₂.gpr .rax) s₂.gpr zeroSlots } : State).gpr r = + s₂.gpr r := fun _ => rfl + rw [e] at rdi rsi rdx rcx r9 r13 r14 + have hm : s'.mem = Spill.saveMem s.mem (fV s₀) s₂.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₂.mem _ _ _ = _; rw [m₂, mem_setReg, hrax] + have fz : Frame [cBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (AesCfb.X86_64.blk_sub s₀)).sub_right (blk_sv_sub s₀) + refine ⟨by rw [rdi, k₂' _ (by decide) (by decide), h.rbx], by rw [rsi, k₂' _ (by decide) (by decide), h.rbp], + by rw [rdx, k₂' _ (by decide) (by decide), h.r12], by rw [rcx, hrax], r8, + by rw [r9, k₂' _ (by decide) (by decide), h.r15], by rw [r13, k₂' _ (by decide) (by decide), h.r13], + by rw [r14, k₂' _ (by decide) (by decide), h.r14], ?_, by rw [rd, rd₂, rd_setReg, h.rd], + by rw [wr, wr₂, wr_setReg, h.wr], ?_, ?_, ?_, ?_⟩ + · rw [cs .rsp (by simp [calleeSaved]), e, k₂' _ (by decide) (by decide), h.rsp] + · exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [AesCfb.X86_64.blocksAt_frame' fz blkZ]; exact h.blocks + · rw [bytesAt_frame fz ivZ (by decide), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + · rw [hm, show Spill.saveMem s.mem (fV s₀) s₂.gpr zeroSlots = + ((s.mem.writeW (cBk s₀) (s₂.gpr .r10)).writeW (cBk s₀ + BitVec.ofNat 64 8) (s₂.gpr .r10)) by + simp only [Spill.saveMem, zeroSlots, Spill.slot, Offset.add_add], z₂] + exact zero_bytes _ _ + +theorem one_toNat : (1 : BitVec 64).toNat = 1 := rfl + +theorem cBk_toNat {s₀ : State} (hp : CPre s₀) : (cBk s₀).toNat = (fV s₀).toNat + 48 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 48) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem tail_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, cBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, cBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, cBlk s₀, fScr s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [modeX86_64, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + State.callEntry_rsp, State.callEntry_gpr s (by decide : Reg.rdi ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rsi ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rdx ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rcx ≠ .rsp), State.callEntry_gpr s (by decide : Reg.r8 ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.r9 ≠ .rsp), h.rdi, h.rsi, h.rdx, h.rcx, h.r8, h.r9, h.rsp, + one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.sch_scr, + hp.iv_sv.sub_right bs, hp.iv_scr, (hp.scr_sv.sub_right bs).symm, + hp.stk_iv.sub_left (AesCfb.X86_64.ret8_sub _), + (hp.stk_sv.sub_left (AesCfb.X86_64.ret8_sub _)).sub_right bs, + hp.stk_scr.sub_left (AesCfb.X86_64.ret8_sub _), hp.stk_sch.sub_left (AesCfb.X86_64.callee8_sub _), + hp.stk_iv.sub_left (AesCfb.X86_64.callee8_sub _), + (hp.stk_sv.sub_left (AesCfb.X86_64.callee8_sub _)).sub_right bs, + hp.stk_scr.sub_left (AesCfb.X86_64.callee8_sub _), hp.iv_wrap, by rw [cBk_toNat hp]; omega, + hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 48, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 48, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBk s₀) 16 = Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem CPre.sched_big {s₀ : State} (hp : CPre s₀) : + ∀ r ∈ cBig s₀, (⟨fW s₀, 16 * (fR s₀ + 1)⟩ : Region).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.sch_iv.sub_left hp.sched_sub + · exact hp.sch_data.sub_left hp.sched_sub + · exact hp.sch_scr.sub_left hp.sched_sub + · exact hp.sch_sv.sub_left hp.sched_sub + · exact hp.stk_sch.symm.sub_left hp.sched_sub + +theorem tail_call_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + WP isa (.call ("vg_aes_ctr" ++ v.suffix) (crypt v.callee)) s (TCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have ef := callEntry_frame s + have stk : Region.Sub (below (s.gpr .rsp) 8) (fStk s₀) := by rw [h.rsp]; exact AesCfb.X86_64.below8_sub _ + have big := big_of (cW1_cW h.frame) + have eW : bytesAt s.callEntry.mem (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ := by + rw [bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.stk_sch.symm.sub_left hp.sched_sub).sub_right stk) hp.sched_len] + exact bytesAt_frame big hp.sched_big hp.sched_len + have eT : bytesAt s.callEntry.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) := by + rw [bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact hp.stk_iv.symm.sub_right stk) (by decide)] + exact h.ctr + have eZ : bytesAt s.callEntry.mem (cBk s₀) 16 = List.replicate 16 0 := by + rw [bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.stk_sv.symm.sub_left (blk_sv_sub s₀)).sub_right stk) (by decide)] + exact h.zero + refine WP.call (k := wholeK) (crypt_correct v) (crypt_noSp v) (by rw [crypt_depth v]; decide) (rd := [fSch s₀]) + (wr := [fIvR s₀, cBlk s₀, fScr s₀]) hpre hc hw ?_ + intro s' rd' wr' cs' fr' _ ⟨s₂, mem₂, _, post₂⟩ + rw [crypt_depth v, h.rsp] at fr' + simp only [modeX86_64, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_gpr s (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rsi ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rdx ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rcx ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.r8 ≠ .rsp), h.rdi, h.rsi, h.rdx, h.rcx, h.r8, one_toNat, mem₂, eW, + eT, AesCtr.ctrMode_out, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] at post₂ + have hrounds : (s₀.gpr .rsi).toNat = fR s₀ := rfl + rw [hrounds] at post₂ + have fc : Frame (cW1 s₀) s.mem s'.mem := fr'.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs' .r13 (by simp [calleeSaved]), h.r13], by rw [cs' .r14 (by simp [calleeSaved]), h.r14], + by rw [cs' .rsp (by simp [calleeSaved]), h.rsp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, + post₂.2, ?_⟩ + · rw [AesCfb.X86_64.blocksAt_frame' fr' fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (AesCfb.X86_64.blk_sub s₀) + · exact (hp.data_sv.sub_left (AesCfb.X86_64.blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (AesCfb.X86_64.blk_sub s₀) + · exact hp.stk_data.symm.sub_left (AesCfb.X86_64.blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (aesWith_length _ _) eZ post₂.1 + +theorem key_ok (s : State) : + ∃ s', runBlock isa tailKey s = some s' ∧ s'.gpr .rax = s.gpr .rax + BitVec.ofNat 64 48 ∧ + (∀ r, r ≠ .rax → s'.gpr r = s.gpr r) ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [tailKey, runBlock_cons, runStep_some, reduceExec, execAlu, readSrc, Option.bind_some] + rfl, ?_⟩ + refine ⟨?_, fun r hr => ?_, ?_, ?_, ?_⟩ + · simp [gpr_setReg] + · simp [gpr_setReg, hr] + · simp [mem_arithFlags, mem_setReg] + · simp [rd_arithFlags, rd_setReg] + · simp [wr_arithFlags, wr_setReg] + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.rsp, h.rd, h.wr, cW1_cW (whole_cW1 h), h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt]⟩ + +theorem key_load_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) : + WP isa (.block loadSave) s (Loaded (TCall s₀) s₀) := + WP.of_runBlock ⟨_, load_ok hp h.rsp h.rd h.wr (big_of (cW1_cW h.frame)), s, h, rfl⟩ + +theorem tail_xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) + (s.setReg .rax (fV s₀)) (Done s₀) := by + obtain ⟨s₁, r₁, rax₁, k₁, m₁, rd₁, wr₁⟩ := key_ok (s.setReg .rax (fV s₀)) + rw [gpr_setReg_self] at rax₁ + have k₁' : ∀ r, r ≠ .rax → s₁.gpr r = s.gpr r := fun r hr => by rw [k₁ r hr, gpr_setReg_of_ne _ _ hr] + rw [mem_setReg] at m₁ + rw [rd_setReg] at rd₁ + rw [wr_setReg] at wr₁ + refine WP.seq (WP.of_runBlock ⟨s₁, r₁, ?_⟩) + have hU : fU s₀ < 16 := Nat.mod_lt _ (by decide) + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have eN := AesCfb.X86_64.fN_eq s₀ + have eU := AesCfb.X86_64.fU_eq s₀ + have hT : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + have hB := cBk_toNat hp + have xp : Modes.X86_64.XPre s₁ (cBk s₀) (fT s₀) (fU s₀) .r13 .r14 := { + pos := by omega + small := by omega + fitK := by omega + fitR := by rw [hT]; omega + disj := (((hp.data_sv.sub_left (AesCfb.X86_64.tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [rd₁, wr₁, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [wr₁, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) + dl := by decide + dRax := by decide + dR10 := by decide + dRcx := by decide } + have x0 : Modes.X86_64.XInv s₁ (cBk s₀) (fT s₀) (fU s₀) .r13 .r14 0 s₁ := { + rax := by rw [rax₁]; exact (BitVec.add_zero _).symm + dat := by rw [k₁' _ (by decide), h.r13]; exact (BitVec.add_zero _).symm + left := by rw [k₁' _ (by decide), h.r14, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Modes.X86_64.xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (AesCfb.X86_64.tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact hp.data_scr.sub_left (AesCfb.X86_64.tail_sub s₀) + · exact (hp.data_sv.sub_left (AesCfb.X86_64.tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (AesCfb.X86_64.tail_sub s₀)).symm + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (AesCfb.X86_64.tail_sub s₀)).sub_right (sv48_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (AesCfb.X86_64.tail_sub s₀) + refine ⟨by rw [d.gpr .rsp (by decide) (by decide) (by decide) (by decide) (by decide), k₁' _ (by decide), h.rsp], + by rw [d.rd, rd₁, h.rd], by rw [d.wr, wr₁, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · refine cW1_cW h.frame |>.trans ?_ + rw [← m₁] + exact d.frame.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, AesCfb.X86_64.tail_sub s₀⟩ + · rw [AesCfb.X86_64.blocksAt_frame' d.frame fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, m₁] + exact h.blocks + · rw [d.data q hq, m₁, h.frame.bytes tailD hlen hq, (AesCfb.X86_64.svMem_frame s₀).bytes tailS hlen hq, + ← AesCfb.X86_64.bytesAt_getD s.mem (cBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, bytesAt_frame d.frame ivT (by decide), m₁, h.ctr, ← AesCtr.next_add] + +theorem final_mid_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) + (hz : s.zf = some (decide (fU s₀ = 0))) : + WP isa (.ite .e (.block []) (finalTail ("vg_aes_ctr" ++ v.suffix) (crypt v.callee))) s (Done s₀) := by + have ev : isa.eval .e s = some (decide (fU s₀ = 0)) := hz + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + refine WP.seq (WP.mono (tail_load_wp hp h) fun _ ⟨w, hw, e⟩ => ?_) + subst e + exact WP.seq (WP.mono (tail_args_wp hp hw) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp v hp h₁) fun _ h₂ => + WP.seq (WP.mono (key_load_wp hp h₂) fun _ ⟨w', hw', e'⟩ => by subst e'; exact tail_xor_wp hp hw' hu))) + +/-! ## Restoring the registers -/ + +theorem final_end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.seq (.block loadSave) (.block finalRestore)) s fun s' => gprPreserved s₀ s' ∧ s'.mem = s.mem := by + have big := big_of h.frame + refine WP.seq (WP.of_runBlock ⟨_, load_ok hp h.rsp h.rd h.wr big, ?_⟩) + have hs : Spill.Saved (s.setReg .rax (fV s₀)).mem ((s.setReg .rax (fV s₀)).gpr .rax) (fG s₀) finalSaved := by + rw [mem_setReg, gpr_setReg_self] + refine (Spill.saveMem_saved _ _ _ _ (by decide)).frame h.frame fun p hp' r hr => ?_ + have hsub : Region.Sub ⟨Spill.slot (fV s₀) p.2, 8⟩ (cSv s₀) := + Offset.sub_base _ (by have := AesCfb.X86_64.saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact hp.scr_sv.symm.sub_left hsub + · exact slot_blk p hp' + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .rax finalSaved)) _ _ + refine WP.mono (Spill.restore_ok .rax finalSaved (fG s₀) _ (by decide) (fun p hp' => ?_) hs) + fun s' ⟨g₁, g₂, mem', _, _⟩ => ?_ + · rw [rd_setReg, wr_setReg, gpr_setReg_self, h.rd, h.wr, hp.rd, hp.wr] + have := AesCfb.X86_64.saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + · have cs := Spill.calleeSaved_ok g₁ g₂ (by decide) + (show _ = (s₀.setReg .rax (fV s₀)).gpr .rsp by + rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), h.rsp]) + refine ⟨⟨fun r hr => by rw [cs r hr]; exact gpr_setReg_of_ne _ _ (AesCfb.X86_64.calleeSaved_ne_rax' hr), ?_⟩, + by rw [mem', mem_setReg]⟩ + rw [mem', mem_setReg] + refine big.readW (r := ⟨fSp s₀, 8⟩) (Region.contains_self _ _) (fun r hr => ?_) (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.ret_iv + · exact hp.ret_data + · exact hp.ret_scr + · exact hp.ret_sv + · exact Offset.base_disjoint_below _ (by decide) + +/-! ## The whole function -/ + +theorem final_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) : + WP isa (cryptFinal v.callee v.suffix) s₀ fun s' => gprPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (final_load_wp hp) fun s₁ e₁ => ?_) + subst e₁ + refine WP.seq (WP.mono (final_setup_wp hp) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (whole_wp v hp h₂) fun s₃ h₃ => ?_) + refine WP.seq (WP.mono (AesCfb.X86_64.final_test_wp h₃) fun s₄ ⟨h₄, z₄⟩ => ?_) + refine WP.seq (WP.mono (final_mid_wp v hp h₄ z₄) fun s₅ h₅ => ?_) + exact WP.mono (final_end_wp hp h₅) fun _ ⟨g, m⟩ => ⟨g, s₅, h₅, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86_64.post s₀ s' := by + show Spec.Ctr.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem cryptFinal_mx (v : Ctr32Impl) : + (cryptFinal v.callee v.suffix).allInstrs (fun i => !loadsMxcsr i) = true := by + simp only [cryptFinal, final, finalTail, Code.allInstrs, crypt_mx v] + decide +kernel + +theorem final_correct (v : Ctr32Impl) (s : State) (hs : ctrFinalX86_64.pre s) : + ∃ t s', Exec isa (cryptFinal v.callee v.suffix) s t s' ∧ abiPreserved s s' ∧ ctrFinalX86_64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp v (CPre.of hs) + exact ⟨t, s', he, abiPreserved_of_exec (cryptFinal_mx v) he hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +/-- Counter blocks whose last 32 bits agree still do after `k` increments. -/ +theorem lo32_next_of {t t' : List Byte} (ht : t.length = 16) (ht' : t'.length = 16) + (h : AesCtr.lo32 t = AesCtr.lo32 t') (k : Nat) : + AesCtr.lo32 (Spec.Ctr.next t k) = AesCtr.lo32 (Spec.Ctr.next t' k) := by + rw [AesCtr.lo32_next ht, AesCtr.lo32_next ht'] + unfold AesCtr.lo32 at h + omega + +theorem TArgs.entry_ctr {s₀ s : State} (hp : CPre s₀) (h : TArgs s₀ s) : + bytesAt s.callEntry.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) := by + rw [bytesAt_frame (callEntry_frame s) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact hp.stk_iv.symm.sub_right (by rw [h.rsp]; exact AesCfb.X86_64.below8_sub _)) (by decide)] + exact h.ctr + +theorem loadSave_taint : ∃ h, (taint.check (Taint.ofRegs [.rsp]) (.block loadSave) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.rdi, .rsi, .rdx, .rcx, .r8, .r9, .rsp, .rax]) + (.block finalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem ftest_taint : ∃ h, (taint.check (Taint.ofRegs [.r14]) (.block [.alu .test .r14 (.reg .r14)]) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.rax, .rbx, .rbp, .r12, .r15, .rsp]) + (.block tailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.rax, .r13, .r14]) + (.seq (.block tailKey) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.rax]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel (v : Ctr32Impl) {s₀ s₀' : State} (h0 : ctrFinalX86_64.pre s₀) (h0' : ctrFinalX86_64.pre s₀') + (hq : ctrFinalX86_64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') (cryptFinal v.callee v.suffix) fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + obtain ⟨⟨qW, qR, qIv, qD, qL, qS, qSp, qV⟩, qLk⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, qD, qN] + have qLo : AesCtr.lo32 (fIv0 s₀) = AesCtr.lo32 (fIv0 s₀') := + AesCtr.lo32_of_leak (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLk + -- `save` to `rax`. + have r₁ := taint_rel (P := fun a b => a = s₀ ∧ b = s₀') (F₁ := (· = s₀.setReg .rax (fV s₀))) + (F₂ := (· = s₀'.setReg .rax (fV s₀'))) [.rsp] loadSave_taint + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h; simp only [List.mem_singleton] at hr; subst hr; exact qSp) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_load_wp hp, final_load_wp hp'⟩ + -- The registers saved and the arguments set up. + have r₂ := taint_rel (P := fun a b => a = s₀.setReg .rax (fV s₀) ∧ b = s₀'.setReg .rax (fV s₀')) + (F₁ := Setup s₀) (F₂ := Setup s₀') [.rdi, .rsi, .rdx, .rcx, .r8, .r9, .rsp, .rax] setup_taint + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> + simp only [gpr_setReg, reduceCtorEq, ↓reduceIte, qW, qR, qIv, qD, qL, qS, qSp, fV, qV]) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩ + -- The whole blocks. + have r₃ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr" ++ v.suffix) (crypt_correct v) (crypt_ct v) + (P := fun a b => Setup s₀ a ∧ Setup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ + · simp only [modeX86_64, State.withRegions_gpr, State.callEntry_rsp, + State.callEntry_gpr _ (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.rsi ≠ .rsp), + State.callEntry_gpr _ (by decide : Reg.rdx ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.rcx ≠ .rsp), + State.callEntry_gpr _ (by decide : Reg.r8 ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.r9 ≠ .rsp), + ha.rdi, ha.rsi, ha.rdx, ha.rcx, ha.r8, ha.r9, ha.rsp, hb.rdi, hb.rsi, hb.rdx, hb.rcx, hb.r8, hb.r9, + hb.rsp] + rw [fW, fW, fIv, fIv, fD, fD, fS, fS, fSp, fSp, qW, qR, qIv, qD, qS, qSp, qN] + exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩ + · simp only [AesCbc.X86_64.iv0, AesCbc.X86_64.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_gpr _ (by decide : Reg.rdx ≠ .rsp), ha.rdx, hb.rdx] + rw [(entry_bytes hp ha).2.1, (entry_bytes hp' hb).2.1] + exact qLo).wp + (F₁ := Whole AesCtr.ctrMode s₀) (F₂ := Whole AesCtr.ctrMode s₀') + fun a b h => ⟨whole_wp v hp h.1, whole_wp v hp' h.2⟩ + -- The test. + have r₄ := taint_rel (P := fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (F₁ := fun (s : State) => Whole AesCtr.ctrMode s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => Whole AesCtr.ctrMode s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) [.r14] ftest_taint + (fun a b h r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r14, h.2.r14, qU]) + fun a b h => ⟨AesCfb.X86_64.final_test_wp h.1, AesCfb.X86_64.final_test_wp h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (finalTail ("vg_aes_ctr" ++ v.suffix) (crypt v.callee)) fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := taint_rel (P := fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (F₁ := Loaded (Whole AesCtr.ctrMode s₀) s₀) (F₂ := Loaded (Whole AesCtr.ctrMode s₀') s₀') [.rsp] + loadSave_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.rsp, h.2.rsp, fSp, fSp, qSp]) + fun a b h => ⟨tail_load_wp hp h.1, tail_load_wp hp' h.2⟩ + have a₂ := taint_rel (P := fun a b => Loaded (Whole AesCtr.ctrMode s₀) s₀ a ∧ + Loaded (Whole AesCtr.ctrMode s₀') s₀' b) + (F₁ := TArgs s₀) (F₂ := TArgs s₀') [.rax, .rbx, .rbp, .r12, .r15, .rsp] tailArgs_taint + (fun a b h r hr => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl + · rw [gpr_setReg_self, gpr_setReg_self, fV, fV, qV] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rbx, hw'.rbx, fW, fW, qW] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rbp, hw'.rbp, qR] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r12, hw'.r12, fIv, fIv, qIv] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r15, hw'.r15, fS, fS, qS] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rsp, hw'.rsp, fSp, fSp, + qSp]) + fun a b h => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + exact ⟨tail_args_wp hp hw, tail_args_wp hp' hw'⟩ + have a₃ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr" ++ v.suffix) (crypt_correct v) (crypt_ct v) + (P := fun a b => TArgs s₀ a ∧ TArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ + · simp only [modeX86_64, State.withRegions_gpr, State.callEntry_rsp, + State.callEntry_gpr _ (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.rsi ≠ .rsp), + State.callEntry_gpr _ (by decide : Reg.rdx ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.rcx ≠ .rsp), + State.callEntry_gpr _ (by decide : Reg.r8 ≠ .rsp), State.callEntry_gpr _ (by decide : Reg.r9 ≠ .rsp), + ha.rdi, ha.rsi, ha.rdx, ha.rcx, ha.r8, ha.r9, ha.rsp, hb.rdi, hb.rsi, hb.rdx, hb.rcx, hb.r8, hb.r9, + hb.rsp] + rw [fW, fW, fIv, fIv, cBk, cBk, fV, fV, fS, fS, fSp, fSp, qW, qR, qIv, qV, qS, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial + · simp only [AesCbc.X86_64.iv0, AesCbc.X86_64.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_gpr _ (by decide : Reg.rdx ≠ .rsp), ha.rdx, hb.rdx] + rw [ha.entry_ctr hp, hb.entry_ctr hp', qN] + exact lo32_next_of (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLo _).wp + (F₁ := TCall s₀) (F₂ := TCall s₀') fun a b h => ⟨tail_call_wp v hp h.1, tail_call_wp v hp' h.2⟩ + have a₄ := taint_rel (P := fun a b => TCall s₀ a ∧ TCall s₀' b) + (F₁ := Loaded (TCall s₀) s₀) (F₂ := Loaded (TCall s₀') s₀') [.rsp] loadSave_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.rsp, h.2.rsp, fSp, fSp, qSp]) + fun a b h => ⟨key_load_wp hp h.1, key_load_wp hp' h.2⟩ + have a₅ := taint_rel (P := fun a b => Loaded (TCall s₀) s₀ a ∧ Loaded (TCall s₀') s₀' b) + (F₁ := Done s₀) (F₂ := Done s₀') [.rax, .r13, .r14] xor_taint + (fun a b h r hr => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [gpr_setReg_self, gpr_setReg_self, fV, fV, qV] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r13, hw'.r13, qT] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r14, hw'.r14, qU]) + fun a b h => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + exact ⟨tail_xor_wp hp hw hu, tail_xor_wp hp' hw' hu'⟩ + exact a₁.seq (a₂.seq ((a₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₄.seq a₅))) + have r₅ : RelCT isa (fun a b => (Whole AesCtr.ctrMode s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (Whole AesCtr.ctrMode s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) + (.ite .e (.block []) (finalTail ("vg_aes_ctr" ++ v.suffix) (crypt v.callee))) + (fun a b => Done s₀ a ∧ Done s₀' b) := by + refine RelCT.ite (fun a b h => ?_) ?_ ?_ + · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + exact ⟨done_of_zero h.1.1.1 h0, done_of_zero h.1.2.1 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + -- `save` to `rax`, and the registers restored. + have r₆ := taint_rel (P := fun a b => Done s₀ a ∧ Done s₀' b) + (F₁ := fun (s : State) => s.gpr .rax = fV s₀) (F₂ := fun (s : State) => s.gpr .rax = fV s₀') [.rsp] + loadSave_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.rsp, h.2.rsp, fSp, fSp, qSp]) + fun a b h => ⟨WP.of_runBlock ⟨_, load_ok hp h.1.rsp h.1.rd h.1.wr (big_of h.1.frame), gpr_setReg_self _ _ _⟩, + WP.of_runBlock ⟨_, load_ok hp' h.2.rsp h.2.rd h.2.wr (big_of h.2.frame), gpr_setReg_self _ _ _⟩⟩ + obtain ⟨_, t₇⟩ := restore_taint + have r₇ := RelCT.taint (A := taint) (P := fun a b => a.gpr .rax = fV s₀ ∧ b.gpr .rax = fV s₀') _ + (fun a b h => Taint.agree_ofRegs fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1, h.2, fV, fV, qV]) t₇ + exact r₁.seq (r₂.seq ((r₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₄.seq (r₅.seq (r₆.seq r₇))))) + +theorem final_ct (v : Ctr32Impl) : + ConstantTime isa ctrFinalX86_64.pre ctrFinalX86_64.pub (cryptFinal v.callee v.suffix) := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel v h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem cryptFinal_spSafe (v : Ctr32Impl) : + (cryptFinal v.callee v.suffix).all (fun i => !X86_64.isa.writesSp i) = true := by + simp only [cryptFinal, final, finalTail, Code.all, crypt_spSafe v] + decide +kernel + +theorem cryptFinal_xdepth (v : Ctr32Impl) : (cryptFinal v.callee v.suffix).x86_64Depth ≤ 16 := by + simp only [cryptFinal, final, finalTail, crypt, Impl.AesCtr.X86_64.body, Code.x86_64Depth, v.noStack] + decide + +theorem cryptFinal_verified (v : Ctr32Impl) : + Verified X86_64.target (cryptFinal v.callee v.suffix) finalScratchContract := + Verified.of_correct (final_correct v) (final_ct v) final_implies + +/-! ## With `save` on the stack + +The final function has six argument words, so `save` is its first stack +argument: it runs its code in a frame of 80 bytes (`withStackArgScratchWiped`): +the quadword standing for the return address, `save`'s address, and `save`'s +64 bytes (the registers, then the block that held the last output block), +which it zeroes before returning. The code's calls use 16 bytes below it, so +96 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract X86_64.abi 96).pre s := by + implies_sat [finalRoundsContract, Spec.Ctr.aesFinalSig, finalPre, finalPost, X86_64.abi, + X86_64.argRegs] [AesCfb.X86_64.finalFrameSat, AesCfb.X86_64.finalSatState] using AesCfb.X86_64.finalFrameSat + +theorem cryptFinal_framed (v : Ctr32Impl) : + Verified X86_64.target + (Impl.StackScratch.X86_64.withStackArgScratchWiped 80 0 8 (cryptFinal v.callee v.suffix)) + (finalRoundsContract X86_64.abi 96) := + X86_64.Verified.stackArgScratchWiped (sig := Spec.Ctr.aesFinalSig) (nm := "save") (e := .u64) (n := 8) + (pre := finalPre X86_64.abi.ptrBits) (post := finalPost X86_64.abi.ptrBits) (wa := false) + (leak := some (finalLeak X86_64.abi.ptrBits)) + (stack := 16) (bytes := 80) (words := 8) (cryptFinal_verified v) (by decide) (by decide) (by decide) + (cryptFinal_spSafe v) (cryptFinal_xdepth v) (by decide) (finalPre_local _) (finalPost_local _) + (finalPost_localOut _) frameSat_pre (finalLeak_local _) + +theorem cryptFinal_framed_spSafe (v : Ctr32Impl) : + (Impl.StackScratch.X86_64.withStackArgScratchWiped 80 0 8 (cryptFinal v.callee v.suffix)).all + (fun i => !X86_64.isa.writesSp i) = true := + X86_64.withStackArgScratch_spSafe (by + simp only [Code.all, cryptFinal_spSafe v, X86_64.wipeAt_spSafe, Bool.and_self]) + +end VG.Proof.AesCtr.X86_64 diff --git a/lean/VerifiedGarbage/Proof/AesOfb/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/Final.lean new file mode 100644 index 00000000000..aa27cd27dc0 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/Final.lean @@ -0,0 +1,232 @@ +module + +public import VerifiedGarbage.Spec.Ofb.Final +public import VerifiedGarbage.Proof.Framework.PostMono +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.Framework.Offset + +-- separate module: shared by the final functions' proofs of every target. + +/-! +# AES-OFB of a message's last piece: the contract on the key schedule it is given + +Not trusted, and the same on every target. `finalRoundsContract`: the +contract of `vg_aes_ofb_final` for the key schedule and the number of rounds +it is given, as `Rounds.lean`'s for the whole-block function, from which the +shared contract of `Spec/Ofb/Final.lean` follows (`final_keyed`). Its +postcondition reads the memory, on entry and on return, only within the +function's buffers (`finalPost_local`, `finalPost_localOut`), as a frame that +keeps more working space on the stack needs. + +A final function calls the whole-block function on the `n = len / 16` whole +blocks of its data, which leaves the last output block `Oₙ` in the IV, then, +if `u = len % 16` bytes are left, enciphers the IV in place, giving +`Oₙ₊₁ = CIPH_K(Oₙ)`, and XORs its first `u` bytes into them. +`cryptFinal_of`: what that leaves is `Spec.Ofb.CryptFinal`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb + +open VG +open VG.Spec.Aes (bytesAt) +open VG.Proof.Modes.CtrFinal (bytesAt_length bytesAt_blocks_tail bytesAt_blocks bytesAt_xor xor_flatten + blocksAt_length16) + +/-! ## From what a final function leaves -/ + +section +variable {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) +include hc + +theorem outputs_length16 (iv : List Byte) (n : Nat) : ∀ o ∈ Spec.Ofb.outputs ciph iv n, o.length = 16 := by + induction n generalizing iv with + | zero => simp [Spec.Ofb.outputs] + | succ n ih => + intro o ho + simp only [Spec.Ofb.outputs, List.mem_cons] at ho + rcases ho with rfl | ho + · exact hc _ + · exact ih _ o ho + +theorem outputs_flatten_length (iv : List Byte) (n : Nat) : (Spec.Ofb.outputs ciph iv n).flatten.length = 16 * n := by + induction n generalizing iv with + | zero => rfl + | succ n ih => + simp only [Spec.Ofb.outputs, List.flatten_cons, List.length_append, hc, ih] + omega + +/-- OFB of the `len` bytes at `D` from the block at `P`, from what a final +function leaves: its `n = len / 16` whole blocks as OFB's, its last +`len % 16` bytes XORed a byte at a time with `CIPH_K(Oₙ)`, `Oₙ` the last +output block of the whole blocks, and the block at `P` the last output +block used. -/ +theorem cryptFinal_of {m₀ m' : Mem} {P D : Addr} {len : Nat} + (hblocks : Spec.Cbc.blocksAt m' D (len / 16) = + Spec.Ofb.crypt ciph (bytesAt m₀ P 16) (Spec.Cbc.blocksAt m₀ D (len / 16))) + (htail : ∀ q < len % 16, m' (D + BitVec.ofNat 64 (16 * (len / 16)) + BitVec.ofNat 64 q) = + m₀ (D + BitVec.ofNat 64 (16 * (len / 16)) + BitVec.ofNat 64 q) ^^^ + (ciph (Spec.Ofb.next ciph (bytesAt m₀ P 16) (len / 16))).getD q 0) + (hiv : bytesAt m' P 16 = + let c := Spec.Ofb.next ciph (bytesAt m₀ P 16) (len / 16) + if len % 16 = 0 then c else ciph c) : + Spec.Ofb.CryptFinal ciph 16 m₀ m' P D len := by + have hu : len % 16 < 16 := Nat.mod_lt _ (by decide) + have ecount : Spec.Ofb.blockCount 16 len = if len % 16 = 0 then len / 16 else len / 16 + 1 := by + unfold Spec.Ofb.blockCount; split <;> omega + have ht := bytesAt_xor (o := ciph (Spec.Ofb.next ciph (bytesAt m₀ P 16) (len / 16))) (by rw [hc]; omega) htail + have hx : Spec.Cbc.xor (Spec.Cbc.blocksAt m₀ D (len / 16)).flatten + (Spec.Ofb.outputs ciph (bytesAt m₀ P 16) (len / 16)).flatten = + (Spec.Ofb.crypt ciph (bytesAt m₀ P 16) (Spec.Cbc.blocksAt m₀ D (len / 16))).flatten := by + rw [xor_flatten _ _ (blocksAt_length16 m₀ D _) (outputs_length16 hc _ _) + (by simp [AesCbc.length_blocksAt, length_outputs]), Spec.Ofb.crypt, AesCbc.length_blocksAt] + have hl : (Spec.Cbc.blocksAt m₀ D (len / 16)).flatten.length = + (Spec.Ofb.outputs ciph (bytesAt m₀ P 16) (len / 16)).flatten.length := by + rw [← bytesAt_blocks, bytesAt_length, outputs_flatten_length hc] + refine ⟨?_, ?_⟩ + · rw [Spec.Ofb.cryptFinal, bytesAt_length, ecount, bytesAt_blocks_tail m' D len, hblocks, ht, + bytesAt_blocks_tail m₀ D len] + split + · rename_i h0 + have e : ∀ (m : Mem) (p : Addr), bytesAt m p (len % 16) = [] := fun m p => by rw [h0]; rfl + rw [e, List.append_nil, ← hx] + simp only [Spec.Cbc.xor, List.zipWith_nil_left, List.append_nil] + · rw [outputs_succ, List.flatten_append, List.flatten_singleton] + simp only [Spec.Cbc.xor] at hx ⊢ + rw [List.zipWith_append hl, hx] + · rw [hiv, ecount] + dsimp only + split + · rfl + · rw [next_succ] + +end + +theorem aesWith_length (nr : Nat) (w : List Byte) (b : List Byte) : (Spec.Cbc.aesWith nr w b).length = 16 := by + simp [Spec.Cbc.aesWith] + +/-! ## The contract -/ + +open VG.Spec.Ofb + +/-- The final function's precondition: 10, 12 or 14 rounds. -/ +def finalPre (pb : Nat) : Curry (aesFinalSig.words pb) (Mem → Prop) := + fun _schedule rounds _iv _data _len _scratch _ => rounds.toNat = 10 ∨ rounds.toNat = 12 ∨ rounds.toNat = 14 + +/-- AES with the key schedule in the first `16 (rounds + 1)` bytes at +`schedule`. -/ +abbrev ciphAt (m : Mem) (schedule : Addr) (rounds : Nat) : Spec.Cbc.Cipher := + Spec.Cbc.aesWith rounds (bytesAt m schedule (16 * (rounds + 1))) + +/-- The final function's postcondition, by AES with the key schedule it is +given, for 10, 12 or 14 rounds (so that it reads only the schedule's 240 +bytes). -/ +def finalPost (pb : Nat) : aesFinalSig.Post pb := + fun schedule rounds iv data len _scratch m m' _ => + (rounds.toNat = 10 ∨ rounds.toNat = 12 ∨ rounds.toNat = 14) → + CryptFinal (ciphAt m schedule rounds.toNat) 16 m m' iv data len.toNat + +/-- For `rounds` of 10, 12 or 14, with the key schedule `w` in the first +`16 (rounds + 1)` bytes at `schedule`: replaces the `len` bytes at `data` +with their OFB encryption or decryption by AES with `w`, a partial last +block included, from the block at `iv`, and that block with the last output +block used (`Spec.Ofb.CryptFinal`). -/ +def finalRoundsContract {M : ISA} (A : Abi M) (stack : Nat := 0) : Contract M := + aesFinalSig.contract A (pre := finalPre A.ptrBits) (post := finalPost A.ptrBits) (stack := stack) + +/-- `Spec.Ofb.aesFinalContract` from `finalRoundsContract`. -/ +theorem final_keyed {T : Target} {c : Prog T.isa} {A : Abi T.isa} {stack : Nat} + (h : Verified T c (finalRoundsContract A stack)) : + Verified T c (Spec.Ofb.aesFinalContract A stack) := + h.post_mono fun _ _ _ _ _ _ _ _ _ hp key ⟨hk, hr, hw⟩ => by + dsimp only [finalPost, ciphAt] at hp + have h' := hp (by rw [hr]; rcases hk with h | h | h <;> rw [h] <;> decide) + rw [hw, hr] at h' + exact h' + +/-! ## Locality -/ + +section +variable {m₁ m₂ : Mem} {p : Addr} + +private theorem bytesAt_congr {n : Nat} (h : ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + bytesAt m₂ p n = bytesAt m₁ p n := + List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +private theorem agree_of {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : + ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by + intro i hi + refine (h _ ?_).symm + by_cases hw : i < 2 ^ 64 + · exact Offset.contains_base _ (by omega) hw + · simp only [Region.Contains] + have := (p + BitVec.ofNat 64 i - p).isLt + omega + +/-- Memories that agree within the final function's buffers agree on the +schedule, the block and the data. -/ +private theorem final_bufs {pb : Nat} {vs : List (BitVec 64)} (hlen : vs.length = 6) + (hb : ∀ r ∈ Sig.bufs aesFinalSig.params vs, ∀ a, r.1.Contains a 1 → m₁ a = m₂ a) : + ∃ k rounds iv data len scr, vs = [k, rounds, iv, data, len, scr] ∧ + (∀ n ≤ 240, bytesAt m₂ k n = bytesAt m₁ k n) ∧ + bytesAt m₂ iv 16 = bytesAt m₁ iv 16 ∧ + bytesAt m₂ data (len.setWidth pb).toNat = bytesAt m₁ data (len.setWidth pb).toNat := by + match vs, hlen with + | [k, rounds, iv, data, len, scr], _ => + simp only [aesFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hk := agree_of hb.1 + have hv := agree_of hb.2.1 + have hd := agree_of hb.2.2.1 + have := Nat.mod_le len.toNat (2 ^ pb) + exact ⟨k, rounds, iv, data, len, scr, rfl, fun n hn => bytesAt_congr fun i hi => hk i (by omega), + bytesAt_congr hv, bytesAt_congr fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega)⟩ + +end + +variable (pb : Nat) + +theorem finalPre_local : ∀ vs m₁ m₂, vs.length = (aesFinalSig.words pb).length → + (∀ b ∈ Sig.bufs aesFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (aesFinalSig.words pb) (finalPre pb) vs m₁ → Curry.apply (aesFinalSig.words pb) (finalPre pb) vs m₂ := by + intro vs m₁ m₂ hlen _ h + match vs, hlen with + | [_, _, _, _, _, _], _ => exact h + +/-- `finalPost` reads the memory on entry only within the buffers. -/ +theorem finalPost_local : ∀ vs m₁ m₂ m' r, vs.length = (aesFinalSig.words pb).length → + (∀ b ∈ Sig.bufs aesFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m₁ m' r → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + obtain ⟨k, rounds, iv, data, len, scr, rfl, hk, hv, hd⟩ := final_bufs (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m₂ m' r + dsimp only [Curry.apply, finalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal, ciphAt] at h ⊢ + intro hr + obtain ⟨h1, h2⟩ := h hr + rw [hk _ (by rcases hr with h | h | h <;> omega), hv, hd] + exact ⟨h1, h2⟩ + +/-- `finalPost` reads the memory on return only within the buffers. -/ +theorem finalPost_localOut : ∀ vs m m₁ m₂ r, vs.length = (aesFinalSig.words pb).length → + (∀ b ∈ Sig.bufs aesFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m m₁ r → + Curry.apply (aesFinalSig.words pb) (finalPost pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + obtain ⟨k, rounds, iv, data, len, scr, rfl, -, hv, hd⟩ := final_bufs (pb := pb) hlen hb + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb, ArgWord.addr] + (finalPost pb) _ m m₂ r + dsimp only [Curry.apply, finalPost, ArgWord.ofRaw, Spec.Ofb.CryptFinal] at h ⊢ + intro hr + rw [hv, hd] + exact h hr + +end VG.Proof.AesOfb diff --git a/lean/VerifiedGarbage/Proof/AesOfb/X86_64/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/X86_64/Final.lean new file mode 100644 index 00000000000..4fd2e0ff1e6 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/X86_64/Final.lean @@ -0,0 +1,181 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.X86_64.Final +public import VerifiedGarbage.Proof.AesOfb.Final +public import VerifiedGarbage.Proof.AesOfb.X86_64.Verified +public import VerifiedGarbage.Proof.AesCfb.X86_64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.X86_64 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.AesOfb.X86_64.Body +import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.X86_64.CT +import VerifiedGarbage.Proof.Framework.X86_64.StackArgScratchWipe + +/-! +# AES-OFB of a message's last piece on x86-64 + +`cryptFinal_framed`: `vg_aes_ofb_final` (`Impl/AesOfb/X86_64/Final.lean`), for +any implementation `v` of the block functions (`BlocksImpl`), meets +`Proof.AesOfb.finalRoundsContract`, from which the shared contract follows +(`Proof.AesOfb.final_keyed`). + +Its code is AES-CFB's final function around a call of the whole-block +AES-OFB function, so its proof is AES-CFB's (`Proof/AesCfb/X86_64/Final.lean`), +for OFB as a `Mode` (`ofbMode`): `final_wp` runs it, for any mode, to what it +leaves before restoring the registers (`Done`); `final_rel` gives its +constant time. `ofbFinalX86_64` is AES-CFB's code contract with OFB's +postcondition, which `final_post` gives from `Done` by +`Proof.AesOfb.cryptFinal_of`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb.X86_64 + +open VG VG.X86_64 +open VG.Spec.Aes (bytesAt) +open VG.Proof.AesCfb.X86_64 (finalX86_64 FPre Done fW fR fIv fD fL fN fU fT fWk fIv0 fBlks final_wp final_ct + finalSatState args_getD stackArgs_one noSp_of_all all_of_noSp finalFrameSat) +open VG.Proof.AesCbc.X86_64 (modeX86_64) +open VG.Proof.Aes.X86_64 (BlocksImpl) +open VG.Impl.AesOfb.X86_64 +open VG.Impl.AesCfb.X86_64 (final finalTail) + +/-- The code's contract, with the arguments `(schedule = rdi, rounds = rsi, +iv = rdx, data = rcx, len = r8, scratch = r9, save = [rsp + 8])`: AES-CFB's +final functions' (`finalX86_64`), with the data and the block at `iv` as +`Spec.Ofb.CryptFinal` says, by AES with the key schedule it is given. -/ +def ofbFinalX86_64 : Contract isa := + { finalX86_64 true with + post := fun s s' => Spec.Ofb.CryptFinal (ciphAt s.mem (s.gpr .rdi) (s.gpr .rsi).toNat) 16 s.mem s'.mem + (s.gpr .rdx) (s.gpr .rcx) (s.gpr .r8).toNat } + +/-- The contract the frame needs: the shared one, with `save`, 48 bytes, as +a seventh argument, and 16 bytes of stack (the return addresses of the +whole-block function and of the block function it calls). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract X86_64.abi Spec.Ofb.aesFinalSig "save" .u64 6 (finalPre X86_64.abi.ptrBits) + (finalPost X86_64.abi.ptrBits) false 16 + +theorem final_implies : ofbFinalX86_64.Implies finalScratchContract where + pre := by + intro s h + sig_pre [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, abi, argRegs, ofbFinalX86_64, finalX86_64, args_getD, + stackArgs_one, List.append_eq] at h + sig_pre [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, abi, argRegs, ofbFinalX86_64, finalX86_64, args_getD, + stackArgs_one, List.append_eq] at h + sig_split h + sig_reduce [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, abi, argRegs, ofbFinalX86_64, finalX86_64, args_getD, + stackArgs_one, List.append_eq] + sig_and_intros + sig_close + all_goals first + | with_reducible assumption + | with_reducible exact Region.Disjoint.symm ‹_› + | omega_arith + post := by + sig_implies_post [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, abi, argRegs, ofbFinalX86_64, finalX86_64, args_getD, + stackArgs_one, List.append_eq] + pub := by + rintro s₁ s₂ - - h + sig_pub [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, abi, argRegs, ofbFinalX86_64, finalX86_64, args_getD, + stackArgs_one, List.append_eq] at h + simp only [List.getD_cons_succ, List.getD_cons_zero] at h + sig_split h + rename_i h1 h2 h3 h4 h5 h6 h7 + exact ⟨h2, h3, h4, h5, h6, h7, h1, h⟩ + sat := by + sig_implies_sat [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, abi, argRegs, ofbFinalX86_64, finalX86_64, args_getD, + stackArgs_one, List.append_eq] [finalSatState, stackArg, stackArgAddr, Mem.readW, Mem.read] + using finalSatState + +/-- `Spec.Ofb.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done ofbMode s₀ s₁) (hm : s'.mem = s₁.mem) : + ofbFinalX86_64.post s₀ s' := by + show Spec.Ofb.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) 16 s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + have e := AesCbc.length_blocksAt s₀.mem (fD s₀) (fN s₀) + have hb := h.blocks + have ht := h.tail + have hi := h.iv + rw [ofbMode_out] at hb + rw [ofbMode_chain, e] at ht hi + exact cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact hb) (fun q hq => by rw [hm]; exact ht q hq) + (by rw [hm]; exact hi) + +theorem final_correct (v : BlocksImpl) (hmx : (cryptFinal v.enc v.suffix).allInstrs (fun i => !loadsMxcsr i) = true) + (hsp : NoSp (crypt v.enc)) (hd : (crypt v.enc).depth = 1) (s : State) (hs : ofbFinalX86_64.pre s) : + ∃ t s', Exec isa (cryptFinal v.enc v.suffix) s t s' ∧ abiPreserved s s' ∧ ofbFinalX86_64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (M := ofbMode) (crypt_correct v) hsp hd v (FPre.of (enc := true) hs) + exact ⟨t, s', he, abiPreserved_of_exec hmx he hg, final_post h₁ hm⟩ + +/-! ## The code's properties -/ + +theorem crypt_noSp (v : BlocksImpl) : NoSp (crypt v.enc) := + noSp_of_all (by + simp only [crypt, Impl.AesCbc.X86_64.whole, body, Code.allInstrs, all_of_noSp v.encNosp] + decide +kernel) + +theorem crypt_depth (v : BlocksImpl) : (crypt v.enc).depth = 1 := by + simp only [crypt, Impl.AesCbc.X86_64.whole, body, Code.depth, v.encDepth] + decide + +theorem cryptFinal_mx (v : BlocksImpl) : + (cryptFinal v.enc v.suffix).allInstrs (fun i => !loadsMxcsr i) = true := by + simp only [cryptFinal, final, finalTail, Code.allInstrs, crypt_mx v, v.encMxcsr] + decide +kernel + +theorem cryptFinal_spSafe (v : BlocksImpl) : + (cryptFinal v.enc v.suffix).all (fun i => !X86_64.isa.writesSp i) = true := by + simp only [cryptFinal, final, finalTail, Code.all, crypt_spSafe v, v.encSpSafe] + decide +kernel + +theorem cryptFinal_xdepth (v : BlocksImpl) : (cryptFinal v.enc v.suffix).x86_64Depth ≤ 16 := by + simp only [cryptFinal, final, finalTail, crypt, Impl.AesCbc.X86_64.whole, body, Code.x86_64Depth, + v.encNoStack] + decide + +/-! ## Verified -/ + +theorem cryptFinal_verified (v : BlocksImpl) : + Verified X86_64.target (cryptFinal v.enc v.suffix) finalScratchContract := + Verified.of_correct (final_correct v (cryptFinal_mx v) (crypt_noSp v) (crypt_depth v)) + (final_ct (enc := true) (crypt_correct v) (AesCbc.X86_64.whole_ct (body_ok v) (body_ct v)) (crypt_noSp v) + (crypt_depth v) v) + final_implies + +/-! ## With `save` on the stack + +As AES-CFB's final functions, the code runs in a frame of 64 bytes +(`withStackArgScratchWiped`): the quadword standing for the return address, +`save`'s address, and `save`'s 48 bytes, which it zeroes before returning. +Its calls use 16 bytes below it, so 80 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract X86_64.abi 80).pre s := by + implies_sat [finalRoundsContract, Spec.Ofb.aesFinalSig, finalPre, finalPost, X86_64.abi, + X86_64.argRegs] [finalFrameSat, finalSatState] using finalFrameSat + +theorem cryptFinal_framed (v : BlocksImpl) : + Verified X86_64.target + (Impl.StackScratch.X86_64.withStackArgScratchWiped 64 0 6 (cryptFinal v.enc v.suffix)) + (finalRoundsContract X86_64.abi 80) := + X86_64.Verified.stackArgScratchWiped (sig := Spec.Ofb.aesFinalSig) (nm := "save") (e := .u64) (n := 6) + (pre := finalPre X86_64.abi.ptrBits) (post := finalPost X86_64.abi.ptrBits) (wa := false) + (stack := 16) (bytes := 64) (words := 6) (cryptFinal_verified v) (by decide) (by decide) (by decide) + (cryptFinal_spSafe v) (cryptFinal_xdepth v) (by decide) (finalPre_local _) (finalPost_local _) + (finalPost_localOut _) frameSat_pre + +theorem cryptFinal_framed_spSafe (v : BlocksImpl) : + (Impl.StackScratch.X86_64.withStackArgScratchWiped 64 0 6 (cryptFinal v.enc v.suffix)).all + (fun i => !X86_64.isa.writesSp i) = true := + X86_64.withStackArgScratch_spSafe (by + simp only [Code.all, cryptFinal_spSafe v, X86_64.wipeAt_spSafe, Bool.and_self]) + +end VG.Proof.AesOfb.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean new file mode 100644 index 00000000000..8c4bf6a2e9a --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean @@ -0,0 +1,79 @@ +module + +public import VerifiedGarbage.Spec.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Camellia.Scratch +import VerifiedGarbage.Proof.Framework.AddrArith + +-- separate module: shared by the final function's proofs of every target. + +/-! +# Camellia-CTR of a message's last piece: the contract on the subkeys it is given + +Not trusted, and the same on every target. `ctrFinalContractSk`: +`Spec.Camellia.ctrFinalContract` on the subkeys at `schedule`, for `rounds` of +18 or 24, from which the shared contract follows (`ctrFinal_of_sk`), as +`ctrContractSk` is for `vg_camellia_ctr` (`CtrScratch.lean`); its +postcondition reads the memory on return only within the function's buffers +(`ctrFinalPostOut_local`), as a frame that keeps working space on the stack +needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by +`Proof.Modes.CtrFinal.cryptFinal_of`, for any cipher. +-/ + +@[expose] public section + +namespace VG.Proof.Camellia + +open VG.Spec.Camellia + +/-- `Spec.Camellia.ctrFinalContract`'s postcondition on the subkeys at +`schedule`, for `rounds` of 18 or 24. -/ +def ctrFinalPostSk (pb : Nat) : ctrFinalSig.Post pb := fun schedule rounds ctr data len m m' _ => + (rounds.toNat = 18 ∨ rounds.toNat = 24) → + Spec.Ctr.CryptFinal (cipher (subkeysAt m schedule rounds.toNat)) m m' ctr data len.toNat + +/-- `Spec.Camellia.ctrFinalContract` with `ctrFinalPostSk`. -/ +def ctrFinalContractSk {M : ISA} (A : Abi M) (stack : Nat := 0) : Contract M := + ctrFinalSig.contract A (pre := ctrFinalPre A.ptrBits) (post := ctrFinalPostSk A.ptrBits) (writeArgs := true) + (stack := stack) + +theorem ctrFinalPost_of_sk (pb : Nat) : Curry.Imp _ (ctrFinalPostSk pb) (fun schedule rounds ctr data len m m' _ => + ∀ key, KeySchedule m schedule rounds.toNat key → + Spec.Ctr.CryptFinal (cipher (expandKey key)) m m' ctr data len.toNat) := by + intro _ _ _ _ _ _ _ _ h key hk + rw [← subkeysAt_of_keySchedule hk] + exact h (rounds_of_keySchedule hk) + +theorem ctrFinal_of_sk {T : Target} {c : Prog T.isa} {A : Abi T.isa} {stack : Nat} + (h : Verified T c (ctrFinalContractSk A stack)) : Verified T c (Spec.Camellia.ctrFinalContract A stack) := + verified_of_post h (ctrFinalPost_of_sk A.ptrBits) + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + Spec.Aes.bytesAt m₂ p k = Spec.Aes.bytesAt m₁ p k := by + simp only [Spec.Aes.bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +/-- `ctrFinalPostSk` reads the memory on return only within the buffers. -/ +theorem ctrFinalPostOut_local (pb : Nat) : ∀ vs m m₁ m₂ r, vs.length = (ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPostSk pb) vs m m₁ r → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPostSk pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + match vs, hlen with + | [k, rounds, ctr, data, len], _ => + simp only [ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hc := agree_of hb.2.1 + have hd := agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPostSk pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPostSk pb) _ m m₂ r + dsimp only [Curry.apply, ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + intro hR + rw [bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] + exact h hR + +end VG.Proof.Camellia diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean new file mode 100644 index 00000000000..5a473d6808d --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean @@ -0,0 +1,1067 @@ +module + +public import VerifiedGarbage.Impl.Camellia.X86_64.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrScratch +public import VerifiedGarbage.Proof.Camellia.X86_64.CtrVerified +public import VerifiedGarbage.Proof.AesCfb.X86_64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.X86_64.Spill +public import VerifiedGarbage.Proof.Framework.X86_64.StackScratch +import VerifiedGarbage.Proof.AesCtr.X86_64.Final +import VerifiedGarbage.Proof.AesCtr.X86_64.CT +import VerifiedGarbage.Proof.Camellia.X86_64.ModesLit +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.X86_64.FbFinal +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86_64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.X86_64.RegUpd +import VerifiedGarbage.Proof.Framework.X86_64.Exec +import VerifiedGarbage.Proof.Framework.X86_64.Reduce +import VerifiedGarbage.Proof.Framework.X86_64.CallFrame +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.Framework.X86_64.StackScratchWipe +meta import VerifiedGarbage.Impl.Camellia.X86_64.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrScratch +meta import VerifiedGarbage.Proof.Camellia.X86_64.CtrVerified +meta import VerifiedGarbage.Proof.AesCfb.X86_64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.X86_64.Spill +meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratch +meta import VerifiedGarbage.Proof.AesCtr.X86_64.Final +meta import VerifiedGarbage.Proof.AesCtr.X86_64.CT +meta import VerifiedGarbage.Proof.Camellia.X86_64.ModesLit +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.X86_64.FbFinal +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.X86_64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.X86_64.RegUpd +meta import VerifiedGarbage.Proof.Framework.X86_64.Exec +meta import VerifiedGarbage.Proof.Framework.X86_64.Reduce +meta import VerifiedGarbage.Proof.Framework.X86_64.CallFrame +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratchWipe + +/-! +# Camellia-CTR of a message's last piece on x86-64 + +`ctrFinal_framed`: `vg_camellia_ctr_final` (`Impl/Camellia/X86_64/CtrFinal.lean`) +meets `Spec.Camellia.ctrFinalContract`, from `Proof.Camellia.ctrFinalContractSk` +(`Proof.Camellia.ctrFinal_of_sk`). + +The code is proven against `ctrFinalX86_64`, with a sixth argument `save` of +64 bytes in `r9` (`ctrFinal_implies`: the shared contract with it), as a +caller of `vg_camellia_ctr` (framed by its own working space on the stack, +`ctrFramed`), through its contract on the subkeys, `ctrContractSk` +(`ctrFramed_sk`; `callee_pre`, `callee_post`, `callee_pub`, from +`Sig.contract`'s form for arguments in registers): + +* `setup_wp`, `whole_wp`: the registers saved in `save`, whose address is + kept in `r15`, and the call on the `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.X86_64.xorLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Camellia.X86_64 + +open VG VG.X86_64 +open VG.Spec.Aes (bytesAt) +open VG.X86_64.RegUpd +open VG.Impl.Camellia.X86_64 (ctrFramed ctrFinalMoves ctrFinalSetup ctrFinalLoad ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.X86_64 (finalSave finalRestore finalSaved) +open VG.Impl.AesCtr.X86_64 (zeroSlots tailKey) +open VG.Proof.AesCfb.X86_64 (fW fR fIv fD fL fN fU fT fData fBlk fTail fSp) + +/-- The code's contract, with the arguments `(schedule = rdi, rounds = rsi, +ctr = rdx, data = rcx, len = r8, save = r9)`, `save` of 64 bytes: the data +and the counter block as `Spec.Ctr.CryptFinal` says, by Camellia with the +subkeys at `schedule`. -/ +def ctrFinalX86_64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .rdi, 272⟩ + let ctr : Region := ⟨s.gpr .rdx, 16⟩ + let data : Region := ⟨s.gpr .rcx, (s.gpr .r8).toNat⟩ + let sv : Region := ⟨s.gpr .r9, 64⟩ + let ret : Region := ⟨s.gpr .rsp, 8⟩ + let stack := below (s.gpr .rsp) 3296 + 3296 ≤ (s.gpr .rsp).toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + ret.Disjoint sched ∧ ret.Disjoint ctr ∧ ret.Disjoint data ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .rdi).toNat + 272 ≤ 2 ^ 64 ∧ (s.gpr .rdx).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .rcx).toNat + (s.gpr .r8).toNat ≤ 2 ^ 64 ∧ (s.gpr .r9).toNat + 64 ≤ 2 ^ 64 ∧ + ((s.gpr .rsi).toNat = 18 ∨ (s.gpr .rsi).toNat = 24) + post s s' := + Spec.Ctr.CryptFinal (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (s.gpr .rdi) (s.gpr .rsi).toNat)) + s.mem s'.mem (s.gpr .rdx) (s.gpr .rcx) (s.gpr .r8).toNat + pub s₁ s₂ := + s₁.gpr .rdi = s₂.gpr .rdi ∧ s₁.gpr .rsi = s₂.gpr .rsi ∧ s₁.gpr .rdx = s₂.gpr .rdx ∧ + s₁.gpr .rcx = s₂.gpr .rcx ∧ s₁.gpr .r8 = s₂.gpr .r8 ∧ s₁.gpr .r9 = s₂.gpr .r9 ∧ + s₁.gpr .rsp = s₂.gpr .rsp + +/-- The contract the frame needs: the shared one on the subkeys, with `save`, +64 bytes, as a sixth argument, and 3296 bytes of stack (the return address of +`vg_camellia_ctr`, and its frame and calls). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract X86_64.abi Spec.Camellia.ctrFinalSig "save" .u64 8 + (Spec.Camellia.ctrFinalPre X86_64.abi.ptrBits) (Proof.Camellia.ctrFinalPostSk X86_64.abi.ptrBits) true 3296 + +/-- A state satisfying the precondition (no data, 18 rounds). -/ +def ctrFinalSat : State where + gpr r := match r with + | .rdi => 0x1000 | .rsi => 18 | .rdx => 0x2000 | .rcx => 0x3000 | .r9 => 0x4000 | .rsp => 0x8000 + | _ => 0 + cf := none + zf := none + sf := none + of := none + mem _ := 0 + rd := [⟨0x1000, 272⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 64⟩] + +theorem ctrFinal_implies : ctrFinalX86_64.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, Proof.Camellia.ctrFinalPostSk, ctrFinalX86_64, + X86_64.abi, X86_64.argRegs] [ctrFinalSat] using ctrFinalSat + +/-! ## The callee -/ + +/-- `vg_camellia_ctr` meets its contract on the subkeys. -/ +theorem ctrFramed_sk : Verified X86_64.target ctrFramed (Proof.Camellia.ctrContractSk X86_64.abi 3288) := + X86_64.Verified.stackScratchWiped (sig := Spec.Camellia.ctrSig) (nm := "scratch") (e := .u64) + (n := 409) (pre := Spec.Camellia.ctrPre X86_64.abi.ptrBits) + (post := Proof.Camellia.ctrPostSk X86_64.abi.ptrBits) (wa := true) (stack := 8) + (bytes := 3280) (by rw [← Proof.Camellia.ctrScratchContract_eq]; exact ctr_verified) + (by decide) (by decide) (by decide) (Code.all_of_allInstrs (by lit_decide)) + (by lit_decide) (by decide) (Proof.Camellia.ctrPostOut_local _) ctrFrameSat_pre + +theorem ctrFramed_spSafe : SpSafe ctrFramed := SpSafe.of_all (Code.all_of_allInstrs (by lit_decide)) + +theorem ctrFramed_depth : ctrFramed.x86_64Depth = 3288 := by lit_decide + +/-- The callee's contract at a call. -/ +abbrev calleeK : Contract isa := Proof.Camellia.ctrContractSk X86_64.abi 3288 + +theorem callee_args {s : State} {W C D : Addr} {R n : Nat} (hrdi : s.gpr .rdi = W) + (hrsi : s.gpr .rsi = BitVec.ofNat 64 R) (hrdx : s.gpr .rdx = C) (hrcx : s.gpr .rcx = D) + (hr8 : s.gpr .r8 = BitVec.ofNat 64 n) (rd wr : List Region) : + regArgs Spec.Camellia.ctrSig (s.callEntry.withRegions rd wr) = [W, BitVec.ofNat 64 R, C, D, BitVec.ofNat 64 n] := by + simp only [regArgs, State.withRegions_gpr, show (Spec.Camellia.ctrSig.words X86_64.abi.ptrBits).length = 5 from rfl, + X86_64.argRegs, List.take_succ_cons, List.take_zero, List.map_cons, List.map_nil, + State.callEntry_gpr s (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rsi ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rdx ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rcx ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.r8 ≠ .rsp), hrdi, hrsi, hrdx, hrcx, hr8] + +theorem callee_bufs (W C D : Addr) {R n : Nat} (hn : n < 2 ^ 64) : + Sig.bufs Spec.Camellia.ctrSig.params [W, BitVec.ofNat 64 R, C, D, BitVec.ofNat 64 n] = + [(⟨W, 272⟩, false), (⟨C, 16⟩, true), (⟨D, 16 * n⟩, true)] := by + simp [Spec.Camellia.ctrSig, Sig.bufs, Elem.size, Nat.mod_eq_of_lt hn, Nat.mul_comm] + +theorem callee_pre {s : State} {W C D : Addr} {R n : Nat} (hrdi : s.gpr .rdi = W) + (hrsi : s.gpr .rsi = BitVec.ofNat 64 R) (hrdx : s.gpr .rdx = C) (hrcx : s.gpr .rcx = D) + (hr8 : s.gpr .r8 = BitVec.ofNat 64 n) (hn : n < 2 ^ 64) (hR : R = 18 ∨ R = 24) + (hsp : 3296 ≤ (s.gpr .rsp).toNat) + (dWC : (⟨W, 272⟩ : Region).Disjoint ⟨C, 16⟩) (dWD : (⟨W, 272⟩ : Region).Disjoint ⟨D, 16 * n⟩) + (dCD : (⟨C, 16⟩ : Region).Disjoint ⟨D, 16 * n⟩) + (hstk : ∀ r ∈ ([⟨W, 272⟩, ⟨C, 16⟩, ⟨D, 16 * n⟩] : List Region), (below (s.gpr .rsp) 3296).Disjoint r) + (fW : W.toNat + 272 ≤ 2 ^ 64) (fC : C.toNat + 16 ≤ 2 ^ 64) (fD : D.toNat + 16 * n ≤ 2 ^ 64) : + calleeK.pre (s.callEntry.withRegions [⟨W, 272⟩] [⟨C, 16⟩, ⟨D, 16 * n⟩]) := by + unfold calleeK Proof.Camellia.ctrContractSk + rw [pre_regs (by decide) (by decide), callee_args hrdi hrsi hrdx hrcx hr8, callee_bufs W C D hn] + have hsp8 : (s.gpr .rsp - 8).toNat = (s.gpr .rsp).toNat - 8 := by + rw [BitVec.toNat_sub_of_le (by rw [BitVec.le_def]; simp; omega)]; rfl + have hret : Region.Sub ⟨s.gpr .rsp - 8, 8⟩ (below (s.gpr .rsp) 3296) := + Offset.sub_below _ (by decide) (by decide) + have hcal : Region.Sub (below (s.gpr .rsp - 8) 3288) (below (s.gpr .rsp) 3296) := below_callee _ 3288 + refine ⟨.inr (by rw [State.withRegions_gpr, State.callEntry_rsp, hsp8]; omega), rfl, rfl, ?_, ?_, ?_, ?_⟩ + · simp only [List.pairwise_cons, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, forall_eq, + List.Pairwise.nil, Bool.true_or, Bool.false_or, forall_const, and_true] + exact ⟨⟨dWC, dWD⟩, dCD, fun _ h => h.elim⟩ + · simp only [State.withRegions_gpr, State.callEntry_rsp] + intro r hr a ha + simp only [List.mem_cons, List.not_mem_nil, or_false] at ha + rw [stackBelow_pos _ (by decide)] at hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl <;> rcases ha with rfl | rfl | rfl + · exact (hstk _ (by simp)).sub_left hret + · exact (hstk _ (by simp)).sub_left hret + · exact (hstk _ (by simp)).sub_left hret + · exact (hstk _ (by simp)).sub_left hcal + · exact (hstk _ (by simp)).sub_left hcal + · exact (hstk _ (by simp)).sub_left hcal + · intro a ha + simp only [List.mem_cons, List.not_mem_nil, or_false] at ha + rcases ha with rfl | rfl | rfl <;> with_reducible assumption + · show (BitVec.ofNat 64 R).toNat = 18 ∨ (BitVec.ofNat 64 R).toNat = 24 + rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt (by omega)]; exact hR + +theorem callee_post {s s₂ : State} {W C D : Addr} {R n : Nat} (hrdi : s.gpr .rdi = W) + (hrsi : s.gpr .rsi = BitVec.ofNat 64 R) (hrdx : s.gpr .rdx = C) (hrcx : s.gpr .rcx = D) + (hr8 : s.gpr .r8 = BitVec.ofNat 64 n) (hn : n < 2 ^ 64) (hR : R = 18 ∨ R = 24) {rd wr : List Region} + (h : calleeK.post (s.callEntry.withRegions rd wr) s₂) : + Spec.Cbc.blocksAt s₂.mem D n = Spec.Ctr.crypt (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.callEntry.mem W R)) + (bytesAt s.callEntry.mem C 16) (Spec.Cbc.blocksAt s.callEntry.mem D n) ∧ + bytesAt s₂.mem C 16 = Spec.Ctr.next (bytesAt s.callEntry.mem C 16) n := by + unfold calleeK Proof.Camellia.ctrContractSk at h + rw [post_regs (by decide), callee_args hrdi hrsi hrdx hrcx hr8] at h + change Curry.apply [ArgWord.addr, ArgWord.int 64, ArgWord.addr, ArgWord.addr, ArgWord.int 64] + (Proof.Camellia.ctrPostSk 64) _ _ _ _ at h + dsimp only [Curry.apply, Proof.Camellia.ctrPostSk, ArgWord.ofRaw] at h + have eN : (BitVec.ofNat 64 n).toNat = n := by rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt hn] + simp only [BitVec.setWidth_eq, eN, State.withRegions_mem] at h + rcases hR with rfl | rfl + · exact h (.inl rfl) + · exact h (.inr rfl) + +theorem callee_pub {s₁ s₂ : State} {W C D : Addr} {R n : Nat} (h₁ : s₁.gpr .rdi = W) + (h₂ : s₁.gpr .rsi = BitVec.ofNat 64 R) (h₃ : s₁.gpr .rdx = C) (h₄ : s₁.gpr .rcx = D) + (h₅ : s₁.gpr .r8 = BitVec.ofNat 64 n) (g₁ : s₂.gpr .rdi = W) + (g₂ : s₂.gpr .rsi = BitVec.ofNat 64 R) (g₃ : s₂.gpr .rdx = C) (g₄ : s₂.gpr .rcx = D) + (g₅ : s₂.gpr .r8 = BitVec.ofNat 64 n) (hsp : s₁.gpr .rsp = s₂.gpr .rsp) (rd₁ wr₁ rd₂ wr₂ : List Region) : + calleeK.pub (s₁.callEntry.withRegions rd₁ wr₁) (s₂.callEntry.withRegions rd₂ wr₂) := by + unfold calleeK Proof.Camellia.ctrContractSk + rw [pub_regs (by decide) (by decide), callee_args h₁ h₂ h₃ h₄ h₅, callee_args g₁ g₂ g₃ g₄ g₅] + refine ⟨?_, fun _ _ => rfl⟩ + simp only [State.withRegions_gpr, State.callEntry_rsp, hsp] + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .r9 +abbrev kSch : Region := ⟨fW s₀, 272⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 48 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below (fSp s₀) 3296 +/-- The registers' values once `save` is in `rax`, and the memory once they +are saved. -/ +abbrev kG : Reg → BitVec 64 := (s₀.setReg .rax (kV s₀)).gpr +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) (kG s₀) finalSaved +/-- The cipher, the counter block and the whole blocks on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Camellia.cipher (Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀)) +abbrev kT : List Byte := bytesAt s₀.mem (fIv s₀) 16 +abbrev kBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (fD s₀) (fN s₀) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp : 3296 ≤ (fSp s₀).toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + ret_sch : (⟨fSp s₀, 8⟩ : Region).Disjoint (kSch s₀) + ret_iv : (⟨fSp s₀, 8⟩ : Region).Disjoint (kIv s₀) + ret_data : (⟨fSp s₀, 8⟩ : Region).Disjoint (fData s₀) + ret_sv : (⟨fSp s₀, 8⟩ : Region).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 272 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 64 ≤ 2 ^ 64 + rounds : fR s₀ = 18 ∨ fR s₀ = 24 + +theorem KPre.of {s₀ : State} (h : ctrFinalX86_64.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22⟩ + +/-! ## Regions and frames -/ + +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := AesCfb.X86_64.blk_sub s₀ +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := AesCfb.X86_64.tail_sub s₀ + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + Spill.saveMem_frame_base _ _ _ finalSaved (by decide) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [AesCfb.X86_64.fN_eq]; omega + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [AesCfb.X86_64.fN_eq, AesCfb.X86_64.fU_eq]; omega) + +theorem KPre.sch_big : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 48 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 48) (by decide), Nat.mod_eq_of_lt (by omega)] + +omit hp in +theorem KPre.rsi : s₀.gpr .rsi = BitVec.ofNat 64 (fR s₀) := by + apply BitVec.eq_of_toNat_eq; simp + +end + +/-- The subkeys, from memory that agrees with the entry's on the schedule. -/ +theorem subkeys_of {s₀ : State} (hp : KPre s₀) {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : + Spec.Camellia.subkeysAt m (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt m₀ (fW s₀) (fR s₀) := + subkeysAt_congr (by rcases hp.rounds with h | h <;> rw [h] <;> decide) + fun i hi => hf.bytes (R := kSch s₀) hd (by show 272 ≤ 2 ^ 64; decide) hi + +/-! ## Saving the registers -/ + +theorem load0_ok (s : State) : runBlock isa [.mov .rax (.reg .r9)] s = some (s.setReg .rax (s.gpr .r9)) := by + simp only [runBlock_cons, runStep_some, runBlock_nil, reduceExec, readSrc, Option.map_some] + +theorem load_ok (s : State) : runBlock isa ctrFinalLoad s = some (s.setReg .rax (s.gpr .r15)) := by + simp only [ctrFinalLoad, runBlock_cons, runStep_some, runBlock_nil, reduceExec, readSrc, Option.map_some] + +theorem moves_ok (s : State) : + ∃ s', runBlock isa ctrFinalMoves s = some s' ∧ + s'.gpr .rbx = s.gpr .rdi ∧ s'.gpr .rbp = s.gpr .rsi ∧ s'.gpr .r12 = s.gpr .rdx ∧ + s'.gpr .r15 = s.gpr .rax ∧ s'.gpr .r14 = s.gpr .r8 &&& 15#64 ∧ + s'.gpr .r13 = s.gpr .r8 - (s.gpr .r8 &&& 15#64) + s.gpr .rcx ∧ s'.gpr .r8 = s.gpr .r8 >>> 4 ∧ + s'.gpr .rdi = s.gpr .rdi ∧ s'.gpr .rsi = s.gpr .rsi ∧ s'.gpr .rdx = s.gpr .rdx ∧ + s'.gpr .rcx = s.gpr .rcx ∧ s'.gpr .rsp = s.gpr .rsp ∧ + s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [reduceCtorEq, ↓reduceIte, ctrFinalMoves, runBlock_cons, + runStep_some, runBlock_nil, reduceExec, execAlu, execShift, readSrc, Option.bind_some, Option.map_some, + gpr_setReg, gpr_arithFlags, Nat.reduceLeDiff, and_self, AesCfb.X86_64.signExtend_15] + rfl, ?_⟩ + simp only [gpr_setReg, gpr_arithFlags, gpr_setFlags, mem_setReg, mem_arithFlags, mem_setFlags, rd_setReg, + rd_arithFlags, rd_setFlags, wr_setReg, wr_arithFlags, wr_setFlags, reduceCtorEq, ↓reduceIte, and_self] + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + rbx : s.gpr .rbx = fW s₀ + rbp : s.gpr .rbp = s₀.gpr .rsi + r12 : s.gpr .r12 = fIv s₀ + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rdi : s.gpr .rdi = fW s₀ + rsi : s.gpr .rsi = s₀.gpr .rsi + rdx : s.gpr .rdx = fIv s₀ + rcx : s.gpr .rcx = fD s₀ + r8 : s.gpr .r8 = BitVec.ofNat 64 (fN s₀) + rsp : s.gpr .rsp = fSp s₀ + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : + WP isa (.block ctrFinalSetup) (s₀.setReg .rax (kV s₀)) (KSetup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions (s₀.setReg .rax (kV s₀)).wr + (Spill.slot ((s₀.setReg .rax (kV s₀)).gpr .rax) p.2) 8 := by + intro p hp' + rw [wr_setReg, gpr_setReg_self, hp.wr] + have := AesCfb.X86_64.saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .rax finalSaved ++ ctrFinalMoves)) _ _ + refine Spill.save_then .rax finalSaved hw ?_ + refine WP.mono (WP.of_runBlock (moves_ok _)) + fun s' ⟨rbx, rbp, r12, r15, r14, r13, r8, rdi, rsi, rdx, rcx, rsp, mem, rd, wr⟩ => ?_ + simp only [gpr_setReg, reduceCtorEq, ↓reduceIte] at rbx rbp r12 r15 r14 r13 r8 rdi rsi rdx rcx rsp + exact ⟨rbx, rbp, r12, by rw [r13, AesCfb.X86_64.and15, AesCfb.X86_64.tail_addr], + by rw [r14, AesCfb.X86_64.and15], r15, rdi, rsi, rdx, rcx, by rw [r8, AesCfb.X86_64.shr4], rsp, + by rw [mem, mem_setReg, gpr_setReg_self], by rw [rd, rd_setReg], by rw [wr, wr_setReg]⟩ + +/-! ## The whole blocks -/ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + rbx : s.gpr .rbx = fW s₀ + rbp : s.gpr .rbp = s₀.gpr .rsi + r12 : s.gpr .r12 = fIv s₀ + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (fN s₀) + +theorem whole_regions {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + calleeK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨callee_pre h.rdi (h.rsi.trans KPre.rsi) h.rdx h.rcx h.r8 (AesCfb.X86_64.n_lt s₀) hp.rounds + (by rw [h.rsp]; exact hp.sp) hp.sch_iv (hp.sch_data.sub_right (blk_sub s₀)) + (hp.iv_data.sub_right (blk_sub s₀)) (fun r hr => ?_) hp.sch_wrap hp.iv_wrap hp.blk_wrap, ?_, ?_⟩ + · rw [h.rsp] + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.stk_sch + · exact hp.stk_iv + · exact hp.stk_data.sub_right (blk_sub s₀) + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The save and a call's return address change only `save` and the stack. -/ +theorem entry_frame {s₀ s : State} (h : KSetup s₀ s) : Frame [kSv s₀, kStk s₀] s₀.mem s.callEntry.mem := by + have f₁ : Frame [kSv s₀, kStk s₀] s₀.mem s.mem := by + rw [h.mem]; exact (svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr] + have f₂ : Frame [kSv s₀, kStk s₀] s.mem s.callEntry.mem := + (AesCbc.X86_64.callEntry_frame s).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨kStk s₀, by simp, by rw [h.rsp]; exact Offset.sub_below _ (by decide) (by decide)⟩ + exact f₁.trans f₂ + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + WP isa (.call "vg_camellia_ctr" ctrFramed) s (KWhole s₀) := by + have ef := entry_frame h + have dS : ∀ r ∈ [kSv s₀, kStk s₀], (kSch s₀).Disjoint r := by + intro r hr; simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.sch_sv + · exact hp.stk_sch.symm + have eT : bytesAt s.callEntry.mem (fIv s₀) 16 = kT s₀ := AesCbc.X86_64.bytesAt_frame ef (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.iv_sv + · exact hp.stk_iv.symm) (by decide) + have eB : Spec.Cbc.blocksAt s.callEntry.mem (fD s₀) (fN s₀) = kBlks s₀ := + AesCfb.X86_64.blocksAt_frame' ef fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.data_sv.sub_left (blk_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀) + obtain ⟨hpre, hc, hw⟩ := whole_regions hp h + refine WP.callF (k := calleeK) ctrFramed_sk.1 ctrFramed_spSafe (by rw [ctrFramed_depth]; decide) hpre hc hw ?_ + intro s' rd' wr' cs' fr' ⟨s₂, mem₂, _, post₂⟩ _ + rw [ctrFramed_depth, h.rsp, h.mem] at fr' + obtain ⟨pb, pc⟩ := callee_post h.rdi (h.rsi.trans KPre.rsi) h.rdx h.rcx h.r8 (AesCfb.X86_64.n_lt s₀) hp.rounds + post₂ + rw [mem₂, subkeys_of hp ef dS, eT, eB] at pb + rw [mem₂, eT] at pc + refine ⟨by rw [cs' .rbx (by simp [calleeSaved]), h.rbx], by rw [cs' .rbp (by simp [calleeSaved]), h.rbp], + by rw [cs' .r12 (by simp [calleeSaved]), h.r12], by rw [cs' .r13 (by simp [calleeSaved]), h.r13], + by rw [cs' .r14 (by simp [calleeSaved]), h.r14], by rw [cs' .r15 (by simp [calleeSaved]), h.r15], + by rw [cs' .rsp (by simp [calleeSaved]), h.rsp], by rw [rd', h.rd], by rw [wr', h.wr], + fr'.mono fun r hr => ?_, pb, pc⟩ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem test_wp {s₀ s : State} (h : KWhole s₀ s) : + WP isa (.block [.alu .test .r14 (.reg .r14)]) s fun s' => KWhole s₀ s' ∧ s'.zf = some (decide (fU s₀ = 0)) := + WP.of_runBlock ⟨_, AesCfb.X86_64.test_ok s, + ⟨h.rbx, h.rbp, h.r12, h.r13, h.r14, h.r15, h.rsp, h.rd, h.wr, h.frame, h.blocks, h.ctr⟩, by + have eU := AesCfb.X86_64.fU_eq s₀ + rw [zf_arithFlags, BitVec.and_self, h.r14, + AesCfb.X86_64.beq_zero' (by have := Nat.mod_lt (fL s₀) (by decide : 16 > 0); omega)]⟩ + +/-! ## The partial last block -/ + +/-- `save` to `rax`, from a state `F` describes. -/ +abbrev Loaded (F : State → Prop) (s₀ s : State) : Prop := ∃ w, F w ∧ s = w.setReg .rax (kV s₀) + +theorem tailMoves_ok (s : State) : + ∃ s', runBlock isa ctrFinalTailMoves s = some s' ∧ + s'.gpr .rdi = s.gpr .rbx ∧ s'.gpr .rsi = s.gpr .rbp ∧ s'.gpr .rdx = s.gpr .r12 ∧ + s'.gpr .rcx = s.gpr .rax + BitVec.ofNat 64 48 ∧ s'.gpr .r8 = 1 ∧ + (∀ r ∈ calleeSaved, s'.gpr r = s.gpr r) ∧ s'.gpr .r13 = s.gpr .r13 ∧ s'.gpr .r14 = s.gpr .r14 ∧ + s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [ctrFinalTailMoves, runBlock_cons, runStep_some, reduceExec, execAlu, readSrc, Option.bind_some, + Option.map_some] + rfl, ?_⟩ + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> + try simp [gpr_setReg, State.setReg32, mem_arithFlags, rd_arithFlags, wr_arithFlags, mem_setReg, rd_setReg, + wr_setReg] + intro r hr + simp only [calleeSaved, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame m _ g zeroSlots fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KTArgs (s₀ s : State) : Prop where + rdi : s.gpr .rdi = fW s₀ + rsi : s.gpr .rsi = s₀.gpr .rsi + rdx : s.gpr .rdx = fIv s₀ + rcx : s.gpr .rcx = kBk s₀ + r8 : s.gpr .r8 = BitVec.ofNat 64 1 + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem tail_load_wp {s₀ s : State} (h : KWhole s₀ s) : WP isa (.block ctrFinalLoad) s (Loaded (KWhole s₀) s₀) := + WP.of_runBlock ⟨_, load_ok s, s, h, by rw [h.r15]⟩ + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) (s.setReg .rax (kV s₀)) (KTArgs s₀) := by + obtain ⟨s₂, r₂, z₂, k₂, m₂, rd₂, wr₂⟩ := AesCtr.X86_64.zero_ok (s.setReg .rax (kV s₀)) + show WP isa (.block ([.mov32 .r10 (.imm 0)] ++ (Spill.saveCode .rax zeroSlots ++ ctrFinalTailMoves))) _ _ + refine WP.block_append_iff.mpr (WP.of_runBlock ⟨s₂, r₂, ?_⟩) + have k₂' : ∀ r, r ≠ .r10 → r ≠ .rax → s₂.gpr r = s.gpr r := fun r h₁ h₂ => by + rw [k₂ r h₁, gpr_setReg_of_ne _ _ h₂] + have hrax : s₂.gpr .rax = kV s₀ := by rw [k₂ _ (by decide), gpr_setReg_self] + have hw : ∀ p ∈ zeroSlots, InRegions s₂.wr (Spill.slot (s₂.gpr .rax) p.2) 8 := by + intro p hp' + rw [wr₂, wr_setReg, h.wr, hp.wr, hrax] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + refine Spill.save_then .rax zeroSlots hw ?_ + refine WP.mono (WP.of_runBlock (tailMoves_ok _)) + fun s' ⟨rdi, rsi, rdx, rcx, r8, cs, r13, r14, mem, rd, wr⟩ => ?_ + have e : ∀ r, ({ s₂ with mem := Spill.saveMem s₂.mem (s₂.gpr .rax) s₂.gpr zeroSlots } : State).gpr r = + s₂.gpr r := fun _ => rfl + rw [e] at rdi rsi rdx rcx r13 r14 + have hm : s'.mem = Spill.saveMem s.mem (kV s₀) s₂.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₂.mem _ _ _ = _; rw [m₂, mem_setReg, hrax] + have fz : Frame [kBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + refine ⟨by rw [rdi, k₂' _ (by decide) (by decide), h.rbx], by rw [rsi, k₂' _ (by decide) (by decide), h.rbp], + by rw [rdx, k₂' _ (by decide) (by decide), h.r12], by rw [rcx, hrax], r8, + by rw [r13, k₂' _ (by decide) (by decide), h.r13], by rw [r14, k₂' _ (by decide) (by decide), h.r14], + by rw [cs .r15 (by simp [calleeSaved]), e, k₂' _ (by decide) (by decide), h.r15], + by rw [cs .rsp (by simp [calleeSaved]), e, k₂' _ (by decide) (by decide), h.rsp], + by rw [rd, rd₂, rd_setReg, h.rd], by rw [wr, wr₂, wr_setReg, h.wr], ?_, ?_, ?_, ?_⟩ + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [AesCfb.X86_64.blocksAt_frame' fz blkZ]; exact h.blocks + · rw [AesCbc.X86_64.bytesAt_frame fz ivZ (by decide)]; exact h.ctr + · rw [hm, show Spill.saveMem s.mem (kV s₀) s₂.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₂.gpr .r10)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₂.gpr .r10)) by + simp only [Spill.saveMem, zeroSlots, Spill.slot, Offset.add_add], z₂] + exact AesCtr.X86_64.zero_bytes _ _ + +theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by + simp [Spec.Camellia.cipher] + +/-- What the call on the block leaves. -/ +structure KTCall (s₀ s : State) : Prop where + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (kT s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (kT s₀) (fN s₀)) + +theorem tail_regions {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s₀ s) : + calleeK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, ⟨kBk s₀, 16 * 1⟩]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, ⟨kBk s₀, 16 * 1⟩]) (s.rd ++ s.wr) ∧ + Covers [kIv s₀, ⟨kBk s₀, 16 * 1⟩] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨callee_pre h.rdi (h.rsi.trans KPre.rsi) h.rdx h.rcx h.r8 (by decide) hp.rounds + (by rw [h.rsp]; exact hp.sp) hp.sch_iv (hp.sch_sv.sub_right bs) (hp.iv_sv.sub_right bs) (fun r hr => ?_) + hp.sch_wrap hp.iv_wrap (by rw [hp.bk_toNat]; have := hp.sv_wrap; omega), ?_, ?_⟩ + · rw [h.rsp] + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.stk_sch + · exact hp.stk_iv + · exact hp.stk_sv.sub_right bs + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 48, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 48, by simp, by simp⟩ + +theorem KTArgs.entry {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s₀ s) : + Spec.Camellia.subkeysAt s.callEntry.mem (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀) ∧ + bytesAt s.callEntry.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (fN s₀) ∧ + bytesAt s.callEntry.mem (kBk s₀) 16 = List.replicate 16 0 := by + have ef := AesCbc.X86_64.callEntry_frame s + have stk : Region.Sub (below (s.gpr .rsp) 8) (kStk s₀) := by + rw [h.rsp]; exact Offset.sub_below _ (by decide) (by decide) + have big := big_of (kW1_kW h.frame) + refine ⟨?_, ?_, ?_⟩ + · rw [subkeys_of hp ef fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.stk_sch.symm.sub_right stk] + exact subkeys_of hp big hp.sch_big + · rw [AesCbc.X86_64.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.stk_iv.symm.sub_right stk) (by decide)] + exact h.ctr + · rw [AesCbc.X86_64.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.stk_sv.symm.sub_left (blk_sv_sub s₀)).sub_right stk) (by decide)] + exact h.zero + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s₀ s) : + WP isa (.call "vg_camellia_ctr" ctrFramed) s (KTCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_regions hp h + obtain ⟨eK, eT, eZ⟩ := h.entry hp + refine WP.callF (k := calleeK) ctrFramed_sk.1 ctrFramed_spSafe (by rw [ctrFramed_depth]; decide) hpre hc hw ?_ + intro s' rd' wr' cs' fr' ⟨s₂, mem₂, _, post₂⟩ _ + rw [ctrFramed_depth, h.rsp] at fr' + obtain ⟨pb, pc⟩ := callee_post h.rdi (h.rsi.trans KPre.rsi) h.rdx h.rcx h.r8 (by decide) hp.rounds post₂ + rw [mem₂, eK, eT] at pb + rw [mem₂, eT] at pc + have fc : Frame (kW1 s₀) s.mem s'.mem := fr'.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kBlk s₀, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs' .r13 (by simp [calleeSaved]), h.r13], by rw [cs' .r14 (by simp [calleeSaved]), h.r14], + by rw [cs' .r15 (by simp [calleeSaved]), h.r15], by rw [cs' .rsp (by simp [calleeSaved]), h.rsp], + by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, pc, ?_⟩ + · rw [AesCfb.X86_64.blocksAt_frame' fr' fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) eZ pb + +theorem key_load_wp {s₀ s : State} (h : KTCall s₀ s) : WP isa (.block ctrFinalLoad) s (Loaded (KTCall s₀) s₀) := + WP.of_runBlock ⟨_, load_ok s, s, h, by rw [h.r15]⟩ + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (kT s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.r15, h.rsp, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu]; exact h.ctr⟩ + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KTCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) + (s.setReg .rax (kV s₀)) (KDone s₀) := by + obtain ⟨s₁, r₁, rax₁, k₁, m₁, rd₁, wr₁⟩ := AesCtr.X86_64.key_ok (s.setReg .rax (kV s₀)) + rw [gpr_setReg_self] at rax₁ + have k₁' : ∀ r, r ≠ .rax → s₁.gpr r = s.gpr r := fun r hr => by rw [k₁ r hr, gpr_setReg_of_ne _ _ hr] + rw [mem_setReg] at m₁ + rw [rd_setReg] at rd₁ + rw [wr_setReg] at wr₁ + refine WP.seq (WP.of_runBlock ⟨s₁, r₁, ?_⟩) + have hU : fU s₀ < 16 := Nat.mod_lt _ (by decide) + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have eN := AesCfb.X86_64.fN_eq s₀ + have eU := AesCfb.X86_64.fU_eq s₀ + have hT : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + have hB := hp.bk_toNat + have xp : Modes.X86_64.XPre s₁ (kBk s₀) (fT s₀) (fU s₀) .r13 .r14 := { + pos := by omega + small := by omega + fitK := by omega + fitR := by rw [hT]; omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [rd₁, wr₁, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [wr₁, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) + dl := by decide + dRax := by decide + dR10 := by decide + dRcx := by decide } + have x0 : Modes.X86_64.XInv s₁ (kBk s₀) (fT s₀) (fU s₀) .r13 .r14 0 s₁ := { + rax := by rw [rax₁]; exact (BitVec.add_zero _).symm + dat := by rw [k₁' _ (by decide), h.r13]; exact (BitVec.add_zero _).symm + left := by rw [k₁' _ (by decide), h.r14, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Modes.X86_64.xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + refine ⟨by rw [d.gpr .r15 (by decide) (by decide) (by decide) (by decide) (by decide), k₁' _ (by decide), h.r15], + by rw [d.gpr .rsp (by decide) (by decide) (by decide) (by decide) (by decide), k₁' _ (by decide), h.rsp], + by rw [d.rd, rd₁, h.rd], by rw [d.wr, wr₁, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · refine kW1_kW h.frame |>.trans ?_ + rw [← m₁] + exact d.frame.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩ + · rw [AesCfb.X86_64.blocksAt_frame' d.frame fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, m₁] + exact h.blocks + · rw [d.data q hq, m₁, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← AesCfb.X86_64.bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, AesCbc.X86_64.bytesAt_frame d.frame ivT (by decide), m₁, h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) (hz : s.zf = some (decide (fU s₀ = 0))) : + WP isa (.ite .e (.block []) ctrFinalTail) s (KDone s₀) := by + have ev : isa.eval .e s = some (decide (fU s₀ = 0)) := hz + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + refine WP.seq (WP.mono (tail_load_wp h) fun _ ⟨w, hw, e⟩ => ?_) + subst e + exact WP.seq (WP.mono (tail_args_wp hp hw) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => + WP.seq (WP.mono (key_load_wp h₂) fun _ ⟨w', hw', e'⟩ => by subst e'; exact tail_xor_wp hp hw' hu))) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.seq (.block ctrFinalLoad) (.block finalRestore)) s fun s' => gprPreserved s₀ s' ∧ s'.mem = s.mem := by + have big := big_of h.frame + refine WP.seq (WP.of_runBlock ⟨_, load_ok s, ?_⟩) + rw [h.r15] + have hs : Spill.Saved (s.setReg .rax (kV s₀)).mem ((s.setReg .rax (kV s₀)).gpr .rax) (kG s₀) finalSaved := by + rw [mem_setReg, gpr_setReg_self] + refine (Spill.saveMem_saved _ _ _ _ (by decide)).frame h.frame fun p hp' r hr => ?_ + have := AesCfb.X86_64.saved_slots p hp' + have hsub : Region.Sub ⟨Spill.slot (kV s₀) p.2, 8⟩ (kSv s₀) := Offset.sub_base _ (by omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .rax finalSaved)) _ _ + refine WP.mono (Spill.restore_ok .rax finalSaved (kG s₀) _ (by decide) (fun p hp' => ?_) hs) + fun s' ⟨g₁, g₂, mem', _, _⟩ => ?_ + · rw [rd_setReg, wr_setReg, gpr_setReg_self, h.rd, h.wr, hp.rd, hp.wr] + have := AesCfb.X86_64.saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + · have cs := Spill.calleeSaved_ok g₁ g₂ (by decide) + (show _ = (s₀.setReg .rax (kV s₀)).gpr .rsp by + rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), h.rsp]) + refine ⟨⟨fun r hr => by rw [cs r hr]; exact gpr_setReg_of_ne _ _ (AesCfb.X86_64.calleeSaved_ne_rax' hr), ?_⟩, + by rw [mem', mem_setReg]⟩ + rw [mem', mem_setReg] + refine big.readW (r := ⟨fSp s₀, 8⟩) (Region.contains_self _ _) (fun r hr => ?_) (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.ret_iv + · exact hp.ret_data + · exact hp.ret_sv + · exact Offset.base_disjoint_below _ (by decide) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => gprPreserved s₀ s' ∧ ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.of_runBlock ⟨_, load0_ok s₀, ?_⟩) + refine WP.seq (WP.mono (setup_wp hp) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₂) fun s₃ h₃ => ?_) + refine WP.seq (WP.mono (test_wp h₃) fun s₄ ⟨h₄, z₄⟩ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₄ z₄) fun s₅ h₅ => ?_) + exact WP.mono (end_wp hp h₅) fun _ ⟨g, m⟩ => ⟨g, s₅, h₅, m⟩ + +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86_64.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem ctrFinal_mx : ctrFinal.allInstrs (fun i => !loadsMxcsr i) = true := by lit_decide + +theorem final_correct (s : State) (hs : ctrFinalX86_64.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalX86_64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, abiPreserved_of_exec ctrFinal_mx he hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem load0_taint : ∃ h, (taint.check (Taint.ofRegs [.r9]) (.block [.mov .rax (.reg .r9)]) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.rdi, .rsi, .rdx, .rcx, .r8, .rsp, .rax]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (Taint.ofRegs [.r14]) (.block [.alu .test .r14 (.reg .r14)]) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem load_taint : ∃ h, (taint.check (Taint.ofRegs [.r15]) (.block ctrFinalLoad) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.rax, .rbx, .rbp, .r12, .rsp]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.rax, .r13, .r14]) + (.seq (.block tailKey) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.rax]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalX86_64.pre s₀) (h0' : ctrFinalX86_64.pre s₀') + (hq : ctrFinalX86_64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qR, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, qD, qN] + have qRn : fR s₀ = fR s₀' := by simp only [fR, qR] + have r₁ := AesCtr.X86_64.taint_rel (P := fun a b => a = s₀ ∧ b = s₀') (F₁ := (· = s₀.setReg .rax (kV s₀))) + (F₂ := (· = s₀'.setReg .rax (kV s₀'))) [.r9] load0_taint + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h; simp only [List.mem_singleton] at hr; subst hr; exact qV) + fun a b h => by + obtain ⟨rfl, rfl⟩ := h; exact ⟨WP.of_runBlock ⟨_, load0_ok _, rfl⟩, WP.of_runBlock ⟨_, load0_ok _, rfl⟩⟩ + have r₂ := AesCtr.X86_64.taint_rel + (P := fun a b => a = s₀.setReg .rax (kV s₀) ∧ b = s₀'.setReg .rax (kV s₀')) + (F₁ := KSetup s₀) (F₂ := KSetup s₀') [.rdi, .rsi, .rdx, .rcx, .r8, .rsp, .rax] setup_taint + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> + simp only [gpr_setReg, reduceCtorEq, ↓reduceIte, qW, qR, qIv, qD, qL, qSp, kV, qV]) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩ + have r₃ := (RelCT.callEx (k := calleeK) (n := "vg_camellia_ctr") ctrFramed_sk.1 ctrFramed_sk.2.1 + (P := fun a b => KSetup s₀ a ∧ KSetup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_regions hp ha + obtain ⟨pb, cb, wb⟩ := whole_regions hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ + exact callee_pub ha.rdi (ha.rsi.trans KPre.rsi) ha.rdx ha.rcx ha.r8 + (hb.rdi.trans (by rw [fW, fW, qW])) (hb.rsi.trans (KPre.rsi.trans (by rw [qRn]))) + (hb.rdx.trans (by rw [fIv, fIv, qIv])) (hb.rcx.trans (by rw [fD, fD, qD])) (hb.r8.trans (by rw [qN])) + (by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]) _ _ _ _).wp + (F₁ := KWhole s₀) (F₂ := KWhole s₀') fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + have r₄ := AesCtr.X86_64.taint_rel (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) + (F₁ := fun (s : State) => KWhole s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => KWhole s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) [.r14] test_taint + (fun a b h r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r14, h.2.r14, qU]) + fun a b h => ⟨test_wp h.1, test_wp h.2⟩ + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) ctrFinalTail + fun a b => KDone s₀ a ∧ KDone s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := AesCtr.X86_64.taint_rel (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) + (F₁ := Loaded (KWhole s₀) s₀) (F₂ := Loaded (KWhole s₀') s₀') [.r15] load_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r15, h.2.r15, kV, kV, qV]) + fun a b h => ⟨tail_load_wp h.1, tail_load_wp h.2⟩ + have a₂ := AesCtr.X86_64.taint_rel (P := fun a b => Loaded (KWhole s₀) s₀ a ∧ Loaded (KWhole s₀') s₀' b) + (F₁ := KTArgs s₀) (F₂ := KTArgs s₀') [.rax, .rbx, .rbp, .r12, .rsp] tailArgs_taint + (fun a b h r hr => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · rw [gpr_setReg_self, gpr_setReg_self, kV, kV, qV] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rbx, hw'.rbx, fW, fW, qW] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rbp, hw'.rbp, qR] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r12, hw'.r12, fIv, fIv, qIv] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rsp, hw'.rsp, fSp, fSp, + qSp]) + fun a b h => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + exact ⟨tail_args_wp hp hw, tail_args_wp hp' hw'⟩ + have a₃ := (RelCT.callEx (k := calleeK) (n := "vg_camellia_ctr") ctrFramed_sk.1 ctrFramed_sk.2.1 + (P := fun a b => KTArgs s₀ a ∧ KTArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_regions hp ha + obtain ⟨pb, cb, wb⟩ := tail_regions hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ + exact callee_pub ha.rdi (ha.rsi.trans KPre.rsi) ha.rdx ha.rcx ha.r8 + (hb.rdi.trans (by rw [fW, fW, qW])) (hb.rsi.trans (KPre.rsi.trans (by rw [qRn]))) + (hb.rdx.trans (by rw [fIv, fIv, qIv])) (hb.rcx.trans (by rw [kBk, kBk, kV, kV, qV])) hb.r8 + (by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]) _ _ _ _).wp + (F₁ := KTCall s₀) (F₂ := KTCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + have a₄ := AesCtr.X86_64.taint_rel (P := fun a b => KTCall s₀ a ∧ KTCall s₀' b) + (F₁ := Loaded (KTCall s₀) s₀) (F₂ := Loaded (KTCall s₀') s₀') [.r15] load_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r15, h.2.r15, kV, kV, qV]) + fun a b h => ⟨key_load_wp h.1, key_load_wp h.2⟩ + have a₅ := AesCtr.X86_64.taint_rel (P := fun a b => Loaded (KTCall s₀) s₀ a ∧ Loaded (KTCall s₀') s₀' b) + (F₁ := KDone s₀) (F₂ := KDone s₀') [.rax, .r13, .r14] xor_taint + (fun a b h r hr => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [gpr_setReg_self, gpr_setReg_self, kV, kV, qV] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r13, hw'.r13, qT] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r14, hw'.r14, qU]) + fun a b h => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + exact ⟨tail_xor_wp hp hw hu, tail_xor_wp hp' hw' hu'⟩ + exact a₁.seq (a₂.seq ((a₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₄.seq a₅))) + have r₅ : RelCT isa (fun a b => (KWhole s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (KWhole s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) (.ite .e (.block []) ctrFinalTail) + (fun a b => KDone s₀ a ∧ KDone s₀' b) := by + refine RelCT.ite (fun a b h => ?_) ?_ ?_ + · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + exact ⟨done_of_zero h.1.1.1 h0, done_of_zero h.1.2.1 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + have r₆ := AesCtr.X86_64.taint_rel (P := fun a b => KDone s₀ a ∧ KDone s₀' b) + (F₁ := fun (s : State) => s.gpr .rax = kV s₀) (F₂ := fun (s : State) => s.gpr .rax = kV s₀') [.r15] + load_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r15, h.2.r15, kV, kV, qV]) + fun a b h => ⟨WP.of_runBlock ⟨_, load_ok _, by rw [gpr_setReg_self, h.1.r15]⟩, + WP.of_runBlock ⟨_, load_ok _, by rw [gpr_setReg_self, h.2.r15]⟩⟩ + obtain ⟨_, t₇⟩ := restore_taint + have r₇ := RelCT.taint (A := taint) (P := fun a b => a.gpr .rax = kV s₀ ∧ b.gpr .rax = kV s₀') _ + (fun a b h => Taint.agree_ofRegs fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1, h.2, kV, kV, qV]) t₇ + exact r₁.seq (r₂.seq ((r₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₄.seq (r₅.seq (r₆.seq r₇))))) + +theorem final_ct : ConstantTime isa ctrFinalX86_64.pre ctrFinalX86_64.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_spSafe : ctrFinal.all (fun i => !X86_64.isa.writesSp i) = true := Code.all_of_allInstrs (by lit_decide) + +theorem ctrFinal_xdepth : ctrFinal.x86_64Depth ≤ 3296 := by lit_decide + +theorem ctrFinal_verified : Verified X86_64.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +`vg_camellia_ctr_final` has five argument words, so `save` is passed in `r9`: +it runs its code in a frame of 72 bytes (`withStackScratchWiped`), the +quadword standing for the return address and `save`'s 64 bytes (the +registers, then the block that held the last output block), which it zeroes +before returning. The code's calls use 3296 bytes below it, so 3368 in all. -/ + +/-- A state satisfying the precondition, without `save`. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk X86_64.abi 3368).pre s := by + implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, + Proof.Camellia.ctrFinalPostSk, X86_64.abi, X86_64.argRegs] [ctrFinalFrameSat, ctrFinalSat] + using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 72 .r9 8 ctrFinal) + (Spec.Camellia.ctrFinalContract X86_64.abi 3368) := + Proof.Camellia.ctrFinal_of_sk <| + X86_64.Verified.stackScratchWiped (sig := Spec.Camellia.ctrFinalSig) (nm := "save") (e := .u64) + (n := 8) (pre := Spec.Camellia.ctrFinalPre X86_64.abi.ptrBits) + (post := Proof.Camellia.ctrFinalPostSk X86_64.abi.ptrBits) (wa := true) (stack := 3296) + (bytes := 72) ctrFinal_verified (by decide) (by decide) (by decide) ctrFinal_spSafe ctrFinal_xdepth + (by decide) (Proof.Camellia.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Camellia.X86_64 diff --git a/lean/VerifiedGarbage/Proof/Modes/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Modes/CtrFinal.lean new file mode 100644 index 00000000000..bac769fa561 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Modes/CtrFinal.lean @@ -0,0 +1,160 @@ +module + +public import VerifiedGarbage.Spec.Ctr.Final +import VerifiedGarbage.Proof.AesCtr.Spec +import VerifiedGarbage.Proof.AesCbc.Spec + +/-! +# CTR of a message's last piece, for any block cipher and target + +Not trusted. A final CTR function (`vg__ctr_final`) calls the +whole-block CTR function on the `n = len / 16` whole blocks of its data, +which leaves `Tₙ₊₁` in the counter block, then, if `u = len % 16 ≠ 0` bytes +are left, the same function on one block of zeros of its own, which leaves +`Oₙ₊₁ = CIPH_K(Tₙ₊₁)` there (`crypt_zero`) and `Tₙ₊₂` in the counter block, +and XORs the first `u` bytes of that block into the data. `cryptFinal_of`: +what that leaves is `Spec.Ctr.CryptFinal`. Nothing here depends on a cipher +or a target. +-/ + +@[expose] public section + +namespace VG.Proof.Modes.CtrFinal + +open VG +open VG.Spec.Aes (bytesAt) + +theorem bytesAt_length (m : Mem) (p : Addr) (n : Nat) : (bytesAt m p n).length = n := by + simp [bytesAt] + +theorem bytesAt_add (m : Mem) (p : Addr) (a b : Nat) : + bytesAt m p (a + b) = bytesAt m p a ++ bytesAt m (p + BitVec.ofNat 64 a) b := by + simp only [bytesAt, List.range_add, List.map_append, List.map_map, Function.comp_def, BitVec.ofNat_add, + BitVec.add_assoc] + +/-- `16 n` bytes, as `n` blocks. -/ +theorem bytesAt_blocks (m : Mem) (p : Addr) : ∀ n, bytesAt m p (16 * n) = (Spec.Cbc.blocksAt m p n).flatten + | 0 => by simp [bytesAt, Spec.Cbc.blocksAt] + | n + 1 => by + have e : Spec.Cbc.blocksAt m p (n + 1) = + Spec.Cbc.blocksAt m p n ++ [bytesAt m (p + BitVec.ofNat 64 (16 * n)) 16] := by + simp [Spec.Cbc.blocksAt, List.range_succ] + rw [Nat.mul_succ, bytesAt_add, bytesAt_blocks m p n, e, List.flatten_append, List.flatten_singleton] + +/-- The `len` bytes at `p`: its whole blocks, then the rest. -/ +theorem bytesAt_blocks_tail (m : Mem) (p : Addr) (len : Nat) : + bytesAt m p len = (Spec.Cbc.blocksAt m p (len / 16)).flatten ++ + bytesAt m (p + BitVec.ofNat 64 (16 * (len / 16))) (len % 16) := by + have h := bytesAt_add m p (16 * (len / 16)) (len % 16) + rw [Nat.div_add_mod] at h + rw [h, bytesAt_blocks] + +/-- The `u` bytes at `T` XORed with the first `u` of `o`, a byte at a time. -/ +theorem bytesAt_xor {m₀ m' : Mem} {T : Addr} {u : Nat} {o : List Byte} (hu : u ≤ o.length) + (h : ∀ q < u, m' (T + BitVec.ofNat 64 q) = m₀ (T + BitVec.ofNat 64 q) ^^^ o.getD q 0) : + bytesAt m' T u = Spec.Cbc.xor (bytesAt m₀ T u) o := by + apply List.ext_getElem (by simp [bytesAt, Spec.Cbc.xor]; omega) + intro q h₁ h₂ + have hq : q < u := by simpa [bytesAt] using h₁ + simp only [bytesAt, Spec.Cbc.xor, List.getElem_zipWith, List.getElem_map, List.getElem_range] + rw [h q hq, List.getD_eq_getElem?_getD, List.getElem?_eq_getElem (by omega), Option.getD_some] + +/-- XORing blocks of 16 bytes, all at once. -/ +theorem xor_flatten : ∀ (xs os : List (List Byte)), (∀ x ∈ xs, x.length = 16) → (∀ o ∈ os, o.length = 16) → + xs.length = os.length → Spec.Cbc.xor xs.flatten os.flatten = (List.zipWith Spec.Cbc.xor xs os).flatten + | [], [], _, _, _ => rfl + | [], _ :: _, _, _, h => absurd h (by simp) + | _ :: _, [], _, _, h => absurd h (by simp) + | x :: xs, o :: os, hx, ho, h => by + simp only [List.flatten_cons, List.zipWith_cons_cons, Spec.Cbc.xor] + rw [List.zipWith_append (by rw [hx x (by simp), ho o (by simp)])] + exact congrArg _ (xor_flatten xs os (fun y hy => hx y (by simp [hy])) (fun y hy => ho y (by simp [hy])) + (by simpa using h)) + +theorem blocksAt_length16 (m : Mem) (p : Addr) (n : Nat) : ∀ x ∈ Spec.Cbc.blocksAt m p n, x.length = 16 := by + intro x hx + obtain ⟨i, -, rfl⟩ := List.mem_map.mp hx + exact bytesAt_length _ _ _ + +theorem outputs_length16 {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) (t : List Byte) (n : Nat) : + ∀ o ∈ (Spec.Ctr.counters t n).map ciph, o.length = 16 := by + intro o ho + obtain ⟨a, -, rfl⟩ := List.mem_map.mp ho + exact hc a + +theorem outputs_flatten_length {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) : + ∀ (t : List Byte) (n : Nat), ((Spec.Ctr.counters t n).map ciph).flatten.length = 16 * n + | _, 0 => rfl + | t, n + 1 => by + simp only [Spec.Ctr.counters, List.map_cons, List.flatten_cons, List.length_append, hc, + outputs_flatten_length hc (Spec.Ctr.inc t) n] + omega + +theorem flatten_length {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) (m : Mem) (p : Addr) + (t : List Byte) (n : Nat) : + (Spec.Cbc.blocksAt m p n).flatten.length = ((Spec.Ctr.counters t n).map ciph).flatten.length := by + rw [← bytesAt_blocks, bytesAt_length, outputs_flatten_length hc] + +/-- CTR's whole blocks, flattened. -/ +theorem crypt_flatten {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) (m : Mem) (p : Addr) + (t : List Byte) (n : Nat) : + Spec.Cbc.xor (Spec.Cbc.blocksAt m p n).flatten ((Spec.Ctr.counters t n).map ciph).flatten = + (Spec.Ctr.crypt ciph t (Spec.Cbc.blocksAt m p n)).flatten := by + rw [xor_flatten _ _ (blocksAt_length16 m p n) (outputs_length16 hc t n) + (by simp [AesCbc.length_blocksAt, AesCtr.length_counters]), Spec.Ctr.crypt, AesCbc.length_blocksAt] + +/-- The number of blocks of `len` bytes, the last possibly partial. -/ +theorem blockCount_eq (len : Nat) : + Spec.Ctr.blockCount len = if len % 16 = 0 then len / 16 else len / 16 + 1 := by + unfold Spec.Ctr.blockCount + split <;> omega + +/-- CTR of one block of zeros: the output block. -/ +theorem crypt_zero {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) (t : List Byte) : + Spec.Ctr.crypt ciph t [List.replicate 16 0] = [ciph t] := by + simp only [Spec.Ctr.crypt, List.length_singleton, Spec.Ctr.counters, List.map_cons, List.map_nil, + List.zipWith_cons_cons, List.zipWith_nil_left] + refine congrArg (· :: []) (List.ext_getElem (by simp [Spec.Cbc.xor, hc]) fun i h₁ h₂ => ?_) + simp only [Spec.Cbc.xor, List.getElem_zipWith, List.getElem_replicate] + exact BitVec.zero_xor + +/-- The block at `p` after the one-block call, from the zeros it held. -/ +theorem bytesAt_of_blocksAt_one {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) {m₀ m : Mem} + {p : Addr} {t : List Byte} (hz : bytesAt m₀ p 16 = List.replicate 16 0) + (h : Spec.Cbc.blocksAt m p 1 = Spec.Ctr.crypt ciph t (Spec.Cbc.blocksAt m₀ p 1)) : bytesAt m p 16 = ciph t := by + have e : ∀ m' : Mem, Spec.Cbc.blocksAt m' p 1 = [bytesAt m' p 16] := fun m' => by + simp [Spec.Cbc.blocksAt] + rw [e, e, hz, crypt_zero hc] at h + exact List.head_eq_of_cons_eq h + +/-- CTR of the `len` bytes at `D` from the counter block at `P`, from what a +final function leaves: its `n = len / 16` whole blocks as CTR's from +`T₁`, its last `len % 16` bytes XORed a byte at a time with +`CIPH_K(Tₙ₊₁)`, and the counter block advanced once per block, a partial +one included. -/ +theorem cryptFinal_of {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = 16) {m₀ m' : Mem} {P D : Addr} + {len : Nat} + (hblocks : Spec.Cbc.blocksAt m' D (len / 16) = + Spec.Ctr.crypt ciph (bytesAt m₀ P 16) (Spec.Cbc.blocksAt m₀ D (len / 16))) + (htail : ∀ q < len % 16, m' (D + BitVec.ofNat 64 (16 * (len / 16)) + BitVec.ofNat 64 q) = + m₀ (D + BitVec.ofNat 64 (16 * (len / 16)) + BitVec.ofNat 64 q) ^^^ + (ciph (Spec.Ctr.next (bytesAt m₀ P 16) (len / 16))).getD q 0) + (hctr : bytesAt m' P 16 = + Spec.Ctr.next (bytesAt m₀ P 16) (if len % 16 = 0 then len / 16 else len / 16 + 1)) : + Spec.Ctr.CryptFinal ciph m₀ m' P D len := by + refine ⟨?_, by rw [hctr, blockCount_eq]⟩ + have hu : len % 16 < 16 := Nat.mod_lt _ (by decide) + have ht := bytesAt_xor (o := ciph (Spec.Ctr.next (bytesAt m₀ P 16) (len / 16))) (by rw [hc]; omega) htail + have hx := crypt_flatten hc m₀ D (bytesAt m₀ P 16) (len / 16) + rw [Spec.Ctr.cryptFinal, bytesAt_length, blockCount_eq, bytesAt_blocks_tail m' D len, hblocks, ht, + bytesAt_blocks_tail m₀ D len] + split + · rename_i h0 + have e : ∀ (m : Mem) (p : Addr), bytesAt m p (len % 16) = [] := fun m p => by rw [h0]; rfl + rw [e, List.append_nil, ← hx] + simp only [Spec.Cbc.xor, List.zipWith_nil_left, List.append_nil] + · rw [AesCtr.counters_succ, List.map_append, List.flatten_append, List.map_singleton, List.flatten_singleton] + simp only [Spec.Cbc.xor] at hx ⊢ + rw [List.zipWith_append (flatten_length hc m₀ D _ _), hx] + +end VG.Proof.Modes.CtrFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean new file mode 100644 index 00000000000..e2af19b5a8e --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean @@ -0,0 +1,71 @@ +module + +public import VerifiedGarbage.Spec.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Framework.Scratch +import VerifiedGarbage.Proof.Framework.Offset + +-- separate module: shared by the final function's proofs of every target. + +/-! +# SM4-CTR of a message's last piece: the contract's postcondition, by name + +Not trusted, and the same on every target. `ctrFinalPost`: +`Spec.Sm4.ctrFinalContract`'s postcondition (`ctrFinalContract_eq`), which +reads the memory on return only within the function's buffers +(`ctrFinalPostOut_local`), as a frame that keeps working space on the stack +needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by +`Proof.Modes.CtrFinal.cryptFinal_of`, for any cipher. +-/ + +@[expose] public section + +namespace VG.Proof.Sm4 + +open VG.Spec.Sm4 + +/-- `Spec.Sm4.ctrFinalContract`'s postcondition. -/ +def ctrFinalPost (pb : Nat) : ctrFinalSig.Post pb := fun schedule ctr data len m m' _ => + Spec.Ctr.CryptFinal (cipher (scheduleAt m schedule)) m m' ctr data len.toNat + +theorem ctrFinalContract_eq {M : ISA} (A : Abi M) (stack : Nat) : + Spec.Sm4.ctrFinalContract A stack = + ctrFinalSig.contract A (post := ctrFinalPost A.ptrBits) (writeArgs := true) (stack := stack) := rfl + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + Spec.Aes.bytesAt m₂ p k = Spec.Aes.bytesAt m₁ p k := by + simp only [Spec.Aes.bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : + ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by + intro i hi + refine (h _ ?_).symm + by_cases hw : i < 2 ^ 64 + · exact Offset.contains_base _ (by omega) hw + · simp only [Region.Contains] + have := (p + BitVec.ofNat 64 i - p).isLt + omega + +/-- `ctrFinalPost` reads the memory on return only within the buffers. -/ +theorem ctrFinalPostOut_local (pb : Nat) : ∀ vs m m₁ m₂ r, vs.length = (ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPost pb) vs m m₁ r → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPost pb) vs m m₂ r := by + intro vs m m₁ m₂ r hlen hb h + match vs, hlen with + | [k, ctr, data, len], _ => + simp only [ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hc := agree_of' hb.2.1 + have hd := agree_of' hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPost pb) _ m m₁ r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPost pb) _ m m₂ r + dsimp only [Curry.apply, ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + rw [bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] + exact h + +end VG.Proof.Sm4 diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86_64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/X86_64/CtrFinal.lean new file mode 100644 index 00000000000..4550441654e --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/X86_64/CtrFinal.lean @@ -0,0 +1,1042 @@ +module + +public import VerifiedGarbage.Impl.Sm4.X86_64.CtrFinal +public import VerifiedGarbage.Proof.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Sm4.Scratch +public import VerifiedGarbage.Proof.Sm4.X86_64.CtrVerified +import VerifiedGarbage.Proof.AesCfb.X86_64.Final +public import VerifiedGarbage.Proof.Framework.RelCT +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.X86_64.Spill +public import VerifiedGarbage.Proof.Framework.X86_64.StackScratch +import VerifiedGarbage.Proof.AesCtr.X86_64.Final +import VerifiedGarbage.Proof.AesCtr.X86_64.CT +import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.X86_64.FbFinal +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86_64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.X86_64.RegUpd +import VerifiedGarbage.Proof.Framework.X86_64.Exec +import VerifiedGarbage.Proof.Framework.X86_64.Reduce +import VerifiedGarbage.Proof.Framework.X86_64.CallFrame +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.Framework.X86_64.StackScratchWipe +meta import VerifiedGarbage.Impl.Sm4.X86_64.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.Scratch +meta import VerifiedGarbage.Proof.Sm4.X86_64.CtrVerified +meta import VerifiedGarbage.Proof.AesCfb.X86_64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.X86_64.Spill +meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratch +meta import VerifiedGarbage.Proof.AesCtr.X86_64.Final +meta import VerifiedGarbage.Proof.AesCtr.X86_64.CT +meta import VerifiedGarbage.Proof.Sm4.X86_64.ModesLit +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.X86_64.FbFinal +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.X86_64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.X86_64.RegUpd +meta import VerifiedGarbage.Proof.Framework.X86_64.Exec +meta import VerifiedGarbage.Proof.Framework.X86_64.Reduce +meta import VerifiedGarbage.Proof.Framework.X86_64.CallFrame +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.Framework.X86_64.StackScratchWipe + +/-! +# SM4-CTR of a message's last piece on x86-64 + +`ctrFinal_framed`: `vg_sm4_ctr_final` (`Impl/Sm4/X86_64/CtrFinal.lean`) +meets `Spec.Sm4.ctrFinalContract`. Its proof is Camellia's +(`Proof/Camellia/X86_64/CtrFinal.lean`) with SM4's arguments: the code is +proven against `ctrFinalX86_64`, with a fifth argument `save` of 64 bytes in +`r8`, as a caller of `vg_sm4_ctr` (framed by its own working space on the +stack, `ctrFramed`) through its contract, `Spec.Sm4.ctrContract` +(`callee_pre`, `callee_post`, `callee_pub`), on the whole blocks +(`whole_wp`), then, if `u = len % 16` bytes are left, on one zeroed block +after the registers in `save` (`tail_args_wp`, `tail_call_wp`), whose first +`u` bytes are XORed into them (`tail_xor_wp`); what is left before the +registers are restored (`KDone`) gives `Spec.Ctr.CryptFinal` +(`Proof.Modes.CtrFinal.cryptFinal_of`). Constant time (`final_rel`): the +blocks by the taint analysis, the calls by the callee's constant time. +-/ + +@[expose] public section + +namespace VG.Proof.Sm4.X86_64 + +open VG VG.X86_64 +open VG.Spec.Aes (bytesAt) +open VG.X86_64.RegUpd +open VG.Impl.Sm4.X86_64 (ctrFramed ctrFinalMoves ctrFinalSetup ctrFinalLoad ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.X86_64 (finalSave finalRestore finalSaved) +open VG.Impl.AesCtr.X86_64 (zeroSlots tailKey) + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +abbrev fW : Addr := s₀.gpr .rdi +abbrev fIv : Addr := s₀.gpr .rsi +abbrev fD : Addr := s₀.gpr .rdx +abbrev fL : Nat := (s₀.gpr .rcx).toNat +abbrev fSp : Addr := s₀.gpr .rsp +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .r8 +/-- The number of whole blocks, and of the bytes after them. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +/-- The data after the whole blocks. -/ +abbrev fT : Addr := fD s₀ + BitVec.ofNat 64 (16 * fN s₀) +abbrev fData : Region := ⟨fD s₀, fL s₀⟩ +abbrev fBlk : Region := ⟨fD s₀, 16 * fN s₀⟩ +abbrev fTail : Region := ⟨fT s₀, fU s₀⟩ + +end + +theorem fN_eq (s₀ : State) : fN s₀ = fL s₀ / 16 := rfl +theorem fU_eq (s₀ : State) : fU s₀ = fL s₀ % 16 := rfl + +theorem n_lt (s₀ : State) : fN s₀ < 2 ^ 64 := by + have := (s₀.gpr .rcx).isLt; have : fL s₀ = (s₀.gpr .rcx).toNat := rfl; rw [fN_eq]; omega + +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) + +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) + +/-- The code's contract, with the arguments `(schedule = rdi, ctr = rsi, +data = rdx, len = rcx, save = r8)`, `save` of 64 bytes: the data and the +counter block as `Spec.Ctr.CryptFinal` says, by SM4 with the schedule at +`schedule`. -/ +def ctrFinalX86_64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .rdi, 128⟩ + let ctr : Region := ⟨s.gpr .rsi, 16⟩ + let data : Region := ⟨s.gpr .rdx, (s.gpr .rcx).toNat⟩ + let sv : Region := ⟨s.gpr .r8, 64⟩ + let ret : Region := ⟨s.gpr .rsp, 8⟩ + let stack := below (s.gpr .rsp) 3224 + 3224 ≤ (s.gpr .rsp).toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + ret.Disjoint sched ∧ ret.Disjoint ctr ∧ ret.Disjoint data ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .rdi).toNat + 128 ≤ 2 ^ 64 ∧ (s.gpr .rsi).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .rdx).toNat + (s.gpr .rcx).toNat ≤ 2 ^ 64 ∧ (s.gpr .r8).toNat + 64 ≤ 2 ^ 64 + post s s' := + Spec.Ctr.CryptFinal (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (s.gpr .rdi))) + s.mem s'.mem (s.gpr .rsi) (s.gpr .rdx) (s.gpr .rcx).toNat + pub s₁ s₂ := + s₁.gpr .rdi = s₂.gpr .rdi ∧ s₁.gpr .rsi = s₂.gpr .rsi ∧ s₁.gpr .rdx = s₂.gpr .rdx ∧ + s₁.gpr .rcx = s₂.gpr .rcx ∧ s₁.gpr .r8 = s₂.gpr .r8 ∧ s₁.gpr .rsp = s₂.gpr .rsp + +/-- The contract the frame needs: the shared one, with `save`, 64 bytes, as a +fifth argument, and 3224 bytes of stack (the return address of `vg_sm4_ctr`, +and its frame and calls). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract X86_64.abi Spec.Sm4.ctrFinalSig "save" .u64 8 (Curry.const (fun _ => True) _) + (Proof.Sm4.ctrFinalPost X86_64.abi.ptrBits) true 3224 + +/-- A state satisfying the precondition (no data). -/ +def ctrFinalSat : State where + gpr r := match r with + | .rdi => 0x1000 | .rsi => 0x2000 | .rdx => 0x3000 | .r8 => 0x4000 | .rsp => 0x8000 + | _ => 0 + cf := none + zf := none + sf := none + of := none + mem _ := 0 + rd := [⟨0x1000, 128⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 64⟩] + +theorem ctrFinal_implies : ctrFinalX86_64.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, ctrFinalX86_64, X86_64.abi, X86_64.argRegs] [ctrFinalSat] + using ctrFinalSat + +/-! ## The callee -/ + +theorem ctrFramed_spSafe : SpSafe ctrFramed := SpSafe.of_all (Code.all_of_allInstrs (by lit_decide)) + +theorem ctrFramed_depth : ctrFramed.x86_64Depth = 3216 := by lit_decide + +/-- The callee's contract at a call. -/ +abbrev calleeK : Contract isa := + Spec.Sm4.ctrSig.contract X86_64.abi (post := Proof.Sm4.ctrPost X86_64.abi.ptrBits) (writeArgs := true) (stack := 3216) + +/-- `vg_sm4_ctr` meets its contract. -/ +theorem ctrFramed_ok : Verified X86_64.target ctrFramed calleeK := ctr_framed + +theorem callee_args {s : State} {W C D : Addr} {n : Nat} (hrdi : s.gpr .rdi = W) (hrsi : s.gpr .rsi = C) + (hrdx : s.gpr .rdx = D) (hrcx : s.gpr .rcx = BitVec.ofNat 64 n) (rd wr : List Region) : + regArgs Spec.Sm4.ctrSig (s.callEntry.withRegions rd wr) = [W, C, D, BitVec.ofNat 64 n] := by + simp only [regArgs, State.withRegions_gpr, show (Spec.Sm4.ctrSig.words X86_64.abi.ptrBits).length = 4 from rfl, + X86_64.argRegs, List.take_succ_cons, List.take_zero, List.map_cons, List.map_nil, + State.callEntry_gpr s (by decide : Reg.rdi ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rsi ≠ .rsp), + State.callEntry_gpr s (by decide : Reg.rdx ≠ .rsp), State.callEntry_gpr s (by decide : Reg.rcx ≠ .rsp), + hrdi, hrsi, hrdx, hrcx] + +theorem callee_bufs (W C D : Addr) {n : Nat} (hn : n < 2 ^ 64) : + Sig.bufs Spec.Sm4.ctrSig.params [W, C, D, BitVec.ofNat 64 n] = + [(⟨W, 128⟩, false), (⟨C, 16⟩, true), (⟨D, 16 * n⟩, true)] := by + simp [Spec.Sm4.ctrSig, Sig.bufs, Elem.size, Nat.mod_eq_of_lt hn, Nat.mul_comm] + +theorem callee_pre {s : State} {W C D : Addr} {n : Nat} (hrdi : s.gpr .rdi = W) (hrsi : s.gpr .rsi = C) + (hrdx : s.gpr .rdx = D) (hrcx : s.gpr .rcx = BitVec.ofNat 64 n) (hn : n < 2 ^ 64) + (hsp : 3224 ≤ (s.gpr .rsp).toNat) + (dWC : (⟨W, 128⟩ : Region).Disjoint ⟨C, 16⟩) (dWD : (⟨W, 128⟩ : Region).Disjoint ⟨D, 16 * n⟩) + (dCD : (⟨C, 16⟩ : Region).Disjoint ⟨D, 16 * n⟩) + (hstk : ∀ r ∈ ([⟨W, 128⟩, ⟨C, 16⟩, ⟨D, 16 * n⟩] : List Region), (below (s.gpr .rsp) 3224).Disjoint r) + (fW : W.toNat + 128 ≤ 2 ^ 64) (fC : C.toNat + 16 ≤ 2 ^ 64) (fD : D.toNat + 16 * n ≤ 2 ^ 64) : + calleeK.pre (s.callEntry.withRegions [⟨W, 128⟩] [⟨C, 16⟩, ⟨D, 16 * n⟩]) := by + unfold calleeK + rw [pre_regs (by decide) (by decide), callee_args hrdi hrsi hrdx hrcx, callee_bufs W C D hn] + have hsp8 : (s.gpr .rsp - 8).toNat = (s.gpr .rsp).toNat - 8 := by + rw [BitVec.toNat_sub_of_le (by rw [BitVec.le_def]; simp; omega)]; rfl + have hret : Region.Sub ⟨s.gpr .rsp - 8, 8⟩ (below (s.gpr .rsp) 3224) := + Offset.sub_below _ (by decide) (by decide) + have hcal : Region.Sub (below (s.gpr .rsp - 8) 3216) (below (s.gpr .rsp) 3224) := below_callee _ 3216 + refine ⟨.inr (by rw [State.withRegions_gpr, State.callEntry_rsp, hsp8]; omega), rfl, rfl, ?_, ?_, ?_, ?_⟩ + · simp only [List.pairwise_cons, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, forall_eq, + List.Pairwise.nil, Bool.true_or, Bool.false_or, forall_const, and_true] + exact ⟨⟨dWC, dWD⟩, dCD, fun _ h => h.elim⟩ + · simp only [State.withRegions_gpr, State.callEntry_rsp] + intro r hr a ha + simp only [List.mem_cons, List.not_mem_nil, or_false] at ha + rw [stackBelow_pos _ (by decide)] at hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl <;> rcases ha with rfl | rfl | rfl + · exact (hstk _ (by simp)).sub_left hret + · exact (hstk _ (by simp)).sub_left hret + · exact (hstk _ (by simp)).sub_left hret + · exact (hstk _ (by simp)).sub_left hcal + · exact (hstk _ (by simp)).sub_left hcal + · exact (hstk _ (by simp)).sub_left hcal + · intro a ha + simp only [List.mem_cons, List.not_mem_nil, or_false] at ha + rcases ha with rfl | rfl | rfl <;> with_reducible assumption + · rw [Curry.apply_const]; trivial + +theorem callee_post {s s₂ : State} {W C D : Addr} {n : Nat} (hrdi : s.gpr .rdi = W) (hrsi : s.gpr .rsi = C) + (hrdx : s.gpr .rdx = D) (hrcx : s.gpr .rcx = BitVec.ofNat 64 n) (hn : n < 2 ^ 64) {rd wr : List Region} + (h : calleeK.post (s.callEntry.withRegions rd wr) s₂) : + Spec.Cbc.blocksAt s₂.mem D n = Spec.Ctr.crypt (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.callEntry.mem W)) + (bytesAt s.callEntry.mem C 16) (Spec.Cbc.blocksAt s.callEntry.mem D n) ∧ + bytesAt s₂.mem C 16 = Spec.Ctr.next (bytesAt s.callEntry.mem C 16) n := by + unfold calleeK at h + rw [post_regs (by decide), callee_args hrdi hrsi hrdx hrcx] at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int 64] + (Proof.Sm4.ctrPost 64) _ _ _ _ at h + dsimp only [Curry.apply, Proof.Sm4.ctrPost, ArgWord.ofRaw] at h + have eN : (BitVec.ofNat 64 n).toNat = n := by rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt hn] + simp only [BitVec.setWidth_eq, eN, State.withRegions_mem] at h + exact h + +theorem callee_pub {s₁ s₂ : State} {W C D : Addr} {n : Nat} (h₁ : s₁.gpr .rdi = W) (h₂ : s₁.gpr .rsi = C) + (h₃ : s₁.gpr .rdx = D) (h₄ : s₁.gpr .rcx = BitVec.ofNat 64 n) (g₁ : s₂.gpr .rdi = W) + (g₂ : s₂.gpr .rsi = C) (g₃ : s₂.gpr .rdx = D) (g₄ : s₂.gpr .rcx = BitVec.ofNat 64 n) + (hsp : s₁.gpr .rsp = s₂.gpr .rsp) (rd₁ wr₁ rd₂ wr₂ : List Region) : + calleeK.pub (s₁.callEntry.withRegions rd₁ wr₁) (s₂.callEntry.withRegions rd₂ wr₂) := by + unfold calleeK + rw [pub_regs (by decide) (by decide), callee_args h₁ h₂ h₃ h₄, callee_args g₁ g₂ g₃ g₄] + refine ⟨?_, fun _ _ => rfl⟩ + simp only [State.withRegions_gpr, State.callEntry_rsp, hsp] + +section +variable (s₀ : State) + +abbrev kSch : Region := ⟨fW s₀, 128⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 48 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below (fSp s₀) 3224 +/-- The registers' values once `save` is in `rax`, and the memory once they +are saved. -/ +abbrev kG : Reg → BitVec 64 := (s₀.setReg .rax (kV s₀)).gpr +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) (kG s₀) finalSaved +/-- The cipher, the counter block and the whole blocks on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Sm4.cipher (Spec.Sm4.scheduleAt s₀.mem (fW s₀)) +abbrev kT : List Byte := bytesAt s₀.mem (fIv s₀) 16 +abbrev kBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (fD s₀) (fN s₀) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp : 3224 ≤ (fSp s₀).toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + ret_sch : (⟨fSp s₀, 8⟩ : Region).Disjoint (kSch s₀) + ret_iv : (⟨fSp s₀, 8⟩ : Region).Disjoint (kIv s₀) + ret_data : (⟨fSp s₀, 8⟩ : Region).Disjoint (fData s₀) + ret_sv : (⟨fSp s₀, 8⟩ : Region).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 128 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 64 ≤ 2 ^ 64 + +theorem KPre.of {s₀ : State} (h : ctrFinalX86_64.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21⟩ + +/-! ## Regions and frames -/ + +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + Spill.saveMem_frame_base _ _ _ finalSaved (by decide) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.sch_big : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 48 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 48) (by decide), Nat.mod_eq_of_lt (by omega)] + + +end + +/-! ## Saving the registers -/ + +theorem load0_ok (s : State) : runBlock isa [.mov .rax (.reg .r8)] s = some (s.setReg .rax (s.gpr .r8)) := by + simp only [runBlock_cons, runStep_some, runBlock_nil, reduceExec, readSrc, Option.map_some] + +theorem load_ok (s : State) : runBlock isa ctrFinalLoad s = some (s.setReg .rax (s.gpr .r15)) := by + simp only [ctrFinalLoad, runBlock_cons, runStep_some, runBlock_nil, reduceExec, readSrc, Option.map_some] + +theorem moves_ok (s : State) : + ∃ s', runBlock isa ctrFinalMoves s = some s' ∧ + s'.gpr .rbx = s.gpr .rdi ∧ s'.gpr .r12 = s.gpr .rsi ∧ + s'.gpr .r15 = s.gpr .rax ∧ s'.gpr .r14 = s.gpr .rcx &&& 15#64 ∧ + s'.gpr .r13 = s.gpr .rcx - (s.gpr .rcx &&& 15#64) + s.gpr .rdx ∧ s'.gpr .rcx = s.gpr .rcx >>> 4 ∧ + s'.gpr .rdi = s.gpr .rdi ∧ s'.gpr .rsi = s.gpr .rsi ∧ s'.gpr .rdx = s.gpr .rdx ∧ + s'.gpr .rsp = s.gpr .rsp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [reduceCtorEq, ↓reduceIte, ctrFinalMoves, runBlock_cons, + runStep_some, runBlock_nil, reduceExec, execAlu, execShift, readSrc, Option.bind_some, Option.map_some, + gpr_setReg, gpr_arithFlags, Nat.reduceLeDiff, and_self, AesCfb.X86_64.signExtend_15] + rfl, ?_⟩ + simp only [gpr_setReg, gpr_arithFlags, gpr_setFlags, mem_setReg, mem_arithFlags, mem_setFlags, rd_setReg, + rd_arithFlags, rd_setFlags, wr_setReg, wr_arithFlags, wr_setFlags, reduceCtorEq, ↓reduceIte, and_self] + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + rbx : s.gpr .rbx = fW s₀ + r12 : s.gpr .r12 = fIv s₀ + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rdi : s.gpr .rdi = fW s₀ + rsi : s.gpr .rsi = fIv s₀ + rdx : s.gpr .rdx = fD s₀ + rcx : s.gpr .rcx = BitVec.ofNat 64 (fN s₀) + rsp : s.gpr .rsp = fSp s₀ + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : + WP isa (.block ctrFinalSetup) (s₀.setReg .rax (kV s₀)) (KSetup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions (s₀.setReg .rax (kV s₀)).wr + (Spill.slot ((s₀.setReg .rax (kV s₀)).gpr .rax) p.2) 8 := by + intro p hp' + rw [wr_setReg, gpr_setReg_self, hp.wr] + have := AesCfb.X86_64.saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .rax finalSaved ++ ctrFinalMoves)) _ _ + refine Spill.save_then .rax finalSaved hw ?_ + refine WP.mono (WP.of_runBlock (moves_ok _)) + fun s' ⟨rbx, r12, r15, r14, r13, rcx, rdi, rsi, rdx, rsp, mem, rd, wr⟩ => ?_ + simp only [gpr_setReg, reduceCtorEq, ↓reduceIte] at rbx r12 r15 r14 r13 rcx rdi rsi rdx rsp + exact ⟨rbx, r12, by rw [r13, AesCfb.X86_64.and15, AesCfb.X86_64.tail_addr], + by rw [r14, AesCfb.X86_64.and15], r15, rdi, rsi, rdx, by rw [rcx, AesCfb.X86_64.shr4], rsp, + by rw [mem, mem_setReg, gpr_setReg_self], by rw [rd, rd_setReg], by rw [wr, wr_setReg]⟩ + +/-! ## The whole blocks -/ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + rbx : s.gpr .rbx = fW s₀ + r12 : s.gpr .r12 = fIv s₀ + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (fN s₀) + +theorem whole_regions {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + calleeK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨callee_pre h.rdi h.rsi h.rdx h.rcx (n_lt s₀) + (by rw [h.rsp]; exact hp.sp) hp.sch_iv (hp.sch_data.sub_right (blk_sub s₀)) + (hp.iv_data.sub_right (blk_sub s₀)) (fun r hr => ?_) hp.sch_wrap hp.iv_wrap hp.blk_wrap, ?_, ?_⟩ + · rw [h.rsp] + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.stk_sch + · exact hp.stk_iv + · exact hp.stk_data.sub_right (blk_sub s₀) + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The save and a call's return address change only `save` and the stack. -/ +theorem entry_frame {s₀ s : State} (h : KSetup s₀ s) : Frame [kSv s₀, kStk s₀] s₀.mem s.callEntry.mem := by + have f₁ : Frame [kSv s₀, kStk s₀] s₀.mem s.mem := by + rw [h.mem]; exact (svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr] + have f₂ : Frame [kSv s₀, kStk s₀] s.mem s.callEntry.mem := + (AesCbc.X86_64.callEntry_frame s).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨kStk s₀, by simp, by rw [h.rsp]; exact Offset.sub_below _ (by decide) (by decide)⟩ + exact f₁.trans f₂ + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + WP isa (.call "vg_sm4_ctr" ctrFramed) s (KWhole s₀) := by + have ef := entry_frame h + have dS : ∀ r ∈ [kSv s₀, kStk s₀], (kSch s₀).Disjoint r := by + intro r hr; simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.sch_sv + · exact hp.stk_sch.symm + have eT : bytesAt s.callEntry.mem (fIv s₀) 16 = kT s₀ := AesCbc.X86_64.bytesAt_frame ef (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.iv_sv + · exact hp.stk_iv.symm) (by decide) + have eB : Spec.Cbc.blocksAt s.callEntry.mem (fD s₀) (fN s₀) = kBlks s₀ := + AesCfb.X86_64.blocksAt_frame' ef fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.data_sv.sub_left (blk_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀) + obtain ⟨hpre, hc, hw⟩ := whole_regions hp h + refine WP.callF (k := calleeK) ctrFramed_ok.1 ctrFramed_spSafe (by rw [ctrFramed_depth]; decide) hpre hc hw ?_ + intro s' rd' wr' cs' fr' ⟨s₂, mem₂, _, post₂⟩ _ + rw [ctrFramed_depth, h.rsp, h.mem] at fr' + obtain ⟨pb, pc⟩ := callee_post h.rdi h.rsi h.rdx h.rcx (n_lt s₀) post₂ + rw [mem₂, Proof.Sm4.scheduleAt_frame ef dS, eT, eB] at pb + rw [mem₂, eT] at pc + refine ⟨by rw [cs' .rbx (by simp [calleeSaved]), h.rbx], + by rw [cs' .r12 (by simp [calleeSaved]), h.r12], by rw [cs' .r13 (by simp [calleeSaved]), h.r13], + by rw [cs' .r14 (by simp [calleeSaved]), h.r14], by rw [cs' .r15 (by simp [calleeSaved]), h.r15], + by rw [cs' .rsp (by simp [calleeSaved]), h.rsp], by rw [rd', h.rd], by rw [wr', h.wr], + fr'.mono fun r hr => ?_, pb, pc⟩ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem test_wp {s₀ s : State} (h : KWhole s₀ s) : + WP isa (.block [.alu .test .r14 (.reg .r14)]) s fun s' => KWhole s₀ s' ∧ s'.zf = some (decide (fU s₀ = 0)) := + WP.of_runBlock ⟨_, AesCfb.X86_64.test_ok s, + ⟨h.rbx, h.r12, h.r13, h.r14, h.r15, h.rsp, h.rd, h.wr, h.frame, h.blocks, h.ctr⟩, by + have eU := fU_eq s₀ + rw [zf_arithFlags, BitVec.and_self, h.r14, + AesCfb.X86_64.beq_zero' (by have := Nat.mod_lt (fL s₀) (by decide : 16 > 0); omega)]⟩ + +/-! ## The partial last block -/ + +/-- `save` to `rax`, from a state `F` describes. -/ +abbrev Loaded (F : State → Prop) (s₀ s : State) : Prop := ∃ w, F w ∧ s = w.setReg .rax (kV s₀) + +theorem tailMoves_ok (s : State) : + ∃ s', runBlock isa ctrFinalTailMoves s = some s' ∧ + s'.gpr .rdi = s.gpr .rbx ∧ s'.gpr .rsi = s.gpr .r12 ∧ + s'.gpr .rdx = s.gpr .rax + BitVec.ofNat 64 48 ∧ s'.gpr .rcx = 1 ∧ + (∀ r ∈ calleeSaved, s'.gpr r = s.gpr r) ∧ s'.gpr .r13 = s.gpr .r13 ∧ s'.gpr .r14 = s.gpr .r14 ∧ + s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by + simp only [ctrFinalTailMoves, runBlock_cons, runStep_some, reduceExec, execAlu, readSrc, Option.bind_some, + Option.map_some] + rfl, ?_⟩ + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> + try simp [gpr_setReg, State.setReg32, mem_arithFlags, rd_arithFlags, wr_arithFlags, mem_setReg, rd_setReg, + wr_setReg] + intro r hr + simp only [calleeSaved, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame m _ g zeroSlots fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KTArgs (s₀ s : State) : Prop where + rdi : s.gpr .rdi = fW s₀ + rsi : s.gpr .rsi = fIv s₀ + rdx : s.gpr .rdx = kBk s₀ + rcx : s.gpr .rcx = BitVec.ofNat 64 1 + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem tail_load_wp {s₀ s : State} (h : KWhole s₀ s) : WP isa (.block ctrFinalLoad) s (Loaded (KWhole s₀) s₀) := + WP.of_runBlock ⟨_, load_ok s, s, h, by rw [h.r15]⟩ + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) (s.setReg .rax (kV s₀)) (KTArgs s₀) := by + obtain ⟨s₂, r₂, z₂, k₂, m₂, rd₂, wr₂⟩ := AesCtr.X86_64.zero_ok (s.setReg .rax (kV s₀)) + show WP isa (.block ([.mov32 .r10 (.imm 0)] ++ (Spill.saveCode .rax zeroSlots ++ ctrFinalTailMoves))) _ _ + refine WP.block_append_iff.mpr (WP.of_runBlock ⟨s₂, r₂, ?_⟩) + have k₂' : ∀ r, r ≠ .r10 → r ≠ .rax → s₂.gpr r = s.gpr r := fun r h₁ h₂ => by + rw [k₂ r h₁, gpr_setReg_of_ne _ _ h₂] + have hrax : s₂.gpr .rax = kV s₀ := by rw [k₂ _ (by decide), gpr_setReg_self] + have hw : ∀ p ∈ zeroSlots, InRegions s₂.wr (Spill.slot (s₂.gpr .rax) p.2) 8 := by + intro p hp' + rw [wr₂, wr_setReg, h.wr, hp.wr, hrax] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + refine Spill.save_then .rax zeroSlots hw ?_ + refine WP.mono (WP.of_runBlock (tailMoves_ok _)) + fun s' ⟨rdi, rsi, rdx, rcx, cs, r13, r14, mem, rd, wr⟩ => ?_ + have e : ∀ r, ({ s₂ with mem := Spill.saveMem s₂.mem (s₂.gpr .rax) s₂.gpr zeroSlots } : State).gpr r = + s₂.gpr r := fun _ => rfl + rw [e] at rdi rsi rdx r13 r14 + have hm : s'.mem = Spill.saveMem s.mem (kV s₀) s₂.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₂.mem _ _ _ = _; rw [m₂, mem_setReg, hrax] + have fz : Frame [kBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + refine ⟨by rw [rdi, k₂' _ (by decide) (by decide), h.rbx], by rw [rsi, k₂' _ (by decide) (by decide), h.r12], + by rw [rdx, hrax], rcx, + by rw [r13, k₂' _ (by decide) (by decide), h.r13], by rw [r14, k₂' _ (by decide) (by decide), h.r14], + by rw [cs .r15 (by simp [calleeSaved]), e, k₂' _ (by decide) (by decide), h.r15], + by rw [cs .rsp (by simp [calleeSaved]), e, k₂' _ (by decide) (by decide), h.rsp], + by rw [rd, rd₂, rd_setReg, h.rd], by rw [wr, wr₂, wr_setReg, h.wr], ?_, ?_, ?_, ?_⟩ + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [AesCfb.X86_64.blocksAt_frame' fz blkZ]; exact h.blocks + · rw [AesCbc.X86_64.bytesAt_frame fz ivZ (by decide)]; exact h.ctr + · rw [hm, show Spill.saveMem s.mem (kV s₀) s₂.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₂.gpr .r10)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₂.gpr .r10)) by + simp only [Spill.saveMem, zeroSlots, Spill.slot, Offset.add_add], z₂] + exact AesCtr.X86_64.zero_bytes _ _ + +theorem cipher_length (k : Spec.Sm4.Schedule) (b : List Byte) : (Spec.Sm4.cipher k b).length = 16 := by + simp [Spec.Sm4.cipher] + +/-- What the call on the block leaves. -/ +structure KTCall (s₀ s : State) : Prop where + r13 : s.gpr .r13 = fT s₀ + r14 : s.gpr .r14 = BitVec.ofNat 64 (fU s₀) + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (kT s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (kT s₀) (fN s₀)) + +theorem tail_regions {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s₀ s) : + calleeK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, ⟨kBk s₀, 16 * 1⟩]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, ⟨kBk s₀, 16 * 1⟩]) (s.rd ++ s.wr) ∧ + Covers [kIv s₀, ⟨kBk s₀, 16 * 1⟩] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨callee_pre h.rdi h.rsi h.rdx h.rcx (by decide) + (by rw [h.rsp]; exact hp.sp) hp.sch_iv (hp.sch_sv.sub_right bs) (hp.iv_sv.sub_right bs) (fun r hr => ?_) + hp.sch_wrap hp.iv_wrap (by rw [hp.bk_toNat]; have := hp.sv_wrap; omega), ?_, ?_⟩ + · rw [h.rsp] + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.stk_sch + · exact hp.stk_iv + · exact hp.stk_sv.sub_right bs + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 48, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 48, by simp, by simp⟩ + +theorem KTArgs.entry {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s₀ s) : + Spec.Sm4.scheduleAt s.callEntry.mem (fW s₀) = Spec.Sm4.scheduleAt s₀.mem (fW s₀) ∧ + bytesAt s.callEntry.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (fN s₀) ∧ + bytesAt s.callEntry.mem (kBk s₀) 16 = List.replicate 16 0 := by + have ef := AesCbc.X86_64.callEntry_frame s + have stk : Region.Sub (below (s.gpr .rsp) 8) (kStk s₀) := by + rw [h.rsp]; exact Offset.sub_below _ (by decide) (by decide) + have big := big_of (kW1_kW h.frame) + refine ⟨?_, ?_, ?_⟩ + · rw [Proof.Sm4.scheduleAt_frame ef fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.stk_sch.symm.sub_right stk] + exact Proof.Sm4.scheduleAt_frame big hp.sch_big + · rw [AesCbc.X86_64.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.stk_iv.symm.sub_right stk) (by decide)] + exact h.ctr + · rw [AesCbc.X86_64.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.stk_sv.symm.sub_left (blk_sv_sub s₀)).sub_right stk) (by decide)] + exact h.zero + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s₀ s) : + WP isa (.call "vg_sm4_ctr" ctrFramed) s (KTCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_regions hp h + obtain ⟨eK, eT, eZ⟩ := h.entry hp + refine WP.callF (k := calleeK) ctrFramed_ok.1 ctrFramed_spSafe (by rw [ctrFramed_depth]; decide) hpre hc hw ?_ + intro s' rd' wr' cs' fr' ⟨s₂, mem₂, _, post₂⟩ _ + rw [ctrFramed_depth, h.rsp] at fr' + obtain ⟨pb, pc⟩ := callee_post h.rdi h.rsi h.rdx h.rcx (by decide) post₂ + rw [mem₂, eK, eT] at pb + rw [mem₂, eT] at pc + have fc : Frame (kW1 s₀) s.mem s'.mem := fr'.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kBlk s₀, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs' .r13 (by simp [calleeSaved]), h.r13], by rw [cs' .r14 (by simp [calleeSaved]), h.r14], + by rw [cs' .r15 (by simp [calleeSaved]), h.r15], by rw [cs' .rsp (by simp [calleeSaved]), h.rsp], + by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, pc, ?_⟩ + · rw [AesCfb.X86_64.blocksAt_frame' fr' fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) eZ pb + +theorem key_load_wp {s₀ s : State} (h : KTCall s₀ s) : WP isa (.block ctrFinalLoad) s (Loaded (KTCall s₀) s₀) := + WP.of_runBlock ⟨_, load_ok s, s, h, by rw [h.r15]⟩ + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + r15 : s.gpr .r15 = kV s₀ + rsp : s.gpr .rsp = fSp s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (kT s₀) (kBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (kT s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (kT s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.r15, h.rsp, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu]; exact h.ctr⟩ + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KTCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) + (s.setReg .rax (kV s₀)) (KDone s₀) := by + obtain ⟨s₁, r₁, rax₁, k₁, m₁, rd₁, wr₁⟩ := AesCtr.X86_64.key_ok (s.setReg .rax (kV s₀)) + rw [gpr_setReg_self] at rax₁ + have k₁' : ∀ r, r ≠ .rax → s₁.gpr r = s.gpr r := fun r hr => by rw [k₁ r hr, gpr_setReg_of_ne _ _ hr] + rw [mem_setReg] at m₁ + rw [rd_setReg] at rd₁ + rw [wr_setReg] at wr₁ + refine WP.seq (WP.of_runBlock ⟨s₁, r₁, ?_⟩) + have hU : fU s₀ < 16 := Nat.mod_lt _ (by decide) + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have hT : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + have hB := hp.bk_toNat + have xp : Modes.X86_64.XPre s₁ (kBk s₀) (fT s₀) (fU s₀) .r13 .r14 := { + pos := by omega + small := by omega + fitK := by omega + fitR := by rw [hT]; omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [rd₁, wr₁, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [wr₁, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) + dl := by decide + dRax := by decide + dR10 := by decide + dRcx := by decide } + have x0 : Modes.X86_64.XInv s₁ (kBk s₀) (fT s₀) (fU s₀) .r13 .r14 0 s₁ := { + rax := by rw [rax₁]; exact (BitVec.add_zero _).symm + dat := by rw [k₁' _ (by decide), h.r13]; exact (BitVec.add_zero _).symm + left := by rw [k₁' _ (by decide), h.r14, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Modes.X86_64.xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + refine ⟨by rw [d.gpr .r15 (by decide) (by decide) (by decide) (by decide) (by decide), k₁' _ (by decide), h.r15], + by rw [d.gpr .rsp (by decide) (by decide) (by decide) (by decide) (by decide), k₁' _ (by decide), h.rsp], + by rw [d.rd, rd₁, h.rd], by rw [d.wr, wr₁, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · refine kW1_kW h.frame |>.trans ?_ + rw [← m₁] + exact d.frame.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩ + · rw [AesCfb.X86_64.blocksAt_frame' d.frame fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, m₁] + exact h.blocks + · rw [d.data q hq, m₁, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← AesCfb.X86_64.bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, AesCbc.X86_64.bytesAt_frame d.frame ivT (by decide), m₁, h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) (hz : s.zf = some (decide (fU s₀ = 0))) : + WP isa (.ite .e (.block []) ctrFinalTail) s (KDone s₀) := by + have ev : isa.eval .e s = some (decide (fU s₀ = 0)) := hz + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + refine WP.seq (WP.mono (tail_load_wp h) fun _ ⟨w, hw, e⟩ => ?_) + subst e + exact WP.seq (WP.mono (tail_args_wp hp hw) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => + WP.seq (WP.mono (key_load_wp h₂) fun _ ⟨w', hw', e'⟩ => by subst e'; exact tail_xor_wp hp hw' hu))) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.seq (.block ctrFinalLoad) (.block finalRestore)) s fun s' => gprPreserved s₀ s' ∧ s'.mem = s.mem := by + have big := big_of h.frame + refine WP.seq (WP.of_runBlock ⟨_, load_ok s, ?_⟩) + rw [h.r15] + have hs : Spill.Saved (s.setReg .rax (kV s₀)).mem ((s.setReg .rax (kV s₀)).gpr .rax) (kG s₀) finalSaved := by + rw [mem_setReg, gpr_setReg_self] + refine (Spill.saveMem_saved _ _ _ _ (by decide)).frame h.frame fun p hp' r hr => ?_ + have := AesCfb.X86_64.saved_slots p hp' + have hsub : Region.Sub ⟨Spill.slot (kV s₀) p.2, 8⟩ (kSv s₀) := Offset.sub_base _ (by omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .rax finalSaved)) _ _ + refine WP.mono (Spill.restore_ok .rax finalSaved (kG s₀) _ (by decide) (fun p hp' => ?_) hs) + fun s' ⟨g₁, g₂, mem', _, _⟩ => ?_ + · rw [rd_setReg, wr_setReg, gpr_setReg_self, h.rd, h.wr, hp.rd, hp.wr] + have := AesCfb.X86_64.saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + · have cs := Spill.calleeSaved_ok g₁ g₂ (by decide) + (show _ = (s₀.setReg .rax (kV s₀)).gpr .rsp by + rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), h.rsp]) + refine ⟨⟨fun r hr => by rw [cs r hr]; exact gpr_setReg_of_ne _ _ (AesCfb.X86_64.calleeSaved_ne_rax' hr), ?_⟩, + by rw [mem', mem_setReg]⟩ + rw [mem', mem_setReg] + refine big.readW (r := ⟨fSp s₀, 8⟩) (Region.contains_self _ _) (fun r hr => ?_) (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.ret_iv + · exact hp.ret_data + · exact hp.ret_sv + · exact Offset.base_disjoint_below _ (by decide) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => gprPreserved s₀ s' ∧ ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.of_runBlock ⟨_, load0_ok s₀, ?_⟩) + refine WP.seq (WP.mono (setup_wp hp) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₂) fun s₃ h₃ => ?_) + refine WP.seq (WP.mono (test_wp h₃) fun s₄ ⟨h₄, z₄⟩ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₄ z₄) fun s₅ h₅ => ?_) + exact WP.mono (end_wp hp h₅) fun _ ⟨g, m⟩ => ⟨g, s₅, h₅, m⟩ + +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86_64.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem ctrFinal_mx : ctrFinal.allInstrs (fun i => !loadsMxcsr i) = true := by lit_decide + +theorem final_correct (s : State) (hs : ctrFinalX86_64.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalX86_64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, abiPreserved_of_exec ctrFinal_mx he hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem load0_taint : ∃ h, (taint.check (Taint.ofRegs [.r8]) (.block [.mov .rax (.reg .r8)]) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.rdi, .rsi, .rdx, .rcx, .rsp, .rax]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (Taint.ofRegs [.r14]) (.block [.alu .test .r14 (.reg .r14)]) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem load_taint : ∃ h, (taint.check (Taint.ofRegs [.r15]) (.block ctrFinalLoad) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.rax, .rbx, .r12, .rsp]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.rax, .r13, .r14]) + (.seq (.block tailKey) (.loop (.block (Impl.Modes.X86_64.xorByte .r13 .r14)) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.rax]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalX86_64.pre s₀) (h0' : ctrFinalX86_64.pre s₀') + (hq : ctrFinalX86_64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, qD, qN] + have r₁ := AesCtr.X86_64.taint_rel (P := fun a b => a = s₀ ∧ b = s₀') (F₁ := (· = s₀.setReg .rax (kV s₀))) + (F₂ := (· = s₀'.setReg .rax (kV s₀'))) [.r8] load0_taint + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h; simp only [List.mem_singleton] at hr; subst hr; exact qV) + fun a b h => by + obtain ⟨rfl, rfl⟩ := h; exact ⟨WP.of_runBlock ⟨_, load0_ok _, rfl⟩, WP.of_runBlock ⟨_, load0_ok _, rfl⟩⟩ + have r₂ := AesCtr.X86_64.taint_rel + (P := fun a b => a = s₀.setReg .rax (kV s₀) ∧ b = s₀'.setReg .rax (kV s₀')) + (F₁ := KSetup s₀) (F₂ := KSetup s₀') [.rdi, .rsi, .rdx, .rcx, .rsp, .rax] setup_taint + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> + simp only [gpr_setReg, reduceCtorEq, ↓reduceIte, qW, qIv, qD, qL, qSp, kV, qV]) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩ + have r₃ := (RelCT.callEx (k := calleeK) (n := "vg_sm4_ctr") ctrFramed_ok.1 ctrFramed_ok.2.1 + (P := fun a b => KSetup s₀ a ∧ KSetup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_regions hp ha + obtain ⟨pb, cb, wb⟩ := whole_regions hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ + exact callee_pub ha.rdi ha.rsi ha.rdx ha.rcx + (hb.rdi.trans (by rw [fW, fW, qW])) (hb.rsi.trans (by rw [fIv, fIv, qIv])) + (hb.rdx.trans (by rw [fD, fD, qD])) (hb.rcx.trans (by rw [qN])) + (by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]) _ _ _ _).wp + (F₁ := KWhole s₀) (F₂ := KWhole s₀') fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + have r₄ := AesCtr.X86_64.taint_rel (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) + (F₁ := fun (s : State) => KWhole s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => KWhole s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) [.r14] test_taint + (fun a b h r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r14, h.2.r14, qU]) + fun a b h => ⟨test_wp h.1, test_wp h.2⟩ + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) ctrFinalTail + fun a b => KDone s₀ a ∧ KDone s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := AesCtr.X86_64.taint_rel (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) + (F₁ := Loaded (KWhole s₀) s₀) (F₂ := Loaded (KWhole s₀') s₀') [.r15] load_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r15, h.2.r15, kV, kV, qV]) + fun a b h => ⟨tail_load_wp h.1, tail_load_wp h.2⟩ + have a₂ := AesCtr.X86_64.taint_rel (P := fun a b => Loaded (KWhole s₀) s₀ a ∧ Loaded (KWhole s₀') s₀' b) + (F₁ := KTArgs s₀) (F₂ := KTArgs s₀') [.rax, .rbx, .r12, .rsp] tailArgs_taint + (fun a b h r hr => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · rw [gpr_setReg_self, gpr_setReg_self, kV, kV, qV] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rbx, hw'.rbx, fW, fW, qW] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r12, hw'.r12, fIv, fIv, qIv] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.rsp, hw'.rsp, fSp, fSp, + qSp]) + fun a b h => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + exact ⟨tail_args_wp hp hw, tail_args_wp hp' hw'⟩ + have a₃ := (RelCT.callEx (k := calleeK) (n := "vg_sm4_ctr") ctrFramed_ok.1 ctrFramed_ok.2.1 + (P := fun a b => KTArgs s₀ a ∧ KTArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_regions hp ha + obtain ⟨pb, cb, wb⟩ := tail_regions hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb, by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]⟩ + exact callee_pub ha.rdi ha.rsi ha.rdx ha.rcx + (hb.rdi.trans (by rw [fW, fW, qW])) (hb.rsi.trans (by rw [fIv, fIv, qIv])) + (hb.rdx.trans (by rw [kBk, kBk, kV, kV, qV])) hb.rcx + (by rw [ha.rsp, hb.rsp, fSp, fSp, qSp]) _ _ _ _).wp + (F₁ := KTCall s₀) (F₂ := KTCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + have a₄ := AesCtr.X86_64.taint_rel (P := fun a b => KTCall s₀ a ∧ KTCall s₀' b) + (F₁ := Loaded (KTCall s₀) s₀) (F₂ := Loaded (KTCall s₀') s₀') [.r15] load_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r15, h.2.r15, kV, kV, qV]) + fun a b h => ⟨key_load_wp h.1, key_load_wp h.2⟩ + have a₅ := AesCtr.X86_64.taint_rel (P := fun a b => Loaded (KTCall s₀) s₀ a ∧ Loaded (KTCall s₀') s₀' b) + (F₁ := KDone s₀) (F₂ := KDone s₀') [.rax, .r13, .r14] xor_taint + (fun a b h r hr => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [gpr_setReg_self, gpr_setReg_self, kV, kV, qV] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r13, hw'.r13, qT] + · rw [gpr_setReg_of_ne _ _ (by decide), gpr_setReg_of_ne _ _ (by decide), hw.r14, hw'.r14, qU]) + fun a b h => by + obtain ⟨⟨w, hw, rfl⟩, ⟨w', hw', rfl⟩⟩ := h + exact ⟨tail_xor_wp hp hw hu, tail_xor_wp hp' hw' hu'⟩ + exact a₁.seq (a₂.seq ((a₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₄.seq a₅))) + have r₅ : RelCT isa (fun a b => (KWhole s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (KWhole s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) (.ite .e (.block []) ctrFinalTail) + (fun a b => KDone s₀ a ∧ KDone s₀' b) := by + refine RelCT.ite (fun a b h => ?_) ?_ ?_ + · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + exact ⟨done_of_zero h.1.1.1 h0, done_of_zero h.1.2.1 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + have r₆ := AesCtr.X86_64.taint_rel (P := fun a b => KDone s₀ a ∧ KDone s₀' b) + (F₁ := fun (s : State) => s.gpr .rax = kV s₀) (F₂ := fun (s : State) => s.gpr .rax = kV s₀') [.r15] + load_taint + (fun a b h r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.r15, h.2.r15, kV, kV, qV]) + fun a b h => ⟨WP.of_runBlock ⟨_, load_ok _, by rw [gpr_setReg_self, h.1.r15]⟩, + WP.of_runBlock ⟨_, load_ok _, by rw [gpr_setReg_self, h.2.r15]⟩⟩ + obtain ⟨_, t₇⟩ := restore_taint + have r₇ := RelCT.taint (A := taint) (P := fun a b => a.gpr .rax = kV s₀ ∧ b.gpr .rax = kV s₀') _ + (fun a b h => Taint.agree_ofRegs fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1, h.2, kV, kV, qV]) t₇ + exact r₁.seq (r₂.seq ((r₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₄.seq (r₅.seq (r₆.seq r₇))))) + +theorem final_ct : ConstantTime isa ctrFinalX86_64.pre ctrFinalX86_64.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_spSafe : ctrFinal.all (fun i => !X86_64.isa.writesSp i) = true := Code.all_of_allInstrs (by lit_decide) + +theorem ctrFinal_xdepth : ctrFinal.x86_64Depth ≤ 3224 := by lit_decide + +theorem ctrFinal_verified : Verified X86_64.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +`vg_sm4_ctr_final` has four argument words, so `save` is passed in `r8`: it +runs its code in a frame of 72 bytes (`withStackScratchWiped`), the quadword +standing for the return address and `save`'s 64 bytes (the registers, then +the block that held the last output block), which it zeroes before +returning. The code's calls use 3224 bytes below it, so 3296 in all. -/ + +theorem ctrFinal_framed : + Verified X86_64.target (Impl.StackScratch.X86_64.withStackScratchWiped 72 .r8 8 ctrFinal) + (Spec.Sm4.ctrFinalContract X86_64.abi 3296) := + X86_64.Verified.stackScratchWiped (sig := Spec.Sm4.ctrFinalSig) (nm := "save") (e := .u64) + (n := 8) (post := Proof.Sm4.ctrFinalPost X86_64.abi.ptrBits) (wa := true) (stack := 3224) + (bytes := 72) ctrFinal_verified (by decide) (by decide) (by decide) ctrFinal_spSafe ctrFinal_xdepth + (by decide) (Proof.Sm4.ctrFinalPostOut_local _) + (X86_64.sat_regs (by decide) (by decide) (by lit_decide) (by rw [Curry.apply_const]; trivial)) + +end VG.Proof.Sm4.X86_64 From 33eb97a6db32cd34ebc691500fee1d6625da7304 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 11:52:14 +0000 Subject: [PATCH 09/18] AES-OFB and CTR: a partial last block by the final functions (WIP: needs the regenerated crates) Whole blocks stay with the whole-block functions; only the bytes after them go to vg_aes_ofb_final, vg_aes_ctr_final, vg_camellia_ctr_final or vg_sm4_ctr_final (AES's of the variant chosen, whose features select now also requires). The Rust code that ran OFB or CTR on the padded last bytes is deleted. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- src/cipher/aes/ctr.rs | 87 +++++++++++++++++++++++++++----------- src/cipher/aes/ofb.rs | 84 ++++++++++++++++++++++++++---------- src/cipher/camellia/ctr.rs | 44 +++++++++++-------- src/cipher/sm4/ctr.rs | 36 ++++++++-------- 4 files changed, 169 insertions(+), 82 deletions(-) diff --git a/src/cipher/aes/ctr.rs b/src/cipher/aes/ctr.rs index 1d074aa31a1..b601cc8c3ea 100644 --- a/src/cipher/aes/ctr.rs +++ b/src/cipher/aes/ctr.rs @@ -16,13 +16,21 @@ use crate::arch::aes::vg_aes_expand_key; use crate::arch::aes::vg_aes_expand_key_aes; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use crate::arch::aes::vg_aes_expand_key_aesni; -use crate::arch::aes_ctr::vg_aes_ctr; #[cfg(target_arch = "aarch64")] -use crate::arch::aes_ctr::{VG_AES_CTR_AES_FEATURES, vg_aes_ctr_aes}; +use crate::arch::aes_ctr::{ + VG_AES_CTR_AES_FEATURES, VG_AES_CTR_FINAL_AES_FEATURES, vg_aes_ctr_aes, vg_aes_ctr_final_aes, +}; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -use crate::arch::aes_ctr::{VG_AES_CTR_AESNI_FEATURES, vg_aes_ctr_aesni}; +use crate::arch::aes_ctr::{ + VG_AES_CTR_AESNI_FEATURES, VG_AES_CTR_FINAL_AESNI_FEATURES, vg_aes_ctr_aesni, + vg_aes_ctr_final_aesni, +}; #[cfg(target_arch = "x86_64")] -use crate::arch::aes_ctr::{VG_AES_CTR_VAES_FEATURES, vg_aes_ctr_vaes}; +use crate::arch::aes_ctr::{ + VG_AES_CTR_FINAL_VAES_FEATURES, VG_AES_CTR_VAES_FEATURES, vg_aes_ctr_final_vaes, + vg_aes_ctr_vaes, +}; +use crate::arch::aes_ctr::{vg_aes_ctr, vg_aes_ctr_final}; use crate::cipher::aes::Backend; use crate::cpu::detected; use crate::error::{IncompleteBlock, InvalidKeyLength}; @@ -51,21 +59,28 @@ macro_rules! instance { /// its CTR function. #[cfg(target_arch = "x86_64")] fn select(f: Features) -> Backend { - Backend::select_for(f, VG_AES_CTR_VAES_FEATURES, VG_AES_CTR_AESNI_FEATURES) + const AESNI: Features = + Features::all(&[VG_AES_CTR_AESNI_FEATURES, VG_AES_CTR_FINAL_AESNI_FEATURES]); + const VAES: Features = + Features::all(&[VG_AES_CTR_VAES_FEATURES, VG_AES_CTR_FINAL_VAES_FEATURES]); + Backend::select_for(f, VAES, AESNI) } /// The best implementation of AES a CPU with the features `f` can run, with /// its CTR function. #[cfg(target_arch = "x86")] fn select(f: Features) -> Backend { - Backend::select_for(f, VG_AES_CTR_AESNI_FEATURES) + const AESNI: Features = + Features::all(&[VG_AES_CTR_AESNI_FEATURES, VG_AES_CTR_FINAL_AESNI_FEATURES]); + Backend::select_for(f, AESNI) } /// The best implementation of AES a CPU with the features `f` can run, with /// its CTR function. #[cfg(target_arch = "aarch64")] fn select(f: Features) -> Backend { - Backend::select_for(f, VG_AES_CTR_AES_FEATURES) + const AES: Features = Features::all(&[VG_AES_CTR_AES_FEATURES, VG_AES_CTR_FINAL_AES_FEATURES]); + Backend::select_for(f, AES) } /// The only implementation of AES on ARMv7, PPC64LE and RISC-V. @@ -135,7 +150,7 @@ impl AesCtr { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.5, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.counter, buffer); + self.key.apply_keystream_final(&mut self.counter, buffer); } } @@ -165,25 +180,49 @@ impl Key { }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// counter block `ctr`, which it replaces with the counter block after - /// the last one used: `ctr` plus the number of blocks (counting a partial - /// last one), modulo `2¹²⁸` (unchanged for empty input). A message may - /// be processed in pieces of whole blocks, each continuing from the `ctr` - /// the last left; a piece whose length is not a multiple of 16 bytes - /// must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the counter block `ctr`, which it replaces + /// with the counter block after the last one used: `ctr` plus the number + /// of blocks, modulo `2¹²⁸` (unchanged for empty input). fn apply_keystream(&self, ctr: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(ctr, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the counter + /// block the whole blocks leave in `ctr`, which it replaces with the + /// next one. + fn apply_keystream_final(&self, ctr: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(ctr, blocks); if !rest.is_empty() { - // The last bytes, padded to a block: CTR XORs them with the first - // bytes of the next output block. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(ctr, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + let f = instance!( + self.backend, + vg_aes_ctr_final, + vg_aes_ctr_final_aesni, + vg_aes_ctr_final_vaes, + vg_aes_ctr_final_aes + ); + let mut scratch = [0; 272]; + // SAFETY: `rounds` is 10, 12 or 14 and the schedule holds its key + // schedule; `rest` is valid for `len` bytes, and it, the block at + // `ctr`, the schedule and the scratch space are separate valid + // objects of the sizes of the signature. `select` chose `f` for + // the CPU's features. + unsafe { + f( + &self.schedule, + self.rounds, + ctr, + rest.as_mut_ptr(), + rest.len(), + &mut scratch, + ); + } + // The scratch space may hold the key schedule, the data and our + // caller's registers. + zeroize(&mut scratch); } } diff --git a/src/cipher/aes/ofb.rs b/src/cipher/aes/ofb.rs index 3c1387ceab8..b815aa93f72 100644 --- a/src/cipher/aes/ofb.rs +++ b/src/cipher/aes/ofb.rs @@ -14,13 +14,21 @@ use crate::arch::aes::vg_aes_expand_key; use crate::arch::aes::vg_aes_expand_key_aes; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use crate::arch::aes::vg_aes_expand_key_aesni; -use crate::arch::aes_ofb::vg_aes_ofb; #[cfg(target_arch = "aarch64")] -use crate::arch::aes_ofb::{VG_AES_OFB_AES_FEATURES, vg_aes_ofb_aes}; +use crate::arch::aes_ofb::{ + VG_AES_OFB_AES_FEATURES, VG_AES_OFB_FINAL_AES_FEATURES, vg_aes_ofb_aes, vg_aes_ofb_final_aes, +}; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -use crate::arch::aes_ofb::{VG_AES_OFB_AESNI_FEATURES, vg_aes_ofb_aesni}; +use crate::arch::aes_ofb::{ + VG_AES_OFB_AESNI_FEATURES, VG_AES_OFB_FINAL_AESNI_FEATURES, vg_aes_ofb_aesni, + vg_aes_ofb_final_aesni, +}; #[cfg(target_arch = "x86_64")] -use crate::arch::aes_ofb::{VG_AES_OFB_VAES_FEATURES, vg_aes_ofb_vaes}; +use crate::arch::aes_ofb::{ + VG_AES_OFB_FINAL_VAES_FEATURES, VG_AES_OFB_VAES_FEATURES, vg_aes_ofb_final_vaes, + vg_aes_ofb_vaes, +}; +use crate::arch::aes_ofb::{vg_aes_ofb, vg_aes_ofb_final}; use crate::cipher::aes::Backend; use crate::cpu::detected; use crate::error::{IncompleteBlock, InvalidKeyLength}; @@ -49,21 +57,28 @@ macro_rules! instance { /// its OFB function. #[cfg(target_arch = "x86_64")] fn select(f: Features) -> Backend { - Backend::select_for(f, VG_AES_OFB_VAES_FEATURES, VG_AES_OFB_AESNI_FEATURES) + const AESNI: Features = + Features::all(&[VG_AES_OFB_AESNI_FEATURES, VG_AES_OFB_FINAL_AESNI_FEATURES]); + const VAES: Features = + Features::all(&[VG_AES_OFB_VAES_FEATURES, VG_AES_OFB_FINAL_VAES_FEATURES]); + Backend::select_for(f, VAES, AESNI) } /// The best implementation of AES a CPU with the features `f` can run, with /// its OFB function. #[cfg(target_arch = "x86")] fn select(f: Features) -> Backend { - Backend::select_for(f, VG_AES_OFB_AESNI_FEATURES) + const AESNI: Features = + Features::all(&[VG_AES_OFB_AESNI_FEATURES, VG_AES_OFB_FINAL_AESNI_FEATURES]); + Backend::select_for(f, AESNI) } /// The best implementation of AES a CPU with the features `f` can run, with /// its OFB function. #[cfg(target_arch = "aarch64")] fn select(f: Features) -> Backend { - Backend::select_for(f, VG_AES_OFB_AES_FEATURES) + const AES: Features = Features::all(&[VG_AES_OFB_AES_FEATURES, VG_AES_OFB_FINAL_AES_FEATURES]); + Backend::select_for(f, AES) } /// The only implementation of AES on ARMv7, PPC64LE and RISC-V. @@ -127,7 +142,7 @@ impl AesOfb { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.4, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.iv, buffer); + self.key.apply_keystream_final(&mut self.iv, buffer); } } @@ -164,23 +179,48 @@ impl Key { }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// block `iv`, which it replaces with the last output block used - /// (unchanged for empty input). A message may be processed in pieces of - /// whole blocks, each continuing from the `iv` the last left; a piece - /// whose length is not a multiple of 16 bytes must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the block `iv`, which it replaces with the + /// last output block (unchanged for empty input). fn apply_keystream(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(iv, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the block + /// the whole blocks leave in `iv`, which it replaces with the output + /// block it used. + fn apply_keystream_final(&self, iv: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(iv, blocks); if !rest.is_empty() { - // The next output block, as OFB of a zero block, XORed into the - // last bytes. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(iv, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + let f = instance!( + self.backend, + vg_aes_ofb_final, + vg_aes_ofb_final_aesni, + vg_aes_ofb_final_vaes, + vg_aes_ofb_final_aes + ); + let mut scratch = [0; 272]; + // SAFETY: `rounds` is 10, 12 or 14 and the schedule holds its key + // schedule; `rest` is valid for `len` bytes, and it, the block at + // `iv`, the schedule and the scratch space are separate valid + // objects of the sizes of the signature. `select` chose `f` for + // the CPU's features. + unsafe { + f( + &self.schedule, + self.rounds, + iv, + rest.as_mut_ptr(), + rest.len(), + &mut scratch, + ); + } + // The scratch space may hold the key schedule, the data and our + // caller's registers. + zeroize(&mut scratch); } } diff --git a/src/cipher/camellia/ctr.rs b/src/cipher/camellia/ctr.rs index 8573626266c..c00c340b94b 100644 --- a/src/cipher/camellia/ctr.rs +++ b/src/cipher/camellia/ctr.rs @@ -13,7 +13,7 @@ ))] use crate::arch::camellia::vg_camellia_expand_key; -use crate::arch::camellia_ctr::vg_camellia_ctr; +use crate::arch::camellia_ctr::{vg_camellia_ctr, vg_camellia_ctr_final}; use crate::error::{IncompleteBlock, InvalidKeyLength}; use crate::zeroize::zeroize; @@ -70,7 +70,7 @@ impl CamelliaCtr { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.5, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.counter, buffer); + self.key.apply_keystream_final(&mut self.counter, buffer); } } @@ -91,25 +91,33 @@ impl Key { Ok(Self { schedule, rounds }) } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// counter block `ctr`, which it replaces with the counter block after - /// the last one used: `ctr` plus the number of blocks (counting a partial - /// last one), modulo `2¹²⁸` (unchanged for empty input). A message may - /// be processed in pieces of whole blocks, each continuing from the `ctr` - /// the last left; a piece whose length is not a multiple of 16 bytes - /// must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the counter block `ctr`, which it replaces + /// with the counter block after the last one used: `ctr` plus the number + /// of blocks, modulo `2¹²⁸` (unchanged for empty input). fn apply_keystream(&self, ctr: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(ctr, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the counter + /// block the whole blocks leave in `ctr`, which it replaces with the + /// next one. + fn apply_keystream_final(&self, ctr: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(ctr, blocks); if !rest.is_empty() { - // The last bytes, padded to a block: CTR XORs them with the first - // bytes of the next output block. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(ctr, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: as for `crypt`, with `rest` valid for `len` bytes. + unsafe { + vg_camellia_ctr_final( + &self.schedule, + self.rounds, + ctr, + rest.as_mut_ptr(), + rest.len(), + ) + }; } } diff --git a/src/cipher/sm4/ctr.rs b/src/cipher/sm4/ctr.rs index aa3438f7df5..3581d9e2814 100644 --- a/src/cipher/sm4/ctr.rs +++ b/src/cipher/sm4/ctr.rs @@ -13,7 +13,7 @@ ))] use crate::arch::sm4::vg_sm4_expand_key; -use crate::arch::sm4_ctr::vg_sm4_ctr; +use crate::arch::sm4_ctr::{vg_sm4_ctr, vg_sm4_ctr_final}; use crate::error::IncompleteBlock; use crate::zeroize::zeroize; @@ -67,7 +67,7 @@ impl Sm4Ctr { /// place, of any length: its whole blocks, then a partial last block if /// there is one (§6.5, `Cₙ* = Pₙ* ⊕ MSB_u(Oₙ)`). pub fn apply_keystream_final(mut self, buffer: &mut [u8]) { - self.key.apply_keystream(&mut self.counter, buffer); + self.key.apply_keystream_final(&mut self.counter, buffer); } } @@ -83,25 +83,25 @@ impl Key { Self { schedule } } - /// Encrypts or decrypts (the same operation) `buffer` in place, from the - /// counter block `ctr`, which it replaces with the counter block after - /// the last one used: `ctr` plus the number of blocks (counting a partial - /// last one), modulo `2¹²⁸` (unchanged for empty input). A message may - /// be processed in pieces of whole blocks, each continuing from the `ctr` - /// the last left; a piece whose length is not a multiple of 16 bytes - /// must end the message. + /// Encrypts or decrypts (the same operation) the whole blocks of + /// `buffer` in place, from the counter block `ctr`, which it replaces + /// with the counter block after the last one used: `ctr` plus the number + /// of blocks, modulo `2¹²⁸` (unchanged for empty input). fn apply_keystream(&self, ctr: &mut [u8; 16], buffer: &mut [u8]) { - let whole = buffer.len() / 16 * 16; - let (blocks, rest) = buffer.split_at_mut(whole); + self.crypt(ctr, buffer); + } + + /// Encrypts or decrypts (the same operation) the rest of a message, of + /// any length, in place: its whole blocks with `crypt`, then the bytes + /// after them, fewer than 16, with the final function, from the counter + /// block the whole blocks leave in `ctr`, which it replaces with the + /// next one. + fn apply_keystream_final(&self, ctr: &mut [u8; 16], buffer: &mut [u8]) { + let (blocks, rest) = buffer.split_at_mut(buffer.len() / 16 * 16); self.crypt(ctr, blocks); if !rest.is_empty() { - // The last bytes, padded to a block: CTR XORs them with the first - // bytes of the next output block. - let mut last = [0; 16]; - last[..rest.len()].copy_from_slice(rest); - self.crypt(ctr, &mut last); - rest.copy_from_slice(&last[..rest.len()]); - zeroize(&mut last); + // SAFETY: as for `crypt`, with `rest` valid for `len` bytes. + unsafe { vg_sm4_ctr_final(&self.schedule, ctr, rest.as_mut_ptr(), rest.len()) }; } } From a438e7470ce5fbfd10994c03e4a087dafc7a3af3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 12:12:35 +0000 Subject: [PATCH 10/18] AES-OFB and AES-CTR final functions on x86 (WIP: crates to come) For every x86 block-function variant, as on x86-64. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Generic/AesBlocks/X86/AesCtr.lean | 8 + .../Generic/AesBlocks/X86/AesOfb.lean | 8 + .../Impl/AesCtr/X86/Final.lean | 84 ++ .../Impl/AesOfb/X86/Final.lean | 41 + .../Proof/AesCfb/X86/Final.lean | 58 +- .../Proof/AesCtr/X86/Final.lean | 1290 +++++++++++++++++ .../Proof/AesOfb/X86/Final.lean | 170 +++ 7 files changed, 1630 insertions(+), 29 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/AesCtr/X86/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/AesOfb/X86/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/X86/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/X86/Final.lean diff --git a/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesCtr.lean b/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesCtr.lean index 20dfecf2696..82b9d6b4229 100644 --- a/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesCtr.lean +++ b/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesCtr.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesCtr.X86.Verified +public import VerifiedGarbage.Proof.AesCtr.X86.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print @@ -19,6 +20,13 @@ def artifacts (v : Proof.Aes.X86.BlocksImpl) : List Artifact := [ stack := 24 verified := Proof.AesCtr.keyed (crypt_verified v) spSafe := crypt_spSafe v + features := v.features }, + Spec.Ctr.aesFinalApi.artifact X86.target { + suffix := v.suffix + code := Impl.StackScratch.X86.withStackScratchWiped 64 6 8 (Impl.AesCtr.X86.cryptFinal v.enc v.suffix) + stack := 116 + verified := Proof.AesCtr.final_keyed (cryptFinal_framed v) + spSafe := cryptFinal_framed_spSafe v features := v.features }] end VG.Generic.AesBlocks.X86.AesCtr diff --git a/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesOfb.lean b/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesOfb.lean index 8315fe1ec76..9a6a8b819fe 100644 --- a/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesOfb.lean +++ b/lean/VerifiedGarbage/Generic/AesBlocks/X86/AesOfb.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesOfb.X86.Verified +public import VerifiedGarbage.Proof.AesOfb.X86.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print @@ -19,6 +20,13 @@ def artifacts (v : Proof.Aes.X86.BlocksImpl) : List Artifact := [ stack := 24 verified := Proof.AesOfb.keyed (crypt_verified v) spSafe := crypt_spSafe v + features := v.features }, + Spec.Ofb.aesFinalApi.artifact X86.target { + suffix := v.suffix + code := Impl.StackScratch.X86.withStackScratchWiped 48 6 4 (Impl.AesOfb.X86.cryptFinal v.enc v.suffix) + stack := 100 + verified := Proof.AesOfb.final_keyed (cryptFinal_framed v) + spSafe := cryptFinal_framed_spSafe v features := v.features }] end VG.Generic.AesBlocks.X86.AesOfb diff --git a/lean/VerifiedGarbage/Impl/AesCtr/X86/Final.lean b/lean/VerifiedGarbage/Impl/AesCtr/X86/Final.lean new file mode 100644 index 00000000000..8b63175145b --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesCtr/X86/Final.lean @@ -0,0 +1,84 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.X86 +public import VerifiedGarbage.Impl.AesCfb.X86.Final + +/-! +# AES-CTR of a message's last piece: x86 (32-bit) implementation + +`cryptFinal b sfx` (cdecl: schedule, rounds, ctr, data, len, scratch, save, +every argument on the stack): the code of `vg_aes_ctr_final`, whose +registration frames it with a buffer of its own on the stack, `save`, the +seventh argument, of 32 bytes: the caller's callee-saved registers, then a +block of the code's own. It is generic over the implementation of the block +functions that the whole-block function calls (`b`, whose callers' names end +in `sfx`, e.g. `_aesni`): + +1. our caller's `ebx`, `esi`, `edi` and `ebp` saved in `save`, as AES-CFB's + final functions do (`Impl/AesCfb/X86/Final.lean`); +2. a call of the whole-block function of the same implementation + (`vg_aes_ctr` and its variants, `Impl/AesCtr/X86.lean`) on the + `len / 16` whole blocks, its six arguments pushed in a frame of their + own, which leaves `Tₙ₊₁` in `ctr`; +3. if `u = len mod 16 ≠ 0`, the block after the registers in `save` zeroed, + a call of the same function on that one block, which leaves + `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and the first `u` bytes of the + block XORed into the `u` bytes left, a byte at a time (the modes' + `tailByte`: from `ebx`, into `esi`, `ebp` of them); +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. +Every argument is reloaded from the stack where it is needed. Only the +pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesCtr.X86 + +open VG.X86 +open VG.Impl.Aes.X86 (Blocks) +open VG.Impl.CmacAes.X86 (argOp at_) +open VG.Impl.AesCfb.X86 (finalSave wholeArgs wholeCall tailTest finalRestore) +open VG.Impl.Modes.X86 (tailByte) + +/-- The four words of the block after the registers in `save`, each zeroed +from `ecx`. -/ +def zeroSlots : List (Reg × Nat) := [(.ecx, 16), (.ecx, 20), (.ecx, 24), (.ecx, 28)] + +/-- `save` (our stack argument 6) to `eax`, and the block after the +registers zeroed. -/ +def zeroBlock : List Instr := [.mov .eax (argOp 6), .mov .ecx (.imm 0)] ++ zeroSlots.map fun p => .store (at_ .eax p.2) p.1 + +/-- The whole-block function's arguments on that block: the schedule, the +rounds, the counter block, the block, `n = 1`, and the working space. -/ +def tailMoves : List Instr := + [.mov .ebx (.reg .eax), .alu .add .ebx (.imm 16), .mov .eax (argOp 0), .mov .ecx (argOp 1), + .mov .edx (argOp 2), .mov .esi (.imm 1), .mov .edi (argOp 5)] + +/-- The block zeroed, and the arguments of the whole-block function on it. -/ +def tailArgs : List Instr := zeroBlock ++ tailMoves + +/-- The tail loop's operands: `ebx` the block, `ebp` the `u` bytes left, and +`esi` the data after the whole blocks, `data + (len - u)`. -/ +def xorArgs : List Instr := + [.mov .ebx (argOp 6), .alu .add .ebx (.imm 16), .mov .esi (argOp 3), .mov .ebp (argOp 4), + .mov .eax (.reg .ebp), .alu .and .ebp (.imm 15), .alu .sub .eax (.reg .ebp), .alu .add .esi (.reg .eax)] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, by a call of the whole-block function `name`, `whole`, on it, and its +first `u` bytes XORed into the data. -/ +def finalTail (name : String) (whole : Prog isa) : Prog isa := + .seq (.block tailArgs) (.seq (wholeCall name whole) (.seq (.block xorArgs) (.loop (.block tailByte) .ne))) + +/-- The whole function, around calls of the whole-block function `name`, +`whole`. -/ +def final (name : String) (whole : Prog isa) : Prog isa := + .seq (.block (finalSave ++ wholeArgs)) (.seq (wholeCall name whole) + (.seq (.block tailTest) (.seq (.ite .e (.block []) (finalTail name whole)) (.block finalRestore)))) + +/-- `vg_aes_ctr_final`, calling `vg_aes_ctr` with the block function `b`, +whose callers' names end in `sfx`. -/ +def cryptFinal (b : Blocks) (sfx : String) : Prog isa := final ("vg_aes_ctr" ++ sfx) (crypt b) + +end VG.Impl.AesCtr.X86 diff --git a/lean/VerifiedGarbage/Impl/AesOfb/X86/Final.lean b/lean/VerifiedGarbage/Impl/AesOfb/X86/Final.lean new file mode 100644 index 00000000000..c4d77a33226 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesOfb/X86/Final.lean @@ -0,0 +1,41 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.X86 +public import VerifiedGarbage.Impl.AesCfb.X86.Final + +/-! +# AES-OFB of a message's last piece: x86 (32-bit) implementation + +`cryptFinal b sfx` (cdecl: schedule, rounds, iv, data, len, scratch, save, +every argument on the stack): the code of `vg_aes_ofb_final`, whose +registration frames it with a buffer of its own on the stack, `save`, the +seventh argument, where the code keeps its caller's callee-saved registers. +It is AES-CFB's final function (`Impl.AesCfb.X86.final`) around a call of +the whole-block AES-OFB function of the same implementation of the block +functions (`b`, whose callers' names end in `sfx`, e.g. `_aesni`): + +1. our caller's `ebx`, `esi`, `edi` and `ebp` saved in `save`; +2. a call of `vg_aes_ofb` (and its variants, `Impl/AesOfb/X86.lean`) on the + `len / 16` whole blocks, which leaves the last output block `Oₙ` in `iv`; +3. if `u = len mod 16 ≠ 0`, a call of the block function on the block at + `iv` in place, which leaves `Oₙ₊₁ = CIPH_K(Oₙ)` there, the last output + block used, and its first `u` bytes XORed into the `u` bytes left, a + byte at a time; +4. the registers restored. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesOfb.X86 + +open VG.X86 +open VG.Impl.Aes.X86 (Blocks) + +/-- `vg_aes_ofb_final`, calling `vg_aes_ofb` with the block function `b`, +whose callers' names end in `sfx`. -/ +def cryptFinal (b : Blocks) (sfx : String) : Prog isa := + Impl.AesCfb.X86.final ("vg_aes_ofb" ++ sfx) (crypt b) b + +end VG.Impl.AesOfb.X86 diff --git a/lean/VerifiedGarbage/Proof/AesCfb/X86/Final.lean b/lean/VerifiedGarbage/Proof/AesCfb/X86/Final.lean index b7b3f1c5804..73819de6973 100644 --- a/lean/VerifiedGarbage/Proof/AesCfb/X86/Final.lean +++ b/lean/VerifiedGarbage/Proof/AesCfb/X86/Final.lean @@ -1038,10 +1038,10 @@ theorem Ciph.pt {M : Mode} {s₀ s : State} (hp : FPre s₀) (h : Ciph M s₀ s) theorem Done.pt {M : Mode} {s₀ s : State} (hp : FPre s₀) (h : Done M s₀ s) : Pt s₀ s := ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of h.frame) hi⟩ -theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeX86 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeX86 (cfbMode enc)).pre (modeX86 (cfbMode enc)).pub whole) +theorem final_rel {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 M).post s s') + (hct : ConstantTime isa (modeX86 M).pre (modeX86 M).pub whole) (hsp : NoSp whole) (hst : stackUse whole = 24) (v : BlocksImpl) {s₀ s₀' : State} (h0 : (finalX86 enc).pre s₀) (h0' : (finalX86 enc).pre s₀') (hq : (finalX86 enc).pub s₀ s₀') : RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole v.enc) fun _ _ => True := by @@ -1071,9 +1071,9 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} -- The whole blocks. have eRd : wholeRd s₀' = wholeRd s₀ := by simp only [wholeRd, fSch, fW, fE, qW, qE] have eWr : wholeWr s₀' = wholeWr s₀ := by simp only [wholeWr, fIvR, fBlk, fScr, fIv, fD, fS, qIv, qD, qS, qN] - have c₂ := RelCT.callWith (k := modeX86 (cfbMode enc)) (n := name) (rs := wholeRegs) hv hct + have c₂ := RelCT.callWith (k := modeX86 M) (n := name) (rs := wholeRegs) hv hct (P := fun a b => Setup s₀ a ∧ Setup s₀' b) (wholeRd s₀) (wholeWr s₀) fun a b ⟨ha, hb⟩ => by - have pb := hb.callPre (M := cfbMode enc) hp' + have pb := hb.callPre (M := M) hp' rw [eRd, eWr] at pb obtain ⟨a0, a1, a2, a3, a4, a5⟩ := ha.args hp obtain ⟨b0, b1, b2, b3, b4, b5⟩ := hb.args hp' @@ -1088,18 +1088,18 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} · rw [a4, b4, qN] · rw [a5, b5, qS] have r₂ : RelCT isa (fun a b => Setup s₀ a ∧ Setup s₀' b) (wholeCall name whole) - (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) := - (RelCT.wp (c := wholeCall name whole) (F₁ := Whole (cfbMode enc) s₀) (F₂ := Whole (cfbMode enc) s₀') c₂ + (fun a b => Whole M s₀ a ∧ Whole M s₀' b) := + (RelCT.wp (c := wholeCall name whole) (F₁ := Whole M s₀) (F₂ := Whole M s₀') c₂ fun a b h => ⟨whole_wp hv hsp hst hp h.1, whole_wp hv hsp hst hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 -- The test. obtain ⟨_, t₃⟩ : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block tailTest) h).isSome = true := ⟨_, by taint_decide⟩ have r₃ := ((RelCT.taint (A := taint) - (P := fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) _ + (P := fun a b => Whole M s₀ a ∧ Whole M s₀' b) _ (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₃).wp - (F₁ := fun (s : State) => Whole (cfbMode enc) s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) - (F₂ := fun (s : State) => Whole (cfbMode enc) s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) + (F₁ := fun (s : State) => Whole M s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => Whole M s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) fun a b h => ⟨final_test_wp hp h.1, final_test_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 -- The partial last segment. obtain ⟨_, t₄⟩ : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block Impl.AesOfb.X86.ivArgs) h).isSome = @@ -1107,36 +1107,36 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} obtain ⟨_, t₅⟩ : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.seq (.block xorArgs) (.loop (.block Impl.Modes.X86.tailByte) .ne)) h).isSome = true := ⟨_, by taint_decide⟩ - have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) - (finalTail v.enc) fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b := by + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) + (finalTail v.enc) fun a b => Done M s₀ a ∧ Done M s₀' b := by have hu' : fU s₀' ≠ 0 := qU ▸ hu have a₄ := ((RelCT.taint (A := taint) - (P := fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) _ + (P := fun a b => Whole M s₀ a ∧ Whole M s₀' b) _ (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₄).wp - (F₁ := fun (s : State) => Whole (cfbMode enc) s₀ s ∧ BlkPre s (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) - (F₂ := fun (s : State) => Whole (cfbMode enc) s₀' s ∧ BlkPre s (fW s₀') (fIv s₀') (fS s₀') (fR s₀')) + (F₁ := fun (s : State) => Whole M s₀ s ∧ BlkPre s (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) + (F₂ := fun (s : State) => Whole M s₀' s ∧ BlkPre s (fW s₀') (fIv s₀') (fS s₀') (fR s₀')) fun a b h => ⟨final_ivArgs_wp hp h.1, final_ivArgs_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 have a₅ := ((blk_rel (b := v.enc) v.encOk v.encCt (E := fE s₀) - (P := fun a b => (Whole (cfbMode enc) s₀ a ∧ BlkPre a (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) ∧ - (Whole (cfbMode enc) s₀' b ∧ BlkPre b (fW s₀') (fIv s₀') (fS s₀') (fR s₀'))) + (P := fun a b => (Whole M s₀ a ∧ BlkPre a (fW s₀) (fIv s₀) (fS s₀) (fR s₀)) ∧ + (Whole M s₀' b ∧ BlkPre b (fW s₀') (fIv s₀') (fS s₀') (fR s₀'))) fun a b h => by have e₂ := h.2.2 rw [← qW, ← qIv, ← qS, ← qR] at e₂ exact ⟨h.1.2, e₂, h.1.1.esp, by rw [h.2.1.esp, qE]⟩).wp - (F₁ := Ciph (cfbMode enc) s₀) (F₂ := Ciph (cfbMode enc) s₀') + (F₁ := Ciph M s₀) (F₂ := Ciph M s₀') fun a b h => ⟨final_ciph_wp v hp h.1, final_ciph_wp v hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 have a₆ := ((RelCT.taint (A := taint) - (P := fun a b => Ciph (cfbMode enc) s₀ a ∧ Ciph (cfbMode enc) s₀' b) _ + (P := fun a b => Ciph M s₀ a ∧ Ciph M s₀' b) _ (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₅).wp - (F₁ := Done (cfbMode enc) s₀) (F₂ := Done (cfbMode enc) s₀') + (F₁ := Done M s₀) (F₂ := Done M s₀') fun a b h => ⟨WP.seq (WP.mono (final_xorArgs_wp hp h.1) fun _ h₃ => final_xor_wp hp h₃ hu), WP.seq (WP.mono (final_xorArgs_wp hp' h.2) fun _ h₃ => final_xor_wp hp' h₃ hu')⟩).mono (fun _ _ h => h) fun _ _ h => h.2 exact a₄.seq (a₅.seq a₆) - have r₄ : RelCT isa (fun a b => (Whole (cfbMode enc) s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ - (Whole (cfbMode enc) s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) + have r₄ : RelCT isa (fun a b => (Whole M s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (Whole M s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) (.ite .e (.block []) (finalTail v.enc)) - (fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) := by + (fun a b => Done M s₀ a ∧ Done M s₀' b) := by refine RelCT.ite (fun a b h => ?_) ?_ ?_ · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] · refine RelCT.block_nil fun a b h => ?_ @@ -1149,14 +1149,14 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} -- The registers restored. obtain ⟨_, t₆⟩ : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block finalRestore) h).isSome = true := ⟨_, by taint_decide⟩ - have r₅ := RelCT.taint (A := taint) (P := fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) _ + have r₅ := RelCT.taint (A := taint) (P := fun a b => Done M s₀ a ∧ Done M s₀' b) _ (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₆ exact r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅))) -theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeX86 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeX86 (cfbMode enc)).pre (modeX86 (cfbMode enc)).pub whole) +theorem final_ct {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 M).post s s') + (hct : ConstantTime isa (modeX86 M).pre (modeX86 M).pub whole) (hsp : NoSp whole) (hst : stackUse whole = 24) (v : BlocksImpl) : ConstantTime isa (finalX86 enc).pre (finalX86 enc).pub (final name whole v.enc) := fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct hsp hst v h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 diff --git a/lean/VerifiedGarbage/Proof/AesCtr/X86/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/X86/Final.lean new file mode 100644 index 00000000000..5e41fe080af --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/X86/Final.lean @@ -0,0 +1,1290 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.X86.Final +public import VerifiedGarbage.Proof.AesCtr.Final +public import VerifiedGarbage.Proof.AesCtr.X86.Verified +public import VerifiedGarbage.Proof.AesCtr.Spec +public import VerifiedGarbage.Proof.AesCfb.X86.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.X86.Spill +public import VerifiedGarbage.Proof.Framework.X86.CallWith +public import VerifiedGarbage.Proof.AesCbc.X86.Call +public import VerifiedGarbage.Impl.StackScratch.X86 +public import VerifiedGarbage.Proof.Framework.X86.ArgTaint +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.Framework.Mem +import VerifiedGarbage.Proof.Framework.X86.RegUpd +import VerifiedGarbage.Proof.CmacAes.X86.UpdateLoop +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.MdStream.X86.Common +import VerifiedGarbage.Proof.Modes.X86.SeqFinal +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCtr.X86.Body +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.X86.CT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.AesCbc.X86.Verified +import VerifiedGarbage.Proof.Framework.X86.RelCT +meta import VerifiedGarbage.Impl.AesCtr.X86.Final +meta import VerifiedGarbage.Proof.AesCtr.Final +meta import VerifiedGarbage.Proof.AesCtr.X86.Verified +meta import VerifiedGarbage.Proof.AesCtr.Spec +meta import VerifiedGarbage.Proof.AesCfb.X86.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.X86.Spill +meta import VerifiedGarbage.Proof.Framework.X86.CallWith +meta import VerifiedGarbage.Proof.AesCbc.X86.Call +meta import VerifiedGarbage.Impl.StackScratch.X86 +meta import VerifiedGarbage.Proof.Framework.X86.ArgTaint +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.Framework.Mem +meta import VerifiedGarbage.Proof.Framework.X86.RegUpd +meta import VerifiedGarbage.Proof.CmacAes.X86.UpdateLoop +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.MdStream.X86.Common +meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCtr.X86.Body +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCbc.X86.CT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.AesCbc.X86.Verified +meta import VerifiedGarbage.Proof.Framework.X86.RelCT + +/-! +# AES-CTR of a message's last piece on x86 (32-bit) + +`cryptFinal_framed`: `vg_aes_ctr_final` (`Impl/AesCtr/X86/Final.lean`), for any +implementation `v` of the block functions (`BlocksImpl`), meets +`Proof.AesCtr.finalRoundsContract`, from which the shared contract follows +(`Proof.AesCtr.final_keyed`). + +The code is proven against `ctrFinalX86`, with a seventh stack argument +`save` of 32 bytes, for its caller's registers and a block of its own +(`final_implies`: the shared contract with it, `finalScratchContract`), as a +caller of the whole-block function, through its contract +(`modeX86 ctrMode`, `WP.callWith`). It shares AES-CFB's final functions' +setup and call of the whole-block function (`Proof/AesCfb/X86/Final.lean`: +`Setup`, `Whole`): + +* `final_setup_wp`, `whole_wp`: the registers saved, and the whole-block + function on the `n = len / 16` whole blocks (`Whole`); +* `final_mid_wp`: if `u = len % 16` bytes are left, the block after the + registers in `save` zeroed and the whole-block function on it + (`tail_args_wp`, `tail_call_wp`), which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed into them + (`Modes.X86.tailLoop_wp`, `final_xor_wp`); what is left before the + registers are restored is `Done`; +* `final_end_wp`: the registers restored from `save`; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Every argument is reloaded from the stack, which nothing writes (`Pt`). +Constant time (`final_rel`): the blocks by the taint analysis from the +stack arguments (`argTaint`), the calls by the whole-block function's +constant time (`RelCT.callWith`), whose public arguments, the pointers, +`rounds` and the number of blocks, agree in both runs. `cryptFinal_framed` +runs the code with `save` in a frame of 64 bytes +(`Verified.stackScratchWiped`), zeroed on return, the block included; with +the 52 bytes its calls use below it, 116 in all. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr.X86 + +open VG VG.X86 +open VG.Spec.Aes (bytesAt) + +/-- The code's contract, with the arguments on the stack `(schedule, rounds, +ctr, data, len, scratch, save)`, `save` of 32 bytes: the data and the +counter block as `Spec.Ctr.CryptFinal` says, by AES with the key schedule it +is given. -/ +def ctrFinalX86 : Contract isa where + pre s := + let sched : Region := ⟨(arg s 0).setWidth 64, 240⟩ + let iv : Region := ⟨(arg s 2).setWidth 64, 16⟩ + let data : Region := ⟨(arg s 3).setWidth 64, (arg s 4).toNat⟩ + let scr : Region := ⟨(arg s 5).setWidth 64, 2176⟩ + let sv : Region := ⟨(arg s 6).setWidth 64, 32⟩ + let args : Region := ⟨argAddr s 0, 28⟩ + let ret : Region := ⟨(s.gpr .esp).setWidth 64, 4⟩ + let stack : Region := ⟨(s.gpr .esp).setWidth 64 - BitVec.ofNat 64 52, 52⟩ + s.rd = [sched, args] ∧ s.wr = [iv, data, scr, sv] ∧ + sched.Disjoint iv ∧ sched.Disjoint data ∧ sched.Disjoint scr ∧ sched.Disjoint sv ∧ + iv.Disjoint data ∧ iv.Disjoint scr ∧ iv.Disjoint sv ∧ iv.Disjoint args ∧ + data.Disjoint scr ∧ data.Disjoint sv ∧ data.Disjoint args ∧ + scr.Disjoint sv ∧ scr.Disjoint args ∧ sv.Disjoint args ∧ + ret.Disjoint iv ∧ ret.Disjoint data ∧ ret.Disjoint scr ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint iv ∧ stack.Disjoint data ∧ stack.Disjoint scr ∧ + stack.Disjoint sv ∧ + (arg s 0).toNat + 240 ≤ 2 ^ 32 ∧ (arg s 2).toNat + 16 ≤ 2 ^ 32 ∧ + (arg s 3).toNat + (arg s 4).toNat ≤ 2 ^ 32 ∧ (arg s 5).toNat + 2176 ≤ 2 ^ 32 ∧ + (arg s 6).toNat + 32 ≤ 2 ^ 32 ∧ + 52 ≤ (s.gpr .esp).toNat ∧ (s.gpr .esp).toNat + 32 ≤ 2 ^ 32 ∧ + ((arg s 1).toNat = 10 ∨ (arg s 1).toNat = 12 ∨ (arg s 1).toNat = 14) + post s s' := + Spec.Ctr.CryptFinal (ciphAt s.mem ((arg s 0).setWidth 64) (arg s 1).toNat) s.mem s'.mem + ((arg s 2).setWidth 64) ((arg s 3).setWidth 64) (arg s 4).toNat + pub s₁ s₂ := s₁.gpr .esp = s₂.gpr .esp ∧ ∀ i < 7, arg s₁ i = arg s₂ i + +/-- The contract the frame needs: the shared one, with `save`, 32 bytes, as +a seventh argument, and 52 bytes of stack (the whole-block function's +arguments, its return address and its own 24 bytes). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract X86.abi Spec.Ctr.aesFinalSig "save" .u64 4 (finalPre X86.abi.ptrBits) + (finalPost X86.abi.ptrBits) false 52 (some (finalLeak X86.abi.ptrBits)) + +/-- A state satisfying the precondition: AES-CFB's (`AesCfb.X86.finalSat`), +with `save` of 32 bytes. -/ +def finalSat : State := { AesCfb.X86.finalSat with + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩, ⟨0x5000, 32⟩] } + +theorem final_implies : ctrFinalX86.Implies finalScratchContract := by + have a0 : arg finalSat 0 = 0x1000 := by decide + have a1 : arg finalSat 1 = 10 := by decide + have a2 : arg finalSat 2 = 0x2000 := by decide + have a3 : arg finalSat 3 = 0x3000 := by decide + have a4 : arg finalSat 4 = 0 := by decide + have a5 : arg finalSat 5 = 0x4000 := by decide + have a6 : arg finalSat 6 = 0x5000 := by decide + have e : argAddr finalSat 0 = 0x8004 := by decide + have esp : finalSat.gpr .esp = 0x8000 := rfl + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, X86.abi, X86.argSlots, X86.argVal, + X86.argBytes, ctrFinalX86] [a0, a1, a2, a3, a4, a5, a6, e, esp] using finalSat + +/-! ## The arguments, by name -/ + +open VG.Impl.AesCtr.X86 +open VG.Impl.AesCfb.X86 (finalSave wholeArgs wholeCall tailTest finalRestore finalSaved) +open VG.Impl.CmacAes.X86 (argOp) +open VG.Proof.CmacAes.X86 (wp_arg arg_ofNat ofNat_and_self_beq) +open VG.Proof.MdStream.X86 (Upd wp_mov wp_movi wp_andi wp_test wp_shr wp_sub wp_add wp_addi eval_e eval_ne) +open VG.Proof.AesCfb.X86 (fE fW fR fIv fD fL fS fV fN fU fT fSch fIvR fData fBlk fTail fScr fSv fArgs fRet + fStk fWk fIv0 fBlks svMem Setup Whole Pt) + +section +variable (s₀ : State) + +/-- `save`: the registers, then the block. -/ +abbrev cSv : Region := ⟨(fV s₀).setWidth 64, 32⟩ +/-- The block after the registers in `save`, as the code computes it and as +a region. -/ +abbrev cBk : BitVec 32 := fV s₀ + BitVec.ofNat 32 16 +abbrev cBlk : Region := ⟨(fV s₀).setWidth 64 + BitVec.ofNat 64 16, 16⟩ + +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] +/-- What the function writes after saving the registers, with the whole +blocks rather than the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, fScr s₀, cBlk s₀, fStk s₀] +/-- What the function writes after saving the registers. -/ +abbrev cW : List Region := [fIvR s₀, fData s₀, fScr s₀, cBlk s₀, fStk s₀] + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + rd : s₀.rd = [fSch s₀, fArgs s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_scr : (fSch s₀).Disjoint (fScr s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_scr : (fIvR s₀).Disjoint (fScr s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + iv_args : (fIvR s₀).Disjoint (fArgs s₀) + data_scr : (fData s₀).Disjoint (fScr s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_args : (fData s₀).Disjoint (fArgs s₀) + scr_sv : (fScr s₀).Disjoint (cSv s₀) + scr_args : (fScr s₀).Disjoint (fArgs s₀) + sv_args : (cSv s₀).Disjoint (fArgs s₀) + ret_iv : (fRet s₀).Disjoint (fIvR s₀) + ret_data : (fRet s₀).Disjoint (fData s₀) + ret_scr : (fRet s₀).Disjoint (fScr s₀) + ret_sv : (fRet s₀).Disjoint (cSv s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_iv : (fStk s₀).Disjoint (fIvR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_scr : (fStk s₀).Disjoint (fScr s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + sch_fit : (fW s₀).toNat + 240 ≤ 2 ^ 32 + iv_fit : (fIv s₀).toNat + 16 ≤ 2 ^ 32 + data_fit : (fD s₀).toNat + fL s₀ ≤ 2 ^ 32 + scr_fit : (fS s₀).toNat + 2176 ≤ 2 ^ 32 + sv_fit : (fV s₀).toNat + 32 ≤ 2 ^ 32 + esp52 : 52 ≤ (fE s₀).toNat + esp_fit : (fE s₀).toNat + 32 ≤ 2 ^ 32 + rounds : fR s₀ = 10 ∨ fR s₀ = 12 ∨ fR s₀ = 14 + +theorem CPre.of {s₀ : State} (h : ctrFinalX86.pre s₀) : CPre s₀ := by + obtain ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33⟩ := h + have e := AesCfb.X86.stk_eq a31 + exact ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, + e ▸ a21, e ▸ a22, e ▸ a23, e ▸ a24, e ▸ a25, a26, a27, a28, a29, a30, a31, a32, a33⟩ + +/-! ## Addresses and regions -/ + +theorem sv16_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) +theorem sv_blk (s₀ : State) : (fSv s₀).Disjoint (cBlk s₀) := Offset.base_disjoint _ (Nat.le_refl _) (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.cBk_addr : (cBk s₀).setWidth 64 = (cBlk s₀).base := addr_eq (by have := hp.sv_fit; omega) + +theorem CPre.cBk_toNat : (cBk s₀).toNat = (fV s₀).toNat + 16 := by + have := hp.sv_fit + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem CPre.argA {i : Nat} (hi : i < 7) : argAddr s₀ i = argAddr s₀ 0 + BitVec.ofNat 64 (4 * i) := by + have : (s₀.gpr .esp).toNat + 32 ≤ 2 ^ 32 := hp.esp_fit + simp only [argAddr] + rw [show (s₀.gpr .esp + BitVec.ofNat 32 (4 + 4 * i)).setWidth 64 = addr (s₀.gpr .esp) (4 + 4 * i) from rfl, + show (s₀.gpr .esp + BitVec.ofNat 32 (4 + 4 * 0)).setWidth 64 = addr (s₀.gpr .esp) (4 + 4 * 0) from rfl, + addr_eq (by omega), addr_eq (by omega), Offset.add_add] + +theorem CPre.arg_sub {i : Nat} (hi : i < 7) : Region.Sub ⟨argAddr s₀ i, 4⟩ (fArgs s₀) := by + rw [hp.argA hi]; exact Offset.sub_base _ (by omega) + +theorem CPre.arg_in {i : Nat} (hi : i < 7) : InRegions (s₀.rd ++ s₀.wr) (argAddr s₀ i) 4 := by + refine ⟨fArgs s₀, by simp [hp.rd], ?_⟩ + rw [hp.argA hi]; exact Offset.contains_base _ (by omega) (by omega) + +theorem CPre.args_stk : (fArgs s₀).Disjoint (fStk s₀) := by + have : (s₀.gpr .esp).toNat + 32 ≤ 2 ^ 32 := hp.esp_fit + have e : argAddr s₀ 0 = (fE s₀).setWidth 64 + BitVec.ofNat 64 4 := addr_eq (by omega) + rw [AesCfb.X86.stk_eq hp.esp52] + show Region.Disjoint ⟨argAddr s₀ 0, 28⟩ _ + rw [e]; exact (Offset.disjoint_below_above _ (by decide)).symm + +theorem CPre.ret_stk : (fRet s₀).Disjoint (fStk s₀) := by + rw [AesCfb.X86.stk_eq hp.esp52] + have := Offset.disjoint_below_above ((fE s₀).setWidth 64) (m := 52) (a := 0) (l := 4) (by decide) + rw [BitVec.add_zero] at this + exact this.symm + +/-- The stack arguments are unchanged where only `cBig` changes. -/ +theorem CPre.arg_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) {i : Nat} (hi : i < 7) : + m.readW (argAddr s₀ i) 32 = arg s₀ i := + hf.readW (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.iv_args.symm.sub_left (hp.arg_sub hi) + · exact hp.data_args.symm.sub_left (hp.arg_sub hi) + · exact hp.scr_args.symm.sub_left (hp.arg_sub hi) + · exact hp.sv_args.symm.sub_left (hp.arg_sub hi) + · exact hp.args_stk.sub_left (hp.arg_sub hi)) (by decide) + +/-- The return address is unchanged where only `cBig` changes. -/ +theorem CPre.ret_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + m.readW ((fE s₀).setWidth 64) 32 = s₀.mem.readW ((fE s₀).setWidth 64) 32 := + hf.readW (r := fRet s₀) (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.ret_iv + · exact hp.ret_data + · exact hp.ret_scr + · exact hp.ret_sv + · exact hp.ret_stk) (by decide) + +theorem CPre.sched_sub : Region.Sub ⟨(fW s₀).setWidth 64, 16 * (fR s₀ + 1)⟩ (fSch s₀) := + Region.sub_prefix (by rcases hp.rounds with h | h | h <;> omega) + +theorem CPre.sched_len : 16 * (fR s₀ + 1) ≤ 2 ^ 64 := by rcases hp.rounds with h | h | h <;> omega + +theorem CPre.sched_big : ∀ r ∈ cBig s₀, (⟨(fW s₀).setWidth 64, 16 * (fR s₀ + 1)⟩ : Region).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.sch_iv.sub_left hp.sched_sub + · exact hp.sch_data.sub_left hp.sched_sub + · exact hp.sch_scr.sub_left hp.sched_sub + · exact hp.sch_sv.sub_left hp.sched_sub + · exact hp.stk_sch.symm.sub_left hp.sched_sub + +/-- The key schedule is unchanged where only `cBig` changes. -/ +theorem CPre.sched_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + bytesAt m ((fW s₀).setWidth 64) (16 * (fR s₀ + 1)) = fWk s₀ := + Proof.Cmac.bytesAt_frame hf hp.sched_big hp.sched_len + +theorem CPre.blk_fit : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 32 := by + have := hp.data_fit; have := Nat.mul_div_le (fL s₀) 16; have : fN s₀ = fL s₀ / 16 := rfl; omega + +theorem CPre.stk_sub {a k : Nat} (h : a + k ≤ 52) : + Region.Sub (below (fE s₀ - BitVec.ofNat 32 k) a) (fStk s₀) := below_inner h hp.esp52 + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + exact Offset.base_disjoint _ (Nat.le_refl _) (by omega) + +end + +/-! ## Frames -/ + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, AesCfb.X86.blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem whole_cW1 {M : AesCbc.Mode} {s₀ s : State} (h : Whole M s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h | h <;> simp [h] + +/-- Everything the function writes, from the save on. -/ +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((AesCfb.X86.svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv16_sub s₀⟩).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +/-! ## Saving the registers, and the whole-block function's arguments -/ + +theorem final_setup_wp {s₀ : State} (hp : CPre s₀) : + WP isa (.block (finalSave ++ wholeArgs)) s₀ (Setup s₀) := by + rw [AesCfb.X86.setup_eq] + refine wp_arg (s₀ := s₀) rfl (hp.arg_in (by decide)) rfl fun s₁ u₁ => ?_ + have h₁ : s₁.gpr .eax = fV s₀ := u₁.gpr + refine Spill.save_ofNat_ok finalSaved AesCfb.X86.finalSaved_fits + (by rw [h₁]; have := hp.sv_fit; omega) (fun p hp' => ?_) fun s₂ u₂ => ?_ + · have hb : p.2 + 4 ≤ 16 := AesCfb.X86.finalSaved_fits.1 p hp' + rw [h₁, u₁.wr, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have hm₂ : s₂.mem = svMem s₀ := by + rw [u₂.mem, u₁.mem, h₁, svMem] + exact Spill.saveMem_congr _ _ (fun _ _ => rfl) fun p hp' => + u₁.other _ (AesCfb.X86.finalSaved_ne_eax p hp') + have esp₂ : s₂.gpr .esp = s₀.gpr .esp := by rw [u₂.gpr, u₁.other _ (by decide)] + have rw₂ : s₂.rd ++ s₂.wr = s₀.rd ++ s₀.wr := by rw [u₂.rd, u₂.wr, u₁.rd, u₁.wr] + have big := big_of (s₀ := s₀) (Frame.refl _ (svMem s₀)) + have ak : ∀ i < 7, (svMem s₀).readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [AesCfb.X86.wholeArgs_eq] + refine wp_arg (s₀ := s₀) esp₂ (by rw [rw₂]; exact hp.arg_in (by decide)) + (by rw [hm₂]; exact ak 0 (by decide)) fun s₃ u₃ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₃.other _ (by decide), esp₂]) + (by rw [u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₃.mem, hm₂]; exact ak 1 (by decide)) fun s₄ u₄ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₄.mem, u₃.mem, hm₂]; exact ak 2 (by decide)) fun s₅ u₅ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₅.rd, u₅.wr, u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₅.mem, u₄.mem, u₃.mem, hm₂]; exact ak 3 (by decide)) fun s₆ u₆ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₆.mem, u₅.mem, u₄.mem, u₃.mem, hm₂]; exact ak 4 (by decide)) fun s₇ u₇ => ?_ + refine wp_shr (by decide) fun s₈ u₈ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₈.rd, u₈.wr, u₇.rd, u₇.wr, u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂] + exact hp.arg_in (by decide)) + (by rw [u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, hm₂]; exact ak 5 (by decide)) fun s₉ u₉ => ?_ + refine WP.block_nil ⟨?_, ?_, ?_, ?_, ?_, u₉.gpr, ?_, ?_, ?_, ?_⟩ + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), u₃.gpr] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.gpr] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.gpr] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr] + · rw [u₉.other _ (by decide), u₈.gpr, u₇.gpr, AesCfb.X86.shr4] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), esp₂] + · rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, hm₂] + · rw [u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-! ## The calls of the whole-block function -/ + +open VG.Proof.AesCbc (Mode) +open VG.Proof.AesCbc.X86 (modeX86) +open VG.Proof.AesCfb.X86 (wholeRegs wholeRegs_esp wholeRd wholeWr toNat_n) +open VG.Proof.Aes.X86 (BlocksImpl) + +/-- The regions the whole-block function is given on the partial block. -/ +abbrev tailWr (s₀ : State) : List Region := [fIvR s₀, cBlk s₀, fScr s₀] + +theorem one_toNat : (1 : BitVec 32).toNat = 1 := rfl + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +/-- The callee's return address and stack are in ours. -/ +theorem CPre.retC_sub : Region.Sub ⟨(fE s₀ - BitVec.ofNat 32 28).setWidth 64, 4⟩ (fStk s₀) := by + have : Region.Sub ⟨(fE s₀ - BitVec.ofNat 32 24 - BitVec.ofNat 32 4).setWidth 64, 4⟩ (fStk s₀) := + hp.stk_sub (by decide) + rwa [show fE s₀ - BitVec.ofNat 32 24 - BitVec.ofNat 32 4 = fE s₀ - BitVec.ofNat 32 28 by + rw [BitVec.sub_sub]; rfl] at this + +theorem CPre.stkC_sub : + Region.Sub ⟨(fE s₀ - BitVec.ofNat 32 28).setWidth 64 - BitVec.ofNat 64 24, 24⟩ (fStk s₀) := by + have := hp.esp52 + have : Region.Sub ⟨(fE s₀ - BitVec.ofNat 32 28 - BitVec.ofNat 32 24).setWidth 64, 24⟩ (fStk s₀) := + hp.stk_sub (by decide) + rwa [Taint.sub_setWidth (by rw [sub_toNat (by omega)]; omega)] at this + +theorem CPre.argsC_sub : Region.Sub (below (fE s₀) 24) (fStk s₀) := below_sub (by decide) hp.esp52 + +theorem CPre.callee_esp : 24 ≤ (fE s₀ - BitVec.ofNat 32 28).toNat ∧ + (fE s₀ - BitVec.ofNat 32 28).toNat + 28 ≤ 2 ^ 32 := by + have := hp.esp52; have := hp.esp_fit + rw [sub_toNat (by omega)]; omega + +/-- The arguments the call pushes, from a state whose stack pointer is as +on entry. -/ +theorem CPre.pushArgs {s : State} (hesp : s.gpr .esp = fE s₀) : + arg (pushed wholeRegs s).callEntry 0 = s.gpr .eax ∧ arg (pushed wholeRegs s).callEntry 1 = s.gpr .ecx ∧ + arg (pushed wholeRegs s).callEntry 2 = s.gpr .edx ∧ arg (pushed wholeRegs s).callEntry 3 = s.gpr .ebx ∧ + arg (pushed wholeRegs s).callEntry 4 = s.gpr .esi ∧ arg (pushed wholeRegs s).callEntry 5 = s.gpr .edi := by + have f : 4 * wholeRegs.length + 4 ≤ (s.gpr .esp).toNat := by + rw [hesp]; have := hp.esp52; simp only [List.length_cons, List.length_nil]; omega + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ <;> rw [callEntry_arg f wholeRegs_esp (by decide)] <;> rfl + +omit hp in +theorem calleeEsp_eq {s : State} (hesp : s.gpr .esp = fE s₀) : + (pushed wholeRegs s).callEntry.gpr .esp = fE s₀ - BitVec.ofNat 32 28 := by + rw [callEntry_esp', hesp]; rfl + +omit hp in +theorem calleeArgs_eq {s : State} (hesp : s.gpr .esp = fE s₀) : + argAddr (pushed wholeRegs s).callEntry 0 = (fE s₀ - BitVec.ofNat 32 24).setWidth 64 := by + rw [callEntry_argAddr0, hesp]; rfl + +theorem CPre.callPre {M : Mode} {s : State} (h : Setup s₀ s) : + CallPre (modeX86 M) wholeRegs (wholeRd s₀) (wholeWr s₀) s := by + obtain ⟨a0, a1, a2, a3, a4, a5⟩ := hp.pushArgs h.esp + have eA := calleeArgs_eq h.esp + have eSp := calleeEsp_eq h.esp + obtain ⟨c1, c2⟩ := hp.callee_esp + refine ⟨?_, ?_, ?_⟩ + · simp only [modeX86, State.withRegions_rd, State.withRegions_wr, State.withRegions_gpr, + arg_withRegions, argAddr_withRegions, a0, a1, a2, a3, a4, a5, h.eax, h.ecx, h.edx, h.ebx, h.esi, h.edi, + eA, eSp, toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (AesCfb.X86.blk_sub s₀), hp.sch_scr, + hp.iv_data.sub_right (AesCfb.X86.blk_sub s₀), hp.iv_scr, hp.data_scr.sub_left (AesCfb.X86.blk_sub s₀), + hp.stk_iv.sub_left hp.argsC_sub, (hp.stk_data.sub_left hp.argsC_sub).sub_right (AesCfb.X86.blk_sub s₀), + hp.stk_scr.sub_left hp.argsC_sub, + hp.stk_iv.sub_left hp.retC_sub, (hp.stk_data.sub_left hp.retC_sub).sub_right (AesCfb.X86.blk_sub s₀), + hp.stk_scr.sub_left hp.retC_sub, + hp.stk_sch.sub_left hp.stkC_sub, hp.stk_iv.sub_left hp.stkC_sub, + (hp.stk_data.sub_left hp.stkC_sub).sub_right (AesCfb.X86.blk_sub s₀), hp.stk_scr.sub_left hp.stkC_sub, + hp.sch_fit, hp.iv_fit, hp.blk_fit, hp.scr_fit, c1, c2, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr, h.esp] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨below (fE s₀) 24, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +end + +theorem whole_wp {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 M).post s s') + (hsp : NoSp whole) (hst : stackUse whole = 24) {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WP isa (wholeCall name whole) s (Whole M s₀) := by + have f : 4 * wholeRegs.length + 4 ≤ (s.gpr .esp).toNat := by + rw [h.esp]; have := hp.esp52; simp only [List.length_cons, List.length_nil]; omega + -- What the callee reads, on entry. + have ef : Frame [fSv s₀, fStk s₀] s₀.mem (pushed wholeRegs s).callEntry.mem := + ((AesCfb.X86.svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (by + rw [← h.mem] + exact (callEntry_frame f wholeRegs_esp).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fStk s₀, by simp, by rw [h.esp]; exact below_sub (by decide) hp.esp52⟩) + have eW : bytesAt (pushed wholeRegs s).callEntry.mem ((fW s₀).setWidth 64) (16 * (fR s₀ + 1)) = fWk s₀ := + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact (hp.sch_sv.sub_left hp.sched_sub).sub_right (sv16_sub s₀) + · exact hp.stk_sch.symm.sub_left hp.sched_sub) hp.sched_len + have eIv : bytesAt (pushed wholeRegs s).callEntry.mem ((fIv s₀).setWidth 64) 16 = fIv0 s₀ := + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hp.iv_sv.sub_right (sv16_sub s₀) + · exact hp.stk_iv.symm) (by decide) + have eB : Spec.Cbc.blocksAt (pushed wholeRegs s).callEntry.mem ((fD s₀).setWidth 64) (fN s₀) = fBlks s₀ := + AesCfb.X86.blocksAt_frame' ef (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact (hp.data_sv.sub_left (AesCfb.X86.blk_sub s₀)).sub_right (sv16_sub s₀) + · exact hp.stk_data.symm.sub_left (AesCfb.X86.blk_sub s₀)) + obtain ⟨a0, a1, a2, a3, a4, a5⟩ := hp.pushArgs h.esp + refine WP.callWith (rs := wholeRegs) hv hsp (by decide) wholeRegs_esp + (by rw [hst, h.esp]; have := hp.esp52; simp only [List.length_cons, List.length_nil]; omega) + (hp.callPre h) fun s' rd' wr' cs' f' ⟨s₂, m₂, post₂⟩ => ?_ + rw [hst, h.esp, h.mem] at f' + simp only [modeX86, State.withRegions_mem, arg_withRegions, a0, a1, a2, a3, a4, h.eax, h.ecx, h.edx, h.ebx, + h.esi, toNat_n, m₂, eW, eIv, eB] at post₂ + exact ⟨by rw [cs' .esp (by simp [calleeSaved]), h.esp], by rw [rd', h.rd], by rw [wr', h.wr], f', post₂.1, + post₂.2⟩ + +theorem whole_cW {M : Mode} {s₀ s : State} (h : Whole M s₀ s) : Frame (cW s₀) (svMem s₀) s.mem := + cW1_cW (whole_cW1 h) + +/-- The test sets ZF if no bytes are left after the whole blocks. -/ +theorem final_test_wp {M : Mode} {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole M s₀ s) : + WP isa (.block tailTest) s fun s' => Whole M s₀ s' ∧ s'.zf = some (decide (fU s₀ = 0)) := by + have big := big_of (whole_cW h) + rw [AesCfb.X86.tailTest_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) (hp.arg_keep big (by decide)) + fun s₁ u₁ => wp_andi fun s₂ u₂ => wp_test fun s₃ f₃ z₃ => WP.block_nil + ⟨h.of_eq (by rw [f₃.gpr, u₂.other _ (by decide), u₁.other _ (by decide)]) + (by rw [f₃.mem, u₂.mem, u₁.mem]) (by rw [f₃.rd, u₂.rd, u₁.rd]) (by rw [f₃.wr, u₂.wr, u₁.wr]), ?_⟩ + have := AesCfb.X86.fU_lt s₀ + rw [z₃, u₂.gpr, u₁.gpr, AesCfb.X86.and15, ofNat_and_self_beq (by omega)] + +/-! ## The partial last block: its arguments -/ + +theorem zeroSlots_fits : Spill.Fits 32 zeroSlots := by decide + +/-- Four zeroed words make 16 zero bytes. -/ +theorem zero_bytes (m : Mem) (A : Addr) {g : Reg → BitVec 32} (hg : g .ecx = 0) : + bytesAt (Spill.saveMem m (A + BitVec.ofNat 64 ·) g zeroSlots) (A + BitVec.ofNat 64 16) 16 = + List.replicate 16 0 := by + have hs := Spill.saveMem_saved_ofNat m A g zeroSlots_fits (by decide) + apply List.ext_getElem (by simp [bytesAt]) + intro i h₁ _ + have hi : i < 16 := by simpa [bytesAt] using h₁ + simp only [bytesAt, List.getElem_map, List.getElem_range, List.getElem_replicate] + have e : A + BitVec.ofNat 64 16 + BitVec.ofNat 64 i = + A + BitVec.ofNat 64 (16 + 4 * (i / 4)) + BitVec.ofNat 64 (i % 4) := by + rw [Offset.add_add, Offset.add_add]; congr 2; omega + have hmem : ((.ecx, 16 + 4 * (i / 4)) : Reg × Nat) ∈ zeroSlots := by + rcases (by omega : i / 4 = 0 ∨ i / 4 = 1 ∨ i / 4 = 2 ∨ i / 4 = 3) with h | h | h | h <;> rw [h] <;> decide + have hw := hs _ hmem + rw [e, Mem.readW_byte (Spill.saveMem m (A + BitVec.ofNat 64 ·) g zeroSlots) _ (Nat.mod_lt _ (by decide))] + simp only at hw + rw [hw, hg] + simp + +theorem tailArgs_eq : tailArgs = .mov .eax (argOp 6) :: .mov .ecx (.imm 0) :: + (Spill.saveCode .eax zeroSlots ++ ([.mov .ebx (.reg .eax), .alu .add .ebx (.imm 16), .mov .eax (argOp 0), + .mov .ecx (argOp 1), .mov .edx (argOp 2), .mov .esi (.imm 1), .mov .edi (argOp 5)] : List Instr)) := rfl + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + eax : s.gpr .eax = fW s₀ + ecx : s.gpr .ecx = arg s₀ 1 + edx : s.gpr .edx = fIv s₀ + ebx : s.gpr .ebx = cBk s₀ + esi : s.gpr .esi = 1 + edi : s.gpr .edi = fS s₀ + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBlk s₀).base 16 = List.replicate 16 0 + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block tailArgs) s (TArgs s₀) := by + have f₁ := whole_cW1 h + have big := big_of (cW1_cW f₁) + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have ak : ∀ i < 7, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [tailArgs_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (ak 6 (by decide)) fun s₁ u₁ => ?_ + refine wp_movi fun s₂ u₂ => ?_ + have eax₂ : s₂.gpr .eax = fV s₀ := by rw [u₂.other _ (by decide), u₁.gpr] + refine Spill.save_ofNat_ok zeroSlots zeroSlots_fits (by rw [eax₂]; exact hp.sv_fit) (fun p hp' => ?_) + fun s₃ u₃ => ?_ + · have hb : p.2 + 4 ≤ 32 := zeroSlots_fits.1 p hp' + rw [eax₂, u₂.wr, u₁.wr, h.wr, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have hm₃ : s₃.mem = Spill.saveMem s.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₂.gpr zeroSlots := by + rw [u₃.mem, eax₂, u₂.mem, u₁.mem] + have fz : Frame [cBlk s₀] s.mem s₃.mem := by + rw [hm₃] + exact Spill.saveMem_frame List.mem_cons_self _ _ _ _ fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl | rfl | rfl + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + have g₃ : s₃.gpr = s₂.gpr := u₃.gpr + have esp₃ : s₃.gpr .esp = fE s₀ := by rw [g₃, u₂.other _ (by decide), u₁.other _ (by decide), h.esp] + have rw₃ : s₃.rd ++ s₃.wr = s₀.rd ++ s₀.wr := by rw [u₃.rd, u₃.wr, u₂.rd, u₂.wr, u₁.rd, u₁.wr, hrw] + have ak₃ : ∀ i < 7, s₃.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => by + rw [fz.readW (r := ⟨argAddr s₀ i, 4⟩) (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.sv_args.symm.sub_left (hp.arg_sub hi)).sub_right (blk_sv_sub s₀)) (by decide)] + exact ak i hi + refine wp_mov fun s₄ u₄ => wp_addi fun s₅ u₅ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₅.mem, u₄.mem]; exact ak₃ 0 (by decide)) fun s₆ u₆ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₆.mem, u₅.mem, u₄.mem]; exact ak₃ 1 (by decide)) fun s₇ u₇ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₇.rd, u₇.wr, u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem]; exact ak₃ 2 (by decide)) fun s₈ u₈ => wp_movi fun s₉ u₉ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₉.rd, u₉.wr, u₈.rd, u₈.wr, u₇.rd, u₇.wr, u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃] + exact hp.arg_in (by decide)) + (by rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem]; exact ak₃ 5 (by decide)) fun s₁₀ u₁₀ => ?_ + have m₁₀ : s₁₀.mem = s₃.mem := by rw [u₁₀.mem, u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem] + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (AesCfb.X86.blk_sub s₀)).sub_right (blk_sv_sub s₀) + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + refine WP.block_nil ⟨?_, ?_, ?_, ?_, ?_, u₁₀.gpr, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · rw [u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr] + · rw [u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), u₇.gpr] + · rw [u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.gpr] + · rw [u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), + u₆.other _ (by decide), u₅.gpr, u₄.gpr, g₃, eax₂]; rfl + · rw [u₁₀.other _ (by decide), u₉.gpr] + · rw [u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), + u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), esp₃] + · rw [u₁₀.rd, u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd, h.rd] + · rw [u₁₀.wr, u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr, h.wr] + · rw [m₁₀]; exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [m₁₀, AesCfb.X86.blocksAt_frame' fz blkZ]; exact h.blocks + · rw [m₁₀, Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + · rw [m₁₀, hm₃] + exact zero_bytes _ _ (by rw [u₂.gpr]) + +/-! ## The partial last block: the call -/ + +theorem CPre.tailPre {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + CallPre (modeX86 AesCtr.ctrMode) wholeRegs (wholeRd s₀) (tailWr s₀) s := by + obtain ⟨a0, a1, a2, a3, a4, a5⟩ := hp.pushArgs h.esp + have eA := calleeArgs_eq h.esp + have eSp := calleeEsp_eq h.esp + obtain ⟨c1, c2⟩ := hp.callee_esp + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [modeX86, State.withRegions_rd, State.withRegions_wr, State.withRegions_gpr, + arg_withRegions, argAddr_withRegions, a0, a1, a2, a3, a4, a5, h.eax, h.ecx, h.edx, h.ebx, h.esi, h.edi, + eA, eSp, hp.cBk_addr, one_toNat, Nat.mul_one] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.sch_scr, + hp.iv_sv.sub_right bs, hp.iv_scr, (hp.scr_sv.sub_right bs).symm, + hp.stk_iv.sub_left hp.argsC_sub, (hp.stk_sv.sub_left hp.argsC_sub).sub_right bs, + hp.stk_scr.sub_left hp.argsC_sub, + hp.stk_iv.sub_left hp.retC_sub, (hp.stk_sv.sub_left hp.retC_sub).sub_right bs, + hp.stk_scr.sub_left hp.retC_sub, + hp.stk_sch.sub_left hp.stkC_sub, hp.stk_iv.sub_left hp.stkC_sub, + (hp.stk_sv.sub_left hp.stkC_sub).sub_right bs, hp.stk_scr.sub_left hp.stkC_sub, + hp.sch_fit, hp.iv_fit, by rw [hp.cBk_toNat]; have := hp.sv_fit; omega, hp.scr_fit, c1, c2, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr, h.esp] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨below (fE s₀) 24, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 16, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 16, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBlk s₀).base 16 = Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem tail_call_wp {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s') + (hsp : NoSp whole) (hst : stackUse whole = 24) {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + WP isa (wholeCall name whole) s (TCall s₀) := by + have f : 4 * wholeRegs.length + 4 ≤ (s.gpr .esp).toNat := by + rw [h.esp]; have := hp.esp52; simp only [List.length_cons, List.length_nil]; omega + have ef : Frame [fStk s₀] s.mem (pushed wholeRegs s).callEntry.mem := + (callEntry_frame f wholeRegs_esp).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fStk s₀, by simp, by rw [h.esp]; exact below_sub (by decide) hp.esp52⟩ + have big := big_of (cW1_cW h.frame) + have eW : bytesAt (pushed wholeRegs s).callEntry.mem ((fW s₀).setWidth 64) (16 * (fR s₀ + 1)) = fWk s₀ := by + rw [Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact hp.stk_sch.symm.sub_left hp.sched_sub) hp.sched_len] + exact hp.sched_keep big + have eT : bytesAt (pushed wholeRegs s).callEntry.mem ((fIv s₀).setWidth 64) 16 = + Spec.Ctr.next (fIv0 s₀) (fN s₀) := by + rw [Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.stk_iv.symm) (by decide)] + exact h.ctr + have eZ : bytesAt (pushed wholeRegs s).callEntry.mem (cBlk s₀).base 16 = List.replicate 16 0 := by + rw [Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact hp.stk_sv.symm.sub_left (blk_sv_sub s₀)) (by decide)] + exact h.zero + obtain ⟨a0, a1, a2, a3, a4, a5⟩ := hp.pushArgs h.esp + refine WP.callWith (rs := wholeRegs) hv hsp (by decide) wholeRegs_esp + (by rw [hst, h.esp]; have := hp.esp52; simp only [List.length_cons, List.length_nil]; omega) + (hp.tailPre h) fun s' rd' wr' cs' f' ⟨s₂, m₂, post₂⟩ => ?_ + rw [hst, h.esp] at f' + simp only [modeX86, State.withRegions_mem, arg_withRegions, a0, a1, a2, a3, a4, h.eax, h.ecx, h.edx, h.ebx, + h.esi, hp.cBk_addr, one_toNat, m₂, eW, eT, AesCtr.ctrMode_out, AesCtr.ctrMode_chain, + AesCbc.length_blocksAt] at post₂ + have fc : Frame (cW1 s₀) s.mem s'.mem := f'.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h | h <;> simp [h] + refine ⟨by rw [cs' .esp (by simp [calleeSaved]), h.esp], by rw [rd', h.rd], by rw [wr', h.wr], + h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [AesCfb.X86.blocksAt_frame' f' fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (AesCfb.X86.blk_sub s₀) + · exact (hp.data_sv.sub_left (AesCfb.X86.blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (AesCfb.X86.blk_sub s₀) + · exact hp.stk_data.symm.sub_left (AesCfb.X86.blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (aesWith_length _ _) eZ post₂.1 + +/-! ## The partial last block: the bytes XORed -/ + +theorem xorArgs_eq : xorArgs = [.mov .ebx (argOp 6), .alu .add .ebx (.imm 16), .mov .esi (argOp 3), + .mov .ebp (argOp 4), .mov .eax (.reg .ebp), .alu .and .ebp (.imm 15), .alu .sub .eax (.reg .ebp), + .alu .add .esi (.reg .eax)] := rfl + +/-- The tail loop's operands. -/ +structure XArgs (s₀ s : State) : Prop where + call : TCall s₀ s + ebx : s.gpr .ebx = cBk s₀ + esi : s.gpr .esi = fT s₀ + ebp : s.gpr .ebp = BitVec.ofNat 32 (fU s₀) + +theorem final_xorArgs_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) : + WP isa (.block xorArgs) s (XArgs s₀) := by + have big := big_of (cW1_cW h.frame) + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have ak : ∀ i < 7, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [xorArgs_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (ak 6 (by decide)) fun s₁ u₁ => ?_ + refine wp_addi fun s₁' u₁' => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₁'.other _ (by decide), u₁.other _ (by decide), h.esp]) + (by rw [u₁'.rd, u₁'.wr, u₁.rd, u₁.wr, hrw]; exact hp.arg_in (by decide)) + (by rw [u₁'.mem, u₁.mem]; exact ak 3 (by decide)) fun s₂ u₂ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₂.other _ (by decide), u₁'.other _ (by decide), u₁.other _ (by decide), h.esp]) + (by rw [u₂.rd, u₂.wr, u₁'.rd, u₁'.wr, u₁.rd, u₁.wr, hrw]; exact hp.arg_in (by decide)) + (by rw [u₂.mem, u₁'.mem, u₁.mem]; exact ak 4 (by decide)) fun s₃ u₃ => ?_ + refine wp_mov fun s₄ u₄ => wp_andi fun s₅ u₅ => wp_sub fun s₆ u₆ _ => wp_add fun s₇ u₇ => WP.block_nil ?_ + have e₅ : s₅.gpr .ebp = BitVec.ofNat 32 (fU s₀) := by + rw [u₅.gpr, u₄.other _ (by decide), u₃.gpr, AesCfb.X86.and15] + have m₇ : s₇.mem = s.mem := by rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁'.mem, u₁.mem] + refine ⟨⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩, ?_, ?_, ?_⟩ + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), u₂.other _ (by decide), u₁'.other _ (by decide), u₁.other _ (by decide), h.esp] + · rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁'.rd, u₁.rd, h.rd] + · rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁'.wr, u₁.wr, h.wr] + · rw [m₇]; exact h.frame + · rw [m₇]; exact h.blocks + · rw [m₇]; exact h.ctr + · rw [m₇]; exact h.out + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), u₂.other _ (by decide), u₁'.gpr, u₁.gpr]; rfl + · rw [u₇.gpr, u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), + u₂.gpr, u₆.gpr, u₅.other _ (by decide), u₄.gpr, u₃.gpr, e₅, AesCfb.X86.sub_mod16] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), e₅] + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem ((fTail s₀).base + BitVec.ofNat 64 q) = s₀.mem ((fTail s₀).base + BitVec.ofNat 64 q) ^^^ + (Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = + Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.esp, h.rd, h.wr, whole_cW h, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt]⟩ + +theorem CPre.tail_addr {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).setWidth 64 = (fTail s₀).base := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + exact addr_eq (by omega) + +theorem CPre.toNat_tail {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem final_xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : XArgs s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.loop (.block Impl.Modes.X86.tailByte) .ne) s (Done s₀) := by + have hU := AesCfb.X86.fU_lt s₀ + have hT := hp.toNat_tail hu + have eT := hp.tail_addr hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_fit + have hVw := hp.sv_fit + have hB := hp.cBk_toNat + have eB := hp.cBk_addr + have eN : fN s₀ = fL s₀ / 16 := rfl + have eU : fU s₀ = fL s₀ % 16 := rfl + have hc := h.call + have xp : Modes.X86.XPre s (cBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fitK := by omega + fitR := by rw [hT]; omega + disj := by + rw [eT, eB] + exact ((((hp.data_sv.sub_left (AesCfb.X86.tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega)))).symm + rdK := fun q hq => by + rw [hc.rd, hc.wr, hp.rd, hp.wr, eB] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [hc.wr, hp.wr, eT] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show (fTail s₀).base + BitVec.ofNat 64 q = (fD s₀).setWidth 64 + BitVec.ofNat 64 (16 * fN s₀ + q) from + Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : Modes.X86.XInv s (cBk s₀) (fT s₀) (fU s₀) 0 s := { + ebx := by rw [h.ebx]; exact (BitVec.add_zero _).symm + esi := by rw [h.esi]; exact (BitVec.add_zero _).symm + ebp := by rw [h.ebp, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + syms := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Modes.X86.tailLoop_wp xp x0) fun s' d => ?_ + have fT' : Frame [fTail s₀] s.mem s'.mem := by have := d.frame; rw [eT] at this; exact this + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (AesCfb.X86.tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact hp.data_scr.sub_left (AesCfb.X86.tail_sub s₀) + · exact (hp.data_sv.sub_left (AesCfb.X86.tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (AesCfb.X86.tail_sub s₀)).symm + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (AesCfb.X86.tail_sub s₀)).sub_right (sv16_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + refine ⟨by rw [d.gpr .esp (by decide) (by decide) (by decide) (by decide) (by decide), hc.esp], + by rw [d.rd, hc.rd], by rw [d.wr, hc.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW hc.frame).trans (fT'.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, AesCfb.X86.tail_sub s₀⟩) + · rw [AesCfb.X86.blocksAt_frame' fT' fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact hc.blocks + · have := d.data q hq + rw [eT, eB] at this + rw [this, hc.frame.bytes tailD hlen hq, (AesCfb.X86.svMem_frame s₀).bytes tailS hlen hq, + MdStream.X86.bytesAt_getD hc.out (show q < 16 by omega)] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame fT' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_data.sub_right (AesCfb.X86.tail_sub s₀)) + (by decide), hc.ctr, ← AesCtr.next_add] + +theorem final_mid_wp {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s') + (hsp : NoSp whole) (hst : stackUse whole = 24) {s₀ : State} (hp : CPre s₀) {s : State} + (h : Whole AesCtr.ctrMode s₀ s) (hz : s.zf = some (decide (fU s₀ = 0))) : + WP isa (.ite .e (.block []) (finalTail name whole)) s (Done s₀) := by + have ev : isa.eval .e s = some (decide (fU s₀ = 0)) := by + show VG.X86.eval .e s = _; rw [eval_e, hz] + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hv hsp hst hp h₁) fun _ h₂ => + WP.seq (WP.mono (final_xorArgs_wp hp h₂) fun _ h₃ => final_xor_wp hp h₃ hu))) + +/-! ## Restoring the registers -/ + +theorem final_end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block finalRestore) s fun s' => abiPreserved s₀ s' ∧ s'.mem = s.mem := by + have big := big_of h.frame + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have hs : Spill.Saved s.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₀.gpr finalSaved := + (Spill.saveMem_saved_ofNat s₀.mem _ s₀.gpr AesCfb.X86.finalSaved_fits (by decide)).of_frame h.frame + (fun p hp' => Offset.contains_base _ (AesCfb.X86.finalSaved_fits.1 p hp') + (by have := AesCfb.X86.finalSaved_fits.1 p hp'; omega)) + fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact (hp.iv_sv.sub_right (sv16_sub s₀)).symm + · exact (hp.data_sv.sub_right (sv16_sub s₀)).symm + · exact (hp.scr_sv.sub_right (sv16_sub s₀)).symm + · exact sv_blk s₀ + · exact (hp.stk_sv.sub_right (sv16_sub s₀)).symm + rw [AesCfb.X86.restore_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (hp.arg_keep big (by decide)) + fun s₁ u₁ => ?_ + refine Spill.restore_ofNat_ok finalSaved AesCfb.X86.finalSaved_fits + (by rw [u₁.gpr]; have h32 : (arg s₀ 6).toNat + 32 ≤ 2 ^ 32 := hp.sv_fit; omega) AesCfb.X86.finalSaved_ne_eax + (fun p hp' => ?_) (by rw [u₁.gpr, u₁.mem]; exact hs) fun s₂ r₂ => WP.block_nil ?_ + · have := AesCfb.X86.finalSaved_fits.1 p hp' + rw [u₁.gpr, u₁.rd, u₁.wr, hrw, hp.rd, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + refine ⟨⟨r₂.abi (by decide) (by decide) (by rw [u₁.other _ (by decide), h.esp]), ?_⟩, by rw [r₂.mem, u₁.mem]⟩ + rw [r₂.mem, u₁.mem]; exact hp.ret_keep big + +/-! ## The whole function -/ + +theorem final_wp {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s') + (hsp : NoSp whole) (hst : stackUse whole = 24) {s₀ : State} (hp : CPre s₀) : + WP isa (final name whole) s₀ fun s' => abiPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (final_setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hv hsp hst hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (final_test_wp hp h₂) fun s₃ ⟨h₃, z₃⟩ => ?_) + refine WP.seq (WP.mono (final_mid_wp hv hsp hst hp h₃ z₃) fun s₄ h₄ => ?_) + exact WP.mono (final_end_wp hp h₄) fun _ ⟨g, m⟩ => ⟨g, s₄, h₄, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86.post s₀ s' := by + show Spec.Ctr.CryptFinal (ciphAt s₀.mem ((fW s₀).setWidth 64) (fR s₀)) s₀.mem s'.mem + ((fIv s₀).setWidth 64) ((fD s₀).setWidth 64) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s') + (hsp : NoSp whole) (hst : stackUse whole = 24) (s : State) (hs : ctrFinalX86.pre s) : + ∃ t s', Exec isa (final name whole) s t s' ∧ abiPreserved s s' ∧ ctrFinalX86.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp hv hsp hst (CPre.of hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem CPre.argsOut {s₀ : State} (hp : CPre s₀) {s : State} (h : Pt s₀ s) : ArgsOut 7 s := by + have hs := hp.esp_fit + refine ⟨by rw [h.esp]; omega, ?_⟩ + rw [h.wr, hp.wr, h.esp] + simp only [List.mem_cons, List.not_mem_nil, or_false] + rintro r (rfl | rfl | rfl | rfl) + · exact Taint.frame_disjoint (n := 28) (by omega) hp.ret_iv hp.iv_args.symm + · exact Taint.frame_disjoint (n := 28) (by omega) hp.ret_data hp.data_args.symm + · exact Taint.frame_disjoint (n := 28) (by omega) hp.ret_scr hp.scr_args.symm + · exact Taint.frame_disjoint (n := 28) (by omega) hp.ret_sv hp.sv_args.symm + +/-- Two runs agree on `esp`, the stack arguments and the registers `rs`. -/ +theorem Pt.agree {s₀ s₀' : State} (hq : ctrFinalX86.pub s₀ s₀') (hp : CPre s₀) (hp' : CPre s₀') + {rs : List Reg} {s₁ s₂ : State} (h₁ : Pt s₀ s₁) (h₂ : Pt s₀' s₂) (hr : ∀ r ∈ rs, s₁.gpr r = s₂.gpr r) : + VG.X86.Taint.Agree (argTaint rs (4 + 4 * 7)) s₁ s₂ := + agree_argTaint hr (by rw [h₁.esp, h₂.esp, fE, fE, hq.1]) (hp.argsOut h₁) (hp'.argsOut h₂) + fun i hi => by + rw [AesCfb.X86.arg_cur h₁.esp (h₁.args i hi), AesCfb.X86.arg_cur h₂.esp (h₂.args i hi), hq.2 i hi] + +theorem whole_pt {M : Mode} {s₀ s : State} (hp : CPre s₀) (h : Whole M s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (whole_cW h)) hi⟩ + +theorem TArgs.pt {s₀ s : State} (hp : CPre s₀) (h : TArgs s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (cW1_cW h.frame)) hi⟩ + +theorem TCall.pt {s₀ s : State} (hp : CPre s₀) (h : TCall s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (cW1_cW h.frame)) hi⟩ + +theorem Done.pt {s₀ s : State} (hp : CPre s₀) (h : Done s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of h.frame) hi⟩ + +theorem setup_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block (finalSave ++ wholeArgs)) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block tailTest) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block tailArgs) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) + (.seq (.block xorArgs) (.loop (.block Impl.Modes.X86.tailByte) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 7)) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s') + (hct : ConstantTime isa (modeX86 AesCtr.ctrMode).pre (modeX86 AesCtr.ctrMode).pub whole) + (hsp : NoSp whole) (hst : stackUse whole = 24) {s₀ s₀' : State} + (h0 : ctrFinalX86.pre s₀) (h0' : ctrFinalX86.pre s₀') (hq : ctrFinalX86.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole) fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + have qE : fE s₀ = fE s₀' := hq.1 + have qA : ∀ i < 7, arg s₀ i = arg s₀' i := hq.2 + have qW : fW s₀ = fW s₀' := qA 0 (by decide) + have qIv : fIv s₀ = fIv s₀' := qA 2 (by decide) + have qD : fD s₀ = fD s₀' := qA 3 (by decide) + have qL : fL s₀ = fL s₀' := by simp only [fL, qA 4 (by decide)] + have qS : fS s₀ = fS s₀' := qA 5 (by decide) + have qV : fV s₀ = fV s₀' := qA 6 (by decide) + have qU : fU s₀ = fU s₀' := by simp only [fU, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, qL] + have pt₀ : ∀ {t : State}, Pt t t := ⟨rfl, rfl, fun _ _ => rfl⟩ + -- The registers saved and the whole-block function's arguments. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := ((RelCT.taint (A := taint) (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + exact Pt.agree (rs := []) hq hp hp' pt₀ pt₀ fun r hr => by simp at hr) t₁).wp + (F₁ := Setup s₀) (F₂ := Setup s₀') + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + -- The whole blocks. + have eRd : wholeRd s₀' = wholeRd s₀ := by simp only [wholeRd, fSch, fW, fE, qW, qE] + have eWr : wholeWr s₀' = wholeWr s₀ := by simp only [wholeWr, fIvR, fBlk, fScr, fIv, fD, fS, qIv, qD, qS, qN] + have c₂ := RelCT.callWith (k := modeX86 AesCtr.ctrMode) (n := name) (rs := wholeRegs) hv hct + (P := fun a b => Setup s₀ a ∧ Setup s₀' b) (wholeRd s₀) (wholeWr s₀) fun a b ⟨ha, hb⟩ => by + have pb := hp'.callPre (M := AesCtr.ctrMode) hb + rw [eRd, eWr] at pb + obtain ⟨a0, a1, a2, a3, a4, a5⟩ := hp.pushArgs ha.esp + obtain ⟨b0, b1, b2, b3, b4, b5⟩ := hp'.pushArgs hb.esp + refine ⟨hp.callPre ha, pb, by rw [ha.esp, hb.esp, qE], ?_, fun i hi => ?_⟩ + · simp only [State.withRegions_gpr, calleeEsp_eq ha.esp, calleeEsp_eq hb.esp, qE] + · simp only [arg_withRegions] + rcases (by omega : i = 0 ∨ i = 1 ∨ i = 2 ∨ i = 3 ∨ i = 4 ∨ i = 5) with rfl | rfl | rfl | rfl | rfl | rfl + · rw [a0, b0, ha.eax, hb.eax, qW] + · rw [a1, b1, ha.ecx, hb.ecx, qA 1 (by decide)] + · rw [a2, b2, ha.edx, hb.edx, qIv] + · rw [a3, b3, ha.ebx, hb.ebx, qD] + · rw [a4, b4, ha.esi, hb.esi, qN] + · rw [a5, b5, ha.edi, hb.edi, qS] + have r₂ : RelCT isa (fun a b => Setup s₀ a ∧ Setup s₀' b) (wholeCall name whole) + (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) := + (RelCT.wp (c := wholeCall name whole) (F₁ := Whole AesCtr.ctrMode s₀) (F₂ := Whole AesCtr.ctrMode s₀') c₂ + fun a b h => ⟨whole_wp hv hsp hst hp h.1, whole_wp hv hsp hst hp' h.2⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + -- The test. + obtain ⟨_, t₃⟩ := test_taint + have r₃ := ((RelCT.taint (A := taint) + (P := fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (whole_pt hp h.1) (whole_pt hp' h.2) fun r hr => by simp at hr) t₃).wp + (F₁ := fun (s : State) => Whole AesCtr.ctrMode s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => Whole AesCtr.ctrMode s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) + fun a b h => ⟨final_test_wp hp h.1, final_test_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + -- The partial last block. + obtain ⟨_, t₄⟩ := tailArgs_taint + obtain ⟨_, t₅⟩ := xor_taint + have tail (hu : fU s₀ ≠ 0) : + RelCT isa (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (finalTail name whole) fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₄ := ((RelCT.taint (A := taint) + (P := fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (whole_pt hp h.1) (whole_pt hp' h.2) fun r hr => by simp at hr) t₄).wp + (F₁ := TArgs s₀) (F₂ := TArgs s₀') + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + have eWr' : tailWr s₀' = tailWr s₀ := by simp only [tailWr, fIvR, cBlk, fScr, fIv, fV, fS, qIv, qV, qS] + have c₅ := RelCT.callWith (k := modeX86 AesCtr.ctrMode) (n := name) (rs := wholeRegs) hv hct + (P := fun a b => TArgs s₀ a ∧ TArgs s₀' b) (wholeRd s₀) (tailWr s₀) fun a b ⟨ha, hb⟩ => by + have pb := hp'.tailPre hb + rw [eRd, eWr'] at pb + obtain ⟨a0, a1, a2, a3, a4, a5⟩ := hp.pushArgs ha.esp + obtain ⟨b0, b1, b2, b3, b4, b5⟩ := hp'.pushArgs hb.esp + refine ⟨hp.tailPre ha, pb, by rw [ha.esp, hb.esp, qE], ?_, fun i hi => ?_⟩ + · simp only [State.withRegions_gpr, calleeEsp_eq ha.esp, calleeEsp_eq hb.esp, qE] + · simp only [arg_withRegions] + rcases (by omega : i = 0 ∨ i = 1 ∨ i = 2 ∨ i = 3 ∨ i = 4 ∨ i = 5) with + rfl | rfl | rfl | rfl | rfl | rfl + · rw [a0, b0, ha.eax, hb.eax, qW] + · rw [a1, b1, ha.ecx, hb.ecx, qA 1 (by decide)] + · rw [a2, b2, ha.edx, hb.edx, qIv] + · rw [a3, b3, ha.ebx, hb.ebx, cBk, cBk, qV] + · rw [a4, b4, ha.esi, hb.esi] + · rw [a5, b5, ha.edi, hb.edi, qS] + have a₅ : RelCT isa (fun a b => TArgs s₀ a ∧ TArgs s₀' b) (wholeCall name whole) + (fun a b => TCall s₀ a ∧ TCall s₀' b) := + (RelCT.wp (c := wholeCall name whole) (F₁ := TCall s₀) (F₂ := TCall s₀') c₅ + fun a b h => ⟨tail_call_wp hv hsp hst hp h.1, tail_call_wp hv hsp hst hp' h.2⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + have a₆ := ((RelCT.taint (A := taint) + (P := fun a b => TCall s₀ a ∧ TCall s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₅).wp + (F₁ := Done s₀) (F₂ := Done s₀') + fun a b h => ⟨WP.seq (WP.mono (final_xorArgs_wp hp h.1) fun _ h₃ => final_xor_wp hp h₃ hu), + WP.seq (WP.mono (final_xorArgs_wp hp' h.2) fun _ h₃ => final_xor_wp hp' h₃ hu')⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + exact a₄.seq (a₅.seq a₆) + have r₄ : RelCT isa (fun a b => (Whole AesCtr.ctrMode s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (Whole AesCtr.ctrMode s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) + (.ite .e (.block []) (finalTail name whole)) + (fun a b => Done s₀ a ∧ Done s₀' b) := by + refine RelCT.ite (fun a b h => ?_) ?_ ?_ + · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + exact ⟨done_of_zero h.1.1.1 h0, done_of_zero h.1.2.1 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + -- The registers restored. + obtain ⟨_, t₆⟩ := restore_taint + have r₅ := RelCT.taint (A := taint) (P := fun a b => Done s₀ a ∧ Done s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₆ + exact r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅))) + +theorem final_ct {name : String} {whole : Prog isa} + (hv : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s') + (hct : ConstantTime isa (modeX86 AesCtr.ctrMode).pre (modeX86 AesCtr.ctrMode).pub whole) + (hsp : NoSp whole) (hst : stackUse whole = 24) : + ConstantTime isa ctrFinalX86.pre ctrFinalX86.pub (final name whole) := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct hsp hst h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## The code's properties -/ + +theorem crypt_noSp (v : BlocksImpl) : NoSp (crypt v.enc) := + NoSp.of_all (by + simp only [crypt, Impl.AesCbc.X86.whole, body, Impl.AesCbc.X86.blkCall, Code.allInstrs, + AesCfb.X86.all_of_noSp v.encNosp] + decide +kernel) + +theorem crypt_stack (v : BlocksImpl) : stackUse (crypt v.enc) = 24 := by + simp only [crypt, Impl.AesCbc.X86.whole, body, Impl.AesCbc.X86.blkCall, stackUse, v.encStack] + decide + +theorem cryptFinal_noSp (v : BlocksImpl) : + (cryptFinal v.enc v.suffix).allInstrs (fun i => !Taint.clobbers i .esp) = true := by + simp only [cryptFinal, final, wholeCall, finalTail, Code.allInstrs, AesCfb.X86.all_of_noSp (crypt_noSp v)] + decide +kernel + +theorem cryptFinal_stack (v : BlocksImpl) : stackUse (cryptFinal v.enc v.suffix) ≤ 52 := by + simp only [cryptFinal, final, wholeCall, finalTail, stackUse, crypt_stack v] + decide + +theorem cryptFinal_spSafe (v : BlocksImpl) : + (cryptFinal v.enc v.suffix).all (fun i => !isa.writesSp i) = true := by + simp only [cryptFinal, final, wholeCall, finalTail, Code.all, crypt_spSafe v] + decide +kernel + +/-! ## Verified -/ + +theorem whole_ok (v : BlocksImpl) : ∀ s, (modeX86 AesCtr.ctrMode).pre s → + ∃ t s', Exec isa (crypt v.enc) s t s' ∧ abiPreserved s s' ∧ (modeX86 AesCtr.ctrMode).post s s' := + fun _ hs => AesCbc.X86.whole_wp (body_ok v) hs + +theorem cryptFinal_verified (v : BlocksImpl) : + Verified X86.target (cryptFinal v.enc v.suffix) finalScratchContract := + Verified.of_correct (final_correct (whole_ok v) (crypt_noSp v) (crypt_stack v)) + (final_ct (whole_ok v) (AesCbc.X86.whole_ct (body_ok v) (body_ct v)) (crypt_noSp v) (crypt_stack v)) + final_implies + +/-! ## With `save` on the stack + +The final function has six argument slots, so `save` is its seventh +argument: it runs its code in a frame of 64 bytes +(`withStackScratchWiped 64 6 8`): the word standing for the return address, +a copy of the six arguments, `save`'s address, and `save`'s 32 bytes (the +registers, then the block that held the last output block), which it zeroes +before returning. The code's calls use 52 bytes below it, so 116 in all. -/ + +theorem frameSat_pre : ∃ s, (Spec.Ctr.aesFinalSig.contract X86.abi (pre := finalPre X86.abi.ptrBits) + (post := finalPost X86.abi.ptrBits) (stack := 116)).pre s := by + have a0 : arg AesCbc.X86.sat 0 = 0x1000 := by decide + have a1 : arg AesCbc.X86.sat 1 = 10 := by decide + have a2 : arg AesCbc.X86.sat 2 = 0x2000 := by decide + have a3 : arg AesCbc.X86.sat 3 = 0x3000 := by decide + have a4 : arg AesCbc.X86.sat 4 = 0 := by decide + have a5 : arg AesCbc.X86.sat 5 = 0x4000 := by decide + have e : argAddr AesCbc.X86.sat 0 = 0x8004 := by decide + have esp : AesCbc.X86.sat.gpr .esp = 0x8000 := rfl + sig_implies_sat [Spec.Ctr.aesFinalSig, finalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [a0, a1, a2, a3, a4, a5, e, esp] using AesCbc.X86.sat + +theorem cryptFinal_framed (v : BlocksImpl) : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 64 6 8 (cryptFinal v.enc v.suffix)) + (finalRoundsContract X86.abi 116) := + X86.Verified.stackScratchWiped (sig := Spec.Ctr.aesFinalSig) (nm := "save") (e := .u64) (n := 4) + (pre := finalPre X86.abi.ptrBits) (post := finalPost X86.abi.ptrBits) (wa := false) (stack := 52) + (leak := some (finalLeak X86.abi.ptrBits)) + (bytes := 64) (words := 8) (cryptFinal_verified v) (by decide) (cryptFinal_noSp v) (cryptFinal_stack v) + (by decide) (finalPre_local _) (finalPost_local _) (finalPost_localOut _) frameSat_pre + (hleak := finalLeak_local _) + +theorem framed_spSafe {c : Prog isa} (h : c.all (fun i => !isa.writesSp i) = true) : + (Impl.StackScratch.X86.withStackScratchWiped 64 6 8 c).all (fun i => !isa.writesSp i) = true := by + have hf : (Impl.StackScratch.X86.withStackScratchWiped 64 6 8 (.block [])).all + (fun i => !isa.writesSp i) = true := by decide +kernel + simp only [Impl.StackScratch.X86.withStackScratchWiped, Impl.StackScratch.X86.withStackScratch, Code.all, + List.all_nil, Bool.and_eq_true] at hf ⊢ + simp_all + +theorem cryptFinal_framed_spSafe (v : BlocksImpl) : + (Impl.StackScratch.X86.withStackScratchWiped 64 6 8 (cryptFinal v.enc v.suffix)).all + (fun i => !isa.writesSp i) = true := + framed_spSafe (cryptFinal_spSafe v) + +end VG.Proof.AesCtr.X86 diff --git a/lean/VerifiedGarbage/Proof/AesOfb/X86/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/X86/Final.lean new file mode 100644 index 00000000000..561a32fe13b --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/X86/Final.lean @@ -0,0 +1,170 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.X86.Final +public import VerifiedGarbage.Proof.AesOfb.Final +public import VerifiedGarbage.Proof.AesOfb.X86.Verified +public import VerifiedGarbage.Proof.AesCfb.X86.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.X86 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +import VerifiedGarbage.Proof.AesOfb.X86.Body +public import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.X86.CT +import VerifiedGarbage.Proof.AesCbc.X86.Verified + +/-! +# AES-OFB of a message's last piece on x86 (32-bit) + +`cryptFinal_framed`: `vg_aes_ofb_final` (`Impl/AesOfb/X86/Final.lean`), for any +implementation `v` of the block functions (`BlocksImpl`), meets +`Proof.AesOfb.finalRoundsContract`, from which the shared contract follows +(`Proof.AesOfb.final_keyed`). + +Its code is AES-CFB's final function around a call of the whole-block +AES-OFB function, so its proof is AES-CFB's (`Proof/AesCfb/X86/Final.lean`), +for OFB as a `Mode` (`ofbMode`): `final_wp` runs it, for any mode, to what it +leaves before restoring the registers (`Done`); `final_ct` gives its +constant time. `ofbFinalX86` is AES-CFB's code contract with OFB's +postcondition, which `final_post` gives from `Done` by +`Proof.AesOfb.cryptFinal_of`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb.X86 + +open VG VG.X86 +open VG.Spec.Aes (bytesAt) +open VG.Proof.AesCfb.X86 (finalX86 FPre Done fW fR fIv fD fL fN final_wp final_ct finalSat all_of_noSp + framed_spSafe) +open VG.Proof.AesCbc.X86 (modeX86) +open VG.Proof.Aes.X86 (BlocksImpl) +open VG.Impl.AesOfb.X86 +open VG.Impl.AesCfb.X86 (final finalTail wholeCall) + +/-- The code's contract, with the arguments on the stack `(schedule, rounds, +iv, data, len, scratch, save)`: AES-CFB's final functions' (`finalX86`), +with the data and the block at `iv` as `Spec.Ofb.CryptFinal` says, by AES +with the key schedule it is given. -/ +def ofbFinalX86 : Contract isa := + { finalX86 true with + post := fun s s' => Spec.Ofb.CryptFinal (ciphAt s.mem ((arg s 0).setWidth 64) (arg s 1).toNat) 16 s.mem + s'.mem ((arg s 2).setWidth 64) ((arg s 3).setWidth 64) (arg s 4).toNat } + +/-- The contract the frame needs: the shared one, with `save`, 16 bytes, as +a seventh argument, and 52 bytes of stack (the whole-block function's +arguments, its return address and its own 24 bytes). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract X86.abi Spec.Ofb.aesFinalSig "save" .u64 2 (finalPre X86.abi.ptrBits) + (finalPost X86.abi.ptrBits) false 52 + +theorem final_implies : ofbFinalX86.Implies finalScratchContract := by + have a0 : arg finalSat 0 = 0x1000 := by decide + have a1 : arg finalSat 1 = 10 := by decide + have a2 : arg finalSat 2 = 0x2000 := by decide + have a3 : arg finalSat 3 = 0x3000 := by decide + have a4 : arg finalSat 4 = 0 := by decide + have a5 : arg finalSat 5 = 0x4000 := by decide + have a6 : arg finalSat 6 = 0x5000 := by decide + have e : argAddr finalSat 0 = 0x8004 := by decide + have esp : finalSat.gpr .esp = 0x8000 := rfl + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, X86.abi, X86.argSlots, X86.argVal, + X86.argBytes, ofbFinalX86, finalX86] [a0, a1, a2, a3, a4, a5, a6, e, esp] using finalSat + +/-- `Spec.Ofb.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done ofbMode s₀ s₁) (hm : s'.mem = s₁.mem) : + ofbFinalX86.post s₀ s' := by + show Spec.Ofb.CryptFinal (ciphAt s₀.mem ((fW s₀).setWidth 64) (fR s₀)) 16 s₀.mem s'.mem + ((fIv s₀).setWidth 64) ((fD s₀).setWidth 64) (fL s₀) + have e := AesCbc.length_blocksAt s₀.mem ((fD s₀).setWidth 64) (fN s₀) + have hb := h.blocks + have ht := h.tail + have hi := h.iv + rw [ofbMode_out] at hb + rw [ofbMode_chain, e] at ht hi + exact cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact hb) (fun q hq => by rw [hm]; exact ht q hq) + (by rw [hm]; exact hi) + +theorem final_correct (v : BlocksImpl) (hsp : NoSp (crypt v.enc)) (hst : stackUse (crypt v.enc) = 24) + (s : State) (hs : ofbFinalX86.pre s) : + ∃ t s', Exec isa (cryptFinal v.enc v.suffix) s t s' ∧ abiPreserved s s' ∧ ofbFinalX86.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := + final_wp (M := ofbMode) (fun _ hs => AesCbc.X86.whole_wp (body_ok v) hs) hsp hst v (FPre.of (enc := true) hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## The code's properties -/ + +theorem crypt_noSp (v : BlocksImpl) : NoSp (crypt v.enc) := + NoSp.of_all (by + simp only [crypt, Impl.AesCbc.X86.whole, body, Impl.AesCbc.X86.blkCall, Code.allInstrs, + all_of_noSp v.encNosp] + decide +kernel) + +theorem crypt_stack (v : BlocksImpl) : stackUse (crypt v.enc) = 24 := by + simp only [crypt, Impl.AesCbc.X86.whole, body, Impl.AesCbc.X86.blkCall, stackUse, v.encStack] + decide + +theorem cryptFinal_noSp (v : BlocksImpl) : + (cryptFinal v.enc v.suffix).allInstrs (fun i => !Taint.clobbers i .esp) = true := by + simp only [cryptFinal, final, wholeCall, finalTail, Impl.AesCbc.X86.blkCall, Code.allInstrs, + all_of_noSp (crypt_noSp v), all_of_noSp v.encNosp] + decide +kernel + +theorem cryptFinal_stack (v : BlocksImpl) : stackUse (cryptFinal v.enc v.suffix) ≤ 52 := by + simp only [cryptFinal, final, wholeCall, finalTail, Impl.AesCbc.X86.blkCall, stackUse, crypt_stack v, + v.encStack] + decide + +theorem cryptFinal_spSafe (v : BlocksImpl) : + (cryptFinal v.enc v.suffix).all (fun i => !isa.writesSp i) = true := by + simp only [cryptFinal, final, wholeCall, finalTail, Impl.AesCbc.X86.blkCall, Code.all, crypt_spSafe v, + v.encSpSafe] + decide +kernel + +/-! ## Verified -/ + +theorem cryptFinal_verified (v : BlocksImpl) : + Verified X86.target (cryptFinal v.enc v.suffix) finalScratchContract := + Verified.of_correct (final_correct v (crypt_noSp v) (crypt_stack v)) + (final_ct (enc := true) (fun _ hs => AesCbc.X86.whole_wp (body_ok v) hs) + (AesCbc.X86.whole_ct (body_ok v) (body_ct v)) (crypt_noSp v) (crypt_stack v) v) + final_implies + +/-! ## With `save` on the stack + +As AES-CFB's final functions, the code runs in a frame of 48 bytes +(`withStackScratchWiped 48 6 4`): the word standing for the return address, +a copy of the six arguments, `save`'s address, and `save`'s 16 bytes, which +it zeroes before returning. The code's calls use 52 bytes below it, so 100 +in all. -/ + +theorem frameSat_pre : ∃ s, (Spec.Ofb.aesFinalSig.contract X86.abi (pre := finalPre X86.abi.ptrBits) + (post := finalPost X86.abi.ptrBits) (stack := 100)).pre s := by + have a0 : arg AesCbc.X86.sat 0 = 0x1000 := by decide + have a1 : arg AesCbc.X86.sat 1 = 10 := by decide + have a2 : arg AesCbc.X86.sat 2 = 0x2000 := by decide + have a3 : arg AesCbc.X86.sat 3 = 0x3000 := by decide + have a4 : arg AesCbc.X86.sat 4 = 0 := by decide + have a5 : arg AesCbc.X86.sat 5 = 0x4000 := by decide + have e : argAddr AesCbc.X86.sat 0 = 0x8004 := by decide + have esp : AesCbc.X86.sat.gpr .esp = 0x8000 := rfl + sig_implies_sat [Spec.Ofb.aesFinalSig, finalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [a0, a1, a2, a3, a4, a5, e, esp] using AesCbc.X86.sat + +theorem cryptFinal_framed (v : BlocksImpl) : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 48 6 4 (cryptFinal v.enc v.suffix)) + (finalRoundsContract X86.abi 100) := + X86.Verified.stackScratchWiped (sig := Spec.Ofb.aesFinalSig) (nm := "save") (e := .u64) (n := 2) + (pre := finalPre X86.abi.ptrBits) (post := finalPost X86.abi.ptrBits) (wa := false) (stack := 52) + (bytes := 48) (words := 4) (cryptFinal_verified v) (by decide) (cryptFinal_noSp v) (cryptFinal_stack v) + (by decide) (finalPre_local _) (finalPost_local _) (finalPost_localOut _) frameSat_pre + +theorem cryptFinal_framed_spSafe (v : BlocksImpl) : + (Impl.StackScratch.X86.withStackScratchWiped 48 6 4 (cryptFinal v.enc v.suffix)).all + (fun i => !isa.writesSp i) = true := + framed_spSafe (cryptFinal_spSafe v) + +end VG.Proof.AesOfb.X86 From 0cc31989278b21e2175c3d4c3956b3c5443f8285 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 12:22:47 +0000 Subject: [PATCH 11/18] AES-OFB and CTR (AES, Camellia, SM4) final functions on AArch64 (WIP: crates to come) As on x86-64; AES's for every variant. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/CamelliaCtr/AArch64.lean | 8 +- .../Artifacts/Sm4Ctr/AArch64.lean | 8 +- .../Generic/AesBlocks/AArch64/AesOfb.lean | 7 + .../Generic/AesCtr32/AArch64/AesCtr.lean | 7 + .../Impl/AesCtr/AArch64/Final.lean | 81 ++ .../Impl/AesOfb/AArch64/Final.lean | 44 + .../Impl/Camellia/AArch64/CtrFinal.lean | 83 ++ .../Impl/Sm4/AArch64/CtrFinal.lean | 83 ++ .../Proof/AesCfb/AArch64/Final.lean | 42 +- .../Proof/AesCtr/AArch64/Final.lean | 885 ++++++++++++++++ .../Proof/AesOfb/AArch64/Final.lean | 122 +++ .../Proof/Camellia/AArch64/CtrFinal.lean | 966 ++++++++++++++++++ .../Proof/Sm4/AArch64/CtrFinal.lean | 958 +++++++++++++++++ 13 files changed, 3271 insertions(+), 23 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/AesCtr/AArch64/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/AesOfb/AArch64/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/Camellia/AArch64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Impl/Sm4/AArch64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/AArch64/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/AArch64/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/AArch64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/AArch64/CtrFinal.lean diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/AArch64.lean b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/AArch64.lean index 641a2d66b10..09922f7d1cd 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/AArch64.lean @@ -1,8 +1,10 @@ module public import VerifiedGarbage.Proof.Camellia.AArch64.CtrVerified +public import VerifiedGarbage.Proof.Camellia.AArch64.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Camellia.AArch64.Lit /-! # Camellia-CTR artifacts on baseline AArch64 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ctrApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 3344 .x5 418 Impl.Camellia.AArch64.ctr stack := 3344 - verified := Proof.Camellia.AArch64.ctr_framed }] + verified := Proof.Camellia.AArch64.ctr_framed }, + Spec.Camellia.ctrFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 80 .x5 10 Impl.Camellia.AArch64.ctrFinal + stack := 3424 + verified := Proof.Camellia.AArch64.CtrFinal.ctrFinal_framed }] end VG.Artifacts.CamelliaCtr.AArch64 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/AArch64.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/AArch64.lean index 949794db472..95714c0242b 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/AArch64.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/AArch64.lean @@ -1,8 +1,10 @@ module public import VerifiedGarbage.Proof.Sm4.AArch64.CtrVerified +public import VerifiedGarbage.Proof.Sm4.AArch64.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print +import VerifiedGarbage.Proof.Sm4.AArch64.Lit /-! # SM4-CTR artifacts on baseline AArch64 -/ @@ -14,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ctrApi.artifact AArch64.target { code := Impl.StackScratch.AArch64.withStackScratchWiped 3264 .x4 408 Impl.Sm4.AArch64.ctr stack := 3264 - verified := Proof.Sm4.AArch64.ctr_framed }] + verified := Proof.Sm4.AArch64.ctr_framed }, + Spec.Sm4.ctrFinalApi.artifact AArch64.target { + code := Impl.StackScratch.AArch64.withStackScratchWiped 80 .x4 10 Impl.Sm4.AArch64.ctrFinal + stack := 3344 + verified := Proof.Sm4.AArch64.CtrFinal.ctrFinal_framed }] end VG.Artifacts.Sm4Ctr.AArch64 diff --git a/lean/VerifiedGarbage/Generic/AesBlocks/AArch64/AesOfb.lean b/lean/VerifiedGarbage/Generic/AesBlocks/AArch64/AesOfb.lean index 0b5dc89ded9..df2325beeb3 100644 --- a/lean/VerifiedGarbage/Generic/AesBlocks/AArch64/AesOfb.lean +++ b/lean/VerifiedGarbage/Generic/AesBlocks/AArch64/AesOfb.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesOfb.AArch64.Verified +public import VerifiedGarbage.Proof.AesOfb.AArch64.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print @@ -17,6 +18,12 @@ def artifacts (v : Proof.Aes.AArch64.BlocksImpl) : List Artifact := [ suffix := v.suffix code := Impl.AesOfb.AArch64.crypt v.enc verified := Proof.AesOfb.keyed (crypt_verified v) + features := v.features }, + Spec.Ofb.aesFinalApi.artifact AArch64.target { + suffix := v.suffix + code := Impl.StackScratch.AArch64.withStackScratchWiped 64 .x6 8 (Impl.AesOfb.AArch64.cryptFinal v.enc v.suffix) + stack := 64 + verified := Proof.AesOfb.final_keyed (cryptFinal_framed v) features := v.features }] end VG.Generic.AesBlocks.AArch64.AesOfb diff --git a/lean/VerifiedGarbage/Generic/AesCtr32/AArch64/AesCtr.lean b/lean/VerifiedGarbage/Generic/AesCtr32/AArch64/AesCtr.lean index aa854deb3d3..fbe9aa7c377 100644 --- a/lean/VerifiedGarbage/Generic/AesCtr32/AArch64/AesCtr.lean +++ b/lean/VerifiedGarbage/Generic/AesCtr32/AArch64/AesCtr.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesCtr.AArch64.Verified +public import VerifiedGarbage.Proof.AesCtr.AArch64.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.AArch64.Print @@ -17,6 +18,12 @@ def artifacts (v : Proof.Aes.AArch64.Ctr32Impl) : List Artifact := [ suffix := v.suffix code := Impl.AesCtr.AArch64.crypt v.callee verified := Proof.AesCtr.keyed (crypt_verified v) + features := v.features }, + Spec.Ctr.aesFinalApi.artifact AArch64.target { + suffix := v.suffix + code := Impl.StackScratch.AArch64.withStackScratchWiped 80 .x6 10 (Impl.AesCtr.AArch64.cryptFinal v.callee v.suffix) + stack := 80 + verified := Proof.AesCtr.final_keyed (Final.cryptFinal_framed v) features := v.features }] end VG.Generic.AesCtr32.AArch64.AesCtr diff --git a/lean/VerifiedGarbage/Impl/AesCtr/AArch64/Final.lean b/lean/VerifiedGarbage/Impl/AesCtr/AArch64/Final.lean new file mode 100644 index 00000000000..0214991c4be --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesCtr/AArch64/Final.lean @@ -0,0 +1,81 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.AArch64 +public import VerifiedGarbage.Impl.AesCfb.AArch64.Final + +/-! +# AES-CTR of a message's last piece: AArch64 implementation + +`cryptFinal c sfx` (schedule = x0, rounds = x1, ctr = x2, data = x3, +len = x4, scratch = x5, save = x6): the code of `vg_aes_ctr_final`, whose +registration frames it with a buffer of its own on the stack, `save`, the +seventh argument, of 80 bytes: the caller's callee-saved registers and the +return address, then a block of the code's own. It is generic over the +implementation of `vg_aes_ctr32` that the whole-block function calls (`c`, +whose callers' names end in `sfx`, e.g. `_aes`): + +1. the registers saved in `save`, and the arguments kept in `x19` + (schedule), `x20` (rounds), `x21` (ctr), `x22` (the data after its whole + blocks), `x23` (`u = len mod 16`, the bytes after them), `x24` (scratch) + and `x25` (`save`), as AES-CFB's final functions do + (`Impl/AesCfb/AArch64/Final.lean`); +2. a call of the whole-block function of the same implementation + (`vg_aes_ctr` and its variants, `Impl/AesCtr/AArch64.lean`) on the + `len / 16` whole blocks, which leaves `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of the + same function on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time (the modes' `xorByte`); +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds`, `len` and the last 32 bits of the counter block +can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesCtr.AArch64 + +open VG.AArch64 +open VG.Impl.Aes.AArch64 (Ctr32) +open VG.Impl.AesCbc.AArch64 (mov) +open VG.Impl.AesCfb.AArch64 (finalSetup finalRestore) +open VG.Impl.Modes.AArch64 (xorByte) + +/-- The two doublewords of the block after the registers in `save`, each +zeroed from `x9`. -/ +def zeroSlots : List (Reg × Nat) := [(.x9, 64), (.x9, 72)] + +/-- The arguments of the whole-block function on that block: the schedule, +the rounds, the counter block, the block, `n = 1`, and the working space. -/ +def tailMoves : List Instr := + [mov .x0 .x19, mov .x1 .x20, mov .x2 .x21, .addImm .x .x3 .x25 64, .movz .x .x4 1 0, mov .x5 .x24] + +/-- The block, from `save` in `x25`, zeroed, and the arguments of the +whole-block function on it. -/ +def tailArgs : List Instr := + .movz .x .x9 0 0 :: (zeroSlots.map fun p => .str .x p.1 .x25 p.2) ++ tailMoves + +/-- The block's address, from `save` in `x25`, for the XOR. -/ +def tailKey : List Instr := [.addImm .x .x9 .x25 64] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, by a call of the whole-block function `name`, `whole`, on it, and its +first `u` bytes XORed into the data. -/ +def finalTail (name : String) (whole : Prog isa) : Prog isa := + .seq (.block tailArgs) (.seq (.call name whole) + (.seq (.block tailKey) (.loop (.block (xorByte .x22 .x23)) (.nonzero .x .x23)))) + +/-- The whole function, around calls of the whole-block function `name`, +`whole`. -/ +def final (name : String) (whole : Prog isa) : Prog isa := + .seq (.block finalSetup) (.seq (.call name whole) + (.seq (.ite (.zero .x .x23) (.block []) (finalTail name whole)) (.block finalRestore))) + +/-- `vg_aes_ctr_final`, calling `vg_aes_ctr` with `vg_aes_ctr32`'s +implementation `c`, whose callers' names end in `sfx`. -/ +def cryptFinal (c : Ctr32) (sfx : String) : Prog isa := final ("vg_aes_ctr" ++ sfx) (crypt c) + +end VG.Impl.AesCtr.AArch64 diff --git a/lean/VerifiedGarbage/Impl/AesOfb/AArch64/Final.lean b/lean/VerifiedGarbage/Impl/AesOfb/AArch64/Final.lean new file mode 100644 index 00000000000..acbd0886083 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesOfb/AArch64/Final.lean @@ -0,0 +1,44 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.AArch64 +public import VerifiedGarbage.Impl.AesCfb.AArch64.Final + +/-! +# AES-OFB of a message's last piece: AArch64 implementation + +`cryptFinal b sfx` (schedule = x0, rounds = x1, iv = x2, data = x3, +len = x4, scratch = x5, save = x6): the code of `vg_aes_ofb_final`, whose +registration frames it with a buffer of its own on the stack, `save`, the +seventh argument, where the code keeps its caller's callee-saved registers +and its return address. It is AES-CFB's final function +(`Impl.AesCfb.AArch64.final`) around a call of the whole-block AES-OFB +function of the same implementation of the block functions (`b`, whose +callers' names end in `sfx`, e.g. `_aes`): + +1. the registers saved in `save`, and the arguments kept in callee-saved + registers; +2. a call of `vg_aes_ofb` (and its variants, `Impl/AesOfb/AArch64.lean`) on + the `len / 16` whole blocks, which leaves the last output block `Oₙ` in + `iv`; +3. if `u = len mod 16 ≠ 0`, a call of the block function on the block at + `iv` in place, which leaves `Oₙ₊₁ = CIPH_K(Oₙ)` there, the last output + block used, and its first `u` bytes XORed into the `u` bytes left, a + byte at a time; +4. the registers restored. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesOfb.AArch64 + +open VG.AArch64 +open VG.Impl.Aes.AArch64 (Blocks) + +/-- `vg_aes_ofb_final`, calling `vg_aes_ofb` with the block function `b`, +whose callers' names end in `sfx`. -/ +def cryptFinal (b : Blocks) (sfx : String) : Prog isa := + Impl.AesCfb.AArch64.final ("vg_aes_ofb" ++ sfx) (crypt b) b + +end VG.Impl.AesOfb.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Camellia/AArch64/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/AArch64/CtrFinal.lean new file mode 100644 index 00000000000..89b0aa36ffe --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Camellia/AArch64/CtrFinal.lean @@ -0,0 +1,83 @@ +module + +public import VerifiedGarbage.Impl.Camellia.AArch64.Ctr +public import VerifiedGarbage.Impl.AesCtr.AArch64.Final +public import VerifiedGarbage.Impl.StackScratch.AArch64 + +/-! +# Camellia-CTR of a message's last piece: AArch64 implementation + +`ctrFinal` (schedule = x0, rounds = x1, ctr = x2, data = x3, len = x4, +save = x5): the code of `vg_camellia_ctr_final`, whose registration frames it +with a buffer of its own on the stack, `save`, of 80 bytes, passed in `x5`: +the caller's callee-saved registers and the return address, then a block of +the code's own. It is AES-CTR's final function's +(`Impl/AesCtr/AArch64/Final.lean`) with Camellia's arguments, around calls +of `vg_camellia_ctr`, framed by its own working space on the stack +(`ctrFramed`): + +1. the registers saved in `save` (AES-CFB's final functions' slots, + `finalSaved`), and the arguments kept in `x19` (schedule), `x20` + (rounds), `x21` (ctr), `x22` (the data after its whole blocks), `x23` + (`u = len mod 16`, the bytes after them) and `x25` (`save`); +2. a call of `vg_camellia_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_camellia_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Camellia.AArch64 + +open VG.AArch64 +open VG.Impl.AesCbc.AArch64 (mov) +open VG.Impl.AesCfb.AArch64 (finalSaved finalRestore) +open VG.Impl.AesCtr.AArch64 (zeroSlots tailKey) +open VG.Impl.Modes.AArch64 (xorByte) + +/-- `vg_camellia_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.AArch64.withStackScratchWiped 3344 .x5 418 ctr + +/-- The registers saved in `save`, at `x5`. -/ +def ctrFinalSave : List Instr := finalSaved.map fun (r, d) => .str .x r .x5 d + +/-- The arguments to their registers, `x22` and `x23` the data after the +whole blocks and its length, `x25` `save`, and `x4` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [mov .x19 .x0, mov .x20 .x1, mov .x21 .x2, mov .x25 .x5, .lsr .x .x9 .x4 4, + .lsl .x .x10 .x9 4, .add .x .x22 .x3 .x10, .sub .x .x23 .x4 .x10, mov .x4 .x9] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrFinalSave ++ ctrFinalMoves + +/-- The arguments of `vg_camellia_ctr` on the block after the registers: +the schedule, the rounds, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [mov .x0 .x19, mov .x1 .x20, mov .x2 .x21, .addImm .x .x3 .x25 64, .movz .x .x4 1 0] + +/-- The block, from `save` in `x25`, zeroed, and the arguments of +`vg_camellia_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .movz .x .x9 0 0 :: (zeroSlots.map fun p => .str .x p.1 .x25 p.2) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq (.call "vg_camellia_ctr" ctrFramed) + (.seq (.block tailKey) (.loop (.block (xorByte .x22 .x23)) (.nonzero .x .x23)))) + +/-- `vg_camellia_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq (.call "vg_camellia_ctr" ctrFramed) + (.seq (.ite (.zero .x .x23) (.block []) ctrFinalTail) (.block finalRestore))) + +end VG.Impl.Camellia.AArch64 diff --git a/lean/VerifiedGarbage/Impl/Sm4/AArch64/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/AArch64/CtrFinal.lean new file mode 100644 index 00000000000..53383972280 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Sm4/AArch64/CtrFinal.lean @@ -0,0 +1,83 @@ +module + +public import VerifiedGarbage.Impl.Sm4.AArch64.Ctr +public import VerifiedGarbage.Impl.AesCtr.AArch64.Final +public import VerifiedGarbage.Impl.StackScratch.AArch64 + +/-! +# SM4-CTR of a message's last piece: AArch64 implementation + +`ctrFinal` (schedule = x0, ctr = x1, data = x2, len = x3, save = x4): the +code of `vg_sm4_ctr_final`, whose registration frames it with a buffer of its +own on the stack, `save`, of 80 bytes, passed in `x4`: +the caller's callee-saved registers and the return address, then a block of +the code's own. It is AES-CTR's final function's +(`Impl/AesCtr/AArch64/Final.lean`) with SM4's arguments, around calls +of `vg_sm4_ctr`, framed by its own working space on the stack +(`ctrFramed`): + +1. the registers saved in `save` (AES-CFB's final functions' slots, + `finalSaved`), and the arguments kept in `x19` (schedule), `x21` (ctr), + `x22` (the data after its whole blocks), `x23` (`u = len mod 16`, the + bytes after them) and `x25` (`save`); +2. a call of `vg_sm4_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_sm4_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Sm4.AArch64 + +open VG.AArch64 +open VG.Impl.AesCbc.AArch64 (mov) +open VG.Impl.AesCfb.AArch64 (finalSaved finalRestore) +open VG.Impl.AesCtr.AArch64 (zeroSlots tailKey) +open VG.Impl.Modes.AArch64 (xorByte) + +/-- `vg_sm4_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.AArch64.withStackScratchWiped 3264 .x4 408 ctr + +/-- The registers saved in `save`, at `x4`. -/ +def ctrFinalSave : List Instr := finalSaved.map fun (r, d) => .str .x r .x4 d + +/-- The arguments to their registers, `x22` and `x23` the data after the +whole blocks and its length, `x25` `save`, and `x3` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [mov .x19 .x0, mov .x21 .x1, mov .x25 .x4, .lsr .x .x9 .x3 4, + .lsl .x .x10 .x9 4, .add .x .x22 .x2 .x10, .sub .x .x23 .x3 .x10, mov .x3 .x9] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrFinalSave ++ ctrFinalMoves + +/-- The arguments of `vg_sm4_ctr` on the block after the registers: +the schedule, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [mov .x0 .x19, mov .x1 .x21, .addImm .x .x2 .x25 64, .movz .x .x3 1 0] + +/-- The block, from `save` in `x25`, zeroed, and the arguments of +`vg_sm4_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .movz .x .x9 0 0 :: (zeroSlots.map fun p => .str .x p.1 .x25 p.2) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq (.call "vg_sm4_ctr" ctrFramed) + (.seq (.block tailKey) (.loop (.block (xorByte .x22 .x23)) (.nonzero .x .x23)))) + +/-- `vg_sm4_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq (.call "vg_sm4_ctr" ctrFramed) + (.seq (.ite (.zero .x .x23) (.block []) ctrFinalTail) (.block finalRestore))) + +end VG.Impl.Sm4.AArch64 diff --git a/lean/VerifiedGarbage/Proof/AesCfb/AArch64/Final.lean b/lean/VerifiedGarbage/Proof/AesCfb/AArch64/Final.lean index de54022b1e2..72bb561b81f 100644 --- a/lean/VerifiedGarbage/Proof/AesCfb/AArch64/Final.lean +++ b/lean/VerifiedGarbage/Proof/AesCfb/AArch64/Final.lean @@ -812,10 +812,10 @@ theorem agree_of {s₁ s₂ : State} {rs : List Reg} (hsp : s₁.sp = s₂.sp) ( taint.Agree (Taint.ofRegs rs) s₁ s₂ := ⟨hsp, fun r hr => h r (Taint.mem_ofRegs.mp hr)⟩ -theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeAArch64 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeAArch64 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeAArch64 (cfbMode enc)).pre (modeAArch64 (cfbMode enc)).pub whole) +theorem final_rel {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeAArch64 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeAArch64 M).post s s') + (hct : ConstantTime isa (modeAArch64 M).pre (modeAArch64 M).pub whole) (nf : whole.noFrames = true) (v : BlocksImpl) {s₀ s₀' : State} (h0 : (finalAArch64 enc).pre s₀) (h0' : (finalAArch64 enc).pre s₀') (hq : (finalAArch64 enc).pub s₀ s₀') : RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole v.enc) fun _ _ => True := by @@ -837,7 +837,7 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} (F₁ := Setup s₀) (F₂ := Setup s₀') fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩ -- The whole blocks. - have r₂ := (RelCT.callEx (k := modeAArch64 (cfbMode enc)) (n := name) hv hct + have r₂ := (RelCT.callEx (k := modeAArch64 M) (n := name) hv hct (P := fun a b => Setup s₀ a ∧ Setup s₀' b) fun a b ⟨ha, hb⟩ => by obtain ⟨pa, ca, wa⟩ := whole_pre (M := cfbMode enc) hp ha obtain ⟨pb, cb, wb⟩ := whole_pre (M := cfbMode enc) hp' hb @@ -847,7 +847,7 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} ha.x0, ha.x1, ha.x2, ha.x3, ha.x4, ha.x5, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.x4, hb.x5, hb.sp] rw [fW, fW, fIv, fIv, fD, fD, fS, fS, qW, qR, qIv, qD, qS, qSp, qN] exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩).wp - (F₁ := Whole (cfbMode enc) s₀) (F₂ := Whole (cfbMode enc) s₀') + (F₁ := Whole M s₀) (F₂ := Whole M s₀') fun a b h => ⟨whole_wp hv nf hp h.1, whole_wp hv nf hp' h.2⟩ -- The partial last segment. obtain ⟨_, t₃⟩ : ∃ h, (taint.check (Taint.ofRegs [.x19, .x20, .x21, .x24]) @@ -856,11 +856,11 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} (.seq (.block [Impl.AesCbc.AArch64.mov .x9 .x21]) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) h).isSome = true := ⟨_, by taint_decide⟩ - have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) - (finalTail v.enc) fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b := by + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) + (finalTail v.enc) fun a b => Done M s₀ a ∧ Done M s₀' b := by have hu' : fU s₀' ≠ 0 := qU ▸ hu have a₃ := (RelCT.taint (A := taint) - (P := fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) _ + (P := fun a b => Whole M s₀ a ∧ Whole M s₀' b) _ (fun a b h => agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl | rfl @@ -868,10 +868,10 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} · rw [h.1.x20, h.2.x20, qR] · rw [h.1.x21, h.2.x21, fIv, fIv, qIv] · rw [h.1.x24, h.2.x24, fS, fS, qS]) t₃).wp - (F₁ := IvA (cfbMode enc) s₀) (F₂ := IvA (cfbMode enc) s₀') + (F₁ := IvA M s₀) (F₂ := IvA M s₀') fun a b h => ⟨final_ivArgs_wp hp h.1, final_ivArgs_wp hp' h.2⟩ have a₄ := (AesCbc.AArch64.blk_rel (b := v.enc) v.encOk v.encCt - (P := fun a b => IvA (cfbMode enc) s₀ a ∧ IvA (cfbMode enc) s₀' b) + (P := fun a b => IvA M s₀ a ∧ IvA M s₀' b) fun a b h => by have e₂ := h.2.pre have eW : fW s₀' = fW s₀ := qW.symm @@ -880,23 +880,23 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} have eR : fR s₀' = fR s₀ := by simp only [fR, qR] rw [eW, eIv, eS, eR] at e₂ exact ⟨h.1.pre, e₂, by rw [h.1.whole.sp, h.2.whole.sp, qSp]⟩).wp - (F₁ := Ciph (cfbMode enc) s₀) (F₂ := Ciph (cfbMode enc) s₀') + (F₁ := Ciph M s₀) (F₂ := Ciph M s₀') fun a b h => ⟨final_ciph_wp v hp h.1, final_ciph_wp v hp' h.2⟩ have a₅ := (RelCT.taint (A := taint) - (P := fun a b => Ciph (cfbMode enc) s₀ a ∧ Ciph (cfbMode enc) s₀' b) _ + (P := fun a b => Ciph M s₀ a ∧ Ciph M s₀' b) _ (fun a b h => agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl · rw [h.1.x21, h.2.x21, fIv, fIv, qIv] · rw [h.1.x22, h.2.x22, qT] · rw [h.1.x23, h.2.x23, qU]) t₄).wp - (F₁ := Done (cfbMode enc) s₀) (F₂ := Done (cfbMode enc) s₀') + (F₁ := Done M s₀) (F₂ := Done M s₀') fun a b h => ⟨final_xor_wp hp h.1 hu, final_xor_wp hp' h.2 hu'⟩ exact (a₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((a₄.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₅.mono (fun _ _ h => h) fun _ _ h => h.2)) - have r₃ : RelCT isa (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) + have r₃ : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) (.ite (.zero .x .x23) (.block []) (finalTail v.enc)) - (fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) := by + (fun a b => Done M s₀ a ∧ Done M s₀' b) := by refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ · refine RelCT.block_nil fun a b h => ?_ have h0 : fU s₀ = 0 := by @@ -912,17 +912,17 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} -- The registers restored. obtain ⟨_, t₅⟩ : ∃ h, (taint.check (Taint.ofRegs [.x25]) (.block finalRestore) h).isSome = true := ⟨_, by taint_decide⟩ - have r₄ := RelCT.taint (A := taint) (P := fun a b => (Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) ∧ + have r₄ := RelCT.taint (A := taint) (P := fun a b => (Done M s₀ a ∧ Done M s₀' b) ∧ a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ (fun a b h => agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.x25, h.1.2.x25, fV, fV, qV]) t₅ exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₃'.seq r₄)) -theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeAArch64 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeAArch64 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeAArch64 (cfbMode enc)).pre (modeAArch64 (cfbMode enc)).pub whole) +theorem final_ct {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeAArch64 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeAArch64 M).post s s') + (hct : ConstantTime isa (modeAArch64 M).pre (modeAArch64 M).pub whole) (nf : whole.noFrames = true) (v : BlocksImpl) : ConstantTime isa (finalAArch64 enc).pre (finalAArch64 enc).pub (final name whole v.enc) := fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct nf v h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 diff --git a/lean/VerifiedGarbage/Proof/AesCtr/AArch64/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/AArch64/Final.lean new file mode 100644 index 00000000000..9970ac98049 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/AArch64/Final.lean @@ -0,0 +1,885 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.AArch64.Final +public import VerifiedGarbage.Proof.AesCtr.Final +public import VerifiedGarbage.Proof.AesCtr.AArch64.Verified +public import VerifiedGarbage.Proof.AesCtr.AArch64.CT +public import VerifiedGarbage.Proof.AesCfb.AArch64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.AArch64.Spill +public import VerifiedGarbage.Impl.StackScratch.AArch64 +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCtr.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.AArch64.FbFinal +import VerifiedGarbage.Proof.Modes.AArch64.Steps +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.AArch64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.AArch64.RegUpd +import VerifiedGarbage.Proof.Framework.AArch64.Exec +import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +import VerifiedGarbage.Proof.Framework.AArch64.Taint +import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.AesCbc.AArch64.Block +meta import VerifiedGarbage.Impl.AesCtr.AArch64.Final +meta import VerifiedGarbage.Proof.AesCtr.Final +meta import VerifiedGarbage.Proof.AesCtr.AArch64.Verified +meta import VerifiedGarbage.Proof.AesCtr.AArch64.CT +meta import VerifiedGarbage.Proof.AesCfb.AArch64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.AArch64.Spill +meta import VerifiedGarbage.Impl.StackScratch.AArch64 +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCtr.Spec +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.AArch64.FbFinal +meta import VerifiedGarbage.Proof.Modes.AArch64.Steps +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.AArch64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.AArch64.RegUpd +meta import VerifiedGarbage.Proof.Framework.AArch64.Exec +meta import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +meta import VerifiedGarbage.Proof.Framework.AArch64.Taint +meta import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.AesCbc.AArch64.Block + +/-! +# AES-CTR of a message's last piece on AArch64 + +`cryptFinal_framed`: `vg_aes_ctr_final` (`Impl/AesCtr/AArch64/Final.lean`), +for any implementation `v` of `vg_aes_ctr32` (`Ctr32Impl`), meets +`Proof.AesCtr.finalRoundsContract`, from which the shared contract follows +(`Proof.AesCtr.final_keyed`). + +The code is proven against `ctrFinalAArch64`, with a seventh argument `save` +(`x6`) of 80 bytes, for its caller's registers and return address and a block +of its own (`final_implies`: the shared contract with it, +`finalScratchContract`), as a caller of the whole-block function, through its +contract (`modeAArch64 ctrMode`, with `ctrPub`). It shares AES-CFB's final +functions' setup (`Proof/AesCfb/AArch64/Final.lean`: `Setup`, `Whole`): + +* `final_setup_wp`, `whole_wp`: the registers saved, and the whole-block + function on the `n = len / 16` whole blocks (`Whole`); +* `final_mid_wp`: if `u = len % 16` bytes are left, the block after the + registers in `save` zeroed and the whole-block function on it + (`tail_args_wp`, `tail_call_wp`), which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed into them + (`Modes.AArch64.xorLoop_wp`, `tail_xor_wp`); what is left before the + registers are restored is `Done`; +* `final_end_wp`: the registers restored; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the whole-block function's constant time, whose public data, the last 32 +bits of the counter block, agree in both runs at both calls: they do on +entry (the contract's leak), and after `n` blocks they are those on entry +plus `n` modulo `2³²`. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr.AArch64.Final + +open VG VG.AArch64 +open VG.Spec.Aes (bytesAt) +open VG.AArch64.RegUpd +open VG.Impl.AesCtr.AArch64 (tailArgs tailMoves tailKey zeroSlots finalTail final cryptFinal crypt) +open VG.Impl.AesCfb.AArch64 (finalSaved finalMoves finalSetup finalRestore) +open VG.Proof.AesCfb.AArch64.Final (fW fR fIv fD fL fS fV fN fU fT fSch fIvR fData fBlk fTail fScr fSv + fWk fIv0 fBlks svMem Setup Whole Kept finalSat finalFrameSat moves_ok shr4 shr4_shl4 sub_shl4 cs_of + callEntry_x5 toNat_n eval_u bytesAt_getD blocksAt_frame' svMem_frame saved_slots saved_fits blk_sub + tail_sub fN_eq fU_eq n_lt u_lt agree_of WP.sp_eq) +open VG.Proof.AesCbc (Mode) +open VG.Proof.AesCbc.AArch64 (modeAArch64 callEntry_x0 callEntry_x1 callEntry_x2 callEntry_x3 callEntry_x4) +open VG.Proof.Aes.AArch64 (Ctr32Impl) + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = x0, rounds = x1, +ctr = x2, data = x3, len = x4, scratch = x5, save = x6)`, `save` of 80 +bytes: the data and the counter block as `Spec.Ctr.CryptFinal` says, by AES +with the key schedule it is given; the counter block's last four bytes are +public. -/ +def ctrFinalAArch64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .x0, 240⟩ + let iv : Region := ⟨s.gpr .x2, 16⟩ + let data : Region := ⟨s.gpr .x3, (s.gpr .x4).toNat⟩ + let scr : Region := ⟨s.gpr .x5, 2176⟩ + let sv : Region := ⟨s.gpr .x6, 80⟩ + s.rd = [sched] ∧ s.wr = [iv, data, scr, sv] ∧ + sched.Disjoint iv ∧ sched.Disjoint data ∧ sched.Disjoint scr ∧ sched.Disjoint sv ∧ + iv.Disjoint data ∧ iv.Disjoint scr ∧ iv.Disjoint sv ∧ + data.Disjoint scr ∧ data.Disjoint sv ∧ scr.Disjoint sv ∧ + (s.gpr .x0).toNat + 240 ≤ 2 ^ 64 ∧ (s.gpr .x2).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .x3).toNat + (s.gpr .x4).toNat ≤ 2 ^ 64 ∧ (s.gpr .x5).toNat + 2176 ≤ 2 ^ 64 ∧ + (s.gpr .x6).toNat + 80 ≤ 2 ^ 64 ∧ + ((s.gpr .x1).toNat = 10 ∨ (s.gpr .x1).toNat = 12 ∨ (s.gpr .x1).toNat = 14) + post s s' := + Spec.Ctr.CryptFinal (ciphAt s.mem (s.gpr .x0) (s.gpr .x1).toNat) s.mem s'.mem (s.gpr .x2) (s.gpr .x3) + (s.gpr .x4).toNat + pub s₁ s₂ := + (s₁.gpr .x0 = s₂.gpr .x0 ∧ s₁.gpr .x1 = s₂.gpr .x1 ∧ s₁.gpr .x2 = s₂.gpr .x2 ∧ + s₁.gpr .x3 = s₂.gpr .x3 ∧ s₁.gpr .x4 = s₂.gpr .x4 ∧ s₁.gpr .x5 = s₂.gpr .x5 ∧ + s₁.gpr .x6 = s₂.gpr .x6 ∧ s₁.sp = s₂.sp) ∧ + Spec.Ctr.ctrLeak s₁.mem (s₁.gpr .x2) = Spec.Ctr.ctrLeak s₂.mem (s₂.gpr .x2) + +/-- The contract the frame needs: the shared one, with `save`, 80 bytes, as +a seventh argument, and no stack (a call keeps its return address in +`x30`). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract AArch64.abi Spec.Ctr.aesFinalSig "save" .u64 10 (finalPre AArch64.abi.ptrBits) + (finalPost AArch64.abi.ptrBits) false 0 (some (finalLeak AArch64.abi.ptrBits)) + +/-- A state satisfying the precondition. -/ +def ctrSat : State := { finalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩, ⟨0x6000, 80⟩] } + +theorem final_implies : ctrFinalAArch64.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, Spec.Ctr.ctrLeak, ctrFinalAArch64, AArch64.abi, + AArch64.argRegs] [ctrSat, finalSat] using ctrSat + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`, the registers then the block. -/ +abbrev cSv : Region := ⟨fV s₀, 80⟩ +/-- The block after the registers in `save`. -/ +abbrev cBk : Addr := fV s₀ + BitVec.ofNat 64 64 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + rd : s₀.rd = [fSch s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_scr : (fSch s₀).Disjoint (fScr s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_scr : (fIvR s₀).Disjoint (fScr s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + data_scr : (fData s₀).Disjoint (fScr s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + scr_sv : (fScr s₀).Disjoint (cSv s₀) + sch_wrap : (fW s₀).toNat + 240 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + scr_wrap : (fS s₀).toNat + 2176 ≤ 2 ^ 64 + sv_wrap : (fV s₀).toNat + 80 ≤ 2 ^ 64 + rounds : fR s₀ = 10 ∨ fR s₀ = 12 ∨ fR s₀ = 14 + +theorem CPre.of {s₀ : State} (h : ctrFinalAArch64.pre s₀) : CPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ + +/-! ## Regions -/ + +theorem sv64_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem CPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem CPre.sched_sub : Region.Sub ⟨fW s₀, 16 * (fR s₀ + 1)⟩ (fSch s₀) := + Region.sub_prefix (by rcases hp.rounds with h | h | h <;> omega) + +theorem CPre.sched_len : 16 * (fR s₀ + 1) ≤ 2 ^ 64 := by + rcases hp.rounds with h | h | h <;> omega + +end + +/-- The save changes only `save`. -/ +theorem svMem_frame' (s₀ : State) : Frame [cSv s₀] s₀.mem (svMem s₀) := + (svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨fV s₀ + BitVec.ofNat 64 p.2, 8⟩ (cBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +/-! ## Saving the registers, and the whole blocks -/ + +theorem final_setup_wp {s₀ : State} (hp : CPre s₀) : WP isa (.block finalSetup) s₀ (Setup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions s₀.wr (s₀.gpr .x6 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [hp.wr] + have := saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .x6 finalSaved ++ finalMoves)) _ _ + refine Spill.save_ok saved_fits hw ?_ + refine WP.mono (WP.of_runBlock (moves_ok _)) + fun s' ⟨x19, x20, x21, x24, x25, x22, x23, x4, keep, sp, mem, rd, wr⟩ => ?_ + have k (r : Reg) (h₁ : r ≠ .x19) (h₂ : r ≠ .x20) (h₃ : r ≠ .x21) (h₄ : r ≠ .x22) (h₅ : r ≠ .x23) + (h₆ : r ≠ .x24) (h₇ : r ≠ .x25) (h₈ : r ≠ .x4) (h₉ : r ≠ .x9) (h₁₀ : r ≠ .x10) : + s'.gpr r = s₀.gpr r := keep r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ h₉ h₁₀ + exact ⟨x19, x20, x21, by rw [x22, shr4_shl4], by rw [x23, shr4_shl4, sub_shl4], x24, x25, + k .x0 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide), + k .x1 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide), + k .x2 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide), + k .x3 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide), + by rw [x4, shr4], + k .x5 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide), + fun r hr => by + rcases hr with rfl | rfl | rfl <;> + exact k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide), + sp, mem, rd, wr⟩ + +theorem crypt_noFrames (v : Ctr32Impl) : (crypt v.callee).noFrames = true := by + simp only [crypt, Impl.AesCbc.AArch64.whole, Impl.AesCtr.AArch64.body, Code.noFrames, v.noFrames, + Bool.and_self] + +/-- The whole-block function's contract: `modeAArch64 ctrMode`, with the +last 32 bits of the counter block public. -/ +abbrev wholeK : Contract isa := { modeAArch64 AesCtr.ctrMode with pub := ctrPub } + +theorem whole_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, fBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, fBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, fBlk s₀, fScr s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [modeAArch64, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + callEntry_x0, callEntry_x1, callEntry_x2, callEntry_x3, callEntry_x4, callEntry_x5, h.x0, h.x1, h.x2, + h.x3, h.x4, h.x5, toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), hp.sch_scr, + hp.iv_data.sub_right (blk_sub s₀), hp.iv_scr, hp.data_scr.sub_left (blk_sub s₀), + hp.iv_wrap, hp.blk_wrap, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- The schedule, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : CPre s₀) : + bytesAt (svMem s₀) (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ ∧ bytesAt (svMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ + Spec.Cbc.blocksAt (svMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame' s₀ + exact ⟨Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv.sub_left hp.sched_sub) hp.sched_len, + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +theorem whole_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WP isa (.call ("vg_aes_ctr" ++ v.suffix) (crypt v.callee)) s (Whole AesCtr.ctrMode s₀) := by + obtain ⟨eW, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.call (k := wholeK) (crypt_correct v) (rd := [fSch s₀]) (wr := [fIvR s₀, fBlk s₀, fScr s₀]) hpre + hc hw ?_ (crypt_noFrames v) + intro s' rd' wr' sp' fr' cs' _ post₂ + rw [h.mem] at fr' + simp only [modeAArch64, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_x0, callEntry_x1, callEntry_x2, callEntry_x3, callEntry_x4, h.x0, h.x1, h.x2, h.x3, h.x4, + toNat_n, h.mem, eW, eIv, eB] at post₂ + exact ⟨by rw [cs_of cs' .x19 (by simp), h.x19], by rw [cs_of cs' .x20 (by simp), h.x20], + by rw [cs_of cs' .x21 (by simp), h.x21], by rw [cs_of cs' .x22 (by simp), h.x22], + by rw [cs_of cs' .x23 (by simp), h.x23], by rw [cs_of cs' .x24 (by simp), h.x24], + by rw [cs_of cs' .x25 (by simp), h.x25], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], fr', post₂.1, post₂.2⟩ + +/-! ## The partial last block: its arguments -/ + +/-- Two zeroed doublewords make 16 zero bytes. -/ +theorem zero_bytes (m : Mem) (B : Addr) : + bytesAt ((m.writeW B (0 : BitVec 64)).writeW (B + BitVec.ofNat 64 8) (0 : BitVec 64)) B 16 = + List.replicate 16 0 := by + apply List.ext_getElem (by simp [bytesAt]) + intro i h₁ _ + have hi : i < 16 := by simpa [bytesAt] using h₁ + simp only [bytesAt, List.getElem_map, List.getElem_range, List.getElem_replicate, Mem.writeW, Mem.write, + Mem.sub_ofNat_toNat B (show i < 2 ^ 64 by omega), Offset.sub_toNat' B (show 8 < 2 ^ 64 by decide) + (show i < 2 ^ 64 by omega)] + by_cases h8 : 8 ≤ i + · rw [ite_eq_left h8, ite_eq_left (by omega)]; simp + · rw [ite_eq_right h8, ite_eq_right (by omega), ite_eq_left (by omega)]; simp + +theorem zero_ok (s : State) : + ∃ s', runBlock isa [.movz .x .x9 0 0] s = some s' ∧ s'.gpr .x9 = 0 ∧ + (∀ r, r ≠ .x9 → s'.gpr r = s.gpr r) ∧ s'.sp = s.sp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by crun [], ?_⟩ + refine ⟨by simp [gpr_write], fun r hr => by simp [gpr_write, hr], rfl, rfl, rfl, rfl⟩ + +theorem tailMoves_ok (s : State) : + ∃ s', runBlock isa tailMoves s = some s' ∧ + s'.gpr .x0 = s.gpr .x19 ∧ s'.gpr .x1 = s.gpr .x20 ∧ s'.gpr .x2 = s.gpr .x21 ∧ + s'.gpr .x3 = s.gpr .x25 + BitVec.ofNat 64 64 ∧ s'.gpr .x4 = 1 ∧ s'.gpr .x5 = s.gpr .x24 ∧ + (∀ r ∈ preserved, s'.gpr r = s.gpr r) ∧ + s'.sp = s.sp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by crun [tailMoves], ?_⟩ + refine ⟨by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], + by simp [gpr_write], fun r hr => ?_, rfl, rfl, rfl, rfl⟩ + simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp [gpr_write] + +/-! ## Frames -/ + +section +variable (s₀ : State) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, fScr s₀, cBlk s₀] +/-- What the function writes after saving the registers. -/ +abbrev cW : List Region := [fIvR s₀, fData s₀, fScr s₀, cBlk s₀] +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + +end + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem whole_cW1 {M : Mode} {s₀ s : State} (h : Whole M s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame' s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩) + +theorem CPre.sched_big {s₀ : State} (hp : CPre s₀) : + ∀ r ∈ cBig s₀, (⟨fW s₀, 16 * (fR s₀ + 1)⟩ : Region).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv.sub_left hp.sched_sub + · exact hp.sch_data.sub_left hp.sched_sub + · exact hp.sch_scr.sub_left hp.sched_sub + · exact hp.sch_sv.sub_left hp.sched_sub + +/-! ## The partial last block -/ + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + x0 : s.gpr .x0 = fW s₀ + x1 : s.gpr .x1 = s₀.gpr .x1 + x2 : s.gpr .x2 = fIv s₀ + x3 : s.gpr .x3 = cBk s₀ + x4 : s.gpr .x4 = 1 + x5 : s.gpr .x5 = fS s₀ + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = fV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [cBlk s₀] m (Spill.saveMem m (fV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block tailArgs) s (TArgs s₀) := by + have f₁ := whole_cW1 h + obtain ⟨s₁, r₁, z₁, k₁, sp₁, m₁, rd₁, wr₁⟩ := zero_ok s + show WP isa (.block ([.movz .x .x9 0 0] ++ (Spill.saveCode .x25 zeroSlots ++ tailMoves))) _ _ + refine WP.block_append_iff.mpr (WP.of_runBlock ⟨s₁, r₁, ?_⟩) + have h25 : s₁.gpr .x25 = fV s₀ := by rw [k₁ _ (by decide), h.x25] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .x25 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [wr₁, h.wr, hp.wr, h25] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + refine Spill.save_ok (by decide) hw ?_ + refine WP.mono (WP.of_runBlock (tailMoves_ok _)) + fun s' ⟨x0, x1, x2, x3, x4, x5, cs, sp, mem, rd, wr⟩ => ?_ + have c (r : Reg) (hr : r = .x19 ∨ r = .x20 ∨ r = .x21 ∨ r = .x22 ∨ r = .x23 ∨ r = .x24 ∨ r = .x25 ∨ + r = .x26 ∨ r = .x27 ∨ r = .x28) : s'.gpr r = s.gpr r := by + rw [cs r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide)] + exact k₁ r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + have hm : s'.mem = Spill.saveMem s.mem (fV s₀) s₁.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₁.mem _ _ _ = _; rw [m₁, h25] + have fz : Frame [cBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + refine ⟨by rw [x0]; exact (k₁ _ (by decide)).trans h.x19, by rw [x1]; exact (k₁ _ (by decide)).trans h.x20, + by rw [x2]; exact (k₁ _ (by decide)).trans h.x21, by rw [x3, h25], x4, + by rw [x5]; exact (k₁ _ (by decide)).trans h.x24, + by rw [c .x22 (by simp), h.x22], by rw [c .x23 (by simp), h.x23], by rw [c .x25 (by simp), h.x25], + fun r hr => by rw [c r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp, show ({ s₁ with mem := _ } : State).sp = s₁.sp from rfl, sp₁, h.sp], + by rw [rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, rd₁, h.rd], + by rw [wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, wr₁, h.wr], ?_, ?_, ?_, ?_⟩ + · exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + · rw [hm, show Spill.saveMem s.mem (fV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (cBk s₀) (s₁.gpr .x9)).writeW (cBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .x9)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z₁] + exact zero_bytes _ _ + +theorem one_toNat : (1 : BitVec 64).toNat = 1 := rfl + +theorem cBk_toNat {s₀ : State} (hp : CPre s₀) : (cBk s₀).toNat = (fV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem tail_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, cBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, cBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, cBlk s₀, fScr s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [modeAArch64, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + callEntry_x0, callEntry_x1, callEntry_x2, callEntry_x3, callEntry_x4, callEntry_x5, h.x0, h.x1, h.x2, + h.x3, h.x4, h.x5, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.sch_scr, hp.iv_sv.sub_right bs, hp.iv_scr, + (hp.scr_sv.sub_right bs).symm, hp.iv_wrap, by rw [cBk_toNat hp]; omega, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 64, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 64, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = fV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBk s₀) 16 = Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem tail_call_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + WP isa (.call ("vg_aes_ctr" ++ v.suffix) (crypt v.callee)) s (TCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (cW1_cW h.frame) + have eW : bytesAt s.mem (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ := + Proof.Cmac.bytesAt_frame big hp.sched_big hp.sched_len + refine WP.call (k := wholeK) (crypt_correct v) (rd := [fSch s₀]) (wr := [fIvR s₀, cBlk s₀, fScr s₀]) hpre + hc hw ?_ (crypt_noFrames v) + intro s' rd' wr' sp' fr' cs' _ post₂ + simp only [modeAArch64, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_x0, callEntry_x1, callEntry_x2, callEntry_x3, callEntry_x4, h.x0, h.x1, h.x2, h.x3, h.x4, + one_toNat, eW, h.ctr, AesCtr.ctrMode_out, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] at post₂ + have fc : Frame (cW1 s₀) s.mem s'.mem := fr'.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs_of cs' .x22 (by simp), h.x22], by rw [cs_of cs' .x23 (by simp), h.x23], + by rw [cs_of cs' .x25 (by simp), h.x25], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [blocksAt_frame' fr' fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (aesWith_length _ _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + x25 : s.gpr .x25 = fV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.x25, h.kept, h.rd, h.wr, cW1_cW (whole_cW1 h), h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt]⟩ + +theorem toNat_tail {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem tail_xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) s + (Done s₀) := by + obtain ⟨s₁, run₁, x9₁, o₁, mem₁, rd₁, wr₁⟩ := Proof.Modes.AArch64.addImm_ok s .x9 .x25 (v := 64) (by decide) + refine WP.seq (WP.of_runBlock ⟨s₁, run₁, ?_⟩) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : Proof.Modes.AArch64.XPre s₁ (cBk s₀) (fT s₀) (fU s₀) .x22 .x23 := { + pos := by omega + small := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [rd₁, wr₁, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [wr₁, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) + dl := by decide + d9 := by decide + d6 := by decide + d7 := by decide } + have x0 : Proof.Modes.AArch64.XInv s₁ (cBk s₀) (fT s₀) (fU s₀) .x22 .x23 0 s₁ := { + x9 := by rw [x9₁, h.x25]; exact (BitVec.add_zero _).symm + dat := by rw [o₁ _ (by decide), h.x22]; exact (BitVec.add_zero _).symm + left := by rw [o₁ _ (by decide), h.x23, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Proof.Modes.AArch64.xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact hp.data_scr.sub_left (tail_sub s₀) + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (sv64_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have g (r : Reg) (hr : r = .x25 ∨ r = .x26 ∨ r = .x27 ∨ r = .x28) : s'.gpr r = s.gpr r := by + rw [d.gpr r (by rcases hr with rfl | rfl | rfl | rfl <;> decide) (by rcases hr with rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl <;> decide) (by rcases hr with rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl <;> decide), + o₁ _ (by rcases hr with rfl | rfl | rfl | rfl <;> decide)] + refine ⟨by rw [g .x25 (by simp), h.x25], fun r hr => by rw [g r (by rcases hr with rfl | rfl | rfl <;> simp), + h.kept r hr], by rw [d.rd, rd₁, h.rd], by rw [d.wr, wr₁, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · refine cW1_cW h.frame |>.trans ?_ + rw [← mem₁] + exact d.frame.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩ + · rw [blocksAt_frame' d.frame fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, mem₁] + exact h.blocks + · rw [d.data q hq, mem₁, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (cBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame d.frame ivT (by decide), mem₁, h.ctr, ← AesCtr.next_add] + +theorem final_mid_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.ite (.zero .x .x23) (.block []) (finalTail ("vg_aes_ctr" ++ v.suffix) (crypt v.callee))) s + (Done s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp v hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem final_end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block finalRestore) s fun s' => (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.mem = s.mem := by + have hs : Spill.Saved (fV s₀) s₀.gpr finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (fV s₀) s₀.gpr).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨fV s₀ + BitVec.ofNat 64 p.2, 8⟩ (cSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact hp.scr_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + show WP isa (.block (Spill.restoreCode .x25 finalSaved)) _ _ + refine WP.mono (Spill.restore_wp h.x25 saved_fits (by decide) (fun p hp' => ?_) hs) + fun s' r => ⟨fun q hq => r.gpr_of ?_, r.mem⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + · simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hq + rcases hq with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl + all_goals first + | exact .inl (by decide) + | exact .inr (h.kept _ (by simp)) + +/-! ## The whole function -/ + +theorem final_wp (v : Ctr32Impl) {s₀ : State} (hp : CPre s₀) : + WP isa (cryptFinal v.callee v.suffix) s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (final_setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp v hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (final_mid_wp v hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (final_end_wp hp h₃) fun _ ⟨g, m⟩ => ⟨g, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalAArch64.post s₀ s' := by + show Spec.Ctr.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_keepsV (v : Ctr32Impl) : (cryptFinal v.callee v.suffix).allInstrs keepsV = true := by + simp only [cryptFinal, final, finalTail, Code.allInstrs, crypt_keepsV v, Bool.true_and] + decide + +theorem final_correct (v : Ctr32Impl) (s : State) (hs : ctrFinalAArch64.pre s) : + ∃ t s', Exec isa (cryptFinal v.callee v.suffix) s t s' ∧ abiPreserved s s' ∧ ctrFinalAArch64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp v (CPre.of hs) + exact ⟨t, s', he, ⟨hg, AArch64.Exec.sp he, Exec.preservedV he (final_keepsV v)⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +/-- Counter blocks whose last 32 bits agree still do after `k` increments. -/ +theorem lo32_next_of {t t' : List Byte} (ht : t.length = 16) (ht' : t'.length = 16) + (h : AesCtr.lo32 t = AesCtr.lo32 t') (k : Nat) : + AesCtr.lo32 (Spec.Ctr.next t k) = AesCtr.lo32 (Spec.Ctr.next t' k) := by + rw [AesCtr.lo32_next ht, AesCtr.lo32_next ht'] + unfold AesCtr.lo32 at h + omega + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.x0, .x1, .x2, .x3, .x4, .x5, .x6]) + (.block finalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.x19, .x20, .x21, .x24, .x25]) + (.block tailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.x25, .x22, .x23]) + (.seq (.block tailKey) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.x25]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel (v : Ctr32Impl) {s₀ s₀' : State} (h0 : ctrFinalAArch64.pre s₀) (h0' : ctrFinalAArch64.pre s₀') + (hq : ctrFinalAArch64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') (cryptFinal v.callee v.suffix) fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + obtain ⟨⟨qW, qR, qIv, qD, qL, qS, qV, qSp⟩, qLk⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + have qLo : AesCtr.lo32 (fIv0 s₀) = AesCtr.lo32 (fIv0 s₀') := + AesCtr.lo32_of_leak (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLk + -- The registers saved and the arguments set up. + have r₁ := taint_rel (P := fun a b => a = s₀ ∧ b = s₀') (F₁ := Setup s₀) (F₂ := Setup s₀') + [.x0, .x1, .x2, .x3, .x4, .x5, .x6] setup_taint + (fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact qSp) + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr" ++ v.suffix) (crypt_correct v) (crypt_ct v) + (P := fun a b => Setup s₀ a ∧ Setup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb⟩ + · simp only [modeAArch64, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_x0, callEntry_x1, callEntry_x2, callEntry_x3, callEntry_x4, callEntry_x5, + ha.x0, ha.x1, ha.x2, ha.x3, ha.x4, ha.x5, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.x4, hb.x5, hb.sp] + rw [fW, fW, fIv, fIv, fD, fD, fS, fS, qW, qR, qIv, qD, qS, qSp, qN] + exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩ + · simp only [AesCbc.AArch64.iv0, AesCbc.AArch64.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_mem, callEntry_x2, ha.x2, hb.x2, ha.mem, hb.mem] + rw [(sv_bytes hp).2.1, (sv_bytes hp').2.1] + exact qLo).wp + (F₁ := Whole AesCtr.ctrMode s₀) (F₂ := Whole AesCtr.ctrMode s₀') + fun a b h => ⟨whole_wp v hp h.1, whole_wp v hp' h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (finalTail ("vg_aes_ctr" ++ v.suffix) (crypt v.callee)) fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := taint_rel (P := fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (F₁ := TArgs s₀) (F₂ := TArgs s₀') [.x19, .x20, .x21, .x24, .x25] tailArgs_taint + (fun a b h => by rw [h.1.sp, h.2.sp, qSp]) + (fun a b h r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · rw [h.1.x19, h.2.x19, fW, fW, qW] + · rw [h.1.x20, h.2.x20, qR] + · rw [h.1.x21, h.2.x21, fIv, fIv, qIv] + · rw [h.1.x24, h.2.x24, fS, fS, qS] + · rw [h.1.x25, h.2.x25, fV, fV, qV]) + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩ + have a₂ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr" ++ v.suffix) (crypt_correct v) (crypt_ct v) + (P := fun a b => TArgs s₀ a ∧ TArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb⟩ + · simp only [modeAArch64, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_x0, callEntry_x1, callEntry_x2, callEntry_x3, callEntry_x4, callEntry_x5, + ha.x0, ha.x1, ha.x2, ha.x3, ha.x4, ha.x5, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.x4, hb.x5, hb.sp] + rw [fW, fW, fIv, fIv, cBk, cBk, fV, fV, fS, fS, qW, qR, qIv, qV, qS, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial + · simp only [AesCbc.AArch64.iv0, AesCbc.AArch64.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_mem, callEntry_x2, ha.x2, hb.x2] + rw [ha.ctr, hb.ctr, qN] + exact lo32_next_of (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLo _).wp + (F₁ := TCall s₀) (F₂ := TCall s₀') fun a b h => ⟨tail_call_wp v hp h.1, tail_call_wp v hp' h.2⟩ + have a₃ := taint_rel (P := fun a b => TCall s₀ a ∧ TCall s₀' b) + (F₁ := Done s₀) (F₂ := Done s₀') [.x25, .x22, .x23] xor_taint + (fun a b h => by rw [h.1.sp, h.2.sp, qSp]) + (fun a b h r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.x25, h.2.x25, fV, fV, qV] + · rw [h.1.x22, h.2.x22, qT] + · rw [h.1.x23, h.2.x23, qU]) + fun a b h => ⟨tail_xor_wp hp h.1 hu, tail_xor_wp hp' h.2 hu'⟩ + exact a₁.seq ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq a₃) + have r₃ : RelCT isa (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (.ite (.zero .x .x23) (.block []) (finalTail ("vg_aes_ctr" ++ v.suffix) (crypt v.callee))) + (fun a b => Done s₀ a ∧ Done s₀' b) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1] at this; simpa using this + exact ⟨done_of_zero h.1.1 h0, done_of_zero h.1.2 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1, h.1.2⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1] at this; simpa using this + have r₃' := r₃.wp (F₁ := fun (s : State) => s.sp = s₀.sp) (F₂ := fun (s : State) => s.sp = s₀'.sp) + fun a b h => + ⟨WP.mono (WP.sp_eq (final_mid_wp v hp h.1)) fun _ x => x.2.trans h.1.sp, + WP.mono (WP.sp_eq (final_mid_wp v hp' h.2)) fun _ x => x.2.trans h.2.sp⟩ + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := RelCT.taint (A := taint) (P := fun a b => (Done s₀ a ∧ Done s₀' b) ∧ + a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ + (fun a b h => agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.x25, h.1.2.x25, fV, fV, qV]) t₅ + exact r₁.seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₃'.seq r₄)) + +theorem final_ct (v : Ctr32Impl) : + ConstantTime isa ctrFinalAArch64.pre ctrFinalAArch64.pub (cryptFinal v.callee v.suffix) := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel v h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem cryptFinal_verified (v : Ctr32Impl) : + Verified AArch64.target (cryptFinal v.callee v.suffix) finalScratchContract := + Verified.of_correct (final_correct v) (final_ct v) final_implies + +/-! ## With `save` on the stack + +The final function has six argument words, so `save` is its seventh, in +`x6`: it runs its code in a frame of 80 bytes on the stack +(`withStackScratchWiped`), `save`'s 80 bytes (the registers, then the block +that held the last output block), which it zeroes before returning. The +code's calls use no stack, so 80 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract AArch64.abi 80).pre s := by + implies_sat [finalRoundsContract, Spec.Ctr.aesFinalSig, finalPre, finalPost, AArch64.abi, + AArch64.argRegs] [finalFrameSat, finalSat] using finalFrameSat + +theorem cryptFinal_framed (v : Ctr32Impl) : + Verified AArch64.target + (Impl.StackScratch.AArch64.withStackScratchWiped 80 .x6 10 (cryptFinal v.callee v.suffix)) + (finalRoundsContract AArch64.abi 80) := + AArch64.Verified.stackScratchWiped (sig := Spec.Ctr.aesFinalSig) (nm := "save") (e := .u64) (n := 10) + (pre := finalPre AArch64.abi.ptrBits) (post := finalPost AArch64.abi.ptrBits) (wa := false) + (leak := some (finalLeak AArch64.abi.ptrBits)) + (stack := 0) (bytes := 80) (words := 10) (cryptFinal_verified v) (by decide) (by decide) (by decide) + (finalPost_localOut _) frameSat_pre + +end VG.Proof.AesCtr.AArch64.Final diff --git a/lean/VerifiedGarbage/Proof/AesOfb/AArch64/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/AArch64/Final.lean new file mode 100644 index 00000000000..fdc109fec5e --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/AArch64/Final.lean @@ -0,0 +1,122 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.AArch64.Final +public import VerifiedGarbage.Proof.AesOfb.Final +public import VerifiedGarbage.Proof.AesOfb.AArch64.Verified +public import VerifiedGarbage.Proof.AesCfb.AArch64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.AArch64 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.AArch64.Exec +import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +import VerifiedGarbage.Proof.AesOfb.AArch64.Body +import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.AArch64.CT + +/-! +# AES-OFB of a message's last piece on AArch64 + +`cryptFinal_framed`: `vg_aes_ofb_final` (`Impl/AesOfb/AArch64/Final.lean`), for +any implementation `v` of the block functions (`BlocksImpl`), meets +`Proof.AesOfb.finalRoundsContract`, from which the shared contract follows +(`Proof.AesOfb.final_keyed`). + +Its code is AES-CFB's final function around a call of the whole-block +AES-OFB function, so its proof is AES-CFB's (`Proof/AesCfb/AArch64/Final.lean`), +for OFB as a `Mode` (`ofbMode`): `final_wp` runs it, for any mode, to what it +leaves before restoring the registers (`Done`); `final_rel` gives its +constant time. `ofbFinalAArch64` is AES-CFB's code contract with OFB's +postcondition, which `final_post` gives from `Done` by +`Proof.AesOfb.cryptFinal_of`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb.AArch64 + +open VG VG.AArch64 +open VG.Spec.Aes (bytesAt) +open VG.Proof.AesCfb.AArch64.Final (finalAArch64 FPre Done fW fR fIv fD fL fN fU fT fWk fIv0 fBlks final_wp + final_ct final_keepsV finalSat finalFrameSat) +open VG.Proof.AesCbc.AArch64 (modeAArch64) +open VG.Proof.Aes.AArch64 (BlocksImpl) +open VG.Impl.AesOfb.AArch64 +open VG.Impl.AesCfb.AArch64 (final finalTail) + +/-- The code's contract, with the arguments `(schedule = x0, rounds = x1, +iv = x2, data = x3, len = x4, scratch = x5, save = x6)`: AES-CFB's final +functions' (`finalAArch64`), with the data and the block at `iv` as +`Spec.Ofb.CryptFinal` says, by AES with the key schedule it is given. -/ +def ofbFinalAArch64 : Contract isa := + { finalAArch64 true with + post := fun s s' => Spec.Ofb.CryptFinal (ciphAt s.mem (s.gpr .x0) (s.gpr .x1).toNat) 16 s.mem s'.mem + (s.gpr .x2) (s.gpr .x3) (s.gpr .x4).toNat } + +/-- The contract the frame needs: the shared one, with `save`, 64 bytes, as +a seventh argument, and no stack (a call keeps its return address in +`x30`). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract AArch64.abi Spec.Ofb.aesFinalSig "save" .u64 8 (finalPre AArch64.abi.ptrBits) + (finalPost AArch64.abi.ptrBits) false 0 + +theorem final_implies : ofbFinalAArch64.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, ofbFinalAArch64, finalAArch64, AArch64.abi, + AArch64.argRegs] [finalSat] using finalSat + +/-- `Spec.Ofb.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done ofbMode s₀ s₁) (hm : s'.mem = s₁.mem) : + ofbFinalAArch64.post s₀ s' := by + show Spec.Ofb.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) 16 s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + have e := AesCbc.length_blocksAt s₀.mem (fD s₀) (fN s₀) + have hb := h.blocks + have ht := h.tail + have hi := h.iv + rw [ofbMode_out] at hb + rw [ofbMode_chain, e] at ht hi + exact cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact hb) (fun q hq => by rw [hm]; exact ht q hq) + (by rw [hm]; exact hi) + +/-! ## The code's properties -/ + +theorem crypt_noFrames (v : BlocksImpl) : (crypt v.enc).noFrames = true := by + simp only [crypt, Impl.AesCbc.AArch64.whole, body, Code.noFrames, v.encNoFrames, Bool.and_self] + +theorem final_correct (v : BlocksImpl) (s : State) (hs : ofbFinalAArch64.pre s) : + ∃ t s', Exec isa (cryptFinal v.enc v.suffix) s t s' ∧ abiPreserved s s' ∧ ofbFinalAArch64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := + final_wp (M := ofbMode) (crypt_correct v) (crypt_noFrames v) v (FPre.of (enc := true) hs) + exact ⟨t, s', he, ⟨hg, AArch64.Exec.sp he, Exec.preservedV he (final_keepsV v (crypt_keepsV v))⟩, + final_post h₁ hm⟩ + +/-! ## Verified -/ + +theorem cryptFinal_verified (v : BlocksImpl) : + Verified AArch64.target (cryptFinal v.enc v.suffix) finalScratchContract := + Verified.of_correct (final_correct v) + (final_ct (enc := true) (crypt_correct v) (AesCbc.AArch64.whole_ct (body_ok v) (body_ct v)) + (crypt_noFrames v) v) + final_implies + +/-! ## With `save` on the stack + +As AES-CFB's final functions, the code runs in a frame of 64 bytes on the +stack (`withStackScratchWiped`), `save`'s 64 bytes, which it zeroes before +returning. Its calls use no stack, so 64 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract AArch64.abi 64).pre s := by + implies_sat [finalRoundsContract, Spec.Ofb.aesFinalSig, finalPre, finalPost, AArch64.abi, + AArch64.argRegs] [finalFrameSat, finalSat] using finalFrameSat + +theorem cryptFinal_framed (v : BlocksImpl) : + Verified AArch64.target + (Impl.StackScratch.AArch64.withStackScratchWiped 64 .x6 8 (cryptFinal v.enc v.suffix)) + (finalRoundsContract AArch64.abi 64) := + AArch64.Verified.stackScratchWiped (sig := Spec.Ofb.aesFinalSig) (nm := "save") (e := .u64) (n := 8) + (pre := finalPre AArch64.abi.ptrBits) (post := finalPost AArch64.abi.ptrBits) (wa := false) + (stack := 0) (bytes := 64) (words := 8) (cryptFinal_verified v) (by decide) (by decide) (by decide) + (finalPost_localOut _) frameSat_pre + +end VG.Proof.AesOfb.AArch64 diff --git a/lean/VerifiedGarbage/Proof/Camellia/AArch64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/AArch64/CtrFinal.lean new file mode 100644 index 00000000000..f0b198a9384 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/AArch64/CtrFinal.lean @@ -0,0 +1,966 @@ +module + +public import VerifiedGarbage.Impl.Camellia.AArch64.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrScratch +public import VerifiedGarbage.Proof.Camellia.AArch64.CtrVerified +public import VerifiedGarbage.Proof.AesCfb.AArch64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.AArch64.Spill +public import VerifiedGarbage.Impl.StackScratch.AArch64 +import VerifiedGarbage.Proof.AesCtr.AArch64.Final +import VerifiedGarbage.Proof.AesCtr.AArch64.CT +import VerifiedGarbage.Proof.Camellia.AArch64.Lit +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.AArch64.FbFinal +import VerifiedGarbage.Proof.Modes.AArch64.Steps +import VerifiedGarbage.Proof.Modes.AArch64.Xor +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCbc.AArch64.Block +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.AArch64.Call +import VerifiedGarbage.Proof.Framework.AArch64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.AArch64.RegUpd +import VerifiedGarbage.Proof.Framework.AArch64.Exec +import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +import VerifiedGarbage.Proof.Framework.AArch64.Taint +import VerifiedGarbage.Proof.Framework.AArch64.Lit +import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.Camellia.AArch64.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrScratch +meta import VerifiedGarbage.Proof.Camellia.AArch64.CtrVerified +meta import VerifiedGarbage.Proof.AesCfb.AArch64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.AArch64.Spill +meta import VerifiedGarbage.Impl.StackScratch.AArch64 +meta import VerifiedGarbage.Proof.AesCtr.AArch64.Final +meta import VerifiedGarbage.Proof.AesCtr.AArch64.CT +meta import VerifiedGarbage.Proof.Camellia.AArch64.Lit +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.AArch64.FbFinal +meta import VerifiedGarbage.Proof.Modes.AArch64.Steps +meta import VerifiedGarbage.Proof.Modes.AArch64.Xor +import VerifiedGarbage.Proof.Modes.AArch64.Xor +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCbc.AArch64.Block +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.AArch64.Call +meta import VerifiedGarbage.Proof.Framework.AArch64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.AArch64.RegUpd +meta import VerifiedGarbage.Proof.Framework.AArch64.Exec +meta import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +meta import VerifiedGarbage.Proof.Framework.AArch64.Taint +meta import VerifiedGarbage.Proof.Framework.AArch64.Lit +meta import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# Camellia-CTR of a message's last piece on AArch64 + +`ctrFinal_framed`: `vg_camellia_ctr_final` (`Impl/Camellia/AArch64/CtrFinal.lean`) meets +`Spec.Camellia.ctrFinalContract`, from `Proof.Camellia.ctrFinalContractSk` +(`Proof.Camellia.ctrFinal_of_sk`). + +The code is proven against `ctrFinalAArch64`, with the arguments +`(schedule = x0, rounds = x1, ctr = x2, data = x3, len = x4, save = x5)`, a sixth argument `save` (`x5`) of 80 bytes for its caller's registers and +return address and a block of its own, and 3344 bytes of stack for its +calls (`ctrFinal_implies`: the shared contract with it), as a caller of +`vg_camellia_ctr`, framed by its own working space on the stack (`ctrFramed`), +through a contract of its own, `ctrF`, which the callee's shared contract +implies (`ctrF_implies`), with `WP.callF` (the callee's frames lie within the +stack, `ctr_depth`). It is AES-CTR's final function's proof +(`Proof/AesCtr/AArch64/Final.lean`) with Camellia's arguments: + +* `setup_wp`, `whole_wp`: the registers saved in `save`, whose address is + kept in `x25`, and the call on the `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.AArch64.xorLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`), by Camellia with the subkeys at `schedule`. + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Camellia.AArch64.CtrFinal + +open VG VG.AArch64 +open VG.Spec.Aes (bytesAt) +open VG.AArch64.RegUpd +open VG.Impl.Camellia.AArch64 (ctrFramed ctrFinalSave ctrFinalMoves ctrFinalSetup ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.AArch64 (finalSaved finalRestore) +open VG.Impl.AesCtr.AArch64 (zeroSlots tailKey) + +/-! ## The callee -/ + +/-- `vg_camellia_ctr(schedule = x0, rounds = x1, ctr = x2, data = x3, n = x4)` +with its 3344 bytes of stack. -/ +def ctrF : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .x0, 272⟩ + let ctr : Region := ⟨s.gpr .x2, 16⟩ + let data : Region := ⟨s.gpr .x3, 16 * (s.gpr .x4).toNat⟩ + 3344 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data] ∧ sched.Disjoint ctr ∧ sched.Disjoint data ∧ + ctr.Disjoint data ∧ (below s.sp 3344).Disjoint sched ∧ (below s.sp 3344).Disjoint ctr ∧ + (below s.sp 3344).Disjoint data ∧ + (s.gpr .x0).toNat + 272 ≤ 2 ^ 64 ∧ (s.gpr .x2).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .x3).toNat + 16 * (s.gpr .x4).toNat ≤ 2 ^ 64 ∧ + ((s.gpr .x1).toNat = 18 ∨ (s.gpr .x1).toNat = 24) + post s s' := + Spec.Cbc.blocksAt s'.mem (s.gpr .x3) (s.gpr .x4).toNat = + Spec.Ctr.crypt (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (s.gpr .x0) (s.gpr .x1).toNat)) + (bytesAt s.mem (s.gpr .x2) 16) (Spec.Cbc.blocksAt s.mem (s.gpr .x3) (s.gpr .x4).toNat) ∧ + bytesAt s'.mem (s.gpr .x2) 16 = Spec.Ctr.next (bytesAt s.mem (s.gpr .x2) 16) (s.gpr .x4).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .x0 = s₂.gpr .x0 ∧ s₁.gpr .x1 = s₂.gpr .x1 ∧ s₁.gpr .x2 = s₂.gpr .x2 ∧ + s₁.gpr .x3 = s₂.gpr .x3 ∧ s₁.gpr .x4 = s₂.gpr .x4 + +/-- `vg_camellia_ctr` meets its contract on the subkeys. -/ +theorem ctrFramed_sk : Verified AArch64.target ctrFramed (Proof.Camellia.ctrContractSk AArch64.abi 3344) := + AArch64.Verified.stackScratchWiped (sig := Spec.Camellia.ctrSig) (nm := "scratch") (e := .u64) + (n := 418) (pre := Spec.Camellia.ctrPre AArch64.abi.ptrBits) + (post := Proof.Camellia.ctrPostSk AArch64.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 3344) (by rw [← Proof.Camellia.ctrScratchContract_eq]; exact Camellia.AArch64.ctr_verified) + (by decide) (by decide) (by decide) (Proof.Camellia.ctrPostOut_local _) Camellia.AArch64.ctrFrameSat_pre + +theorem ctrF_implies : (Proof.Camellia.ctrContractSk AArch64.abi 3344).Implies ctrF where + pre s hs := by + sig_pre [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Spec.Camellia.ctrPre, AArch64.abi, + AArch64.argRegs] + simp only [Nat.mul_comm (s.gpr .x4).toNat 16] + exact hs + post s s' hs h := by + sig_reduce [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Proof.Camellia.ctrPostSk, AArch64.abi, + AArch64.argRegs] at h + simp only [BitVec.setWidth_eq] at h + exact h hs.2.2.2.2.2.2.2.2.2.2.2.2 + pub s₁ s₂ _ _ h := by + sig_reduce [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, AArch64.abi, AArch64.argRegs] + obtain ⟨hsp, h0, h1, h2, h3, h4⟩ := h + exact ⟨hsp, fun _ _ => by rw [h0, h1, h2, h3, h4], fun _ hr => absurd hr List.not_mem_nil⟩ + sat := ⟨Camellia.AArch64.ctrFrameSat, by + refine ⟨by decide, rfl, rfl, Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), by decide, by decide, by decide, by decide⟩⟩ + +theorem ctr_depth : 16 * ctrFramed.aarch64Depth ≤ 3344 := by lit_decide + +theorem ctr_ok : ∀ s, ctrF.pre s → ∃ t s', Exec isa ctrFramed s t s' ∧ abiPreserved s s' ∧ ctrF.post s s' := + (ctrFramed_sk.of_implies ctrF_implies).1 + +theorem ctr_ct : ConstantTime isa ctrF.pre ctrF.pub ctrFramed := + (ctrFramed_sk.of_implies ctrF_implies).2.1 + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = x0, rounds = x1, +ctr = x2, data = x3, len = x4, save = x5)`, `save` of 80 bytes, and 3344 +bytes of stack for the calls: the data and the counter block as +`Spec.Ctr.CryptFinal` says, by Camellia with the subkeys at `schedule`. -/ +def ctrFinalAArch64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .x0, 272⟩ + let ctr : Region := ⟨s.gpr .x2, 16⟩ + let data : Region := ⟨s.gpr .x3, (s.gpr .x4).toNat⟩ + let sv : Region := ⟨s.gpr .x5, 80⟩ + let stack := below s.sp 3344 + 3344 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .x0).toNat + 272 ≤ 2 ^ 64 ∧ (s.gpr .x2).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .x3).toNat + (s.gpr .x4).toNat ≤ 2 ^ 64 ∧ (s.gpr .x5).toNat + 80 ≤ 2 ^ 64 ∧ + ((s.gpr .x1).toNat = 18 ∨ (s.gpr .x1).toNat = 24) + post s s' := + Spec.Ctr.CryptFinal (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (s.gpr .x0) (s.gpr .x1).toNat)) + s.mem s'.mem (s.gpr .x2) (s.gpr .x3) (s.gpr .x4).toNat + pub s₁ s₂ := + s₁.gpr .x0 = s₂.gpr .x0 ∧ s₁.gpr .x1 = s₂.gpr .x1 ∧ s₁.gpr .x2 = s₂.gpr .x2 ∧ + s₁.gpr .x3 = s₂.gpr .x3 ∧ s₁.gpr .x4 = s₂.gpr .x4 ∧ s₁.gpr .x5 = s₂.gpr .x5 ∧ s₁.sp = s₂.sp + +/-- The contract the frame needs: the shared one on the subkeys, with `save`, +80 bytes, as a sixth argument, and 3344 bytes of stack (`vg_camellia_ctr`'s +frame). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract AArch64.abi Spec.Camellia.ctrFinalSig "save" .u64 10 + (Spec.Camellia.ctrFinalPre AArch64.abi.ptrBits) (Proof.Camellia.ctrFinalPostSk AArch64.abi.ptrBits) true 3344 + +/-- A state satisfying the precondition (no data, 18 rounds). -/ +def ctrFinalSat : State where + gpr r := match r with + | .x0 => 0x1000 | .x1 => 18 | .x2 => 0x2000 | .x3 => 0x3000 | .x5 => 0x4000 | _ => 0 + sp := 0x8000 + mem _ := 0 + rd := [⟨0x1000, 272⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 80⟩] + +theorem ctrFinal_implies : ctrFinalAArch64.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, Proof.Camellia.ctrFinalPostSk, ctrFinalAArch64, + AArch64.abi, AArch64.argRegs] [ctrFinalSat] using ctrFinalSat + +/-! ## The arguments, by name -/ + +open VG.Proof.AesCfb.AArch64.Final (fW fR fIv fD fL fN fU fT fData fBlk fTail fIv0 fBlks Kept cs_of + bytesAt_getD blocksAt_frame' saved_slots saved_fits blk_sub tail_sub fN_eq fU_eq n_lt u_lt toNat_n agree_of + WP.sp_eq shr4 shr4_shl4 sub_shl4) +open VG.Proof.AesCtr.AArch64.Final (zero_bytes zero_ok one_toNat lo32_next_of) + +section +variable (s₀ : State) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .x5 +abbrev kSch : Region := ⟨fW s₀, 272⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 80⟩ +abbrev kSv64 : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 64 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below s₀.sp 3344 +/-- The memory once the registers are saved. -/ +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) s₀.gpr finalSaved +/-- The cipher on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Camellia.cipher (Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀)) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp : 3344 ≤ s₀.sp.toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 272 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 80 ≤ 2 ^ 64 + rounds : fR s₀ = 18 ∨ fR s₀ = 24 + +theorem KPre.of {s₀ : State} (h : ctrFinalAArch64.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ + +/-! ## Regions and frames -/ + +theorem sv64_sub (s₀ : State) : Region.Sub (kSv64 s₀) (kSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +end + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + (Spill.saveMem_frame_base (n := 64) (by decide) (by decide) _ _ _).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨kSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem KPre.sch_big {s₀ : State} (hp : KPre s₀) : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The subkeys, from memory that agrees with the entry's on the schedule. -/ +theorem subkeys_of {s₀ : State} (hp : KPre s₀) {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : + Spec.Camellia.subkeysAt m (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt m₀ (fW s₀) (fR s₀) := + Proof.Camellia.subkeysAt_congr (by rcases hp.rounds with h | h <;> rw [h] <;> decide) + fun i hi => hf.bytes (R := kSch s₀) hd (by show 272 ≤ 2 ^ 64; decide) hi + +/-- The stack a call of `vg_camellia_ctr` uses lies within the stack. -/ +theorem stk_sub (s₀ : State) : Region.Sub (below s₀.sp (16 * ctrFramed.aarch64Depth)) (kStk s₀) := + fun x hx => Offset.below_mono s₀.sp ctr_depth (by decide) x hx + +/-! ## Saving the registers -/ + +theorem moves_ok (s : State) : + ∃ s', runBlock isa ctrFinalMoves s = some s' ∧ + s'.gpr .x19 = s.gpr .x0 ∧ s'.gpr .x20 = s.gpr .x1 ∧ s'.gpr .x21 = s.gpr .x2 ∧ s'.gpr .x25 = s.gpr .x5 ∧ + s'.gpr .x22 = s.gpr .x3 + (s.gpr .x4 >>> 4 <<< 4) ∧ s'.gpr .x23 = s.gpr .x4 - (s.gpr .x4 >>> 4 <<< 4) ∧ + s'.gpr .x4 = s.gpr .x4 >>> 4 ∧ + (∀ r, r ≠ .x19 → r ≠ .x20 → r ≠ .x21 → r ≠ .x22 → r ≠ .x23 → r ≠ .x25 → r ≠ .x4 → + r ≠ .x9 → r ≠ .x10 → s'.gpr r = s.gpr r) ∧ + s'.sp = s.sp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by crun [ctrFinalMoves, Impl.AesCbc.AArch64.mov], ?_⟩ + refine ⟨by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], + by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], + fun r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ h₉ => ?_, rfl, rfl, rfl, rfl⟩ + simp [gpr_write, h₁, h₂, h₃, h₄, h₅, h₆, h₇, h₈, h₉] + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + x19 : s.gpr .x19 = fW s₀ + x20 : s.gpr .x20 = s₀.gpr .x1 + x21 : s.gpr .x21 = fIv s₀ + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + x0 : s.gpr .x0 = fW s₀ + x1 : s.gpr .x1 = s₀.gpr .x1 + x2 : s.gpr .x2 = fIv s₀ + x3 : s.gpr .x3 = fD s₀ + x4 : s.gpr .x4 = BitVec.ofNat 64 (fN s₀) + kept : Kept s₀ s + sp : s.sp = s₀.sp + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (KSetup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions s₀.wr (s₀.gpr .x5 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .x5 finalSaved ++ ctrFinalMoves)) _ _ + refine Spill.save_ok saved_fits hw ?_ + refine WP.mono (WP.of_runBlock (moves_ok _)) + fun s' ⟨x19, x20, x21, x25, x22, x23, x4, keep, sp, mem, rd, wr⟩ => ?_ + have k (r : Reg) (h₁ : r ≠ .x19) (h₂ : r ≠ .x20) (h₃ : r ≠ .x21) (h₄ : r ≠ .x22) (h₅ : r ≠ .x23) + (h₆ : r ≠ .x25) (h₇ : r ≠ .x4) (h₈ : r ≠ .x9) (h₉ : r ≠ .x10) : + s'.gpr r = s₀.gpr r := keep r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ h₉ + exact ⟨x19, x20, x21, by rw [x22, shr4_shl4], by rw [x23, shr4_shl4, sub_shl4], x25, + k .x0 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide), + k .x1 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide), + k .x2 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide), + k .x3 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide), + by rw [x4, shr4], + fun r hr => by + rcases hr with rfl | rfl | rfl <;> + exact k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide), + sp, mem, rd, wr⟩ + +/-! ## The whole blocks -/ + +theorem whole_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, AesCbc.AArch64.callEntry_x4, h.x0, h.x1, h.x2, h.x3, h.x4, h.sp, toNat_n] + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), + hp.iv_data.sub_right (blk_sub s₀), hp.stk_sch, hp.stk_iv, hp.stk_data.sub_right (blk_sub s₀), + hp.sch_wrap, hp.iv_wrap, hp.blk_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The subkeys, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : KPre s₀) : + Spec.Camellia.subkeysAt (kSvMem s₀) (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀) ∧ + bytesAt (kSvMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ Spec.Cbc.blocksAt (kSvMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame s₀ + exact ⟨subkeys_of hp ef (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv), + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + x19 : s.gpr .x19 = fW s₀ + x20 : s.gpr .x20 = s₀.gpr .x1 + x21 : s.gpr .x21 = fIv s₀ + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +/-- A call's frame, within the regions it was given and the stack. -/ +theorem call_frame {s₀ s s' : State} (hsp : s.sp = s₀.sp) {wr : List Region} + (hf : Frame (wr ++ [below s.sp (16 * ctrFramed.aarch64Depth)]) s.mem s'.mem) : + Frame (wr ++ [kStk s₀]) s.mem s'.mem := + hf.sub fun r hr => by + rcases List.mem_append.mp hr with h | h + · exact ⟨r, List.mem_append_left _ h, fun _ h => h⟩ + · simp only [List.mem_singleton] at h; subst h + exact ⟨kStk s₀, by simp, by rw [hsp]; exact stk_sub s₀⟩ + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + WP isa (.call "vg_camellia_ctr" ctrFramed) s (KWhole s₀) := by + obtain ⟨eK, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.callF (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, fBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + rw [h.mem] at fr + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, AesCbc.AArch64.callEntry_x4, h.x0, h.x1, h.x2, h.x3, h.x4, + toNat_n, h.mem] at post₂ + have hR : (s₀.gpr .x1).toNat = fR s₀ := rfl + rw [hR, eK, eIv, eB] at post₂ + exact ⟨by rw [cs_of cs' .x19 (by simp), h.x19], by rw [cs_of cs' .x20 (by simp), h.x20], + by rw [cs_of cs' .x21 (by simp), h.x21], by rw [cs_of cs' .x22 (by simp), h.x22], + by rw [cs_of cs' .x23 (by simp), h.x23], by rw [cs_of cs' .x25 (by simp), h.x25], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], + fr.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h], + post₂.1, post₂.2⟩ + +/-! ## The partial last block -/ + +theorem eval_u {s₀ s : State} (h : KWhole s₀ s) : + isa.eval (.zero .x .x23) s = some (decide (fU s₀ = 0)) := by + rw [Proof.Modes.AArch64.eval_zero, h.x23, Proof.Modes.AArch64.ofNat_beq_zero (by have := u_lt s₀; omega)] + +theorem tailMoves_ok (s : State) : + ∃ s', runBlock isa ctrFinalTailMoves s = some s' ∧ + s'.gpr .x0 = s.gpr .x19 ∧ s'.gpr .x1 = s.gpr .x20 ∧ s'.gpr .x2 = s.gpr .x21 ∧ + s'.gpr .x3 = s.gpr .x25 + BitVec.ofNat 64 64 ∧ s'.gpr .x4 = 1 ∧ + (∀ r ∈ preserved, s'.gpr r = s.gpr r) ∧ + s'.sp = s.sp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by crun [ctrFinalTailMoves], ?_⟩ + refine ⟨by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], + fun r hr => ?_, rfl, rfl, rfl, rfl⟩ + simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp [gpr_write] + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KArgs (s₀ s : State) : Prop where + x0 : s.gpr .x0 = fW s₀ + x1 : s.gpr .x1 = s₀.gpr .x1 + x2 : s.gpr .x2 = fIv s₀ + x3 : s.gpr .x3 = kBk s₀ + x4 : s.gpr .x4 = 1 + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (KArgs s₀) := by + obtain ⟨s₁, r₁, z₁, k₁, sp₁, m₁, rd₁, wr₁⟩ := zero_ok s + show WP isa (.block ([.movz .x .x9 0 0] ++ (Spill.saveCode .x25 zeroSlots ++ ctrFinalTailMoves))) _ _ + refine WP.block_append_iff.mpr (WP.of_runBlock ⟨s₁, r₁, ?_⟩) + have h25 : s₁.gpr .x25 = kV s₀ := by rw [k₁ _ (by decide), h.x25] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .x25 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [wr₁, h.wr, hp.wr, h25] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + refine Spill.save_ok (by decide) hw ?_ + refine WP.mono (WP.of_runBlock (tailMoves_ok _)) + fun s' ⟨x0, x1, x2, x3, x4, cs, sp, mem, rd, wr⟩ => ?_ + have c (r : Reg) (hr : r = .x19 ∨ r = .x20 ∨ r = .x21 ∨ r = .x22 ∨ r = .x23 ∨ r = .x24 ∨ r = .x25 ∨ + r = .x26 ∨ r = .x27 ∨ r = .x28) : s'.gpr r = s.gpr r := by + rw [cs r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide)] + exact k₁ r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + have hm : s'.mem = Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₁.mem _ _ _ = _; rw [m₁, h25] + have fz : Frame [kBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + refine ⟨by rw [x0]; exact (k₁ _ (by decide)).trans h.x19, by rw [x1]; exact (k₁ _ (by decide)).trans h.x20, + by rw [x2]; exact (k₁ _ (by decide)).trans h.x21, by rw [x3, h25], x4, + by rw [c .x22 (by simp), h.x22], by rw [c .x23 (by simp), h.x23], by rw [c .x25 (by simp), h.x25], + fun r hr => by rw [c r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp, show ({ s₁ with mem := _ } : State).sp = s₁.sp from rfl, sp₁, h.sp], + by rw [rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, rd₁, h.rd], + by rw [wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, wr₁, h.wr], ?_, ?_, ?_, ?_⟩ + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.ctr] + · rw [hm, show Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₁.gpr .x9)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .x9)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z₁] + exact zero_bytes _ _ + +theorem tail_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, kBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, kBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, kBlk s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, AesCbc.AArch64.callEntry_x4, h.x0, h.x1, h.x2, h.x3, h.x4, h.sp, one_toNat, + Nat.mul_one] + have := hp.sv_wrap + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.iv_sv.sub_right bs, hp.stk_sch, + hp.stk_iv, hp.stk_sv.sub_right bs, hp.sch_wrap, hp.iv_wrap, by rw [hp.bk_toNat]; omega, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure KCall (s₀ s : State) : Prop where + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by + simp [Spec.Camellia.cipher] + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + WP isa (.call "vg_camellia_ctr" ctrFramed) s (KCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (kW1_kW h.frame) + have eK := subkeys_of hp big hp.sch_big + refine WP.callF (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, kBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, AesCbc.AArch64.callEntry_x4, h.x0, h.x1, h.x2, h.x3, h.x4, + one_toNat, h.ctr] at post₂ + have hR : (s₀.gpr .x1).toNat = fR s₀ := rfl + rw [hR, eK] at post₂ + have fc : Frame (kW1 s₀) s.mem s'.mem := fr.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs_of cs' .x22 (by simp), h.x22], by rw [cs_of cs' .x23 (by simp), h.x23], + by rw [cs_of cs' .x25 (by simp), h.x25], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.x25, h.kept, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem toNat_tail {s₀ : State} (hp : KPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) s + (KDone s₀) := by + obtain ⟨s₁, run₁, x9₁, o₁, mem₁, rd₁, wr₁⟩ := Proof.Modes.AArch64.addImm_ok s .x9 .x25 (v := 64) (by decide) + refine WP.seq (WP.of_runBlock ⟨s₁, run₁, ?_⟩) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : Proof.Modes.AArch64.XPre s₁ (kBk s₀) (fT s₀) (fU s₀) .x22 .x23 := { + pos := by omega + small := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [rd₁, wr₁, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [wr₁, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) + dl := by decide + d9 := by decide + d6 := by decide + d7 := by decide } + have x0 : Proof.Modes.AArch64.XInv s₁ (kBk s₀) (fT s₀) (fU s₀) .x22 .x23 0 s₁ := { + x9 := by rw [x9₁, h.x25]; exact (BitVec.add_zero _).symm + dat := by rw [o₁ _ (by decide), h.x22]; exact (BitVec.add_zero _).symm + left := by rw [o₁ _ (by decide), h.x23, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Proof.Modes.AArch64.xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have g (r : Reg) (hr : r = .x25 ∨ r = .x26 ∨ r = .x27 ∨ r = .x28) : s'.gpr r = s.gpr r := by + rw [d.gpr r (by rcases hr with rfl | rfl | rfl | rfl <;> decide) (by rcases hr with rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl <;> decide) (by rcases hr with rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl <;> decide), + o₁ _ (by rcases hr with rfl | rfl | rfl | rfl <;> decide)] + refine ⟨by rw [g .x25 (by simp), h.x25], fun r hr => by rw [g r (by rcases hr with rfl | rfl | rfl <;> simp), + h.kept r hr], by rw [d.rd, rd₁, h.rd], by rw [d.wr, wr₁, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · refine kW1_kW h.frame |>.trans ?_ + rw [← mem₁] + exact d.frame.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩ + · rw [blocksAt_frame' d.frame fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, mem₁] + exact h.blocks + · rw [d.data q hq, mem₁, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame d.frame ivT (by decide), mem₁, h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.ite (.zero .x .x23) (.block []) ctrFinalTail) s (KDone s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.block finalRestore) s fun s' => (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.mem = s.mem := by + have hs : Spill.Saved (kV s₀) s₀.gpr finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (kV s₀) s₀.gpr).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .x25 finalSaved)) _ _ + refine WP.mono (Spill.restore_wp h.x25 saved_fits (by decide) (fun p hp' => ?_) hs) + fun s' r => ⟨fun q hq => r.gpr_of ?_, r.mem⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + · simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hq + rcases hq with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl + all_goals first + | exact .inl (by decide) + | exact .inr (h.kept _ (by simp)) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (end_wp hp h₃) fun _ ⟨g, m⟩ => ⟨g, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalAArch64.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem ctrFinal_keepsV : ctrFinal.allInstrs keepsV = true := by lit_decide + +theorem final_correct (s : State) (hs : ctrFinalAArch64.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalAArch64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, ⟨hg, AArch64.Exec.sp he, Exec.preservedV he ctrFinal_keepsV⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.x0, .x1, .x2, .x3, .x4, .x5]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.x19, .x20, .x21, .x25]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.x25, .x22, .x23]) + (.seq (.block tailKey) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.x25]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalAArch64.pre s₀) (h0' : ctrFinalAArch64.pre s₀') + (hq : ctrFinalAArch64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qR, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + -- The registers saved and the arguments set up. + have r₁ := AesCtr.AArch64.taint_rel (P := fun a b => a = s₀ ∧ b = s₀') (F₁ := KSetup s₀) (F₂ := KSetup s₀') + [.x0, .x1, .x2, .x3, .x4, .x5] setup_taint + (fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact qSp) + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := ctrF) (n := "vg_camellia_ctr") ctr_ok ctr_ct + (P := fun a b => KSetup s₀ a ∧ KSetup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, AesCbc.AArch64.callEntry_x4, + ha.x0, ha.x1, ha.x2, ha.x3, ha.x4, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.x4, hb.sp] + rw [fW, fW, fIv, fIv, fD, fD, qW, qR, qIv, qD, qSp, qN] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := KWhole s₀) (F₂ := KWhole s₀') fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) ctrFinalTail + fun a b => KDone s₀ a ∧ KDone s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := AesCtr.AArch64.taint_rel (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) + (F₁ := KArgs s₀) (F₂ := KArgs s₀') [.x19, .x20, .x21, .x25] tailArgs_taint + (fun a b h => by rw [h.1.sp, h.2.sp, qSp]) + (fun a b h r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · rw [h.1.x19, h.2.x19, fW, fW, qW] + · rw [h.1.x20, h.2.x20, qR] + · rw [h.1.x21, h.2.x21, fIv, fIv, qIv] + · rw [h.1.x25, h.2.x25, kV, kV, qV]) + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩ + have a₂ := (RelCT.callEx (k := ctrF) (n := "vg_camellia_ctr") ctr_ok ctr_ct + (P := fun a b => KArgs s₀ a ∧ KArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, AesCbc.AArch64.callEntry_x4, + ha.x0, ha.x1, ha.x2, ha.x3, ha.x4, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.x4, hb.sp] + rw [fW, fW, fIv, fIv, kBk, kBk, kV, kV, qW, qR, qIv, qV, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := KCall s₀) (F₂ := KCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + have a₃ := AesCtr.AArch64.taint_rel (P := fun a b => KCall s₀ a ∧ KCall s₀' b) + (F₁ := KDone s₀) (F₂ := KDone s₀') [.x25, .x22, .x23] xor_taint + (fun a b h => by rw [h.1.sp, h.2.sp, qSp]) + (fun a b h r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.x25, h.2.x25, kV, kV, qV] + · rw [h.1.x22, h.2.x22, qT] + · rw [h.1.x23, h.2.x23, qU]) + fun a b h => ⟨tail_xor_wp hp h.1 hu, tail_xor_wp hp' h.2 hu'⟩ + exact a₁.seq ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq a₃) + have r₃ : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) (.ite (.zero .x .x23) (.block []) ctrFinalTail) + (fun a b => KDone s₀ a ∧ KDone s₀' b) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1] at this; simpa using this + exact ⟨done_of_zero h.1.1 h0, done_of_zero h.1.2 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1, h.1.2⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1] at this; simpa using this + have r₃' := r₃.wp (F₁ := fun (s : State) => s.sp = s₀.sp) (F₂ := fun (s : State) => s.sp = s₀'.sp) + fun a b h => + ⟨WP.mono (WP.sp_eq (mid_wp hp h.1)) fun _ x => x.2.trans h.1.sp, + WP.mono (WP.sp_eq (mid_wp hp' h.2)) fun _ x => x.2.trans h.2.sp⟩ + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := RelCT.taint (A := taint) (P := fun a b => (KDone s₀ a ∧ KDone s₀' b) ∧ + a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ + (fun a b h => AesCfb.AArch64.Final.agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.x25, h.1.2.x25, kV, kV, qV]) t₅ + exact r₁.seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₃'.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalAArch64.pre ctrFinalAArch64.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified AArch64.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +The final function has five argument words, so `save` is its sixth, in `x5`: +it runs its code in a frame of 80 bytes on the stack (`withStackScratchWiped`), +`save`'s 80 bytes (the registers, then the block that held the last output +block), which it zeroes before returning. Its calls use 3344 bytes below it, +so 3424 in all. -/ + +/-- A state satisfying the shared contract's precondition. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk AArch64.abi 3424).pre s := by + implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, + Proof.Camellia.ctrFinalPostSk, AArch64.abi, AArch64.argRegs] [ctrFinalFrameSat, ctrFinalSat] + using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 80 .x5 10 ctrFinal) + (Spec.Camellia.ctrFinalContract AArch64.abi 3424) := + Proof.Camellia.ctrFinal_of_sk <| + AArch64.Verified.stackScratchWiped (sig := Spec.Camellia.ctrFinalSig) (nm := "save") (e := .u64) (n := 10) + (pre := Spec.Camellia.ctrFinalPre AArch64.abi.ptrBits) (post := Proof.Camellia.ctrFinalPostSk AArch64.abi.ptrBits) + (wa := true) (stack := 3344) (bytes := 80) (words := 10) ctrFinal_verified (by decide) (by decide) + (by decide) (Proof.Camellia.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Camellia.AArch64.CtrFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/AArch64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/AArch64/CtrFinal.lean new file mode 100644 index 00000000000..190f09afc69 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/AArch64/CtrFinal.lean @@ -0,0 +1,958 @@ +module + +public import VerifiedGarbage.Impl.Sm4.AArch64.CtrFinal +public import VerifiedGarbage.Proof.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Sm4.Scratch +public import VerifiedGarbage.Proof.Sm4.AArch64.CtrVerified +public import VerifiedGarbage.Proof.AesCfb.AArch64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.AArch64.Spill +public import VerifiedGarbage.Impl.StackScratch.AArch64 +import VerifiedGarbage.Proof.AesCtr.AArch64.Final +import VerifiedGarbage.Proof.AesCtr.AArch64.CT +import VerifiedGarbage.Proof.Sm4.AArch64.Lit +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.AArch64.FbFinal +import VerifiedGarbage.Proof.Modes.AArch64.Steps +import VerifiedGarbage.Proof.Modes.AArch64.Xor +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCbc.AArch64.Block +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.AArch64.Call +import VerifiedGarbage.Proof.Framework.AArch64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.AArch64.RegUpd +import VerifiedGarbage.Proof.Framework.AArch64.Exec +import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +import VerifiedGarbage.Proof.Framework.AArch64.Taint +import VerifiedGarbage.Proof.Framework.AArch64.Lit +import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.Sm4.AArch64.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.Scratch +meta import VerifiedGarbage.Proof.Sm4.AArch64.CtrVerified +meta import VerifiedGarbage.Proof.AesCfb.AArch64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.AArch64.Spill +meta import VerifiedGarbage.Impl.StackScratch.AArch64 +meta import VerifiedGarbage.Proof.AesCtr.AArch64.Final +meta import VerifiedGarbage.Proof.AesCtr.AArch64.CT +meta import VerifiedGarbage.Proof.Sm4.AArch64.Lit +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.AArch64.FbFinal +meta import VerifiedGarbage.Proof.Modes.AArch64.Steps +meta import VerifiedGarbage.Proof.Modes.AArch64.Xor +import VerifiedGarbage.Proof.Modes.AArch64.Xor +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCbc.AArch64.Block +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.AArch64.Call +meta import VerifiedGarbage.Proof.Framework.AArch64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.AArch64.RegUpd +meta import VerifiedGarbage.Proof.Framework.AArch64.Exec +meta import VerifiedGarbage.Proof.Framework.AArch64.VecPreserved +meta import VerifiedGarbage.Proof.Framework.AArch64.Taint +meta import VerifiedGarbage.Proof.Framework.AArch64.Lit +meta import VerifiedGarbage.Proof.Framework.AArch64.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# SM4-CTR of a message's last piece on AArch64 + +`ctrFinal_framed`: `vg_sm4_ctr_final` (`Impl/Sm4/AArch64/CtrFinal.lean`) meets +`Spec.Sm4.ctrFinalContract`. + +The code is proven against `ctrFinalAArch64`, with the arguments +`(schedule = x0, ctr = x1, data = x2, len = x3, save = x4)`, a fifth argument `save` (`x4`) of 80 bytes for its caller's registers and +return address and a block of its own, and 3264 bytes of stack for its +calls (`ctrFinal_implies`: the shared contract with it), as a caller of +`vg_sm4_ctr`, framed by its own working space on the stack (`ctrFramed`), +through a contract of its own, `ctrF`, which the callee's shared contract +implies (`ctrF_implies`), with `WP.callF` (the callee's frames lie within the +stack, `ctr_depth`). It is AES-CTR's final function's proof +(`Proof/AesCtr/AArch64/Final.lean`) with SM4's arguments: + +* `setup_wp`, `whole_wp`: the registers saved in `save`, whose address is + kept in `x25`, and the call on the `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.AArch64.xorLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`), by SM4 with the schedule at `schedule`. + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Sm4.AArch64.CtrFinal + +open VG VG.AArch64 +open VG.Spec.Aes (bytesAt) +open VG.AArch64.RegUpd +open VG.Impl.Sm4.AArch64 (ctrFramed ctrFinalSave ctrFinalMoves ctrFinalSetup ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.AArch64 (finalSaved finalRestore) +open VG.Impl.AesCtr.AArch64 (zeroSlots tailKey) + +/-! ## The callee -/ + +/-- `vg_sm4_ctr(schedule = x0, ctr = x1, data = x2, n = x3)` with its 3264 +bytes of stack. -/ +def ctrF : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .x0, 128⟩ + let ctr : Region := ⟨s.gpr .x1, 16⟩ + let data : Region := ⟨s.gpr .x2, 16 * (s.gpr .x3).toNat⟩ + 3264 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data] ∧ sched.Disjoint ctr ∧ sched.Disjoint data ∧ + ctr.Disjoint data ∧ (below s.sp 3264).Disjoint sched ∧ (below s.sp 3264).Disjoint ctr ∧ + (below s.sp 3264).Disjoint data ∧ + (s.gpr .x0).toNat + 128 ≤ 2 ^ 64 ∧ (s.gpr .x1).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .x2).toNat + 16 * (s.gpr .x3).toNat ≤ 2 ^ 64 + post s s' := + Spec.Cbc.blocksAt s'.mem (s.gpr .x2) (s.gpr .x3).toNat = + Spec.Ctr.crypt (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (s.gpr .x0))) + (bytesAt s.mem (s.gpr .x1) 16) (Spec.Cbc.blocksAt s.mem (s.gpr .x2) (s.gpr .x3).toNat) ∧ + bytesAt s'.mem (s.gpr .x1) 16 = Spec.Ctr.next (bytesAt s.mem (s.gpr .x1) 16) (s.gpr .x3).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .x0 = s₂.gpr .x0 ∧ s₁.gpr .x1 = s₂.gpr .x1 ∧ s₁.gpr .x2 = s₂.gpr .x2 ∧ + s₁.gpr .x3 = s₂.gpr .x3 + +theorem ctrF_implies : (Spec.Sm4.ctrContract AArch64.abi 3264).Implies ctrF where + pre s hs := by + sig_pre [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, AArch64.abi, AArch64.argRegs] + simp only [Nat.mul_comm (s.gpr .x3).toNat 16] + exact hs + post s s' _ h := by + sig_reduce [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, AArch64.abi, AArch64.argRegs] at h + simp only [BitVec.setWidth_eq] at h + exact h + pub s₁ s₂ _ _ h := by + sig_reduce [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, AArch64.abi, AArch64.argRegs] + obtain ⟨hsp, h0, h1, h2, h3⟩ := h + exact ⟨hsp, fun _ _ => by rw [h0, h1, h2, h3], fun _ hr => absurd hr List.not_mem_nil⟩ + sat := ⟨Sm4.AArch64.ctrFrameSat, by + refine ⟨by decide, rfl, rfl, Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), by decide, by decide, by decide⟩⟩ + +theorem ctr_depth : 16 * ctrFramed.aarch64Depth ≤ 3264 := by lit_decide + +theorem ctr_ok : ∀ s, ctrF.pre s → ∃ t s', Exec isa ctrFramed s t s' ∧ abiPreserved s s' ∧ ctrF.post s s' := + (Sm4.AArch64.ctr_framed.of_implies ctrF_implies).1 + +theorem ctr_ct : ConstantTime isa ctrF.pre ctrF.pub ctrFramed := + (Sm4.AArch64.ctr_framed.of_implies ctrF_implies).2.1 + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = x0, ctr = x1, +data = x2, len = x3, save = x4)`, `save` of 80 bytes, and 3264 bytes of stack +for the calls: the data and the counter block as `Spec.Ctr.CryptFinal` says, +by SM4 with the schedule at `schedule`. -/ +def ctrFinalAArch64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .x0, 128⟩ + let ctr : Region := ⟨s.gpr .x1, 16⟩ + let data : Region := ⟨s.gpr .x2, (s.gpr .x3).toNat⟩ + let sv : Region := ⟨s.gpr .x4, 80⟩ + let stack := below s.sp 3264 + 3264 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .x0).toNat + 128 ≤ 2 ^ 64 ∧ (s.gpr .x1).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .x2).toNat + (s.gpr .x3).toNat ≤ 2 ^ 64 ∧ (s.gpr .x4).toNat + 80 ≤ 2 ^ 64 + post s s' := + Spec.Ctr.CryptFinal (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (s.gpr .x0))) + s.mem s'.mem (s.gpr .x1) (s.gpr .x2) (s.gpr .x3).toNat + pub s₁ s₂ := + s₁.gpr .x0 = s₂.gpr .x0 ∧ s₁.gpr .x1 = s₂.gpr .x1 ∧ s₁.gpr .x2 = s₂.gpr .x2 ∧ + s₁.gpr .x3 = s₂.gpr .x3 ∧ s₁.gpr .x4 = s₂.gpr .x4 ∧ s₁.sp = s₂.sp + +/-- The contract the frame needs: the shared one, with `save`, 80 bytes, as a +fifth argument, and 3264 bytes of stack (`vg_sm4_ctr`'s frame). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract AArch64.abi Spec.Sm4.ctrFinalSig "save" .u64 10 (Curry.const (fun _ => True) _) + (Proof.Sm4.ctrFinalPost AArch64.abi.ptrBits) true 3264 + +/-- A state satisfying the precondition (no data). -/ +def ctrFinalSat : State where + gpr r := match r with + | .x0 => 0x1000 | .x1 => 0x2000 | .x2 => 0x3000 | .x4 => 0x4000 | _ => 0 + sp := 0x8000 + mem _ := 0 + rd := [⟨0x1000, 128⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 80⟩] + +theorem ctrFinal_implies : ctrFinalAArch64.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, ctrFinalAArch64, AArch64.abi, AArch64.argRegs] [ctrFinalSat] + using ctrFinalSat + +/-! ## The arguments, by name -/ + +open VG.Proof.AesCfb.AArch64.Final (Kept cs_of bytesAt_getD blocksAt_frame' saved_slots saved_fits + WP.sp_eq shr4 shr4_shl4 sub_shl4) +open VG.Proof.AesCtr.AArch64.Final (zero_bytes zero_ok one_toNat lo32_next_of) + +section +variable (s₀ : State) + +abbrev fW : Addr := s₀.gpr .x0 +abbrev fIv : Addr := s₀.gpr .x1 +abbrev fD : Addr := s₀.gpr .x2 +abbrev fL : Nat := (s₀.gpr .x3).toNat +/-- The number of whole blocks, and of the bytes after them. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +/-- The data after the whole blocks. -/ +abbrev fT : Addr := fD s₀ + BitVec.ofNat 64 (16 * fN s₀) +abbrev fData : Region := ⟨fD s₀, fL s₀⟩ +abbrev fBlk : Region := ⟨fD s₀, 16 * fN s₀⟩ +abbrev fTail : Region := ⟨fT s₀, fU s₀⟩ +/-- The counter block and the whole blocks on entry. -/ +abbrev fIv0 : List Byte := bytesAt s₀.mem (fIv s₀) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (fD s₀) (fN s₀) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .x4 +abbrev kSch : Region := ⟨fW s₀, 128⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 80⟩ +abbrev kSv64 : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 64 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below s₀.sp 3264 +/-- The memory once the registers are saved. -/ +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) s₀.gpr finalSaved +/-- The cipher on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Sm4.cipher (Spec.Sm4.scheduleAt s₀.mem (fW s₀)) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp : 3264 ≤ s₀.sp.toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 128 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 80 ≤ 2 ^ 64 + +theorem KPre.of {s₀ : State} (h : ctrFinalAArch64.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17⟩ + +/-! ## Regions and frames -/ + +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) + +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) + +theorem fN_eq (s₀ : State) : fN s₀ = fL s₀ / 16 := rfl +theorem fU_eq (s₀ : State) : fU s₀ = fL s₀ % 16 := rfl + +theorem n_lt (s₀ : State) : fN s₀ < 2 ^ 64 := by + have := (s₀.gpr .x3).isLt; have : fL s₀ = (s₀.gpr .x3).toNat := rfl; rw [fN_eq]; omega + +theorem u_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +theorem toNat_n (s₀ : State) : (BitVec.ofNat 64 (fN s₀)).toNat = fN s₀ := by + rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt (n_lt s₀)] + +theorem sv64_sub (s₀ : State) : Region.Sub (kSv64 s₀) (kSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +end + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + (Spill.saveMem_frame_base (n := 64) (by decide) (by decide) _ _ _).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨kSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem KPre.sch_big {s₀ : State} (hp : KPre s₀) : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The schedule, from memory that agrees with the entry's on it. -/ +theorem sched_of {s₀ : State} {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : Spec.Sm4.scheduleAt m (fW s₀) = Spec.Sm4.scheduleAt m₀ (fW s₀) := + Proof.Sm4.scheduleAt_frame hf hd + +/-- The stack a call of `vg_sm4_ctr` uses lies within the stack. -/ +theorem stk_sub (s₀ : State) : Region.Sub (below s₀.sp (16 * ctrFramed.aarch64Depth)) (kStk s₀) := + fun x hx => Offset.below_mono s₀.sp ctr_depth (by decide) x hx + +/-! ## Saving the registers -/ + +theorem moves_ok (s : State) : + ∃ s', runBlock isa ctrFinalMoves s = some s' ∧ + s'.gpr .x19 = s.gpr .x0 ∧ s'.gpr .x21 = s.gpr .x1 ∧ s'.gpr .x25 = s.gpr .x4 ∧ + s'.gpr .x22 = s.gpr .x2 + (s.gpr .x3 >>> 4 <<< 4) ∧ s'.gpr .x23 = s.gpr .x3 - (s.gpr .x3 >>> 4 <<< 4) ∧ + s'.gpr .x3 = s.gpr .x3 >>> 4 ∧ + (∀ r, r ≠ .x19 → r ≠ .x21 → r ≠ .x22 → r ≠ .x23 → r ≠ .x25 → r ≠ .x3 → + r ≠ .x9 → r ≠ .x10 → s'.gpr r = s.gpr r) ∧ + s'.sp = s.sp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by crun [ctrFinalMoves, Impl.AesCbc.AArch64.mov], ?_⟩ + refine ⟨by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], + by simp [gpr_write], by simp [gpr_write], fun r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ => ?_, rfl, rfl, rfl, rfl⟩ + simp [gpr_write, h₁, h₂, h₃, h₄, h₅, h₆, h₇, h₈] + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + x19 : s.gpr .x19 = fW s₀ + x21 : s.gpr .x21 = fIv s₀ + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + x0 : s.gpr .x0 = fW s₀ + x1 : s.gpr .x1 = fIv s₀ + x2 : s.gpr .x2 = fD s₀ + x3 : s.gpr .x3 = BitVec.ofNat 64 (fN s₀) + kept : Kept s₀ s + sp : s.sp = s₀.sp + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (KSetup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions s₀.wr (s₀.gpr .x4 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .x4 finalSaved ++ ctrFinalMoves)) _ _ + refine Spill.save_ok saved_fits hw ?_ + refine WP.mono (WP.of_runBlock (moves_ok _)) + fun s' ⟨x19, x21, x25, x22, x23, x3, keep, sp, mem, rd, wr⟩ => ?_ + have k (r : Reg) (h₁ : r ≠ .x19) (h₂ : r ≠ .x21) (h₃ : r ≠ .x22) (h₄ : r ≠ .x23) (h₅ : r ≠ .x25) + (h₆ : r ≠ .x3) (h₇ : r ≠ .x9) (h₈ : r ≠ .x10) : + s'.gpr r = s₀.gpr r := keep r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ + exact ⟨x19, x21, by rw [x22, shr4_shl4], by rw [x23, shr4_shl4, sub_shl4], x25, + k .x0 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide), + k .x1 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide), + k .x2 (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide), + by rw [x3, shr4], + fun r hr => by + rcases hr with rfl | rfl | rfl <;> + exact k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide), + sp, mem, rd, wr⟩ + +/-! ## The whole blocks -/ + +theorem whole_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, h.x0, h.x1, h.x2, h.x3, h.sp, toNat_n] + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), + hp.iv_data.sub_right (blk_sub s₀), hp.stk_sch, hp.stk_iv, hp.stk_data.sub_right (blk_sub s₀), + hp.sch_wrap, hp.iv_wrap, hp.blk_wrap⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The schedule, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : KPre s₀) : + Spec.Sm4.scheduleAt (kSvMem s₀) (fW s₀) = Spec.Sm4.scheduleAt s₀.mem (fW s₀) ∧ + bytesAt (kSvMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ Spec.Cbc.blocksAt (kSvMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame s₀ + exact ⟨sched_of ef (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv), + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + x19 : s.gpr .x19 = fW s₀ + x21 : s.gpr .x21 = fIv s₀ + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +/-- A call's frame, within the regions it was given and the stack. -/ +theorem call_frame {s₀ s s' : State} (hsp : s.sp = s₀.sp) {wr : List Region} + (hf : Frame (wr ++ [below s.sp (16 * ctrFramed.aarch64Depth)]) s.mem s'.mem) : + Frame (wr ++ [kStk s₀]) s.mem s'.mem := + hf.sub fun r hr => by + rcases List.mem_append.mp hr with h | h + · exact ⟨r, List.mem_append_left _ h, fun _ h => h⟩ + · simp only [List.mem_singleton] at h; subst h + exact ⟨kStk s₀, by simp, by rw [hsp]; exact stk_sub s₀⟩ + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + WP isa (.call "vg_sm4_ctr" ctrFramed) s (KWhole s₀) := by + obtain ⟨eK, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.callF (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, fBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + rw [h.mem] at fr + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, h.x0, h.x1, h.x2, h.x3, toNat_n, h.mem] at post₂ + rw [eK, eIv, eB] at post₂ + exact ⟨by rw [cs_of cs' .x19 (by simp), h.x19], by rw [cs_of cs' .x21 (by simp), h.x21], by rw [cs_of cs' .x22 (by simp), h.x22], + by rw [cs_of cs' .x23 (by simp), h.x23], by rw [cs_of cs' .x25 (by simp), h.x25], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], + fr.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h], + post₂.1, post₂.2⟩ + +/-! ## The partial last block -/ + +theorem eval_u {s₀ s : State} (h : KWhole s₀ s) : + isa.eval (.zero .x .x23) s = some (decide (fU s₀ = 0)) := by + rw [Proof.Modes.AArch64.eval_zero, h.x23, Proof.Modes.AArch64.ofNat_beq_zero (by have := u_lt s₀; omega)] + +theorem tailMoves_ok (s : State) : + ∃ s', runBlock isa ctrFinalTailMoves s = some s' ∧ + s'.gpr .x0 = s.gpr .x19 ∧ s'.gpr .x1 = s.gpr .x21 ∧ s'.gpr .x2 = s.gpr .x25 + BitVec.ofNat 64 64 ∧ + s'.gpr .x3 = 1 ∧ (∀ r ∈ preserved, s'.gpr r = s.gpr r) ∧ + s'.sp = s.sp ∧ s'.mem = s.mem ∧ s'.rd = s.rd ∧ s'.wr = s.wr := by + refine ⟨_, by crun [ctrFinalTailMoves], ?_⟩ + refine ⟨by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], by simp [gpr_write], + fun r hr => ?_, rfl, rfl, rfl, rfl⟩ + simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp [gpr_write] + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KArgs (s₀ s : State) : Prop where + x0 : s.gpr .x0 = fW s₀ + x1 : s.gpr .x1 = fIv s₀ + x2 : s.gpr .x2 = kBk s₀ + x3 : s.gpr .x3 = 1 + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (KArgs s₀) := by + obtain ⟨s₁, r₁, z₁, k₁, sp₁, m₁, rd₁, wr₁⟩ := zero_ok s + show WP isa (.block ([.movz .x .x9 0 0] ++ (Spill.saveCode .x25 zeroSlots ++ ctrFinalTailMoves))) _ _ + refine WP.block_append_iff.mpr (WP.of_runBlock ⟨s₁, r₁, ?_⟩) + have h25 : s₁.gpr .x25 = kV s₀ := by rw [k₁ _ (by decide), h.x25] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .x25 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [wr₁, h.wr, hp.wr, h25] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by decide)⟩ + refine Spill.save_ok (by decide) hw ?_ + refine WP.mono (WP.of_runBlock (tailMoves_ok _)) + fun s' ⟨x0, x1, x2, x3, cs, sp, mem, rd, wr⟩ => ?_ + have c (r : Reg) (hr : r = .x19 ∨ r = .x20 ∨ r = .x21 ∨ r = .x22 ∨ r = .x23 ∨ r = .x24 ∨ r = .x25 ∨ + r = .x26 ∨ r = .x27 ∨ r = .x28) : s'.gpr r = s.gpr r := by + rw [cs r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide)] + exact k₁ r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + have hm : s'.mem = Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₁.mem _ _ _ = _; rw [m₁, h25] + have fz : Frame [kBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + refine ⟨by rw [x0]; exact (k₁ _ (by decide)).trans h.x19, by rw [x1]; exact (k₁ _ (by decide)).trans h.x21, + by rw [x2, h25], x3, + by rw [c .x22 (by simp), h.x22], by rw [c .x23 (by simp), h.x23], by rw [c .x25 (by simp), h.x25], + fun r hr => by rw [c r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp, show ({ s₁ with mem := _ } : State).sp = s₁.sp from rfl, sp₁, h.sp], + by rw [rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, rd₁, h.rd], + by rw [wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, wr₁, h.wr], ?_, ?_, ?_, ?_⟩ + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.ctr] + · rw [hm, show Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₁.gpr .x9)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .x9)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z₁] + exact zero_bytes _ _ + +theorem tail_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, kBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, kBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, kBlk s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, h.x0, h.x1, h.x2, h.x3, h.sp, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.iv_sv.sub_right bs, hp.stk_sch, + hp.stk_iv, hp.stk_sv.sub_right bs, hp.sch_wrap, hp.iv_wrap, by rw [hp.bk_toNat]; omega⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure KCall (s₀ s : State) : Prop where + x22 : s.gpr .x22 = fT s₀ + x23 : s.gpr .x23 = BitVec.ofNat 64 (fU s₀) + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem cipher_length (k : Spec.Sm4.Schedule) (b : List Byte) : (Spec.Sm4.cipher k b).length = 16 := by + simp [Spec.Sm4.cipher] + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + WP isa (.call "vg_sm4_ctr" ctrFramed) s (KCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (kW1_kW h.frame) + have eK := sched_of big hp.sch_big + refine WP.callF (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, kBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, h.x0, h.x1, h.x2, h.x3, one_toNat, h.ctr] at post₂ + rw [eK] at post₂ + have fc : Frame (kW1 s₀) s.mem s'.mem := fr.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs_of cs' .x22 (by simp), h.x22], by rw [cs_of cs' .x23 (by simp), h.x23], + by rw [cs_of cs' .x25 (by simp), h.x25], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + x25 : s.gpr .x25 = kV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.x25, h.kept, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem toNat_tail {s₀ : State} (hp : KPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) s + (KDone s₀) := by + obtain ⟨s₁, run₁, x9₁, o₁, mem₁, rd₁, wr₁⟩ := Proof.Modes.AArch64.addImm_ok s .x9 .x25 (v := 64) (by decide) + refine WP.seq (WP.of_runBlock ⟨s₁, run₁, ?_⟩) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : Proof.Modes.AArch64.XPre s₁ (kBk s₀) (fT s₀) (fU s₀) .x22 .x23 := { + pos := by omega + small := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [rd₁, wr₁, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [wr₁, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) + dl := by decide + d9 := by decide + d6 := by decide + d7 := by decide } + have x0 : Proof.Modes.AArch64.XInv s₁ (kBk s₀) (fT s₀) (fU s₀) .x22 .x23 0 s₁ := { + x9 := by rw [x9₁, h.x25]; exact (BitVec.add_zero _).symm + dat := by rw [o₁ _ (by decide), h.x22]; exact (BitVec.add_zero _).symm + left := by rw [o₁ _ (by decide), h.x23, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Proof.Modes.AArch64.xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have g (r : Reg) (hr : r = .x25 ∨ r = .x26 ∨ r = .x27 ∨ r = .x28) : s'.gpr r = s.gpr r := by + rw [d.gpr r (by rcases hr with rfl | rfl | rfl | rfl <;> decide) (by rcases hr with rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl <;> decide) (by rcases hr with rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl <;> decide), + o₁ _ (by rcases hr with rfl | rfl | rfl | rfl <;> decide)] + refine ⟨by rw [g .x25 (by simp), h.x25], fun r hr => by rw [g r (by rcases hr with rfl | rfl | rfl <;> simp), + h.kept r hr], by rw [d.rd, rd₁, h.rd], by rw [d.wr, wr₁, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · refine kW1_kW h.frame |>.trans ?_ + rw [← mem₁] + exact d.frame.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩ + · rw [blocksAt_frame' d.frame fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, mem₁] + exact h.blocks + · rw [d.data q hq, mem₁, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame d.frame ivT (by decide), mem₁, h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.ite (.zero .x .x23) (.block []) ctrFinalTail) s (KDone s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.block finalRestore) s fun s' => (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.mem = s.mem := by + have hs : Spill.Saved (kV s₀) s₀.gpr finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (kV s₀) s₀.gpr).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .x25 finalSaved)) _ _ + refine WP.mono (Spill.restore_wp h.x25 saved_fits (by decide) (fun p hp' => ?_) hs) + fun s' r => ⟨fun q hq => r.gpr_of ?_, r.mem⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + · simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hq + rcases hq with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl + all_goals first + | exact .inl (by decide) + | exact .inr (h.kept _ (by simp)) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (end_wp hp h₃) fun _ ⟨g, m⟩ => ⟨g, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalAArch64.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem ctrFinal_keepsV : ctrFinal.allInstrs keepsV = true := by lit_decide + +theorem final_correct (s : State) (hs : ctrFinalAArch64.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalAArch64.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, ⟨hg, AArch64.Exec.sp he, Exec.preservedV he ctrFinal_keepsV⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.x0, .x1, .x2, .x3, .x4]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.x19, .x21, .x25]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.x25, .x22, .x23]) + (.seq (.block tailKey) (.loop (.block (Impl.Modes.AArch64.xorByte .x22 .x23)) (.nonzero .x .x23))) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.x25]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalAArch64.pre s₀) (h0' : ctrFinalAArch64.pre s₀') + (hq : ctrFinalAArch64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + -- The registers saved and the arguments set up. + have r₁ := AesCtr.AArch64.taint_rel (P := fun a b => a = s₀ ∧ b = s₀') (F₁ := KSetup s₀) (F₂ := KSetup s₀') + [.x0, .x1, .x2, .x3, .x4] setup_taint + (fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact qSp) + (fun a b h r hr => by + obtain ⟨rfl, rfl⟩ := h + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := ctrF) (n := "vg_sm4_ctr") ctr_ok ctr_ct + (P := fun a b => KSetup s₀ a ∧ KSetup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, ha.x0, ha.x1, ha.x2, ha.x3, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.sp] + rw [fW, fW, fIv, fIv, fD, fD, qW, qIv, qD, qSp, qN] + refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := KWhole s₀) (F₂ := KWhole s₀') fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) ctrFinalTail + fun a b => KDone s₀ a ∧ KDone s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := AesCtr.AArch64.taint_rel (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) + (F₁ := KArgs s₀) (F₂ := KArgs s₀') [.x19, .x21, .x25] tailArgs_taint + (fun a b h => by rw [h.1.sp, h.2.sp, qSp]) + (fun a b h r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.x19, h.2.x19, fW, fW, qW] + · rw [h.1.x21, h.2.x21, fIv, fIv, qIv] + · rw [h.1.x25, h.2.x25, kV, kV, qV]) + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩ + have a₂ := (RelCT.callEx (k := ctrF) (n := "vg_sm4_ctr") ctr_ok ctr_ct + (P := fun a b => KArgs s₀ a ∧ KArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + AesCbc.AArch64.callEntry_x0, AesCbc.AArch64.callEntry_x1, AesCbc.AArch64.callEntry_x2, + AesCbc.AArch64.callEntry_x3, ha.x0, ha.x1, ha.x2, ha.x3, ha.sp, hb.x0, hb.x1, hb.x2, hb.x3, hb.sp] + rw [fW, fW, fIv, fIv, kBk, kBk, kV, kV, qW, qIv, qV, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := KCall s₀) (F₂ := KCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + have a₃ := AesCtr.AArch64.taint_rel (P := fun a b => KCall s₀ a ∧ KCall s₀' b) + (F₁ := KDone s₀) (F₂ := KDone s₀') [.x25, .x22, .x23] xor_taint + (fun a b h => by rw [h.1.sp, h.2.sp, qSp]) + (fun a b h r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.x25, h.2.x25, kV, kV, qV] + · rw [h.1.x22, h.2.x22, qT] + · rw [h.1.x23, h.2.x23, qU]) + fun a b h => ⟨tail_xor_wp hp h.1 hu, tail_xor_wp hp' h.2 hu'⟩ + exact a₁.seq ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq a₃) + have r₃ : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) (.ite (.zero .x .x23) (.block []) ctrFinalTail) + (fun a b => KDone s₀ a ∧ KDone s₀' b) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1] at this; simpa using this + exact ⟨done_of_zero h.1.1 h0, done_of_zero h.1.2 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1, h.1.2⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1] at this; simpa using this + have r₃' := r₃.wp (F₁ := fun (s : State) => s.sp = s₀.sp) (F₂ := fun (s : State) => s.sp = s₀'.sp) + fun a b h => + ⟨WP.mono (WP.sp_eq (mid_wp hp h.1)) fun _ x => x.2.trans h.1.sp, + WP.mono (WP.sp_eq (mid_wp hp' h.2)) fun _ x => x.2.trans h.2.sp⟩ + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := RelCT.taint (A := taint) (P := fun a b => (KDone s₀ a ∧ KDone s₀' b) ∧ + a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ + (fun a b h => AesCfb.AArch64.Final.agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.x25, h.1.2.x25, kV, kV, qV]) t₅ + exact r₁.seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₃'.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalAArch64.pre ctrFinalAArch64.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified AArch64.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +The final function has four argument words, so `save` is its fifth, in `x4`: +it runs its code in a frame of 80 bytes on the stack (`withStackScratchWiped`), +`save`'s 80 bytes (the registers, then the block that held the last output +block), which it zeroes before returning. Its calls use 3264 bytes below it, +so 3344 in all. -/ + +/-- A state satisfying the shared contract's precondition. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Spec.Sm4.ctrFinalContract AArch64.abi 3344).pre s := by + implies_sat [Spec.Sm4.ctrFinalContract, Spec.Sm4.ctrFinalSig, AArch64.abi, AArch64.argRegs] + [ctrFinalFrameSat, ctrFinalSat] using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified AArch64.target (Impl.StackScratch.AArch64.withStackScratchWiped 80 .x4 10 ctrFinal) + (Spec.Sm4.ctrFinalContract AArch64.abi 3344) := by + rw [Proof.Sm4.ctrFinalContract_eq] + exact AArch64.Verified.stackScratchWiped (sig := Spec.Sm4.ctrFinalSig) (nm := "save") (e := .u64) (n := 10) + (post := Proof.Sm4.ctrFinalPost AArch64.abi.ptrBits) (wa := true) (stack := 3264) (bytes := 80) (words := 10) + ctrFinal_verified (by decide) (by decide) (by decide) (Proof.Sm4.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Sm4.AArch64.CtrFinal From d26f12a06fabf8d36af31cdcc5edb839b6a5defe Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 12:34:41 +0000 Subject: [PATCH 12/18] AES-OFB and CTR (AES, Camellia, SM4) final functions on ARMv7 (WIP: crates to come) As on the other targets. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../VerifiedGarbage/Artifacts/AesCtr/Arm.lean | 7 +- .../VerifiedGarbage/Artifacts/AesOfb/Arm.lean | 7 +- .../Artifacts/CamelliaCtr/Arm.lean | 7 +- .../VerifiedGarbage/Artifacts/Sm4Ctr/Arm.lean | 7 +- .../Impl/AesCtr/Arm/Final.lean | 77 ++ .../Impl/AesOfb/Arm/Final.lean | 38 + .../Impl/Camellia/Arm/CtrFinal.lean | 87 ++ .../Impl/Sm4/Arm/CtrFinal.lean | 84 ++ .../Proof/AesCfb/Arm/Final.lean | 25 +- .../Proof/AesCtr/Arm/Final.lean | 1167 ++++++++++++++++ .../Proof/AesOfb/Arm/Final.lean | 118 ++ .../Proof/Camellia/Arm/CtrFinal.lean | 1231 +++++++++++++++++ .../Proof/Sm4/Arm/CtrFinal.lean | 1101 +++++++++++++++ 13 files changed, 3939 insertions(+), 17 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/AesCtr/Arm/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/AesOfb/Arm/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/Camellia/Arm/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Impl/Sm4/Arm/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/Arm/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/Arm/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean diff --git a/lean/VerifiedGarbage/Artifacts/AesCtr/Arm.lean b/lean/VerifiedGarbage/Artifacts/AesCtr/Arm.lean index d6d08c7b655..243aba9f386 100644 --- a/lean/VerifiedGarbage/Artifacts/AesCtr/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/AesCtr/Arm.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesCtr.Arm.Verified +public import VerifiedGarbage.Proof.AesCtr.Arm.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print @@ -16,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Ctr.aesApi.artifact Arm.target { code := Impl.AesCtr.Arm.crypt stack := 8 - verified := Proof.AesCtr.keyed crypt_verified }] + verified := Proof.AesCtr.keyed crypt_verified }, + Spec.Ctr.aesFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 72 2 14 Impl.AesCtr.Arm.cryptFinal + stack := 88 + verified := Proof.AesCtr.final_keyed cryptFinal_framed }] end VG.Artifacts.AesCtr.Arm diff --git a/lean/VerifiedGarbage/Artifacts/AesOfb/Arm.lean b/lean/VerifiedGarbage/Artifacts/AesOfb/Arm.lean index 439bf0783ae..45e3ab8bb27 100644 --- a/lean/VerifiedGarbage/Artifacts/AesOfb/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/AesOfb/Arm.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesOfb.Arm.Verified +public import VerifiedGarbage.Proof.AesOfb.Arm.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print @@ -16,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Ofb.aesApi.artifact Arm.target { code := Impl.AesOfb.Arm.crypt stack := 8 - verified := Proof.AesOfb.keyed crypt_verified }] + verified := Proof.AesOfb.keyed crypt_verified }, + Spec.Ofb.aesFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 56 2 10 Impl.AesOfb.Arm.cryptFinal + stack := 72 + verified := Proof.AesOfb.final_keyed cryptFinal_framed }] end VG.Artifacts.AesOfb.Arm diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/Arm.lean b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/Arm.lean index 21400af5221..4155aa5b843 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/Arm.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Camellia.Arm.CtrVerified +public import VerifiedGarbage.Proof.Camellia.Arm.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print @@ -14,6 +15,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ctrApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 88 1 18 Impl.Camellia.Arm.ctr stack := 2904 - verified := Proof.Camellia.Arm.ctr_framed }] + verified := Proof.Camellia.Arm.ctr_framed }, + Spec.Camellia.ctrFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 72 1 14 Impl.Camellia.Arm.ctrFinal + stack := 2984 + verified := Proof.Camellia.Arm.CtrFinal.ctrFinal_framed }] end VG.Artifacts.CamelliaCtr.Arm diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/Arm.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/Arm.lean index a53e685cd54..abe3301d1a4 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/Arm.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/Arm.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Sm4.Arm.BatchVerified +public import VerifiedGarbage.Proof.Sm4.Arm.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.Arm.Print @@ -14,6 +15,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ctrApi.artifact Arm.target { code := Impl.StackScratch.Arm.withStackScratchWiped 1520 0 378 Impl.Sm4.Arm.BatchCtr.ctr stack := 1520 - verified := Proof.Sm4.Arm.BatchVerified.framed }] + verified := Proof.Sm4.Arm.BatchVerified.framed }, + Spec.Sm4.ctrFinalApi.artifact Arm.target { + code := Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 Impl.Sm4.Arm.ctrFinal + stack := 1584 + verified := Proof.Sm4.Arm.CtrFinal.ctrFinal_framed }] end VG.Artifacts.Sm4Ctr.Arm diff --git a/lean/VerifiedGarbage/Impl/AesCtr/Arm/Final.lean b/lean/VerifiedGarbage/Impl/AesCtr/Arm/Final.lean new file mode 100644 index 00000000000..6aecd5f1037 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesCtr/Arm/Final.lean @@ -0,0 +1,77 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.Arm +public import VerifiedGarbage.Impl.AesCfb.Arm.Final + +/-! +# AES-CTR of a message's last piece: 32-bit ARM implementation + +`cryptFinal` (schedule = r0, rounds = r1, ctr = r2, data = r3, len = `[sp]`, +scratch = `[sp + 4]`, save = `[sp + 8]`): the code of `vg_aes_ctr_final`, +whose registration frames it with a buffer of its own on the stack, `save`, +the seventh argument, of 56 bytes: the caller's callee-saved registers and +its return address, then, at 40, a block of the code's own: + +1. the registers saved in `save`, and the arguments kept in `r4` + (schedule), `r5` (rounds), `r6` (ctr), `r7` (the data after its whole + blocks), `r8` (`u = len mod 16`, the bytes after them) and `r10` + (scratch), as AES-CFB's final functions do + (`Impl/AesCfb/Arm/Final.lean`); +2. a call of `vg_aes_ctr` (`Impl/AesCtr/Arm.lean`) on the `len / 16` whole + blocks, in a frame that pushes its stack arguments, which leaves `Tₙ₊₁` + in `ctr`; +3. if `u ≠ 0`, the block at `save + 40` zeroed, a call of `vg_aes_ctr` on + that one block, which leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and + the first `u` bytes of the block XORed into the `u` bytes left, a byte at + a time (the modes' `xorByte`); +4. the registers restored from `save`, whose address is reloaded from the + stack. + +The registration's frame zeroes `save`, the block included, on return. +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesCtr.Arm + +open VG.Arm +open VG.Impl.CmacAes.Arm (mov) +open VG.Impl.AesCfb.Arm (loadSave finalSetup wholeFrame finalEnd) +open VG.Impl.Modes.Arm (xorByte) + +/-- The block at `save + 40` zeroed, through `r0`. -/ +def zeroArgs : List Instr := + [.mov .r0 (.imm 0), .str .r0 .r12 40, .str .r0 .r12 44, .str .r0 .r12 48, .str .r0 .r12 52] + +/-- The arguments of the whole-block function on that block: the schedule, +the rounds, the counter block, the block, and in `r12` and `lr`, to push, +`n = 1` and the scratch buffer. -/ +def oneArgs : List Instr := + [mov .r0 .r4, mov .r1 .r5, mov .r2 .r6, .dp .add .r3 .r12 (.imm 40), + .mov .r12 (.imm 1), mov .lr .r10] + +/-- `save` loaded, the block zeroed, and the arguments on it. -/ +def tailArgs : List Instr := loadSave ++ zeroArgs ++ oneArgs + +/-- The arguments of the XOR: the block (`r0`), the data after the whole +blocks (`r6`) and the bytes left (`r7`). -/ +def xorArgs : List Instr := + loadSave ++ [.dp .add .r0 .r12 (.imm 40), mov .r6 .r7, mov .r7 .r8] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, by a call of the whole-block function `name`, `whole`, on it, and its +first `u` bytes XORed into the data. -/ +def finalTail (name : String) (whole : Prog isa) : Prog isa := + .seq (.block tailArgs) (.seq (wholeFrame name whole) (.seq (.block xorArgs) (.loop (.block xorByte) .ne))) + +/-- The whole function, around calls of the whole-block function `name`, +`whole`. -/ +def final (name : String) (whole : Prog isa) : Prog isa := + .seq (.block finalSetup) (.seq (wholeFrame name whole) + (.seq (.block [.cmp .r8 (.imm 0)]) (.seq (.ite .eq (.block []) (finalTail name whole)) (.block finalEnd)))) + +/-- `vg_aes_ctr_final`, calling `vg_aes_ctr`. -/ +def cryptFinal : Prog isa := final "vg_aes_ctr" crypt + +end VG.Impl.AesCtr.Arm diff --git a/lean/VerifiedGarbage/Impl/AesOfb/Arm/Final.lean b/lean/VerifiedGarbage/Impl/AesOfb/Arm/Final.lean new file mode 100644 index 00000000000..5076fd73b87 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesOfb/Arm/Final.lean @@ -0,0 +1,38 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.Arm +public import VerifiedGarbage.Impl.AesCfb.Arm.Final + +/-! +# AES-OFB of a message's last piece: 32-bit ARM implementation + +`cryptFinal` (schedule = r0, rounds = r1, iv = r2, data = r3, len = `[sp]`, +scratch = `[sp + 4]`, save = `[sp + 8]`): the code of `vg_aes_ofb_final`, +whose registration frames it with a buffer of its own on the stack, `save`, +the seventh argument, where the code keeps its caller's callee-saved +registers and its return address. It is AES-CFB's final function +(`Impl.AesCfb.Arm.final`) around a call of the whole-block AES-OFB function: + +1. the registers saved in `save`, and the arguments kept in callee-saved + registers; +2. a call of `vg_aes_ofb` (`Impl/AesOfb/Arm.lean`) on the `len / 16` whole + blocks, which leaves the last output block `Oₙ` in `iv`; +3. if `u = len mod 16 ≠ 0`, a call of `vg_aes_encrypt_blocks` on the block + at `iv` in place, which leaves `Oₙ₊₁ = CIPH_K(Oₙ)` there, the last output + block used, and its first `u` bytes XORed into the `u` bytes left, a byte + at a time; +4. the registers restored. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesOfb.Arm + +open VG.Arm + +/-- `vg_aes_ofb_final`, calling `vg_aes_ofb`. -/ +def cryptFinal : Prog isa := Impl.AesCfb.Arm.final "vg_aes_ofb" crypt + +end VG.Impl.AesOfb.Arm diff --git a/lean/VerifiedGarbage/Impl/Camellia/Arm/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/Arm/CtrFinal.lean new file mode 100644 index 00000000000..ba6591e2392 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Camellia/Arm/CtrFinal.lean @@ -0,0 +1,87 @@ +module + +public import VerifiedGarbage.Impl.Camellia.Arm.Ctr +public import VerifiedGarbage.Impl.StackScratch.Arm +public import VerifiedGarbage.Impl.AesCfb.Arm.Final + +/-! +# Camellia-CTR of a message's last piece: 32-bit ARM implementation + +`ctrFinal` (schedule = r0, rounds = r1, ctr = r2, data = r3, len = `[sp]`, +save = `[sp + 4]`): the code of `vg_camellia_ctr_final`, whose registration +frames it with a buffer of its own on the stack, `save`, the sixth argument, +of 56 bytes: the caller's callee-saved registers and its return address, +then, at 40, a block of the code's own. It is AES-CTR's final function's +(`Impl/AesCtr/Arm/Final.lean`) with Camellia's arguments, around calls of +`vg_camellia_ctr`, framed by its own working space on the stack +(`ctrFramed`), in a frame that pushes its stack argument, the number of +blocks (`push {r12, lr}`): + +1. the registers saved in `save` (through `r12`), and the arguments kept in + `r4` (schedule), `r5` (rounds), `r6` (ctr), `r7` (the data after its + whole blocks) and `r8` (`u = len mod 16`, the bytes after them), and + `r12` the number of whole blocks; +2. a call of `vg_camellia_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block at `save + 40` zeroed, a call of `vg_camellia_ctr` + on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, + and the first `u` bytes of the block XORed into the `u` bytes left, a byte + at a time (the modes' `xorByte`); +4. the registers restored from `save`, whose address is reloaded from the + stack. + +The registration's frame zeroes `save`, the block included, on return. +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Camellia.Arm + +open VG.Arm +open VG.Impl.CmacAes.Arm (mov) +open VG.Impl.AesCfb.Arm (finalSave finalRestore) +open VG.Impl.Modes.Arm (xorByte) + +/-- `vg_camellia_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.Arm.withStackScratchWiped 88 1 18 ctr + +/-- `save`, the second stack argument, to `r12`. -/ +def ctrSave : List Instr := [.ldrSp .r12 4] + +/-- The arguments to their registers: `r4` the schedule, `r5` the rounds, +`r6` the counter block, `r8` the bytes after the whole blocks, `r12` their +number and `r7` the data after them. -/ +def ctrFinalMoves : List Instr := + [mov .r4 .r0, mov .r5 .r1, mov .r6 .r2, .ldrSp .r8 0, .mov .r12 (.shifted .r8 .lsr 4), + .dp .and .r8 .r8 (.imm 15), .dp .add .r7 .r3 (.shifted .r12 .lsl 4)] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrSave ++ finalSave ++ ctrFinalMoves + +/-- The call of `vg_camellia_ctr`, with the number of blocks in `r12` +pushed as its stack argument. -/ +def ctrCall : Prog isa := .frame (.push [.r12, .lr]) (.call "vg_camellia_ctr" ctrFramed) (.pop .r12 8) + +/-- The block at `save + 40` zeroed, through `r0`, and the arguments of +`vg_camellia_ctr` on it: the schedule, the rounds, the counter block, the +block and, in `r12`, `n = 1`. -/ +def ctrTailArgs : List Instr := + ctrSave ++ [.mov .r0 (.imm 0), .str .r0 .r12 40, .str .r0 .r12 44, .str .r0 .r12 48, .str .r0 .r12 52, + mov .r0 .r4, mov .r1 .r5, mov .r2 .r6, .dp .add .r3 .r12 (.imm 40), .mov .r12 (.imm 1)] + +/-- The arguments of the XOR: the block (`r0`), the data after the whole +blocks (`r6`) and the bytes left (`r7`). -/ +def ctrXorArgs : List Instr := ctrSave ++ [.dp .add .r0 .r12 (.imm 40), mov .r6 .r7, mov .r7 .r8] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrTailArgs) (.seq ctrCall (.seq (.block ctrXorArgs) (.loop (.block xorByte) .ne))) + +/-- `vg_camellia_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq ctrCall + (.seq (.block [.cmp .r8 (.imm 0)]) (.seq (.ite .eq (.block []) ctrFinalTail) (.block (ctrSave ++ finalRestore))))) + +end VG.Impl.Camellia.Arm diff --git a/lean/VerifiedGarbage/Impl/Sm4/Arm/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/Arm/CtrFinal.lean new file mode 100644 index 00000000000..d4ca12ba8ec --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Sm4/Arm/CtrFinal.lean @@ -0,0 +1,84 @@ +module + +public import VerifiedGarbage.Impl.Sm4.Arm.BatchCtr +public import VerifiedGarbage.Impl.StackScratch.Arm +public import VerifiedGarbage.Impl.AesCfb.Arm.Final + +/-! +# SM4-CTR of a message's last piece: 32-bit ARM implementation + +`ctrFinal` (schedule = r0, ctr = r1, data = r2, len = r3, save = `[sp]`): +the code of `vg_sm4_ctr_final`, whose registration frames it with a buffer of +its own on the stack, `save`, the fifth argument, of 56 bytes: the caller's +callee-saved registers and its return address, then, at 40, a block of the +code's own. It is AES-CTR's final function's +(`Impl/AesCtr/Arm/Final.lean`) with SM4's arguments, around calls of +`vg_sm4_ctr`, framed by its own working space on the stack (`ctrFramed`), +whose arguments are all in registers: + +1. the registers saved in `save` (through `r12`), and the arguments kept in + `r4` (schedule), `r6` (ctr), `r7` (the data after its whole blocks) and + `r8` (`u = len mod 16`, the bytes after them), and `r3` the number of + whole blocks; +2. a call of `vg_sm4_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block at `save + 40` zeroed, a call of `vg_sm4_ctr` on + that one block, which leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and + the first `u` bytes of the block XORed into the `u` bytes left, a byte at + a time (the modes' `xorByte`); +4. the registers restored from `save`, whose address is reloaded from the + stack. + +The registration's frame zeroes `save`, the block included, on return. +Only the pointers and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Sm4.Arm + +open VG.Arm +open VG.Impl.CmacAes.Arm (mov) +open VG.Impl.AesCfb.Arm (finalSave finalRestore) +open VG.Impl.Modes.Arm (xorByte) + +/-- `vg_sm4_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.Arm.withStackScratchWiped 1520 0 378 BatchCtr.ctr + +/-- `save`, the stack argument, to `r12`. -/ +def ctrSave : List Instr := [.ldrSp .r12 0] + +/-- The arguments to their registers: `r4` the schedule, `r6` the counter +block, `r8` the bytes after the whole blocks, `r3` their number and `r7` the +data after them. -/ +def ctrFinalMoves : List Instr := + [mov .r4 .r0, mov .r6 .r1, .dp .and .r8 .r3 (.imm 15), .mov .r3 (.shifted .r3 .lsr 4), + .dp .add .r7 .r2 (.shifted .r3 .lsl 4)] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrSave ++ finalSave ++ ctrFinalMoves + +/-- The call of `vg_sm4_ctr`. -/ +def ctrCall : Prog isa := .call "vg_sm4_ctr" ctrFramed + +/-- The block at `save + 40` zeroed, through `r0`, and the arguments of +`vg_sm4_ctr` on it: the schedule, the counter block, the block and `n = 1`. -/ +def ctrTailArgs : List Instr := + ctrSave ++ [.mov .r0 (.imm 0), .str .r0 .r12 40, .str .r0 .r12 44, .str .r0 .r12 48, .str .r0 .r12 52, + mov .r0 .r4, mov .r1 .r6, .dp .add .r2 .r12 (.imm 40), .mov .r3 (.imm 1)] + +/-- The arguments of the XOR: the block (`r0`), the data after the whole +blocks (`r6`) and the bytes left (`r7`). -/ +def ctrXorArgs : List Instr := ctrSave ++ [.dp .add .r0 .r12 (.imm 40), mov .r6 .r7, mov .r7 .r8] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrTailArgs) (.seq ctrCall (.seq (.block ctrXorArgs) (.loop (.block xorByte) .ne))) + +/-- `vg_sm4_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq ctrCall + (.seq (.block [.cmp .r8 (.imm 0)]) (.seq (.ite .eq (.block []) ctrFinalTail) (.block (ctrSave ++ finalRestore))))) + +end VG.Impl.Sm4.Arm diff --git a/lean/VerifiedGarbage/Proof/AesCfb/Arm/Final.lean b/lean/VerifiedGarbage/Proof/AesCfb/Arm/Final.lean index b799d8a8f58..0b13d7a5f4e 100644 --- a/lean/VerifiedGarbage/Proof/AesCfb/Arm/Final.lean +++ b/lean/VerifiedGarbage/Proof/AesCfb/Arm/Final.lean @@ -1027,16 +1027,15 @@ theorem FPre.argsWf {s₀ : State} (hp : FPre s₀) : · exact hp.scr_arg.symm · exact hp.sv_arg.symm -theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeArm (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeArm (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeArm (cfbMode enc)).pre (modeArm (cfbMode enc)).pub whole) +theorem final_rel {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeArm M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeArm M).post s s') + (hct : ConstantTime isa (modeArm M).pre (modeArm M).pub whole) (hd : armStack whole = 8) {s₀ s₀' : State} (h0 : (finalArm enc).pre s₀) (h0' : (finalArm enc).pre s₀') (hq : (finalArm enc).pub s₀ s₀') : RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole) fun _ _ => True := by have hp := FPre.of h0 have hp' := FPre.of h0' - let M := cfbMode enc -- The registers saved and the arguments set up. have r₁ := rel_agree (F := fun s => s = s₀) (F' := fun s => s = s₀') (G := Setup s₀) (G' := Setup s₀') (argTaint [.r0, .r1, .r2, .r3] 12) @@ -1128,10 +1127,10 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} (fun _ h => WP.mono (final_end_wp hp' h) fun _ _ => trivial) exact (r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅)))).mono (fun _ _ h => h) fun _ _ _ => trivial -theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeArm (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeArm (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeArm (cfbMode enc)).pre (modeArm (cfbMode enc)).pub whole) +theorem final_ct {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeArm M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeArm M).post s s') + (hct : ConstantTime isa (modeArm M).pre (modeArm M).pub whole) (hd : armStack whole = 8) : ConstantTime isa (finalArm enc).pre (finalArm enc).pub (final name whole) := fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct hd h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 @@ -1174,14 +1173,14 @@ theorem decrypt_stack : armStack decrypt = 8 := by theorem encryptFinal_verified : Verified Arm.target encryptFinal (finalScratchContract true) := Verified.of_correct (final_correct (fun _ hs => AesCbc.Arm.whole_wp encBody_ok hs) encrypt_stack) - (final_ct (fun _ hs => AesCbc.Arm.whole_wp encBody_ok hs) (AesCbc.Arm.whole_ct encBody_ok encBody_ct) - encrypt_stack) + (final_ct (enc := true) (fun _ hs => AesCbc.Arm.whole_wp encBody_ok hs) + (AesCbc.Arm.whole_ct encBody_ok encBody_ct) encrypt_stack) (final_implies true) theorem decryptFinal_verified : Verified Arm.target decryptFinal (finalScratchContract false) := Verified.of_correct (final_correct (fun _ hs => AesCbc.Arm.whole_wp decBody_ok hs) decrypt_stack) - (final_ct (fun _ hs => AesCbc.Arm.whole_wp decBody_ok hs) (AesCbc.Arm.whole_ct decBody_ok decBody_ct) - decrypt_stack) + (final_ct (enc := false) (fun _ hs => AesCbc.Arm.whole_wp decBody_ok hs) + (AesCbc.Arm.whole_ct decBody_ok decBody_ct) decrypt_stack) (final_implies false) /-! ## With `save` on the stack diff --git a/lean/VerifiedGarbage/Proof/AesCtr/Arm/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/Arm/Final.lean new file mode 100644 index 00000000000..ebc5653f5e5 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/Arm/Final.lean @@ -0,0 +1,1167 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.Arm.Final +public import VerifiedGarbage.Proof.AesCtr.Final +public import VerifiedGarbage.Proof.AesCtr.Spec +public import VerifiedGarbage.Proof.AesCfb.Arm.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.Arm +public import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.AesCtr.Arm.Body +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.CmacAes.Arm.Words +import VerifiedGarbage.Proof.Cmac.Block32 +import VerifiedGarbage.Proof.Framework.Arm.Contract +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Arm.Exec +import VerifiedGarbage.Proof.Framework.Arm.Inline +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.Framework.Arm.RelCT +import VerifiedGarbage.Proof.Framework.Arm.RegUpd +meta import VerifiedGarbage.Impl.AesCtr.Arm.Final +meta import VerifiedGarbage.Proof.AesCtr.Final +meta import VerifiedGarbage.Proof.AesCtr.Spec +meta import VerifiedGarbage.Proof.AesCfb.Arm.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Impl.StackScratch.Arm +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.AesCtr.Arm.Body +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.CmacAes.Arm.Words +meta import VerifiedGarbage.Proof.Cmac.Block32 +meta import VerifiedGarbage.Proof.Framework.Arm.Contract +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Arm.Exec +meta import VerifiedGarbage.Proof.Framework.Arm.Inline +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.Framework.Arm.RelCT +meta import VerifiedGarbage.Proof.Framework.Arm.RegUpd + +/-! +# AES-CTR of a message's last piece on ARMv7 + +`cryptFinal_framed`: `vg_aes_ctr_final` (`Impl/AesCtr/Arm/Final.lean`) meets +`Proof.AesCtr.finalRoundsContract`, from which the shared contract follows +(`Proof.AesCtr.final_keyed`). + +The code is proven against `ctrFinalArm`, with a third stack argument `save` +of 56 bytes (`final_implies`: the shared contract with it, +`finalScratchContract`), as a caller of the whole-block function +`vg_aes_ctr` through its contract (`modeArm ctrMode`), in a frame that pushes +its stack arguments: what a call needs and leaves (`WCall`, `WPost`, +`w_call`, constant time by `w_rel`). + +* `final_setup_wp`: as AES-CFB's final functions', `save`'s address loaded, + the registers saved there, and the arguments set up (AES-CFB's `Setup`); +* `whole_wp`: the call on the `n = len / 16` whole blocks (AES-CFB's + `Whole ctrMode`), which leaves `Tₙ₊₁` in `ctr`; +* `final_mid_wp`: if `u = len % 16` bytes are left, the block at `save + 40` + zeroed and the call on that one block (`tail_args_wp`, `tail_call_wp`), + which leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` + bytes XORed into them (`Modes.Arm.xorLoop_wp`, `tail_xor_wp`); what is + left before the registers are restored is `Done`; +* `final_end_wp`: the registers restored from `save`; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the whole-block function's constant time, every address and branch from the +pointers and `len`, which agree in both runs. `cryptFinal_framed` runs the +code with `save` in a frame of 72 bytes on the stack +(`Arm.Verified.stackScratchWiped`), zeroed on return. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr.Arm + +open VG VG.Arm +open VG.Spec.Aes (bytesAt) +open VG.Impl.CmacAes.Arm (mov) +open VG.Impl.AesCfb.Arm (finalSaved loadSave finalSave finalMoves finalSetup wholeFrame finalRestore finalEnd) +open VG.Impl.AesCtr.Arm (zeroArgs oneArgs tailArgs xorArgs finalTail final cryptFinal) +open VG.Proof.AesCfb.Arm (fW fR fIv fD fL fS fV fN fU fT fTa fSch fIvR fData fBlk fTail fScr fArg fStk fWk + fIv0 fBlks svMem fN_eq fU_eq blk_sub tail_sub fL_lt fU_lt shr4 and15 shl4 finalMoves_eq Setup Whole + Whole.of_fupd final_test_wp blocksAt_frame' below8_sub preserved_saved finalSat setup_taint test_taint + end_taint nil_taint armStack_noFrames encBlocks_stack) +open VG.Proof.AesCbc (Mode) +open VG.Proof.AesCbc.Arm (modeArm) +open VG.Proof.AesGcm.Arm (below toNat_ofNat32 pushed_sp8 hspA hA fA view_gpr view_sp arg0 arg1 argAddr0 + cover_pushed cover_pushed' cover_frame covers_append' stackArg_callEntry stackArgAddr_callEntry) +open VG.Arm.FrameStack (armStack belowA) +open VG.Proof.MdStream.Arm (Upd op2_imm op2_reg op2_lsr op2_lsl wp_mov wp_add wp_and wp_cmp wp_ldrSp eval_eq + eval_ne ofNat_beq_zero) +open VG.Proof.Modes.Arm (XPre XInv XDone xorLoop_wp xf add0_32) + +/-- The code's contract, with the arguments `(schedule = r0, rounds = r1, +ctr = r2, data = r3, len = [sp], scratch = [sp + 4], save = [sp + 8])`, +`save` of 56 bytes: the data and the counter block as `Spec.Ctr.CryptFinal` +says, by AES with the key schedule it is given. -/ +def ctrFinalArm : Contract isa where + pre s := + let sched : Region := ⟨State.addr (s.gpr .r0), 240⟩ + let iv : Region := ⟨State.addr (s.gpr .r2), 16⟩ + let data : Region := ⟨State.addr (s.gpr .r3), (stackArg s 0).toNat⟩ + let scr : Region := ⟨State.addr (stackArg s 1), 2176⟩ + let sv : Region := ⟨State.addr (stackArg s 2), 56⟩ + let args : Region := ⟨stackArgAddr s 0, 12⟩ + let stk : Region := ⟨State.addr s.sp - BitVec.ofNat 64 16, 16⟩ + 16 ≤ s.sp.toNat ∧ s.sp.toNat + 12 ≤ 2 ^ 32 ∧ + s.rd = [sched, args] ∧ s.wr = [iv, data, scr, sv] ∧ + sched.Disjoint iv ∧ sched.Disjoint data ∧ sched.Disjoint scr ∧ sched.Disjoint sv ∧ + iv.Disjoint data ∧ iv.Disjoint scr ∧ iv.Disjoint sv ∧ iv.Disjoint args ∧ + data.Disjoint scr ∧ data.Disjoint sv ∧ data.Disjoint args ∧ + scr.Disjoint sv ∧ scr.Disjoint args ∧ sv.Disjoint args ∧ + stk.Disjoint sched ∧ stk.Disjoint iv ∧ stk.Disjoint data ∧ stk.Disjoint scr ∧ + stk.Disjoint sv ∧ stk.Disjoint args ∧ + (s.gpr .r0).toNat + 240 ≤ 2 ^ 32 ∧ (s.gpr .r2).toNat + 16 ≤ 2 ^ 32 ∧ + (s.gpr .r3).toNat + (stackArg s 0).toNat ≤ 2 ^ 32 ∧ (stackArg s 1).toNat + 2176 ≤ 2 ^ 32 ∧ + (stackArg s 2).toNat + 56 ≤ 2 ^ 32 ∧ + ((s.gpr .r1).toNat = 10 ∨ (s.gpr .r1).toNat = 12 ∨ (s.gpr .r1).toNat = 14) + post s s' := + Spec.Ctr.CryptFinal (ciphAt s.mem (State.addr (s.gpr .r0)) (s.gpr .r1).toNat) s.mem s'.mem + (State.addr (s.gpr .r2)) (State.addr (s.gpr .r3)) (stackArg s 0).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .r0 = s₂.gpr .r0 ∧ s₁.gpr .r1 = s₂.gpr .r1 ∧ s₁.gpr .r2 = s₂.gpr .r2 ∧ + s₁.gpr .r3 = s₂.gpr .r3 ∧ stackArg s₁ 0 = stackArg s₂ 0 ∧ stackArg s₁ 1 = stackArg s₂ 1 ∧ + stackArg s₁ 2 = stackArg s₂ 2 + +/-- The contract the frame needs: the shared one, with `save`, 56 bytes, as +a seventh argument, and 16 bytes of stack (the whole-block function's frame +and the one it pushes around its calls). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract Arm.abi Spec.Ctr.aesFinalSig "save" .u64 7 (finalPre Arm.abi.ptrBits) + (finalPost Arm.abi.ptrBits) false 16 (some (finalLeak Arm.abi.ptrBits)) + +/-- A state satisfying the precondition: AES-CFB's, with `save` of 56 +bytes. -/ +def ctrSat : State := + { finalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩, ⟨0x6000, 56⟩] } + +theorem final_implies : ctrFinalArm.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, ctrFinalArm, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] + [ctrSat, finalSat, Arm.stackArg, Arm.stackArgAddr, Mem.readW, Mem.read] using ctrSat + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`, the block in it, and the cipher. -/ +abbrev cSv : Region := ⟨State.addr (fV s₀), 56⟩ +abbrev cBk32 : BitVec 32 := fV s₀ + 40 +abbrev cBk : Addr := State.addr (fV s₀) + BitVec.ofNat 64 40 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ +abbrev cCiph : Spec.Cbc.Cipher := Spec.Cbc.aesWith (fR s₀) (fWk s₀) + +/-- What the function writes, after the save: the block, not the saved +registers. -/ +abbrev cW : List Region := [fIvR s₀, fData s₀, fScr s₀, cBlk s₀, fStk s₀] + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + sp_lo : 16 ≤ s₀.sp.toNat + sp_hi : s₀.sp.toNat + 12 ≤ 2 ^ 32 + rd : s₀.rd = [fSch s₀, fArg s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_scr : (fSch s₀).Disjoint (fScr s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_scr : (fIvR s₀).Disjoint (fScr s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + iv_arg : (fIvR s₀).Disjoint (fArg s₀) + data_scr : (fData s₀).Disjoint (fScr s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_arg : (fData s₀).Disjoint (fArg s₀) + scr_sv : (fScr s₀).Disjoint (cSv s₀) + scr_arg : (fScr s₀).Disjoint (fArg s₀) + sv_arg : (cSv s₀).Disjoint (fArg s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_iv : (fStk s₀).Disjoint (fIvR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_scr : (fStk s₀).Disjoint (fScr s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + stk_arg : (fStk s₀).Disjoint (fArg s₀) + sch_fit : (fW s₀).toNat + 240 ≤ 2 ^ 32 + iv_fit : (fIv s₀).toNat + 16 ≤ 2 ^ 32 + data_fit : (fD s₀).toNat + fL s₀ ≤ 2 ^ 32 + scr_fit : (fS s₀).toNat + 2176 ≤ 2 ^ 32 + sv_fit : (fV s₀).toNat + 56 ≤ 2 ^ 32 + rounds : fR s₀ = 10 ∨ fR s₀ = 12 ∨ fR s₀ = 14 + +theorem CPre.of {s₀ : State} (h : ctrFinalArm.pre s₀) : CPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24, a25, a26, a27, a28, a29, a30⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24, a25, a26, a27, a28, a29, a30⟩ + +/-! ## Regions -/ + +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem CPre.blk_fit : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 32 := by + have := hp.data_fit; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem CPre.sched_sub : Region.Sub ⟨State.addr (fW s₀), 16 * (fR s₀ + 1)⟩ (fSch s₀) := + Region.sub_prefix (by rcases hp.rounds with h | h | h <;> omega) + +theorem CPre.sched_len : 16 * (fR s₀ + 1) ≤ 2 ^ 64 := by + rcases hp.rounds with h | h | h <;> omega + +/-- The stack arguments' addresses. -/ +theorem CPre.argAddr {k : Nat} (hk : k < 3) : + stackArgAddr s₀ k = stackArgAddr s₀ 0 + BitVec.ofNat 64 (4 * k) := by + have := hp.sp_hi + simp only [stackArgAddr] + rw [addr_add (by omega), addr_add (by omega)] + simp + +theorem CPre.arg_in {k : Nat} (hk : k < 3) : InRegions (s₀.rd ++ s₀.wr) (stackArgAddr s₀ k) 4 := by + refine ⟨fArg s₀, by simp [hp.rd], ?_⟩ + rw [hp.argAddr hk] + exact Offset.contains_base _ (by omega) (by omega) + +/-- The tail, as `r7` holds it. -/ +theorem CPre.tail_lt (hu : fU s₀ ≠ 0) : (fD s₀).toNat + 16 * fN s₀ < 2 ^ 32 := by + have := hp.data_fit; have := Nat.div_add_mod (fL s₀) 16; rw [fN_eq]; rw [fU_eq] at hu; omega + +theorem CPre.tailA (hu : fU s₀ ≠ 0) : State.addr (fT s₀) = fTa s₀ := addr_add (hp.tail_lt hu) + +theorem CPre.tail_toNat (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.tail_lt hu + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +/-- The block, as `r3` and `r0` hold it. -/ +theorem CPre.bkA : State.addr (cBk32 s₀) = cBk s₀ := addr_add (k := 40) (by have := hp.sv_fit; omega) + +theorem CPre.bk_toNat : (cBk32 s₀).toNat = (fV s₀).toNat + 40 := by + have := hp.sv_fit + rw [BitVec.toNat_add, show (40 : BitVec 32).toNat = 40 from rfl, Nat.mod_eq_of_lt (by omega)] + +end + +/-- The save changes only `save`. -/ +theorem svMem_frame (s₀ : State) : Frame [cSv s₀] s₀.mem (svMem s₀) := + Spill.saveMem_frame _ _ _ (L := 56) (by decide) finalSaved (by decide) + +/-- Everything the function writes, from entry. -/ +theorem big_frame {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : + Frame [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +/-- The stack arguments survive what the function writes. -/ +theorem CPre.argMem {s₀ : State} (hp : CPre s₀) {m : Mem} + (hf : Frame [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] s₀.mem m) {k : Nat} (hk : k < 3) : + m.readW (stackArgAddr s₀ k) 32 = stackArg s₀ k := by + refine hf.readW (r := fArg s₀) ?_ (fun r hr => ?_) (by decide) + · rw [hp.argAddr hk]; exact Offset.contains_base _ (by omega) (by omega) + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.iv_arg.symm + · exact hp.data_arg.symm + · exact hp.scr_arg.symm + · exact hp.sv_arg.symm + · exact hp.stk_arg.symm + +/-- The stack arguments survive the save. -/ +theorem CPre.svArg {s₀ : State} (hp : CPre s₀) {k : Nat} (hk : k < 3) : + (svMem s₀).readW (stackArgAddr s₀ k) 32 = stackArg s₀ k := + hp.argMem ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) hk + +/-! ## Saving the registers -/ + +theorem final_setup_wp {s₀ : State} (hp : CPre s₀) : WP isa (.block finalSetup) s₀ (Setup s₀) := by + show WP isa (.block (.ldrSp .r12 8 :: (finalSave ++ finalMoves))) s₀ _ + refine wp_ldrSp (a := stackArgAddr s₀ 2) (by decide) rfl (hp.arg_in (by decide)) fun s₁ u₁ => ?_ + have r12₁ : s₁.gpr .r12 = fV s₀ := u₁.gpr + have sv := hp.sv_fit + refine Spill.save_slots_ok (lo := 0) (hi := 36) (by decide) (by rw [r12₁]; omega) (fun d _ hd => ?_) ?_ + · rw [u₁.wr, hp.wr, r12₁] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have m₂ : Spill.saveMem s₁.mem (State.addr (s₁.gpr .r12)) s₁.gpr finalSaved = svMem s₀ := by + rw [u₁.mem, r12₁] + exact Spill.saveMem_congr _ _ _ fun p hp' => u₁.other _ (by + simp only [finalSaved, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + generalize hs₂ : ({ s₁ with mem := Spill.saveMem s₁.mem (State.addr (s₁.gpr .r12)) s₁.gpr finalSaved } : State) = s₂ + have g₂ : s₂.gpr = s₁.gpr := by rw [← hs₂] + have mem₂ : s₂.mem = svMem s₀ := by rw [← hs₂, m₂] + have rd₂ : s₂.rd = s₀.rd := by rw [← hs₂, u₁.rd] + have wr₂ : s₂.wr = s₀.wr := by rw [← hs₂, u₁.wr] + have sp₂ : s₂.sp = s₀.sp := by rw [← hs₂, u₁.sp] + have keep₂ : ∀ r, r ≠ .r12 → s₂.gpr r = s₀.gpr r := fun r h => by rw [g₂, u₁.other _ h] + rw [finalMoves_eq] + refine wp_mov (op2_reg _ _) fun s₃ u₃ => wp_mov (op2_reg _ _) fun s₄ u₄ => wp_mov (op2_reg _ _) fun s₅ u₅ => ?_ + have in₅ : ∀ k < 3, InRegions (s₅.rd ++ s₅.wr) (stackArgAddr s₀ k) 4 := fun k hk => by + rw [u₅.rd, u₄.rd, u₃.rd, u₅.wr, u₄.wr, u₃.wr, rd₂, wr₂]; exact hp.arg_in hk + have spA : ∀ k, State.addr (s₅.sp + BitVec.ofNat 32 (4 * k)) = stackArgAddr s₀ k := fun k => by + rw [u₅.sp, u₄.sp, u₃.sp, sp₂]; rfl + refine wp_ldrSp (a := stackArgAddr s₀ 0) (by decide) (spA 0) (in₅ 0 (by decide)) fun s₆ u₆ => ?_ + refine wp_ldrSp (a := stackArgAddr s₀ 1) (by decide) (by rw [u₆.sp]; exact spA 1) (by + rw [u₆.rd, u₆.wr]; exact in₅ 1 (by decide)) fun s₇ u₇ => ?_ + have mem₅ : s₅.mem = svMem s₀ := by rw [u₅.mem, u₄.mem, u₃.mem, mem₂] + have r8₆ : s₆.gpr .r8 = stackArg s₀ 0 := by rw [u₆.gpr, mem₅, hp.svArg (by decide)] + have r10₇ : s₇.gpr .r10 = stackArg s₀ 1 := by rw [u₇.gpr, u₆.mem, mem₅, hp.svArg (by decide)] + refine wp_mov (op2_lsr (by decide)) fun s₈ u₈ => wp_and (op2_imm (by decide)) fun s₉ u₉ => ?_ + refine wp_add (op2_lsl (by decide)) fun s₁₀ u₁₀ => wp_mov (op2_reg _ _) fun s₁₁ u₁₁ => WP.block_nil ?_ + have hN : 16 * fN s₀ < 2 ^ 32 := by have := fL_lt s₀; rw [fN_eq]; omega + have r12₈ : s₈.gpr .r12 = BitVec.ofNat 32 (fN s₀) := by + rw [u₈.gpr, u₇.other _ (by decide), r8₆, shr4] + have r8₉ : s₉.gpr .r8 = BitVec.ofNat 32 (fU s₀) := by + rw [u₉.gpr, u₈.other _ (by decide), u₇.other _ (by decide), r8₆] + exact and15 _ + have k₃ : ∀ r, r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → r ≠ .r12 → s₅.gpr r = s₀.gpr r := fun r h4 h5 h6 h12 => by + rw [u₅.other _ h6, u₄.other _ h5, u₃.other _ h4, keep₂ _ h12] + have k₈ : ∀ r, r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → r ≠ .r8 → r ≠ .r10 → r ≠ .r12 → r ≠ .r7 → r ≠ .lr → + s₁₁.gpr r = s₀.gpr r := fun r h4 h5 h6 h8 h10 h12 h7 hlr => by + rw [u₁₁.other _ hlr, u₁₀.other _ h7, u₉.other _ h8, u₈.other _ h12, u₇.other _ h10, u₆.other _ h8, + k₃ _ h4 h5 h6 h12] + exact { + r0 := k₈ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r1 := k₈ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r2 := k₈ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r3 := k₈ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r4 := by + rw [u₁₁.other _ (by decide), u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), + u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.gpr, keep₂ _ (by decide)] + r5 := by + rw [u₁₁.other _ (by decide), u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), + u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.gpr, + u₃.other _ (by decide), keep₂ _ (by decide)] + r6 := by + rw [u₁₁.other _ (by decide), u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), + u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr, u₄.other _ (by decide), + u₃.other _ (by decide), keep₂ _ (by decide)] + r7 := by + rw [u₁₁.other _ (by decide), u₁₀.gpr, u₉.other .r12 (by decide), u₉.other .r3 (by decide), r12₈, shl4 hN, + u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), k₃ _ (by decide) (by decide) + (by decide) (by decide)] + r8 := by rw [u₁₁.other _ (by decide), u₁₀.other _ (by decide), r8₉] + r10 := by + rw [u₁₁.other _ (by decide), u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), + r10₇] + r12 := by rw [u₁₁.other _ (by decide), u₁₀.other _ (by decide), u₉.other _ (by decide), r12₈] + lr := by + rw [u₁₁.gpr, u₁₀.other _ (by decide), u₉.other _ (by decide), u₈.other _ (by decide), r10₇] + sp := by rw [u₁₁.sp, u₁₀.sp, u₉.sp, u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, sp₂] + mem := by rw [u₁₁.mem, u₁₀.mem, u₉.mem, u₈.mem, u₇.mem, u₆.mem, mem₅] + rd := by rw [u₁₁.rd, u₁₀.rd, u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, rd₂] + wr := by rw [u₁₁.wr, u₁₀.wr, u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, wr₂] } + +/-! ## A call of the whole-block function -/ + +/-- The 16 bytes below the stack pointer `sp`, which a call uses: its frame +and the one the whole-block function pushes. -/ +abbrev stk16 (sp : BitVec 32) : Region := ⟨State.addr sp - BitVec.ofNat 64 16, 16⟩ + +theorem below_stk (sp : BitVec 32) : Region.Sub (below sp) (stk16 sp) := + Offset.sub_below _ (by decide) (by decide) + +theorem below16_stk {sp : BitVec 32} (hsp : 16 ≤ sp.toNat) : + Region.Sub ⟨State.addr (sp - 8) - BitVec.ofNat 64 8, 8⟩ (stk16 sp) := by + rw [hA (s := { finalSat with sp := sp }) (show 8 ≤ sp.toNat by omega), + show (8 : Addr) = BitVec.ofNat 64 8 from rfl, BitVec.sub_sub, BitVec.ofNat_add_ofNat] + exact Region.sub_prefix (by decide) + +theorem belowA16_stk {sp : BitVec 32} (hsp : 16 ≤ sp.toNat) : Region.Sub (belowA (sp - 8) 8) (stk16 sp) := by + show Region.Sub ⟨State.addr (sp - 8 - BitVec.ofNat 32 8), 8⟩ _ + rw [BitVec.sub_sub, show (8 : BitVec 32) + BitVec.ofNat 32 8 = BitVec.ofNat 32 16 from rfl, + FrameStack.addr_sub' (by omega)] + exact Region.sub_prefix (by decide) + +/-- What a call of `vg_aes_ctr` needs: the key schedule at `W` for `R` +rounds, the counter block at `C`, `n` blocks at `D` and the scratch buffer at +`S`, with `n` in `r12` and `S` in `lr`, to push. -/ +structure WCall (s : State) (W R C D S : BitVec 32) (n : Nat) : Prop where + r0 : s.gpr .r0 = W + r1 : s.gpr .r1 = R + r2 : s.gpr .r2 = C + r3 : s.gpr .r3 = D + r12 : s.gpr .r12 = BitVec.ofNat 32 n + lr : s.gpr .lr = S + rounds : R.toNat = 10 ∨ R.toNat = 12 ∨ R.toNat = 14 + hsp : 16 ≤ s.sp.toNat + fitW : W.toNat + 240 ≤ 2 ^ 32 + fitC : C.toNat + 16 ≤ 2 ^ 32 + fitD : D.toNat + 16 * n ≤ 2 ^ 32 + fitS : S.toNat + 2176 ≤ 2 ^ 32 + wc : (⟨State.addr W, 240⟩ : Region).Disjoint ⟨State.addr C, 16⟩ + wd : (⟨State.addr W, 240⟩ : Region).Disjoint ⟨State.addr D, 16 * n⟩ + ws : (⟨State.addr W, 240⟩ : Region).Disjoint ⟨State.addr S, 2176⟩ + cd : (⟨State.addr C, 16⟩ : Region).Disjoint ⟨State.addr D, 16 * n⟩ + cs : (⟨State.addr C, 16⟩ : Region).Disjoint ⟨State.addr S, 2176⟩ + ds : (⟨State.addr D, 16 * n⟩ : Region).Disjoint ⟨State.addr S, 2176⟩ + bw : (stk16 s.sp).Disjoint ⟨State.addr W, 240⟩ + bc : (stk16 s.sp).Disjoint ⟨State.addr C, 16⟩ + bd : (stk16 s.sp).Disjoint ⟨State.addr D, 16 * n⟩ + bs : (stk16 s.sp).Disjoint ⟨State.addr S, 2176⟩ + reads : Covers [⟨State.addr W, 240⟩] (s.rd ++ s.wr) + writes : Covers [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩, ⟨State.addr S, 2176⟩] s.wr + +/-- AES with `R` rounds and the key schedule at `W`. -/ +abbrev wCiph (m : Mem) (W R : BitVec 32) : Spec.Cbc.Cipher := + Spec.Cbc.aesWith R.toNat (bytesAt m (State.addr W) (16 * (R.toNat + 1))) + +/-- What a call of `vg_aes_ctr` leaves. -/ +structure WPost (s : State) (W R C D S : BitVec 32) (n : Nat) (s' : State) : Prop where + rd : s'.rd = s.rd + wr : s'.wr = s.wr + sp : s'.sp = s.sp + saved : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r + frame : Frame [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩, ⟨State.addr S, 2176⟩, stk16 s.sp] s.mem s'.mem + out : Spec.Cbc.blocksAt s'.mem (State.addr D) n = + Spec.Ctr.crypt (wCiph s.mem W R) (bytesAt s.mem (State.addr C) 16) (Spec.Cbc.blocksAt s.mem (State.addr D) n) + ctr : bytesAt s'.mem (State.addr C) 16 = Spec.Ctr.next (bytesAt s.mem (State.addr C) 16) n + +abbrev wRd (sp W : BitVec 32) : List Region := [⟨State.addr W, 240⟩, below sp] +abbrev wWr (C D S : BitVec 32) (n : Nat) : List Region := + [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩, ⟨State.addr S, 2176⟩] + +theorem crypt_stack : armStack Impl.AesCtr.Arm.crypt = 8 := by + simp only [Impl.AesCtr.Arm.crypt, Impl.AesCbc.Arm.whole, Impl.AesCtr.Arm.body, Impl.AesCbc.Arm.encFrame, + armStack, encBlocks_stack] + decide + +theorem crypt_correct : ∀ s, (modeArm AesCtr.ctrMode).pre s → + ∃ t s', Exec isa Impl.AesCtr.Arm.crypt s t s' ∧ abiPreserved s s' ∧ (modeArm AesCtr.ctrMode).post s s' := + fun _ hs => AesCbc.Arm.whole_wp body_ok hs + +namespace WCall +variable {s : State} {W R C D S : BitVec 32} {n : Nat} (h : WCall s W R C D S n) +include h + +theorem hsp8 : 8 ≤ s.sp.toNat := by have := h.hsp; omega + +theorem n_lt : n < 2 ^ 32 := by have := h.fitD; omega + +theorem pre : (modeArm AesCtr.ctrMode).pre + ((pushed [.r12, .lr] s).callEntry.withRegions (wRd s.sp W) (wWr C D S n)) := by + have hn := toNat_ofNat32 h.n_lt + have hs8 := h.hsp8 + simp only [modeArm, view_gpr _ _ _ .r0 (by decide), view_gpr _ _ _ .r1 (by decide), + view_gpr _ _ _ .r2 (by decide), view_gpr _ _ _ .r3 (by decide), h.r0, h.r1, h.r2, h.r3, + State.withRegions_rd, State.withRegions_wr, view_sp, stackArgAddr_withRegions, stackArg_withRegions, + stackArg_callEntry, stackArgAddr_callEntry, arg0 hs8, arg1 hs8, argAddr0 hs8, h.r12, h.lr, hn, hspA hs8] + have b8 := below_stk s.sp + have b16 := below16_stk h.hsp + refine ⟨trivial, trivial, h.wc, h.wd, h.ws, h.cd, h.cs, h.ds, (h.bc.sub_left b8).symm, + (h.bd.sub_left b8).symm, (h.bs.sub_left b8).symm, h.bw.sub_left b16, h.bc.sub_left b16, + h.bd.sub_left b16, h.bs.sub_left b16, h.fitW, h.fitC, h.fitD, h.fitS, by have := h.hsp; omega, + by have := s.sp.isLt; omega, h.rounds⟩ + +theorem cov : Covers (wRd s.sp W ++ wWr C D S n) ((pushed [.r12, .lr] s).rd ++ (pushed [.r12, .lr] s).wr) := by + refine covers_append' (covers_append' (cover_pushed' h.reads) (cover_frame h.hsp8 (by decide))) + (cover_pushed' (fun x n' hi => ?_)) + obtain ⟨r', hr', hc'⟩ := h.writes x n' hi + exact ⟨r', List.mem_append_right _ hr', hc'⟩ + +theorem covW : Covers (wWr C D S n) (pushed [.r12, .lr] s).wr := cover_pushed h.writes + +end WCall + +theorem w_call {s : State} {W R C D S : BitVec 32} {n : Nat} (h : WCall s W R C D S n) : + WP isa (wholeFrame "vg_aes_ctr" Impl.AesCtr.Arm.crypt) s (WPost s W R C D S n) := by + have hs8 := h.hsp8 + refine WP.frame (rs := [.r12, .lr]) (r := .r12) rfl (by simpa using hs8) (by simp) ?_ + refine FrameStack.WP.callF (k := modeArm AesCtr.ctrMode) crypt_correct (rd := wRd s.sp W) + (wr := wWr C D S n) h.pre h.cov h.covW (by rw [crypt_stack, pushed_sp8, hspA hs8]; have := h.hsp; omega) ?_ + intro s₂ hrd₂ hwr₂ hsp₂ hf hcs hpost + have hn := toNat_ofNat32 h.n_lt + have hR' : 16 * (R.toNat + 1) ≤ 240 := by rcases h.rounds with h' | h' | h' <;> omega + have fA' := fA (s := s) hs8 + have b8 := below_stk s.sp + have bytesW : bytesAt (pushed [.r12, .lr] s).mem (State.addr W) (16 * (R.toNat + 1)) = + bytesAt s.mem (State.addr W) (16 * (R.toNat + 1)) := + Proof.Cmac.bytesAt_frame fA' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ((h.bw.sub_left b8).symm.sub_left (Region.sub_prefix hR'))) (by omega) + have bytesC : bytesAt (pushed [.r12, .lr] s).mem (State.addr C) 16 = bytesAt s.mem (State.addr C) 16 := + Proof.Cmac.bytesAt_frame fA' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact (h.bc.sub_left b8).symm) (by decide) + have blocksD : Spec.Cbc.blocksAt (pushed [.r12, .lr] s).mem (State.addr D) n = + Spec.Cbc.blocksAt s.mem (State.addr D) n := + blocksAt_frame' fA' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact (h.bd.sub_left b8).symm) + obtain ⟨hdata, hctr⟩ := hpost + simp only [State.withRegions_mem, State.callEntry_mem, view_gpr _ _ _ .r0 (by decide), + view_gpr _ _ _ .r1 (by decide), view_gpr _ _ _ .r2 (by decide), view_gpr _ _ _ .r3 (by decide), h.r0, h.r1, + h.r2, h.r3, stackArg_withRegions, stackArg_callEntry, arg0 hs8, h.r12, hn, bytesW, bytesC, + blocksD, AesCtr.ctrMode_out, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] at hdata hctr + have fB : Frame (wWr C D S n ++ [belowA (pushed [.r12, .lr] s).sp (armStack Impl.AesCtr.Arm.crypt)]) + (pushed [.r12, .lr] s).mem s₂.mem := hf + rw [crypt_stack, pushed_sp8] at fB + refine ⟨?_, ?_, ?_, fun r hr hlr => ?_, ?_, ?_, ?_⟩ + · rw [popped_rd, hrd₂, pushed_rd] + · rw [popped_wr, hwr₂, pushed_wr]; rfl + · rw [popped_sp, hsp₂, pushed_sp8]; exact BitVec.sub_add_cancel _ _ + · rw [popped_gpr (by rintro rfl; simp [preserved] at hr), hcs r hr hlr, pushed_gpr] + · rw [popped_mem] + refine (fA'.sub fun r hr => ?_).trans (fB.sub fun r hr => ?_) + · simp only [List.mem_singleton] at hr; subst hr + exact ⟨stk16 s.sp, by simp, b8⟩ + · simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨stk16 s.sp, by simp, belowA16_stk h.hsp⟩ + · rw [popped_mem]; exact hdata + · rw [popped_mem]; exact hctr + +/-- Calls of `vg_aes_ctr` with the same arguments and stack pointer in both +runs are constant time. -/ +theorem w_rel {P : State → State → Prop} + (h : ∀ s₁ s₂, P s₁ s₂ → ∃ W R C D S : BitVec 32, ∃ n : Nat, + WCall s₁ W R C D S n ∧ WCall s₂ W R C D S n ∧ s₁.sp = s₂.sp) : + RelCT isa P (wholeFrame "vg_aes_ctr" Impl.AesCtr.Arm.crypt) fun _ _ => True := by + refine RelCT.frame (fun s₁ s₂ hp => by obtain ⟨_, _, _, _, _, _, _, _, e⟩ := h _ _ hp; exact e) ?_ + intro a b t₁ t₂ a' b' ⟨s₁, s₂, hp, pa, pb⟩ e₁ e₂ + obtain ⟨W, R, C, D, S, n, h₁, h₂, hsp⟩ := h _ _ hp + rw [push_pushed (rs := [.r12, .lr]) rfl (by simpa using h₁.hsp8), Option.some.injEq] at pa + rw [push_pushed (rs := [.r12, .lr]) rfl (by simpa using h₂.hsp8), Option.some.injEq] at pb + subst pa pb + refine RelCT.call (k := modeArm AesCtr.ctrMode) crypt_correct (AesCbc.Arm.whole_ct body_ok body_ct) + (wRd s₁.sp W) (wWr C D S n) (P := fun x y => x = pushed [.r12, .lr] s₁ ∧ y = pushed [.r12, .lr] s₂) + (fun x y ⟨ex, ey⟩ => ?_) _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂ + subst ex ey + have p₂ := h₂.pre + rw [← hsp] at p₂ + refine ⟨h₁.pre, p₂, ?_, h₁.cov, h₁.covW, hsp ▸ h₂.cov, h₂.covW⟩ + simp only [modeArm, stackArg_withRegions, stackArg_callEntry, arg0 h₁.hsp8, arg1 h₁.hsp8, arg0 h₂.hsp8, + arg1 h₂.hsp8, view_gpr _ _ _ .r0 (by decide), view_gpr _ _ _ .r1 (by decide), view_gpr _ _ _ .r2 (by decide), + view_gpr _ _ _ .r3 (by decide), view_sp, h₁.r0, h₁.r1, h₁.r2, h₁.r3, h₁.r12, h₁.lr, h₂.r0, h₂.r1, h₂.r2, + h₂.r3, h₂.r12, h₂.lr, hsp] + exact ⟨trivial, trivial, trivial, trivial, trivial, trivial, trivial⟩ + +/-! ## The whole blocks -/ + +/-- The memory of the regions apart from what the function writes. -/ +theorem CPre.sched_big {s₀ : State} (hp : CPre s₀) : + ∀ r ∈ [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀], + (⟨State.addr (fW s₀), 16 * (fR s₀ + 1)⟩ : Region).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.sch_iv.sub_left hp.sched_sub + · exact hp.sch_data.sub_left hp.sched_sub + · exact hp.sch_scr.sub_left hp.sched_sub + · exact hp.sch_sv.sub_left hp.sched_sub + · exact hp.stk_sch.symm.sub_left hp.sched_sub + +/-- The key schedule, from any memory the function leaves. -/ +theorem CPre.wk {s₀ : State} (hp : CPre s₀) {m : Mem} + (hf : Frame [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] s₀.mem m) : + wCiph m (fW s₀) (s₀.gpr .r1) = cCiph s₀ := by + show Spec.Cbc.aesWith (fR s₀) (bytesAt m (State.addr (fW s₀)) (16 * (fR s₀ + 1))) = _ + rw [Proof.Cmac.bytesAt_frame hf hp.sched_big hp.sched_len] + +theorem CPre.svFrame {s₀ : State} (_ : CPre s₀) : + Frame [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] s₀.mem (svMem s₀) := + (svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr] + +theorem setup_call {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WCall s (fW s₀) (s₀.gpr .r1) (fIv s₀) (fD s₀) (fS s₀) (fN s₀) := by + have hst : stk16 s.sp = fStk s₀ := by rw [h.sp] + refine ⟨h.r0, h.r1, h.r2, h.r3, h.r12, h.lr, hp.rounds, by rw [h.sp]; exact hp.sp_lo, hp.sch_fit, hp.iv_fit, + hp.blk_fit, hp.scr_fit, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), hp.sch_scr, + hp.iv_data.sub_right (blk_sub s₀), hp.iv_scr, hp.data_scr.sub_left (blk_sub s₀), by rw [hst]; exact hp.stk_sch, + by rw [hst]; exact hp.stk_iv, by rw [hst]; exact hp.stk_data.sub_right (blk_sub s₀), + by rw [hst]; exact hp.stk_scr, ?_, ?_⟩ + · rw [h.rd, h.wr, hp.rd] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +theorem whole_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WP isa (wholeFrame "vg_aes_ctr" Impl.AesCtr.Arm.crypt) s (Whole AesCtr.ctrMode s₀) := by + refine WP.mono (w_call (setup_call hp h)) fun s' w => ?_ + have keep : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r := w.saved + have sv := hp.svFrame + have eW : wCiph s.mem (fW s₀) (s₀.gpr .r1) = cCiph s₀ := by rw [h.mem]; exact hp.wk sv + have eIv : bytesAt s.mem (State.addr (fIv s₀)) 16 = fIv0 s₀ := by + rw [h.mem]; exact Proof.Cmac.bytesAt_frame (svMem_frame s₀) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide) + have eB : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = fBlks s₀ := by + rw [h.mem]; exact blocksAt_frame' (svMem_frame s₀) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀)) + have hst : stk16 s.sp = fStk s₀ := by rw [h.sp] + refine ⟨by rw [keep .r4 (by simp [preserved]) (by decide), h.r4], + by rw [keep .r5 (by simp [preserved]) (by decide), h.r5], + by rw [keep .r6 (by simp [preserved]) (by decide), h.r6], + by rw [keep .r7 (by simp [preserved]) (by decide), h.r7], + by rw [keep .r8 (by simp [preserved]) (by decide), h.r8], + by rw [keep .r10 (by simp [preserved]) (by decide), h.r10], + by rw [w.sp, h.sp], by rw [w.rd, h.rd], by rw [w.wr, h.wr], ?_, ?_, ?_⟩ + · rw [← h.mem]; have f := w.frame; rw [hst] at f; exact f + · rw [w.out, eW, eIv, eB, AesCtr.ctrMode_out] + · rw [w.ctr, eIv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + +/-! ## The partial last block -/ + +section +variable (s₀ : State) + +/-- What the function writes before the XOR. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, fScr s₀, cBlk s₀, fStk s₀] + +end + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem whole_cW1 {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h | h <;> simp [h] + +/-- The partial block is apart from what the function writes before the XOR. -/ +theorem CPre.tail_cW1 {s₀ : State} (hp : CPre s₀) : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact hp.data_scr.sub_left (tail_sub s₀) + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + +/-- The whole blocks are apart from what the function writes after them. -/ +theorem CPre.blk_tailW {s₀ : State} (hp : CPre s₀) : + ∀ r ∈ [fIvR s₀, cBlk s₀, fScr s₀, fStk s₀], (fBlk s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (blk_sub s₀)).symm + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (blk_sub s₀) + · exact (hp.stk_data.sub_right (blk_sub s₀)).symm + +/-- The counter block is apart from the block and the tail. -/ +theorem CPre.iv_blk {s₀ : State} (hp : CPre s₀) : (fIvR s₀).Disjoint (cBlk s₀) := + hp.iv_sv.sub_right (blk_sv_sub s₀) + +/-- What the arguments of the call on the block leave. -/ +structure TArgs (s₀ s : State) : Prop where + call : WCall s (fW s₀) (s₀.gpr .r1) (fIv s₀) (cBk32 s₀) (fS s₀) 1 + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = + Spec.Ctr.crypt (cCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fIv s₀)) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + tailb : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) + +theorem zeroArgs_eq (is : List Instr) : + zeroArgs ++ is = .mov .r0 (.imm 0) :: (Proof.CmacAes.Arm.zeroBlk .r0 .r12 40 ++ is) := rfl + +theorem oneArgs_eq : oneArgs = [.mov .r0 (.reg .r4), .mov .r1 (.reg .r5), .mov .r2 (.reg .r6), + .dp .add .r3 .r12 (.imm 40), .mov .r12 (.imm 1), .mov .lr (.reg .r10)] := rfl + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block tailArgs) s (TArgs s₀) := by + show WP isa (.block (.ldrSp .r12 8 :: (zeroArgs ++ oneArgs))) s _ + have f1 := whole_cW1 h + have big := big_frame (cW1_cW f1) + refine wp_ldrSp (a := stackArgAddr s₀ 2) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) fun s₁ u₁ => ?_ + have r12₁ : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big (by decide) + rw [zeroArgs_eq] + refine wp_mov (op2_imm (by decide)) fun s₂ u₂ => ?_ + have sv := hp.sv_fit + have r12₂ : s₂.gpr .r12 = fV s₀ := by rw [u₂.other _ (by decide), r12₁] + have bA : State.addr (s₂.gpr .r12) + BitVec.ofNat 64 40 = cBk s₀ := by rw [r12₂] + refine Proof.CmacAes.Arm.zeroBlk_ok u₂.gpr (by decide) (by rw [r12₂]; omega) ?_ + fun s₃ g₃ m₃ rd₃ wr₃ sp₃ => ?_ + · rw [bA, u₂.wr, u₁.wr, h.wr, hp.wr] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨cSv s₀, by simp, 40, rfl, by simp⟩ + rw [bA] at m₃ + rw [oneArgs_eq] + refine wp_mov (op2_reg _ _) fun s₄ u₄ => wp_mov (op2_reg _ _) fun s₅ u₅ => wp_mov (op2_reg _ _) fun s₆ u₆ => + wp_add (op2_imm (by decide)) fun s₇ u₇ => wp_mov (op2_imm (by decide)) fun s₈ u₈ => + wp_mov (op2_reg _ _) fun s₉ u₉ => WP.block_nil ?_ + have g₂ : ∀ r, r ≠ .r0 → r ≠ .r12 → s₃.gpr r = s.gpr r := fun r h0 h12 => by + rw [g₃, u₂.other _ h0, u₁.other _ h12] + have mem₉ : s₉.mem = Proof.Cmac.zero4 s.mem (cBk s₀) := by + rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, m₃, u₂.mem, u₁.mem] + have sp₉ : s₉.sp = s₀.sp := by rw [u₉.sp, u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, sp₃, u₂.sp, u₁.sp, h.sp] + have rd₉ : s₉.rd = s₀.rd := by rw [u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, rd₃, u₂.rd, u₁.rd, h.rd] + have wr₉ : s₉.wr = s₀.wr := by rw [u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, wr₃, u₂.wr, u₁.wr, h.wr] + have zf : Frame [cBlk s₀] s.mem (Proof.Cmac.zero4 s.mem (cBk s₀)) := AesCbc.zero4_frame _ _ + have zd : ∀ {p : Addr} {n : Nat}, (⟨p, n⟩ : Region).Disjoint (cBlk s₀) → n ≤ 2 ^ 64 → + bytesAt (Proof.Cmac.zero4 s.mem (cBk s₀)) p n = bytesAt s.mem p n := fun hd hn => + Proof.Cmac.bytesAt_frame zf (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hd) hn + have hst : stk16 s₉.sp = fStk s₀ := by rw [sp₉] + have bkA := hp.bkA + have hbk := hp.bk_toNat + refine ⟨⟨?_, ?_, ?_, ?_, by rw [u₉.other _ (by decide), u₈.gpr]; rfl, ?_, hp.rounds, by rw [sp₉]; exact hp.sp_lo, + hp.sch_fit, hp.iv_fit, by rw [hbk]; omega, hp.scr_fit, hp.sch_iv, ?_, hp.sch_scr, ?_, hp.iv_scr, ?_, + by rw [hst]; exact hp.stk_sch, by rw [hst]; exact hp.stk_iv, ?_, by rw [hst]; exact hp.stk_scr, ?_, ?_⟩, + ?_, ?_, sp₉, rd₉, wr₉, ?_, ?_, ?_, ?_, fun q hq => ?_⟩ + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.gpr, g₂ _ (by decide) (by decide), h.r4] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.gpr, u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r5] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr, + u₅.other _ (by decide), u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r6] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.gpr, u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), g₃, u₂.other _ (by decide), r12₁] + · rw [u₉.gpr, u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r10] + · rw [bkA, Nat.mul_one]; exact hp.sch_sv.sub_right (blk_sv_sub s₀) + · rw [bkA, Nat.mul_one]; exact hp.iv_blk + · rw [bkA, Nat.mul_one]; exact (hp.scr_sv.sub_right (blk_sv_sub s₀)).symm + · rw [hst, bkA, Nat.mul_one]; exact hp.stk_sv.sub_right (blk_sv_sub s₀) + · rw [rd₉, wr₉, hp.rd] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · rw [wr₉, hp.wr, bkA, Nat.mul_one] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 40, rfl, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r7] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r8] + · rw [mem₉] + exact f1.trans (zf.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [mem₉, blocksAt_frame' zf (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀)), h.blocks, AesCtr.ctrMode_out] + · rw [mem₉, zd hp.iv_blk (by decide), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + · rw [mem₉, Proof.Cmac.zero4_bytes]; rfl + · rw [mem₉] + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; have := fU_lt s₀; omega + rw [zf.bytes (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)) hlen hq, + f1.bytes hp.tail_cW1 hlen hq, + (svMem_frame s₀).bytes (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (tail_sub s₀)) hlen hq] + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = + Spec.Ctr.crypt (cCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fIv s₀)) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀ + 1) + key : bytesAt s.mem (cBk s₀) 16 = cCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + tailb : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) + +theorem tail_call {s₀ : State} (hp : CPre s₀) {s s' : State} (h : TArgs s₀ s) + (w : WPost s (fW s₀) (s₀.gpr .r1) (fIv s₀) (cBk32 s₀) (fS s₀) 1 s') : TCall s₀ s' := by + have keep : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r := w.saved + have hst : stk16 s.sp = fStk s₀ := by rw [h.sp] + have fw : Frame [fIvR s₀, cBlk s₀, fScr s₀, fStk s₀] s.mem s'.mem := by + have f := w.frame; rw [hst, hp.bkA, Nat.mul_one] at f; exact f + have big := big_frame (cW1_cW h.frame) + have eW : wCiph s.mem (fW s₀) (s₀.gpr .r1) = cCiph s₀ := hp.wk big + have e1 : ∀ m : Mem, Spec.Cbc.blocksAt m (cBk s₀) 1 = [bytesAt m (cBk s₀) 16] := fun m => by + simp [Spec.Cbc.blocksAt] + have hout := w.out + rw [hp.bkA, eW, h.ctr] at hout + have hkey := Proof.Modes.CtrFinal.bytesAt_of_blocksAt_one (aesWith_length _ _) h.zero hout + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; have := fU_lt s₀; omega + refine ⟨by rw [keep .r7 (by simp [preserved]) (by decide), h.r7], + by rw [keep .r8 (by simp [preserved]) (by decide), h.r8], by rw [w.sp, h.sp], by rw [w.rd, h.rd], + by rw [w.wr, h.wr], h.frame.trans (fw.sub fun r hr => ?_), ?_, ?_, hkey, fun q hq => ?_⟩ + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl <;> exact ⟨_, by simp, fun _ h => h⟩ + · rw [blocksAt_frame' fw hp.blk_tailW]; exact h.blocks + · rw [w.ctr, h.ctr]; rfl + · rw [fw.bytes (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (tail_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm) hlen hq] + exact h.tailb q hq + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = + Spec.Ctr.crypt (cCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) ^^^ + (cCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (State.addr (fIv s₀)) 16 = + Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.sp, h.rd, h.wr, cW1_cW (whole_cW1 h), by rw [h.blocks, AesCtr.ctrMode_out], + fun q hq => absurd hq (by omega), + by rw [ite_eq_left_of_eq_true _ _ (eq_true hu), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt]⟩ + +theorem xorArgs_eq : xorArgs = [.ldrSp .r12 8, .dp .add .r0 .r12 (.imm 40), .mov .r6 (.reg .r7), + .mov .r7 (.reg .r8)] := rfl + +theorem tail_xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block xorArgs) (.loop (.block Impl.Modes.Arm.xorByte) .ne)) s (Done s₀) := by + have big := big_frame (cW1_cW h.frame) + rw [xorArgs_eq] + refine WP.seq (wp_ldrSp (a := stackArgAddr s₀ 2) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) fun s₁ u₁ => ?_) + have r12₁ : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big (by decide) + refine wp_add (op2_imm (by decide)) fun s₂ u₂ => wp_mov (op2_reg _ _) fun s₃ u₃ => + wp_mov (op2_reg _ _) fun s₄ u₄ => WP.block_nil ?_ + have hU := fU_lt s₀ + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_fit + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have hT := hp.tail_toNat hu + have aT := hp.tailA hu + have bkA := hp.bkA + have hbk := hp.bk_toNat + have sv := hp.sv_fit + have r0₄ : s₄.gpr .r0 = cBk32 s₀ := by + rw [u₄.other _ (by decide), u₃.other _ (by decide), u₂.gpr, r12₁] + have r6₄ : s₄.gpr .r6 = fT s₀ := by + rw [u₄.other _ (by decide), u₃.gpr, u₂.other _ (by decide), u₁.other _ (by decide), h.r7] + have r7₄ : s₄.gpr .r7 = BitVec.ofNat 32 (fU s₀) := by + rw [u₄.gpr, u₃.other _ (by decide), u₂.other _ (by decide), u₁.other _ (by decide), h.r8] + have mem₄ : s₄.mem = s.mem := by rw [u₄.mem, u₃.mem, u₂.mem, u₁.mem] + have rd₄ : s₄.rd = s₀.rd := by rw [u₄.rd, u₃.rd, u₂.rd, u₁.rd, h.rd] + have wr₄ : s₄.wr = s₀.wr := by rw [u₄.wr, u₃.wr, u₂.wr, u₁.wr, h.wr] + have sp₄ : s₄.sp = s₀.sp := by rw [u₄.sp, u₃.sp, u₂.sp, u₁.sp, h.sp] + have blkT : (cBlk s₀).Disjoint (fTail s₀) := ((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).symm + have xp : XPre s₄ (cBk32 s₀) (fT s₀) (fU s₀) := { + pos := by omega + fK := by rw [hbk]; omega + fR := by rw [hT]; omega + disj := by rw [aT, bkA]; exact blkT.sub_left (Region.sub_prefix (by omega)) + rdK := by + rw [rd₄, wr₄, hp.rd, hp.wr, bkA] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨cSv s₀, by simp, 40, rfl, by simp only; omega⟩ + wrR := by + rw [wr₄, hp.wr, aT] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fData s₀, by simp, 16 * fN s₀, rfl, by simp only; omega⟩ } + have x0 : XInv s₄ (cBk32 s₀) (fT s₀) (fU s₀) 0 s₄ := + ⟨by rw [add0_32, r0₄], by rw [add0_32, r6₄], by rw [Nat.sub_zero, r7₄], by omega, + (Proof.Modes.over_zero _ _ _).symm, rfl, rfl, rfl, fun _ _ _ _ _ _ => rfl⟩ + refine WP.mono (xorLoop_wp xp x0) fun s' d => ?_ + have fo : Frame [fTail s₀] s₄.mem s'.mem := by rw [d.mem, aT]; exact Proof.Modes.over_frame _ _ _ _ + refine ⟨by rw [d.sp, sp₄], by rw [d.rd, rd₄], by rw [d.wr, wr₄], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW h.frame).trans (by + rw [← mem₄] + exact fo.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' fo fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, mem₄] + exact h.blocks + · rw [d.mem, ← aT, Proof.Modes.over_at hq (by omega), aT, mem₄, bkA] + show s.mem (fTa s₀ + BitVec.ofNat 64 q) ^^^ s.mem (cBk s₀ + BitVec.ofNat 64 q) = _ + rw [h.tailb q hq, MdStream.Arm.bytesAt_getD h.key (show q < 16 by omega)] + · rw [ite_eq_right_of_eq_false _ _ (eq_false hu), Proof.Cmac.bytesAt_frame fo (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_data.sub_right (tail_sub s₀)) (by decide), + mem₄, h.ctr] + +theorem final_mid_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) + (hz : s.z = decide (fU s₀ = 0)) : + WP isa (.ite .eq (.block []) (finalTail "vg_aes_ctr" Impl.AesCtr.Arm.crypt)) s (Done s₀) := by + have ev : isa.eval .eq s = some (decide (fU s₀ = 0)) := by show VG.Arm.eval .eq s = _; rw [eval_eq, hz] + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ a => + WP.seq (WP.mono (w_call a.call) fun _ c => tail_xor_wp hp (tail_call hp a c) hu)) + +/-! ## Restoring the registers -/ + +theorem final_end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block finalEnd) s fun s' => abiPreserved s₀ s' ∧ s'.mem = s.mem := by + show WP isa (.block (.ldrSp .r12 8 :: finalRestore)) s _ + refine wp_ldrSp (a := stackArgAddr s₀ 2) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) fun s₁ u₁ => ?_ + have big := big_frame h.frame + have r12 : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big (by decide) + have sv := hp.sv_fit + have hs : Spill.Saved s₁.mem (State.addr (s₁.gpr .r12)) s₀.gpr finalSaved := by + rw [u₁.mem, r12] + refine (Spill.saveMem_saved (lo := 0) (hi := 36) _ _ _ _ (by decide)).frame (lo := 0) (hi := 36) (by decide) + h.frame fun r hr => ?_ + have hsub : Region.Sub ⟨State.addr (fV s₀) + BitVec.ofNat 64 0, 36 - 0⟩ (cSv s₀) := + Offset.sub_base _ (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact hp.scr_sv.symm.sub_left hsub + · exact Offset.disjoint _ (d := 0) (n := 36) (e := 40) (k := 16) (.inl (by decide)) (by decide) (by decide) + · exact hp.stk_sv.symm.sub_left hsub + refine WP.mono (Spill.restore_block_ok (b := .r12) (lo := 0) (hi := 36) (by decide) (by decide) + (by rw [r12]; omega) (fun d _ hd => ?_) hs) fun s' ⟨g, _, m, _, _, sp⟩ => ?_ + · rw [u₁.rd, u₁.wr, h.rd, h.wr, r12] + exact ⟨cSv s₀, by simp [hp.wr], Offset.contains_base _ (by omega) (by omega)⟩ + · exact ⟨⟨fun r hr => Spill.restored_reg g (preserved_saved r hr), by rw [sp, u₁.sp, h.sp]⟩, by rw [m, u₁.mem]⟩ + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : CPre s₀) : + WP isa cryptFinal s₀ fun s' => abiPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (final_setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (final_test_wp h₂) fun s₃ ⟨h₃, z₃⟩ => ?_) + refine WP.seq (WP.mono (final_mid_wp hp h₃ z₃) fun s₄ h₄ => ?_) + exact WP.mono (final_end_wp hp h₄) fun _ ⟨g, m⟩ => ⟨g, s₄, h₄, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalArm.post s₀ s' := by + show Spec.Ctr.CryptFinal (ciphAt s₀.mem (State.addr (fW s₀)) (fR s₀)) s₀.mem s'.mem + (State.addr (fIv s₀)) (State.addr (fD s₀)) (fL s₀) + exact Proof.Modes.CtrFinal.cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalArm.pre s) : + ∃ t s', Exec isa cryptFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalArm.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (CPre.of hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +section +variable {s₀ s₀' : State} (hq : ctrFinalArm.pub s₀ s₀') +include hq + +theorem pub_sp : s₀.sp = s₀'.sp := hq.1 +theorem pub_W : fW s₀ = fW s₀' := hq.2.1 +theorem pub_r1 : s₀.gpr .r1 = s₀'.gpr .r1 := hq.2.2.1 +theorem pub_Iv : fIv s₀ = fIv s₀' := hq.2.2.2.1 +theorem pub_D : fD s₀ = fD s₀' := hq.2.2.2.2.1 +theorem pub_L : stackArg s₀ 0 = stackArg s₀' 0 := hq.2.2.2.2.2.1 +theorem pub_S : fS s₀ = fS s₀' := hq.2.2.2.2.2.2.1 +theorem pub_V : fV s₀ = fV s₀' := hq.2.2.2.2.2.2.2 +theorem pub_N : fN s₀ = fN s₀' := by rw [fN, fN, fL, fL, pub_L hq] +theorem pub_U : fU s₀ = fU s₀' := by rw [fU, fU, fL, fL, pub_L hq] +theorem pub_T : fT s₀ = fT s₀' := by rw [fT, fT, pub_D hq, pub_N hq] + +end + +/-- The arguments' area, apart from what may be written. -/ +theorem CPre.argsWf {s₀ : State} (hp : CPre s₀) : + s₀.sp.toNat + 12 ≤ 2 ^ 32 ∧ ∀ r ∈ s₀.wr, Region.Disjoint ⟨State.addr s₀.sp, 12⟩ r := by + have e : (⟨State.addr s₀.sp, 12⟩ : Region) = fArg s₀ := by simp [stackArgAddr] + refine ⟨hp.sp_hi, ?_⟩ + rw [e, hp.wr] + simp only [List.mem_cons, List.not_mem_nil, or_false] + rintro r (rfl | rfl | rfl | rfl) + · exact hp.iv_arg.symm + · exact hp.data_arg.symm + · exact hp.scr_arg.symm + · exact hp.sv_arg.symm + +/-- Two states of the runs agree on the taint that makes the registers `rs` +and the stack arguments public. -/ +theorem agreeAt {s₀ s₀' : State} (hp : CPre s₀) (hp' : CPre s₀') (hq : ctrFinalArm.pub s₀ s₀') {a b : State} + (sa : a.sp = s₀.sp) (sb : b.sp = s₀'.sp) (wa : a.wr = s₀.wr) (wb : b.wr = s₀'.wr) + (ma : Frame [fIvR s₀, fData s₀, fScr s₀, cSv s₀, fStk s₀] s₀.mem a.mem) + (mb : Frame [fIvR s₀', fData s₀', fScr s₀', cSv s₀', fStk s₀'] s₀'.mem b.mem) {rs : List Reg} + (hr : ∀ r ∈ rs, a.gpr r = b.gpr r) : VG.Arm.Taint.Agree (argTaint rs 12) a b := by + have arg : ∀ {σ s : State}, CPre σ → s.sp = σ.sp → + Frame [fIvR σ, fData σ, fScr σ, cSv σ, fStk σ] σ.mem s.mem → ∀ k < 3, stackArg s k = stackArg σ k := + fun {σ s} hσ hs hm k hk => by + rw [stackArg, show stackArgAddr s k = stackArgAddr σ k by simp only [stackArgAddr, hs]] + exact hσ.argMem hm hk + refine agree_argTaint hr (by rw [sa, sb, pub_sp hq]) (by rw [sa, wa]; exact hp.argsWf) + (by rw [sb, wb]; exact hp'.argsWf) + (argMem_of (j := 3) (by rw [sa, sb, pub_sp hq]) (by rw [sa]; exact hp.sp_hi) fun i hi => ?_) + rw [arg hp sa ma i hi, arg hp' sb mb i hi] + rcases (by omega : i = 0 ∨ i = 1 ∨ i = 2) with rfl | rfl | rfl + · exact pub_L hq + · exact pub_S hq + · exact pub_V hq + +theorem tailArgs_taint : + ∃ h, (taint.check (argTaint [.r4, .r5, .r6, .r10] 12) (.block tailArgs) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (argTaint [.r7, .r8] 12) + (.seq (.block xorArgs) (.loop (.block Impl.Modes.Arm.xorByte) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalArm.pre s₀) (h0' : ctrFinalArm.pre s₀') + (hq : ctrFinalArm.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') cryptFinal fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + let M := AesCtr.ctrMode + -- The registers saved and the arguments set up. + have r₁ := rel_agree (F := fun s => s = s₀) (F' := fun s => s = s₀') (G := Setup s₀) (G' := Setup s₀') + (argTaint [.r0, .r1, .r2, .r3] 12) + (fun s s' e e' => by + subst e e' + refine agreeAt hp hp' hq rfl rfl rfl rfl (Frame.refl _ _) (Frame.refl _ _) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact pub_W hq + · exact pub_r1 hq + · exact pub_Iv hq + · exact pub_D hq) setup_taint + (fun s e => by rw [e]; exact final_setup_wp hp) (fun s e => by rw [e]; exact final_setup_wp hp') + -- The whole blocks. + have r₂ := rel_wp (F := Setup s₀) (F' := Setup s₀') (G := Whole M s₀) (G' := Whole M s₀') + (w_rel fun a b ⟨ha, hb⟩ => ⟨_, _, _, _, _, _, setup_call hp ha, by + rw [pub_W hq, pub_r1 hq, pub_Iv hq, pub_D hq, pub_S hq, pub_N hq]; exact setup_call hp' hb, + by rw [ha.sp, hb.sp, pub_sp hq]⟩) + (fun _ h => whole_wp hp h) (fun _ h => whole_wp hp' h) + -- The test. + have r₃ := rel_agree (F := Whole M s₀) (F' := Whole M s₀') + (G := fun s => Whole M s₀ s ∧ s.z = decide (fU s₀ = 0)) (G' := fun s => Whole M s₀' s ∧ s.z = decide (fU s₀' = 0)) + (Taint.ofRegs [.r8]) (fun a b ha hb => Taint.agree_ofRegs fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [ha.r8, hb.r8, pub_U hq]) test_taint + (fun _ h => final_test_wp h) (fun _ h => final_test_wp h) + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) + (finalTail "vg_aes_ctr" Impl.AesCtr.Arm.crypt) fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := pub_U hq ▸ hu + have a₁ := rel_agree (F := Whole M s₀) (F' := Whole M s₀') (G := TArgs s₀) (G' := TArgs s₀') + (argTaint [.r4, .r5, .r6, .r10] 12) (fun a b ha hb => by + refine agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame (cW1_cW (whole_cW1 ha))) + (big_frame (cW1_cW (whole_cW1 hb))) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · rw [ha.r4, hb.r4, pub_W hq] + · rw [ha.r5, hb.r5, pub_r1 hq] + · rw [ha.r6, hb.r6, pub_Iv hq] + · rw [ha.r10, hb.r10, pub_S hq]) tailArgs_taint + (fun _ h => tail_args_wp hp h) (fun _ h => tail_args_wp hp' h) + have a₂ := rel_wp (F := TArgs s₀) (F' := TArgs s₀') (G := TCall s₀) (G' := TCall s₀') + (w_rel fun a b ⟨ha, hb⟩ => ⟨_, _, _, _, _, _, ha.call, by + rw [pub_W hq, pub_r1 hq, pub_Iv hq, cBk32, pub_V hq, pub_S hq]; exact hb.call, + by rw [ha.sp, hb.sp, pub_sp hq]⟩) + (fun _ h => WP.mono (w_call h.call) fun _ c => tail_call hp h c) + (fun _ h => WP.mono (w_call h.call) fun _ c => tail_call hp' h c) + have a₃ := rel_agree (F := TCall s₀) (F' := TCall s₀') (G := Done s₀) (G' := Done s₀') + (argTaint [.r7, .r8] 12) (fun a b ha hb => by + refine agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame (cW1_cW ha.frame)) + (big_frame (cW1_cW hb.frame)) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · rw [ha.r7, hb.r7, pub_T hq] + · rw [ha.r8, hb.r8, pub_U hq]) xor_taint + (fun _ h => tail_xor_wp hp h hu) (fun _ h => tail_xor_wp hp' h hu') + exact a₁.seq (a₂.seq a₃) + have ev {s : State} {u : Nat} (h : s.z = decide (u = 0)) : isa.eval .eq s = some (decide (u = 0)) := by + show VG.Arm.eval .eq s = _; rw [eval_eq, h] + have r₄ : RelCT isa (fun a b => (Whole M s₀ a ∧ a.z = decide (fU s₀ = 0)) ∧ + (Whole M s₀' b ∧ b.z = decide (fU s₀' = 0))) + (.ite .eq (.block []) (finalTail "vg_aes_ctr" Impl.AesCtr.Arm.crypt)) + (fun a b => Done s₀ a ∧ Done s₀' b) := by + obtain ⟨_, hnil⟩ := nil_taint + refine RelCT.ite (fun a b h => by rw [ev h.1.2, ev h.2.2, pub_U hq]) ?_ ?_ + · refine ((RelCT.taint (A := taint) (Taint.ofRegs []) + (fun _ _ _ => Taint.agree_ofRegs fun r hr => by simp at hr) hnil).wp + (F₁ := Done s₀) (F₂ := Done s₀') fun a b h => ?_).mono (fun _ _ h => h) fun _ _ h => h.2 + have h0 : fU s₀ = 0 := by + have := h.2; rw [ev h.1.1.2] at this; simpa using this + exact ⟨WP.block_nil (done_of_zero h.1.1.1 h0), WP.block_nil (done_of_zero h.1.2.1 (pub_U hq ▸ h0))⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; rw [ev h.1.1.2] at this; simpa using this + -- `save` reloaded, and the registers restored. + have r₅ := rel_agree (F := Done s₀) (F' := Done s₀') (G := fun _ => True) (G' := fun _ => True) + (argTaint [] 12) + (fun a b ha hb => agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame ha.frame) (big_frame hb.frame) + fun r hr => by simp at hr) end_taint + (fun _ h => WP.mono (final_end_wp hp h) fun _ _ => trivial) + (fun _ h => WP.mono (final_end_wp hp' h) fun _ _ => trivial) + exact (r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅)))).mono (fun _ _ h => h) fun _ _ _ => trivial + +theorem final_ct : ConstantTime isa ctrFinalArm.pre ctrFinalArm.pub cryptFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem cryptFinal_verified : Verified Arm.target cryptFinal finalScratchContract := + Verified.of_correct final_correct final_ct final_implies + +/-! ## With `save` on the stack + +The final function has two stack arguments, so `save` is its third: it runs +its code in a frame of 72 bytes (`withStackScratchWiped`): the copies of the +two stack arguments, `save`'s address, the word holding `lr`, and `save`'s +56 bytes, the block included, which it zeroes before returning. The code's +calls use 16 bytes below it, so 88 in all. -/ + +/-- A state satisfying the precondition, without `save`. -/ +def ctrFrameSat : State := + { finalSat with rd := [⟨0x1000, 240⟩, ⟨0x8000, 8⟩], wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩] } + +theorem frameSat_pre : ∃ s, (finalRoundsContract Arm.abi 88).pre s := by + implies_sat [finalRoundsContract, Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [ctrFrameSat, finalSat] using ctrFrameSat + +/-- `cryptFinal`, with `save` on the stack (zeroed on return). -/ +theorem cryptFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 72 2 14 cryptFinal) + (finalRoundsContract Arm.abi 88) := + Arm.Verified.stackScratchWiped (sig := Spec.Ctr.aesFinalSig) (nm := "save") (e := .u64) (n := 7) + (pre := finalPre Arm.abi.ptrBits) (post := finalPost Arm.abi.ptrBits) (wa := false) (stack := 16) + (m := 2) (bytes := 72) cryptFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (finalPre_local _) (finalPost_local _) (finalPost_localOut _) frameSat_pre (hleak := (finalLeak_local _).toL) + +end VG.Proof.AesCtr.Arm diff --git a/lean/VerifiedGarbage/Proof/AesOfb/Arm/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/Arm/Final.lean new file mode 100644 index 00000000000..e860f7142e7 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/Arm/Final.lean @@ -0,0 +1,118 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.Arm.Final +public import VerifiedGarbage.Proof.AesOfb.Final +public import VerifiedGarbage.Proof.AesCfb.Arm.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.Arm +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.Arm.Contract +import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +import VerifiedGarbage.Proof.AesOfb.Arm.Body +public import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec + +/-! +# AES-OFB of a message's last piece on ARMv7 + +`cryptFinal_framed`: `vg_aes_ofb_final` (`Impl/AesOfb/Arm/Final.lean`) meets +`Proof.AesOfb.finalRoundsContract`, from which the shared contract follows +(`Proof.AesOfb.final_keyed`). + +Its code is AES-CFB's final function around a call of the whole-block +AES-OFB function, so its proof is AES-CFB's (`Proof/AesCfb/Arm/Final.lean`), +for OFB as a `Mode` (`ofbMode`): `final_wp` runs it, for any mode, to what it +leaves before restoring the registers (`Done`); `final_ct` gives its +constant time. `ofbFinalArm` is AES-CFB's code contract with OFB's +postcondition, which `final_post` gives from `Done` by +`Proof.AesOfb.cryptFinal_of`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb.Arm + +open VG VG.Arm +open VG.Spec.Aes (bytesAt) +open VG.Proof.AesCfb.Arm (finalArm FPre Done fW fR fIv fD fL fN final_wp final_ct finalSat finalFrameSat + encBlocks_stack) +open VG.Proof.AesCbc.Arm (modeArm) +open VG.Impl.AesOfb.Arm + +/-- The code's contract, with the arguments `(schedule = r0, rounds = r1, +iv = r2, data = r3, len = [sp], scratch = [sp + 4], save = [sp + 8])`: +AES-CFB's final functions' (`finalArm`), with the data and the block at `iv` +as `Spec.Ofb.CryptFinal` says, by AES with the key schedule it is given. -/ +def ofbFinalArm : Contract isa := + { finalArm true with + post := fun s s' => Spec.Ofb.CryptFinal (ciphAt s.mem (State.addr (s.gpr .r0)) (s.gpr .r1).toNat) 16 s.mem + s'.mem (State.addr (s.gpr .r2)) (State.addr (s.gpr .r3)) (stackArg s 0).toNat } + +/-- The contract the frame needs: the shared one, with `save`, 40 bytes, as +a seventh argument, and 16 bytes of stack (the whole-block function's frame +and the one it pushes around its calls). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract Arm.abi Spec.Ofb.aesFinalSig "save" .u64 5 (finalPre Arm.abi.ptrBits) + (finalPost Arm.abi.ptrBits) false 16 + +theorem final_implies : ofbFinalArm.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, ofbFinalArm, finalArm, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] + [finalSat, Arm.stackArg, Arm.stackArgAddr, Mem.readW, Mem.read] using finalSat + +/-- `Spec.Ofb.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done ofbMode s₀ s₁) (hm : s'.mem = s₁.mem) : + ofbFinalArm.post s₀ s' := by + show Spec.Ofb.CryptFinal (ciphAt s₀.mem (State.addr (fW s₀)) (fR s₀)) 16 s₀.mem s'.mem + (State.addr (fIv s₀)) (State.addr (fD s₀)) (fL s₀) + have e := AesCbc.length_blocksAt s₀.mem (State.addr (fD s₀)) (fN s₀) + have hb := h.blocks + have ht := h.tail + have hi := h.iv + rw [ofbMode_out] at hb + rw [ofbMode_chain, e] at ht hi + exact cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact hb) (fun q hq => by rw [hm]; exact ht q hq) + (by rw [hm]; exact hi) + +/-- The whole-block function's frame: 8 bytes around each call of the +block function. -/ +theorem crypt_stack : VG.Arm.FrameStack.armStack crypt = 8 := by + simp only [crypt, Impl.AesCbc.Arm.whole, body, Impl.AesCbc.Arm.encFrame, VG.Arm.FrameStack.armStack, + encBlocks_stack] + decide + +theorem final_correct (s : State) (hs : ofbFinalArm.pre s) : + ∃ t s', Exec isa cryptFinal s t s' ∧ abiPreserved s s' ∧ ofbFinalArm.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := + final_wp (M := ofbMode) (name := "vg_aes_ofb") (fun _ hs => AesCbc.Arm.whole_wp body_ok hs) crypt_stack + (FPre.of (enc := true) hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +theorem cryptFinal_verified : Verified Arm.target cryptFinal finalScratchContract := + Verified.of_correct final_correct + (final_ct (enc := true) (fun _ hs => AesCbc.Arm.whole_wp body_ok hs) (AesCbc.Arm.whole_ct body_ok body_ct) + crypt_stack) + final_implies + +/-! ## With `save` on the stack + +As AES-CFB's final functions, the code runs in a frame of 56 bytes +(`withStackScratchWiped`): the copies of the two stack arguments, `save`'s +address, the word holding `lr`, and `save`'s 40 bytes, which it zeroes before +returning. Its calls use 16 bytes below it, so 72 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract Arm.abi 72).pre s := by + implies_sat [finalRoundsContract, Spec.Ofb.aesFinalSig, finalPre, finalPost, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] [finalFrameSat, finalSat] using finalFrameSat + +/-- `cryptFinal`, with `save` on the stack (zeroed on return). -/ +theorem cryptFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 56 2 10 cryptFinal) + (finalRoundsContract Arm.abi 72) := + Arm.Verified.stackScratchWiped (sig := Spec.Ofb.aesFinalSig) (nm := "save") (e := .u64) (n := 5) + (pre := finalPre Arm.abi.ptrBits) (post := finalPost Arm.abi.ptrBits) (wa := false) (stack := 16) + (m := 2) (bytes := 56) cryptFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (finalPre_local _) (finalPost_local _) (finalPost_localOut _) frameSat_pre + +end VG.Proof.AesOfb.Arm diff --git a/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean new file mode 100644 index 00000000000..456ddc01d7c --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean @@ -0,0 +1,1231 @@ +module + +public import VerifiedGarbage.Impl.Camellia.Arm.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrScratch +public import VerifiedGarbage.Proof.Camellia.Arm.CtrVerified +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.Contract +public import VerifiedGarbage.Proof.Framework.Arm.Spill +public import VerifiedGarbage.Proof.Framework.Arm.ArgTaint +public import VerifiedGarbage.Proof.Framework.Arm.CallF +public import VerifiedGarbage.Proof.CmacAes.Arm.Words +public import VerifiedGarbage.Proof.AesGcm.Arm.Callee +import VerifiedGarbage.Proof.AesCfb.Arm.Final +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Cmac.Block32 +import VerifiedGarbage.Proof.AesCbc.Mem32 +import VerifiedGarbage.Proof.Framework.Arm.Contract +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Arm.Exec +import VerifiedGarbage.Proof.Framework.Arm.Inline +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.Framework.Arm.RelCT +import VerifiedGarbage.Proof.Framework.Arm.RegUpd +meta import VerifiedGarbage.Impl.Camellia.Arm.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrScratch +meta import VerifiedGarbage.Proof.Camellia.Arm.CtrVerified +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.Arm.Spill +meta import VerifiedGarbage.Proof.Framework.Arm.ArgTaint +meta import VerifiedGarbage.Proof.Framework.Arm.CallF +meta import VerifiedGarbage.Proof.CmacAes.Arm.Words +meta import VerifiedGarbage.Proof.AesGcm.Arm.Callee +meta import VerifiedGarbage.Proof.AesCfb.Arm.Final +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Cmac.Block32 +meta import VerifiedGarbage.Proof.AesCbc.Mem32 +meta import VerifiedGarbage.Proof.Framework.Arm.Contract +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Arm.Exec +meta import VerifiedGarbage.Proof.Framework.Arm.Inline +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.Framework.Arm.RelCT +meta import VerifiedGarbage.Proof.Framework.Arm.RegUpd + +/-! +# Camellia-CTR of a message's last piece on ARMv7 + +`ctrFinal_framed`: `vg_camellia_ctr_final` (`Impl/Camellia/Arm/CtrFinal.lean`) +meets `Spec.Camellia.ctrFinalContract`, from `Proof.Camellia.ctrFinalContractSk` +(`Proof.Camellia.ctrFinal_of_sk`). + +The code is proven against `ctrFinalArm`, with a sixth argument `save` of +56 bytes on the stack (`ctrFinal_implies`: the shared contract with it), as +a caller of `vg_camellia_ctr` (framed by its own working space on the stack, +`ctrFramed`), through its contract on the subkeys, `ctrContractSk` +(`ctrFramed_sk`), in a frame that pushes its stack argument: what a call +needs and leaves (`WCall`, `WPost`, `w_call`, constant time by `w_rel`). The +proof is AES-CTR's (`Proof/AesCtr/Arm/Final.lean`), with Camellia's +arguments: + +* `setup_wp`, `whole_wp`: the registers saved in `save`, and the call on the + `n = len / 16` whole blocks (`Whole`), which leaves `Tₙ₊₁` in `ctr`; +* `mid_wp`: if `u = len % 16` bytes are left, the block at `save + 40` + zeroed and the call on it (`tail_args_wp`, `tail_call`), which leaves + `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed + into them (`Modes.Arm.xorLoop_wp`, `tail_xor_wp`); what is left before the + registers are restored is `Done`; +* `end_wp`: the registers restored; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.call`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Camellia.Arm.CtrFinal + +open VG VG.Arm +open VG.Spec.Aes (bytesAt) +open VG.Impl.Camellia.Arm (ctrFramed ctrSave ctrFinalMoves ctrFinalSetup ctrCall ctrTailArgs ctrXorArgs + ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.Arm (finalSaved finalSave finalRestore) +open VG.Proof.AesCfb.Arm (shr4 and15 shl4 blocksAt_frame' preserved_saved) +open VG.Proof.AesGcm.Arm (toNat_ofNat32 below pushed_sp8 hspA hA fA view_gpr view_sp arg0 arg1 argAddr0 + cover_pushed cover_pushed' cover_frame covers_append' stackArg_callEntry stackArgAddr_callEntry) +open VG.Arm.FrameStack (armStack belowA) +open VG.Proof.MdStream.Arm (Upd op2_imm op2_reg op2_lsr op2_lsl wp_mov wp_add wp_and wp_cmp wp_ldrSp + ofNat_beq_zero) +open VG.Proof.Modes.Arm (XPre XInv XDone xorLoop_wp xf add0_32) + +/-- The code's contract, with the arguments `(schedule = r0, rounds = r1, +ctr = r2, data = r3, len = [sp], save = [sp + 4])`, `save` of 56 bytes: the +data and the counter block as `Spec.Ctr.CryptFinal` says, by Camellia with +the subkeys at `schedule`. -/ +def ctrFinalArm : Contract isa where + pre s := + let sched : Region := ⟨State.addr (s.gpr .r0), 272⟩ + let ctr : Region := ⟨State.addr (s.gpr .r2), 16⟩ + let data : Region := ⟨State.addr (s.gpr .r3), (stackArg s 0).toNat⟩ + let sv : Region := ⟨State.addr (stackArg s 1), 56⟩ + let args : Region := ⟨stackArgAddr s 0, 8⟩ + let stk : Region := ⟨State.addr s.sp - BitVec.ofNat 64 2912, 2912⟩ + 2912 ≤ s.sp.toNat ∧ s.sp.toNat + 8 ≤ 2 ^ 32 ∧ + s.rd = [sched, args] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ + ctr.Disjoint data ∧ ctr.Disjoint sv ∧ ctr.Disjoint args ∧ + data.Disjoint sv ∧ data.Disjoint args ∧ sv.Disjoint args ∧ + stk.Disjoint sched ∧ stk.Disjoint ctr ∧ stk.Disjoint data ∧ stk.Disjoint sv ∧ stk.Disjoint args ∧ + (s.gpr .r0).toNat + 272 ≤ 2 ^ 32 ∧ (s.gpr .r2).toNat + 16 ≤ 2 ^ 32 ∧ + (s.gpr .r3).toNat + (stackArg s 0).toNat ≤ 2 ^ 32 ∧ (stackArg s 1).toNat + 56 ≤ 2 ^ 32 ∧ + ((s.gpr .r1).toNat = 18 ∨ (s.gpr .r1).toNat = 24) + post s s' := + Spec.Ctr.CryptFinal (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (State.addr (s.gpr .r0)) + (s.gpr .r1).toNat)) s.mem s'.mem (State.addr (s.gpr .r2)) (State.addr (s.gpr .r3)) (stackArg s 0).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .r0 = s₂.gpr .r0 ∧ s₁.gpr .r1 = s₂.gpr .r1 ∧ s₁.gpr .r2 = s₂.gpr .r2 ∧ + s₁.gpr .r3 = s₂.gpr .r3 ∧ stackArg s₁ 0 = stackArg s₂ 0 ∧ stackArg s₁ 1 = stackArg s₂ 1 + +/-- The contract the frame needs: the shared one on the subkeys, with +`save`, 56 bytes, as a sixth argument, and 2912 bytes of stack (the frame +pushing `vg_camellia_ctr`'s stack argument, and its frame and calls). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract Arm.abi Spec.Camellia.ctrFinalSig "save" .u64 7 (Spec.Camellia.ctrFinalPre Arm.abi.ptrBits) + (Proof.Camellia.ctrFinalPostSk Arm.abi.ptrBits) true 2912 + +/-- A state satisfying the precondition: the schedule at `0x1000`, 18 +rounds, the counter block at `0x2000`, no data at `0x3000` and `save` at +`0x6000` (the stack arguments at `0x8000`). -/ +def ctrFinalSat : State where + gpr r := match r with + | .r0 => 0x1000 | .r1 => 18 | .r2 => 0x2000 | .r3 => 0x3000 | _ => 0 + sp := 0x8000 + n := false + z := false + c := false + v := false + mem a := if a = 0x8005 then 0x60 else 0 + rd := [⟨0x1000, 272⟩, ⟨0x8000, 8⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x6000, 56⟩] + +theorem ctrFinal_implies : ctrFinalArm.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, Proof.Camellia.ctrFinalPostSk, ctrFinalArm, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] + [ctrFinalSat, Arm.stackArg, Arm.stackArgAddr, Mem.readW, Mem.read] using ctrFinalSat + +/-! ## The callee -/ + +/-- `vg_camellia_ctr` meets its contract on the subkeys. -/ +theorem ctrFramed_sk : Verified Arm.target ctrFramed (Proof.Camellia.ctrContractSk Arm.abi 2904) := + Arm.Verified.stackScratchWiped (sig := Spec.Camellia.ctrSig) (nm := "scratch") (e := .u64) (n := 9) + (pre := Spec.Camellia.ctrPre Arm.abi.ptrBits) (post := Proof.Camellia.ctrPostSk Arm.abi.ptrBits) + (wa := true) (stack := 2816) (m := 1) (bytes := 88) + Proof.Camellia.Arm.ctr_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (Proof.Camellia.ctrPre_local _) (Proof.Camellia.ctrPost_local _) (Proof.Camellia.ctrPostOut_local _) + Proof.Camellia.Arm.ctrFrameSat + +theorem ctr_stack : armStack ctrFramed ≤ 2904 := by decide +kernel + +/-- The 2912 bytes below the stack pointer `sp`, which a call uses: the 8 +its frame pushes, and the 2904 of `vg_camellia_ctr` below them. -/ +abbrev stk (sp : BitVec 32) : Region := ⟨State.addr sp - BitVec.ofNat 64 2912, 2912⟩ + +theorem below_stk (sp : BitVec 32) : Region.Sub (below sp) (stk sp) := + Offset.sub_below _ (by decide) (by decide) + +theorem belowA_stk {sp : BitVec 32} {n : Nat} (hn : n ≤ 2904) (hsp : 2912 ≤ sp.toNat) : + Region.Sub (belowA (sp - 8) n) (stk sp) := by + show Region.Sub ⟨State.addr (sp - 8 - BitVec.ofNat 32 n), n⟩ _ + rw [BitVec.sub_sub, show (8 : BitVec 32) + BitVec.ofNat 32 n = BitVec.ofNat 32 (8 + n) by + rw [BitVec.ofNat_add]; rfl, FrameStack.addr_sub' (by omega)] + have e : State.addr sp - BitVec.ofNat 64 (8 + n) = + State.addr sp - BitVec.ofNat 64 2912 + BitVec.ofNat 64 (2904 - n) := by + have := sp.isLt + apply BitVec.eq_of_toNat_eq + simp only [State.addr, BitVec.toNat_add, BitVec.toNat_sub, BitVec.toNat_setWidth, BitVec.toNat_ofNat] + omega + rw [e] + exact Offset.sub_base _ (by omega) + +theorem res_stk (sp : BitVec 32) : + Region.Sub ⟨State.addr sp - BitVec.ofNat 64 8 - BitVec.ofNat 64 2904, 2904⟩ (stk sp) := by + rw [BitVec.sub_sub, BitVec.ofNat_add_ofNat] + exact Region.sub_prefix (by decide) + +/-- What a call of `vg_camellia_ctr` needs: the subkeys at `W` for `R` +rounds, the counter block at `C` and `n` blocks at `D`, in `r0`–`r3`, `n` in +`r12` to push, and the 2912 bytes below the stack pointer. -/ +structure WCall (s : State) (W R C D : BitVec 32) (n : Nat) : Prop where + r0 : s.gpr .r0 = W + r1 : s.gpr .r1 = R + r2 : s.gpr .r2 = C + r3 : s.gpr .r3 = D + r12 : s.gpr .r12 = BitVec.ofNat 32 n + rounds : R.toNat = 18 ∨ R.toNat = 24 + hsp : 2912 ≤ s.sp.toNat + fitW : W.toNat + 272 ≤ 2 ^ 32 + fitC : C.toNat + 16 ≤ 2 ^ 32 + fitD : D.toNat + 16 * n ≤ 2 ^ 32 + wc : (⟨State.addr W, 272⟩ : Region).Disjoint ⟨State.addr C, 16⟩ + wd : (⟨State.addr W, 272⟩ : Region).Disjoint ⟨State.addr D, 16 * n⟩ + cd : (⟨State.addr C, 16⟩ : Region).Disjoint ⟨State.addr D, 16 * n⟩ + bw : (stk s.sp).Disjoint ⟨State.addr W, 272⟩ + bc : (stk s.sp).Disjoint ⟨State.addr C, 16⟩ + bd : (stk s.sp).Disjoint ⟨State.addr D, 16 * n⟩ + reads : Covers [⟨State.addr W, 272⟩] (s.rd ++ s.wr) + writes : Covers [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩] s.wr + +/-- Camellia with the subkeys at `W` for `R` rounds. -/ +abbrev wCiph (m : Mem) (W R : BitVec 32) : Spec.Cbc.Cipher := + Spec.Camellia.cipher (Spec.Camellia.subkeysAt m (State.addr W) R.toNat) + +/-- What a call of `vg_camellia_ctr` leaves. -/ +structure WPost (s : State) (W R C D : BitVec 32) (n : Nat) (s' : State) : Prop where + rd : s'.rd = s.rd + wr : s'.wr = s.wr + sp : s'.sp = s.sp + saved : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r + frame : Frame [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩, stk s.sp] s.mem s'.mem + out : Spec.Cbc.blocksAt s'.mem (State.addr D) n = + Spec.Ctr.crypt (wCiph s.mem W R) (bytesAt s.mem (State.addr C) 16) (Spec.Cbc.blocksAt s.mem (State.addr D) n) + ctr : bytesAt s'.mem (State.addr C) 16 = Spec.Ctr.next (bytesAt s.mem (State.addr C) 16) n + +abbrev wRd (sp W : BitVec 32) : List Region := [⟨State.addr W, 272⟩, ⟨State.addr sp - 8, 4⟩] +abbrev wWr (C D : BitVec 32) (n : Nat) : List Region := [⟨State.addr C, 16⟩, ⟨State.addr D, n * 16⟩] + +namespace WCall +variable {s : State} {W R C D : BitVec 32} {n : Nat} (h : WCall s W R C D n) +include h + +theorem hsp8 : 8 ≤ s.sp.toNat := by have := h.hsp; omega + +theorem n_lt : n < 2 ^ 32 := by have := h.fitD; omega + +theorem pre : (Proof.Camellia.ctrContractSk Arm.abi 2904).pre + ((pushed [.r12, .lr] s).callEntry.withRegions (wRd s.sp W) (wWr C D n)) := by + have hn := toNat_ofNat32 h.n_lt + have hs8 := h.hsp8 + sig_pre [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Spec.Camellia.ctrPre, Arm.abi, Arm.argRegs, + Arm.reduceClassify, Arm.Loc.val] + simp only [stackArgAddr_withRegions, stackArg_withRegions, stackArg_callEntry, stackArgAddr_callEntry, + arg0 hs8, argAddr0 hs8, h.r0, h.r1, h.r2, h.r3, h.r12, hn, FrameStack.sub_toNat' (sp := s.sp) (k := 8) hs8, + FrameStack.addr_sub' (x := s.sp) (k := 8) hs8, Nat.mul_comm n 16] + have b4 : Region.Sub ⟨State.addr s.sp - 8, 4⟩ (stk s.sp) := fun a ha => + below_stk s.sp a (Region.sub_prefix (by decide) a ha) + have rs := res_stk s.sp + refine ⟨by have := h.hsp; omega, by have := s.sp.isLt; omega, rfl, by rw [wWr, Nat.mul_comm]; rfl, h.wc, h.wd, + h.cd, (h.bc.sub_left b4).symm, (h.bd.sub_left b4).symm, h.bw.sub_left rs, h.bc.sub_left rs, h.bd.sub_left rs, + (Offset.base_disjoint_below (State.addr s.sp - BitVec.ofNat 64 8) (n := 2904) (k := 4) (by decide)).symm, + h.fitW, h.fitC, h.fitD, h.rounds⟩ + +theorem cov : Covers (wRd s.sp W ++ wWr C D n) ((pushed [.r12, .lr] s).rd ++ (pushed [.r12, .lr] s).wr) := by + rw [show wWr C D n = [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩] by rw [Nat.mul_comm]] + refine covers_append' (covers_append' (cover_pushed' h.reads) (cover_frame h.hsp8 (by decide))) + (cover_pushed' (fun x n' hi => ?_)) + obtain ⟨r', hr', hc'⟩ := h.writes x n' hi + exact ⟨r', List.mem_append_right _ hr', hc'⟩ + +theorem covW : Covers (wWr C D n) (pushed [.r12, .lr] s).wr := by + rw [show wWr C D n = [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩] by rw [Nat.mul_comm]] + exact cover_pushed h.writes + +end WCall + +theorem w_call {s : State} {W R C D : BitVec 32} {n : Nat} (h : WCall s W R C D n) : + WP isa ctrCall s (WPost s W R C D n) := by + have hs8 := h.hsp8 + refine WP.frame (rs := [.r12, .lr]) (r := .r12) rfl (by simpa using hs8) (by simp) ?_ + refine FrameStack.WP.callF (k := Proof.Camellia.ctrContractSk Arm.abi 2904) ctrFramed_sk.1 (rd := wRd s.sp W) + (wr := wWr C D n) h.pre h.cov h.covW + (by rw [pushed_sp8, hspA hs8]; have := h.hsp; have := ctr_stack; omega) ?_ + intro s₂ hrd₂ hwr₂ hsp₂ hf hcs hpost + have hn := toNat_ofNat32 h.n_lt + have fA' := fA (s := s) hs8 + have b8 := below_stk s.sp + have eW : Spec.Camellia.subkeysAt (pushed [.r12, .lr] s).mem (State.addr W) R.toNat = + Spec.Camellia.subkeysAt s.mem (State.addr W) R.toNat := + Proof.Camellia.subkeysAt_congr (by rcases h.rounds with h' | h' <;> rw [h'] <;> decide) + fun i hi => fA'.bytes (R := ⟨State.addr W, 272⟩) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact (h.bw.sub_left b8).symm) (by show 272 ≤ 2 ^ 64; decide) hi + have bytesC : bytesAt (pushed [.r12, .lr] s).mem (State.addr C) 16 = bytesAt s.mem (State.addr C) 16 := + Proof.Cmac.bytesAt_frame fA' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact (h.bc.sub_left b8).symm) (by decide) + have blocksD : Spec.Cbc.blocksAt (pushed [.r12, .lr] s).mem (State.addr D) n = + Spec.Cbc.blocksAt s.mem (State.addr D) n := + blocksAt_frame' fA' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact (h.bd.sub_left b8).symm) + sig_post [Proof.Camellia.ctrContractSk, Proof.Camellia.ctrPostSk, Spec.Camellia.ctrSig, Arm.abi, Arm.argRegs, + Arm.reduceClassify, Arm.Loc.val] at hpost + have ep : storeWords s.mem (s.sp - 8#32) [s.gpr .r12, s.gpr .lr] = (pushed [.r12, .lr] s).mem := rfl + rw [ep, h.r0, h.r1, h.r2, h.r3, stackArg_withRegions, stackArg_callEntry, arg0 hs8, h.r12, hn] at hpost + obtain ⟨hdata, hctr⟩ := hpost h.rounds + have hdata' : Spec.Cbc.blocksAt s₂.mem (State.addr D) n = + Spec.Ctr.crypt (Spec.Camellia.cipher (Spec.Camellia.subkeysAt (pushed [.r12, .lr] s).mem (State.addr W) R.toNat)) + (bytesAt (pushed [.r12, .lr] s).mem (State.addr C) 16) + (Spec.Cbc.blocksAt (pushed [.r12, .lr] s).mem (State.addr D) n) := hdata + have hctr' : bytesAt s₂.mem (State.addr C) 16 = + Spec.Ctr.next (bytesAt (pushed [.r12, .lr] s).mem (State.addr C) 16) n := hctr + rw [eW, bytesC, blocksD] at hdata' + rw [bytesC] at hctr' + have fB : Frame (wWr C D n ++ [belowA (pushed [.r12, .lr] s).sp (armStack ctrFramed)]) + (pushed [.r12, .lr] s).mem s₂.mem := hf + rw [pushed_sp8] at fB + refine ⟨?_, ?_, ?_, fun r hr hlr => ?_, ?_, ?_, ?_⟩ + · rw [popped_rd, hrd₂, pushed_rd] + · rw [popped_wr, hwr₂, pushed_wr]; rfl + · rw [popped_sp, hsp₂, pushed_sp8]; exact BitVec.sub_add_cancel _ _ + · rw [popped_gpr (by rintro rfl; simp [preserved] at hr), hcs r hr hlr, pushed_gpr] + · rw [popped_mem] + refine (fA'.sub fun r hr => ?_).trans (fB.sub fun r hr => ?_) + · simp only [List.mem_singleton] at hr; subst hr + exact ⟨stk s.sp, by simp, b8⟩ + · simp only [wWr, List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨⟨State.addr D, 16 * n⟩, by simp, fun _ hx => by rwa [Nat.mul_comm] at hx⟩ + · exact ⟨stk s.sp, by simp, belowA_stk ctr_stack h.hsp⟩ + · rw [popped_mem]; exact hdata' + · rw [popped_mem]; exact hctr' + +/-- Calls of `vg_camellia_ctr` with the same arguments and stack pointer in +both runs are constant time. -/ +theorem w_rel {P : State → State → Prop} + (h : ∀ s₁ s₂, P s₁ s₂ → ∃ W R C D : BitVec 32, ∃ n : Nat, + WCall s₁ W R C D n ∧ WCall s₂ W R C D n ∧ s₁.sp = s₂.sp) : + RelCT isa P ctrCall fun _ _ => True := by + refine RelCT.frame (fun s₁ s₂ hp => by obtain ⟨_, _, _, _, _, _, _, e⟩ := h _ _ hp; exact e) ?_ + intro a b t₁ t₂ a' b' ⟨s₁, s₂, hp, pa, pb⟩ e₁ e₂ + obtain ⟨W, R, C, D, n, h₁, h₂, hsp⟩ := h _ _ hp + rw [push_pushed (rs := [.r12, .lr]) rfl (by simpa using h₁.hsp8), Option.some.injEq] at pa + rw [push_pushed (rs := [.r12, .lr]) rfl (by simpa using h₂.hsp8), Option.some.injEq] at pb + subst pa pb + have hn := toNat_ofNat32 h₁.n_lt + refine RelCT.call (k := Proof.Camellia.ctrContractSk Arm.abi 2904) ctrFramed_sk.1 ctrFramed_sk.2.1 + (wRd s₁.sp W) (wWr C D n) (P := fun x y => x = pushed [.r12, .lr] s₁ ∧ y = pushed [.r12, .lr] s₂) + (fun x y ⟨ex, ey⟩ => ?_) _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂ + subst ex ey + have p₂ := h₂.pre + rw [← hsp] at p₂ + refine ⟨h₁.pre, p₂, ?_, h₁.cov, h₁.covW, hsp ▸ h₂.cov, h₂.covW⟩ + sig_pub [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, + Arm.Loc.val] + simp only [stackArg_withRegions, stackArg_callEntry, arg0 h₁.hsp8, arg0 h₂.hsp8, h₁.r0, h₁.r1, h₁.r2, h₁.r3, + h₁.r12, h₂.r0, h₂.r1, h₂.r2, h₂.r3, h₂.r12, hsp] + exact ⟨trivial, trivial, trivial, trivial, trivial, trivial⟩ + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +abbrev fW : BitVec 32 := s₀.gpr .r0 +abbrev fR : Nat := (s₀.gpr .r1).toNat +abbrev fC : BitVec 32 := s₀.gpr .r2 +abbrev fD : BitVec 32 := s₀.gpr .r3 +abbrev fL : Nat := (stackArg s₀ 0).toNat +abbrev fV : BitVec 32 := stackArg s₀ 1 +/-- The number of whole blocks, and of the bytes after them. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +/-- The data after the whole blocks, as a register holds it and as an +address. -/ +abbrev fT : BitVec 32 := fD s₀ + BitVec.ofNat 32 (16 * fN s₀) +abbrev fTa : Addr := State.addr (fD s₀) + BitVec.ofNat 64 (16 * fN s₀) + +abbrev fSch : Region := ⟨State.addr (fW s₀), 272⟩ +abbrev fCR : Region := ⟨State.addr (fC s₀), 16⟩ +abbrev fData : Region := ⟨State.addr (fD s₀), fL s₀⟩ +abbrev fBlk : Region := ⟨State.addr (fD s₀), 16 * fN s₀⟩ +abbrev fTail : Region := ⟨fTa s₀, fU s₀⟩ +abbrev cSv : Region := ⟨State.addr (fV s₀), 56⟩ +abbrev fArg : Region := ⟨stackArgAddr s₀ 0, 8⟩ +abbrev fStk : Region := stk s₀.sp + +/-- The block in `save`. -/ +abbrev cBk32 : BitVec 32 := fV s₀ + 40 +abbrev cBk : Addr := State.addr (fV s₀) + BitVec.ofNat 64 40 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ + +/-- The counter block and the whole blocks on entry, and the cipher. -/ +abbrev fT0 : List Byte := bytesAt s₀.mem (State.addr (fC s₀)) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (State.addr (fD s₀)) (fN s₀) +abbrev cCiph : Spec.Cbc.Cipher := wCiph s₀.mem (fW s₀) (s₀.gpr .r1) + +/-- The memory once the registers are saved. -/ +abbrev svMem : Mem := Spill.saveMem s₀.mem (State.addr (fV s₀)) s₀.gpr finalSaved + +/-- What the function writes after the save: before the XOR, and in all. -/ +abbrev cW1 : List Region := [fCR s₀, fBlk s₀, cBlk s₀, fStk s₀] +abbrev cW : List Region := [fCR s₀, fData s₀, cBlk s₀, fStk s₀] +abbrev cBig : List Region := [fCR s₀, fData s₀, cSv s₀, fStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp_lo : 2912 ≤ s₀.sp.toNat + sp_hi : s₀.sp.toNat + 8 ≤ 2 ^ 32 + rd : s₀.rd = [fSch s₀, fArg s₀] + wr : s₀.wr = [fCR s₀, fData s₀, cSv s₀] + sch_c : (fSch s₀).Disjoint (fCR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + c_data : (fCR s₀).Disjoint (fData s₀) + c_sv : (fCR s₀).Disjoint (cSv s₀) + c_arg : (fCR s₀).Disjoint (fArg s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_arg : (fData s₀).Disjoint (fArg s₀) + sv_arg : (cSv s₀).Disjoint (fArg s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_c : (fStk s₀).Disjoint (fCR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + stk_arg : (fStk s₀).Disjoint (fArg s₀) + sch_fit : (fW s₀).toNat + 272 ≤ 2 ^ 32 + c_fit : (fC s₀).toNat + 16 ≤ 2 ^ 32 + data_fit : (fD s₀).toNat + fL s₀ ≤ 2 ^ 32 + sv_fit : (fV s₀).toNat + 56 ≤ 2 ^ 32 + rounds : fR s₀ = 18 ∨ fR s₀ = 24 + +theorem KPre.of {s₀ : State} (h : ctrFinalArm.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23⟩ + +/-! ## Regions -/ + +theorem fN_eq (s₀ : State) : fN s₀ = fL s₀ / 16 := rfl +theorem fU_eq (s₀ : State) : fU s₀ = fL s₀ % 16 := rfl +theorem fL_lt (s₀ : State) : fL s₀ < 2 ^ 32 := (stackArg s₀ 0).isLt +theorem fU_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_fit : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 32 := by + have := hp.data_fit; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +/-- The stack arguments' addresses. -/ +theorem KPre.argAddr {k : Nat} (hk : k < 2) : + stackArgAddr s₀ k = stackArgAddr s₀ 0 + BitVec.ofNat 64 (4 * k) := by + have := hp.sp_hi + simp only [stackArgAddr] + rw [VG.Arm.addr_add (by omega), VG.Arm.addr_add (by omega)] + simp + +theorem KPre.arg_in {k : Nat} (hk : k < 2) : InRegions (s₀.rd ++ s₀.wr) (stackArgAddr s₀ k) 4 := by + refine ⟨fArg s₀, by simp [hp.rd], ?_⟩ + rw [hp.argAddr hk] + exact Offset.contains_base _ (by omega) (by omega) + +theorem KPre.tail_lt (hu : fU s₀ ≠ 0) : (fD s₀).toNat + 16 * fN s₀ < 2 ^ 32 := by + have := hp.data_fit; have := Nat.div_add_mod (fL s₀) 16; rw [fN_eq]; rw [fU_eq] at hu; omega + +theorem KPre.tailA (hu : fU s₀ ≠ 0) : State.addr (fT s₀) = fTa s₀ := VG.Arm.addr_add (hp.tail_lt hu) + +theorem KPre.tail_toNat (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.tail_lt hu + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem KPre.bkA : State.addr (cBk32 s₀) = cBk s₀ := VG.Arm.addr_add (k := 40) (by have := hp.sv_fit; omega) + +theorem KPre.bk_toNat : (cBk32 s₀).toNat = (fV s₀).toNat + 40 := by + have := hp.sv_fit + rw [BitVec.toNat_add, show (40 : BitVec 32).toNat = 40 from rfl, Nat.mod_eq_of_lt (by omega)] + +theorem KPre.c_blk : (fCR s₀).Disjoint (cBlk s₀) := hp.c_sv.sub_right (blk_sv_sub s₀) + +theorem KPre.sch_big : ∀ r ∈ cBig s₀, (fSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_c + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The cipher, from any memory the function leaves. -/ +theorem KPre.ciph {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : wCiph m (fW s₀) (s₀.gpr .r1) = cCiph s₀ := by + show Spec.Camellia.cipher (Spec.Camellia.subkeysAt m _ _) = _ + rw [Proof.Camellia.subkeysAt_congr (by rcases hp.rounds with h | h <;> simp only [fR] at h <;> rw [h] <;> decide) + fun i hi => hf.bytes (R := fSch s₀) hp.sch_big (by show 272 ≤ 2 ^ 64; decide) hi] + +/-- The stack arguments survive what the function writes. -/ +theorem KPre.argMem {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) {k : Nat} (hk : k < 2) : + m.readW (stackArgAddr s₀ k) 32 = stackArg s₀ k := by + refine hf.readW (r := fArg s₀) ?_ (fun r hr => ?_) (by decide) + · rw [hp.argAddr hk]; exact Offset.contains_base _ (by omega) (by omega) + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.c_arg.symm + · exact hp.data_arg.symm + · exact hp.sv_arg.symm + · exact hp.stk_arg.symm + +end + +/-- The save changes only `save`. -/ +theorem svMem_frame (s₀ : State) : Frame [cSv s₀] s₀.mem (svMem s₀) := + Spill.saveMem_frame _ _ _ (L := 56) (by decide) finalSaved (by decide) + +theorem big_frame {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem KPre.svFrame {s₀ : State} (_ : KPre s₀) : Frame (cBig s₀) s₀.mem (svMem s₀) := + (svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr] + +theorem KPre.svArg {s₀ : State} (hp : KPre s₀) {k : Nat} (hk : k < 2) : + (svMem s₀).readW (stackArgAddr s₀ k) 32 = stackArg s₀ k := hp.argMem hp.svFrame hk + +/-! ## Saving the registers -/ + +/-- What saving the registers and setting up the arguments leaves. -/ +structure Setup (s₀ s : State) : Prop where + r0 : s.gpr .r0 = fW s₀ + r1 : s.gpr .r1 = s₀.gpr .r1 + r2 : s.gpr .r2 = fC s₀ + r3 : s.gpr .r3 = fD s₀ + r4 : s.gpr .r4 = fW s₀ + r5 : s.gpr .r5 = s₀.gpr .r1 + r6 : s.gpr .r6 = fC s₀ + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + r12 : s.gpr .r12 = BitVec.ofNat 32 (fN s₀) + sp : s.sp = s₀.sp + mem : s.mem = svMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem moves_eq : ctrFinalMoves = + [.mov .r4 (.reg .r0), .mov .r5 (.reg .r1), .mov .r6 (.reg .r2), .ldrSp .r8 0, .mov .r12 (.shifted .r8 .lsr 4), + .dp .and .r8 .r8 (.imm 15), .dp .add .r7 .r3 (.shifted .r12 .lsl 4)] := rfl + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (Setup s₀) := by + show WP isa (.block (.ldrSp .r12 4 :: (finalSave ++ ctrFinalMoves))) s₀ _ + refine wp_ldrSp (a := stackArgAddr s₀ 1) (by decide) rfl (hp.arg_in (by decide)) fun s₁ u₁ => ?_ + have r12₁ : s₁.gpr .r12 = fV s₀ := u₁.gpr + have sv := hp.sv_fit + refine Spill.save_slots_ok (lo := 0) (hi := 36) (by decide) (by rw [r12₁]; omega) (fun d _ hd => ?_) ?_ + · rw [u₁.wr, hp.wr, r12₁] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have m₂ : Spill.saveMem s₁.mem (State.addr (s₁.gpr .r12)) s₁.gpr finalSaved = svMem s₀ := by + rw [u₁.mem, r12₁] + exact Spill.saveMem_congr _ _ _ fun p hp' => u₁.other _ (by + simp only [finalSaved, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + generalize hs₂ : ({ s₁ with mem := Spill.saveMem s₁.mem (State.addr (s₁.gpr .r12)) s₁.gpr finalSaved } : State) = s₂ + have g₂ : s₂.gpr = s₁.gpr := by rw [← hs₂] + have mem₂ : s₂.mem = svMem s₀ := by rw [← hs₂, m₂] + have rd₂ : s₂.rd = s₀.rd := by rw [← hs₂, u₁.rd] + have wr₂ : s₂.wr = s₀.wr := by rw [← hs₂, u₁.wr] + have sp₂ : s₂.sp = s₀.sp := by rw [← hs₂, u₁.sp] + have keep₂ : ∀ r, r ≠ .r12 → s₂.gpr r = s₀.gpr r := fun r h => by rw [g₂, u₁.other _ h] + rw [moves_eq] + refine wp_mov (op2_reg _ _) fun s₃ u₃ => wp_mov (op2_reg _ _) fun s₄ u₄ => wp_mov (op2_reg _ _) fun s₅ u₅ => ?_ + refine wp_ldrSp (a := stackArgAddr s₀ 0) (by decide) (by rw [u₅.sp, u₄.sp, u₃.sp, sp₂]; rfl) (by + rw [u₅.rd, u₄.rd, u₃.rd, u₅.wr, u₄.wr, u₃.wr, rd₂, wr₂]; exact hp.arg_in (by decide)) fun s₆ u₆ => ?_ + have mem₅ : s₅.mem = svMem s₀ := by rw [u₅.mem, u₄.mem, u₃.mem, mem₂] + have r8₆ : s₆.gpr .r8 = stackArg s₀ 0 := by rw [u₆.gpr, mem₅, hp.svArg (by decide)] + refine wp_mov (op2_lsr (by decide)) fun s₇ u₇ => wp_and (op2_imm (by decide)) fun s₈ u₈ => ?_ + refine wp_add (op2_lsl (by decide)) fun s₉ u₉ => WP.block_nil ?_ + have hN : 16 * fN s₀ < 2 ^ 32 := by have := fL_lt s₀; rw [fN_eq]; omega + have r12₇ : s₇.gpr .r12 = BitVec.ofNat 32 (fN s₀) := by rw [u₇.gpr, r8₆, shr4] + have k₅ : ∀ r, r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → r ≠ .r12 → s₅.gpr r = s₀.gpr r := fun r h4 h5 h6 h12 => by + rw [u₅.other _ h6, u₄.other _ h5, u₃.other _ h4, keep₂ _ h12] + have k₉ : ∀ r, r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → r ≠ .r12 → r ≠ .r8 → r ≠ .r7 → s₉.gpr r = s₀.gpr r := + fun r h4 h5 h6 h12 h8 h7 => by + rw [u₉.other _ h7, u₈.other _ h8, u₇.other _ h12, u₆.other _ h8, k₅ _ h4 h5 h6 h12] + exact { + r0 := k₉ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r1 := k₉ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r2 := k₉ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r3 := k₉ _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + r4 := by + rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), u₃.gpr, keep₂ _ (by decide)] + r5 := by + rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.gpr, u₃.other _ (by decide), keep₂ _ (by decide)] + r6 := by + rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.gpr, u₄.other _ (by decide), u₃.other _ (by decide), keep₂ _ (by decide)] + r7 := by + rw [u₉.gpr, u₈.other .r12 (by decide), u₈.other .r3 (by decide), r12₇, shl4 hN, u₇.other _ (by decide), + u₆.other _ (by decide), k₅ _ (by decide) (by decide) (by decide) (by decide)] + r8 := by + rw [u₉.other _ (by decide), u₈.gpr, u₇.other _ (by decide), r8₆] + exact and15 _ + r12 := by rw [u₉.other _ (by decide), u₈.other _ (by decide), r12₇] + sp := by rw [u₉.sp, u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, sp₂] + mem := by rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, mem₅] + rd := by rw [u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, rd₂] + wr := by rw [u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, wr₂] } + +/-! ## The whole blocks -/ + +/-- What the call on the whole blocks leaves. -/ +structure Whole (s₀ s : State) : Prop where + r4 : s.gpr .r4 = fW s₀ + r5 : s.gpr .r5 = s₀.gpr .r1 + r6 : s.gpr .r6 = fC s₀ + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame [fCR s₀, fBlk s₀, fStk s₀] (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = Spec.Ctr.next (fT0 s₀) (fN s₀) + +theorem setup_call {s₀ : State} (hp : KPre s₀) {s : State} (h : Setup s₀ s) : + WCall s (fW s₀) (s₀.gpr .r1) (fC s₀) (fD s₀) (fN s₀) := by + have hst : stk s.sp = fStk s₀ := by rw [h.sp] + refine ⟨h.r0, h.r1, h.r2, h.r3, h.r12, hp.rounds, by rw [h.sp]; exact hp.sp_lo, hp.sch_fit, hp.c_fit, + hp.blk_fit, hp.sch_c, hp.sch_data.sub_right (blk_sub s₀), hp.c_data.sub_right (blk_sub s₀), + by rw [hst]; exact hp.stk_sch, by rw [hst]; exact hp.stk_c, by rw [hst]; exact hp.stk_data.sub_right (blk_sub s₀), + ?_, ?_⟩ + · rw [h.rd, h.wr, hp.rd] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fCR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Setup s₀ s) : WP isa ctrCall s (Whole s₀) := by + refine WP.mono (w_call (setup_call hp h)) fun s' w => ?_ + have keep : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r := w.saved + have eW : wCiph s.mem (fW s₀) (s₀.gpr .r1) = cCiph s₀ := by rw [h.mem]; exact hp.ciph hp.svFrame + have eC : bytesAt s.mem (State.addr (fC s₀)) 16 = fT0 s₀ := by + rw [h.mem]; exact Proof.Cmac.bytesAt_frame (svMem_frame s₀) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.c_sv) (by decide) + have eB : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = fBlks s₀ := by + rw [h.mem]; exact blocksAt_frame' (svMem_frame s₀) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀)) + have hst : stk s.sp = fStk s₀ := by rw [h.sp] + refine ⟨by rw [keep .r4 (by simp [preserved]) (by decide), h.r4], + by rw [keep .r5 (by simp [preserved]) (by decide), h.r5], + by rw [keep .r6 (by simp [preserved]) (by decide), h.r6], + by rw [keep .r7 (by simp [preserved]) (by decide), h.r7], + by rw [keep .r8 (by simp [preserved]) (by decide), h.r8], + by rw [w.sp, h.sp], by rw [w.rd, h.rd], by rw [w.wr, h.wr], ?_, ?_, ?_⟩ + · rw [← h.mem]; have f := w.frame; rw [hst] at f; exact f + · rw [w.out, eW, eC, eB] + · rw [w.ctr, eC] + +theorem Whole.of_fupd {s₀ s s' : State} (h : Whole s₀ s) (g : s'.gpr = s.gpr) (m : s'.mem = s.mem) + (rd : s'.rd = s.rd) (wr : s'.wr = s.wr) (sp : s'.sp = s.sp) : Whole s₀ s' := + ⟨by rw [g, h.r4], by rw [g, h.r5], by rw [g, h.r6], by rw [g, h.r7], by rw [g, h.r8], by rw [sp, h.sp], + by rw [rd, h.rd], by rw [wr, h.wr], by rw [m]; exact h.frame, by rw [m]; exact h.blocks, by rw [m]; exact h.ctr⟩ + +/-- The test sets Z if no bytes are left after the whole blocks. -/ +theorem test_wp {s₀ s : State} (h : Whole s₀ s) : + WP isa (.block [.cmp .r8 (.imm 0)]) s fun s' => Whole s₀ s' ∧ s'.z = decide (fU s₀ = 0) := + wp_cmp (op2_imm (by decide)) fun s' f z => WP.block_nil ⟨h.of_fupd f.gpr f.mem f.rd f.wr f.sp, by + rw [z, h.r8]; exact MdStream.Arm.cmp0 (by have := fU_lt s₀; omega)⟩ + +/-! ## The partial last block -/ + +theorem whole_cW1 {s₀ s : State} (h : Whole s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem KPre.tail_cW1 {s₀ : State} (hp : KPre s₀) : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.c_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + +theorem KPre.blk_tailW {s₀ : State} (hp : KPre s₀) : ∀ r ∈ [fCR s₀, cBlk s₀, fStk s₀], (fBlk s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact (hp.c_data.sub_right (blk_sub s₀)).symm + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (blk_sub s₀)).symm + +/-- What the arguments of the call on the block leave. -/ +structure TArgs (s₀ s : State) : Prop where + call : WCall s (fW s₀) (s₀.gpr .r1) (fC s₀) (cBk32 s₀) 1 + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = Spec.Ctr.next (fT0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + tailb : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) + +theorem tailArgs_eq : ctrTailArgs = .ldrSp .r12 4 :: .mov .r0 (.imm 0) :: (Proof.CmacAes.Arm.zeroBlk .r0 .r12 40 ++ + ([.mov .r0 (.reg .r4), .mov .r1 (.reg .r5), .mov .r2 (.reg .r6), .dp .add .r3 .r12 (.imm 40), + .mov .r12 (.imm 1)] : List Instr)) := rfl + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Whole s₀ s) : + WP isa (.block ctrTailArgs) s (TArgs s₀) := by + rw [tailArgs_eq] + have f1 := whole_cW1 h + have big := big_frame (cW1_cW f1) + refine wp_ldrSp (a := stackArgAddr s₀ 1) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) fun s₁ u₁ => ?_ + have r12₁ : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big (by decide) + refine wp_mov (op2_imm (by decide)) fun s₂ u₂ => ?_ + have sv := hp.sv_fit + have r12₂ : s₂.gpr .r12 = fV s₀ := by rw [u₂.other _ (by decide), r12₁] + have bA : State.addr (s₂.gpr .r12) + BitVec.ofNat 64 40 = cBk s₀ := by rw [r12₂] + refine Proof.CmacAes.Arm.zeroBlk_ok u₂.gpr (by decide) (by rw [r12₂]; omega) ?_ + fun s₃ g₃ m₃ rd₃ wr₃ sp₃ => ?_ + · rw [bA, u₂.wr, u₁.wr, h.wr, hp.wr] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨cSv s₀, by simp, 40, rfl, by simp⟩ + rw [bA] at m₃ + refine wp_mov (op2_reg _ _) fun s₄ u₄ => wp_mov (op2_reg _ _) fun s₅ u₅ => wp_mov (op2_reg _ _) fun s₆ u₆ => + wp_add (op2_imm (by decide)) fun s₇ u₇ => wp_mov (op2_imm (by decide)) fun s₈ u₈ => WP.block_nil ?_ + have g₂ : ∀ r, r ≠ .r0 → r ≠ .r12 → s₃.gpr r = s.gpr r := fun r h0 h12 => by + rw [g₃, u₂.other _ h0, u₁.other _ h12] + have mem₈ : s₈.mem = Proof.Cmac.zero4 s.mem (cBk s₀) := by + rw [u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, m₃, u₂.mem, u₁.mem] + have sp₈ : s₈.sp = s₀.sp := by rw [u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, sp₃, u₂.sp, u₁.sp, h.sp] + have rd₈ : s₈.rd = s₀.rd := by rw [u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, rd₃, u₂.rd, u₁.rd, h.rd] + have wr₈ : s₈.wr = s₀.wr := by rw [u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, wr₃, u₂.wr, u₁.wr, h.wr] + have zf : Frame [cBlk s₀] s.mem (Proof.Cmac.zero4 s.mem (cBk s₀)) := AesCbc.zero4_frame _ _ + have hst : stk s₈.sp = fStk s₀ := by rw [sp₈] + have bkA := hp.bkA + have hbk := hp.bk_toNat + refine ⟨⟨?_, ?_, ?_, ?_, by rw [u₈.gpr]; rfl, hp.rounds, by rw [sp₈]; exact hp.sp_lo, hp.sch_fit, hp.c_fit, + by rw [hbk]; omega, hp.sch_c, ?_, ?_, by rw [hst]; exact hp.stk_sch, by rw [hst]; exact hp.stk_c, ?_, ?_, ?_⟩, + ?_, ?_, sp₈, rd₈, wr₈, ?_, ?_, ?_, ?_, fun q hq => ?_⟩ + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.gpr, + g₂ _ (by decide) (by decide), h.r4] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr, u₄.other _ (by decide), + g₂ _ (by decide) (by decide), h.r5] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr, u₅.other _ (by decide), u₄.other _ (by decide), + g₂ _ (by decide) (by decide), h.r6] + · rw [u₈.other _ (by decide), u₇.gpr, u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + g₃, u₂.other _ (by decide), r12₁] + · rw [bkA, Nat.mul_one]; exact hp.sch_sv.sub_right (blk_sv_sub s₀) + · rw [bkA, Nat.mul_one]; exact hp.c_blk + · rw [hst, bkA, Nat.mul_one]; exact hp.stk_sv.sub_right (blk_sv_sub s₀) + · rw [rd₈, wr₈, hp.rd] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · rw [wr₈, hp.wr, bkA, Nat.mul_one] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fCR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 40, rfl, by simp⟩ + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r7] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + u₄.other _ (by decide), g₂ _ (by decide) (by decide), h.r8] + · rw [mem₈] + exact f1.trans (zf.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [mem₈, blocksAt_frame' zf (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀)), h.blocks] + · rw [mem₈, Proof.Cmac.bytesAt_frame zf (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.c_blk) (by decide), h.ctr] + · rw [mem₈, Proof.Cmac.zero4_bytes]; rfl + · rw [mem₈] + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; have := fU_lt s₀; omega + rw [zf.bytes (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)) hlen hq, + f1.bytes hp.tail_cW1 hlen hq, + (svMem_frame s₀).bytes (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (tail_sub s₀)) hlen hq] + +theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by + simp [Spec.Camellia.cipher] + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = Spec.Ctr.next (fT0 s₀) (fN s₀ + 1) + key : bytesAt s.mem (cBk s₀) 16 = cCiph s₀ (Spec.Ctr.next (fT0 s₀) (fN s₀)) + tailb : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) + +theorem tail_call {s₀ : State} (hp : KPre s₀) {s s' : State} (h : TArgs s₀ s) + (w : WPost s (fW s₀) (s₀.gpr .r1) (fC s₀) (cBk32 s₀) 1 s') : TCall s₀ s' := by + have keep : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r := w.saved + have hst : stk s.sp = fStk s₀ := by rw [h.sp] + have fw : Frame [fCR s₀, cBlk s₀, fStk s₀] s.mem s'.mem := by + have f := w.frame; rw [hst, hp.bkA, Nat.mul_one] at f; exact f + have big := big_frame (cW1_cW h.frame) + have eW : wCiph s.mem (fW s₀) (s₀.gpr .r1) = cCiph s₀ := hp.ciph big + have hout := w.out + rw [hp.bkA, eW, h.ctr] at hout + have hkey := Proof.Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero hout + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; have := fU_lt s₀; omega + refine ⟨by rw [keep .r7 (by simp [preserved]) (by decide), h.r7], + by rw [keep .r8 (by simp [preserved]) (by decide), h.r8], by rw [w.sp, h.sp], by rw [w.rd, h.rd], + by rw [w.wr, h.wr], h.frame.trans (fw.sub fun r hr => ?_), ?_, ?_, hkey, fun q hq => ?_⟩ + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl <;> exact ⟨_, by simp, fun _ h => h⟩ + · rw [blocksAt_frame' fw hp.blk_tailW]; exact h.blocks + · rw [w.ctr, h.ctr]; rfl + · rw [fw.bytes (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact (hp.c_data.sub_right (tail_sub s₀)).symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm) hlen hq] + exact h.tailb q hq + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) ^^^ + (cCiph s₀ (Spec.Ctr.next (fT0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = + Spec.Ctr.next (fT0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.sp, h.rd, h.wr, cW1_cW (whole_cW1 h), h.blocks, fun q hq => absurd hq (by omega), + by rw [ite_eq_left_of_eq_true _ _ (eq_true hu), h.ctr]⟩ + +theorem xorArgs_eq : ctrXorArgs = [.ldrSp .r12 4, .dp .add .r0 .r12 (.imm 40), .mov .r6 (.reg .r7), + .mov .r7 (.reg .r8)] := rfl + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block ctrXorArgs) (.loop (.block Impl.Modes.Arm.xorByte) .ne)) s (Done s₀) := by + have big := big_frame (cW1_cW h.frame) + rw [xorArgs_eq] + refine WP.seq (wp_ldrSp (a := stackArgAddr s₀ 1) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) fun s₁ u₁ => ?_) + have r12₁ : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big (by decide) + refine wp_add (op2_imm (by decide)) fun s₂ u₂ => wp_mov (op2_reg _ _) fun s₃ u₃ => + wp_mov (op2_reg _ _) fun s₄ u₄ => WP.block_nil ?_ + have hU := fU_lt s₀ + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_fit + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have hT := hp.tail_toNat hu + have aT := hp.tailA hu + have bkA := hp.bkA + have hbk := hp.bk_toNat + have sv := hp.sv_fit + have r0₄ : s₄.gpr .r0 = cBk32 s₀ := by + rw [u₄.other _ (by decide), u₃.other _ (by decide), u₂.gpr, r12₁] + have r6₄ : s₄.gpr .r6 = fT s₀ := by + rw [u₄.other _ (by decide), u₃.gpr, u₂.other _ (by decide), u₁.other _ (by decide), h.r7] + have r7₄ : s₄.gpr .r7 = BitVec.ofNat 32 (fU s₀) := by + rw [u₄.gpr, u₃.other _ (by decide), u₂.other _ (by decide), u₁.other _ (by decide), h.r8] + have mem₄ : s₄.mem = s.mem := by rw [u₄.mem, u₃.mem, u₂.mem, u₁.mem] + have rd₄ : s₄.rd = s₀.rd := by rw [u₄.rd, u₃.rd, u₂.rd, u₁.rd, h.rd] + have wr₄ : s₄.wr = s₀.wr := by rw [u₄.wr, u₃.wr, u₂.wr, u₁.wr, h.wr] + have sp₄ : s₄.sp = s₀.sp := by rw [u₄.sp, u₃.sp, u₂.sp, u₁.sp, h.sp] + have blkT : (cBlk s₀).Disjoint (fTail s₀) := ((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).symm + have xp : XPre s₄ (cBk32 s₀) (fT s₀) (fU s₀) := { + pos := by omega + fK := by rw [hbk]; omega + fR := by rw [hT]; omega + disj := by rw [aT, bkA]; exact blkT.sub_left (Region.sub_prefix (by omega)) + rdK := by + rw [rd₄, wr₄, hp.rd, hp.wr, bkA] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨cSv s₀, by simp, 40, rfl, by simp only; omega⟩ + wrR := by + rw [wr₄, hp.wr, aT] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fData s₀, by simp, 16 * fN s₀, rfl, by simp only; omega⟩ } + have x0 : XInv s₄ (cBk32 s₀) (fT s₀) (fU s₀) 0 s₄ := + ⟨by rw [add0_32, r0₄], by rw [add0_32, r6₄], by rw [Nat.sub_zero, r7₄], by omega, + (Proof.Modes.over_zero _ _ _).symm, rfl, rfl, rfl, fun _ _ _ _ _ _ => rfl⟩ + refine WP.mono (xorLoop_wp xp x0) fun s' d => ?_ + have fo : Frame [fTail s₀] s₄.mem s'.mem := by rw [d.mem, aT]; exact Proof.Modes.over_frame _ _ _ _ + refine ⟨by rw [d.sp, sp₄], by rw [d.rd, rd₄], by rw [d.wr, wr₄], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW h.frame).trans (by + rw [← mem₄] + exact fo.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' fo fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, mem₄] + exact h.blocks + · rw [d.mem, ← aT, Proof.Modes.over_at hq (by omega), aT, mem₄, bkA] + show s.mem (fTa s₀ + BitVec.ofNat 64 q) ^^^ s.mem (cBk s₀ + BitVec.ofNat 64 q) = _ + rw [h.tailb q hq, MdStream.Arm.bytesAt_getD h.key (show q < 16 by omega)] + · rw [ite_eq_right_of_eq_false _ _ (eq_false hu), Proof.Cmac.bytesAt_frame fo (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.c_data.sub_right (tail_sub s₀)) (by decide), + mem₄, h.ctr] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Whole s₀ s) (hz : s.z = decide (fU s₀ = 0)) : + WP isa (.ite .eq (.block []) ctrFinalTail) s (Done s₀) := by + have ev : isa.eval .eq s = some (decide (fU s₀ = 0)) := by + show VG.Arm.eval .eq s = _; rw [VG.Proof.MdStream.Arm.eval_eq, hz] + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ a => + WP.seq (WP.mono (w_call a.call) fun _ c => tail_xor_wp hp (tail_call hp a c) hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block (ctrSave ++ finalRestore)) s fun s' => abiPreserved s₀ s' ∧ s'.mem = s.mem := by + show WP isa (.block (.ldrSp .r12 4 :: finalRestore)) s _ + refine wp_ldrSp (a := stackArgAddr s₀ 1) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) fun s₁ u₁ => ?_ + have big := big_frame h.frame + have r12 : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big (by decide) + have sv := hp.sv_fit + have hs : Spill.Saved s₁.mem (State.addr (s₁.gpr .r12)) s₀.gpr finalSaved := by + rw [u₁.mem, r12] + refine (Spill.saveMem_saved (lo := 0) (hi := 36) _ _ _ _ (by decide)).frame (lo := 0) (hi := 36) (by decide) + h.frame fun r hr => ?_ + have hsub : Region.Sub ⟨State.addr (fV s₀) + BitVec.ofNat 64 0, 36 - 0⟩ (cSv s₀) := + Offset.sub_base _ (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.c_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact Offset.disjoint _ (d := 0) (n := 36) (e := 40) (k := 16) (.inl (by decide)) (by decide) (by decide) + · exact hp.stk_sv.symm.sub_left hsub + refine WP.mono (Spill.restore_block_ok (b := .r12) (lo := 0) (hi := 36) (by decide) (by decide) + (by rw [r12]; omega) (fun d _ hd => ?_) hs) fun s' ⟨g, _, m, _, _, sp⟩ => ?_ + · rw [u₁.rd, u₁.wr, h.rd, h.wr, r12] + exact ⟨cSv s₀, by simp [hp.wr], Offset.contains_base _ (by omega) (by omega)⟩ + · exact ⟨⟨fun r hr => Spill.restored_reg g (preserved_saved r hr), by rw [sp, u₁.sp, h.sp]⟩, by rw [m, u₁.mem]⟩ + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => abiPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (test_wp h₂) fun s₃ ⟨h₃, z₃⟩ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₃ z₃) fun s₄ h₄ => ?_) + exact WP.mono (end_wp hp h₄) fun _ ⟨g, m⟩ => ⟨g, s₄, h₄, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalArm.post s₀ s' := by + show Spec.Ctr.CryptFinal (cCiph s₀) s₀.mem s'.mem (State.addr (fC s₀)) (State.addr (fD s₀)) (fL s₀) + exact Proof.Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalArm.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalArm.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +section +variable {s₀ s₀' : State} (hq : ctrFinalArm.pub s₀ s₀') +include hq + +theorem pub_sp : s₀.sp = s₀'.sp := hq.1 +theorem pub_W : fW s₀ = fW s₀' := hq.2.1 +theorem pub_r1 : s₀.gpr .r1 = s₀'.gpr .r1 := hq.2.2.1 +theorem pub_C : fC s₀ = fC s₀' := hq.2.2.2.1 +theorem pub_D : fD s₀ = fD s₀' := hq.2.2.2.2.1 +theorem pub_L : stackArg s₀ 0 = stackArg s₀' 0 := hq.2.2.2.2.2.1 +theorem pub_V : fV s₀ = fV s₀' := hq.2.2.2.2.2.2 +theorem pub_N : fN s₀ = fN s₀' := by rw [fN, fN, fL, fL, pub_L hq] +theorem pub_U : fU s₀ = fU s₀' := by rw [fU, fU, fL, fL, pub_L hq] +theorem pub_T : fT s₀ = fT s₀' := by rw [fT, fT, pub_D hq, pub_N hq] + +end + +/-- The arguments' area, apart from what may be written. -/ +theorem KPre.argsWf {s₀ : State} (hp : KPre s₀) : + s₀.sp.toNat + 8 ≤ 2 ^ 32 ∧ ∀ r ∈ s₀.wr, Region.Disjoint ⟨State.addr s₀.sp, 8⟩ r := by + have e : (⟨State.addr s₀.sp, 8⟩ : Region) = fArg s₀ := by simp [stackArgAddr] + refine ⟨hp.sp_hi, ?_⟩ + rw [e, hp.wr] + simp only [List.mem_cons, List.not_mem_nil, or_false] + rintro r (rfl | rfl | rfl) + · exact hp.c_arg.symm + · exact hp.data_arg.symm + · exact hp.sv_arg.symm + +/-- Two states of the runs agree on the taint that makes the registers `rs` +and the stack arguments public. -/ +theorem agreeAt {s₀ s₀' : State} (hp : KPre s₀) (hp' : KPre s₀') (hq : ctrFinalArm.pub s₀ s₀') {a b : State} + (sa : a.sp = s₀.sp) (sb : b.sp = s₀'.sp) (wa : a.wr = s₀.wr) (wb : b.wr = s₀'.wr) + (ma : Frame (cBig s₀) s₀.mem a.mem) (mb : Frame (cBig s₀') s₀'.mem b.mem) {rs : List Reg} + (hr : ∀ r ∈ rs, a.gpr r = b.gpr r) : VG.Arm.Taint.Agree (argTaint rs 8) a b := by + have arg : ∀ {σ s : State}, KPre σ → s.sp = σ.sp → Frame (cBig σ) σ.mem s.mem → + ∀ k < 2, stackArg s k = stackArg σ k := + fun {σ s} hσ hs hm k hk => by + rw [stackArg, show stackArgAddr s k = stackArgAddr σ k by simp only [stackArgAddr, hs]] + exact hσ.argMem hm hk + refine agree_argTaint hr (by rw [sa, sb, pub_sp hq]) (by rw [sa, wa]; exact hp.argsWf) + (by rw [sb, wb]; exact hp'.argsWf) + (argMem_of (j := 2) (by rw [sa, sb, pub_sp hq]) (by rw [sa]; exact hp.sp_hi) fun i hi => ?_) + rw [arg hp sa ma i hi, arg hp' sb mb i hi] + rcases (by omega : i = 0 ∨ i = 1) with rfl | rfl + · exact pub_L hq + · exact pub_V hq + +theorem setup_taint : ∃ h, (taint.check (argTaint [.r0, .r1, .r2, .r3] 8) (.block ctrFinalSetup) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (Taint.ofRegs [.r8]) (.block [.cmp .r8 (.imm 0)]) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (argTaint [.r4, .r5, .r6] 8) (.block ctrTailArgs) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (argTaint [.r7, .r8] 8) + (.seq (.block ctrXorArgs) (.loop (.block Impl.Modes.Arm.xorByte) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem nil_taint : ∃ h, (taint.check (Taint.ofRegs []) (.block []) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem end_taint : ∃ h, (taint.check (argTaint [] 8) (.block (ctrSave ++ finalRestore)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalArm.pre s₀) (h0' : ctrFinalArm.pre s₀') + (hq : ctrFinalArm.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + -- The registers saved and the arguments set up. + have r₁ := rel_agree (F := fun s => s = s₀) (F' := fun s => s = s₀') (G := Setup s₀) (G' := Setup s₀') + (argTaint [.r0, .r1, .r2, .r3] 8) + (fun s s' e e' => by + subst e e' + refine agreeAt hp hp' hq rfl rfl rfl rfl (Frame.refl _ _) (Frame.refl _ _) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact pub_W hq + · exact pub_r1 hq + · exact pub_C hq + · exact pub_D hq) setup_taint + (fun s e => by rw [e]; exact setup_wp hp) (fun s e => by rw [e]; exact setup_wp hp') + -- The whole blocks. + have r₂ := rel_wp (F := Setup s₀) (F' := Setup s₀') (G := Whole s₀) (G' := Whole s₀') + (w_rel fun a b ⟨ha, hb⟩ => ⟨_, _, _, _, _, setup_call hp ha, by + rw [pub_W hq, pub_r1 hq, pub_C hq, pub_D hq, pub_N hq]; exact setup_call hp' hb, + by rw [ha.sp, hb.sp, pub_sp hq]⟩) + (fun _ h => whole_wp hp h) (fun _ h => whole_wp hp' h) + -- The test. + have r₃ := rel_agree (F := Whole s₀) (F' := Whole s₀') + (G := fun s => Whole s₀ s ∧ s.z = decide (fU s₀ = 0)) (G' := fun s => Whole s₀' s ∧ s.z = decide (fU s₀' = 0)) + (Taint.ofRegs [.r8]) (fun a b ha hb => Taint.agree_ofRegs fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [ha.r8, hb.r8, pub_U hq]) test_taint + (fun _ h => test_wp h) (fun _ h => test_wp h) + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole s₀ a ∧ Whole s₀' b) ctrFinalTail + fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := pub_U hq ▸ hu + have a₁ := rel_agree (F := Whole s₀) (F' := Whole s₀') (G := TArgs s₀) (G' := TArgs s₀') + (argTaint [.r4, .r5, .r6] 8) (fun a b ha hb => by + refine agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame (cW1_cW (whole_cW1 ha))) + (big_frame (cW1_cW (whole_cW1 hb))) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [ha.r4, hb.r4, pub_W hq] + · rw [ha.r5, hb.r5, pub_r1 hq] + · rw [ha.r6, hb.r6, pub_C hq]) tailArgs_taint + (fun _ h => tail_args_wp hp h) (fun _ h => tail_args_wp hp' h) + have a₂ := rel_wp (F := TArgs s₀) (F' := TArgs s₀') (G := TCall s₀) (G' := TCall s₀') + (w_rel fun a b ⟨ha, hb⟩ => ⟨_, _, _, _, _, ha.call, by + rw [pub_W hq, pub_r1 hq, pub_C hq, cBk32, pub_V hq]; exact hb.call, by rw [ha.sp, hb.sp, pub_sp hq]⟩) + (fun _ h => WP.mono (w_call h.call) fun _ c => tail_call hp h c) + (fun _ h => WP.mono (w_call h.call) fun _ c => tail_call hp' h c) + have a₃ := rel_agree (F := TCall s₀) (F' := TCall s₀') (G := Done s₀) (G' := Done s₀') + (argTaint [.r7, .r8] 8) (fun a b ha hb => by + refine agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame (cW1_cW ha.frame)) + (big_frame (cW1_cW hb.frame)) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · rw [ha.r7, hb.r7, pub_T hq] + · rw [ha.r8, hb.r8, pub_U hq]) xor_taint + (fun _ h => tail_xor_wp hp h hu) (fun _ h => tail_xor_wp hp' h hu') + exact a₁.seq (a₂.seq a₃) + have ev {s : State} {u : Nat} (h : s.z = decide (u = 0)) : isa.eval .eq s = some (decide (u = 0)) := by + show VG.Arm.eval .eq s = _; rw [VG.Proof.MdStream.Arm.eval_eq, h] + have r₄ : RelCT isa (fun a b => (Whole s₀ a ∧ a.z = decide (fU s₀ = 0)) ∧ + (Whole s₀' b ∧ b.z = decide (fU s₀' = 0))) + (.ite .eq (.block []) ctrFinalTail) (fun a b => Done s₀ a ∧ Done s₀' b) := by + obtain ⟨_, hnil⟩ := nil_taint + refine RelCT.ite (fun a b h => by rw [ev h.1.2, ev h.2.2, pub_U hq]) ?_ ?_ + · refine ((RelCT.taint (A := taint) (Taint.ofRegs []) + (fun _ _ _ => Taint.agree_ofRegs fun r hr => by simp at hr) hnil).wp + (F₁ := Done s₀) (F₂ := Done s₀') fun a b h => ?_).mono (fun _ _ h => h) fun _ _ h => h.2 + have h0 : fU s₀ = 0 := by + have := h.2; rw [ev h.1.1.2] at this; simpa using this + exact ⟨WP.block_nil (done_of_zero h.1.1.1 h0), WP.block_nil (done_of_zero h.1.2.1 (pub_U hq ▸ h0))⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; rw [ev h.1.1.2] at this; simpa using this + -- `save` reloaded, and the registers restored. + have r₅ := rel_agree (F := Done s₀) (F' := Done s₀') (G := fun _ => True) (G' := fun _ => True) + (argTaint [] 8) + (fun a b ha hb => agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame ha.frame) (big_frame hb.frame) + fun r hr => by simp at hr) end_taint + (fun _ h => WP.mono (end_wp hp h) fun _ _ => trivial) + (fun _ h => WP.mono (end_wp hp' h) fun _ _ => trivial) + exact (r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅)))).mono (fun _ _ h => h) fun _ _ _ => trivial + +theorem final_ct : ConstantTime isa ctrFinalArm.pre ctrFinalArm.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified Arm.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +The final function has one stack argument, so `save` is its second: it runs +its code in a frame of 72 bytes (`withStackScratchWiped`): the copy of the +stack argument, `save`'s address, the word holding `lr`, and `save`'s 56 +bytes, the block included, which it zeroes before returning (and 4 bytes of +padding). The code's calls use 2912 bytes below it, so 2984 in all. -/ + +/-- `Spec.Camellia.ctrFinalPre` reads no memory. -/ +theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₁ → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₂ := by + intro vs m₁ m₂ hlen _ h + match vs, hlen with + | [_, _, _, _, _], _ => exact h + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + bytesAt m₂ p k = bytesAt m₁ p k := by + simp only [bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +/-- `Proof.Camellia.ctrFinalPostSk` reads the memory on entry only within +the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, + vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₁ m' r → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, rounds, ctr, data, len], _ => + simp only [Spec.Camellia.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hk := Proof.Camellia.agree_of hb.1 + have hc := Proof.Camellia.agree_of hb.2.1 + have hd := Proof.Camellia.agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Camellia.ctrFinalPostSk pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Camellia.ctrFinalPostSk pb) _ m₂ m' r + dsimp only [Curry.apply, Proof.Camellia.ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + intro hR + rw [Proof.Camellia.subkeysAt_congr (by rcases hR with h' | h' <;> rw [h'] <;> decide) hk, + bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] + exact h hR + +/-- A state satisfying the precondition, without `save`. -/ +def ctrFinalFrameSat : State := + { ctrFinalSat with rd := [⟨0x1000, 272⟩, ⟨0x8000, 4⟩], wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk Arm.abi 2984).pre s := by + implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, + Proof.Camellia.ctrFinalPostSk, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] + [ctrFinalFrameSat, ctrFinalSat] using ctrFinalFrameSat + +/-- `ctrFinal`, with `save` on the stack (zeroed on return). -/ +theorem ctrFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 72 1 14 ctrFinal) + (Spec.Camellia.ctrFinalContract Arm.abi 2984) := + Proof.Camellia.ctrFinal_of_sk <| + Arm.Verified.stackScratchWiped (sig := Spec.Camellia.ctrFinalSig) (nm := "save") (e := .u64) (n := 7) + (pre := Spec.Camellia.ctrFinalPre Arm.abi.ptrBits) (post := Proof.Camellia.ctrFinalPostSk Arm.abi.ptrBits) + (wa := true) (stack := 2912) (m := 1) (bytes := 72) + ctrFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (ctrFinalPre_local _) (ctrFinalPost_local _) (Proof.Camellia.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Camellia.Arm.CtrFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean new file mode 100644 index 00000000000..7fc569e26cf --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean @@ -0,0 +1,1101 @@ +module + +public import VerifiedGarbage.Impl.Sm4.Arm.CtrFinal +public import VerifiedGarbage.Proof.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Sm4.Arm.BatchVerified +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.Contract +public import VerifiedGarbage.Proof.Framework.Arm.Spill +public import VerifiedGarbage.Proof.Framework.Arm.ArgTaint +import VerifiedGarbage.Proof.Sm4.CtrCipher +import VerifiedGarbage.Proof.AesCfb.Arm.Final +import VerifiedGarbage.Proof.Modes.CtrFinal +public import VerifiedGarbage.Proof.CmacAes.Arm.Words +import VerifiedGarbage.Proof.Cmac.Block32 +import VerifiedGarbage.Proof.AesCbc.Mem32 +import VerifiedGarbage.Proof.Framework.Arm.Contract +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Arm.Exec +import VerifiedGarbage.Proof.Framework.Arm.Inline +public import VerifiedGarbage.Proof.Framework.Arm.CallF +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.Framework.Arm.RelCT +import VerifiedGarbage.Proof.Framework.Arm.RegUpd +meta import VerifiedGarbage.Impl.Sm4.Arm.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.Arm.BatchVerified +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.Arm.Spill +meta import VerifiedGarbage.Proof.Framework.Arm.ArgTaint +meta import VerifiedGarbage.Proof.Sm4.CtrCipher +meta import VerifiedGarbage.Proof.AesCfb.Arm.Final +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.CmacAes.Arm.Words +meta import VerifiedGarbage.Proof.Cmac.Block32 +meta import VerifiedGarbage.Proof.AesCbc.Mem32 +meta import VerifiedGarbage.Proof.Framework.Arm.Contract +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.Arm.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Arm.Exec +meta import VerifiedGarbage.Proof.Framework.Arm.Inline +meta import VerifiedGarbage.Proof.Framework.Arm.CallF +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.Framework.Arm.RelCT +meta import VerifiedGarbage.Proof.Framework.Arm.RegUpd + +/-! +# SM4-CTR of a message's last piece on ARMv7 + +`ctrFinal_framed`: `vg_sm4_ctr_final` (`Impl/Sm4/Arm/CtrFinal.lean`) meets +`Spec.Sm4.ctrFinalContract` (`Proof.Sm4.ctrFinalContract_eq`). + +The code is proven against `ctrFinalArm`, with a fifth argument `save` of +56 bytes on the stack (`ctrFinal_implies`: the shared contract with it), as a +caller of `vg_sm4_ctr` (framed by its own working space on the stack, +`ctrFramed`), through its contract: what a call needs and leaves (`WCall`, +`WPost`, `w_call`, constant time by `w_rel`). The proof is AES-CTR's +(`Proof/AesCtr/Arm/Final.lean`), with SM4's arguments: + +* `setup_wp`, `whole_wp`: the registers saved in `save`, and the call on the + `n = len / 16` whole blocks (`Whole`), which leaves `Tₙ₊₁` in `ctr`; +* `mid_wp`: if `u = len % 16` bytes are left, the block at `save + 40` + zeroed and the call on it (`tail_args_wp`, `tail_call`), which leaves + `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed + into them (`Modes.Arm.xorLoop_wp`, `tail_xor_wp`); what is left before the + registers are restored is `Done`; +* `end_wp`: the registers restored; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.call`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Sm4.Arm.CtrFinal + +open VG VG.Arm +open VG.Spec.Aes (bytesAt) +open VG.Impl.Sm4.Arm (ctrFramed ctrSave ctrFinalMoves ctrFinalSetup ctrCall ctrTailArgs ctrXorArgs ctrFinalTail + ctrFinal) +open VG.Impl.AesCfb.Arm (finalSaved finalSave finalRestore) +open VG.Proof.AesCfb.Arm (shr4 and15 shl4 blocksAt_frame' preserved_saved) +open VG.Proof.AesGcm.Arm (toNat_ofNat32) +open VG.Arm.FrameStack (armStack belowA) +open VG.Proof.MdStream.Arm (Upd op2_imm op2_reg op2_lsr op2_lsl wp_mov wp_add wp_and wp_cmp wp_ldrSp eval_eq + eval_ne ofNat_beq_zero) +open VG.Proof.Modes.Arm (XPre XInv XDone xorLoop_wp xf add0_32) + +/-- The code's contract, with the arguments `(schedule = r0, ctr = r1, +data = r2, len = r3, save = [sp])`, `save` of 56 bytes: the data and the +counter block as `Spec.Ctr.CryptFinal` says, by SM4 with the schedule at +`schedule`. -/ +def ctrFinalArm : Contract isa where + pre s := + let sched : Region := ⟨State.addr (s.gpr .r0), 128⟩ + let ctr : Region := ⟨State.addr (s.gpr .r1), 16⟩ + let data : Region := ⟨State.addr (s.gpr .r2), (s.gpr .r3).toNat⟩ + let sv : Region := ⟨State.addr (stackArg s 0), 56⟩ + let args : Region := ⟨stackArgAddr s 0, 4⟩ + let stk : Region := ⟨State.addr s.sp - BitVec.ofNat 64 1520, 1520⟩ + 1520 ≤ s.sp.toNat ∧ s.sp.toNat + 4 ≤ 2 ^ 32 ∧ + s.rd = [sched, args] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ + ctr.Disjoint data ∧ ctr.Disjoint sv ∧ ctr.Disjoint args ∧ + data.Disjoint sv ∧ data.Disjoint args ∧ sv.Disjoint args ∧ + stk.Disjoint sched ∧ stk.Disjoint ctr ∧ stk.Disjoint data ∧ stk.Disjoint sv ∧ stk.Disjoint args ∧ + (s.gpr .r0).toNat + 128 ≤ 2 ^ 32 ∧ (s.gpr .r1).toNat + 16 ≤ 2 ^ 32 ∧ + (s.gpr .r2).toNat + (s.gpr .r3).toNat ≤ 2 ^ 32 ∧ (stackArg s 0).toNat + 56 ≤ 2 ^ 32 + post s s' := + Spec.Ctr.CryptFinal (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (State.addr (s.gpr .r0)))) s.mem s'.mem + (State.addr (s.gpr .r1)) (State.addr (s.gpr .r2)) (s.gpr .r3).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .r0 = s₂.gpr .r0 ∧ s₁.gpr .r1 = s₂.gpr .r1 ∧ s₁.gpr .r2 = s₂.gpr .r2 ∧ + s₁.gpr .r3 = s₂.gpr .r3 ∧ stackArg s₁ 0 = stackArg s₂ 0 + +/-- The contract the frame needs: the shared one, with `save`, 56 bytes, as +a fifth argument, and 1520 bytes of stack (`vg_sm4_ctr`'s frame and +calls). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract Arm.abi Spec.Sm4.ctrFinalSig "save" .u64 7 (Curry.const (fun _ => True) _) + (Proof.Sm4.ctrFinalPost Arm.abi.ptrBits) true 1520 + +/-- A state satisfying the precondition: the schedule at `0x1000`, the +counter block at `0x2000`, no data at `0x3000` and `save` at `0x6000` (the +stack argument at `0x8000`). -/ +def ctrFinalSat : State where + gpr r := match r with + | .r0 => 0x1000 | .r1 => 0x2000 | .r2 => 0x3000 | _ => 0 + sp := 0x8000 + n := false + z := false + c := false + v := false + mem a := if a = 0x8001 then 0x60 else 0 + rd := [⟨0x1000, 128⟩, ⟨0x8000, 4⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x6000, 56⟩] + +theorem ctrFinal_implies : ctrFinalArm.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, ctrFinalArm, Arm.abi, + Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, Arm.State.addr] + [ctrFinalSat, Arm.stackArg, Arm.stackArgAddr, Mem.readW, Mem.read] using ctrFinalSat + +theorem ctr_stack : armStack ctrFramed ≤ 1520 := by decide +kernel + +/-! ## A call of `vg_sm4_ctr` -/ + +/-- The 1520 bytes below the stack pointer `sp`, which a call uses. -/ +abbrev stk (sp : BitVec 32) : Region := ⟨State.addr sp - BitVec.ofNat 64 1520, 1520⟩ + +theorem belowA_stk {sp : BitVec 32} {n : Nat} (hn : n ≤ 1520) (hsp : 1520 ≤ sp.toNat) : + Region.Sub (belowA sp n) (stk sp) := by + simp only [belowA] + rw [FrameStack.addr_sub' (by omega)] + have e : State.addr sp - BitVec.ofNat 64 n = + State.addr sp - BitVec.ofNat 64 1520 + BitVec.ofNat 64 (1520 - n) := by + have := sp.isLt + apply BitVec.eq_of_toNat_eq + simp only [State.addr, BitVec.toNat_add, BitVec.toNat_sub, BitVec.toNat_setWidth, BitVec.toNat_ofNat] + omega + rw [e] + exact Offset.sub_base _ (by omega) + +/-- What a call of `vg_sm4_ctr` needs: the schedule at `W`, the counter block +at `C` and `n` blocks at `D`, in `r0`–`r3`, and the 1520 bytes below the +stack pointer. -/ +structure WCall (s : State) (W C D : BitVec 32) (n : Nat) : Prop where + r0 : s.gpr .r0 = W + r1 : s.gpr .r1 = C + r2 : s.gpr .r2 = D + r3 : s.gpr .r3 = BitVec.ofNat 32 n + hsp : 1520 ≤ s.sp.toNat + fitW : W.toNat + 128 ≤ 2 ^ 32 + fitC : C.toNat + 16 ≤ 2 ^ 32 + fitD : D.toNat + 16 * n ≤ 2 ^ 32 + wc : (⟨State.addr W, 128⟩ : Region).Disjoint ⟨State.addr C, 16⟩ + wd : (⟨State.addr W, 128⟩ : Region).Disjoint ⟨State.addr D, 16 * n⟩ + cd : (⟨State.addr C, 16⟩ : Region).Disjoint ⟨State.addr D, 16 * n⟩ + bw : (stk s.sp).Disjoint ⟨State.addr W, 128⟩ + bc : (stk s.sp).Disjoint ⟨State.addr C, 16⟩ + bd : (stk s.sp).Disjoint ⟨State.addr D, 16 * n⟩ + reads : Covers [⟨State.addr W, 128⟩] (s.rd ++ s.wr) + writes : Covers [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩] s.wr + +/-- SM4 with the schedule at `W`. -/ +abbrev wCiph (m : Mem) (W : BitVec 32) : Spec.Cbc.Cipher := Spec.Sm4.cipher (Spec.Sm4.scheduleAt m (State.addr W)) + +/-- What a call of `vg_sm4_ctr` leaves. -/ +structure WPost (s : State) (W C D : BitVec 32) (n : Nat) (s' : State) : Prop where + rd : s'.rd = s.rd + wr : s'.wr = s.wr + sp : s'.sp = s.sp + saved : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r + frame : Frame [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩, stk s.sp] s.mem s'.mem + out : Spec.Cbc.blocksAt s'.mem (State.addr D) n = + Spec.Ctr.crypt (wCiph s.mem W) (bytesAt s.mem (State.addr C) 16) (Spec.Cbc.blocksAt s.mem (State.addr D) n) + ctr : bytesAt s'.mem (State.addr C) 16 = Spec.Ctr.next (bytesAt s.mem (State.addr C) 16) n + +abbrev wRd (W : BitVec 32) : List Region := [⟨State.addr W, 128⟩] +abbrev wWr (C D : BitVec 32) (n : Nat) : List Region := [⟨State.addr C, 16⟩, ⟨State.addr D, n * 16⟩] + +namespace WCall +variable {s : State} {W C D : BitVec 32} {n : Nat} (h : WCall s W C D n) +include h + +theorem n_lt : n < 2 ^ 32 := by have := h.fitD; omega + +theorem pre : (Spec.Sm4.ctrContract Arm.abi 1520).pre (s.callEntry.withRegions (wRd W) (wWr C D n)) := by + have hn := toNat_ofNat32 h.n_lt + sig_pre [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + rw [h.r0, h.r1, h.r2, h.r3, hn, Nat.mul_comm n 16] + exact ⟨h.hsp, by have := s.sp.isLt; omega, rfl, by unfold wWr; rw [Nat.mul_comm n 16]; rfl, h.wc, h.wd, h.cd, + h.bw, h.bc, h.bd, h.fitW, h.fitC, h.fitD⟩ + +theorem cov : Covers (wRd W ++ wWr C D n) (s.rd ++ s.wr) := by + rw [show wWr C D n = [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩] by rw [Nat.mul_comm]] + refine VG.Proof.AesGcm.Arm.covers_append' h.reads (fun x n' hi => ?_) + obtain ⟨r', hr', hc'⟩ := h.writes x n' hi + exact ⟨r', List.mem_append_right _ hr', hc'⟩ + +theorem covW : Covers (wWr C D n) s.wr := by + rw [show wWr C D n = [⟨State.addr C, 16⟩, ⟨State.addr D, 16 * n⟩] by rw [Nat.mul_comm]] + exact h.writes + +end WCall + +theorem w_call {s : State} {W C D : BitVec 32} {n : Nat} (h : WCall s W C D n) : + WP isa ctrCall s (WPost s W C D n) := by + refine FrameStack.WP.callF (k := Spec.Sm4.ctrContract Arm.abi 1520) Proof.Sm4.Arm.BatchVerified.framed.1 + (rd := wRd W) (wr := wWr C D n) h.pre h.cov h.covW (Nat.le_trans ctr_stack h.hsp) ?_ + intro s' hrd hwr hsp hf hcs hpost + have hn := toNat_ofNat32 h.n_lt + sig_post [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] at hpost + rw [h.r0, h.r1, h.r2, h.r3, hn] at hpost + obtain ⟨hdata, hctr⟩ := hpost + refine ⟨hrd, hwr, hsp, hcs, hf.sub fun r hr => ?_, hdata, hctr⟩ + simp only [wWr, List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, List.mem_cons_self, fun _ h => h⟩ + · exact ⟨⟨State.addr D, 16 * n⟩, by simp, fun _ hx => by rwa [Nat.mul_comm] at hx⟩ + · exact ⟨stk s.sp, by simp, belowA_stk ctr_stack h.hsp⟩ + +/-- Calls of `vg_sm4_ctr` with the same arguments and stack pointer in both +runs are constant time. -/ +theorem w_rel {P : State → State → Prop} + (h : ∀ s₁ s₂, P s₁ s₂ → ∃ W C D : BitVec 32, ∃ n : Nat, + WCall s₁ W C D n ∧ WCall s₂ W C D n ∧ s₁.sp = s₂.sp) : + RelCT isa P ctrCall fun _ _ => True := by + intro a b t₁ t₂ a' b' hp e₁ e₂ + obtain ⟨W, C, D, n, h₁, h₂, hsp⟩ := h _ _ hp + have hn := toNat_ofNat32 h₁.n_lt + have r := RelCT.call (k := Spec.Sm4.ctrContract Arm.abi 1520) Proof.Sm4.Arm.BatchVerified.framed.1 + Proof.Sm4.Arm.BatchVerified.framed.2.1 (wRd W) (wWr C D n) + (P := fun x y => x = a ∧ y = b) (fun x y ⟨ex, ey⟩ => ?_) _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂ + · exact ⟨r.1, trivial⟩ + subst ex ey + refine ⟨h₁.pre, h₂.pre, ?_, h₁.cov, h₁.covW, h₂.cov, h₂.covW⟩ + sig_pub [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val] + rw [h₁.r0, h₁.r1, h₁.r2, h₁.r3, h₂.r0, h₂.r1, h₂.r2, h₂.r3, hsp] + exact ⟨rfl, rfl, rfl, rfl, rfl⟩ + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +abbrev fW : BitVec 32 := s₀.gpr .r0 +abbrev fC : BitVec 32 := s₀.gpr .r1 +abbrev fD : BitVec 32 := s₀.gpr .r2 +abbrev fL : Nat := (s₀.gpr .r3).toNat +abbrev fV : BitVec 32 := stackArg s₀ 0 +/-- The number of whole blocks, and of the bytes after them. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +/-- The data after the whole blocks, as a register holds it and as an +address. -/ +abbrev fT : BitVec 32 := fD s₀ + BitVec.ofNat 32 (16 * fN s₀) +abbrev fTa : Addr := State.addr (fD s₀) + BitVec.ofNat 64 (16 * fN s₀) + +abbrev fSch : Region := ⟨State.addr (fW s₀), 128⟩ +abbrev fCR : Region := ⟨State.addr (fC s₀), 16⟩ +abbrev fData : Region := ⟨State.addr (fD s₀), fL s₀⟩ +abbrev fBlk : Region := ⟨State.addr (fD s₀), 16 * fN s₀⟩ +abbrev fTail : Region := ⟨fTa s₀, fU s₀⟩ +abbrev cSv : Region := ⟨State.addr (fV s₀), 56⟩ +abbrev fArg : Region := ⟨stackArgAddr s₀ 0, 4⟩ +abbrev fStk : Region := stk s₀.sp + +/-- The block in `save`. -/ +abbrev cBk32 : BitVec 32 := fV s₀ + 40 +abbrev cBk : Addr := State.addr (fV s₀) + BitVec.ofNat 64 40 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ + +/-- The counter block and the whole blocks on entry, and the cipher. -/ +abbrev fT0 : List Byte := bytesAt s₀.mem (State.addr (fC s₀)) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (State.addr (fD s₀)) (fN s₀) +abbrev cCiph : Spec.Cbc.Cipher := wCiph s₀.mem (fW s₀) + +/-- The memory once the registers are saved. -/ +abbrev svMem : Mem := Spill.saveMem s₀.mem (State.addr (fV s₀)) s₀.gpr finalSaved + +/-- What the function writes after the save: before the XOR, and in all. -/ +abbrev cW1 : List Region := [fCR s₀, fBlk s₀, cBlk s₀, fStk s₀] +abbrev cW : List Region := [fCR s₀, fData s₀, cBlk s₀, fStk s₀] +abbrev cBig : List Region := [fCR s₀, fData s₀, cSv s₀, fStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp_lo : 1520 ≤ s₀.sp.toNat + sp_hi : s₀.sp.toNat + 4 ≤ 2 ^ 32 + rd : s₀.rd = [fSch s₀, fArg s₀] + wr : s₀.wr = [fCR s₀, fData s₀, cSv s₀] + sch_c : (fSch s₀).Disjoint (fCR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + c_data : (fCR s₀).Disjoint (fData s₀) + c_sv : (fCR s₀).Disjoint (cSv s₀) + c_arg : (fCR s₀).Disjoint (fArg s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_arg : (fData s₀).Disjoint (fArg s₀) + sv_arg : (cSv s₀).Disjoint (fArg s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_c : (fStk s₀).Disjoint (fCR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + stk_arg : (fStk s₀).Disjoint (fArg s₀) + sch_fit : (fW s₀).toNat + 128 ≤ 2 ^ 32 + c_fit : (fC s₀).toNat + 16 ≤ 2 ^ 32 + data_fit : (fD s₀).toNat + fL s₀ ≤ 2 ^ 32 + sv_fit : (fV s₀).toNat + 56 ≤ 2 ^ 32 + +theorem KPre.of {s₀ : State} (h : ctrFinalArm.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22⟩ + +/-! ## Regions -/ + +theorem fN_eq (s₀ : State) : fN s₀ = fL s₀ / 16 := rfl +theorem fU_eq (s₀ : State) : fU s₀ = fL s₀ % 16 := rfl +theorem fL_lt (s₀ : State) : fL s₀ < 2 ^ 32 := (s₀.gpr .r3).isLt +theorem fU_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_fit : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 32 := by + have := hp.data_fit; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.arg_in : InRegions (s₀.rd ++ s₀.wr) (stackArgAddr s₀ 0) 4 := + ⟨fArg s₀, by simp [hp.rd], Region.contains_self _ _⟩ + +theorem KPre.tail_lt (hu : fU s₀ ≠ 0) : (fD s₀).toNat + 16 * fN s₀ < 2 ^ 32 := by + have := hp.data_fit; have := Nat.div_add_mod (fL s₀) 16; rw [fN_eq]; rw [fU_eq] at hu; omega + +theorem KPre.tailA (hu : fU s₀ ≠ 0) : State.addr (fT s₀) = fTa s₀ := addr_add (hp.tail_lt hu) + +theorem KPre.tail_toNat (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.tail_lt hu + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem KPre.bkA : State.addr (cBk32 s₀) = cBk s₀ := addr_add (k := 40) (by have := hp.sv_fit; omega) + +theorem KPre.bk_toNat : (cBk32 s₀).toNat = (fV s₀).toNat + 40 := by + have := hp.sv_fit + rw [BitVec.toNat_add, show (40 : BitVec 32).toNat = 40 from rfl, Nat.mod_eq_of_lt (by omega)] + +theorem KPre.c_blk : (fCR s₀).Disjoint (cBlk s₀) := hp.c_sv.sub_right (blk_sv_sub s₀) + +theorem KPre.sch_big : ∀ r ∈ cBig s₀, Region.Disjoint ⟨State.addr (fW s₀), 128⟩ r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_c + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The cipher, from any memory the function leaves. -/ +theorem KPre.ciph {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : wCiph m (fW s₀) = cCiph s₀ := by + show Spec.Sm4.cipher (Spec.Sm4.scheduleAt m _) = _ + rw [Proof.Sm4.scheduleAt_frame hf hp.sch_big] + +/-- The stack argument survives what the function writes. -/ +theorem KPre.argMem {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + m.readW (stackArgAddr s₀ 0) 32 = stackArg s₀ 0 := by + refine hf.readW (r := fArg s₀) (Region.contains_self _ _) (fun r hr => ?_) (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.c_arg.symm + · exact hp.data_arg.symm + · exact hp.sv_arg.symm + · exact hp.stk_arg.symm + +end + +/-- The save changes only `save`. -/ +theorem svMem_frame (s₀ : State) : Frame [cSv s₀] s₀.mem (svMem s₀) := + Spill.saveMem_frame _ _ _ (L := 56) (by decide) finalSaved (by decide) + +theorem big_frame {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem KPre.svFrame {s₀ : State} (_ : KPre s₀) : Frame (cBig s₀) s₀.mem (svMem s₀) := + (svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr] + +/-! ## Saving the registers -/ + +/-- What saving the registers and setting up the arguments leaves. -/ +structure Setup (s₀ s : State) : Prop where + r0 : s.gpr .r0 = fW s₀ + r1 : s.gpr .r1 = fC s₀ + r2 : s.gpr .r2 = fD s₀ + r3 : s.gpr .r3 = BitVec.ofNat 32 (fN s₀) + r4 : s.gpr .r4 = fW s₀ + r6 : s.gpr .r6 = fC s₀ + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + mem : s.mem = svMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem moves_eq : ctrFinalMoves = + [.mov .r4 (.reg .r0), .mov .r6 (.reg .r1), .dp .and .r8 .r3 (.imm 15), .mov .r3 (.shifted .r3 .lsr 4), + .dp .add .r7 .r2 (.shifted .r3 .lsl 4)] := rfl + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (Setup s₀) := by + show WP isa (.block (.ldrSp .r12 0 :: (finalSave ++ ctrFinalMoves))) s₀ _ + refine wp_ldrSp (a := stackArgAddr s₀ 0) (by decide) rfl hp.arg_in fun s₁ u₁ => ?_ + have r12₁ : s₁.gpr .r12 = fV s₀ := u₁.gpr + have sv := hp.sv_fit + refine Spill.save_slots_ok (lo := 0) (hi := 36) (by decide) (by rw [r12₁]; omega) (fun d _ hd => ?_) ?_ + · rw [u₁.wr, hp.wr, r12₁] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have m₂ : Spill.saveMem s₁.mem (State.addr (s₁.gpr .r12)) s₁.gpr finalSaved = svMem s₀ := by + rw [u₁.mem, r12₁] + exact Spill.saveMem_congr _ _ _ fun p hp' => u₁.other _ (by + simp only [finalSaved, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + generalize hs₂ : ({ s₁ with mem := Spill.saveMem s₁.mem (State.addr (s₁.gpr .r12)) s₁.gpr finalSaved } : State) = s₂ + have g₂ : s₂.gpr = s₁.gpr := by rw [← hs₂] + have mem₂ : s₂.mem = svMem s₀ := by rw [← hs₂, m₂] + have rd₂ : s₂.rd = s₀.rd := by rw [← hs₂, u₁.rd] + have wr₂ : s₂.wr = s₀.wr := by rw [← hs₂, u₁.wr] + have sp₂ : s₂.sp = s₀.sp := by rw [← hs₂, u₁.sp] + have keep₂ : ∀ r, r ≠ .r12 → s₂.gpr r = s₀.gpr r := fun r h => by rw [g₂, u₁.other _ h] + rw [moves_eq] + refine wp_mov (op2_reg _ _) fun s₃ u₃ => wp_mov (op2_reg _ _) fun s₄ u₄ => wp_and (op2_imm (by decide)) + fun s₅ u₅ => wp_mov (op2_lsr (by decide)) fun s₆ u₆ => wp_add (op2_lsl (by decide)) fun s₇ u₇ => WP.block_nil ?_ + have hN : 16 * fN s₀ < 2 ^ 32 := by have := fL_lt s₀; rw [fN_eq]; omega + have k₄ : ∀ r, r ≠ .r4 → r ≠ .r6 → r ≠ .r12 → s₄.gpr r = s₀.gpr r := fun r h4 h6 h12 => by + rw [u₄.other _ h6, u₃.other _ h4, keep₂ _ h12] + have r3₆ : s₆.gpr .r3 = BitVec.ofNat 32 (fN s₀) := by + rw [u₆.gpr, u₅.other _ (by decide), k₄ _ (by decide) (by decide) (by decide), shr4] + exact { + r0 := by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + k₄ _ (by decide) (by decide) (by decide)] + r1 := by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + k₄ _ (by decide) (by decide) (by decide)] + r2 := by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + k₄ _ (by decide) (by decide) (by decide)] + r3 := by rw [u₇.other _ (by decide), r3₆] + r4 := by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.gpr, keep₂ _ (by decide)] + r6 := by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.gpr, + u₃.other _ (by decide), keep₂ _ (by decide)] + r7 := by + rw [u₇.gpr, u₆.other .r2 (by decide), r3₆, shl4 hN, u₅.other _ (by decide), + k₄ _ (by decide) (by decide) (by decide)] + r8 := by + rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr, k₄ _ (by decide) (by decide) (by decide)] + exact and15 _ + sp := by rw [u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, sp₂] + mem := by rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, mem₂] + rd := by rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, rd₂] + wr := by rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, wr₂] } + +/-! ## The whole blocks -/ + +/-- What the call on the whole blocks leaves. -/ +structure Whole (s₀ s : State) : Prop where + r4 : s.gpr .r4 = fW s₀ + r6 : s.gpr .r6 = fC s₀ + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame [fCR s₀, fBlk s₀, fStk s₀] (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = Spec.Ctr.next (fT0 s₀) (fN s₀) + +theorem setup_call {s₀ : State} (hp : KPre s₀) {s : State} (h : Setup s₀ s) : + WCall s (fW s₀) (fC s₀) (fD s₀) (fN s₀) := by + have hst : stk s.sp = fStk s₀ := by rw [h.sp] + refine ⟨h.r0, h.r1, h.r2, h.r3, by rw [h.sp]; exact hp.sp_lo, hp.sch_fit, hp.c_fit, hp.blk_fit, hp.sch_c, + hp.sch_data.sub_right (blk_sub s₀), hp.c_data.sub_right (blk_sub s₀), by rw [hst]; exact hp.stk_sch, + by rw [hst]; exact hp.stk_c, by rw [hst]; exact hp.stk_data.sub_right (blk_sub s₀), ?_, ?_⟩ + · rw [h.rd, h.wr, hp.rd] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fCR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Setup s₀ s) : WP isa ctrCall s (Whole s₀) := by + refine WP.mono (w_call (setup_call hp h)) fun s' w => ?_ + have keep : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r := w.saved + have eW : wCiph s.mem (fW s₀) = cCiph s₀ := by rw [h.mem]; exact hp.ciph hp.svFrame + have eC : bytesAt s.mem (State.addr (fC s₀)) 16 = fT0 s₀ := by + rw [h.mem]; exact Proof.Cmac.bytesAt_frame (svMem_frame s₀) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.c_sv) (by decide) + have eB : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = fBlks s₀ := by + rw [h.mem]; exact blocksAt_frame' (svMem_frame s₀) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀)) + have hst : stk s.sp = fStk s₀ := by rw [h.sp] + refine ⟨by rw [keep .r4 (by simp [preserved]) (by decide), h.r4], + by rw [keep .r6 (by simp [preserved]) (by decide), h.r6], + by rw [keep .r7 (by simp [preserved]) (by decide), h.r7], + by rw [keep .r8 (by simp [preserved]) (by decide), h.r8], + by rw [w.sp, h.sp], by rw [w.rd, h.rd], by rw [w.wr, h.wr], ?_, ?_, ?_⟩ + · rw [← h.mem]; have f := w.frame; rw [hst] at f; exact f + · rw [w.out, eW, eC, eB] + · rw [w.ctr, eC] + +theorem Whole.of_fupd {s₀ s s' : State} (h : Whole s₀ s) (g : s'.gpr = s.gpr) (m : s'.mem = s.mem) + (rd : s'.rd = s.rd) (wr : s'.wr = s.wr) (sp : s'.sp = s.sp) : Whole s₀ s' := + ⟨by rw [g, h.r4], by rw [g, h.r6], by rw [g, h.r7], by rw [g, h.r8], by rw [sp, h.sp], by rw [rd, h.rd], + by rw [wr, h.wr], by rw [m]; exact h.frame, by rw [m]; exact h.blocks, by rw [m]; exact h.ctr⟩ + +/-- The test sets Z if no bytes are left after the whole blocks. -/ +theorem test_wp {s₀ s : State} (h : Whole s₀ s) : + WP isa (.block [.cmp .r8 (.imm 0)]) s fun s' => Whole s₀ s' ∧ s'.z = decide (fU s₀ = 0) := + wp_cmp (op2_imm (by decide)) fun s' f z => WP.block_nil ⟨h.of_fupd f.gpr f.mem f.rd f.wr f.sp, by + rw [z, h.r8]; exact MdStream.Arm.cmp0 (by have := fU_lt s₀; omega)⟩ + +/-! ## The partial last block -/ + +theorem whole_cW1 {s₀ s : State} (h : Whole s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem KPre.tail_cW1 {s₀ : State} (hp : KPre s₀) : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.c_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + +theorem KPre.blk_tailW {s₀ : State} (hp : KPre s₀) : ∀ r ∈ [fCR s₀, cBlk s₀, fStk s₀], (fBlk s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact (hp.c_data.sub_right (blk_sub s₀)).symm + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (blk_sub s₀)).symm + +/-- What the arguments of the call on the block leave. -/ +structure TArgs (s₀ s : State) : Prop where + call : WCall s (fW s₀) (fC s₀) (cBk32 s₀) 1 + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = Spec.Ctr.next (fT0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + tailb : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) + +theorem tailArgs_eq : ctrTailArgs = .ldrSp .r12 0 :: .mov .r0 (.imm 0) :: (Proof.CmacAes.Arm.zeroBlk .r0 .r12 40 ++ + ([.mov .r0 (.reg .r4), .mov .r1 (.reg .r6), .dp .add .r2 .r12 (.imm 40), .mov .r3 (.imm 1)] : List Instr)) := rfl + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Whole s₀ s) : + WP isa (.block ctrTailArgs) s (TArgs s₀) := by + rw [tailArgs_eq] + have f1 := whole_cW1 h + have big := big_frame (cW1_cW f1) + refine wp_ldrSp (a := stackArgAddr s₀ 0) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in) fun s₁ u₁ => ?_ + have r12₁ : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big + refine wp_mov (op2_imm (by decide)) fun s₂ u₂ => ?_ + have sv := hp.sv_fit + have r12₂ : s₂.gpr .r12 = fV s₀ := by rw [u₂.other _ (by decide), r12₁] + have bA : State.addr (s₂.gpr .r12) + BitVec.ofNat 64 40 = cBk s₀ := by rw [r12₂] + refine Proof.CmacAes.Arm.zeroBlk_ok u₂.gpr (by decide) (by rw [r12₂]; omega) ?_ + fun s₃ g₃ m₃ rd₃ wr₃ sp₃ => ?_ + · rw [bA, u₂.wr, u₁.wr, h.wr, hp.wr] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨cSv s₀, by simp, 40, rfl, by simp⟩ + rw [bA] at m₃ + refine wp_mov (op2_reg _ _) fun s₄ u₄ => wp_mov (op2_reg _ _) fun s₅ u₅ => + wp_add (op2_imm (by decide)) fun s₆ u₆ => wp_mov (op2_imm (by decide)) fun s₇ u₇ => WP.block_nil ?_ + have g₂ : ∀ r, r ≠ .r0 → r ≠ .r12 → s₃.gpr r = s.gpr r := fun r h0 h12 => by + rw [g₃, u₂.other _ h0, u₁.other _ h12] + have mem₇ : s₇.mem = Proof.Cmac.zero4 s.mem (cBk s₀) := by + rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, m₃, u₂.mem, u₁.mem] + have sp₇ : s₇.sp = s₀.sp := by rw [u₇.sp, u₆.sp, u₅.sp, u₄.sp, sp₃, u₂.sp, u₁.sp, h.sp] + have rd₇ : s₇.rd = s₀.rd := by rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, rd₃, u₂.rd, u₁.rd, h.rd] + have wr₇ : s₇.wr = s₀.wr := by rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, wr₃, u₂.wr, u₁.wr, h.wr] + have zf : Frame [cBlk s₀] s.mem (Proof.Cmac.zero4 s.mem (cBk s₀)) := AesCbc.zero4_frame _ _ + have hst : stk s₇.sp = fStk s₀ := by rw [sp₇] + have bkA := hp.bkA + have hbk := hp.bk_toNat + refine ⟨⟨?_, ?_, ?_, by rw [u₇.gpr]; rfl, by rw [sp₇]; exact hp.sp_lo, hp.sch_fit, hp.c_fit, + by rw [hbk]; omega, hp.sch_c, ?_, ?_, by rw [hst]; exact hp.stk_sch, by rw [hst]; exact hp.stk_c, ?_, ?_, ?_⟩, + ?_, ?_, sp₇, rd₇, wr₇, ?_, ?_, ?_, ?_, fun q hq => ?_⟩ + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.gpr, + g₂ _ (by decide) (by decide), h.r4] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr, u₄.other _ (by decide), + g₂ _ (by decide) (by decide), h.r6] + · rw [u₇.other _ (by decide), u₆.gpr, u₅.other _ (by decide), u₄.other _ (by decide), g₃, + u₂.other _ (by decide), r12₁] + · rw [bkA, Nat.mul_one]; exact hp.sch_sv.sub_right (blk_sv_sub s₀) + · rw [bkA, Nat.mul_one]; exact hp.c_blk + · rw [hst, bkA, Nat.mul_one]; exact hp.stk_sv.sub_right (blk_sv_sub s₀) + · rw [rd₇, wr₇, hp.rd] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · rw [wr₇, hp.wr, bkA, Nat.mul_one] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fCR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 40, rfl, by simp⟩ + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + g₂ _ (by decide) (by decide), h.r7] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + g₂ _ (by decide) (by decide), h.r8] + · rw [mem₇] + exact f1.trans (zf.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [mem₇, blocksAt_frame' zf (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀)), h.blocks] + · rw [mem₇, Proof.Cmac.bytesAt_frame zf (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.c_blk) (by decide), h.ctr] + · rw [mem₇, Proof.Cmac.zero4_bytes]; rfl + · rw [mem₇] + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; have := fU_lt s₀; omega + rw [zf.bytes (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)) hlen hq, + f1.bytes hp.tail_cW1 hlen hq, + (svMem_frame s₀).bytes (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (tail_sub s₀)) hlen hq] + +theorem cipher_length (sk : Spec.Sm4.Schedule) (b : List Byte) : (Spec.Sm4.cipher sk b).length = 16 := by + simp [Spec.Sm4.cipher] + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + r7 : s.gpr .r7 = fT s₀ + r8 : s.gpr .r8 = BitVec.ofNat 32 (fU s₀) + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = Spec.Ctr.next (fT0 s₀) (fN s₀ + 1) + key : bytesAt s.mem (cBk s₀) 16 = cCiph s₀ (Spec.Ctr.next (fT0 s₀) (fN s₀)) + tailb : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) + +theorem tail_call {s₀ : State} (hp : KPre s₀) {s s' : State} (h : TArgs s₀ s) + (w : WPost s (fW s₀) (fC s₀) (cBk32 s₀) 1 s') : TCall s₀ s' := by + have keep : ∀ r ∈ preserved, r ≠ .lr → s'.gpr r = s.gpr r := w.saved + have hst : stk s.sp = fStk s₀ := by rw [h.sp] + have fw : Frame [fCR s₀, cBlk s₀, fStk s₀] s.mem s'.mem := by + have f := w.frame; rw [hst, hp.bkA, Nat.mul_one] at f; exact f + have big := big_frame (cW1_cW h.frame) + have eW : wCiph s.mem (fW s₀) = cCiph s₀ := hp.ciph big + have hout := w.out + rw [hp.bkA, eW, h.ctr] at hout + have hkey := Proof.Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero hout + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; have := fU_lt s₀; omega + refine ⟨by rw [keep .r7 (by simp [preserved]) (by decide), h.r7], + by rw [keep .r8 (by simp [preserved]) (by decide), h.r8], by rw [w.sp, h.sp], by rw [w.rd, h.rd], + by rw [w.wr, h.wr], h.frame.trans (fw.sub fun r hr => ?_), ?_, ?_, hkey, fun q hq => ?_⟩ + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl <;> exact ⟨_, by simp, fun _ h => h⟩ + · rw [blocksAt_frame' fw hp.blk_tailW]; exact h.blocks + · rw [w.ctr, h.ctr]; rfl + · rw [fw.bytes (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact (hp.c_data.sub_right (tail_sub s₀)).symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm) hlen hq] + exact h.tailb q hq + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (State.addr (fD s₀)) (fN s₀) = Spec.Ctr.crypt (cCiph s₀) (fT0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fTa s₀ + BitVec.ofNat 64 q) = s₀.mem (fTa s₀ + BitVec.ofNat 64 q) ^^^ + (cCiph s₀ (Spec.Ctr.next (fT0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (State.addr (fC s₀)) 16 = + Spec.Ctr.next (fT0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.sp, h.rd, h.wr, cW1_cW (whole_cW1 h), h.blocks, fun q hq => absurd hq (by omega), + by rw [ite_eq_left_of_eq_true _ _ (eq_true hu), h.ctr]⟩ + +theorem xorArgs_eq : ctrXorArgs = [.ldrSp .r12 0, .dp .add .r0 .r12 (.imm 40), .mov .r6 (.reg .r7), + .mov .r7 (.reg .r8)] := rfl + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block ctrXorArgs) (.loop (.block Impl.Modes.Arm.xorByte) .ne)) s (Done s₀) := by + have big := big_frame (cW1_cW h.frame) + rw [xorArgs_eq] + refine WP.seq (wp_ldrSp (a := stackArgAddr s₀ 0) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in) fun s₁ u₁ => ?_) + have r12₁ : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big + refine wp_add (op2_imm (by decide)) fun s₂ u₂ => wp_mov (op2_reg _ _) fun s₃ u₃ => + wp_mov (op2_reg _ _) fun s₄ u₄ => WP.block_nil ?_ + have hU := fU_lt s₀ + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_fit + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have hT := hp.tail_toNat hu + have aT := hp.tailA hu + have bkA := hp.bkA + have hbk := hp.bk_toNat + have sv := hp.sv_fit + have r0₄ : s₄.gpr .r0 = cBk32 s₀ := by + rw [u₄.other _ (by decide), u₃.other _ (by decide), u₂.gpr, r12₁] + have r6₄ : s₄.gpr .r6 = fT s₀ := by + rw [u₄.other _ (by decide), u₃.gpr, u₂.other _ (by decide), u₁.other _ (by decide), h.r7] + have r7₄ : s₄.gpr .r7 = BitVec.ofNat 32 (fU s₀) := by + rw [u₄.gpr, u₃.other _ (by decide), u₂.other _ (by decide), u₁.other _ (by decide), h.r8] + have mem₄ : s₄.mem = s.mem := by rw [u₄.mem, u₃.mem, u₂.mem, u₁.mem] + have rd₄ : s₄.rd = s₀.rd := by rw [u₄.rd, u₃.rd, u₂.rd, u₁.rd, h.rd] + have wr₄ : s₄.wr = s₀.wr := by rw [u₄.wr, u₃.wr, u₂.wr, u₁.wr, h.wr] + have sp₄ : s₄.sp = s₀.sp := by rw [u₄.sp, u₃.sp, u₂.sp, u₁.sp, h.sp] + have blkT : (cBlk s₀).Disjoint (fTail s₀) := ((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).symm + have xp : XPre s₄ (cBk32 s₀) (fT s₀) (fU s₀) := { + pos := by omega + fK := by rw [hbk]; omega + fR := by rw [hT]; omega + disj := by rw [aT, bkA]; exact blkT.sub_left (Region.sub_prefix (by omega)) + rdK := by + rw [rd₄, wr₄, hp.rd, hp.wr, bkA] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨cSv s₀, by simp, 40, rfl, by simp only; omega⟩ + wrR := by + rw [wr₄, hp.wr, aT] + exact Covers.of_sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fData s₀, by simp, 16 * fN s₀, rfl, by simp only; omega⟩ } + have x0 : XInv s₄ (cBk32 s₀) (fT s₀) (fU s₀) 0 s₄ := + ⟨by rw [add0_32, r0₄], by rw [add0_32, r6₄], by rw [Nat.sub_zero, r7₄], by omega, + (Proof.Modes.over_zero _ _ _).symm, rfl, rfl, rfl, fun _ _ _ _ _ _ => rfl⟩ + refine WP.mono (xorLoop_wp xp x0) fun s' d => ?_ + have fo : Frame [fTail s₀] s₄.mem s'.mem := by rw [d.mem, aT]; exact Proof.Modes.over_frame _ _ _ _ + refine ⟨by rw [d.sp, sp₄], by rw [d.rd, rd₄], by rw [d.wr, wr₄], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW h.frame).trans (by + rw [← mem₄] + exact fo.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' fo fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail, mem₄] + exact h.blocks + · rw [d.mem, ← aT, Proof.Modes.over_at hq (by omega), aT, mem₄, bkA] + show s.mem (fTa s₀ + BitVec.ofNat 64 q) ^^^ s.mem (cBk s₀ + BitVec.ofNat 64 q) = _ + rw [h.tailb q hq, MdStream.Arm.bytesAt_getD h.key (show q < 16 by omega)] + · rw [ite_eq_right_of_eq_false _ _ (eq_false hu), Proof.Cmac.bytesAt_frame fo (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.c_data.sub_right (tail_sub s₀)) (by decide), + mem₄, h.ctr] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Whole s₀ s) (hz : s.z = decide (fU s₀ = 0)) : + WP isa (.ite .eq (.block []) ctrFinalTail) s (Done s₀) := by + have ev : isa.eval .eq s = some (decide (fU s₀ = 0)) := by + show VG.Arm.eval .eq s = _; rw [VG.Proof.MdStream.Arm.eval_eq, hz] + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ a => + WP.seq (WP.mono (w_call a.call) fun _ c => tail_xor_wp hp (tail_call hp a c) hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block (ctrSave ++ finalRestore)) s fun s' => abiPreserved s₀ s' ∧ s'.mem = s.mem := by + show WP isa (.block (.ldrSp .r12 0 :: finalRestore)) s _ + refine wp_ldrSp (a := stackArgAddr s₀ 0) (by decide) (by rw [h.sp]; rfl) + (by rw [h.rd, h.wr]; exact hp.arg_in) fun s₁ u₁ => ?_ + have big := big_frame h.frame + have r12 : s₁.gpr .r12 = fV s₀ := by rw [u₁.gpr]; exact hp.argMem big + have sv := hp.sv_fit + have hs : Spill.Saved s₁.mem (State.addr (s₁.gpr .r12)) s₀.gpr finalSaved := by + rw [u₁.mem, r12] + refine (Spill.saveMem_saved (lo := 0) (hi := 36) _ _ _ _ (by decide)).frame (lo := 0) (hi := 36) (by decide) + h.frame fun r hr => ?_ + have hsub : Region.Sub ⟨State.addr (fV s₀) + BitVec.ofNat 64 0, 36 - 0⟩ (cSv s₀) := + Offset.sub_base _ (by decide) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.c_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact Offset.disjoint _ (d := 0) (n := 36) (e := 40) (k := 16) (.inl (by decide)) (by decide) (by decide) + · exact hp.stk_sv.symm.sub_left hsub + refine WP.mono (Spill.restore_block_ok (b := .r12) (lo := 0) (hi := 36) (by decide) (by decide) + (by rw [r12]; omega) (fun d _ hd => ?_) hs) fun s' ⟨g, _, m, _, _, sp⟩ => ?_ + · rw [u₁.rd, u₁.wr, h.rd, h.wr, r12] + exact ⟨cSv s₀, by simp [hp.wr], Offset.contains_base _ (by omega) (by omega)⟩ + · exact ⟨⟨fun r hr => Spill.restored_reg g (preserved_saved r hr), by rw [sp, u₁.sp, h.sp]⟩, by rw [m, u₁.mem]⟩ + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => abiPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (test_wp h₂) fun s₃ ⟨h₃, z₃⟩ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₃ z₃) fun s₄ h₄ => ?_) + exact WP.mono (end_wp hp h₄) fun _ ⟨g, m⟩ => ⟨g, s₄, h₄, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalArm.post s₀ s' := by + show Spec.Ctr.CryptFinal (cCiph s₀) s₀.mem s'.mem (State.addr (fC s₀)) (State.addr (fD s₀)) (fL s₀) + exact Proof.Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalArm.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalArm.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +section +variable {s₀ s₀' : State} (hq : ctrFinalArm.pub s₀ s₀') +include hq + +theorem pub_sp : s₀.sp = s₀'.sp := hq.1 +theorem pub_W : fW s₀ = fW s₀' := hq.2.1 +theorem pub_C : fC s₀ = fC s₀' := hq.2.2.1 +theorem pub_D : fD s₀ = fD s₀' := hq.2.2.2.1 +theorem pub_r3 : s₀.gpr .r3 = s₀'.gpr .r3 := hq.2.2.2.2.1 +theorem pub_V : fV s₀ = fV s₀' := hq.2.2.2.2.2 +theorem pub_N : fN s₀ = fN s₀' := by rw [fN, fN, fL, fL, pub_r3 hq] +theorem pub_U : fU s₀ = fU s₀' := by rw [fU, fU, fL, fL, pub_r3 hq] +theorem pub_T : fT s₀ = fT s₀' := by rw [fT, fT, pub_D hq, pub_N hq] + +end + +/-- The argument's area, apart from what may be written. -/ +theorem KPre.argsWf {s₀ : State} (hp : KPre s₀) : + s₀.sp.toNat + 4 ≤ 2 ^ 32 ∧ ∀ r ∈ s₀.wr, Region.Disjoint ⟨State.addr s₀.sp, 4⟩ r := by + have e : (⟨State.addr s₀.sp, 4⟩ : Region) = fArg s₀ := by simp [stackArgAddr] + refine ⟨hp.sp_hi, ?_⟩ + rw [e, hp.wr] + simp only [List.mem_cons, List.not_mem_nil, or_false] + rintro r (rfl | rfl | rfl) + · exact hp.c_arg.symm + · exact hp.data_arg.symm + · exact hp.sv_arg.symm + +/-- Two states of the runs agree on the taint that makes the registers `rs` +and the stack argument public. -/ +theorem agreeAt {s₀ s₀' : State} (hp : KPre s₀) (hp' : KPre s₀') (hq : ctrFinalArm.pub s₀ s₀') {a b : State} + (sa : a.sp = s₀.sp) (sb : b.sp = s₀'.sp) (wa : a.wr = s₀.wr) (wb : b.wr = s₀'.wr) + (ma : Frame (cBig s₀) s₀.mem a.mem) (mb : Frame (cBig s₀') s₀'.mem b.mem) {rs : List Reg} + (hr : ∀ r ∈ rs, a.gpr r = b.gpr r) : VG.Arm.Taint.Agree (argTaint rs 4) a b := by + have arg : ∀ {σ s : State}, KPre σ → s.sp = σ.sp → Frame (cBig σ) σ.mem s.mem → stackArg s 0 = stackArg σ 0 := + fun {σ s} hσ hs hm => by + rw [stackArg, show stackArgAddr s 0 = stackArgAddr σ 0 by simp only [stackArgAddr, hs]] + exact hσ.argMem hm + refine agree_argTaint hr (by rw [sa, sb, pub_sp hq]) (by rw [sa, wa]; exact hp.argsWf) + (by rw [sb, wb]; exact hp'.argsWf) + (argMem_of (j := 1) (by rw [sa, sb, pub_sp hq]) (by rw [sa]; exact hp.sp_hi) fun i hi => ?_) + obtain rfl : i = 0 := by omega + rw [arg hp sa ma, arg hp' sb mb] + exact pub_V hq + +theorem setup_taint : ∃ h, (taint.check (argTaint [.r0, .r1, .r2, .r3] 4) (.block ctrFinalSetup) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (Taint.ofRegs [.r8]) (.block [.cmp .r8 (.imm 0)]) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (argTaint [.r4, .r6] 4) (.block ctrTailArgs) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (argTaint [.r7, .r8] 4) + (.seq (.block ctrXorArgs) (.loop (.block Impl.Modes.Arm.xorByte) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem nil_taint : ∃ h, (taint.check (Taint.ofRegs []) (.block []) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem end_taint : ∃ h, (taint.check (argTaint [] 4) (.block (ctrSave ++ finalRestore)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalArm.pre s₀) (h0' : ctrFinalArm.pre s₀') + (hq : ctrFinalArm.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + -- The registers saved and the arguments set up. + have r₁ := rel_agree (F := fun s => s = s₀) (F' := fun s => s = s₀') (G := Setup s₀) (G' := Setup s₀') + (argTaint [.r0, .r1, .r2, .r3] 4) + (fun s s' e e' => by + subst e e' + refine agreeAt hp hp' hq rfl rfl rfl rfl (Frame.refl _ _) (Frame.refl _ _) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact pub_W hq + · exact pub_C hq + · exact pub_D hq + · exact pub_r3 hq) setup_taint + (fun s e => by rw [e]; exact setup_wp hp) (fun s e => by rw [e]; exact setup_wp hp') + -- The whole blocks. + have r₂ := rel_wp (F := Setup s₀) (F' := Setup s₀') (G := Whole s₀) (G' := Whole s₀') + (w_rel fun a b ⟨ha, hb⟩ => ⟨_, _, _, _, setup_call hp ha, by + rw [pub_W hq, pub_C hq, pub_D hq, pub_N hq]; exact setup_call hp' hb, + by rw [ha.sp, hb.sp, pub_sp hq]⟩) + (fun _ h => whole_wp hp h) (fun _ h => whole_wp hp' h) + -- The test. + have r₃ := rel_agree (F := Whole s₀) (F' := Whole s₀') + (G := fun s => Whole s₀ s ∧ s.z = decide (fU s₀ = 0)) (G' := fun s => Whole s₀' s ∧ s.z = decide (fU s₀' = 0)) + (Taint.ofRegs [.r8]) (fun a b ha hb => Taint.agree_ofRegs fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [ha.r8, hb.r8, pub_U hq]) test_taint + (fun _ h => test_wp h) (fun _ h => test_wp h) + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole s₀ a ∧ Whole s₀' b) ctrFinalTail + fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := pub_U hq ▸ hu + have a₁ := rel_agree (F := Whole s₀) (F' := Whole s₀') (G := TArgs s₀) (G' := TArgs s₀') + (argTaint [.r4, .r6] 4) (fun a b ha hb => by + refine agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame (cW1_cW (whole_cW1 ha))) + (big_frame (cW1_cW (whole_cW1 hb))) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · rw [ha.r4, hb.r4, pub_W hq] + · rw [ha.r6, hb.r6, pub_C hq]) tailArgs_taint + (fun _ h => tail_args_wp hp h) (fun _ h => tail_args_wp hp' h) + have a₂ := rel_wp (F := TArgs s₀) (F' := TArgs s₀') (G := TCall s₀) (G' := TCall s₀') + (w_rel fun a b ⟨ha, hb⟩ => ⟨_, _, _, _, ha.call, by + rw [pub_W hq, pub_C hq, cBk32, pub_V hq]; exact hb.call, by rw [ha.sp, hb.sp, pub_sp hq]⟩) + (fun _ h => WP.mono (w_call h.call) fun _ c => tail_call hp h c) + (fun _ h => WP.mono (w_call h.call) fun _ c => tail_call hp' h c) + have a₃ := rel_agree (F := TCall s₀) (F' := TCall s₀') (G := Done s₀) (G' := Done s₀') + (argTaint [.r7, .r8] 4) (fun a b ha hb => by + refine agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame (cW1_cW ha.frame)) + (big_frame (cW1_cW hb.frame)) fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · rw [ha.r7, hb.r7, pub_T hq] + · rw [ha.r8, hb.r8, pub_U hq]) xor_taint + (fun _ h => tail_xor_wp hp h hu) (fun _ h => tail_xor_wp hp' h hu') + exact a₁.seq (a₂.seq a₃) + have ev {s : State} {u : Nat} (h : s.z = decide (u = 0)) : isa.eval .eq s = some (decide (u = 0)) := by + show VG.Arm.eval .eq s = _; rw [VG.Proof.MdStream.Arm.eval_eq, h] + have r₄ : RelCT isa (fun a b => (Whole s₀ a ∧ a.z = decide (fU s₀ = 0)) ∧ + (Whole s₀' b ∧ b.z = decide (fU s₀' = 0))) + (.ite .eq (.block []) ctrFinalTail) (fun a b => Done s₀ a ∧ Done s₀' b) := by + obtain ⟨_, hnil⟩ := nil_taint + refine RelCT.ite (fun a b h => by rw [ev h.1.2, ev h.2.2, pub_U hq]) ?_ ?_ + · refine ((RelCT.taint (A := taint) (Taint.ofRegs []) + (fun _ _ _ => Taint.agree_ofRegs fun r hr => by simp at hr) hnil).wp + (F₁ := Done s₀) (F₂ := Done s₀') fun a b h => ?_).mono (fun _ _ h => h) fun _ _ h => h.2 + have h0 : fU s₀ = 0 := by + have := h.2; rw [ev h.1.1.2] at this; simpa using this + exact ⟨WP.block_nil (done_of_zero h.1.1.1 h0), WP.block_nil (done_of_zero h.1.2.1 (pub_U hq ▸ h0))⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; rw [ev h.1.1.2] at this; simpa using this + -- `save` reloaded, and the registers restored. + have r₅ := rel_agree (F := Done s₀) (F' := Done s₀') (G := fun _ => True) (G' := fun _ => True) + (argTaint [] 4) + (fun a b ha hb => agreeAt hp hp' hq ha.sp hb.sp ha.wr hb.wr (big_frame ha.frame) (big_frame hb.frame) + fun r hr => by simp at hr) end_taint + (fun _ h => WP.mono (end_wp hp h) fun _ _ => trivial) + (fun _ h => WP.mono (end_wp hp' h) fun _ _ => trivial) + exact (r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅)))).mono (fun _ _ h => h) fun _ _ _ => trivial + +theorem final_ct : ConstantTime isa ctrFinalArm.pre ctrFinalArm.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified Arm.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +The final function has no stack arguments, so `save` is its first: it runs +its code in a frame of 64 bytes (`withStackScratchWiped`): `save`'s address, +the word holding `lr`, and `save`'s 56 bytes, the block included, which it +zeroes before returning. The code's calls use 1520 bytes below it, so 1584 +in all. -/ + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + bytesAt m₂ p k = bytesAt m₁ p k := by + simp only [bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : + ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by + intro i hi + refine (h _ ?_).symm + by_cases hw : i < 2 ^ 64 + · exact Offset.contains_base _ (by omega) hw + · simp only [Region.Contains] + have := (p + BitVec.ofNat 64 i - p).isLt + omega + +/-- `Proof.Sm4.ctrFinalPost` reads the memory on entry only within the +buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Sm4.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Sm4.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₁ m' r → + Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, ctr, data, len], _ => + simp only [Spec.Sm4.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hk := agree_of' hb.1 + have hc := agree_of' hb.2.1 + have hd := agree_of' hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Sm4.ctrFinalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Sm4.ctrFinalPost pb) _ m₂ m' r + dsimp only [Curry.apply, Proof.Sm4.ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + rw [Proof.Sm4.scheduleAt_congr hk, bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), + bytesAt_congr' hc] + exact h + +/-- A state satisfying the precondition, without `save`. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with rd := [⟨0x1000, 128⟩], wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : + ∃ s, (Spec.Sm4.ctrFinalSig.contract Arm.abi (post := Proof.Sm4.ctrFinalPost Arm.abi.ptrBits) + (writeArgs := true) (stack := 1584)).pre s := by + implies_sat [Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, Arm.abi, Arm.argRegs, Arm.reduceClassify, Arm.Loc.val, + Arm.State.addr] [ctrFinalFrameSat, ctrFinalSat] using ctrFinalFrameSat + +/-- `ctrFinal`, with `save` on the stack (zeroed on return). -/ +theorem ctrFinal_framed : + Verified Arm.target (Impl.StackScratch.Arm.withStackScratchWiped 64 0 14 ctrFinal) + (Spec.Sm4.ctrFinalContract Arm.abi 1584) := by + rw [Proof.Sm4.ctrFinalContract_eq] + exact Arm.Verified.stackScratchWiped (sig := Spec.Sm4.ctrFinalSig) (nm := "save") (e := .u64) (n := 7) + (post := Proof.Sm4.ctrFinalPost Arm.abi.ptrBits) (wa := true) (stack := 1520) (m := 0) (bytes := 64) + ctrFinal_verified (by decide) (by decide) (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (ctrFinalPost_local _) + (Proof.Sm4.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Sm4.Arm.CtrFinal From 765d7b975bd8c017d2bfa8cfa92af87809095d25 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 12:39:50 +0000 Subject: [PATCH 13/18] Camellia and SM4 CTR final functions on x86 (WIP: crates to come) As on the other targets: a call of the framed whole-block CTR function on the whole blocks, then one on a zeroed block in the wiped save area. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/CamelliaCtr/X86.lean | 8 +- .../VerifiedGarbage/Artifacts/Sm4Ctr/X86.lean | 8 +- .../Impl/Camellia/X86/CtrFinal.lean | 87 + .../Impl/Sm4/X86/CtrFinal.lean | 89 + .../Proof/Camellia/X86/CtrFinal.lean | 1438 +++++++++++++++++ .../Proof/Sm4/X86/CtrFinal.lean | 1392 ++++++++++++++++ 6 files changed, 3020 insertions(+), 2 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/Camellia/X86/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Impl/Sm4/X86/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86.lean b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86.lean index f2aea846a55..cf210827530 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/X86.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Camellia.X86.CtrVerified +public import VerifiedGarbage.Proof.Camellia.X86.CtrFinal import VerifiedGarbage.Proof.Camellia.X86.CtrLit public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print @@ -15,6 +16,11 @@ def artifacts : List Artifact := [ Spec.Camellia.ctrApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 2756 5 682 Impl.Camellia.X86.ctr stack := 2772 - verified := Proof.Camellia.X86.Ctr.ctr_framed }] + verified := Proof.Camellia.X86.Ctr.ctr_framed }, + Spec.Camellia.ctrFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 60 5 8 Impl.Camellia.X86.ctrFinal + stack := 2856 + verified := Proof.Camellia.X86.CtrFinal.ctrFinal_framed + spSafe := Proof.Camellia.X86.CtrFinal.ctrFinal_framed_spSafe }] end VG.Artifacts.CamelliaCtr.X86 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86.lean index e8e75ca7056..3539718be6c 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/X86.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Sm4.X86.CtrVerified +public import VerifiedGarbage.Proof.Sm4.X86.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.X86.Print import VerifiedGarbage.Proof.Sm4.X86.CtrLit @@ -15,6 +16,11 @@ def artifacts : List Artifact := [ Spec.Sm4.ctrApi.artifact X86.target { code := Impl.StackScratch.X86.withStackScratchWiped 1496 4 368 Impl.Sm4.X86.ctr stack := 1516 - verified := Proof.Sm4.X86.Ctr.ctr_framed }] + verified := Proof.Sm4.X86.Ctr.ctr_framed }, + Spec.Sm4.ctrFinalApi.artifact X86.target { + code := Impl.StackScratch.X86.withStackScratchWiped 56 4 8 Impl.Sm4.X86.ctrFinal + stack := 1592 + verified := Proof.Sm4.X86.CtrFinal.ctrFinal_framed + spSafe := Proof.Sm4.X86.CtrFinal.ctrFinal_framed_spSafe }] end VG.Artifacts.Sm4Ctr.X86 diff --git a/lean/VerifiedGarbage/Impl/Camellia/X86/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/X86/CtrFinal.lean new file mode 100644 index 00000000000..64fd277c91f --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Camellia/X86/CtrFinal.lean @@ -0,0 +1,87 @@ +module + +public import VerifiedGarbage.Impl.Camellia.X86.Ctr +public import VerifiedGarbage.Impl.AesCtr.X86.Final +public import VerifiedGarbage.Impl.StackScratch.X86 + +/-! +# Camellia-CTR of a message's last piece: x86 (32-bit) implementation + +`ctrFinal` (cdecl: schedule, rounds, ctr, data, len, save, every argument +on the stack): the code of `vg_camellia_ctr_final`, whose registration frames +it with a buffer of its own on the stack, `save`, the sixth argument, of 32 +bytes: the caller's callee-saved registers, then a block of the code's own. +It is AES-CTR's final function's (`Impl/AesCtr/X86/Final.lean`) with +Camellia's arguments, around calls of `vg_camellia_ctr`, framed by its own +working space on the stack (`ctrFramed`), its five arguments pushed in a +frame of their own (`ctrCall`): + +1. our caller's `ebx`, `esi`, `edi` and `ebp` saved in `save`; +2. a call of `vg_camellia_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u = len mod 16 ≠ 0`, the block after the registers in `save` zeroed, + a call of `vg_camellia_ctr` on that one block, which leaves + `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and the first `u` bytes of the + block XORed into the `u` bytes left, a byte at a time (the modes' + `tailByte`: from `ebx`, into `esi`, `ebp` of them); +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. +Every argument is reloaded from the stack where it is needed. Only the +pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Camellia.X86 + +open VG.X86 +open VG.Impl.CmacAes.X86 (argOp at_) +open VG.Impl.AesCfb.X86 (finalSaved tailTest) +open VG.Impl.AesCtr.X86 (zeroSlots) +open VG.Impl.Modes.X86 (tailByte) + +/-- `vg_camellia_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.X86.withStackScratchWiped 2756 5 682 ctr + +/-- `save` (our stack argument 5) to `eax`, and the registers saved there. -/ +def ctrFinalSave : List Instr := .mov .eax (argOp 5) :: finalSaved.map fun p => .store (at_ .eax p.2) p.1 + +/-- The arguments of `vg_camellia_ctr` on the whole blocks: ours, but the +number of whole blocks, `len >> 4`, for `len`. -/ +def ctrFinalArgs : List Instr := + [.mov .eax (argOp 0), .mov .ecx (argOp 1), .mov .edx (argOp 2), .mov .ebx (argOp 3), .mov .esi (argOp 4), + .shift .shr .esi 4] + +/-- The call of `vg_camellia_ctr(eax, ecx, edx, ebx, esi)`, its arguments +pushed last to first. -/ +def ctrCall : Prog isa := .frame (.push [.esi, .ebx, .edx, .ecx, .eax]) (.call "vg_camellia_ctr" ctrFramed) (.pop .eax 5) + +/-- The block after the registers in `save` zeroed, and the arguments of +`vg_camellia_ctr` on it: the schedule, the rounds, the counter block, the +block and `n = 1`. -/ +def ctrFinalTailArgs : List Instr := + [.mov .eax (argOp 5), .mov .ecx (.imm 0)] ++ zeroSlots.map (fun p => .store (at_ .eax p.2) p.1) ++ + [.mov .ebx (.reg .eax), .alu .add .ebx (.imm 16), .mov .eax (argOp 0), .mov .ecx (argOp 1), + .mov .edx (argOp 2), .mov .esi (.imm 1)] + +/-- The tail loop's operands: `ebx` the block, `ebp` the `u` bytes left, and +`esi` the data after the whole blocks, `data + (len - u)`. -/ +def ctrFinalXorArgs : List Instr := + [.mov .ebx (argOp 5), .alu .add .ebx (.imm 16), .mov .esi (argOp 3), .mov .ebp (argOp 4), + .mov .eax (.reg .ebp), .alu .and .ebp (.imm 15), .alu .sub .eax (.reg .ebp), .alu .add .esi (.reg .eax)] + +/-- The registers restored, from `save`. -/ +def ctrFinalRestore : List Instr := .mov .eax (argOp 5) :: finalSaved.map fun p => .mov p.1 (.mem (at_ .eax p.2)) + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq ctrCall (.seq (.block ctrFinalXorArgs) (.loop (.block tailByte) .ne))) + +/-- `vg_camellia_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block (ctrFinalSave ++ ctrFinalArgs)) (.seq ctrCall + (.seq (.block tailTest) (.seq (.ite .e (.block []) ctrFinalTail) (.block ctrFinalRestore)))) + +end VG.Impl.Camellia.X86 diff --git a/lean/VerifiedGarbage/Impl/Sm4/X86/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/X86/CtrFinal.lean new file mode 100644 index 00000000000..92f0c92584f --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Sm4/X86/CtrFinal.lean @@ -0,0 +1,89 @@ +module + +public import VerifiedGarbage.Impl.Sm4.X86.Ctr +public import VerifiedGarbage.Impl.AesCtr.X86.Final +public import VerifiedGarbage.Impl.StackScratch.X86 + +/-! +# SM4-CTR of a message's last piece: x86 (32-bit) implementation + +`ctrFinal` (cdecl: schedule, ctr, data, len, save, every argument on the +stack): the code of `vg_sm4_ctr_final`, whose registration frames it with a +buffer of its own on the stack, `save`, the fifth argument, of 32 bytes: the +caller's callee-saved registers, then a block of the code's own. It is +AES-CTR's final function's (`Impl/AesCtr/X86/Final.lean`) with SM4's +arguments, around calls of `vg_sm4_ctr`, framed by its own working space on +the stack (`ctrFramed`), its four arguments pushed in a frame of their own +(`ctrCall`): + +1. our caller's `ebx`, `esi`, `edi` and `ebp` saved in `save`; +2. a call of `vg_sm4_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u = len mod 16 ≠ 0`, the block after the registers in `save` zeroed, + a call of `vg_sm4_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` + there and `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed + into the `u` bytes left, a byte at a time (the modes' `tailByte`: from + `ebx`, into `esi`, `ebp` of them); +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. +Every argument is reloaded from the stack where it is needed. Only the +pointers and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Sm4.X86 + +open VG.X86 +open VG.Impl.CmacAes.X86 (argOp at_) +open VG.Impl.AesCfb.X86 (finalSaved) +open VG.Impl.AesCtr.X86 (zeroSlots) +open VG.Impl.Modes.X86 (tailByte) + +/-- `vg_sm4_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.X86.withStackScratchWiped 1496 4 368 ctr + +/-- `save` (our stack argument 4) to `eax`, and the registers saved there. -/ +def ctrFinalSave : List Instr := .mov .eax (argOp 4) :: finalSaved.map fun p => .store (at_ .eax p.2) p.1 + +/-- The arguments of `vg_sm4_ctr` on the whole blocks: ours, but the number +of whole blocks, `len >> 4`, for `len`. -/ +def ctrFinalArgs : List Instr := + [.mov .eax (argOp 0), .mov .edx (argOp 1), .mov .ebx (argOp 2), .mov .esi (argOp 3), .shift .shr .esi 4] + +/-- The call of `vg_sm4_ctr(eax, edx, ebx, esi)`, its arguments pushed last +to first. -/ +def ctrCall : Prog isa := .frame (.push [.esi, .ebx, .edx, .eax]) (.call "vg_sm4_ctr" ctrFramed) (.pop .eax 4) + +/-- ZF set if no bytes are left after the whole blocks. -/ +def ctrFinalTest : List Instr := [.mov .eax (argOp 3), .alu .and .eax (.imm 15), .alu .test .eax (.reg .eax)] + +/-- The block after the registers in `save` zeroed, and the arguments of +`vg_sm4_ctr` on it: the schedule, the counter block, the block and +`n = 1`. -/ +def ctrFinalTailArgs : List Instr := + [.mov .eax (argOp 4), .mov .ecx (.imm 0)] ++ zeroSlots.map (fun p => .store (at_ .eax p.2) p.1) ++ + [.mov .ebx (.reg .eax), .alu .add .ebx (.imm 16), .mov .eax (argOp 0), .mov .edx (argOp 1), + .mov .esi (.imm 1)] + +/-- The tail loop's operands: `ebx` the block, `ebp` the `u` bytes left, and +`esi` the data after the whole blocks, `data + (len - u)`. -/ +def ctrFinalXorArgs : List Instr := + [.mov .ebx (argOp 4), .alu .add .ebx (.imm 16), .mov .esi (argOp 2), .mov .ebp (argOp 3), + .mov .eax (.reg .ebp), .alu .and .ebp (.imm 15), .alu .sub .eax (.reg .ebp), .alu .add .esi (.reg .eax)] + +/-- The registers restored, from `save`. -/ +def ctrFinalRestore : List Instr := .mov .eax (argOp 4) :: finalSaved.map fun p => .mov p.1 (.mem (at_ .eax p.2)) + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq ctrCall (.seq (.block ctrFinalXorArgs) (.loop (.block tailByte) .ne))) + +/-- `vg_sm4_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block (ctrFinalSave ++ ctrFinalArgs)) (.seq ctrCall + (.seq (.block ctrFinalTest) (.seq (.ite .e (.block []) ctrFinalTail) (.block ctrFinalRestore)))) + +end VG.Impl.Sm4.X86 diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean new file mode 100644 index 00000000000..2c43b11dd9c --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean @@ -0,0 +1,1438 @@ +module + +public import VerifiedGarbage.Impl.Camellia.X86.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrScratch +public import VerifiedGarbage.Proof.Camellia.X86.CtrVerified +public import VerifiedGarbage.Proof.AesCtr.X86.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.X86.Spill +public import VerifiedGarbage.Proof.Framework.X86.CallWith +public import VerifiedGarbage.Proof.Framework.X86.ArgTaint +import VerifiedGarbage.Proof.Camellia.X86.CtrLit +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.Framework.Mem +import VerifiedGarbage.Proof.Framework.X86.RegUpd +import VerifiedGarbage.Proof.CmacAes.X86.UpdateLoop +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.MdStream.X86.Common +import VerifiedGarbage.Proof.Modes.X86.SeqFinal +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.X86.RelCT +meta import VerifiedGarbage.Impl.Camellia.X86.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrScratch +meta import VerifiedGarbage.Proof.Camellia.X86.CtrVerified +meta import VerifiedGarbage.Proof.AesCtr.X86.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.X86.Spill +meta import VerifiedGarbage.Proof.Framework.X86.CallWith +meta import VerifiedGarbage.Proof.Framework.X86.ArgTaint +meta import VerifiedGarbage.Proof.Camellia.X86.CtrLit +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.Framework.Mem +meta import VerifiedGarbage.Proof.Framework.X86.RegUpd +meta import VerifiedGarbage.Proof.CmacAes.X86.UpdateLoop +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.MdStream.X86.Common +meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.X86.RelCT + +/-! +# Camellia-CTR of a message's last piece on x86 (32-bit) + +`ctrFinal_framed`: `vg_camellia_ctr_final` (`Impl/Camellia/X86/CtrFinal.lean`) +meets `Spec.Camellia.ctrFinalContract`, from `Proof.Camellia.ctrFinalContractSk` +(`Proof.Camellia.ctrFinal_of_sk`). + +The code is proven against `ctrFinalX86`, with a sixth stack argument `save` +of 32 bytes, for its caller's registers and a block of its own, its +arguments read only (`verified_wide`: the shared contract on the subkeys +with `save`, `finalScratchContract`, by `wide_implies`, from `wideX86`, which +has them writable), as a caller of `vg_camellia_ctr` (framed by its own working space on the stack, +`ctrFramed`), through its contract on the subkeys, `ctrContractSk` +(`ctrFramed_sk`; `CCall.callPre`, `calleeK_post`, `calleeK_pub`, from +`Sig.contract`'s form for arguments on the stack). It is AES-CTR's final +function's proof (`Proof/AesCtr/X86/Final.lean`) with Camellia's arguments: + +* `setup_wp`, `whole_wp`: the registers saved, and the call on the + `n = len / 16` whole blocks (`ctr_call`, `Whole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.X86.tailLoop_wp`, `xor_wp`); what is left before + the registers are restored is `Done`; +* `end_wp`: the registers restored from `save`; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Every argument is reloaded from the stack, which nothing writes (`Pt`). +Constant time (`final_rel`): the blocks by the taint analysis from the +stack arguments (`argTaint`), the calls by the callee's constant time +(`RelCT.callWith`), whose public arguments, the pointers, `rounds` and the +number of blocks, agree in both runs. `ctrFinal_framed` runs the code with +`save` in a frame of 60 bytes (`Verified.stackScratchWiped`), zeroed on +return, the block included; with the 2796 bytes its calls use below it +(the callee's five arguments, its return address and its 2772 bytes), 2856 +in all. +-/ + +@[expose] public section + +namespace VG.Proof.Camellia.X86.CtrFinal + +open VG VG.X86 +open VG.Spec.Aes (bytesAt) + +/-- The code's contract, with the arguments on the stack `(schedule, rounds, +ctr, data, len, save)`, `save` of 32 bytes: the data and the counter block +as `Spec.Ctr.CryptFinal` says, by Camellia with the subkeys at `schedule`. +The code only reads its arguments (`wideX86` has them writable, as the +signature's contract does). -/ +def ctrFinalX86 : Contract isa where + pre s := + let sched : Region := ⟨(arg s 0).setWidth 64, 272⟩ + let ctr : Region := ⟨(arg s 2).setWidth 64, 16⟩ + let data : Region := ⟨(arg s 3).setWidth 64, (arg s 4).toNat⟩ + let sv : Region := ⟨(arg s 5).setWidth 64, 32⟩ + let args : Region := ⟨argAddr s 0, 24⟩ + let ret : Region := ⟨(s.gpr .esp).setWidth 64, 4⟩ + let stack : Region := ⟨(s.gpr .esp).setWidth 64 - BitVec.ofNat 64 2796, 2796⟩ + s.rd = [sched, args] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ + ctr.Disjoint data ∧ ctr.Disjoint sv ∧ ctr.Disjoint args ∧ + data.Disjoint sv ∧ data.Disjoint args ∧ sv.Disjoint args ∧ + ret.Disjoint ctr ∧ ret.Disjoint data ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (arg s 0).toNat + 272 ≤ 2 ^ 32 ∧ (arg s 2).toNat + 16 ≤ 2 ^ 32 ∧ + (arg s 3).toNat + (arg s 4).toNat ≤ 2 ^ 32 ∧ (arg s 5).toNat + 32 ≤ 2 ^ 32 ∧ + 2796 ≤ (s.gpr .esp).toNat ∧ (s.gpr .esp).toNat + 28 ≤ 2 ^ 32 ∧ + ((arg s 1).toNat = 18 ∨ (arg s 1).toNat = 24) + post s s' := + Spec.Ctr.CryptFinal (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem ((arg s 0).setWidth 64) (arg s 1).toNat)) + s.mem s'.mem ((arg s 2).setWidth 64) ((arg s 3).setWidth 64) (arg s 4).toNat + pub s₁ s₂ := s₁.gpr .esp = s₂.gpr .esp ∧ ∀ i < 6, arg s₁ i = arg s₂ i + +/-- `ctrFinalX86` with the argument slots writable, as the signature's +contract has them. -/ +def wideX86 : Contract isa := + { ctrFinalX86 with + pre := fun s => + let sched : Region := ⟨(arg s 0).setWidth 64, 272⟩ + let ctr : Region := ⟨(arg s 2).setWidth 64, 16⟩ + let data : Region := ⟨(arg s 3).setWidth 64, (arg s 4).toNat⟩ + let sv : Region := ⟨(arg s 5).setWidth 64, 32⟩ + let args : Region := ⟨argAddr s 0, 24⟩ + let ret : Region := ⟨(s.gpr .esp).setWidth 64, 4⟩ + let stack : Region := ⟨(s.gpr .esp).setWidth 64 - BitVec.ofNat 64 2796, 2796⟩ + s.rd = [sched] ∧ s.wr = [ctr, data, sv, args] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ + ctr.Disjoint data ∧ ctr.Disjoint sv ∧ ctr.Disjoint args ∧ + data.Disjoint sv ∧ data.Disjoint args ∧ sv.Disjoint args ∧ + ret.Disjoint ctr ∧ ret.Disjoint data ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (arg s 0).toNat + 272 ≤ 2 ^ 32 ∧ (arg s 2).toNat + 16 ≤ 2 ^ 32 ∧ + (arg s 3).toNat + (arg s 4).toNat ≤ 2 ^ 32 ∧ (arg s 5).toNat + 32 ≤ 2 ^ 32 ∧ + 2796 ≤ (s.gpr .esp).toNat ∧ (s.gpr .esp).toNat + 28 ≤ 2 ^ 32 ∧ + ((arg s 1).toNat = 18 ∨ (arg s 1).toNat = 24) } + +/-- The contract the frame needs: the shared one on the subkeys, with +`save`, 32 bytes, as a sixth argument, and 2796 bytes of stack (the callee's +five arguments, its return address and its own 2772 bytes). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract X86.abi Spec.Camellia.ctrFinalSig "save" .u64 4 (Spec.Camellia.ctrFinalPre X86.abi.ptrBits) + (Proof.Camellia.ctrFinalPostSk X86.abi.ptrBits) true 2796 + +/-- A state satisfying the precondition: the subkeys at `0x1000`, 18 +rounds, the counter block at `0x2000`, no data at `0x3000` and `save` at +`0x4000`, as stack arguments at `0x8004`. -/ +def finalSat : State where + gpr r := match r with | .esp => 0x8000 | _ => 0 + cf := none + zf := none + sf := none + of := none + mem a := if a = 0x8005 then 0x10 else if a = 0x8008 then 0x12 + else if a = 0x800d then 0x20 else if a = 0x8011 then 0x30 else if a = 0x8019 then 0x40 else 0 + rd := [⟨0x1000, 272⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 32⟩, ⟨0x8004, 24⟩] + +theorem wide_implies : wideX86.Implies finalScratchContract := by + have a0 : arg finalSat 0 = 0x1000 := by decide + have a1 : arg finalSat 1 = 0x12 := by decide + have a2 : arg finalSat 2 = 0x2000 := by decide + have a3 : arg finalSat 3 = 0x3000 := by decide + have a4 : arg finalSat 4 = 0 := by decide + have a5 : arg finalSat 5 = 0x4000 := by decide + have e : argAddr finalSat 0 = 0x8004 := by decide + have esp : finalSat.gpr .esp = 0x8000 := rfl + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, Proof.Camellia.ctrFinalPostSk, X86.abi, X86.argSlots, + X86.argVal, X86.argBytes, wideX86, ctrFinalX86] [a0, a1, a2, a3, a4, a5, e, esp] using finalSat + +/-- The regions `ctrFinalX86` gives: the arguments read only. -/ +def narrowRd (s : State) : List Region := [⟨(arg s 0).setWidth 64, 272⟩, ⟨argAddr s 0, 24⟩] +def narrowWr (s : State) : List Region := + [⟨(arg s 2).setWidth 64, 16⟩, ⟨(arg s 3).setWidth 64, (arg s 4).toNat⟩, ⟨(arg s 5).setWidth 64, 32⟩] + +theorem narrow_pre (s : State) (h : wideX86.pre s) : ctrFinalX86.pre (s.withRegions (narrowRd s) (narrowWr s)) := by + obtain ⟨_, _, h⟩ := h + simp only [ctrFinalX86, narrowRd, narrowWr, arg_withRegions, argAddr_withRegions, State.withRegions_gpr, + State.withRegions_rd, State.withRegions_wr] + exact ⟨trivial, trivial, h⟩ + +/-- `ctrFinalX86` gives `wideX86`. -/ +theorem verified_wide {c : Prog isa} (h : ∀ s, ctrFinalX86.pre s → ∃ t s', Exec isa c s t s' ∧ abiPreserved s s' ∧ + ctrFinalX86.post s s') + (hct : ConstantTime isa ctrFinalX86.pre ctrFinalX86.pub c) : Verified X86.target c finalScratchContract := by + have hsat := wide_implies.sat_left + have narrowSat : ∃ s, ctrFinalX86.pre s := by + obtain ⟨s, hs⟩ := hsat + exact ⟨_, narrow_pre s hs⟩ + apply Verified.of_implies _ wide_implies + refine Verified.narrowTo (k := ctrFinalX86) (Verified.of_correct h hct (.refl narrowSat)) + narrowRd narrowWr narrow_pre ?_ ?_ (fun _ _ _ h => h) (fun _ _ _ _ h => h) hsat + · intro s h + obtain ⟨rd, wr, _⟩ := h + rw [rd, wr] + intro a n ⟨r, hr, hc⟩ + refine ⟨r, ?_, hc⟩ + simp only [narrowRd, narrowWr, List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, + or_false] at hr ⊢ + rcases hr with h | h | h | h | h <;> simp_all only [or_true, true_or] + · intro s h + obtain ⟨_, wr, _⟩ := h + rw [wr] + intro a n ⟨r, hr, hc⟩ + refine ⟨r, ?_, hc⟩ + simp only [narrowWr, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp_all only [or_true, true_or] + +/-! ## The callee -/ + +open VG.Impl.Camellia.X86 (ctrFramed ctrCall ctrFinalSave ctrFinalArgs ctrFinalTailArgs ctrFinalXorArgs + ctrFinalRestore ctrFinalTail ctrFinal) + +/-- `vg_camellia_ctr` meets its contract on the subkeys. -/ +theorem ctrFramed_sk : Verified X86.target ctrFramed (Proof.Camellia.ctrContractSk X86.abi 2772) := + X86.Verified.stackScratchWiped (sig := Spec.Camellia.ctrSig) (nm := "scratch") (e := .u64) + (n := 341) (pre := Spec.Camellia.ctrPre X86.abi.ptrBits) (post := Proof.Camellia.ctrPostSk X86.abi.ptrBits) + (wa := true) (stack := 16) (bytes := 2756) Ctr.ctr_verified (by decide) (by lit_decide) (by lit_decide) + (by decide) (Proof.Camellia.ctrPre_local _) (Proof.Camellia.ctrPost_local _) + (Proof.Camellia.ctrPostOut_local _) (Ctr.frameSat_ctr _) + +/-- The contract `vg_camellia_ctr` is called by. -/ +abbrev calleeK : Contract isa := Proof.Camellia.ctrContractSk X86.abi 2772 + +abbrev ctrRegs : List Reg := [.esi, .ebx, .edx, .ecx, .eax] + +theorem ctrRegs_esp : Reg.esp ∉ ctrRegs := by decide + +theorem ctr_stack : stackUse ctrFramed = 2772 := by + have h : stackUse Impl.Camellia.X86.ctr = 16 := by lit_decide + simp only [ctrFramed, Impl.StackScratch.X86.withStackScratchWiped, Impl.StackScratch.X86.withStackScratch, + stackUse, h, X86.frameBytes] + decide + +theorem ctr_nosp : NoSp ctrFramed := NoSp.of_all (by unfold ctrFramed; lit_decide) + +theorem sw32 (x : BitVec 32) : (x.setWidth 64).setWidth 32 = x := by + apply BitVec.eq_of_toNat_eq; simp + +theorem toNat_sw (x : BitVec 32) : (x.setWidth 64).toNat = x.toNat := by + simp only [BitVec.toNat_setWidth]; exact Nat.mod_eq_of_lt (by have := x.isLt; omega) + +/-- The bytes `[d, d + n)` of the `b` bytes below `E`, from their bottom. -/ +theorem below_off {E : BitVec 32} {b d k : Nat} (hb : b ≤ E.toNat) (hk : k ≤ b) (hd : d = b - k) : + ((E - BitVec.ofNat 32 k).setWidth 64) = (below E b).base + BitVec.ofNat 64 d := by + apply BitVec.eq_of_toNat_eq + have := E.isLt + simp only [BitVec.toNat_setWidth, BitVec.toNat_add, BitVec.toNat_ofNat] + rw [sub_toNat (by omega), sub_toNat hb] + subst hd + rw [Nat.mod_eq_of_lt (a := E.toNat - k) (by omega), Nat.mod_eq_of_lt (a := E.toNat - b) (by omega), + Nat.mod_eq_of_lt (a := b - k) (by omega), Nat.mod_eq_of_lt (by omega)] + omega + +theorem subkeysAt_frame {rs : List Region} {m m' : Mem} (hf : Frame rs m m') {p : Addr} {R : Nat} + (hR : R = 18 ∨ R = 24) (hd : ∀ r ∈ rs, (⟨p, 272⟩ : Region).Disjoint r) : + Spec.Camellia.subkeysAt m' p R = Spec.Camellia.subkeysAt m p R := + Proof.Camellia.subkeysAt_congr (by rcases hR with rfl | rfl <;> decide) + fun i hi => hf.bytes (R := ⟨p, 272⟩) hd (by show 272 ≤ 2 ^ 64; omega) hi + +theorem one_disj {k : Region} {p : Addr} {n : Nat} (h : k.Disjoint ⟨p, n⟩) : + ∀ r ∈ [k], (⟨p, n⟩ : Region).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact h.symm + +/-- What a call of `vg_camellia_ctr` needs: the subkeys at `W` with `R` +rounds, the counter block at `C` and `n` blocks at `D`, and 2796 bytes of +stack for the arguments, the return address and the callee's frames. -/ +structure CCall (s : State) (W R C D : BitVec 32) (n : Nat) : Prop where + eax : s.gpr .eax = W + ecx : s.gpr .ecx = R + edx : s.gpr .edx = C + ebx : s.gpr .ebx = D + esi : s.gpr .esi = BitVec.ofNat 32 n + esp : 2796 ≤ (s.gpr .esp).toNat + rounds : R.toNat = 18 ∨ R.toNat = 24 + wc : (⟨W.setWidth 64, 272⟩ : Region).Disjoint ⟨C.setWidth 64, 16⟩ + wd : (⟨W.setWidth 64, 272⟩ : Region).Disjoint ⟨D.setWidth 64, 16 * n⟩ + cd : (⟨C.setWidth 64, 16⟩ : Region).Disjoint ⟨D.setWidth 64, 16 * n⟩ + bw : (below (s.gpr .esp) 2796).Disjoint ⟨W.setWidth 64, 272⟩ + bc : (below (s.gpr .esp) 2796).Disjoint ⟨C.setWidth 64, 16⟩ + bd : (below (s.gpr .esp) 2796).Disjoint ⟨D.setWidth 64, 16 * n⟩ + fW : W.toNat + 272 ≤ 2 ^ 32 + fC : C.toNat + 16 ≤ 2 ^ 32 + fD : D.toNat + 16 * n ≤ 2 ^ 32 + reads : Covers [⟨W.setWidth 64, 272⟩] (s.rd ++ s.wr) + writes : Covers [⟨C.setWidth 64, 16⟩, ⟨D.setWidth 64, 16 * n⟩] s.wr + +/-- What a call of `vg_camellia_ctr` leaves. -/ +structure CPost (s : State) (W R C D : BitVec 32) (n : Nat) (s' : State) : Prop where + rd : s'.rd = s.rd + wr : s'.wr = s.wr + saved : ∀ r ∈ calleeSaved, s'.gpr r = s.gpr r + frame : Frame [⟨C.setWidth 64, 16⟩, ⟨D.setWidth 64, 16 * n⟩, below (s.gpr .esp) 2796] s.mem s'.mem + out : Spec.Cbc.blocksAt s'.mem (D.setWidth 64) n = + Spec.Ctr.crypt (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (W.setWidth 64) R.toNat)) + (bytesAt s.mem (C.setWidth 64) 16) (Spec.Cbc.blocksAt s.mem (D.setWidth 64) n) + ctr : bytesAt s'.mem (C.setWidth 64) 16 = Spec.Ctr.next (bytesAt s.mem (C.setWidth 64) 16) n + +abbrev calleeRd (W : BitVec 32) : List Region := [⟨W.setWidth 64, 272⟩] +abbrev calleeWr (E C D : BitVec 32) (n : Nat) : List Region := + [⟨C.setWidth 64, 16⟩, ⟨D.setWidth 64, n * 16⟩, below E 20] + +namespace CCall +variable {s : State} {W R C D : BitVec 32} {n : Nat} (h : CCall s W R C D n) +include h + +theorem fit : 4 * ctrRegs.length + 4 ≤ (s.gpr .esp).toNat := by + have := h.esp; simp only [List.length_cons, List.length_nil]; omega + +theorem n_lt : n < 2 ^ 32 := by have := h.fD; omega + +theorem args : arg (pushed ctrRegs s).callEntry 0 = W ∧ arg (pushed ctrRegs s).callEntry 1 = R ∧ + arg (pushed ctrRegs s).callEntry 2 = C ∧ arg (pushed ctrRegs s).callEntry 3 = D ∧ + arg (pushed ctrRegs s).callEntry 4 = BitVec.ofNat 32 n := by + refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> + rw [callEntry_arg h.fit ctrRegs_esp (by decide)] <;> simp [h.eax, h.ecx, h.edx, h.ebx, h.esi] + +theorem callPre : CallPre calleeK ctrRegs (calleeRd W) (calleeWr (s.gpr .esp) C D n) s := by + obtain ⟨a0, a1, a2, a3, a4⟩ := h.args + have hn : (BitVec.ofNat 32 n).toNat = n := by rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt h.n_lt] + have hE := h.esp + have := (s.gpr .esp).isLt + have eA : argAddr (pushed ctrRegs s).callEntry 0 = (below (s.gpr .esp) 2796).base + BitVec.ofNat 64 2776 := by + rw [callEntry_argAddr0]; exact below_off (by omega) (by decide) rfl + have eB : (below (s.gpr .esp) 20) = ⟨(below (s.gpr .esp) 2796).base + BitVec.ofNat 64 2776, 20⟩ := + congrArg (fun x => (⟨x, 20⟩ : Region)) (below_off (by omega) (by decide) rfl) + have e6 : s.gpr .esp - 4 - 4 - 4 - 4 - 4 - 4 = s.gpr .esp - BitVec.ofNat 32 24 := by + simp only [BitVec.sub_sub]; rfl + have eR : (s.gpr .esp - BitVec.ofNat 32 24).setWidth 64 = + (below (s.gpr .esp) 2796).base + BitVec.ofNat 64 2772 := + below_off (by omega) (by decide) rfl + have eS : (below (s.gpr .esp) 2796).base + BitVec.ofNat 64 2772 - 2772#64 = (below (s.gpr .esp) 2796).base := + BitVec.add_sub_cancel _ _ + have eN : (s.gpr .esp - BitVec.ofNat 32 24).toNat = (s.gpr .esp).toNat - 24 := sub_toNat (by omega) + let B := (below (s.gpr .esp) 2796).base + try rewrite [show (below (s.gpr .esp) 2796).base = B from rfl] at * + have hb : below (s.gpr .esp) 2796 = ⟨B, 2796⟩ := rfl + have sb {d k : Nat} (hd : d + k ≤ 2796) {r : Region} (hr : (below (s.gpr .esp) 2796).Disjoint r) : + (⟨B + BitVec.ofNat 64 d, k⟩ : Region).Disjoint r := by + rw [hb] at hr; exact hr.sub_left (Offset.sub_base _ hd) + have sb0 {r : Region} (hr : (below (s.gpr .esp) 2796).Disjoint r) : (⟨B, 2772⟩ : Region).Disjoint r := by + rw [hb] at hr; exact hr.sub_left (Region.sub_prefix (by decide)) + have hwd := h.wd + have hcd := h.cd + have hbd := h.bd + have hfD := h.fD + rw [Nat.mul_comm] at hwd hcd hbd hfD + refine ⟨?_, ?_, ?_⟩ + · sig_pre [calleeK, Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Spec.Camellia.ctrPre, X86.abi, argVal, + ↓reduceIte, Nat.reduceEqDiff, argBytes, Nat.reduceDiv, List.sum_cons, List.sum_nil, Nat.reduceAdd, + Nat.reduceMul, sw32, toNat_sw] + simp only [arg_withRegions, argAddr_withRegions, a0, a1, a2, a3, a4, hn, eA, e6, eN, eR, eS] + have r1 : (⟨B + BitVec.ofNat 64 2772, 4⟩ : Region).Disjoint ⟨B + BitVec.ofNat 64 2776, 20⟩ := + Offset.disjoint B (.inl (by decide)) (by omega) (by omega) + have r2 : (⟨B, 2772⟩ : Region).Disjoint ⟨B + BitVec.ofNat 64 2776, 20⟩ := + Offset.base_disjoint B (by decide) (by omega) + exact ⟨by omega, by omega, trivial, by rw [calleeWr, eB], h.wc, hwd, (sb (by decide) h.bw).symm, hcd, + (sb (by decide) h.bc).symm, (sb (by decide) hbd).symm, sb (by decide) h.bw, sb (by decide) h.bc, + sb (by decide) hbd, r1, sb0 h.bw, sb0 h.bc, sb0 hbd, r2, h.fW, h.fC, hfD, h.rounds⟩ + · intro a m ⟨r, hr, hcn⟩ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · obtain ⟨r', hr', hc'⟩ := h.reads a m ⟨_, List.mem_singleton_self _, hcn⟩ + exact InRegions_append_cons.mpr (.inr ⟨r', hr', hc'⟩) + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨_, by simp, hcn⟩ + exact InRegions_append_cons.mpr (.inr ⟨r', List.mem_append_right _ hr', hc'⟩) + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨⟨D.setWidth 64, 16 * n⟩, by simp, by rwa [Nat.mul_comm]⟩ + exact InRegions_append_cons.mpr (.inr ⟨r', List.mem_append_right _ hr', hc'⟩) + · exact InRegions_append_cons.mpr (.inl hcn) + · intro a m ⟨r, hr, hcn⟩ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨_, by simp, hcn⟩ + exact ⟨r', List.mem_cons_of_mem _ hr', hc'⟩ + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨⟨D.setWidth 64, 16 * n⟩, by simp, by rwa [Nat.mul_comm]⟩ + exact ⟨r', List.mem_cons_of_mem _ hr', hc'⟩ + · exact ⟨_, List.mem_cons_self .., hcn⟩ + +end CCall + +/-- `vg_camellia_ctr`'s postcondition. -/ +theorem calleeK_post {s s' : State} (h : calleeK.post s s') (hR : (arg s 1).toNat = 18 ∨ (arg s 1).toNat = 24) : + Spec.Cbc.blocksAt s'.mem ((arg s 3).setWidth 64) (arg s 4).toNat = + Spec.Ctr.crypt (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem ((arg s 0).setWidth 64) (arg s 1).toNat)) + (bytesAt s.mem ((arg s 2).setWidth 64) 16) (Spec.Cbc.blocksAt s.mem ((arg s 3).setWidth 64) (arg s 4).toNat) ∧ + bytesAt s'.mem ((arg s 2).setWidth 64) 16 = Spec.Ctr.next (bytesAt s.mem ((arg s 2).setWidth 64) 16) (arg s 4).toNat := by + sig_post [calleeK, Proof.Camellia.ctrContractSk, Proof.Camellia.ctrPostSk, Spec.Camellia.ctrSig, X86.abi, argVal, + ↓reduceIte, Nat.reduceEqDiff, argBytes, Nat.reduceDiv, List.sum_cons, List.sum_nil, Nat.reduceAdd, Nat.reduceMul, + sw32, toNat_sw] at h + exact h hR + +/-- Its public data, from the arguments. -/ +theorem calleeK_pub {s₁ s₂ : State} (h : s₁.gpr .esp = s₂.gpr .esp ∧ ∀ i < 5, arg s₁ i = arg s₂ i) : + calleeK.pub s₁ s₂ := by + obtain ⟨a₁, a₂⟩ := h + sig_pub [calleeK, Proof.Camellia.ctrContractSk, Proof.Camellia.ctrPostSk, Spec.Camellia.ctrSig, X86.abi, argVal, + ↓reduceIte, Nat.reduceEqDiff, argBytes, Nat.reduceDiv, List.sum_cons, List.sum_nil, Nat.reduceAdd, Nat.reduceMul, + sw32, toNat_sw] + exact ⟨a₁, a₂ 0 (by decide), a₂ 1 (by decide), a₂ 2 (by decide), a₂ 3 (by decide), a₂ 4 (by decide)⟩ + +theorem ctr_call {s : State} {W R C D : BitVec 32} {n : Nat} (h : CCall s W R C D n) : + WP isa ctrCall s (CPost s W R C D n) := by + have hn : (BitVec.ofNat 32 n).toNat = n := by rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt h.n_lt] + unfold ctrCall + refine WP.callWith (rs := ctrRegs) (k := calleeK) ctrFramed_sk.1 ctr_nosp (by simp) ctrRegs_esp + (by rw [ctr_stack]; have := h.esp; simp only [List.length_cons, List.length_nil]; omega) + h.callPre fun s' rd' wr' cs' f' ⟨s₂, m₂, post⟩ => ?_ + obtain ⟨a0, a1, a2, a3, a4⟩ := h.args + rw [ctr_stack] at f' + have fE := callEntry_frame h.fit ctrRegs_esp + rw [show 4 * ctrRegs.length + 4 = 24 from rfl] at fE + have fE' : Frame [below (s.gpr .esp) 2796] s.mem (pushed ctrRegs s).callEntry.mem := + fE.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨_, List.mem_singleton_self _, VG.X86.below_sub (by decide) h.esp⟩ + have hR := h.rounds + obtain ⟨hdata, hctr⟩ := calleeK_post post (by simp only [arg_withRegions, a1]; exact hR) + simp only [arg_withRegions, State.withRegions_mem, a0, a1, a2, a3, a4, hn, m₂] at hdata hctr + rw [Proof.Cmac.bytesAt_frame fE' (one_disj h.bc) (by decide), AesCfb.X86.blocksAt_frame' fE' (one_disj h.bd), + subkeysAt_frame fE' hR (one_disj h.bw)] at hdata + rw [Proof.Cmac.bytesAt_frame fE' (one_disj h.bc) (by decide)] at hctr + refine ⟨rd', wr', cs', ?_, hdata, hctr⟩ + refine f'.sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨⟨D.setWidth 64, 16 * n⟩, by simp, by rw [Nat.mul_comm]; exact fun _ h => h⟩ + · exact ⟨below (s.gpr .esp) 2796, by simp, VG.X86.below_sub (by decide) h.esp⟩ + · exact ⟨below (s.gpr .esp) 2796, by simp, VG.X86.below_sub (by decide) h.esp⟩ + +/-- Calls of `vg_camellia_ctr` with the same arguments and stack pointer in +both runs are constant time. -/ +theorem ctr_rel {P : State → State → Prop} {W R C D E : BitVec 32} {n : Nat} + (h : ∀ s₁ s₂, P s₁ s₂ → CCall s₁ W R C D n ∧ CCall s₂ W R C D n ∧ s₁.gpr .esp = E ∧ s₂.gpr .esp = E) : + RelCT isa P ctrCall fun _ _ => True := by + unfold ctrCall + refine RelCT.callWith (rs := ctrRegs) ctrFramed_sk.1 ctrFramed_sk.2.1 (calleeRd W) (calleeWr E C D n) + fun s₁ s₂ hP => ?_ + obtain ⟨h₁, h₂, e₁, e₂⟩ := h s₁ s₂ hP + have p₁ := h₁.callPre + have p₂ := h₂.callPre + rw [e₁] at p₁ + rw [e₂] at p₂ + refine ⟨p₁, p₂, e₁.trans e₂.symm, calleeK_pub ⟨?_, fun i hi => ?_⟩⟩ + · simp only [State.withRegions_gpr, callEntry_esp', e₁, e₂] + obtain ⟨a0, a1, a2, a3, a4⟩ := h₁.args + obtain ⟨b0, b1, b2, b3, b4⟩ := h₂.args + simp only [arg_withRegions] + rcases (by omega : i = 0 ∨ i = 1 ∨ i = 2 ∨ i = 3 ∨ i = 4) with rfl | rfl | rfl | rfl | rfl + · rw [a0, b0] + · rw [a1, b1] + · rw [a2, b2] + · rw [a3, b3] + · rw [a4, b4] + +theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by + simp [Spec.Camellia.cipher] + +/-! ## The arguments, by name -/ + +open VG.Impl.CmacAes.X86 (argOp) +open VG.Impl.AesCfb.X86 (finalSaved tailTest) +open VG.Impl.AesCtr.X86 (zeroSlots) +open VG.Proof.CmacAes.X86 (wp_arg ofNat_and_self_beq) +open VG.Proof.MdStream.X86 (wp_mov wp_movi wp_andi wp_test wp_shr wp_sub wp_add wp_addi eval_e) + +section +variable (s₀ : State) + +abbrev fE : BitVec 32 := s₀.gpr .esp +abbrev fW : BitVec 32 := arg s₀ 0 +abbrev fRr : BitVec 32 := arg s₀ 1 +abbrev fR : Nat := (arg s₀ 1).toNat +abbrev fIv : BitVec 32 := arg s₀ 2 +abbrev fD : BitVec 32 := arg s₀ 3 +abbrev fL : Nat := (arg s₀ 4).toNat +abbrev fV : BitVec 32 := arg s₀ 5 +/-- The whole blocks, the bytes after them, and where those start. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +abbrev fT : BitVec 32 := fD s₀ + BitVec.ofNat 32 (16 * fN s₀) +abbrev fSch : Region := ⟨(fW s₀).setWidth 64, 272⟩ +abbrev fIvR : Region := ⟨(fIv s₀).setWidth 64, 16⟩ +abbrev fData : Region := ⟨(fD s₀).setWidth 64, fL s₀⟩ +abbrev fBlk : Region := ⟨(fD s₀).setWidth 64, 16 * fN s₀⟩ +abbrev fTail : Region := ⟨(fD s₀).setWidth 64 + BitVec.ofNat 64 (16 * fN s₀), fU s₀⟩ +/-- The registers in `save`; all of `save`; the block after the registers, +as the code computes it and as a region. -/ +abbrev fSv : Region := ⟨(fV s₀).setWidth 64, 16⟩ +abbrev cSv : Region := ⟨(fV s₀).setWidth 64, 32⟩ +abbrev cBk : BitVec 32 := fV s₀ + BitVec.ofNat 32 16 +abbrev cBlk : Region := ⟨(fV s₀).setWidth 64 + BitVec.ofNat 64 16, 16⟩ +abbrev fArgs : Region := ⟨argAddr s₀ 0, 24⟩ +abbrev fRet : Region := ⟨(fE s₀).setWidth 64, 4⟩ +abbrev fStk : Region := below (fE s₀) 2796 +/-- The cipher, the counter block and the whole blocks on entry. -/ +abbrev fCiph : Spec.Cbc.Cipher := Spec.Camellia.cipher (Spec.Camellia.subkeysAt s₀.mem ((fW s₀).setWidth 64) (fR s₀)) +abbrev fIv0 : List Byte := bytesAt s₀.mem ((fIv s₀).setWidth 64) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem ((fD s₀).setWidth 64) (fN s₀) + +/-- The memory once the registers are saved. -/ +def svMem : Mem := Spill.saveMem s₀.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₀.gpr finalSaved + +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, cSv s₀, fStk s₀] +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, cBlk s₀, fStk s₀] +abbrev cW : List Region := [fIvR s₀, fData s₀, cBlk s₀, fStk s₀] + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + rd : s₀.rd = [fSch s₀, fArgs s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + iv_args : (fIvR s₀).Disjoint (fArgs s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_args : (fData s₀).Disjoint (fArgs s₀) + sv_args : (cSv s₀).Disjoint (fArgs s₀) + ret_iv : (fRet s₀).Disjoint (fIvR s₀) + ret_data : (fRet s₀).Disjoint (fData s₀) + ret_sv : (fRet s₀).Disjoint (cSv s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_iv : (fStk s₀).Disjoint (fIvR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + sch_fit : (fW s₀).toNat + 272 ≤ 2 ^ 32 + iv_fit : (fIv s₀).toNat + 16 ≤ 2 ^ 32 + data_fit : (fD s₀).toNat + fL s₀ ≤ 2 ^ 32 + sv_fit : (fV s₀).toNat + 32 ≤ 2 ^ 32 + espB : 2796 ≤ (fE s₀).toNat + esp_fit : (fE s₀).toNat + 28 ≤ 2 ^ 32 + rounds : fR s₀ = 18 ∨ fR s₀ = 24 + +theorem stk_eq {s₀ : State} (h : 2796 ≤ (fE s₀).toNat) : + fStk s₀ = ⟨(fE s₀).setWidth 64 - BitVec.ofNat 64 2796, 2796⟩ := by + show (⟨(fE s₀ - BitVec.ofNat 32 2796).setWidth 64, 2796⟩ : Region) = _ + rw [Taint.sub_setWidth h] + +theorem CPre.of {s₀ : State} (h : ctrFinalX86.pre s₀) : CPre s₀ := by + obtain ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24, a25⟩ := h + have e := stk_eq a23 + exact ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, e ▸ a15, e ▸ a16, e ▸ a17, e ▸ a18, + a19, a20, a21, a22, a23, a24, a25⟩ + +/-! ## Addresses and regions -/ + +theorem sv16_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) +theorem sv_blk (s₀ : State) : (fSv s₀).Disjoint (cBlk s₀) := Offset.base_disjoint _ (Nat.le_refl _) (by decide) +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) +theorem fU_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.cBk_addr : (cBk s₀).setWidth 64 = (cBlk s₀).base := addr_eq (by have := hp.sv_fit; omega) + +theorem CPre.cBk_toNat : (cBk s₀).toNat = (fV s₀).toNat + 16 := by + have := hp.sv_fit + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem CPre.cBlk1 : (⟨(cBk s₀).setWidth 64, 16 * 1⟩ : Region) = cBlk s₀ := by rw [hp.cBk_addr] + +theorem CPre.argA {i : Nat} (hi : i < 6) : argAddr s₀ i = argAddr s₀ 0 + BitVec.ofNat 64 (4 * i) := by + have : (s₀.gpr .esp).toNat + 28 ≤ 2 ^ 32 := hp.esp_fit + simp only [argAddr] + rw [show (s₀.gpr .esp + BitVec.ofNat 32 (4 + 4 * i)).setWidth 64 = addr (s₀.gpr .esp) (4 + 4 * i) from rfl, + show (s₀.gpr .esp + BitVec.ofNat 32 (4 + 4 * 0)).setWidth 64 = addr (s₀.gpr .esp) (4 + 4 * 0) from rfl, + addr_eq (by omega), addr_eq (by omega), Offset.add_add] + +theorem CPre.arg_sub {i : Nat} (hi : i < 6) : Region.Sub ⟨argAddr s₀ i, 4⟩ (fArgs s₀) := by + rw [hp.argA hi]; exact Offset.sub_base _ (by omega) + +theorem CPre.arg_in {i : Nat} (hi : i < 6) : InRegions (s₀.rd ++ s₀.wr) (argAddr s₀ i) 4 := by + refine ⟨fArgs s₀, by simp [hp.rd], ?_⟩ + rw [hp.argA hi]; exact Offset.contains_base _ (by omega) (by omega) + +theorem CPre.args_stk : (fArgs s₀).Disjoint (fStk s₀) := by + have : (s₀.gpr .esp).toNat + 28 ≤ 2 ^ 32 := hp.esp_fit + have e : argAddr s₀ 0 = (fE s₀).setWidth 64 + BitVec.ofNat 64 4 := addr_eq (by omega) + rw [stk_eq hp.espB] + show Region.Disjoint ⟨argAddr s₀ 0, 24⟩ _ + rw [e]; exact (Offset.disjoint_below_above _ (by decide)).symm + +theorem CPre.ret_stk : (fRet s₀).Disjoint (fStk s₀) := by + rw [stk_eq hp.espB] + have := Offset.disjoint_below_above ((fE s₀).setWidth 64) (m := 2796) (a := 0) (l := 4) (by decide) + rw [BitVec.add_zero] at this + exact this.symm + +/-- The stack arguments are unchanged where only `cBig` changes. -/ +theorem CPre.arg_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) {i : Nat} (hi : i < 6) : + m.readW (argAddr s₀ i) 32 = arg s₀ i := + hf.readW (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_args.symm.sub_left (hp.arg_sub hi) + · exact hp.data_args.symm.sub_left (hp.arg_sub hi) + · exact hp.sv_args.symm.sub_left (hp.arg_sub hi) + · exact hp.args_stk.sub_left (hp.arg_sub hi)) (by decide) + +/-- The return address is unchanged where only `cBig` changes. -/ +theorem CPre.ret_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + m.readW ((fE s₀).setWidth 64) 32 = s₀.mem.readW ((fE s₀).setWidth 64) 32 := + hf.readW (r := fRet s₀) (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.ret_iv + · exact hp.ret_data + · exact hp.ret_sv + · exact hp.ret_stk) (by decide) + +/-- The subkeys are unchanged where only `cBig` changes. -/ +theorem CPre.sched_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + Spec.Camellia.subkeysAt m ((fW s₀).setWidth 64) (fR s₀) = + Spec.Camellia.subkeysAt s₀.mem ((fW s₀).setWidth 64) (fR s₀) := + subkeysAt_frame hf hp.rounds fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +theorem CPre.blk_fit : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 32 := by + have := hp.data_fit; have := Nat.mul_div_le (fL s₀) 16; have : fN s₀ = fL s₀ / 16 := rfl; omega + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + exact Offset.base_disjoint _ (Nat.le_refl _) (by omega) + +end + +/-! ## Frames -/ + +/-- The save changes only `save`. -/ +theorem svMem_frame (s₀ : State) : Frame [fSv s₀] s₀.mem (svMem s₀) := + Spill.saveMem_frame List.mem_cons_self _ _ _ _ fun p hp => + have : p.2 + 4 ≤ 16 := (show Spill.Fits 16 finalSaved by decide).1 p hp + Offset.contains_base _ (by omega) (by omega) + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +/-- Everything the function writes, from the save on. -/ +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv16_sub s₀⟩).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.sv_sched : Spec.Camellia.subkeysAt (svMem s₀) ((fW s₀).setWidth 64) (fR s₀) = + Spec.Camellia.subkeysAt s₀.mem ((fW s₀).setWidth 64) (fR s₀) := + hp.sched_keep (big_of (Frame.refl _ _)) + +theorem CPre.sv_iv : bytesAt (svMem s₀) ((fIv s₀).setWidth 64) 16 = fIv0 s₀ := + Proof.Cmac.bytesAt_frame (svMem_frame s₀) (one_disj (hp.iv_sv.sub_right (sv16_sub s₀)).symm) (by decide) + +theorem CPre.sv_blocks : Spec.Cbc.blocksAt (svMem s₀) ((fD s₀).setWidth 64) (fN s₀) = fBlks s₀ := + AesCfb.X86.blocksAt_frame' (svMem_frame s₀) + (one_disj ((hp.data_sv.sub_left (blk_sub s₀)).sub_right (sv16_sub s₀)).symm) + +end + +/-! ## Saving the registers, and the arguments of the call on the whole blocks -/ + +theorem setup_eq : ctrFinalSave ++ ctrFinalArgs = + .mov .eax (argOp 5) :: (Spill.saveCode .eax finalSaved ++ ctrFinalArgs) := rfl + +theorem args_eq : ctrFinalArgs = [.mov .eax (argOp 0), .mov .ecx (argOp 1), .mov .edx (argOp 2), + .mov .ebx (argOp 3), .mov .esi (argOp 4), .shift .shr .esi 4] := rfl + +/-- What saving the registers and setting up the arguments leaves. -/ +structure Setup (s₀ s : State) : Prop where + eax : s.gpr .eax = fW s₀ + ecx : s.gpr .ecx = fRr s₀ + edx : s.gpr .edx = fIv s₀ + ebx : s.gpr .ebx = fD s₀ + esi : s.gpr .esi = BitVec.ofNat 32 (fN s₀) + esp : s.gpr .esp = fE s₀ + mem : s.mem = svMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : CPre s₀) : + WP isa (.block (ctrFinalSave ++ ctrFinalArgs)) s₀ (Setup s₀) := by + rw [setup_eq] + refine wp_arg (s₀ := s₀) rfl (hp.arg_in (by decide)) rfl fun s₁ u₁ => ?_ + have h₁ : s₁.gpr .eax = fV s₀ := u₁.gpr + refine Spill.save_ofNat_ok finalSaved AesCfb.X86.finalSaved_fits + (by rw [h₁]; have := hp.sv_fit; omega) (fun p hp' => ?_) fun s₂ u₂ => ?_ + · have hb : p.2 + 4 ≤ 16 := AesCfb.X86.finalSaved_fits.1 p hp' + rw [h₁, u₁.wr, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have hm₂ : s₂.mem = svMem s₀ := by + rw [u₂.mem, u₁.mem, h₁, svMem] + exact Spill.saveMem_congr _ _ (fun _ _ => rfl) fun p hp' => + u₁.other _ (AesCfb.X86.finalSaved_ne_eax p hp') + have esp₂ : s₂.gpr .esp = s₀.gpr .esp := by rw [u₂.gpr, u₁.other _ (by decide)] + have rw₂ : s₂.rd ++ s₂.wr = s₀.rd ++ s₀.wr := by rw [u₂.rd, u₂.wr, u₁.rd, u₁.wr] + have big := big_of (s₀ := s₀) (Frame.refl _ (svMem s₀)) + have ak : ∀ i < 6, (svMem s₀).readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [args_eq] + refine wp_arg (s₀ := s₀) esp₂ (by rw [rw₂]; exact hp.arg_in (by decide)) + (by rw [hm₂]; exact ak 0 (by decide)) fun s₃ u₃ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₃.other _ (by decide), esp₂]) + (by rw [u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₃.mem, hm₂]; exact ak 1 (by decide)) fun s₄ u₄ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₄.mem, u₃.mem, hm₂]; exact ak 2 (by decide)) fun s₅ u₅ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₅.rd, u₅.wr, u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₅.mem, u₄.mem, u₃.mem, hm₂]; exact ak 3 (by decide)) fun s₆ u₆ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₆.mem, u₅.mem, u₄.mem, u₃.mem, hm₂]; exact ak 4 (by decide)) fun s₇ u₇ => ?_ + refine wp_shr (by decide) fun s₈ u₈ => ?_ + refine WP.block_nil ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + u₄.other _ (by decide), u₃.gpr] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.gpr] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr] + · rw [u₈.gpr, u₇.gpr, AesCfb.X86.shr4] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + u₄.other _ (by decide), u₃.other _ (by decide), esp₂] + · rw [u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, hm₂] + · rw [u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-! ## The call on the whole blocks -/ + +theorem Setup.call {s₀ s : State} (hp : CPre s₀) (h : Setup s₀ s) : + CCall s (fW s₀) (fRr s₀) (fIv s₀) (fD s₀) (fN s₀) where + eax := h.eax + ecx := h.ecx + edx := h.edx + ebx := h.ebx + esi := h.esi + esp := by rw [h.esp]; exact hp.espB + rounds := hp.rounds + wc := hp.sch_iv + wd := hp.sch_data.sub_right (blk_sub s₀) + cd := hp.iv_data.sub_right (blk_sub s₀) + bw := by rw [h.esp]; exact hp.stk_sch + bc := by rw [h.esp]; exact hp.stk_iv + bd := by rw [h.esp]; exact hp.stk_data.sub_right (blk_sub s₀) + fW := hp.sch_fit + fC := hp.iv_fit + fD := hp.blk_fit + reads := by + rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + writes := by + rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- What the call on the whole blocks leaves. -/ +structure Whole (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame [fIvR s₀, fBlk s₀, fStk s₀] (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +theorem whole_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : WP isa ctrCall s (Whole s₀) := by + refine WP.mono (ctr_call (h.call hp)) fun s' c => ?_ + have f := c.frame + rw [h.esp, h.mem] at f + refine ⟨by rw [c.saved .esp (by simp [calleeSaved]), h.esp], by rw [c.rd, h.rd], by rw [c.wr, h.wr], f, ?_, ?_⟩ + · rw [c.out, h.mem, hp.sv_sched, hp.sv_iv, hp.sv_blocks] + · rw [c.ctr, h.mem, hp.sv_iv] + +theorem Whole.of_eq {s₀ s s' : State} (h : Whole s₀ s) (esp : s'.gpr .esp = s.gpr .esp) + (mem : s'.mem = s.mem) (rd : s'.rd = s.rd) (wr : s'.wr = s.wr) : Whole s₀ s' := + ⟨by rw [esp, h.esp], by rw [rd, h.rd], by rw [wr, h.wr], by rw [mem]; exact h.frame, + by rw [mem]; exact h.blocks, by rw [mem]; exact h.ctr⟩ + +theorem whole_cW1 {s₀ s : State} (h : Whole s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem whole_cW {s₀ s : State} (h : Whole s₀ s) : Frame (cW s₀) (svMem s₀) s.mem := + cW1_cW (whole_cW1 h) + +/-- The test sets ZF if no bytes are left after the whole blocks. -/ +theorem test_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole s₀ s) : + WP isa (.block tailTest) s fun s' => Whole s₀ s' ∧ s'.zf = some (decide (fU s₀ = 0)) := by + have big := big_of (whole_cW h) + rw [AesCfb.X86.tailTest_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) (hp.arg_keep big (by decide)) + fun s₁ u₁ => wp_andi fun s₂ u₂ => wp_test fun s₃ f₃ z₃ => WP.block_nil + ⟨h.of_eq (by rw [f₃.gpr, u₂.other _ (by decide), u₁.other _ (by decide)]) + (by rw [f₃.mem, u₂.mem, u₁.mem]) (by rw [f₃.rd, u₂.rd, u₁.rd]) (by rw [f₃.wr, u₂.wr, u₁.wr]), ?_⟩ + have := fU_lt s₀ + rw [z₃, u₂.gpr, u₁.gpr, AesCfb.X86.and15, ofNat_and_self_beq (by omega)] + +/-! ## The partial last block: its arguments -/ + +theorem tailArgs_eq : ctrFinalTailArgs = .mov .eax (argOp 5) :: .mov .ecx (.imm 0) :: + (Spill.saveCode .eax zeroSlots ++ ([.mov .ebx (.reg .eax), .alu .add .ebx (.imm 16), .mov .eax (argOp 0), + .mov .ecx (argOp 1), .mov .edx (argOp 2), .mov .esi (.imm 1)] : List Instr)) := rfl + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + eax : s.gpr .eax = fW s₀ + ecx : s.gpr .ecx = fRr s₀ + edx : s.gpr .edx = fIv s₀ + ebx : s.gpr .ebx = cBk s₀ + esi : s.gpr .esi = 1 + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBlk s₀).base 16 = List.replicate 16 0 + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (TArgs s₀) := by + have f₁ := whole_cW1 h + have big := big_of (cW1_cW f₁) + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have ak : ∀ i < 6, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [tailArgs_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (ak 5 (by decide)) fun s₁ u₁ => ?_ + refine wp_movi fun s₂ u₂ => ?_ + have eax₂ : s₂.gpr .eax = fV s₀ := by rw [u₂.other _ (by decide), u₁.gpr] + refine Spill.save_ofNat_ok zeroSlots AesCtr.X86.zeroSlots_fits (by rw [eax₂]; exact hp.sv_fit) + (fun p hp' => ?_) fun s₃ u₃ => ?_ + · have hb : p.2 + 4 ≤ 32 := AesCtr.X86.zeroSlots_fits.1 p hp' + rw [eax₂, u₂.wr, u₁.wr, h.wr, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have hm₃ : s₃.mem = Spill.saveMem s.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₂.gpr zeroSlots := by + rw [u₃.mem, eax₂, u₂.mem, u₁.mem] + have fz : Frame [cBlk s₀] s.mem s₃.mem := by + rw [hm₃] + exact Spill.saveMem_frame List.mem_cons_self _ _ _ _ fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl | rfl | rfl + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + have g₃ : s₃.gpr = s₂.gpr := u₃.gpr + have esp₃ : s₃.gpr .esp = fE s₀ := by rw [g₃, u₂.other _ (by decide), u₁.other _ (by decide), h.esp] + have rw₃ : s₃.rd ++ s₃.wr = s₀.rd ++ s₀.wr := by rw [u₃.rd, u₃.wr, u₂.rd, u₂.wr, u₁.rd, u₁.wr, hrw] + have ak₃ : ∀ i < 6, s₃.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => by + rw [fz.readW (r := ⟨argAddr s₀ i, 4⟩) (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.sv_args.symm.sub_left (hp.arg_sub hi)).sub_right (blk_sv_sub s₀)) (by decide)] + exact ak i hi + refine wp_mov fun s₄ u₄ => wp_addi fun s₅ u₅ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₅.mem, u₄.mem]; exact ak₃ 0 (by decide)) fun s₆ u₆ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₆.mem, u₅.mem, u₄.mem]; exact ak₃ 1 (by decide)) fun s₇ u₇ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₇.rd, u₇.wr, u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem]; exact ak₃ 2 (by decide)) fun s₈ u₈ => wp_movi fun s₉ u₉ => ?_ + have m₉ : s₉.mem = s₃.mem := by rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem] + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + refine WP.block_nil ⟨?_, ?_, ?_, ?_, u₉.gpr, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.gpr] + · rw [u₉.other _ (by decide), u₈.gpr] + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.gpr, u₄.gpr, g₃, eax₂]; rfl + · rw [u₉.other _ (by decide), u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), + u₅.other _ (by decide), u₄.other _ (by decide), esp₃] + · rw [u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd, h.rd] + · rw [u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr, h.wr] + · rw [m₉]; exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [m₉, AesCfb.X86.blocksAt_frame' fz blkZ]; exact h.blocks + · rw [m₉, Proof.Cmac.bytesAt_frame fz ivZ (by decide)]; exact h.ctr + · rw [m₉, hm₃] + exact AesCtr.X86.zero_bytes _ _ (by rw [u₂.gpr]) + +/-! ## The partial last block: the call -/ + +theorem TArgs.call {s₀ s : State} (hp : CPre s₀) (h : TArgs s₀ s) : + CCall s (fW s₀) (fRr s₀) (fIv s₀) (cBk s₀) 1 where + eax := h.eax + ecx := h.ecx + edx := h.edx + ebx := h.ebx + esi := h.esi + esp := by rw [h.esp]; exact hp.espB + rounds := hp.rounds + wc := hp.sch_iv + wd := by rw [hp.cBlk1]; exact hp.sch_sv.sub_right (blk_sv_sub s₀) + cd := by rw [hp.cBlk1]; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + bw := by rw [h.esp]; exact hp.stk_sch + bc := by rw [h.esp]; exact hp.stk_iv + bd := by rw [hp.cBlk1, h.esp]; exact hp.stk_sv.sub_right (blk_sv_sub s₀) + fW := hp.sch_fit + fC := hp.iv_fit + fD := by rw [hp.cBk_toNat]; have := hp.sv_fit; omega + reads := by + rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + writes := by + rw [hp.cBlk1, h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 16, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBlk s₀).base 16 = fCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem tail_call_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : WP isa ctrCall s (TCall s₀) := by + have big := big_of (cW1_cW h.frame) + refine WP.mono (ctr_call (h.call hp)) fun s' c => ?_ + have f := c.frame + rw [hp.cBlk1, h.esp] at f + have out := c.out + rw [hp.cBk_addr, hp.sched_keep big, h.ctr] at out + refine ⟨by rw [c.saved .esp (by simp [calleeSaved]), h.esp], by rw [c.rd, h.rd], by rw [c.wr, h.wr], + h.frame.trans (f.mono fun r hr => ?_), ?_, by rw [c.ctr, h.ctr], + Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero out⟩ + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + · rw [AesCfb.X86.blocksAt_frame' f fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + +/-! ## The partial last block: the bytes XORed -/ + +theorem xorArgs_eq : ctrFinalXorArgs = [.mov .ebx (argOp 5), .alu .add .ebx (.imm 16), .mov .esi (argOp 3), + .mov .ebp (argOp 4), .mov .eax (.reg .ebp), .alu .and .ebp (.imm 15), .alu .sub .eax (.reg .ebp), + .alu .add .esi (.reg .eax)] := rfl + +/-- The tail loop's operands. -/ +structure XArgs (s₀ s : State) : Prop where + call : TCall s₀ s + ebx : s.gpr .ebx = cBk s₀ + esi : s.gpr .esi = fT s₀ + ebp : s.gpr .ebp = BitVec.ofNat 32 (fU s₀) + +theorem xorArgs_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) : + WP isa (.block ctrFinalXorArgs) s (XArgs s₀) := by + have big := big_of (cW1_cW h.frame) + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have ak : ∀ i < 6, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [xorArgs_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (ak 5 (by decide)) fun s₁ u₁ => ?_ + refine wp_addi fun s₁' u₁' => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₁'.other _ (by decide), u₁.other _ (by decide), h.esp]) + (by rw [u₁'.rd, u₁'.wr, u₁.rd, u₁.wr, hrw]; exact hp.arg_in (by decide)) + (by rw [u₁'.mem, u₁.mem]; exact ak 3 (by decide)) fun s₂ u₂ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₂.other _ (by decide), u₁'.other _ (by decide), u₁.other _ (by decide), h.esp]) + (by rw [u₂.rd, u₂.wr, u₁'.rd, u₁'.wr, u₁.rd, u₁.wr, hrw]; exact hp.arg_in (by decide)) + (by rw [u₂.mem, u₁'.mem, u₁.mem]; exact ak 4 (by decide)) fun s₃ u₃ => ?_ + refine wp_mov fun s₄ u₄ => wp_andi fun s₅ u₅ => wp_sub fun s₆ u₆ _ => wp_add fun s₇ u₇ => WP.block_nil ?_ + have e₅ : s₅.gpr .ebp = BitVec.ofNat 32 (fU s₀) := by + rw [u₅.gpr, u₄.other _ (by decide), u₃.gpr, AesCfb.X86.and15] + have m₇ : s₇.mem = s.mem := by rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁'.mem, u₁.mem] + refine ⟨⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩, ?_, ?_, ?_⟩ + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), u₂.other _ (by decide), u₁'.other _ (by decide), u₁.other _ (by decide), h.esp] + · rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁'.rd, u₁.rd, h.rd] + · rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁'.wr, u₁.wr, h.wr] + · rw [m₇]; exact h.frame + · rw [m₇]; exact h.blocks + · rw [m₇]; exact h.ctr + · rw [m₇]; exact h.out + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), u₂.other _ (by decide), u₁'.gpr, u₁.gpr]; rfl + · rw [u₇.gpr, u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), + u₂.gpr, u₆.gpr, u₅.other _ (by decide), u₄.gpr, u₃.gpr, e₅, AesCfb.X86.sub_mod16] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), e₅] + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem ((fTail s₀).base + BitVec.ofNat 64 q) = s₀.mem ((fTail s₀).base + BitVec.ofNat 64 q) ^^^ + (fCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = + Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.esp, h.rd, h.wr, whole_cW h, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem CPre.tail_addr {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).setWidth 64 = (fTail s₀).base := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + exact addr_eq (by omega) + +theorem CPre.toNat_tail {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : XArgs s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.loop (.block Impl.Modes.X86.tailByte) .ne) s (Done s₀) := by + have hU := fU_lt s₀ + have hT := hp.toNat_tail hu + have eT := hp.tail_addr hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_fit + have hVw := hp.sv_fit + have hB := hp.cBk_toNat + have eB := hp.cBk_addr + have eN : fN s₀ = fL s₀ / 16 := rfl + have eU : fU s₀ = fL s₀ % 16 := rfl + have hc := h.call + have xp : Modes.X86.XPre s (cBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fitK := by omega + fitR := by rw [hT]; omega + disj := by + rw [eT, eB] + exact ((((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega)))).symm + rdK := fun q hq => by + rw [hc.rd, hc.wr, hp.rd, hp.wr, eB] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [hc.wr, hp.wr, eT] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show (fTail s₀).base + BitVec.ofNat 64 q = (fD s₀).setWidth 64 + BitVec.ofNat 64 (16 * fN s₀ + q) from + Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : Modes.X86.XInv s (cBk s₀) (fT s₀) (fU s₀) 0 s := { + ebx := by rw [h.ebx]; exact (BitVec.add_zero _).symm + esi := by rw [h.esi]; exact (BitVec.add_zero _).symm + ebp := by rw [h.ebp, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + syms := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Modes.X86.tailLoop_wp xp x0) fun s' d => ?_ + have fT' : Frame [fTail s₀] s.mem s'.mem := by have := d.frame; rw [eT] at this; exact this + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (sv16_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + refine ⟨by rw [d.gpr .esp (by decide) (by decide) (by decide) (by decide) (by decide), hc.esp], + by rw [d.rd, hc.rd], by rw [d.wr, hc.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW hc.frame).trans (fT'.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [AesCfb.X86.blocksAt_frame' fT' fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact hc.blocks + · have := d.data q hq + rw [eT, eB] at this + rw [this, hc.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + MdStream.X86.bytesAt_getD hc.out (show q < 16 by omega)] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame fT' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_data.sub_right (tail_sub s₀)) + (by decide), hc.ctr, ← Proof.AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole s₀ s) (hz : s.zf = some (decide (fU s₀ = 0))) : + WP isa (.ite .e (.block []) ctrFinalTail) s (Done s₀) := by + have ev : isa.eval .e s = some (decide (fU s₀ = 0)) := by + show VG.X86.eval .e s = _; rw [VG.Proof.MdStream.X86.eval_e, hz] + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => + WP.seq (WP.mono (xorArgs_wp hp h₂) fun _ h₃ => xor_wp hp h₃ hu))) + +/-! ## Restoring the registers -/ + +theorem restore_eq : ctrFinalRestore = .mov .eax (argOp 5) :: (Spill.restoreCode .eax finalSaved ++ []) := rfl + +theorem end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block ctrFinalRestore) s fun s' => abiPreserved s₀ s' ∧ s'.mem = s.mem := by + have big := big_of h.frame + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have hs : Spill.Saved s.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₀.gpr finalSaved := + (Spill.saveMem_saved_ofNat s₀.mem _ s₀.gpr AesCfb.X86.finalSaved_fits (by decide)).of_frame h.frame + (fun p hp' => Offset.contains_base _ (AesCfb.X86.finalSaved_fits.1 p hp') + (by have := AesCfb.X86.finalSaved_fits.1 p hp'; omega)) + fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_sv.sub_right (sv16_sub s₀)).symm + · exact (hp.data_sv.sub_right (sv16_sub s₀)).symm + · exact sv_blk s₀ + · exact (hp.stk_sv.sub_right (sv16_sub s₀)).symm + rw [restore_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (hp.arg_keep big (by decide)) + fun s₁ u₁ => ?_ + refine Spill.restore_ofNat_ok finalSaved AesCfb.X86.finalSaved_fits + (by rw [u₁.gpr]; have h32 : (arg s₀ 5).toNat + 32 ≤ 2 ^ 32 := hp.sv_fit; omega) AesCfb.X86.finalSaved_ne_eax + (fun p hp' => ?_) (by rw [u₁.gpr, u₁.mem]; exact hs) fun s₂ r₂ => WP.block_nil ?_ + · have := AesCfb.X86.finalSaved_fits.1 p hp' + rw [u₁.gpr, u₁.rd, u₁.wr, hrw, hp.rd, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + refine ⟨⟨r₂.abi (by decide) (by decide) (by rw [u₁.other _ (by decide), h.esp]), ?_⟩, by rw [r₂.mem, u₁.mem]⟩ + rw [r₂.mem, u₁.mem]; exact hp.ret_keep big + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : CPre s₀) : + WP isa ctrFinal s₀ fun s' => abiPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (test_wp hp h₂) fun s₃ ⟨h₃, z₃⟩ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₃ z₃) fun s₄ h₄ => ?_) + exact WP.mono (end_wp hp h₄) fun _ ⟨g, m⟩ => ⟨g, s₄, h₄, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86.post s₀ s' := by + show Spec.Ctr.CryptFinal (fCiph s₀) s₀.mem s'.mem ((fIv s₀).setWidth 64) ((fD s₀).setWidth 64) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalX86.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalX86.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (CPre.of hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +/-- What every state between the blocks keeps: the stack pointer, the +writable regions and the stack arguments. -/ +structure Pt (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + wr : s.wr = s₀.wr + args : ∀ i < 6, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i + +theorem CPre.argsOut {s₀ : State} (hp : CPre s₀) {s : State} (h : Pt s₀ s) : ArgsOut 6 s := by + have hs := hp.esp_fit + refine ⟨by rw [h.esp]; omega, ?_⟩ + rw [h.wr, hp.wr, h.esp] + simp only [List.mem_cons, List.not_mem_nil, or_false] + rintro r (rfl | rfl | rfl) + · exact Taint.frame_disjoint (n := 24) (by omega) hp.ret_iv hp.iv_args.symm + · exact Taint.frame_disjoint (n := 24) (by omega) hp.ret_data hp.data_args.symm + · exact Taint.frame_disjoint (n := 24) (by omega) hp.ret_sv hp.sv_args.symm + +/-- Two runs agree on `esp`, the stack arguments and the registers `rs`. -/ +theorem Pt.agree {s₀ s₀' : State} (hq : ctrFinalX86.pub s₀ s₀') (hp : CPre s₀) (hp' : CPre s₀') + {rs : List Reg} {s₁ s₂ : State} (h₁ : Pt s₀ s₁) (h₂ : Pt s₀' s₂) (hr : ∀ r ∈ rs, s₁.gpr r = s₂.gpr r) : + VG.X86.Taint.Agree (argTaint rs (4 + 4 * 6)) s₁ s₂ := + agree_argTaint hr (by rw [h₁.esp, h₂.esp, fE, fE, hq.1]) (hp.argsOut h₁) (hp'.argsOut h₂) + fun i hi => by + rw [AesCfb.X86.arg_cur h₁.esp (h₁.args i hi), AesCfb.X86.arg_cur h₂.esp (h₂.args i hi), hq.2 i hi] + +theorem whole_pt {s₀ s : State} (hp : CPre s₀) (h : Whole s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (whole_cW h)) hi⟩ + +theorem TArgs.pt {s₀ s : State} (hp : CPre s₀) (h : TArgs s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (cW1_cW h.frame)) hi⟩ + +theorem TCall.pt {s₀ s : State} (hp : CPre s₀) (h : TCall s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (cW1_cW h.frame)) hi⟩ + +theorem Done.pt {s₀ s : State} (hp : CPre s₀) (h : Done s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of h.frame) hi⟩ + +theorem setup_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 6)) (.block (ctrFinalSave ++ ctrFinalArgs)) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 6)) (.block tailTest) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 6)) (.block ctrFinalTailArgs) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 6)) + (.seq (.block ctrFinalXorArgs) (.loop (.block Impl.Modes.X86.tailByte) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 6)) (.block ctrFinalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalX86.pre s₀) (h0' : ctrFinalX86.pre s₀') + (hq : ctrFinalX86.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + have qE : fE s₀ = fE s₀' := hq.1 + have qA : ∀ i < 6, arg s₀ i = arg s₀' i := hq.2 + have qW : fW s₀ = fW s₀' := qA 0 (by decide) + have qR : fRr s₀ = fRr s₀' := qA 1 (by decide) + have qIv : fIv s₀ = fIv s₀' := qA 2 (by decide) + have qL : fL s₀ = fL s₀' := by simp only [fL, qA 4 (by decide)] + have qD : fD s₀ = fD s₀' := qA 3 (by decide) + have qV : fV s₀ = fV s₀' := qA 5 (by decide) + have qU : fU s₀ = fU s₀' := by simp only [fU, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, qL] + have qB : cBk s₀ = cBk s₀' := by simp only [cBk, qV] + have pt₀ : ∀ {t : State}, Pt t t := ⟨rfl, rfl, fun _ _ => rfl⟩ + -- The registers saved and the arguments of the first call. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := ((RelCT.taint (A := taint) (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + exact Pt.agree (rs := []) hq hp hp' pt₀ pt₀ fun r hr => by simp at hr) t₁).wp + (F₁ := Setup s₀) (F₂ := Setup s₀') + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + -- The whole blocks. + have c₂ := ctr_rel (P := fun a b => Setup s₀ a ∧ Setup s₀' b) (E := fE s₀) fun a b ⟨ha, hb⟩ => by + have cb := hb.call hp' + rw [← qW, ← qR, ← qIv, ← qD, ← qN] at cb + exact ⟨ha.call hp, cb, ha.esp, hb.esp.trans qE.symm⟩ + have r₂ : RelCT isa (fun a b => Setup s₀ a ∧ Setup s₀' b) ctrCall (fun a b => Whole s₀ a ∧ Whole s₀' b) := + (RelCT.wp (c := ctrCall) (F₁ := Whole s₀) (F₂ := Whole s₀') c₂ + fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + -- The test. + obtain ⟨_, t₃⟩ := test_taint + have r₃ := ((RelCT.taint (A := taint) (P := fun a b => Whole s₀ a ∧ Whole s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (whole_pt hp h.1) (whole_pt hp' h.2) fun r hr => by simp at hr) + t₃).wp + (F₁ := fun (s : State) => Whole s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => Whole s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) + fun a b h => ⟨test_wp hp h.1, test_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + -- The partial last block. + obtain ⟨_, t₄⟩ := tailArgs_taint + obtain ⟨_, t₅⟩ := xor_taint + have tail (hu : fU s₀ ≠ 0) : + RelCT isa (fun a b => Whole s₀ a ∧ Whole s₀' b) ctrFinalTail fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₄ := ((RelCT.taint (A := taint) (P := fun a b => Whole s₀ a ∧ Whole s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (whole_pt hp h.1) (whole_pt hp' h.2) fun r hr => by simp at hr) + t₄).wp + (F₁ := TArgs s₀) (F₂ := TArgs s₀') + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + have c₅ := ctr_rel (P := fun a b => TArgs s₀ a ∧ TArgs s₀' b) (E := fE s₀) fun a b ⟨ha, hb⟩ => by + have cb := hb.call hp' + rw [← qW, ← qR, ← qIv, ← qB] at cb + exact ⟨ha.call hp, cb, ha.esp, hb.esp.trans qE.symm⟩ + have a₅ : RelCT isa (fun a b => TArgs s₀ a ∧ TArgs s₀' b) ctrCall (fun a b => TCall s₀ a ∧ TCall s₀' b) := + (RelCT.wp (c := ctrCall) (F₁ := TCall s₀) (F₂ := TCall s₀') c₅ + fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + have a₆ := ((RelCT.taint (A := taint) (P := fun a b => TCall s₀ a ∧ TCall s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₅).wp + (F₁ := Done s₀) (F₂ := Done s₀') + fun a b h => ⟨WP.seq (WP.mono (xorArgs_wp hp h.1) fun _ h₃ => xor_wp hp h₃ hu), + WP.seq (WP.mono (xorArgs_wp hp' h.2) fun _ h₃ => xor_wp hp' h₃ hu')⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + exact a₄.seq (a₅.seq a₆) + have r₄ : RelCT isa (fun a b => (Whole s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (Whole s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) + (.ite .e (.block []) ctrFinalTail) (fun a b => Done s₀ a ∧ Done s₀' b) := by + refine RelCT.ite (fun a b h => ?_) ?_ ?_ + · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + exact ⟨done_of_zero h.1.1.1 h0, done_of_zero h.1.2.1 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + -- The registers restored. + obtain ⟨_, t₆⟩ := restore_taint + have r₅ := RelCT.taint (A := taint) (P := fun a b => Done s₀ a ∧ Done s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₆ + exact r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅))) + +theorem final_ct : ConstantTime isa ctrFinalX86.pre ctrFinalX86.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## The code's properties -/ + +theorem ctrFinal_noSp : ctrFinal.allInstrs (fun i => !Taint.clobbers i .esp) = true := by + simp only [ctrFinal, ctrCall, ctrFinalTail, Code.allInstrs, AesCfb.X86.all_of_noSp ctr_nosp] + decide + +theorem ctrFinal_stack : stackUse ctrFinal ≤ 2796 := by + simp only [ctrFinal, ctrCall, ctrFinalTail, stackUse, ctr_stack] + decide + +theorem ctrFinal_verified : Verified X86.target ctrFinal finalScratchContract := + verified_wide final_correct final_ct + +/-! ## With `save` on the stack + +The final function has five argument slots, so `save` is its sixth argument: +it runs its code in a frame of 60 bytes (`withStackScratchWiped 60 5 8`): the +word standing for the return address, a copy of the five arguments, `save`'s +address, and `save`'s 32 bytes (the registers, then the block that held the +last output block), which it zeroes before returning. The code's calls use +2796 bytes below it, so 2856 in all. -/ + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + Spec.Aes.bytesAt m₂ p k = Spec.Aes.bytesAt m₁ p k := by + simp only [Spec.Aes.bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +/-- `ctrFinalPre` reads no memory. -/ +theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₁ → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₂ := by + intro vs m₁ m₂ hlen _ h + match vs, hlen with + | [_, _, _, _, _], _ => exact h + +/-- `ctrFinalPostSk` reads the memory on entry only within the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₁ m' r → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, rounds, ctr, data, len], _ => + simp only [Spec.Camellia.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hs := Proof.Camellia.agree_of hb.1 + have hc := Proof.Camellia.agree_of hb.2.1 + have hd := Proof.Camellia.agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Camellia.ctrFinalPostSk pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Camellia.ctrFinalPostSk pb) _ m₂ m' r + dsimp only [Curry.apply, Proof.Camellia.ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + intro hR + rw [Proof.Camellia.subkeysAt_congr (by rcases hR with h | h <;> rw [h] <;> decide) fun i hi => hs i hi, + bytesAt_congr' hc, bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega)] + exact h hR + +theorem frameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk X86.abi 2856).pre s := by + implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, X86.abi, + X86.argSlots, X86.argVal, X86.argBytes] [Fb.frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using Fb.frameSat + +theorem ctrFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 60 5 8 ctrFinal) + (Spec.Camellia.ctrFinalContract X86.abi 2856) := + Proof.Camellia.ctrFinal_of_sk <| + X86.Verified.stackScratchWiped (sig := Spec.Camellia.ctrFinalSig) (nm := "save") (e := .u64) (n := 4) + (pre := Spec.Camellia.ctrFinalPre X86.abi.ptrBits) (post := Proof.Camellia.ctrFinalPostSk X86.abi.ptrBits) + (wa := true) (stack := 2796) (bytes := 60) (words := 8) ctrFinal_verified (by decide) ctrFinal_noSp + ctrFinal_stack (by decide) (ctrFinalPre_local _) (ctrFinalPost_local _) + (Proof.Camellia.ctrFinalPostOut_local _) frameSat_pre + +theorem ctrFinal_framed_spSafe : + (Impl.StackScratch.X86.withStackScratchWiped 60 5 8 ctrFinal).all (fun i => !isa.writesSp i) = true := + Code.all_of_allInstrs (by lit_decide) + +end VG.Proof.Camellia.X86.CtrFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean new file mode 100644 index 00000000000..1569df2031d --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean @@ -0,0 +1,1392 @@ +module + +public import VerifiedGarbage.Impl.Sm4.X86.CtrFinal +public import VerifiedGarbage.Proof.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Sm4.Scratch +public import VerifiedGarbage.Proof.Sm4.X86.CtrVerified +public import VerifiedGarbage.Proof.AesCtr.X86.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.X86.Spill +public import VerifiedGarbage.Proof.Framework.X86.CallWith +public import VerifiedGarbage.Proof.Framework.X86.ArgTaint +import VerifiedGarbage.Proof.Sm4.X86.CtrLit +import VerifiedGarbage.Proof.Sm4.CtrCipher +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.Framework.Mem +import VerifiedGarbage.Proof.Framework.X86.RegUpd +import VerifiedGarbage.Proof.CmacAes.X86.UpdateLoop +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.MdStream.X86.Common +import VerifiedGarbage.Proof.Modes.X86.SeqFinal +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.X86.RelCT +meta import VerifiedGarbage.Impl.Sm4.X86.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.Scratch +meta import VerifiedGarbage.Proof.Sm4.X86.CtrVerified +meta import VerifiedGarbage.Proof.AesCtr.X86.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.X86.Spill +meta import VerifiedGarbage.Proof.Framework.X86.CallWith +meta import VerifiedGarbage.Proof.Framework.X86.ArgTaint +meta import VerifiedGarbage.Proof.Sm4.X86.CtrLit +meta import VerifiedGarbage.Proof.Sm4.CtrCipher +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.X86.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.Framework.Mem +meta import VerifiedGarbage.Proof.Framework.X86.RegUpd +meta import VerifiedGarbage.Proof.CmacAes.X86.UpdateLoop +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.MdStream.X86.Common +meta import VerifiedGarbage.Proof.Modes.X86.SeqFinal +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.X86.RelCT + +/-! +# SM4-CTR of a message's last piece on x86 (32-bit) + +`ctrFinal_framed`: `vg_sm4_ctr_final` (`Impl/Sm4/X86/CtrFinal.lean`) meets +`Spec.Sm4.ctrFinalContract`. + +The code is proven against `ctrFinalX86`, with a fifth stack argument `save` +of 32 bytes, for its caller's registers and a block of its own, its +arguments read only (`verified_wide`: the shared contract with `save`, +`finalScratchContract`, by `wide_implies`, from `wideX86`, which has them +writable), as a caller of `vg_sm4_ctr` (framed by its own working space on +the stack, `ctrFramed`), through its contract, `Spec.Sm4.ctrContract` +(`CCall.callPre`, `calleeK_post`, `calleeK_pub`, from `Sig.contract`'s form +for arguments on the stack). It is AES-CTR's final function's proof +(`Proof/AesCtr/X86/Final.lean`) with SM4's arguments: + +* `setup_wp`, `whole_wp`: the registers saved, and the call on the + `n = len / 16` whole blocks (`ctr_call`, `Whole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.X86.tailLoop_wp`, `xor_wp`); what is left before + the registers are restored is `Done`; +* `end_wp`: the registers restored from `save`; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Every argument is reloaded from the stack, which nothing writes (`Pt`). +Constant time (`final_rel`): the blocks by the taint analysis from the +stack arguments (`argTaint`), the calls by the callee's constant time +(`RelCT.callWith`), whose public arguments, the pointers and the number of +blocks, agree in both runs. `ctrFinal_framed` runs the code with `save` in a +frame of 56 bytes (`Verified.stackScratchWiped`), zeroed on return, the +block included; with the 1536 bytes its calls use below it (the callee's +four arguments, its return address and its 1516 bytes), 1592 in all. +-/ + +@[expose] public section + +namespace VG.Proof.Sm4.X86.CtrFinal + +open VG VG.X86 +open VG.Spec.Aes (bytesAt) + +/-- The code's contract, with the arguments on the stack `(schedule, ctr, +data, len, save)`, `save` of 32 bytes: the data and the counter block as +`Spec.Ctr.CryptFinal` says, by SM4 with the schedule at `schedule`. The code +only reads its arguments (`wideX86` has them writable, as the signature's +contract does). -/ +def ctrFinalX86 : Contract isa where + pre s := + let sched : Region := ⟨(arg s 0).setWidth 64, 128⟩ + let ctr : Region := ⟨(arg s 1).setWidth 64, 16⟩ + let data : Region := ⟨(arg s 2).setWidth 64, (arg s 3).toNat⟩ + let sv : Region := ⟨(arg s 4).setWidth 64, 32⟩ + let args : Region := ⟨argAddr s 0, 20⟩ + let ret : Region := ⟨(s.gpr .esp).setWidth 64, 4⟩ + let stack : Region := ⟨(s.gpr .esp).setWidth 64 - BitVec.ofNat 64 1536, 1536⟩ + s.rd = [sched, args] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ + ctr.Disjoint data ∧ ctr.Disjoint sv ∧ ctr.Disjoint args ∧ + data.Disjoint sv ∧ data.Disjoint args ∧ sv.Disjoint args ∧ + ret.Disjoint ctr ∧ ret.Disjoint data ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (arg s 0).toNat + 128 ≤ 2 ^ 32 ∧ (arg s 1).toNat + 16 ≤ 2 ^ 32 ∧ + (arg s 2).toNat + (arg s 3).toNat ≤ 2 ^ 32 ∧ (arg s 4).toNat + 32 ≤ 2 ^ 32 ∧ + 1536 ≤ (s.gpr .esp).toNat ∧ (s.gpr .esp).toNat + 24 ≤ 2 ^ 32 + post s s' := + Spec.Ctr.CryptFinal (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem ((arg s 0).setWidth 64))) + s.mem s'.mem ((arg s 1).setWidth 64) ((arg s 2).setWidth 64) (arg s 3).toNat + pub s₁ s₂ := s₁.gpr .esp = s₂.gpr .esp ∧ ∀ i < 5, arg s₁ i = arg s₂ i + +/-- `ctrFinalX86` with the argument slots writable, as the signature's +contract has them. -/ +def wideX86 : Contract isa := + { ctrFinalX86 with + pre := fun s => + let sched : Region := ⟨(arg s 0).setWidth 64, 128⟩ + let ctr : Region := ⟨(arg s 1).setWidth 64, 16⟩ + let data : Region := ⟨(arg s 2).setWidth 64, (arg s 3).toNat⟩ + let sv : Region := ⟨(arg s 4).setWidth 64, 32⟩ + let args : Region := ⟨argAddr s 0, 20⟩ + let ret : Region := ⟨(s.gpr .esp).setWidth 64, 4⟩ + let stack : Region := ⟨(s.gpr .esp).setWidth 64 - BitVec.ofNat 64 1536, 1536⟩ + s.rd = [sched] ∧ s.wr = [ctr, data, sv, args] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ + ctr.Disjoint data ∧ ctr.Disjoint sv ∧ ctr.Disjoint args ∧ + data.Disjoint sv ∧ data.Disjoint args ∧ sv.Disjoint args ∧ + ret.Disjoint ctr ∧ ret.Disjoint data ∧ ret.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (arg s 0).toNat + 128 ≤ 2 ^ 32 ∧ (arg s 1).toNat + 16 ≤ 2 ^ 32 ∧ + (arg s 2).toNat + (arg s 3).toNat ≤ 2 ^ 32 ∧ (arg s 4).toNat + 32 ≤ 2 ^ 32 ∧ + 1536 ≤ (s.gpr .esp).toNat ∧ (s.gpr .esp).toNat + 24 ≤ 2 ^ 32 } + +/-- The contract the frame needs: the shared one, with `save`, 32 bytes, as +a fifth argument, and 1536 bytes of stack (the callee's four arguments, its +return address and its own 1516 bytes). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract X86.abi Spec.Sm4.ctrFinalSig "save" .u64 4 (Curry.const (fun _ => True) _) + (Proof.Sm4.ctrFinalPost X86.abi.ptrBits) true 1536 + +/-- A state satisfying the precondition: the schedule at `0x1000`, the +counter block at `0x2000`, no data at `0x3000` and `save` at `0x4000`, as +stack arguments at `0x8004`. -/ +def finalSat : State where + gpr r := match r with | .esp => 0x8000 | _ => 0 + cf := none + zf := none + sf := none + of := none + mem a := if a = 0x8005 then 0x10 else if a = 0x8009 then 0x20 else if a = 0x800d then 0x30 + else if a = 0x8015 then 0x40 else 0 + rd := [⟨0x1000, 128⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 32⟩, ⟨0x8004, 20⟩] + +theorem wide_implies : wideX86.Implies finalScratchContract := by + have a0 : arg finalSat 0 = 0x1000 := by decide + have a1 : arg finalSat 1 = 0x2000 := by decide + have a2 : arg finalSat 2 = 0x3000 := by decide + have a3 : arg finalSat 3 = 0 := by decide + have a4 : arg finalSat 4 = 0x4000 := by decide + have e : argAddr finalSat 0 = 0x8004 := by decide + have esp : finalSat.gpr .esp = 0x8000 := rfl + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, X86.abi, X86.argSlots, X86.argVal, X86.argBytes, wideX86, + ctrFinalX86] [a0, a1, a2, a3, a4, e, esp] using finalSat + +/-- The regions `ctrFinalX86` gives: the arguments read only. -/ +def narrowRd (s : State) : List Region := [⟨(arg s 0).setWidth 64, 128⟩, ⟨argAddr s 0, 20⟩] +def narrowWr (s : State) : List Region := + [⟨(arg s 1).setWidth 64, 16⟩, ⟨(arg s 2).setWidth 64, (arg s 3).toNat⟩, ⟨(arg s 4).setWidth 64, 32⟩] + +theorem narrow_pre (s : State) (h : wideX86.pre s) : ctrFinalX86.pre (s.withRegions (narrowRd s) (narrowWr s)) := by + obtain ⟨_, _, h⟩ := h + simp only [ctrFinalX86, narrowRd, narrowWr, arg_withRegions, argAddr_withRegions, State.withRegions_gpr, + State.withRegions_rd, State.withRegions_wr] + exact ⟨trivial, trivial, h⟩ + +/-- `ctrFinalX86` gives `wideX86`. -/ +theorem verified_wide {c : Prog isa} (h : ∀ s, ctrFinalX86.pre s → ∃ t s', Exec isa c s t s' ∧ abiPreserved s s' ∧ + ctrFinalX86.post s s') + (hct : ConstantTime isa ctrFinalX86.pre ctrFinalX86.pub c) : Verified X86.target c finalScratchContract := by + have hsat := wide_implies.sat_left + have narrowSat : ∃ s, ctrFinalX86.pre s := by + obtain ⟨s, hs⟩ := hsat + exact ⟨_, narrow_pre s hs⟩ + apply Verified.of_implies _ wide_implies + refine Verified.narrowTo (k := ctrFinalX86) (Verified.of_correct h hct (.refl narrowSat)) + narrowRd narrowWr narrow_pre ?_ ?_ (fun _ _ _ h => h) (fun _ _ _ _ h => h) hsat + · intro s h + obtain ⟨rd, wr, _⟩ := h + rw [rd, wr] + intro a n ⟨r, hr, hc⟩ + refine ⟨r, ?_, hc⟩ + simp only [narrowRd, narrowWr, List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, + or_false] at hr ⊢ + rcases hr with h | h | h | h | h <;> simp_all only [or_true, true_or] + · intro s h + obtain ⟨_, wr, _⟩ := h + rw [wr] + intro a n ⟨r, hr, hc⟩ + refine ⟨r, ?_, hc⟩ + simp only [narrowWr, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp_all only [or_true, true_or] + +/-! ## The callee -/ + +open VG.Impl.Sm4.X86 (ctrFramed ctrCall ctrFinalSave ctrFinalArgs ctrFinalTest ctrFinalTailArgs ctrFinalXorArgs + ctrFinalRestore ctrFinalTail ctrFinal) + +/-- The contract `vg_sm4_ctr` is called by. -/ +abbrev calleeK : Contract isa := Spec.Sm4.ctrContract X86.abi 1516 + +abbrev ctrRegs : List Reg := [.esi, .ebx, .edx, .eax] + +theorem ctrRegs_esp : Reg.esp ∉ ctrRegs := by decide + +theorem ctr_stack : stackUse ctrFramed = 1516 := by + have h : stackUse Impl.Sm4.X86.ctr = 20 := by lit_decide + simp only [ctrFramed, Impl.StackScratch.X86.withStackScratchWiped, Impl.StackScratch.X86.withStackScratch, + stackUse, h, X86.frameBytes] + decide + +theorem ctr_nosp : NoSp ctrFramed := NoSp.of_all (by unfold ctrFramed; lit_decide) + +theorem sw32 (x : BitVec 32) : (x.setWidth 64).setWidth 32 = x := by + apply BitVec.eq_of_toNat_eq; simp + +theorem toNat_sw (x : BitVec 32) : (x.setWidth 64).toNat = x.toNat := by + simp only [BitVec.toNat_setWidth]; exact Nat.mod_eq_of_lt (by have := x.isLt; omega) + +/-- The bytes `[d, d + n)` of the `b` bytes below `E`, from their bottom. -/ +theorem below_off {E : BitVec 32} {b d k : Nat} (hb : b ≤ E.toNat) (hk : k ≤ b) (hd : d = b - k) : + ((E - BitVec.ofNat 32 k).setWidth 64) = (below E b).base + BitVec.ofNat 64 d := by + apply BitVec.eq_of_toNat_eq + have := E.isLt + simp only [BitVec.toNat_setWidth, BitVec.toNat_add, BitVec.toNat_ofNat] + rw [sub_toNat (by omega), sub_toNat hb] + subst hd + rw [Nat.mod_eq_of_lt (a := E.toNat - k) (by omega), Nat.mod_eq_of_lt (a := E.toNat - b) (by omega), + Nat.mod_eq_of_lt (a := b - k) (by omega), Nat.mod_eq_of_lt (by omega)] + omega + +theorem one_disj {k : Region} {p : Addr} {n : Nat} (h : k.Disjoint ⟨p, n⟩) : + ∀ r ∈ [k], (⟨p, n⟩ : Region).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact h.symm + +/-- What a call of `vg_sm4_ctr` needs: the schedule at `W`, the counter +block at `C` and `n` blocks at `D`, and 1536 bytes of stack for the +arguments, the return address and the callee's frames. -/ +structure CCall (s : State) (W C D : BitVec 32) (n : Nat) : Prop where + eax : s.gpr .eax = W + edx : s.gpr .edx = C + ebx : s.gpr .ebx = D + esi : s.gpr .esi = BitVec.ofNat 32 n + esp : 1536 ≤ (s.gpr .esp).toNat + wc : (⟨W.setWidth 64, 128⟩ : Region).Disjoint ⟨C.setWidth 64, 16⟩ + wd : (⟨W.setWidth 64, 128⟩ : Region).Disjoint ⟨D.setWidth 64, 16 * n⟩ + cd : (⟨C.setWidth 64, 16⟩ : Region).Disjoint ⟨D.setWidth 64, 16 * n⟩ + bw : (below (s.gpr .esp) 1536).Disjoint ⟨W.setWidth 64, 128⟩ + bc : (below (s.gpr .esp) 1536).Disjoint ⟨C.setWidth 64, 16⟩ + bd : (below (s.gpr .esp) 1536).Disjoint ⟨D.setWidth 64, 16 * n⟩ + fW : W.toNat + 128 ≤ 2 ^ 32 + fC : C.toNat + 16 ≤ 2 ^ 32 + fD : D.toNat + 16 * n ≤ 2 ^ 32 + reads : Covers [⟨W.setWidth 64, 128⟩] (s.rd ++ s.wr) + writes : Covers [⟨C.setWidth 64, 16⟩, ⟨D.setWidth 64, 16 * n⟩] s.wr + +/-- What a call of `vg_sm4_ctr` leaves. -/ +structure CPost (s : State) (W C D : BitVec 32) (n : Nat) (s' : State) : Prop where + rd : s'.rd = s.rd + wr : s'.wr = s.wr + saved : ∀ r ∈ calleeSaved, s'.gpr r = s.gpr r + frame : Frame [⟨C.setWidth 64, 16⟩, ⟨D.setWidth 64, 16 * n⟩, below (s.gpr .esp) 1536] s.mem s'.mem + out : Spec.Cbc.blocksAt s'.mem (D.setWidth 64) n = + Spec.Ctr.crypt (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (W.setWidth 64))) + (bytesAt s.mem (C.setWidth 64) 16) (Spec.Cbc.blocksAt s.mem (D.setWidth 64) n) + ctr : bytesAt s'.mem (C.setWidth 64) 16 = Spec.Ctr.next (bytesAt s.mem (C.setWidth 64) 16) n + +abbrev calleeRd (W : BitVec 32) : List Region := [⟨W.setWidth 64, 128⟩] +abbrev calleeWr (E C D : BitVec 32) (n : Nat) : List Region := + [⟨C.setWidth 64, 16⟩, ⟨D.setWidth 64, n * 16⟩, below E 16] + +namespace CCall +variable {s : State} {W C D : BitVec 32} {n : Nat} (h : CCall s W C D n) +include h + +theorem fit : 4 * ctrRegs.length + 4 ≤ (s.gpr .esp).toNat := by + have := h.esp; simp only [List.length_cons, List.length_nil]; omega + +theorem n_lt : n < 2 ^ 32 := by have := h.fD; omega + +theorem args : arg (pushed ctrRegs s).callEntry 0 = W ∧ arg (pushed ctrRegs s).callEntry 1 = C ∧ + arg (pushed ctrRegs s).callEntry 2 = D ∧ arg (pushed ctrRegs s).callEntry 3 = BitVec.ofNat 32 n := by + refine ⟨?_, ?_, ?_, ?_⟩ <;> + rw [callEntry_arg h.fit ctrRegs_esp (by decide)] <;> simp [h.eax, h.edx, h.ebx, h.esi] + +theorem callPre : CallPre calleeK ctrRegs (calleeRd W) (calleeWr (s.gpr .esp) C D n) s := by + obtain ⟨a0, a1, a2, a3⟩ := h.args + have hn : (BitVec.ofNat 32 n).toNat = n := by rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt h.n_lt] + have hE := h.esp + have := (s.gpr .esp).isLt + have eA : argAddr (pushed ctrRegs s).callEntry 0 = (below (s.gpr .esp) 1536).base + BitVec.ofNat 64 1520 := by + rw [callEntry_argAddr0]; exact below_off (by omega) (by decide) rfl + have eB : (below (s.gpr .esp) 16) = ⟨(below (s.gpr .esp) 1536).base + BitVec.ofNat 64 1520, 16⟩ := + congrArg (fun x => (⟨x, 16⟩ : Region)) (below_off (by omega) (by decide) rfl) + have e5 : s.gpr .esp - 4 - 4 - 4 - 4 - 4 = s.gpr .esp - BitVec.ofNat 32 20 := by + simp only [BitVec.sub_sub]; rfl + have eR : (s.gpr .esp - BitVec.ofNat 32 20).setWidth 64 = + (below (s.gpr .esp) 1536).base + BitVec.ofNat 64 1516 := + below_off (by omega) (by decide) rfl + have eS : (below (s.gpr .esp) 1536).base + BitVec.ofNat 64 1516 - 1516#64 = (below (s.gpr .esp) 1536).base := + BitVec.add_sub_cancel _ _ + have eN : (s.gpr .esp - BitVec.ofNat 32 20).toNat = (s.gpr .esp).toNat - 20 := sub_toNat (by omega) + let B := (below (s.gpr .esp) 1536).base + try rewrite [show (below (s.gpr .esp) 1536).base = B from rfl] at * + have hb : below (s.gpr .esp) 1536 = ⟨B, 1536⟩ := rfl + have sb {d k : Nat} (hd : d + k ≤ 1536) {r : Region} (hr : (below (s.gpr .esp) 1536).Disjoint r) : + (⟨B + BitVec.ofNat 64 d, k⟩ : Region).Disjoint r := by + rw [hb] at hr; exact hr.sub_left (Offset.sub_base _ hd) + have sb0 {r : Region} (hr : (below (s.gpr .esp) 1536).Disjoint r) : (⟨B, 1516⟩ : Region).Disjoint r := by + rw [hb] at hr; exact hr.sub_left (Region.sub_prefix (by decide)) + have hwd := h.wd + have hcd := h.cd + have hbd := h.bd + have hfD := h.fD + rw [Nat.mul_comm] at hwd hcd hbd hfD + refine ⟨?_, ?_, ?_⟩ + · sig_pre [calleeK, Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, X86.abi, argVal, ↓reduceIte, Nat.reduceEqDiff, + argBytes, Nat.reduceDiv, List.sum_cons, List.sum_nil, Nat.reduceAdd, Nat.reduceMul, sw32, toNat_sw] + simp only [arg_withRegions, argAddr_withRegions, a0, a1, a2, a3, hn, eA, e5, eN, eR, eS] + have r1 : (⟨B + BitVec.ofNat 64 1516, 4⟩ : Region).Disjoint ⟨B + BitVec.ofNat 64 1520, 16⟩ := + Offset.disjoint B (.inl (by decide)) (by omega) (by omega) + have r2 : (⟨B, 1516⟩ : Region).Disjoint ⟨B + BitVec.ofNat 64 1520, 16⟩ := + Offset.base_disjoint B (by decide) (by omega) + exact ⟨by omega, by omega, trivial, by rw [calleeWr, eB], h.wc, hwd, (sb (by decide) h.bw).symm, hcd, + (sb (by decide) h.bc).symm, (sb (by decide) hbd).symm, sb (by decide) h.bw, sb (by decide) h.bc, + sb (by decide) hbd, r1, sb0 h.bw, sb0 h.bc, sb0 hbd, r2, h.fW, h.fC, hfD⟩ + · intro a m ⟨r, hr, hcn⟩ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · obtain ⟨r', hr', hc'⟩ := h.reads a m ⟨_, List.mem_singleton_self _, hcn⟩ + exact InRegions_append_cons.mpr (.inr ⟨r', hr', hc'⟩) + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨_, by simp, hcn⟩ + exact InRegions_append_cons.mpr (.inr ⟨r', List.mem_append_right _ hr', hc'⟩) + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨⟨D.setWidth 64, 16 * n⟩, by simp, by rwa [Nat.mul_comm]⟩ + exact InRegions_append_cons.mpr (.inr ⟨r', List.mem_append_right _ hr', hc'⟩) + · exact InRegions_append_cons.mpr (.inl hcn) + · intro a m ⟨r, hr, hcn⟩ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨_, by simp, hcn⟩ + exact ⟨r', List.mem_cons_of_mem _ hr', hc'⟩ + · obtain ⟨r', hr', hc'⟩ := h.writes a m ⟨⟨D.setWidth 64, 16 * n⟩, by simp, by rwa [Nat.mul_comm]⟩ + exact ⟨r', List.mem_cons_of_mem _ hr', hc'⟩ + · exact ⟨_, List.mem_cons_self .., hcn⟩ + +end CCall + +/-- `vg_sm4_ctr`'s postcondition. -/ +theorem calleeK_post {s s' : State} (h : calleeK.post s s') : + Spec.Cbc.blocksAt s'.mem ((arg s 2).setWidth 64) (arg s 3).toNat = + Spec.Ctr.crypt (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem ((arg s 0).setWidth 64))) + (bytesAt s.mem ((arg s 1).setWidth 64) 16) (Spec.Cbc.blocksAt s.mem ((arg s 2).setWidth 64) (arg s 3).toNat) ∧ + bytesAt s'.mem ((arg s 1).setWidth 64) 16 = Spec.Ctr.next (bytesAt s.mem ((arg s 1).setWidth 64) 16) (arg s 3).toNat := by + sig_post [calleeK, Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, X86.abi, argVal, ↓reduceIte, Nat.reduceEqDiff, argBytes, + Nat.reduceDiv, List.sum_cons, List.sum_nil, Nat.reduceAdd, Nat.reduceMul, sw32, toNat_sw] at h + exact h + +/-- Its public data, from the arguments. -/ +theorem calleeK_pub {s₁ s₂ : State} (h : s₁.gpr .esp = s₂.gpr .esp ∧ ∀ i < 4, arg s₁ i = arg s₂ i) : + calleeK.pub s₁ s₂ := by + obtain ⟨a₁, a₂⟩ := h + sig_pub [calleeK, Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, X86.abi, argVal, ↓reduceIte, Nat.reduceEqDiff, argBytes, + Nat.reduceDiv, List.sum_cons, List.sum_nil, Nat.reduceAdd, Nat.reduceMul, sw32, toNat_sw] + exact ⟨a₁, a₂ 0 (by decide), a₂ 1 (by decide), a₂ 2 (by decide), a₂ 3 (by decide)⟩ + +theorem ctr_call {s : State} {W C D : BitVec 32} {n : Nat} (h : CCall s W C D n) : + WP isa ctrCall s (CPost s W C D n) := by + have hn : (BitVec.ofNat 32 n).toNat = n := by rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt h.n_lt] + unfold ctrCall + refine WP.callWith (rs := ctrRegs) (k := calleeK) (c := ctrFramed) Proof.Sm4.X86.Ctr.ctr_framed.1 ctr_nosp (by simp) ctrRegs_esp + (by rw [ctr_stack]; have := h.esp; simp only [List.length_cons, List.length_nil]; omega) + h.callPre fun s' rd' wr' cs' f' ⟨s₂, m₂, post⟩ => ?_ + obtain ⟨a0, a1, a2, a3⟩ := h.args + rw [ctr_stack] at f' + have fE := callEntry_frame h.fit ctrRegs_esp + rw [show 4 * ctrRegs.length + 4 = 20 from rfl] at fE + have fE' : Frame [below (s.gpr .esp) 1536] s.mem (pushed ctrRegs s).callEntry.mem := + fE.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact ⟨_, List.mem_singleton_self _, VG.X86.below_sub (by decide) h.esp⟩ + obtain ⟨hdata, hctr⟩ := calleeK_post post + simp only [arg_withRegions, State.withRegions_mem, a0, a1, a2, a3, hn, m₂] at hdata hctr + rw [Proof.Cmac.bytesAt_frame fE' (one_disj h.bc) (by decide), AesCfb.X86.blocksAt_frame' fE' (one_disj h.bd), + Proof.Sm4.scheduleAt_frame fE' (one_disj h.bw)] at hdata + rw [Proof.Cmac.bytesAt_frame fE' (one_disj h.bc) (by decide)] at hctr + refine ⟨rd', wr', cs', ?_, hdata, hctr⟩ + refine f'.sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨⟨D.setWidth 64, 16 * n⟩, by simp, by rw [Nat.mul_comm]; exact fun _ h => h⟩ + · exact ⟨below (s.gpr .esp) 1536, by simp, VG.X86.below_sub (by decide) h.esp⟩ + · exact ⟨below (s.gpr .esp) 1536, by simp, VG.X86.below_sub (by decide) h.esp⟩ + +/-- Calls of `vg_sm4_ctr` with the same arguments and stack pointer in both +runs are constant time. -/ +theorem ctr_rel {P : State → State → Prop} {W C D E : BitVec 32} {n : Nat} + (h : ∀ s₁ s₂, P s₁ s₂ → CCall s₁ W C D n ∧ CCall s₂ W C D n ∧ s₁.gpr .esp = E ∧ s₂.gpr .esp = E) : + RelCT isa P ctrCall fun _ _ => True := by + unfold ctrCall + refine RelCT.callWith (rs := ctrRegs) (c := ctrFramed) Proof.Sm4.X86.Ctr.ctr_framed.1 Proof.Sm4.X86.Ctr.ctr_framed.2.1 + (calleeRd W) (calleeWr E C D n) fun s₁ s₂ hP => ?_ + obtain ⟨h₁, h₂, e₁, e₂⟩ := h s₁ s₂ hP + have p₁ := h₁.callPre + have p₂ := h₂.callPre + rw [e₁] at p₁ + rw [e₂] at p₂ + refine ⟨p₁, p₂, e₁.trans e₂.symm, calleeK_pub ⟨?_, fun i hi => ?_⟩⟩ + · simp only [State.withRegions_gpr, callEntry_esp', e₁, e₂] + obtain ⟨a0, a1, a2, a3⟩ := h₁.args + obtain ⟨b0, b1, b2, b3⟩ := h₂.args + simp only [arg_withRegions] + rcases (by omega : i = 0 ∨ i = 1 ∨ i = 2 ∨ i = 3) with rfl | rfl | rfl | rfl + · rw [a0, b0] + · rw [a1, b1] + · rw [a2, b2] + · rw [a3, b3] + +theorem cipher_length (k : Spec.Sm4.Schedule) (b : List Byte) : (Spec.Sm4.cipher k b).length = 16 := by + simp [Spec.Sm4.cipher] + +/-! ## The arguments, by name -/ + +open VG.Impl.CmacAes.X86 (argOp) +open VG.Impl.AesCfb.X86 (finalSaved) +open VG.Impl.AesCtr.X86 (zeroSlots) +open VG.Proof.CmacAes.X86 (wp_arg ofNat_and_self_beq) +open VG.Proof.MdStream.X86 (wp_mov wp_movi wp_andi wp_test wp_shr wp_sub wp_add wp_addi eval_e) + +section +variable (s₀ : State) + +abbrev fE : BitVec 32 := s₀.gpr .esp +abbrev fW : BitVec 32 := arg s₀ 0 +abbrev fIv : BitVec 32 := arg s₀ 1 +abbrev fD : BitVec 32 := arg s₀ 2 +abbrev fL : Nat := (arg s₀ 3).toNat +abbrev fV : BitVec 32 := arg s₀ 4 +/-- The whole blocks, the bytes after them, and where those start. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +abbrev fT : BitVec 32 := fD s₀ + BitVec.ofNat 32 (16 * fN s₀) +abbrev fSch : Region := ⟨(fW s₀).setWidth 64, 128⟩ +abbrev fIvR : Region := ⟨(fIv s₀).setWidth 64, 16⟩ +abbrev fData : Region := ⟨(fD s₀).setWidth 64, fL s₀⟩ +abbrev fBlk : Region := ⟨(fD s₀).setWidth 64, 16 * fN s₀⟩ +abbrev fTail : Region := ⟨(fD s₀).setWidth 64 + BitVec.ofNat 64 (16 * fN s₀), fU s₀⟩ +/-- The registers in `save`; all of `save`; the block after the registers, +as the code computes it and as a region. -/ +abbrev fSv : Region := ⟨(fV s₀).setWidth 64, 16⟩ +abbrev cSv : Region := ⟨(fV s₀).setWidth 64, 32⟩ +abbrev cBk : BitVec 32 := fV s₀ + BitVec.ofNat 32 16 +abbrev cBlk : Region := ⟨(fV s₀).setWidth 64 + BitVec.ofNat 64 16, 16⟩ +abbrev fArgs : Region := ⟨argAddr s₀ 0, 20⟩ +abbrev fRet : Region := ⟨(fE s₀).setWidth 64, 4⟩ +abbrev fStk : Region := below (fE s₀) 1536 +/-- The cipher, the counter block and the whole blocks on entry. -/ +abbrev fCiph : Spec.Cbc.Cipher := Spec.Sm4.cipher (Spec.Sm4.scheduleAt s₀.mem ((fW s₀).setWidth 64)) +abbrev fIv0 : List Byte := bytesAt s₀.mem ((fIv s₀).setWidth 64) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem ((fD s₀).setWidth 64) (fN s₀) + +/-- The memory once the registers are saved. -/ +def svMem : Mem := Spill.saveMem s₀.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₀.gpr finalSaved + +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, cSv s₀, fStk s₀] +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, cBlk s₀, fStk s₀] +abbrev cW : List Region := [fIvR s₀, fData s₀, cBlk s₀, fStk s₀] + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + rd : s₀.rd = [fSch s₀, fArgs s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + iv_args : (fIvR s₀).Disjoint (fArgs s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + data_args : (fData s₀).Disjoint (fArgs s₀) + sv_args : (cSv s₀).Disjoint (fArgs s₀) + ret_iv : (fRet s₀).Disjoint (fIvR s₀) + ret_data : (fRet s₀).Disjoint (fData s₀) + ret_sv : (fRet s₀).Disjoint (cSv s₀) + stk_sch : (fStk s₀).Disjoint (fSch s₀) + stk_iv : (fStk s₀).Disjoint (fIvR s₀) + stk_data : (fStk s₀).Disjoint (fData s₀) + stk_sv : (fStk s₀).Disjoint (cSv s₀) + sch_fit : (fW s₀).toNat + 128 ≤ 2 ^ 32 + iv_fit : (fIv s₀).toNat + 16 ≤ 2 ^ 32 + data_fit : (fD s₀).toNat + fL s₀ ≤ 2 ^ 32 + sv_fit : (fV s₀).toNat + 32 ≤ 2 ^ 32 + espB : 1536 ≤ (fE s₀).toNat + esp_fit : (fE s₀).toNat + 24 ≤ 2 ^ 32 + +theorem stk_eq {s₀ : State} (h : 1536 ≤ (fE s₀).toNat) : + fStk s₀ = ⟨(fE s₀).setWidth 64 - BitVec.ofNat 64 1536, 1536⟩ := by + show (⟨(fE s₀ - BitVec.ofNat 32 1536).setWidth 64, 1536⟩ : Region) = _ + rw [Taint.sub_setWidth h] + +theorem CPre.of {s₀ : State} (h : ctrFinalX86.pre s₀) : CPre s₀ := by + obtain ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, + a23, a24⟩ := h + have e := stk_eq a23 + exact ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, e ▸ a15, e ▸ a16, e ▸ a17, e ▸ a18, + a19, a20, a21, a22, a23, a24⟩ + +/-! ## Addresses and regions -/ + +theorem sv16_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) +theorem sv_blk (s₀ : State) : (fSv s₀).Disjoint (cBlk s₀) := Offset.base_disjoint _ (Nat.le_refl _) (by decide) +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) +theorem fU_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.cBk_addr : (cBk s₀).setWidth 64 = (cBlk s₀).base := addr_eq (by have := hp.sv_fit; omega) + +theorem CPre.cBk_toNat : (cBk s₀).toNat = (fV s₀).toNat + 16 := by + have := hp.sv_fit + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem CPre.cBlk1 : (⟨(cBk s₀).setWidth 64, 16 * 1⟩ : Region) = cBlk s₀ := by rw [hp.cBk_addr] + +theorem CPre.argA {i : Nat} (hi : i < 5) : argAddr s₀ i = argAddr s₀ 0 + BitVec.ofNat 64 (4 * i) := by + have : (s₀.gpr .esp).toNat + 24 ≤ 2 ^ 32 := hp.esp_fit + simp only [argAddr] + rw [show (s₀.gpr .esp + BitVec.ofNat 32 (4 + 4 * i)).setWidth 64 = addr (s₀.gpr .esp) (4 + 4 * i) from rfl, + show (s₀.gpr .esp + BitVec.ofNat 32 (4 + 4 * 0)).setWidth 64 = addr (s₀.gpr .esp) (4 + 4 * 0) from rfl, + addr_eq (by omega), addr_eq (by omega), Offset.add_add] + +theorem CPre.arg_sub {i : Nat} (hi : i < 5) : Region.Sub ⟨argAddr s₀ i, 4⟩ (fArgs s₀) := by + rw [hp.argA hi]; exact Offset.sub_base _ (by omega) + +theorem CPre.arg_in {i : Nat} (hi : i < 5) : InRegions (s₀.rd ++ s₀.wr) (argAddr s₀ i) 4 := by + refine ⟨fArgs s₀, by simp [hp.rd], ?_⟩ + rw [hp.argA hi]; exact Offset.contains_base _ (by omega) (by omega) + +theorem CPre.args_stk : (fArgs s₀).Disjoint (fStk s₀) := by + have : (s₀.gpr .esp).toNat + 24 ≤ 2 ^ 32 := hp.esp_fit + have e : argAddr s₀ 0 = (fE s₀).setWidth 64 + BitVec.ofNat 64 4 := addr_eq (by omega) + rw [stk_eq hp.espB] + show Region.Disjoint ⟨argAddr s₀ 0, 20⟩ _ + rw [e]; exact (Offset.disjoint_below_above _ (by decide)).symm + +theorem CPre.ret_stk : (fRet s₀).Disjoint (fStk s₀) := by + rw [stk_eq hp.espB] + have := Offset.disjoint_below_above ((fE s₀).setWidth 64) (m := 1536) (a := 0) (l := 4) (by decide) + rw [BitVec.add_zero] at this + exact this.symm + +/-- The stack arguments are unchanged where only `cBig` changes. -/ +theorem CPre.arg_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) {i : Nat} (hi : i < 5) : + m.readW (argAddr s₀ i) 32 = arg s₀ i := + hf.readW (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_args.symm.sub_left (hp.arg_sub hi) + · exact hp.data_args.symm.sub_left (hp.arg_sub hi) + · exact hp.sv_args.symm.sub_left (hp.arg_sub hi) + · exact hp.args_stk.sub_left (hp.arg_sub hi)) (by decide) + +/-- The return address is unchanged where only `cBig` changes. -/ +theorem CPre.ret_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + m.readW ((fE s₀).setWidth 64) 32 = s₀.mem.readW ((fE s₀).setWidth 64) 32 := + hf.readW (r := fRet s₀) (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.ret_iv + · exact hp.ret_data + · exact hp.ret_sv + · exact hp.ret_stk) (by decide) + +/-- The schedule is unchanged where only `cBig` changes. -/ +theorem CPre.sched_keep {m : Mem} (hf : Frame (cBig s₀) s₀.mem m) : + Spec.Sm4.scheduleAt m ((fW s₀).setWidth 64) = Spec.Sm4.scheduleAt s₀.mem ((fW s₀).setWidth 64) := + Proof.Sm4.scheduleAt_frame hf fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +theorem CPre.blk_fit : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 32 := by + have := hp.data_fit; have := Nat.mul_div_le (fL s₀) 16; have : fN s₀ = fL s₀ / 16 := rfl; omega + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + exact Offset.base_disjoint _ (Nat.le_refl _) (by omega) + +end + +/-! ## Frames -/ + +/-- The save changes only `save`. -/ +theorem svMem_frame (s₀ : State) : Frame [fSv s₀] s₀.mem (svMem s₀) := + Spill.saveMem_frame List.mem_cons_self _ _ _ _ fun p hp => + have : p.2 + 4 ≤ 16 := (show Spill.Fits 16 finalSaved by decide).1 p hp + Offset.contains_base _ (by omega) (by omega) + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +/-- Everything the function writes, from the save on. -/ +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv16_sub s₀⟩).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.sv_sched : Spec.Sm4.scheduleAt (svMem s₀) ((fW s₀).setWidth 64) = + Spec.Sm4.scheduleAt s₀.mem ((fW s₀).setWidth 64) := + hp.sched_keep (big_of (Frame.refl _ _)) + +theorem CPre.sv_iv : bytesAt (svMem s₀) ((fIv s₀).setWidth 64) 16 = fIv0 s₀ := + Proof.Cmac.bytesAt_frame (svMem_frame s₀) (one_disj (hp.iv_sv.sub_right (sv16_sub s₀)).symm) (by decide) + +theorem CPre.sv_blocks : Spec.Cbc.blocksAt (svMem s₀) ((fD s₀).setWidth 64) (fN s₀) = fBlks s₀ := + AesCfb.X86.blocksAt_frame' (svMem_frame s₀) + (one_disj ((hp.data_sv.sub_left (blk_sub s₀)).sub_right (sv16_sub s₀)).symm) + +end + +/-! ## Saving the registers, and the arguments of the call on the whole blocks -/ + +theorem setup_eq : ctrFinalSave ++ ctrFinalArgs = + .mov .eax (argOp 4) :: (Spill.saveCode .eax finalSaved ++ ctrFinalArgs) := rfl + +theorem args_eq : ctrFinalArgs = [.mov .eax (argOp 0), .mov .edx (argOp 1), .mov .ebx (argOp 2), + .mov .esi (argOp 3), .shift .shr .esi 4] := rfl + +/-- What saving the registers and setting up the arguments leaves. -/ +structure Setup (s₀ s : State) : Prop where + eax : s.gpr .eax = fW s₀ + edx : s.gpr .edx = fIv s₀ + ebx : s.gpr .ebx = fD s₀ + esi : s.gpr .esi = BitVec.ofNat 32 (fN s₀) + esp : s.gpr .esp = fE s₀ + mem : s.mem = svMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : CPre s₀) : + WP isa (.block (ctrFinalSave ++ ctrFinalArgs)) s₀ (Setup s₀) := by + rw [setup_eq] + refine wp_arg (s₀ := s₀) rfl (hp.arg_in (by decide)) rfl fun s₁ u₁ => ?_ + have h₁ : s₁.gpr .eax = fV s₀ := u₁.gpr + refine Spill.save_ofNat_ok finalSaved AesCfb.X86.finalSaved_fits + (by rw [h₁]; have := hp.sv_fit; omega) (fun p hp' => ?_) fun s₂ u₂ => ?_ + · have hb : p.2 + 4 ≤ 16 := AesCfb.X86.finalSaved_fits.1 p hp' + rw [h₁, u₁.wr, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have hm₂ : s₂.mem = svMem s₀ := by + rw [u₂.mem, u₁.mem, h₁, svMem] + exact Spill.saveMem_congr _ _ (fun _ _ => rfl) fun p hp' => + u₁.other _ (AesCfb.X86.finalSaved_ne_eax p hp') + have esp₂ : s₂.gpr .esp = s₀.gpr .esp := by rw [u₂.gpr, u₁.other _ (by decide)] + have rw₂ : s₂.rd ++ s₂.wr = s₀.rd ++ s₀.wr := by rw [u₂.rd, u₂.wr, u₁.rd, u₁.wr] + have big := big_of (s₀ := s₀) (Frame.refl _ (svMem s₀)) + have ak : ∀ i < 5, (svMem s₀).readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [args_eq] + refine wp_arg (s₀ := s₀) esp₂ (by rw [rw₂]; exact hp.arg_in (by decide)) + (by rw [hm₂]; exact ak 0 (by decide)) fun s₃ u₃ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₃.other _ (by decide), esp₂]) + (by rw [u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₃.mem, hm₂]; exact ak 1 (by decide)) fun s₄ u₄ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₄.mem, u₃.mem, hm₂]; exact ak 2 (by decide)) fun s₅ u₅ => ?_ + refine wp_arg (s₀ := s₀) + (by rw [u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), esp₂]) + (by rw [u₅.rd, u₅.wr, u₄.rd, u₄.wr, u₃.rd, u₃.wr, rw₂]; exact hp.arg_in (by decide)) + (by rw [u₅.mem, u₄.mem, u₃.mem, hm₂]; exact ak 3 (by decide)) fun s₆ u₆ => ?_ + refine wp_shr (by decide) fun s₇ u₇ => ?_ + refine WP.block_nil ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), u₃.gpr] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.gpr] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr] + · rw [u₇.gpr, u₆.gpr, AesCfb.X86.shr4] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), esp₂] + · rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, hm₂] + · rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-! ## The call on the whole blocks -/ + +theorem Setup.call {s₀ s : State} (hp : CPre s₀) (h : Setup s₀ s) : + CCall s (fW s₀) (fIv s₀) (fD s₀) (fN s₀) where + eax := h.eax + edx := h.edx + ebx := h.ebx + esi := h.esi + esp := by rw [h.esp]; exact hp.espB + wc := hp.sch_iv + wd := hp.sch_data.sub_right (blk_sub s₀) + cd := hp.iv_data.sub_right (blk_sub s₀) + bw := by rw [h.esp]; exact hp.stk_sch + bc := by rw [h.esp]; exact hp.stk_iv + bd := by rw [h.esp]; exact hp.stk_data.sub_right (blk_sub s₀) + fW := hp.sch_fit + fC := hp.iv_fit + fD := hp.blk_fit + reads := by + rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + writes := by + rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- What the call on the whole blocks leaves. -/ +structure Whole (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame [fIvR s₀, fBlk s₀, fStk s₀] (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +theorem whole_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : WP isa ctrCall s (Whole s₀) := by + refine WP.mono (ctr_call (h.call hp)) fun s' c => ?_ + have f := c.frame + rw [h.esp, h.mem] at f + refine ⟨by rw [c.saved .esp (by simp [calleeSaved]), h.esp], by rw [c.rd, h.rd], by rw [c.wr, h.wr], f, ?_, ?_⟩ + · rw [c.out, h.mem, hp.sv_sched, hp.sv_iv, hp.sv_blocks] + · rw [c.ctr, h.mem, hp.sv_iv] + +theorem Whole.of_eq {s₀ s s' : State} (h : Whole s₀ s) (esp : s'.gpr .esp = s.gpr .esp) + (mem : s'.mem = s.mem) (rd : s'.rd = s.rd) (wr : s'.wr = s.wr) : Whole s₀ s' := + ⟨by rw [esp, h.esp], by rw [rd, h.rd], by rw [wr, h.wr], by rw [mem]; exact h.frame, + by rw [mem]; exact h.blocks, by rw [mem]; exact h.ctr⟩ + +theorem whole_cW1 {s₀ s : State} (h : Whole s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem whole_cW {s₀ s : State} (h : Whole s₀ s) : Frame (cW s₀) (svMem s₀) s.mem := + cW1_cW (whole_cW1 h) + +/-- The test sets ZF if no bytes are left after the whole blocks. -/ +theorem test_eq : ctrFinalTest = [.mov .eax (argOp 3), .alu .and .eax (.imm 15), .alu .test .eax (.reg .eax)] := + rfl + +theorem test_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole s₀ s) : + WP isa (.block ctrFinalTest) s fun s' => Whole s₀ s' ∧ s'.zf = some (decide (fU s₀ = 0)) := by + have big := big_of (whole_cW h) + rw [test_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [h.rd, h.wr]; exact hp.arg_in (by decide)) (hp.arg_keep big (by decide)) + fun s₁ u₁ => wp_andi fun s₂ u₂ => wp_test fun s₃ f₃ z₃ => WP.block_nil + ⟨h.of_eq (by rw [f₃.gpr, u₂.other _ (by decide), u₁.other _ (by decide)]) + (by rw [f₃.mem, u₂.mem, u₁.mem]) (by rw [f₃.rd, u₂.rd, u₁.rd]) (by rw [f₃.wr, u₂.wr, u₁.wr]), ?_⟩ + have := fU_lt s₀ + rw [z₃, u₂.gpr, u₁.gpr, AesCfb.X86.and15, ofNat_and_self_beq (by omega)] + +/-! ## The partial last block: its arguments -/ + +theorem tailArgs_eq : ctrFinalTailArgs = .mov .eax (argOp 4) :: .mov .ecx (.imm 0) :: + (Spill.saveCode .eax zeroSlots ++ ([.mov .ebx (.reg .eax), .alu .add .ebx (.imm 16), .mov .eax (argOp 0), + .mov .edx (argOp 1), .mov .esi (.imm 1)] : List Instr)) := rfl + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + eax : s.gpr .eax = fW s₀ + edx : s.gpr .edx = fIv s₀ + ebx : s.gpr .ebx = cBk s₀ + esi : s.gpr .esi = 1 + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBlk s₀).base 16 = List.replicate 16 0 + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (TArgs s₀) := by + have f₁ := whole_cW1 h + have big := big_of (cW1_cW f₁) + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have ak : ∀ i < 5, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [tailArgs_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (ak 4 (by decide)) fun s₁ u₁ => ?_ + refine wp_movi fun s₂ u₂ => ?_ + have eax₂ : s₂.gpr .eax = fV s₀ := by rw [u₂.other _ (by decide), u₁.gpr] + refine Spill.save_ofNat_ok zeroSlots AesCtr.X86.zeroSlots_fits (by rw [eax₂]; exact hp.sv_fit) + (fun p hp' => ?_) fun s₃ u₃ => ?_ + · have hb : p.2 + 4 ≤ 32 := AesCtr.X86.zeroSlots_fits.1 p hp' + rw [eax₂, u₂.wr, u₁.wr, h.wr, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + have hm₃ : s₃.mem = Spill.saveMem s.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₂.gpr zeroSlots := by + rw [u₃.mem, eax₂, u₂.mem, u₁.mem] + have fz : Frame [cBlk s₀] s.mem s₃.mem := by + rw [hm₃] + exact Spill.saveMem_frame List.mem_cons_self _ _ _ _ fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl | rfl | rfl + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + · exact Offset.contains _ (by decide) (by decide) (by decide) + have g₃ : s₃.gpr = s₂.gpr := u₃.gpr + have esp₃ : s₃.gpr .esp = fE s₀ := by rw [g₃, u₂.other _ (by decide), u₁.other _ (by decide), h.esp] + have rw₃ : s₃.rd ++ s₃.wr = s₀.rd ++ s₀.wr := by rw [u₃.rd, u₃.wr, u₂.rd, u₂.wr, u₁.rd, u₁.wr, hrw] + have ak₃ : ∀ i < 5, s₃.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => by + rw [fz.readW (r := ⟨argAddr s₀ i, 4⟩) (Region.contains_self _ _) (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr + exact (hp.sv_args.symm.sub_left (hp.arg_sub hi)).sub_right (blk_sv_sub s₀)) (by decide)] + exact ak i hi + refine wp_mov fun s₄ u₄ => wp_addi fun s₅ u₅ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₅.mem, u₄.mem]; exact ak₃ 0 (by decide)) fun s₆ u₆ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), esp₃]) + (by rw [u₆.rd, u₆.wr, u₅.rd, u₅.wr, u₄.rd, u₄.wr, rw₃]; exact hp.arg_in (by decide)) + (by rw [u₆.mem, u₅.mem, u₄.mem]; exact ak₃ 1 (by decide)) fun s₇ u₇ => wp_movi fun s₈ u₈ => ?_ + have m₉ : s₈.mem = s₃.mem := by rw [u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem] + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + refine WP.block_nil ⟨?_, ?_, ?_, u₈.gpr, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.gpr] + · rw [u₈.other _ (by decide), u₇.gpr] + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.gpr, u₄.gpr, g₃, eax₂]; rfl + · rw [u₈.other _ (by decide), u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), + u₄.other _ (by decide), esp₃] + · rw [u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd, h.rd] + · rw [u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr, h.wr] + · rw [m₉]; exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [m₉, AesCfb.X86.blocksAt_frame' fz blkZ]; exact h.blocks + · rw [m₉, Proof.Cmac.bytesAt_frame fz ivZ (by decide)]; exact h.ctr + · rw [m₉, hm₃] + exact AesCtr.X86.zero_bytes _ _ (by rw [u₂.gpr]) + +/-! ## The partial last block: the call -/ + +theorem TArgs.call {s₀ s : State} (hp : CPre s₀) (h : TArgs s₀ s) : + CCall s (fW s₀) (fIv s₀) (cBk s₀) 1 where + eax := h.eax + edx := h.edx + ebx := h.ebx + esi := h.esi + esp := by rw [h.esp]; exact hp.espB + wc := hp.sch_iv + wd := by rw [hp.cBlk1]; exact hp.sch_sv.sub_right (blk_sv_sub s₀) + cd := by rw [hp.cBlk1]; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + bw := by rw [h.esp]; exact hp.stk_sch + bc := by rw [h.esp]; exact hp.stk_iv + bd := by rw [hp.cBlk1, h.esp]; exact hp.stk_sv.sub_right (blk_sv_sub s₀) + fW := hp.sch_fit + fC := hp.iv_fit + fD := by rw [hp.cBk_toNat]; have := hp.sv_fit; omega + reads := by + rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_singleton] at hr; subst hr + exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + writes := by + rw [hp.cBlk1, h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 16, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBlk s₀).base 16 = fCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem tail_call_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : WP isa ctrCall s (TCall s₀) := by + have big := big_of (cW1_cW h.frame) + refine WP.mono (ctr_call (h.call hp)) fun s' c => ?_ + have f := c.frame + rw [hp.cBlk1, h.esp] at f + have out := c.out + rw [hp.cBk_addr, hp.sched_keep big, h.ctr] at out + refine ⟨by rw [c.saved .esp (by simp [calleeSaved]), h.esp], by rw [c.rd, h.rd], by rw [c.wr, h.wr], + h.frame.trans (f.mono fun r hr => ?_), ?_, by rw [c.ctr, h.ctr], + Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero out⟩ + · simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + · rw [AesCfb.X86.blocksAt_frame' f fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + +/-! ## The partial last block: the bytes XORed -/ + +theorem xorArgs_eq : ctrFinalXorArgs = [.mov .ebx (argOp 4), .alu .add .ebx (.imm 16), .mov .esi (argOp 2), + .mov .ebp (argOp 3), .mov .eax (.reg .ebp), .alu .and .ebp (.imm 15), .alu .sub .eax (.reg .ebp), + .alu .add .esi (.reg .eax)] := rfl + +/-- The tail loop's operands. -/ +structure XArgs (s₀ s : State) : Prop where + call : TCall s₀ s + ebx : s.gpr .ebx = cBk s₀ + esi : s.gpr .esi = fT s₀ + ebp : s.gpr .ebp = BitVec.ofNat 32 (fU s₀) + +theorem xorArgs_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) : + WP isa (.block ctrFinalXorArgs) s (XArgs s₀) := by + have big := big_of (cW1_cW h.frame) + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have ak : ∀ i < 5, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i := fun i hi => hp.arg_keep big hi + rw [xorArgs_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (ak 4 (by decide)) fun s₁ u₁ => ?_ + refine wp_addi fun s₁' u₁' => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₁'.other _ (by decide), u₁.other _ (by decide), h.esp]) + (by rw [u₁'.rd, u₁'.wr, u₁.rd, u₁.wr, hrw]; exact hp.arg_in (by decide)) + (by rw [u₁'.mem, u₁.mem]; exact ak 2 (by decide)) fun s₂ u₂ => ?_ + refine wp_arg (s₀ := s₀) (by rw [u₂.other _ (by decide), u₁'.other _ (by decide), u₁.other _ (by decide), h.esp]) + (by rw [u₂.rd, u₂.wr, u₁'.rd, u₁'.wr, u₁.rd, u₁.wr, hrw]; exact hp.arg_in (by decide)) + (by rw [u₂.mem, u₁'.mem, u₁.mem]; exact ak 3 (by decide)) fun s₃ u₃ => ?_ + refine wp_mov fun s₄ u₄ => wp_andi fun s₅ u₅ => wp_sub fun s₆ u₆ _ => wp_add fun s₇ u₇ => WP.block_nil ?_ + have e₅ : s₅.gpr .ebp = BitVec.ofNat 32 (fU s₀) := by + rw [u₅.gpr, u₄.other _ (by decide), u₃.gpr, AesCfb.X86.and15] + have m₇ : s₇.mem = s.mem := by rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁'.mem, u₁.mem] + refine ⟨⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩, ?_, ?_, ?_⟩ + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), u₂.other _ (by decide), u₁'.other _ (by decide), u₁.other _ (by decide), h.esp] + · rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁'.rd, u₁.rd, h.rd] + · rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁'.wr, u₁.wr, h.wr] + · rw [m₇]; exact h.frame + · rw [m₇]; exact h.blocks + · rw [m₇]; exact h.ctr + · rw [m₇]; exact h.out + · rw [u₇.other _ (by decide), u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), + u₃.other _ (by decide), u₂.other _ (by decide), u₁'.gpr, u₁.gpr]; rfl + · rw [u₇.gpr, u₆.other _ (by decide), u₅.other _ (by decide), u₄.other _ (by decide), u₃.other _ (by decide), + u₂.gpr, u₆.gpr, u₅.other _ (by decide), u₄.gpr, u₃.gpr, e₅, AesCfb.X86.sub_mod16] + · rw [u₇.other _ (by decide), u₆.other _ (by decide), e₅] + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem ((fD s₀).setWidth 64) (fN s₀) = Spec.Ctr.crypt (fCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem ((fTail s₀).base + BitVec.ofNat 64 q) = s₀.mem ((fTail s₀).base + BitVec.ofNat 64 q) ^^^ + (fCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem ((fIv s₀).setWidth 64) 16 = + Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.esp, h.rd, h.wr, whole_cW h, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem CPre.tail_addr {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).setWidth 64 = (fTail s₀).base := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + exact addr_eq (by omega) + +theorem CPre.toNat_tail {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_fit + have := Nat.div_add_mod (fL s₀) 16 + have : fN s₀ = fL s₀ / 16 := rfl + have : fU s₀ = fL s₀ % 16 := rfl + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +theorem xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : XArgs s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.loop (.block Impl.Modes.X86.tailByte) .ne) s (Done s₀) := by + have hU := fU_lt s₀ + have hT := hp.toNat_tail hu + have eT := hp.tail_addr hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_fit + have hVw := hp.sv_fit + have hB := hp.cBk_toNat + have eB := hp.cBk_addr + have eN : fN s₀ = fL s₀ / 16 := rfl + have eU : fU s₀ = fL s₀ % 16 := rfl + have hc := h.call + have xp : Modes.X86.XPre s (cBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fitK := by omega + fitR := by rw [hT]; omega + disj := by + rw [eT, eB] + exact ((((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega)))).symm + rdK := fun q hq => by + rw [hc.rd, hc.wr, hp.rd, hp.wr, eB] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [hc.wr, hp.wr, eT] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show (fTail s₀).base + BitVec.ofNat 64 q = (fD s₀).setWidth 64 + BitVec.ofNat 64 (16 * fN s₀ + q) from + Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : Modes.X86.XInv s (cBk s₀) (fT s₀) (fU s₀) 0 s := { + ebx := by rw [h.ebx]; exact (BitVec.add_zero _).symm + esi := by rw [h.esi]; exact (BitVec.add_zero _).symm + ebp := by rw [h.ebp, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + syms := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Modes.X86.tailLoop_wp xp x0) fun s' d => ?_ + have fT' : Frame [fTail s₀] s.mem s'.mem := by have := d.frame; rw [eT] at this; exact this + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (sv16_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + refine ⟨by rw [d.gpr .esp (by decide) (by decide) (by decide) (by decide) (by decide), hc.esp], + by rw [d.rd, hc.rd], by rw [d.wr, hc.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW hc.frame).trans (fT'.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [AesCfb.X86.blocksAt_frame' fT' fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact hc.blocks + · have := d.data q hq + rw [eT, eB] at this + rw [this, hc.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + MdStream.X86.bytesAt_getD hc.out (show q < 16 by omega)] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame fT' (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_data.sub_right (tail_sub s₀)) + (by decide), hc.ctr, ← Proof.AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole s₀ s) (hz : s.zf = some (decide (fU s₀ = 0))) : + WP isa (.ite .e (.block []) ctrFinalTail) s (Done s₀) := by + have ev : isa.eval .e s = some (decide (fU s₀ = 0)) := by + show VG.X86.eval .e s = _; rw [VG.Proof.MdStream.X86.eval_e, hz] + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [ev, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [ev, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => + WP.seq (WP.mono (xorArgs_wp hp h₂) fun _ h₃ => xor_wp hp h₃ hu))) + +/-! ## Restoring the registers -/ + +theorem restore_eq : ctrFinalRestore = .mov .eax (argOp 4) :: (Spill.restoreCode .eax finalSaved ++ []) := rfl + +theorem end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block ctrFinalRestore) s fun s' => abiPreserved s₀ s' ∧ s'.mem = s.mem := by + have big := big_of h.frame + have hrw : s.rd ++ s.wr = s₀.rd ++ s₀.wr := by rw [h.rd, h.wr] + have hs : Spill.Saved s.mem ((fV s₀).setWidth 64 + BitVec.ofNat 64 ·) s₀.gpr finalSaved := + (Spill.saveMem_saved_ofNat s₀.mem _ s₀.gpr AesCfb.X86.finalSaved_fits (by decide)).of_frame h.frame + (fun p hp' => Offset.contains_base _ (AesCfb.X86.finalSaved_fits.1 p hp') + (by have := AesCfb.X86.finalSaved_fits.1 p hp'; omega)) + fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_sv.sub_right (sv16_sub s₀)).symm + · exact (hp.data_sv.sub_right (sv16_sub s₀)).symm + · exact sv_blk s₀ + · exact (hp.stk_sv.sub_right (sv16_sub s₀)).symm + rw [restore_eq] + refine wp_arg (s₀ := s₀) h.esp (by rw [hrw]; exact hp.arg_in (by decide)) (hp.arg_keep big (by decide)) + fun s₁ u₁ => ?_ + refine Spill.restore_ofNat_ok finalSaved AesCfb.X86.finalSaved_fits + (by rw [u₁.gpr]; have h32 : (arg s₀ 4).toNat + 32 ≤ 2 ^ 32 := hp.sv_fit; omega) AesCfb.X86.finalSaved_ne_eax + (fun p hp' => ?_) (by rw [u₁.gpr, u₁.mem]; exact hs) fun s₂ r₂ => WP.block_nil ?_ + · have := AesCfb.X86.finalSaved_fits.1 p hp' + rw [u₁.gpr, u₁.rd, u₁.wr, hrw, hp.rd, hp.wr] + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + refine ⟨⟨r₂.abi (by decide) (by decide) (by rw [u₁.other _ (by decide), h.esp]), ?_⟩, by rw [r₂.mem, u₁.mem]⟩ + rw [r₂.mem, u₁.mem]; exact hp.ret_keep big + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : CPre s₀) : + WP isa ctrFinal s₀ fun s' => abiPreserved s₀ s' ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (test_wp hp h₂) fun s₃ ⟨h₃, z₃⟩ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₃ z₃) fun s₄ h₄ => ?_) + exact WP.mono (end_wp hp h₄) fun _ ⟨g, m⟩ => ⟨g, s₄, h₄, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86.post s₀ s' := by + show Spec.Ctr.CryptFinal (fCiph s₀) s₀.mem s'.mem ((fIv s₀).setWidth 64) ((fD s₀).setWidth 64) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalX86.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalX86.post s s' := by + obtain ⟨t, s', he, hg, s₁, h₁, hm⟩ := final_wp (CPre.of hs) + exact ⟨t, s', he, hg, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +/-- What every state between the blocks keeps: the stack pointer, the +writable regions and the stack arguments. -/ +structure Pt (s₀ s : State) : Prop where + esp : s.gpr .esp = fE s₀ + wr : s.wr = s₀.wr + args : ∀ i < 5, s.mem.readW (argAddr s₀ i) 32 = arg s₀ i + +theorem CPre.argsOut {s₀ : State} (hp : CPre s₀) {s : State} (h : Pt s₀ s) : ArgsOut 5 s := by + have hs := hp.esp_fit + refine ⟨by rw [h.esp]; omega, ?_⟩ + rw [h.wr, hp.wr, h.esp] + simp only [List.mem_cons, List.not_mem_nil, or_false] + rintro r (rfl | rfl | rfl) + · exact Taint.frame_disjoint (n := 20) (by omega) hp.ret_iv hp.iv_args.symm + · exact Taint.frame_disjoint (n := 20) (by omega) hp.ret_data hp.data_args.symm + · exact Taint.frame_disjoint (n := 20) (by omega) hp.ret_sv hp.sv_args.symm + +/-- Two runs agree on `esp`, the stack arguments and the registers `rs`. -/ +theorem Pt.agree {s₀ s₀' : State} (hq : ctrFinalX86.pub s₀ s₀') (hp : CPre s₀) (hp' : CPre s₀') + {rs : List Reg} {s₁ s₂ : State} (h₁ : Pt s₀ s₁) (h₂ : Pt s₀' s₂) (hr : ∀ r ∈ rs, s₁.gpr r = s₂.gpr r) : + VG.X86.Taint.Agree (argTaint rs (4 + 4 * 5)) s₁ s₂ := + agree_argTaint hr (by rw [h₁.esp, h₂.esp, fE, fE, hq.1]) (hp.argsOut h₁) (hp'.argsOut h₂) + fun i hi => by + rw [AesCfb.X86.arg_cur h₁.esp (h₁.args i hi), AesCfb.X86.arg_cur h₂.esp (h₂.args i hi), hq.2 i hi] + +theorem whole_pt {s₀ s : State} (hp : CPre s₀) (h : Whole s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (whole_cW h)) hi⟩ + +theorem TArgs.pt {s₀ s : State} (hp : CPre s₀) (h : TArgs s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (cW1_cW h.frame)) hi⟩ + +theorem TCall.pt {s₀ s : State} (hp : CPre s₀) (h : TCall s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of (cW1_cW h.frame)) hi⟩ + +theorem Done.pt {s₀ s : State} (hp : CPre s₀) (h : Done s₀ s) : Pt s₀ s := + ⟨h.esp, h.wr, fun _ hi => hp.arg_keep (big_of h.frame) hi⟩ + +theorem setup_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 5)) (.block (ctrFinalSave ++ ctrFinalArgs)) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem test_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 5)) (.block ctrFinalTest) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 5)) (.block ctrFinalTailArgs) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 5)) + (.seq (.block ctrFinalXorArgs) (.loop (.block Impl.Modes.X86.tailByte) .ne)) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (argTaint [] (4 + 4 * 5)) (.block ctrFinalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalX86.pre s₀) (h0' : ctrFinalX86.pre s₀') + (hq : ctrFinalX86.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + have qE : fE s₀ = fE s₀' := hq.1 + have qA : ∀ i < 5, arg s₀ i = arg s₀' i := hq.2 + have qW : fW s₀ = fW s₀' := qA 0 (by decide) + have qIv : fIv s₀ = fIv s₀' := qA 1 (by decide) + have qL : fL s₀ = fL s₀' := by simp only [fL, qA 3 (by decide)] + have qD : fD s₀ = fD s₀' := qA 2 (by decide) + have qV : fV s₀ = fV s₀' := qA 4 (by decide) + have qU : fU s₀ = fU s₀' := by simp only [fU, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, qL] + have qB : cBk s₀ = cBk s₀' := by simp only [cBk, qV] + have pt₀ : ∀ {t : State}, Pt t t := ⟨rfl, rfl, fun _ _ => rfl⟩ + -- The registers saved and the arguments of the first call. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := ((RelCT.taint (A := taint) (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + exact Pt.agree (rs := []) hq hp hp' pt₀ pt₀ fun r hr => by simp at hr) t₁).wp + (F₁ := Setup s₀) (F₂ := Setup s₀') + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + -- The whole blocks. + have c₂ := ctr_rel (P := fun a b => Setup s₀ a ∧ Setup s₀' b) (E := fE s₀) fun a b ⟨ha, hb⟩ => by + have cb := hb.call hp' + rw [← qW, ← qIv, ← qD, ← qN] at cb + exact ⟨ha.call hp, cb, ha.esp, hb.esp.trans qE.symm⟩ + have r₂ : RelCT isa (fun a b => Setup s₀ a ∧ Setup s₀' b) ctrCall (fun a b => Whole s₀ a ∧ Whole s₀' b) := + (RelCT.wp (c := ctrCall) (F₁ := Whole s₀) (F₂ := Whole s₀') c₂ + fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + -- The test. + obtain ⟨_, t₃⟩ := test_taint + have r₃ := ((RelCT.taint (A := taint) (P := fun a b => Whole s₀ a ∧ Whole s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (whole_pt hp h.1) (whole_pt hp' h.2) fun r hr => by simp at hr) + t₃).wp + (F₁ := fun (s : State) => Whole s₀ s ∧ s.zf = some (decide (fU s₀ = 0))) + (F₂ := fun (s : State) => Whole s₀' s ∧ s.zf = some (decide (fU s₀' = 0))) + fun a b h => ⟨test_wp hp h.1, test_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + -- The partial last block. + obtain ⟨_, t₄⟩ := tailArgs_taint + obtain ⟨_, t₅⟩ := xor_taint + have tail (hu : fU s₀ ≠ 0) : + RelCT isa (fun a b => Whole s₀ a ∧ Whole s₀' b) ctrFinalTail fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₄ := ((RelCT.taint (A := taint) (P := fun a b => Whole s₀ a ∧ Whole s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (whole_pt hp h.1) (whole_pt hp' h.2) fun r hr => by simp at hr) + t₄).wp + (F₁ := TArgs s₀) (F₂ := TArgs s₀') + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + have c₅ := ctr_rel (P := fun a b => TArgs s₀ a ∧ TArgs s₀' b) (E := fE s₀) fun a b ⟨ha, hb⟩ => by + have cb := hb.call hp' + rw [← qW, ← qIv, ← qB] at cb + exact ⟨ha.call hp, cb, ha.esp, hb.esp.trans qE.symm⟩ + have a₅ : RelCT isa (fun a b => TArgs s₀ a ∧ TArgs s₀' b) ctrCall (fun a b => TCall s₀ a ∧ TCall s₀' b) := + (RelCT.wp (c := ctrCall) (F₁ := TCall s₀) (F₂ := TCall s₀') c₅ + fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩).mono (fun _ _ h => h) fun _ _ h => h.2 + have a₆ := ((RelCT.taint (A := taint) (P := fun a b => TCall s₀ a ∧ TCall s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₅).wp + (F₁ := Done s₀) (F₂ := Done s₀') + fun a b h => ⟨WP.seq (WP.mono (xorArgs_wp hp h.1) fun _ h₃ => xor_wp hp h₃ hu), + WP.seq (WP.mono (xorArgs_wp hp' h.2) fun _ h₃ => xor_wp hp' h₃ hu')⟩).mono + (fun _ _ h => h) fun _ _ h => h.2 + exact a₄.seq (a₅.seq a₆) + have r₄ : RelCT isa (fun a b => (Whole s₀ a ∧ a.zf = some (decide (fU s₀ = 0))) ∧ + (Whole s₀' b ∧ b.zf = some (decide (fU s₀' = 0)))) + (.ite .e (.block []) ctrFinalTail) (fun a b => Done s₀ a ∧ Done s₀' b) := by + refine RelCT.ite (fun a b h => ?_) ?_ ?_ + · show a.zf = b.zf; rw [h.1.2, h.2.2, qU] + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + exact ⟨done_of_zero h.1.1.1 h0, done_of_zero h.1.2.1 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1.1, h.1.2.1⟩) fun _ _ h => h + have := h.2; change a.zf = _ at this; rw [h.1.1.2] at this; simpa using this + -- The registers restored. + obtain ⟨_, t₆⟩ := restore_taint + have r₅ := RelCT.taint (A := taint) (P := fun a b => Done s₀ a ∧ Done s₀' b) _ + (fun a b h => Pt.agree (rs := []) hq hp hp' (h.1.pt hp) (h.2.pt hp') fun r hr => by simp at hr) t₆ + exact r₁.seq (r₂.seq (r₃.seq (r₄.seq r₅))) + +theorem final_ct : ConstantTime isa ctrFinalX86.pre ctrFinalX86.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## The code's properties -/ + +theorem ctrFinal_noSp : ctrFinal.allInstrs (fun i => !Taint.clobbers i .esp) = true := by + simp only [ctrFinal, ctrCall, ctrFinalTail, Code.allInstrs, AesCfb.X86.all_of_noSp ctr_nosp] + decide + +theorem ctrFinal_stack : stackUse ctrFinal ≤ 1536 := by + simp only [ctrFinal, ctrCall, ctrFinalTail, stackUse, ctr_stack] + decide + +theorem ctrFinal_verified : Verified X86.target ctrFinal finalScratchContract := + verified_wide final_correct final_ct + +/-! ## With `save` on the stack + +The final function has four argument slots, so `save` is its fifth argument: +it runs its code in a frame of 56 bytes (`withStackScratchWiped 56 4 8`): the +word standing for the return address, a copy of the four arguments, `save`'s +address, and `save`'s 32 bytes (the registers, then the block that held the +last output block), which it zeroes before returning. The code's calls use +1536 bytes below it, so 1592 in all. -/ + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + Spec.Aes.bytesAt m₂ p k = Spec.Aes.bytesAt m₁ p k := by + simp only [Spec.Aes.bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : + ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by + intro i hi + refine (h _ ?_).symm + by_cases hw : i < 2 ^ 64 + · exact Offset.contains_base _ (by omega) hw + · simp only [Region.Contains] + have := (p + BitVec.ofNat 64 i - p).isLt + omega + +/-- `ctrFinalPost` reads the memory on entry only within the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Sm4.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Sm4.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₁ m' r → + Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, ctr, data, len], _ => + simp only [Spec.Sm4.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hs := agree_of' hb.1 + have hc := agree_of' hb.2.1 + have hd := agree_of' hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Sm4.ctrFinalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Sm4.ctrFinalPost pb) _ m₂ m' r + dsimp only [Curry.apply, Proof.Sm4.ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + rw [Proof.Sm4.scheduleAt_congr hs, bytesAt_congr' hc, + bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega)] + exact h + +theorem frameSat_pre : ∃ s, (Spec.Sm4.ctrFinalContract X86.abi 1592).pre s := by + implies_sat [Spec.Sm4.ctrFinalContract, Spec.Sm4.ctrFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] + [Fb.frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using Fb.frameSat + +theorem ctrFinal_framed : + Verified X86.target (Impl.StackScratch.X86.withStackScratchWiped 56 4 8 ctrFinal) + (Spec.Sm4.ctrFinalContract X86.abi 1592) := + X86.Verified.stackScratchWiped (sig := Spec.Sm4.ctrFinalSig) (nm := "save") (e := .u64) (n := 4) + (pre := Curry.const (fun _ => True) _) (post := Proof.Sm4.ctrFinalPost X86.abi.ptrBits) + (wa := true) (stack := 1536) (bytes := 56) (words := 8) ctrFinal_verified (by decide) ctrFinal_noSp + ctrFinal_stack (by decide) (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (ctrFinalPost_local _) + (Proof.Sm4.ctrFinalPostOut_local _) frameSat_pre + +theorem ctrFinal_framed_spSafe : + (Impl.StackScratch.X86.withStackScratchWiped 56 4 8 ctrFinal).all (fun i => !isa.writesSp i) = true := + Code.all_of_allInstrs (by lit_decide) + +end VG.Proof.Sm4.X86.CtrFinal From 59ab43db58ff58a65e6eeb44773dd12bf167c2e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 12:50:51 +0000 Subject: [PATCH 14/18] AES-OFB and CTR (AES, Camellia, SM4) final functions on PPC64LE (WIP: crates to come) As on the other targets. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/AesCtr/PPC64LE.lean | 7 +- .../Artifacts/AesOfb/PPC64LE.lean | 7 +- .../Artifacts/CamelliaCtr/PPC64LE.lean | 7 +- .../Artifacts/Sm4Ctr/PPC64LE.lean | 7 +- .../Impl/AesCtr/PPC64LE/Final.lean | 77 ++ .../Impl/AesOfb/PPC64LE/Final.lean | 39 + .../Impl/Camellia/PPC64LE/CtrFinal.lean | 87 ++ .../Impl/Sm4/PPC64LE/CtrFinal.lean | 86 ++ .../Proof/AesCfb/PPC64LE/Final.lean | 44 +- .../Proof/AesCtr/PPC64LE/Final.lean | 921 ++++++++++++++ .../Proof/AesOfb/PPC64LE/Final.lean | 115 ++ .../Proof/Camellia/PPC64LE/CtrFinal.lean | 1063 +++++++++++++++++ .../Proof/Sm4/PPC64LE/CtrFinal.lean | 1055 ++++++++++++++++ 13 files changed, 3489 insertions(+), 26 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/AesCtr/PPC64LE/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/AesOfb/PPC64LE/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/Camellia/PPC64LE/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Impl/Sm4/PPC64LE/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/PPC64LE/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/PPC64LE/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean diff --git a/lean/VerifiedGarbage/Artifacts/AesCtr/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/AesCtr/PPC64LE.lean index 873e9ea32be..814fe156484 100644 --- a/lean/VerifiedGarbage/Artifacts/AesCtr/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/AesCtr/PPC64LE.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesCtr.PPC64LE.Verified +public import VerifiedGarbage.Proof.AesCtr.PPC64LE.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print @@ -13,6 +14,10 @@ namespace VG.Artifacts.AesCtr.PPC64LE def artifacts : List Artifact := [ Spec.Ctr.aesApi.artifact PPC64LE.target { code := Impl.AesCtr.PPC64LE.crypt - verified := Proof.AesCtr.keyed Proof.AesCtr.PPC64LE.crypt_verified }] + verified := Proof.AesCtr.keyed Proof.AesCtr.PPC64LE.crypt_verified }, + Spec.Ctr.aesFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 112 .r9 10 Impl.AesCtr.PPC64LE.cryptFinal + stack := 112 + verified := Proof.AesCtr.final_keyed Proof.AesCtr.PPC64LE.Final.cryptFinal_framed }] end VG.Artifacts.AesCtr.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/AesOfb/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/AesOfb/PPC64LE.lean index 70bf9fd997e..3feb88f7e10 100644 --- a/lean/VerifiedGarbage/Artifacts/AesOfb/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/AesOfb/PPC64LE.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesOfb.PPC64LE.Verified +public import VerifiedGarbage.Proof.AesOfb.PPC64LE.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print @@ -13,6 +14,10 @@ namespace VG.Artifacts.AesOfb.PPC64LE def artifacts : List Artifact := [ Spec.Ofb.aesApi.artifact PPC64LE.target { code := Impl.AesOfb.PPC64LE.crypt - verified := Proof.AesOfb.keyed Proof.AesOfb.PPC64LE.crypt_verified }] + verified := Proof.AesOfb.keyed Proof.AesOfb.PPC64LE.crypt_verified }, + Spec.Ofb.aesFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 96 .r9 8 Impl.AesOfb.PPC64LE.cryptFinal + stack := 96 + verified := Proof.AesOfb.final_keyed Proof.AesOfb.PPC64LE.cryptFinal_framed }] end VG.Artifacts.AesOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/PPC64LE.lean index 2e17887f6e4..072e8161d03 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/PPC64LE.lean @@ -2,6 +2,7 @@ module public import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesVerified public import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesFrame +public import VerifiedGarbage.Proof.Camellia.PPC64LE.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesLit @@ -17,6 +18,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ctrApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 3408 .r8 422 Impl.Camellia.PPC64LE.ctr stack := 3408 - verified := Proof.Camellia.PPC64LE.ctr_framed Proof.Camellia.PPC64LE.Modes.ctr_verified }] + verified := Proof.Camellia.PPC64LE.ctr_framed Proof.Camellia.PPC64LE.Modes.ctr_verified }, + Spec.Camellia.ctrFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 112 .r8 10 Impl.Camellia.PPC64LE.ctrFinal + stack := 3520 + verified := Proof.Camellia.PPC64LE.CtrFinal.ctrFinal_framed }] end VG.Artifacts.CamelliaCtr.PPC64LE diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/PPC64LE.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/PPC64LE.lean index ce9fb3de523..96a6bd66bec 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/PPC64LE.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/PPC64LE.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrVerified +public import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.PPC64LE.Print import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrLit @@ -16,6 +17,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ctrApi.artifact PPC64LE.target { code := Impl.StackScratch.PPC64LE.withStackScratchWiped 3296 .r7 408 Impl.Sm4.PPC64LE.ctr stack := 3296 - verified := Proof.Sm4.PPC64LE.Modes.ctr_framed }] + verified := Proof.Sm4.PPC64LE.Modes.ctr_framed }, + Spec.Sm4.ctrFinalApi.artifact PPC64LE.target { + code := Impl.StackScratch.PPC64LE.withStackScratchWiped 112 .r7 10 Impl.Sm4.PPC64LE.ctrFinal + stack := 3408 + verified := Proof.Sm4.PPC64LE.CtrFinal.ctrFinal_framed }] end VG.Artifacts.Sm4Ctr.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/AesCtr/PPC64LE/Final.lean b/lean/VerifiedGarbage/Impl/AesCtr/PPC64LE/Final.lean new file mode 100644 index 00000000000..f6c33769015 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesCtr/PPC64LE/Final.lean @@ -0,0 +1,77 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.PPC64LE +public import VerifiedGarbage.Impl.AesCfb.PPC64LE.Final + +/-! +# AES-CTR of a message's last piece: PPC64LE implementation + +`cryptFinal` (schedule = r3, rounds = r4, ctr = r5, data = r6, len = r7, +scratch = r8, save = r9): the code of `vg_aes_ctr_final`, whose registration +frames it with a buffer of its own on the stack, `save`, the seventh +argument, of 80 bytes: the return address and the caller's callee-saved +registers, then a block of the code's own. + +1. the return address (through `r0`) and the registers saved in `save`, and + the arguments kept in `r14` (schedule), `r15` (rounds), `r16` (ctr), + `r19` (scratch), `r31` (the data after its whole blocks), `r30` + (`u = len mod 16`, the bytes after them) and `r20` (`save`), as AES-CFB's + final functions do (`Impl/AesCfb/PPC64LE/Final.lean`); +2. a call of the whole-block function `vg_aes_ctr` + (`Impl/AesCtr/PPC64LE.lean`) on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + the same function on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time (the modes' `tailByte`, from `r8`, the + block, into `r31`, `r30` bytes); +4. the registers and the return address restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds`, `len` and the last 32 bits of the counter block +can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesCtr.PPC64LE + +open VG.PPC64LE +open VG.Impl.AesCbc.PPC64LE (mov) +open VG.Impl.AesCfb.PPC64LE (finalSetup finalRestore) +open VG.Impl.Modes.PPC64LE (tailByte) + +/-- The two doublewords of the block after the registers in `save`, each +zeroed from `r9`. -/ +def zeroSlots : List (Reg × Nat) := [(.r9, 64), (.r9, 72)] + +/-- The arguments of the whole-block function on that block: the schedule, +the rounds, the counter block, the block, `n = 1`, and the working space. -/ +def tailMoves : List Instr := + [mov .r3 .r14, mov .r4 .r15, mov .r5 .r16, .addi .r6 .r20 64, .li .r7 1, mov .r8 .r19] + +/-- The block, from `save` in `r20`, zeroed, and the arguments of the +whole-block function on it. -/ +def tailArgs : List Instr := + .li .r9 0 :: (zeroSlots.map fun p => .store .d p.1 .r20 p.2) ++ tailMoves + +/-- The block's address, from `save` in `r20`, for the XOR. -/ +def tailKey : List Instr := [.addi .r8 .r20 64] + +/-- A call of the whole-block function. -/ +def wholeCall : Prog isa := .call "vg_aes_ctr" crypt + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, by a call of the whole-block function on it, and its first `u` +bytes XORed into the data. -/ +def finalTail : Prog isa := + .seq (.block tailArgs) (.seq wholeCall + (.seq (.block tailKey) (.loop (.block tailByte) (.nonzero .d .r30)))) + +/-- `vg_aes_ctr_final`, calling `vg_aes_ctr`. -/ +def cryptFinal : Prog isa := + .seq (.block finalSetup) (.seq wholeCall + (.seq (.ite (.zero .d .r30) (.block []) finalTail) (.block finalRestore))) + +end VG.Impl.AesCtr.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/AesOfb/PPC64LE/Final.lean b/lean/VerifiedGarbage/Impl/AesOfb/PPC64LE/Final.lean new file mode 100644 index 00000000000..02f7004e946 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesOfb/PPC64LE/Final.lean @@ -0,0 +1,39 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.PPC64LE +public import VerifiedGarbage.Impl.AesCfb.PPC64LE.Final + +/-! +# AES-OFB of a message's last piece: PPC64LE implementation + +`cryptFinal` (schedule = r3, rounds = r4, iv = r5, data = r6, len = r7, +scratch = r8, save = r9): the code of `vg_aes_ofb_final`, whose registration +frames it with a buffer of its own on the stack, `save`, the seventh +argument, where the code keeps its return address and its caller's +callee-saved registers. It is AES-CFB's final function +(`Impl.AesCfb.PPC64LE.final`) around a call of the whole-block AES-OFB +function `vg_aes_ofb` (`Impl/AesOfb/PPC64LE.lean`): + +1. the return address and the registers saved in `save`, and the arguments + kept in callee-saved registers; +2. a call of `vg_aes_ofb` on the `len / 16` whole blocks, which leaves the + last output block `Oₙ` in `iv`; +3. if `u = len mod 16 ≠ 0`, a call of the block function on the block at + `iv` in place, which leaves `Oₙ₊₁ = CIPH_K(Oₙ)` there, the last output + block used, and its first `u` bytes XORed into the `u` bytes left, a + byte at a time; +4. the registers and the return address restored. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesOfb.PPC64LE + +open VG.PPC64LE + +/-- `vg_aes_ofb_final`, calling `vg_aes_ofb`. -/ +def cryptFinal : Prog isa := Impl.AesCfb.PPC64LE.final "vg_aes_ofb" crypt + +end VG.Impl.AesOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/CtrFinal.lean new file mode 100644 index 00000000000..ce0d0344961 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Camellia/PPC64LE/CtrFinal.lean @@ -0,0 +1,87 @@ +module + +public import VerifiedGarbage.Impl.Camellia.PPC64LE.Modes +public import VerifiedGarbage.Impl.AesCtr.PPC64LE.Final +public import VerifiedGarbage.Impl.StackScratch.PPC64LE + +/-! +# Camellia-CTR of a message's last piece: PPC64LE implementation + +`ctrFinal` (schedule = r3, rounds = r4, ctr = r5, data = r6, len = r7, +save = r8): the code of `vg_camellia_ctr_final`, whose registration frames +it with a buffer of its own on the stack, `save`, of 80 bytes, passed in +`r8`: the return address and the caller's callee-saved registers, then a +block of the code's own. It is AES-CTR's final function's +(`Impl/AesCtr/PPC64LE/Final.lean`) with Camellia's arguments, around calls +of `vg_camellia_ctr`, framed by its own working space on the stack +(`ctrFramed`): + +1. the return address (through `r0`) and the registers saved in `save` + (AES-CFB's final functions' slots, `finalSaved`), and the arguments kept + in `r14` (schedule), `r15` (rounds), `r16` (ctr), `r31` (the data after + its whole blocks), `r30` (`u = len mod 16`, the bytes after them) and + `r20` (`save`); +2. a call of `vg_camellia_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_camellia_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers and the return address restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Camellia.PPC64LE + +open VG.PPC64LE +open VG.Impl.AesCbc.PPC64LE (mov) +open VG.Impl.AesCfb.PPC64LE (finalSaved finalRestore) +open VG.Impl.AesCtr.PPC64LE (zeroSlots tailKey) +open VG.Impl.Modes.PPC64LE (tailByte) + +/-- `vg_camellia_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.PPC64LE.withStackScratchWiped 3408 .r8 422 ctr + +/-- A call of `vg_camellia_ctr`. -/ +def ctrCall : Prog isa := .call "vg_camellia_ctr" ctrFramed + +/-- The return address and the registers saved in `save`, at `r8`. -/ +def ctrFinalSave : List Instr := .mflr .r0 :: finalSaved.map fun (r, d) => .store .d r .r8 d + +/-- The arguments to their registers, `r31` and `r30` the data after the +whole blocks and its length, `r20` `save`, and `r7` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [mov .r14 .r3, mov .r15 .r4, mov .r16 .r5, mov .r20 .r8, .lsr .d .r10 .r7 4, + .lsl .r11 .r10 4, .add .r31 .r6 .r11, .sub .r30 .r7 .r11, mov .r7 .r10] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrFinalSave ++ ctrFinalMoves + +/-- The arguments of `vg_camellia_ctr` on the block after the registers: +the schedule, the rounds, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [mov .r3 .r14, mov .r4 .r15, mov .r5 .r16, .addi .r6 .r20 64, .li .r7 1] + +/-- The block, from `save` in `r20`, zeroed, and the arguments of +`vg_camellia_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .li .r9 0 :: (zeroSlots.map fun p => .store .d p.1 .r20 p.2) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq ctrCall + (.seq (.block tailKey) (.loop (.block tailByte) (.nonzero .d .r30)))) + +/-- `vg_camellia_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq ctrCall + (.seq (.ite (.zero .d .r30) (.block []) ctrFinalTail) (.block finalRestore))) + +end VG.Impl.Camellia.PPC64LE diff --git a/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/CtrFinal.lean new file mode 100644 index 00000000000..ca7b3ff56c0 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Sm4/PPC64LE/CtrFinal.lean @@ -0,0 +1,86 @@ +module + +public import VerifiedGarbage.Impl.Sm4.PPC64LE.Ctr +public import VerifiedGarbage.Impl.AesCtr.PPC64LE.Final +public import VerifiedGarbage.Impl.StackScratch.PPC64LE + +/-! +# SM4-CTR of a message's last piece: PPC64LE implementation + +`ctrFinal` (schedule = r3, ctr = r4, data = r5, len = r6, save = r7): the +code of `vg_sm4_ctr_final`, whose registration frames it with a buffer of its +own on the stack, `save`, of 80 bytes, passed in `r7`: the return address and +the caller's callee-saved registers, then a block of the code's own. It is +AES-CTR's final function's (`Impl/AesCtr/PPC64LE/Final.lean`) with SM4's +arguments, around calls of `vg_sm4_ctr`, framed by its own working space on +the stack (`ctrFramed`): + +1. the return address (through `r0`) and the registers saved in `save` + (AES-CFB's final functions' slots, `finalSaved`), and the arguments kept + in `r14` (schedule), `r16` (ctr), `r31` (the data after its whole + blocks), `r30` (`u = len mod 16`, the bytes after them) and `r20` + (`save`); +2. a call of `vg_sm4_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_sm4_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers and the return address restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Sm4.PPC64LE + +open VG.PPC64LE +open VG.Impl.AesCbc.PPC64LE (mov) +open VG.Impl.AesCfb.PPC64LE (finalSaved finalRestore) +open VG.Impl.AesCtr.PPC64LE (zeroSlots tailKey) +open VG.Impl.Modes.PPC64LE (tailByte) + +/-- `vg_sm4_ctr`, with its working space on the stack. -/ +def ctrFramed : Prog isa := Impl.StackScratch.PPC64LE.withStackScratchWiped 3296 .r7 408 ctr + +/-- A call of `vg_sm4_ctr`. -/ +def ctrCall : Prog isa := .call "vg_sm4_ctr" ctrFramed + +/-- The return address and the registers saved in `save`, at `r7`. -/ +def ctrFinalSave : List Instr := .mflr .r0 :: finalSaved.map fun (r, d) => .store .d r .r7 d + +/-- The arguments to their registers, `r31` and `r30` the data after the +whole blocks and its length, `r20` `save`, and `r6` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [mov .r14 .r3, mov .r16 .r4, mov .r20 .r7, .lsr .d .r10 .r6 4, + .lsl .r11 .r10 4, .add .r31 .r5 .r11, .sub .r30 .r6 .r11, mov .r6 .r10] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrFinalSave ++ ctrFinalMoves + +/-- The arguments of `vg_sm4_ctr` on the block after the registers: the +schedule, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [mov .r3 .r14, mov .r4 .r16, .addi .r5 .r20 64, .li .r6 1] + +/-- The block, from `save` in `r20`, zeroed, and the arguments of +`vg_sm4_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .li .r9 0 :: (zeroSlots.map fun p => .store .d p.1 .r20 p.2) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq ctrCall + (.seq (.block tailKey) (.loop (.block tailByte) (.nonzero .d .r30)))) + +/-- `vg_sm4_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq ctrCall + (.seq (.ite (.zero .d .r30) (.block []) ctrFinalTail) (.block finalRestore))) + +end VG.Impl.Sm4.PPC64LE diff --git a/lean/VerifiedGarbage/Proof/AesCfb/PPC64LE/Final.lean b/lean/VerifiedGarbage/Proof/AesCfb/PPC64LE/Final.lean index 905e08dd621..14d603b6b74 100644 --- a/lean/VerifiedGarbage/Proof/AesCfb/PPC64LE/Final.lean +++ b/lean/VerifiedGarbage/Proof/AesCfb/PPC64LE/Final.lean @@ -813,10 +813,10 @@ theorem decrypt_noFrames : Impl.AesCfb.PPC64LE.decrypt.noFrames = true := by /-! ## Constant time -/ -theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modePPC64LE (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modePPC64LE (cfbMode enc)).post s s') - (hct : ConstantTime isa (modePPC64LE (cfbMode enc)).pre (modePPC64LE (cfbMode enc)).pub whole) +theorem final_rel {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modePPC64LE M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modePPC64LE M).post s s') + (hct : ConstantTime isa (modePPC64LE M).pre (modePPC64LE M).pub whole) (nf : whole.noFrames = true) {s₀ s₀' : State} (h0 : (finalPPC64LE enc).pre s₀) (h0' : (finalPPC64LE enc).pre s₀') (hq : (finalPPC64LE enc).pub s₀ s₀') : RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole) fun _ _ => True := by @@ -840,7 +840,7 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} obtain ⟨rfl, rfl⟩ := h exact ⟨wp_sp (final_setup_wp hp), wp_sp (final_setup_wp hp')⟩ -- The whole blocks. - have r₂ := (RelCT.callEx (k := modePPC64LE (cfbMode enc)) (n := name) hv hct + have r₂ := (RelCT.callEx (k := modePPC64LE M) (n := name) hv hct (P := fun a b => (Setup s₀ a ∧ a.sp = s₀.sp) ∧ (Setup s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by obtain ⟨pa, ca, wa⟩ := whole_pre (M := cfbMode enc) hp ha.1 obtain ⟨pb, cb, wb⟩ := whole_pre (M := cfbMode enc) hp' hb.1 @@ -853,8 +853,8 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.1.r7, hb.1.r8, hb.2] rw [fW, fW, fIv, fIv, fD, fD, fS, fS, qW, qR, qIv, qD, qS, qSp, qN] exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩).wp - (F₁ := fun (s : State) => Whole (cfbMode enc) s₀ s ∧ s.sp = s₀.sp) - (F₂ := fun (s : State) => Whole (cfbMode enc) s₀' s ∧ s.sp = s₀'.sp) + (F₁ := fun (s : State) => Whole M s₀ s ∧ s.sp = s₀.sp) + (F₂ := fun (s : State) => Whole M s₀' s ∧ s.sp = s₀'.sp) fun a b h => ⟨WP.mono (wp_sp (whole_wp hv nf hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, WP.mono (wp_sp (whole_wp hv nf hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ -- The partial last segment. @@ -863,11 +863,11 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} obtain ⟨_, t₄⟩ : ∃ h, (taint.check (Taint.ofRegs [.r16, .r30, .r31]) xorCode h).isSome = true := ⟨_, by taint_decide⟩ have tail (hu : fU s₀ ≠ 0) : RelCT isa - (fun a b => (Whole (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Whole (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) - finalTail fun a b => (Done (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Done (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp) := by + (fun a b => (Whole M s₀ a ∧ a.sp = s₀.sp) ∧ (Whole M s₀' b ∧ b.sp = s₀'.sp)) + finalTail fun a b => (Done M s₀ a ∧ a.sp = s₀.sp) ∧ (Done M s₀' b ∧ b.sp = s₀'.sp) := by have hu' : fU s₀' ≠ 0 := qU ▸ hu have a₃ := (taintRegs - (P := fun a b => (Whole (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Whole (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) _ + (P := fun a b => (Whole M s₀ a ∧ a.sp = s₀.sp) ∧ (Whole M s₀' b ∧ b.sp = s₀'.sp)) _ (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl | rfl @@ -875,12 +875,12 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} · rw [h.1.1.r15, h.2.1.r15, qR] · rw [h.1.1.r16, h.2.1.r16, fIv, fIv, qIv] · rw [h.1.1.r19, h.2.1.r19, fS, fS, qS]⟩) t₃).wp - (F₁ := fun (s : State) => IvA (cfbMode enc) s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => IvA (cfbMode enc) s₀' s ∧ s.sp = s₀'.sp) + (F₁ := fun (s : State) => IvA M s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => IvA M s₀' s ∧ s.sp = s₀'.sp) fun a b h => ⟨WP.mono (wp_sp (final_ivArgs_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, WP.mono (wp_sp (final_ivArgs_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ have a₄ := (blk_rel (name := "vg_aes_encrypt_blocks") Proof.Aes.PPC64LE.encryptBlocks_correct Proof.Aes.PPC64LE.encryptBlocks_ct - (P := fun a b => (IvA (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (IvA (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) + (P := fun a b => (IvA M s₀ a ∧ a.sp = s₀.sp) ∧ (IvA M s₀' b ∧ b.sp = s₀'.sp)) fun a b h => by have e₂ := h.2.1.pre have eW : fW s₀' = fW s₀ := qW.symm @@ -889,26 +889,26 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} have eR : fR s₀' = fR s₀ := by simp only [fR, qR] rw [eW, eIv, eS, eR] at e₂ exact ⟨h.1.1.pre, e₂, by rw [h.1.2, h.2.2, qSp]⟩).wp - (F₁ := fun (s : State) => Ciph (cfbMode enc) s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => Ciph (cfbMode enc) s₀' s ∧ s.sp = s₀'.sp) + (F₁ := fun (s : State) => Ciph M s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => Ciph M s₀' s ∧ s.sp = s₀'.sp) fun a b h => ⟨WP.mono (wp_sp (final_ciph_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, WP.mono (wp_sp (final_ciph_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ have a₅ := (taintRegs - (P := fun a b => (Ciph (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Ciph (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) _ + (P := fun a b => (Ciph M s₀ a ∧ a.sp = s₀.sp) ∧ (Ciph M s₀' b ∧ b.sp = s₀'.sp)) _ (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl · rw [h.1.1.r16, h.2.1.r16, fIv, fIv, qIv] · rw [h.1.1.r30, h.2.1.r30, qU] · rw [h.1.1.r31, h.2.1.r31, qT]⟩) t₄).wp - (F₁ := fun (s : State) => Done (cfbMode enc) s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => Done (cfbMode enc) s₀' s ∧ s.sp = s₀'.sp) + (F₁ := fun (s : State) => Done M s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => Done M s₀' s ∧ s.sp = s₀'.sp) fun a b h => ⟨WP.mono (wp_sp (final_xor_wp hp h.1.1 hu)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, WP.mono (wp_sp (final_xor_wp hp' h.2.1 hu')) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ exact (a₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((a₄.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₅.mono (fun _ _ h => h) fun _ _ h => h.2)) have r₃ : RelCT isa - (fun a b => (Whole (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Whole (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) + (fun a b => (Whole M s₀ a ∧ a.sp = s₀.sp) ∧ (Whole M s₀' b ∧ b.sp = s₀'.sp)) (.ite (.zero .d .r30) (.block []) finalTail) - (fun a b => (Done (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Done (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) := by + (fun a b => (Done M s₀ a ∧ a.sp = s₀.sp) ∧ (Done M s₀' b ∧ b.sp = s₀'.sp)) := by refine RelCT.ite (fun a b h => by rw [eval_u h.1.1, eval_u h.2.1, qU]) ?_ ?_ · refine RelCT.block_nil fun a b h => ?_ have h0 : fU s₀ = 0 := by @@ -921,16 +921,16 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} obtain ⟨_, t₅⟩ : ∃ h, (taint.check (Taint.ofRegs [.r20]) (.block finalRestore) h).isSome = true := ⟨_, by taint_decide⟩ have r₄ := taintRegs - (P := fun a b => (Done (cfbMode enc) s₀ a ∧ a.sp = s₀.sp) ∧ (Done (cfbMode enc) s₀' b ∧ b.sp = s₀'.sp)) _ + (P := fun a b => (Done M s₀ a ∧ a.sp = s₀.sp) ∧ (Done M s₀' b ∧ b.sp = s₀'.sp)) _ (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.r20, h.2.1.r20, fV, fV, qV]⟩) t₅ exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₃.seq r₄)) -theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modePPC64LE (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modePPC64LE (cfbMode enc)).post s s') - (hct : ConstantTime isa (modePPC64LE (cfbMode enc)).pre (modePPC64LE (cfbMode enc)).pub whole) +theorem final_ct {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modePPC64LE M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modePPC64LE M).post s s') + (hct : ConstantTime isa (modePPC64LE M).pre (modePPC64LE M).pub whole) (nf : whole.noFrames = true) : ConstantTime isa (finalPPC64LE enc).pre (finalPPC64LE enc).pub (final name whole) := fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct nf h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 diff --git a/lean/VerifiedGarbage/Proof/AesCtr/PPC64LE/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/PPC64LE/Final.lean new file mode 100644 index 00000000000..0dd542f9294 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/PPC64LE/Final.lean @@ -0,0 +1,921 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.PPC64LE.Final +public import VerifiedGarbage.Proof.AesCtr.Final +public import VerifiedGarbage.Proof.AesCtr.PPC64LE.Verified +public import VerifiedGarbage.Proof.AesCtr.PPC64LE.CT +public import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.PPC64LE.Spill +public import VerifiedGarbage.Impl.StackScratch.PPC64LE +import VerifiedGarbage.Proof.AesCtr.PPC64LE.Call +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCtr.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.PPC64LE.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.PPC64LE.Step +import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +import VerifiedGarbage.Proof.Framework.PPC64LE.Taint +import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +import VerifiedGarbage.Proof.AesCbc.PPC64LE.Body +import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT +meta import VerifiedGarbage.Impl.AesCtr.PPC64LE.Final +meta import VerifiedGarbage.Proof.AesCtr.Final +meta import VerifiedGarbage.Proof.AesCtr.PPC64LE.Verified +meta import VerifiedGarbage.Proof.AesCtr.PPC64LE.CT +meta import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Spill +meta import VerifiedGarbage.Impl.StackScratch.PPC64LE +meta import VerifiedGarbage.Proof.AesCtr.PPC64LE.Call +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCtr.Spec +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.PPC64LE.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Step +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Taint +meta import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Proof.AesCbc.PPC64LE.Body +meta import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT + +/-! +# AES-CTR of a message's last piece on PPC64LE + +`cryptFinal_framed`: `vg_aes_ctr_final` (`Impl/AesCtr/PPC64LE/Final.lean`) +meets `Proof.AesCtr.finalRoundsContract`, from which the shared contract +follows (`Proof.AesCtr.final_keyed`). + +The code is proven against `ctrFinalPPC64LE`, with a seventh argument `save` +(`r9`) of 80 bytes, for its return address and its caller's registers and a +block of its own (`final_implies`: the shared contract with it, +`finalScratchContract`), as a caller of the whole-block function, through its +contract (`modePPC64LE ctrMode`, with `ctrPub`). It shares AES-CFB's final +functions' setup (`Proof/AesCfb/PPC64LE/Final.lean`: `Setup`, `Whole`): + +* `final_setup_wp`, `whole_wp`: the registers saved, and the whole-block + function on the `n = len / 16` whole blocks (`Whole`); +* `final_mid_wp`: if `u = len % 16` bytes are left, the block after the + registers in `save` zeroed and the whole-block function on it + (`tail_args_wp`, `tail_call_wp`), which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed into them + (`Modes.PPC64LE.tailLoop_wp`, `tail_xor_wp`); what is left before the + registers are restored is `Done`; +* `final_end_wp`: the registers and the return address restored; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the whole-block function's constant time, whose public data, the last 32 +bits of the counter block, agree in both runs at both calls: they do on +entry (the contract's leak), and after `n` blocks they are those on entry +plus `n` modulo `2³²`. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr.PPC64LE.Final + +open VG VG.PPC64LE +open VG.Spec.Aes (bytesAt) +open VG.Impl.AesCtr.PPC64LE (zeroSlots tailMoves tailArgs tailKey wholeCall finalTail cryptFinal crypt) +open VG.Impl.AesCfb.PPC64LE (finalSaved finalSetup finalRestore) +open VG.Proof.AesCfb.PPC64LE.Final (fW fR fIv fD fL fS fV fN fU fT fSch fIvR fData fBlk fTail fScr fSv + fWk fIv0 fBlks saveG svMem Setup Whole Kept vars finalSat finalFrameSat moves_wp shr4 shr4_shl4 sub_shl4 + toNat_n eval_u bytesAt_getD blocksAt_frame' svMem_frame saved_slots saved_fits blk_sub tail_sub fN_eq + fU_eq n_lt u_lt preserved_ne_r0 upd_gpr r4_ofNat restore_eq) +open VG.Proof.AesCbc (Mode) +open VG.Proof.AesCbc.PPC64LE (modePPC64LE callEntry_gpr' taintRegs wp_sp) + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = r3, rounds = r4, +ctr = r5, data = r6, len = r7, scratch = r8, save = r9)`, `save` of 80 +bytes: the data and the counter block as `Spec.Ctr.CryptFinal` says, by AES +with the key schedule it is given; the counter block's last four bytes are +public. -/ +def ctrFinalPPC64LE : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .r3, 240⟩ + let iv : Region := ⟨s.gpr .r5, 16⟩ + let data : Region := ⟨s.gpr .r6, (s.gpr .r7).toNat⟩ + let scr : Region := ⟨s.gpr .r8, 2176⟩ + let sv : Region := ⟨s.gpr .r9, 80⟩ + s.rd = [sched] ∧ s.wr = [iv, data, scr, sv] ∧ + sched.Disjoint iv ∧ sched.Disjoint data ∧ sched.Disjoint scr ∧ sched.Disjoint sv ∧ + iv.Disjoint data ∧ iv.Disjoint scr ∧ iv.Disjoint sv ∧ + data.Disjoint scr ∧ data.Disjoint sv ∧ scr.Disjoint sv ∧ + (s.gpr .r3).toNat + 240 ≤ 2 ^ 64 ∧ (s.gpr .r5).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .r6).toNat + (s.gpr .r7).toNat ≤ 2 ^ 64 ∧ (s.gpr .r8).toNat + 2176 ≤ 2 ^ 64 ∧ + (s.gpr .r9).toNat + 80 ≤ 2 ^ 64 ∧ + ((s.gpr .r4).toNat = 10 ∨ (s.gpr .r4).toNat = 12 ∨ (s.gpr .r4).toNat = 14) + post s s' := + Spec.Ctr.CryptFinal (ciphAt s.mem (s.gpr .r3) (s.gpr .r4).toNat) s.mem s'.mem (s.gpr .r5) (s.gpr .r6) + (s.gpr .r7).toNat + pub s₁ s₂ := + (s₁.gpr .r3 = s₂.gpr .r3 ∧ s₁.gpr .r4 = s₂.gpr .r4 ∧ s₁.gpr .r5 = s₂.gpr .r5 ∧ + s₁.gpr .r6 = s₂.gpr .r6 ∧ s₁.gpr .r7 = s₂.gpr .r7 ∧ s₁.gpr .r8 = s₂.gpr .r8 ∧ + s₁.gpr .r9 = s₂.gpr .r9 ∧ s₁.sp = s₂.sp) ∧ + Spec.Ctr.ctrLeak s₁.mem (s₁.gpr .r5) = Spec.Ctr.ctrLeak s₂.mem (s₂.gpr .r5) + +/-- The contract the frame needs: the shared one, with `save`, 80 bytes, as +a seventh argument, and no stack (a call stores nothing in memory). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract PPC64LE.abi Spec.Ctr.aesFinalSig "save" .u64 10 (finalPre PPC64LE.abi.ptrBits) + (finalPost PPC64LE.abi.ptrBits) false 0 (some (finalLeak PPC64LE.abi.ptrBits)) + +/-- A state satisfying the precondition. -/ +def ctrSat : State := { finalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩, ⟨0x6000, 80⟩] } + +theorem final_implies : ctrFinalPPC64LE.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, Spec.Ctr.ctrLeak, ctrFinalPPC64LE, PPC64LE.abi, + PPC64LE.argRegs] [ctrSat, finalSat] using ctrSat + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`, the registers then the block. -/ +abbrev cSv : Region := ⟨fV s₀, 80⟩ +/-- The block after the registers in `save`. -/ +abbrev cBk : Addr := fV s₀ + BitVec.ofNat 64 64 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + rd : s₀.rd = [fSch s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_scr : (fSch s₀).Disjoint (fScr s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_scr : (fIvR s₀).Disjoint (fScr s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + data_scr : (fData s₀).Disjoint (fScr s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + scr_sv : (fScr s₀).Disjoint (cSv s₀) + sch_wrap : (fW s₀).toNat + 240 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + scr_wrap : (fS s₀).toNat + 2176 ≤ 2 ^ 64 + sv_wrap : (fV s₀).toNat + 80 ≤ 2 ^ 64 + rounds : fR s₀ = 10 ∨ fR s₀ = 12 ∨ fR s₀ = 14 + +theorem CPre.of {s₀ : State} (h : ctrFinalPPC64LE.pre s₀) : CPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ + +/-! ## Regions -/ + +theorem sv64_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem CPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem CPre.sched_sub : Region.Sub ⟨fW s₀, 16 * (fR s₀ + 1)⟩ (fSch s₀) := + Region.sub_prefix (by rcases hp.rounds with h | h | h <;> omega) + +theorem CPre.sched_len : 16 * (fR s₀ + 1) ≤ 2 ^ 64 := by + rcases hp.rounds with h | h | h <;> omega + +end + +/-- The save changes only `save`. -/ +theorem svMem_frame' (s₀ : State) : Frame [cSv s₀] s₀.mem (svMem s₀) := + (svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨fV s₀ + BitVec.ofNat 64 p.2, 8⟩ (cBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +/-! ## Saving the registers, and the whole blocks -/ + +theorem final_setup_wp {s₀ : State} (hp : CPre s₀) : WP isa (.block finalSetup) s₀ (Setup s₀) := by + show WP isa (.block (.mflr .r0 :: (Spill.saveCode .r9 finalSaved ++ Impl.AesCfb.PPC64LE.finalMoves))) _ _ + refine WP.cons exec_mflr (Spill.save_ok (b := .r9) (l := finalSaved) (by decide) saved_fits + (fun p hp' => ?_) ?_) + · show InRegions s₀.wr (fV s₀ + BitVec.ofNat 64 p.2) 8 + rw [hp.wr] + have := saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + refine moves_wp fun s' r14 r15 r16 r19 r20 r31 r30 r7 keep mem rd wr => ?_ + have g₀ (r : Reg) (hr : r ≠ .r0) : (s₀.write .r0 s₀.lr).gpr r = s₀.gpr r := by + simp [State.write, hr] + have k (r : Reg) (h₁ : r ≠ .r14) (h₂ : r ≠ .r15) (h₃ : r ≠ .r16) (h₄ : r ≠ .r19) (h₅ : r ≠ .r20) + (h₆ : r ≠ .r10) (h₇ : r ≠ .r11) (h₈ : r ≠ .r31) (h₉ : r ≠ .r30) (h₁₀ : r ≠ .r7) (h₀ : r ≠ .r0) : + s'.gpr r = s₀.gpr r := (keep r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ h₉ h₁₀).trans (g₀ r h₀) + exact { + r14 := r14.trans (g₀ .r3 (by decide)) + r15 := r15.trans (g₀ .r4 (by decide)) + r16 := r16.trans (g₀ .r5 (by decide)) + r19 := r19.trans (g₀ .r8 (by decide)) + r20 := r20.trans (g₀ .r9 (by decide)) + r30 := by rw [r30, g₀ .r7 (by decide), shr4_shl4, sub_shl4] + r31 := by rw [r31, g₀ .r6 (by decide), g₀ .r7 (by decide), shr4_shl4] + r3 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) + r4 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) + r5 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) + r6 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) + r7 := by rw [r7, g₀ .r7 (by decide), shr4] + r8 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) (by decide) + kept := fun r hr hv => by + obtain ⟨h7, -, -, h10, h11, h14, h15, h16, h19, h20, h30, h31⟩ := Proof.AesCfb.PPC64LE.Final.preserved_ne' hr hv + exact k r h14 h15 h16 h19 h20 h10 h11 h31 h30 h7 (preserved_ne_r0 r hr) + mem := mem + rd := rd + wr := wr } + +theorem crypt_noFrames : crypt.noFrames = true := by + simp only [crypt, Impl.AesCbc.PPC64LE.whole, Impl.AesCtr.PPC64LE.body, Impl.AesCtr.PPC64LE.ctrCall, + Code.noFrames, Bool.true_and, Bool.and_true] + exact Proof.AesCtr.PPC64LE.ctr32_noFrames + +/-- The whole-block function's contract: `modePPC64LE ctrMode`, with the +last 32 bits of the counter block public. -/ +abbrev wholeK : Contract isa := { modePPC64LE AesCtr.ctrMode with pub := ctrPub } + +theorem whole_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, fBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, fBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, fBlk s₀, fScr s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [modePPC64LE, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r8 ∉ linkRegs), + h.r3, h.r4, h.r5, h.r6, h.r7, h.r8, toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), hp.sch_scr, + hp.iv_data.sub_right (blk_sub s₀), hp.iv_scr, hp.data_scr.sub_left (blk_sub s₀), + hp.iv_wrap, hp.blk_wrap, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- The schedule, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : CPre s₀) : + bytesAt (svMem s₀) (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ ∧ bytesAt (svMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ + Spec.Cbc.blocksAt (svMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame' s₀ + exact ⟨Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv.sub_left hp.sched_sub) hp.sched_len, + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +theorem whole_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WP isa wholeCall s (Whole AesCtr.ctrMode s₀) := by + obtain ⟨eW, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.call (k := wholeK) crypt_correct (rd := [fSch s₀]) (wr := [fIvR s₀, fBlk s₀, fScr s₀]) hpre + hc hw ?_ crypt_noFrames + intro s' rd' wr' _ fr' cs' _ post₂ + rw [h.mem] at fr' + simp only [modePPC64LE, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), h.r3, h.r4, h.r5, h.r6, h.r7, + toNat_n, h.mem, eW, eIv, eB] at post₂ + exact ⟨by rw [cs' .r14 (by decide), h.r14], by rw [cs' .r15 (by decide), h.r15], + by rw [cs' .r16 (by decide), h.r16], by rw [cs' .r19 (by decide), h.r19], + by rw [cs' .r20 (by decide), h.r20], by rw [cs' .r30 (by decide), h.r30], + by rw [cs' .r31 (by decide), h.r31], + fun r hr hv => by rw [cs' r hr, h.kept r hr hv], + by rw [rd', h.rd], by rw [wr', h.wr], fr', post₂.1, post₂.2⟩ + +/-! ## The partial last block: its arguments -/ + +/-- Two zeroed doublewords make 16 zero bytes. -/ +theorem zero_bytes (m : Mem) (B : Addr) : + bytesAt ((m.writeW B (0 : BitVec 64)).writeW (B + BitVec.ofNat 64 8) (0 : BitVec 64)) B 16 = + List.replicate 16 0 := by + apply List.ext_getElem (by simp [bytesAt]) + intro i h₁ _ + have hi : i < 16 := by simpa [bytesAt] using h₁ + simp only [bytesAt, List.getElem_map, List.getElem_range, List.getElem_replicate, Mem.writeW, Mem.write, + Mem.sub_ofNat_toNat B (show i < 2 ^ 64 by omega), Offset.sub_toNat' B (show 8 < 2 ^ 64 by decide) + (show i < 2 ^ 64 by omega)] + by_cases h8 : 8 ≤ i + · rw [ite_eq_left h8, ite_eq_left (by omega)]; simp + · rw [ite_eq_right h8, ite_eq_right (by omega), ite_eq_left (by omega)]; simp + +/-- The arguments of the whole-block function on the block. -/ +theorem tailMoves_wp {s : State} {Φ : State → Prop} + (k : ∀ s', s'.gpr .r3 = s.gpr .r14 → s'.gpr .r4 = s.gpr .r15 → s'.gpr .r5 = s.gpr .r16 → + s'.gpr .r6 = s.gpr .r20 + BitVec.ofNat 64 64 → s'.gpr .r7 = BitVec.ofNat 64 1 → + s'.gpr .r8 = s.gpr .r19 → + (∀ r, r ≠ .r3 → r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → r ≠ .r7 → r ≠ .r8 → s'.gpr r = s.gpr r) → + s'.mem = s.mem → s'.rd = s.rd → s'.wr = s.wr → Φ s') : + WP isa (.block tailMoves) s Φ := by + unfold tailMoves Impl.AesCbc.PPC64LE.mov + refine wp_mr fun s₁ u₁ => wp_mr fun s₂ u₂ => wp_mr fun s₃ u₃ => wp_addi (by decide) (by decide) fun s₄ u₄ => + wp_li (by decide) fun s₅ u₅ => wp_mr fun s₆ u₆ => wp_nil ?_ + refine k s₆ ?_ ?_ ?_ ?_ ?_ ?_ (fun r h₃ h₄ h₅ h₆ h₇ h₈ => ?_) ?_ ?_ ?_ + all_goals try (simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, + reduceCtorEq, ↓reduceIte]; done) + · simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, h₃, h₄, h₅, h₆, h₇, + h₈, ↓reduceIte] + · rw [u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + · rw [u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-! ## Frames -/ + +section +variable (s₀ : State) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, fScr s₀, cBlk s₀] +/-- What the function writes after saving the registers. -/ +abbrev cW : List Region := [fIvR s₀, fData s₀, fScr s₀, cBlk s₀] +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + +end + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem whole_cW1 {M : Mode} {s₀ s : State} (h : Whole M s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame' s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩) + +theorem CPre.sched_big {s₀ : State} (hp : CPre s₀) : + ∀ r ∈ cBig s₀, (⟨fW s₀, 16 * (fR s₀ + 1)⟩ : Region).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv.sub_left hp.sched_sub + · exact hp.sch_data.sub_left hp.sched_sub + · exact hp.sch_scr.sub_left hp.sched_sub + · exact hp.sch_sv.sub_left hp.sched_sub + +/-! ## The partial last block -/ + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + r3 : s.gpr .r3 = fW s₀ + r4 : s.gpr .r4 = s₀.gpr .r4 + r5 : s.gpr .r5 = fIv s₀ + r6 : s.gpr .r6 = cBk s₀ + r7 : s.gpr .r7 = BitVec.ofNat 64 1 + r8 : s.gpr .r8 = fS s₀ + r20 : s.gpr .r20 = fV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [cBlk s₀] m (Spill.saveMem m (fV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +theorem preserved_ne_args {r : Reg} (hr : r ∈ preserved) : + r ≠ .r3 ∧ r ≠ .r4 ∧ r ≠ .r5 ∧ r ≠ .r6 ∧ r ≠ .r7 ∧ r ≠ .r8 ∧ r ≠ .r9 := by + revert hr; cases r <;> decide + +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block tailArgs) s (TArgs s₀) := by + have f₁ := whole_cW1 h + show WP isa (.block (.li .r9 0 :: (Spill.saveCode .r20 zeroSlots ++ tailMoves))) _ _ + refine wp_li (by decide) fun s₁ u₁ => ?_ + have h20 : s₁.gpr .r20 = fV s₀ := by rw [u₁.other _ (by decide), h.r20] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .r20 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [u₁.wr, h.wr, hp.wr, h20] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + refine Spill.save_ok (by decide) (by decide) hw ?_ + refine tailMoves_wp fun s' r3 r4 r5 r6 r7 r8 o mem rd wr => ?_ + have c (r : Reg) (hr : r ∈ preserved) : s'.gpr r = s.gpr r := by + obtain ⟨h3, h4, h5, h6, h7, h8, h9⟩ := preserved_ne_args hr + rw [o r h3 h4 h5 h6 h7 h8] + exact u₁.other r h9 + have hm : s'.mem = Spill.saveMem s.mem (fV s₀) s₁.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₁.mem _ _ _ = _; rw [u₁.mem, h20] + have fz : Frame [cBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have g₁ (r : Reg) (hr : r ≠ .r9) : s₁.gpr r = s.gpr r := u₁.other r hr + refine ⟨by rw [r3, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r14], + by rw [r4, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r15], + by rw [r5, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r16], + by rw [r6, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, h20], + r7, + by rw [r8, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r19], + by rw [c .r20 (by decide), h.r20], by rw [c .r30 (by decide), h.r30], by rw [c .r31 (by decide), h.r31], + fun r hr hv => by rw [c r hr, h.kept r hr hv], + by rw [rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, u₁.rd, h.rd], + by rw [wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, u₁.wr, h.wr], ?_, ?_, ?_, ?_⟩ + · exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + · have z₁ : s₁.gpr .r9 = (0 : BitVec 64) := u₁.gpr + rw [hm, show Spill.saveMem s.mem (fV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (cBk s₀) (s₁.gpr .r9)).writeW (cBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .r9)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z₁] + exact zero_bytes _ _ + +theorem one_toNat : (BitVec.ofNat 64 1).toNat = 1 := rfl + +theorem cBk_toNat {s₀ : State} (hp : CPre s₀) : (cBk s₀).toNat = (fV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem tail_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, cBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, cBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, cBlk s₀, fScr s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [modePPC64LE, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r8 ∉ linkRegs), + h.r3, h.r4, h.r5, h.r6, h.r7, h.r8, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.sch_scr, hp.iv_sv.sub_right bs, hp.iv_scr, + (hp.scr_sv.sub_right bs).symm, hp.iv_wrap, by rw [cBk_toNat hp]; omega, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 64, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 64, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + r20 : s.gpr .r20 = fV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBk s₀) 16 = Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem tail_call_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + WP isa wholeCall s (TCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (cW1_cW h.frame) + have eW : bytesAt s.mem (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ := + Proof.Cmac.bytesAt_frame big hp.sched_big hp.sched_len + refine WP.call (k := wholeK) crypt_correct (rd := [fSch s₀]) (wr := [fIvR s₀, cBlk s₀, fScr s₀]) hpre + hc hw ?_ crypt_noFrames + intro s' rd' wr' _ fr' cs' _ post₂ + simp only [modePPC64LE, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), h.r3, h.r4, h.r5, h.r6, h.r7, + one_toNat, eW, h.ctr, AesCtr.ctrMode_out, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] at post₂ + refine ⟨by rw [cs' .r20 (by decide), h.r20], by rw [cs' .r30 (by decide), h.r30], + by rw [cs' .r31 (by decide), h.r31], fun r hr hv => by rw [cs' r hr, h.kept r hr hv], + by rw [rd', h.rd], by rw [wr', h.wr], ?_, ?_, post₂.2, ?_⟩ + · exact h.frame.trans (fr'.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + · rw [blocksAt_frame' fr' fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (aesWith_length _ _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + r20 : s.gpr .r20 = fV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.r20, h.kept, h.rd, h.wr, cW1_cW (whole_cW1 h), h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt]⟩ + +theorem toNat_tail {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +/-- The XOR of the partial last block. -/ +abbrev xorCode : Prog isa := + .seq (.block tailKey) (.loop (.block Impl.Modes.PPC64LE.tailByte) (.nonzero .d .r30)) + +theorem tail_xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa xorCode s (Done s₀) := by + refine WP.seq (wp_addi (by decide) (by decide) fun s₁ u₁ => wp_nil ?_) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have hB := cBk_toNat hp + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : Proof.Modes.PPC64LE.XPre s₁ (cBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fitK := by omega + fitR := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [u₁.rd, u₁.wr, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [u₁.wr, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : Proof.Modes.PPC64LE.XInv s₁ (cBk s₀) (fT s₀) (fU s₀) 0 s₁ := { + r8 := by rw [u₁.gpr, h.r20]; exact (BitVec.add_zero _).symm + r31 := by rw [u₁.other _ (by decide), h.r31]; exact (BitVec.add_zero _).symm + r30 := by rw [u₁.other _ (by decide), h.r30, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Proof.Modes.PPC64LE.tailLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact hp.data_scr.sub_left (tail_sub s₀) + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (sv64_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have df : Frame [fTail s₀] s.mem s'.mem := by rw [← u₁.mem]; exact d.frame + have g (r : Reg) (h8 : r ≠ .r8) (h9 : r ≠ .r9) (h10 : r ≠ .r10) (h30 : r ≠ .r30) (h31 : r ≠ .r31) : + s'.gpr r = s.gpr r := by + rw [d.gpr r h8 h9 h10 h30 h31, u₁.other r h8] + refine ⟨by rw [g .r20 (by decide) (by decide) (by decide) (by decide) (by decide), h.r20], + fun r hr hv => ?_, by rw [d.rd, u₁.rd, h.rd], by rw [d.wr, u₁.wr, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · obtain ⟨-, h8, h9, h10, -, -, -, -, -, -, h30, h31⟩ := Proof.AesCfb.PPC64LE.Final.preserved_ne' hr hv + rw [g r h8 h9 h10 h30 h31, h.kept r hr hv] + · exact (cW1_cW h.frame).trans (df.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' df fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact h.blocks + · rw [d.data q hq, u₁.mem, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (cBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame df ivT (by decide), h.ctr, ← AesCtr.next_add] + +theorem final_mid_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.ite (.zero .d .r30) (.block []) finalTail) s (Done s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem final_end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block finalRestore) s fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.lr = s₀.lr ∧ s'.mem = s.mem := by + have hs : Spill.Saved (fV s₀) (saveG s₀) finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (fV s₀) (saveG s₀)).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨fV s₀ + BitVec.ofNat 64 p.2, 8⟩ (cSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact hp.scr_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + rw [restore_eq] + refine Spill.restore_ok (b := .r20) (l := finalSaved) (by decide) h.r20 saved_fits (by decide) + (fun p hp' => ?_) hs fun s₃ r₃ => ?_ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + refine WP.cons exec_mtlr (wp_nil ⟨fun r hr => ?_, ?_, r₃.mem⟩) + · show s₃.gpr r = _ + have h0 : saveG s₀ r = s₀.gpr r := by + show (s₀.write .r0 s₀.lr).gpr r = _ + simp [State.write, preserved_ne_r0 r hr] + rw [r₃.gpr_of (r := r) ?_, h0] + by_cases hv : r ∈ vars + · left + simp only [vars, List.mem_cons, List.not_mem_nil, or_false] at hv + rcases hv with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide + · right; rw [h.kept r hr hv, h0] + · show s₃.gpr .r0 = _ + rw [r₃.gpr (.r0, 0) (by decide)]; rfl + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : CPre s₀) : + WP isa cryptFinal s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.lr = s₀.lr ∧ ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (final_setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (final_mid_wp hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (final_end_wp hp h₃) fun _ ⟨g, l, m⟩ => ⟨g, l, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalPPC64LE.post s₀ s' := by + show Spec.Ctr.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalPPC64LE.pre s) : + ∃ t s', Exec isa cryptFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalPPC64LE.post s s' := by + obtain ⟨t, s', he, hg, hl, s₁, h₁, hm⟩ := final_wp (CPre.of hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hl⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +/-- Counter blocks whose last 32 bits agree still do after `k` increments. -/ +theorem lo32_next_of {t t' : List Byte} (ht : t.length = 16) (ht' : t'.length = 16) + (h : AesCtr.lo32 t = AesCtr.lo32 t') (k : Nat) : + AesCtr.lo32 (Spec.Ctr.next t k) = AesCtr.lo32 (Spec.Ctr.next t' k) := by + rw [AesCtr.lo32_next ht, AesCtr.lo32_next ht'] + unfold AesCtr.lo32 at h + omega + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7, .r8, .r9]) + (.block finalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.r14, .r15, .r16, .r19, .r20]) + (.block tailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.r20, .r30, .r31]) xorCode h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.r20]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalPPC64LE.pre s₀) (h0' : ctrFinalPPC64LE.pre s₀') + (hq : ctrFinalPPC64LE.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') cryptFinal fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + obtain ⟨⟨qW, qR, qIv, qD, qL, qS, qV, qSp⟩, qLk⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + have qLo : AesCtr.lo32 (fIv0 s₀) = AesCtr.lo32 (fIv0 s₀') := + AesCtr.lo32_of_leak (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLk + -- The registers saved and the arguments set up. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := (taintRegs (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + refine ⟨qSp, fun r hr => ?_⟩ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) t₁).wp + (F₁ := fun (s : State) => Setup s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => Setup s₀' s ∧ s.sp = s₀'.sp) + fun a b h => by + obtain ⟨rfl, rfl⟩ := h + exact ⟨wp_sp (final_setup_wp hp), wp_sp (final_setup_wp hp')⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr") crypt_correct crypt_ct + (P := fun a b => (Setup s₀ a ∧ a.sp = s₀.sp) ∧ (Setup s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha.1 + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb.1 + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb⟩ + · simp only [modePPC64LE, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_gpr' _ (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r7 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r8 ∉ linkRegs), + ha.1.r3, ha.1.r4, ha.1.r5, ha.1.r6, ha.1.r7, ha.1.r8, ha.2, + hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.1.r7, hb.1.r8, hb.2] + rw [fW, fW, fIv, fIv, fD, fD, fS, fS, qW, qR, qIv, qD, qS, qSp, qN] + exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩ + · simp only [AesCbc.PPC64LE.iv0, AesCbc.PPC64LE.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_mem, callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), ha.1.r5, hb.1.r5, + ha.1.mem, hb.1.mem] + rw [(sv_bytes hp).2.1, (sv_bytes hp').2.1] + exact qLo).wp + (F₁ := fun (s : State) => Whole AesCtr.ctrMode s₀ s ∧ s.sp = s₀.sp) + (F₂ := fun (s : State) => Whole AesCtr.ctrMode s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (whole_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (whole_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + -- The partial last block. + obtain ⟨_, t₃⟩ := tailArgs_taint + obtain ⟨_, t₄⟩ := xor_taint + have tail (hu : fU s₀ ≠ 0) : RelCT isa + (fun a b => (Whole AesCtr.ctrMode s₀ a ∧ a.sp = s₀.sp) ∧ (Whole AesCtr.ctrMode s₀' b ∧ b.sp = s₀'.sp)) + finalTail fun a b => (Done s₀ a ∧ a.sp = s₀.sp) ∧ (Done s₀' b ∧ b.sp = s₀'.sp) := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := (taintRegs + (P := fun a b => (Whole AesCtr.ctrMode s₀ a ∧ a.sp = s₀.sp) ∧ (Whole AesCtr.ctrMode s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · rw [h.1.1.r14, h.2.1.r14, fW, fW, qW] + · rw [h.1.1.r15, h.2.1.r15, qR] + · rw [h.1.1.r16, h.2.1.r16, fIv, fIv, qIv] + · rw [h.1.1.r19, h.2.1.r19, fS, fS, qS] + · rw [h.1.1.r20, h.2.1.r20, fV, fV, qV]⟩) t₃).wp + (F₁ := fun (s : State) => TArgs s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => TArgs s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_args_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_args_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + have a₂ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr") crypt_correct crypt_ct + (P := fun a b => (TArgs s₀ a ∧ a.sp = s₀.sp) ∧ (TArgs s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha.1 + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb.1 + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb⟩ + · simp only [modePPC64LE, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_gpr' _ (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r7 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r8 ∉ linkRegs), + ha.1.r3, ha.1.r4, ha.1.r5, ha.1.r6, ha.1.r7, ha.1.r8, ha.2, + hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.1.r7, hb.1.r8, hb.2] + rw [fW, fW, fIv, fIv, cBk, cBk, fV, fV, fS, fS, qW, qR, qIv, qV, qS, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial + · simp only [AesCbc.PPC64LE.iv0, AesCbc.PPC64LE.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_mem, callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), ha.1.r5, hb.1.r5] + rw [ha.1.ctr, hb.1.ctr, qN] + exact lo32_next_of (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLo _).wp + (F₁ := fun (s : State) => TCall s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => TCall s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_call_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_call_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + have a₃ := (taintRegs + (P := fun a b => (TCall s₀ a ∧ a.sp = s₀.sp) ∧ (TCall s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.1.r20, h.2.1.r20, fV, fV, qV] + · rw [h.1.1.r30, h.2.1.r30, qU] + · rw [h.1.1.r31, h.2.1.r31, qT]⟩) t₄).wp + (F₁ := fun (s : State) => Done s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => Done s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_xor_wp hp h.1.1 hu)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_xor_wp hp' h.2.1 hu')) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + exact (a₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq + ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₃.mono (fun _ _ h => h) fun _ _ h => h.2)) + have r₃ : RelCT isa + (fun a b => (Whole AesCtr.ctrMode s₀ a ∧ a.sp = s₀.sp) ∧ (Whole AesCtr.ctrMode s₀' b ∧ b.sp = s₀'.sp)) + (.ite (.zero .d .r30) (.block []) finalTail) + (fun a b => (Done s₀ a ∧ a.sp = s₀.sp) ∧ (Done s₀' b ∧ b.sp = s₀'.sp)) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1.1, eval_u h.2.1, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1.1] at this; simpa using this + exact ⟨⟨done_of_zero h.1.1.1 h0, h.1.1.2⟩, ⟨done_of_zero h.1.2.1 (qU ▸ h0), h.1.2.2⟩⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1.1] at this; simpa using this + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := taintRegs + (P := fun a b => (Done s₀ a ∧ a.sp = s₀.sp) ∧ (Done s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.r20, h.2.1.r20, fV, fV, qV]⟩) t₅ + exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq + (r₃.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalPPC64LE.pre ctrFinalPPC64LE.pub cryptFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem cryptFinal_verified : Verified PPC64LE.target cryptFinal finalScratchContract := + Verified.of_correct final_correct final_ct final_implies + +/-! ## With `save` on the stack + +The final function has six argument words, so `save` is its seventh, in +`r9`: it runs its code in a frame of 112 bytes on the stack +(`withStackScratchWiped`), its 32-byte header and `save`'s 80 bytes (the +registers, then the block that held the last output block), which it zeroes +before returning. The code's calls use no stack, so 112 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract PPC64LE.abi (0 + 112)).pre s := by + implies_sat [finalRoundsContract, Spec.Ctr.aesFinalSig, finalPre, finalPost, PPC64LE.abi, + PPC64LE.argRegs] [finalFrameSat, finalSat] using finalFrameSat + +theorem cryptFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 112 .r9 10 cryptFinal) + (finalRoundsContract PPC64LE.abi 112) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Ctr.aesFinalSig) (nm := "save") (e := .u64) (n := 10) + (pre := finalPre PPC64LE.abi.ptrBits) (post := finalPost PPC64LE.abi.ptrBits) (wa := false) + (leak := some (finalLeak PPC64LE.abi.ptrBits)) + (stack := 0) (bytes := 112) (words := 10) cryptFinal_verified (by decide) (by decide) (by decide) + (finalPre_local _) (finalPost_local _) (finalPost_localOut _) frameSat_pre (hleak := finalLeak_local _) + +end VG.Proof.AesCtr.PPC64LE.Final diff --git a/lean/VerifiedGarbage/Proof/AesOfb/PPC64LE/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/PPC64LE/Final.lean new file mode 100644 index 00000000000..b54a01abdce --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/PPC64LE/Final.lean @@ -0,0 +1,115 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.PPC64LE.Final +public import VerifiedGarbage.Proof.AesOfb.Final +public import VerifiedGarbage.Proof.AesOfb.PPC64LE.Verified +public import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.PPC64LE +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +import VerifiedGarbage.Proof.AesOfb.PPC64LE.Body +import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT + +/-! +# AES-OFB of a message's last piece on PPC64LE + +`cryptFinal_framed`: `vg_aes_ofb_final` (`Impl/AesOfb/PPC64LE/Final.lean`) +meets `Proof.AesOfb.finalRoundsContract`, from which the shared contract +follows (`Proof.AesOfb.final_keyed`). + +Its code is AES-CFB's final function around a call of the whole-block +AES-OFB function, so its proof is AES-CFB's (`Proof/AesCfb/PPC64LE/Final.lean`), +for OFB as a `Mode` (`ofbMode`): `final_wp` runs it, for any mode, to what it +leaves before restoring the registers (`Done`); `final_ct` gives its +constant time. `ofbFinalPPC64LE` is AES-CFB's code contract with OFB's +postcondition, which `final_post` gives from `Done` by +`Proof.AesOfb.cryptFinal_of`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb.PPC64LE + +open VG VG.PPC64LE +open VG.Spec.Aes (bytesAt) +open VG.Proof.AesCfb.PPC64LE.Final (finalPPC64LE FPre Done fW fR fIv fD fL fN fU fT fWk fIv0 fBlks final_wp + final_ct finalSat finalFrameSat) +open VG.Proof.AesCbc.PPC64LE (modePPC64LE) +open VG.Impl.AesOfb.PPC64LE + +/-- The code's contract, with the arguments `(schedule = r3, rounds = r4, +iv = r5, data = r6, len = r7, scratch = r8, save = r9)`: AES-CFB's final +functions' (`finalPPC64LE`), with the data and the block at `iv` as +`Spec.Ofb.CryptFinal` says, by AES with the key schedule it is given. -/ +def ofbFinalPPC64LE : Contract isa := + { finalPPC64LE true with + post := fun s s' => Spec.Ofb.CryptFinal (ciphAt s.mem (s.gpr .r3) (s.gpr .r4).toNat) 16 s.mem s'.mem + (s.gpr .r5) (s.gpr .r6) (s.gpr .r7).toNat } + +/-- The contract the frame needs: the shared one, with `save`, 64 bytes, as +a seventh argument, and no stack (a call stores nothing in memory). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract PPC64LE.abi Spec.Ofb.aesFinalSig "save" .u64 8 (finalPre PPC64LE.abi.ptrBits) + (finalPost PPC64LE.abi.ptrBits) false 0 + +theorem final_implies : ofbFinalPPC64LE.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, ofbFinalPPC64LE, finalPPC64LE, PPC64LE.abi, + PPC64LE.argRegs] [finalSat] using finalSat + +/-- `Spec.Ofb.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done ofbMode s₀ s₁) (hm : s'.mem = s₁.mem) : + ofbFinalPPC64LE.post s₀ s' := by + show Spec.Ofb.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) 16 s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + have e := AesCbc.length_blocksAt s₀.mem (fD s₀) (fN s₀) + have hb := h.blocks + have ht := h.tail + have hi := h.iv + rw [ofbMode_out] at hb + rw [ofbMode_chain, e] at ht hi + exact cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact hb) (fun q hq => by rw [hm]; exact ht q hq) + (by rw [hm]; exact hi) + +/-! ## The code's properties -/ + +theorem crypt_noFrames : crypt.noFrames = true := by + simp only [crypt, Impl.AesCbc.PPC64LE.whole, body, Impl.AesCbc.PPC64LE.encCall, Code.noFrames, + Bool.true_and, Bool.and_true] + exact Proof.AesCbc.PPC64LE.encryptBlocks_noFrames + +theorem final_correct (s : State) (hs : ofbFinalPPC64LE.pre s) : + ∃ t s', Exec isa cryptFinal s t s' ∧ abiPreserved s s' ∧ ofbFinalPPC64LE.post s s' := by + obtain ⟨t, s', he, hg, hl, s₁, h₁, hm⟩ := + final_wp (M := ofbMode) crypt_correct crypt_noFrames (FPre.of (enc := true) hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hl⟩, final_post h₁ hm⟩ + +/-! ## Verified -/ + +theorem cryptFinal_verified : Verified PPC64LE.target cryptFinal finalScratchContract := + Verified.of_correct final_correct + (final_ct (enc := true) crypt_correct (AesCbc.PPC64LE.whole_ct body_ok body_ct) crypt_noFrames) + final_implies + +/-! ## With `save` on the stack + +As AES-CFB's final functions, the code runs in a frame of 96 bytes on the +stack (`withStackScratchWiped`), its 32-byte header and `save`'s 64 bytes, +which it zeroes before returning. Its calls use no stack, so 96 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract PPC64LE.abi (0 + 96)).pre s := by + implies_sat [finalRoundsContract, Spec.Ofb.aesFinalSig, finalPre, finalPost, PPC64LE.abi, + PPC64LE.argRegs] [finalFrameSat, finalSat] using finalFrameSat + +theorem cryptFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 96 .r9 8 cryptFinal) + (finalRoundsContract PPC64LE.abi 96) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Ofb.aesFinalSig) (nm := "save") (e := .u64) (n := 8) + (pre := finalPre PPC64LE.abi.ptrBits) (post := finalPost PPC64LE.abi.ptrBits) (wa := false) + (stack := 0) (bytes := 96) (words := 8) cryptFinal_verified (by decide) (by decide) (by decide) + (finalPre_local _) (finalPost_local _) (finalPost_localOut _) frameSat_pre + +end VG.Proof.AesOfb.PPC64LE diff --git a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean new file mode 100644 index 00000000000..8ce56bd4513 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean @@ -0,0 +1,1063 @@ +module + +public import VerifiedGarbage.Impl.Camellia.PPC64LE.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrScratch +public import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesVerified +public import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.PPC64LE.Spill +public import VerifiedGarbage.Proof.Framework.PPC64LE.CallAny +public import VerifiedGarbage.Impl.StackScratch.PPC64LE +import VerifiedGarbage.Proof.AesCtr.PPC64LE.Final +import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesFrame +import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesLit +import VerifiedGarbage.Proof.Camellia.PPC64LE.Lit +import VerifiedGarbage.Proof.Camellia.Scratch +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.PPC64LE.Call +import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.Lit +import VerifiedGarbage.Proof.Framework.PPC64LE.Lit +import VerifiedGarbage.Proof.Framework.PPC64LE.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.PPC64LE.Step +import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +import VerifiedGarbage.Proof.Framework.PPC64LE.Taint +import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.Camellia.PPC64LE.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrScratch +meta import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesVerified +meta import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Spill +meta import VerifiedGarbage.Proof.Framework.PPC64LE.CallAny +meta import VerifiedGarbage.Impl.StackScratch.PPC64LE +meta import VerifiedGarbage.Proof.AesCtr.PPC64LE.Final +meta import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesFrame +meta import VerifiedGarbage.Proof.Camellia.PPC64LE.ModesLit +meta import VerifiedGarbage.Proof.Camellia.PPC64LE.Lit +meta import VerifiedGarbage.Proof.Camellia.Scratch +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCbc.PPC64LE.Call +meta import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.Lit +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit +meta import VerifiedGarbage.Proof.Framework.PPC64LE.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Step +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Taint +meta import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# Camellia-CTR of a message's last piece on PPC64LE + +`ctrFinal_framed`: `vg_camellia_ctr_final` (`Impl/Camellia/PPC64LE/CtrFinal.lean`) +meets `Spec.Camellia.ctrFinalContract`, from `Proof.Camellia.ctrFinalContractSk` +(`Proof.Camellia.ctrFinal_of_sk`). + +The code is proven against `ctrFinalPPC64LE`, with the arguments +`(schedule = r3, rounds = r4, ctr = r5, data = r6, len = r7, save = r8)`, a +sixth argument `save` (`r8`) of 80 bytes for its return address and its +caller's registers and a block of its own, and 3408 bytes of stack for its +calls (`ctrFinal_implies`: the shared contract with it), as a caller of +`vg_camellia_ctr`, framed by its own working space on the stack +(`ctrFramed`), through a contract of its own, `ctrF`, which the callee's +shared contract implies (`ctrF_implies`), with `WP.callAny` (the callee's +frame is the 3408 bytes below the stack pointer, `ctr_sdepth`). It is AES-CTR's +final function's proof (`Proof/AesCtr/PPC64LE/Final.lean`) with Camellia's +arguments: + +* `setup_wp`, `whole_wp`: the return address and the registers saved in + `save`, whose address is kept in `r20`, and the call on the + `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.PPC64LE.tailLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers and the return address restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`), by Camellia with the subkeys at + `schedule`. + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. + +The frame of the registration needs the contract's precondition and +postcondition to read the memory on entry only within the function's +buffers (`ctrFinalPre_local`, `ctrFinalPost_local`). +-/ + +@[expose] public section + +namespace VG.Proof.Camellia.PPC64LE.CtrFinal + +open VG VG.PPC64LE +open VG.Spec.Aes (bytesAt) +open VG.Impl.Camellia.PPC64LE (ctrFramed ctrCall ctrFinalSave ctrFinalMoves ctrFinalSetup ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.PPC64LE (finalSaved finalRestore) +open VG.Impl.AesCtr.PPC64LE (zeroSlots tailKey) +open VG.Proof.AesCfb.PPC64LE.Final (fW fR fIv fD fL fN fU fT fData fBlk fTail fIv0 fBlks Kept vars + bytesAt_getD blocksAt_frame' saved_slots saved_fits blk_sub tail_sub fN_eq fU_eq n_lt u_lt toNat_n + shr4 shr4_shl4 sub_shl4 upd_gpr preserved_ne_r0 restore_eq) +open VG.Proof.AesCtr.PPC64LE.Final (zero_bytes one_toNat preserved_ne_args) +open VG.Proof.AesCbc.PPC64LE (callEntry_gpr' taintRegs wp_sp) + +/-! ## The callee -/ + +/-- `vg_camellia_ctr(schedule = r3, rounds = r4, ctr = r5, data = r6, n = r7)` +with its 3408 bytes of stack. -/ +def ctrF : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .r3, 272⟩ + let ctr : Region := ⟨s.gpr .r5, 16⟩ + let data : Region := ⟨s.gpr .r6, 16 * (s.gpr .r7).toNat⟩ + 3408 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data] ∧ sched.Disjoint ctr ∧ sched.Disjoint data ∧ + ctr.Disjoint data ∧ (below s.sp 3408).Disjoint sched ∧ (below s.sp 3408).Disjoint ctr ∧ + (below s.sp 3408).Disjoint data ∧ + (s.gpr .r3).toNat + 272 ≤ 2 ^ 64 ∧ (s.gpr .r5).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .r6).toNat + 16 * (s.gpr .r7).toNat ≤ 2 ^ 64 ∧ + ((s.gpr .r4).toNat = 18 ∨ (s.gpr .r4).toNat = 24) + post s s' := + Spec.Cbc.blocksAt s'.mem (s.gpr .r6) (s.gpr .r7).toNat = + Spec.Ctr.crypt (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (s.gpr .r3) (s.gpr .r4).toNat)) + (bytesAt s.mem (s.gpr .r5) 16) (Spec.Cbc.blocksAt s.mem (s.gpr .r6) (s.gpr .r7).toNat) ∧ + bytesAt s'.mem (s.gpr .r5) 16 = Spec.Ctr.next (bytesAt s.mem (s.gpr .r5) 16) (s.gpr .r7).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .r3 = s₂.gpr .r3 ∧ s₁.gpr .r4 = s₂.gpr .r4 ∧ s₁.gpr .r5 = s₂.gpr .r5 ∧ + s₁.gpr .r6 = s₂.gpr .r6 ∧ s₁.gpr .r7 = s₂.gpr .r7 + +/-- `vg_camellia_ctr` meets its contract on the subkeys. -/ +theorem ctrFramed_sk : Verified PPC64LE.target ctrFramed (Proof.Camellia.ctrContractSk PPC64LE.abi 3408) := + PPC64LE.Verified.stackScratchWiped (sig := Spec.Camellia.ctrSig) (nm := "scratch") (e := .u64) + (n := 422) (pre := Spec.Camellia.ctrPre PPC64LE.abi.ptrBits) + (post := Proof.Camellia.ctrPostSk PPC64LE.abi.ptrBits) (wa := true) (stack := 0) + (bytes := 3408) (words := 422) + (by rw [← Proof.Camellia.ctrScratchContract_eq]; exact Camellia.PPC64LE.Modes.ctr_verified) + (by decide) (by decide) (by decide) (Proof.Camellia.ctrPre_local _) + (Proof.Camellia.ctrPost_local _) (Proof.Camellia.ctrPostOut_local _) Camellia.PPC64LE.ctrFrameSat_pre + +theorem ctrF_implies : (Proof.Camellia.ctrContractSk PPC64LE.abi 3408).Implies ctrF where + pre s hs := by + sig_pre [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Spec.Camellia.ctrPre, PPC64LE.abi, + PPC64LE.argRegs] + simp only [Nat.mul_comm (s.gpr .r7).toNat 16] + exact hs + post s s' hs h := by + sig_reduce [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, Proof.Camellia.ctrPostSk, PPC64LE.abi, + PPC64LE.argRegs] at h + simp only [BitVec.setWidth_eq] at h + exact h hs.2.2.2.2.2.2.2.2.2.2.2.2 + pub s₁ s₂ _ _ h := by + sig_reduce [Proof.Camellia.ctrContractSk, Spec.Camellia.ctrSig, PPC64LE.abi, PPC64LE.argRegs] + obtain ⟨hsp, h0, h1, h2, h3, h4⟩ := h + exact ⟨hsp, fun _ _ => by rw [h0, h1, h2, h3, h4], fun _ hr => absurd hr List.not_mem_nil⟩ + sat := ⟨Camellia.PPC64LE.modeFrameSat, by + refine ⟨by decide, rfl, rfl, Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), by decide, by decide, by decide, by decide⟩⟩ + +/-- The callee's frame is the 3408 bytes below the stack pointer. -/ +theorem ctr_sdepth : sdepth ctrFramed = 3408 := by lit_decide + +theorem ctr_ok : ∀ s, ctrF.pre s → ∃ t s', Exec isa ctrFramed s t s' ∧ abiPreserved s s' ∧ ctrF.post s s' := + (ctrFramed_sk.of_implies ctrF_implies).1 + +theorem ctr_ct : ConstantTime isa ctrF.pre ctrF.pub ctrFramed := + (ctrFramed_sk.of_implies ctrF_implies).2.1 + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = r3, rounds = r4, +ctr = r5, data = r6, len = r7, save = r8)`, `save` of 80 bytes, and 3408 +bytes of stack for the calls: the data and the counter block as +`Spec.Ctr.CryptFinal` says, by Camellia with the subkeys at `schedule`. -/ +def ctrFinalPPC64LE : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .r3, 272⟩ + let ctr : Region := ⟨s.gpr .r5, 16⟩ + let data : Region := ⟨s.gpr .r6, (s.gpr .r7).toNat⟩ + let sv : Region := ⟨s.gpr .r8, 80⟩ + let stack := below s.sp 3408 + 3408 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .r3).toNat + 272 ≤ 2 ^ 64 ∧ (s.gpr .r5).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .r6).toNat + (s.gpr .r7).toNat ≤ 2 ^ 64 ∧ (s.gpr .r8).toNat + 80 ≤ 2 ^ 64 ∧ + ((s.gpr .r4).toNat = 18 ∨ (s.gpr .r4).toNat = 24) + post s s' := + Spec.Ctr.CryptFinal (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (s.gpr .r3) (s.gpr .r4).toNat)) + s.mem s'.mem (s.gpr .r5) (s.gpr .r6) (s.gpr .r7).toNat + pub s₁ s₂ := + s₁.gpr .r3 = s₂.gpr .r3 ∧ s₁.gpr .r4 = s₂.gpr .r4 ∧ s₁.gpr .r5 = s₂.gpr .r5 ∧ + s₁.gpr .r6 = s₂.gpr .r6 ∧ s₁.gpr .r7 = s₂.gpr .r7 ∧ s₁.gpr .r8 = s₂.gpr .r8 ∧ s₁.sp = s₂.sp + +/-- The contract the frame needs: the shared one on the subkeys, with `save`, +80 bytes, as a sixth argument, and 3408 bytes of stack (`vg_camellia_ctr`'s +frame). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract PPC64LE.abi Spec.Camellia.ctrFinalSig "save" .u64 10 + (Spec.Camellia.ctrFinalPre PPC64LE.abi.ptrBits) (Proof.Camellia.ctrFinalPostSk PPC64LE.abi.ptrBits) true 3408 + +/-- A state satisfying the precondition (no data, 18 rounds). -/ +def ctrFinalSat : State where + gpr r := match r with + | .r3 => 0x1000 | .r4 => 18 | .r5 => 0x2000 | .r6 => 0x3000 | .r8 => 0x4000 | _ => 0 + lr := 0 + sp := 0x8000 + mem _ := 0 + rd := [⟨0x1000, 272⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 80⟩] + +theorem ctrFinal_implies : ctrFinalPPC64LE.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, Proof.Camellia.ctrFinalPostSk, ctrFinalPPC64LE, + PPC64LE.abi, PPC64LE.argRegs] [ctrFinalSat] using ctrFinalSat + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .r8 +abbrev kSch : Region := ⟨fW s₀, 272⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 80⟩ +abbrev kSv64 : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 64 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below s₀.sp 3408 +/-- The values saved: `r0` holds the return address. -/ +abbrev kSaveG : Reg → BitVec 64 := (s₀.write .r0 s₀.lr).gpr +/-- The memory once the return address and the registers are saved. -/ +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) (kSaveG s₀) finalSaved +/-- The cipher on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Camellia.cipher (Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀)) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp : 3408 ≤ s₀.sp.toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 272 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 80 ≤ 2 ^ 64 + rounds : fR s₀ = 18 ∨ fR s₀ = 24 + +theorem KPre.of {s₀ : State} (h : ctrFinalPPC64LE.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18⟩ + +/-! ## Regions and frames -/ + +theorem sv64_sub (s₀ : State) : Region.Sub (kSv64 s₀) (kSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +end + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + (Spill.saveMem_frame_base (n := 64) (by decide) (by decide) _ _ _).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨kSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem KPre.sch_big {s₀ : State} (hp : KPre s₀) : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The subkeys, from memory that agrees with the entry's on the schedule. -/ +theorem subkeys_of {s₀ : State} (hp : KPre s₀) {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : + Spec.Camellia.subkeysAt m (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt m₀ (fW s₀) (fR s₀) := + Proof.Camellia.subkeysAt_congr (by rcases hp.rounds with h | h <;> rw [h] <;> decide) + fun i hi => hf.bytes (R := kSch s₀) hd (by show 272 ≤ 2 ^ 64; decide) hi + +/-- A call's frame, within the regions it was given and the stack. -/ +theorem call_frame {s₀ s s' : State} (hsp : s.sp = s₀.sp) {wr : List Region} + (hf : Frame (wr ++ [below s.sp (sdepth ctrFramed)]) s.mem s'.mem) : + Frame (wr ++ [kStk s₀]) s.mem s'.mem := by + rw [ctr_sdepth, hsp] at hf; exact hf + +/-! ## Saving the registers -/ + +theorem moves_wp {s : State} {Φ : State → Prop} + (k : ∀ s', s'.gpr .r14 = s.gpr .r3 → s'.gpr .r15 = s.gpr .r4 → s'.gpr .r16 = s.gpr .r5 → + s'.gpr .r20 = s.gpr .r8 → + s'.gpr .r31 = s.gpr .r6 + (s.gpr .r7 >>> 4 <<< 4) → + s'.gpr .r30 = s.gpr .r7 - (s.gpr .r7 >>> 4 <<< 4) → s'.gpr .r7 = s.gpr .r7 >>> 4 → + (∀ r, r ≠ .r14 → r ≠ .r15 → r ≠ .r16 → r ≠ .r20 → r ≠ .r10 → r ≠ .r11 → + r ≠ .r31 → r ≠ .r30 → r ≠ .r7 → s'.gpr r = s.gpr r) → + s'.mem = s.mem → s'.rd = s.rd → s'.wr = s.wr → Φ s') : + WP isa (.block ctrFinalMoves) s Φ := by + unfold ctrFinalMoves Impl.AesCbc.PPC64LE.mov + refine wp_mr fun s₁ u₁ => wp_mr fun s₂ u₂ => wp_mr fun s₃ u₃ => wp_mr fun s₄ u₄ => + wp_lsr (by decide) fun s₅ u₅ => wp_lsl (by decide) fun s₆ u₆ => wp_add fun s₇ u₇ => + wp_sub fun s₈ u₈ => wp_mr fun s₉ u₉ => wp_nil ?_ + refine k s₉ ?_ ?_ ?_ ?_ ?_ ?_ ?_ (fun r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ h₉ => ?_) ?_ ?_ ?_ + all_goals try (simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, + upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; done) + · simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, + upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, h₁, h₂, h₃, h₄, h₅, h₆, h₇, h₈, h₉, ↓reduceIte] + · rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + · rw [u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + r14 : s.gpr .r14 = fW s₀ + r15 : s.gpr .r15 = s₀.gpr .r4 + r16 : s.gpr .r16 = fIv s₀ + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + r3 : s.gpr .r3 = fW s₀ + r4 : s.gpr .r4 = s₀.gpr .r4 + r5 : s.gpr .r5 = fIv s₀ + r6 : s.gpr .r6 = fD s₀ + r7 : s.gpr .r7 = BitVec.ofNat 64 (fN s₀) + kept : Kept s₀ s + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (KSetup s₀) := by + show WP isa (.block (.mflr .r0 :: (Spill.saveCode .r8 finalSaved ++ ctrFinalMoves))) _ _ + refine WP.cons exec_mflr (Spill.save_ok (b := .r8) (l := finalSaved) (by decide) saved_fits + (fun p hp' => ?_) ?_) + · show InRegions s₀.wr (kV s₀ + BitVec.ofNat 64 p.2) 8 + rw [hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + refine moves_wp fun s' r14 r15 r16 r20 r31 r30 r7 keep mem rd wr => ?_ + have g₀ (r : Reg) (hr : r ≠ .r0) : (s₀.write .r0 s₀.lr).gpr r = s₀.gpr r := by + simp [State.write, hr] + have k (r : Reg) (h₁ : r ≠ .r14) (h₂ : r ≠ .r15) (h₃ : r ≠ .r16) (h₅ : r ≠ .r20) + (h₆ : r ≠ .r10) (h₇ : r ≠ .r11) (h₈ : r ≠ .r31) (h₉ : r ≠ .r30) (h₁₀ : r ≠ .r7) (h₀ : r ≠ .r0) : + s'.gpr r = s₀.gpr r := (keep r h₁ h₂ h₃ h₅ h₆ h₇ h₈ h₉ h₁₀).trans (g₀ r h₀) + exact { + r14 := r14.trans (g₀ .r3 (by decide)) + r15 := r15.trans (g₀ .r4 (by decide)) + r16 := r16.trans (g₀ .r5 (by decide)) + r20 := r20.trans (g₀ .r8 (by decide)) + r30 := by rw [r30, g₀ .r7 (by decide), shr4_shl4, sub_shl4] + r31 := by rw [r31, g₀ .r6 (by decide), g₀ .r7 (by decide), shr4_shl4] + r3 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) + r4 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) + r5 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) + r6 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) (by decide) + r7 := by rw [r7, g₀ .r7 (by decide), shr4] + kept := fun r hr hv => by + obtain ⟨h7, -, -, h10, h11, h14, h15, h16, -, h20, h30, h31⟩ := + Proof.AesCfb.PPC64LE.Final.preserved_ne' hr hv + exact k r h14 h15 h16 h20 h10 h11 h31 h30 h7 (preserved_ne_r0 r hr) + mem := mem + rd := rd + wr := wr } + +/-! ## The whole blocks -/ + +theorem whole_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) (hsp : s.sp = s₀.sp) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), + h.r3, h.r4, h.r5, h.r6, h.r7, hsp, toNat_n] + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), + hp.iv_data.sub_right (blk_sub s₀), hp.stk_sch, hp.stk_iv, hp.stk_data.sub_right (blk_sub s₀), + hp.sch_wrap, hp.iv_wrap, hp.blk_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The subkeys, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : KPre s₀) : + Spec.Camellia.subkeysAt (kSvMem s₀) (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀) ∧ + bytesAt (kSvMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ Spec.Cbc.blocksAt (kSvMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame s₀ + exact ⟨subkeys_of hp ef (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv), + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + r14 : s.gpr .r14 = fW s₀ + r15 : s.gpr .r15 = s₀.gpr .r4 + r16 : s.gpr .r16 = fIv s₀ + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +theorem ctr_hd : sdepth ctrFramed < 2 ^ 64 := by rw [ctr_sdepth]; decide + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) (hsp : s.sp = s₀.sp) : + WP isa ctrCall s (KWhole s₀) := by + obtain ⟨eK, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h hsp + refine WP.callAny (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, fBlk s₀]) hpre hc hw ?_ ctr_hd + intro s' rd' wr' _ fr' cs' post₂ + have fr := call_frame hsp fr' + rw [h.mem] at fr + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), h.r3, h.r4, h.r5, h.r6, h.r7, + toNat_n, h.mem] at post₂ + have hR : (s₀.gpr .r4).toNat = fR s₀ := rfl + rw [hR, eK, eIv, eB] at post₂ + exact ⟨by rw [cs' .r14 (by decide), h.r14], by rw [cs' .r15 (by decide), h.r15], + by rw [cs' .r16 (by decide), h.r16], by rw [cs' .r20 (by decide), h.r20], + by rw [cs' .r30 (by decide), h.r30], by rw [cs' .r31 (by decide), h.r31], + fun r hr hv => by rw [cs' r hr, h.kept r hr hv], + by rw [rd', h.rd], by rw [wr', h.wr], + fr.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h], + post₂.1, post₂.2⟩ + +/-! ## The partial last block -/ + +theorem eval_u {s₀ s : State} (h : KWhole s₀ s) : + isa.eval (.zero .d .r30) s = some (decide (fU s₀ = 0)) := by + rw [eval_zero, h.r30, ofNat_beq_zero (by have := u_lt s₀; omega)] + +/-- The arguments of `vg_camellia_ctr` on the block. -/ +theorem tailMoves_wp {s : State} {Φ : State → Prop} + (k : ∀ s', s'.gpr .r3 = s.gpr .r14 → s'.gpr .r4 = s.gpr .r15 → s'.gpr .r5 = s.gpr .r16 → + s'.gpr .r6 = s.gpr .r20 + BitVec.ofNat 64 64 → s'.gpr .r7 = BitVec.ofNat 64 1 → + (∀ r, r ≠ .r3 → r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → r ≠ .r7 → s'.gpr r = s.gpr r) → + s'.mem = s.mem → s'.rd = s.rd → s'.wr = s.wr → Φ s') : + WP isa (.block ctrFinalTailMoves) s Φ := by + unfold ctrFinalTailMoves Impl.AesCbc.PPC64LE.mov + refine wp_mr fun s₁ u₁ => wp_mr fun s₂ u₂ => wp_mr fun s₃ u₃ => wp_addi (by decide) (by decide) fun s₄ u₄ => + wp_li (by decide) fun s₅ u₅ => wp_nil ?_ + refine k s₅ ?_ ?_ ?_ ?_ ?_ (fun r h₃ h₄ h₅ h₆ h₇ => ?_) ?_ ?_ ?_ + all_goals try (simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, + reduceCtorEq, ↓reduceIte]; done) + · simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, h₃, h₄, h₅, h₆, h₇, ↓reduceIte] + · rw [u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + · rw [u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KArgs (s₀ s : State) : Prop where + r3 : s.gpr .r3 = fW s₀ + r4 : s.gpr .r4 = s₀.gpr .r4 + r5 : s.gpr .r5 = fIv s₀ + r6 : s.gpr .r6 = kBk s₀ + r7 : s.gpr .r7 = BitVec.ofNat 64 1 + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (KArgs s₀) := by + show WP isa (.block (.li .r9 0 :: (Spill.saveCode .r20 zeroSlots ++ ctrFinalTailMoves))) _ _ + refine wp_li (by decide) fun s₁ u₁ => ?_ + have h20 : s₁.gpr .r20 = kV s₀ := by rw [u₁.other _ (by decide), h.r20] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .r20 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [u₁.wr, h.wr, hp.wr, h20] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + refine Spill.save_ok (by decide) (by decide) hw ?_ + refine tailMoves_wp fun s' r3 r4 r5 r6 r7 o mem rd wr => ?_ + have c (r : Reg) (hr : r ∈ preserved) : s'.gpr r = s.gpr r := by + obtain ⟨h3, h4, h5, h6, h7, -, h9⟩ := preserved_ne_args hr + rw [o r h3 h4 h5 h6 h7] + exact u₁.other r h9 + have hm : s'.mem = Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₁.mem _ _ _ = _; rw [u₁.mem, h20] + have fz : Frame [kBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have g₁ (r : Reg) (hr : r ≠ .r9) : s₁.gpr r = s.gpr r := u₁.other r hr + refine ⟨by rw [r3, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r14], + by rw [r4, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r15], + by rw [r5, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r16], + by rw [r6, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, h20], + r7, + by rw [c .r20 (by decide), h.r20], by rw [c .r30 (by decide), h.r30], by rw [c .r31 (by decide), h.r31], + fun r hr hv => by rw [c r hr, h.kept r hr hv], + by rw [rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, u₁.rd, h.rd], + by rw [wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, u₁.wr, h.wr], ?_, ?_, ?_, ?_⟩ + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.ctr] + · have z₁ : s₁.gpr .r9 = (0 : BitVec 64) := u₁.gpr + rw [hm, show Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₁.gpr .r9)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .r9)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z₁] + exact zero_bytes _ _ + +theorem tail_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) (hsp : s.sp = s₀.sp) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, kBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, kBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, kBlk s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), + h.r3, h.r4, h.r5, h.r6, h.r7, hsp, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.iv_sv.sub_right bs, hp.stk_sch, + hp.stk_iv, hp.stk_sv.sub_right bs, hp.sch_wrap, hp.iv_wrap, by rw [hp.bk_toNat]; omega, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure KCall (s₀ s : State) : Prop where + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by + simp [Spec.Camellia.cipher] + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) (hsp : s.sp = s₀.sp) : + WP isa ctrCall s (KCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h hsp + have big := big_of (kW1_kW h.frame) + have eK := subkeys_of hp big hp.sch_big + refine WP.callAny (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, kBlk s₀]) hpre hc hw ?_ ctr_hd + intro s' rd' wr' _ fr' cs' post₂ + have fr := call_frame hsp fr' + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r7 ∉ linkRegs), h.r3, h.r4, h.r5, h.r6, h.r7, + one_toNat, h.ctr] at post₂ + have hR : (s₀.gpr .r4).toNat = fR s₀ := rfl + rw [hR, eK] at post₂ + have fc : Frame (kW1 s₀) s.mem s'.mem := fr.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs' .r20 (by decide), h.r20], by rw [cs' .r30 (by decide), h.r30], + by rw [cs' .r31 (by decide), h.r31], fun r hr hv => by rw [cs' r hr, h.kept r hr hv], + by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + r20 : s.gpr .r20 = kV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.r20, h.kept, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem toNat_tail {s₀ : State} (hp : KPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +/-- The XOR of the partial last block. -/ +abbrev xorCode : Prog isa := + .seq (.block tailKey) (.loop (.block Impl.Modes.PPC64LE.tailByte) (.nonzero .d .r30)) + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa xorCode s (KDone s₀) := by + refine WP.seq (wp_addi (by decide) (by decide) fun s₁ u₁ => wp_nil ?_) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have hB := hp.bk_toNat + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : Proof.Modes.PPC64LE.XPre s₁ (kBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fitK := by omega + fitR := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [u₁.rd, u₁.wr, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [u₁.wr, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : Proof.Modes.PPC64LE.XInv s₁ (kBk s₀) (fT s₀) (fU s₀) 0 s₁ := { + r8 := by rw [u₁.gpr, h.r20]; exact (BitVec.add_zero _).symm + r31 := by rw [u₁.other _ (by decide), h.r31]; exact (BitVec.add_zero _).symm + r30 := by rw [u₁.other _ (by decide), h.r30, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Proof.Modes.PPC64LE.tailLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have df : Frame [fTail s₀] s.mem s'.mem := by rw [← u₁.mem]; exact d.frame + have g (r : Reg) (h8 : r ≠ .r8) (h9 : r ≠ .r9) (h10 : r ≠ .r10) (h30 : r ≠ .r30) (h31 : r ≠ .r31) : + s'.gpr r = s.gpr r := by + rw [d.gpr r h8 h9 h10 h30 h31, u₁.other r h8] + refine ⟨by rw [g .r20 (by decide) (by decide) (by decide) (by decide) (by decide), h.r20], + fun r hr hv => ?_, by rw [d.rd, u₁.rd, h.rd], by rw [d.wr, u₁.wr, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · obtain ⟨-, h8, h9, h10, -, -, -, -, -, -, h30, h31⟩ := Proof.AesCfb.PPC64LE.Final.preserved_ne' hr hv + rw [g r h8 h9 h10 h30 h31, h.kept r hr hv] + · exact (kW1_kW h.frame).trans (df.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' df fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact h.blocks + · rw [d.data q hq, u₁.mem, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame df ivT (by decide), h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) (hsp : s.sp = s₀.sp) : + WP isa (.ite (.zero .d .r30) (.block []) ctrFinalTail) s (KDone s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (wp_sp (tail_args_wp hp h)) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁.1 (h₁.2.trans hsp)) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.block finalRestore) s fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.lr = s₀.lr ∧ s'.mem = s.mem := by + have hs : Spill.Saved (kV s₀) (kSaveG s₀) finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (kV s₀) (kSaveG s₀)).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + · exact hp.stk_sv.symm.sub_left hsub + rw [restore_eq] + refine Spill.restore_ok (b := .r20) (l := finalSaved) (by decide) h.r20 saved_fits (by decide) + (fun p hp' => ?_) hs fun s₃ r₃ => ?_ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + refine WP.cons exec_mtlr (wp_nil ⟨fun r hr => ?_, ?_, r₃.mem⟩) + · show s₃.gpr r = _ + have h0 : kSaveG s₀ r = s₀.gpr r := by + show (s₀.write .r0 s₀.lr).gpr r = _ + simp [State.write, preserved_ne_r0 r hr] + rw [r₃.gpr_of (r := r) ?_, h0] + by_cases hv : r ∈ vars + · left + simp only [vars, List.mem_cons, List.not_mem_nil, or_false] at hv + rcases hv with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide + · right; rw [h.kept r hr hv, h0] + · show s₃.gpr .r0 = _ + rw [r₃.gpr (.r0, 0) (by decide)]; rfl + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.lr = s₀.lr ∧ ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (wp_sp (setup_wp hp)) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (wp_sp (whole_wp hp h₁.1 h₁.2)) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₂.1 (h₂.2.trans h₁.2)) fun s₃ h₃ => ?_) + exact WP.mono (end_wp hp h₃) fun _ ⟨g, l, m⟩ => ⟨g, l, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalPPC64LE.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalPPC64LE.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalPPC64LE.post s s' := by + obtain ⟨t, s', he, hg, hl, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hl⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7, .r8]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.r14, .r15, .r16, .r20]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.r20, .r30, .r31]) xorCode h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.r20]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalPPC64LE.pre s₀) (h0' : ctrFinalPPC64LE.pre s₀') + (hq : ctrFinalPPC64LE.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qR, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + -- The registers saved and the arguments set up. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := (taintRegs (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + refine ⟨qSp, fun r hr => ?_⟩ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) t₁).wp + (F₁ := fun (s : State) => KSetup s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KSetup s₀' s ∧ s.sp = s₀'.sp) + fun a b h => by + obtain ⟨rfl, rfl⟩ := h + exact ⟨wp_sp (setup_wp hp), wp_sp (setup_wp hp')⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := ctrF) (n := "vg_camellia_ctr") ctr_ok ctr_ct + (P := fun a b => (KSetup s₀ a ∧ a.sp = s₀.sp) ∧ (KSetup s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha.1 ha.2 + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb.1 hb.2 + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_gpr' _ (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r7 ∉ linkRegs), + ha.1.r3, ha.1.r4, ha.1.r5, ha.1.r6, ha.1.r7, ha.2, hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.1.r7, hb.2] + rw [fW, fW, fIv, fIv, fD, fD, qW, qR, qIv, qD, qSp, qN] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := fun (s : State) => KWhole s₀ s ∧ s.sp = s₀.sp) + (F₂ := fun (s : State) => KWhole s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (whole_wp hp h.1.1 h.1.2)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (whole_wp hp' h.2.1 h.2.2)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + -- The partial last block. + obtain ⟨_, t₃⟩ := tailArgs_taint + obtain ⟨_, t₄⟩ := xor_taint + have tail (hu : fU s₀ ≠ 0) : RelCT isa + (fun a b => (KWhole s₀ a ∧ a.sp = s₀.sp) ∧ (KWhole s₀' b ∧ b.sp = s₀'.sp)) + ctrFinalTail fun a b => (KDone s₀ a ∧ a.sp = s₀.sp) ∧ (KDone s₀' b ∧ b.sp = s₀'.sp) := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := (taintRegs + (P := fun a b => (KWhole s₀ a ∧ a.sp = s₀.sp) ∧ (KWhole s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · rw [h.1.1.r14, h.2.1.r14, fW, fW, qW] + · rw [h.1.1.r15, h.2.1.r15, qR] + · rw [h.1.1.r16, h.2.1.r16, fIv, fIv, qIv] + · rw [h.1.1.r20, h.2.1.r20, kV, kV, qV]⟩) t₃).wp + (F₁ := fun (s : State) => KArgs s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KArgs s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_args_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_args_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + have a₂ := (RelCT.callEx (k := ctrF) (n := "vg_camellia_ctr") ctr_ok ctr_ct + (P := fun a b => (KArgs s₀ a ∧ a.sp = s₀.sp) ∧ (KArgs s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha.1 ha.2 + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb.1 hb.2 + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_gpr' _ (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r6 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r7 ∉ linkRegs), + ha.1.r3, ha.1.r4, ha.1.r5, ha.1.r6, ha.1.r7, ha.2, hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.1.r7, hb.2] + rw [fW, fW, fIv, fIv, kBk, kBk, kV, kV, qW, qR, qIv, qV, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := fun (s : State) => KCall s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KCall s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_call_wp hp h.1.1 h.1.2)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_call_wp hp' h.2.1 h.2.2)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + have a₃ := (taintRegs + (P := fun a b => (KCall s₀ a ∧ a.sp = s₀.sp) ∧ (KCall s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.1.r20, h.2.1.r20, kV, kV, qV] + · rw [h.1.1.r30, h.2.1.r30, qU] + · rw [h.1.1.r31, h.2.1.r31, qT]⟩) t₄).wp + (F₁ := fun (s : State) => KDone s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KDone s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_xor_wp hp h.1.1 hu)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_xor_wp hp' h.2.1 hu')) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + exact (a₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq + ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₃.mono (fun _ _ h => h) fun _ _ h => h.2)) + have r₃ : RelCT isa + (fun a b => (KWhole s₀ a ∧ a.sp = s₀.sp) ∧ (KWhole s₀' b ∧ b.sp = s₀'.sp)) + (.ite (.zero .d .r30) (.block []) ctrFinalTail) + (fun a b => (KDone s₀ a ∧ a.sp = s₀.sp) ∧ (KDone s₀' b ∧ b.sp = s₀'.sp)) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1.1, eval_u h.2.1, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1.1] at this; simpa using this + exact ⟨⟨done_of_zero h.1.1.1 h0, h.1.1.2⟩, ⟨done_of_zero h.1.2.1 (qU ▸ h0), h.1.2.2⟩⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1.1] at this; simpa using this + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := taintRegs + (P := fun a b => (KDone s₀ a ∧ a.sp = s₀.sp) ∧ (KDone s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.r20, h.2.1.r20, kV, kV, qV]⟩) t₅ + exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq + (r₃.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalPPC64LE.pre ctrFinalPPC64LE.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified PPC64LE.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## Locality + +The frame needs the contract's precondition and postcondition to read the +memory on entry only within the function's buffers. -/ + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + bytesAt m₂ p k = bytesAt m₁ p k := by + simp only [Spec.Aes.bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₁ → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₂ := by + intro vs m₁ m₂ hlen _ h + match vs, hlen with + | [_, _, _, _, _], _ => exact h + +/-- `ctrFinalPostSk` reads the memory on entry only within the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₁ m' r → + Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, rounds, ctr, data, len], _ => + simp only [Spec.Camellia.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hs := Proof.Camellia.agree_of hb.1 + have hc := Proof.Camellia.agree_of hb.2.1 + have hd := Proof.Camellia.agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Camellia.ctrFinalPostSk pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Camellia.ctrFinalPostSk pb) _ m₂ m' r + dsimp only [Curry.apply, Proof.Camellia.ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + intro hR + rw [Proof.Camellia.subkeysAt_congr (by rcases hR with h | h <;> rw [h] <;> decide) fun i hi => hs i hi, + bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] + exact h hR + +/-! ## With `save` on the stack + +The final function has five argument words, so `save` is its sixth, in `r8`: +it runs its code in a frame of 112 bytes on the stack +(`withStackScratchWiped`), its 32-byte header and `save`'s 80 bytes (the +registers, then the block that held the last output block), which it zeroes +before returning. Its calls use 3408 bytes below it, so 3520 in all. -/ + +/-- A state satisfying the shared contract's precondition. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk PPC64LE.abi (3408 + 112)).pre s := by + implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, + Proof.Camellia.ctrFinalPostSk, PPC64LE.abi, PPC64LE.argRegs] [ctrFinalFrameSat, ctrFinalSat] + using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 112 .r8 10 ctrFinal) + (Spec.Camellia.ctrFinalContract PPC64LE.abi 3520) := + Proof.Camellia.ctrFinal_of_sk <| + PPC64LE.Verified.stackScratchWiped (sig := Spec.Camellia.ctrFinalSig) (nm := "save") (e := .u64) (n := 10) + (pre := Spec.Camellia.ctrFinalPre PPC64LE.abi.ptrBits) + (post := Proof.Camellia.ctrFinalPostSk PPC64LE.abi.ptrBits) + (wa := true) (stack := 3408) (bytes := 112) (words := 10) ctrFinal_verified (by decide) (by decide) + (by decide) (ctrFinalPre_local _) (ctrFinalPost_local _) (Proof.Camellia.ctrFinalPostOut_local _) + ctrFinalFrameSat_pre + +end VG.Proof.Camellia.PPC64LE.CtrFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean new file mode 100644 index 00000000000..ef35d6acb15 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean @@ -0,0 +1,1055 @@ +module + +public import VerifiedGarbage.Impl.Sm4.PPC64LE.CtrFinal +public import VerifiedGarbage.Proof.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Sm4.Scratch +public import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrVerified +public import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.PPC64LE.Spill +public import VerifiedGarbage.Proof.Framework.PPC64LE.CallAny +public import VerifiedGarbage.Impl.StackScratch.PPC64LE +import VerifiedGarbage.Proof.AesCtr.PPC64LE.Final +import VerifiedGarbage.Proof.Sm4.PPC64LE.ModesFrame +import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrLit +import VerifiedGarbage.Proof.Sm4.PPC64LE.Lit +import VerifiedGarbage.Proof.Sm4.CtrCipher +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.PPC64LE.Call +import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.Lit +import VerifiedGarbage.Proof.Framework.PPC64LE.Lit +import VerifiedGarbage.Proof.Framework.PPC64LE.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.PPC64LE.Step +import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +import VerifiedGarbage.Proof.Framework.PPC64LE.Taint +import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.Sm4.PPC64LE.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.Scratch +meta import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrVerified +meta import VerifiedGarbage.Proof.AesCfb.PPC64LE.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Spill +meta import VerifiedGarbage.Proof.Framework.PPC64LE.CallAny +meta import VerifiedGarbage.Impl.StackScratch.PPC64LE +meta import VerifiedGarbage.Proof.AesCtr.PPC64LE.Final +meta import VerifiedGarbage.Proof.Sm4.PPC64LE.ModesFrame +meta import VerifiedGarbage.Proof.Sm4.PPC64LE.CtrLit +meta import VerifiedGarbage.Proof.Sm4.PPC64LE.Lit +meta import VerifiedGarbage.Proof.Sm4.CtrCipher +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.PPC64LE.SeqFinal +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCbc.PPC64LE.Call +meta import VerifiedGarbage.Proof.AesCbc.PPC64LE.CT +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.Lit +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Lit +meta import VerifiedGarbage.Proof.Framework.PPC64LE.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Step +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Exec +meta import VerifiedGarbage.Proof.Framework.PPC64LE.Taint +meta import VerifiedGarbage.Proof.Framework.PPC64LE.StackScratchWipe +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# SM4-CTR of a message's last piece on PPC64LE + +`ctrFinal_framed`: `vg_sm4_ctr_final` (`Impl/Sm4/PPC64LE/CtrFinal.lean`) +meets `Spec.Sm4.ctrFinalContract`. + +The code is proven against `ctrFinalPPC64LE`, with the arguments +`(schedule = r3, ctr = r4, data = r5, len = r6, save = r7)`, a fifth argument +`save` (`r7`) of 80 bytes for its return address and its caller's registers +and a block of its own, and 3296 bytes of stack for its calls +(`ctrFinal_implies`: the shared contract with it), as a caller of +`vg_sm4_ctr`, framed by its own working space on the stack (`ctrFramed`), +through a contract of its own, `ctrF`, which the callee's shared contract +implies (`ctrF_implies`), with `WP.callAny` (the callee's frame is the 3296 +bytes below the stack pointer, `ctr_sdepth`). It is AES-CTR's final +function's proof (`Proof/AesCtr/PPC64LE/Final.lean`) with SM4's arguments: + +* `setup_wp`, `whole_wp`: the return address and the registers saved in + `save`, whose address is kept in `r20`, and the call on the + `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.PPC64LE.tailLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers and the return address restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`), by SM4 with the schedule at + `schedule`. + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. + +The frame of the registration needs the contract's postcondition to read the +memory on entry only within the function's buffers (`ctrFinalPost_local`). +-/ + +@[expose] public section + +namespace VG.Proof.Sm4.PPC64LE.CtrFinal + +open VG VG.PPC64LE +open VG.Spec.Aes (bytesAt) +open VG.Impl.Sm4.PPC64LE (ctrFramed ctrCall ctrFinalSave ctrFinalMoves ctrFinalSetup ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.PPC64LE (finalSaved finalRestore) +open VG.Impl.AesCtr.PPC64LE (zeroSlots tailKey) +open VG.Proof.AesCfb.PPC64LE.Final (Kept vars bytesAt_getD blocksAt_frame' saved_slots saved_fits + shr4 shr4_shl4 sub_shl4 upd_gpr preserved_ne_r0 restore_eq) +open VG.Proof.AesCtr.PPC64LE.Final (zero_bytes one_toNat preserved_ne_args) +open VG.Proof.AesCbc.PPC64LE (callEntry_gpr' taintRegs wp_sp) + +/-! ## The callee -/ + +/-- `vg_sm4_ctr(schedule = r3, ctr = r4, data = r5, n = r6)` with its 3296 +bytes of stack. -/ +def ctrF : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .r3, 128⟩ + let ctr : Region := ⟨s.gpr .r4, 16⟩ + let data : Region := ⟨s.gpr .r5, 16 * (s.gpr .r6).toNat⟩ + 3296 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data] ∧ sched.Disjoint ctr ∧ sched.Disjoint data ∧ + ctr.Disjoint data ∧ (below s.sp 3296).Disjoint sched ∧ (below s.sp 3296).Disjoint ctr ∧ + (below s.sp 3296).Disjoint data ∧ + (s.gpr .r3).toNat + 128 ≤ 2 ^ 64 ∧ (s.gpr .r4).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .r5).toNat + 16 * (s.gpr .r6).toNat ≤ 2 ^ 64 + post s s' := + Spec.Cbc.blocksAt s'.mem (s.gpr .r5) (s.gpr .r6).toNat = + Spec.Ctr.crypt (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (s.gpr .r3))) + (bytesAt s.mem (s.gpr .r4) 16) (Spec.Cbc.blocksAt s.mem (s.gpr .r5) (s.gpr .r6).toNat) ∧ + bytesAt s'.mem (s.gpr .r4) 16 = Spec.Ctr.next (bytesAt s.mem (s.gpr .r4) 16) (s.gpr .r6).toNat + pub s₁ s₂ := + s₁.sp = s₂.sp ∧ s₁.gpr .r3 = s₂.gpr .r3 ∧ s₁.gpr .r4 = s₂.gpr .r4 ∧ s₁.gpr .r5 = s₂.gpr .r5 ∧ + s₁.gpr .r6 = s₂.gpr .r6 + +theorem ctrF_implies : (Spec.Sm4.ctrContract PPC64LE.abi 3296).Implies ctrF where + pre s hs := by + sig_pre [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, PPC64LE.abi, PPC64LE.argRegs] + simp only [Nat.mul_comm (s.gpr .r6).toNat 16] + exact hs + post s s' _ h := by + sig_reduce [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, PPC64LE.abi, PPC64LE.argRegs] at h + simp only [BitVec.setWidth_eq] at h + exact h + pub s₁ s₂ _ _ h := by + sig_reduce [Spec.Sm4.ctrContract, Spec.Sm4.ctrSig, PPC64LE.abi, PPC64LE.argRegs] + obtain ⟨hsp, h0, h1, h2, h3⟩ := h + exact ⟨hsp, fun _ _ => by rw [h0, h1, h2, h3], fun _ hr => absurd hr List.not_mem_nil⟩ + sat := ⟨Sm4.PPC64LE.modeFrameSat, by + refine ⟨by decide, rfl, rfl, Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), Region.disjoint_of_sep (by decide), + Region.disjoint_of_sep (by decide), by decide, by decide, by decide⟩⟩ + +/-- The callee's frame is the 3296 bytes below the stack pointer. -/ +theorem ctr_sdepth : sdepth ctrFramed = 3296 := by lit_decide + +theorem ctr_hd : sdepth ctrFramed < 2 ^ 64 := by rw [ctr_sdepth]; decide + +theorem ctr_ok : ∀ s, ctrF.pre s → ∃ t s', Exec isa ctrFramed s t s' ∧ abiPreserved s s' ∧ ctrF.post s s' := + (Sm4.PPC64LE.Modes.ctr_framed.of_implies ctrF_implies).1 + +theorem ctr_ct : ConstantTime isa ctrF.pre ctrF.pub ctrFramed := + (Sm4.PPC64LE.Modes.ctr_framed.of_implies ctrF_implies).2.1 + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = r3, ctr = r4, +data = r5, len = r6, save = r7)`, `save` of 80 bytes, and 3296 bytes of stack +for the calls: the data and the counter block as `Spec.Ctr.CryptFinal` says, +by SM4 with the schedule at `schedule`. -/ +def ctrFinalPPC64LE : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .r3, 128⟩ + let ctr : Region := ⟨s.gpr .r4, 16⟩ + let data : Region := ⟨s.gpr .r5, (s.gpr .r6).toNat⟩ + let sv : Region := ⟨s.gpr .r7, 80⟩ + let stack := below s.sp 3296 + 3296 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .r3).toNat + 128 ≤ 2 ^ 64 ∧ (s.gpr .r4).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .r5).toNat + (s.gpr .r6).toNat ≤ 2 ^ 64 ∧ (s.gpr .r7).toNat + 80 ≤ 2 ^ 64 + post s s' := + Spec.Ctr.CryptFinal (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (s.gpr .r3))) + s.mem s'.mem (s.gpr .r4) (s.gpr .r5) (s.gpr .r6).toNat + pub s₁ s₂ := + s₁.gpr .r3 = s₂.gpr .r3 ∧ s₁.gpr .r4 = s₂.gpr .r4 ∧ s₁.gpr .r5 = s₂.gpr .r5 ∧ + s₁.gpr .r6 = s₂.gpr .r6 ∧ s₁.gpr .r7 = s₂.gpr .r7 ∧ s₁.sp = s₂.sp + +/-- The contract the frame needs: the shared one, with `save`, 80 bytes, as a +fifth argument, and 3296 bytes of stack (`vg_sm4_ctr`'s frame). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract PPC64LE.abi Spec.Sm4.ctrFinalSig "save" .u64 10 (Curry.const (fun _ => True) _) + (Proof.Sm4.ctrFinalPost PPC64LE.abi.ptrBits) true 3296 + +/-- A state satisfying the precondition (no data). -/ +def ctrFinalSat : State where + gpr r := match r with + | .r3 => 0x1000 | .r4 => 0x2000 | .r5 => 0x3000 | .r7 => 0x4000 | _ => 0 + lr := 0 + sp := 0x8000 + mem _ := 0 + rd := [⟨0x1000, 128⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 80⟩] + +theorem ctrFinal_implies : ctrFinalPPC64LE.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, ctrFinalPPC64LE, PPC64LE.abi, PPC64LE.argRegs] [ctrFinalSat] + using ctrFinalSat + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +abbrev fW : Addr := s₀.gpr .r3 +abbrev fIv : Addr := s₀.gpr .r4 +abbrev fD : Addr := s₀.gpr .r5 +abbrev fL : Nat := (s₀.gpr .r6).toNat +/-- The number of whole blocks, and of the bytes after them. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +/-- The data after the whole blocks. -/ +abbrev fT : Addr := fD s₀ + BitVec.ofNat 64 (16 * fN s₀) +abbrev fData : Region := ⟨fD s₀, fL s₀⟩ +abbrev fBlk : Region := ⟨fD s₀, 16 * fN s₀⟩ +abbrev fTail : Region := ⟨fT s₀, fU s₀⟩ +/-- The counter block and the whole blocks on entry. -/ +abbrev fIv0 : List Byte := bytesAt s₀.mem (fIv s₀) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (fD s₀) (fN s₀) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .r7 +abbrev kSch : Region := ⟨fW s₀, 128⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 80⟩ +abbrev kSv64 : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 64 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below s₀.sp 3296 +/-- The values saved: `r0` holds the return address. -/ +abbrev kSaveG : Reg → BitVec 64 := (s₀.write .r0 s₀.lr).gpr +/-- The memory once the return address and the registers are saved. -/ +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) (kSaveG s₀) finalSaved +/-- The cipher on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Sm4.cipher (Spec.Sm4.scheduleAt s₀.mem (fW s₀)) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + sp : 3296 ≤ s₀.sp.toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 128 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 80 ≤ 2 ^ 64 + +theorem KPre.of {s₀ : State} (h : ctrFinalPPC64LE.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17⟩ + +/-! ## Regions and frames -/ + +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) + +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) + +theorem fN_eq (s₀ : State) : fN s₀ = fL s₀ / 16 := rfl +theorem fU_eq (s₀ : State) : fU s₀ = fL s₀ % 16 := rfl + +theorem n_lt (s₀ : State) : fN s₀ < 2 ^ 64 := by + have := (s₀.gpr .r6).isLt; have : fL s₀ = (s₀.gpr .r6).toNat := rfl; rw [fN_eq]; omega + +theorem u_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +theorem toNat_n (s₀ : State) : (BitVec.ofNat 64 (fN s₀)).toNat = fN s₀ := by + rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt (n_lt s₀)] + +theorem sv64_sub (s₀ : State) : Region.Sub (kSv64 s₀) (kSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +end + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + (Spill.saveMem_frame_base (n := 64) (by decide) (by decide) _ _ _).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨kSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem KPre.sch_big {s₀ : State} (hp : KPre s₀) : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The schedule, from memory that agrees with the entry's on it. -/ +theorem sched_of {s₀ : State} {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : Spec.Sm4.scheduleAt m (fW s₀) = Spec.Sm4.scheduleAt m₀ (fW s₀) := + Proof.Sm4.scheduleAt_frame hf hd + +/-- A call's frame, within the regions it was given and the stack. -/ +theorem call_frame {s₀ s s' : State} (hsp : s.sp = s₀.sp) {wr : List Region} + (hf : Frame (wr ++ [below s.sp (sdepth ctrFramed)]) s.mem s'.mem) : + Frame (wr ++ [kStk s₀]) s.mem s'.mem := by + rw [ctr_sdepth, hsp] at hf; exact hf + +/-! ## Saving the registers -/ + +theorem moves_wp {s : State} {Φ : State → Prop} + (k : ∀ s', s'.gpr .r14 = s.gpr .r3 → s'.gpr .r16 = s.gpr .r4 → s'.gpr .r20 = s.gpr .r7 → + s'.gpr .r31 = s.gpr .r5 + (s.gpr .r6 >>> 4 <<< 4) → + s'.gpr .r30 = s.gpr .r6 - (s.gpr .r6 >>> 4 <<< 4) → s'.gpr .r6 = s.gpr .r6 >>> 4 → + (∀ r, r ≠ .r14 → r ≠ .r16 → r ≠ .r20 → r ≠ .r10 → r ≠ .r11 → + r ≠ .r31 → r ≠ .r30 → r ≠ .r6 → s'.gpr r = s.gpr r) → + s'.mem = s.mem → s'.rd = s.rd → s'.wr = s.wr → Φ s') : + WP isa (.block ctrFinalMoves) s Φ := by + unfold ctrFinalMoves Impl.AesCbc.PPC64LE.mov + refine wp_mr fun s₁ u₁ => wp_mr fun s₂ u₂ => wp_mr fun s₃ u₃ => + wp_lsr (by decide) fun s₄ u₄ => wp_lsl (by decide) fun s₅ u₅ => wp_add fun s₆ u₆ => + wp_sub fun s₇ u₇ => wp_mr fun s₈ u₈ => wp_nil ?_ + refine k s₈ ?_ ?_ ?_ ?_ ?_ ?_ (fun r h₁ h₂ h₃ h₄ h₅ h₆ h₇ h₈ => ?_) ?_ ?_ ?_ + all_goals try (simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, + upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; done) + · simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, + upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, h₁, h₂, h₃, h₄, h₅, h₆, h₇, h₈, ↓reduceIte] + · rw [u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + · rw [u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + r14 : s.gpr .r14 = fW s₀ + r16 : s.gpr .r16 = fIv s₀ + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + r3 : s.gpr .r3 = fW s₀ + r4 : s.gpr .r4 = fIv s₀ + r5 : s.gpr .r5 = fD s₀ + r6 : s.gpr .r6 = BitVec.ofNat 64 (fN s₀) + kept : Kept s₀ s + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (KSetup s₀) := by + show WP isa (.block (.mflr .r0 :: (Spill.saveCode .r7 finalSaved ++ ctrFinalMoves))) _ _ + refine WP.cons exec_mflr (Spill.save_ok (b := .r7) (l := finalSaved) (by decide) saved_fits + (fun p hp' => ?_) ?_) + · show InRegions s₀.wr (kV s₀ + BitVec.ofNat 64 p.2) 8 + rw [hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + refine moves_wp fun s' r14 r16 r20 r31 r30 r6 keep mem rd wr => ?_ + have g₀ (r : Reg) (hr : r ≠ .r0) : (s₀.write .r0 s₀.lr).gpr r = s₀.gpr r := by + simp [State.write, hr] + have k (r : Reg) (h₁ : r ≠ .r14) (h₃ : r ≠ .r16) (h₅ : r ≠ .r20) + (h₆ : r ≠ .r10) (h₇ : r ≠ .r11) (h₈ : r ≠ .r31) (h₉ : r ≠ .r30) (h₁₀ : r ≠ .r6) (h₀ : r ≠ .r0) : + s'.gpr r = s₀.gpr r := (keep r h₁ h₃ h₅ h₆ h₇ h₈ h₉ h₁₀).trans (g₀ r h₀) + exact { + r14 := r14.trans (g₀ .r3 (by decide)) + r16 := r16.trans (g₀ .r4 (by decide)) + r20 := r20.trans (g₀ .r7 (by decide)) + r30 := by rw [r30, g₀ .r6 (by decide), shr4_shl4, sub_shl4] + r31 := by rw [r31, g₀ .r5 (by decide), g₀ .r6 (by decide), shr4_shl4] + r3 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) + r4 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) + r5 := k _ (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (by decide) + r6 := by rw [r6, g₀ .r6 (by decide), shr4] + kept := fun r hr hv => by + obtain ⟨h3, -, -, h6, -, -, -⟩ := preserved_ne_args hr + obtain ⟨-, -, -, h10, h11, h14, -, h16, -, h20, h30, h31⟩ := + Proof.AesCfb.PPC64LE.Final.preserved_ne' hr hv + exact k r h14 h16 h20 h10 h11 h31 h30 h6 (preserved_ne_r0 r hr) + mem := mem + rd := rd + wr := wr } + +/-! ## The whole blocks -/ + +theorem whole_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) (hsp : s.sp = s₀.sp) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), h.r3, h.r4, h.r5, h.r6, hsp, toNat_n] + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), + hp.iv_data.sub_right (blk_sub s₀), hp.stk_sch, hp.stk_iv, hp.stk_data.sub_right (blk_sub s₀), + hp.sch_wrap, hp.iv_wrap, hp.blk_wrap⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The schedule, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : KPre s₀) : + Spec.Sm4.scheduleAt (kSvMem s₀) (fW s₀) = Spec.Sm4.scheduleAt s₀.mem (fW s₀) ∧ + bytesAt (kSvMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ Spec.Cbc.blocksAt (kSvMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame s₀ + exact ⟨sched_of ef (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv), + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + r14 : s.gpr .r14 = fW s₀ + r16 : s.gpr .r16 = fIv s₀ + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) (hsp : s.sp = s₀.sp) : + WP isa ctrCall s (KWhole s₀) := by + obtain ⟨eK, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h hsp + refine WP.callAny (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, fBlk s₀]) hpre hc hw ?_ ctr_hd + intro s' rd' wr' _ fr' cs' post₂ + have fr := call_frame hsp fr' + rw [h.mem] at fr + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + h.r3, h.r4, h.r5, h.r6, toNat_n, h.mem] at post₂ + rw [eK, eIv, eB] at post₂ + exact ⟨by rw [cs' .r14 (by decide), h.r14], by rw [cs' .r16 (by decide), h.r16], + by rw [cs' .r20 (by decide), h.r20], by rw [cs' .r30 (by decide), h.r30], + by rw [cs' .r31 (by decide), h.r31], + fun r hr hv => by rw [cs' r hr, h.kept r hr hv], + by rw [rd', h.rd], by rw [wr', h.wr], + fr.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h], + post₂.1, post₂.2⟩ + +/-! ## The partial last block -/ + +theorem eval_u {s₀ s : State} (h : KWhole s₀ s) : + isa.eval (.zero .d .r30) s = some (decide (fU s₀ = 0)) := by + rw [eval_zero, h.r30, ofNat_beq_zero (by have := u_lt s₀; omega)] + +/-- The arguments of `vg_sm4_ctr` on the block. -/ +theorem tailMoves_wp {s : State} {Φ : State → Prop} + (k : ∀ s', s'.gpr .r3 = s.gpr .r14 → s'.gpr .r4 = s.gpr .r16 → + s'.gpr .r5 = s.gpr .r20 + BitVec.ofNat 64 64 → s'.gpr .r6 = BitVec.ofNat 64 1 → + (∀ r, r ≠ .r3 → r ≠ .r4 → r ≠ .r5 → r ≠ .r6 → s'.gpr r = s.gpr r) → + s'.mem = s.mem → s'.rd = s.rd → s'.wr = s.wr → Φ s') : + WP isa (.block ctrFinalTailMoves) s Φ := by + unfold ctrFinalTailMoves Impl.AesCbc.PPC64LE.mov + refine wp_mr fun s₁ u₁ => wp_mr fun s₂ u₂ => wp_addi (by decide) (by decide) fun s₃ u₃ => + wp_li (by decide) fun s₄ u₄ => wp_nil ?_ + refine k s₄ ?_ ?_ ?_ ?_ (fun r h₃ h₄ h₅ h₆ => ?_) ?_ ?_ ?_ + all_goals try (simp only [upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, + reduceCtorEq, ↓reduceIte]; done) + · simp only [upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, h₃, h₄, h₅, h₆, ↓reduceIte] + · rw [u₄.mem, u₃.mem, u₂.mem, u₁.mem] + · rw [u₄.rd, u₃.rd, u₂.rd, u₁.rd] + · rw [u₄.wr, u₃.wr, u₂.wr, u₁.wr] + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KArgs (s₀ s : State) : Prop where + r3 : s.gpr .r3 = fW s₀ + r4 : s.gpr .r4 = fIv s₀ + r5 : s.gpr .r5 = kBk s₀ + r6 : s.gpr .r6 = BitVec.ofNat 64 1 + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (KArgs s₀) := by + show WP isa (.block (.li .r9 0 :: (Spill.saveCode .r20 zeroSlots ++ ctrFinalTailMoves))) _ _ + refine wp_li (by decide) fun s₁ u₁ => ?_ + have h20 : s₁.gpr .r20 = kV s₀ := by rw [u₁.other _ (by decide), h.r20] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .r20 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [u₁.wr, h.wr, hp.wr, h20] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + refine Spill.save_ok (by decide) (by decide) hw ?_ + refine tailMoves_wp fun s' r3 r4 r5 r6 o mem rd wr => ?_ + have c (r : Reg) (hr : r ∈ preserved) : s'.gpr r = s.gpr r := by + obtain ⟨h3, h4, h5, h6, -, -, h9⟩ := preserved_ne_args hr + rw [o r h3 h4 h5 h6] + exact u₁.other r h9 + have hm : s'.mem = Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots := by + rw [mem]; show Spill.saveMem s₁.mem _ _ _ = _; rw [u₁.mem, h20] + have fz : Frame [kBlk s₀] s.mem s'.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have g₁ (r : Reg) (hr : r ≠ .r9) : s₁.gpr r = s.gpr r := u₁.other r hr + refine ⟨by rw [r3, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r14], + by rw [r4, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, g₁ _ (by decide), h.r16], + by rw [r5, show ({ s₁ with mem := _ } : State).gpr = s₁.gpr from rfl, h20], + r6, + by rw [c .r20 (by decide), h.r20], by rw [c .r30 (by decide), h.r30], by rw [c .r31 (by decide), h.r31], + fun r hr hv => by rw [c r hr, h.kept r hr hv], + by rw [rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, u₁.rd, h.rd], + by rw [wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, u₁.wr, h.wr], ?_, ?_, ?_, ?_⟩ + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.ctr] + · have z₁ : s₁.gpr .r9 = (0 : BitVec 64) := u₁.gpr + rw [hm, show Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₁.gpr .r9)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .r9)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z₁] + exact zero_bytes _ _ + +theorem tail_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) (hsp : s.sp = s₀.sp) : + ctrF.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, kBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, kBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, kBlk s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [ctrF, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, State.withRegions_sp, + State.callEntry_sp, callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), h.r3, h.r4, h.r5, h.r6, hsp, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨hp.sp, trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.iv_sv.sub_right bs, hp.stk_sch, + hp.stk_iv, hp.stk_sv.sub_right bs, hp.sch_wrap, hp.iv_wrap, by rw [hp.bk_toNat]; omega⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure KCall (s₀ s : State) : Prop where + r20 : s.gpr .r20 = kV s₀ + r30 : s.gpr .r30 = BitVec.ofNat 64 (fU s₀) + r31 : s.gpr .r31 = fT s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem cipher_length (k : Spec.Sm4.Schedule) (b : List Byte) : (Spec.Sm4.cipher k b).length = 16 := by + simp [Spec.Sm4.cipher] + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) (hsp : s.sp = s₀.sp) : + WP isa ctrCall s (KCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h hsp + have big := big_of (kW1_kW h.frame) + have eK := sched_of big hp.sch_big + refine WP.callAny (k := ctrF) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, kBlk s₀]) hpre hc hw ?_ ctr_hd + intro s' rd' wr' _ fr' cs' post₂ + have fr := call_frame hsp fr' + simp only [ctrF, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry_gpr' s (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' s (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' s (by decide : Reg.r6 ∉ linkRegs), + h.r3, h.r4, h.r5, h.r6, one_toNat, h.ctr] at post₂ + rw [eK] at post₂ + have fc : Frame (kW1 s₀) s.mem s'.mem := fr.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs' .r20 (by decide), h.r20], by rw [cs' .r30 (by decide), h.r30], + by rw [cs' .r31 (by decide), h.r31], fun r hr hv => by rw [cs' r hr, h.kept r hr hv], + by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + r20 : s.gpr .r20 = kV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.r20, h.kept, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem toNat_tail {s₀ : State} (hp : KPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +/-- The XOR of the partial last block. -/ +abbrev xorCode : Prog isa := + .seq (.block tailKey) (.loop (.block Impl.Modes.PPC64LE.tailByte) (.nonzero .d .r30)) + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa xorCode s (KDone s₀) := by + refine WP.seq (wp_addi (by decide) (by decide) fun s₁ u₁ => wp_nil ?_) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have hB := hp.bk_toNat + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : Proof.Modes.PPC64LE.XPre s₁ (kBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fitK := by omega + fitR := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [u₁.rd, u₁.wr, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [u₁.wr, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : Proof.Modes.PPC64LE.XInv s₁ (kBk s₀) (fT s₀) (fU s₀) 0 s₁ := { + r8 := by rw [u₁.gpr, h.r20]; exact (BitVec.add_zero _).symm + r31 := by rw [u₁.other _ (by decide), h.r31]; exact (BitVec.add_zero _).symm + r30 := by rw [u₁.other _ (by decide), h.r30, Nat.sub_zero] + lt := by omega + data := fun q _ => by rw [ite_eq_right (Nat.not_lt_zero q)] + frame := Frame.refl _ _ + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (Proof.Modes.PPC64LE.tailLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have df : Frame [fTail s₀] s.mem s'.mem := by rw [← u₁.mem]; exact d.frame + have g (r : Reg) (h8 : r ≠ .r8) (h9 : r ≠ .r9) (h10 : r ≠ .r10) (h30 : r ≠ .r30) (h31 : r ≠ .r31) : + s'.gpr r = s.gpr r := by + rw [d.gpr r h8 h9 h10 h30 h31, u₁.other r h8] + refine ⟨by rw [g .r20 (by decide) (by decide) (by decide) (by decide) (by decide), h.r20], + fun r hr hv => ?_, by rw [d.rd, u₁.rd, h.rd], by rw [d.wr, u₁.wr, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · obtain ⟨-, h8, h9, h10, -, -, -, -, -, -, h30, h31⟩ := Proof.AesCfb.PPC64LE.Final.preserved_ne' hr hv + rw [g r h8 h9 h10 h30 h31, h.kept r hr hv] + · exact (kW1_kW h.frame).trans (df.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' df fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact h.blocks + · rw [d.data q hq, u₁.mem, h.frame.bytes tailD hlen hq, (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame df ivT (by decide), h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) (hsp : s.sp = s₀.sp) : + WP isa (.ite (.zero .d .r30) (.block []) ctrFinalTail) s (KDone s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (wp_sp (tail_args_wp hp h)) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁.1 (h₁.2.trans hsp)) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.block finalRestore) s fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.lr = s₀.lr ∧ s'.mem = s.mem := by + have hs : Spill.Saved (kV s₀) (kSaveG s₀) finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (kV s₀) (kSaveG s₀)).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + · exact hp.stk_sv.symm.sub_left hsub + rw [restore_eq] + refine Spill.restore_ok (b := .r20) (l := finalSaved) (by decide) h.r20 saved_fits (by decide) + (fun p hp' => ?_) hs fun s₃ r₃ => ?_ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + refine WP.cons exec_mtlr (wp_nil ⟨fun r hr => ?_, ?_, r₃.mem⟩) + · show s₃.gpr r = _ + have h0 : kSaveG s₀ r = s₀.gpr r := by + show (s₀.write .r0 s₀.lr).gpr r = _ + simp [State.write, preserved_ne_r0 r hr] + rw [r₃.gpr_of (r := r) ?_, h0] + by_cases hv : r ∈ vars + · left + simp only [vars, List.mem_cons, List.not_mem_nil, or_false] at hv + rcases hv with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> decide + · right; rw [h.kept r hr hv, h0] + · show s₃.gpr .r0 = _ + rw [r₃.gpr (.r0, 0) (by decide)]; rfl + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.lr = s₀.lr ∧ ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (wp_sp (setup_wp hp)) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (wp_sp (whole_wp hp h₁.1 h₁.2)) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₂.1 (h₂.2.trans h₁.2)) fun s₃ h₃ => ?_) + exact WP.mono (end_wp hp h₃) fun _ ⟨g, l, m⟩ => ⟨g, l, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalPPC64LE.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalPPC64LE.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalPPC64LE.post s s' := by + obtain ⟨t, s', he, hg, hl, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hl⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.r3, .r4, .r5, .r6, .r7]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.r14, .r16, .r20]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.r20, .r30, .r31]) xorCode h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.r20]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalPPC64LE.pre s₀) (h0' : ctrFinalPPC64LE.pre s₀') + (hq : ctrFinalPPC64LE.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + -- The registers saved and the arguments set up. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := (taintRegs (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + refine ⟨qSp, fun r hr => ?_⟩ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) t₁).wp + (F₁ := fun (s : State) => KSetup s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KSetup s₀' s ∧ s.sp = s₀'.sp) + fun a b h => by + obtain ⟨rfl, rfl⟩ := h + exact ⟨wp_sp (setup_wp hp), wp_sp (setup_wp hp')⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := ctrF) (n := "vg_sm4_ctr") ctr_ok ctr_ct + (P := fun a b => (KSetup s₀ a ∧ a.sp = s₀.sp) ∧ (KSetup s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha.1 ha.2 + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb.1 hb.2 + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_gpr' _ (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r6 ∉ linkRegs), + ha.1.r3, ha.1.r4, ha.1.r5, ha.1.r6, ha.2, hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.2] + rw [fW, fW, fIv, fIv, fD, fD, qW, qIv, qD, qSp, qN] + refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := fun (s : State) => KWhole s₀ s ∧ s.sp = s₀.sp) + (F₂ := fun (s : State) => KWhole s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (whole_wp hp h.1.1 h.1.2)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (whole_wp hp' h.2.1 h.2.2)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + -- The partial last block. + obtain ⟨_, t₃⟩ := tailArgs_taint + obtain ⟨_, t₄⟩ := xor_taint + have tail (hu : fU s₀ ≠ 0) : RelCT isa + (fun a b => (KWhole s₀ a ∧ a.sp = s₀.sp) ∧ (KWhole s₀' b ∧ b.sp = s₀'.sp)) + ctrFinalTail fun a b => (KDone s₀ a ∧ a.sp = s₀.sp) ∧ (KDone s₀' b ∧ b.sp = s₀'.sp) := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + have a₁ := (taintRegs + (P := fun a b => (KWhole s₀ a ∧ a.sp = s₀.sp) ∧ (KWhole s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.1.r14, h.2.1.r14, fW, fW, qW] + · rw [h.1.1.r16, h.2.1.r16, fIv, fIv, qIv] + · rw [h.1.1.r20, h.2.1.r20, kV, kV, qV]⟩) t₃).wp + (F₁ := fun (s : State) => KArgs s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KArgs s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_args_wp hp h.1.1)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_args_wp hp' h.2.1)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + have a₂ := (RelCT.callEx (k := ctrF) (n := "vg_sm4_ctr") ctr_ok ctr_ct + (P := fun a b => (KArgs s₀ a ∧ a.sp = s₀.sp) ∧ (KArgs s₀' b ∧ b.sp = s₀'.sp)) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha.1 ha.2 + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb.1 hb.2 + refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ + simp only [ctrF, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry_gpr' _ (by decide : Reg.r3 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r4 ∉ linkRegs), + callEntry_gpr' _ (by decide : Reg.r5 ∉ linkRegs), callEntry_gpr' _ (by decide : Reg.r6 ∉ linkRegs), + ha.1.r3, ha.1.r4, ha.1.r5, ha.1.r6, ha.2, hb.1.r3, hb.1.r4, hb.1.r5, hb.1.r6, hb.2] + rw [fW, fW, fIv, fIv, kBk, kBk, kV, kV, qW, qIv, qV, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial).wp + (F₁ := fun (s : State) => KCall s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KCall s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_call_wp hp h.1.1 h.1.2)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_call_wp hp' h.2.1 h.2.2)) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + have a₃ := (taintRegs + (P := fun a b => (KCall s₀ a ∧ a.sp = s₀.sp) ∧ (KCall s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.1.r20, h.2.1.r20, kV, kV, qV] + · rw [h.1.1.r30, h.2.1.r30, qU] + · rw [h.1.1.r31, h.2.1.r31, qT]⟩) t₄).wp + (F₁ := fun (s : State) => KDone s₀ s ∧ s.sp = s₀.sp) (F₂ := fun (s : State) => KDone s₀' s ∧ s.sp = s₀'.sp) + fun a b h => ⟨WP.mono (wp_sp (tail_xor_wp hp h.1.1 hu)) fun _ x => ⟨x.1, x.2.trans h.1.2⟩, + WP.mono (wp_sp (tail_xor_wp hp' h.2.1 hu')) fun _ x => ⟨x.1, x.2.trans h.2.2⟩⟩ + exact (a₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq + ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₃.mono (fun _ _ h => h) fun _ _ h => h.2)) + have r₃ : RelCT isa + (fun a b => (KWhole s₀ a ∧ a.sp = s₀.sp) ∧ (KWhole s₀' b ∧ b.sp = s₀'.sp)) + (.ite (.zero .d .r30) (.block []) ctrFinalTail) + (fun a b => (KDone s₀ a ∧ a.sp = s₀.sp) ∧ (KDone s₀' b ∧ b.sp = s₀'.sp)) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1.1, eval_u h.2.1, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1.1] at this; simpa using this + exact ⟨⟨done_of_zero h.1.1.1 h0, h.1.1.2⟩, ⟨done_of_zero h.1.2.1 (qU ▸ h0), h.1.2.2⟩⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1.1] at this; simpa using this + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := taintRegs + (P := fun a b => (KDone s₀ a ∧ a.sp = s₀.sp) ∧ (KDone s₀' b ∧ b.sp = s₀'.sp)) _ + (fun a b h => ⟨by rw [h.1.2, h.2.2, qSp], fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.r20, h.2.1.r20, kV, kV, qV]⟩) t₅ + exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq + (r₃.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalPPC64LE.pre ctrFinalPPC64LE.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified PPC64LE.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## Locality + +The frame needs the contract's postcondition to read the memory on entry +only within the function's buffers. -/ + +private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} + (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : + bytesAt m₂ p k = bytesAt m₁ p k := by + simp only [Spec.Aes.bytesAt] + exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) + +private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : + ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by + intro i hi + refine (h _ ?_).symm + by_cases hw : i < 2 ^ 64 + · exact Offset.contains_base _ (by omega) hw + · simp only [Region.Contains] + have := (p + BitVec.ofNat 64 i - p).isLt + omega + +/-- `ctrFinalPost` reads the memory on entry only within the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Sm4.ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs Spec.Sm4.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₁ m' r → + Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, ctr, data, len], _ => + simp only [Spec.Sm4.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hs := agree_of' hb.1 + have hc := agree_of' hb.2.1 + have hd := agree_of' hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Sm4.ctrFinalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (Proof.Sm4.ctrFinalPost pb) _ m₂ m' r + dsimp only [Curry.apply, Proof.Sm4.ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + rw [Proof.Sm4.scheduleAt_congr hs, + bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] + exact h + +/-! ## With `save` on the stack + +The final function has four argument words, so `save` is its fifth, in `r7`: +it runs its code in a frame of 112 bytes on the stack +(`withStackScratchWiped`), its 32-byte header and `save`'s 80 bytes (the +registers, then the block that held the last output block), which it zeroes +before returning. Its calls use 3296 bytes below it, so 3408 in all. -/ + +/-- A state satisfying the shared contract's precondition. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Spec.Sm4.ctrFinalContract PPC64LE.abi (3296 + 112)).pre s := by + implies_sat [Spec.Sm4.ctrFinalContract, Spec.Sm4.ctrFinalSig, PPC64LE.abi, PPC64LE.argRegs] + [ctrFinalFrameSat, ctrFinalSat] using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified PPC64LE.target (Impl.StackScratch.PPC64LE.withStackScratchWiped 112 .r7 10 ctrFinal) + (Spec.Sm4.ctrFinalContract PPC64LE.abi 3408) := by + rw [Proof.Sm4.ctrFinalContract_eq] + exact PPC64LE.Verified.stackScratchWiped (sig := Spec.Sm4.ctrFinalSig) (nm := "save") (e := .u64) (n := 10) + (post := Proof.Sm4.ctrFinalPost PPC64LE.abi.ptrBits) (wa := true) (stack := 3296) (bytes := 112) + (words := 10) ctrFinal_verified (by decide) (by decide) (by decide) + (fun _ _ _ _ _ _ => by rw [Curry.apply_const]; trivial) (ctrFinalPost_local _) + (Proof.Sm4.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Sm4.PPC64LE.CtrFinal From 517af687dd70962bbd7b8b9896f9b0573385e6fe Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 13:00:39 +0000 Subject: [PATCH 15/18] AES-OFB and CTR (AES, Camellia, SM4) final functions on RISC-V (WIP: crates to come) As on the other targets. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Artifacts/AesCtr/RISCV64.lean | 7 +- .../Artifacts/AesOfb/RISCV64.lean | 7 +- .../Artifacts/CamelliaCtr/RISCV64.lean | 7 +- .../Artifacts/Sm4Ctr/RISCV64.lean | 7 +- .../Impl/AesCtr/RISCV64/Final.lean | 74 ++ .../Impl/AesOfb/RISCV64/Final.lean | 39 + .../Impl/Camellia/RISCV64/CtrFinal.lean | 79 ++ .../Impl/Sm4/RISCV64/CtrFinal.lean | 78 ++ .../Proof/AesCfb/RISCV64/Final.lean | 54 +- .../Proof/AesCtr/RISCV64/Final.lean | 912 +++++++++++++++++ .../Proof/AesOfb/RISCV64/Final.lean | 109 ++ .../Proof/Camellia/RISCV64/CtrFinal.lean | 952 ++++++++++++++++++ .../Proof/Sm4/RISCV64/CtrFinal.lean | 951 +++++++++++++++++ 13 files changed, 3246 insertions(+), 30 deletions(-) create mode 100644 lean/VerifiedGarbage/Impl/AesCtr/RISCV64/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/AesOfb/RISCV64/Final.lean create mode 100644 lean/VerifiedGarbage/Impl/Camellia/RISCV64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Impl/Sm4/RISCV64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/AesCtr/RISCV64/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/AesOfb/RISCV64/Final.lean create mode 100644 lean/VerifiedGarbage/Proof/Camellia/RISCV64/CtrFinal.lean create mode 100644 lean/VerifiedGarbage/Proof/Sm4/RISCV64/CtrFinal.lean diff --git a/lean/VerifiedGarbage/Artifacts/AesCtr/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/AesCtr/RISCV64.lean index 970fe06b9ed..759917aea03 100644 --- a/lean/VerifiedGarbage/Artifacts/AesCtr/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/AesCtr/RISCV64.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesCtr.RISCV64.Verified +public import VerifiedGarbage.Proof.AesCtr.RISCV64.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.AesCtr.RISCV64.Lit @@ -14,6 +15,10 @@ namespace VG.Artifacts.AesCtr.RISCV64 def artifacts : List Artifact := [ Spec.Ctr.aesApi.artifact RISCV64.target { code := Impl.AesCtr.RISCV64.crypt - verified := Proof.AesCtr.keyed Proof.AesCtr.RISCV64.crypt_verified }] + verified := Proof.AesCtr.keyed Proof.AesCtr.RISCV64.crypt_verified }, + Spec.Ctr.aesFinalApi.artifact RISCV64.target { + code := Impl.StackScratch.RISCV64.withStackScratchWiped 80 .a6 10 Impl.AesCtr.RISCV64.cryptFinal + stack := 80 + verified := Proof.AesCtr.final_keyed Proof.AesCtr.RISCV64.Final.cryptFinal_framed }] end VG.Artifacts.AesCtr.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/AesOfb/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/AesOfb/RISCV64.lean index cb81bc0a98a..459c118d86c 100644 --- a/lean/VerifiedGarbage/Artifacts/AesOfb/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/AesOfb/RISCV64.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.AesOfb.RISCV64.Verified +public import VerifiedGarbage.Proof.AesOfb.RISCV64.Final public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print @@ -13,6 +14,10 @@ namespace VG.Artifacts.AesOfb.RISCV64 def artifacts : List Artifact := [ Spec.Ofb.aesApi.artifact RISCV64.target { code := Impl.AesOfb.RISCV64.crypt - verified := Proof.AesOfb.keyed Proof.AesOfb.RISCV64.crypt_verified }] + verified := Proof.AesOfb.keyed Proof.AesOfb.RISCV64.crypt_verified }, + Spec.Ofb.aesFinalApi.artifact RISCV64.target { + code := Impl.StackScratch.RISCV64.withStackScratchWiped 64 .a6 8 Impl.AesOfb.RISCV64.cryptFinal + stack := 64 + verified := Proof.AesOfb.final_keyed Proof.AesOfb.RISCV64.cryptFinal_framed }] end VG.Artifacts.AesOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/RISCV64.lean index 09c8c3fefce..9a02242d96c 100644 --- a/lean/VerifiedGarbage/Artifacts/CamelliaCtr/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/CamelliaCtr/RISCV64.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Camellia.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Camellia.RISCV64.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Camellia.RISCV64.ModesLit @@ -15,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Camellia.ctrApi.artifact RISCV64.target { code := Impl.Camellia.RISCV64.ctr stack := 3248 - verified := Proof.Camellia.RISCV64.Modes.ctr_verified }] + verified := Proof.Camellia.RISCV64.Modes.ctr_verified }, + Spec.Camellia.ctrFinalApi.artifact RISCV64.target { + code := Impl.StackScratch.RISCV64.withStackScratchWiped 80 .a5 10 Impl.Camellia.RISCV64.ctrFinal + stack := 3328 + verified := Proof.Camellia.RISCV64.CtrFinal.ctrFinal_framed }] end VG.Artifacts.CamelliaCtr.RISCV64 diff --git a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/RISCV64.lean b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/RISCV64.lean index 197a2f4ebcb..27022d5bd3e 100644 --- a/lean/VerifiedGarbage/Artifacts/Sm4Ctr/RISCV64.lean +++ b/lean/VerifiedGarbage/Artifacts/Sm4Ctr/RISCV64.lean @@ -1,6 +1,7 @@ module public import VerifiedGarbage.Proof.Sm4.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.Sm4.RISCV64.CtrFinal public import VerifiedGarbage.Proof.Framework.Registration public import VerifiedGarbage.TCB.RISCV64.Print import VerifiedGarbage.Proof.Sm4.RISCV64.ModesLit @@ -15,6 +16,10 @@ def artifacts : List Artifact := [ Spec.Sm4.ctrApi.artifact RISCV64.target { code := Impl.Sm4.RISCV64.ctr stack := 3232 - verified := Proof.Sm4.RISCV64.Modes.ctr_verified }] + verified := Proof.Sm4.RISCV64.Modes.ctr_verified }, + Spec.Sm4.ctrFinalApi.artifact RISCV64.target { + code := Impl.StackScratch.RISCV64.withStackScratchWiped 80 .a4 10 Impl.Sm4.RISCV64.ctrFinal + stack := 3312 + verified := Proof.Sm4.RISCV64.CtrFinal.ctrFinal_framed }] end VG.Artifacts.Sm4Ctr.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/AesCtr/RISCV64/Final.lean b/lean/VerifiedGarbage/Impl/AesCtr/RISCV64/Final.lean new file mode 100644 index 00000000000..441283d5b9c --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesCtr/RISCV64/Final.lean @@ -0,0 +1,74 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.RISCV64 +public import VerifiedGarbage.Impl.AesCfb.RISCV64.Final + +/-! +# AES-CTR of a message's last piece: RISC-V implementation + +`cryptFinal` (schedule = a0, rounds = a1, ctr = a2, data = a3, len = a4, +scratch = a5, save = a6): the code of `vg_aes_ctr_final`, whose +registration frames it with a buffer of its own on the stack, `save`, the +seventh argument, of 80 bytes: the return address and the caller's +callee-saved registers, then a block of the code's own. + +1. the registers saved in `save`, and the arguments kept in `s1` + (schedule), `s4` (rounds), `s5` (ctr), `s6` (scratch), `s2` (the data + after its whole blocks), `s3` (`u = len mod 16`, the bytes after them) and + `s7` (`save`), as AES-CFB's final functions do + (`Impl/AesCfb/RISCV64/Final.lean`); +2. a call of the whole-block function `vg_aes_ctr` + (`Impl/AesCtr/RISCV64.lean`) on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of the + same function on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time (the modes' `xorStep`, from `t2`, the block, + into `s2`, `s3` bytes); +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds`, `len` and the last 32 bits of the counter block +can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesCtr.RISCV64 + +open VG.RISCV64 +open VG.Impl.AesCbc.RISCV64 (mov) +open VG.Impl.AesCfb.RISCV64 (finalSetup finalRestore) +open VG.Impl.Modes.RISCV64 (xorStep) + +/-- The two doublewords of the block after the registers in `save`, each +zeroed from `t0`. -/ +def zeroSlots : List (Reg × Nat) := [(.t0, 64), (.t0, 72)] + +/-- The arguments of the whole-block function on that block: the schedule, +the rounds, the counter block, the block, `n = 1`, and the working space. -/ +def tailMoves : List Instr := + [mov .a0 .s1, mov .a1 .s4, mov .a2 .s5, .addi .a3 .s7 64, .li .a4 1, mov .a5 .s6] + +/-- The block, from `save` in `s7`, zeroed, and the arguments of the +whole-block function on it. -/ +def tailArgs : List Instr := + .li .t0 0 :: (zeroSlots.map fun p => .store .d p.1 .s7 p.2) ++ tailMoves + +/-- The block's address, from `save` in `s7`, for the XOR. -/ +def tailKey : List Instr := [.addi .t2 .s7 64] + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, by a call of `vg_aes_ctr` on it, and its first `u` bytes XORed into +the data. -/ +def finalTail : Prog isa := + .seq (.block tailArgs) (.seq (.call "vg_aes_ctr" crypt) + (.seq (.block tailKey) (.loop (.block xorStep) (.nonzero .s3)))) + +/-- `vg_aes_ctr_final`, calling `vg_aes_ctr`. -/ +def cryptFinal : Prog isa := + .seq (.block finalSetup) (.seq (.call "vg_aes_ctr" crypt) + (.seq (.ite (.zero .s3) (.block []) finalTail) (.block finalRestore))) + +end VG.Impl.AesCtr.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/AesOfb/RISCV64/Final.lean b/lean/VerifiedGarbage/Impl/AesOfb/RISCV64/Final.lean new file mode 100644 index 00000000000..2287c49b286 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/AesOfb/RISCV64/Final.lean @@ -0,0 +1,39 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.RISCV64 +public import VerifiedGarbage.Impl.AesCfb.RISCV64.Final + +/-! +# AES-OFB of a message's last piece: RISC-V implementation + +`cryptFinal` (schedule = a0, rounds = a1, iv = a2, data = a3, len = a4, +scratch = a5, save = a6): the code of `vg_aes_ofb_final`, whose +registration frames it with a buffer of its own on the stack, `save`, the +seventh argument, where the code keeps its return address and its caller's +callee-saved registers. It is AES-CFB's final function +(`Impl.AesCfb.RISCV64.final`) around a call of the whole-block AES-OFB +function, `vg_aes_ofb` (`Impl/AesOfb/RISCV64.lean`): + +1. the return address and the registers saved in `save`, and the arguments + kept in callee-saved registers; +2. a call of `vg_aes_ofb` on the `len / 16` whole blocks, which leaves the + last output block `Oₙ` in `iv`; +3. if `u = len mod 16 ≠ 0`, a call of the block function + `vg_aes_encrypt_blocks` on the block at `iv` in place, which leaves + `Oₙ₊₁ = CIPH_K(Oₙ)` there, the last output block used, and its first `u` + bytes XORed into the `u` bytes left, a byte at a time; +4. the registers restored. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.AesOfb.RISCV64 + +open VG.RISCV64 + +/-- `vg_aes_ofb_final`, calling `vg_aes_ofb`. -/ +def cryptFinal : Prog isa := Impl.AesCfb.RISCV64.final "vg_aes_ofb" crypt + +end VG.Impl.AesOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Camellia/RISCV64/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Camellia/RISCV64/CtrFinal.lean new file mode 100644 index 00000000000..0fb26db2812 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Camellia/RISCV64/CtrFinal.lean @@ -0,0 +1,79 @@ +module + +public import VerifiedGarbage.Impl.Camellia.RISCV64.Modes +public import VerifiedGarbage.Impl.AesCtr.RISCV64.Final + +/-! +# Camellia-CTR of a message's last piece: RISC-V implementation + +`ctrFinal` (schedule = a0, rounds = a1, ctr = a2, data = a3, len = a4, +save = a5): the code of `vg_camellia_ctr_final`, whose registration frames +it with a buffer of its own on the stack, `save`, of 80 bytes, passed in +`a5`: the return address and the caller's callee-saved registers, then a +block of the code's own. It is AES-CTR's final function's +(`Impl/AesCtr/RISCV64/Final.lean`) with Camellia's arguments, around calls +of `vg_camellia_ctr` (`Impl.Camellia.RISCV64.ctr`), which keeps its own +working space on the stack below: + +1. the registers saved in `save` (AES-CFB's final functions' slots, + `finalSaved`), and the arguments kept in `s1` (schedule), `s4` (rounds), + `s5` (ctr), `s2` (the data after its whole blocks), `s3` + (`u = len mod 16`, the bytes after them) and `s7` (`save`); +2. a call of `vg_camellia_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_camellia_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers, `rounds` and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Camellia.RISCV64 + +open VG.RISCV64 +open VG.Impl.AesCbc.RISCV64 (mov) +open VG.Impl.AesCfb.RISCV64 (finalSaved finalRestore) +open VG.Impl.AesCtr.RISCV64 (zeroSlots tailKey) +open VG.Impl.Modes.RISCV64 (xorStep) + +/-- The registers saved in `save`, at `a5`. -/ +def ctrFinalSave : List Instr := finalSaved.map fun (r, d) => .store .d r .a5 d + +/-- The arguments to their registers, `s2` and `s3` the data after the +whole blocks and its length, `s7` `save`, and `a4` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [mov .s1 .a0, mov .s4 .a1, mov .s5 .a2, mov .s7 .a5, .shift .srl .d .t0 .a4 4, + .shift .sll .d .t1 .t0 4, .add .s2 .a3 .t1, .sub .s3 .a4 .t1, mov .a4 .t0] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrFinalSave ++ ctrFinalMoves + +/-- The arguments of `vg_camellia_ctr` on the block after the registers: +the schedule, the rounds, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [mov .a0 .s1, mov .a1 .s4, mov .a2 .s5, .addi .a3 .s7 64, .li .a4 1] + +/-- The block, from `save` in `s7`, zeroed, and the arguments of +`vg_camellia_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .li .t0 0 :: (zeroSlots.map fun p => .store .d p.1 .s7 p.2) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq (.call "vg_camellia_ctr" ctr) + (.seq (.block tailKey) (.loop (.block xorStep) (.nonzero .s3)))) + +/-- `vg_camellia_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq (.call "vg_camellia_ctr" ctr) + (.seq (.ite (.zero .s3) (.block []) ctrFinalTail) (.block finalRestore))) + +end VG.Impl.Camellia.RISCV64 diff --git a/lean/VerifiedGarbage/Impl/Sm4/RISCV64/CtrFinal.lean b/lean/VerifiedGarbage/Impl/Sm4/RISCV64/CtrFinal.lean new file mode 100644 index 00000000000..9f27789e2b9 --- /dev/null +++ b/lean/VerifiedGarbage/Impl/Sm4/RISCV64/CtrFinal.lean @@ -0,0 +1,78 @@ +module + +public import VerifiedGarbage.Impl.Sm4.RISCV64.Modes +public import VerifiedGarbage.Impl.AesCtr.RISCV64.Final + +/-! +# SM4-CTR of a message's last piece: RISC-V implementation + +`ctrFinal` (schedule = a0, ctr = a1, data = a2, len = a3, save = a4): the +code of `vg_sm4_ctr_final`, whose registration frames it with a buffer of +its own on the stack, `save`, of 80 bytes, passed in `a4`: the return +address and the caller's callee-saved registers, then a block of the code's +own. It is AES-CTR's final function's (`Impl/AesCtr/RISCV64/Final.lean`) +with SM4's arguments, around calls of `vg_sm4_ctr` (`Impl.Sm4.RISCV64.ctr`), +which keeps its own working space on the stack below: + +1. the registers saved in `save` (AES-CFB's final functions' slots, + `finalSaved`), and the arguments kept in `s1` (schedule), `s5` (ctr), + `s2` (the data after its whole blocks), `s3` (`u = len mod 16`, the bytes + after them) and `s7` (`save`); +2. a call of `vg_sm4_ctr` on the `len / 16` whole blocks, which leaves + `Tₙ₊₁` in `ctr`; +3. if `u ≠ 0`, the block after the registers in `save` zeroed, a call of + `vg_sm4_ctr` on that one block, which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and the first `u` bytes of the block XORed into the `u` + bytes left, a byte at a time; +4. the registers restored. + +The registration's frame zeroes `save`, the block included, on return. + +Only the pointers and `len` can affect timing. +-/ + +@[expose] public section + +namespace VG.Impl.Sm4.RISCV64 + +open VG.RISCV64 +open VG.Impl.AesCbc.RISCV64 (mov) +open VG.Impl.AesCfb.RISCV64 (finalSaved finalRestore) +open VG.Impl.AesCtr.RISCV64 (zeroSlots tailKey) +open VG.Impl.Modes.RISCV64 (xorStep) + +/-- The registers saved in `save`, at `a4`. -/ +def ctrFinalSave : List Instr := finalSaved.map fun (r, d) => .store .d r .a4 d + +/-- The arguments to their registers, `s2` and `s3` the data after the +whole blocks and its length, `s7` `save`, and `a3` the number of whole +blocks. -/ +def ctrFinalMoves : List Instr := + [mov .s1 .a0, mov .s5 .a1, mov .s7 .a4, .shift .srl .d .t0 .a3 4, + .shift .sll .d .t1 .t0 4, .add .s2 .a2 .t1, .sub .s3 .a3 .t1, mov .a3 .t0] + +/-- The registers saved; the arguments to their registers. -/ +def ctrFinalSetup : List Instr := ctrFinalSave ++ ctrFinalMoves + +/-- The arguments of `vg_sm4_ctr` on the block after the registers: +the schedule, the counter block, the block and `n = 1`. -/ +def ctrFinalTailMoves : List Instr := + [mov .a0 .s1, mov .a1 .s5, .addi .a2 .s7 64, .li .a3 1] + +/-- The block, from `save` in `s7`, zeroed, and the arguments of +`vg_sm4_ctr` on it. -/ +def ctrFinalTailArgs : List Instr := + .li .t0 0 :: (zeroSlots.map fun p => .store .d p.1 .s7 p.2) ++ ctrFinalTailMoves + +/-- The partial last block: the output block `CIPH_K(Tₙ₊₁)` in the block of +`save`, and its first `u` bytes XORed into the data. -/ +def ctrFinalTail : Prog isa := + .seq (.block ctrFinalTailArgs) (.seq (.call "vg_sm4_ctr" ctr) + (.seq (.block tailKey) (.loop (.block xorStep) (.nonzero .s3)))) + +/-- `vg_sm4_ctr_final`. -/ +def ctrFinal : Prog isa := + .seq (.block ctrFinalSetup) (.seq (.call "vg_sm4_ctr" ctr) + (.seq (.ite (.zero .s3) (.block []) ctrFinalTail) (.block finalRestore))) + +end VG.Impl.Sm4.RISCV64 diff --git a/lean/VerifiedGarbage/Proof/AesCfb/RISCV64/Final.lean b/lean/VerifiedGarbage/Proof/AesCfb/RISCV64/Final.lean index 06e6513b1cc..ff18029df5d 100644 --- a/lean/VerifiedGarbage/Proof/AesCfb/RISCV64/Final.lean +++ b/lean/VerifiedGarbage/Proof/AesCfb/RISCV64/Final.lean @@ -83,7 +83,9 @@ verified functions, through their contracts (`WP.call`, `blk_call`): Constant time (`final_rel`): the blocks by the taint analysis, the calls by their contracts' constant time (`RelCT.callEx`, `blk_rel`), every address and branch from the pointers and `len`, which agree in both runs. -`encryptFinal_framed` runs the code with `save` in a frame of 64 bytes on +`final_wp` and `final_rel` hold for any mode `M` of the whole-block +function, so AES-OFB's final function (`Proof/AesOfb/RISCV64/Final.lean`) +reuses them. `encryptFinal_framed` runs the code with `save` in a frame of 64 bytes on the stack (`RISCV64.Verified.stackScratchWiped`), zeroed on return. -/ @@ -772,10 +774,10 @@ theorem agree_of {s₁ s₂ : State} {rs : List Reg} (hsp : s₁.sp = s₂.sp) ( taint.Agree (Taint.ofRegs rs) s₁ s₂ := ⟨hsp, fun r hr => h r (Taint.mem_ofRegs.mp hr)⟩ -theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeRISCV64 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeRISCV64 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeRISCV64 (cfbMode enc)).pre (modeRISCV64 (cfbMode enc)).pub whole) +theorem final_rel {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeRISCV64 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeRISCV64 M).post s s') + (hct : ConstantTime isa (modeRISCV64 M).pre (modeRISCV64 M).pub whole) (nf : whole.noFrames = true) {s₀ s₀' : State} (h0 : (finalRISCV64 enc).pre s₀) (h0' : (finalRISCV64 enc).pre s₀') (hq : (finalRISCV64 enc).pub s₀ s₀') : RelCT isa (fun a b => a = s₀ ∧ b = s₀') (final name whole) fun _ _ => True := by @@ -797,10 +799,10 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} (F₁ := Setup s₀) (F₂ := Setup s₀') fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩ -- The whole blocks. - have r₂ := (RelCT.callEx (k := modeRISCV64 (cfbMode enc)) (n := name) hv hct + have r₂ := (RelCT.callEx (k := modeRISCV64 M) (n := name) hv hct (P := fun a b => Setup s₀ a ∧ Setup s₀' b) fun a b ⟨ha, hb⟩ => by - obtain ⟨pa, ca, wa⟩ := whole_pre (M := cfbMode enc) hp ha - obtain ⟨pb, cb, wb⟩ := whole_pre (M := cfbMode enc) hp' hb + obtain ⟨pa, ca, wa⟩ := whole_pre (M := M) hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre (M := M) hp' hb refine ⟨_, _, _, _, pa, pb, ?_, ca, wa, cb, wb⟩ simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), @@ -812,7 +814,7 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} ha.a0, ha.a1, ha.a2, ha.a3, ha.a4, ha.a5, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.a4, hb.a5, hb.sp] rw [fW, fW, fIv, fIv, fD, fD, fS, fS, qW, qR, qIv, qD, qS, qSp, qN] exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩).wp - (F₁ := Whole (cfbMode enc) s₀) (F₂ := Whole (cfbMode enc) s₀') + (F₁ := Whole M s₀) (F₂ := Whole M s₀') fun a b h => ⟨whole_wp hv nf hp h.1, whole_wp hv nf hp' h.2⟩ -- The partial last segment. obtain ⟨_, t₃⟩ : ∃ h, (taint.check (Taint.ofRegs [.s1, .s4, .s5, .s6]) @@ -821,11 +823,11 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} (.seq (.block [Impl.AesCbc.RISCV64.mov .t2 .s5]) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) h).isSome = true := ⟨_, by taint_decide⟩ - have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) - finalTail fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b := by + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) + finalTail fun a b => Done M s₀ a ∧ Done M s₀' b := by have hu' : fU s₀' ≠ 0 := qU ▸ hu have a₃ := (RelCT.taint (A := taint) - (P := fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) _ + (P := fun a b => Whole M s₀ a ∧ Whole M s₀' b) _ (fun a b h => agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl | rfl @@ -833,11 +835,11 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} · rw [h.1.s4, h.2.s4, qR] · rw [h.1.s5, h.2.s5, fIv, fIv, qIv] · rw [h.1.s6, h.2.s6, fS, fS, qS]) t₃).wp - (F₁ := IvA (cfbMode enc) s₀) (F₂ := IvA (cfbMode enc) s₀') + (F₁ := IvA M s₀) (F₂ := IvA M s₀') fun a b h => ⟨final_ivArgs_wp hp h.1, final_ivArgs_wp hp' h.2⟩ have a₄ := (AesCbc.RISCV64.blk_rel (name := "vg_aes_encrypt_blocks") Proof.Aes.RISCV64.encryptBlocks_correct Proof.Aes.RISCV64.encryptBlocks_ct - (P := fun a b => IvA (cfbMode enc) s₀ a ∧ IvA (cfbMode enc) s₀' b) + (P := fun a b => IvA M s₀ a ∧ IvA M s₀' b) fun a b h => by have e₂ := h.2.pre have eW : fW s₀' = fW s₀ := qW.symm @@ -846,23 +848,23 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} have eR : fR s₀' = fR s₀ := by simp only [fR, qR] rw [eW, eIv, eS, eR] at e₂ exact ⟨h.1.pre, e₂, by rw [h.1.whole.sp, h.2.whole.sp, qSp]⟩).wp - (F₁ := Ciph (cfbMode enc) s₀) (F₂ := Ciph (cfbMode enc) s₀') + (F₁ := Ciph M s₀) (F₂ := Ciph M s₀') fun a b h => ⟨final_ciph_wp hp h.1, final_ciph_wp hp' h.2⟩ have a₅ := (RelCT.taint (A := taint) - (P := fun a b => Ciph (cfbMode enc) s₀ a ∧ Ciph (cfbMode enc) s₀' b) _ + (P := fun a b => Ciph M s₀ a ∧ Ciph M s₀' b) _ (fun a b h => agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by simp only [List.mem_cons, List.not_mem_nil, or_false] at hr rcases hr with rfl | rfl | rfl · rw [h.1.s5, h.2.s5, fIv, fIv, qIv] · rw [h.1.s2, h.2.s2, qT] · rw [h.1.s3, h.2.s3, qU]) t₄).wp - (F₁ := Done (cfbMode enc) s₀) (F₂ := Done (cfbMode enc) s₀') + (F₁ := Done M s₀) (F₂ := Done M s₀') fun a b h => ⟨final_xor_wp hp h.1 hu, final_xor_wp hp' h.2 hu'⟩ exact (a₃.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((a₄.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₅.mono (fun _ _ h => h) fun _ _ h => h.2)) - have r₃ : RelCT isa (fun a b => Whole (cfbMode enc) s₀ a ∧ Whole (cfbMode enc) s₀' b) + have r₃ : RelCT isa (fun a b => Whole M s₀ a ∧ Whole M s₀' b) (.ite (.zero .s3) (.block []) finalTail) - (fun a b => Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) := by + (fun a b => Done M s₀ a ∧ Done M s₀' b) := by refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ · refine RelCT.block_nil fun a b h => ?_ have h0 : fU s₀ = 0 := by @@ -878,17 +880,17 @@ theorem final_rel {enc : Bool} {name : String} {whole : Prog isa} -- The registers restored. obtain ⟨_, t₅⟩ : ∃ h, (taint.check (Taint.ofRegs [.s7]) (.block finalRestore) h).isSome = true := ⟨_, by taint_decide⟩ - have r₄ := RelCT.taint (A := taint) (P := fun a b => (Done (cfbMode enc) s₀ a ∧ Done (cfbMode enc) s₀' b) ∧ + have r₄ := RelCT.taint (A := taint) (P := fun a b => (Done M s₀ a ∧ Done M s₀' b) ∧ a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ (fun a b h => agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.s7, h.1.2.s7, fV, fV, qV]) t₅ exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (r₃'.seq r₄)) -theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} - (hv : ∀ s, (modeRISCV64 (cfbMode enc)).pre s → - ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeRISCV64 (cfbMode enc)).post s s') - (hct : ConstantTime isa (modeRISCV64 (cfbMode enc)).pre (modeRISCV64 (cfbMode enc)).pub whole) +theorem final_ct {enc : Bool} {M : Mode} {name : String} {whole : Prog isa} + (hv : ∀ s, (modeRISCV64 M).pre s → + ∃ t s', Exec isa whole s t s' ∧ abiPreserved s s' ∧ (modeRISCV64 M).post s s') + (hct : ConstantTime isa (modeRISCV64 M).pre (modeRISCV64 M).pub whole) (nf : whole.noFrames = true) : ConstantTime isa (finalRISCV64 enc).pre (finalRISCV64 enc).pub (final name whole) := fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel hv hct nf h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 @@ -897,11 +899,11 @@ theorem final_ct {enc : Bool} {name : String} {whole : Prog isa} theorem encryptFinal_verified : Verified RISCV64.target encryptCode (finalScratchContract true) := Verified.of_correct (final_correct encrypt_correct encrypt_noFrames) - (final_ct encrypt_correct encrypt_ct encrypt_noFrames) (final_implies true) + (final_ct (enc := true) encrypt_correct encrypt_ct encrypt_noFrames) (final_implies true) theorem decryptFinal_verified : Verified RISCV64.target decryptCode (finalScratchContract false) := Verified.of_correct (final_correct decrypt_correct decrypt_noFrames) - (final_ct decrypt_correct decrypt_ct decrypt_noFrames) (final_implies false) + (final_ct (enc := false) decrypt_correct decrypt_ct decrypt_noFrames) (final_implies false) /-! ## With `save` on the stack diff --git a/lean/VerifiedGarbage/Proof/AesCtr/RISCV64/Final.lean b/lean/VerifiedGarbage/Proof/AesCtr/RISCV64/Final.lean new file mode 100644 index 00000000000..69789cd82c9 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesCtr/RISCV64/Final.lean @@ -0,0 +1,912 @@ +module + +public import VerifiedGarbage.Impl.AesCtr.RISCV64.Final +public import VerifiedGarbage.Proof.AesCtr.Final +public import VerifiedGarbage.Proof.AesCtr.RISCV64.Verified +public import VerifiedGarbage.Proof.AesCtr.RISCV64.CT +public import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.RISCV64.Spill +public import VerifiedGarbage.Impl.StackScratch.RISCV64 +import VerifiedGarbage.Proof.AesCtr.RISCV64.Call +import VerifiedGarbage.Proof.AesCtr.RISCV64.Lit +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.AesCtr.Spec +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.RISCV64.CT +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.Words +import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.RISCV64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.RISCV64.RegUpd +import VerifiedGarbage.Proof.Framework.RISCV64.Steps +import VerifiedGarbage.Proof.Framework.RISCV64.Exec +import VerifiedGarbage.Proof.Framework.RISCV64.Taint +import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.AesCtr.RISCV64.Final +meta import VerifiedGarbage.Proof.AesCtr.Final +meta import VerifiedGarbage.Proof.AesCtr.RISCV64.Verified +meta import VerifiedGarbage.Proof.AesCtr.RISCV64.CT +meta import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.RISCV64.Spill +meta import VerifiedGarbage.Impl.StackScratch.RISCV64 +meta import VerifiedGarbage.Proof.AesCtr.RISCV64.Call +meta import VerifiedGarbage.Proof.AesCtr.RISCV64.Lit +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.AesCtr.Spec +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCbc.RISCV64.CT +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.Words +meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.RISCV64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.RISCV64.RegUpd +meta import VerifiedGarbage.Proof.Framework.RISCV64.Steps +meta import VerifiedGarbage.Proof.Framework.RISCV64.Exec +meta import VerifiedGarbage.Proof.Framework.RISCV64.Taint +meta import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# AES-CTR of a message's last piece on RISC-V + +`cryptFinal_framed`: `vg_aes_ctr_final` (`Impl/AesCtr/RISCV64/Final.lean`) +meets `Proof.AesCtr.finalRoundsContract`, from which the shared contract +follows (`Proof.AesCtr.final_keyed`). + +The code is proven against `ctrFinalRISCV64`, with a seventh argument `save` +(`a6`) of 80 bytes, for its return address and its caller's registers and a +block of its own (`final_implies`: the shared contract with it, +`finalScratchContract`), as a caller of the whole-block function, through its +contract (`modeRISCV64 ctrMode`, with `ctrPub`). It shares AES-CFB's final +functions' setup (`Proof/AesCfb/RISCV64/Final.lean`: `Setup`, `Whole`): + +* `final_setup_wp`, `whole_wp`: the registers saved, and the whole-block + function on the `n = len / 16` whole blocks (`Whole`); +* `final_mid_wp`: if `u = len % 16` bytes are left, the block after the + registers in `save` zeroed and the whole-block function on it + (`tail_args_wp`, `tail_call_wp`), which leaves `CIPH_K(Tₙ₊₁)` there and + `Tₙ₊₂` in `ctr`, and its first `u` bytes XORed into them + (`Modes.RISCV64.xorLoop_wp`, `tail_xor_wp`); what is left before the + registers are restored is `Done`; +* `final_end_wp`: the registers restored; +* `final_post`: `Done` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`). + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the whole-block function's constant time, whose public data, the last 32 +bits of the counter block, agree in both runs at both calls: they do on +entry (the contract's leak), and after `n` blocks they are those on entry +plus `n` modulo `2³²`. +-/ + +@[expose] public section + +namespace VG.Proof.AesCtr.RISCV64.Final + +open VG VG.RISCV64 +open VG.Spec.Aes (bytesAt) +open VG.Impl.AesCtr.RISCV64 (tailArgs tailMoves tailKey zeroSlots finalTail cryptFinal crypt) +open VG.Impl.AesCfb.RISCV64 (finalSaved finalMoves finalSetup finalRestore) +open VG.Proof.AesCfb.RISCV64.Final (fW fR fIv fD fL fS fV fN fU fT fSch fIvR fData fBlk fTail fScr fSv + fWk fIv0 fBlks svMem Setup Whole Kept finalSat finalFrameSat shr4 shr4_shl4 sub_shl4 cs_of callEntry + toNat_n eval_u bytesAt_getD blocksAt_frame' svMem_frame saved_slots saved_fits blk_sub tail_sub fN_eq + fU_eq n_lt u_lt agree_of upd_gpr a1_ofNat) +open VG.Proof.AesCbc (Mode) +open VG.RISCV64.Steps +open VG.Proof.AesCbc.RISCV64 (modeRISCV64 one_toNat) + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = a0, rounds = a1, +ctr = a2, data = a3, len = a4, scratch = a5, save = a6)`, `save` of 80 +bytes: the data and the counter block as `Spec.Ctr.CryptFinal` says, by AES +with the key schedule it is given; the counter block's last four bytes are +public. -/ +def ctrFinalRISCV64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .a0, 240⟩ + let iv : Region := ⟨s.gpr .a2, 16⟩ + let data : Region := ⟨s.gpr .a3, (s.gpr .a4).toNat⟩ + let scr : Region := ⟨s.gpr .a5, 2176⟩ + let sv : Region := ⟨s.gpr .a6, 80⟩ + s.rd = [sched] ∧ s.wr = [iv, data, scr, sv] ∧ + sched.Disjoint iv ∧ sched.Disjoint data ∧ sched.Disjoint scr ∧ sched.Disjoint sv ∧ + iv.Disjoint data ∧ iv.Disjoint scr ∧ iv.Disjoint sv ∧ + data.Disjoint scr ∧ data.Disjoint sv ∧ scr.Disjoint sv ∧ + (s.gpr .a0).toNat + 240 ≤ 2 ^ 64 ∧ (s.gpr .a2).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .a3).toNat + (s.gpr .a4).toNat ≤ 2 ^ 64 ∧ (s.gpr .a5).toNat + 2176 ≤ 2 ^ 64 ∧ + (s.gpr .a6).toNat + 80 ≤ 2 ^ 64 ∧ (s.gpr .a6).toNat % 8 = 0 ∧ + ((s.gpr .a1).toNat = 10 ∨ (s.gpr .a1).toNat = 12 ∨ (s.gpr .a1).toNat = 14) + post s s' := + Spec.Ctr.CryptFinal (ciphAt s.mem (s.gpr .a0) (s.gpr .a1).toNat) s.mem s'.mem (s.gpr .a2) (s.gpr .a3) + (s.gpr .a4).toNat + pub s₁ s₂ := + (s₁.gpr .a0 = s₂.gpr .a0 ∧ s₁.gpr .a1 = s₂.gpr .a1 ∧ s₁.gpr .a2 = s₂.gpr .a2 ∧ + s₁.gpr .a3 = s₂.gpr .a3 ∧ s₁.gpr .a4 = s₂.gpr .a4 ∧ s₁.gpr .a5 = s₂.gpr .a5 ∧ + s₁.gpr .a6 = s₂.gpr .a6 ∧ s₁.sp = s₂.sp) ∧ + Spec.Ctr.ctrLeak s₁.mem (s₁.gpr .a2) = Spec.Ctr.ctrLeak s₂.mem (s₂.gpr .a2) + +/-- The contract the frame needs: the shared one, with `save`, 80 bytes, as +a seventh argument, and no stack (a call keeps its return address in +`ra`). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract RISCV64.abi Spec.Ctr.aesFinalSig "save" .u64 10 (finalPre RISCV64.abi.ptrBits) + (finalPost RISCV64.abi.ptrBits) false 0 (some (finalLeak RISCV64.abi.ptrBits)) + +/-- A state satisfying the precondition. -/ +def ctrSat : State := { finalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 2176⟩, ⟨0x6000, 80⟩] } + +theorem final_implies : ctrFinalRISCV64.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ctr.aesFinalSig, finalPre, finalPost, finalLeak, Spec.Ctr.ctrLeak, ctrFinalRISCV64, RISCV64.abi, + RISCV64.argRegs] [ctrSat, finalSat] using ctrSat + +/-! ## The arguments, by name -/ + +section +variable (s₀ : State) + +/-- `save`, the registers then the block. -/ +abbrev cSv : Region := ⟨fV s₀, 80⟩ +/-- The block after the registers in `save`. -/ +abbrev cBk : Addr := fV s₀ + BitVec.ofNat 64 64 +abbrev cBlk : Region := ⟨cBk s₀, 16⟩ + +end + +/-- The precondition, by name. -/ +structure CPre (s₀ : State) : Prop where + rd : s₀.rd = [fSch s₀] + wr : s₀.wr = [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + sch_iv : (fSch s₀).Disjoint (fIvR s₀) + sch_data : (fSch s₀).Disjoint (fData s₀) + sch_scr : (fSch s₀).Disjoint (fScr s₀) + sch_sv : (fSch s₀).Disjoint (cSv s₀) + iv_data : (fIvR s₀).Disjoint (fData s₀) + iv_scr : (fIvR s₀).Disjoint (fScr s₀) + iv_sv : (fIvR s₀).Disjoint (cSv s₀) + data_scr : (fData s₀).Disjoint (fScr s₀) + data_sv : (fData s₀).Disjoint (cSv s₀) + scr_sv : (fScr s₀).Disjoint (cSv s₀) + sch_wrap : (fW s₀).toNat + 240 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + scr_wrap : (fS s₀).toNat + 2176 ≤ 2 ^ 64 + sv_wrap : (fV s₀).toNat + 80 ≤ 2 ^ 64 + sv_al : (fV s₀).toNat % 8 = 0 + rounds : fR s₀ = 10 ∨ fR s₀ = 12 ∨ fR s₀ = 14 + +theorem CPre.of {s₀ : State} (h : ctrFinalRISCV64.pre s₀) : CPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19⟩ + +/-! ## Regions -/ + +theorem sv64_sub (s₀ : State) : Region.Sub (fSv s₀) (cSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (cBlk s₀) (cSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : CPre s₀) +include hp + +theorem CPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem CPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem CPre.sched_sub : Region.Sub ⟨fW s₀, 16 * (fR s₀ + 1)⟩ (fSch s₀) := + Region.sub_prefix (by rcases hp.rounds with h | h | h <;> omega) + +theorem CPre.sched_len : 16 * (fR s₀ + 1) ≤ 2 ^ 64 := by + rcases hp.rounds with h | h | h <;> omega + +end + +/-- The save changes only `save`. -/ +theorem svMem_frame' (s₀ : State) : Frame [cSv s₀] s₀.mem (svMem s₀) := + (svMem_frame s₀).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨cSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨fV s₀ + BitVec.ofNat 64 p.2, 8⟩ (cBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +/-! ## Saving the registers, and the whole blocks -/ + +set_option linter.unusedSimpArgs false in +theorem final_setup_wp {s₀ : State} (hp : CPre s₀) : WP isa (.block finalSetup) s₀ (Setup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions s₀.wr (s₀.gpr .a6 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [hp.wr] + have := saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .a6 finalSaved ++ finalMoves)) _ _ + refine Spill.save_ok hp.sv_al saved_fits hw ?_ + unfold finalMoves Impl.AesCbc.RISCV64.mov + refine wp_mv fun s₁ u₁ => wp_mv fun s₂ u₂ => wp_mv fun s₃ u₃ => wp_mv fun s₄ u₄ => wp_mv fun s₅ u₅ => + wp_srl (by decide) fun s₆ u₆ => wp_sll (by decide) fun s₇ u₇ => wp_add fun s₈ u₈ => + wp_sub fun s₉ u₉ => wp_mv fun s₁₀ u₁₀ => WP.block_nil ?_ + exact { + s1 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s4 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s5 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s2 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4_shl4] + s3 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4_shl4, sub_shl4] + s6 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s7 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a0 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a1 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a2 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a3 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a4 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4] + a5 := by simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + kept := fun r hr => by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp only [upd_gpr u₁₀, upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + sp := by rw [u₁₀.sp, u₉.sp, u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, u₂.sp, u₁.sp] + mem := by rw [u₁₀.mem, u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + rd := by rw [u₁₀.rd, u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + wr := by rw [u₁₀.wr, u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] } + +theorem crypt_noFrames : crypt.noFrames = true := by + simp only [crypt, Impl.AesCbc.RISCV64.whole, Impl.AesCtr.RISCV64.body, Impl.AesCtr.RISCV64.ctrCall, + Code.noFrames, Bool.and_self, Bool.and_true, Bool.true_and] + exact ctr32_noFrames + +/-- The whole-block function's contract: `modeRISCV64 ctrMode`, with the +last 32 bits of the counter block public. -/ +abbrev wholeK : Contract isa := { modeRISCV64 AesCtr.ctrMode with pub := ctrPub } + +theorem whole_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, fBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, fBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, fBlk s₀, fScr s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), callEntry s (by decide : Reg.a5 ∉ linkRegs), + h.a0, h.a1, h.a2, h.a3, h.a4, h.a5, toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), hp.sch_scr, + hp.iv_data.sub_right (blk_sub s₀), hp.iv_scr, hp.data_scr.sub_left (blk_sub s₀), + hp.iv_wrap, hp.blk_wrap, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- The schedule, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : CPre s₀) : + bytesAt (svMem s₀) (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ ∧ bytesAt (svMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ + Spec.Cbc.blocksAt (svMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame' s₀ + exact ⟨Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv.sub_left hp.sched_sub) hp.sched_len, + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +theorem whole_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Setup s₀ s) : + WP isa (.call "vg_aes_ctr" crypt) s (Whole AesCtr.ctrMode s₀) := by + obtain ⟨eW, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.call (k := wholeK) crypt_correct (rd := [fSch s₀]) (wr := [fIvR s₀, fBlk s₀, fScr s₀]) hpre + hc hw ?_ crypt_noFrames + intro s' rd' wr' sp' fr' cs' _ post₂ + rw [h.mem] at fr' + simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), h.a0, h.a1, h.a2, h.a3, h.a4, + toNat_n, h.mem, eW, eIv, eB] at post₂ + exact ⟨by rw [cs_of cs' .s1 (by simp), h.s1], by rw [cs_of cs' .s4 (by simp), h.s4], + by rw [cs_of cs' .s5 (by simp), h.s5], by rw [cs_of cs' .s2 (by simp), h.s2], + by rw [cs_of cs' .s3 (by simp), h.s3], by rw [cs_of cs' .s6 (by simp), h.s6], + by rw [cs_of cs' .s7 (by simp), h.s7], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], fr', post₂.1, post₂.2⟩ + +/-! ## The partial last block: its arguments -/ + +/-- Two zeroed doublewords make 16 zero bytes. -/ +theorem zero_bytes (m : Mem) (B : Addr) : + bytesAt ((m.writeW B (0 : BitVec 64)).writeW (B + BitVec.ofNat 64 8) (0 : BitVec 64)) B 16 = + List.replicate 16 0 := by + apply List.ext_getElem (by simp [bytesAt]) + intro i h₁ _ + have hi : i < 16 := by simpa [bytesAt] using h₁ + simp only [bytesAt, List.getElem_map, List.getElem_range, List.getElem_replicate, Mem.writeW, Mem.write, + Mem.sub_ofNat_toNat B (show i < 2 ^ 64 by omega), Offset.sub_toNat' B (show 8 < 2 ^ 64 by decide) + (show i < 2 ^ 64 by omega)] + by_cases h8 : 8 ≤ i + · rw [ite_eq_left h8, ite_eq_left (by omega)]; simp + · rw [ite_eq_right h8, ite_eq_right (by omega), ite_eq_left (by omega)]; simp + +/-! ## Frames -/ + +section +variable (s₀ : State) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data. -/ +abbrev cW1 : List Region := [fIvR s₀, fBlk s₀, fScr s₀, cBlk s₀] +/-- What the function writes after saving the registers. -/ +abbrev cW : List Region := [fIvR s₀, fData s₀, fScr s₀, cBlk s₀] +/-- What the function writes. -/ +abbrev cBig : List Region := [fIvR s₀, fData s₀, fScr s₀, cSv s₀] + +end + +theorem cW1_cW {s₀ : State} {m : Mem} (hf : Frame (cW1 s₀) (svMem s₀) m) : Frame (cW s₀) (svMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem whole_cW1 {M : Mode} {s₀ s : State} (h : Whole M s₀ s) : Frame (cW1 s₀) (svMem s₀) s.mem := + h.frame.mono fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h] + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (cW s₀) (svMem s₀) m) : Frame (cBig s₀) s₀.mem m := + ((svMem_frame' s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨cSv s₀, by simp, blk_sv_sub s₀⟩) + +theorem CPre.sched_big {s₀ : State} (hp : CPre s₀) : + ∀ r ∈ cBig s₀, (⟨fW s₀, 16 * (fR s₀ + 1)⟩ : Region).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv.sub_left hp.sched_sub + · exact hp.sch_data.sub_left hp.sched_sub + · exact hp.sch_scr.sub_left hp.sched_sub + · exact hp.sch_sv.sub_left hp.sched_sub + +/-! ## The partial last block -/ + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure TArgs (s₀ s : State) : Prop where + a0 : s.gpr .a0 = fW s₀ + a1 : s.gpr .a1 = s₀.gpr .a1 + a2 : s.gpr .a2 = fIv s₀ + a3 : s.gpr .a3 = cBk s₀ + a4 : s.gpr .a4 = BitVec.ofNat 64 1 + a5 : s.gpr .a5 = fS s₀ + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = fV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (cBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [cBlk s₀] m (Spill.saveMem m (fV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +set_option linter.unusedSimpArgs false in +theorem tail_args_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.block tailArgs) s (TArgs s₀) := by + have f₁ := whole_cW1 h + show WP isa (.block (.li .t0 0 :: (Spill.saveCode .s7 zeroSlots ++ tailMoves))) _ _ + refine wp_li (imm := 0) (by decide) fun s₁ z => ?_ + have h7 : s₁.gpr .s7 = fV s₀ := by rw [z.other _ (by decide), h.s7] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .s7 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [z.wr, h.wr, hp.wr, h7] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + · exact ⟨cSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + refine Spill.save_ok (by rw [h7]; exact hp.sv_al) (by decide) hw ?_ + unfold tailMoves Impl.AesCbc.RISCV64.mov + refine wp_mv fun s₂ u₂ => wp_mv fun s₃ u₃ => wp_mv fun s₄ u₄ => wp_addi (imm := 64) (by decide) fun s₅ u₅ => + wp_li (imm := 1) (by decide) fun s₆ u₆ => wp_mv fun s₇ u₇ => WP.block_nil ?_ + have c (r : Reg) (hr : r = .s0 ∨ r = .s1 ∨ r = .s2 ∨ r = .s3 ∨ r = .s4 ∨ r = .s5 ∨ r = .s6 ∨ r = .s7 ∨ + r = .s8 ∨ r = .s9 ∨ r = .s10 ∨ r = .s11) : s₇.gpr r = s.gpr r := by + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> + simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, + ↓reduceIte] <;> exact z.other _ (by decide) + have sp : s₇.sp = s.sp := by + rw [u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, u₂.sp, show ({ s₁ with mem := _ } : State).sp = s₁.sp from rfl, z.sp] + have rd : s₇.rd = s.rd := by + rw [u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, z.rd] + have wr : s₇.wr = s.wr := by + rw [u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, z.wr] + have hm : s₇.mem = Spill.saveMem s.mem (fV s₀) s₁.gpr zeroSlots := by + rw [u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, h7] + show Spill.saveMem s₁.mem _ _ _ = _ + rw [z.mem] + have fz : Frame [cBlk s₀] s.mem s₇.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [cBlk s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [cBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have g7 : ({ s₁ with mem := Spill.saveMem s₁.mem (s₁.gpr .s7) s₁.gpr zeroSlots } : State).gpr = s₁.gpr := rfl + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, by rw [c .s2 (by simp), h.s2], by rw [c .s3 (by simp), h.s3], + by rw [c .s7 (by simp), h.s7], + fun r hr => by rw [c r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp, h.sp], by rw [rd, h.rd], by rw [wr, h.wr], ?_, ?_, ?_, ?_⟩ + · simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, + g7] + rw [z.other _ (by decide), h.s1] + · simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, + g7] + rw [z.other _ (by decide), h.s4] + · simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, + g7] + rw [z.other _ (by decide), h.s5] + · simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, + g7] + rw [h7] + · simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte] + · simp only [upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, + g7] + rw [z.other _ (by decide), h.s6] + · exact f₁.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] + · rw [hm, show Spill.saveMem s.mem (fV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (cBk s₀) (s₁.gpr .t0)).writeW (cBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .t0)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z.gpr] + exact zero_bytes _ _ + +theorem cBk_toNat {s₀ : State} (hp : CPre s₀) : (cBk s₀).toNat = (fV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +theorem tail_pre {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + wholeK.pre (s.callEntry.withRegions [fSch s₀] [fIvR s₀, cBlk s₀, fScr s₀]) ∧ + Covers ([fSch s₀] ++ [fIvR s₀, cBlk s₀, fScr s₀]) (s.rd ++ s.wr) ∧ + Covers [fIvR s₀, cBlk s₀, fScr s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), callEntry s (by decide : Reg.a5 ∉ linkRegs), + h.a0, h.a1, h.a2, h.a3, h.a4, h.a5, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.sch_scr, hp.iv_sv.sub_right bs, hp.iv_scr, + (hp.scr_sv.sub_right bs).symm, hp.iv_wrap, by rw [cBk_toNat hp]; omega, hp.scr_wrap, hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨fSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 64, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨fIvR s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨cSv s₀, by simp, 64, by simp, by simp⟩ + · exact ⟨fScr s₀, by simp, 0, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure TCall (s₀ s : State) : Prop where + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = fV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW1 s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (cBk s₀) 16 = Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem tail_call_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TArgs s₀ s) : + WP isa (.call "vg_aes_ctr" crypt) s (TCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (cW1_cW h.frame) + have eW : bytesAt s.mem (fW s₀) (16 * (fR s₀ + 1)) = fWk s₀ := + Proof.Cmac.bytesAt_frame big hp.sched_big hp.sched_len + refine WP.call (k := wholeK) crypt_correct (rd := [fSch s₀]) (wr := [fIvR s₀, cBlk s₀, fScr s₀]) hpre + hc hw ?_ crypt_noFrames + intro s' rd' wr' sp' fr' cs' _ post₂ + simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), h.a0, h.a1, h.a2, h.a3, h.a4, + one_toNat, eW, h.ctr, AesCtr.ctrMode_out, AesCtr.ctrMode_chain, AesCbc.length_blocksAt] at post₂ + have fc : Frame (cW1 s₀) s.mem s'.mem := fr'.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs_of cs' .s2 (by simp), h.s2], by rw [cs_of cs' .s3 (by simp), h.s3], + by rw [cs_of cs' .s7 (by simp), h.s7], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₂.2, ?_⟩ + · rw [blocksAt_frame' fr' fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.data_scr.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (aesWith_length _ _) h.zero post₂.1 + +/-- What the function leaves before restoring the registers. -/ +structure Done (s₀ s : State) : Prop where + s7 : s.gpr .s7 = fV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (cW s₀) (svMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = + Spec.Ctr.crypt (Spec.Cbc.aesWith (fR s₀) (fWk s₀)) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (Spec.Cbc.aesWith (fR s₀) (fWk s₀) (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : Whole AesCtr.ctrMode s₀ s) (hu : fU s₀ = 0) : Done s₀ s := + ⟨h.s7, h.kept, h.rd, h.wr, cW1_cW (whole_cW1 h), h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.iv, AesCtr.ctrMode_chain, AesCbc.length_blocksAt]⟩ + +theorem toNat_tail {s₀ : State} (hp : CPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +open VG.Proof.Modes.RISCV64 (XPre XInv xorLoop_wp xf) + +theorem tail_xor_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : TCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) s (Done s₀) := by + refine WP.seq (wp_addi (imm := 64) (by decide) fun s₁ u₁ => WP.block_nil ?_) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have hB := cBk_toNat hp + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : XPre s₁ (cBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fK := by omega + fR := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [u₁.rd, u₁.wr, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨cSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [u₁.wr, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : XInv s₁ (cBk s₀) (fT s₀) (fU s₀) 0 s₁ := { + t2 := by rw [u₁.gpr, h.s7]; exact (BitVec.add_zero _).symm + s2 := by rw [u₁.other _ (by decide), h.s2]; exact (BitVec.add_zero _).symm + s3 := by rw [u₁.other _ (by decide), h.s3, Nat.sub_zero] + lt := by omega + mem := (Proof.Modes.over_zero _ _ _).symm + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ cW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact hp.data_scr.sub_left (tail_sub s₀) + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + have tailS : ∀ r ∈ [fSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (sv64_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (fIvR s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have g (r : Reg) (hr : r = .s7 ∨ r = .s0 ∨ r = .s8 ∨ r = .s9 ∨ r = .s10 ∨ r = .s11) : s'.gpr r = s.gpr r := by + rw [d.gpr r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide), + u₁.other _ (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide)] + have fr : Frame [fTail s₀] s.mem s'.mem := by + rw [d.mem, u₁.mem]; exact Proof.Modes.over_frame _ _ _ _ + refine ⟨by rw [g .s7 (by simp), h.s7], fun r hr => by + rw [g r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [d.rd, u₁.rd, h.rd], by rw [d.wr, u₁.wr, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (cW1_cW h.frame).trans (fr.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact h.blocks + · rw [d.mem, Proof.Modes.over_at hq (by omega), xf, u₁.mem, h.frame.bytes tailD hlen hq, + (svMem_frame s₀).bytes tailS hlen hq, + ← bytesAt_getD s.mem (cBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame fr ivT (by decide), h.ctr, ← AesCtr.next_add] + +theorem final_mid_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Whole AesCtr.ctrMode s₀ s) : + WP isa (.ite (.zero .s3) (.block []) finalTail) s (Done s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem final_end_wp {s₀ : State} (hp : CPre s₀) {s : State} (h : Done s₀ s) : + WP isa (.block finalRestore) s fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.gpr .ra = s₀.gpr .ra ∧ s'.mem = s.mem := by + have hs : Spill.Saved (fV s₀) s₀.gpr finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (fV s₀) s₀.gpr).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨fV s₀ + BitVec.ofNat 64 p.2, 8⟩ (cSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact hp.scr_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + show WP isa (.block (Spill.restoreCode .s7 finalSaved)) _ _ + refine WP.mono (Spill.restore_wp hp.sv_al h.s7 saved_fits (by decide) (fun p hp' => ?_) hs) + fun s' r => ⟨fun q hq => r.gpr_of ?_, r.gpr (.ra, 0) (by decide), r.mem⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨cSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + · simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hq + rcases hq with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl + all_goals first + | exact .inl (by decide) + | exact .inr (h.kept _ (by simp)) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : CPre s₀) : + WP isa cryptFinal s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.gpr .ra = s₀.gpr .ra ∧ + ∃ s₁, Done s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (final_setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (final_mid_wp hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (final_end_wp hp h₃) fun _ ⟨g, ra, m⟩ => ⟨g, ra, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalRISCV64.post s₀ s' := by + show Spec.Ctr.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalRISCV64.pre s) : + ∃ t s', Exec isa cryptFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalRISCV64.post s s' := by + obtain ⟨t, s', he, hg, hra, s₁, h₁, hm⟩ := final_wp (CPre.of hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hra⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +/-- Counter blocks whose last 32 bits agree still do after `k` increments. -/ +theorem lo32_next_of {t t' : List Byte} (ht : t.length = 16) (ht' : t'.length = 16) + (h : AesCtr.lo32 t = AesCtr.lo32 t') (k : Nat) : + AesCtr.lo32 (Spec.Ctr.next t k) = AesCtr.lo32 (Spec.Ctr.next t' k) := by + rw [AesCtr.lo32_next ht, AesCtr.lo32_next ht'] + unfold AesCtr.lo32 at h + omega + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4, .a5, .a6]) + (.block finalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.s1, .s4, .s5, .s6, .s7]) + (.block tailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.s7, .s2, .s3]) + (.seq (.block tailKey) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.s7]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalRISCV64.pre s₀) (h0' : ctrFinalRISCV64.pre s₀') + (hq : ctrFinalRISCV64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') cryptFinal fun _ _ => True := by + have hp := CPre.of h0 + have hp' := CPre.of h0' + obtain ⟨⟨qW, qR, qIv, qD, qL, qS, qV, qSp⟩, qLk⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + have qLo : AesCtr.lo32 (fIv0 s₀) = AesCtr.lo32 (fIv0 s₀') := + AesCtr.lo32_of_leak (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLk + -- The registers saved and the arguments set up. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := (RelCT.taint (A := taint) (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + refine agree_of qSp fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) t₁).wp + (F₁ := Setup s₀) (F₂ := Setup s₀') + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨final_setup_wp hp, final_setup_wp hp'⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr") crypt_correct crypt_ct + (P := fun a b => Setup s₀ a ∧ Setup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb⟩ + · simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), + callEntry a (by decide : Reg.a2 ∉ linkRegs), callEntry a (by decide : Reg.a3 ∉ linkRegs), + callEntry a (by decide : Reg.a4 ∉ linkRegs), callEntry a (by decide : Reg.a5 ∉ linkRegs), + callEntry b (by decide : Reg.a0 ∉ linkRegs), callEntry b (by decide : Reg.a1 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), callEntry b (by decide : Reg.a3 ∉ linkRegs), + callEntry b (by decide : Reg.a4 ∉ linkRegs), callEntry b (by decide : Reg.a5 ∉ linkRegs), + ha.a0, ha.a1, ha.a2, ha.a3, ha.a4, ha.a5, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.a4, hb.a5, hb.sp] + rw [fW, fW, fIv, fIv, fD, fD, fS, fS, qW, qR, qIv, qD, qS, qSp, qN] + exact ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl⟩ + · simp only [AesCbc.RISCV64.iv0, AesCbc.RISCV64.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_mem, callEntry a (by decide : Reg.a2 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), ha.a2, hb.a2, ha.mem, hb.mem] + rw [(sv_bytes hp).2.1, (sv_bytes hp').2.1] + exact qLo).wp + (F₁ := Whole AesCtr.ctrMode s₀) (F₂ := Whole AesCtr.ctrMode s₀') + fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + finalTail fun a b => Done s₀ a ∧ Done s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + obtain ⟨_, t₃⟩ := tailArgs_taint + have a₁ := (RelCT.taint (A := taint) + (P := fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) _ + (fun a b h => agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl + · rw [h.1.s1, h.2.s1, fW, fW, qW] + · rw [h.1.s4, h.2.s4, qR] + · rw [h.1.s5, h.2.s5, fIv, fIv, qIv] + · rw [h.1.s6, h.2.s6, fS, fS, qS] + · rw [h.1.s7, h.2.s7, fV, fV, qV]) t₃).wp + (F₁ := TArgs s₀) (F₂ := TArgs s₀') + fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩ + have a₂ := (RelCT.callEx (k := wholeK) (n := "vg_aes_ctr") crypt_correct crypt_ct + (P := fun a b => TArgs s₀ a ∧ TArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ⟨?_, ?_⟩, ca, wa, cb, wb⟩ + · simp only [modeRISCV64, State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), + callEntry a (by decide : Reg.a2 ∉ linkRegs), callEntry a (by decide : Reg.a3 ∉ linkRegs), + callEntry a (by decide : Reg.a4 ∉ linkRegs), callEntry a (by decide : Reg.a5 ∉ linkRegs), + callEntry b (by decide : Reg.a0 ∉ linkRegs), callEntry b (by decide : Reg.a1 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), callEntry b (by decide : Reg.a3 ∉ linkRegs), + callEntry b (by decide : Reg.a4 ∉ linkRegs), callEntry b (by decide : Reg.a5 ∉ linkRegs), + ha.a0, ha.a1, ha.a2, ha.a3, ha.a4, ha.a5, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.a4, hb.a5, hb.sp] + rw [fW, fW, fIv, fIv, cBk, cBk, fV, fV, fS, fS, qW, qR, qIv, qV, qS, qSp] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> first | rfl | trivial + · simp only [AesCbc.RISCV64.iv0, AesCbc.RISCV64.Iv, State.withRegions_gpr, State.withRegions_mem, + State.callEntry_mem, callEntry a (by decide : Reg.a2 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), ha.a2, hb.a2] + rw [ha.ctr, hb.ctr, qN] + exact lo32_next_of (Proof.Cmac.bytesAt_length _ _ _) (Proof.Cmac.bytesAt_length _ _ _) qLo _).wp + (F₁ := TCall s₀) (F₂ := TCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + obtain ⟨_, t₄⟩ := xor_taint + have a₃ := (RelCT.taint (A := taint) (P := fun a b => TCall s₀ a ∧ TCall s₀' b) _ + (fun a b h => agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.s7, h.2.s7, fV, fV, qV] + · rw [h.1.s2, h.2.s2, qT] + · rw [h.1.s3, h.2.s3, qU]) t₄).wp + (F₁ := Done s₀) (F₂ := Done s₀') + fun a b h => ⟨tail_xor_wp hp h.1 hu, tail_xor_wp hp' h.2 hu'⟩ + exact (a₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq + ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₃.mono (fun _ _ h => h) fun _ _ h => h.2)) + have r₃ : RelCT isa (fun a b => Whole AesCtr.ctrMode s₀ a ∧ Whole AesCtr.ctrMode s₀' b) + (.ite (.zero .s3) (.block []) finalTail) (fun a b => Done s₀ a ∧ Done s₀' b) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1] at this; simpa using this + exact ⟨done_of_zero h.1.1 h0, done_of_zero h.1.2 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1, h.1.2⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1] at this; simpa using this + have r₃' := r₃.wp (F₁ := fun (s : State) => s.sp = s₀.sp) (F₂ := fun (s : State) => s.sp = s₀'.sp) + fun a b h => + ⟨WP.mono (AesCbc.RISCV64.wp_sp (final_mid_wp hp h.1)) fun _ x => x.2.trans h.1.sp, + WP.mono (AesCbc.RISCV64.wp_sp (final_mid_wp hp' h.2)) fun _ x => x.2.trans h.2.sp⟩ + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := RelCT.taint (A := taint) (P := fun a b => (Done s₀ a ∧ Done s₀' b) ∧ + a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ + (fun a b h => agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.s7, h.1.2.s7, fV, fV, qV]) t₅ + exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq + (r₃'.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalRISCV64.pre ctrFinalRISCV64.pub cryptFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem cryptFinal_verified : Verified RISCV64.target cryptFinal finalScratchContract := + Verified.of_correct final_correct final_ct final_implies + +/-! ## With `save` on the stack + +The final function has six argument words, so `save` is its seventh, in +`a6`: it runs its code in a frame of 80 bytes on the stack +(`withStackScratchWiped`), `save`'s 80 bytes (the registers, then the block +that held the last output block), which it zeroes before returning. The +code's calls use no stack, so 80 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract RISCV64.abi 80).pre s := by + implies_sat [finalRoundsContract, Spec.Ctr.aesFinalSig, finalPre, finalPost, RISCV64.abi, + RISCV64.argRegs] [finalFrameSat, finalSat] using finalFrameSat + +theorem cryptFinal_framed : + Verified RISCV64.target (Impl.StackScratch.RISCV64.withStackScratchWiped 80 .a6 10 cryptFinal) + (finalRoundsContract RISCV64.abi 80) := + RISCV64.Verified.stackScratchWiped (sig := Spec.Ctr.aesFinalSig) (nm := "save") (e := .u64) (n := 10) + (pre := finalPre RISCV64.abi.ptrBits) (post := finalPost RISCV64.abi.ptrBits) (wa := false) + (leak := some (finalLeak RISCV64.abi.ptrBits)) + (stack := 0) (bytes := 80) (words := 10) cryptFinal_verified (by decide) (by decide) (by decide) + (finalPost_localOut _) frameSat_pre + +end VG.Proof.AesCtr.RISCV64.Final diff --git a/lean/VerifiedGarbage/Proof/AesOfb/RISCV64/Final.lean b/lean/VerifiedGarbage/Proof/AesOfb/RISCV64/Final.lean new file mode 100644 index 00000000000..d4e50843ff9 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/AesOfb/RISCV64/Final.lean @@ -0,0 +1,109 @@ +module + +public import VerifiedGarbage.Impl.AesOfb.RISCV64.Final +public import VerifiedGarbage.Proof.AesOfb.Final +public import VerifiedGarbage.Proof.AesOfb.RISCV64.Verified +public import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Impl.StackScratch.RISCV64 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.RISCV64.Exec +import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +import VerifiedGarbage.Proof.AesOfb.Spec +import VerifiedGarbage.Proof.AesCbc.Spec + +/-! +# AES-OFB of a message's last piece on RISC-V + +`cryptFinal_framed`: `vg_aes_ofb_final` (`Impl/AesOfb/RISCV64/Final.lean`) +meets `Proof.AesOfb.finalRoundsContract`, from which the shared contract +follows (`Proof.AesOfb.final_keyed`). + +Its code is AES-CFB's final function around a call of the whole-block +AES-OFB function, so its proof is AES-CFB's (`Proof/AesCfb/RISCV64/Final.lean`), +for OFB as a `Mode` (`ofbMode`): `final_wp` runs it, for any mode, to what it +leaves before restoring the registers (`Done`); `final_ct` gives its +constant time. `ofbFinalRISCV64` is AES-CFB's code contract with OFB's +postcondition, which `final_post` gives from `Done` by +`Proof.AesOfb.cryptFinal_of`. +-/ + +@[expose] public section + +namespace VG.Proof.AesOfb.RISCV64 + +open VG VG.RISCV64 +open VG.Spec.Aes (bytesAt) +open VG.Proof.AesCfb.RISCV64.Final (finalRISCV64 FPre Done fW fR fIv fD fL fN final_wp final_ct finalSat + finalFrameSat) +open VG.Impl.AesOfb.RISCV64 + +/-- The code's contract, with the arguments `(schedule = a0, rounds = a1, +iv = a2, data = a3, len = a4, scratch = a5, save = a6)`: AES-CFB's final +functions' (`finalRISCV64`), with the data and the block at `iv` as +`Spec.Ofb.CryptFinal` says, by AES with the key schedule it is given. -/ +def ofbFinalRISCV64 : Contract isa := + { finalRISCV64 true with + post := fun s s' => Spec.Ofb.CryptFinal (ciphAt s.mem (s.gpr .a0) (s.gpr .a1).toNat) 16 s.mem s'.mem + (s.gpr .a2) (s.gpr .a3) (s.gpr .a4).toNat } + +/-- The contract the frame needs: the shared one, with `save`, 64 bytes, as +a seventh argument, and no stack (a call keeps its return address in +`ra`). -/ +abbrev finalScratchContract : Contract isa := + Sig.scratchContract RISCV64.abi Spec.Ofb.aesFinalSig "save" .u64 8 (finalPre RISCV64.abi.ptrBits) + (finalPost RISCV64.abi.ptrBits) false 0 + +theorem final_implies : ofbFinalRISCV64.Implies finalScratchContract := by + sig_implies [finalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Ofb.aesFinalSig, finalPre, finalPost, ofbFinalRISCV64, finalRISCV64, RISCV64.abi, + RISCV64.argRegs] [finalSat] using finalSat + +/-- `Spec.Ofb.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : Done ofbMode s₀ s₁) (hm : s'.mem = s₁.mem) : + ofbFinalRISCV64.post s₀ s' := by + show Spec.Ofb.CryptFinal (ciphAt s₀.mem (fW s₀) (fR s₀)) 16 s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + have e := AesCbc.length_blocksAt s₀.mem (fD s₀) (fN s₀) + have hb := h.blocks + have ht := h.tail + have hi := h.iv + rw [ofbMode_out] at hb + rw [ofbMode_chain, e] at ht hi + exact cryptFinal_of (aesWith_length _ _) (by rw [hm]; exact hb) (fun q hq => by rw [hm]; exact ht q hq) + (by rw [hm]; exact hi) + +/-! ## The code's properties -/ + +theorem crypt_noFrames : crypt.noFrames = true := rfl + +theorem final_correct (s : State) (hs : ofbFinalRISCV64.pre s) : + ∃ t s', Exec isa cryptFinal s t s' ∧ abiPreserved s s' ∧ ofbFinalRISCV64.post s s' := by + obtain ⟨t, s', he, hg, hra, s₁, h₁, hm⟩ := + final_wp (M := ofbMode) crypt_correct crypt_noFrames (FPre.of (enc := true) hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hra⟩, final_post h₁ hm⟩ + +/-! ## Verified -/ + +theorem cryptFinal_verified : Verified RISCV64.target cryptFinal finalScratchContract := + Verified.of_correct final_correct (final_ct (enc := true) crypt_correct crypt_ct crypt_noFrames) + final_implies + +/-! ## With `save` on the stack + +As AES-CFB's final functions, the code runs in a frame of 64 bytes on the +stack (`withStackScratchWiped`), `save`'s 64 bytes, which it zeroes before +returning. Its calls use no stack, so 64 in all. -/ + +theorem frameSat_pre : ∃ s, (finalRoundsContract RISCV64.abi 64).pre s := by + implies_sat [finalRoundsContract, Spec.Ofb.aesFinalSig, finalPre, finalPost, RISCV64.abi, + RISCV64.argRegs] [finalFrameSat, finalSat] using finalFrameSat + +theorem cryptFinal_framed : + Verified RISCV64.target (Impl.StackScratch.RISCV64.withStackScratchWiped 64 .a6 8 cryptFinal) + (finalRoundsContract RISCV64.abi 64) := + RISCV64.Verified.stackScratchWiped (sig := Spec.Ofb.aesFinalSig) (nm := "save") (e := .u64) (n := 8) + (pre := finalPre RISCV64.abi.ptrBits) (post := finalPost RISCV64.abi.ptrBits) (wa := false) + (stack := 0) (bytes := 64) (words := 8) cryptFinal_verified (by decide) (by decide) (by decide) + (finalPost_localOut _) frameSat_pre + +end VG.Proof.AesOfb.RISCV64 diff --git a/lean/VerifiedGarbage/Proof/Camellia/RISCV64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/RISCV64/CtrFinal.lean new file mode 100644 index 00000000000..6c935365b11 --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Camellia/RISCV64/CtrFinal.lean @@ -0,0 +1,952 @@ +module + +public import VerifiedGarbage.Impl.Camellia.RISCV64.CtrFinal +public import VerifiedGarbage.Proof.Camellia.CtrFinal +public import VerifiedGarbage.Proof.Camellia.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.RISCV64.Spill +public import VerifiedGarbage.Proof.Framework.RISCV64.CallAny +public import VerifiedGarbage.Impl.StackScratch.RISCV64 +import VerifiedGarbage.Proof.AesCtr.RISCV64.Final +import VerifiedGarbage.Proof.Camellia.RISCV64.ModesConstantTime +import VerifiedGarbage.Proof.Camellia.RISCV64.ModesLit +import VerifiedGarbage.Proof.Camellia.Scratch +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.Words +import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.RISCV64.CT +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.Lit +import VerifiedGarbage.Proof.Framework.RISCV64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.RISCV64.RegUpd +import VerifiedGarbage.Proof.Framework.RISCV64.Steps +import VerifiedGarbage.Proof.Framework.RISCV64.Exec +import VerifiedGarbage.Proof.Framework.RISCV64.Taint +import VerifiedGarbage.Proof.Framework.RISCV64.Lit +import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.Camellia.RISCV64.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.CtrFinal +meta import VerifiedGarbage.Proof.Camellia.RISCV64.ModesVerified +meta import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.RISCV64.Spill +meta import VerifiedGarbage.Proof.Framework.RISCV64.CallAny +meta import VerifiedGarbage.Impl.StackScratch.RISCV64 +meta import VerifiedGarbage.Proof.AesCtr.RISCV64.Final +meta import VerifiedGarbage.Proof.Camellia.RISCV64.ModesConstantTime +meta import VerifiedGarbage.Proof.Camellia.RISCV64.ModesLit +meta import VerifiedGarbage.Proof.Camellia.Scratch +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.Words +meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCbc.RISCV64.CT +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.Lit +meta import VerifiedGarbage.Proof.Framework.RISCV64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.RISCV64.RegUpd +meta import VerifiedGarbage.Proof.Framework.RISCV64.Steps +meta import VerifiedGarbage.Proof.Framework.RISCV64.Exec +meta import VerifiedGarbage.Proof.Framework.RISCV64.Taint +meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit +meta import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# Camellia-CTR of a message's last piece on RISC-V + +`ctrFinal_framed`: `vg_camellia_ctr_final` (`Impl/Camellia/RISCV64/CtrFinal.lean`) meets +`Spec.Camellia.ctrFinalContract`, from `Proof.Camellia.ctrFinalContractSk` +(`Proof.Camellia.ctrFinal_of_sk`). + +The code is proven against `ctrFinalRISCV64`, with the arguments +`(schedule = a0, rounds = a1, ctr = a2, data = a3, len = a4, save = a5)`, a +sixth argument `save` (`a5`) of 80 bytes for its return address and its +caller's registers and a block of its own, and 3248 bytes of stack for its +calls (`ctrFinal_implies`: the shared contract with it), as a caller of +`vg_camellia_ctr`, which keeps its own working space in a frame on the +stack, through the register-form contract its proofs give it +(`Modes.modeContract Modes.ctrPost`, `Modes.ctr_correct`, +`ctr_constantTime`), with `WP.callAny` (the callee's frames lie within the +stack, `ctr_depth`). It is AES-CTR's final function's proof +(`Proof/AesCtr/RISCV64/Final.lean`) with Camellia's arguments: + +* `setup_wp`, `whole_wp`: the registers saved in `save`, whose address is + kept in `s7`, and the call on the `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.RISCV64.xorLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`), by Camellia with the subkeys at + `schedule`. + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Camellia.RISCV64.CtrFinal + +open VG VG.RISCV64 +open VG.RISCV64.Steps +open VG.Spec.Aes (bytesAt) +open VG.Impl.Camellia.RISCV64 (ctr ctrFinalSave ctrFinalMoves ctrFinalSetup ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.RISCV64 (finalSaved finalRestore) +open VG.Impl.AesCtr.RISCV64 (zeroSlots tailKey) + +/-! ## The callee -/ + +/-- `vg_camellia_ctr`'s contract, as its proofs state it: the arguments +`(schedule = a0, rounds = a1, ctr = a2, data = a3, n = a4)` and a frame of +3248 bytes below the stack pointer. -/ +abbrev ctrK : Contract isa := Modes.modeContract Modes.ctrPost + +theorem ctr_depth : sdepth ctr ≤ 3248 := by lit_decide + +theorem ctr_ok : ∀ s, ctrK.pre s → ∃ t s', Exec isa ctr s t s' ∧ abiPreserved s s' ∧ ctrK.post s s' := + Modes.ctr_correct + +theorem ctr_ct : ConstantTime isa ctrK.pre ctrK.pub ctr := ctr_constantTime _ + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = a0, rounds = a1, +ctr = a2, data = a3, len = a4, save = a5)`, `save` of 80 bytes, and 3248 +bytes of stack for the calls: the data and the counter block as +`Spec.Ctr.CryptFinal` says, by Camellia with the subkeys at `schedule`. -/ +def ctrFinalRISCV64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .a0, 272⟩ + let ctr : Region := ⟨s.gpr .a2, 16⟩ + let data : Region := ⟨s.gpr .a3, (s.gpr .a4).toNat⟩ + let sv : Region := ⟨s.gpr .a5, 80⟩ + let stack := below s.sp 3248 + s.sp.toNat % 16 = 0 ∧ 3248 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .a0).toNat + 272 ≤ 2 ^ 64 ∧ (s.gpr .a2).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .a3).toNat + (s.gpr .a4).toNat ≤ 2 ^ 64 ∧ (s.gpr .a5).toNat + 80 ≤ 2 ^ 64 ∧ + (s.gpr .a5).toNat % 8 = 0 ∧ + ((s.gpr .a1).toNat = 18 ∨ (s.gpr .a1).toNat = 24) + post s s' := + Spec.Ctr.CryptFinal (Spec.Camellia.cipher (Spec.Camellia.subkeysAt s.mem (s.gpr .a0) (s.gpr .a1).toNat)) + s.mem s'.mem (s.gpr .a2) (s.gpr .a3) (s.gpr .a4).toNat + pub s₁ s₂ := + s₁.gpr .a0 = s₂.gpr .a0 ∧ s₁.gpr .a1 = s₂.gpr .a1 ∧ s₁.gpr .a2 = s₂.gpr .a2 ∧ + s₁.gpr .a3 = s₂.gpr .a3 ∧ s₁.gpr .a4 = s₂.gpr .a4 ∧ s₁.gpr .a5 = s₂.gpr .a5 ∧ s₁.sp = s₂.sp + +/-- The contract the frame needs: the shared one on the subkeys, with `save`, +80 bytes, as a sixth argument, and 3248 bytes of stack (`vg_camellia_ctr`'s +frame). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract RISCV64.abi Spec.Camellia.ctrFinalSig "save" .u64 10 + (Spec.Camellia.ctrFinalPre RISCV64.abi.ptrBits) (Proof.Camellia.ctrFinalPostSk RISCV64.abi.ptrBits) true 3248 + +/-- A state satisfying the precondition (no data, 18 rounds). -/ +def ctrFinalSat : State where + gpr r := match r with + | .a0 => 0x1000 | .a1 => 18 | .a2 => 0x2000 | .a3 => 0x3000 | .a5 => 0x4000 | _ => 0 + sp := 0x8000 + mem _ := 0 + rd := [⟨0x1000, 272⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 80⟩] + +theorem ctrFinal_implies : ctrFinalRISCV64.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, Proof.Camellia.ctrFinalPostSk, ctrFinalRISCV64, + RISCV64.abi, RISCV64.argRegs] [ctrFinalSat] using ctrFinalSat + +/-! ## The arguments, by name -/ + +open VG.Proof.AesCfb.RISCV64.Final (fW fR fIv fD fL fN fU fT fData fBlk fTail fIv0 fBlks Kept cs_of callEntry + bytesAt_getD blocksAt_frame' saved_slots saved_fits blk_sub tail_sub fN_eq fU_eq n_lt u_lt toNat_n + shr4 shr4_shl4 sub_shl4 upd_gpr) +open VG.Proof.AesCtr.RISCV64.Final (zero_bytes) +open VG.Proof.AesCbc.RISCV64 (one_toNat) + +section +variable (s₀ : State) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .a5 +abbrev kSch : Region := ⟨fW s₀, 272⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 80⟩ +abbrev kSv64 : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 64 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below s₀.sp 3248 +/-- The memory once the registers are saved. -/ +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) s₀.gpr finalSaved +/-- The cipher on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Camellia.cipher (Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀)) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + al : s₀.sp.toNat % 16 = 0 + sp : 3248 ≤ s₀.sp.toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 272 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 80 ≤ 2 ^ 64 + sv_al : (kV s₀).toNat % 8 = 0 + rounds : fR s₀ = 18 ∨ fR s₀ = 24 + +theorem KPre.of {s₀ : State} (h : ctrFinalRISCV64.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20⟩ + +/-! ## Regions and frames -/ + +theorem sv64_sub (s₀ : State) : Region.Sub (kSv64 s₀) (kSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +end + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + (Spill.saveMem_frame_base (n := 64) (by decide) (by decide) _ _ _).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨kSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem KPre.sch_big {s₀ : State} (hp : KPre s₀) : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The subkeys, from memory that agrees with the entry's on the schedule. -/ +theorem subkeys_of {s₀ : State} (hp : KPre s₀) {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : + Spec.Camellia.subkeysAt m (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt m₀ (fW s₀) (fR s₀) := + Proof.Camellia.subkeysAt_congr (by rcases hp.rounds with h | h <;> rw [h] <;> decide) + fun i hi => hf.bytes (R := kSch s₀) hd (by show 272 ≤ 2 ^ 64; decide) hi + +/-- A call's frame, within the regions it was given and the stack. -/ +theorem call_frame {s₀ s s' : State} (hsp : s.sp = s₀.sp) {wr : List Region} + (hf : Frame (wr ++ [below s.sp (sdepth ctr)]) s.mem s'.mem) : + Frame (wr ++ [kStk s₀]) s.mem s'.mem := + hf.sub fun r hr => by + rcases List.mem_append.mp hr with h | h + · exact ⟨r, List.mem_append_left _ h, fun _ h => h⟩ + · simp only [List.mem_singleton] at h; subst h + exact ⟨kStk s₀, by simp, fun x hx => by rw [hsp] at hx; exact Offset.below_mono s₀.sp ctr_depth (by decide) x hx⟩ + +/-! ## Saving the registers -/ + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + s1 : s.gpr .s1 = fW s₀ + s4 : s.gpr .s4 = s₀.gpr .a1 + s5 : s.gpr .s5 = fIv s₀ + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + a0 : s.gpr .a0 = fW s₀ + a1 : s.gpr .a1 = s₀.gpr .a1 + a2 : s.gpr .a2 = fIv s₀ + a3 : s.gpr .a3 = fD s₀ + a4 : s.gpr .a4 = BitVec.ofNat 64 (fN s₀) + kept : Kept s₀ s + sp : s.sp = s₀.sp + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +set_option linter.unusedSimpArgs false in +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (KSetup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions s₀.wr (s₀.gpr .a5 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .a5 finalSaved ++ ctrFinalMoves)) _ _ + refine Spill.save_ok hp.sv_al saved_fits hw ?_ + unfold ctrFinalMoves Impl.AesCbc.RISCV64.mov + refine wp_mv fun s₁ u₁ => wp_mv fun s₂ u₂ => wp_mv fun s₃ u₃ => wp_mv fun s₄ u₄ => + wp_srl (by decide) fun s₅ u₅ => wp_sll (by decide) fun s₆ u₆ => wp_add fun s₇ u₇ => + wp_sub fun s₈ u₈ => wp_mv fun s₉ u₉ => WP.block_nil ?_ + exact { + s1 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s4 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s5 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s2 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4_shl4] + s3 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4_shl4, sub_shl4] + s7 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a0 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a1 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a2 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a3 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a4 := by simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4] + kept := fun r hr => by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp only [upd_gpr u₉, upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + sp := by rw [u₉.sp, u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, u₂.sp, u₁.sp] + mem := by rw [u₉.mem, u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + rd := by rw [u₉.rd, u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + wr := by rw [u₉.wr, u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] } + +/-! ## The whole blocks -/ + +theorem whole_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + ctrK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [Modes.modeContract, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + State.withRegions_sp, State.callEntry_sp, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), h.a0, h.a1, h.a2, h.a3, h.a4, h.sp, toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), + hp.iv_data.sub_right (blk_sub s₀), hp.sch_wrap, hp.iv_wrap, hp.blk_wrap, hp.al, hp.sp, hp.stk_sch, + hp.stk_iv, hp.stk_data.sub_right (blk_sub s₀), hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The subkeys, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : KPre s₀) : + Spec.Camellia.subkeysAt (kSvMem s₀) (fW s₀) (fR s₀) = Spec.Camellia.subkeysAt s₀.mem (fW s₀) (fR s₀) ∧ + bytesAt (kSvMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ Spec.Cbc.blocksAt (kSvMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame s₀ + exact ⟨subkeys_of hp ef (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv), + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + s1 : s.gpr .s1 = fW s₀ + s4 : s.gpr .s4 = s₀.gpr .a1 + s5 : s.gpr .s5 = fIv s₀ + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + WP isa (.call "vg_camellia_ctr" ctr) s (KWhole s₀) := by + obtain ⟨eK, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.callAny (k := ctrK) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, fBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + rw [h.mem] at fr + simp only [Modes.modeContract, Modes.ctrPost, Modes.dataAt, Modes.ivAt, Modes.ciph, Modes.rounds, + State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), h.a0, h.a1, h.a2, h.a3, h.a4, + toNat_n, h.mem] at post₂ + have hR : (s₀.gpr .a1).toNat = fR s₀ := rfl + rw [hR] at post₂ + have post₃ := post₂ hp.rounds + rw [eK, eIv, eB] at post₃ + exact ⟨by rw [cs_of cs' .s1 (by simp), h.s1], by rw [cs_of cs' .s4 (by simp), h.s4], + by rw [cs_of cs' .s5 (by simp), h.s5], by rw [cs_of cs' .s2 (by simp), h.s2], + by rw [cs_of cs' .s3 (by simp), h.s3], by rw [cs_of cs' .s7 (by simp), h.s7], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], + fr.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h], + post₃.1, post₃.2⟩ + +/-! ## The partial last block -/ + +theorem eval_u {s₀ s : State} (h : KWhole s₀ s) : + isa.eval (.zero .s3) s = some (decide (fU s₀ = 0)) := + eval_zero_ofNat s .s3 (by have := u_lt s₀; omega) h.s3 + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KArgs (s₀ s : State) : Prop where + a0 : s.gpr .a0 = fW s₀ + a1 : s.gpr .a1 = s₀.gpr .a1 + a2 : s.gpr .a2 = fIv s₀ + a3 : s.gpr .a3 = kBk s₀ + a4 : s.gpr .a4 = BitVec.ofNat 64 1 + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +set_option linter.unusedSimpArgs false in +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (KArgs s₀) := by + show WP isa (.block (.li .t0 0 :: (Spill.saveCode .s7 zeroSlots ++ ctrFinalTailMoves))) _ _ + refine wp_li (imm := 0) (by decide) fun s₁ z => ?_ + have h7 : s₁.gpr .s7 = kV s₀ := by rw [z.other _ (by decide), h.s7] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .s7 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [z.wr, h.wr, hp.wr, h7] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + refine Spill.save_ok (by rw [h7]; exact hp.sv_al) (by decide) hw ?_ + unfold ctrFinalTailMoves Impl.AesCbc.RISCV64.mov + refine wp_mv fun s₂ u₂ => wp_mv fun s₃ u₃ => wp_mv fun s₄ u₄ => wp_addi (imm := 64) (by decide) fun s₅ u₅ => + wp_li (imm := 1) (by decide) fun s₆ u₆ => WP.block_nil ?_ + have c (r : Reg) (hr : r = .s0 ∨ r = .s1 ∨ r = .s2 ∨ r = .s3 ∨ r = .s4 ∨ r = .s5 ∨ r = .s6 ∨ r = .s7 ∨ + r = .s8 ∨ r = .s9 ∨ r = .s10 ∨ r = .s11) : s₆.gpr r = s.gpr r := by + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> + simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, + ↓reduceIte] <;> exact z.other _ (by decide) + have sp : s₆.sp = s.sp := by + rw [u₆.sp, u₅.sp, u₄.sp, u₃.sp, u₂.sp, show ({ s₁ with mem := _ } : State).sp = s₁.sp from rfl, z.sp] + have rd : s₆.rd = s.rd := by + rw [u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, z.rd] + have wr : s₆.wr = s.wr := by + rw [u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, z.wr] + have hm : s₆.mem = Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots := by + rw [u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, h7] + show Spill.saveMem s₁.mem _ _ _ = _ + rw [z.mem] + have fz : Frame [kBlk s₀] s.mem s₆.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have g7 : ({ s₁ with mem := Spill.saveMem s₁.mem (s₁.gpr .s7) s₁.gpr zeroSlots } : State).gpr = s₁.gpr := rfl + refine ⟨?_, ?_, ?_, ?_, ?_, by rw [c .s2 (by simp), h.s2], by rw [c .s3 (by simp), h.s3], + by rw [c .s7 (by simp), h.s7], + fun r hr => by rw [c r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp, h.sp], by rw [rd, h.rd], by rw [wr, h.wr], ?_, ?_, ?_, ?_⟩ + · simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [z.other _ (by decide), h.s1] + · simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [z.other _ (by decide), h.s4] + · simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [z.other _ (by decide), h.s5] + · simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [h7] + · simp only [upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte] + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.ctr] + · rw [hm, show Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₁.gpr .t0)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .t0)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z.gpr] + exact zero_bytes _ _ + +theorem tail_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + ctrK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, kBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, kBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, kBlk s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [Modes.modeContract, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + State.withRegions_sp, State.callEntry_sp, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), h.a0, h.a1, h.a2, h.a3, h.a4, h.sp, one_toNat, + Nat.mul_one] + have := hp.sv_wrap + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.iv_sv.sub_right bs, hp.sch_wrap, + hp.iv_wrap, by rw [hp.bk_toNat]; omega, hp.al, hp.sp, hp.stk_sch, hp.stk_iv, hp.stk_sv.sub_right bs, + hp.rounds⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure KCall (s₀ s : State) : Prop where + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by + simp [Spec.Camellia.cipher] + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + WP isa (.call "vg_camellia_ctr" ctr) s (KCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (kW1_kW h.frame) + have eK := subkeys_of hp big hp.sch_big + refine WP.callAny (k := ctrK) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, kBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + simp only [Modes.modeContract, Modes.ctrPost, Modes.dataAt, Modes.ivAt, Modes.ciph, Modes.rounds, + State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + callEntry s (by decide : Reg.a4 ∉ linkRegs), h.a0, h.a1, h.a2, h.a3, h.a4, + one_toNat, h.ctr] at post₂ + have hR : (s₀.gpr .a1).toNat = fR s₀ := rfl + rw [hR] at post₂ + have post₃ := post₂ hp.rounds + rw [eK] at post₃ + have fc : Frame (kW1 s₀) s.mem s'.mem := fr.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs_of cs' .s2 (by simp), h.s2], by rw [cs_of cs' .s3 (by simp), h.s3], + by rw [cs_of cs' .s7 (by simp), h.s7], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₃.2, ?_⟩ + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero post₃.1 + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.s7, h.kept, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem toNat_tail {s₀ : State} (hp : KPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +open VG.Proof.Modes.RISCV64 (XPre XInv xorLoop_wp xf) + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) s (KDone s₀) := by + refine WP.seq (wp_addi (imm := 64) (by decide) fun s₁ u₁ => WP.block_nil ?_) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have hB := hp.bk_toNat + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : XPre s₁ (kBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fK := by omega + fR := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [u₁.rd, u₁.wr, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [u₁.wr, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : XInv s₁ (kBk s₀) (fT s₀) (fU s₀) 0 s₁ := { + t2 := by rw [u₁.gpr, h.s7]; exact (BitVec.add_zero _).symm + s2 := by rw [u₁.other _ (by decide), h.s2]; exact (BitVec.add_zero _).symm + s3 := by rw [u₁.other _ (by decide), h.s3, Nat.sub_zero] + lt := by omega + mem := (Proof.Modes.over_zero _ _ _).symm + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have g (r : Reg) (hr : r = .s7 ∨ r = .s0 ∨ r = .s8 ∨ r = .s9 ∨ r = .s10 ∨ r = .s11) : s'.gpr r = s.gpr r := by + rw [d.gpr r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide), + u₁.other _ (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide)] + have fr : Frame [fTail s₀] s.mem s'.mem := by + rw [d.mem, u₁.mem]; exact Proof.Modes.over_frame _ _ _ _ + refine ⟨by rw [g .s7 (by simp), h.s7], fun r hr => by + rw [g r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [d.rd, u₁.rd, h.rd], by rw [d.wr, u₁.wr, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (kW1_kW h.frame).trans (fr.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact h.blocks + · rw [d.mem, Proof.Modes.over_at hq (by omega), xf, u₁.mem, h.frame.bytes tailD hlen hq, + (svMem_frame s₀).bytes tailS hlen hq, ← bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame fr ivT (by decide), h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.ite (.zero .s3) (.block []) ctrFinalTail) s (KDone s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.block finalRestore) s fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.gpr .ra = s₀.gpr .ra ∧ s'.mem = s.mem := by + have hs : Spill.Saved (kV s₀) s₀.gpr finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (kV s₀) s₀.gpr).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .s7 finalSaved)) _ _ + refine WP.mono (Spill.restore_wp hp.sv_al h.s7 saved_fits (by decide) (fun p hp' => ?_) hs) + fun s' r => ⟨fun q hq => r.gpr_of ?_, r.gpr (.ra, 0) (by decide), r.mem⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + · simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hq + rcases hq with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl + all_goals first + | exact .inl (by decide) + | exact .inr (h.kept _ (by simp)) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.gpr .ra = s₀.gpr .ra ∧ + ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (end_wp hp h₃) fun _ ⟨g, ra, m⟩ => ⟨g, ra, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalRISCV64.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalRISCV64.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalRISCV64.post s s' := by + obtain ⟨t, s', he, hg, hra, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hra⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4, .a5]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.s1, .s4, .s5, .s7]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.s7, .s2, .s3]) + (.seq (.block tailKey) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.s7]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +/-- The callee's public arguments, from the registers. -/ +theorem ctr_pub {a b : State} (hsp : a.sp = b.sp) (h0 : a.gpr .a0 = b.gpr .a0) (h1 : a.gpr .a1 = b.gpr .a1) + (h2 : a.gpr .a2 = b.gpr .a2) (h3 : a.gpr .a3 = b.gpr .a3) (h4 : a.gpr .a4 = b.gpr .a4) : ctrK.pub a b := by + show modePub a b + rw [Modes.modePub_iff] + exact ⟨hsp, h0, h1, h2, h3, h4⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalRISCV64.pre s₀) (h0' : ctrFinalRISCV64.pre s₀') + (hq : ctrFinalRISCV64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qR, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + -- The registers saved and the arguments set up. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := (RelCT.taint (A := taint) (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + refine AesCfb.RISCV64.Final.agree_of qSp fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) t₁).wp + (F₁ := KSetup s₀) (F₂ := KSetup s₀') + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := ctrK) (n := "vg_camellia_ctr") ctr_ok ctr_ct + (P := fun a b => KSetup s₀ a ∧ KSetup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ctr_pub ?_ ?_ ?_ ?_ ?_ ?_, ca, wa, cb, wb⟩ <;> + simp only [State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), + callEntry a (by decide : Reg.a2 ∉ linkRegs), callEntry a (by decide : Reg.a3 ∉ linkRegs), + callEntry a (by decide : Reg.a4 ∉ linkRegs), + callEntry b (by decide : Reg.a0 ∉ linkRegs), callEntry b (by decide : Reg.a1 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), callEntry b (by decide : Reg.a3 ∉ linkRegs), + callEntry b (by decide : Reg.a4 ∉ linkRegs), + ha.a0, ha.a1, ha.a2, ha.a3, ha.a4, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.a4, hb.sp] + · exact qSp + · rw [fW, fW, qW] + · exact qR + · rw [fIv, fIv, qIv] + · rw [fD, fD, qD] + · rw [qN]).wp + (F₁ := KWhole s₀) (F₂ := KWhole s₀') fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) ctrFinalTail + fun a b => KDone s₀ a ∧ KDone s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + obtain ⟨_, t₃⟩ := tailArgs_taint + have a₁ := (RelCT.taint (A := taint) (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) _ + (fun a b h => AesCfb.RISCV64.Final.agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · rw [h.1.s1, h.2.s1, fW, fW, qW] + · rw [h.1.s4, h.2.s4, qR] + · rw [h.1.s5, h.2.s5, fIv, fIv, qIv] + · rw [h.1.s7, h.2.s7, kV, kV, qV]) t₃).wp + (F₁ := KArgs s₀) (F₂ := KArgs s₀') fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩ + have a₂ := (RelCT.callEx (k := ctrK) (n := "vg_camellia_ctr") ctr_ok ctr_ct + (P := fun a b => KArgs s₀ a ∧ KArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ctr_pub ?_ ?_ ?_ ?_ ?_ ?_, ca, wa, cb, wb⟩ <;> + simp only [State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), + callEntry a (by decide : Reg.a2 ∉ linkRegs), callEntry a (by decide : Reg.a3 ∉ linkRegs), + callEntry a (by decide : Reg.a4 ∉ linkRegs), + callEntry b (by decide : Reg.a0 ∉ linkRegs), callEntry b (by decide : Reg.a1 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), callEntry b (by decide : Reg.a3 ∉ linkRegs), + callEntry b (by decide : Reg.a4 ∉ linkRegs), + ha.a0, ha.a1, ha.a2, ha.a3, ha.a4, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.a4, hb.sp] + · exact qSp + · rw [fW, fW, qW] + · exact qR + · rw [fIv, fIv, qIv] + · rw [kBk, kBk, kV, kV, qV]).wp + (F₁ := KCall s₀) (F₂ := KCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + obtain ⟨_, t₄⟩ := xor_taint + have a₃ := (RelCT.taint (A := taint) (P := fun a b => KCall s₀ a ∧ KCall s₀' b) _ + (fun a b h => AesCfb.RISCV64.Final.agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.s7, h.2.s7, kV, kV, qV] + · rw [h.1.s2, h.2.s2, qT] + · rw [h.1.s3, h.2.s3, qU]) t₄).wp + (F₁ := KDone s₀) (F₂ := KDone s₀') fun a b h => ⟨tail_xor_wp hp h.1 hu, tail_xor_wp hp' h.2 hu'⟩ + exact (a₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq + ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₃.mono (fun _ _ h => h) fun _ _ h => h.2)) + have r₃ : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) (.ite (.zero .s3) (.block []) ctrFinalTail) + (fun a b => KDone s₀ a ∧ KDone s₀' b) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1] at this; simpa using this + exact ⟨done_of_zero h.1.1 h0, done_of_zero h.1.2 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1, h.1.2⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1] at this; simpa using this + have r₃' := r₃.wp (F₁ := fun (s : State) => s.sp = s₀.sp) (F₂ := fun (s : State) => s.sp = s₀'.sp) + fun a b h => + ⟨WP.mono (AesCbc.RISCV64.wp_sp (mid_wp hp h.1)) fun _ x => x.2.trans h.1.sp, + WP.mono (AesCbc.RISCV64.wp_sp (mid_wp hp' h.2)) fun _ x => x.2.trans h.2.sp⟩ + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := RelCT.taint (A := taint) (P := fun a b => (KDone s₀ a ∧ KDone s₀' b) ∧ + a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ + (fun a b h => AesCfb.RISCV64.Final.agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.s7, h.1.2.s7, kV, kV, qV]) t₅ + exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq + (r₃'.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalRISCV64.pre ctrFinalRISCV64.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified RISCV64.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +The final function has five argument words, so `save` is its sixth, in `a5`: +it runs its code in a frame of 80 bytes on the stack (`withStackScratchWiped`), +`save`'s 80 bytes (the registers, then the block that held the last output +block), which it zeroes before returning. Its calls use 3248 bytes below it, +so 3328 in all. -/ + +/-- A state satisfying the shared contract's precondition. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk RISCV64.abi 3328).pre s := by + implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, + Proof.Camellia.ctrFinalPostSk, RISCV64.abi, RISCV64.argRegs] [ctrFinalFrameSat, ctrFinalSat] + using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified RISCV64.target (Impl.StackScratch.RISCV64.withStackScratchWiped 80 .a5 10 ctrFinal) + (Spec.Camellia.ctrFinalContract RISCV64.abi 3328) := + Proof.Camellia.ctrFinal_of_sk <| + RISCV64.Verified.stackScratchWiped (sig := Spec.Camellia.ctrFinalSig) (nm := "save") (e := .u64) (n := 10) + (pre := Spec.Camellia.ctrFinalPre RISCV64.abi.ptrBits) (post := Proof.Camellia.ctrFinalPostSk RISCV64.abi.ptrBits) + (wa := true) (stack := 3248) (bytes := 80) (words := 10) ctrFinal_verified (by decide) (by decide) + (by decide) (Proof.Camellia.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Camellia.RISCV64.CtrFinal diff --git a/lean/VerifiedGarbage/Proof/Sm4/RISCV64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/RISCV64/CtrFinal.lean new file mode 100644 index 00000000000..98da28d3afd --- /dev/null +++ b/lean/VerifiedGarbage/Proof/Sm4/RISCV64/CtrFinal.lean @@ -0,0 +1,951 @@ +module + +public import VerifiedGarbage.Impl.Sm4.RISCV64.CtrFinal +public import VerifiedGarbage.Proof.Sm4.CtrFinal +public import VerifiedGarbage.Proof.Sm4.RISCV64.ModesVerified +public import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +public import VerifiedGarbage.Proof.Framework.Scratch +public import VerifiedGarbage.Proof.Framework.RISCV64.Spill +public import VerifiedGarbage.Proof.Framework.RISCV64.CallAny +public import VerifiedGarbage.Impl.StackScratch.RISCV64 +import VerifiedGarbage.Proof.AesCtr.RISCV64.Final +import VerifiedGarbage.Proof.Sm4.RISCV64.ModesConstantTime +import VerifiedGarbage.Proof.Sm4.RISCV64.ModesLit +import VerifiedGarbage.Proof.Sm4.Scratch +import VerifiedGarbage.Proof.Modes.CtrFinal +import VerifiedGarbage.Proof.Modes.Words +import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal +import VerifiedGarbage.Proof.Cmac.Spec +import VerifiedGarbage.Proof.Cmac.Frame +import VerifiedGarbage.Proof.AesCbc.Spec +import VerifiedGarbage.Proof.AesCbc.RISCV64.CT +import VerifiedGarbage.Proof.AesCtr.Ctr32 +import VerifiedGarbage.Proof.Framework.Contract +import VerifiedGarbage.Proof.Framework.Lit +import VerifiedGarbage.Proof.Framework.RISCV64.RelCT +import VerifiedGarbage.Proof.Framework.RelCTAssoc +import VerifiedGarbage.Proof.Framework.RISCV64.RegUpd +import VerifiedGarbage.Proof.Framework.RISCV64.Steps +import VerifiedGarbage.Proof.Framework.RISCV64.Exec +import VerifiedGarbage.Proof.Framework.RISCV64.Taint +import VerifiedGarbage.Proof.Framework.RISCV64.Lit +import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Framework.AddrArith +meta import VerifiedGarbage.Impl.Sm4.RISCV64.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.CtrFinal +meta import VerifiedGarbage.Proof.Sm4.RISCV64.ModesVerified +meta import VerifiedGarbage.Proof.AesCfb.RISCV64.Final +meta import VerifiedGarbage.Proof.Framework.Scratch +meta import VerifiedGarbage.Proof.Framework.RISCV64.Spill +meta import VerifiedGarbage.Proof.Framework.RISCV64.CallAny +meta import VerifiedGarbage.Impl.StackScratch.RISCV64 +meta import VerifiedGarbage.Proof.AesCtr.RISCV64.Final +meta import VerifiedGarbage.Proof.Sm4.RISCV64.ModesConstantTime +meta import VerifiedGarbage.Proof.Sm4.RISCV64.ModesLit +meta import VerifiedGarbage.Proof.Sm4.Scratch +meta import VerifiedGarbage.Proof.Modes.CtrFinal +meta import VerifiedGarbage.Proof.Modes.Words +meta import VerifiedGarbage.Proof.Modes.RISCV64.SeqFinal +meta import VerifiedGarbage.Proof.Cmac.Spec +meta import VerifiedGarbage.Proof.Cmac.Frame +meta import VerifiedGarbage.Proof.AesCbc.Spec +meta import VerifiedGarbage.Proof.AesCbc.RISCV64.CT +meta import VerifiedGarbage.Proof.AesCtr.Ctr32 +meta import VerifiedGarbage.Proof.Framework.Contract +meta import VerifiedGarbage.Proof.Framework.Lit +meta import VerifiedGarbage.Proof.Framework.RISCV64.RelCT +meta import VerifiedGarbage.Proof.Framework.RelCTAssoc +meta import VerifiedGarbage.Proof.Framework.RISCV64.RegUpd +meta import VerifiedGarbage.Proof.Framework.RISCV64.Steps +meta import VerifiedGarbage.Proof.Framework.RISCV64.Exec +meta import VerifiedGarbage.Proof.Framework.RISCV64.Taint +meta import VerifiedGarbage.Proof.Framework.RISCV64.Lit +meta import VerifiedGarbage.Proof.Framework.RISCV64.StackScratch +meta import VerifiedGarbage.Proof.Framework.Offset +meta import VerifiedGarbage.Proof.Framework.AddrArith + +/-! +# SM4-CTR of a message's last piece on RISC-V + +`ctrFinal_framed`: `vg_sm4_ctr_final` (`Impl/Sm4/RISCV64/CtrFinal.lean`) meets +`Spec.Sm4.ctrFinalContract`. + +The code is proven against `ctrFinalRISCV64`, with the arguments +`(schedule = a0, ctr = a1, data = a2, len = a3, save = a4)`, a fifth argument +`save` (`a4`) of 80 bytes for its return address and its caller's registers +and a block of its own, and 3232 bytes of stack for its calls +(`ctrFinal_implies`: the shared contract with it), as a caller of +`vg_sm4_ctr`, which keeps its own working space in a frame on the +stack, through the register-form contract its proofs give it +(`Modes.modeContract Modes.ctrPost`, `Modes.ctr_correct`, +`ctr_constantTime`), with `WP.callAny` (the callee's frames lie within the +stack, `ctr_depth`). It is AES-CTR's final function's proof +(`Proof/AesCtr/RISCV64/Final.lean`) with SM4's arguments: + +* `setup_wp`, `whole_wp`: the registers saved in `save`, whose address is + kept in `s7`, and the call on the `n = len / 16` whole blocks (`KWhole`); +* `mid_wp`: if `u = len % 16` bytes are left, the block after the registers + in `save` zeroed and the call on it (`tail_args_wp`, `tail_call_wp`), which + leaves `CIPH_K(Tₙ₊₁)` there and `Tₙ₊₂` in `ctr`, and its first `u` bytes + XORed into them (`Modes.RISCV64.xorLoop_wp`, `tail_xor_wp`); what is left + before the registers are restored is `KDone`; +* `end_wp`: the registers restored; +* `final_post`: `KDone` gives `Spec.Ctr.CryptFinal` + (`Proof.Modes.CtrFinal.cryptFinal_of`), by SM4 with the schedule at + `schedule`. + +Constant time (`final_rel`): the blocks by the taint analysis, the calls by +the callee's constant time (`RelCT.callEx`), whose public arguments agree. +-/ + +@[expose] public section + +namespace VG.Proof.Sm4.RISCV64.CtrFinal + +open VG VG.RISCV64 +open VG.RISCV64.Steps +open VG.Spec.Aes (bytesAt) +open VG.Impl.Sm4.RISCV64 (ctr ctrFinalSave ctrFinalMoves ctrFinalSetup ctrFinalTailMoves + ctrFinalTailArgs ctrFinalTail ctrFinal) +open VG.Impl.AesCfb.RISCV64 (finalSaved finalRestore) +open VG.Impl.AesCtr.RISCV64 (zeroSlots tailKey) + +/-! ## The callee -/ + +/-- `vg_sm4_ctr`'s contract, as its proofs state it: the arguments +`(schedule = a0, ctr = a1, data = a2, n = a3)` and a frame of 3232 bytes +below the stack pointer. -/ +abbrev ctrK : Contract isa := Modes.modeContract Modes.ctrPost + +theorem ctr_depth : sdepth ctr ≤ 3232 := by lit_decide + +theorem ctr_ok : ∀ s, ctrK.pre s → ∃ t s', Exec isa ctr s t s' ∧ abiPreserved s s' ∧ ctrK.post s s' := + Modes.ctr_correct + +theorem ctr_ct : ConstantTime isa ctrK.pre ctrK.pub ctr := ctr_constantTime _ + +/-! ## The contract -/ + +/-- The code's contract, with the arguments `(schedule = a0, ctr = a1, +data = a2, len = a3, save = a4)`, `save` of 80 bytes, and 3232 bytes of stack +for the calls: the data and the counter block as `Spec.Ctr.CryptFinal` says, +by SM4 with the schedule at `schedule`. -/ +def ctrFinalRISCV64 : Contract isa where + pre s := + let sched : Region := ⟨s.gpr .a0, 128⟩ + let ctr : Region := ⟨s.gpr .a1, 16⟩ + let data : Region := ⟨s.gpr .a2, (s.gpr .a3).toNat⟩ + let sv : Region := ⟨s.gpr .a4, 80⟩ + let stack := below s.sp 3232 + s.sp.toNat % 16 = 0 ∧ 3232 ≤ s.sp.toNat ∧ s.rd = [sched] ∧ s.wr = [ctr, data, sv] ∧ + sched.Disjoint ctr ∧ sched.Disjoint data ∧ sched.Disjoint sv ∧ ctr.Disjoint data ∧ ctr.Disjoint sv ∧ + data.Disjoint sv ∧ + stack.Disjoint sched ∧ stack.Disjoint ctr ∧ stack.Disjoint data ∧ stack.Disjoint sv ∧ + (s.gpr .a0).toNat + 128 ≤ 2 ^ 64 ∧ (s.gpr .a1).toNat + 16 ≤ 2 ^ 64 ∧ + (s.gpr .a2).toNat + (s.gpr .a3).toNat ≤ 2 ^ 64 ∧ (s.gpr .a4).toNat + 80 ≤ 2 ^ 64 ∧ + (s.gpr .a4).toNat % 8 = 0 + post s s' := + Spec.Ctr.CryptFinal (Spec.Sm4.cipher (Spec.Sm4.scheduleAt s.mem (s.gpr .a0))) + s.mem s'.mem (s.gpr .a1) (s.gpr .a2) (s.gpr .a3).toNat + pub s₁ s₂ := + s₁.gpr .a0 = s₂.gpr .a0 ∧ s₁.gpr .a1 = s₂.gpr .a1 ∧ s₁.gpr .a2 = s₂.gpr .a2 ∧ + s₁.gpr .a3 = s₂.gpr .a3 ∧ s₁.gpr .a4 = s₂.gpr .a4 ∧ s₁.sp = s₂.sp + +/-- The contract the frame needs: the shared one, with `save`, 80 bytes, as a +fifth argument, and 3232 bytes of stack (`vg_sm4_ctr`'s frame). -/ +abbrev ctrFinalScratchContract : Contract isa := + Sig.scratchContract RISCV64.abi Spec.Sm4.ctrFinalSig "save" .u64 10 (Curry.const (fun _ => True) _) + (Proof.Sm4.ctrFinalPost RISCV64.abi.ptrBits) true 3232 + +/-- A state satisfying the precondition (no data). -/ +def ctrFinalSat : State where + gpr r := match r with + | .a0 => 0x1000 | .a1 => 0x2000 | .a2 => 0x3000 | .a4 => 0x4000 | _ => 0 + sp := 0x8000 + mem _ := 0 + rd := [⟨0x1000, 128⟩] + wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩, ⟨0x4000, 80⟩] + +theorem ctrFinal_implies : ctrFinalRISCV64.Implies ctrFinalScratchContract := by + sig_implies [ctrFinalScratchContract, Sig.scratchContract, Sig.withScratch, Curry.withScratch, Curry.app, + Spec.Sm4.ctrFinalSig, Proof.Sm4.ctrFinalPost, ctrFinalRISCV64, RISCV64.abi, RISCV64.argRegs] [ctrFinalSat] + using ctrFinalSat + +/-! ## The arguments, by name -/ + +open VG.Proof.AesCfb.RISCV64.Final (Kept cs_of callEntry bytesAt_getD blocksAt_frame' saved_slots saved_fits + shr4 shr4_shl4 sub_shl4 upd_gpr) +open VG.Proof.AesCtr.RISCV64.Final (zero_bytes) +open VG.Proof.AesCbc.RISCV64 (one_toNat) + +section +variable (s₀ : State) + +abbrev fW : Addr := s₀.gpr .a0 +abbrev fIv : Addr := s₀.gpr .a1 +abbrev fD : Addr := s₀.gpr .a2 +abbrev fL : Nat := (s₀.gpr .a3).toNat +/-- The number of whole blocks, and of the bytes after them. -/ +abbrev fN : Nat := fL s₀ / 16 +abbrev fU : Nat := fL s₀ % 16 +/-- The data after the whole blocks. -/ +abbrev fT : Addr := fD s₀ + BitVec.ofNat 64 (16 * fN s₀) +abbrev fData : Region := ⟨fD s₀, fL s₀⟩ +abbrev fBlk : Region := ⟨fD s₀, 16 * fN s₀⟩ +abbrev fTail : Region := ⟨fT s₀, fU s₀⟩ +/-- The counter block and the whole blocks on entry. -/ +abbrev fIv0 : List Byte := bytesAt s₀.mem (fIv s₀) 16 +abbrev fBlks : List (List Byte) := Spec.Cbc.blocksAt s₀.mem (fD s₀) (fN s₀) + +/-- `save`. -/ +abbrev kV : Addr := s₀.gpr .a4 +abbrev kSch : Region := ⟨fW s₀, 128⟩ +abbrev kIv : Region := ⟨fIv s₀, 16⟩ +abbrev kSv : Region := ⟨kV s₀, 80⟩ +abbrev kSv64 : Region := ⟨kV s₀, 64⟩ +/-- The block after the registers in `save`. -/ +abbrev kBk : Addr := kV s₀ + BitVec.ofNat 64 64 +abbrev kBlk : Region := ⟨kBk s₀, 16⟩ +/-- The stack the calls use. -/ +abbrev kStk : Region := below s₀.sp 3232 +/-- The memory once the registers are saved. -/ +abbrev kSvMem : Mem := Spill.saveMem s₀.mem (kV s₀) s₀.gpr finalSaved +/-- The cipher on entry. -/ +abbrev kCiph : Spec.Cbc.Cipher := Spec.Sm4.cipher (Spec.Sm4.scheduleAt s₀.mem (fW s₀)) + +/-- What the function writes after saving the registers, with the whole +blocks rather than the data; and with the data. -/ +abbrev kW1 : List Region := [kIv s₀, fBlk s₀, kBlk s₀, kStk s₀] +abbrev kW : List Region := [kIv s₀, fData s₀, kBlk s₀, kStk s₀] +/-- What the function writes. -/ +abbrev kBig : List Region := [kIv s₀, fData s₀, kSv s₀, kStk s₀] + +end + +/-- The precondition, by name. -/ +structure KPre (s₀ : State) : Prop where + al : s₀.sp.toNat % 16 = 0 + sp : 3232 ≤ s₀.sp.toNat + rd : s₀.rd = [kSch s₀] + wr : s₀.wr = [kIv s₀, fData s₀, kSv s₀] + sch_iv : (kSch s₀).Disjoint (kIv s₀) + sch_data : (kSch s₀).Disjoint (fData s₀) + sch_sv : (kSch s₀).Disjoint (kSv s₀) + iv_data : (kIv s₀).Disjoint (fData s₀) + iv_sv : (kIv s₀).Disjoint (kSv s₀) + data_sv : (fData s₀).Disjoint (kSv s₀) + stk_sch : (kStk s₀).Disjoint (kSch s₀) + stk_iv : (kStk s₀).Disjoint (kIv s₀) + stk_data : (kStk s₀).Disjoint (fData s₀) + stk_sv : (kStk s₀).Disjoint (kSv s₀) + sch_wrap : (fW s₀).toNat + 128 ≤ 2 ^ 64 + iv_wrap : (fIv s₀).toNat + 16 ≤ 2 ^ 64 + data_wrap : (fD s₀).toNat + fL s₀ ≤ 2 ^ 64 + sv_wrap : (kV s₀).toNat + 80 ≤ 2 ^ 64 + sv_al : (kV s₀).toNat % 8 = 0 + +theorem KPre.of {s₀ : State} (h : ctrFinalRISCV64.pre s₀) : KPre s₀ := + let ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19⟩ := h + ⟨a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19⟩ + +/-! ## Regions and frames -/ + +theorem blk_sub (s₀ : State) : Region.Sub (fBlk s₀) (fData s₀) := Region.sub_prefix (Nat.mul_div_le _ _) + +theorem tail_sub (s₀ : State) : Region.Sub (fTail s₀) (fData s₀) := + Offset.sub_base _ (by rw [Nat.div_add_mod]) + +theorem fN_eq (s₀ : State) : fN s₀ = fL s₀ / 16 := rfl +theorem fU_eq (s₀ : State) : fU s₀ = fL s₀ % 16 := rfl + +theorem n_lt (s₀ : State) : fN s₀ < 2 ^ 64 := by + have := (s₀.gpr .a3).isLt; have : fL s₀ = (s₀.gpr .a3).toNat := rfl; rw [fN_eq]; omega + +theorem u_lt (s₀ : State) : fU s₀ < 16 := Nat.mod_lt _ (by decide) + +theorem toNat_n (s₀ : State) : (BitVec.ofNat 64 (fN s₀)).toNat = fN s₀ := by + rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt (n_lt s₀)] + +theorem sv64_sub (s₀ : State) : Region.Sub (kSv64 s₀) (kSv s₀) := Region.sub_prefix (by decide) +theorem blk_sv_sub (s₀ : State) : Region.Sub (kBlk s₀) (kSv s₀) := Offset.sub_base _ (by decide) + +section +variable {s₀ : State} (hp : KPre s₀) +include hp + +theorem KPre.blk_tail : (fBlk s₀).Disjoint (fTail s₀) := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + exact Offset.base_disjoint _ (Nat.le_refl _) (by rw [fN_eq, fU_eq]; omega) + +theorem KPre.blk_wrap : (fD s₀).toNat + 16 * fN s₀ ≤ 2 ^ 64 := by + have := hp.data_wrap; have := Nat.mul_div_le (fL s₀) 16; rw [fN_eq]; omega + +theorem KPre.bk_toNat : (kBk s₀).toNat = (kV s₀).toNat + 64 := by + have := hp.sv_wrap + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 64) (by decide), Nat.mod_eq_of_lt (by omega)] + +end + +theorem svMem_frame (s₀ : State) : Frame [kSv s₀] s₀.mem (kSvMem s₀) := + (Spill.saveMem_frame_base (n := 64) (by decide) (by decide) _ _ _).sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨kSv s₀, by simp, sv64_sub s₀⟩ + +/-- The slots of the registers miss the block. -/ +theorem slot_blk (s₀ : State) : + ∀ p ∈ finalSaved, Region.Disjoint ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kBlk s₀) := by + intro p hp' + have := saved_slots p hp' + exact Offset.disjoint _ (.inl (by omega)) (by omega) (by decide) + +theorem kW1_kW {s₀ : State} {m : Mem} (hf : Frame (kW1 s₀) (kSvMem s₀) m) : Frame (kW s₀) (kSvMem s₀) m := + hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨fData s₀, by simp, blk_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + +theorem big_of {s₀ : State} {m : Mem} (hf : Frame (kW s₀) (kSvMem s₀) m) : Frame (kBig s₀) s₀.mem m := + ((svMem_frame s₀).mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]).trans + (hf.sub fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨kSv s₀, by simp, blk_sv_sub s₀⟩ + · exact ⟨_, by simp, fun _ h => h⟩) + +theorem KPre.sch_big {s₀ : State} (hp : KPre s₀) : ∀ r ∈ kBig s₀, (kSch s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.sch_iv + · exact hp.sch_data + · exact hp.sch_sv + · exact hp.stk_sch.symm + +/-- The schedule, from memory that agrees with the entry's on it. -/ +theorem sched_of {s₀ : State} {rs : List Region} {m₀ m : Mem} (hf : Frame rs m₀ m) + (hd : ∀ r ∈ rs, (kSch s₀).Disjoint r) : Spec.Sm4.scheduleAt m (fW s₀) = Spec.Sm4.scheduleAt m₀ (fW s₀) := + Proof.Sm4.scheduleAt_frame hf hd + +/-- A call's frame, within the regions it was given and the stack. -/ +theorem call_frame {s₀ s s' : State} (hsp : s.sp = s₀.sp) {wr : List Region} + (hf : Frame (wr ++ [below s.sp (sdepth ctr)]) s.mem s'.mem) : + Frame (wr ++ [kStk s₀]) s.mem s'.mem := + hf.sub fun r hr => by + rcases List.mem_append.mp hr with h | h + · exact ⟨r, List.mem_append_left _ h, fun _ h => h⟩ + · simp only [List.mem_singleton] at h; subst h + exact ⟨kStk s₀, by simp, fun x hx => by rw [hsp] at hx; exact Offset.below_mono s₀.sp ctr_depth (by decide) x hx⟩ + +/-! ## Saving the registers -/ + +/-- What saving the registers and setting up the arguments leaves. -/ +structure KSetup (s₀ s : State) : Prop where + s1 : s.gpr .s1 = fW s₀ + s5 : s.gpr .s5 = fIv s₀ + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + a0 : s.gpr .a0 = fW s₀ + a1 : s.gpr .a1 = fIv s₀ + a2 : s.gpr .a2 = fD s₀ + a3 : s.gpr .a3 = BitVec.ofNat 64 (fN s₀) + kept : Kept s₀ s + sp : s.sp = s₀.sp + mem : s.mem = kSvMem s₀ + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + +set_option linter.unusedSimpArgs false in +theorem setup_wp {s₀ : State} (hp : KPre s₀) : WP isa (.block ctrFinalSetup) s₀ (KSetup s₀) := by + have hw : ∀ p ∈ finalSaved, InRegions s₀.wr (s₀.gpr .a4 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by omega)⟩ + show WP isa (.block (Spill.saveCode .a4 finalSaved ++ ctrFinalMoves)) _ _ + refine Spill.save_ok hp.sv_al saved_fits hw ?_ + unfold ctrFinalMoves Impl.AesCbc.RISCV64.mov + refine wp_mv fun s₁ u₁ => wp_mv fun s₂ u₂ => wp_mv fun s₃ u₃ => + wp_srl (by decide) fun s₄ u₄ => wp_sll (by decide) fun s₅ u₅ => wp_add fun s₆ u₆ => + wp_sub fun s₇ u₇ => wp_mv fun s₈ u₈ => WP.block_nil ?_ + exact { + s1 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s5 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + s2 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4_shl4] + s3 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte]; rw [shr4_shl4, sub_shl4] + s7 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a0 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a1 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a2 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + a3 := by simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] ; rw [shr4] + kept := fun r hr => by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp only [upd_gpr u₈, upd_gpr u₇, upd_gpr u₆, upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, upd_gpr u₁, reduceCtorEq, ↓reduceIte] <;> rfl + sp := by rw [u₈.sp, u₇.sp, u₆.sp, u₅.sp, u₄.sp, u₃.sp, u₂.sp, u₁.sp] + mem := by rw [u₈.mem, u₇.mem, u₆.mem, u₅.mem, u₄.mem, u₃.mem, u₂.mem, u₁.mem] + rd := by rw [u₈.rd, u₇.rd, u₆.rd, u₅.rd, u₄.rd, u₃.rd, u₂.rd, u₁.rd] + wr := by rw [u₈.wr, u₇.wr, u₆.wr, u₅.wr, u₄.wr, u₃.wr, u₂.wr, u₁.wr] } + +/-! ## The whole blocks -/ + +theorem whole_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + ctrK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, fBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, fBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, fBlk s₀] s.wr := by + refine ⟨?_, ?_, ?_⟩ + · simp only [Modes.modeContract, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + State.withRegions_sp, State.callEntry_sp, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + h.a0, h.a1, h.a2, h.a3, h.sp, toNat_n] + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_data.sub_right (blk_sub s₀), + hp.iv_data.sub_right (blk_sub s₀), hp.sch_wrap, hp.iv_wrap, hp.blk_wrap, hp.al, hp.sp, hp.stk_sch, + hp.stk_iv, hp.stk_data.sub_right (blk_sub s₀)⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨fData s₀, by simp, 0, by simp, by simpa using Nat.mul_div_le (fL s₀) 16⟩ + +/-- The schedule, the counter block and the whole blocks once the registers +are saved, as on entry. -/ +theorem sv_bytes {s₀ : State} (hp : KPre s₀) : + Spec.Sm4.scheduleAt (kSvMem s₀) (fW s₀) = Spec.Sm4.scheduleAt s₀.mem (fW s₀) ∧ + bytesAt (kSvMem s₀) (fIv s₀) 16 = fIv0 s₀ ∧ Spec.Cbc.blocksAt (kSvMem s₀) (fD s₀) (fN s₀) = fBlks s₀ := by + have ef := svMem_frame s₀ + exact ⟨sched_of ef (fun r hr => by simp only [List.mem_singleton] at hr; subst hr; exact hp.sch_sv), + Proof.Cmac.bytesAt_frame ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv) (by decide), + blocksAt_frame' ef (fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.data_sv.sub_left (blk_sub s₀))⟩ + +/-- What the call on the whole blocks leaves. -/ +structure KWhole (s₀ s : State) : Prop where + s1 : s.gpr .s1 = fW s₀ + s5 : s.gpr .s5 = fIv s₀ + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + +theorem whole_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KSetup s₀ s) : + WP isa (.call "vg_sm4_ctr" ctr) s (KWhole s₀) := by + obtain ⟨eK, eIv, eB⟩ := sv_bytes hp + obtain ⟨hpre, hc, hw⟩ := whole_pre hp h + refine WP.callAny (k := ctrK) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, fBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + rw [h.mem] at fr + simp only [Modes.modeContract, Modes.ctrPost, Modes.dataAt, Modes.ivAt, Modes.ciph, + State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + h.a0, h.a1, h.a2, h.a3, toNat_n, h.mem] at post₂ + have post₃ := post₂ + rw [eK, eIv, eB] at post₃ + exact ⟨by rw [cs_of cs' .s1 (by simp), h.s1], by rw [cs_of cs' .s5 (by simp), h.s5], by rw [cs_of cs' .s2 (by simp), h.s2], + by rw [cs_of cs' .s3 (by simp), h.s3], by rw [cs_of cs' .s7 (by simp), h.s7], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], + fr.mono fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr ⊢ + rcases hr with h | h | h <;> simp [h], + post₃.1, post₃.2⟩ + +/-! ## The partial last block -/ + +theorem eval_u {s₀ s : State} (h : KWhole s₀ s) : + isa.eval (.zero .s3) s = some (decide (fU s₀ = 0)) := + eval_zero_ofNat s .s3 (by have := u_lt s₀; omega) h.s3 + +/-- What zeroing the block and setting up the arguments leaves. -/ +structure KArgs (s₀ s : State) : Prop where + a0 : s.gpr .a0 = fW s₀ + a1 : s.gpr .a1 = fIv s₀ + a2 : s.gpr .a2 = kBk s₀ + a3 : s.gpr .a3 = BitVec.ofNat 64 1 + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (fN s₀) + zero : bytesAt s.mem (kBk s₀) 16 = List.replicate 16 0 + +theorem zero_frame (s₀ : State) (m : Mem) (g : Reg → BitVec 64) : + Frame [kBlk s₀] m (Spill.saveMem m (kV s₀) g zeroSlots) := + Spill.saveMem_frame (lo := 64) (n := 16) (fun p hp' => by + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl <;> decide) (by decide) m _ g + +set_option linter.unusedSimpArgs false in +theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.block ctrFinalTailArgs) s (KArgs s₀) := by + show WP isa (.block (.li .t0 0 :: (Spill.saveCode .s7 zeroSlots ++ ctrFinalTailMoves))) _ _ + refine wp_li (imm := 0) (by decide) fun s₁ z => ?_ + have h7 : s₁.gpr .s7 = kV s₀ := by rw [z.other _ (by decide), h.s7] + have hw : ∀ p ∈ zeroSlots, InRegions s₁.wr (s₁.gpr .s7 + BitVec.ofNat 64 p.2) 8 := by + intro p hp' + rw [z.wr, h.wr, hp.wr, h7] + simp only [zeroSlots, List.mem_cons, List.not_mem_nil, or_false] at hp' + rcases hp' with rfl | rfl + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + · exact ⟨kSv s₀, by simp, Offset.contains_base _ (by decide) (by have := hp.sv_wrap; omega)⟩ + refine Spill.save_ok (by rw [h7]; exact hp.sv_al) (by decide) hw ?_ + unfold ctrFinalTailMoves Impl.AesCbc.RISCV64.mov + refine wp_mv fun s₂ u₂ => wp_mv fun s₃ u₃ => wp_addi (imm := 64) (by decide) fun s₄ u₄ => + wp_li (imm := 1) (by decide) fun s₅ u₅ => WP.block_nil ?_ + have c (r : Reg) (hr : r = .s0 ∨ r = .s1 ∨ r = .s2 ∨ r = .s3 ∨ r = .s4 ∨ r = .s5 ∨ r = .s6 ∨ r = .s7 ∨ + r = .s8 ∨ r = .s9 ∨ r = .s10 ∨ r = .s11) : s₅.gpr r = s.gpr r := by + rcases hr with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> + simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, + ↓reduceIte] <;> exact z.other _ (by decide) + have sp : s₅.sp = s.sp := by + rw [u₅.sp, u₄.sp, u₃.sp, u₂.sp, show ({ s₁ with mem := _ } : State).sp = s₁.sp from rfl, z.sp] + have rd : s₅.rd = s.rd := by + rw [u₅.rd, u₄.rd, u₃.rd, u₂.rd, show ({ s₁ with mem := _ } : State).rd = s₁.rd from rfl, z.rd] + have wr : s₅.wr = s.wr := by + rw [u₅.wr, u₄.wr, u₃.wr, u₂.wr, show ({ s₁ with mem := _ } : State).wr = s₁.wr from rfl, z.wr] + have hm : s₅.mem = Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots := by + rw [u₅.mem, u₄.mem, u₃.mem, u₂.mem, h7] + show Spill.saveMem s₁.mem _ _ _ = _ + rw [z.mem] + have fz : Frame [kBlk s₀] s.mem s₅.mem := by rw [hm]; exact zero_frame s₀ _ _ + have ivZ : ∀ r ∈ [kBlk s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr; exact hp.iv_sv.sub_right (blk_sv_sub s₀) + have blkZ : ∀ r ∈ [kBlk s₀], (fBlk s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + have g7 : ({ s₁ with mem := Spill.saveMem s₁.mem (s₁.gpr .s7) s₁.gpr zeroSlots } : State).gpr = s₁.gpr := rfl + refine ⟨?_, ?_, ?_, ?_, by rw [c .s2 (by simp), h.s2], by rw [c .s3 (by simp), h.s3], + by rw [c .s7 (by simp), h.s7], + fun r hr => by rw [c r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp, h.sp], by rw [rd, h.rd], by rw [wr, h.wr], ?_, ?_, ?_, ?_⟩ + · simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [z.other _ (by decide), h.s1] + · simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [z.other _ (by decide), h.s5] + · simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte, g7] + rw [h7] + · simp only [upd_gpr u₅, upd_gpr u₄, upd_gpr u₃, upd_gpr u₂, reduceCtorEq, ↓reduceIte] + · exact h.frame.trans (fz.mono fun r hr => by simp only [List.mem_singleton] at hr; simp [hr]) + · rw [blocksAt_frame' fz blkZ]; exact h.blocks + · rw [Proof.Cmac.bytesAt_frame fz ivZ (by decide), h.ctr] + · rw [hm, show Spill.saveMem s.mem (kV s₀) s₁.gpr zeroSlots = + ((s.mem.writeW (kBk s₀) (s₁.gpr .t0)).writeW (kBk s₀ + BitVec.ofNat 64 8) (s₁.gpr .t0)) by + simp only [Spill.saveMem, zeroSlots, Offset.add_add], z.gpr] + exact zero_bytes _ _ + +theorem tail_pre {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + ctrK.pre (s.callEntry.withRegions [kSch s₀] [kIv s₀, kBlk s₀]) ∧ + Covers ([kSch s₀] ++ [kIv s₀, kBlk s₀]) (s.rd ++ s.wr) ∧ Covers [kIv s₀, kBlk s₀] s.wr := by + have bs := blk_sv_sub s₀ + refine ⟨?_, ?_, ?_⟩ + · simp only [Modes.modeContract, State.withRegions_gpr, State.withRegions_rd, State.withRegions_wr, + State.withRegions_sp, State.callEntry_sp, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + h.a0, h.a1, h.a2, h.a3, h.sp, one_toNat, Nat.mul_one] + have := hp.sv_wrap + exact ⟨trivial, trivial, hp.sch_iv, hp.sch_sv.sub_right bs, hp.iv_sv.sub_right bs, hp.sch_wrap, + hp.iv_wrap, by rw [hp.bk_toNat]; omega, hp.al, hp.sp, hp.stk_sch, hp.stk_iv, hp.stk_sv.sub_right bs⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨kSch s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + · rw [h.wr, hp.wr] + refine Covers.of_sub fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact ⟨kIv s₀, by simp, 0, by simp, by simp⟩ + · exact ⟨kSv s₀, by simp, 64, by simp, by simp⟩ + +/-- What the call on the block leaves. -/ +structure KCall (s₀ s : State) : Prop where + s2 : s.gpr .s2 = fT s₀ + s3 : s.gpr .s3 = BitVec.ofNat 64 (fU s₀) + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + sp : s.sp = s₀.sp + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW1 s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (Spec.Ctr.next (fIv0 s₀) (fN s₀)) 1 + out : bytesAt s.mem (kBk s₀) 16 = kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀)) + +theorem cipher_length (k : Spec.Sm4.Schedule) (b : List Byte) : (Spec.Sm4.cipher k b).length = 16 := by + simp [Spec.Sm4.cipher] + +theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KArgs s₀ s) : + WP isa (.call "vg_sm4_ctr" ctr) s (KCall s₀) := by + obtain ⟨hpre, hc, hw⟩ := tail_pre hp h + have big := big_of (kW1_kW h.frame) + have eK := sched_of big hp.sch_big + refine WP.callAny (k := ctrK) ctr_ok (rd := [kSch s₀]) (wr := [kIv s₀, kBlk s₀]) hpre hc hw ?_ + (by have := ctr_depth; omega) + intro s' rd' wr' sp' fr' cs' post₂ + have fr := call_frame h.sp fr' + simp only [Modes.modeContract, Modes.ctrPost, Modes.dataAt, Modes.ivAt, Modes.ciph, + State.withRegions_gpr, State.withRegions_mem, State.callEntry_mem, + callEntry s (by decide : Reg.a0 ∉ linkRegs), callEntry s (by decide : Reg.a1 ∉ linkRegs), + callEntry s (by decide : Reg.a2 ∉ linkRegs), callEntry s (by decide : Reg.a3 ∉ linkRegs), + h.a0, h.a1, h.a2, h.a3, one_toNat, h.ctr] at post₂ + have post₃ := post₂ + rw [eK] at post₃ + have fc : Frame (kW1 s₀) s.mem s'.mem := fr.sub fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + · exact ⟨_, by simp, fun _ h => h⟩ + refine ⟨by rw [cs_of cs' .s2 (by simp), h.s2], by rw [cs_of cs' .s3 (by simp), h.s3], + by rw [cs_of cs' .s7 (by simp), h.s7], + fun r hr => by rw [cs_of cs' r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [sp', h.sp], by rw [rd', h.rd], by rw [wr', h.wr], h.frame.trans fc, ?_, post₃.2, ?_⟩ + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.cons_append, List.nil_append, List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hp.iv_data.symm.sub_left (blk_sub s₀) + · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) + · exact hp.stk_data.symm.sub_left (blk_sub s₀)] + exact h.blocks + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) h.zero post₃.1 + +/-- What the function leaves before restoring the registers. -/ +structure KDone (s₀ s : State) : Prop where + s7 : s.gpr .s7 = kV s₀ + kept : Kept s₀ s + rd : s.rd = s₀.rd + wr : s.wr = s₀.wr + frame : Frame (kW s₀) (kSvMem s₀) s.mem + blocks : Spec.Cbc.blocksAt s.mem (fD s₀) (fN s₀) = Spec.Ctr.crypt (kCiph s₀) (fIv0 s₀) (fBlks s₀) + tail : ∀ q < fU s₀, s.mem (fT s₀ + BitVec.ofNat 64 q) = s₀.mem (fT s₀ + BitVec.ofNat 64 q) ^^^ + (kCiph s₀ (Spec.Ctr.next (fIv0 s₀) (fN s₀))).getD q 0 + ctr : bytesAt s.mem (fIv s₀) 16 = Spec.Ctr.next (fIv0 s₀) (if fU s₀ = 0 then fN s₀ else fN s₀ + 1) + +theorem done_of_zero {s₀ s : State} (h : KWhole s₀ s) (hu : fU s₀ = 0) : KDone s₀ s := + ⟨h.s7, h.kept, h.rd, h.wr, kW1_kW h.frame, h.blocks, fun q hq => absurd hq (by omega), by + rw [ite_eq_left hu, h.ctr]⟩ + +theorem toNat_tail {s₀ : State} (hp : KPre s₀) (hu : fU s₀ ≠ 0) : (fT s₀).toNat = (fD s₀).toNat + 16 * fN s₀ := by + have := hp.data_wrap + have := Nat.div_add_mod (fL s₀) 16 + have eN := fN_eq s₀ + have eU := fU_eq s₀ + rw [BitVec.toNat_add, BitVec.toNat_ofNat, Nat.mod_eq_of_lt (a := 16 * fN s₀) (by omega), + Nat.mod_eq_of_lt (by omega)] + +open VG.Proof.Modes.RISCV64 (XPre XInv xorLoop_wp xf) + +theorem tail_xor_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KCall s₀ s) (hu : fU s₀ ≠ 0) : + WP isa (.seq (.block tailKey) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) s (KDone s₀) := by + refine WP.seq (wp_addi (imm := 64) (by decide) fun s₁ u₁ => WP.block_nil ?_) + have hU := u_lt s₀ + have hT := toNat_tail hp hu + have hL := Nat.div_add_mod (fL s₀) 16 + have hDw := hp.data_wrap + have hVw := hp.sv_wrap + have hB := hp.bk_toNat + have eN := fN_eq s₀ + have eU := fU_eq s₀ + have xp : XPre s₁ (kBk s₀) (fT s₀) (fU s₀) := { + pos := by omega + fK := by omega + fR := by omega + disj := (((hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀)).sub_right + (Region.sub_prefix (by omega))).symm + rdK := fun q hq => by + rw [u₁.rd, u₁.wr, h.rd, h.wr, hp.rd, hp.wr] + refine ⟨kSv s₀, by simp, ?_⟩ + rw [Offset.add_add] + exact Offset.contains_base _ (by omega) (by omega) + wrR := fun q hq => by + rw [u₁.wr, h.wr, hp.wr] + refine ⟨fData s₀, by simp, ?_⟩ + rw [show fT s₀ + BitVec.ofNat 64 q = fD s₀ + BitVec.ofNat 64 (16 * fN s₀ + q) from Offset.add_add _ _ _] + exact Offset.contains_base _ (by omega) (by omega) } + have x0 : XInv s₁ (kBk s₀) (fT s₀) (fU s₀) 0 s₁ := { + t2 := by rw [u₁.gpr, h.s7]; exact (BitVec.add_zero _).symm + s2 := by rw [u₁.other _ (by decide), h.s2]; exact (BitVec.add_zero _).symm + s3 := by rw [u₁.other _ (by decide), h.s3, Nat.sub_zero] + lt := by omega + mem := (Proof.Modes.over_zero _ _ _).symm + rd := rfl + wr := rfl + gpr := fun _ _ _ _ _ _ => rfl } + refine WP.mono (xorLoop_wp xp x0) fun s' d => ?_ + have tailD : ∀ r ∈ kW1 s₀, (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact (hp.iv_data.sub_right (tail_sub s₀)).symm + · exact hp.blk_tail.symm + · exact (hp.data_sv.sub_left (tail_sub s₀)).sub_right (blk_sv_sub s₀) + · exact (hp.stk_data.sub_right (tail_sub s₀)).symm + have tailS : ∀ r ∈ [kSv s₀], (fTail s₀).Disjoint r := by + intro r hr + simp only [List.mem_singleton] at hr; subst hr + exact hp.data_sv.sub_left (tail_sub s₀) + have hlen : (fTail s₀).len ≤ 2 ^ 64 := by show fU s₀ ≤ 2 ^ 64; omega + have ivT : ∀ r ∈ [fTail s₀], (kIv s₀).Disjoint r := by + intro r hr; simp only [List.mem_singleton] at hr; subst hr + exact hp.iv_data.sub_right (tail_sub s₀) + have g (r : Reg) (hr : r = .s7 ∨ r = .s0 ∨ r = .s8 ∨ r = .s9 ∨ r = .s10 ∨ r = .s11) : s'.gpr r = s.gpr r := by + rw [d.gpr r (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide) + (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide), + u₁.other _ (by rcases hr with rfl | rfl | rfl | rfl | rfl | rfl <;> decide)] + have fr : Frame [fTail s₀] s.mem s'.mem := by + rw [d.mem, u₁.mem]; exact Proof.Modes.over_frame _ _ _ _ + refine ⟨by rw [g .s7 (by simp), h.s7], fun r hr => by + rw [g r (by rcases hr with rfl | rfl | rfl | rfl | rfl <;> simp), h.kept r hr], + by rw [d.rd, u₁.rd, h.rd], by rw [d.wr, u₁.wr, h.wr], ?_, ?_, fun q hq => ?_, ?_⟩ + · exact (kW1_kW h.frame).trans (fr.sub fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact ⟨fData s₀, by simp, tail_sub s₀⟩) + · rw [blocksAt_frame' fr fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; exact hp.blk_tail] + exact h.blocks + · rw [d.mem, Proof.Modes.over_at hq (by omega), xf, u₁.mem, h.frame.bytes tailD hlen hq, + (svMem_frame s₀).bytes tailS hlen hq, ← bytesAt_getD s.mem (kBk s₀) (show q < 16 by omega), h.out] + · rw [ite_eq_right hu, Proof.Cmac.bytesAt_frame fr ivT (by decide), h.ctr, ← AesCtr.next_add] + +theorem mid_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s₀ s) : + WP isa (.ite (.zero .s3) (.block []) ctrFinalTail) s (KDone s₀) := by + by_cases hu : fU s₀ = 0 + · exact WP.ite true (by rw [eval_u h, decide_eq_true hu]) (fun _ => WP.block_nil (done_of_zero h hu)) + (fun h => by cases h) + · refine WP.ite false (by rw [eval_u h, decide_eq_false hu]) (fun h => by cases h) fun _ => ?_ + exact WP.seq (WP.mono (tail_args_wp hp h) fun _ h₁ => + WP.seq (WP.mono (tail_call_wp hp h₁) fun _ h₂ => tail_xor_wp hp h₂ hu)) + +/-! ## Restoring the registers -/ + +theorem end_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KDone s₀ s) : + WP isa (.block finalRestore) s fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.gpr .ra = s₀.gpr .ra ∧ s'.mem = s.mem := by + have hs : Spill.Saved (kV s₀) s₀.gpr finalSaved s.mem := + (Spill.saveMem_saved (by decide) s₀.mem (kV s₀) s₀.gpr).frame h.frame fun p hp' r hr => by + have hsub : Region.Sub ⟨kV s₀ + BitVec.ofNat 64 p.2, 8⟩ (kSv s₀) := + Offset.sub_base _ (by have := saved_slots p hp'; omega) + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl + · exact hp.iv_sv.symm.sub_left hsub + · exact hp.data_sv.symm.sub_left hsub + · exact slot_blk s₀ p hp' + · exact hp.stk_sv.symm.sub_left hsub + show WP isa (.block (Spill.restoreCode .s7 finalSaved)) _ _ + refine WP.mono (Spill.restore_wp hp.sv_al h.s7 saved_fits (by decide) (fun p hp' => ?_) hs) + fun s' r => ⟨fun q hq => r.gpr_of ?_, r.gpr (.ra, 0) (by decide), r.mem⟩ + · rw [h.rd, h.wr, hp.rd, hp.wr] + have := saved_slots p hp' + exact ⟨kSv s₀, by simp, Offset.contains_base _ (by omega) (by have := hp.sv_wrap; omega)⟩ + · simp only [preserved, List.mem_cons, List.not_mem_nil, or_false] at hq + rcases hq with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl + all_goals first + | exact .inl (by decide) + | exact .inr (h.kept _ (by simp)) + +/-! ## The whole function -/ + +theorem final_wp {s₀ : State} (hp : KPre s₀) : + WP isa ctrFinal s₀ fun s' => + (∀ r ∈ preserved, s'.gpr r = s₀.gpr r) ∧ s'.gpr .ra = s₀.gpr .ra ∧ + ∃ s₁, KDone s₀ s₁ ∧ s'.mem = s₁.mem := by + refine WP.seq (WP.mono (setup_wp hp) fun s₁ h₁ => ?_) + refine WP.seq (WP.mono (whole_wp hp h₁) fun s₂ h₂ => ?_) + refine WP.seq (WP.mono (mid_wp hp h₂) fun s₃ h₃ => ?_) + exact WP.mono (end_wp hp h₃) fun _ ⟨g, ra, m⟩ => ⟨g, ra, s₃, h₃, m⟩ + +/-- `Spec.Ctr.CryptFinal`, from what the function leaves. -/ +theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalRISCV64.post s₀ s' := by + show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) + exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) + +theorem final_correct (s : State) (hs : ctrFinalRISCV64.pre s) : + ∃ t s', Exec isa ctrFinal s t s' ∧ abiPreserved s s' ∧ ctrFinalRISCV64.post s s' := by + obtain ⟨t, s', he, hg, hra, s₁, h₁, hm⟩ := final_wp (KPre.of hs) + exact ⟨t, s', he, ⟨hg, Exec.sp he, hra⟩, final_post h₁ hm⟩ + +/-! ## Constant time -/ + +theorem setup_taint : ∃ h, (taint.check (Taint.ofRegs [.a0, .a1, .a2, .a3, .a4]) + (.block ctrFinalSetup) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem tailArgs_taint : ∃ h, (taint.check (Taint.ofRegs [.s1, .s5, .s7]) + (.block ctrFinalTailArgs) h).isSome = true := ⟨_, by taint_decide⟩ + +theorem xor_taint : ∃ h, (taint.check (Taint.ofRegs [.s7, .s2, .s3]) + (.seq (.block tailKey) (.loop (.block Impl.Modes.RISCV64.xorStep) (.nonzero .s3))) h).isSome = + true := ⟨_, by taint_decide⟩ + +theorem restore_taint : ∃ h, (taint.check (Taint.ofRegs [.s7]) (.block finalRestore) h).isSome = true := + ⟨_, by taint_decide⟩ + +/-- The callee's public arguments, from the registers. -/ +theorem ctr_pub {a b : State} (hsp : a.sp = b.sp) (h0 : a.gpr .a0 = b.gpr .a0) (h1 : a.gpr .a1 = b.gpr .a1) + (h2 : a.gpr .a2 = b.gpr .a2) (h3 : a.gpr .a3 = b.gpr .a3) : ctrK.pub a b := by + show modePub a b + rw [Modes.modePub_iff] + exact ⟨hsp, h0, h1, h2, h3⟩ + +theorem final_rel {s₀ s₀' : State} (h0 : ctrFinalRISCV64.pre s₀) (h0' : ctrFinalRISCV64.pre s₀') + (hq : ctrFinalRISCV64.pub s₀ s₀') : + RelCT isa (fun a b => a = s₀ ∧ b = s₀') ctrFinal fun _ _ => True := by + have hp := KPre.of h0 + have hp' := KPre.of h0' + obtain ⟨qW, qIv, qD, qL, qV, qSp⟩ := hq + have qU : fU s₀ = fU s₀' := by simp only [fU, fL, qL] + have qN : fN s₀ = fN s₀' := by simp only [fN, fL, qL] + have qT : fT s₀ = fT s₀' := by simp only [fT, fD, qD, qN] + -- The registers saved and the arguments set up. + obtain ⟨_, t₁⟩ := setup_taint + have r₁ := (RelCT.taint (A := taint) (P := fun a b => a = s₀ ∧ b = s₀') _ + (fun a b h => by + obtain ⟨rfl, rfl⟩ := h + refine AesCfb.RISCV64.Final.agree_of qSp fun r hr => ?_ + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl | rfl | rfl <;> with_reducible assumption) t₁).wp + (F₁ := KSetup s₀) (F₂ := KSetup s₀') + fun a b h => by obtain ⟨rfl, rfl⟩ := h; exact ⟨setup_wp hp, setup_wp hp'⟩ + -- The whole blocks. + have r₂ := (RelCT.callEx (k := ctrK) (n := "vg_sm4_ctr") ctr_ok ctr_ct + (P := fun a b => KSetup s₀ a ∧ KSetup s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := whole_pre hp ha + obtain ⟨pb, cb, wb⟩ := whole_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ctr_pub ?_ ?_ ?_ ?_ ?_, ca, wa, cb, wb⟩ <;> + simp only [State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), + callEntry a (by decide : Reg.a2 ∉ linkRegs), callEntry a (by decide : Reg.a3 ∉ linkRegs), + callEntry b (by decide : Reg.a0 ∉ linkRegs), callEntry b (by decide : Reg.a1 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), callEntry b (by decide : Reg.a3 ∉ linkRegs), + ha.a0, ha.a1, ha.a2, ha.a3, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.sp] + · exact qSp + · rw [fW, fW, qW] + · rw [fIv, fIv, qIv] + · rw [fD, fD, qD] + · rw [qN]).wp + (F₁ := KWhole s₀) (F₂ := KWhole s₀') fun a b h => ⟨whole_wp hp h.1, whole_wp hp' h.2⟩ + -- The partial last block. + have tail (hu : fU s₀ ≠ 0) : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) ctrFinalTail + fun a b => KDone s₀ a ∧ KDone s₀' b := by + have hu' : fU s₀' ≠ 0 := qU ▸ hu + obtain ⟨_, t₃⟩ := tailArgs_taint + have a₁ := (RelCT.taint (A := taint) (P := fun a b => KWhole s₀ a ∧ KWhole s₀' b) _ + (fun a b h => AesCfb.RISCV64.Final.agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.s1, h.2.s1, fW, fW, qW] + · rw [h.1.s5, h.2.s5, fIv, fIv, qIv] + · rw [h.1.s7, h.2.s7, kV, kV, qV]) t₃).wp + (F₁ := KArgs s₀) (F₂ := KArgs s₀') fun a b h => ⟨tail_args_wp hp h.1, tail_args_wp hp' h.2⟩ + have a₂ := (RelCT.callEx (k := ctrK) (n := "vg_sm4_ctr") ctr_ok ctr_ct + (P := fun a b => KArgs s₀ a ∧ KArgs s₀' b) fun a b ⟨ha, hb⟩ => by + obtain ⟨pa, ca, wa⟩ := tail_pre hp ha + obtain ⟨pb, cb, wb⟩ := tail_pre hp' hb + refine ⟨_, _, _, _, pa, pb, ctr_pub ?_ ?_ ?_ ?_ ?_, ca, wa, cb, wb⟩ <;> + simp only [State.withRegions_gpr, State.withRegions_sp, State.callEntry_sp, + callEntry a (by decide : Reg.a0 ∉ linkRegs), callEntry a (by decide : Reg.a1 ∉ linkRegs), + callEntry a (by decide : Reg.a2 ∉ linkRegs), callEntry a (by decide : Reg.a3 ∉ linkRegs), + callEntry b (by decide : Reg.a0 ∉ linkRegs), callEntry b (by decide : Reg.a1 ∉ linkRegs), + callEntry b (by decide : Reg.a2 ∉ linkRegs), callEntry b (by decide : Reg.a3 ∉ linkRegs), + ha.a0, ha.a1, ha.a2, ha.a3, ha.sp, hb.a0, hb.a1, hb.a2, hb.a3, hb.sp] + · exact qSp + · rw [fW, fW, qW] + · rw [fIv, fIv, qIv] + · rw [kBk, kBk, kV, kV, qV]).wp + (F₁ := KCall s₀) (F₂ := KCall s₀') fun a b h => ⟨tail_call_wp hp h.1, tail_call_wp hp' h.2⟩ + obtain ⟨_, t₄⟩ := xor_taint + have a₃ := (RelCT.taint (A := taint) (P := fun a b => KCall s₀ a ∧ KCall s₀' b) _ + (fun a b h => AesCfb.RISCV64.Final.agree_of (by rw [h.1.sp, h.2.sp, qSp]) fun r hr => by + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · rw [h.1.s7, h.2.s7, kV, kV, qV] + · rw [h.1.s2, h.2.s2, qT] + · rw [h.1.s3, h.2.s3, qU]) t₄).wp + (F₁ := KDone s₀) (F₂ := KDone s₀') fun a b h => ⟨tail_xor_wp hp h.1 hu, tail_xor_wp hp' h.2 hu'⟩ + exact (a₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq + ((a₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq (a₃.mono (fun _ _ h => h) fun _ _ h => h.2)) + have r₃ : RelCT isa (fun a b => KWhole s₀ a ∧ KWhole s₀' b) (.ite (.zero .s3) (.block []) ctrFinalTail) + (fun a b => KDone s₀ a ∧ KDone s₀' b) := by + refine RelCT.ite (fun a b h => by rw [eval_u h.1, eval_u h.2, qU]) ?_ ?_ + · refine RelCT.block_nil fun a b h => ?_ + have h0 : fU s₀ = 0 := by + have := h.2; rw [eval_u h.1.1] at this; simpa using this + exact ⟨done_of_zero h.1.1 h0, done_of_zero h.1.2 (qU ▸ h0)⟩ + · refine (RelCT.exists_ fun (hu : fU s₀ ≠ 0) => tail hu).mono + (fun a b h => ⟨?_, h.1.1, h.1.2⟩) fun _ _ h => h + have := h.2; rw [eval_u h.1.1] at this; simpa using this + have r₃' := r₃.wp (F₁ := fun (s : State) => s.sp = s₀.sp) (F₂ := fun (s : State) => s.sp = s₀'.sp) + fun a b h => + ⟨WP.mono (AesCbc.RISCV64.wp_sp (mid_wp hp h.1)) fun _ x => x.2.trans h.1.sp, + WP.mono (AesCbc.RISCV64.wp_sp (mid_wp hp' h.2)) fun _ x => x.2.trans h.2.sp⟩ + -- The registers restored. + obtain ⟨_, t₅⟩ := restore_taint + have r₄ := RelCT.taint (A := taint) (P := fun a b => (KDone s₀ a ∧ KDone s₀' b) ∧ + a.sp = s₀.sp ∧ b.sp = s₀'.sp) _ + (fun a b h => AesCfb.RISCV64.Final.agree_of (by rw [h.2.1, h.2.2, qSp]) fun r hr => by + simp only [List.mem_singleton] at hr; subst hr; rw [h.1.1.s7, h.1.2.s7, kV, kV, qV]) t₅ + exact (r₁.mono (fun _ _ h => h) fun _ _ h => h.2).seq ((r₂.mono (fun _ _ h => h) fun _ _ h => h.2).seq + (r₃'.seq r₄)) + +theorem final_ct : ConstantTime isa ctrFinalRISCV64.pre ctrFinalRISCV64.pub ctrFinal := + fun _ _ _ _ _ _ h₁ h₂ hq e₁ e₂ => (final_rel h₁ h₂ hq _ _ _ _ _ _ ⟨rfl, rfl⟩ e₁ e₂).1 + +/-! ## Verified -/ + +theorem ctrFinal_verified : Verified RISCV64.target ctrFinal ctrFinalScratchContract := + Verified.of_correct final_correct final_ct ctrFinal_implies + +/-! ## With `save` on the stack + +The final function has four argument words, so `save` is its fifth, in `a4`: +it runs its code in a frame of 80 bytes on the stack (`withStackScratchWiped`), +`save`'s 80 bytes (the registers, then the block that held the last output +block), which it zeroes before returning. Its calls use 3232 bytes below it, +so 3312 in all. -/ + +/-- A state satisfying the shared contract's precondition. -/ +def ctrFinalFrameSat : State := { ctrFinalSat with wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } + +theorem ctrFinalFrameSat_pre : ∃ s, (Spec.Sm4.ctrFinalContract RISCV64.abi 3312).pre s := by + implies_sat [Spec.Sm4.ctrFinalContract, Spec.Sm4.ctrFinalSig, RISCV64.abi, RISCV64.argRegs] + [ctrFinalFrameSat, ctrFinalSat] using ctrFinalFrameSat + +theorem ctrFinal_framed : + Verified RISCV64.target (Impl.StackScratch.RISCV64.withStackScratchWiped 80 .a4 10 ctrFinal) + (Spec.Sm4.ctrFinalContract RISCV64.abi 3312) := by + rw [Proof.Sm4.ctrFinalContract_eq] + exact RISCV64.Verified.stackScratchWiped (sig := Spec.Sm4.ctrFinalSig) (nm := "save") (e := .u64) (n := 10) + (post := Proof.Sm4.ctrFinalPost RISCV64.abi.ptrBits) (wa := true) (stack := 3232) (bytes := 80) (words := 10) + ctrFinal_verified (by decide) (by decide) (by decide) (Proof.Sm4.ctrFinalPostOut_local _) ctrFinalFrameSat_pre + +end VG.Proof.Sm4.RISCV64.CtrFinal From da570fcd8664b1b9132a8d7e4f93937754ea2c90 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 13:07:36 +0000 Subject: [PATCH 16/18] OFB/CTR finals: one copy of each shared lemma ofbFinal_of (and RISC-V's ofbFinal_out) move into the target-independent Proof/Modes/FbFinal.lean; the CTR finals' entry-memory locality lemmas (Camellia's ctrFinalPre_local and ctrFinalPost_local, SM4's ctrFinalPost_local) into Proof/{Camellia,Sm4}/CtrFinal.lean. No statement, code or registration changes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../Proof/Camellia/Arm/CtrFinal.lean | 41 ---------------- .../Proof/Camellia/CtrFinal.lean | 40 ++++++++++++++-- .../Proof/Camellia/PPC64LE/CtrFinal.lean | 45 +----------------- .../Proof/Camellia/X86/CtrFinal.lean | 39 --------------- .../Proof/Modes/Arm/SeqFinal.lean | 25 ---------- lean/VerifiedGarbage/Proof/Modes/FbFinal.lean | 46 +++++++++++++----- .../Proof/Modes/PPC64LE/SeqFinal.lean | 22 --------- .../Proof/Modes/RISCV64/SeqFinal.lean | 23 --------- .../Proof/Modes/X86/SeqFinal.lean | 22 --------- .../Proof/Sm4/Arm/CtrFinal.lean | 40 ---------------- lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean | 30 ++++++++++-- .../Proof/Sm4/PPC64LE/CtrFinal.lean | 47 +------------------ .../Proof/Sm4/X86/CtrFinal.lean | 39 --------------- 13 files changed, 102 insertions(+), 357 deletions(-) diff --git a/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean index 456ddc01d7c..be23527b46a 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/Arm/CtrFinal.lean @@ -1167,47 +1167,6 @@ stack argument, `save`'s address, the word holding `lr`, and `save`'s 56 bytes, the block included, which it zeroes before returning (and 4 bytes of padding). The code's calls use 2912 bytes below it, so 2984 in all. -/ -/-- `Spec.Camellia.ctrFinalPre` reads no memory. -/ -theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₁ → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₂ := by - intro vs m₁ m₂ hlen _ h - match vs, hlen with - | [_, _, _, _, _], _ => exact h - -private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} - (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : - bytesAt m₂ p k = bytesAt m₁ p k := by - simp only [bytesAt] - exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) - -/-- `Proof.Camellia.ctrFinalPostSk` reads the memory on entry only within -the buffers. -/ -theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, - vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₁ m' r → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₂ m' r := by - intro vs m₁ m₂ m' r hlen hb h - match vs, hlen with - | [k, rounds, ctr, data, len], _ => - simp only [Spec.Camellia.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, - forall_eq, Elem.size, Nat.mul_one] at hb - have hk := Proof.Camellia.agree_of hb.1 - have hc := Proof.Camellia.agree_of hb.2.1 - have hd := Proof.Camellia.agree_of hb.2.2 - change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Camellia.ctrFinalPostSk pb) _ m₁ m' r at h - change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Camellia.ctrFinalPostSk pb) _ m₂ m' r - dsimp only [Curry.apply, Proof.Camellia.ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ - have := Nat.mod_le len.toNat (2 ^ pb) - intro hR - rw [Proof.Camellia.subkeysAt_congr (by rcases hR with h' | h' <;> rw [h'] <;> decide) hk, - bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] - exact h hR - /-- A state satisfying the precondition, without `save`. -/ def ctrFinalFrameSat : State := { ctrFinalSat with rd := [⟨0x1000, 272⟩, ⟨0x8000, 4⟩], wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } diff --git a/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean index 8c4bf6a2e9a..43885359760 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/CtrFinal.lean @@ -14,9 +14,10 @@ Not trusted, and the same on every target. `ctrFinalContractSk`: `Spec.Camellia.ctrFinalContract` on the subkeys at `schedule`, for `rounds` of 18 or 24, from which the shared contract follows (`ctrFinal_of_sk`), as `ctrContractSk` is for `vg_camellia_ctr` (`CtrScratch.lean`); its -postcondition reads the memory on return only within the function's buffers -(`ctrFinalPostOut_local`), as a frame that keeps working space on the stack -needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by +precondition and postcondition read the memory on entry, and its +postcondition the memory on return, only within the function's buffers +(`ctrFinalPre_local`, `ctrFinalPost_local`, `ctrFinalPostOut_local`), as a +frame that keeps working space on the stack needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by `Proof.Modes.CtrFinal.cryptFinal_of`, for any cipher. -/ @@ -76,4 +77,37 @@ theorem ctrFinalPostOut_local (pb : Nat) : ∀ vs m m₁ m₂ r, vs.length = (ct rw [bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] exact h hR +/-- `Spec.Camellia.ctrFinalPre` reads no memory. -/ +theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPre pb) vs m₁ → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPre pb) vs m₂ := by + intro vs m₁ m₂ hlen _ h + match vs, hlen with + | [_, _, _, _, _], _ => exact h + +/-- `ctrFinalPostSk` reads the memory on entry only within the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPostSk pb) vs m₁ m' r → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPostSk pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, rounds, ctr, data, len], _ => + simp only [ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hk := agree_of hb.1 + have hc := agree_of hb.2.1 + have hd := agree_of hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPostSk pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPostSk pb) _ m₂ m' r + dsimp only [Curry.apply, ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + intro hR + rw [subkeysAt_congr (by rcases hR with h' | h' <;> rw [h'] <;> decide) hk, + bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] + exact h hR + end VG.Proof.Camellia diff --git a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean index 8ce56bd4513..d468e053c00 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/PPC64LE/CtrFinal.lean @@ -104,7 +104,7 @@ the callee's constant time (`RelCT.callEx`), whose public arguments agree. The frame of the registration needs the contract's precondition and postcondition to read the memory on entry only within the function's -buffers (`ctrFinalPre_local`, `ctrFinalPost_local`). +buffers (`Proof.Camellia.ctrFinalPre_local`, `ctrFinalPost_local`). -/ @[expose] public section @@ -990,49 +990,6 @@ theorem final_ct : ConstantTime isa ctrFinalPPC64LE.pre ctrFinalPPC64LE.pub ctrF theorem ctrFinal_verified : Verified PPC64LE.target ctrFinal ctrFinalScratchContract := Verified.of_correct final_correct final_ct ctrFinal_implies -/-! ## Locality - -The frame needs the contract's precondition and postcondition to read the -memory on entry only within the function's buffers. -/ - -private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} - (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : - bytesAt m₂ p k = bytesAt m₁ p k := by - simp only [Spec.Aes.bytesAt] - exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) - -theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₁ → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₂ := by - intro vs m₁ m₂ hlen _ h - match vs, hlen with - | [_, _, _, _, _], _ => exact h - -/-- `ctrFinalPostSk` reads the memory on entry only within the buffers. -/ -theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₁ m' r → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₂ m' r := by - intro vs m₁ m₂ m' r hlen hb h - match vs, hlen with - | [k, rounds, ctr, data, len], _ => - simp only [Spec.Camellia.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, - forall_eq, Elem.size, Nat.mul_one] at hb - have hs := Proof.Camellia.agree_of hb.1 - have hc := Proof.Camellia.agree_of hb.2.1 - have hd := Proof.Camellia.agree_of hb.2.2 - change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Camellia.ctrFinalPostSk pb) _ m₁ m' r at h - change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Camellia.ctrFinalPostSk pb) _ m₂ m' r - dsimp only [Curry.apply, Proof.Camellia.ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ - have := Nat.mod_le len.toNat (2 ^ pb) - intro hR - rw [Proof.Camellia.subkeysAt_congr (by rcases hR with h | h <;> rw [h] <;> decide) fun i hi => hs i hi, - bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] - exact h hR - /-! ## With `save` on the stack The final function has five argument words, so `save` is its sixth, in `r8`: diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean index 2c43b11dd9c..ff68ca89ad3 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/X86/CtrFinal.lean @@ -1378,45 +1378,6 @@ address, and `save`'s 32 bytes (the registers, then the block that held the last output block), which it zeroes before returning. The code's calls use 2796 bytes below it, so 2856 in all. -/ -private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} - (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : - Spec.Aes.bytesAt m₂ p k = Spec.Aes.bytesAt m₁ p k := by - simp only [Spec.Aes.bytesAt] - exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) - -/-- `ctrFinalPre` reads no memory. -/ -theorem ctrFinalPre_local (pb : Nat) : ∀ vs m₁ m₂, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₁ → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Spec.Camellia.ctrFinalPre pb) vs m₂ := by - intro vs m₁ m₂ hlen _ h - match vs, hlen with - | [_, _, _, _, _], _ => exact h - -/-- `ctrFinalPostSk` reads the memory on entry only within the buffers. -/ -theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Camellia.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Camellia.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₁ m' r → - Curry.apply (Spec.Camellia.ctrFinalSig.words pb) (Proof.Camellia.ctrFinalPostSk pb) vs m₂ m' r := by - intro vs m₁ m₂ m' r hlen hb h - match vs, hlen with - | [k, rounds, ctr, data, len], _ => - simp only [Spec.Camellia.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, - forall_eq, Elem.size, Nat.mul_one] at hb - have hs := Proof.Camellia.agree_of hb.1 - have hc := Proof.Camellia.agree_of hb.2.1 - have hd := Proof.Camellia.agree_of hb.2.2 - change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Camellia.ctrFinalPostSk pb) _ m₁ m' r at h - change Curry.apply [ArgWord.addr, ArgWord.int pb, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Camellia.ctrFinalPostSk pb) _ m₂ m' r - dsimp only [Curry.apply, Proof.Camellia.ctrFinalPostSk, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ - have := Nat.mod_le len.toNat (2 ^ pb) - intro hR - rw [Proof.Camellia.subkeysAt_congr (by rcases hR with h | h <;> rw [h] <;> decide) fun i hi => hs i hi, - bytesAt_congr' hc, bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega)] - exact h hR - theorem frameSat_pre : ∃ s, (Proof.Camellia.ctrFinalContractSk X86.abi 2856).pre s := by implies_sat [Proof.Camellia.ctrFinalContractSk, Spec.Camellia.ctrFinalSig, Spec.Camellia.ctrFinalPre, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] [Fb.frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using Fb.frameSat diff --git a/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean index 400f4f19702..917f5fc6950 100644 --- a/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/Arm/SeqFinal.lean @@ -1069,31 +1069,6 @@ theorem cfbDecF_finalOk (c : Core) (h1 : 1 ≤ c.lg) (h31 : c.lg ≤ 31) (hl : 2 /-! ## OFB -/ -/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` -whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last -`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block -(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ -theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) - (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) - (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) - (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = - Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) - (ciph (Spec.Ofb.next ciph iv (len / L)))) : - bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by - have hx := VG.Proof.Modes.xor_flatten_outputs hc m₀ (len / L) D iv - have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] - rw [VG.Proof.Modes.bytesAt_blocks_tail L m' D len, hblocks, htail, Spec.Ofb.cryptFinal, - VG.Proof.Modes.bytesAt_length, VG.Proof.Modes.blockCount_eq hL, VG.Proof.Modes.bytesAt_blocks_tail L m₀ D len, - Spec.Ofb.crypt, hnB] - split - · rename_i h0 - rw [h0, ← hx] - simp [bytesAt, Spec.Cbc.xor] - · rw [VG.Proof.AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] - exact (List.zipWith_append (by - rw [← VG.Proof.Modes.bytesAt_mul, VG.Proof.Modes.bytesAt_length, - VG.Proof.Modes.length_flatten_outputs hc])).symm - /-- The final function with `ofb` encrypts and decrypts as `Spec.Ofb.CryptFinal` says, for a cipher whose every output is a block. -/ theorem ofbFinal_post {c : Core} {S : CoreSpec c} {s s' : State} (h : (seqFinalArm c S ofb).post s s') diff --git a/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean b/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean index 7cb487ee7e9..4911e43253e 100644 --- a/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/FbFinal.lean @@ -259,6 +259,40 @@ theorem xor_flatten_outputs {L : Nat} {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (cip List.flatten_cons, ← xor_flatten_outputs hc m₀ n] exact List.zipWith_append (by rw [hc, bytesAt_length]) +/-- OFB of the `len` bytes at `D`, as a final function leaves them: its +`n = len / L` whole blocks as `Spec.Ofb.crypt`'s from `iv`, then its last +`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block +(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ +theorem ofbFinal_out {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + (m₀ : Mem) (D : Addr) (iv : List Byte) (len : Nat) : + (Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))).flatten ++ + Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) + (ciph (Spec.Ofb.next ciph iv (len / L))) = + Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by + have hx := xor_flatten_outputs hc m₀ (len / L) D iv + have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] + rw [Spec.Ofb.cryptFinal, bytesAt_length, blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] + split + · rename_i h0 + rw [h0, ← hx] + simp [bytesAt, Spec.Cbc.xor] + · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] + exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm + +/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` +whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last +`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block +(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ +theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) + (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) + (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) + (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = + Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) + (ciph (Spec.Ofb.next ciph iv (len / L)))) : + bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by + rw [bytesAt_blocks_tail L m' D len, hblocks, htail] + exact ofbFinal_out hL hc m₀ D iv len + /-- OFB of the `len` bytes at `D`, from the bytes and the block a final function leaves: `Spec.Ofb.cryptFinal`, and the last output block used, `Spec.Ofb.next` after `⌈len / L⌉` blocks. -/ @@ -268,19 +302,9 @@ theorem ofbFinal_of_bytes {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) ∧ fbNextF .ofb L ciph m₀ D iv len = Spec.Ofb.next ciph iv (Spec.Ofb.blockCount L len) := by obtain ⟨hb, hn⟩ := ofb_of L ciph m₀ D iv (len / L) - have hx := xor_flatten_outputs hc m₀ (len / L) D iv have hT := fbFinal_tail hL hc h rw [hn] at hT - have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] - refine ⟨?_, ?_⟩ - · rw [bytesAt_blocks_tail L m' D len, fbFinal_blocks hc h, hb, hT, Spec.Ofb.cryptFinal, bytesAt_length, - blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] - split - · rename_i h0 - rw [h0, ← hx] - simp [bytesAt, Spec.Cbc.xor] - · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] - exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm + refine ⟨ofbFinal_of hL hc m₀ m' D iv len (by rw [fbFinal_blocks hc h, hb]) hT, ?_⟩ · rw [fbNextF, hn, blockCount_eq hL] split · rfl diff --git a/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean index 6739dc07ba1..f977c01fef6 100644 --- a/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/PPC64LE/SeqFinal.lean @@ -1173,28 +1173,6 @@ theorem ofb_post_inBounds (c : Core) : ∀ o ∈ (Mode.ofb c.bw).post, o.InBound (copyBlk_inBounds (by simp [lens]) (by simp [lens]) o) (xorBlk_inBounds (by simp [lens]) (by simp [lens]) (by simp [lens]) o) -/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` -whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last -`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block -(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ -theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) - (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) - (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) - (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = - Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) - (ciph (Spec.Ofb.next ciph iv (len / L)))) : - bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by - have hx := xor_flatten_outputs hc m₀ (len / L) D iv - have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] - rw [bytesAt_blocks_tail L m' D len, hblocks, htail, Spec.Ofb.cryptFinal, bytesAt_length, - blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] - split - · rename_i h0 - rw [h0, ← hx] - simp [bytesAt, Spec.Cbc.xor] - · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] - exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm - /-- OFB of a message's last piece: `seqFinal`'s results as `Spec.Ofb.CryptFinal`'s, for the `len` bytes at the data. -/ theorem ofbFinal_wp (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : SeqPre c byteMode s₀) diff --git a/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean index 057b88ee8c4..3c1e968afe7 100644 --- a/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/RISCV64/SeqFinal.lean @@ -748,29 +748,6 @@ theorem ofb_finalOk (c : Core) : FinalOk c (Mode.ofb c.bw) := exact append_ok (copyBlk_inBounds (b _) (b _)) (xorBlk_inBounds (b _) (b _) (b _)) o ho, append_ok (copyBlk_wordAl _ _ _) (xorBlk_wordAl _ _ _ _)⟩ -/-- OFB of the `len` bytes at `D`, as a final function leaves them: its -`n = len / L` whole blocks as `Spec.Ofb.crypt`'s from `iv`, then its last -`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block -(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ -theorem ofbFinal_out {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) - (m₀ : Mem) (D : Addr) (iv : List Byte) (len : Nat) : - (Spec.Ofb.crypt ciph iv (chunksAt L m₀ D (len / L))).flatten ++ - Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) - (ciph (Spec.Ofb.next ciph iv (len / L))) = - Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by - rw [show chunksAt L m₀ D (len / L) = Proof.Modes.blocksOf L m₀ D (len / L) from rfl] - have hx := Proof.Modes.xor_flatten_outputs hc m₀ (len / L) D iv - have hnB : (Proof.Modes.blocksOf L m₀ D (len / L)).length = len / L := by simp [Proof.Modes.blocksOf] - rw [Spec.Ofb.cryptFinal, Proof.Modes.bytesAt_length, Proof.Modes.blockCount_eq hL, - Proof.Modes.bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] - split - · rename_i h0 - rw [h0, ← hx] - simp [bytesAt, Spec.Cbc.xor] - · rw [Proof.AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] - exact (List.zipWith_append (by - rw [← Proof.Modes.bytesAt_mul, Proof.Modes.bytesAt_length, Proof.Modes.length_flatten_outputs hc])).symm - /-- OFB of a message's last piece, as the specification's. -/ theorem ofbFinal_wp (cs : CoreSpec c) {s₀ : State} {k : cs.Key} (hp : SeqPre c byteMode s₀) (hk : cs.KeyArgs s₀ (wrs0 c byteMode s₀) k) : diff --git a/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean b/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean index fb6965507c6..3f09519a13e 100644 --- a/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean +++ b/lean/VerifiedGarbage/Proof/Modes/X86/SeqFinal.lean @@ -1164,28 +1164,6 @@ theorem ofb_post_inBounds (c : Core) : ∀ o ∈ (Mode.ofb c.bw).post, o.InBound (copyBlk_inBounds (by simp [lens]) (by simp [lens]) o) (xorBlk_inBounds (by simp [lens]) (by simp [lens]) (by simp [lens]) o) -/-- OFB of the `len` bytes at `D` by a final function: its `n = len / L` -whole blocks replaced by `Spec.Ofb.crypt`'s from `iv`, and its last -`len % L` bytes XORed with `CIPH_K(Oₙ)`, `Oₙ` the last whole output block -(`Spec.Ofb.next` after `n`): `Spec.Ofb.cryptFinal`. -/ -theorem ofbFinal_of {L : Nat} (hL : 0 < L) {ciph : Spec.Cbc.Cipher} (hc : ∀ b, (ciph b).length = L) - (m₀ m' : Mem) (D : Addr) (iv : List Byte) (len : Nat) - (hblocks : blocksOf L m' D (len / L) = Spec.Ofb.crypt ciph iv (blocksOf L m₀ D (len / L))) - (htail : bytesAt m' (D + BitVec.ofNat 64 (L * (len / L))) (len % L) = - Spec.Cbc.xor (bytesAt m₀ (D + BitVec.ofNat 64 (L * (len / L))) (len % L)) - (ciph (Spec.Ofb.next ciph iv (len / L)))) : - bytesAt m' D len = Spec.Ofb.cryptFinal ciph L iv (bytesAt m₀ D len) := by - have hx := xor_flatten_outputs hc m₀ (len / L) D iv - have hnB : (blocksOf L m₀ D (len / L)).length = len / L := by simp [blocksOf] - rw [bytesAt_blocks_tail L m' D len, hblocks, htail, Spec.Ofb.cryptFinal, bytesAt_length, - blockCount_eq hL, bytesAt_blocks_tail L m₀ D len, Spec.Ofb.crypt, hnB] - split - · rename_i h0 - rw [h0, ← hx] - simp [bytesAt, Spec.Cbc.xor] - · rw [AesOfb.outputs_succ, List.flatten_append, List.flatten_singleton, ← hx] - exact (List.zipWith_append (by rw [← bytesAt_mul, bytesAt_length, length_flatten_outputs hc])).symm - /-- OFB of a message's last piece: `seqFinal`'s results as `Spec.Ofb.CryptFinal`'s, for the `len` bytes at the data. -/ theorem ofbFinal_wp (cs : CoreSpec c) {M' : Mode} {s₀ : State} {k : cs.Key} (hp : SeqPre c M' s₀) diff --git a/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean index 7fc569e26cf..fee1227bffc 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/Arm/CtrFinal.lean @@ -1038,46 +1038,6 @@ the word holding `lr`, and `save`'s 56 bytes, the block included, which it zeroes before returning. The code's calls use 1520 bytes below it, so 1584 in all. -/ -private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} - (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : - bytesAt m₂ p k = bytesAt m₁ p k := by - simp only [bytesAt] - exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) - -private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : - ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by - intro i hi - refine (h _ ?_).symm - by_cases hw : i < 2 ^ 64 - · exact Offset.contains_base _ (by omega) hw - · simp only [Region.Contains] - have := (p + BitVec.ofNat 64 i - p).isLt - omega - -/-- `Proof.Sm4.ctrFinalPost` reads the memory on entry only within the -buffers. -/ -theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Sm4.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Sm4.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₁ m' r → - Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₂ m' r := by - intro vs m₁ m₂ m' r hlen hb h - match vs, hlen with - | [k, ctr, data, len], _ => - simp only [Spec.Sm4.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, - forall_eq, Elem.size, Nat.mul_one] at hb - have hk := agree_of' hb.1 - have hc := agree_of' hb.2.1 - have hd := agree_of' hb.2.2 - change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Sm4.ctrFinalPost pb) _ m₁ m' r at h - change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Sm4.ctrFinalPost pb) _ m₂ m' r - dsimp only [Curry.apply, Proof.Sm4.ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ - have := Nat.mod_le len.toNat (2 ^ pb) - rw [Proof.Sm4.scheduleAt_congr hk, bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), - bytesAt_congr' hc] - exact h - /-- A state satisfying the precondition, without `save`. -/ def ctrFinalFrameSat : State := { ctrFinalSat with rd := [⟨0x1000, 128⟩], wr := [⟨0x2000, 16⟩, ⟨0x3000, 0⟩] } diff --git a/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean index e2af19b5a8e..f874ed3ee01 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/CtrFinal.lean @@ -3,6 +3,7 @@ module public import VerifiedGarbage.Spec.Sm4.CtrFinal public import VerifiedGarbage.Proof.Framework.Scratch import VerifiedGarbage.Proof.Framework.Offset +import VerifiedGarbage.Proof.Sm4.CtrCipher -- separate module: shared by the final function's proofs of every target. @@ -11,9 +12,9 @@ import VerifiedGarbage.Proof.Framework.Offset Not trusted, and the same on every target. `ctrFinalPost`: `Spec.Sm4.ctrFinalContract`'s postcondition (`ctrFinalContract_eq`), which -reads the memory on return only within the function's buffers -(`ctrFinalPostOut_local`), as a frame that keeps working space on the stack -needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by +reads the memory on entry and on return only within the function's buffers +(`ctrFinalPost_local`, `ctrFinalPostOut_local`), as a frame that keeps +working space on the stack needs. What a final function leaves gives `Spec.Ctr.CryptFinal` by `Proof.Modes.CtrFinal.cryptFinal_of`, for any cipher. -/ @@ -68,4 +69,27 @@ theorem ctrFinalPostOut_local (pb : Nat) : ∀ vs m m₁ m₂ r, vs.length = (ct rw [bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] exact h +/-- `ctrFinalPost` reads the memory on entry only within the buffers. -/ +theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (ctrFinalSig.words pb).length → + (∀ b ∈ Sig.bufs ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPost pb) vs m₁ m' r → + Curry.apply (ctrFinalSig.words pb) (ctrFinalPost pb) vs m₂ m' r := by + intro vs m₁ m₂ m' r hlen hb h + match vs, hlen with + | [k, ctr, data, len], _ => + simp only [ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, + forall_eq, Elem.size, Nat.mul_one] at hb + have hk := agree_of' hb.1 + have hc := agree_of' hb.2.1 + have hd := agree_of' hb.2.2 + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPost pb) _ m₁ m' r at h + change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] + (ctrFinalPost pb) _ m₂ m' r + dsimp only [Curry.apply, ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ + have := Nat.mod_le len.toNat (2 ^ pb) + rw [scheduleAt_congr hk, bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), + bytesAt_congr' hc] + exact h + end VG.Proof.Sm4 diff --git a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean index ef35d6acb15..3eddf6893af 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/PPC64LE/CtrFinal.lean @@ -101,7 +101,8 @@ Constant time (`final_rel`): the blocks by the taint analysis, the calls by the callee's constant time (`RelCT.callEx`), whose public arguments agree. The frame of the registration needs the contract's postcondition to read the -memory on entry only within the function's buffers (`ctrFinalPost_local`). +memory on entry only within the function's buffers +(`Proof.Sm4.ctrFinalPost_local`). -/ @[expose] public section @@ -983,50 +984,6 @@ theorem final_ct : ConstantTime isa ctrFinalPPC64LE.pre ctrFinalPPC64LE.pub ctrF theorem ctrFinal_verified : Verified PPC64LE.target ctrFinal ctrFinalScratchContract := Verified.of_correct final_correct final_ct ctrFinal_implies -/-! ## Locality - -The frame needs the contract's postcondition to read the memory on entry -only within the function's buffers. -/ - -private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} - (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : - bytesAt m₂ p k = bytesAt m₁ p k := by - simp only [Spec.Aes.bytesAt] - exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) - -private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : - ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by - intro i hi - refine (h _ ?_).symm - by_cases hw : i < 2 ^ 64 - · exact Offset.contains_base _ (by omega) hw - · simp only [Region.Contains] - have := (p + BitVec.ofNat 64 i - p).isLt - omega - -/-- `ctrFinalPost` reads the memory on entry only within the buffers. -/ -theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Sm4.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Sm4.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₁ m' r → - Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₂ m' r := by - intro vs m₁ m₂ m' r hlen hb h - match vs, hlen with - | [k, ctr, data, len], _ => - simp only [Spec.Sm4.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, - forall_eq, Elem.size, Nat.mul_one] at hb - have hs := agree_of' hb.1 - have hc := agree_of' hb.2.1 - have hd := agree_of' hb.2.2 - change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Sm4.ctrFinalPost pb) _ m₁ m' r at h - change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Sm4.ctrFinalPost pb) _ m₂ m' r - dsimp only [Curry.apply, Proof.Sm4.ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ - have := Nat.mod_le len.toNat (2 ^ pb) - rw [Proof.Sm4.scheduleAt_congr hs, - bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega), bytesAt_congr' hc] - exact h - /-! ## With `save` on the stack The final function has four argument words, so `save` is its fifth, in `r7`: diff --git a/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean index 1569df2031d..fbb3bdc97d1 100644 --- a/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Sm4/X86/CtrFinal.lean @@ -1333,45 +1333,6 @@ address, and `save`'s 32 bytes (the registers, then the block that held the last output block), which it zeroes before returning. The code's calls use 1536 bytes below it, so 1592 in all. -/ -private theorem bytesAt_congr' {m₁ m₂ : Mem} {p : Addr} {k : Nat} - (h : ∀ i < k, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i)) : - Spec.Aes.bytesAt m₂ p k = Spec.Aes.bytesAt m₁ p k := by - simp only [Spec.Aes.bytesAt] - exact List.map_congr_left fun i hi => h i (List.mem_range.mp hi) - -private theorem agree_of' {m₁ m₂ : Mem} {p : Addr} {n : Nat} (h : ∀ a, Region.Contains ⟨p, n⟩ a 1 → m₁ a = m₂ a) : - ∀ i < n, m₂ (p + BitVec.ofNat 64 i) = m₁ (p + BitVec.ofNat 64 i) := by - intro i hi - refine (h _ ?_).symm - by_cases hw : i < 2 ^ 64 - · exact Offset.contains_base _ (by omega) hw - · simp only [Region.Contains] - have := (p + BitVec.ofNat 64 i - p).isLt - omega - -/-- `ctrFinalPost` reads the memory on entry only within the buffers. -/ -theorem ctrFinalPost_local (pb : Nat) : ∀ vs m₁ m₂ m' r, vs.length = (Spec.Sm4.ctrFinalSig.words pb).length → - (∀ b ∈ Sig.bufs Spec.Sm4.ctrFinalSig.params vs, ∀ a, b.1.Contains a 1 → m₁ a = m₂ a) → - Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₁ m' r → - Curry.apply (Spec.Sm4.ctrFinalSig.words pb) (Proof.Sm4.ctrFinalPost pb) vs m₂ m' r := by - intro vs m₁ m₂ m' r hlen hb h - match vs, hlen with - | [k, ctr, data, len], _ => - simp only [Spec.Sm4.ctrFinalSig, Sig.bufs, List.mem_cons, List.not_mem_nil, or_false, forall_eq_or_imp, - forall_eq, Elem.size, Nat.mul_one] at hb - have hs := agree_of' hb.1 - have hc := agree_of' hb.2.1 - have hd := agree_of' hb.2.2 - change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Sm4.ctrFinalPost pb) _ m₁ m' r at h - change Curry.apply [ArgWord.addr, ArgWord.addr, ArgWord.addr, ArgWord.int pb] - (Proof.Sm4.ctrFinalPost pb) _ m₂ m' r - dsimp only [Curry.apply, Proof.Sm4.ctrFinalPost, ArgWord.ofRaw, Spec.Ctr.CryptFinal] at h ⊢ - have := Nat.mod_le len.toNat (2 ^ pb) - rw [Proof.Sm4.scheduleAt_congr hs, bytesAt_congr' hc, - bytesAt_congr' fun i hi => hd i (by rw [BitVec.toNat_setWidth] at hi; omega)] - exact h - theorem frameSat_pre : ∃ s, (Spec.Sm4.ctrFinalContract X86.abi 1592).pre s := by implies_sat [Spec.Sm4.ctrFinalContract, Spec.Sm4.ctrFinalSig, X86.abi, X86.argSlots, X86.argVal, X86.argBytes] [Fb.frameSat, X86.arg, X86.argAddr, Mem.readW, Mem.read] using Fb.frameSat From ddcf267cf5025c7fc1201a28a462e761112869bc Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 13:19:17 +0000 Subject: [PATCH 17/18] Regenerate the crates: OFB and CTR final functions on every target Also renames the x86-64 Camellia CTR proof's cipher_length to ctr_cipher_length, which clashed with the OFB/CFB final proof's in the same namespace once the emitter imported both. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../assembly/aes_ctr.s | 130 + .../assembly/aes_ofb.s | 120 + .../assembly/blowfish_ofb.s | 964 ++ .../assembly/camellia_ctr.s | 63 + .../assembly/camellia_ofb.s | 302 + .../assembly/cast5_ofb.s | 415 + .../assembly/idea_ofb.s | 830 ++ .../assembly/seed_ofb.s | 214 + .../assembly/sm4_ctr.s | 61 + .../assembly/sm4_ofb.s | 1164 ++ .../assembly/triple_des_ofb.s | 231 + .../src/aes_ctr.rs | 84 + .../src/aes_ofb.rs | 82 + .../src/blowfish_ofb.rs | 153 + .../src/camellia_ctr.rs | 37 + .../src/camellia_ofb.rs | 75 + .../src/cast5_ofb.rs | 110 + .../src/idea_ofb.rs | 134 + .../src/seed_ofb.rs | 60 + .../src/sm4_ctr.rs | 36 + .../src/sm4_ofb.rs | 179 + .../src/triple_des_ofb.rs | 62 + .../assembly/aes_ctr.s | 95 + .../assembly/aes_ofb.s | 83 + .../assembly/blowfish_ofb.s | 95 + .../assembly/camellia_ctr.s | 90 + .../assembly/camellia_ofb.s | 119 + .../assembly/cast5_ofb.s | 166 + .../assembly/idea_ofb.s | 95 + .../assembly/seed_ofb.s | 115 + .../assembly/sm4_ctr.s | 81 + .../assembly/sm4_ofb.s | 115 + .../assembly/triple_des_ofb.s | 95 + .../verified-garbage-asm-arm/src/aes_ctr.rs | 114 + .../verified-garbage-asm-arm/src/aes_ofb.rs | 103 + .../src/blowfish_ofb.rs | 111 + .../src/camellia_ctr.rs | 107 + .../src/camellia_ofb.rs | 136 + .../verified-garbage-asm-arm/src/cast5_ofb.rs | 183 + .../verified-garbage-asm-arm/src/idea_ofb.rs | 111 + .../verified-garbage-asm-arm/src/seed_ofb.rs | 131 + .../verified-garbage-asm-arm/src/sm4_ctr.rs | 97 + .../verified-garbage-asm-arm/src/sm4_ofb.rs | 131 + .../src/triple_des_ofb.rs | 111 + .../assembly/aes_ctr.s | 73 + .../assembly/aes_ofb.s | 67 + .../assembly/blowfish_ofb.s | 374 + .../assembly/camellia_ctr.s | 71 + .../assembly/camellia_ofb.s | 1926 ++++ .../assembly/cast5_ofb.s | 557 + .../assembly/idea_ofb.s | 858 ++ .../assembly/seed_ofb.s | 258 + .../assembly/sm4_ctr.s | 69 + .../assembly/sm4_ofb.s | 526 + .../assembly/triple_des_ofb.s | 154 + .../src/aes_ctr.rs | 35 + .../src/aes_ofb.rs | 36 + .../src/blowfish_ofb.rs | 56 + .../src/camellia_ctr.rs | 33 + .../src/camellia_ofb.rs | 68 + .../src/cast5_ofb.rs | 157 + .../src/idea_ofb.rs | 36 + .../src/seed_ofb.rs | 39 + .../src/sm4_ctr.rs | 32 + .../src/sm4_ofb.rs | 42 + .../src/triple_des_ofb.rs | 39 + .../assembly/aes_ctr.s | 72 + .../assembly/aes_ofb.s | 66 + .../assembly/blowfish_ofb.s | 4066 +++++++ .../assembly/camellia_ctr.s | 70 + .../assembly/camellia_ofb.s | 9895 ++++++++++++++++ .../assembly/cast5_ofb.s | 1889 ++++ .../assembly/idea_ofb.s | 2041 ++++ .../assembly/seed_ofb.s | 5383 +++++++++ .../assembly/sm4_ctr.s | 68 + .../assembly/sm4_ofb.s | 9036 +++++++++++++++ .../assembly/triple_des_ofb.s | 2725 +++++ .../src/aes_ctr.rs | 91 + .../src/aes_ofb.rs | 86 + .../src/blowfish_ofb.rs | 4081 +++++++ .../src/camellia_ctr.rs | 87 + .../src/camellia_ofb.rs | 9911 +++++++++++++++++ .../src/cast5_ofb.rs | 1906 ++++ .../src/idea_ofb.rs | 2056 ++++ .../src/seed_ofb.rs | 5398 +++++++++ .../src/sm4_ctr.rs | 84 + .../src/sm4_ofb.rs | 9051 +++++++++++++++ .../src/triple_des_ofb.rs | 2740 +++++ .../assembly/aes_ctr.s | 220 + .../assembly/aes_ofb.s | 190 + .../assembly/blowfish_ofb.s | 438 + .../assembly/camellia_ctr.s | 102 + .../assembly/camellia_ofb.s | 1257 +++ .../assembly/cast5_ofb.s | 769 ++ .../assembly/idea_ofb.s | 1005 ++ .../assembly/seed_ofb.s | 423 + .../assembly/sm4_ctr.s | 94 + .../assembly/sm4_ofb.s | 510 + .../assembly/triple_des_ofb.s | 538 + .../verified-garbage-asm-x86/src/aes_ctr.rs | 76 + .../verified-garbage-asm-x86/src/aes_ofb.rs | 78 + .../src/blowfish_ofb.rs | 59 + .../src/camellia_ctr.rs | 36 + .../src/camellia_ofb.rs | 56 + .../verified-garbage-asm-x86/src/cast5_ofb.rs | 91 + .../verified-garbage-asm-x86/src/idea_ofb.rs | 39 + .../verified-garbage-asm-x86/src/seed_ofb.rs | 42 + .../verified-garbage-asm-x86/src/sm4_ctr.rs | 35 + .../verified-garbage-asm-x86/src/sm4_ofb.rs | 45 + .../src/triple_des_ofb.rs | 42 + .../assembly/aes_ctr.s | 213 + .../assembly/aes_ofb.s | 186 + .../assembly/blowfish_ofb.s | 525 + .../assembly/camellia_ctr.s | 69 + .../assembly/camellia_ofb.s | 965 ++ .../assembly/cast5_ofb.s | 604 + .../assembly/idea_ofb.s | 969 ++ .../assembly/seed_ofb.s | 303 + .../assembly/sm4_ctr.s | 67 + .../assembly/sm4_ofb.s | 930 ++ .../assembly/triple_des_ofb.s | 283 + .../src/aes_ctr.rs | 116 + .../src/aes_ofb.rs | 119 + .../src/blowfish_ofb.rs | 56 + .../src/camellia_ctr.rs | 34 + .../src/camellia_ofb.rs | 55 + .../src/cast5_ofb.rs | 72 + .../src/idea_ofb.rs | 36 + .../src/seed_ofb.rs | 39 + .../src/sm4_ctr.rs | 33 + .../src/sm4_ofb.rs | 43 + .../src/triple_des_ofb.rs | 39 + .../Proof/Camellia/X86_64/CtrFinal.lean | 6 +- 133 files changed, 96202 insertions(+), 3 deletions(-) diff --git a/crates/verified-garbage-asm-aarch64/assembly/aes_ctr.s b/crates/verified-garbage-asm-aarch64/assembly/aes_ctr.s index 91554f51aeb..08497bca3af 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/aes_ctr.s +++ b/crates/verified-garbage-asm-aarch64/assembly/aes_ctr.s @@ -69,6 +69,71 @@ vg_aes_ctr_aes: ret .p2align 6 +vg_aes_ctr_final_aes: + sub sp, sp, #80 + add x6, sp, #0 + str x19, [x6, #0] + str x20, [x6, #8] + str x21, [x6, #16] + str x22, [x6, #24] + str x23, [x6, #32] + str x24, [x6, #40] + str x30, [x6, #48] + str x25, [x6, #56] + add x19, x0, #0 + add x20, x1, #0 + add x21, x2, #0 + add x24, x5, #0 + add x25, x6, #0 + lsr x9, x4, #4 + lsl x10, x9, #4 + add x22, x3, x10 + sub x23, x4, x10 + add x4, x9, #0 + bl {vg_aes_ctr_aes} + cbz x23, 20f + movz x9, #0, lsl #0 + str x9, [x25, #64] + str x9, [x25, #72] + add x0, x19, #0 + add x1, x20, #0 + add x2, x21, #0 + add x3, x25, #64 + movz x4, #1, lsl #0 + add x5, x24, #0 + bl {vg_aes_ctr_aes} + add x9, x25, #64 +22: + ldrb w6, [x9, #0] + ldrb w7, [x22, #0] + eor x7, x7, x6 + strb w7, [x22, #0] + add x9, x9, #1 + add x22, x22, #1 + sub x23, x23, #1 + cbnz x23, 22b + b 21f +20: +21: + ldr x19, [x25, #0] + ldr x20, [x25, #8] + ldr x21, [x25, #16] + ldr x22, [x25, #24] + ldr x23, [x25, #32] + ldr x24, [x25, #40] + ldr x30, [x25, #48] + ldr x25, [x25, #56] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + add sp, sp, #80 + ret + .p2align 6 + vg_aes_ctr: str x19, [x5, #2064] str x20, [x5, #2072] @@ -133,3 +198,68 @@ vg_aes_ctr: ldr x24, [x24, #2112] ret .p2align 6 + +vg_aes_ctr_final: + sub sp, sp, #80 + add x6, sp, #0 + str x19, [x6, #0] + str x20, [x6, #8] + str x21, [x6, #16] + str x22, [x6, #24] + str x23, [x6, #32] + str x24, [x6, #40] + str x30, [x6, #48] + str x25, [x6, #56] + add x19, x0, #0 + add x20, x1, #0 + add x21, x2, #0 + add x24, x5, #0 + add x25, x6, #0 + lsr x9, x4, #4 + lsl x10, x9, #4 + add x22, x3, x10 + sub x23, x4, x10 + add x4, x9, #0 + bl {vg_aes_ctr} + cbz x23, 20f + movz x9, #0, lsl #0 + str x9, [x25, #64] + str x9, [x25, #72] + add x0, x19, #0 + add x1, x20, #0 + add x2, x21, #0 + add x3, x25, #64 + movz x4, #1, lsl #0 + add x5, x24, #0 + bl {vg_aes_ctr} + add x9, x25, #64 +22: + ldrb w6, [x9, #0] + ldrb w7, [x22, #0] + eor x7, x7, x6 + strb w7, [x22, #0] + add x9, x9, #1 + add x22, x22, #1 + sub x23, x23, #1 + cbnz x23, 22b + b 21f +20: +21: + ldr x19, [x25, #0] + ldr x20, [x25, #8] + ldr x21, [x25, #16] + ldr x22, [x25, #24] + ldr x23, [x25, #32] + ldr x24, [x25, #40] + ldr x30, [x25, #48] + ldr x25, [x25, #56] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + add sp, sp, #80 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/aes_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/aes_ofb.s index 47e483fd733..3d795b8b55e 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/aes_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/aes_ofb.s @@ -50,6 +50,66 @@ vg_aes_ofb_aes: ret .p2align 6 +vg_aes_ofb_final_aes: + sub sp, sp, #64 + add x6, sp, #0 + str x19, [x6, #0] + str x20, [x6, #8] + str x21, [x6, #16] + str x22, [x6, #24] + str x23, [x6, #32] + str x24, [x6, #40] + str x30, [x6, #48] + str x25, [x6, #56] + add x19, x0, #0 + add x20, x1, #0 + add x21, x2, #0 + add x24, x5, #0 + add x25, x6, #0 + lsr x9, x4, #4 + lsl x10, x9, #4 + add x22, x3, x10 + sub x23, x4, x10 + add x4, x9, #0 + bl {vg_aes_ofb_aes} + cbz x23, 20f + add x0, x19, #0 + add x1, x20, #0 + add x2, x21, #0 + movz x3, #1, lsl #0 + add x4, x24, #0 + bl {vg_aes_encrypt_blocks_aes} + add x9, x21, #0 +22: + ldrb w6, [x9, #0] + ldrb w7, [x22, #0] + eor x7, x7, x6 + strb w7, [x22, #0] + add x9, x9, #1 + add x22, x22, #1 + sub x23, x23, #1 + cbnz x23, 22b + b 21f +20: +21: + ldr x19, [x25, #0] + ldr x20, [x25, #8] + ldr x21, [x25, #16] + ldr x22, [x25, #24] + ldr x23, [x25, #32] + ldr x24, [x25, #40] + ldr x30, [x25, #48] + ldr x25, [x25, #56] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + add sp, sp, #64 + ret + .p2align 6 + vg_aes_ofb: str x19, [x5, #2064] str x20, [x5, #2072] @@ -95,3 +155,63 @@ vg_aes_ofb: ldr x24, [x24, #2112] ret .p2align 6 + +vg_aes_ofb_final: + sub sp, sp, #64 + add x6, sp, #0 + str x19, [x6, #0] + str x20, [x6, #8] + str x21, [x6, #16] + str x22, [x6, #24] + str x23, [x6, #32] + str x24, [x6, #40] + str x30, [x6, #48] + str x25, [x6, #56] + add x19, x0, #0 + add x20, x1, #0 + add x21, x2, #0 + add x24, x5, #0 + add x25, x6, #0 + lsr x9, x4, #4 + lsl x10, x9, #4 + add x22, x3, x10 + sub x23, x4, x10 + add x4, x9, #0 + bl {vg_aes_ofb} + cbz x23, 20f + add x0, x19, #0 + add x1, x20, #0 + add x2, x21, #0 + movz x3, #1, lsl #0 + add x4, x24, #0 + bl {vg_aes_encrypt_blocks} + add x9, x21, #0 +22: + ldrb w6, [x9, #0] + ldrb w7, [x22, #0] + eor x7, x7, x6 + strb w7, [x22, #0] + add x9, x9, #1 + add x22, x22, #1 + sub x23, x23, #1 + cbnz x23, 22b + b 21f +20: +21: + ldr x19, [x25, #0] + ldr x20, [x25, #8] + ldr x21, [x25, #16] + ldr x22, [x25, #24] + ldr x23, [x25, #32] + ldr x24, [x25, #40] + ldr x30, [x25, #48] + ldr x25, [x25, #56] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + add sp, sp, #64 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/blowfish_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/blowfish_ofb.s index 83faebfebaa..58841f25677 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/blowfish_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/blowfish_ofb.s @@ -952,3 +952,967 @@ vg_blowfish_ofb: add sp, sp, #224 ret .p2align 6 + +vg_blowfish_ofb_final: + sub sp, sp, #224 + add x4, sp, #0 + add x5, x4, #0 + str x19, [x5, #128] + str x20, [x5, #136] + str x21, [x5, #144] + str x22, [x5, #152] + str x23, [x5, #160] + str x24, [x5, #168] + str x25, [x5, #176] + str x26, [x5, #184] + str x27, [x5, #192] + str x28, [x5, #200] + add x25, x1, #0 + add x23, x2, #0 + add x24, x3, #0 + ldr x6, [x25, #0] + str x6, [x5, #0] + cbz x24, 20f +22: + umov x8, v8.d[0] + umov x9, v9.d[0] + umov x10, v10.d[0] + umov x11, v11.d[0] + umov x12, v12.d[0] + umov x13, v13.d[0] + umov x14, v14.d[0] + umov x15, v15.d[0] + add x16, x5, #0 + add x4, x5, #0 + movz x6, #64, lsl #0 + dup v2.16b, w6 + movz x6, #128, lsl #0 + dup v3.16b, w6 + ldr q20, [x4, #0] + ldr q21, [x4, #16] + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + uzp1 v4.4s, v20.4s, v21.4s + uzp2 v8.4s, v20.4s, v21.4s + ldr q20, [x4, #32] + ldr q21, [x4, #48] + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + uzp1 v5.4s, v20.4s, v21.4s + uzp2 v9.4s, v20.4s, v21.4s + ldr q20, [x4, #64] + ldr q21, [x4, #80] + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + uzp1 v6.4s, v20.4s, v21.4s + uzp2 v10.4s, v20.4s, v21.4s + ldr q20, [x4, #96] + ldr q21, [x4, #112] + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + uzp1 v7.4s, v20.4s, v21.4s + uzp2 v11.4s, v20.4s, v21.4s + add x5, x0, #0 + movz x7, #8, lsl #0 +23: + ldr w6, [x5, #4096] + dup v0.4s, w6 + eor v4.16b, v4.16b, v0.16b + eor v5.16b, v5.16b, v0.16b + eor v6.16b, v6.16b, v0.16b + eor v7.16b, v7.16b, v0.16b + uzp1 v0.16b, v4.16b, v5.16b + uzp2 v1.16b, v4.16b, v5.16b + uzp1 v20.16b, v6.16b, v7.16b + uzp2 v21.16b, v6.16b, v7.16b + uzp1 v19.16b, v0.16b, v20.16b + uzp2 v17.16b, v0.16b, v20.16b + uzp1 v18.16b, v1.16b, v21.16b + uzp2 v16.16b, v1.16b, v21.16b + eor v24.16b, v16.16b, v2.16b + eor v25.16b, v16.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #0] + ldr q29, [x0, #16] + ldr q30, [x0, #32] + ldr q31, [x0, #48] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #64] + ldr q29, [x0, #80] + ldr q30, [x0, #96] + ldr q31, [x0, #112] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #128] + ldr q29, [x0, #144] + ldr q30, [x0, #160] + ldr q31, [x0, #176] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #192] + ldr q29, [x0, #208] + ldr q30, [x0, #224] + ldr q31, [x0, #240] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #256] + ldr q29, [x0, #272] + ldr q30, [x0, #288] + ldr q31, [x0, #304] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #320] + ldr q29, [x0, #336] + ldr q30, [x0, #352] + ldr q31, [x0, #368] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #384] + ldr q29, [x0, #400] + ldr q30, [x0, #416] + ldr q31, [x0, #432] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #448] + ldr q29, [x0, #464] + ldr q30, [x0, #480] + ldr q31, [x0, #496] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #512] + ldr q29, [x0, #528] + ldr q30, [x0, #544] + ldr q31, [x0, #560] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #576] + ldr q29, [x0, #592] + ldr q30, [x0, #608] + ldr q31, [x0, #624] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #640] + ldr q29, [x0, #656] + ldr q30, [x0, #672] + ldr q31, [x0, #688] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #704] + ldr q29, [x0, #720] + ldr q30, [x0, #736] + ldr q31, [x0, #752] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #768] + ldr q29, [x0, #784] + ldr q30, [x0, #800] + ldr q31, [x0, #816] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #832] + ldr q29, [x0, #848] + ldr q30, [x0, #864] + ldr q31, [x0, #880] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #896] + ldr q29, [x0, #912] + ldr q30, [x0, #928] + ldr q31, [x0, #944] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #960] + ldr q29, [x0, #976] + ldr q30, [x0, #992] + ldr q31, [x0, #1008] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + mov v12.16b, v21.16b + mov v13.16b, v23.16b + mov v14.16b, v0.16b + mov v15.16b, v1.16b + eor v24.16b, v17.16b, v2.16b + eor v25.16b, v17.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #1024] + ldr q29, [x0, #1040] + ldr q30, [x0, #1056] + ldr q31, [x0, #1072] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1088] + ldr q29, [x0, #1104] + ldr q30, [x0, #1120] + ldr q31, [x0, #1136] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1152] + ldr q29, [x0, #1168] + ldr q30, [x0, #1184] + ldr q31, [x0, #1200] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1216] + ldr q29, [x0, #1232] + ldr q30, [x0, #1248] + ldr q31, [x0, #1264] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #1280] + ldr q29, [x0, #1296] + ldr q30, [x0, #1312] + ldr q31, [x0, #1328] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1344] + ldr q29, [x0, #1360] + ldr q30, [x0, #1376] + ldr q31, [x0, #1392] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1408] + ldr q29, [x0, #1424] + ldr q30, [x0, #1440] + ldr q31, [x0, #1456] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1472] + ldr q29, [x0, #1488] + ldr q30, [x0, #1504] + ldr q31, [x0, #1520] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #1536] + ldr q29, [x0, #1552] + ldr q30, [x0, #1568] + ldr q31, [x0, #1584] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1600] + ldr q29, [x0, #1616] + ldr q30, [x0, #1632] + ldr q31, [x0, #1648] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1664] + ldr q29, [x0, #1680] + ldr q30, [x0, #1696] + ldr q31, [x0, #1712] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1728] + ldr q29, [x0, #1744] + ldr q30, [x0, #1760] + ldr q31, [x0, #1776] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #1792] + ldr q29, [x0, #1808] + ldr q30, [x0, #1824] + ldr q31, [x0, #1840] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1856] + ldr q29, [x0, #1872] + ldr q30, [x0, #1888] + ldr q31, [x0, #1904] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1920] + ldr q29, [x0, #1936] + ldr q30, [x0, #1952] + ldr q31, [x0, #1968] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1984] + ldr q29, [x0, #2000] + ldr q30, [x0, #2016] + ldr q31, [x0, #2032] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + add v12.4s, v12.4s, v21.4s + add v13.4s, v13.4s, v23.4s + add v14.4s, v14.4s, v0.4s + add v15.4s, v15.4s, v1.4s + eor v24.16b, v18.16b, v2.16b + eor v25.16b, v18.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #2048] + ldr q29, [x0, #2064] + ldr q30, [x0, #2080] + ldr q31, [x0, #2096] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2112] + ldr q29, [x0, #2128] + ldr q30, [x0, #2144] + ldr q31, [x0, #2160] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2176] + ldr q29, [x0, #2192] + ldr q30, [x0, #2208] + ldr q31, [x0, #2224] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #2240] + ldr q29, [x0, #2256] + ldr q30, [x0, #2272] + ldr q31, [x0, #2288] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #2304] + ldr q29, [x0, #2320] + ldr q30, [x0, #2336] + ldr q31, [x0, #2352] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2368] + ldr q29, [x0, #2384] + ldr q30, [x0, #2400] + ldr q31, [x0, #2416] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2432] + ldr q29, [x0, #2448] + ldr q30, [x0, #2464] + ldr q31, [x0, #2480] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #2496] + ldr q29, [x0, #2512] + ldr q30, [x0, #2528] + ldr q31, [x0, #2544] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #2560] + ldr q29, [x0, #2576] + ldr q30, [x0, #2592] + ldr q31, [x0, #2608] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2624] + ldr q29, [x0, #2640] + ldr q30, [x0, #2656] + ldr q31, [x0, #2672] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2688] + ldr q29, [x0, #2704] + ldr q30, [x0, #2720] + ldr q31, [x0, #2736] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #2752] + ldr q29, [x0, #2768] + ldr q30, [x0, #2784] + ldr q31, [x0, #2800] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #2816] + ldr q29, [x0, #2832] + ldr q30, [x0, #2848] + ldr q31, [x0, #2864] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2880] + ldr q29, [x0, #2896] + ldr q30, [x0, #2912] + ldr q31, [x0, #2928] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2944] + ldr q29, [x0, #2960] + ldr q30, [x0, #2976] + ldr q31, [x0, #2992] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3008] + ldr q29, [x0, #3024] + ldr q30, [x0, #3040] + ldr q31, [x0, #3056] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + eor v12.16b, v12.16b, v21.16b + eor v13.16b, v13.16b, v23.16b + eor v14.16b, v14.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v24.16b, v19.16b, v2.16b + eor v25.16b, v19.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #3072] + ldr q29, [x0, #3088] + ldr q30, [x0, #3104] + ldr q31, [x0, #3120] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3136] + ldr q29, [x0, #3152] + ldr q30, [x0, #3168] + ldr q31, [x0, #3184] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3200] + ldr q29, [x0, #3216] + ldr q30, [x0, #3232] + ldr q31, [x0, #3248] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3264] + ldr q29, [x0, #3280] + ldr q30, [x0, #3296] + ldr q31, [x0, #3312] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #3328] + ldr q29, [x0, #3344] + ldr q30, [x0, #3360] + ldr q31, [x0, #3376] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3392] + ldr q29, [x0, #3408] + ldr q30, [x0, #3424] + ldr q31, [x0, #3440] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3456] + ldr q29, [x0, #3472] + ldr q30, [x0, #3488] + ldr q31, [x0, #3504] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3520] + ldr q29, [x0, #3536] + ldr q30, [x0, #3552] + ldr q31, [x0, #3568] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #3584] + ldr q29, [x0, #3600] + ldr q30, [x0, #3616] + ldr q31, [x0, #3632] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3648] + ldr q29, [x0, #3664] + ldr q30, [x0, #3680] + ldr q31, [x0, #3696] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3712] + ldr q29, [x0, #3728] + ldr q30, [x0, #3744] + ldr q31, [x0, #3760] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3776] + ldr q29, [x0, #3792] + ldr q30, [x0, #3808] + ldr q31, [x0, #3824] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #3840] + ldr q29, [x0, #3856] + ldr q30, [x0, #3872] + ldr q31, [x0, #3888] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3904] + ldr q29, [x0, #3920] + ldr q30, [x0, #3936] + ldr q31, [x0, #3952] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3968] + ldr q29, [x0, #3984] + ldr q30, [x0, #4000] + ldr q31, [x0, #4016] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #4032] + ldr q29, [x0, #4048] + ldr q30, [x0, #4064] + ldr q31, [x0, #4080] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + add v12.4s, v12.4s, v21.4s + add v13.4s, v13.4s, v23.4s + add v14.4s, v14.4s, v0.4s + add v15.4s, v15.4s, v1.4s + eor v8.16b, v8.16b, v12.16b + eor v9.16b, v9.16b, v13.16b + eor v10.16b, v10.16b, v14.16b + eor v11.16b, v11.16b, v15.16b + add x5, x5, #4 + ldr w6, [x5, #4096] + dup v0.4s, w6 + eor v8.16b, v8.16b, v0.16b + eor v9.16b, v9.16b, v0.16b + eor v10.16b, v10.16b, v0.16b + eor v11.16b, v11.16b, v0.16b + uzp1 v0.16b, v8.16b, v9.16b + uzp2 v1.16b, v8.16b, v9.16b + uzp1 v20.16b, v10.16b, v11.16b + uzp2 v21.16b, v10.16b, v11.16b + uzp1 v19.16b, v0.16b, v20.16b + uzp2 v17.16b, v0.16b, v20.16b + uzp1 v18.16b, v1.16b, v21.16b + uzp2 v16.16b, v1.16b, v21.16b + eor v24.16b, v16.16b, v2.16b + eor v25.16b, v16.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #0] + ldr q29, [x0, #16] + ldr q30, [x0, #32] + ldr q31, [x0, #48] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #64] + ldr q29, [x0, #80] + ldr q30, [x0, #96] + ldr q31, [x0, #112] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #128] + ldr q29, [x0, #144] + ldr q30, [x0, #160] + ldr q31, [x0, #176] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #192] + ldr q29, [x0, #208] + ldr q30, [x0, #224] + ldr q31, [x0, #240] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #256] + ldr q29, [x0, #272] + ldr q30, [x0, #288] + ldr q31, [x0, #304] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #320] + ldr q29, [x0, #336] + ldr q30, [x0, #352] + ldr q31, [x0, #368] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #384] + ldr q29, [x0, #400] + ldr q30, [x0, #416] + ldr q31, [x0, #432] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #448] + ldr q29, [x0, #464] + ldr q30, [x0, #480] + ldr q31, [x0, #496] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #512] + ldr q29, [x0, #528] + ldr q30, [x0, #544] + ldr q31, [x0, #560] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #576] + ldr q29, [x0, #592] + ldr q30, [x0, #608] + ldr q31, [x0, #624] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #640] + ldr q29, [x0, #656] + ldr q30, [x0, #672] + ldr q31, [x0, #688] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #704] + ldr q29, [x0, #720] + ldr q30, [x0, #736] + ldr q31, [x0, #752] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #768] + ldr q29, [x0, #784] + ldr q30, [x0, #800] + ldr q31, [x0, #816] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v16.16b + ldr q28, [x0, #832] + ldr q29, [x0, #848] + ldr q30, [x0, #864] + ldr q31, [x0, #880] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #896] + ldr q29, [x0, #912] + ldr q30, [x0, #928] + ldr q31, [x0, #944] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #960] + ldr q29, [x0, #976] + ldr q30, [x0, #992] + ldr q31, [x0, #1008] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + mov v12.16b, v21.16b + mov v13.16b, v23.16b + mov v14.16b, v0.16b + mov v15.16b, v1.16b + eor v24.16b, v17.16b, v2.16b + eor v25.16b, v17.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #1024] + ldr q29, [x0, #1040] + ldr q30, [x0, #1056] + ldr q31, [x0, #1072] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1088] + ldr q29, [x0, #1104] + ldr q30, [x0, #1120] + ldr q31, [x0, #1136] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1152] + ldr q29, [x0, #1168] + ldr q30, [x0, #1184] + ldr q31, [x0, #1200] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1216] + ldr q29, [x0, #1232] + ldr q30, [x0, #1248] + ldr q31, [x0, #1264] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #1280] + ldr q29, [x0, #1296] + ldr q30, [x0, #1312] + ldr q31, [x0, #1328] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1344] + ldr q29, [x0, #1360] + ldr q30, [x0, #1376] + ldr q31, [x0, #1392] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1408] + ldr q29, [x0, #1424] + ldr q30, [x0, #1440] + ldr q31, [x0, #1456] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1472] + ldr q29, [x0, #1488] + ldr q30, [x0, #1504] + ldr q31, [x0, #1520] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #1536] + ldr q29, [x0, #1552] + ldr q30, [x0, #1568] + ldr q31, [x0, #1584] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1600] + ldr q29, [x0, #1616] + ldr q30, [x0, #1632] + ldr q31, [x0, #1648] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1664] + ldr q29, [x0, #1680] + ldr q30, [x0, #1696] + ldr q31, [x0, #1712] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1728] + ldr q29, [x0, #1744] + ldr q30, [x0, #1760] + ldr q31, [x0, #1776] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #1792] + ldr q29, [x0, #1808] + ldr q30, [x0, #1824] + ldr q31, [x0, #1840] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v17.16b + ldr q28, [x0, #1856] + ldr q29, [x0, #1872] + ldr q30, [x0, #1888] + ldr q31, [x0, #1904] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #1920] + ldr q29, [x0, #1936] + ldr q30, [x0, #1952] + ldr q31, [x0, #1968] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #1984] + ldr q29, [x0, #2000] + ldr q30, [x0, #2016] + ldr q31, [x0, #2032] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + add v12.4s, v12.4s, v21.4s + add v13.4s, v13.4s, v23.4s + add v14.4s, v14.4s, v0.4s + add v15.4s, v15.4s, v1.4s + eor v24.16b, v18.16b, v2.16b + eor v25.16b, v18.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #2048] + ldr q29, [x0, #2064] + ldr q30, [x0, #2080] + ldr q31, [x0, #2096] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2112] + ldr q29, [x0, #2128] + ldr q30, [x0, #2144] + ldr q31, [x0, #2160] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2176] + ldr q29, [x0, #2192] + ldr q30, [x0, #2208] + ldr q31, [x0, #2224] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #2240] + ldr q29, [x0, #2256] + ldr q30, [x0, #2272] + ldr q31, [x0, #2288] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #2304] + ldr q29, [x0, #2320] + ldr q30, [x0, #2336] + ldr q31, [x0, #2352] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2368] + ldr q29, [x0, #2384] + ldr q30, [x0, #2400] + ldr q31, [x0, #2416] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2432] + ldr q29, [x0, #2448] + ldr q30, [x0, #2464] + ldr q31, [x0, #2480] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #2496] + ldr q29, [x0, #2512] + ldr q30, [x0, #2528] + ldr q31, [x0, #2544] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #2560] + ldr q29, [x0, #2576] + ldr q30, [x0, #2592] + ldr q31, [x0, #2608] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2624] + ldr q29, [x0, #2640] + ldr q30, [x0, #2656] + ldr q31, [x0, #2672] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2688] + ldr q29, [x0, #2704] + ldr q30, [x0, #2720] + ldr q31, [x0, #2736] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #2752] + ldr q29, [x0, #2768] + ldr q30, [x0, #2784] + ldr q31, [x0, #2800] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #2816] + ldr q29, [x0, #2832] + ldr q30, [x0, #2848] + ldr q31, [x0, #2864] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v18.16b + ldr q28, [x0, #2880] + ldr q29, [x0, #2896] + ldr q30, [x0, #2912] + ldr q31, [x0, #2928] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #2944] + ldr q29, [x0, #2960] + ldr q30, [x0, #2976] + ldr q31, [x0, #2992] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3008] + ldr q29, [x0, #3024] + ldr q30, [x0, #3040] + ldr q31, [x0, #3056] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + eor v12.16b, v12.16b, v21.16b + eor v13.16b, v13.16b, v23.16b + eor v14.16b, v14.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v24.16b, v19.16b, v2.16b + eor v25.16b, v19.16b, v3.16b + eor v26.16b, v24.16b, v3.16b + ldr q28, [x0, #3072] + ldr q29, [x0, #3088] + ldr q30, [x0, #3104] + ldr q31, [x0, #3120] + tbl v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3136] + ldr q29, [x0, #3152] + ldr q30, [x0, #3168] + ldr q31, [x0, #3184] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3200] + ldr q29, [x0, #3216] + ldr q30, [x0, #3232] + ldr q31, [x0, #3248] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3264] + ldr q29, [x0, #3280] + ldr q30, [x0, #3296] + ldr q31, [x0, #3312] + tbx v20.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #3328] + ldr q29, [x0, #3344] + ldr q30, [x0, #3360] + ldr q31, [x0, #3376] + tbl v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3392] + ldr q29, [x0, #3408] + ldr q30, [x0, #3424] + ldr q31, [x0, #3440] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3456] + ldr q29, [x0, #3472] + ldr q30, [x0, #3488] + ldr q31, [x0, #3504] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3520] + ldr q29, [x0, #3536] + ldr q30, [x0, #3552] + ldr q31, [x0, #3568] + tbx v21.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #3584] + ldr q29, [x0, #3600] + ldr q30, [x0, #3616] + ldr q31, [x0, #3632] + tbl v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3648] + ldr q29, [x0, #3664] + ldr q30, [x0, #3680] + ldr q31, [x0, #3696] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3712] + ldr q29, [x0, #3728] + ldr q30, [x0, #3744] + ldr q31, [x0, #3760] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #3776] + ldr q29, [x0, #3792] + ldr q30, [x0, #3808] + ldr q31, [x0, #3824] + tbx v22.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + ldr q28, [x0, #3840] + ldr q29, [x0, #3856] + ldr q30, [x0, #3872] + ldr q31, [x0, #3888] + tbl v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v19.16b + ldr q28, [x0, #3904] + ldr q29, [x0, #3920] + ldr q30, [x0, #3936] + ldr q31, [x0, #3952] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v24.16b + ldr q28, [x0, #3968] + ldr q29, [x0, #3984] + ldr q30, [x0, #4000] + ldr q31, [x0, #4016] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v25.16b + ldr q28, [x0, #4032] + ldr q29, [x0, #4048] + ldr q30, [x0, #4064] + ldr q31, [x0, #4080] + tbx v23.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v26.16b + zip1 v0.16b, v20.16b, v22.16b + zip2 v1.16b, v20.16b, v22.16b + zip1 v20.16b, v21.16b, v23.16b + zip2 v22.16b, v21.16b, v23.16b + zip1 v21.16b, v0.16b, v20.16b + zip2 v23.16b, v0.16b, v20.16b + zip1 v0.16b, v1.16b, v22.16b + zip2 v1.16b, v1.16b, v22.16b + add v12.4s, v12.4s, v21.4s + add v13.4s, v13.4s, v23.4s + add v14.4s, v14.4s, v0.4s + add v15.4s, v15.4s, v1.4s + eor v4.16b, v4.16b, v12.16b + eor v5.16b, v5.16b, v13.16b + eor v6.16b, v6.16b, v14.16b + eor v7.16b, v7.16b, v15.16b + add x5, x5, #4 + sub x7, x7, #1 + cbnz x7, 23b + ldr w6, [x0, #4160] + dup v0.4s, w6 + eor v4.16b, v4.16b, v0.16b + eor v5.16b, v5.16b, v0.16b + eor v6.16b, v6.16b, v0.16b + eor v7.16b, v7.16b, v0.16b + ldr w6, [x0, #4164] + dup v0.4s, w6 + eor v8.16b, v8.16b, v0.16b + eor v9.16b, v9.16b, v0.16b + eor v10.16b, v10.16b, v0.16b + eor v11.16b, v11.16b, v0.16b + zip1 v20.4s, v8.4s, v4.4s + zip2 v21.4s, v8.4s, v4.4s + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + str q20, [x4, #0] + str q21, [x4, #16] + zip1 v20.4s, v9.4s, v5.4s + zip2 v21.4s, v9.4s, v5.4s + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + str q20, [x4, #32] + str q21, [x4, #48] + zip1 v20.4s, v10.4s, v6.4s + zip2 v21.4s, v10.4s, v6.4s + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + str q20, [x4, #64] + str q21, [x4, #80] + zip1 v20.4s, v11.4s, v7.4s + zip2 v21.4s, v11.4s, v7.4s + rev32 v20.16b, v20.16b + rev32 v21.16b, v21.16b + str q20, [x4, #96] + str q21, [x4, #112] + dup v8.2d, x8 + dup v9.2d, x9 + dup v10.2d, x10 + dup v11.2d, x11 + dup v12.2d, x12 + dup v13.2d, x13 + dup v14.2d, x14 + dup v15.2d, x15 + add x5, x16, #0 + lsr x8, x24, #3 + cbz x8, 24f + ldr x6, [x23, #0] + ldr x7, [x5, #0] + eor x6, x6, x7 + str x6, [x23, #0] + add x23, x23, #8 + sub x24, x24, #8 + b 25f +24: + add x9, x5, #0 +26: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 26b +25: + cbnz x24, 22b + b 21f +20: +21: + ldr x6, [x5, #0] + str x6, [x25, #0] + ldr x19, [x5, #128] + ldr x20, [x5, #136] + ldr x21, [x5, #144] + ldr x22, [x5, #152] + ldr x23, [x5, #160] + ldr x24, [x5, #168] + ldr x25, [x5, #176] + ldr x26, [x5, #184] + ldr x27, [x5, #192] + ldr x28, [x5, #200] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + add sp, sp, #224 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/camellia_ctr.s b/crates/verified-garbage-asm-aarch64/assembly/camellia_ctr.s index 3f3a87b253a..2efea7091df 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/camellia_ctr.s +++ b/crates/verified-garbage-asm-aarch64/assembly/camellia_ctr.s @@ -377,3 +377,66 @@ vg_camellia_ctr: add sp, sp, #3344 ret .p2align 6 + +vg_camellia_ctr_final: + sub sp, sp, #80 + add x5, sp, #0 + str x19, [x5, #0] + str x20, [x5, #8] + str x21, [x5, #16] + str x22, [x5, #24] + str x23, [x5, #32] + str x24, [x5, #40] + str x30, [x5, #48] + str x25, [x5, #56] + add x19, x0, #0 + add x20, x1, #0 + add x21, x2, #0 + add x25, x5, #0 + lsr x9, x4, #4 + lsl x10, x9, #4 + add x22, x3, x10 + sub x23, x4, x10 + add x4, x9, #0 + bl {vg_camellia_ctr} + cbz x23, 20f + movz x9, #0, lsl #0 + str x9, [x25, #64] + str x9, [x25, #72] + add x0, x19, #0 + add x1, x20, #0 + add x2, x21, #0 + add x3, x25, #64 + movz x4, #1, lsl #0 + bl {vg_camellia_ctr} + add x9, x25, #64 +22: + ldrb w6, [x9, #0] + ldrb w7, [x22, #0] + eor x7, x7, x6 + strb w7, [x22, #0] + add x9, x9, #1 + add x22, x22, #1 + sub x23, x23, #1 + cbnz x23, 22b + b 21f +20: +21: + ldr x19, [x25, #0] + ldr x20, [x25, #8] + ldr x21, [x25, #16] + ldr x22, [x25, #24] + ldr x23, [x25, #32] + ldr x24, [x25, #40] + ldr x30, [x25, #48] + ldr x25, [x25, #56] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + add sp, sp, #80 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/camellia_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/camellia_ofb.s index 542f0cf4ce9..ed023298777 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/camellia_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/camellia_ofb.s @@ -290,3 +290,305 @@ vg_camellia_ofb: add sp, sp, #3344 ret .p2align 6 + +vg_camellia_ofb_final: + sub sp, sp, #3344 + add x5, sp, #0 + add x5, x5, #0 + str x19, [x5, #3152] + str x20, [x5, #3160] + str x21, [x5, #3168] + str x22, [x5, #3176] + str x23, [x5, #3184] + str x24, [x5, #3192] + str x25, [x5, #3200] + str x26, [x5, #3208] + str x27, [x5, #3216] + str x28, [x5, #3224] + add x19, x2, #0 + add x23, x3, #0 + add x24, x4, #0 + add x20, x30, #0 + add x22, x5, #0 + add x26, x1, #0 + add x2, x5, #0 + movz x3, #418, lsl #0 + bl {vg_camellia_prepare_encrypt_keys} + add x5, x22, #0 + add x30, x20, #0 + ldr x6, [x19, #0] + str x6, [x5, #768] + ldr x6, [x19, #8] + str x6, [x5, #776] + cbz x24, 20f +22: + add x20, x30, #0 + add x0, x26, #0 + add x1, x5, #0 + movz x2, #418, lsl #0 + bl {vg_camellia_encrypt_prepared} + add x5, x22, #0 + add x30, x20, #0 + lsr x8, x24, #4 + cbz x8, 23f + ldr x6, [x23, #0] + ldr x7, [x5, #768] + eor x6, x6, x7 + str x6, [x23, #0] + ldr x6, [x23, #8] + ldr x7, [x5, #776] + eor x6, x6, x7 + str x6, [x23, #8] + add x23, x23, #16 + sub x24, x24, #16 + b 24f +23: + add x9, x5, #768 +25: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 25b +24: + cbnz x24, 22b + b 21f +20: +21: + ldr x6, [x5, #768] + str x6, [x19, #0] + ldr x6, [x5, #776] + str x6, [x19, #8] + ldr x19, [x5, #3152] + ldr x20, [x5, #3160] + ldr x21, [x5, #3168] + ldr x22, [x5, #3176] + ldr x23, [x5, #3184] + ldr x24, [x5, #3192] + ldr x25, [x5, #3200] + ldr x26, [x5, #3208] + ldr x27, [x5, #3216] + ldr x28, [x5, #3224] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #512 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #1024 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #1536 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #2048 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #2560 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #3072 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + add sp, sp, #3344 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/cast5_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/cast5_ofb.s index 1e38f41be1d..92ecb98dddb 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/cast5_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/cast5_ofb.s @@ -403,3 +403,418 @@ vg_cast5_ofb: add sp, sp, #112 ret .p2align 6 + +vg_cast5_ofb_final: + sub sp, sp, #112 + add x5, sp, #0 + add x5, x5, #0 + str x19, [x5, #8] + str x20, [x5, #16] + str x21, [x5, #24] + str x22, [x5, #32] + str x23, [x5, #40] + str x24, [x5, #48] + str x25, [x5, #56] + str x26, [x5, #64] + str x27, [x5, #72] + str x28, [x5, #80] + add x25, x2, #0 + add x23, x3, #0 + add x24, x4, #0 + ldr x6, [x25, #0] + str x6, [x5, #0] + cbz x24, 20f +22: + add x16, x5, #0 + add x2, x5, #0 + ldr w5, [x2, #0] + rev w5, w5 + ldr w6, [x2, #4] + rev w6, w6 + add x12, x0, #0 + lsr x7, x1, #2 + add x7, x7, #1 + sub x8, x1, #16 +23: + ldr w9, [x12, #0] + add w4, w9, w6 + ldr w13, [x12, #64] + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #31 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #30 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #28 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #24 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #16 + csel w4, w15, w4, ne + lsl w14, w4, #24 + lsr w14, w14, #24 + mov v0.s[0], w14 + lsl w14, w4, #16 + lsr w14, w14, #24 + mov v0.s[1], w14 + lsl w14, w4, #8 + lsr w14, w14, #24 + mov v0.s[2], w14 + lsr w14, w4, #24 + mov v0.s[3], w14 + adrp x10, {VG_CAST5_S1234} + add x10, x10, {VG_CAST5_S1234} + movz x11, #64, lsl #0 + movi v1.2d, #0 + movi v2.2d, #0 + cmeq v3.4s, v3.4s, v3.4s + ushr v3.4s, v3.4s, #31 +24: + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #0] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #16] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #32] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #48] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + add x10, x10, #64 + sub x11, x11, #1 + cbnz x11, 24b + umov w9, v1.s[3] + umov w14, v1.s[2] + umov w15, v1.s[1] + umov w10, v1.s[0] + eor w4, w9, w14 + sub w4, w4, w15 + add w4, w4, w10 + eor w4, w4, w5 + orr w5, w6, w6 + orr w6, w4, w4 + add x12, x12, #4 + ldr w9, [x12, #0] + eor w4, w9, w6 + ldr w13, [x12, #64] + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #31 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #30 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #28 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #24 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #16 + csel w4, w15, w4, ne + lsl w14, w4, #24 + lsr w14, w14, #24 + mov v0.s[0], w14 + lsl w14, w4, #16 + lsr w14, w14, #24 + mov v0.s[1], w14 + lsl w14, w4, #8 + lsr w14, w14, #24 + mov v0.s[2], w14 + lsr w14, w4, #24 + mov v0.s[3], w14 + adrp x10, {VG_CAST5_S1234} + add x10, x10, {VG_CAST5_S1234} + movz x11, #64, lsl #0 + movi v1.2d, #0 + movi v2.2d, #0 + cmeq v3.4s, v3.4s, v3.4s + ushr v3.4s, v3.4s, #31 +25: + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #0] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #16] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #32] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #48] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + add x10, x10, #64 + sub x11, x11, #1 + cbnz x11, 25b + umov w9, v1.s[3] + umov w14, v1.s[2] + umov w15, v1.s[1] + umov w10, v1.s[0] + sub w4, w9, w14 + add w4, w4, w15 + eor w4, w4, w10 + eor w4, w4, w5 + orr w5, w6, w6 + orr w6, w4, w4 + add x12, x12, #4 + ldr w9, [x12, #0] + sub w4, w9, w6 + ldr w13, [x12, #64] + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #31 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #30 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #28 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #24 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #16 + csel w4, w15, w4, ne + lsl w14, w4, #24 + lsr w14, w14, #24 + mov v0.s[0], w14 + lsl w14, w4, #16 + lsr w14, w14, #24 + mov v0.s[1], w14 + lsl w14, w4, #8 + lsr w14, w14, #24 + mov v0.s[2], w14 + lsr w14, w4, #24 + mov v0.s[3], w14 + adrp x10, {VG_CAST5_S1234} + add x10, x10, {VG_CAST5_S1234} + movz x11, #64, lsl #0 + movi v1.2d, #0 + movi v2.2d, #0 + cmeq v3.4s, v3.4s, v3.4s + ushr v3.4s, v3.4s, #31 +26: + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #0] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #16] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #32] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #48] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + add x10, x10, #64 + sub x11, x11, #1 + cbnz x11, 26b + umov w9, v1.s[3] + umov w14, v1.s[2] + umov w15, v1.s[1] + umov w10, v1.s[0] + add w4, w9, w14 + eor w4, w4, w15 + sub w4, w4, w10 + eor w4, w4, w5 + orr w5, w6, w6 + orr w6, w4, w4 + add x12, x12, #4 + sub x7, x7, #1 + cbnz x7, 23b + cbz x8, 27f + b 28f +27: + ldr w9, [x12, #0] + add w4, w9, w6 + ldr w13, [x12, #64] + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #31 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #30 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #28 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #24 + csel w4, w15, w4, ne + lsr w13, w13, #1 + movz w14, #1, lsl #0 + tst w13, w14 + ror w15, w4, #16 + csel w4, w15, w4, ne + lsl w14, w4, #24 + lsr w14, w14, #24 + mov v0.s[0], w14 + lsl w14, w4, #16 + lsr w14, w14, #24 + mov v0.s[1], w14 + lsl w14, w4, #8 + lsr w14, w14, #24 + mov v0.s[2], w14 + lsr w14, w4, #24 + mov v0.s[3], w14 + adrp x10, {VG_CAST5_S1234} + add x10, x10, {VG_CAST5_S1234} + movz x11, #64, lsl #0 + movi v1.2d, #0 + movi v2.2d, #0 + cmeq v3.4s, v3.4s, v3.4s + ushr v3.4s, v3.4s, #31 +29: + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #0] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #16] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #32] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + cmeq v4.4s, v0.4s, v2.4s + ldr q5, [x10, #48] + and v5.16b, v5.16b, v4.16b + orr v1.16b, v1.16b, v5.16b + add v2.4s, v2.4s, v3.4s + add x10, x10, #64 + sub x11, x11, #1 + cbnz x11, 29b + umov w9, v1.s[3] + umov w14, v1.s[2] + umov w15, v1.s[1] + umov w10, v1.s[0] + eor w4, w9, w14 + sub w4, w4, w15 + add w4, w4, w10 + eor w4, w4, w5 + orr w5, w6, w6 + orr w6, w4, w4 + add x12, x12, #4 +28: + rev w6, w6 + str w6, [x2, #0] + rev w5, w5 + str w5, [x2, #4] + add x2, x2, #8 + sub x3, x3, #1 + add x5, x16, #0 + lsr x8, x24, #3 + cbz x8, 210f + ldr x6, [x23, #0] + ldr x7, [x5, #0] + eor x6, x6, x7 + str x6, [x23, #0] + add x23, x23, #8 + sub x24, x24, #8 + b 211f +210: + add x9, x5, #0 +212: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 212b +211: + cbnz x24, 22b + b 21f +20: +21: + ldr x6, [x5, #0] + str x6, [x25, #0] + ldr x19, [x5, #8] + ldr x20, [x5, #16] + ldr x21, [x5, #24] + ldr x22, [x5, #32] + ldr x23, [x5, #40] + ldr x24, [x5, #48] + ldr x25, [x5, #56] + ldr x26, [x5, #64] + ldr x27, [x5, #72] + ldr x28, [x5, #80] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + str x17, [sp, #96] + add sp, sp, #112 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/idea_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/idea_ofb.s index c711ad37488..2e8115aee0f 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/idea_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/idea_ofb.s @@ -818,3 +818,833 @@ vg_idea_ofb: add sp, sp, #208 ret .p2align 6 + +vg_idea_ofb_final: + sub sp, sp, #208 + add x4, sp, #0 + add x5, x4, #0 + str x19, [x5, #112] + str x20, [x5, #120] + str x21, [x5, #128] + str x22, [x5, #136] + str x23, [x5, #144] + str x24, [x5, #152] + str x25, [x5, #160] + str x26, [x5, #168] + str x27, [x5, #176] + str x28, [x5, #184] + add x25, x1, #0 + add x23, x2, #0 + add x24, x3, #0 + ldr x6, [x0, #0] + str x6, [x5, #8] + ldr x6, [x0, #8] + str x6, [x5, #16] + ldr x6, [x0, #16] + str x6, [x5, #24] + ldr x6, [x0, #24] + str x6, [x5, #32] + ldr x6, [x0, #32] + str x6, [x5, #40] + ldr x6, [x0, #40] + str x6, [x5, #48] + ldr x6, [x0, #48] + str x6, [x5, #56] + ldr x6, [x0, #56] + str x6, [x5, #64] + ldr x6, [x0, #64] + str x6, [x5, #72] + ldr x6, [x0, #72] + str x6, [x5, #80] + ldr x6, [x0, #80] + str x6, [x5, #88] + ldr x6, [x0, #88] + str x6, [x5, #96] + ldr x6, [x0, #96] + str x6, [x5, #104] + ldr x6, [x25, #0] + str x6, [x5, #0] + cbz x24, 20f +22: + add x2, x5, #0 + add x0, x5, #8 + add x1, x5, #0 + movz x15, #65535, lsl #0 + ldrb w3, [x1, #0] + lsl x3, x3, #8 + ldrb w7, [x1, #1] + orr x3, x3, x7 + ldrb w4, [x1, #2] + lsl x4, x4, #8 + ldrb w7, [x1, #3] + orr x4, x4, x7 + ldrb w5, [x1, #4] + lsl x5, x5, #8 + ldrb w7, [x1, #5] + orr x5, x5, x7 + ldrb w6, [x1, #6] + lsl x6, x6, #8 + ldrb w7, [x1, #7] + orr x6, x6, x7 + ldr w8, [x0, #0] + ldr w9, [x0, #4] + ldr w13, [x0, #8] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #12] + ldr w9, [x0, #16] + ldr w13, [x0, #20] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #24] + ldr w9, [x0, #28] + ldr w13, [x0, #32] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #36] + ldr w9, [x0, #40] + ldr w13, [x0, #44] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #48] + ldr w9, [x0, #52] + ldr w13, [x0, #56] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #60] + ldr w9, [x0, #64] + ldr w13, [x0, #68] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #72] + ldr w9, [x0, #76] + ldr w13, [x0, #80] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr w8, [x0, #84] + ldr w9, [x0, #88] + ldr w13, [x0, #92] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x9, #16 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x4, x4, x14 + and x4, x4, x15 + add x5, x5, x9 + and x5, x5, x15 + eor x7, x3, x5 + sub x11, x7, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x13, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x7, x12, x15 + eor x14, x4, x6 + add x14, x14, x7 + lsr x10, x13, #16 + sub x11, x14, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x10, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x14, x12, x15 + add x7, x7, x14 + and x7, x7, x15 + eor x3, x3, x14 + eor x5, x5, x14 + eor x4, x4, x7 + eor x6, x6, x7 + add x14, x4, #0 + add x4, x5, #0 + add x5, x14, #0 + ldr x8, [x0, #96] + sub x11, x3, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x8, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x3, x12, x15 + lsr x14, x8, #48 + sub x11, x6, #1 + and x11, x11, x15 + add x11, x11, #1 + sub x12, x14, #1 + and x12, x12, x15 + add x12, x12, #1 + mul x11, x11, x12 + and x12, x11, x15 + lsr x11, x11, #16 + sub x12, x12, x11 + lsr x11, x12, #63 + add x12, x12, x11 + lsl x11, x11, #16 + add x12, x12, x11 + and x6, x12, x15 + lsr x14, x8, #16 + add x5, x5, x14 + and x5, x5, x15 + lsr x14, x8, #32 + add x4, x4, x14 + and x4, x4, x15 + strb w3, [x1, #1] + lsr x14, x3, #8 + strb w14, [x1, #0] + strb w5, [x1, #3] + lsr x14, x5, #8 + strb w14, [x1, #2] + strb w4, [x1, #5] + lsr x14, x4, #8 + strb w14, [x1, #4] + strb w6, [x1, #7] + lsr x14, x6, #8 + strb w14, [x1, #6] + add x5, x2, #0 + lsr x8, x24, #3 + cbz x8, 23f + ldr x6, [x23, #0] + ldr x7, [x5, #0] + eor x6, x6, x7 + str x6, [x23, #0] + add x23, x23, #8 + sub x24, x24, #8 + b 24f +23: + add x9, x5, #0 +25: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 25b +24: + cbnz x24, 22b + b 21f +20: +21: + ldr x6, [x5, #0] + str x6, [x25, #0] + ldr x19, [x5, #112] + ldr x20, [x5, #120] + ldr x21, [x5, #128] + ldr x22, [x5, #136] + ldr x23, [x5, #144] + ldr x24, [x5, #152] + ldr x25, [x5, #160] + ldr x26, [x5, #168] + ldr x27, [x5, #176] + ldr x28, [x5, #184] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + add sp, sp, #208 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/seed_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/seed_ofb.s index f516081787f..1a95eb11b85 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/seed_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/seed_ofb.s @@ -202,3 +202,217 @@ vg_seed_ofb: add sp, sp, #1456 ret .p2align 6 + +vg_seed_ofb_final: + sub sp, sp, #1456 + add x4, sp, #0 + add x5, x4, #0 + str x19, [x5, #1360] + str x20, [x5, #1368] + str x21, [x5, #1376] + str x22, [x5, #1384] + str x23, [x5, #1392] + str x24, [x5, #1400] + str x25, [x5, #1408] + str x26, [x5, #1416] + str x27, [x5, #1424] + str x28, [x5, #1432] + add x25, x1, #0 + add x23, x2, #0 + add x24, x3, #0 + dup v31.2d, x25 + ldr x6, [x0, #0] + str x6, [x5, #1232] + ldr x6, [x0, #8] + str x6, [x5, #1240] + ldr x6, [x0, #16] + str x6, [x5, #1248] + ldr x6, [x0, #24] + str x6, [x5, #1256] + ldr x6, [x0, #32] + str x6, [x5, #1264] + ldr x6, [x0, #40] + str x6, [x5, #1272] + ldr x6, [x0, #48] + str x6, [x5, #1280] + ldr x6, [x0, #56] + str x6, [x5, #1288] + ldr x6, [x0, #64] + str x6, [x5, #1296] + ldr x6, [x0, #72] + str x6, [x5, #1304] + ldr x6, [x0, #80] + str x6, [x5, #1312] + ldr x6, [x0, #88] + str x6, [x5, #1320] + ldr x6, [x0, #96] + str x6, [x5, #1328] + ldr x6, [x0, #104] + str x6, [x5, #1336] + ldr x6, [x0, #112] + str x6, [x5, #1344] + ldr x6, [x0, #120] + str x6, [x5, #1352] + umov x25, v31.d[0] + ldr x6, [x25, #0] + str x6, [x5, #976] + ldr x6, [x25, #8] + str x6, [x5, #984] + cbz x24, 20f +22: + dup v31.2d, x25 + dup v28.2d, x30 + dup v27.2d, x5 + dup v29.2d, x23 + dup v30.2d, x24 + add x0, x5, #1232 + add x1, x5, #976 + movz x2, #16, lsl #0 + add x3, x5, #0 + bl {vg_seed_encrypt_blocks} + umov x5, v27.d[0] + umov x30, v28.d[0] + umov x23, v29.d[0] + umov x24, v30.d[0] + umov x25, v31.d[0] + lsr x8, x24, #4 + cbz x8, 23f + ldr x6, [x23, #0] + ldr x7, [x5, #976] + eor x6, x6, x7 + str x6, [x23, #0] + ldr x6, [x23, #8] + ldr x7, [x5, #984] + eor x6, x6, x7 + str x6, [x23, #8] + add x23, x23, #16 + sub x24, x24, #16 + b 24f +23: + add x9, x5, #976 +25: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 25b +24: + cbnz x24, 22b + b 21f +20: +21: + ldr x6, [x5, #976] + str x6, [x25, #0] + ldr x6, [x5, #984] + str x6, [x25, #8] + ldr x19, [x5, #1360] + ldr x20, [x5, #1368] + ldr x21, [x5, #1376] + ldr x22, [x5, #1384] + ldr x23, [x5, #1392] + ldr x24, [x5, #1400] + ldr x25, [x5, #1408] + ldr x26, [x5, #1416] + ldr x27, [x5, #1424] + ldr x28, [x5, #1432] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #512 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #1024 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + add sp, sp, #1456 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/sm4_ctr.s b/crates/verified-garbage-asm-aarch64/assembly/sm4_ctr.s index 076cc8b378e..600252cc49e 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/sm4_ctr.s +++ b/crates/verified-garbage-asm-aarch64/assembly/sm4_ctr.s @@ -415,3 +415,64 @@ vg_sm4_ctr: add sp, sp, #3264 ret .p2align 6 + +vg_sm4_ctr_final: + sub sp, sp, #80 + add x4, sp, #0 + str x19, [x4, #0] + str x20, [x4, #8] + str x21, [x4, #16] + str x22, [x4, #24] + str x23, [x4, #32] + str x24, [x4, #40] + str x30, [x4, #48] + str x25, [x4, #56] + add x19, x0, #0 + add x21, x1, #0 + add x25, x4, #0 + lsr x9, x3, #4 + lsl x10, x9, #4 + add x22, x2, x10 + sub x23, x3, x10 + add x3, x9, #0 + bl {vg_sm4_ctr} + cbz x23, 20f + movz x9, #0, lsl #0 + str x9, [x25, #64] + str x9, [x25, #72] + add x0, x19, #0 + add x1, x21, #0 + add x2, x25, #64 + movz x3, #1, lsl #0 + bl {vg_sm4_ctr} + add x9, x25, #64 +22: + ldrb w6, [x9, #0] + ldrb w7, [x22, #0] + eor x7, x7, x6 + strb w7, [x22, #0] + add x9, x9, #1 + add x22, x22, #1 + sub x23, x23, #1 + cbnz x23, 22b + b 21f +20: +21: + ldr x19, [x25, #0] + ldr x20, [x25, #8] + ldr x21, [x25, #16] + ldr x22, [x25, #24] + ldr x23, [x25, #32] + ldr x24, [x25, #40] + ldr x30, [x25, #48] + ldr x25, [x25, #56] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + add sp, sp, #80 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/sm4_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/sm4_ofb.s index a8a87cf3ee1..ed0e1711e6d 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/sm4_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/sm4_ofb.s @@ -1152,3 +1152,1167 @@ vg_sm4_ofb: add sp, sp, #3264 ret .p2align 6 + +vg_sm4_ofb_final: + sub sp, sp, #3264 + add x4, sp, #0 + add x5, x4, #0 + str x19, [x5, #3168] + str x20, [x5, #3176] + str x21, [x5, #3184] + str x22, [x5, #3192] + str x23, [x5, #3200] + str x24, [x5, #3208] + str x25, [x5, #3216] + str x26, [x5, #3224] + str x27, [x5, #3232] + str x28, [x5, #3240] + add x19, x1, #0 + add x23, x2, #0 + add x24, x3, #0 + movz x21, #37078, lsl #0 + movk x21, #65257, lsl #16 + movk x21, #57804, lsl #32 + movk x21, #46909, lsl #48 + str x21, [x5, #0] + movz x21, #46614, lsl #0 + movk x21, #49684, lsl #16 + movk x21, #64296, lsl #32 + movk x21, #1324, lsl #48 + str x21, [x5, #8] + movz x21, #26411, lsl #0 + movk x21, #30362, lsl #16 + movk x21, #48682, lsl #32 + movk x21, #49924, lsl #48 + str x21, [x5, #16] + movz x21, #17578, lsl #0 + movk x21, #9747, lsl #16 + movk x21, #34377, lsl #32 + movk x21, #39174, lsl #48 + str x21, [x5, #24] + movz x21, #17052, lsl #0 + movk x21, #62544, lsl #16 + movk x21, #61329, lsl #32 + movk x21, #31384, lsl #48 + str x21, [x5, #32] + movz x21, #21555, lsl #0 + movk x21, #17163, lsl #16 + movk x21, #53229, lsl #32 + movk x21, #25260, lsl #48 + str x21, [x5, #40] + movz x21, #46052, lsl #0 + movk x21, #43292, lsl #16 + movk x21, #2249, lsl #32 + movk x21, #38376, lsl #48 + str x21, [x5, #48] + movz x21, #57216, lsl #0 + movk x21, #64148, lsl #16 + movk x21, #36725, lsl #32 + movk x21, #42559, lsl #48 + str x21, [x5, #56] + movz x21, #1863, lsl #0 + movk x21, #64679, lsl #16 + movk x21, #29683, lsl #32 + movk x21, #47639, lsl #48 + str x21, [x5, #64] + movz x21, #22915, lsl #0 + movk x21, #6460, lsl #16 + movk x21, #34278, lsl #32 + movk x21, #43087, lsl #48 + str x21, [x5, #72] + movz x21, #27496, lsl #0 + movk x21, #45697, lsl #16 + movk x21, #25713, lsl #32 + movk x21, #35802, lsl #48 + str x21, [x5, #80] + movz x21, #60408, lsl #0 + movk x21, #19215, lsl #16 + movk x21, #22128, lsl #32 + movk x21, #13725, lsl #48 + str x21, [x5, #88] + movz x21, #9246, lsl #0 + movk x21, #24078, lsl #16 + movk x21, #22627, lsl #32 + movk x21, #41681, lsl #48 + str x21, [x5, #96] + movz x21, #8741, lsl #0 + movk x21, #15228, lsl #16 + movk x21, #8449, lsl #32 + movk x21, #34680, lsl #48 + str x21, [x5, #104] + movz x21, #212, lsl #0 + movk x21, #22342, lsl #16 + movk x21, #54175, lsl #32 + movk x21, #21031, lsl #48 + str x21, [x5, #112] + movz x21, #13900, lsl #0 + movk x21, #59138, lsl #16 + movk x21, #50336, lsl #32 + movk x21, #40648, lsl #48 + str x21, [x5, #120] + movz x21, #49130, lsl #0 + movk x21, #53898, lsl #16 + movk x21, #51008, lsl #32 + movk x21, #46392, lsl #48 + str x21, [x5, #128] + movz x21, #63395, lsl #0 + movk x21, #52978, lsl #16 + movk x21, #25081, lsl #32 + movk x21, #41237, lsl #48 + str x21, [x5, #136] + movz x21, #44768, lsl #0 + movk x21, #42077, lsl #16 + movk x21, #13467, lsl #32 + movk x21, #21786, lsl #48 + str x21, [x5, #144] + movz x21, #37805, lsl #0 + movk x21, #12338, lsl #16 + movk x21, #36085, lsl #32 + movk x21, #58289, lsl #48 + str x21, [x5, #152] + movz x21, #63005, lsl #0 + movk x21, #12002, lsl #16 + movk x21, #26242, lsl #32 + movk x21, #24778, lsl #48 + str x21, [x5, #160] + movz x21, #10688, lsl #0 + movk x21, #43811, lsl #16 + movk x21, #21261, lsl #32 + movk x21, #28494, lsl #48 + str x21, [x5, #168] + movz x21, #56277, lsl #0 + movk x21, #17719, lsl #16 + movk x21, #64990, lsl #32 + movk x21, #12174, lsl #48 + str x21, [x5, #176] + movz x21, #65283, lsl #0 + movk x21, #29290, lsl #16 + movk x21, #27757, lsl #32 + movk x21, #20827, lsl #48 + str x21, [x5, #184] + movz x21, #7053, lsl #0 + movk x21, #37551, lsl #16 + movk x21, #56763, lsl #32 + movk x21, #32700, lsl #48 + str x21, [x5, #192] + movz x21, #55569, lsl #0 + movk x21, #16732, lsl #16 + movk x21, #4127, lsl #32 + movk x21, #55386, lsl #48 + str x21, [x5, #200] + movz x21, #49418, lsl #0 + movk x21, #34865, lsl #16 + movk x21, #52645, lsl #32 + movk x21, #48507, lsl #48 + str x21, [x5, #208] + movz x21, #29741, lsl #0 + movk x21, #4816, lsl #16 + movk x21, #58808, lsl #32 + movk x21, #45236, lsl #48 + str x21, [x5, #216] + movz x21, #27017, lsl #0 + movk x21, #19095, lsl #16 + movk x21, #38412, lsl #32 + movk x21, #32375, lsl #48 + str x21, [x5, #224] + movz x21, #47461, lsl #0 + movk x21, #2545, lsl #16 + movk x21, #28357, lsl #32 + movk x21, #33990, lsl #48 + str x21, [x5, #232] + movz x21, #61464, lsl #0 + movk x21, #60541, lsl #16 + movk x21, #56378, lsl #32 + movk x21, #8269, lsl #48 + str x21, [x5, #240] + movz x21, #61049, lsl #0 + movk x21, #15967, lsl #16 + movk x21, #52183, lsl #32 + movk x21, #18489, lsl #48 + str x21, [x5, #248] + add x14, x0, #0 + add x15, x5, #256 + movz x17, #8, lsl #0 +20: + ldr x21, [x14, #0] + str x21, [x15, #0] + ldr x21, [x14, #8] + str x21, [x15, #8] + add x14, x14, #16 + add x15, x15, #16 + sub x17, x17, #1 + cbnz x17, 20b + ldr x6, [x19, #0] + str x6, [x5, #768] + ldr x6, [x19, #8] + str x6, [x5, #776] + cbz x24, 21f +23: + ldr q16, [x5, #0] + ldr q17, [x5, #16] + ldr q18, [x5, #32] + ldr q19, [x5, #48] + ldr q20, [x5, #64] + ldr q21, [x5, #80] + ldr q22, [x5, #96] + ldr q23, [x5, #112] + ldr q24, [x5, #128] + ldr q25, [x5, #144] + ldr q26, [x5, #160] + ldr q27, [x5, #176] + ldr q28, [x5, #192] + ldr q29, [x5, #208] + ldr q30, [x5, #224] + ldr q31, [x5, #240] + movz w15, #64, lsl #0 + dup v4.16b, w15 + movz w15, #128, lsl #0 + dup v5.16b, w15 + movz w15, #192, lsl #0 + dup v6.16b, w15 + ldr w6, [x5, #768] + rev w6, w6 + ldr w7, [x5, #772] + rev w7, w7 + ldr w8, [x5, #776] + rev w8, w8 + ldr w9, [x5, #780] + rev w9, w9 + ldr w10, [x5, #256] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #260] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #264] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #268] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #272] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #276] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #280] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #284] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #288] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #292] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #296] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #300] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #304] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #308] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #312] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #316] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #320] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #324] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #328] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #332] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #336] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #340] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #344] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #348] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #352] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #356] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #360] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #364] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + ldr w10, [x5, #368] + eor w10, w10, w7 + eor w10, w10, w8 + eor w10, w10, w9 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w6, w6, w11 + ldr w10, [x5, #372] + eor w10, w10, w8 + eor w10, w10, w9 + eor w10, w10, w6 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w7, w7, w11 + ldr w10, [x5, #376] + eor w10, w10, w9 + eor w10, w10, w6 + eor w10, w10, w7 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w8, w8, w11 + ldr w10, [x5, #380] + eor w10, w10, w6 + eor w10, w10, w7 + eor w10, w10, w8 + dup v0.4s, w10 + eor v1.16b, v0.16b, v4.16b + eor v2.16b, v0.16b, v5.16b + eor v3.16b, v0.16b, v6.16b + tbl v0.16b, {v16.16b, v17.16b, v18.16b, v19.16b}, v0.16b + tbl v1.16b, {v20.16b, v21.16b, v22.16b, v23.16b}, v1.16b + tbl v2.16b, {v24.16b, v25.16b, v26.16b, v27.16b}, v2.16b + tbl v3.16b, {v28.16b, v29.16b, v30.16b, v31.16b}, v3.16b + orr v2.16b, v2.16b, v3.16b + orr v0.16b, v0.16b, v1.16b + orr v0.16b, v0.16b, v2.16b + umov w10, v0.s[0] + eor w11, w10, w10, ror #30 + eor w11, w11, w10, ror #22 + eor w11, w11, w10, ror #14 + eor w11, w11, w10, ror #8 + eor w9, w9, w11 + rev w9, w9 + str w9, [x5, #768] + rev w8, w8 + str w8, [x5, #772] + rev w7, w7 + str w7, [x5, #776] + rev w6, w6 + str w6, [x5, #780] + lsr x8, x24, #4 + cbz x8, 24f + ldr x6, [x23, #0] + ldr x7, [x5, #768] + eor x6, x6, x7 + str x6, [x23, #0] + ldr x6, [x23, #8] + ldr x7, [x5, #776] + eor x6, x6, x7 + str x6, [x23, #8] + add x23, x23, #16 + sub x24, x24, #16 + b 25f +24: + add x9, x5, #768 +26: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 26b +25: + cbnz x24, 23b + b 22f +21: +22: + ldr x6, [x5, #768] + str x6, [x19, #0] + ldr x6, [x5, #776] + str x6, [x19, #8] + ldr x19, [x5, #3168] + ldr x20, [x5, #3176] + ldr x21, [x5, #3184] + ldr x22, [x5, #3192] + ldr x23, [x5, #3200] + ldr x24, [x5, #3208] + ldr x25, [x5, #3216] + ldr x26, [x5, #3224] + ldr x27, [x5, #3232] + ldr x28, [x5, #3240] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #512 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #1024 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #1536 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #2048 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #2560 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #3072 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + add sp, sp, #3264 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/assembly/triple_des_ofb.s b/crates/verified-garbage-asm-aarch64/assembly/triple_des_ofb.s index fc4b892b87c..f85c2cb0672 100644 --- a/crates/verified-garbage-asm-aarch64/assembly/triple_des_ofb.s +++ b/crates/verified-garbage-asm-aarch64/assembly/triple_des_ofb.s @@ -219,3 +219,234 @@ vg_triple_des_ofb: add sp, sp, #1008 ret .p2align 6 + +vg_triple_des_ofb_final: + sub sp, sp, #1008 + add x4, sp, #0 + add x5, x4, #0 + str x19, [x5, #904] + str x20, [x5, #912] + str x21, [x5, #920] + str x22, [x5, #928] + str x23, [x5, #936] + str x24, [x5, #944] + str x25, [x5, #952] + str x26, [x5, #960] + str x27, [x5, #968] + str x28, [x5, #976] + add x25, x1, #0 + add x23, x2, #0 + add x24, x3, #0 + ldr x6, [x0, #0] + str x6, [x5, #520] + ldr x6, [x0, #8] + str x6, [x5, #528] + ldr x6, [x0, #16] + str x6, [x5, #536] + ldr x6, [x0, #24] + str x6, [x5, #544] + ldr x6, [x0, #32] + str x6, [x5, #552] + ldr x6, [x0, #40] + str x6, [x5, #560] + ldr x6, [x0, #48] + str x6, [x5, #568] + ldr x6, [x0, #56] + str x6, [x5, #576] + ldr x6, [x0, #64] + str x6, [x5, #584] + ldr x6, [x0, #72] + str x6, [x5, #592] + ldr x6, [x0, #80] + str x6, [x5, #600] + ldr x6, [x0, #88] + str x6, [x5, #608] + ldr x6, [x0, #96] + str x6, [x5, #616] + ldr x6, [x0, #104] + str x6, [x5, #624] + ldr x6, [x0, #112] + str x6, [x5, #632] + ldr x6, [x0, #120] + str x6, [x5, #640] + ldr x6, [x0, #128] + str x6, [x5, #648] + ldr x6, [x0, #136] + str x6, [x5, #656] + ldr x6, [x0, #144] + str x6, [x5, #664] + ldr x6, [x0, #152] + str x6, [x5, #672] + ldr x6, [x0, #160] + str x6, [x5, #680] + ldr x6, [x0, #168] + str x6, [x5, #688] + ldr x6, [x0, #176] + str x6, [x5, #696] + ldr x6, [x0, #184] + str x6, [x5, #704] + ldr x6, [x0, #192] + str x6, [x5, #712] + ldr x6, [x0, #200] + str x6, [x5, #720] + ldr x6, [x0, #208] + str x6, [x5, #728] + ldr x6, [x0, #216] + str x6, [x5, #736] + ldr x6, [x0, #224] + str x6, [x5, #744] + ldr x6, [x0, #232] + str x6, [x5, #752] + ldr x6, [x0, #240] + str x6, [x5, #760] + ldr x6, [x0, #248] + str x6, [x5, #768] + ldr x6, [x0, #256] + str x6, [x5, #776] + ldr x6, [x0, #264] + str x6, [x5, #784] + ldr x6, [x0, #272] + str x6, [x5, #792] + ldr x6, [x0, #280] + str x6, [x5, #800] + ldr x6, [x0, #288] + str x6, [x5, #808] + ldr x6, [x0, #296] + str x6, [x5, #816] + ldr x6, [x0, #304] + str x6, [x5, #824] + ldr x6, [x0, #312] + str x6, [x5, #832] + ldr x6, [x0, #320] + str x6, [x5, #840] + ldr x6, [x0, #328] + str x6, [x5, #848] + ldr x6, [x0, #336] + str x6, [x5, #856] + ldr x6, [x0, #344] + str x6, [x5, #864] + ldr x6, [x0, #352] + str x6, [x5, #872] + ldr x6, [x0, #360] + str x6, [x5, #880] + ldr x6, [x0, #368] + str x6, [x5, #888] + ldr x6, [x0, #376] + str x6, [x5, #896] + ldr x6, [x25, #0] + str x6, [x5, #512] + cbz x24, 20f +22: + add x0, x5, #520 + add x1, x5, #512 + add x2, x5, #0 + add x26, x30, #0 + bl {vg_triple_des_encrypt_block} + add x5, x2, #0 + add x30, x26, #0 + lsr x8, x24, #3 + cbz x8, 23f + ldr x6, [x23, #0] + ldr x7, [x5, #512] + eor x6, x6, x7 + str x6, [x23, #0] + add x23, x23, #8 + sub x24, x24, #8 + b 24f +23: + add x9, x5, #512 +25: + ldrb w6, [x9, #0] + ldrb w7, [x23, #0] + eor x7, x7, x6 + strb w7, [x23, #0] + add x9, x9, #1 + add x23, x23, #1 + sub x24, x24, #1 + cbnz x24, 25b +24: + cbnz x24, 22b + b 21f +20: +21: + ldr x6, [x5, #512] + str x6, [x25, #0] + ldr x19, [x5, #904] + ldr x20, [x5, #912] + ldr x21, [x5, #920] + ldr x22, [x5, #928] + ldr x23, [x5, #936] + ldr x24, [x5, #944] + ldr x25, [x5, #952] + ldr x26, [x5, #960] + ldr x27, [x5, #968] + ldr x28, [x5, #976] + movz x17, #0, lsl #0 + add x16, sp, #0 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + stp x17, x17, [x16, #480] + stp x17, x17, [x16, #496] + add x16, sp, #512 + stp x17, x17, [x16, #0] + stp x17, x17, [x16, #16] + stp x17, x17, [x16, #32] + stp x17, x17, [x16, #48] + stp x17, x17, [x16, #64] + stp x17, x17, [x16, #80] + stp x17, x17, [x16, #96] + stp x17, x17, [x16, #112] + stp x17, x17, [x16, #128] + stp x17, x17, [x16, #144] + stp x17, x17, [x16, #160] + stp x17, x17, [x16, #176] + stp x17, x17, [x16, #192] + stp x17, x17, [x16, #208] + stp x17, x17, [x16, #224] + stp x17, x17, [x16, #240] + stp x17, x17, [x16, #256] + stp x17, x17, [x16, #272] + stp x17, x17, [x16, #288] + stp x17, x17, [x16, #304] + stp x17, x17, [x16, #320] + stp x17, x17, [x16, #336] + stp x17, x17, [x16, #352] + stp x17, x17, [x16, #368] + stp x17, x17, [x16, #384] + stp x17, x17, [x16, #400] + stp x17, x17, [x16, #416] + stp x17, x17, [x16, #432] + stp x17, x17, [x16, #448] + stp x17, x17, [x16, #464] + str x17, [sp, #992] + add sp, sp, #1008 + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-aarch64/src/aes_ctr.rs b/crates/verified-garbage-asm-aarch64/src/aes_ctr.rs index 8bc2a6d3ed8..10aa0cfd684 100644 --- a/crates/verified-garbage-asm-aarch64/src/aes_ctr.rs +++ b/crates/verified-garbage-asm-aarch64/src/aes_ctr.rs @@ -48,6 +48,50 @@ b 21f ) } +/// The CPU features `vg_aes_ctr_final_aes` requires (`Artifact.features`). +pub const VG_AES_CTR_FINAL_AES_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES); + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the 80 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes` target feature. +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final_aes(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r".inst 0xd10143ff,0x910003e6,0xf90000d3,0xf90004d4,0xf90008d5,0xf9000cd6,0xf90010d7,0xf90014d8 +.inst 0xf90018de,0xf9001cd9,0x91000013,0x91000034,0x91000055,0x910000b8,0x910000d9,0xd344fc89 +.inst 0xd37ced2a,0x8b0a0076,0xcb0a0097,0x91000124 +bl {vg_aes_ctr_aes} +cbz x23, 20f +.inst 0xd2800009,0xf9002329,0xf9002729,0x91000260,0x91000281,0x910002a2,0x91010323,0xd2800024 +.inst 0x91000305 +bl {vg_aes_ctr_aes} +.inst 0x91010329 +22: +.inst 0x39400126,0x394002c7,0xca0600e7,0x390002c7,0x91000529,0x910006d6,0xd10006f7 +cbnz x23, 22b +b 21f +20: +21: +.inst 0xf9400333,0xf9400734,0xf9400b35,0xf9400f36,0xf9401337,0xf9401738,0xf9401b3e,0xf9401f39 +.inst 0xd2800011,0x910003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0x910143ff +.inst 0xd65f03c0 +.p2align 6", + vg_aes_ctr_aes = sym super::aes_ctr::vg_aes_ctr_aes, + ) +} + /// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of whole blocks, in place: XORs the `n` 16-byte blocks at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `n = 0`), so that a further call continues the message. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. /// /// Contract: `VG.Spec.Ctr.aesContract`. Constant time: only the pointers, `rounds`, `n` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. @@ -88,3 +132,43 @@ b 21f vg_aes_ctr32 = sym super::aes::vg_aes_ctr32::vg_aes_ctr32, ) } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the 80 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r".inst 0xd10143ff,0x910003e6,0xf90000d3,0xf90004d4,0xf90008d5,0xf9000cd6,0xf90010d7,0xf90014d8 +.inst 0xf90018de,0xf9001cd9,0x91000013,0x91000034,0x91000055,0x910000b8,0x910000d9,0xd344fc89 +.inst 0xd37ced2a,0x8b0a0076,0xcb0a0097,0x91000124 +bl {vg_aes_ctr} +cbz x23, 20f +.inst 0xd2800009,0xf9002329,0xf9002729,0x91000260,0x91000281,0x910002a2,0x91010323,0xd2800024 +.inst 0x91000305 +bl {vg_aes_ctr} +.inst 0x91010329 +22: +.inst 0x39400126,0x394002c7,0xca0600e7,0x390002c7,0x91000529,0x910006d6,0xd10006f7 +cbnz x23, 22b +b 21f +20: +21: +.inst 0xf9400333,0xf9400734,0xf9400b35,0xf9400f36,0xf9401337,0xf9401738,0xf9401b3e,0xf9401f39 +.inst 0xd2800011,0x910003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0x910143ff +.inst 0xd65f03c0 +.p2align 6", + vg_aes_ctr = sym super::aes_ctr::vg_aes_ctr, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/aes_ofb.rs b/crates/verified-garbage-asm-aarch64/src/aes_ofb.rs index 22669b9fb77..3f8875376fd 100644 --- a/crates/verified-garbage-asm-aarch64/src/aes_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/aes_ofb.rs @@ -42,6 +42,49 @@ b 21f ) } +/// The CPU features `vg_aes_ofb_final_aes` requires (`Artifact.features`). +pub const VG_AES_OFB_FINAL_AES_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES); + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the 64 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes` target feature. +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final_aes(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r".inst 0xd10103ff,0x910003e6,0xf90000d3,0xf90004d4,0xf90008d5,0xf9000cd6,0xf90010d7,0xf90014d8 +.inst 0xf90018de,0xf9001cd9,0x91000013,0x91000034,0x91000055,0x910000b8,0x910000d9,0xd344fc89 +.inst 0xd37ced2a,0x8b0a0076,0xcb0a0097,0x91000124 +bl {vg_aes_ofb_aes} +cbz x23, 20f +.inst 0x91000260,0x91000281,0x910002a2,0xd2800023,0x91000304 +bl {vg_aes_encrypt_blocks_aes} +.inst 0x910002a9 +22: +.inst 0x39400126,0x394002c7,0xca0600e7,0x390002c7,0x91000529,0x910006d6,0xd10006f7 +cbnz x23, 22b +b 21f +20: +21: +.inst 0xf9400333,0xf9400734,0xf9400b35,0xf9400f36,0xf9401337,0xf9401738,0xf9401b3e,0xf9401f39 +.inst 0xd2800011,0x910003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0x910103ff,0xd65f03c0 +.p2align 6", + vg_aes_ofb_aes = sym super::aes_ofb::vg_aes_ofb_aes, + vg_aes_encrypt_blocks_aes = sym super::aes::vg_aes_encrypt_blocks_aes, + ) +} + /// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of whole blocks, in place: XORs the `n` 16-byte blocks at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, and replaces `*iv` with `Oₙ` (leaving it unchanged if `n = 0`), so that a further call continues the message. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. /// /// Contract: `VG.Spec.Ofb.aesContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data. @@ -76,3 +119,42 @@ b 21f vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, ) } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the 64 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r".inst 0xd10103ff,0x910003e6,0xf90000d3,0xf90004d4,0xf90008d5,0xf9000cd6,0xf90010d7,0xf90014d8 +.inst 0xf90018de,0xf9001cd9,0x91000013,0x91000034,0x91000055,0x910000b8,0x910000d9,0xd344fc89 +.inst 0xd37ced2a,0x8b0a0076,0xcb0a0097,0x91000124 +bl {vg_aes_ofb} +cbz x23, 20f +.inst 0x91000260,0x91000281,0x910002a2,0xd2800023,0x91000304 +bl {vg_aes_encrypt_blocks} +.inst 0x910002a9 +22: +.inst 0x39400126,0x394002c7,0xca0600e7,0x390002c7,0x91000529,0x910006d6,0xd10006f7 +cbnz x23, 22b +b 21f +20: +21: +.inst 0xf9400333,0xf9400734,0xf9400b35,0xf9400f36,0xf9401337,0xf9401738,0xf9401b3e,0xf9401f39 +.inst 0xd2800011,0x910003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0x910103ff,0xd65f03c0 +.p2align 6", + vg_aes_ofb = sym super::aes_ofb::vg_aes_ofb, + vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/blowfish_ofb.rs b/crates/verified-garbage-asm-aarch64/src/blowfish_ofb.rs index f2d30d04b55..4c13ab0fff5 100644 --- a/crates/verified-garbage-asm-aarch64/src/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/blowfish_ofb.rs @@ -147,3 +147,156 @@ b 21f .p2align 6", ) } + +/// Blowfish-OFB encryption or decryption (NIST SP 800-38A §6.4, Schneier, FSE 1994) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Blowfish encryption under the schedule written by `vg_blowfish_expand_key`. +/// +/// Contract: `VG.Spec.Blowfish.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 4168 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 224 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_blowfish_ofb_final(schedule: *const [u8; 4168], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd10383ff,0x910003e4,0x91000085,0xf90040b3,0xf90044b4,0xf90048b5,0xf9004cb6,0xf90050b7 +.inst 0xf90054b8,0xf90058b9,0xf9005cba,0xf90060bb,0xf90064bc,0x91000039,0x91000057,0x91000078 +.inst 0xf9400326,0xf90000a6 +cbz x24, 20f +22: +.inst 0x4e083d08,0x4e083d29,0x4e083d4a,0x4e083d6b,0x4e083d8c,0x4e083dad,0x4e083dce,0x4e083def +.inst 0x910000b0,0x910000a4,0xd2800806,0x4e010cc2,0xd2801006,0x4e010cc3,0x3dc00094,0x3dc00495 +.inst 0x6e200a94,0x6e200ab5,0x4e951a84,0x4e955a88,0x3dc00894,0x3dc00c95,0x6e200a94,0x6e200ab5 +.inst 0x4e951a85,0x4e955a89,0x3dc01094,0x3dc01495,0x6e200a94,0x6e200ab5,0x4e951a86,0x4e955a8a +.inst 0x3dc01894,0x3dc01c95,0x6e200a94,0x6e200ab5,0x4e951a87,0x4e955a8b,0x91000005,0xd2800107 +23: +.inst 0xb95000a6,0x4e040cc0,0x6e201c84,0x6e201ca5,0x6e201cc6,0x6e201ce7,0x4e051880,0x4e055881 +.inst 0x4e0718d4,0x4e0758d5,0x4e141813,0x4e145811,0x4e151832,0x4e155830,0x6e221e18,0x6e231e19 +.inst 0x6e231f1a,0x3dc0001c,0x3dc0041d,0x3dc0081e,0x3dc00c1f,0x4e106394,0x3dc0101c,0x3dc0141d +.inst 0x3dc0181e,0x3dc01c1f,0x4e187394,0x3dc0201c,0x3dc0241d,0x3dc0281e,0x3dc02c1f,0x4e197394 +.inst 0x3dc0301c,0x3dc0341d,0x3dc0381e,0x3dc03c1f,0x4e1a7394,0x3dc0401c,0x3dc0441d,0x3dc0481e +.inst 0x3dc04c1f,0x4e106395,0x3dc0501c,0x3dc0541d,0x3dc0581e,0x3dc05c1f,0x4e187395,0x3dc0601c +.inst 0x3dc0641d,0x3dc0681e,0x3dc06c1f,0x4e197395,0x3dc0701c,0x3dc0741d,0x3dc0781e,0x3dc07c1f +.inst 0x4e1a7395,0x3dc0801c,0x3dc0841d,0x3dc0881e,0x3dc08c1f,0x4e106396,0x3dc0901c,0x3dc0941d +.inst 0x3dc0981e,0x3dc09c1f,0x4e187396,0x3dc0a01c,0x3dc0a41d,0x3dc0a81e,0x3dc0ac1f,0x4e197396 +.inst 0x3dc0b01c,0x3dc0b41d,0x3dc0b81e,0x3dc0bc1f,0x4e1a7396,0x3dc0c01c,0x3dc0c41d,0x3dc0c81e +.inst 0x3dc0cc1f,0x4e106397,0x3dc0d01c,0x3dc0d41d,0x3dc0d81e,0x3dc0dc1f,0x4e187397,0x3dc0e01c +.inst 0x3dc0e41d,0x3dc0e81e,0x3dc0ec1f,0x4e197397,0x3dc0f01c,0x3dc0f41d,0x3dc0f81e,0x3dc0fc1f +.inst 0x4e1a7397,0x4e163a80,0x4e167a81,0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820 +.inst 0x4e167821,0x4eb51eac,0x4eb71eed,0x4ea01c0e,0x4ea11c2f,0x6e221e38,0x6e231e39,0x6e231f1a +.inst 0x3dc1001c,0x3dc1041d,0x3dc1081e,0x3dc10c1f,0x4e116394,0x3dc1101c,0x3dc1141d,0x3dc1181e +.inst 0x3dc11c1f,0x4e187394,0x3dc1201c,0x3dc1241d,0x3dc1281e,0x3dc12c1f,0x4e197394,0x3dc1301c +.inst 0x3dc1341d,0x3dc1381e,0x3dc13c1f,0x4e1a7394,0x3dc1401c,0x3dc1441d,0x3dc1481e,0x3dc14c1f +.inst 0x4e116395,0x3dc1501c,0x3dc1541d,0x3dc1581e,0x3dc15c1f,0x4e187395,0x3dc1601c,0x3dc1641d +.inst 0x3dc1681e,0x3dc16c1f,0x4e197395,0x3dc1701c,0x3dc1741d,0x3dc1781e,0x3dc17c1f,0x4e1a7395 +.inst 0x3dc1801c,0x3dc1841d,0x3dc1881e,0x3dc18c1f,0x4e116396,0x3dc1901c,0x3dc1941d,0x3dc1981e +.inst 0x3dc19c1f,0x4e187396,0x3dc1a01c,0x3dc1a41d,0x3dc1a81e,0x3dc1ac1f,0x4e197396,0x3dc1b01c +.inst 0x3dc1b41d,0x3dc1b81e,0x3dc1bc1f,0x4e1a7396,0x3dc1c01c,0x3dc1c41d,0x3dc1c81e,0x3dc1cc1f +.inst 0x4e116397,0x3dc1d01c,0x3dc1d41d,0x3dc1d81e,0x3dc1dc1f,0x4e187397,0x3dc1e01c,0x3dc1e41d +.inst 0x3dc1e81e,0x3dc1ec1f,0x4e197397,0x3dc1f01c,0x3dc1f41d,0x3dc1f81e,0x3dc1fc1f,0x4e1a7397 +.inst 0x4e163a80,0x4e167a81,0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821 +.inst 0x4eb5858c,0x4eb785ad,0x4ea085ce,0x4ea185ef,0x6e221e58,0x6e231e59,0x6e231f1a,0x3dc2001c +.inst 0x3dc2041d,0x3dc2081e,0x3dc20c1f,0x4e126394,0x3dc2101c,0x3dc2141d,0x3dc2181e,0x3dc21c1f +.inst 0x4e187394,0x3dc2201c,0x3dc2241d,0x3dc2281e,0x3dc22c1f,0x4e197394,0x3dc2301c,0x3dc2341d +.inst 0x3dc2381e,0x3dc23c1f,0x4e1a7394,0x3dc2401c,0x3dc2441d,0x3dc2481e,0x3dc24c1f,0x4e126395 +.inst 0x3dc2501c,0x3dc2541d,0x3dc2581e,0x3dc25c1f,0x4e187395,0x3dc2601c,0x3dc2641d,0x3dc2681e +.inst 0x3dc26c1f,0x4e197395,0x3dc2701c,0x3dc2741d,0x3dc2781e,0x3dc27c1f,0x4e1a7395,0x3dc2801c +.inst 0x3dc2841d,0x3dc2881e,0x3dc28c1f,0x4e126396,0x3dc2901c,0x3dc2941d,0x3dc2981e,0x3dc29c1f +.inst 0x4e187396,0x3dc2a01c,0x3dc2a41d,0x3dc2a81e,0x3dc2ac1f,0x4e197396,0x3dc2b01c,0x3dc2b41d +.inst 0x3dc2b81e,0x3dc2bc1f,0x4e1a7396,0x3dc2c01c,0x3dc2c41d,0x3dc2c81e,0x3dc2cc1f,0x4e126397 +.inst 0x3dc2d01c,0x3dc2d41d,0x3dc2d81e,0x3dc2dc1f,0x4e187397,0x3dc2e01c,0x3dc2e41d,0x3dc2e81e +.inst 0x3dc2ec1f,0x4e197397,0x3dc2f01c,0x3dc2f41d,0x3dc2f81e,0x3dc2fc1f,0x4e1a7397,0x4e163a80 +.inst 0x4e167a81,0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821,0x6e351d8c +.inst 0x6e371dad,0x6e201dce,0x6e211def,0x6e221e78,0x6e231e79,0x6e231f1a,0x3dc3001c,0x3dc3041d +.inst 0x3dc3081e,0x3dc30c1f,0x4e136394,0x3dc3101c,0x3dc3141d,0x3dc3181e,0x3dc31c1f,0x4e187394 +.inst 0x3dc3201c,0x3dc3241d,0x3dc3281e,0x3dc32c1f,0x4e197394,0x3dc3301c,0x3dc3341d,0x3dc3381e +.inst 0x3dc33c1f,0x4e1a7394,0x3dc3401c,0x3dc3441d,0x3dc3481e,0x3dc34c1f,0x4e136395,0x3dc3501c +.inst 0x3dc3541d,0x3dc3581e,0x3dc35c1f,0x4e187395,0x3dc3601c,0x3dc3641d,0x3dc3681e,0x3dc36c1f +.inst 0x4e197395,0x3dc3701c,0x3dc3741d,0x3dc3781e,0x3dc37c1f,0x4e1a7395,0x3dc3801c,0x3dc3841d +.inst 0x3dc3881e,0x3dc38c1f,0x4e136396,0x3dc3901c,0x3dc3941d,0x3dc3981e,0x3dc39c1f,0x4e187396 +.inst 0x3dc3a01c,0x3dc3a41d,0x3dc3a81e,0x3dc3ac1f,0x4e197396,0x3dc3b01c,0x3dc3b41d,0x3dc3b81e +.inst 0x3dc3bc1f,0x4e1a7396,0x3dc3c01c,0x3dc3c41d,0x3dc3c81e,0x3dc3cc1f,0x4e136397,0x3dc3d01c +.inst 0x3dc3d41d,0x3dc3d81e,0x3dc3dc1f,0x4e187397,0x3dc3e01c,0x3dc3e41d,0x3dc3e81e,0x3dc3ec1f +.inst 0x4e197397,0x3dc3f01c,0x3dc3f41d,0x3dc3f81e,0x3dc3fc1f,0x4e1a7397,0x4e163a80,0x4e167a81 +.inst 0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821,0x4eb5858c,0x4eb785ad +.inst 0x4ea085ce,0x4ea185ef,0x6e2c1d08,0x6e2d1d29,0x6e2e1d4a,0x6e2f1d6b,0x910010a5,0xb95000a6 +.inst 0x4e040cc0,0x6e201d08,0x6e201d29,0x6e201d4a,0x6e201d6b,0x4e091900,0x4e095901,0x4e0b1954 +.inst 0x4e0b5955,0x4e141813,0x4e145811,0x4e151832,0x4e155830,0x6e221e18,0x6e231e19,0x6e231f1a +.inst 0x3dc0001c,0x3dc0041d,0x3dc0081e,0x3dc00c1f,0x4e106394,0x3dc0101c,0x3dc0141d,0x3dc0181e +.inst 0x3dc01c1f,0x4e187394,0x3dc0201c,0x3dc0241d,0x3dc0281e,0x3dc02c1f,0x4e197394,0x3dc0301c +.inst 0x3dc0341d,0x3dc0381e,0x3dc03c1f,0x4e1a7394,0x3dc0401c,0x3dc0441d,0x3dc0481e,0x3dc04c1f +.inst 0x4e106395,0x3dc0501c,0x3dc0541d,0x3dc0581e,0x3dc05c1f,0x4e187395,0x3dc0601c,0x3dc0641d +.inst 0x3dc0681e,0x3dc06c1f,0x4e197395,0x3dc0701c,0x3dc0741d,0x3dc0781e,0x3dc07c1f,0x4e1a7395 +.inst 0x3dc0801c,0x3dc0841d,0x3dc0881e,0x3dc08c1f,0x4e106396,0x3dc0901c,0x3dc0941d,0x3dc0981e +.inst 0x3dc09c1f,0x4e187396,0x3dc0a01c,0x3dc0a41d,0x3dc0a81e,0x3dc0ac1f,0x4e197396,0x3dc0b01c +.inst 0x3dc0b41d,0x3dc0b81e,0x3dc0bc1f,0x4e1a7396,0x3dc0c01c,0x3dc0c41d,0x3dc0c81e,0x3dc0cc1f +.inst 0x4e106397,0x3dc0d01c,0x3dc0d41d,0x3dc0d81e,0x3dc0dc1f,0x4e187397,0x3dc0e01c,0x3dc0e41d +.inst 0x3dc0e81e,0x3dc0ec1f,0x4e197397,0x3dc0f01c,0x3dc0f41d,0x3dc0f81e,0x3dc0fc1f,0x4e1a7397 +.inst 0x4e163a80,0x4e167a81,0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821 +.inst 0x4eb51eac,0x4eb71eed,0x4ea01c0e,0x4ea11c2f,0x6e221e38,0x6e231e39,0x6e231f1a,0x3dc1001c +.inst 0x3dc1041d,0x3dc1081e,0x3dc10c1f,0x4e116394,0x3dc1101c,0x3dc1141d,0x3dc1181e,0x3dc11c1f +.inst 0x4e187394,0x3dc1201c,0x3dc1241d,0x3dc1281e,0x3dc12c1f,0x4e197394,0x3dc1301c,0x3dc1341d +.inst 0x3dc1381e,0x3dc13c1f,0x4e1a7394,0x3dc1401c,0x3dc1441d,0x3dc1481e,0x3dc14c1f,0x4e116395 +.inst 0x3dc1501c,0x3dc1541d,0x3dc1581e,0x3dc15c1f,0x4e187395,0x3dc1601c,0x3dc1641d,0x3dc1681e +.inst 0x3dc16c1f,0x4e197395,0x3dc1701c,0x3dc1741d,0x3dc1781e,0x3dc17c1f,0x4e1a7395,0x3dc1801c +.inst 0x3dc1841d,0x3dc1881e,0x3dc18c1f,0x4e116396,0x3dc1901c,0x3dc1941d,0x3dc1981e,0x3dc19c1f +.inst 0x4e187396,0x3dc1a01c,0x3dc1a41d,0x3dc1a81e,0x3dc1ac1f,0x4e197396,0x3dc1b01c,0x3dc1b41d +.inst 0x3dc1b81e,0x3dc1bc1f,0x4e1a7396,0x3dc1c01c,0x3dc1c41d,0x3dc1c81e,0x3dc1cc1f,0x4e116397 +.inst 0x3dc1d01c,0x3dc1d41d,0x3dc1d81e,0x3dc1dc1f,0x4e187397,0x3dc1e01c,0x3dc1e41d,0x3dc1e81e +.inst 0x3dc1ec1f,0x4e197397,0x3dc1f01c,0x3dc1f41d,0x3dc1f81e,0x3dc1fc1f,0x4e1a7397,0x4e163a80 +.inst 0x4e167a81,0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821,0x4eb5858c +.inst 0x4eb785ad,0x4ea085ce,0x4ea185ef,0x6e221e58,0x6e231e59,0x6e231f1a,0x3dc2001c,0x3dc2041d +.inst 0x3dc2081e,0x3dc20c1f,0x4e126394,0x3dc2101c,0x3dc2141d,0x3dc2181e,0x3dc21c1f,0x4e187394 +.inst 0x3dc2201c,0x3dc2241d,0x3dc2281e,0x3dc22c1f,0x4e197394,0x3dc2301c,0x3dc2341d,0x3dc2381e +.inst 0x3dc23c1f,0x4e1a7394,0x3dc2401c,0x3dc2441d,0x3dc2481e,0x3dc24c1f,0x4e126395,0x3dc2501c +.inst 0x3dc2541d,0x3dc2581e,0x3dc25c1f,0x4e187395,0x3dc2601c,0x3dc2641d,0x3dc2681e,0x3dc26c1f +.inst 0x4e197395,0x3dc2701c,0x3dc2741d,0x3dc2781e,0x3dc27c1f,0x4e1a7395,0x3dc2801c,0x3dc2841d +.inst 0x3dc2881e,0x3dc28c1f,0x4e126396,0x3dc2901c,0x3dc2941d,0x3dc2981e,0x3dc29c1f,0x4e187396 +.inst 0x3dc2a01c,0x3dc2a41d,0x3dc2a81e,0x3dc2ac1f,0x4e197396,0x3dc2b01c,0x3dc2b41d,0x3dc2b81e +.inst 0x3dc2bc1f,0x4e1a7396,0x3dc2c01c,0x3dc2c41d,0x3dc2c81e,0x3dc2cc1f,0x4e126397,0x3dc2d01c +.inst 0x3dc2d41d,0x3dc2d81e,0x3dc2dc1f,0x4e187397,0x3dc2e01c,0x3dc2e41d,0x3dc2e81e,0x3dc2ec1f +.inst 0x4e197397,0x3dc2f01c,0x3dc2f41d,0x3dc2f81e,0x3dc2fc1f,0x4e1a7397,0x4e163a80,0x4e167a81 +.inst 0x4e173ab4,0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821,0x6e351d8c,0x6e371dad +.inst 0x6e201dce,0x6e211def,0x6e221e78,0x6e231e79,0x6e231f1a,0x3dc3001c,0x3dc3041d,0x3dc3081e +.inst 0x3dc30c1f,0x4e136394,0x3dc3101c,0x3dc3141d,0x3dc3181e,0x3dc31c1f,0x4e187394,0x3dc3201c +.inst 0x3dc3241d,0x3dc3281e,0x3dc32c1f,0x4e197394,0x3dc3301c,0x3dc3341d,0x3dc3381e,0x3dc33c1f +.inst 0x4e1a7394,0x3dc3401c,0x3dc3441d,0x3dc3481e,0x3dc34c1f,0x4e136395,0x3dc3501c,0x3dc3541d +.inst 0x3dc3581e,0x3dc35c1f,0x4e187395,0x3dc3601c,0x3dc3641d,0x3dc3681e,0x3dc36c1f,0x4e197395 +.inst 0x3dc3701c,0x3dc3741d,0x3dc3781e,0x3dc37c1f,0x4e1a7395,0x3dc3801c,0x3dc3841d,0x3dc3881e +.inst 0x3dc38c1f,0x4e136396,0x3dc3901c,0x3dc3941d,0x3dc3981e,0x3dc39c1f,0x4e187396,0x3dc3a01c +.inst 0x3dc3a41d,0x3dc3a81e,0x3dc3ac1f,0x4e197396,0x3dc3b01c,0x3dc3b41d,0x3dc3b81e,0x3dc3bc1f +.inst 0x4e1a7396,0x3dc3c01c,0x3dc3c41d,0x3dc3c81e,0x3dc3cc1f,0x4e136397,0x3dc3d01c,0x3dc3d41d +.inst 0x3dc3d81e,0x3dc3dc1f,0x4e187397,0x3dc3e01c,0x3dc3e41d,0x3dc3e81e,0x3dc3ec1f,0x4e197397 +.inst 0x3dc3f01c,0x3dc3f41d,0x3dc3f81e,0x3dc3fc1f,0x4e1a7397,0x4e163a80,0x4e167a81,0x4e173ab4 +.inst 0x4e177ab6,0x4e143815,0x4e147817,0x4e163820,0x4e167821,0x4eb5858c,0x4eb785ad,0x4ea085ce +.inst 0x4ea185ef,0x6e2c1c84,0x6e2d1ca5,0x6e2e1cc6,0x6e2f1ce7,0x910010a5,0xd10004e7 +cbnz x7, 23b +.inst 0xb9504006,0x4e040cc0,0x6e201c84,0x6e201ca5,0x6e201cc6,0x6e201ce7,0xb9504406,0x4e040cc0 +.inst 0x6e201d08,0x6e201d29,0x6e201d4a,0x6e201d6b,0x4e843914,0x4e847915,0x6e200a94,0x6e200ab5 +.inst 0x3d800094,0x3d800495,0x4e853934,0x4e857935,0x6e200a94,0x6e200ab5,0x3d800894,0x3d800c95 +.inst 0x4e863954,0x4e867955,0x6e200a94,0x6e200ab5,0x3d801094,0x3d801495,0x4e873974,0x4e877975 +.inst 0x6e200a94,0x6e200ab5,0x3d801894,0x3d801c95,0x4e080d08,0x4e080d29,0x4e080d4a,0x4e080d6b +.inst 0x4e080d8c,0x4e080dad,0x4e080dce,0x4e080def,0x91000205,0xd343ff08 +cbz x8, 24f +.inst 0xf94002e6,0xf94000a7,0xca0700c6,0xf90002e6,0x910022f7,0xd1002318 +b 25f +24: +.inst 0x910000a9 +26: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 26b +25: +cbnz x24, 22b +b 21f +20: +21: +.inst 0xf94000a6,0xf9000326,0xf94040b3,0xf94044b4,0xf94048b5,0xf9404cb6,0xf94050b7,0xf94054b8 +.inst 0xf94058b9,0xf9405cba,0xf94060bb,0xf94064bc,0xd2800011,0x910003f0,0xa9004611,0xa9014611 +.inst 0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611 +.inst 0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0x910383ff,0xd65f03c0 +.p2align 6", + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/camellia_ctr.rs b/crates/verified-garbage-asm-aarch64/src/camellia_ctr.rs index 048e46e1adb..19f9232cbca 100644 --- a/crates/verified-garbage-asm-aarch64/src/camellia_ctr.rs +++ b/crates/verified-garbage-asm-aarch64/src/camellia_ctr.rs @@ -87,3 +87,40 @@ b 21f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-CTR encryption or decryption (NIST SP 800-38A §6.5, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ctrFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 3424 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ctr_final(schedule: *const [u8; 272], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd10143ff,0x910003e5,0xf90000b3,0xf90004b4,0xf90008b5,0xf9000cb6,0xf90010b7,0xf90014b8 +.inst 0xf90018be,0xf9001cb9,0x91000013,0x91000034,0x91000055,0x910000b9,0xd344fc89,0xd37ced2a +.inst 0x8b0a0076,0xcb0a0097,0x91000124 +bl {vg_camellia_ctr} +cbz x23, 20f +.inst 0xd2800009,0xf9002329,0xf9002729,0x91000260,0x91000281,0x910002a2,0x91010323,0xd2800024 +bl {vg_camellia_ctr} +.inst 0x91010329 +22: +.inst 0x39400126,0x394002c7,0xca0600e7,0x390002c7,0x91000529,0x910006d6,0xd10006f7 +cbnz x23, 22b +b 21f +20: +21: +.inst 0xf9400333,0xf9400734,0xf9400b35,0xf9400f36,0xf9401337,0xf9401738,0xf9401b3e,0xf9401f39 +.inst 0xd2800011,0x910003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0x910143ff +.inst 0xd65f03c0 +.p2align 6", + vg_camellia_ctr = sym super::camellia_ctr::vg_camellia_ctr, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/camellia_ofb.rs b/crates/verified-garbage-asm-aarch64/src/camellia_ofb.rs index 0a81b9cc6c8..9c4cfb4aaf6 100644 --- a/crates/verified-garbage-asm-aarch64/src/camellia_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/camellia_ofb.rs @@ -68,3 +68,78 @@ b 21f vg_camellia_encrypt_prepared = sym super::camellia::vg_camellia_encrypt_prepared::vg_camellia_encrypt_prepared, ) } + +/// Camellia-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 3344 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ofb_final(schedule: *const [u8; 272], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd13443ff,0x910003e5,0x910000a5,0xf90628b3,0xf9062cb4,0xf90630b5,0xf90634b6,0xf90638b7 +.inst 0xf9063cb8,0xf90640b9,0xf90644ba,0xf90648bb,0xf9064cbc,0x91000053,0x91000077,0x91000098 +.inst 0x910003d4,0x910000b6,0x9100003a,0x910000a2,0xd2803443 +bl {vg_camellia_prepare_encrypt_keys} +.inst 0x910002c5,0x9100029e,0xf9400266,0xf90180a6,0xf9400666,0xf90184a6 +cbz x24, 20f +22: +.inst 0x910003d4,0x91000340,0x910000a1,0xd2803442 +bl {vg_camellia_encrypt_prepared} +.inst 0x910002c5,0x9100029e,0xd344ff08 +cbz x8, 23f +.inst 0xf94002e6,0xf94180a7,0xca0700c6,0xf90002e6,0xf94006e6,0xf94184a7,0xca0700c6,0xf90006e6 +.inst 0x910042f7,0xd1004318 +b 24f +23: +.inst 0x910c00a9 +25: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 25b +24: +cbnz x24, 22b +b 21f +20: +21: +.inst 0xf94180a6,0xf9000266,0xf94184a6,0xf9000666,0xf94628b3,0xf9462cb4,0xf94630b5,0xf94634b6 +.inst 0xf94638b7,0xf9463cb8,0xf94640b9,0xf94644ba,0xf94648bb,0xf9464cbc,0xd2800011,0x910003f0 +.inst 0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611 +.inst 0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611 +.inst 0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611 +.inst 0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611 +.inst 0x910803f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611 +.inst 0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611 +.inst 0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611 +.inst 0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611 +.inst 0xa91f4611,0x911003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611 +.inst 0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611 +.inst 0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611 +.inst 0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611 +.inst 0xa91e4611,0xa91f4611,0x911803f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611 +.inst 0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611 +.inst 0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611 +.inst 0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611 +.inst 0xa91d4611,0xa91e4611,0xa91f4611,0x912003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611 +.inst 0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611 +.inst 0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611 +.inst 0xa9144611,0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611 +.inst 0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611,0x912803f0,0xa9004611,0xa9014611,0xa9024611 +.inst 0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611 +.inst 0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611 +.inst 0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611 +.inst 0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611,0x913003f0,0xa9004611,0xa9014611 +.inst 0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611 +.inst 0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0x913443ff +.inst 0xd65f03c0 +.p2align 6", + vg_camellia_prepare_encrypt_keys = sym super::camellia::vg_camellia_prepare_encrypt_keys::vg_camellia_prepare_encrypt_keys, + vg_camellia_encrypt_prepared = sym super::camellia::vg_camellia_encrypt_prepared::vg_camellia_encrypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/cast5_ofb.rs b/crates/verified-garbage-asm-aarch64/src/cast5_ofb.rs index e088c4d39a1..702cb4e0641 100644 --- a/crates/verified-garbage-asm-aarch64/src/cast5_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/cast5_ofb.rs @@ -104,3 +104,113 @@ b 21f VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, ) } + +/// CAST5-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 2144 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is CAST5 encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_cast5_expand_key` writes them. +/// +/// Contract: `VG.Spec.Cast5.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 12 (for a key of up to 10 bytes) or 16 (for a longer one). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 112 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_cast5_ofb_final(schedule: *const [u8; 128], rounds: usize, iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd101c3ff,0x910003e5,0x910000a5,0xf90004b3,0xf90008b4,0xf9000cb5,0xf90010b6,0xf90014b7 +.inst 0xf90018b8,0xf9001cb9,0xf90020ba,0xf90024bb,0xf90028bc,0x91000059,0x91000077,0x91000098 +.inst 0xf9400326,0xf90000a6 +cbz x24, 20f +22: +.inst 0x910000b0,0x910000a2,0xb9400045,0x5ac008a5,0xb9400446,0x5ac008c6,0x9100000c,0xd342fc27 +.inst 0x910004e7,0xd1004028 +23: +.inst 0xb9400189,0x0b060124,0xb940418d,0x5280002e,0x6a0e01bf,0x13847c8f,0x1a8411e4,0x53017dad +.inst 0x5280002e,0x6a0e01bf,0x1384788f,0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384708f +.inst 0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384608f,0x1a8411e4,0x53017dad,0x5280002e +.inst 0x6a0e01bf,0x1384408f,0x1a8411e4,0x53081c8e,0x53187dce,0x4e041dc0,0x53103c8e,0x53187dce +.inst 0x4e0c1dc0,0x53185c8e,0x53187dce,0x4e141dc0,0x53187c8e,0x4e1c1dc0", + concat!("adrp x10, ", vg_sym_page!("{VG_CAST5_S1234}")), + concat!("add x10, x10, ", vg_sym_pageoff!("{VG_CAST5_S1234}")), + r".inst 0xd280080b,0x6f00e401,0x6f00e402,0x6ea38c63,0x6f210463 +24: +.inst 0x6ea28c04,0x3dc00145,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00545,0x4e241ca5 +.inst 0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00945,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04 +.inst 0x3dc00d45,0x4e241ca5,0x4ea51c21,0x4ea38442,0x9101014a,0xd100056b +cbnz x11, 24b +.inst 0x0e1c3c29,0x0e143c2e,0x0e0c3c2f,0x0e043c2a,0x4a0e0124,0x4b0f0084,0x0b0a0084,0x4a050084 +.inst 0x2a0600c5,0x2a040086,0x9100118c,0xb9400189,0x4a060124,0xb940418d,0x5280002e,0x6a0e01bf +.inst 0x13847c8f,0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384788f,0x1a8411e4,0x53017dad +.inst 0x5280002e,0x6a0e01bf,0x1384708f,0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384608f +.inst 0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384408f,0x1a8411e4,0x53081c8e,0x53187dce +.inst 0x4e041dc0,0x53103c8e,0x53187dce,0x4e0c1dc0,0x53185c8e,0x53187dce,0x4e141dc0,0x53187c8e +.inst 0x4e1c1dc0", + concat!("adrp x10, ", vg_sym_page!("{VG_CAST5_S1234}")), + concat!("add x10, x10, ", vg_sym_pageoff!("{VG_CAST5_S1234}")), + r".inst 0xd280080b,0x6f00e401,0x6f00e402,0x6ea38c63,0x6f210463 +25: +.inst 0x6ea28c04,0x3dc00145,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00545,0x4e241ca5 +.inst 0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00945,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04 +.inst 0x3dc00d45,0x4e241ca5,0x4ea51c21,0x4ea38442,0x9101014a,0xd100056b +cbnz x11, 25b +.inst 0x0e1c3c29,0x0e143c2e,0x0e0c3c2f,0x0e043c2a,0x4b0e0124,0x0b0f0084,0x4a0a0084,0x4a050084 +.inst 0x2a0600c5,0x2a040086,0x9100118c,0xb9400189,0x4b060124,0xb940418d,0x5280002e,0x6a0e01bf +.inst 0x13847c8f,0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384788f,0x1a8411e4,0x53017dad +.inst 0x5280002e,0x6a0e01bf,0x1384708f,0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384608f +.inst 0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384408f,0x1a8411e4,0x53081c8e,0x53187dce +.inst 0x4e041dc0,0x53103c8e,0x53187dce,0x4e0c1dc0,0x53185c8e,0x53187dce,0x4e141dc0,0x53187c8e +.inst 0x4e1c1dc0", + concat!("adrp x10, ", vg_sym_page!("{VG_CAST5_S1234}")), + concat!("add x10, x10, ", vg_sym_pageoff!("{VG_CAST5_S1234}")), + r".inst 0xd280080b,0x6f00e401,0x6f00e402,0x6ea38c63,0x6f210463 +26: +.inst 0x6ea28c04,0x3dc00145,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00545,0x4e241ca5 +.inst 0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00945,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04 +.inst 0x3dc00d45,0x4e241ca5,0x4ea51c21,0x4ea38442,0x9101014a,0xd100056b +cbnz x11, 26b +.inst 0x0e1c3c29,0x0e143c2e,0x0e0c3c2f,0x0e043c2a,0x0b0e0124,0x4a0f0084,0x4b0a0084,0x4a050084 +.inst 0x2a0600c5,0x2a040086,0x9100118c,0xd10004e7 +cbnz x7, 23b +cbz x8, 27f +b 28f +27: +.inst 0xb9400189,0x0b060124,0xb940418d,0x5280002e,0x6a0e01bf,0x13847c8f,0x1a8411e4,0x53017dad +.inst 0x5280002e,0x6a0e01bf,0x1384788f,0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384708f +.inst 0x1a8411e4,0x53017dad,0x5280002e,0x6a0e01bf,0x1384608f,0x1a8411e4,0x53017dad,0x5280002e +.inst 0x6a0e01bf,0x1384408f,0x1a8411e4,0x53081c8e,0x53187dce,0x4e041dc0,0x53103c8e,0x53187dce +.inst 0x4e0c1dc0,0x53185c8e,0x53187dce,0x4e141dc0,0x53187c8e,0x4e1c1dc0", + concat!("adrp x10, ", vg_sym_page!("{VG_CAST5_S1234}")), + concat!("add x10, x10, ", vg_sym_pageoff!("{VG_CAST5_S1234}")), + r".inst 0xd280080b,0x6f00e401,0x6f00e402,0x6ea38c63,0x6f210463 +29: +.inst 0x6ea28c04,0x3dc00145,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00545,0x4e241ca5 +.inst 0x4ea51c21,0x4ea38442,0x6ea28c04,0x3dc00945,0x4e241ca5,0x4ea51c21,0x4ea38442,0x6ea28c04 +.inst 0x3dc00d45,0x4e241ca5,0x4ea51c21,0x4ea38442,0x9101014a,0xd100056b +cbnz x11, 29b +.inst 0x0e1c3c29,0x0e143c2e,0x0e0c3c2f,0x0e043c2a,0x4a0e0124,0x4b0f0084,0x0b0a0084,0x4a050084 +.inst 0x2a0600c5,0x2a040086,0x9100118c +28: +.inst 0x5ac008c6,0xb9000046,0x5ac008a5,0xb9000445,0x91002042,0xd1000463,0x91000205,0xd343ff08 +cbz x8, 210f +.inst 0xf94002e6,0xf94000a7,0xca0700c6,0xf90002e6,0x910022f7,0xd1002318 +b 211f +210: +.inst 0x910000a9 +212: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 212b +211: +cbnz x24, 22b +b 21f +20: +21: +.inst 0xf94000a6,0xf9000326,0xf94004b3,0xf94008b4,0xf9400cb5,0xf94010b6,0xf94014b7,0xf94018b8 +.inst 0xf9401cb9,0xf94020ba,0xf94024bb,0xf94028bc,0xd2800011,0x910003f0,0xa9004611,0xa9014611 +.inst 0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xf90033f1,0x9101c3ff,0xd65f03c0 +.p2align 6", + VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/idea_ofb.rs b/crates/verified-garbage-asm-aarch64/src/idea_ofb.rs index acea2cfe5c3..917dec6666e 100644 --- a/crates/verified-garbage-asm-aarch64/src/idea_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/idea_ofb.rs @@ -128,3 +128,137 @@ b 21f .p2align 6", ) } + +/// IDEA-OFB encryption or decryption (NIST SP 800-38A §6.4, Lai 1992 §3.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is IDEA encryption under the encryption subkeys written by `vg_idea_expand_key`. +/// +/// Contract: `VG.Spec.Idea.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 104 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 208 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_idea_ofb_final(schedule: *const [u8; 104], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd10343ff,0x910003e4,0x91000085,0xf90038b3,0xf9003cb4,0xf90040b5,0xf90044b6,0xf90048b7 +.inst 0xf9004cb8,0xf90050b9,0xf90054ba,0xf90058bb,0xf9005cbc,0x91000039,0x91000057,0x91000078 +.inst 0xf9400006,0xf90004a6,0xf9400406,0xf90008a6,0xf9400806,0xf9000ca6,0xf9400c06,0xf90010a6 +.inst 0xf9401006,0xf90014a6,0xf9401406,0xf90018a6,0xf9401806,0xf9001ca6,0xf9401c06,0xf90020a6 +.inst 0xf9402006,0xf90024a6,0xf9402406,0xf90028a6,0xf9402806,0xf9002ca6,0xf9402c06,0xf90030a6 +.inst 0xf9403006,0xf90034a6,0xf9400326,0xf90000a6 +cbz x24, 20f +22: +.inst 0x910000a2,0x910020a0,0x910000a1,0xd29fffef,0x39400023,0xd378dc63,0x39400427,0xaa070063 +.inst 0x39400824,0xd378dc84,0x39400c27,0xaa070084,0x39401025,0xd378dca5,0x39401427,0xaa0700a5 +.inst 0x39401826,0xd378dcc6,0x39401c27,0xaa0700c6,0xb9400008,0xb9400409,0xb940080d,0xd100046b +.inst 0x8a0f016b,0x9100056b,0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b +.inst 0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183,0xd350fd2e,0xd10004cb +.inst 0x8a0f016b,0x9100056b,0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b +.inst 0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e0084 +.inst 0x8a0f0084,0x8b0900a5,0x8a0f00a5,0xca050067,0xd10004eb,0x8a0f016b,0x9100056b,0xd10005ac +.inst 0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c +.inst 0xd370bd6b,0x8b0b018c,0x8a0f0187,0xca06008e,0x8b0701ce,0xd350fdaa,0xd10005cb,0x8a0f016b +.inst 0x9100056b,0xd100054c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c +.inst 0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f018e,0x8b0e00e7,0x8a0f00e7,0xca0e0063 +.inst 0xca0e00a5,0xca070084,0xca0700c6,0x9100008e,0x910000a4,0x910001c5,0xb9400c08,0xb9401009 +.inst 0xb940140d,0xd100046b,0x8a0f016b,0x9100056b,0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b +.inst 0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183 +.inst 0xd350fd2e,0xd10004cb,0x8a0f016b,0x9100056b,0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b +.inst 0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186 +.inst 0xd350fd0e,0x8b0e0084,0x8a0f0084,0x8b0900a5,0x8a0f00a5,0xca050067,0xd10004eb,0x8a0f016b +.inst 0x9100056b,0xd10005ac,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c +.inst 0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0187,0xca06008e,0x8b0701ce,0xd350fdaa +.inst 0xd10005cb,0x8a0f016b,0x9100056b,0xd100054c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c +.inst 0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f018e,0x8b0e00e7 +.inst 0x8a0f00e7,0xca0e0063,0xca0e00a5,0xca070084,0xca0700c6,0x9100008e,0x910000a4,0x910001c5 +.inst 0xb9401808,0xb9401c09,0xb940200d,0xd100046b,0x8a0f016b,0x9100056b,0xd100050c,0x8a0f018c +.inst 0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b +.inst 0x8b0b018c,0x8a0f0183,0xd350fd2e,0xd10004cb,0x8a0f016b,0x9100056b,0xd10005cc,0x8a0f018c +.inst 0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b +.inst 0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e0084,0x8a0f0084,0x8b0900a5,0x8a0f00a5,0xca050067 +.inst 0xd10004eb,0x8a0f016b,0x9100056b,0xd10005ac,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c +.inst 0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0187,0xca06008e +.inst 0x8b0701ce,0xd350fdaa,0xd10005cb,0x8a0f016b,0x9100056b,0xd100054c,0x8a0f018c,0x9100058c +.inst 0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c +.inst 0x8a0f018e,0x8b0e00e7,0x8a0f00e7,0xca0e0063,0xca0e00a5,0xca070084,0xca0700c6,0x9100008e +.inst 0x910000a4,0x910001c5,0xb9402408,0xb9402809,0xb9402c0d,0xd100046b,0x8a0f016b,0x9100056b +.inst 0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b +.inst 0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183,0xd350fd2e,0xd10004cb,0x8a0f016b,0x9100056b +.inst 0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b +.inst 0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e0084,0x8a0f0084,0x8b0900a5 +.inst 0x8a0f00a5,0xca050067,0xd10004eb,0x8a0f016b,0x9100056b,0xd10005ac,0x8a0f018c,0x9100058c +.inst 0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c +.inst 0x8a0f0187,0xca06008e,0x8b0701ce,0xd350fdaa,0xd10005cb,0x8a0f016b,0x9100056b,0xd100054c +.inst 0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c +.inst 0xd370bd6b,0x8b0b018c,0x8a0f018e,0x8b0e00e7,0x8a0f00e7,0xca0e0063,0xca0e00a5,0xca070084 +.inst 0xca0700c6,0x9100008e,0x910000a4,0x910001c5,0xb9403008,0xb9403409,0xb940380d,0xd100046b +.inst 0x8a0f016b,0x9100056b,0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b +.inst 0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183,0xd350fd2e,0xd10004cb +.inst 0x8a0f016b,0x9100056b,0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b +.inst 0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e0084 +.inst 0x8a0f0084,0x8b0900a5,0x8a0f00a5,0xca050067,0xd10004eb,0x8a0f016b,0x9100056b,0xd10005ac +.inst 0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c +.inst 0xd370bd6b,0x8b0b018c,0x8a0f0187,0xca06008e,0x8b0701ce,0xd350fdaa,0xd10005cb,0x8a0f016b +.inst 0x9100056b,0xd100054c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c +.inst 0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f018e,0x8b0e00e7,0x8a0f00e7,0xca0e0063 +.inst 0xca0e00a5,0xca070084,0xca0700c6,0x9100008e,0x910000a4,0x910001c5,0xb9403c08,0xb9404009 +.inst 0xb940440d,0xd100046b,0x8a0f016b,0x9100056b,0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b +.inst 0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183 +.inst 0xd350fd2e,0xd10004cb,0x8a0f016b,0x9100056b,0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b +.inst 0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186 +.inst 0xd350fd0e,0x8b0e0084,0x8a0f0084,0x8b0900a5,0x8a0f00a5,0xca050067,0xd10004eb,0x8a0f016b +.inst 0x9100056b,0xd10005ac,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c +.inst 0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0187,0xca06008e,0x8b0701ce,0xd350fdaa +.inst 0xd10005cb,0x8a0f016b,0x9100056b,0xd100054c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c +.inst 0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f018e,0x8b0e00e7 +.inst 0x8a0f00e7,0xca0e0063,0xca0e00a5,0xca070084,0xca0700c6,0x9100008e,0x910000a4,0x910001c5 +.inst 0xb9404808,0xb9404c09,0xb940500d,0xd100046b,0x8a0f016b,0x9100056b,0xd100050c,0x8a0f018c +.inst 0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b +.inst 0x8b0b018c,0x8a0f0183,0xd350fd2e,0xd10004cb,0x8a0f016b,0x9100056b,0xd10005cc,0x8a0f018c +.inst 0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b +.inst 0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e0084,0x8a0f0084,0x8b0900a5,0x8a0f00a5,0xca050067 +.inst 0xd10004eb,0x8a0f016b,0x9100056b,0xd10005ac,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c +.inst 0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0187,0xca06008e +.inst 0x8b0701ce,0xd350fdaa,0xd10005cb,0x8a0f016b,0x9100056b,0xd100054c,0x8a0f018c,0x9100058c +.inst 0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c +.inst 0x8a0f018e,0x8b0e00e7,0x8a0f00e7,0xca0e0063,0xca0e00a5,0xca070084,0xca0700c6,0x9100008e +.inst 0x910000a4,0x910001c5,0xb9405408,0xb9405809,0xb9405c0d,0xd100046b,0x8a0f016b,0x9100056b +.inst 0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b +.inst 0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183,0xd350fd2e,0xd10004cb,0x8a0f016b,0x9100056b +.inst 0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b +.inst 0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e0084,0x8a0f0084,0x8b0900a5 +.inst 0x8a0f00a5,0xca050067,0xd10004eb,0x8a0f016b,0x9100056b,0xd10005ac,0x8a0f018c,0x9100058c +.inst 0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c,0xd370bd6b,0x8b0b018c +.inst 0x8a0f0187,0xca06008e,0x8b0701ce,0xd350fdaa,0xd10005cb,0x8a0f016b,0x9100056b,0xd100054c +.inst 0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b,0x8b0b018c +.inst 0xd370bd6b,0x8b0b018c,0x8a0f018e,0x8b0e00e7,0x8a0f00e7,0xca0e0063,0xca0e00a5,0xca070084 +.inst 0xca0700c6,0x9100008e,0x910000a4,0x910001c5,0xf9403008,0xd100046b,0x8a0f016b,0x9100056b +.inst 0xd100050c,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b +.inst 0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0183,0xd370fd0e,0xd10004cb,0x8a0f016b,0x9100056b +.inst 0xd10005cc,0x8a0f018c,0x9100058c,0x9b0c7d6b,0x8a0f016c,0xd350fd6b,0xcb0b018c,0xd37ffd8b +.inst 0x8b0b018c,0xd370bd6b,0x8b0b018c,0x8a0f0186,0xd350fd0e,0x8b0e00a5,0x8a0f00a5,0xd360fd0e +.inst 0x8b0e0084,0x8a0f0084,0x39000423,0xd348fc6e,0x3900002e,0x39000c25,0xd348fcae,0x3900082e +.inst 0x39001424,0xd348fc8e,0x3900102e,0x39001c26,0xd348fcce,0x3900182e,0x91000045,0xd343ff08 +cbz x8, 23f +.inst 0xf94002e6,0xf94000a7,0xca0700c6,0xf90002e6,0x910022f7,0xd1002318 +b 24f +23: +.inst 0x910000a9 +25: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 25b +24: +cbnz x24, 22b +b 21f +20: +21: +.inst 0xf94000a6,0xf9000326,0xf94038b3,0xf9403cb4,0xf94040b5,0xf94044b6,0xf94048b7,0xf9404cb8 +.inst 0xf94050b9,0xf94054ba,0xf94058bb,0xf9405cbc,0xd2800011,0x910003f0,0xa9004611,0xa9014611 +.inst 0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611 +.inst 0xa90a4611,0xa90b4611,0xa90c4611,0x910343ff,0xd65f03c0 +.p2align 6", + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/seed_ofb.rs b/crates/verified-garbage-asm-aarch64/src/seed_ofb.rs index f0aa3f81ea8..e6e49bab1c5 100644 --- a/crates/verified-garbage-asm-aarch64/src/seed_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/seed_ofb.rs @@ -53,3 +53,63 @@ b 21f vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, ) } + +/// SEED-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 4269 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SEED encryption under the schedule written by `vg_seed_expand_key`. +/// +/// Contract: `VG.Spec.Seed.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 1456 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_seed_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd116c3ff,0x910003e4,0x91000085,0xf902a8b3,0xf902acb4,0xf902b0b5,0xf902b4b6,0xf902b8b7 +.inst 0xf902bcb8,0xf902c0b9,0xf902c4ba,0xf902c8bb,0xf902ccbc,0x91000039,0x91000057,0x91000078 +.inst 0x4e080f3f,0xf9400006,0xf90268a6,0xf9400406,0xf9026ca6,0xf9400806,0xf90270a6,0xf9400c06 +.inst 0xf90274a6,0xf9401006,0xf90278a6,0xf9401406,0xf9027ca6,0xf9401806,0xf90280a6,0xf9401c06 +.inst 0xf90284a6,0xf9402006,0xf90288a6,0xf9402406,0xf9028ca6,0xf9402806,0xf90290a6,0xf9402c06 +.inst 0xf90294a6,0xf9403006,0xf90298a6,0xf9403406,0xf9029ca6,0xf9403806,0xf902a0a6,0xf9403c06 +.inst 0xf902a4a6,0x4e083ff9,0xf9400326,0xf901e8a6,0xf9400726,0xf901eca6 +cbz x24, 20f +22: +.inst 0x4e080f3f,0x4e080fdc,0x4e080cbb,0x4e080efd,0x4e080f1e,0x911340a0,0x910f40a1,0xd2800202 +.inst 0x910000a3 +bl {vg_seed_encrypt_blocks} +.inst 0x4e083f65,0x4e083f9e,0x4e083fb7,0x4e083fd8,0x4e083ff9,0xd344ff08 +cbz x8, 23f +.inst 0xf94002e6,0xf941e8a7,0xca0700c6,0xf90002e6,0xf94006e6,0xf941eca7,0xca0700c6,0xf90006e6 +.inst 0x910042f7,0xd1004318 +b 24f +23: +.inst 0x910f40a9 +25: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 25b +24: +cbnz x24, 22b +b 21f +20: +21: +.inst 0xf941e8a6,0xf9000326,0xf941eca6,0xf9000726,0xf942a8b3,0xf942acb4,0xf942b0b5,0xf942b4b6 +.inst 0xf942b8b7,0xf942bcb8,0xf942c0b9,0xf942c4ba,0xf942c8bb,0xf942ccbc,0xd2800011,0x910003f0 +.inst 0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611 +.inst 0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611 +.inst 0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611 +.inst 0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611 +.inst 0x910803f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611 +.inst 0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611 +.inst 0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611 +.inst 0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611 +.inst 0xa91f4611,0x911003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611 +.inst 0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611 +.inst 0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611 +.inst 0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0x9116c3ff,0xd65f03c0 +.p2align 6", + vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/sm4_ctr.rs b/crates/verified-garbage-asm-aarch64/src/sm4_ctr.rs index af4cffdae90..1c42a3abb8f 100644 --- a/crates/verified-garbage-asm-aarch64/src/sm4_ctr.rs +++ b/crates/verified-garbage-asm-aarch64/src/sm4_ctr.rs @@ -91,3 +91,39 @@ b 21f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-CTR encryption or decryption (NIST SP 800-38A §6.5, draft-ribose-cfrg-sm4-10 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ctrFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 3344 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ctr_final(schedule: *const [u8; 128], ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd10143ff,0x910003e4,0xf9000093,0xf9000494,0xf9000895,0xf9000c96,0xf9001097,0xf9001498 +.inst 0xf900189e,0xf9001c99,0x91000013,0x91000035,0x91000099,0xd344fc69,0xd37ced2a,0x8b0a0056 +.inst 0xcb0a0077,0x91000123 +bl {vg_sm4_ctr} +cbz x23, 20f +.inst 0xd2800009,0xf9002329,0xf9002729,0x91000260,0x910002a1,0x91010322,0xd2800023 +bl {vg_sm4_ctr} +.inst 0x91010329 +22: +.inst 0x39400126,0x394002c7,0xca0600e7,0x390002c7,0x91000529,0x910006d6,0xd10006f7 +cbnz x23, 22b +b 21f +20: +21: +.inst 0xf9400333,0xf9400734,0xf9400b35,0xf9400f36,0xf9401337,0xf9401738,0xf9401b3e,0xf9401f39 +.inst 0xd2800011,0x910003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0x910143ff +.inst 0xd65f03c0 +.p2align 6", + vg_sm4_ctr = sym super::sm4_ctr::vg_sm4_ctr, + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/sm4_ofb.rs b/crates/verified-garbage-asm-aarch64/src/sm4_ofb.rs index fd0682ed569..da9ab78fe6b 100644 --- a/crates/verified-garbage-asm-aarch64/src/sm4_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/sm4_ofb.rs @@ -172,3 +172,182 @@ b 22f .p2align 6", ) } + +/// SM4-OFB encryption or decryption (NIST SP 800-38A §6.4, GB/T 32907-2016 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 3264 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd13303ff,0x910003e4,0x91000085,0xf90630b3,0xf90634b4,0xf90638b5,0xf9063cb6,0xf90640b7 +.inst 0xf90644b8,0xf90648b9,0xf9064cba,0xf90650bb,0xf90654bc,0x91000033,0x91000057,0x91000078 +.inst 0xd2921ad5,0xf2bfdd35,0xf2dc3995,0xf2f6e7b5,0xf90000b5,0xd296c2d5,0xf2b84295,0xf2df6515 +.inst 0xf2e0a595,0xf90004b5,0xd28ce575,0xf2aed355,0xf2d7c555,0xf2f86095,0xf90008b5,0xd2889555 +.inst 0xf2a4c275,0xf2d0c935,0xf2f320d5,0xf9000cb5,0xd2885395,0xf2be8a15,0xf2ddf235,0xf2ef5315 +.inst 0xf90010b5,0xd28a8675,0xf2a86175,0xf2d9fdb5,0xf2ec5595,0xf90014b5,0xd2967c95,0xf2b52395 +.inst 0xf2c11935,0xf2f2bd15,0xf90018b5,0xd29bf015,0xf2bf5295,0xf2d1eeb5,0xf2f4c7f5,0xf9001cb5 +.inst 0xd280e8f5,0xf2bf94f5,0xf2ce7e75,0xf2f742f5,0xf90020b5,0xd28b3075,0xf2a32795,0xf2d0bcd5 +.inst 0xf2f509f5,0xf90024b5,0xd28d6d15,0xf2b65035,0xf2cc8e35,0xf2f17b55,0xf90028b5,0xd29d7f15 +.inst 0xf2a961f5,0xf2cace15,0xf2e6b3b5,0xf9002cb5,0xd28483d5,0xf2abc1d5,0xf2cb0c75,0xf2f45a35 +.inst 0xf90030b5,0xd28444b5,0xf2a76f95,0xf2c42035,0xf2f0ef15,0xf90034b5,0xd2801a95,0xf2aae8d5 +.inst 0xf2da73f5,0xf2ea44f5,0xf90038b5,0xd286c995,0xf2bce055,0xf2d89415,0xf2f3d915,0xf9003cb5 +.inst 0xd297fd55,0xf2ba5155,0xf2d8e815,0xf2f6a715,0xf90040b5,0xd29ef475,0xf2b9de55,0xf2cc3f35 +.inst 0xf2f422b5,0xf90044b5,0xd295dc15,0xf2b48bb5,0xf2c69375,0xf2eaa355,0xf90048b5,0xd29275b5 +.inst 0xf2a60655,0xf2d19eb5,0xf2fc7635,0xf9004cb5,0xd29ec3b5,0xf2a5dc55,0xf2ccd055,0xf2ec1955 +.inst 0xf90050b5,0xd2853815,0xf2b56475,0xf2ca61b5,0xf2ede9d5,0xf90054b5,0xd29b7ab5,0xf2a8a6f5 +.inst 0xf2dfbbd5,0xf2e5f1d5,0xf90058b5,0xd29fe075,0xf2ae4d55,0xf2cd8db5,0xf2ea2b75,0xf9005cb5 +.inst 0xd28371b5,0xf2b255f5,0xf2dbb775,0xf2eff795,0xf90060b5,0xd29b2235,0xf2a82b95,0xf2c203f5 +.inst 0xf2fb0b55,0xf90064b5,0xd2982155,0xf2b10635,0xf2d9b4b5,0xf2f7af75,0xf90068b5,0xd28e85b5 +.inst 0xf2a25a15,0xf2dcb715,0xf2f61695,0xf9006cb5,0xd28d3135,0xf2a952f5,0xf2d2c195,0xf2efcef5 +.inst 0xf90070b5,0xd2972cb5,0xf2a13e35,0xf2cdd8b5,0xf2f098d5,0xf90074b5,0xd29e0315,0xf2bd8fb5 +.inst 0xf2db8755,0xf2e409b5,0xf90078b5,0xd29dcf35,0xf2a7cbf5,0xf2d97af5,0xf2e90735,0xf9007cb5 +.inst 0x9100000e,0x910400af,0xd2800111 +20: +.inst 0xf94001d5,0xf90001f5,0xf94005d5,0xf90005f5,0x910041ce,0x910041ef,0xd1000631 +cbnz x17, 20b +.inst 0xf9400266,0xf90180a6,0xf9400666,0xf90184a6 +cbz x24, 21f +23: +.inst 0x3dc000b0,0x3dc004b1,0x3dc008b2,0x3dc00cb3,0x3dc010b4,0x3dc014b5,0x3dc018b6,0x3dc01cb7 +.inst 0x3dc020b8,0x3dc024b9,0x3dc028ba,0x3dc02cbb,0x3dc030bc,0x3dc034bd,0x3dc038be,0x3dc03cbf +.inst 0x5280080f,0x4e010de4,0x5280100f,0x4e010de5,0x5280180f,0x4e010de6,0xb94300a6,0x5ac008c6 +.inst 0xb94304a7,0x5ac008e7,0xb94308a8,0x5ac00908,0xb9430ca9,0x5ac00929,0xb94100aa,0x4a07014a +.inst 0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281 +.inst 0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b +.inst 0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94104aa,0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40 +.inst 0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42 +.inst 0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7 +.inst 0xb94108aa,0x4a09014a,0x4a06014a,0x4a07014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03 +.inst 0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a +.inst 0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0108,0xb9410caa,0x4a06014a,0x4a07014a +.inst 0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302 +.inst 0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b +.inst 0x4aca216b,0x4a0b0129,0xb94110aa,0x4a07014a,0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01 +.inst 0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00 +.inst 0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94114aa +.inst 0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200 +.inst 0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b +.inst 0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7,0xb94118aa,0x4a09014a,0x4a06014a,0x4a07014a +.inst 0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383 +.inst 0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b +.inst 0x4a0b0108,0xb9411caa,0x4a06014a,0x4a07014a,0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02 +.inst 0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00 +.inst 0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0129,0xb94120aa,0x4a07014a +.inst 0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281 +.inst 0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b +.inst 0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94124aa,0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40 +.inst 0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42 +.inst 0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7 +.inst 0xb94128aa,0x4a09014a,0x4a06014a,0x4a07014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03 +.inst 0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a +.inst 0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0108,0xb9412caa,0x4a06014a,0x4a07014a +.inst 0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302 +.inst 0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b +.inst 0x4aca216b,0x4a0b0129,0xb94130aa,0x4a07014a,0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01 +.inst 0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00 +.inst 0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94134aa +.inst 0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200 +.inst 0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b +.inst 0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7,0xb94138aa,0x4a09014a,0x4a06014a,0x4a07014a +.inst 0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383 +.inst 0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b +.inst 0x4a0b0108,0xb9413caa,0x4a06014a,0x4a07014a,0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02 +.inst 0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00 +.inst 0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0129,0xb94140aa,0x4a07014a +.inst 0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281 +.inst 0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b +.inst 0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94144aa,0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40 +.inst 0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42 +.inst 0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7 +.inst 0xb94148aa,0x4a09014a,0x4a06014a,0x4a07014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03 +.inst 0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a +.inst 0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0108,0xb9414caa,0x4a06014a,0x4a07014a +.inst 0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302 +.inst 0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b +.inst 0x4aca216b,0x4a0b0129,0xb94150aa,0x4a07014a,0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01 +.inst 0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00 +.inst 0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94154aa +.inst 0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200 +.inst 0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b +.inst 0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7,0xb94158aa,0x4a09014a,0x4a06014a,0x4a07014a +.inst 0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383 +.inst 0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b +.inst 0x4a0b0108,0xb9415caa,0x4a06014a,0x4a07014a,0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02 +.inst 0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00 +.inst 0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0129,0xb94160aa,0x4a07014a +.inst 0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281 +.inst 0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b +.inst 0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94164aa,0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40 +.inst 0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42 +.inst 0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7 +.inst 0xb94168aa,0x4a09014a,0x4a06014a,0x4a07014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03 +.inst 0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a +.inst 0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0108,0xb9416caa,0x4a06014a,0x4a07014a +.inst 0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302 +.inst 0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b +.inst 0x4aca216b,0x4a0b0129,0xb94170aa,0x4a07014a,0x4a08014a,0x4a09014a,0x4e040d40,0x6e241c01 +.inst 0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00 +.inst 0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00c6,0xb94174aa +.inst 0x4a08014a,0x4a09014a,0x4a06014a,0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200 +.inst 0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b +.inst 0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b00e7,0xb94178aa,0x4a09014a,0x4a06014a,0x4a07014a +.inst 0x4e040d40,0x6e241c01,0x6e251c02,0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383 +.inst 0x4ea31c42,0x4ea11c00,0x4ea21c00,0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b +.inst 0x4a0b0108,0xb9417caa,0x4a06014a,0x4a07014a,0x4a08014a,0x4e040d40,0x6e241c01,0x6e251c02 +.inst 0x6e261c03,0x4e006200,0x4e016281,0x4e026302,0x4e036383,0x4ea31c42,0x4ea11c00,0x4ea21c00 +.inst 0x0e043c0a,0x4aca794b,0x4aca596b,0x4aca396b,0x4aca216b,0x4a0b0129,0x5ac00929,0xb90300a9 +.inst 0x5ac00908,0xb90304a8,0x5ac008e7,0xb90308a7,0x5ac008c6,0xb9030ca6,0xd344ff08 +cbz x8, 24f +.inst 0xf94002e6,0xf94180a7,0xca0700c6,0xf90002e6,0xf94006e6,0xf94184a7,0xca0700c6,0xf90006e6 +.inst 0x910042f7,0xd1004318 +b 25f +24: +.inst 0x910c00a9 +26: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 26b +25: +cbnz x24, 23b +b 22f +21: +22: +.inst 0xf94180a6,0xf9000266,0xf94184a6,0xf9000666,0xf94630b3,0xf94634b4,0xf94638b5,0xf9463cb6 +.inst 0xf94640b7,0xf94644b8,0xf94648b9,0xf9464cba,0xf94650bb,0xf94654bc,0xd2800011,0x910003f0 +.inst 0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611 +.inst 0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611 +.inst 0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611 +.inst 0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611 +.inst 0x910803f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611 +.inst 0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611 +.inst 0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611 +.inst 0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611 +.inst 0xa91f4611,0x911003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611 +.inst 0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611 +.inst 0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611 +.inst 0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611 +.inst 0xa91e4611,0xa91f4611,0x911803f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611,0xa9044611 +.inst 0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611 +.inst 0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611,0xa9144611 +.inst 0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611 +.inst 0xa91d4611,0xa91e4611,0xa91f4611,0x912003f0,0xa9004611,0xa9014611,0xa9024611,0xa9034611 +.inst 0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611,0xa90b4611 +.inst 0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611,0xa9134611 +.inst 0xa9144611,0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611,0xa91b4611 +.inst 0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611,0x912803f0,0xa9004611,0xa9014611,0xa9024611 +.inst 0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611,0xa90a4611 +.inst 0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611,0xa9124611 +.inst 0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611,0xa91a4611 +.inst 0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611,0x913003f0,0xa9004611,0xa9014611 +.inst 0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611 +.inst 0xa90a4611,0xa90b4611,0x913303ff,0xd65f03c0 +.p2align 6", + ) +} diff --git a/crates/verified-garbage-asm-aarch64/src/triple_des_ofb.rs b/crates/verified-garbage-asm-aarch64/src/triple_des_ofb.rs index 8dd1b13e23d..e18ab5a35cc 100644 --- a/crates/verified-garbage-asm-aarch64/src/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/triple_des_ofb.rs @@ -55,3 +55,65 @@ b 21f vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, ) } + +/// Triple DES-OFB encryption or decryption (NIST SP 800-38A §6.4, FIPS 46-3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Triple DES encryption under the schedule written by `vg_triple_des_expand_key`. +/// +/// Contract: `VG.Spec.TripleDes.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 384 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 1008 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_triple_des_ofb_final(schedule: *const [u8; 384], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".inst 0xd10fc3ff,0x910003e4,0x91000085,0xf901c4b3,0xf901c8b4,0xf901ccb5,0xf901d0b6,0xf901d4b7 +.inst 0xf901d8b8,0xf901dcb9,0xf901e0ba,0xf901e4bb,0xf901e8bc,0x91000039,0x91000057,0x91000078 +.inst 0xf9400006,0xf90104a6,0xf9400406,0xf90108a6,0xf9400806,0xf9010ca6,0xf9400c06,0xf90110a6 +.inst 0xf9401006,0xf90114a6,0xf9401406,0xf90118a6,0xf9401806,0xf9011ca6,0xf9401c06,0xf90120a6 +.inst 0xf9402006,0xf90124a6,0xf9402406,0xf90128a6,0xf9402806,0xf9012ca6,0xf9402c06,0xf90130a6 +.inst 0xf9403006,0xf90134a6,0xf9403406,0xf90138a6,0xf9403806,0xf9013ca6,0xf9403c06,0xf90140a6 +.inst 0xf9404006,0xf90144a6,0xf9404406,0xf90148a6,0xf9404806,0xf9014ca6,0xf9404c06,0xf90150a6 +.inst 0xf9405006,0xf90154a6,0xf9405406,0xf90158a6,0xf9405806,0xf9015ca6,0xf9405c06,0xf90160a6 +.inst 0xf9406006,0xf90164a6,0xf9406406,0xf90168a6,0xf9406806,0xf9016ca6,0xf9406c06,0xf90170a6 +.inst 0xf9407006,0xf90174a6,0xf9407406,0xf90178a6,0xf9407806,0xf9017ca6,0xf9407c06,0xf90180a6 +.inst 0xf9408006,0xf90184a6,0xf9408406,0xf90188a6,0xf9408806,0xf9018ca6,0xf9408c06,0xf90190a6 +.inst 0xf9409006,0xf90194a6,0xf9409406,0xf90198a6,0xf9409806,0xf9019ca6,0xf9409c06,0xf901a0a6 +.inst 0xf940a006,0xf901a4a6,0xf940a406,0xf901a8a6,0xf940a806,0xf901aca6,0xf940ac06,0xf901b0a6 +.inst 0xf940b006,0xf901b4a6,0xf940b406,0xf901b8a6,0xf940b806,0xf901bca6,0xf940bc06,0xf901c0a6 +.inst 0xf9400326,0xf90100a6 +cbz x24, 20f +22: +.inst 0x910820a0,0x910800a1,0x910000a2,0x910003da +bl {vg_triple_des_encrypt_block} +.inst 0x91000045,0x9100035e,0xd343ff08 +cbz x8, 23f +.inst 0xf94002e6,0xf94100a7,0xca0700c6,0xf90002e6,0x910022f7,0xd1002318 +b 24f +23: +.inst 0x910800a9 +25: +.inst 0x39400126,0x394002e7,0xca0600e7,0x390002e7,0x91000529,0x910006f7,0xd1000718 +cbnz x24, 25b +24: +cbnz x24, 22b +b 21f +20: +21: +.inst 0xf94100a6,0xf9000326,0xf941c4b3,0xf941c8b4,0xf941ccb5,0xf941d0b6,0xf941d4b7,0xf941d8b8 +.inst 0xf941dcb9,0xf941e0ba,0xf941e4bb,0xf941e8bc,0xd2800011,0x910003f0,0xa9004611,0xa9014611 +.inst 0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611,0xa9094611 +.inst 0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611,0xa9114611 +.inst 0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611,0xa9184611,0xa9194611 +.inst 0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xa91e4611,0xa91f4611,0x910803f0,0xa9004611 +.inst 0xa9014611,0xa9024611,0xa9034611,0xa9044611,0xa9054611,0xa9064611,0xa9074611,0xa9084611 +.inst 0xa9094611,0xa90a4611,0xa90b4611,0xa90c4611,0xa90d4611,0xa90e4611,0xa90f4611,0xa9104611 +.inst 0xa9114611,0xa9124611,0xa9134611,0xa9144611,0xa9154611,0xa9164611,0xa9174611,0xa9184611 +.inst 0xa9194611,0xa91a4611,0xa91b4611,0xa91c4611,0xa91d4611,0xf901f3f1,0x910fc3ff,0xd65f03c0 +.p2align 6", + vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, + ) +} diff --git a/crates/verified-garbage-asm-arm/assembly/aes_ctr.s b/crates/verified-garbage-asm-arm/assembly/aes_ctr.s index 83e7ca9aa99..1e827c6cb54 100644 --- a/crates/verified-garbage-asm-arm/assembly/aes_ctr.s +++ b/crates/verified-garbage-asm-arm/assembly/aes_ctr.s @@ -107,3 +107,98 @@ vg_aes_ctr: ldr lr, [r10, #2092] ldr r10, [r10, #2088] bx lr + +vg_aes_ctr_final: + sub sp, sp, #72 + add r12, sp, #0 + str lr, [r12, #12] + ldr lr, [sp, #72] + str lr, [r12, #0] + ldr lr, [sp, #76] + str lr, [r12, #4] + add lr, sp, #16 + str lr, [r12, #8] + ldr lr, [sp, #12] + ldr r12, [sp, #8] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r8, [r12, #16] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + mov r4, r0 + mov r5, r1 + mov r6, r2 + ldr r8, [sp, #0] + ldr r10, [sp, #4] + lsr r12, r8, #4 + and r8, r8, #15 + add r7, r3, r12, lsl #4 + mov lr, r10 + push {r12, lr} + bl {vg_aes_ctr} + ldr r12, [sp], #8 + cmp r8, #0 + beq 20f + ldr r12, [sp, #8] + mov r0, #0 + str r0, [r12, #40] + str r0, [r12, #44] + str r0, [r12, #48] + str r0, [r12, #52] + mov r0, r4 + mov r1, r5 + mov r2, r6 + add r3, r12, #40 + mov r12, #1 + mov lr, r10 + push {r12, lr} + bl {vg_aes_ctr} + ldr r12, [sp], #8 + ldr r12, [sp, #8] + add r0, r12, #40 + mov r6, r7 + mov r7, r8 +22: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 22b + b 21f +20: +21: + ldr r12, [sp, #8] + ldr r4, [r12, #0] + ldr r5, [r12, #4] + ldr r6, [r12, #8] + ldr r7, [r12, #12] + ldr r8, [r12, #16] + ldr r9, [r12, #20] + ldr r10, [r12, #24] + ldr r11, [r12, #28] + ldr lr, [r12, #32] + add r12, sp, #16 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + add sp, sp, #72 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/aes_ofb.s b/crates/verified-garbage-asm-arm/assembly/aes_ofb.s index f5f9e97d11d..4e220331bbf 100644 --- a/crates/verified-garbage-asm-arm/assembly/aes_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/aes_ofb.s @@ -62,3 +62,86 @@ vg_aes_ofb: ldr lr, [r10, #2092] ldr r10, [r10, #2088] bx lr + +vg_aes_ofb_final: + sub sp, sp, #56 + add r12, sp, #0 + str lr, [r12, #12] + ldr lr, [sp, #56] + str lr, [r12, #0] + ldr lr, [sp, #60] + str lr, [r12, #4] + add lr, sp, #16 + str lr, [r12, #8] + ldr lr, [sp, #12] + ldr r12, [sp, #8] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r8, [r12, #16] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + mov r4, r0 + mov r5, r1 + mov r6, r2 + ldr r8, [sp, #0] + ldr r10, [sp, #4] + lsr r12, r8, #4 + and r8, r8, #15 + add r7, r3, r12, lsl #4 + mov lr, r10 + push {r12, lr} + bl {vg_aes_ofb} + ldr r12, [sp], #8 + cmp r8, #0 + beq 20f + mov r0, r4 + mov r1, r5 + mov r2, r6 + mov r3, #1 + mov r12, r10 + push {r12, lr} + bl {vg_aes_encrypt_blocks} + ldr r12, [sp], #8 + mov r0, r6 + mov r6, r7 + mov r7, r8 +22: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 22b + b 21f +20: +21: + ldr r12, [sp, #8] + ldr r4, [r12, #0] + ldr r5, [r12, #4] + ldr r6, [r12, #8] + ldr r7, [r12, #12] + ldr r8, [r12, #16] + ldr r9, [r12, #20] + ldr r10, [r12, #24] + ldr r11, [r12, #28] + ldr lr, [r12, #32] + add r12, sp, #16 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + add sp, sp, #56 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/blowfish_ofb.s b/crates/verified-garbage-asm-arm/assembly/blowfish_ofb.s index 26d89cfdaa7..301c968649f 100644 --- a/crates/verified-garbage-asm-arm/assembly/blowfish_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/blowfish_ofb.s @@ -82,3 +82,98 @@ vg_blowfish_ofb: str r2, [r12, #52] add sp, sp, #64 bx lr + +vg_blowfish_ofb_final: + sub sp, sp, #64 + add r12, sp, #0 + str lr, [r12, #4] + add lr, sp, #8 + str lr, [r12, #0] + ldr lr, [sp, #4] + ldr r12, [sp, #0] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r5, r1 + mov r6, r2 + mov r7, r3 + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + add r1, r8, #40 + mov r2, #1 + bl {vg_blowfish_ecb_encrypt} + lsr r9, r7, #3 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + add r6, r6, #8 + subs r7, r7, #8 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #8 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + add sp, sp, #64 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/camellia_ctr.s b/crates/verified-garbage-asm-arm/assembly/camellia_ctr.s index 213b6227e20..1a99a7449a1 100644 --- a/crates/verified-garbage-asm-arm/assembly/camellia_ctr.s +++ b/crates/verified-garbage-asm-arm/assembly/camellia_ctr.s @@ -138,3 +138,93 @@ vg_camellia_ctr: str r2, [r12, #68] add sp, sp, #88 bx lr + +vg_camellia_ctr_final: + sub sp, sp, #72 + add r12, sp, #0 + str lr, [r12, #8] + ldr lr, [sp, #72] + str lr, [r12, #0] + add lr, sp, #12 + str lr, [r12, #4] + ldr lr, [sp, #8] + ldr r12, [sp, #4] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r8, [r12, #16] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + mov r4, r0 + mov r5, r1 + mov r6, r2 + ldr r8, [sp, #0] + lsr r12, r8, #4 + and r8, r8, #15 + add r7, r3, r12, lsl #4 + push {r12, lr} + bl {vg_camellia_ctr} + ldr r12, [sp], #8 + cmp r8, #0 + beq 20f + ldr r12, [sp, #4] + mov r0, #0 + str r0, [r12, #40] + str r0, [r12, #44] + str r0, [r12, #48] + str r0, [r12, #52] + mov r0, r4 + mov r1, r5 + mov r2, r6 + add r3, r12, #40 + mov r12, #1 + push {r12, lr} + bl {vg_camellia_ctr} + ldr r12, [sp], #8 + ldr r12, [sp, #4] + add r0, r12, #40 + mov r6, r7 + mov r7, r8 +22: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 22b + b 21f +20: +21: + ldr r12, [sp, #4] + ldr r4, [r12, #0] + ldr r5, [r12, #4] + ldr r6, [r12, #8] + ldr r7, [r12, #12] + ldr r8, [r12, #16] + ldr r9, [r12, #20] + ldr r10, [r12, #24] + ldr r11, [r12, #28] + ldr lr, [r12, #32] + add r12, sp, #12 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + add sp, sp, #72 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/camellia_ofb.s b/crates/verified-garbage-asm-arm/assembly/camellia_ofb.s index dba0463dbe1..098bdad745f 100644 --- a/crates/verified-garbage-asm-arm/assembly/camellia_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/camellia_ofb.s @@ -106,3 +106,122 @@ vg_camellia_ofb: str r2, [r12, #68] add sp, sp, #88 bx lr + +vg_camellia_ofb_final: + sub sp, sp, #88 + add r12, sp, #0 + str lr, [r12, #8] + ldr lr, [sp, #88] + str lr, [r12, #0] + add lr, sp, #12 + str lr, [r12, #4] + ldr lr, [sp, #8] + ldr r12, [sp, #4] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r11, r1 + mov r5, r2 + mov r6, r3 + ldr r7, [sp, #0] + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + ldr r9, [r5, #8] + str r9, [r8, #48] + ldr r9, [r5, #12] + str r9, [r8, #52] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + mov r1, r11 + add r2, r8, #40 + mov r3, #1 + bl {vg_camellia_ecb_encrypt} + lsr r9, r7, #4 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + ldr r9, [r6, #8] + ldr r10, [r8, #48] + eor r9, r9, r10 + str r9, [r6, #8] + ldr r9, [r6, #12] + ldr r10, [r8, #52] + eor r9, r9, r10 + str r9, [r6, #12] + add r6, r6, #16 + subs r7, r7, #16 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r9, [r8, #48] + str r9, [r5, #8] + ldr r9, [r8, #52] + str r9, [r5, #12] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #12 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + str r2, [r12, #56] + str r2, [r12, #60] + str r2, [r12, #64] + str r2, [r12, #68] + add sp, sp, #88 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/cast5_ofb.s b/crates/verified-garbage-asm-arm/assembly/cast5_ofb.s index 169ad6494a0..6fcb864a136 100644 --- a/crates/verified-garbage-asm-arm/assembly/cast5_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/cast5_ofb.s @@ -153,3 +153,169 @@ vg_cast5_ofb: str r2, [r12, #308] add sp, sp, #328 bx lr + +vg_cast5_ofb_final: + sub sp, sp, #328 + add r12, sp, #0 + str lr, [r12, #8] + ldr lr, [sp, #328] + str lr, [r12, #0] + add lr, sp, #12 + str lr, [r12, #4] + ldr lr, [sp, #8] + ldr r12, [sp, #4] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r11, r1 + mov r5, r2 + mov r6, r3 + ldr r7, [sp, #0] + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + mov r1, r11 + add r2, r8, #40 + mov r3, #1 + add r12, r8, #56 + push {r12, lr} + bl {vg_cast5_ecb_encrypt} + ldr r12, [sp], #8 + lsr r9, r7, #3 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + add r6, r6, #8 + subs r7, r7, #8 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #12 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + str r2, [r12, #56] + str r2, [r12, #60] + str r2, [r12, #64] + str r2, [r12, #68] + str r2, [r12, #72] + str r2, [r12, #76] + str r2, [r12, #80] + str r2, [r12, #84] + str r2, [r12, #88] + str r2, [r12, #92] + str r2, [r12, #96] + str r2, [r12, #100] + str r2, [r12, #104] + str r2, [r12, #108] + str r2, [r12, #112] + str r2, [r12, #116] + str r2, [r12, #120] + str r2, [r12, #124] + str r2, [r12, #128] + str r2, [r12, #132] + str r2, [r12, #136] + str r2, [r12, #140] + str r2, [r12, #144] + str r2, [r12, #148] + str r2, [r12, #152] + str r2, [r12, #156] + str r2, [r12, #160] + str r2, [r12, #164] + str r2, [r12, #168] + str r2, [r12, #172] + str r2, [r12, #176] + str r2, [r12, #180] + str r2, [r12, #184] + str r2, [r12, #188] + str r2, [r12, #192] + str r2, [r12, #196] + str r2, [r12, #200] + str r2, [r12, #204] + str r2, [r12, #208] + str r2, [r12, #212] + str r2, [r12, #216] + str r2, [r12, #220] + str r2, [r12, #224] + str r2, [r12, #228] + str r2, [r12, #232] + str r2, [r12, #236] + str r2, [r12, #240] + str r2, [r12, #244] + str r2, [r12, #248] + str r2, [r12, #252] + str r2, [r12, #256] + str r2, [r12, #260] + str r2, [r12, #264] + str r2, [r12, #268] + str r2, [r12, #272] + str r2, [r12, #276] + str r2, [r12, #280] + str r2, [r12, #284] + str r2, [r12, #288] + str r2, [r12, #292] + str r2, [r12, #296] + str r2, [r12, #300] + str r2, [r12, #304] + str r2, [r12, #308] + add sp, sp, #328 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/idea_ofb.s b/crates/verified-garbage-asm-arm/assembly/idea_ofb.s index da4ef5b9ccb..40cad808845 100644 --- a/crates/verified-garbage-asm-arm/assembly/idea_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/idea_ofb.s @@ -82,3 +82,98 @@ vg_idea_ofb: str r2, [r12, #52] add sp, sp, #64 bx lr + +vg_idea_ofb_final: + sub sp, sp, #64 + add r12, sp, #0 + str lr, [r12, #4] + add lr, sp, #8 + str lr, [r12, #0] + ldr lr, [sp, #4] + ldr r12, [sp, #0] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r5, r1 + mov r6, r2 + mov r7, r3 + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + add r1, r8, #40 + mov r2, #1 + bl {vg_idea_ecb} + lsr r9, r7, #3 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + add r6, r6, #8 + subs r7, r7, #8 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #8 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + add sp, sp, #64 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/seed_ofb.s b/crates/verified-garbage-asm-arm/assembly/seed_ofb.s index b83eaf31060..9411306a5dd 100644 --- a/crates/verified-garbage-asm-arm/assembly/seed_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/seed_ofb.s @@ -102,3 +102,118 @@ vg_seed_ofb: str r2, [r12, #68] add sp, sp, #80 bx lr + +vg_seed_ofb_final: + sub sp, sp, #80 + add r12, sp, #0 + str lr, [r12, #4] + add lr, sp, #8 + str lr, [r12, #0] + ldr lr, [sp, #4] + ldr r12, [sp, #0] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r5, r1 + mov r6, r2 + mov r7, r3 + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + ldr r9, [r5, #8] + str r9, [r8, #48] + ldr r9, [r5, #12] + str r9, [r8, #52] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + add r1, r8, #40 + mov r2, #1 + bl {vg_seed_ecb_encrypt} + lsr r9, r7, #4 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + ldr r9, [r6, #8] + ldr r10, [r8, #48] + eor r9, r9, r10 + str r9, [r6, #8] + ldr r9, [r6, #12] + ldr r10, [r8, #52] + eor r9, r9, r10 + str r9, [r6, #12] + add r6, r6, #16 + subs r7, r7, #16 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r9, [r8, #48] + str r9, [r5, #8] + ldr r9, [r8, #52] + str r9, [r5, #12] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #8 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + str r2, [r12, #56] + str r2, [r12, #60] + str r2, [r12, #64] + str r2, [r12, #68] + add sp, sp, #80 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/sm4_ctr.s b/crates/verified-garbage-asm-arm/assembly/sm4_ctr.s index df8726a5857..c29f82f6d97 100644 --- a/crates/verified-garbage-asm-arm/assembly/sm4_ctr.s +++ b/crates/verified-garbage-asm-arm/assembly/sm4_ctr.s @@ -2356,3 +2356,84 @@ vg_sm4_ctr: str r2, [r12, #1508] add sp, sp, #1520 bx lr + +vg_sm4_ctr_final: + sub sp, sp, #64 + add r12, sp, #0 + str lr, [r12, #4] + add lr, sp, #8 + str lr, [r12, #0] + ldr lr, [sp, #4] + ldr r12, [sp, #0] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r8, [r12, #16] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + mov r4, r0 + mov r6, r1 + and r8, r3, #15 + lsr r3, r3, #4 + add r7, r2, r3, lsl #4 + bl {vg_sm4_ctr} + cmp r8, #0 + beq 20f + ldr r12, [sp, #0] + mov r0, #0 + str r0, [r12, #40] + str r0, [r12, #44] + str r0, [r12, #48] + str r0, [r12, #52] + mov r0, r4 + mov r1, r6 + add r2, r12, #40 + mov r3, #1 + bl {vg_sm4_ctr} + ldr r12, [sp, #0] + add r0, r12, #40 + mov r6, r7 + mov r7, r8 +22: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 22b + b 21f +20: +21: + ldr r12, [sp, #0] + ldr r4, [r12, #0] + ldr r5, [r12, #4] + ldr r6, [r12, #8] + ldr r7, [r12, #12] + ldr r8, [r12, #16] + ldr r9, [r12, #20] + ldr r10, [r12, #24] + ldr r11, [r12, #28] + ldr lr, [r12, #32] + add r12, sp, #8 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + add sp, sp, #64 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/sm4_ofb.s b/crates/verified-garbage-asm-arm/assembly/sm4_ofb.s index e3b54c7d82e..db11e344e70 100644 --- a/crates/verified-garbage-asm-arm/assembly/sm4_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/sm4_ofb.s @@ -2497,3 +2497,118 @@ vg_sm4_ofb: str r2, [r12, #1508] add sp, sp, #1520 bx lr + +vg_sm4_ofb_final: + sub sp, sp, #80 + add r12, sp, #0 + str lr, [r12, #4] + add lr, sp, #8 + str lr, [r12, #0] + ldr lr, [sp, #4] + ldr r12, [sp, #0] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r5, r1 + mov r6, r2 + mov r7, r3 + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + ldr r9, [r5, #8] + str r9, [r8, #48] + ldr r9, [r5, #12] + str r9, [r8, #52] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + add r1, r8, #40 + mov r2, #1 + bl {vg_sm4_ecb_encrypt} + lsr r9, r7, #4 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + ldr r9, [r6, #8] + ldr r10, [r8, #48] + eor r9, r9, r10 + str r9, [r6, #8] + ldr r9, [r6, #12] + ldr r10, [r8, #52] + eor r9, r9, r10 + str r9, [r6, #12] + add r6, r6, #16 + subs r7, r7, #16 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r9, [r8, #48] + str r9, [r5, #8] + ldr r9, [r8, #52] + str r9, [r5, #12] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #8 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + str r2, [r12, #56] + str r2, [r12, #60] + str r2, [r12, #64] + str r2, [r12, #68] + add sp, sp, #80 + bx lr diff --git a/crates/verified-garbage-asm-arm/assembly/triple_des_ofb.s b/crates/verified-garbage-asm-arm/assembly/triple_des_ofb.s index 229c704d48e..9a65046beec 100644 --- a/crates/verified-garbage-asm-arm/assembly/triple_des_ofb.s +++ b/crates/verified-garbage-asm-arm/assembly/triple_des_ofb.s @@ -82,3 +82,98 @@ vg_triple_des_ofb: str r2, [r12, #52] add sp, sp, #64 bx lr + +vg_triple_des_ofb_final: + sub sp, sp, #64 + add r12, sp, #0 + str lr, [r12, #4] + add lr, sp, #8 + str lr, [r12, #0] + ldr lr, [sp, #4] + ldr r12, [sp, #0] + str r4, [r12, #0] + str r5, [r12, #4] + str r6, [r12, #8] + str r7, [r12, #12] + str r9, [r12, #20] + str r10, [r12, #24] + str r11, [r12, #28] + str lr, [r12, #32] + str r8, [r12, #16] + mov r4, r0 + mov r5, r1 + mov r6, r2 + mov r7, r3 + mov r8, r12 + ldr r9, [r5, #0] + str r9, [r8, #40] + ldr r9, [r5, #4] + str r9, [r8, #44] + cmp r7, #0 + beq 20f +22: + mov r0, r4 + add r1, r8, #40 + mov r2, #1 + bl {vg_triple_des_ecb_encrypt} + lsr r9, r7, #3 + cmp r9, #0 + beq 23f + ldr r9, [r6, #0] + ldr r10, [r8, #40] + eor r9, r9, r10 + str r9, [r6, #0] + ldr r9, [r6, #4] + ldr r10, [r8, #44] + eor r9, r9, r10 + str r9, [r6, #4] + add r6, r6, #8 + subs r7, r7, #8 + b 24f +23: + add r0, r8, #40 +25: + ldrb r9, [r6, #0] + ldrb r10, [r0, #0] + eor r9, r9, r10 + strb r9, [r6, #0] + add r0, r0, #1 + add r6, r6, #1 + subs r7, r7, #1 + bne 25b +24: + bne 22b + b 21f +20: +21: + ldr r9, [r8, #40] + str r9, [r5, #0] + ldr r9, [r8, #44] + str r9, [r5, #4] + ldr r4, [r8, #0] + ldr r5, [r8, #4] + ldr r6, [r8, #8] + ldr r7, [r8, #12] + ldr r9, [r8, #20] + ldr r10, [r8, #24] + ldr r11, [r8, #28] + ldr lr, [r8, #32] + ldr r8, [r8, #16] + add r12, sp, #8 + mov r2, #0 + str r2, [r12, #0] + str r2, [r12, #4] + str r2, [r12, #8] + str r2, [r12, #12] + str r2, [r12, #16] + str r2, [r12, #20] + str r2, [r12, #24] + str r2, [r12, #28] + str r2, [r12, #32] + str r2, [r12, #36] + str r2, [r12, #40] + str r2, [r12, #44] + str r2, [r12, #48] + str r2, [r12, #52] + add sp, sp, #64 + bx lr diff --git a/crates/verified-garbage-asm-arm/src/aes_ctr.rs b/crates/verified-garbage-asm-arm/src/aes_ctr.rs index a4e11a54f99..77f01c16ebe 100644 --- a/crates/verified-garbage-asm-arm/src/aes_ctr.rs +++ b/crates/verified-garbage-asm-arm/src/aes_ctr.rs @@ -125,3 +125,117 @@ bx lr", vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, ) } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the 88 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r"sub sp, sp, #72 +add r12, sp, #0 +str lr, [r12, #12] +ldr lr, [sp, #72] +str lr, [r12, #0] +ldr lr, [sp, #76] +str lr, [r12, #4] +add lr, sp, #16 +str lr, [r12, #8] +ldr lr, [sp, #12] +ldr r12, [sp, #8] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r8, [r12, #16] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +mov r4, r0 +mov r5, r1 +mov r6, r2 +ldr r8, [sp, #0] +ldr r10, [sp, #4] +lsr r12, r8, #4 +and r8, r8, #15 +add r7, r3, r12, lsl #4 +mov lr, r10 +push {{r12, lr}} +bl {vg_aes_ctr} +ldr r12, [sp], #8 +cmp r8, #0 +beq 20f +ldr r12, [sp, #8] +mov r0, #0 +str r0, [r12, #40] +str r0, [r12, #44] +str r0, [r12, #48] +str r0, [r12, #52] +mov r0, r4 +mov r1, r5 +mov r2, r6 +add r3, r12, #40 +mov r12, #1 +mov lr, r10 +push {{r12, lr}} +bl {vg_aes_ctr} +ldr r12, [sp], #8 +ldr r12, [sp, #8] +add r0, r12, #40 +mov r6, r7 +mov r7, r8 +22: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 22b +b 21f +20: +21: +ldr r12, [sp, #8] +ldr r4, [r12, #0] +ldr r5, [r12, #4] +ldr r6, [r12, #8] +ldr r7, [r12, #12] +ldr r8, [r12, #16] +ldr r9, [r12, #20] +ldr r10, [r12, #24] +ldr r11, [r12, #28] +ldr lr, [r12, #32] +add r12, sp, #16 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +add sp, sp, #72 +bx lr", + vg_aes_ctr = sym super::aes_ctr::vg_aes_ctr, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/aes_ofb.rs b/crates/verified-garbage-asm-arm/src/aes_ofb.rs index 3a2abc61d03..4b61380b5c0 100644 --- a/crates/verified-garbage-asm-arm/src/aes_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/aes_ofb.rs @@ -80,3 +80,106 @@ bx lr", vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, ) } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the 72 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r"sub sp, sp, #56 +add r12, sp, #0 +str lr, [r12, #12] +ldr lr, [sp, #56] +str lr, [r12, #0] +ldr lr, [sp, #60] +str lr, [r12, #4] +add lr, sp, #16 +str lr, [r12, #8] +ldr lr, [sp, #12] +ldr r12, [sp, #8] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r8, [r12, #16] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +mov r4, r0 +mov r5, r1 +mov r6, r2 +ldr r8, [sp, #0] +ldr r10, [sp, #4] +lsr r12, r8, #4 +and r8, r8, #15 +add r7, r3, r12, lsl #4 +mov lr, r10 +push {{r12, lr}} +bl {vg_aes_ofb} +ldr r12, [sp], #8 +cmp r8, #0 +beq 20f +mov r0, r4 +mov r1, r5 +mov r2, r6 +mov r3, #1 +mov r12, r10 +push {{r12, lr}} +bl {vg_aes_encrypt_blocks} +ldr r12, [sp], #8 +mov r0, r6 +mov r6, r7 +mov r7, r8 +22: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 22b +b 21f +20: +21: +ldr r12, [sp, #8] +ldr r4, [r12, #0] +ldr r5, [r12, #4] +ldr r6, [r12, #8] +ldr r7, [r12, #12] +ldr r8, [r12, #16] +ldr r9, [r12, #20] +ldr r10, [r12, #24] +ldr r11, [r12, #28] +ldr lr, [r12, #32] +add r12, sp, #16 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +add sp, sp, #56 +bx lr", + vg_aes_ofb = sym super::aes_ofb::vg_aes_ofb, + vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/blowfish_ofb.rs b/crates/verified-garbage-asm-arm/src/blowfish_ofb.rs index d7a98516975..7ae718ddaa7 100644 --- a/crates/verified-garbage-asm-arm/src/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/blowfish_ofb.rs @@ -97,3 +97,114 @@ bx lr", vg_blowfish_ecb_encrypt = sym super::blowfish::vg_blowfish_ecb_encrypt, ) } + +/// Blowfish-OFB encryption or decryption (NIST SP 800-38A §6.4, Schneier, FSE 1994) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Blowfish encryption under the schedule written by `vg_blowfish_expand_key`. +/// +/// Contract: `VG.Spec.Blowfish.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 4168 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 320 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_blowfish_ofb_final(schedule: *const [u8; 4168], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #64 +add r12, sp, #0 +str lr, [r12, #4] +add lr, sp, #8 +str lr, [r12, #0] +ldr lr, [sp, #4] +ldr r12, [sp, #0] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r5, r1 +mov r6, r2 +mov r7, r3 +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +add r1, r8, #40 +mov r2, #1 +bl {vg_blowfish_ecb_encrypt} +lsr r9, r7, #3 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +add r6, r6, #8 +subs r7, r7, #8 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #8 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +add sp, sp, #64 +bx lr", + vg_blowfish_ecb_encrypt = sym super::blowfish::vg_blowfish_ecb_encrypt, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/camellia_ctr.rs b/crates/verified-garbage-asm-arm/src/camellia_ctr.rs index 8cb41cf2f61..41833228669 100644 --- a/crates/verified-garbage-asm-arm/src/camellia_ctr.rs +++ b/crates/verified-garbage-asm-arm/src/camellia_ctr.rs @@ -154,3 +154,110 @@ bx lr", vg_camellia_ecb_encrypt = sym super::camellia::vg_camellia_ecb_encrypt, ) } + +/// Camellia-CTR encryption or decryption (NIST SP 800-38A §6.5, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ctrFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `ctr` and `data` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 2984 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ctr_final(schedule: *const [u8; 272], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #72 +add r12, sp, #0 +str lr, [r12, #8] +ldr lr, [sp, #72] +str lr, [r12, #0] +add lr, sp, #12 +str lr, [r12, #4] +ldr lr, [sp, #8] +ldr r12, [sp, #4] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r8, [r12, #16] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +mov r4, r0 +mov r5, r1 +mov r6, r2 +ldr r8, [sp, #0] +lsr r12, r8, #4 +and r8, r8, #15 +add r7, r3, r12, lsl #4 +push {{r12, lr}} +bl {vg_camellia_ctr} +ldr r12, [sp], #8 +cmp r8, #0 +beq 20f +ldr r12, [sp, #4] +mov r0, #0 +str r0, [r12, #40] +str r0, [r12, #44] +str r0, [r12, #48] +str r0, [r12, #52] +mov r0, r4 +mov r1, r5 +mov r2, r6 +add r3, r12, #40 +mov r12, #1 +push {{r12, lr}} +bl {vg_camellia_ctr} +ldr r12, [sp], #8 +ldr r12, [sp, #4] +add r0, r12, #40 +mov r6, r7 +mov r7, r8 +22: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 22b +b 21f +20: +21: +ldr r12, [sp, #4] +ldr r4, [r12, #0] +ldr r5, [r12, #4] +ldr r6, [r12, #8] +ldr r7, [r12, #12] +ldr r8, [r12, #16] +ldr r9, [r12, #20] +ldr r10, [r12, #24] +ldr r11, [r12, #28] +ldr lr, [r12, #32] +add r12, sp, #12 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +add sp, sp, #72 +bx lr", + vg_camellia_ctr = sym super::camellia_ctr::vg_camellia_ctr, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/camellia_ofb.rs b/crates/verified-garbage-asm-arm/src/camellia_ofb.rs index 9dcfa322bd4..b4b1d48fcb3 100644 --- a/crates/verified-garbage-asm-arm/src/camellia_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/camellia_ofb.rs @@ -122,3 +122,139 @@ bx lr", vg_camellia_ecb_encrypt = sym super::camellia::vg_camellia_ecb_encrypt, ) } + +/// Camellia-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `iv` and `data` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 2904 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ofb_final(schedule: *const [u8; 272], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #88 +add r12, sp, #0 +str lr, [r12, #8] +ldr lr, [sp, #88] +str lr, [r12, #0] +add lr, sp, #12 +str lr, [r12, #4] +ldr lr, [sp, #8] +ldr r12, [sp, #4] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r11, r1 +mov r5, r2 +mov r6, r3 +ldr r7, [sp, #0] +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +ldr r9, [r5, #8] +str r9, [r8, #48] +ldr r9, [r5, #12] +str r9, [r8, #52] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +mov r1, r11 +add r2, r8, #40 +mov r3, #1 +bl {vg_camellia_ecb_encrypt} +lsr r9, r7, #4 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +ldr r9, [r6, #8] +ldr r10, [r8, #48] +eor r9, r9, r10 +str r9, [r6, #8] +ldr r9, [r6, #12] +ldr r10, [r8, #52] +eor r9, r9, r10 +str r9, [r6, #12] +add r6, r6, #16 +subs r7, r7, #16 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r9, [r8, #48] +str r9, [r5, #8] +ldr r9, [r8, #52] +str r9, [r5, #12] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #12 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +str r2, [r12, #56] +str r2, [r12, #60] +str r2, [r12, #64] +str r2, [r12, #68] +add sp, sp, #88 +bx lr", + vg_camellia_ecb_encrypt = sym super::camellia::vg_camellia_ecb_encrypt, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/cast5_ofb.rs b/crates/verified-garbage-asm-arm/src/cast5_ofb.rs index ff0490a898e..dedfb4a2f73 100644 --- a/crates/verified-garbage-asm-arm/src/cast5_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/cast5_ofb.rs @@ -169,3 +169,186 @@ bx lr", vg_cast5_ecb_encrypt = sym super::cast5::vg_cast5_ecb_encrypt, ) } + +/// CAST5-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 2144 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is CAST5 encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_cast5_expand_key` writes them. +/// +/// Contract: `VG.Spec.Cast5.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 12 (for a key of up to 10 bytes) or 16 (for a longer one). +/// * `iv` and `data` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 336 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_cast5_ofb_final(schedule: *const [u8; 128], rounds: usize, iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #328 +add r12, sp, #0 +str lr, [r12, #8] +ldr lr, [sp, #328] +str lr, [r12, #0] +add lr, sp, #12 +str lr, [r12, #4] +ldr lr, [sp, #8] +ldr r12, [sp, #4] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r11, r1 +mov r5, r2 +mov r6, r3 +ldr r7, [sp, #0] +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +mov r1, r11 +add r2, r8, #40 +mov r3, #1 +add r12, r8, #56 +push {{r12, lr}} +bl {vg_cast5_ecb_encrypt} +ldr r12, [sp], #8 +lsr r9, r7, #3 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +add r6, r6, #8 +subs r7, r7, #8 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #12 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +str r2, [r12, #56] +str r2, [r12, #60] +str r2, [r12, #64] +str r2, [r12, #68] +str r2, [r12, #72] +str r2, [r12, #76] +str r2, [r12, #80] +str r2, [r12, #84] +str r2, [r12, #88] +str r2, [r12, #92] +str r2, [r12, #96] +str r2, [r12, #100] +str r2, [r12, #104] +str r2, [r12, #108] +str r2, [r12, #112] +str r2, [r12, #116] +str r2, [r12, #120] +str r2, [r12, #124] +str r2, [r12, #128] +str r2, [r12, #132] +str r2, [r12, #136] +str r2, [r12, #140] +str r2, [r12, #144] +str r2, [r12, #148] +str r2, [r12, #152] +str r2, [r12, #156] +str r2, [r12, #160] +str r2, [r12, #164] +str r2, [r12, #168] +str r2, [r12, #172] +str r2, [r12, #176] +str r2, [r12, #180] +str r2, [r12, #184] +str r2, [r12, #188] +str r2, [r12, #192] +str r2, [r12, #196] +str r2, [r12, #200] +str r2, [r12, #204] +str r2, [r12, #208] +str r2, [r12, #212] +str r2, [r12, #216] +str r2, [r12, #220] +str r2, [r12, #224] +str r2, [r12, #228] +str r2, [r12, #232] +str r2, [r12, #236] +str r2, [r12, #240] +str r2, [r12, #244] +str r2, [r12, #248] +str r2, [r12, #252] +str r2, [r12, #256] +str r2, [r12, #260] +str r2, [r12, #264] +str r2, [r12, #268] +str r2, [r12, #272] +str r2, [r12, #276] +str r2, [r12, #280] +str r2, [r12, #284] +str r2, [r12, #288] +str r2, [r12, #292] +str r2, [r12, #296] +str r2, [r12, #300] +str r2, [r12, #304] +str r2, [r12, #308] +add sp, sp, #328 +bx lr", + vg_cast5_ecb_encrypt = sym super::cast5::vg_cast5_ecb_encrypt, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/idea_ofb.rs b/crates/verified-garbage-asm-arm/src/idea_ofb.rs index b036936c0cc..a4b91d35afe 100644 --- a/crates/verified-garbage-asm-arm/src/idea_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/idea_ofb.rs @@ -97,3 +97,114 @@ bx lr", vg_idea_ecb = sym super::idea::vg_idea_ecb, ) } + +/// IDEA-OFB encryption or decryption (NIST SP 800-38A §6.4, Lai 1992 §3.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is IDEA encryption under the encryption subkeys written by `vg_idea_expand_key`. +/// +/// Contract: `VG.Spec.Idea.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 104 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 96 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_idea_ofb_final(schedule: *const [u8; 104], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #64 +add r12, sp, #0 +str lr, [r12, #4] +add lr, sp, #8 +str lr, [r12, #0] +ldr lr, [sp, #4] +ldr r12, [sp, #0] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r5, r1 +mov r6, r2 +mov r7, r3 +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +add r1, r8, #40 +mov r2, #1 +bl {vg_idea_ecb} +lsr r9, r7, #3 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +add r6, r6, #8 +subs r7, r7, #8 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #8 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +add sp, sp, #64 +bx lr", + vg_idea_ecb = sym super::idea::vg_idea_ecb, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/seed_ofb.rs b/crates/verified-garbage-asm-arm/src/seed_ofb.rs index 32a409e84d4..a4169fe5b88 100644 --- a/crates/verified-garbage-asm-arm/src/seed_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/seed_ofb.rs @@ -117,3 +117,134 @@ bx lr", vg_seed_ecb_encrypt = sym super::seed::vg_seed_ecb_encrypt, ) } + +/// SEED-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 4269 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SEED encryption under the schedule written by `vg_seed_expand_key`. +/// +/// Contract: `VG.Spec.Seed.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 832 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_seed_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #80 +add r12, sp, #0 +str lr, [r12, #4] +add lr, sp, #8 +str lr, [r12, #0] +ldr lr, [sp, #4] +ldr r12, [sp, #0] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r5, r1 +mov r6, r2 +mov r7, r3 +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +ldr r9, [r5, #8] +str r9, [r8, #48] +ldr r9, [r5, #12] +str r9, [r8, #52] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +add r1, r8, #40 +mov r2, #1 +bl {vg_seed_ecb_encrypt} +lsr r9, r7, #4 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +ldr r9, [r6, #8] +ldr r10, [r8, #48] +eor r9, r9, r10 +str r9, [r6, #8] +ldr r9, [r6, #12] +ldr r10, [r8, #52] +eor r9, r9, r10 +str r9, [r6, #12] +add r6, r6, #16 +subs r7, r7, #16 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r9, [r8, #48] +str r9, [r5, #8] +ldr r9, [r8, #52] +str r9, [r5, #12] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #8 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +str r2, [r12, #56] +str r2, [r12, #60] +str r2, [r12, #64] +str r2, [r12, #68] +add sp, sp, #80 +bx lr", + vg_seed_ecb_encrypt = sym super::seed::vg_seed_ecb_encrypt, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/sm4_ctr.rs b/crates/verified-garbage-asm-arm/src/sm4_ctr.rs index c90b3acd36d..ee972f8e5c4 100644 --- a/crates/verified-garbage-asm-arm/src/sm4_ctr.rs +++ b/crates/verified-garbage-asm-arm/src/sm4_ctr.rs @@ -2371,3 +2371,100 @@ bx lr", vg_sm4_prepare_keys = sym super::sm4::vg_sm4_prepare_keys::vg_sm4_prepare_keys, ) } + +/// SM4-CTR encryption or decryption (NIST SP 800-38A §6.5, draft-ribose-cfrg-sm4-10 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ctrFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 1584 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ctr_final(schedule: *const [u8; 128], ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #64 +add r12, sp, #0 +str lr, [r12, #4] +add lr, sp, #8 +str lr, [r12, #0] +ldr lr, [sp, #4] +ldr r12, [sp, #0] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r8, [r12, #16] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +mov r4, r0 +mov r6, r1 +and r8, r3, #15 +lsr r3, r3, #4 +add r7, r2, r3, lsl #4 +bl {vg_sm4_ctr} +cmp r8, #0 +beq 20f +ldr r12, [sp, #0] +mov r0, #0 +str r0, [r12, #40] +str r0, [r12, #44] +str r0, [r12, #48] +str r0, [r12, #52] +mov r0, r4 +mov r1, r6 +add r2, r12, #40 +mov r3, #1 +bl {vg_sm4_ctr} +ldr r12, [sp, #0] +add r0, r12, #40 +mov r6, r7 +mov r7, r8 +22: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 22b +b 21f +20: +21: +ldr r12, [sp, #0] +ldr r4, [r12, #0] +ldr r5, [r12, #4] +ldr r6, [r12, #8] +ldr r7, [r12, #12] +ldr r8, [r12, #16] +ldr r9, [r12, #20] +ldr r10, [r12, #24] +ldr r11, [r12, #28] +ldr lr, [r12, #32] +add r12, sp, #8 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +add sp, sp, #64 +bx lr", + vg_sm4_ctr = sym super::sm4_ctr::vg_sm4_ctr, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/sm4_ofb.rs b/crates/verified-garbage-asm-arm/src/sm4_ofb.rs index 7fe3d2e7de9..fe8856e3e8b 100644 --- a/crates/verified-garbage-asm-arm/src/sm4_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/sm4_ofb.rs @@ -2512,3 +2512,134 @@ bx lr", vg_sm4_prepare_keys = sym super::sm4::vg_sm4_prepare_keys::vg_sm4_prepare_keys, ) } + +/// SM4-OFB encryption or decryption (NIST SP 800-38A §6.4, GB/T 32907-2016 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 1560 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #80 +add r12, sp, #0 +str lr, [r12, #4] +add lr, sp, #8 +str lr, [r12, #0] +ldr lr, [sp, #4] +ldr r12, [sp, #0] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r5, r1 +mov r6, r2 +mov r7, r3 +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +ldr r9, [r5, #8] +str r9, [r8, #48] +ldr r9, [r5, #12] +str r9, [r8, #52] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +add r1, r8, #40 +mov r2, #1 +bl {vg_sm4_ecb_encrypt} +lsr r9, r7, #4 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +ldr r9, [r6, #8] +ldr r10, [r8, #48] +eor r9, r9, r10 +str r9, [r6, #8] +ldr r9, [r6, #12] +ldr r10, [r8, #52] +eor r9, r9, r10 +str r9, [r6, #12] +add r6, r6, #16 +subs r7, r7, #16 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r9, [r8, #48] +str r9, [r5, #8] +ldr r9, [r8, #52] +str r9, [r5, #12] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #8 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +str r2, [r12, #56] +str r2, [r12, #60] +str r2, [r12, #64] +str r2, [r12, #68] +add sp, sp, #80 +bx lr", + vg_sm4_ecb_encrypt = sym super::sm4::vg_sm4_ecb_encrypt, + ) +} diff --git a/crates/verified-garbage-asm-arm/src/triple_des_ofb.rs b/crates/verified-garbage-asm-arm/src/triple_des_ofb.rs index a86e9ab60ed..35b34e1da06 100644 --- a/crates/verified-garbage-asm-arm/src/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/triple_des_ofb.rs @@ -97,3 +97,114 @@ bx lr", vg_triple_des_ecb_encrypt = sym super::triple_des::vg_triple_des_ecb_encrypt, ) } + +/// Triple DES-OFB encryption or decryption (NIST SP 800-38A §6.4, FIPS 46-3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Triple DES encryption under the schedule written by `vg_triple_des_expand_key`. +/// +/// Contract: `VG.Spec.TripleDes.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 384 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 1088 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_triple_des_ofb_final(schedule: *const [u8; 384], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r"sub sp, sp, #64 +add r12, sp, #0 +str lr, [r12, #4] +add lr, sp, #8 +str lr, [r12, #0] +ldr lr, [sp, #4] +ldr r12, [sp, #0] +str r4, [r12, #0] +str r5, [r12, #4] +str r6, [r12, #8] +str r7, [r12, #12] +str r9, [r12, #20] +str r10, [r12, #24] +str r11, [r12, #28] +str lr, [r12, #32] +str r8, [r12, #16] +mov r4, r0 +mov r5, r1 +mov r6, r2 +mov r7, r3 +mov r8, r12 +ldr r9, [r5, #0] +str r9, [r8, #40] +ldr r9, [r5, #4] +str r9, [r8, #44] +cmp r7, #0 +beq 20f +22: +mov r0, r4 +add r1, r8, #40 +mov r2, #1 +bl {vg_triple_des_ecb_encrypt} +lsr r9, r7, #3 +cmp r9, #0 +beq 23f +ldr r9, [r6, #0] +ldr r10, [r8, #40] +eor r9, r9, r10 +str r9, [r6, #0] +ldr r9, [r6, #4] +ldr r10, [r8, #44] +eor r9, r9, r10 +str r9, [r6, #4] +add r6, r6, #8 +subs r7, r7, #8 +b 24f +23: +add r0, r8, #40 +25: +ldrb r9, [r6, #0] +ldrb r10, [r0, #0] +eor r9, r9, r10 +strb r9, [r6, #0] +add r0, r0, #1 +add r6, r6, #1 +subs r7, r7, #1 +bne 25b +24: +bne 22b +b 21f +20: +21: +ldr r9, [r8, #40] +str r9, [r5, #0] +ldr r9, [r8, #44] +str r9, [r5, #4] +ldr r4, [r8, #0] +ldr r5, [r8, #4] +ldr r6, [r8, #8] +ldr r7, [r8, #12] +ldr r9, [r8, #20] +ldr r10, [r8, #24] +ldr r11, [r8, #28] +ldr lr, [r8, #32] +ldr r8, [r8, #16] +add r12, sp, #8 +mov r2, #0 +str r2, [r12, #0] +str r2, [r12, #4] +str r2, [r12, #8] +str r2, [r12, #12] +str r2, [r12, #16] +str r2, [r12, #20] +str r2, [r12, #24] +str r2, [r12, #28] +str r2, [r12, #32] +str r2, [r12, #36] +str r2, [r12, #40] +str r2, [r12, #44] +str r2, [r12, #48] +str r2, [r12, #52] +add sp, sp, #64 +bx lr", + vg_triple_des_ecb_encrypt = sym super::triple_des::vg_triple_des_ecb_encrypt, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/aes_ctr.s b/crates/verified-garbage-asm-powerpc64le/assembly/aes_ctr.s index 70e793d67bf..187dbd118b3 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/aes_ctr.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/aes_ctr.s @@ -80,3 +80,76 @@ vg_aes_ctr: ld %r19, 2104(%r19) mtlr %r0 blr + +vg_aes_ctr_final: + stdu %r1, -112(%r1) + addi %r9, %r1, 32 + mflr %r0 + std %r0, 0(%r9) + std %r14, 8(%r9) + std %r15, 16(%r9) + std %r16, 24(%r9) + std %r19, 32(%r9) + std %r30, 40(%r9) + std %r31, 48(%r9) + std %r20, 56(%r9) + or %r14, %r3, %r3 + or %r15, %r4, %r4 + or %r16, %r5, %r5 + or %r19, %r8, %r8 + or %r20, %r9, %r9 + rldicl %r10, %r7, 60, 4 + rldicr %r11, %r10, 4, 59 + add %r31, %r6, %r11 + subf %r30, %r11, %r7 + or %r7, %r10, %r10 + bl {vg_aes_ctr} + cmpldi %cr0, %r30, 0 + beq %cr0, 20f + li %r9, 0 + std %r9, 64(%r20) + std %r9, 72(%r20) + or %r3, %r14, %r14 + or %r4, %r15, %r15 + or %r5, %r16, %r16 + addi %r6, %r20, 64 + li %r7, 1 + or %r8, %r19, %r19 + bl {vg_aes_ctr} + addi %r8, %r20, 64 +22: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + ld %r0, 0(%r20) + ld %r14, 8(%r20) + ld %r15, 16(%r20) + ld %r16, 24(%r20) + ld %r19, 32(%r20) + ld %r30, 40(%r20) + ld %r31, 48(%r20) + ld %r20, 56(%r20) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + addi %r1, %r1, 112 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/aes_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/aes_ofb.s index 2712c683169..bef5c14cf20 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/aes_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/aes_ofb.s @@ -52,3 +52,70 @@ vg_aes_ofb: ld %r19, 2104(%r19) mtlr %r0 blr + +vg_aes_ofb_final: + stdu %r1, -96(%r1) + addi %r9, %r1, 32 + mflr %r0 + std %r0, 0(%r9) + std %r14, 8(%r9) + std %r15, 16(%r9) + std %r16, 24(%r9) + std %r19, 32(%r9) + std %r30, 40(%r9) + std %r31, 48(%r9) + std %r20, 56(%r9) + or %r14, %r3, %r3 + or %r15, %r4, %r4 + or %r16, %r5, %r5 + or %r19, %r8, %r8 + or %r20, %r9, %r9 + rldicl %r10, %r7, 60, 4 + rldicr %r11, %r10, 4, 59 + add %r31, %r6, %r11 + subf %r30, %r11, %r7 + or %r7, %r10, %r10 + bl {vg_aes_ofb} + cmpldi %cr0, %r30, 0 + beq %cr0, 20f + or %r3, %r14, %r14 + or %r4, %r15, %r15 + or %r5, %r16, %r16 + li %r6, 1 + or %r7, %r19, %r19 + bl {vg_aes_encrypt_blocks} + or %r8, %r16, %r16 +22: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + ld %r0, 0(%r20) + ld %r14, 8(%r20) + ld %r15, 16(%r20) + ld %r16, 24(%r20) + ld %r19, 32(%r20) + ld %r30, 40(%r20) + ld %r31, 48(%r20) + ld %r20, 56(%r20) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + addi %r1, %r1, 96 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/blowfish_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/blowfish_ofb.s index 5d6599e969f..5d997effb5b 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/blowfish_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/blowfish_ofb.s @@ -356,3 +356,377 @@ vg_blowfish_ofb: std %r11, 88(%r12) addi %r1, %r1, 128 blr + +vg_blowfish_ofb_final: + stdu %r1, -128(%r1) + addi %r7, %r1, 32 + mflr %r0 + std %r0, 64(%r7) + std %r29, 40(%r7) + std %r30, 48(%r7) + std %r31, 56(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 72(%r5) + lwz %r8, 4(%r31) + stw %r8, 76(%r5) + or %r31, %r6, %r6 + cmpldi %cr0, %r30, 0 + beq %cr0, 20f +22: + lwz %r8, 72(%r5) + stw %r8, 32(%r5) + lwz %r8, 76(%r5) + stw %r8, 36(%r5) + or %r6, %r5, %r5 + std %r14, 0(%r6) + std %r15, 8(%r6) + std %r16, 16(%r6) + std %r17, 24(%r6) + li %r0, 0 + addi %r16, %r6, 32 + lwbrx %r4, %r16, %r0 + addi %r12, %r16, 4 + lwbrx %r5, %r12, %r0 + addi %r8, %r3, 4096 +23: + lwz %r12, 0(%r8) + xor %r4, %r4, %r12 + rldicr %r9, %r4, 32, 31 + rldicl %r9, %r9, 8, 56 + li %r14, 255 + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 8, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 16, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + li %r10, 0 + or %r15, %r3, %r3 +24: + rldicl %r11, %r9, 62, 2 + addi %r11, %r11, -1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + and %r11, %r11, %r14 + addi %r9, %r9, -4 + lwz %r12, 0(%r15) + and %r12, %r12, %r11 + or %r10, %r10, %r12 + lwz %r12, 256(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 8, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 512(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 16, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 768(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 24, 0, 31 + or %r10, %r10, %r12 + addi %r15, %r15, 4 + subf %r12, %r3, %r15 + addi %r12, %r12, -256 + cmpldi %cr0, %r12, 0 + bne %cr0, 24b + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 24, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 16, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + or %r7, %r10, %r10 + rldicr %r9, %r4, 40, 23 + rldicl %r9, %r9, 8, 56 + li %r14, 255 + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 8, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 16, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + li %r10, 0 + or %r15, %r3, %r3 +25: + rldicl %r11, %r9, 62, 2 + addi %r11, %r11, -1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + and %r11, %r11, %r14 + addi %r9, %r9, -4 + lwz %r12, 1024(%r15) + and %r12, %r12, %r11 + or %r10, %r10, %r12 + lwz %r12, 1280(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 8, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 1536(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 16, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 1792(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 24, 0, 31 + or %r10, %r10, %r12 + addi %r15, %r15, 4 + subf %r12, %r3, %r15 + addi %r12, %r12, -256 + cmpldi %cr0, %r12, 0 + bne %cr0, 25b + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 24, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 16, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + add %r7, %r7, %r10 + rldicr %r9, %r4, 48, 15 + rldicl %r9, %r9, 8, 56 + li %r14, 255 + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 8, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 16, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + li %r10, 0 + or %r15, %r3, %r3 +26: + rldicl %r11, %r9, 62, 2 + addi %r11, %r11, -1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + and %r11, %r11, %r14 + addi %r9, %r9, -4 + lwz %r12, 2048(%r15) + and %r12, %r12, %r11 + or %r10, %r10, %r12 + lwz %r12, 2304(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 8, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 2560(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 16, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 2816(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 24, 0, 31 + or %r10, %r10, %r12 + addi %r15, %r15, 4 + subf %r12, %r3, %r15 + addi %r12, %r12, -256 + cmpldi %cr0, %r12, 0 + bne %cr0, 26b + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 24, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 16, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + xor %r7, %r7, %r10 + rldicr %r9, %r4, 56, 7 + rldicl %r9, %r9, 8, 56 + li %r14, 255 + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 8, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r14, 16, 0, 31 + xor %r12, %r12, %r14 + and %r12, %r12, %r11 + xor %r14, %r14, %r12 + li %r10, 0 + or %r15, %r3, %r3 +27: + rldicl %r11, %r9, 62, 2 + addi %r11, %r11, -1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + and %r11, %r11, %r14 + addi %r9, %r9, -4 + lwz %r12, 3072(%r15) + and %r12, %r12, %r11 + or %r10, %r10, %r12 + lwz %r12, 3328(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 8, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 3584(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 16, 0, 31 + or %r10, %r10, %r12 + lwz %r12, 3840(%r15) + and %r12, %r12, %r11 + rlwinm %r12, %r12, 24, 0, 31 + or %r10, %r10, %r12 + addi %r15, %r15, 4 + subf %r12, %r3, %r15 + addi %r12, %r12, -256 + cmpldi %cr0, %r12, 0 + bne %cr0, 27b + rldicr %r11, %r9, 63, 0 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 24, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + rldicr %r11, %r9, 62, 1 + rldicl %r11, %r11, 1, 63 + subf %r11, %r11, %r0 + rlwinm %r12, %r10, 16, 0, 31 + xor %r12, %r12, %r10 + and %r12, %r12, %r11 + xor %r10, %r10, %r12 + add %r7, %r7, %r10 + xor %r5, %r5, %r7 + or %r12, %r4, %r4 + or %r4, %r5, %r5 + or %r5, %r12, %r12 + addi %r8, %r8, 4 + subf %r12, %r3, %r8 + addi %r12, %r12, -4160 + cmpldi %cr0, %r12, 0 + bne %cr0, 23b + lwz %r12, 0(%r8) + xor %r12, %r4, %r12 + lwz %r4, 4(%r8) + xor %r4, %r4, %r5 + or %r5, %r12, %r12 + stwbrx %r4, %r16, %r0 + addi %r12, %r16, 4 + stwbrx %r5, %r12, %r0 + addi %r16, %r16, 8 + addi %r17, %r17, -1 + or %r5, %r6, %r6 + ld %r14, 0(%r6) + ld %r15, 8(%r6) + ld %r16, 16(%r6) + ld %r17, 24(%r6) + rldicl %r8, %r30, 61, 3 + cmpldi %cr0, %r8, 0 + beq %cr0, 28f + lwz %r8, 32(%r5) + stw %r8, 72(%r5) + lwz %r8, 36(%r5) + stw %r8, 76(%r5) + lwz %r8, 0(%r31) + lwz %r9, 32(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 36(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + addi %r31, %r31, 8 + addi %r30, %r30, -8 + b 29f +28: + lwz %r8, 32(%r5) + stw %r8, 72(%r5) + lwz %r8, 36(%r5) + stw %r8, 76(%r5) + addi %r8, %r5, 32 +210: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 210b +29: + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + or %r31, %r29, %r29 + lwz %r8, 72(%r5) + stw %r8, 0(%r31) + lwz %r8, 76(%r5) + stw %r8, 4(%r31) + ld %r29, 40(%r5) + ld %r30, 48(%r5) + ld %r31, 56(%r5) + ld %r0, 64(%r5) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + std %r11, 80(%r12) + std %r11, 88(%r12) + addi %r1, %r1, 128 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ctr.s b/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ctr.s index 57639de9f0d..c7d4db7ab01 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ctr.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ctr.s @@ -1910,3 +1910,74 @@ vg_camellia_ctr: std %r11, 3368(%r12) addi %r1, %r1, 3408 blr + +vg_camellia_ctr_final: + stdu %r1, -112(%r1) + addi %r8, %r1, 32 + mflr %r0 + std %r0, 0(%r8) + std %r14, 8(%r8) + std %r15, 16(%r8) + std %r16, 24(%r8) + std %r19, 32(%r8) + std %r30, 40(%r8) + std %r31, 48(%r8) + std %r20, 56(%r8) + or %r14, %r3, %r3 + or %r15, %r4, %r4 + or %r16, %r5, %r5 + or %r20, %r8, %r8 + rldicl %r10, %r7, 60, 4 + rldicr %r11, %r10, 4, 59 + add %r31, %r6, %r11 + subf %r30, %r11, %r7 + or %r7, %r10, %r10 + bl {vg_camellia_ctr} + cmpldi %cr0, %r30, 0 + beq %cr0, 20f + li %r9, 0 + std %r9, 64(%r20) + std %r9, 72(%r20) + or %r3, %r14, %r14 + or %r4, %r15, %r15 + or %r5, %r16, %r16 + addi %r6, %r20, 64 + li %r7, 1 + bl {vg_camellia_ctr} + addi %r8, %r20, 64 +22: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + ld %r0, 0(%r20) + ld %r14, 8(%r20) + ld %r15, 16(%r20) + ld %r16, 24(%r20) + ld %r19, 32(%r20) + ld %r30, 40(%r20) + ld %r31, 48(%r20) + ld %r20, 56(%r20) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + addi %r1, %r1, 112 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ofb.s index 8c245b35c3a..d3f37dd182e 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/camellia_ofb.s @@ -1904,3 +1904,1929 @@ vg_camellia_ofb: std %r11, 3368(%r12) addi %r1, %r1, 3408 blr + +vg_camellia_ofb_final: + stdu %r1, -3408(%r1) + addi %r8, %r1, 32 + std %r28, 3360(%r8) + or %r28, %r4, %r4 + or %r4, %r5, %r5 + or %r5, %r6, %r6 + or %r6, %r7, %r7 + or %r7, %r8, %r8 + mflr %r0 + std %r0, 3336(%r7) + std %r29, 3312(%r7) + std %r30, 3320(%r7) + std %r31, 3328(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 3344(%r5) + lwz %r8, 4(%r31) + stw %r8, 3348(%r5) + lwz %r8, 8(%r31) + stw %r8, 3352(%r5) + lwz %r8, 12(%r31) + stw %r8, 3356(%r5) + or %r31, %r6, %r6 + or %r6, %r5, %r5 + or %r4, %r28, %r28 + li %r5, 0 + or %r9, %r29, %r29 + or %r10, %r30, %r30 + or %r11, %r31, %r31 + or %r12, %r3, %r3 + or %r0, %r28, %r28 + or %r8, %r6, %r6 + std %r14, 2944(%r8) + std %r15, 2952(%r8) + std %r16, 2960(%r8) + std %r17, 2968(%r8) + std %r18, 2976(%r8) + std %r19, 2984(%r8) + std %r20, 2992(%r8) + std %r21, 3000(%r8) + std %r22, 3008(%r8) + std %r23, 3016(%r8) + std %r24, 3024(%r8) + std %r25, 3032(%r8) + std %r26, 3040(%r8) + std %r27, 3048(%r8) + std %r28, 3056(%r8) + std %r29, 3064(%r8) + std %r30, 3072(%r8) + std %r31, 3080(%r8) + lis %r22, 255 + ori %r22, %r22, 255 + rldicr %r22, %r22, 32, 31 + oris %r22, %r22, 255 + ori %r22, %r22, 255 + std %r22, 384(%r8) + lis %r22, -256 + ori %r22, %r22, 65280 + rldicr %r22, %r22, 32, 31 + oris %r22, %r22, 65280 + ori %r22, %r22, 65280 + std %r22, 392(%r8) + lis %r22, 255 + ori %r22, %r22, 65280 + rldicr %r22, %r22, 32, 31 + oris %r22, %r22, 0 + ori %r22, %r22, 0 + std %r22, 400(%r8) + lis %r22, 0 + ori %r22, %r22, 0 + rldicr %r22, %r22, 32, 31 + oris %r22, %r22, 255 + ori %r22, %r22, 65280 + std %r22, 408(%r8) + lis %r22, 0 + ori %r22, %r22, 255 + rldicr %r22, %r22, 32, 31 + oris %r22, %r22, 65280 + ori %r22, %r22, 0 + std %r22, 416(%r8) + addi %r22, %r4, -18 + cmpldi %cr0, %r5, 0 + beq %cr0, 20f + cmpldi %cr0, %r22, 0 + beq %cr0, 22f + addi %r7, %r8, 2816 + addi %r3, %r3, 256 + li %r23, 30 + b 23f +22: + addi %r7, %r8, 2304 + addi %r3, %r3, 192 + li %r23, 22 +23: + addi %r4, %r8, 768 + ld %r14, 0(%r3) + or %r15, %r14, %r14 + or %r16, %r14, %r14 + or %r17, %r14, %r14 + or %r18, %r14, %r14 + or %r19, %r14, %r14 + or %r20, %r14, %r14 + or %r21, %r14, %r14 + lis %r24, 0 + ori %r24, %r24, 0 + rldicr %r24, %r24, 32, 31 + oris %r24, %r24, 65535 + ori %r24, %r24, 0 + lis %r25, 0 + ori %r25, %r25, 65280 + rldicr %r25, %r25, 32, 31 + oris %r25, %r25, 0 + ori %r25, %r25, 65280 + lis %r27, 21845 + ori %r27, %r27, 21845 + rldicr %r27, %r27, 32, 31 + oris %r27, %r27, 21845 + ori %r27, %r27, 21845 + lis %r28, 13107 + ori %r28, %r28, 13107 + rldicr %r28, %r28, 32, 31 + oris %r28, %r28, 13107 + ori %r28, %r28, 13107 + lis %r29, 3855 + ori %r29, %r29, 3855 + rldicr %r29, %r29, 32, 31 + oris %r29, %r29, 3855 + ori %r29, %r29, 3855 + rldicl %r22, %r14, 48, 16 + xor %r22, %r22, %r14 + and %r22, %r22, %r24 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 16, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 48, 16 + xor %r22, %r22, %r15 + and %r22, %r22, %r24 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 16, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 48, 16 + xor %r22, %r22, %r16 + and %r22, %r22, %r24 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 16, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 48, 16 + xor %r22, %r22, %r17 + and %r22, %r22, %r24 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 16, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 48, 16 + xor %r22, %r22, %r18 + and %r22, %r22, %r24 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 16, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 48, 16 + xor %r22, %r22, %r19 + and %r22, %r22, %r24 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 16, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 48, 16 + xor %r22, %r22, %r20 + and %r22, %r22, %r24 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 16, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 48, 16 + xor %r22, %r22, %r21 + and %r22, %r22, %r24 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 16, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 56, 8 + xor %r22, %r22, %r14 + and %r22, %r22, %r25 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 8, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 56, 8 + xor %r22, %r22, %r15 + and %r22, %r22, %r25 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 8, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 56, 8 + xor %r22, %r22, %r16 + and %r22, %r22, %r25 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 8, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 56, 8 + xor %r22, %r22, %r17 + and %r22, %r22, %r25 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 8, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 56, 8 + xor %r22, %r22, %r18 + and %r22, %r22, %r25 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 8, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 56, 8 + xor %r22, %r22, %r19 + and %r22, %r22, %r25 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 8, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 56, 8 + xor %r22, %r22, %r20 + and %r22, %r22, %r25 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 8, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 56, 8 + xor %r22, %r22, %r21 + and %r22, %r22, %r25 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 8, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 63, 1 + xor %r22, %r22, %r15 + and %r22, %r22, %r27 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 1, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r16, 63, 1 + xor %r22, %r22, %r17 + and %r22, %r22, %r27 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 1, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r18, 63, 1 + xor %r22, %r22, %r19 + and %r22, %r22, %r27 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 1, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r20, 63, 1 + xor %r22, %r22, %r21 + and %r22, %r22, %r27 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 1, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r14, 62, 2 + xor %r22, %r22, %r16 + and %r22, %r22, %r28 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 2, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 62, 2 + xor %r22, %r22, %r17 + and %r22, %r22, %r28 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 2, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r18, 62, 2 + xor %r22, %r22, %r20 + and %r22, %r22, %r28 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 2, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 62, 2 + xor %r22, %r22, %r21 + and %r22, %r22, %r28 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 2, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r14, 60, 4 + xor %r22, %r22, %r18 + and %r22, %r22, %r29 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 4, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 60, 4 + xor %r22, %r22, %r19 + and %r22, %r22, %r29 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 4, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 60, 4 + xor %r22, %r22, %r20 + and %r22, %r22, %r29 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 4, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 60, 4 + xor %r22, %r22, %r21 + and %r22, %r22, %r29 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 4, 0 + xor %r17, %r17, %r22 + std %r14, 0(%r4) + std %r15, 8(%r4) + std %r16, 16(%r4) + std %r17, 24(%r4) + std %r18, 32(%r4) + std %r19, 40(%r4) + std %r20, 48(%r4) + std %r21, 56(%r4) + addi %r4, %r4, 64 + ld %r14, 8(%r3) + or %r15, %r14, %r14 + or %r16, %r14, %r14 + or %r17, %r14, %r14 + or %r18, %r14, %r14 + or %r19, %r14, %r14 + or %r20, %r14, %r14 + or %r21, %r14, %r14 + lis %r24, 0 + ori %r24, %r24, 0 + rldicr %r24, %r24, 32, 31 + oris %r24, %r24, 65535 + ori %r24, %r24, 0 + lis %r25, 0 + ori %r25, %r25, 65280 + rldicr %r25, %r25, 32, 31 + oris %r25, %r25, 0 + ori %r25, %r25, 65280 + lis %r27, 21845 + ori %r27, %r27, 21845 + rldicr %r27, %r27, 32, 31 + oris %r27, %r27, 21845 + ori %r27, %r27, 21845 + lis %r28, 13107 + ori %r28, %r28, 13107 + rldicr %r28, %r28, 32, 31 + oris %r28, %r28, 13107 + ori %r28, %r28, 13107 + lis %r29, 3855 + ori %r29, %r29, 3855 + rldicr %r29, %r29, 32, 31 + oris %r29, %r29, 3855 + ori %r29, %r29, 3855 + rldicl %r22, %r14, 48, 16 + xor %r22, %r22, %r14 + and %r22, %r22, %r24 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 16, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 48, 16 + xor %r22, %r22, %r15 + and %r22, %r22, %r24 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 16, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 48, 16 + xor %r22, %r22, %r16 + and %r22, %r22, %r24 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 16, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 48, 16 + xor %r22, %r22, %r17 + and %r22, %r22, %r24 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 16, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 48, 16 + xor %r22, %r22, %r18 + and %r22, %r22, %r24 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 16, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 48, 16 + xor %r22, %r22, %r19 + and %r22, %r22, %r24 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 16, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 48, 16 + xor %r22, %r22, %r20 + and %r22, %r22, %r24 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 16, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 48, 16 + xor %r22, %r22, %r21 + and %r22, %r22, %r24 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 16, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 56, 8 + xor %r22, %r22, %r14 + and %r22, %r22, %r25 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 8, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 56, 8 + xor %r22, %r22, %r15 + and %r22, %r22, %r25 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 8, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 56, 8 + xor %r22, %r22, %r16 + and %r22, %r22, %r25 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 8, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 56, 8 + xor %r22, %r22, %r17 + and %r22, %r22, %r25 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 8, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 56, 8 + xor %r22, %r22, %r18 + and %r22, %r22, %r25 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 8, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 56, 8 + xor %r22, %r22, %r19 + and %r22, %r22, %r25 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 8, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 56, 8 + xor %r22, %r22, %r20 + and %r22, %r22, %r25 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 8, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 56, 8 + xor %r22, %r22, %r21 + and %r22, %r22, %r25 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 8, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 63, 1 + xor %r22, %r22, %r15 + and %r22, %r22, %r27 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 1, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r16, 63, 1 + xor %r22, %r22, %r17 + and %r22, %r22, %r27 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 1, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r18, 63, 1 + xor %r22, %r22, %r19 + and %r22, %r22, %r27 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 1, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r20, 63, 1 + xor %r22, %r22, %r21 + and %r22, %r22, %r27 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 1, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r14, 62, 2 + xor %r22, %r22, %r16 + and %r22, %r22, %r28 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 2, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 62, 2 + xor %r22, %r22, %r17 + and %r22, %r22, %r28 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 2, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r18, 62, 2 + xor %r22, %r22, %r20 + and %r22, %r22, %r28 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 2, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 62, 2 + xor %r22, %r22, %r21 + and %r22, %r22, %r28 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 2, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r14, 60, 4 + xor %r22, %r22, %r18 + and %r22, %r22, %r29 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 4, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 60, 4 + xor %r22, %r22, %r19 + and %r22, %r22, %r29 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 4, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 60, 4 + xor %r22, %r22, %r20 + and %r22, %r22, %r29 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 4, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 60, 4 + xor %r22, %r22, %r21 + and %r22, %r22, %r29 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 4, 0 + xor %r17, %r17, %r22 + std %r14, 0(%r4) + std %r15, 8(%r4) + std %r16, 16(%r4) + std %r17, 24(%r4) + std %r18, 32(%r4) + std %r19, 40(%r4) + std %r20, 48(%r4) + std %r21, 56(%r4) + addi %r4, %r4, 64 + addi %r3, %r3, -8 +24: + ld %r14, 0(%r3) + or %r15, %r14, %r14 + or %r16, %r14, %r14 + or %r17, %r14, %r14 + or %r18, %r14, %r14 + or %r19, %r14, %r14 + or %r20, %r14, %r14 + or %r21, %r14, %r14 + lis %r24, 0 + ori %r24, %r24, 0 + rldicr %r24, %r24, 32, 31 + oris %r24, %r24, 65535 + ori %r24, %r24, 0 + lis %r25, 0 + ori %r25, %r25, 65280 + rldicr %r25, %r25, 32, 31 + oris %r25, %r25, 0 + ori %r25, %r25, 65280 + lis %r27, 21845 + ori %r27, %r27, 21845 + rldicr %r27, %r27, 32, 31 + oris %r27, %r27, 21845 + ori %r27, %r27, 21845 + lis %r28, 13107 + ori %r28, %r28, 13107 + rldicr %r28, %r28, 32, 31 + oris %r28, %r28, 13107 + ori %r28, %r28, 13107 + lis %r29, 3855 + ori %r29, %r29, 3855 + rldicr %r29, %r29, 32, 31 + oris %r29, %r29, 3855 + ori %r29, %r29, 3855 + rldicl %r22, %r14, 48, 16 + xor %r22, %r22, %r14 + and %r22, %r22, %r24 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 16, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 48, 16 + xor %r22, %r22, %r15 + and %r22, %r22, %r24 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 16, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 48, 16 + xor %r22, %r22, %r16 + and %r22, %r22, %r24 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 16, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 48, 16 + xor %r22, %r22, %r17 + and %r22, %r22, %r24 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 16, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 48, 16 + xor %r22, %r22, %r18 + and %r22, %r22, %r24 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 16, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 48, 16 + xor %r22, %r22, %r19 + and %r22, %r22, %r24 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 16, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 48, 16 + xor %r22, %r22, %r20 + and %r22, %r22, %r24 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 16, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 48, 16 + xor %r22, %r22, %r21 + and %r22, %r22, %r24 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 16, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 56, 8 + xor %r22, %r22, %r14 + and %r22, %r22, %r25 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 8, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 56, 8 + xor %r22, %r22, %r15 + and %r22, %r22, %r25 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 8, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 56, 8 + xor %r22, %r22, %r16 + and %r22, %r22, %r25 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 8, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 56, 8 + xor %r22, %r22, %r17 + and %r22, %r22, %r25 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 8, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 56, 8 + xor %r22, %r22, %r18 + and %r22, %r22, %r25 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 8, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 56, 8 + xor %r22, %r22, %r19 + and %r22, %r22, %r25 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 8, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 56, 8 + xor %r22, %r22, %r20 + and %r22, %r22, %r25 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 8, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 56, 8 + xor %r22, %r22, %r21 + and %r22, %r22, %r25 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 8, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 63, 1 + xor %r22, %r22, %r15 + and %r22, %r22, %r27 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 1, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r16, 63, 1 + xor %r22, %r22, %r17 + and %r22, %r22, %r27 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 1, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r18, 63, 1 + xor %r22, %r22, %r19 + and %r22, %r22, %r27 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 1, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r20, 63, 1 + xor %r22, %r22, %r21 + and %r22, %r22, %r27 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 1, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r14, 62, 2 + xor %r22, %r22, %r16 + and %r22, %r22, %r28 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 2, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 62, 2 + xor %r22, %r22, %r17 + and %r22, %r22, %r28 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 2, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r18, 62, 2 + xor %r22, %r22, %r20 + and %r22, %r22, %r28 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 2, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 62, 2 + xor %r22, %r22, %r21 + and %r22, %r22, %r28 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 2, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r14, 60, 4 + xor %r22, %r22, %r18 + and %r22, %r22, %r29 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 4, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 60, 4 + xor %r22, %r22, %r19 + and %r22, %r22, %r29 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 4, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 60, 4 + xor %r22, %r22, %r20 + and %r22, %r22, %r29 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 4, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 60, 4 + xor %r22, %r22, %r21 + and %r22, %r22, %r29 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 4, 0 + xor %r17, %r17, %r22 + std %r14, 0(%r4) + std %r15, 8(%r4) + std %r16, 16(%r4) + std %r17, 24(%r4) + std %r18, 32(%r4) + std %r19, 40(%r4) + std %r20, 48(%r4) + std %r21, 56(%r4) + addi %r4, %r4, 64 + addi %r3, %r3, -8 + addi %r23, %r23, -1 + cmpldi %cr0, %r23, 0 + bne %cr0, 24b + addi %r3, %r3, -8 + ld %r14, 0(%r3) + or %r15, %r14, %r14 + or %r16, %r14, %r14 + or %r17, %r14, %r14 + or %r18, %r14, %r14 + or %r19, %r14, %r14 + or %r20, %r14, %r14 + or %r21, %r14, %r14 + lis %r24, 0 + ori %r24, %r24, 0 + rldicr %r24, %r24, 32, 31 + oris %r24, %r24, 65535 + ori %r24, %r24, 0 + lis %r25, 0 + ori %r25, %r25, 65280 + rldicr %r25, %r25, 32, 31 + oris %r25, %r25, 0 + ori %r25, %r25, 65280 + lis %r27, 21845 + ori %r27, %r27, 21845 + rldicr %r27, %r27, 32, 31 + oris %r27, %r27, 21845 + ori %r27, %r27, 21845 + lis %r28, 13107 + ori %r28, %r28, 13107 + rldicr %r28, %r28, 32, 31 + oris %r28, %r28, 13107 + ori %r28, %r28, 13107 + lis %r29, 3855 + ori %r29, %r29, 3855 + rldicr %r29, %r29, 32, 31 + oris %r29, %r29, 3855 + ori %r29, %r29, 3855 + rldicl %r22, %r14, 48, 16 + xor %r22, %r22, %r14 + and %r22, %r22, %r24 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 16, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 48, 16 + xor %r22, %r22, %r15 + and %r22, %r22, %r24 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 16, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 48, 16 + xor %r22, %r22, %r16 + and %r22, %r22, %r24 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 16, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 48, 16 + xor %r22, %r22, %r17 + and %r22, %r22, %r24 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 16, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 48, 16 + xor %r22, %r22, %r18 + and %r22, %r22, %r24 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 16, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 48, 16 + xor %r22, %r22, %r19 + and %r22, %r22, %r24 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 16, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 48, 16 + xor %r22, %r22, %r20 + and %r22, %r22, %r24 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 16, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 48, 16 + xor %r22, %r22, %r21 + and %r22, %r22, %r24 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 16, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 56, 8 + xor %r22, %r22, %r14 + and %r22, %r22, %r25 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 8, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 56, 8 + xor %r22, %r22, %r15 + and %r22, %r22, %r25 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 8, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 56, 8 + xor %r22, %r22, %r16 + and %r22, %r22, %r25 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 8, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 56, 8 + xor %r22, %r22, %r17 + and %r22, %r22, %r25 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 8, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 56, 8 + xor %r22, %r22, %r18 + and %r22, %r22, %r25 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 8, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 56, 8 + xor %r22, %r22, %r19 + and %r22, %r22, %r25 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 8, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 56, 8 + xor %r22, %r22, %r20 + and %r22, %r22, %r25 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 8, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 56, 8 + xor %r22, %r22, %r21 + and %r22, %r22, %r25 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 8, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 63, 1 + xor %r22, %r22, %r15 + and %r22, %r22, %r27 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 1, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r16, 63, 1 + xor %r22, %r22, %r17 + and %r22, %r22, %r27 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 1, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r18, 63, 1 + xor %r22, %r22, %r19 + and %r22, %r22, %r27 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 1, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r20, 63, 1 + xor %r22, %r22, %r21 + and %r22, %r22, %r27 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 1, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r14, 62, 2 + xor %r22, %r22, %r16 + and %r22, %r22, %r28 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 2, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 62, 2 + xor %r22, %r22, %r17 + and %r22, %r22, %r28 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 2, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r18, 62, 2 + xor %r22, %r22, %r20 + and %r22, %r22, %r28 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 2, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 62, 2 + xor %r22, %r22, %r21 + and %r22, %r22, %r28 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 2, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r14, 60, 4 + xor %r22, %r22, %r18 + and %r22, %r22, %r29 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 4, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 60, 4 + xor %r22, %r22, %r19 + and %r22, %r22, %r29 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 4, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 60, 4 + xor %r22, %r22, %r20 + and %r22, %r22, %r29 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 4, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 60, 4 + xor %r22, %r22, %r21 + and %r22, %r22, %r29 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 4, 0 + xor %r17, %r17, %r22 + std %r14, 0(%r4) + std %r15, 8(%r4) + std %r16, 16(%r4) + std %r17, 24(%r4) + std %r18, 32(%r4) + std %r19, 40(%r4) + std %r20, 48(%r4) + std %r21, 56(%r4) + addi %r4, %r4, 64 + ld %r14, 8(%r3) + or %r15, %r14, %r14 + or %r16, %r14, %r14 + or %r17, %r14, %r14 + or %r18, %r14, %r14 + or %r19, %r14, %r14 + or %r20, %r14, %r14 + or %r21, %r14, %r14 + lis %r24, 0 + ori %r24, %r24, 0 + rldicr %r24, %r24, 32, 31 + oris %r24, %r24, 65535 + ori %r24, %r24, 0 + lis %r25, 0 + ori %r25, %r25, 65280 + rldicr %r25, %r25, 32, 31 + oris %r25, %r25, 0 + ori %r25, %r25, 65280 + lis %r27, 21845 + ori %r27, %r27, 21845 + rldicr %r27, %r27, 32, 31 + oris %r27, %r27, 21845 + ori %r27, %r27, 21845 + lis %r28, 13107 + ori %r28, %r28, 13107 + rldicr %r28, %r28, 32, 31 + oris %r28, %r28, 13107 + ori %r28, %r28, 13107 + lis %r29, 3855 + ori %r29, %r29, 3855 + rldicr %r29, %r29, 32, 31 + oris %r29, %r29, 3855 + ori %r29, %r29, 3855 + rldicl %r22, %r14, 48, 16 + xor %r22, %r22, %r14 + and %r22, %r22, %r24 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 16, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 48, 16 + xor %r22, %r22, %r15 + and %r22, %r22, %r24 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 16, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 48, 16 + xor %r22, %r22, %r16 + and %r22, %r22, %r24 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 16, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 48, 16 + xor %r22, %r22, %r17 + and %r22, %r22, %r24 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 16, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 48, 16 + xor %r22, %r22, %r18 + and %r22, %r22, %r24 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 16, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 48, 16 + xor %r22, %r22, %r19 + and %r22, %r22, %r24 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 16, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 48, 16 + xor %r22, %r22, %r20 + and %r22, %r22, %r24 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 16, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 48, 16 + xor %r22, %r22, %r21 + and %r22, %r22, %r24 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 16, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 56, 8 + xor %r22, %r22, %r14 + and %r22, %r22, %r25 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 8, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 56, 8 + xor %r22, %r22, %r15 + and %r22, %r22, %r25 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 8, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 56, 8 + xor %r22, %r22, %r16 + and %r22, %r22, %r25 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 8, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 56, 8 + xor %r22, %r22, %r17 + and %r22, %r22, %r25 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 8, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 56, 8 + xor %r22, %r22, %r18 + and %r22, %r22, %r25 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 8, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 56, 8 + xor %r22, %r22, %r19 + and %r22, %r22, %r25 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 8, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 56, 8 + xor %r22, %r22, %r20 + and %r22, %r22, %r25 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 8, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 56, 8 + xor %r22, %r22, %r21 + and %r22, %r22, %r25 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 8, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 63, 1 + xor %r22, %r22, %r15 + and %r22, %r22, %r27 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 1, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r16, 63, 1 + xor %r22, %r22, %r17 + and %r22, %r22, %r27 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 1, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r18, 63, 1 + xor %r22, %r22, %r19 + and %r22, %r22, %r27 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 1, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r20, 63, 1 + xor %r22, %r22, %r21 + and %r22, %r22, %r27 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 1, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r14, 62, 2 + xor %r22, %r22, %r16 + and %r22, %r22, %r28 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 2, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 62, 2 + xor %r22, %r22, %r17 + and %r22, %r22, %r28 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 2, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r18, 62, 2 + xor %r22, %r22, %r20 + and %r22, %r22, %r28 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 2, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 62, 2 + xor %r22, %r22, %r21 + and %r22, %r22, %r28 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 2, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r14, 60, 4 + xor %r22, %r22, %r18 + and %r22, %r22, %r29 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 4, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 60, 4 + xor %r22, %r22, %r19 + and %r22, %r22, %r29 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 4, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 60, 4 + xor %r22, %r22, %r20 + and %r22, %r22, %r29 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 4, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 60, 4 + xor %r22, %r22, %r21 + and %r22, %r22, %r29 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 4, 0 + xor %r17, %r17, %r22 + std %r14, 0(%r4) + std %r15, 8(%r4) + std %r16, 16(%r4) + std %r17, 24(%r4) + std %r18, 32(%r4) + std %r19, 40(%r4) + std %r20, 48(%r4) + std %r21, 56(%r4) + addi %r4, %r4, 64 + b 21f +20: + cmpldi %cr0, %r22, 0 + beq %cr0, 25f + addi %r7, %r8, 2816 + li %r23, 34 + b 26f +25: + addi %r7, %r8, 2304 + li %r23, 26 +26: + addi %r4, %r8, 768 +27: + ld %r14, 0(%r3) + or %r15, %r14, %r14 + or %r16, %r14, %r14 + or %r17, %r14, %r14 + or %r18, %r14, %r14 + or %r19, %r14, %r14 + or %r20, %r14, %r14 + or %r21, %r14, %r14 + lis %r24, 0 + ori %r24, %r24, 0 + rldicr %r24, %r24, 32, 31 + oris %r24, %r24, 65535 + ori %r24, %r24, 0 + lis %r25, 0 + ori %r25, %r25, 65280 + rldicr %r25, %r25, 32, 31 + oris %r25, %r25, 0 + ori %r25, %r25, 65280 + lis %r27, 21845 + ori %r27, %r27, 21845 + rldicr %r27, %r27, 32, 31 + oris %r27, %r27, 21845 + ori %r27, %r27, 21845 + lis %r28, 13107 + ori %r28, %r28, 13107 + rldicr %r28, %r28, 32, 31 + oris %r28, %r28, 13107 + ori %r28, %r28, 13107 + lis %r29, 3855 + ori %r29, %r29, 3855 + rldicr %r29, %r29, 32, 31 + oris %r29, %r29, 3855 + ori %r29, %r29, 3855 + rldicl %r22, %r14, 48, 16 + xor %r22, %r22, %r14 + and %r22, %r22, %r24 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 16, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 48, 16 + xor %r22, %r22, %r15 + and %r22, %r22, %r24 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 16, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 48, 16 + xor %r22, %r22, %r16 + and %r22, %r22, %r24 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 16, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 48, 16 + xor %r22, %r22, %r17 + and %r22, %r22, %r24 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 16, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 48, 16 + xor %r22, %r22, %r18 + and %r22, %r22, %r24 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 16, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 48, 16 + xor %r22, %r22, %r19 + and %r22, %r22, %r24 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 16, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 48, 16 + xor %r22, %r22, %r20 + and %r22, %r22, %r24 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 16, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 48, 16 + xor %r22, %r22, %r21 + and %r22, %r22, %r24 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 16, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 56, 8 + xor %r22, %r22, %r14 + and %r22, %r22, %r25 + xor %r14, %r14, %r22 + rldicl %r22, %r22, 8, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 56, 8 + xor %r22, %r22, %r15 + and %r22, %r22, %r25 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 8, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 56, 8 + xor %r22, %r22, %r16 + and %r22, %r22, %r25 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 8, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 56, 8 + xor %r22, %r22, %r17 + and %r22, %r22, %r25 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 8, 0 + xor %r17, %r17, %r22 + rldicl %r22, %r18, 56, 8 + xor %r22, %r22, %r18 + and %r22, %r22, %r25 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 8, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 56, 8 + xor %r22, %r22, %r19 + and %r22, %r22, %r25 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 8, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r20, 56, 8 + xor %r22, %r22, %r20 + and %r22, %r22, %r25 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 8, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r21, 56, 8 + xor %r22, %r22, %r21 + and %r22, %r22, %r25 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 8, 0 + xor %r21, %r21, %r22 + rldicl %r22, %r14, 63, 1 + xor %r22, %r22, %r15 + and %r22, %r22, %r27 + xor %r15, %r15, %r22 + rldicl %r22, %r22, 1, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r16, 63, 1 + xor %r22, %r22, %r17 + and %r22, %r22, %r27 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 1, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r18, 63, 1 + xor %r22, %r22, %r19 + and %r22, %r22, %r27 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 1, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r20, 63, 1 + xor %r22, %r22, %r21 + and %r22, %r22, %r27 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 1, 0 + xor %r20, %r20, %r22 + rldicl %r22, %r14, 62, 2 + xor %r22, %r22, %r16 + and %r22, %r22, %r28 + xor %r16, %r16, %r22 + rldicl %r22, %r22, 2, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 62, 2 + xor %r22, %r22, %r17 + and %r22, %r22, %r28 + xor %r17, %r17, %r22 + rldicl %r22, %r22, 2, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r18, 62, 2 + xor %r22, %r22, %r20 + and %r22, %r22, %r28 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 2, 0 + xor %r18, %r18, %r22 + rldicl %r22, %r19, 62, 2 + xor %r22, %r22, %r21 + and %r22, %r22, %r28 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 2, 0 + xor %r19, %r19, %r22 + rldicl %r22, %r14, 60, 4 + xor %r22, %r22, %r18 + and %r22, %r22, %r29 + xor %r18, %r18, %r22 + rldicl %r22, %r22, 4, 0 + xor %r14, %r14, %r22 + rldicl %r22, %r15, 60, 4 + xor %r22, %r22, %r19 + and %r22, %r22, %r29 + xor %r19, %r19, %r22 + rldicl %r22, %r22, 4, 0 + xor %r15, %r15, %r22 + rldicl %r22, %r16, 60, 4 + xor %r22, %r22, %r20 + and %r22, %r22, %r29 + xor %r20, %r20, %r22 + rldicl %r22, %r22, 4, 0 + xor %r16, %r16, %r22 + rldicl %r22, %r17, 60, 4 + xor %r22, %r22, %r21 + and %r22, %r22, %r29 + xor %r21, %r21, %r22 + rldicl %r22, %r22, 4, 0 + xor %r17, %r17, %r22 + std %r14, 0(%r4) + std %r15, 8(%r4) + std %r16, 16(%r4) + std %r17, 24(%r4) + std %r18, 32(%r4) + std %r19, 40(%r4) + std %r20, 48(%r4) + std %r21, 56(%r4) + addi %r4, %r4, 64 + addi %r3, %r3, 8 + addi %r23, %r23, -1 + cmpldi %cr0, %r23, 0 + bne %cr0, 27b +21: + ld %r14, 2944(%r8) + ld %r15, 2952(%r8) + ld %r16, 2960(%r8) + ld %r17, 2968(%r8) + ld %r18, 2976(%r8) + ld %r19, 2984(%r8) + ld %r20, 2992(%r8) + ld %r21, 3000(%r8) + ld %r22, 3008(%r8) + ld %r23, 3016(%r8) + ld %r24, 3024(%r8) + ld %r25, 3032(%r8) + ld %r26, 3040(%r8) + ld %r27, 3048(%r8) + ld %r28, 3056(%r8) + ld %r29, 3064(%r8) + ld %r30, 3072(%r8) + ld %r31, 3080(%r8) + or %r5, %r6, %r6 + or %r3, %r12, %r12 + or %r28, %r0, %r0 + or %r29, %r9, %r9 + or %r30, %r10, %r10 + or %r31, %r11, %r11 + cmpldi %cr0, %r30, 0 + beq %cr0, 28f +210: + lwz %r8, 3344(%r5) + stw %r8, 3088(%r5) + lwz %r8, 3348(%r5) + stw %r8, 3092(%r5) + lwz %r8, 3352(%r5) + stw %r8, 3096(%r5) + lwz %r8, 3356(%r5) + stw %r8, 3100(%r5) + or %r10, %r3, %r3 + or %r6, %r5, %r5 + or %r3, %r28, %r28 + or %r4, %r5, %r5 + li %r5, 414 + bl {vg_camellia_crypt_prepared} + or %r5, %r6, %r6 + or %r3, %r10, %r10 + rldicl %r8, %r30, 60, 4 + cmpldi %cr0, %r8, 0 + beq %cr0, 211f + lwz %r8, 3088(%r5) + stw %r8, 3344(%r5) + lwz %r8, 3092(%r5) + stw %r8, 3348(%r5) + lwz %r8, 3096(%r5) + stw %r8, 3352(%r5) + lwz %r8, 3100(%r5) + stw %r8, 3356(%r5) + lwz %r8, 0(%r31) + lwz %r9, 3088(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 3092(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + lwz %r8, 8(%r31) + lwz %r9, 3096(%r5) + xor %r8, %r8, %r9 + stw %r8, 8(%r31) + lwz %r8, 12(%r31) + lwz %r9, 3100(%r5) + xor %r8, %r8, %r9 + stw %r8, 12(%r31) + addi %r31, %r31, 16 + addi %r30, %r30, -16 + b 212f +211: + lwz %r8, 3088(%r5) + stw %r8, 3344(%r5) + lwz %r8, 3092(%r5) + stw %r8, 3348(%r5) + lwz %r8, 3096(%r5) + stw %r8, 3352(%r5) + lwz %r8, 3100(%r5) + stw %r8, 3356(%r5) + addi %r8, %r5, 3088 +213: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 213b +212: + cmpldi %cr0, %r30, 0 + bne %cr0, 210b + b 29f +28: +29: + or %r31, %r29, %r29 + lwz %r8, 3344(%r5) + stw %r8, 0(%r31) + lwz %r8, 3348(%r5) + stw %r8, 4(%r31) + lwz %r8, 3352(%r5) + stw %r8, 8(%r31) + lwz %r8, 3356(%r5) + stw %r8, 12(%r31) + ld %r29, 3312(%r5) + ld %r30, 3320(%r5) + ld %r31, 3328(%r5) + ld %r0, 3336(%r5) + mtlr %r0 + ld %r28, 3360(%r5) + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + std %r11, 80(%r12) + std %r11, 88(%r12) + std %r11, 96(%r12) + std %r11, 104(%r12) + std %r11, 112(%r12) + std %r11, 120(%r12) + std %r11, 128(%r12) + std %r11, 136(%r12) + std %r11, 144(%r12) + std %r11, 152(%r12) + std %r11, 160(%r12) + std %r11, 168(%r12) + std %r11, 176(%r12) + std %r11, 184(%r12) + std %r11, 192(%r12) + std %r11, 200(%r12) + std %r11, 208(%r12) + std %r11, 216(%r12) + std %r11, 224(%r12) + std %r11, 232(%r12) + std %r11, 240(%r12) + std %r11, 248(%r12) + std %r11, 256(%r12) + std %r11, 264(%r12) + std %r11, 272(%r12) + std %r11, 280(%r12) + std %r11, 288(%r12) + std %r11, 296(%r12) + std %r11, 304(%r12) + std %r11, 312(%r12) + std %r11, 320(%r12) + std %r11, 328(%r12) + std %r11, 336(%r12) + std %r11, 344(%r12) + std %r11, 352(%r12) + std %r11, 360(%r12) + std %r11, 368(%r12) + std %r11, 376(%r12) + std %r11, 384(%r12) + std %r11, 392(%r12) + std %r11, 400(%r12) + std %r11, 408(%r12) + std %r11, 416(%r12) + std %r11, 424(%r12) + std %r11, 432(%r12) + std %r11, 440(%r12) + std %r11, 448(%r12) + std %r11, 456(%r12) + std %r11, 464(%r12) + std %r11, 472(%r12) + std %r11, 480(%r12) + std %r11, 488(%r12) + std %r11, 496(%r12) + std %r11, 504(%r12) + std %r11, 512(%r12) + std %r11, 520(%r12) + std %r11, 528(%r12) + std %r11, 536(%r12) + std %r11, 544(%r12) + std %r11, 552(%r12) + std %r11, 560(%r12) + std %r11, 568(%r12) + std %r11, 576(%r12) + std %r11, 584(%r12) + std %r11, 592(%r12) + std %r11, 600(%r12) + std %r11, 608(%r12) + std %r11, 616(%r12) + std %r11, 624(%r12) + std %r11, 632(%r12) + std %r11, 640(%r12) + std %r11, 648(%r12) + std %r11, 656(%r12) + std %r11, 664(%r12) + std %r11, 672(%r12) + std %r11, 680(%r12) + std %r11, 688(%r12) + std %r11, 696(%r12) + std %r11, 704(%r12) + std %r11, 712(%r12) + std %r11, 720(%r12) + std %r11, 728(%r12) + std %r11, 736(%r12) + std %r11, 744(%r12) + std %r11, 752(%r12) + std %r11, 760(%r12) + std %r11, 768(%r12) + std %r11, 776(%r12) + std %r11, 784(%r12) + std %r11, 792(%r12) + std %r11, 800(%r12) + std %r11, 808(%r12) + std %r11, 816(%r12) + std %r11, 824(%r12) + std %r11, 832(%r12) + std %r11, 840(%r12) + std %r11, 848(%r12) + std %r11, 856(%r12) + std %r11, 864(%r12) + std %r11, 872(%r12) + std %r11, 880(%r12) + std %r11, 888(%r12) + std %r11, 896(%r12) + std %r11, 904(%r12) + std %r11, 912(%r12) + std %r11, 920(%r12) + std %r11, 928(%r12) + std %r11, 936(%r12) + std %r11, 944(%r12) + std %r11, 952(%r12) + std %r11, 960(%r12) + std %r11, 968(%r12) + std %r11, 976(%r12) + std %r11, 984(%r12) + std %r11, 992(%r12) + std %r11, 1000(%r12) + std %r11, 1008(%r12) + std %r11, 1016(%r12) + std %r11, 1024(%r12) + std %r11, 1032(%r12) + std %r11, 1040(%r12) + std %r11, 1048(%r12) + std %r11, 1056(%r12) + std %r11, 1064(%r12) + std %r11, 1072(%r12) + std %r11, 1080(%r12) + std %r11, 1088(%r12) + std %r11, 1096(%r12) + std %r11, 1104(%r12) + std %r11, 1112(%r12) + std %r11, 1120(%r12) + std %r11, 1128(%r12) + std %r11, 1136(%r12) + std %r11, 1144(%r12) + std %r11, 1152(%r12) + std %r11, 1160(%r12) + std %r11, 1168(%r12) + std %r11, 1176(%r12) + std %r11, 1184(%r12) + std %r11, 1192(%r12) + std %r11, 1200(%r12) + std %r11, 1208(%r12) + std %r11, 1216(%r12) + std %r11, 1224(%r12) + std %r11, 1232(%r12) + std %r11, 1240(%r12) + std %r11, 1248(%r12) + std %r11, 1256(%r12) + std %r11, 1264(%r12) + std %r11, 1272(%r12) + std %r11, 1280(%r12) + std %r11, 1288(%r12) + std %r11, 1296(%r12) + std %r11, 1304(%r12) + std %r11, 1312(%r12) + std %r11, 1320(%r12) + std %r11, 1328(%r12) + std %r11, 1336(%r12) + std %r11, 1344(%r12) + std %r11, 1352(%r12) + std %r11, 1360(%r12) + std %r11, 1368(%r12) + std %r11, 1376(%r12) + std %r11, 1384(%r12) + std %r11, 1392(%r12) + std %r11, 1400(%r12) + std %r11, 1408(%r12) + std %r11, 1416(%r12) + std %r11, 1424(%r12) + std %r11, 1432(%r12) + std %r11, 1440(%r12) + std %r11, 1448(%r12) + std %r11, 1456(%r12) + std %r11, 1464(%r12) + std %r11, 1472(%r12) + std %r11, 1480(%r12) + std %r11, 1488(%r12) + std %r11, 1496(%r12) + std %r11, 1504(%r12) + std %r11, 1512(%r12) + std %r11, 1520(%r12) + std %r11, 1528(%r12) + std %r11, 1536(%r12) + std %r11, 1544(%r12) + std %r11, 1552(%r12) + std %r11, 1560(%r12) + std %r11, 1568(%r12) + std %r11, 1576(%r12) + std %r11, 1584(%r12) + std %r11, 1592(%r12) + std %r11, 1600(%r12) + std %r11, 1608(%r12) + std %r11, 1616(%r12) + std %r11, 1624(%r12) + std %r11, 1632(%r12) + std %r11, 1640(%r12) + std %r11, 1648(%r12) + std %r11, 1656(%r12) + std %r11, 1664(%r12) + std %r11, 1672(%r12) + std %r11, 1680(%r12) + std %r11, 1688(%r12) + std %r11, 1696(%r12) + std %r11, 1704(%r12) + std %r11, 1712(%r12) + std %r11, 1720(%r12) + std %r11, 1728(%r12) + std %r11, 1736(%r12) + std %r11, 1744(%r12) + std %r11, 1752(%r12) + std %r11, 1760(%r12) + std %r11, 1768(%r12) + std %r11, 1776(%r12) + std %r11, 1784(%r12) + std %r11, 1792(%r12) + std %r11, 1800(%r12) + std %r11, 1808(%r12) + std %r11, 1816(%r12) + std %r11, 1824(%r12) + std %r11, 1832(%r12) + std %r11, 1840(%r12) + std %r11, 1848(%r12) + std %r11, 1856(%r12) + std %r11, 1864(%r12) + std %r11, 1872(%r12) + std %r11, 1880(%r12) + std %r11, 1888(%r12) + std %r11, 1896(%r12) + std %r11, 1904(%r12) + std %r11, 1912(%r12) + std %r11, 1920(%r12) + std %r11, 1928(%r12) + std %r11, 1936(%r12) + std %r11, 1944(%r12) + std %r11, 1952(%r12) + std %r11, 1960(%r12) + std %r11, 1968(%r12) + std %r11, 1976(%r12) + std %r11, 1984(%r12) + std %r11, 1992(%r12) + std %r11, 2000(%r12) + std %r11, 2008(%r12) + std %r11, 2016(%r12) + std %r11, 2024(%r12) + std %r11, 2032(%r12) + std %r11, 2040(%r12) + std %r11, 2048(%r12) + std %r11, 2056(%r12) + std %r11, 2064(%r12) + std %r11, 2072(%r12) + std %r11, 2080(%r12) + std %r11, 2088(%r12) + std %r11, 2096(%r12) + std %r11, 2104(%r12) + std %r11, 2112(%r12) + std %r11, 2120(%r12) + std %r11, 2128(%r12) + std %r11, 2136(%r12) + std %r11, 2144(%r12) + std %r11, 2152(%r12) + std %r11, 2160(%r12) + std %r11, 2168(%r12) + std %r11, 2176(%r12) + std %r11, 2184(%r12) + std %r11, 2192(%r12) + std %r11, 2200(%r12) + std %r11, 2208(%r12) + std %r11, 2216(%r12) + std %r11, 2224(%r12) + std %r11, 2232(%r12) + std %r11, 2240(%r12) + std %r11, 2248(%r12) + std %r11, 2256(%r12) + std %r11, 2264(%r12) + std %r11, 2272(%r12) + std %r11, 2280(%r12) + std %r11, 2288(%r12) + std %r11, 2296(%r12) + std %r11, 2304(%r12) + std %r11, 2312(%r12) + std %r11, 2320(%r12) + std %r11, 2328(%r12) + std %r11, 2336(%r12) + std %r11, 2344(%r12) + std %r11, 2352(%r12) + std %r11, 2360(%r12) + std %r11, 2368(%r12) + std %r11, 2376(%r12) + std %r11, 2384(%r12) + std %r11, 2392(%r12) + std %r11, 2400(%r12) + std %r11, 2408(%r12) + std %r11, 2416(%r12) + std %r11, 2424(%r12) + std %r11, 2432(%r12) + std %r11, 2440(%r12) + std %r11, 2448(%r12) + std %r11, 2456(%r12) + std %r11, 2464(%r12) + std %r11, 2472(%r12) + std %r11, 2480(%r12) + std %r11, 2488(%r12) + std %r11, 2496(%r12) + std %r11, 2504(%r12) + std %r11, 2512(%r12) + std %r11, 2520(%r12) + std %r11, 2528(%r12) + std %r11, 2536(%r12) + std %r11, 2544(%r12) + std %r11, 2552(%r12) + std %r11, 2560(%r12) + std %r11, 2568(%r12) + std %r11, 2576(%r12) + std %r11, 2584(%r12) + std %r11, 2592(%r12) + std %r11, 2600(%r12) + std %r11, 2608(%r12) + std %r11, 2616(%r12) + std %r11, 2624(%r12) + std %r11, 2632(%r12) + std %r11, 2640(%r12) + std %r11, 2648(%r12) + std %r11, 2656(%r12) + std %r11, 2664(%r12) + std %r11, 2672(%r12) + std %r11, 2680(%r12) + std %r11, 2688(%r12) + std %r11, 2696(%r12) + std %r11, 2704(%r12) + std %r11, 2712(%r12) + std %r11, 2720(%r12) + std %r11, 2728(%r12) + std %r11, 2736(%r12) + std %r11, 2744(%r12) + std %r11, 2752(%r12) + std %r11, 2760(%r12) + std %r11, 2768(%r12) + std %r11, 2776(%r12) + std %r11, 2784(%r12) + std %r11, 2792(%r12) + std %r11, 2800(%r12) + std %r11, 2808(%r12) + std %r11, 2816(%r12) + std %r11, 2824(%r12) + std %r11, 2832(%r12) + std %r11, 2840(%r12) + std %r11, 2848(%r12) + std %r11, 2856(%r12) + std %r11, 2864(%r12) + std %r11, 2872(%r12) + std %r11, 2880(%r12) + std %r11, 2888(%r12) + std %r11, 2896(%r12) + std %r11, 2904(%r12) + std %r11, 2912(%r12) + std %r11, 2920(%r12) + std %r11, 2928(%r12) + std %r11, 2936(%r12) + std %r11, 2944(%r12) + std %r11, 2952(%r12) + std %r11, 2960(%r12) + std %r11, 2968(%r12) + std %r11, 2976(%r12) + std %r11, 2984(%r12) + std %r11, 2992(%r12) + std %r11, 3000(%r12) + std %r11, 3008(%r12) + std %r11, 3016(%r12) + std %r11, 3024(%r12) + std %r11, 3032(%r12) + std %r11, 3040(%r12) + std %r11, 3048(%r12) + std %r11, 3056(%r12) + std %r11, 3064(%r12) + std %r11, 3072(%r12) + std %r11, 3080(%r12) + std %r11, 3088(%r12) + std %r11, 3096(%r12) + std %r11, 3104(%r12) + std %r11, 3112(%r12) + std %r11, 3120(%r12) + std %r11, 3128(%r12) + std %r11, 3136(%r12) + std %r11, 3144(%r12) + std %r11, 3152(%r12) + std %r11, 3160(%r12) + std %r11, 3168(%r12) + std %r11, 3176(%r12) + std %r11, 3184(%r12) + std %r11, 3192(%r12) + std %r11, 3200(%r12) + std %r11, 3208(%r12) + std %r11, 3216(%r12) + std %r11, 3224(%r12) + std %r11, 3232(%r12) + std %r11, 3240(%r12) + std %r11, 3248(%r12) + std %r11, 3256(%r12) + std %r11, 3264(%r12) + std %r11, 3272(%r12) + std %r11, 3280(%r12) + std %r11, 3288(%r12) + std %r11, 3296(%r12) + std %r11, 3304(%r12) + std %r11, 3312(%r12) + std %r11, 3320(%r12) + std %r11, 3328(%r12) + std %r11, 3336(%r12) + std %r11, 3344(%r12) + std %r11, 3352(%r12) + std %r11, 3360(%r12) + std %r11, 3368(%r12) + addi %r1, %r1, 3408 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/cast5_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/cast5_ofb.s index 7544fa68118..9c66f40c8b0 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/cast5_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/cast5_ofb.s @@ -518,3 +518,560 @@ vg_cast5_ofb: std %r11, 168(%r12) addi %r1, %r1, 208 blr + +vg_cast5_ofb_final: + stdu %r1, -208(%r1) + addi %r8, %r1, 32 + or %r10, %r4, %r4 + or %r4, %r5, %r5 + or %r5, %r6, %r6 + or %r6, %r7, %r7 + or %r7, %r8, %r8 + addi %r10, %r10, -12 + cmpldi %cr0, %r10, 0 + beq %cr0, 20f + mflr %r0 + std %r0, 152(%r7) + std %r29, 128(%r7) + std %r30, 136(%r7) + std %r31, 144(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 160(%r5) + lwz %r8, 4(%r31) + stw %r8, 164(%r5) + or %r31, %r6, %r6 + cmpldi %cr0, %r30, 0 + beq %cr0, 22f +24: + lwz %r8, 160(%r5) + stw %r8, 0(%r5) + lwz %r8, 164(%r5) + stw %r8, 4(%r5) + or %r6, %r29, %r29 + or %r7, %r30, %r30 + std %r14, 8(%r5) + std %r15, 16(%r5) + std %r16, 24(%r5) + std %r17, 32(%r5) + std %r18, 40(%r5) + std %r19, 48(%r5) + std %r20, 56(%r5) + std %r21, 64(%r5) + std %r22, 72(%r5) + std %r23, 80(%r5) + std %r24, 88(%r5) + std %r25, 96(%r5) + std %r26, 104(%r5) + std %r27, 112(%r5) + std %r28, 120(%r5) + bcl 20, 31, 2f +2: + mflr %r27 + addis %r27, %r27, ({VG_CAST5_S1234} + addi %r27, %r27, ({VG_CAST5_S1234} + li %r26, 255 + li %r0, 0 + li %r4, 16 + lwbrx %r8, %r5, %r0 + addi %r24, %r5, 4 + lwbrx %r9, %r24, %r0 + or %r10, %r3, %r3 + or %r11, %r4, %r4 + li %r12, 1 +25: + cmpldi %cr0, %r12, 0 + beq %cr0, 26f + addi %r24, %r12, -1 + cmpldi %cr0, %r24, 0 + beq %cr0, 28f + lwz %r28, 0(%r10) + xor %r28, %r28, %r9 + b 29f +28: + lwz %r28, 0(%r10) + add %r28, %r28, %r9 +29: + b 27f +26: + lwz %r28, 0(%r10) + subf %r28, %r9, %r28 +27: + lwz %r29, 64(%r10) + rldicr %r30, %r29, 63, 0 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 1, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 62, 1 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 2, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 61, 2 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 4, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 60, 3 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 8, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 59, 4 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 16, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + and %r14, %r28, %r26 + rlwinm %r15, %r28, 24, 8, 31 + and %r15, %r15, %r26 + rlwinm %r16, %r28, 16, 16, 31 + and %r16, %r16, %r26 + rlwinm %r17, %r28, 8, 24, 31 + or %r23, %r27, %r27 + li %r22, 0 + li %r18, 0 + li %r19, 0 + li %r20, 0 + li %r21, 0 +210: + lwz %r25, 0(%r23) + xor %r24, %r14, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r18, %r18, %r25 + lwz %r25, 4(%r23) + xor %r24, %r15, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r19, %r19, %r25 + lwz %r25, 8(%r23) + xor %r24, %r16, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r20, %r20, %r25 + lwz %r25, 12(%r23) + xor %r24, %r17, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r21, %r21, %r25 + addi %r23, %r23, 16 + addi %r22, %r22, 1 + addi %r24, %r22, -256 + cmpldi %cr0, %r24, 0 + bne %cr0, 210b + cmpldi %cr0, %r12, 0 + beq %cr0, 211f + addi %r24, %r12, -1 + cmpldi %cr0, %r24, 0 + beq %cr0, 213f + subf %r28, %r20, %r21 + add %r28, %r28, %r19 + xor %r28, %r28, %r18 + b 214f +213: + xor %r28, %r21, %r20 + subf %r28, %r19, %r28 + add %r28, %r28, %r18 +214: + b 212f +211: + add %r28, %r21, %r20 + xor %r28, %r28, %r19 + subf %r28, %r18, %r28 +212: + xor %r28, %r28, %r8 + or %r8, %r9, %r9 + or %r9, %r28, %r28 + addi %r10, %r10, 4 + addi %r24, %r12, -2 + cmpldi %cr0, %r24, 0 + beq %cr0, 215f + addi %r12, %r12, 1 + b 216f +215: + li %r12, 0 +216: + addi %r11, %r11, -1 + cmpldi %cr0, %r11, 0 + bne %cr0, 25b + stwbrx %r9, %r5, %r0 + addi %r24, %r5, 4 + stwbrx %r8, %r24, %r0 + ld %r14, 8(%r5) + ld %r15, 16(%r5) + ld %r16, 24(%r5) + ld %r17, 32(%r5) + ld %r18, 40(%r5) + ld %r19, 48(%r5) + ld %r20, 56(%r5) + ld %r21, 64(%r5) + ld %r22, 72(%r5) + ld %r23, 80(%r5) + ld %r24, 88(%r5) + ld %r25, 96(%r5) + ld %r26, 104(%r5) + ld %r27, 112(%r5) + ld %r28, 120(%r5) + or %r29, %r6, %r6 + or %r30, %r7, %r7 + rldicl %r8, %r30, 61, 3 + cmpldi %cr0, %r8, 0 + beq %cr0, 217f + lwz %r8, 0(%r5) + stw %r8, 160(%r5) + lwz %r8, 4(%r5) + stw %r8, 164(%r5) + lwz %r8, 0(%r31) + lwz %r9, 0(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 4(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + addi %r31, %r31, 8 + addi %r30, %r30, -8 + b 218f +217: + lwz %r8, 0(%r5) + stw %r8, 160(%r5) + lwz %r8, 4(%r5) + stw %r8, 164(%r5) + addi %r8, %r5, 0 +219: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 219b +218: + cmpldi %cr0, %r30, 0 + bne %cr0, 24b + b 23f +22: +23: + or %r31, %r29, %r29 + lwz %r8, 160(%r5) + stw %r8, 0(%r31) + lwz %r8, 164(%r5) + stw %r8, 4(%r31) + ld %r29, 128(%r5) + ld %r30, 136(%r5) + ld %r31, 144(%r5) + ld %r0, 152(%r5) + mtlr %r0 + b 21f +20: + mflr %r0 + std %r0, 152(%r7) + std %r29, 128(%r7) + std %r30, 136(%r7) + std %r31, 144(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 160(%r5) + lwz %r8, 4(%r31) + stw %r8, 164(%r5) + or %r31, %r6, %r6 + cmpldi %cr0, %r30, 0 + beq %cr0, 220f +222: + lwz %r8, 160(%r5) + stw %r8, 0(%r5) + lwz %r8, 164(%r5) + stw %r8, 4(%r5) + or %r6, %r29, %r29 + or %r7, %r30, %r30 + std %r14, 8(%r5) + std %r15, 16(%r5) + std %r16, 24(%r5) + std %r17, 32(%r5) + std %r18, 40(%r5) + std %r19, 48(%r5) + std %r20, 56(%r5) + std %r21, 64(%r5) + std %r22, 72(%r5) + std %r23, 80(%r5) + std %r24, 88(%r5) + std %r25, 96(%r5) + std %r26, 104(%r5) + std %r27, 112(%r5) + std %r28, 120(%r5) + bcl 20, 31, 2f +2: + mflr %r27 + addis %r27, %r27, ({VG_CAST5_S1234} + addi %r27, %r27, ({VG_CAST5_S1234} + li %r26, 255 + li %r0, 0 + li %r4, 12 + lwbrx %r8, %r5, %r0 + addi %r24, %r5, 4 + lwbrx %r9, %r24, %r0 + or %r10, %r3, %r3 + or %r11, %r4, %r4 + li %r12, 1 +223: + cmpldi %cr0, %r12, 0 + beq %cr0, 224f + addi %r24, %r12, -1 + cmpldi %cr0, %r24, 0 + beq %cr0, 226f + lwz %r28, 0(%r10) + xor %r28, %r28, %r9 + b 227f +226: + lwz %r28, 0(%r10) + add %r28, %r28, %r9 +227: + b 225f +224: + lwz %r28, 0(%r10) + subf %r28, %r9, %r28 +225: + lwz %r29, 64(%r10) + rldicr %r30, %r29, 63, 0 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 1, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 62, 1 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 2, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 61, 2 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 4, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 60, 3 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 8, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + rldicr %r30, %r29, 59, 4 + rldicl %r30, %r30, 1, 63 + addi %r30, %r30, -1 + rlwinm %r24, %r28, 16, 0, 31 + xor %r25, %r28, %r24 + and %r25, %r25, %r30 + xor %r28, %r24, %r25 + and %r14, %r28, %r26 + rlwinm %r15, %r28, 24, 8, 31 + and %r15, %r15, %r26 + rlwinm %r16, %r28, 16, 16, 31 + and %r16, %r16, %r26 + rlwinm %r17, %r28, 8, 24, 31 + or %r23, %r27, %r27 + li %r22, 0 + li %r18, 0 + li %r19, 0 + li %r20, 0 + li %r21, 0 +228: + lwz %r25, 0(%r23) + xor %r24, %r14, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r18, %r18, %r25 + lwz %r25, 4(%r23) + xor %r24, %r15, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r19, %r19, %r25 + lwz %r25, 8(%r23) + xor %r24, %r16, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r20, %r20, %r25 + lwz %r25, 12(%r23) + xor %r24, %r17, %r22 + addi %r24, %r24, -1 + rldicl %r24, %r24, 1, 63 + subf %r24, %r24, %r0 + and %r25, %r25, %r24 + or %r21, %r21, %r25 + addi %r23, %r23, 16 + addi %r22, %r22, 1 + addi %r24, %r22, -256 + cmpldi %cr0, %r24, 0 + bne %cr0, 228b + cmpldi %cr0, %r12, 0 + beq %cr0, 229f + addi %r24, %r12, -1 + cmpldi %cr0, %r24, 0 + beq %cr0, 231f + subf %r28, %r20, %r21 + add %r28, %r28, %r19 + xor %r28, %r28, %r18 + b 232f +231: + xor %r28, %r21, %r20 + subf %r28, %r19, %r28 + add %r28, %r28, %r18 +232: + b 230f +229: + add %r28, %r21, %r20 + xor %r28, %r28, %r19 + subf %r28, %r18, %r28 +230: + xor %r28, %r28, %r8 + or %r8, %r9, %r9 + or %r9, %r28, %r28 + addi %r10, %r10, 4 + addi %r24, %r12, -2 + cmpldi %cr0, %r24, 0 + beq %cr0, 233f + addi %r12, %r12, 1 + b 234f +233: + li %r12, 0 +234: + addi %r11, %r11, -1 + cmpldi %cr0, %r11, 0 + bne %cr0, 223b + stwbrx %r9, %r5, %r0 + addi %r24, %r5, 4 + stwbrx %r8, %r24, %r0 + ld %r14, 8(%r5) + ld %r15, 16(%r5) + ld %r16, 24(%r5) + ld %r17, 32(%r5) + ld %r18, 40(%r5) + ld %r19, 48(%r5) + ld %r20, 56(%r5) + ld %r21, 64(%r5) + ld %r22, 72(%r5) + ld %r23, 80(%r5) + ld %r24, 88(%r5) + ld %r25, 96(%r5) + ld %r26, 104(%r5) + ld %r27, 112(%r5) + ld %r28, 120(%r5) + or %r29, %r6, %r6 + or %r30, %r7, %r7 + rldicl %r8, %r30, 61, 3 + cmpldi %cr0, %r8, 0 + beq %cr0, 235f + lwz %r8, 0(%r5) + stw %r8, 160(%r5) + lwz %r8, 4(%r5) + stw %r8, 164(%r5) + lwz %r8, 0(%r31) + lwz %r9, 0(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 4(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + addi %r31, %r31, 8 + addi %r30, %r30, -8 + b 236f +235: + lwz %r8, 0(%r5) + stw %r8, 160(%r5) + lwz %r8, 4(%r5) + stw %r8, 164(%r5) + addi %r8, %r5, 0 +237: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 237b +236: + cmpldi %cr0, %r30, 0 + bne %cr0, 222b + b 221f +220: +221: + or %r31, %r29, %r29 + lwz %r8, 160(%r5) + stw %r8, 0(%r31) + lwz %r8, 164(%r5) + stw %r8, 4(%r31) + ld %r29, 128(%r5) + ld %r30, 136(%r5) + ld %r31, 144(%r5) + ld %r0, 152(%r5) + mtlr %r0 +21: + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + std %r11, 80(%r12) + std %r11, 88(%r12) + std %r11, 96(%r12) + std %r11, 104(%r12) + std %r11, 112(%r12) + std %r11, 120(%r12) + std %r11, 128(%r12) + std %r11, 136(%r12) + std %r11, 144(%r12) + std %r11, 152(%r12) + std %r11, 160(%r12) + std %r11, 168(%r12) + addi %r1, %r1, 208 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/idea_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/idea_ofb.s index 4ff7bdf60fb..3ec491d8044 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/idea_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/idea_ofb.s @@ -840,3 +840,861 @@ vg_idea_ofb: std %r11, 56(%r12) addi %r1, %r1, 96 blr + +vg_idea_ofb_final: + stdu %r1, -96(%r1) + addi %r7, %r1, 32 + mflr %r0 + std %r0, 32(%r7) + std %r29, 8(%r7) + std %r30, 16(%r7) + std %r31, 24(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 40(%r5) + lwz %r8, 4(%r31) + stw %r8, 44(%r5) + or %r31, %r6, %r6 + cmpldi %cr0, %r30, 0 + beq %cr0, 20f +22: + lwz %r8, 40(%r5) + stw %r8, 0(%r5) + lwz %r8, 44(%r5) + stw %r8, 4(%r5) + li %r0, 0 + ori %r0, %r0, 65535 + addi %r4, %r5, 0 + lbz %r6, 0(%r4) + rldicr %r6, %r6, 8, 55 + lbz %r11, 1(%r4) + or %r6, %r6, %r11 + lbz %r7, 2(%r4) + rldicr %r7, %r7, 8, 55 + lbz %r11, 3(%r4) + or %r7, %r7, %r11 + lbz %r8, 4(%r4) + rldicr %r8, %r8, 8, 55 + lbz %r11, 5(%r4) + or %r8, %r8, %r11 + lbz %r9, 6(%r4) + rldicr %r9, %r9, 8, 55 + lbz %r11, 7(%r4) + or %r9, %r9, %r11 + or %r11, %r6, %r6 + lwz %r12, 0(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 6(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 2(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 4(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 8(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 10(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 12(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 18(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 14(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 16(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 20(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 22(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 24(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 30(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 26(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 28(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 32(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 34(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 36(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 42(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 38(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 40(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 44(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 46(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 48(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 54(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 50(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 52(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 56(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 58(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 60(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 66(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 62(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 64(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 68(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 70(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 72(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 78(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 74(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 76(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 80(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 82(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 84(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 90(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 86(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + lwz %r12, 88(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + xor %r11, %r6, %r8 + lwz %r12, 92(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r10, %r12, %r12 + xor %r11, %r7, %r9 + add %r11, %r11, %r10 + lwz %r12, 94(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + add %r10, %r10, %r12 + and %r10, %r10, %r0 + xor %r6, %r6, %r12 + xor %r8, %r8, %r12 + xor %r7, %r7, %r10 + xor %r9, %r9, %r10 + or %r11, %r7, %r7 + or %r7, %r8, %r8 + or %r8, %r11, %r11 + or %r11, %r6, %r6 + lwz %r12, 96(%r3) + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r6, %r12, %r12 + or %r11, %r9, %r9 + lwz %r12, 100(%r3) + rldicl %r12, %r12, 48, 16 + addi %r11, %r11, -1 + and %r11, %r11, %r0 + addi %r11, %r11, 1 + addi %r12, %r12, -1 + and %r12, %r12, %r0 + addi %r12, %r12, 1 + mulld %r11, %r11, %r12 + and %r12, %r11, %r0 + rldicl %r11, %r11, 48, 16 + subf %r12, %r11, %r12 + rldicl %r11, %r12, 1, 63 + add %r12, %r12, %r11 + rldicr %r11, %r11, 16, 47 + add %r12, %r12, %r11 + and %r12, %r12, %r0 + or %r9, %r12, %r12 + lwz %r12, 98(%r3) + add %r8, %r8, %r12 + and %r8, %r8, %r0 + lwz %r12, 100(%r3) + add %r7, %r7, %r12 + and %r7, %r7, %r0 + stb %r6, 1(%r4) + rldicl %r11, %r6, 56, 8 + stb %r11, 0(%r4) + stb %r8, 3(%r4) + rldicl %r11, %r8, 56, 8 + stb %r11, 2(%r4) + stb %r7, 5(%r4) + rldicl %r11, %r7, 56, 8 + stb %r11, 4(%r4) + stb %r9, 7(%r4) + rldicl %r11, %r9, 56, 8 + stb %r11, 6(%r4) + rldicl %r8, %r30, 61, 3 + cmpldi %cr0, %r8, 0 + beq %cr0, 23f + lwz %r8, 0(%r5) + stw %r8, 40(%r5) + lwz %r8, 4(%r5) + stw %r8, 44(%r5) + lwz %r8, 0(%r31) + lwz %r9, 0(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 4(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + addi %r31, %r31, 8 + addi %r30, %r30, -8 + b 24f +23: + lwz %r8, 0(%r5) + stw %r8, 40(%r5) + lwz %r8, 4(%r5) + stw %r8, 44(%r5) + addi %r8, %r5, 0 +25: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 25b +24: + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + or %r31, %r29, %r29 + lwz %r8, 40(%r5) + stw %r8, 0(%r31) + lwz %r8, 44(%r5) + stw %r8, 4(%r31) + ld %r29, 8(%r5) + ld %r30, 16(%r5) + ld %r31, 24(%r5) + ld %r0, 32(%r5) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + addi %r1, %r1, 96 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/seed_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/seed_ofb.s index 3e5dba204fb..76a741024dc 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/seed_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/seed_ofb.s @@ -236,3 +236,261 @@ vg_seed_ofb: std %r11, 1144(%r12) addi %r1, %r1, 1184 blr + +vg_seed_ofb_final: + stdu %r1, -1184(%r1) + addi %r7, %r1, 32 + mflr %r0 + std %r0, 1128(%r7) + std %r29, 1104(%r7) + std %r30, 1112(%r7) + std %r31, 1120(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 1136(%r5) + lwz %r8, 4(%r31) + stw %r8, 1140(%r5) + lwz %r8, 8(%r31) + stw %r8, 1144(%r5) + lwz %r8, 12(%r31) + stw %r8, 1148(%r5) + or %r31, %r6, %r6 + cmpldi %cr0, %r30, 0 + beq %cr0, 20f +22: + lwz %r8, 1136(%r5) + stw %r8, 1088(%r5) + lwz %r8, 1140(%r5) + stw %r8, 1092(%r5) + lwz %r8, 1144(%r5) + stw %r8, 1096(%r5) + lwz %r8, 1148(%r5) + stw %r8, 1100(%r5) + addi %r4, %r5, 1088 + or %r6, %r5, %r5 + li %r5, 1 + bl {vg_seed_encrypt_blocks} + or %r5, %r8, %r8 + addi %r3, %r3, -0 + rldicl %r8, %r30, 60, 4 + cmpldi %cr0, %r8, 0 + beq %cr0, 23f + lwz %r8, 1088(%r5) + stw %r8, 1136(%r5) + lwz %r8, 1092(%r5) + stw %r8, 1140(%r5) + lwz %r8, 1096(%r5) + stw %r8, 1144(%r5) + lwz %r8, 1100(%r5) + stw %r8, 1148(%r5) + lwz %r8, 0(%r31) + lwz %r9, 1088(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 1092(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + lwz %r8, 8(%r31) + lwz %r9, 1096(%r5) + xor %r8, %r8, %r9 + stw %r8, 8(%r31) + lwz %r8, 12(%r31) + lwz %r9, 1100(%r5) + xor %r8, %r8, %r9 + stw %r8, 12(%r31) + addi %r31, %r31, 16 + addi %r30, %r30, -16 + b 24f +23: + lwz %r8, 1088(%r5) + stw %r8, 1136(%r5) + lwz %r8, 1092(%r5) + stw %r8, 1140(%r5) + lwz %r8, 1096(%r5) + stw %r8, 1144(%r5) + lwz %r8, 1100(%r5) + stw %r8, 1148(%r5) + addi %r8, %r5, 1088 +25: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 25b +24: + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + or %r31, %r29, %r29 + lwz %r8, 1136(%r5) + stw %r8, 0(%r31) + lwz %r8, 1140(%r5) + stw %r8, 4(%r31) + lwz %r8, 1144(%r5) + stw %r8, 8(%r31) + lwz %r8, 1148(%r5) + stw %r8, 12(%r31) + ld %r29, 1104(%r5) + ld %r30, 1112(%r5) + ld %r31, 1120(%r5) + ld %r0, 1128(%r5) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + std %r11, 80(%r12) + std %r11, 88(%r12) + std %r11, 96(%r12) + std %r11, 104(%r12) + std %r11, 112(%r12) + std %r11, 120(%r12) + std %r11, 128(%r12) + std %r11, 136(%r12) + std %r11, 144(%r12) + std %r11, 152(%r12) + std %r11, 160(%r12) + std %r11, 168(%r12) + std %r11, 176(%r12) + std %r11, 184(%r12) + std %r11, 192(%r12) + std %r11, 200(%r12) + std %r11, 208(%r12) + std %r11, 216(%r12) + std %r11, 224(%r12) + std %r11, 232(%r12) + std %r11, 240(%r12) + std %r11, 248(%r12) + std %r11, 256(%r12) + std %r11, 264(%r12) + std %r11, 272(%r12) + std %r11, 280(%r12) + std %r11, 288(%r12) + std %r11, 296(%r12) + std %r11, 304(%r12) + std %r11, 312(%r12) + std %r11, 320(%r12) + std %r11, 328(%r12) + std %r11, 336(%r12) + std %r11, 344(%r12) + std %r11, 352(%r12) + std %r11, 360(%r12) + std %r11, 368(%r12) + std %r11, 376(%r12) + std %r11, 384(%r12) + std %r11, 392(%r12) + std %r11, 400(%r12) + std %r11, 408(%r12) + std %r11, 416(%r12) + std %r11, 424(%r12) + std %r11, 432(%r12) + std %r11, 440(%r12) + std %r11, 448(%r12) + std %r11, 456(%r12) + std %r11, 464(%r12) + std %r11, 472(%r12) + std %r11, 480(%r12) + std %r11, 488(%r12) + std %r11, 496(%r12) + std %r11, 504(%r12) + std %r11, 512(%r12) + std %r11, 520(%r12) + std %r11, 528(%r12) + std %r11, 536(%r12) + std %r11, 544(%r12) + std %r11, 552(%r12) + std %r11, 560(%r12) + std %r11, 568(%r12) + std %r11, 576(%r12) + std %r11, 584(%r12) + std %r11, 592(%r12) + std %r11, 600(%r12) + std %r11, 608(%r12) + std %r11, 616(%r12) + std %r11, 624(%r12) + std %r11, 632(%r12) + std %r11, 640(%r12) + std %r11, 648(%r12) + std %r11, 656(%r12) + std %r11, 664(%r12) + std %r11, 672(%r12) + std %r11, 680(%r12) + std %r11, 688(%r12) + std %r11, 696(%r12) + std %r11, 704(%r12) + std %r11, 712(%r12) + std %r11, 720(%r12) + std %r11, 728(%r12) + std %r11, 736(%r12) + std %r11, 744(%r12) + std %r11, 752(%r12) + std %r11, 760(%r12) + std %r11, 768(%r12) + std %r11, 776(%r12) + std %r11, 784(%r12) + std %r11, 792(%r12) + std %r11, 800(%r12) + std %r11, 808(%r12) + std %r11, 816(%r12) + std %r11, 824(%r12) + std %r11, 832(%r12) + std %r11, 840(%r12) + std %r11, 848(%r12) + std %r11, 856(%r12) + std %r11, 864(%r12) + std %r11, 872(%r12) + std %r11, 880(%r12) + std %r11, 888(%r12) + std %r11, 896(%r12) + std %r11, 904(%r12) + std %r11, 912(%r12) + std %r11, 920(%r12) + std %r11, 928(%r12) + std %r11, 936(%r12) + std %r11, 944(%r12) + std %r11, 952(%r12) + std %r11, 960(%r12) + std %r11, 968(%r12) + std %r11, 976(%r12) + std %r11, 984(%r12) + std %r11, 992(%r12) + std %r11, 1000(%r12) + std %r11, 1008(%r12) + std %r11, 1016(%r12) + std %r11, 1024(%r12) + std %r11, 1032(%r12) + std %r11, 1040(%r12) + std %r11, 1048(%r12) + std %r11, 1056(%r12) + std %r11, 1064(%r12) + std %r11, 1072(%r12) + std %r11, 1080(%r12) + std %r11, 1088(%r12) + std %r11, 1096(%r12) + std %r11, 1104(%r12) + std %r11, 1112(%r12) + std %r11, 1120(%r12) + std %r11, 1128(%r12) + std %r11, 1136(%r12) + std %r11, 1144(%r12) + addi %r1, %r1, 1184 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ctr.s b/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ctr.s index 1c8e4e45996..5c2f6070f0d 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ctr.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ctr.s @@ -510,3 +510,72 @@ vg_sm4_ctr: std %r11, 3256(%r12) addi %r1, %r1, 3296 blr + +vg_sm4_ctr_final: + stdu %r1, -112(%r1) + addi %r7, %r1, 32 + mflr %r0 + std %r0, 0(%r7) + std %r14, 8(%r7) + std %r15, 16(%r7) + std %r16, 24(%r7) + std %r19, 32(%r7) + std %r30, 40(%r7) + std %r31, 48(%r7) + std %r20, 56(%r7) + or %r14, %r3, %r3 + or %r16, %r4, %r4 + or %r20, %r7, %r7 + rldicl %r10, %r6, 60, 4 + rldicr %r11, %r10, 4, 59 + add %r31, %r5, %r11 + subf %r30, %r11, %r6 + or %r6, %r10, %r10 + bl {vg_sm4_ctr} + cmpldi %cr0, %r30, 0 + beq %cr0, 20f + li %r9, 0 + std %r9, 64(%r20) + std %r9, 72(%r20) + or %r3, %r14, %r14 + or %r4, %r16, %r16 + addi %r5, %r20, 64 + li %r6, 1 + bl {vg_sm4_ctr} + addi %r8, %r20, 64 +22: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + ld %r0, 0(%r20) + ld %r14, 8(%r20) + ld %r15, 16(%r20) + ld %r16, 24(%r20) + ld %r19, 32(%r20) + ld %r30, 40(%r20) + ld %r31, 48(%r20) + ld %r20, 56(%r20) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + addi %r1, %r1, 112 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ofb.s index 139423e2e91..1a8061bbf29 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/sm4_ofb.s @@ -504,3 +504,529 @@ vg_sm4_ofb: std %r11, 3256(%r12) addi %r1, %r1, 3296 blr + +vg_sm4_ofb_final: + stdu %r1, -3296(%r1) + addi %r7, %r1, 32 + mflr %r0 + std %r0, 3240(%r7) + std %r29, 3216(%r7) + std %r30, 3224(%r7) + std %r31, 3232(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 3248(%r5) + lwz %r8, 4(%r31) + stw %r8, 3252(%r5) + lwz %r8, 8(%r31) + stw %r8, 3256(%r5) + lwz %r8, 12(%r31) + stw %r8, 3260(%r5) + or %r31, %r6, %r6 + or %r7, %r3, %r3 + li %r4, 0 + li %r6, 402 + bl {vg_sm4_prepare_keys} + or %r3, %r7, %r7 + cmpldi %cr0, %r30, 0 + beq %cr0, 20f +22: + lwz %r8, 3248(%r5) + stw %r8, 768(%r5) + lwz %r8, 3252(%r5) + stw %r8, 772(%r5) + lwz %r8, 3256(%r5) + stw %r8, 776(%r5) + lwz %r8, 3260(%r5) + stw %r8, 780(%r5) + or %r7, %r3, %r3 + or %r3, %r5, %r5 + li %r4, 402 + bl {vg_sm4_crypt_prepared} + or %r3, %r7, %r7 + rldicl %r8, %r30, 60, 4 + cmpldi %cr0, %r8, 0 + beq %cr0, 23f + lwz %r8, 768(%r5) + stw %r8, 3248(%r5) + lwz %r8, 772(%r5) + stw %r8, 3252(%r5) + lwz %r8, 776(%r5) + stw %r8, 3256(%r5) + lwz %r8, 780(%r5) + stw %r8, 3260(%r5) + lwz %r8, 0(%r31) + lwz %r9, 768(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 772(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + lwz %r8, 8(%r31) + lwz %r9, 776(%r5) + xor %r8, %r8, %r9 + stw %r8, 8(%r31) + lwz %r8, 12(%r31) + lwz %r9, 780(%r5) + xor %r8, %r8, %r9 + stw %r8, 12(%r31) + addi %r31, %r31, 16 + addi %r30, %r30, -16 + b 24f +23: + lwz %r8, 768(%r5) + stw %r8, 3248(%r5) + lwz %r8, 772(%r5) + stw %r8, 3252(%r5) + lwz %r8, 776(%r5) + stw %r8, 3256(%r5) + lwz %r8, 780(%r5) + stw %r8, 3260(%r5) + addi %r8, %r5, 768 +25: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 25b +24: + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + or %r31, %r29, %r29 + lwz %r8, 3248(%r5) + stw %r8, 0(%r31) + lwz %r8, 3252(%r5) + stw %r8, 4(%r31) + lwz %r8, 3256(%r5) + stw %r8, 8(%r31) + lwz %r8, 3260(%r5) + stw %r8, 12(%r31) + ld %r29, 3216(%r5) + ld %r30, 3224(%r5) + ld %r31, 3232(%r5) + ld %r0, 3240(%r5) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + std %r11, 80(%r12) + std %r11, 88(%r12) + std %r11, 96(%r12) + std %r11, 104(%r12) + std %r11, 112(%r12) + std %r11, 120(%r12) + std %r11, 128(%r12) + std %r11, 136(%r12) + std %r11, 144(%r12) + std %r11, 152(%r12) + std %r11, 160(%r12) + std %r11, 168(%r12) + std %r11, 176(%r12) + std %r11, 184(%r12) + std %r11, 192(%r12) + std %r11, 200(%r12) + std %r11, 208(%r12) + std %r11, 216(%r12) + std %r11, 224(%r12) + std %r11, 232(%r12) + std %r11, 240(%r12) + std %r11, 248(%r12) + std %r11, 256(%r12) + std %r11, 264(%r12) + std %r11, 272(%r12) + std %r11, 280(%r12) + std %r11, 288(%r12) + std %r11, 296(%r12) + std %r11, 304(%r12) + std %r11, 312(%r12) + std %r11, 320(%r12) + std %r11, 328(%r12) + std %r11, 336(%r12) + std %r11, 344(%r12) + std %r11, 352(%r12) + std %r11, 360(%r12) + std %r11, 368(%r12) + std %r11, 376(%r12) + std %r11, 384(%r12) + std %r11, 392(%r12) + std %r11, 400(%r12) + std %r11, 408(%r12) + std %r11, 416(%r12) + std %r11, 424(%r12) + std %r11, 432(%r12) + std %r11, 440(%r12) + std %r11, 448(%r12) + std %r11, 456(%r12) + std %r11, 464(%r12) + std %r11, 472(%r12) + std %r11, 480(%r12) + std %r11, 488(%r12) + std %r11, 496(%r12) + std %r11, 504(%r12) + std %r11, 512(%r12) + std %r11, 520(%r12) + std %r11, 528(%r12) + std %r11, 536(%r12) + std %r11, 544(%r12) + std %r11, 552(%r12) + std %r11, 560(%r12) + std %r11, 568(%r12) + std %r11, 576(%r12) + std %r11, 584(%r12) + std %r11, 592(%r12) + std %r11, 600(%r12) + std %r11, 608(%r12) + std %r11, 616(%r12) + std %r11, 624(%r12) + std %r11, 632(%r12) + std %r11, 640(%r12) + std %r11, 648(%r12) + std %r11, 656(%r12) + std %r11, 664(%r12) + std %r11, 672(%r12) + std %r11, 680(%r12) + std %r11, 688(%r12) + std %r11, 696(%r12) + std %r11, 704(%r12) + std %r11, 712(%r12) + std %r11, 720(%r12) + std %r11, 728(%r12) + std %r11, 736(%r12) + std %r11, 744(%r12) + std %r11, 752(%r12) + std %r11, 760(%r12) + std %r11, 768(%r12) + std %r11, 776(%r12) + std %r11, 784(%r12) + std %r11, 792(%r12) + std %r11, 800(%r12) + std %r11, 808(%r12) + std %r11, 816(%r12) + std %r11, 824(%r12) + std %r11, 832(%r12) + std %r11, 840(%r12) + std %r11, 848(%r12) + std %r11, 856(%r12) + std %r11, 864(%r12) + std %r11, 872(%r12) + std %r11, 880(%r12) + std %r11, 888(%r12) + std %r11, 896(%r12) + std %r11, 904(%r12) + std %r11, 912(%r12) + std %r11, 920(%r12) + std %r11, 928(%r12) + std %r11, 936(%r12) + std %r11, 944(%r12) + std %r11, 952(%r12) + std %r11, 960(%r12) + std %r11, 968(%r12) + std %r11, 976(%r12) + std %r11, 984(%r12) + std %r11, 992(%r12) + std %r11, 1000(%r12) + std %r11, 1008(%r12) + std %r11, 1016(%r12) + std %r11, 1024(%r12) + std %r11, 1032(%r12) + std %r11, 1040(%r12) + std %r11, 1048(%r12) + std %r11, 1056(%r12) + std %r11, 1064(%r12) + std %r11, 1072(%r12) + std %r11, 1080(%r12) + std %r11, 1088(%r12) + std %r11, 1096(%r12) + std %r11, 1104(%r12) + std %r11, 1112(%r12) + std %r11, 1120(%r12) + std %r11, 1128(%r12) + std %r11, 1136(%r12) + std %r11, 1144(%r12) + std %r11, 1152(%r12) + std %r11, 1160(%r12) + std %r11, 1168(%r12) + std %r11, 1176(%r12) + std %r11, 1184(%r12) + std %r11, 1192(%r12) + std %r11, 1200(%r12) + std %r11, 1208(%r12) + std %r11, 1216(%r12) + std %r11, 1224(%r12) + std %r11, 1232(%r12) + std %r11, 1240(%r12) + std %r11, 1248(%r12) + std %r11, 1256(%r12) + std %r11, 1264(%r12) + std %r11, 1272(%r12) + std %r11, 1280(%r12) + std %r11, 1288(%r12) + std %r11, 1296(%r12) + std %r11, 1304(%r12) + std %r11, 1312(%r12) + std %r11, 1320(%r12) + std %r11, 1328(%r12) + std %r11, 1336(%r12) + std %r11, 1344(%r12) + std %r11, 1352(%r12) + std %r11, 1360(%r12) + std %r11, 1368(%r12) + std %r11, 1376(%r12) + std %r11, 1384(%r12) + std %r11, 1392(%r12) + std %r11, 1400(%r12) + std %r11, 1408(%r12) + std %r11, 1416(%r12) + std %r11, 1424(%r12) + std %r11, 1432(%r12) + std %r11, 1440(%r12) + std %r11, 1448(%r12) + std %r11, 1456(%r12) + std %r11, 1464(%r12) + std %r11, 1472(%r12) + std %r11, 1480(%r12) + std %r11, 1488(%r12) + std %r11, 1496(%r12) + std %r11, 1504(%r12) + std %r11, 1512(%r12) + std %r11, 1520(%r12) + std %r11, 1528(%r12) + std %r11, 1536(%r12) + std %r11, 1544(%r12) + std %r11, 1552(%r12) + std %r11, 1560(%r12) + std %r11, 1568(%r12) + std %r11, 1576(%r12) + std %r11, 1584(%r12) + std %r11, 1592(%r12) + std %r11, 1600(%r12) + std %r11, 1608(%r12) + std %r11, 1616(%r12) + std %r11, 1624(%r12) + std %r11, 1632(%r12) + std %r11, 1640(%r12) + std %r11, 1648(%r12) + std %r11, 1656(%r12) + std %r11, 1664(%r12) + std %r11, 1672(%r12) + std %r11, 1680(%r12) + std %r11, 1688(%r12) + std %r11, 1696(%r12) + std %r11, 1704(%r12) + std %r11, 1712(%r12) + std %r11, 1720(%r12) + std %r11, 1728(%r12) + std %r11, 1736(%r12) + std %r11, 1744(%r12) + std %r11, 1752(%r12) + std %r11, 1760(%r12) + std %r11, 1768(%r12) + std %r11, 1776(%r12) + std %r11, 1784(%r12) + std %r11, 1792(%r12) + std %r11, 1800(%r12) + std %r11, 1808(%r12) + std %r11, 1816(%r12) + std %r11, 1824(%r12) + std %r11, 1832(%r12) + std %r11, 1840(%r12) + std %r11, 1848(%r12) + std %r11, 1856(%r12) + std %r11, 1864(%r12) + std %r11, 1872(%r12) + std %r11, 1880(%r12) + std %r11, 1888(%r12) + std %r11, 1896(%r12) + std %r11, 1904(%r12) + std %r11, 1912(%r12) + std %r11, 1920(%r12) + std %r11, 1928(%r12) + std %r11, 1936(%r12) + std %r11, 1944(%r12) + std %r11, 1952(%r12) + std %r11, 1960(%r12) + std %r11, 1968(%r12) + std %r11, 1976(%r12) + std %r11, 1984(%r12) + std %r11, 1992(%r12) + std %r11, 2000(%r12) + std %r11, 2008(%r12) + std %r11, 2016(%r12) + std %r11, 2024(%r12) + std %r11, 2032(%r12) + std %r11, 2040(%r12) + std %r11, 2048(%r12) + std %r11, 2056(%r12) + std %r11, 2064(%r12) + std %r11, 2072(%r12) + std %r11, 2080(%r12) + std %r11, 2088(%r12) + std %r11, 2096(%r12) + std %r11, 2104(%r12) + std %r11, 2112(%r12) + std %r11, 2120(%r12) + std %r11, 2128(%r12) + std %r11, 2136(%r12) + std %r11, 2144(%r12) + std %r11, 2152(%r12) + std %r11, 2160(%r12) + std %r11, 2168(%r12) + std %r11, 2176(%r12) + std %r11, 2184(%r12) + std %r11, 2192(%r12) + std %r11, 2200(%r12) + std %r11, 2208(%r12) + std %r11, 2216(%r12) + std %r11, 2224(%r12) + std %r11, 2232(%r12) + std %r11, 2240(%r12) + std %r11, 2248(%r12) + std %r11, 2256(%r12) + std %r11, 2264(%r12) + std %r11, 2272(%r12) + std %r11, 2280(%r12) + std %r11, 2288(%r12) + std %r11, 2296(%r12) + std %r11, 2304(%r12) + std %r11, 2312(%r12) + std %r11, 2320(%r12) + std %r11, 2328(%r12) + std %r11, 2336(%r12) + std %r11, 2344(%r12) + std %r11, 2352(%r12) + std %r11, 2360(%r12) + std %r11, 2368(%r12) + std %r11, 2376(%r12) + std %r11, 2384(%r12) + std %r11, 2392(%r12) + std %r11, 2400(%r12) + std %r11, 2408(%r12) + std %r11, 2416(%r12) + std %r11, 2424(%r12) + std %r11, 2432(%r12) + std %r11, 2440(%r12) + std %r11, 2448(%r12) + std %r11, 2456(%r12) + std %r11, 2464(%r12) + std %r11, 2472(%r12) + std %r11, 2480(%r12) + std %r11, 2488(%r12) + std %r11, 2496(%r12) + std %r11, 2504(%r12) + std %r11, 2512(%r12) + std %r11, 2520(%r12) + std %r11, 2528(%r12) + std %r11, 2536(%r12) + std %r11, 2544(%r12) + std %r11, 2552(%r12) + std %r11, 2560(%r12) + std %r11, 2568(%r12) + std %r11, 2576(%r12) + std %r11, 2584(%r12) + std %r11, 2592(%r12) + std %r11, 2600(%r12) + std %r11, 2608(%r12) + std %r11, 2616(%r12) + std %r11, 2624(%r12) + std %r11, 2632(%r12) + std %r11, 2640(%r12) + std %r11, 2648(%r12) + std %r11, 2656(%r12) + std %r11, 2664(%r12) + std %r11, 2672(%r12) + std %r11, 2680(%r12) + std %r11, 2688(%r12) + std %r11, 2696(%r12) + std %r11, 2704(%r12) + std %r11, 2712(%r12) + std %r11, 2720(%r12) + std %r11, 2728(%r12) + std %r11, 2736(%r12) + std %r11, 2744(%r12) + std %r11, 2752(%r12) + std %r11, 2760(%r12) + std %r11, 2768(%r12) + std %r11, 2776(%r12) + std %r11, 2784(%r12) + std %r11, 2792(%r12) + std %r11, 2800(%r12) + std %r11, 2808(%r12) + std %r11, 2816(%r12) + std %r11, 2824(%r12) + std %r11, 2832(%r12) + std %r11, 2840(%r12) + std %r11, 2848(%r12) + std %r11, 2856(%r12) + std %r11, 2864(%r12) + std %r11, 2872(%r12) + std %r11, 2880(%r12) + std %r11, 2888(%r12) + std %r11, 2896(%r12) + std %r11, 2904(%r12) + std %r11, 2912(%r12) + std %r11, 2920(%r12) + std %r11, 2928(%r12) + std %r11, 2936(%r12) + std %r11, 2944(%r12) + std %r11, 2952(%r12) + std %r11, 2960(%r12) + std %r11, 2968(%r12) + std %r11, 2976(%r12) + std %r11, 2984(%r12) + std %r11, 2992(%r12) + std %r11, 3000(%r12) + std %r11, 3008(%r12) + std %r11, 3016(%r12) + std %r11, 3024(%r12) + std %r11, 3032(%r12) + std %r11, 3040(%r12) + std %r11, 3048(%r12) + std %r11, 3056(%r12) + std %r11, 3064(%r12) + std %r11, 3072(%r12) + std %r11, 3080(%r12) + std %r11, 3088(%r12) + std %r11, 3096(%r12) + std %r11, 3104(%r12) + std %r11, 3112(%r12) + std %r11, 3120(%r12) + std %r11, 3128(%r12) + std %r11, 3136(%r12) + std %r11, 3144(%r12) + std %r11, 3152(%r12) + std %r11, 3160(%r12) + std %r11, 3168(%r12) + std %r11, 3176(%r12) + std %r11, 3184(%r12) + std %r11, 3192(%r12) + std %r11, 3200(%r12) + std %r11, 3208(%r12) + std %r11, 3216(%r12) + std %r11, 3224(%r12) + std %r11, 3232(%r12) + std %r11, 3240(%r12) + std %r11, 3248(%r12) + std %r11, 3256(%r12) + addi %r1, %r1, 3296 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/assembly/triple_des_ofb.s b/crates/verified-garbage-asm-powerpc64le/assembly/triple_des_ofb.s index 433653fbbdc..f43781d0d00 100644 --- a/crates/verified-garbage-asm-powerpc64le/assembly/triple_des_ofb.s +++ b/crates/verified-garbage-asm-powerpc64le/assembly/triple_des_ofb.s @@ -136,3 +136,157 @@ vg_triple_des_ofb: std %r11, 568(%r12) addi %r1, %r1, 608 blr + +vg_triple_des_ofb_final: + stdu %r1, -608(%r1) + addi %r7, %r1, 32 + mflr %r0 + std %r0, 544(%r7) + std %r29, 520(%r7) + std %r30, 528(%r7) + std %r31, 536(%r7) + or %r29, %r4, %r4 + or %r30, %r6, %r6 + or %r31, %r4, %r4 + or %r6, %r5, %r5 + or %r5, %r7, %r7 + lwz %r8, 0(%r31) + stw %r8, 552(%r5) + lwz %r8, 4(%r31) + stw %r8, 556(%r5) + or %r31, %r6, %r6 + cmpldi %cr0, %r30, 0 + beq %cr0, 20f +22: + lwz %r8, 552(%r5) + stw %r8, 512(%r5) + lwz %r8, 556(%r5) + stw %r8, 516(%r5) + addi %r4, %r5, 512 + bl {vg_triple_des_encrypt_block} + rldicl %r8, %r30, 61, 3 + cmpldi %cr0, %r8, 0 + beq %cr0, 23f + lwz %r8, 512(%r5) + stw %r8, 552(%r5) + lwz %r8, 516(%r5) + stw %r8, 556(%r5) + lwz %r8, 0(%r31) + lwz %r9, 512(%r5) + xor %r8, %r8, %r9 + stw %r8, 0(%r31) + lwz %r8, 4(%r31) + lwz %r9, 516(%r5) + xor %r8, %r8, %r9 + stw %r8, 4(%r31) + addi %r31, %r31, 8 + addi %r30, %r30, -8 + b 24f +23: + lwz %r8, 512(%r5) + stw %r8, 552(%r5) + lwz %r8, 516(%r5) + stw %r8, 556(%r5) + addi %r8, %r5, 512 +25: + lbz %r9, 0(%r31) + lbz %r10, 0(%r8) + xor %r9, %r9, %r10 + stb %r9, 0(%r31) + addi %r8, %r8, 1 + addi %r31, %r31, 1 + addi %r30, %r30, -1 + cmpldi %cr0, %r30, 0 + bne %cr0, 25b +24: + cmpldi %cr0, %r30, 0 + bne %cr0, 22b + b 21f +20: +21: + or %r31, %r29, %r29 + lwz %r8, 552(%r5) + stw %r8, 0(%r31) + lwz %r8, 556(%r5) + stw %r8, 4(%r31) + ld %r29, 520(%r5) + ld %r30, 528(%r5) + ld %r31, 536(%r5) + ld %r0, 544(%r5) + mtlr %r0 + addi %r12, %r1, 32 + li %r11, 0 + std %r11, 0(%r12) + std %r11, 8(%r12) + std %r11, 16(%r12) + std %r11, 24(%r12) + std %r11, 32(%r12) + std %r11, 40(%r12) + std %r11, 48(%r12) + std %r11, 56(%r12) + std %r11, 64(%r12) + std %r11, 72(%r12) + std %r11, 80(%r12) + std %r11, 88(%r12) + std %r11, 96(%r12) + std %r11, 104(%r12) + std %r11, 112(%r12) + std %r11, 120(%r12) + std %r11, 128(%r12) + std %r11, 136(%r12) + std %r11, 144(%r12) + std %r11, 152(%r12) + std %r11, 160(%r12) + std %r11, 168(%r12) + std %r11, 176(%r12) + std %r11, 184(%r12) + std %r11, 192(%r12) + std %r11, 200(%r12) + std %r11, 208(%r12) + std %r11, 216(%r12) + std %r11, 224(%r12) + std %r11, 232(%r12) + std %r11, 240(%r12) + std %r11, 248(%r12) + std %r11, 256(%r12) + std %r11, 264(%r12) + std %r11, 272(%r12) + std %r11, 280(%r12) + std %r11, 288(%r12) + std %r11, 296(%r12) + std %r11, 304(%r12) + std %r11, 312(%r12) + std %r11, 320(%r12) + std %r11, 328(%r12) + std %r11, 336(%r12) + std %r11, 344(%r12) + std %r11, 352(%r12) + std %r11, 360(%r12) + std %r11, 368(%r12) + std %r11, 376(%r12) + std %r11, 384(%r12) + std %r11, 392(%r12) + std %r11, 400(%r12) + std %r11, 408(%r12) + std %r11, 416(%r12) + std %r11, 424(%r12) + std %r11, 432(%r12) + std %r11, 440(%r12) + std %r11, 448(%r12) + std %r11, 456(%r12) + std %r11, 464(%r12) + std %r11, 472(%r12) + std %r11, 480(%r12) + std %r11, 488(%r12) + std %r11, 496(%r12) + std %r11, 504(%r12) + std %r11, 512(%r12) + std %r11, 520(%r12) + std %r11, 528(%r12) + std %r11, 536(%r12) + std %r11, 544(%r12) + std %r11, 552(%r12) + std %r11, 560(%r12) + std %r11, 568(%r12) + addi %r1, %r1, 608 + blr diff --git a/crates/verified-garbage-asm-powerpc64le/src/aes_ctr.rs b/crates/verified-garbage-asm-powerpc64le/src/aes_ctr.rs index b44fada3d91..0c01a8d5a48 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/aes_ctr.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/aes_ctr.rs @@ -40,3 +40,38 @@ b 21f vg_aes_ctr32 = sym super::aes::vg_aes_ctr32::vg_aes_ctr32, ) } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the 112 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "kf8h+CAAITmmAgh8AAAJ+AgAyfkQAOn5GAAJ+iAAafooAMn7MADp+zgAifp4G258eCOPfHgrsHx4QxN9eEs0fQLh6njkJkt5FFrmf1A4y394U0d9" +bl {vg_aes_ctr} +.base64 "AAA+KA==" +beq %cr0, 20f +.base64 "AAAgOUAANPlIADT5eHPDfXh75H14gwV+QADUOAEA4Dh4m2h+" +bl {vg_aes_ctr} +.base64 "QAAUOQ==" +22: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 22b +b 21f +20: +21: +.base64 "AAAU6AgA1OkQAPTpGAAU6iAAdOooANTrMAD06zgAlOqmAwh8IACBOQAAYDkAAGz5CABs+RAAbPkYAGz5IABs+SgAbPkwAGz5OABs+UAAbPlIAGz5cAAhOCAAgE4=""#, + vg_aes_ctr = sym super::aes_ctr::vg_aes_ctr, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/aes_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/aes_ofb.rs index 34f2505583a..2db7849086b 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/aes_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/aes_ofb.rs @@ -34,3 +34,39 @@ b 21f vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, ) } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the 96 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "of8h+CAAITmmAgh8AAAJ+AgAyfkQAOn5GAAJ+iAAafooAMn7MADp+zgAifp4G258eCOPfHgrsHx4QxN9eEs0fQLh6njkJkt5FFrmf1A4y394U0d9" +bl {vg_aes_ofb} +.base64 "AAA+KA==" +beq %cr0, 20f +.base64 "eHPDfXh75H14gwV+AQDAOHibZ34=" +bl {vg_aes_encrypt_blocks} +.base64 "eIMIfg==" +22: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 22b +b 21f +20: +21: +.base64 "AAAU6AgA1OkQAPTpGAAU6iAAdOooANTrMAD06zgAlOqmAwh8IACBOQAAYDkAAGz5CABs+RAAbPkYAGz5IABs+SgAbPkwAGz5OABs+WAAITggAIBO""#, + vg_aes_ofb = sym super::aes_ofb::vg_aes_ofb, + vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/blowfish_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/blowfish_ofb.rs index be65e54e8c0..3c566ed770f 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/blowfish_ofb.rs @@ -48,3 +48,59 @@ b 21f .base64 "eOu/f0gABYEAAB+RTAAFgQQAH5EoAKXrMADF6zgA5etAAAXopgMIfCAAgTkAAGA5AABs+QgAbPkQAGz5GABs+SAAbPkoAGz5MABs+TgAbPlAAGz5SABs+VAAbPlYAGz5gAAhOCAAgE4=""#, ) } + +/// Blowfish-OFB encryption or decryption (NIST SP 800-38A §6.4, Schneier, FSE 1994) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Blowfish encryption under the schedule written by `vg_blowfish_expand_key`. +/// +/// Contract: `VG.Spec.Blowfish.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 4168 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 128 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_blowfish_ofb_final(schedule: *const [u8; 4168], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "gf8h+CAA4TimAgh8QAAH+CgAp/swAMf7OADn+3gjnXx4M958eCOffHgrpnx4O+V8AAAfgUgABZEEAB+BTAAFkXgz33wAAD4o" +beq %cr0, 20f +22: +.base64 "SAAFgSAABZFMAAWBJAAFkXgrpnwAAMb5CADm+RAABvoYACb6AAAAOCAABjosBJB8BACQOSwErHwAEAM5" +23: +.base64 "AACIgXhihHzGB4l4IEYpef8AwDkG+Ct54A9reVAAa30+QMxVeHKMfThYjH14Ys59RvAreeAPa3lQAGt9PoDMVXhyjH04WIx9eGLOfQAAQDl4G298" +24: +.base64 "gvAref//azngD2t5UABrfThwa338/yk5AACPgThYjH14Y0p9AAGPgThYjH0+QIxVeGNKfQACj4E4WIx9PoCMVXhjSn0AA4+BOFiMfT7AjFV4Y0p9BADvOVB4g30A/4w5AAAsKA==" +bne %cr0, 24b +.base64 "BvgreeAPa3lQAGt9PsBMVXhSjH04WIx9eGJKfUbwK3ngD2t5UABrfT6ATFV4Uox9OFiMfXhiSn14U0d9xkWJeCBGKXn/AMA5BvgreeAPa3lQAGt9PkDMVXhyjH04WIx9eGLOfUbwK3ngD2t5UABrfT6AzFV4cox9OFiMfXhizn0AAEA5eBtvfA==" +25: +.base64 "gvAref//azngD2t5UABrfThwa338/yk5AASPgThYjH14Y0p9AAWPgThYjH0+QIxVeGNKfQAGj4E4WIx9PoCMVXhjSn0AB4+BOFiMfT7AjFV4Y0p9BADvOVB4g30A/4w5AAAsKA==" +bne %cr0, 25b +.base64 "BvgreeAPa3lQAGt9PsBMVXhSjH04WIx9eGJKfUbwK3ngD2t5UABrfT6ATFV4Uox9OFiMfXhiSn0UUud8xoOJeCBGKXn/AMA5BvgreeAPa3lQAGt9PkDMVXhyjH04WIx9eGLOfUbwK3ngD2t5UABrfT6AzFV4cox9OFiMfXhizn0AAEA5eBtvfA==" +26: +.base64 "gvAref//azngD2t5UABrfThwa338/yk5AAiPgThYjH14Y0p9AAmPgThYjH0+QIxVeGNKfQAKj4E4WIx9PoCMVXhjSn0AC4+BOFiMfT7AjFV4Y0p9BADvOVB4g30A/4w5AAAsKA==" +bne %cr0, 26b +.base64 "BvgreeAPa3lQAGt9PsBMVXhSjH04WIx9eGJKfUbwK3ngD2t5UABrfT6ATFV4Uox9OFiMfXhiSn14Uud8xsGJeCBGKXn/AMA5BvgreeAPa3lQAGt9PkDMVXhyjH04WIx9eGLOfUbwK3ngD2t5UABrfT6AzFV4cox9OFiMfXhizn0AAEA5eBtvfA==" +27: +.base64 "gvAref//azngD2t5UABrfThwa338/yk5AAyPgThYjH14Y0p9AA2PgThYjH0+QIxVeGNKfQAOj4E4WIx9PoCMVXhjSn0AD4+BOFiMfT7AjFV4Y0p9BADvOVB4g30A/4w5AAAsKA==" +bne %cr0, 27b +.base64 "BvgreeAPa3lQAGt9PsBMVXhSjH04WIx9eGJKfUbwK3ngD2t5UABrfT6ATFV4Uox9OFiMfXhiSn0UUud8eDqlfHgjjHx4K6R8eGOFfQQACDlQQIN9wO+MOQAALCg=" +bne %cr0, 23b +.base64 "AACIgXhijHwEAIiAeCqEfHhjhX0sBZB8BACQOSwFrHwIABA6//8xOngzxXwAAMbpCADm6RAABuoYACbqwujIewAAKCg=" +beq %cr0, 28f +.base64 "IAAFgUgABZEkAAWBTAAFkQAAH4EgACWBeEoIfQAAH5EEAB+BJAAlgXhKCH0EAB+RCAD/O/j/3js=" +b 29f +28: +.base64 "IAAFgUgABZEkAAWBTAAFkSAABTk=" +210: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 210b +29: +.base64 "AAA+KA==" +bne %cr0, 22b +b 21f +20: +21: +.base64 "eOu/f0gABYEAAB+RTAAFgQQAH5EoAKXrMADF6zgA5etAAAXopgMIfCAAgTkAAGA5AABs+QgAbPkQAGz5GABs+SAAbPkoAGz5MABs+TgAbPlAAGz5SABs+VAAbPlYAGz5gAAhOCAAgE4=""#, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/camellia_ctr.rs b/crates/verified-garbage-asm-powerpc64le/src/camellia_ctr.rs index 14a5b277896..075ef9ead24 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/camellia_ctr.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/camellia_ctr.rs @@ -60,3 +60,36 @@ b 29f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-CTR encryption or decryption (NIST SP 800-38A §6.5, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ctrFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 3520 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ctr_final(schedule: *const [u8; 272], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "kf8h+CAAATmmAgh8AAAI+AgAyPkQAOj5GAAI+iAAaPooAMj7MADo+zgAiPp4G258eCOPfHgrsHx4QxR9AuHqeOQmS3kUWuZ/UDjLf3hTR30=" +bl {vg_camellia_ctr} +.base64 "AAA+KA==" +beq %cr0, 20f +.base64 "AAAgOUAANPlIADT5eHPDfXh75H14gwV+QADUOAEA4Dg=" +bl {vg_camellia_ctr} +.base64 "QAAUOQ==" +22: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 22b +b 21f +20: +21: +.base64 "AAAU6AgA1OkQAPTpGAAU6iAAdOooANTrMAD06zgAlOqmAwh8IACBOQAAYDkAAGz5CABs+RAAbPkYAGz5IABs+SgAbPkwAGz5OABs+UAAbPlIAGz5cAAhOCAAgE4=""#, + vg_camellia_ctr = sym super::camellia_ctr::vg_camellia_ctr, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/camellia_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/camellia_ofb.rs index 81fbd245fe0..a59a4844b34 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/camellia_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/camellia_ofb.rs @@ -60,3 +60,71 @@ b 29f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 3408 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ofb_final(schedule: *const [u8; 272], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "sfIh+CAAATkgDYj7eCOcfHgrpHx4M8V8eDvmfHhDB32mAgh8CA0H+PAMp/v4DMf7AA3n+3gjnXx4M958eCOffHgrpnx4O+V8AAAfgRANBZEEAB+BFA0FkQgAH4EYDQWRDAAfgRwNBZF4M998eCumfHjjhH8AAKA4eOupf3jzyn94++t/eBtsfHjjgH94M8h8gAvI+YgL6PmQCwj6mAso+qALSPqoC2j6sAuI+rgLqPrAC8j6yAvo+tALCPvYCyj74AtI++gLaPvwC4j7+Auo+wAMyPsIDOj7/wDAPv8A1mLGB9Z6/wDWZv8A1mKAAcj6AP/APgD/1mLGB9Z6AP/WZgD/1mKIAcj6/wDAPgD/1mLGB9Z6AADWZgAA1mKQAcj6AADAPgAA1mLGB9Z6/wDWZgD/1mKYAcj6AADAPv8A1mLGB9Z6AP/WZgAA1mKgAcj67v/EOgAAJSg=" +beq %cr0, 20f +.base64 "AAA2KA==" +beq %cr0, 22f +.base64 "AAvoOAABYzgeAOA6" +b 23f +22: +.base64 "AAnoOMAAYzgWAOA6" +23: +.base64 "AAOIOAAAw+l4c899eHPQfXhz0X14c9J9eHPTfXhz1H14c9V9AAAAPwAAGGPGBxh7//8YZwAAGGMAACA/AP85Y8YHOXsAADlnAP85Y1VVYD9VVXtjxgd7e1VVe2dVVXtjMzOAPzMznGPGB5x7MzOcZzMznGMPD6A/Dw+9Y8YHvXsPD71nDw+9YwKE1nl4ctZ+OMDWfniyzn0AgNZ6eLLOfQKE9nl4etZ+OMDWfniy730AgNZ6eLLvfQKEFnp4gtZ+OMDWfniyEH4AgNZ6eLIQfgKENnp4itZ+OMDWfniyMX4AgNZ6eLIxfgKEVnp4ktZ+OMDWfniyUn4AgNZ6eLJSfgKEdnp4mtZ+OMDWfniyc34AgNZ6eLJzfgKElnp4otZ+OMDWfniylH4AgNZ6eLKUfgKEtnp4qtZ+OMDWfniytX4AgNZ6eLK1fgLC1nl4ctZ+OMjWfniyzn0AQNZ6eLLOfQLC9nl4etZ+OMjWfniy730AQNZ6eLLvfQLCFnp4gtZ+OMjWfniyEH4AQNZ6eLIQfgLCNnp4itZ+OMjWfniyMX4AQNZ6eLIxfgLCVnp4ktZ+OMjWfniyUn4AQNZ6eLJSfgLCdnp4mtZ+OMjWfniyc34AQNZ6eLJzfgLClnp4otZ+OMjWfniylH4AQNZ6eLKUfgLCtnp4qtZ+OMjWfniytX4AQNZ6eLK1fkL41nl4etZ+ONjWfniy730ACNZ6eLLOfUL4Fnp4itZ+ONjWfniyMX4ACNZ6eLIQfkL4Vnp4mtZ+ONjWfniyc34ACNZ6eLJSfkL4lnp4qtZ+ONjWfniytX4ACNZ6eLKUfoLw1nl4gtZ+OODWfniyEH4AENZ6eLLOfYLw9nl4itZ+OODWfniyMX4AENZ6eLLvfYLwVnp4otZ+OODWfniylH4AENZ6eLJSfoLwdnp4qtZ+OODWfniytX4AENZ6eLJzfgLh1nl4ktZ+OOjWfniyUn4AINZ6eLLOfQLh9nl4mtZ+OOjWfniyc34AINZ6eLLvfQLhFnp4otZ+OOjWfniylH4AINZ6eLIQfgLhNnp4qtZ+OOjWfniytX4AINZ6eLIxfgAAxPkIAOT5EAAE+hgAJPogAET6KABk+jAAhPo4AKT6QACEOAgAw+l4c899eHPQfXhz0X14c9J9eHPTfXhz1H14c9V9AAAAPwAAGGPGBxh7//8YZwAAGGMAACA/AP85Y8YHOXsAADlnAP85Y1VVYD9VVXtjxgd7e1VVe2dVVXtjMzOAPzMznGPGB5x7MzOcZzMznGMPD6A/Dw+9Y8YHvXsPD71nDw+9YwKE1nl4ctZ+OMDWfniyzn0AgNZ6eLLOfQKE9nl4etZ+OMDWfniy730AgNZ6eLLvfQKEFnp4gtZ+OMDWfniyEH4AgNZ6eLIQfgKENnp4itZ+OMDWfniyMX4AgNZ6eLIxfgKEVnp4ktZ+OMDWfniyUn4AgNZ6eLJSfgKEdnp4mtZ+OMDWfniyc34AgNZ6eLJzfgKElnp4otZ+OMDWfniylH4AgNZ6eLKUfgKEtnp4qtZ+OMDWfniytX4AgNZ6eLK1fgLC1nl4ctZ+OMjWfniyzn0AQNZ6eLLOfQLC9nl4etZ+OMjWfniy730AQNZ6eLLvfQLCFnp4gtZ+OMjWfniyEH4AQNZ6eLIQfgLCNnp4itZ+OMjWfniyMX4AQNZ6eLIxfgLCVnp4ktZ+OMjWfniyUn4AQNZ6eLJSfgLCdnp4mtZ+OMjWfniyc34AQNZ6eLJzfgLClnp4otZ+OMjWfniylH4AQNZ6eLKUfgLCtnp4qtZ+OMjWfniytX4AQNZ6eLK1fkL41nl4etZ+ONjWfniy730ACNZ6eLLOfUL4Fnp4itZ+ONjWfniyMX4ACNZ6eLIQfkL4Vnp4mtZ+ONjWfniyc34ACNZ6eLJSfkL4lnp4qtZ+ONjWfniytX4ACNZ6eLKUfoLw1nl4gtZ+OODWfniyEH4AENZ6eLLOfYLw9nl4itZ+OODWfniyMX4AENZ6eLLvfYLwVnp4otZ+OODWfniylH4AENZ6eLJSfoLwdnp4qtZ+OODWfniytX4AENZ6eLJzfgLh1nl4ktZ+OOjWfniyUn4AINZ6eLLOfQLh9nl4mtZ+OOjWfniyc34AINZ6eLLvfQLhFnp4otZ+OOjWfniylH4AINZ6eLIQfgLhNnp4qtZ+OOjWfniytX4AINZ6eLIxfgAAxPkIAOT5EAAE+hgAJPogAET6KABk+jAAhPo4AKT6QACEOPj/Yzg=" +24: +.base64 "AADD6Xhzz314c9B9eHPRfXhz0n14c9N9eHPUfXhz1X0AAAA/AAAYY8YHGHv//xhnAAAYYwAAID8A/zljxgc5ewAAOWcA/zljVVVgP1VVe2PGB3t7VVV7Z1VVe2MzM4A/MzOcY8YHnHszM5xnMzOcYw8PoD8PD71jxge9ew8PvWcPD71jAoTWeXhy1n44wNZ+eLLOfQCA1np4ss59AoT2eXh61n44wNZ+eLLvfQCA1np4su99AoQWeniC1n44wNZ+eLIQfgCA1np4shB+AoQ2eniK1n44wNZ+eLIxfgCA1np4sjF+AoRWeniS1n44wNZ+eLJSfgCA1np4slJ+AoR2enia1n44wNZ+eLJzfgCA1np4snN+AoSWenii1n44wNZ+eLKUfgCA1np4spR+AoS2eniq1n44wNZ+eLK1fgCA1np4srV+AsLWeXhy1n44yNZ+eLLOfQBA1np4ss59AsL2eXh61n44yNZ+eLLvfQBA1np4su99AsIWeniC1n44yNZ+eLIQfgBA1np4shB+AsI2eniK1n44yNZ+eLIxfgBA1np4sjF+AsJWeniS1n44yNZ+eLJSfgBA1np4slJ+AsJ2enia1n44yNZ+eLJzfgBA1np4snN+AsKWenii1n44yNZ+eLKUfgBA1np4spR+AsK2eniq1n44yNZ+eLK1fgBA1np4srV+QvjWeXh61n442NZ+eLLvfQAI1np4ss59QvgWeniK1n442NZ+eLIxfgAI1np4shB+QvhWenia1n442NZ+eLJzfgAI1np4slJ+QviWeniq1n442NZ+eLK1fgAI1np4spR+gvDWeXiC1n444NZ+eLIQfgAQ1np4ss59gvD2eXiK1n444NZ+eLIxfgAQ1np4su99gvBWenii1n444NZ+eLKUfgAQ1np4slJ+gvB2eniq1n444NZ+eLK1fgAQ1np4snN+AuHWeXiS1n446NZ+eLJSfgAg1np4ss59AuH2eXia1n446NZ+eLJzfgAg1np4su99AuEWenii1n446NZ+eLKUfgAg1np4shB+AuE2eniq1n446NZ+eLK1fgAg1np4sjF+AADE+QgA5PkQAAT6GAAk+iAARPooAGT6MACE+jgApPpAAIQ4+P9jOP//9zoAADco" +bne %cr0, 24b +.base64 "+P9jOAAAw+l4c899eHPQfXhz0X14c9J9eHPTfXhz1H14c9V9AAAAPwAAGGPGBxh7//8YZwAAGGMAACA/AP85Y8YHOXsAADlnAP85Y1VVYD9VVXtjxgd7e1VVe2dVVXtjMzOAPzMznGPGB5x7MzOcZzMznGMPD6A/Dw+9Y8YHvXsPD71nDw+9YwKE1nl4ctZ+OMDWfniyzn0AgNZ6eLLOfQKE9nl4etZ+OMDWfniy730AgNZ6eLLvfQKEFnp4gtZ+OMDWfniyEH4AgNZ6eLIQfgKENnp4itZ+OMDWfniyMX4AgNZ6eLIxfgKEVnp4ktZ+OMDWfniyUn4AgNZ6eLJSfgKEdnp4mtZ+OMDWfniyc34AgNZ6eLJzfgKElnp4otZ+OMDWfniylH4AgNZ6eLKUfgKEtnp4qtZ+OMDWfniytX4AgNZ6eLK1fgLC1nl4ctZ+OMjWfniyzn0AQNZ6eLLOfQLC9nl4etZ+OMjWfniy730AQNZ6eLLvfQLCFnp4gtZ+OMjWfniyEH4AQNZ6eLIQfgLCNnp4itZ+OMjWfniyMX4AQNZ6eLIxfgLCVnp4ktZ+OMjWfniyUn4AQNZ6eLJSfgLCdnp4mtZ+OMjWfniyc34AQNZ6eLJzfgLClnp4otZ+OMjWfniylH4AQNZ6eLKUfgLCtnp4qtZ+OMjWfniytX4AQNZ6eLK1fkL41nl4etZ+ONjWfniy730ACNZ6eLLOfUL4Fnp4itZ+ONjWfniyMX4ACNZ6eLIQfkL4Vnp4mtZ+ONjWfniyc34ACNZ6eLJSfkL4lnp4qtZ+ONjWfniytX4ACNZ6eLKUfoLw1nl4gtZ+OODWfniyEH4AENZ6eLLOfYLw9nl4itZ+OODWfniyMX4AENZ6eLLvfYLwVnp4otZ+OODWfniylH4AENZ6eLJSfoLwdnp4qtZ+OODWfniytX4AENZ6eLJzfgLh1nl4ktZ+OOjWfniyUn4AINZ6eLLOfQLh9nl4mtZ+OOjWfniyc34AINZ6eLLvfQLhFnp4otZ+OOjWfniylH4AINZ6eLIQfgLhNnp4qtZ+OOjWfniytX4AINZ6eLIxfgAAxPkIAOT5EAAE+hgAJPogAET6KABk+jAAhPo4AKT6QACEOAgAw+l4c899eHPQfXhz0X14c9J9eHPTfXhz1H14c9V9AAAAPwAAGGPGBxh7//8YZwAAGGMAACA/AP85Y8YHOXsAADlnAP85Y1VVYD9VVXtjxgd7e1VVe2dVVXtjMzOAPzMznGPGB5x7MzOcZzMznGMPD6A/Dw+9Y8YHvXsPD71nDw+9YwKE1nl4ctZ+OMDWfniyzn0AgNZ6eLLOfQKE9nl4etZ+OMDWfniy730AgNZ6eLLvfQKEFnp4gtZ+OMDWfniyEH4AgNZ6eLIQfgKENnp4itZ+OMDWfniyMX4AgNZ6eLIxfgKEVnp4ktZ+OMDWfniyUn4AgNZ6eLJSfgKEdnp4mtZ+OMDWfniyc34AgNZ6eLJzfgKElnp4otZ+OMDWfniylH4AgNZ6eLKUfgKEtnp4qtZ+OMDWfniytX4AgNZ6eLK1fgLC1nl4ctZ+OMjWfniyzn0AQNZ6eLLOfQLC9nl4etZ+OMjWfniy730AQNZ6eLLvfQLCFnp4gtZ+OMjWfniyEH4AQNZ6eLIQfgLCNnp4itZ+OMjWfniyMX4AQNZ6eLIxfgLCVnp4ktZ+OMjWfniyUn4AQNZ6eLJSfgLCdnp4mtZ+OMjWfniyc34AQNZ6eLJzfgLClnp4otZ+OMjWfniylH4AQNZ6eLKUfgLCtnp4qtZ+OMjWfniytX4AQNZ6eLK1fkL41nl4etZ+ONjWfniy730ACNZ6eLLOfUL4Fnp4itZ+ONjWfniyMX4ACNZ6eLIQfkL4Vnp4mtZ+ONjWfniyc34ACNZ6eLJSfkL4lnp4qtZ+ONjWfniytX4ACNZ6eLKUfoLw1nl4gtZ+OODWfniyEH4AENZ6eLLOfYLw9nl4itZ+OODWfniyMX4AENZ6eLLvfYLwVnp4otZ+OODWfniylH4AENZ6eLJSfoLwdnp4qtZ+OODWfniytX4AENZ6eLJzfgLh1nl4ktZ+OOjWfniyUn4AINZ6eLLOfQLh9nl4mtZ+OOjWfniyc34AINZ6eLLvfQLhFnp4otZ+OOjWfniylH4AINZ6eLIQfgLhNnp4qtZ+OOjWfniytX4AINZ6eLIxfgAAxPkIAOT5EAAE+hgAJPogAET6KABk+jAAhPo4AKT6QACEOA==" +b 21f +20: +.base64 "AAA2KA==" +beq %cr0, 25f +.base64 "AAvoOCIA4Do=" +b 26f +25: +.base64 "AAnoOBoA4Do=" +26: +.base64 "AAOIOA==" +27: +.base64 "AADD6Xhzz314c9B9eHPRfXhz0n14c9N9eHPUfXhz1X0AAAA/AAAYY8YHGHv//xhnAAAYYwAAID8A/zljxgc5ewAAOWcA/zljVVVgP1VVe2PGB3t7VVV7Z1VVe2MzM4A/MzOcY8YHnHszM5xnMzOcYw8PoD8PD71jxge9ew8PvWcPD71jAoTWeXhy1n44wNZ+eLLOfQCA1np4ss59AoT2eXh61n44wNZ+eLLvfQCA1np4su99AoQWeniC1n44wNZ+eLIQfgCA1np4shB+AoQ2eniK1n44wNZ+eLIxfgCA1np4sjF+AoRWeniS1n44wNZ+eLJSfgCA1np4slJ+AoR2enia1n44wNZ+eLJzfgCA1np4snN+AoSWenii1n44wNZ+eLKUfgCA1np4spR+AoS2eniq1n44wNZ+eLK1fgCA1np4srV+AsLWeXhy1n44yNZ+eLLOfQBA1np4ss59AsL2eXh61n44yNZ+eLLvfQBA1np4su99AsIWeniC1n44yNZ+eLIQfgBA1np4shB+AsI2eniK1n44yNZ+eLIxfgBA1np4sjF+AsJWeniS1n44yNZ+eLJSfgBA1np4slJ+AsJ2enia1n44yNZ+eLJzfgBA1np4snN+AsKWenii1n44yNZ+eLKUfgBA1np4spR+AsK2eniq1n44yNZ+eLK1fgBA1np4srV+QvjWeXh61n442NZ+eLLvfQAI1np4ss59QvgWeniK1n442NZ+eLIxfgAI1np4shB+QvhWenia1n442NZ+eLJzfgAI1np4slJ+QviWeniq1n442NZ+eLK1fgAI1np4spR+gvDWeXiC1n444NZ+eLIQfgAQ1np4ss59gvD2eXiK1n444NZ+eLIxfgAQ1np4su99gvBWenii1n444NZ+eLKUfgAQ1np4slJ+gvB2eniq1n444NZ+eLK1fgAQ1np4snN+AuHWeXiS1n446NZ+eLJSfgAg1np4ss59AuH2eXia1n446NZ+eLJzfgAg1np4su99AuEWenii1n446NZ+eLKUfgAg1np4shB+AuE2eniq1n446NZ+eLK1fgAg1np4sjF+AADE+QgA5PkQAAT6GAAk+iAARPooAGT6MACE+jgApPpAAIQ4CABjOP//9zoAADco" +bne %cr0, 27b +21: +.base64 "gAvI6YgL6OmQCwjqmAso6qALSOqoC2jqsAuI6rgLqOrAC8jqyAvo6tALCOvYCyjr4AtI6+gLaOvwC4jr+Auo6wAMyOsIDOjreDPFfHhjg314Axx8eEs9fXhTXn14W399AAA+KA==" +beq %cr0, 28f +210: +.base64 "EA0FgRAMBZEUDQWBFAwFkRgNBYEYDAWRHA0FgRwMBZF4G2p8eCumfHjjg394K6R8ngGgOA==" +bl {vg_camellia_crypt_prepared} +.base64 "eDPFfHhTQ30C4ch7AAAoKA==" +beq %cr0, 211f +.base64 "EAwFgRANBZEUDAWBFA0FkRgMBYEYDQWRHAwFgRwNBZEAAB+BEAwlgXhKCH0AAB+RBAAfgRQMJYF4Sgh9BAAfkQgAH4EYDCWBeEoIfQgAH5EMAB+BHAwlgXhKCH0MAB+READ/O/D/3js=" +b 212f +211: +.base64 "EAwFgRANBZEUDAWBFA0FkRgMBYEYDQWRHAwFgRwNBZEQDAU5" +213: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 213b +212: +.base64 "AAA+KA==" +bne %cr0, 210b +b 29f +28: +29: +.base64 "eOu/fxANBYEAAB+RFA0FgQQAH5EYDQWBCAAfkRwNBYEMAB+R8Ayl6/gMxesADeXrCA0F6KYDCHwgDYXrIACBOQAAYDkAAGz5CABs+RAAbPkYAGz5IABs+SgAbPkwAGz5OABs+UAAbPlIAGz5UABs+VgAbPlgAGz5aABs+XAAbPl4AGz5gABs+YgAbPmQAGz5mABs+aAAbPmoAGz5sABs+bgAbPnAAGz5yABs+dAAbPnYAGz54ABs+egAbPnwAGz5+ABs+QABbPkIAWz5EAFs+RgBbPkgAWz5KAFs+TABbPk4AWz5QAFs+UgBbPlQAWz5WAFs+WABbPloAWz5cAFs+XgBbPmAAWz5iAFs+ZABbPmYAWz5oAFs+agBbPmwAWz5uAFs+cABbPnIAWz50AFs+dgBbPngAWz56AFs+fABbPn4AWz5AAJs+QgCbPkQAmz5GAJs+SACbPkoAmz5MAJs+TgCbPlAAmz5SAJs+VACbPlYAmz5YAJs+WgCbPlwAmz5eAJs+YACbPmIAmz5kAJs+ZgCbPmgAmz5qAJs+bACbPm4Amz5wAJs+cgCbPnQAmz52AJs+eACbPnoAmz58AJs+fgCbPkAA2z5CANs+RADbPkYA2z5IANs+SgDbPkwA2z5OANs+UADbPlIA2z5UANs+VgDbPlgA2z5aANs+XADbPl4A2z5gANs+YgDbPmQA2z5mANs+aADbPmoA2z5sANs+bgDbPnAA2z5yANs+dADbPnYA2z54ANs+egDbPnwA2z5+ANs+QAEbPkIBGz5EARs+RgEbPkgBGz5KARs+TAEbPk4BGz5QARs+UgEbPlQBGz5WARs+WAEbPloBGz5cARs+XgEbPmABGz5iARs+ZAEbPmYBGz5oARs+agEbPmwBGz5uARs+cAEbPnIBGz50ARs+dgEbPngBGz56ARs+fAEbPn4BGz5AAVs+QgFbPkQBWz5GAVs+SAFbPkoBWz5MAVs+TgFbPlABWz5SAVs+VAFbPlYBWz5YAVs+WgFbPlwBWz5eAVs+YAFbPmIBWz5kAVs+ZgFbPmgBWz5qAVs+bAFbPm4BWz5wAVs+cgFbPnQBWz52AVs+eAFbPnoBWz58AVs+fgFbPkABmz5CAZs+RAGbPkYBmz5IAZs+SgGbPkwBmz5OAZs+UAGbPlIBmz5UAZs+VgGbPlgBmz5aAZs+XAGbPl4Bmz5gAZs+YgGbPmQBmz5mAZs+aAGbPmoBmz5sAZs+bgGbPnABmz5yAZs+dAGbPnYBmz54AZs+egGbPnwBmz5+AZs+QAHbPkIB2z5EAds+RgHbPkgB2z5KAds+TAHbPk4B2z5QAds+UgHbPlQB2z5WAds+WAHbPloB2z5cAds+XgHbPmAB2z5iAds+ZAHbPmYB2z5oAds+agHbPmwB2z5uAds+cAHbPnIB2z50Ads+dgHbPngB2z56Ads+fAHbPn4B2z5AAhs+QgIbPkQCGz5GAhs+SAIbPkoCGz5MAhs+TgIbPlACGz5SAhs+VAIbPlYCGz5YAhs+WgIbPlwCGz5eAhs+YAIbPmICGz5kAhs+ZgIbPmgCGz5qAhs+bAIbPm4CGz5wAhs+cgIbPnQCGz52Ahs+eAIbPnoCGz58Ahs+fgIbPkACWz5CAls+RAJbPkYCWz5IAls+SgJbPkwCWz5OAls+UAJbPlICWz5UAls+VgJbPlgCWz5aAls+XAJbPl4CWz5gAls+YgJbPmQCWz5mAls+aAJbPmoCWz5sAls+bgJbPnACWz5yAls+dAJbPnYCWz54Als+egJbPnwCWz5+Als+QAKbPkICmz5EAps+RgKbPkgCmz5KAps+TAKbPk4Cmz5QAps+UgKbPlQCmz5WAps+WAKbPloCmz5cAps+XgKbPmACmz5iAps+ZAKbPmYCmz5oAps+agKbPmwCmz5uAps+cAKbPnICmz50Aps+dgKbPngCmz56Aps+fAKbPn4Cmz5AAts+QgLbPkQC2z5GAts+SALbPkoC2z5MAts+TgLbPlAC2z5SAts+VALbPlYC2z5YAts+WgLbPlwC2z5eAts+YALbPmIC2z5kAts+ZgLbPmgC2z5qAts+bALbPm4C2z5wAts+cgLbPnQC2z52Ats+eALbPnoC2z58Ats+fgLbPkADGz5CAxs+RAMbPkYDGz5IAxs+SgMbPkwDGz5OAxs+UAMbPlIDGz5UAxs+VgMbPlgDGz5aAxs+XAMbPl4DGz5gAxs+YgMbPmQDGz5mAxs+aAMbPmoDGz5sAxs+bgMbPnADGz5yAxs+dAMbPnYDGz54Axs+egMbPnwDGz5+Axs+QANbPkIDWz5EA1s+RgNbPkgDWz5KA1s+VANITggAIBO""#, + vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/cast5_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/cast5_ofb.rs index 69844ebbec0..7ea23bbc95d 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/cast5_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/cast5_ofb.rs @@ -139,3 +139,160 @@ b 218f VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, ) } + +/// CAST5-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 2144 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is CAST5 encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_cast5_expand_key` writes them. +/// +/// Contract: `VG.Spec.Cast5.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 12 (for a key of up to 10 bytes) or 16 (for a longer one). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 208 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_cast5_ofb_final(schedule: *const [u8; 128], rounds: usize, iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "Mf8h+CAAATl4I4p8eCukfHgzxXx4O+Z8eEMHffT/SjkAACoo" +beq %cr0, 20f +.base64 "pgIIfJgAB/iAAKf7iADH+5AA5/t4I518eDPefHgjn3x4K6Z8eDvlfAAAH4GgAAWRBAAfgaQABZF4M998AAA+KA==" +beq %cr0, 22f +24: +.base64 "oAAFgQAABZGkAAWBBAAFkXjrpn9488d/CADF+RAA5fkYAAX6IAAl+igARfowAGX6OACF+kAApfpIAMX6UADl+lgABftgACX7aABF+3AAZft4AIX7" +bcl 20, 31, 2f +2: +mflr %r27 +addis %r27, %r27, ({VG_CAST5_S1234} - 2b)@ha +addi %r27, %r27, ({VG_CAST5_S1234} - 2b)@l +.base64 "/wBAOwAAADgQAIA4LAQFfQQABTssBDh9eBtqfHgji3wBAIA5" +25: +.base64 "AAAsKA==" +beq %cr0, 26f +.base64 "//8MOwAAOCg=" +beq %cr0, 28f +.base64 "AACKg3hKnH8=" +b 29f +28: +.base64 "AACKgxRKnH8=" +29: +b 27f +26: +.base64 "AACKg1DgiX8=" +27: +.base64 "QACqgwb4vnvgD957///eOz4ImFd4wpl/OPA5f3jKHH9G8L574A/ee///3js+EJhXeMKZfzjwOX94yhx/hui+e+AP3nv//947PiCYV3jCmX848Dl/eMocf8bgvnvgD957///eOz5AmFd4wpl/OPA5f3jKHH8G2b574A/ee///3js+gJhXeMKZfzjwOX94yhx/ONCOfz7Cj1c40O99PoSQVzjQEH4+RpFXeNt3fwAAwDoAAEA6AABgOgAAgDoAAKA6" +210: +.base64 "AAA3g3iy2H3//xg74A8Ye1AAGH84wDl/eMtSfgQAN4N4svh9//8YO+APGHtQABh/OMA5f3jLc34IADeDeLIYfv//GDvgDxh7UAAYfzjAOX94y5R+DAA3g3iyOH7//xg74A8Ye1AAGH84wDl/eMu1fhAA9zoBANY6AP8WOwAAOCg=" +bne %cr0, 210b +.base64 "AAAsKA==" +beq %cr0, 211f +.base64 "//8MOwAAOCg=" +beq %cr0, 213f +.base64 "UKiUfxSanH94kpx/" +b 214f +213: +.base64 "eKK8flDgk38Ukpx/" +214: +b 212f +211: +.base64 "FKKVf3ianH9Q4JJ/" +212: +.base64 "eEKcf3hLKH1444l/BABKOf7/DDsAADgo" +beq %cr0, 215f +.base64 "AQCMOQ==" +b 216f +215: +.base64 "AACAOQ==" +216: +.base64 "//9rOQAAKyg=" +bne %cr0, 25b +.base64 "LAUlfQQABTssBRh9CADF6RAA5ekYAAXqIAAl6igAReowAGXqOACF6kAApepIAMXqUADl6lgABetgACXraABF63AAZet4AIXreDPdfHg7/nzC6Mh7AAAoKA==" +beq %cr0, 217f +.base64 "AAAFgaAABZEEAAWBpAAFkQAAH4EAACWBeEoIfQAAH5EEAB+BBAAlgXhKCH0EAB+RCAD/O/j/3js=" +b 218f +217: +.base64 "AAAFgaAABZEEAAWBpAAFkQAABTk=" +219: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 219b +218: +.base64 "AAA+KA==" +bne %cr0, 24b +b 23f +22: +23: +.base64 "eOu/f6AABYEAAB+RpAAFgQQAH5GAAKXriADF65AA5euYAAXopgMIfA==" +b 21f +20: +.base64 "pgIIfJgAB/iAAKf7iADH+5AA5/t4I518eDPefHgjn3x4K6Z8eDvlfAAAH4GgAAWRBAAfgaQABZF4M998AAA+KA==" +beq %cr0, 220f +222: +.base64 "oAAFgQAABZGkAAWBBAAFkXjrpn9488d/CADF+RAA5fkYAAX6IAAl+igARfowAGX6OACF+kAApfpIAMX6UADl+lgABftgACX7aABF+3AAZft4AIX7" +bcl 20, 31, 2f +2: +mflr %r27 +addis %r27, %r27, ({VG_CAST5_S1234} - 2b)@ha +addi %r27, %r27, ({VG_CAST5_S1234} - 2b)@l +.base64 "/wBAOwAAADgMAIA4LAQFfQQABTssBDh9eBtqfHgji3wBAIA5" +223: +.base64 "AAAsKA==" +beq %cr0, 224f +.base64 "//8MOwAAOCg=" +beq %cr0, 226f +.base64 "AACKg3hKnH8=" +b 227f +226: +.base64 "AACKgxRKnH8=" +227: +b 225f +224: +.base64 "AACKg1DgiX8=" +225: +.base64 "QACqgwb4vnvgD957///eOz4ImFd4wpl/OPA5f3jKHH9G8L574A/ee///3js+EJhXeMKZfzjwOX94yhx/hui+e+AP3nv//947PiCYV3jCmX848Dl/eMocf8bgvnvgD957///eOz5AmFd4wpl/OPA5f3jKHH8G2b574A/ee///3js+gJhXeMKZfzjwOX94yhx/ONCOfz7Cj1c40O99PoSQVzjQEH4+RpFXeNt3fwAAwDoAAEA6AABgOgAAgDoAAKA6" +228: +.base64 "AAA3g3iy2H3//xg74A8Ye1AAGH84wDl/eMtSfgQAN4N4svh9//8YO+APGHtQABh/OMA5f3jLc34IADeDeLIYfv//GDvgDxh7UAAYfzjAOX94y5R+DAA3g3iyOH7//xg74A8Ye1AAGH84wDl/eMu1fhAA9zoBANY6AP8WOwAAOCg=" +bne %cr0, 228b +.base64 "AAAsKA==" +beq %cr0, 229f +.base64 "//8MOwAAOCg=" +beq %cr0, 231f +.base64 "UKiUfxSanH94kpx/" +b 232f +231: +.base64 "eKK8flDgk38Ukpx/" +232: +b 230f +229: +.base64 "FKKVf3ianH9Q4JJ/" +230: +.base64 "eEKcf3hLKH1444l/BABKOf7/DDsAADgo" +beq %cr0, 233f +.base64 "AQCMOQ==" +b 234f +233: +.base64 "AACAOQ==" +234: +.base64 "//9rOQAAKyg=" +bne %cr0, 223b +.base64 "LAUlfQQABTssBRh9CADF6RAA5ekYAAXqIAAl6igAReowAGXqOACF6kAApepIAMXqUADl6lgABetgACXraABF63AAZet4AIXreDPdfHg7/nzC6Mh7AAAoKA==" +beq %cr0, 235f +.base64 "AAAFgaAABZEEAAWBpAAFkQAAH4EAACWBeEoIfQAAH5EEAB+BBAAlgXhKCH0EAB+RCAD/O/j/3js=" +b 236f +235: +.base64 "AAAFgaAABZEEAAWBpAAFkQAABTk=" +237: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 237b +236: +.base64 "AAA+KA==" +bne %cr0, 222b +b 221f +220: +221: +.base64 "eOu/f6AABYEAAB+RpAAFgQQAH5GAAKXriADF65AA5euYAAXopgMIfA==" +21: +.base64 "IACBOQAAYDkAAGz5CABs+RAAbPkYAGz5IABs+SgAbPkwAGz5OABs+UAAbPlIAGz5UABs+VgAbPlgAGz5aABs+XAAbPl4AGz5gABs+YgAbPmQAGz5mABs+aAAbPmoAGz50AAhOCAAgE4=""#, + VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/idea_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/idea_ofb.rs index cecc6aea2a3..8f35f42ed32 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/idea_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/idea_ofb.rs @@ -28,3 +28,39 @@ b 21f .base64 "eOu/fygABYEAAB+RLAAFgQQAH5EIAKXrEADF6xgA5esgAAXopgMIfCAAgTkAAGA5AABs+QgAbPkQAGz5GABs+SAAbPkoAGz5MABs+TgAbPlgACE4IACATg==""#, ) } + +/// IDEA-OFB encryption or decryption (NIST SP 800-38A §6.4, Lai 1992 §3.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is IDEA encryption under the encryption subkeys written by `vg_idea_expand_key`. +/// +/// Contract: `VG.Spec.Idea.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 104 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 96 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_idea_ofb_final(schedule: *const [u8; 104], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "of8h+CAA4TimAgh8IAAH+AgAp/sQAMf7GADn+3gjnXx4M958eCOffHgrpnx4O+V8AAAfgSgABZEEAB+BLAAFkXgz33wAAD4o" +beq %cr0, 20f +22: +.base64 "KAAFgQAABZEsAAWBBAAFkQAAADj//wBgAACFOAAAxIjkRcZ4AQBkiXhbxnwCAOSI5EXneAMAZIl4W+d8BAAEieRFCHkFAGSJeFsIfQYAJInkRSl5BwBkiXhbKX14M8t8AACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9BgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX0CAIOBFGLnfDgA53wEAIOBFGIIfTgACH14Qst8CACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfQoAg4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8DACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9EgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX0OAIOBFGLnfDgA53wQAIOBFGIIfTgACH14Qst8FACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfRYAg4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8GACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9HgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX0aAIOBFGLnfDgA53wcAIOBFGIIfTgACH14Qst8IACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfSIAg4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8JACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9KgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX0mAIOBFGLnfDgA53woAIOBFGIIfTgACH14Qst8LACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfS4Ag4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8MACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9NgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX0yAIOBFGLnfDgA53w0AIOBFGIIfTgACH14Qst8OACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfToAg4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8PACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9QgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX0+AIOBFGLnfDgA53xAAIOBFGIIfTgACH14Qst8RACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfUYAg4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8SACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9TgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX1KAIOBFGLnfDgA53xMAIOBFGIIfTgACH14Qst8UACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfVIAg4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8VACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9WgCDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjiX1WAIOBFGLnfDgA53xYAIOBFGIIfTgACH14Qst8XACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjin14Sut8FFJrfV4Ag4H//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH0UYkp9OABKfXhixnx4Ygh9eFLnfHhSKX14O+t8eEMHfXhbaH14M8t8YACDgf//azk4AGt9AQBrOf//jDk4AIx9AQCMOdJha304AGx9AoRreVBgi33gD4t5FFqMfeSDa3kUWox9OACMfXhjhn14Syt9ZACDgQKEjHn//2s5OABrfQEAazn//4w5OACMfQEAjDnSYWt9OABsfQKEa3lQYIt94A+LeRRajH3kg2t5FFqMfTgAjH14Y4l9YgCDgRRiCH04AAh9ZACDgRRi53w4AOd8AQDEmALCy3gAAGSZAwAEmQLCC3kCAGSZBQDkmALC63gEAGSZBwAkmQLCK3kGAGSZwujIewAAKCg=" +beq %cr0, 23f +.base64 "AAAFgSgABZEEAAWBLAAFkQAAH4EAACWBeEoIfQAAH5EEAB+BBAAlgXhKCH0EAB+RCAD/O/j/3js=" +b 24f +23: +.base64 "AAAFgSgABZEEAAWBLAAFkQAABTk=" +25: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 25b +24: +.base64 "AAA+KA==" +bne %cr0, 22b +b 21f +20: +21: +.base64 "eOu/fygABYEAAB+RLAAFgQQAH5EIAKXrEADF6xgA5esgAAXopgMIfCAAgTkAAGA5AABs+QgAbPkQAGz5GABs+SAAbPkoAGz5MABs+TgAbPlgACE4IACATg==""#, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/seed_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/seed_ofb.rs index f6984417333..021c558219f 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/seed_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/seed_ofb.rs @@ -31,3 +31,42 @@ b 21f vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, ) } + +/// SEED-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 4269 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SEED encryption under the schedule written by `vg_seed_expand_key`. +/// +/// Contract: `VG.Spec.Seed.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 1184 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_seed_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "Yfsh+CAA4TimAgh8aAQH+FAEp/tYBMf7YATn+3gjnXx4M958eCOffHgrpnx4O+V8AAAfgXAEBZEEAB+BdAQFkQgAH4F4BAWRDAAfgXwEBZF4M998AAA+KA==" +beq %cr0, 20f +22: +.base64 "cAQFgUAEBZF0BAWBRAQFkXgEBYFIBAWRfAQFgUwEBZFABIU4eCumfAEAoDg=" +bl {vg_seed_encrypt_blocks} +.base64 "eEMFfQAAYzgC4ch7AAAoKA==" +beq %cr0, 23f +.base64 "QAQFgXAEBZFEBAWBdAQFkUgEBYF4BAWRTAQFgXwEBZEAAB+BQAQlgXhKCH0AAB+RBAAfgUQEJYF4Sgh9BAAfkQgAH4FIBCWBeEoIfQgAH5EMAB+BTAQlgXhKCH0MAB+READ/O/D/3js=" +b 24f +23: +.base64 "QAQFgXAEBZFEBAWBdAQFkUgEBYF4BAWRTAQFgXwEBZFABAU5" +25: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 25b +24: +.base64 "AAA+KA==" +bne %cr0, 22b +b 21f +20: +21: +.base64 "eOu/f3AEBYEAAB+RdAQFgQQAH5F4BAWBCAAfkXwEBYEMAB+RUASl61gExetgBOXraAQF6KYDCHwgAIE5AABgOQAAbPkIAGz5EABs+RgAbPkgAGz5KABs+TAAbPk4AGz5QABs+UgAbPlQAGz5WABs+WAAbPloAGz5cABs+XgAbPmAAGz5iABs+ZAAbPmYAGz5oABs+agAbPmwAGz5uABs+cAAbPnIAGz50ABs+dgAbPngAGz56ABs+fAAbPn4AGz5AAFs+QgBbPkQAWz5GAFs+SABbPkoAWz5MAFs+TgBbPlAAWz5SAFs+VABbPlYAWz5YAFs+WgBbPlwAWz5eAFs+YABbPmIAWz5kAFs+ZgBbPmgAWz5qAFs+bABbPm4AWz5wAFs+cgBbPnQAWz52AFs+eABbPnoAWz58AFs+fgBbPkAAmz5CAJs+RACbPkYAmz5IAJs+SgCbPkwAmz5OAJs+UACbPlIAmz5UAJs+VgCbPlgAmz5aAJs+XACbPl4Amz5gAJs+YgCbPmQAmz5mAJs+aACbPmoAmz5sAJs+bgCbPnAAmz5yAJs+dACbPnYAmz54AJs+egCbPnwAmz5+AJs+QADbPkIA2z5EANs+RgDbPkgA2z5KANs+TADbPk4A2z5QANs+UgDbPlQA2z5WANs+WADbPloA2z5cANs+XgDbPmAA2z5iANs+ZADbPmYA2z5oANs+agDbPmwA2z5uANs+cADbPnIA2z50ANs+dgDbPngA2z56ANs+fADbPn4A2z5AARs+QgEbPkQBGz5GARs+SAEbPkoBGz5MARs+TgEbPlABGz5SARs+VAEbPlYBGz5YARs+WgEbPlwBGz5eARs+aAEITggAIBO""#, + vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/sm4_ctr.rs b/crates/verified-garbage-asm-powerpc64le/src/sm4_ctr.rs index 0427bc1aec2..bfa4330647a 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/sm4_ctr.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/sm4_ctr.rs @@ -34,3 +34,35 @@ b 21f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-CTR encryption or decryption (NIST SP 800-38A §6.5, draft-ribose-cfrg-sm4-10 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ctrFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 3408 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ctr_final(schedule: *const [u8; 128], ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "kf8h+CAA4TimAgh8AAAH+AgAx/kQAOf5GAAH+iAAZ/ooAMf7MADn+zgAh/p4G258eCOQfHg79HwC4cp45CZLeRRa5X9QMMt/eFNGfQ==" +bl {vg_sm4_ctr} +.base64 "AAA+KA==" +beq %cr0, 20f +.base64 "AAAgOUAANPlIADT5eHPDfXiDBH5AALQ4AQDAOA==" +bl {vg_sm4_ctr} +.base64 "QAAUOQ==" +22: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 22b +b 21f +20: +21: +.base64 "AAAU6AgA1OkQAPTpGAAU6iAAdOooANTrMAD06zgAlOqmAwh8IACBOQAAYDkAAGz5CABs+RAAbPkYAGz5IABs+SgAbPkwAGz5OABs+UAAbPlIAGz5cAAhOCAAgE4=""#, + vg_sm4_ctr = sym super::sm4_ctr::vg_sm4_ctr, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/sm4_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/sm4_ofb.rs index 82f6f33df84..9f8ab5bf378 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/sm4_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/sm4_ofb.rs @@ -34,3 +34,45 @@ b 21f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-OFB encryption or decryption (NIST SP 800-38A §6.4, GB/T 32907-2016 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 3296 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "IfMh+CAA4TimAgh8qAwH+JAMp/uYDMf7oAzn+3gjnXx4M958eCOffHgrpnx4O+V8AAAfgbAMBZEEAB+BtAwFkQgAH4G4DAWRDAAfgbwMBZF4M998eBtnfAAAgDiSAcA4" +bl {vg_sm4_prepare_keys} +.base64 "eDvjfAAAPig=" +beq %cr0, 20f +22: +.base64 "sAwFgQADBZG0DAWBBAMFkbgMBYEIAwWRvAwFgQwDBZF4G2d8eCujfJIBgDg=" +bl {vg_sm4_crypt_prepared} +.base64 "eDvjfALhyHsAACgo" +beq %cr0, 23f +.base64 "AAMFgbAMBZEEAwWBtAwFkQgDBYG4DAWRDAMFgbwMBZEAAB+BAAMlgXhKCH0AAB+RBAAfgQQDJYF4Sgh9BAAfkQgAH4EIAyWBeEoIfQgAH5EMAB+BDAMlgXhKCH0MAB+READ/O/D/3js=" +b 24f +23: +.base64 "AAMFgbAMBZEEAwWBtAwFkQgDBYG4DAWRDAMFgbwMBZEAAwU5" +25: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 25b +24: +.base64 "AAA+KA==" +bne %cr0, 22b +b 21f +20: +21: +.base64 "eOu/f7AMBYEAAB+RtAwFgQQAH5G4DAWBCAAfkbwMBYEMAB+RkAyl65gMxeugDOXrqAwF6KYDCHwgAIE5AABgOQAAbPkIAGz5EABs+RgAbPkgAGz5KABs+TAAbPk4AGz5QABs+UgAbPlQAGz5WABs+WAAbPloAGz5cABs+XgAbPmAAGz5iABs+ZAAbPmYAGz5oABs+agAbPmwAGz5uABs+cAAbPnIAGz50ABs+dgAbPngAGz56ABs+fAAbPn4AGz5AAFs+QgBbPkQAWz5GAFs+SABbPkoAWz5MAFs+TgBbPlAAWz5SAFs+VABbPlYAWz5YAFs+WgBbPlwAWz5eAFs+YABbPmIAWz5kAFs+ZgBbPmgAWz5qAFs+bABbPm4AWz5wAFs+cgBbPnQAWz52AFs+eABbPnoAWz58AFs+fgBbPkAAmz5CAJs+RACbPkYAmz5IAJs+SgCbPkwAmz5OAJs+UACbPlIAmz5UAJs+VgCbPlgAmz5aAJs+XACbPl4Amz5gAJs+YgCbPmQAmz5mAJs+aACbPmoAmz5sAJs+bgCbPnAAmz5yAJs+dACbPnYAmz54AJs+egCbPnwAmz5+AJs+QADbPkIA2z5EANs+RgDbPkgA2z5KANs+TADbPk4A2z5QANs+UgDbPlQA2z5WANs+WADbPloA2z5cANs+XgDbPmAA2z5iANs+ZADbPmYA2z5oANs+agDbPmwA2z5uANs+cADbPnIA2z50ANs+dgDbPngA2z56ANs+fADbPn4A2z5AARs+QgEbPkQBGz5GARs+SAEbPkoBGz5MARs+TgEbPlABGz5SARs+VAEbPlYBGz5YARs+WgEbPlwBGz5eARs+YAEbPmIBGz5kARs+ZgEbPmgBGz5qARs+bAEbPm4BGz5wARs+cgEbPnQBGz52ARs+eAEbPnoBGz58ARs+fgEbPkABWz5CAVs+RAFbPkYBWz5IAVs+SgFbPkwBWz5OAVs+UAFbPlIBWz5UAVs+VgFbPlgBWz5aAVs+XAFbPl4BWz5gAVs+YgFbPmQBWz5mAVs+aAFbPmoBWz5sAVs+bgFbPnABWz5yAVs+dAFbPnYBWz54AVs+egFbPnwBWz5+AVs+QAGbPkIBmz5EAZs+RgGbPkgBmz5KAZs+TAGbPk4Bmz5QAZs+UgGbPlQBmz5WAZs+WAGbPloBmz5cAZs+XgGbPmABmz5iAZs+ZAGbPmYBmz5oAZs+agGbPmwBmz5uAZs+cAGbPnIBmz50AZs+dgGbPngBmz56AZs+fAGbPn4Bmz5AAds+QgHbPkQB2z5GAds+SAHbPkoB2z5MAds+TgHbPlAB2z5SAds+VAHbPlYB2z5YAds+WgHbPlwB2z5eAds+YAHbPmIB2z5kAds+ZgHbPmgB2z5qAds+bAHbPm4B2z5wAds+cgHbPnQB2z52Ads+eAHbPnoB2z58Ads+fgHbPkACGz5CAhs+RAIbPkYCGz5IAhs+SgIbPkwCGz5OAhs+UAIbPlICGz5UAhs+VgIbPlgCGz5aAhs+XAIbPl4CGz5gAhs+YgIbPmQCGz5mAhs+aAIbPmoCGz5sAhs+bgIbPnACGz5yAhs+dAIbPnYCGz54Ahs+egIbPnwCGz5+Ahs+QAJbPkICWz5EAls+RgJbPkgCWz5KAls+TAJbPk4CWz5QAls+UgJbPlQCWz5WAls+WAJbPloCWz5cAls+XgJbPmACWz5iAls+ZAJbPmYCWz5oAls+agJbPmwCWz5uAls+cAJbPnICWz50Als+dgJbPngCWz56Als+fAJbPn4CWz5AAps+QgKbPkQCmz5GAps+SAKbPkoCmz5MAps+TgKbPlACmz5SAps+VAKbPlYCmz5YAps+WgKbPlwCmz5eAps+YAKbPmICmz5kAps+ZgKbPmgCmz5qAps+bAKbPm4Cmz5wAps+cgKbPnQCmz52Aps+eAKbPnoCmz58Aps+fgKbPkAC2z5CAts+RALbPkYC2z5IAts+SgLbPkwC2z5OAts+UALbPlIC2z5UAts+VgLbPlgC2z5aAts+XALbPl4C2z5gAts+YgLbPmQC2z5mAts+aALbPmoC2z5sAts+bgLbPnAC2z5yAts+dALbPnYC2z54Ats+egLbPnwC2z5+Ats+QAMbPkIDGz5EAxs+RgMbPkgDGz5KAxs+TAMbPk4DGz5QAxs+UgMbPlQDGz5WAxs+WAMbPloDGz5cAxs+XgMbPmADGz5iAxs+ZAMbPmYDGz5oAxs+agMbPmwDGz5uAxs+eAMITggAIBO""#, + vg_sm4_prepare_keys = sym super::sm4::vg_sm4_prepare_keys::vg_sm4_prepare_keys, + vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-powerpc64le/src/triple_des_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/triple_des_ofb.rs index c437ce63df4..61602985c54 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/triple_des_ofb.rs @@ -31,3 +31,42 @@ b 21f vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, ) } + +/// Triple DES-OFB encryption or decryption (NIST SP 800-38A §6.4, FIPS 46-3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Triple DES encryption under the schedule written by `vg_triple_des_expand_key`. +/// +/// Contract: `VG.Spec.TripleDes.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 384 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 608 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_triple_des_ofb_final(schedule: *const [u8; 384], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "of0h+CAA4TimAgh8IAIH+AgCp/sQAsf7GALn+3gjnXx4M958eCOffHgrpnx4O+V8AAAfgSgCBZEEAB+BLAIFkXgz33wAAD4o" +beq %cr0, 20f +22: +.base64 "KAIFgQACBZEsAgWBBAIFkQAChTg=" +bl {vg_triple_des_encrypt_block} +.base64 "wujIewAAKCg=" +beq %cr0, 23f +.base64 "AAIFgSgCBZEEAgWBLAIFkQAAH4EAAiWBeEoIfQAAH5EEAB+BBAIlgXhKCH0EAB+RCAD/O/j/3js=" +b 24f +23: +.base64 "AAIFgSgCBZEEAgWBLAIFkQACBTk=" +25: +.base64 "AAA/iQAASIl4Uil9AAA/mQEACDkBAP87///eOwAAPig=" +bne %cr0, 25b +24: +.base64 "AAA+KA==" +bne %cr0, 22b +b 21f +20: +21: +.base64 "eOu/fygCBYEAAB+RLAIFgQQAH5EIAqXrEALF6xgC5esgAgXopgMIfCAAgTkAAGA5AABs+QgAbPkQAGz5GABs+SAAbPkoAGz5MABs+TgAbPlAAGz5SABs+VAAbPlYAGz5YABs+WgAbPlwAGz5eABs+YAAbPmIAGz5kABs+ZgAbPmgAGz5qABs+bAAbPm4AGz5wABs+cgAbPnQAGz52ABs+eAAbPnoAGz58ABs+fgAbPkAAWz5CAFs+RABbPkYAWz5IAFs+SgBbPkwAWz5OAFs+UABbPlIAWz5UAFs+VgBbPlgAWz5aAFs+XABbPl4AWz5gAFs+YgBbPmQAWz5mAFs+aABbPmoAWz5sAFs+bgBbPnAAWz5yAFs+dABbPnYAWz54AFs+egBbPnwAWz5+AFs+QACbPkIAmz5EAJs+RgCbPkgAmz5KAJs+TACbPk4Amz5YAIhOCAAgE4=""#, + vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, + ) +} diff --git a/crates/verified-garbage-asm-riscv64/assembly/aes_ctr.s b/crates/verified-garbage-asm-riscv64/assembly/aes_ctr.s index 757bbfb76bc..42481ba9fe4 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/aes_ctr.s +++ b/crates/verified-garbage-asm-riscv64/assembly/aes_ctr.s @@ -173,3 +173,75 @@ vg_aes_ctr: ld s6, 64(t0) ret .option pop + +vg_aes_ctr_final: + .option push + .option arch, +m, +c + addi sp, sp, -80 + addi a6, sp, 0 + sd ra, 0(a6) + sd s1, 8(a6) + sd s2, 16(a6) + sd s3, 24(a6) + sd s4, 32(a6) + sd s5, 40(a6) + sd s6, 48(a6) + sd s7, 56(a6) + addi s1, a0, 0 + addi s4, a1, 0 + addi s5, a2, 0 + addi s6, a5, 0 + addi s7, a6, 0 + srli t0, a4, 4 + slli t1, t0, 4 + add s2, a3, t1 + sub s3, a4, t1 + addi a4, t0, 0 + call {vg_aes_ctr} + beqz s3, 20f + addi t0, zero, 0 + sd t0, 64(s7) + sd t0, 72(s7) + addi a0, s1, 0 + addi a1, s4, 0 + addi a2, s5, 0 + addi a3, s7, 64 + addi a4, zero, 1 + addi a5, s6, 0 + call {vg_aes_ctr} + addi t2, s7, 64 +22: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 22b + j 21f +20: +21: + ld ra, 0(s7) + ld s1, 8(s7) + ld s2, 16(s7) + ld s3, 24(s7) + ld s4, 32(s7) + ld s5, 40(s7) + ld s6, 48(s7) + ld s7, 56(s7) + addi t5, sp, 0 + addi t6, zero, 0 + sd t6, 0(t5) + sd t6, 8(t5) + sd t6, 16(t5) + sd t6, 24(t5) + sd t6, 32(t5) + sd t6, 40(t5) + sd t6, 48(t5) + sd t6, 56(t5) + sd t6, 64(t5) + sd t6, 72(t5) + addi sp, sp, 80 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/aes_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/aes_ofb.s index b86f4d71ec5..f4f8137966e 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/aes_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/aes_ofb.s @@ -21,3 +21,69 @@ vg_aes_ofb: ld s1, 24(t0) ret .option pop + +vg_aes_ofb_final: + .option push + .option arch, +m, +c + addi sp, sp, -64 + addi a6, sp, 0 + sd ra, 0(a6) + sd s1, 8(a6) + sd s2, 16(a6) + sd s3, 24(a6) + sd s4, 32(a6) + sd s5, 40(a6) + sd s6, 48(a6) + sd s7, 56(a6) + addi s1, a0, 0 + addi s4, a1, 0 + addi s5, a2, 0 + addi s6, a5, 0 + addi s7, a6, 0 + srli t0, a4, 4 + slli t1, t0, 4 + add s2, a3, t1 + sub s3, a4, t1 + addi a4, t0, 0 + call {vg_aes_ofb} + beqz s3, 20f + addi a0, s1, 0 + addi a1, s4, 0 + addi a2, s5, 0 + addi a3, zero, 1 + addi a4, s6, 0 + call {vg_aes_encrypt_blocks} + addi t2, s5, 0 +22: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 22b + j 21f +20: +21: + ld ra, 0(s7) + ld s1, 8(s7) + ld s2, 16(s7) + ld s3, 24(s7) + ld s4, 32(s7) + ld s5, 40(s7) + ld s6, 48(s7) + ld s7, 56(s7) + addi t5, sp, 0 + addi t6, zero, 0 + sd t6, 0(t5) + sd t6, 8(t5) + sd t6, 16(t5) + sd t6, 24(t5) + sd t6, 32(t5) + sd t6, 40(t5) + sd t6, 48(t5) + sd t6, 56(t5) + addi sp, sp, 64 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/blowfish_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/blowfish_ofb.s index 6a6aaf0c914..1fcb30e17cd 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/blowfish_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/blowfish_ofb.s @@ -4031,3 +4031,4069 @@ vg_blowfish_ofb: addi sp, sp, 160 ret .option pop + +vg_blowfish_ofb_final: + .option push + .option arch, +m, +c + addi sp, sp, -160 + addi sp, sp, -2032 + addi sp, sp, -2032 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + addi s2, a2, 0 + addi t0, s4, 56 + addi t2, a0, 0 + addi t4, zero, 1042 + slli t4, t4, 2 +20: + lbu t1, 0(t2) + sb t1, 0(t0) + addi t2, t2, 1 + addi t0, t0, 1 + addi t4, t4, -1 + bnez t4, 20b + andi t0, s2, 3 + beqz t0, 21f + beqz s3, 23f +25: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + addi a7, s4, 56 + addi a1, s4, 48 + lbu a3, 0(a1) + slli a3, a3, 24 + lbu t4, 1(a1) + slli t4, t4, 16 + or a3, a3, t4 + lbu t4, 2(a1) + slli t4, t4, 8 + or a3, a3, t4 + lbu t4, 3(a1) + or a3, a3, t4 + lbu a4, 4(a1) + slli a4, a4, 24 + lbu t4, 5(a1) + slli t4, t4, 16 + or a4, a4, t4 + lbu t4, 6(a1) + slli t4, t4, 8 + or a4, a4, t4 + lbu t4, 7(a1) + or a4, a4, t4 + addi a6, a7, 2047 + addi a6, a6, 2047 + addi a6, a6, 2 +26: + lwu t4, 0(a6) + xor a3, a3, t4 + slli t1, a3, 32 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 24 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + or a5, t2, t2 + addi a7, a7, 1024 + slli t1, a3, 40 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 16 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + add a5, a5, t2 + addi a7, a7, 1024 + slli t1, a3, 48 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 8 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + xor a5, a5, t2 + addi a7, a7, 1024 + slli t1, a3, 56 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 0 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + add a5, a5, t2 + addi a7, a7, -2048 + addi a7, a7, -1024 + xor a4, a4, a5 + or t4, a3, a3 + or a3, a4, a4 + or a4, t4, t4 + addi a6, a6, 4 + sub t4, a6, a7 + addi t4, t4, -2047 + addi t4, t4, -2047 + addi t4, t4, -66 + bnez t4, 26b + lwu t4, 0(a6) + xor t4, a3, t4 + lwu a3, 4(a6) + xor a3, a3, a4 + or a4, t4, t4 + srli t4, a3, 24 + sb t4, 0(a1) + srli t4, a3, 16 + sb t4, 1(a1) + srli t4, a3, 8 + sb t4, 2(a1) + srli t4, a3, 0 + sb t4, 3(a1) + srli t4, a4, 24 + sb t4, 4(a1) + srli t4, a4, 16 + sb t4, 5(a1) + srli t4, a4, 8 + sb t4, 6(a1) + srli t4, a4, 0 + sb t4, 7(a1) + addi a1, a1, 8 + addi a2, a2, -1 + addi t0, zero, 8 + bltu s3, t0, 27f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 48(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 52(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 28f +27: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +29: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 29b +28: + bnez s3, 25b + j 24f +23: +24: + j 22f +21: + beqz s3, 210f +212: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + addi a7, s4, 56 + addi a1, s4, 48 + lbu a3, 0(a1) + slli a3, a3, 24 + lbu t4, 1(a1) + slli t4, t4, 16 + or a3, a3, t4 + lbu t4, 2(a1) + slli t4, t4, 8 + or a3, a3, t4 + lbu t4, 3(a1) + or a3, a3, t4 + lbu a4, 4(a1) + slli a4, a4, 24 + lbu t4, 5(a1) + slli t4, t4, 16 + or a4, a4, t4 + lbu t4, 6(a1) + slli t4, t4, 8 + or a4, a4, t4 + lbu t4, 7(a1) + or a4, a4, t4 + addi a6, a7, 2047 + addi a6, a6, 2047 + addi a6, a6, 2 +213: + lwu t4, 0(a6) + xor a3, a3, t4 + slli t1, a3, 32 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 24 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + or a5, t2, t2 + addi a7, a7, 1024 + slli t1, a3, 40 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 16 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + add a5, a5, t2 + addi a7, a7, 1024 + slli t1, a3, 48 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 8 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + xor a5, a5, t2 + addi a7, a7, 1024 + slli t1, a3, 56 + srli t1, t1, 59 + addi t3, zero, 1 + sll t1, t3, t1 + slli t3, t1, 63 + srai t3, t3, 63 + ld t2, 0(a7) + and t2, t2, t3 + ld t5, 256(a7) + and t5, t5, t3 + ld t6, 512(a7) + and t6, t6, t3 + ld t0, 768(a7) + and t0, t0, t3 + slli t3, t1, 62 + srai t3, t3, 63 + ld t4, 8(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 264(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 520(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 776(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 61 + srai t3, t3, 63 + ld t4, 16(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 272(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 528(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 784(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 60 + srai t3, t3, 63 + ld t4, 24(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 280(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 536(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 792(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 59 + srai t3, t3, 63 + ld t4, 32(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 288(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 544(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 800(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 58 + srai t3, t3, 63 + ld t4, 40(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 296(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 552(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 808(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 57 + srai t3, t3, 63 + ld t4, 48(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 304(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 560(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 816(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 56 + srai t3, t3, 63 + ld t4, 56(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 312(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 568(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 824(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 55 + srai t3, t3, 63 + ld t4, 64(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 320(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 576(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 832(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 54 + srai t3, t3, 63 + ld t4, 72(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 328(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 584(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 840(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 53 + srai t3, t3, 63 + ld t4, 80(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 336(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 592(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 848(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 52 + srai t3, t3, 63 + ld t4, 88(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 344(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 600(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 856(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 51 + srai t3, t3, 63 + ld t4, 96(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 352(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 608(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 864(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 50 + srai t3, t3, 63 + ld t4, 104(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 360(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 616(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 872(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 49 + srai t3, t3, 63 + ld t4, 112(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 368(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 624(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 880(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 48 + srai t3, t3, 63 + ld t4, 120(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 376(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 632(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 888(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 47 + srai t3, t3, 63 + ld t4, 128(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 384(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 640(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 896(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 46 + srai t3, t3, 63 + ld t4, 136(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 392(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 648(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 904(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 45 + srai t3, t3, 63 + ld t4, 144(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 400(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 656(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 912(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 44 + srai t3, t3, 63 + ld t4, 152(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 408(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 664(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 920(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 43 + srai t3, t3, 63 + ld t4, 160(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 416(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 672(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 928(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 42 + srai t3, t3, 63 + ld t4, 168(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 424(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 680(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 936(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 41 + srai t3, t3, 63 + ld t4, 176(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 432(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 688(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 944(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 40 + srai t3, t3, 63 + ld t4, 184(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 440(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 696(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 952(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 39 + srai t3, t3, 63 + ld t4, 192(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 448(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 704(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 960(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 38 + srai t3, t3, 63 + ld t4, 200(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 456(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 712(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 968(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 37 + srai t3, t3, 63 + ld t4, 208(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 464(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 720(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 976(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 36 + srai t3, t3, 63 + ld t4, 216(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 472(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 728(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 984(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 35 + srai t3, t3, 63 + ld t4, 224(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 480(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 736(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 992(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 34 + srai t3, t3, 63 + ld t4, 232(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 488(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 744(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1000(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 33 + srai t3, t3, 63 + ld t4, 240(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 496(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 752(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1008(a7) + and t4, t4, t3 + or t0, t0, t4 + slli t3, t1, 32 + srai t3, t3, 63 + ld t4, 248(a7) + and t4, t4, t3 + or t2, t2, t4 + ld t4, 504(a7) + and t4, t4, t3 + or t5, t5, t4 + ld t4, 760(a7) + and t4, t4, t3 + or t6, t6, t4 + ld t4, 1016(a7) + and t4, t4, t3 + or t0, t0, t4 + srli t3, a3, 0 + andi t3, t3, 7 + slli t3, t3, 3 + srl t2, t2, t3 + andi t2, t2, 255 + srl t5, t5, t3 + andi t5, t5, 255 + slli t5, t5, 8 + srl t6, t6, t3 + andi t6, t6, 255 + slli t6, t6, 16 + srl t0, t0, t3 + andi t0, t0, 255 + slli t0, t0, 24 + or t2, t2, t5 + or t6, t6, t0 + or t2, t2, t6 + add a5, a5, t2 + addi a7, a7, -2048 + addi a7, a7, -1024 + xor a4, a4, a5 + or t4, a3, a3 + or a3, a4, a4 + or a4, t4, t4 + addi a6, a6, 4 + sub t4, a6, a7 + addi t4, t4, -2047 + addi t4, t4, -2047 + addi t4, t4, -66 + bnez t4, 213b + lwu t4, 0(a6) + xor t4, a3, t4 + lwu a3, 4(a6) + xor a3, a3, a4 + or a4, t4, t4 + srli t4, a3, 24 + sb t4, 0(a1) + srli t4, a3, 16 + sb t4, 1(a1) + srli t4, a3, 8 + sb t4, 2(a1) + srli t4, a3, 0 + sb t4, 3(a1) + srli t4, a4, 24 + sb t4, 4(a1) + srli t4, a4, 16 + sb t4, 5(a1) + srli t4, a4, 8 + sb t4, 6(a1) + srli t4, a4, 0 + sb t4, 7(a1) + addi a1, a1, 8 + addi a2, a2, -1 + addi t0, zero, 8 + bltu s3, t0, 214f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lwu t0, 0(s2) + lwu t1, 48(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 52(s4) + xor t0, t0, t1 + sw t0, 4(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 215f +214: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +216: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 216b +215: + bnez s3, 212b + j 211f +210: +211: +22: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 528 +217: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 217b + addi sp, sp, 2032 + addi sp, sp, 2032 + addi sp, sp, 160 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/camellia_ctr.s b/crates/verified-garbage-asm-riscv64/assembly/camellia_ctr.s index e2ee29c41ee..889c24b0410 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/camellia_ctr.s +++ b/crates/verified-garbage-asm-riscv64/assembly/camellia_ctr.s @@ -22462,3 +22462,73 @@ vg_camellia_ctr: 21: ret .option pop + +vg_camellia_ctr_final: + .option push + .option arch, +m, +c + addi sp, sp, -80 + addi a5, sp, 0 + sd ra, 0(a5) + sd s1, 8(a5) + sd s2, 16(a5) + sd s3, 24(a5) + sd s4, 32(a5) + sd s5, 40(a5) + sd s6, 48(a5) + sd s7, 56(a5) + addi s1, a0, 0 + addi s4, a1, 0 + addi s5, a2, 0 + addi s7, a5, 0 + srli t0, a4, 4 + slli t1, t0, 4 + add s2, a3, t1 + sub s3, a4, t1 + addi a4, t0, 0 + call {vg_camellia_ctr} + beqz s3, 20f + addi t0, zero, 0 + sd t0, 64(s7) + sd t0, 72(s7) + addi a0, s1, 0 + addi a1, s4, 0 + addi a2, s5, 0 + addi a3, s7, 64 + addi a4, zero, 1 + call {vg_camellia_ctr} + addi t2, s7, 64 +22: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 22b + j 21f +20: +21: + ld ra, 0(s7) + ld s1, 8(s7) + ld s2, 16(s7) + ld s3, 24(s7) + ld s4, 32(s7) + ld s5, 40(s7) + ld s6, 48(s7) + ld s7, 56(s7) + addi t5, sp, 0 + addi t6, zero, 0 + sd t6, 0(t5) + sd t6, 8(t5) + sd t6, 16(t5) + sd t6, 24(t5) + sd t6, 32(t5) + sd t6, 40(t5) + sd t6, 48(t5) + sd t6, 56(t5) + sd t6, 64(t5) + sd t6, 72(t5) + addi sp, sp, 80 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/camellia_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/camellia_ofb.s index 8b23fe36e98..9f8ba0bcccf 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/camellia_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/camellia_ofb.s @@ -9806,3 +9806,9898 @@ vg_camellia_ofb: 21: ret .option pop + +vg_camellia_ofb_final: + .option push + .option arch, +m, +c + addi t0, a1, 0 + addi a1, a2, 0 + addi a2, a3, 0 + addi a3, a4, 0 + addi t0, t0, -18 + beqz t0, 20f + addi sp, sp, -2032 + addi sp, sp, -1216 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 40(s4) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 44(s4) + addi s2, a2, 0 + addi t0, s4, 48 + sd ra, 784(s4) + sd a0, 792(s4) + addi a2, s1, 0 + addi a3, s2, 0 + addi ra, s3, 0 + addi a1, zero, 24 + addi a5, t0, 0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + sd s8, 704(a5) + sd s9, 712(a5) + sd s10, 720(a5) + sd s11, 728(a5) + lui t0, 4080 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 4080 + addiw t1, t1, 255 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 384(a5) + lui t0, 1044496 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 1044496 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 392(a5) + lui t0, 4096 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 400(a5) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4096 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 408(a5) + lui t0, 0 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 1044480 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 416(a5) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 1048560 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 424(a5) + lui t0, 16 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 432(a5) + lui t0, 349525 + addiw t0, t0, 1365 + slli t0, t0, 32 + lui t1, 349525 + addiw t1, t1, 1365 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 448(a5) + lui t0, 209715 + addiw t0, t0, 819 + slli t0, t0, 32 + lui t1, 209715 + addiw t1, t1, 819 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 456(a5) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 464(a5) + addi t0, a1, -18 + beqz t0, 22f + addi a4, a5, 1536 + addi a4, a4, 1536 + addi t1, zero, 34 + j 23f +22: + addi a4, a5, 1536 + addi a4, a4, 1024 + addi t1, zero, 26 +23: + addi a1, a5, 1024 +24: + lbu s0, 0(a0) + lbu t0, 1(a0) + slli t0, t0, 8 + or s0, s0, t0 + lbu t0, 2(a0) + slli t0, t0, 16 + or s0, s0, t0 + lbu t0, 3(a0) + slli t0, t0, 24 + or s0, s0, t0 + lbu t2, 4(a0) + lbu t0, 5(a0) + slli t0, t0, 8 + or t2, t2, t0 + lbu t0, 6(a0) + slli t0, t0, 16 + or t2, t2, t0 + lbu t0, 7(a0) + slli t0, t0, 24 + or t2, t2, t0 + slli t2, t2, 32 + or s0, s0, t2 + addi s1, s0, 0 + addi s2, s0, 0 + addi s3, s0, 0 + addi s4, s0, 0 + addi s5, s0, 0 + addi s6, s0, 0 + addi s7, s0, 0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 0(a1) + sd s1, 8(a1) + sd s2, 16(a1) + sd s3, 24(a1) + sd s4, 32(a1) + sd s5, 40(a1) + sd s6, 48(a1) + sd s7, 56(a1) + addi a1, a1, 64 + addi a0, a0, 8 + addi t1, t1, -1 + bnez t1, 24b + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + ld s8, 704(a5) + ld s9, 712(a5) + ld s10, 720(a5) + ld s11, 728(a5) + addi s1, a2, 0 + addi s2, a3, 0 + addi s3, ra, 0 + addi s4, a5, -48 + ld ra, 736(a5) + ld a0, 744(a5) + andi t0, s2, 3 + beqz t0, 25f + beqz s3, 27f +29: + lwu t0, 32(s4) + sw t0, 816(s4) + lwu t0, 36(s4) + sw t0, 820(s4) + lwu t0, 40(s4) + sw t0, 824(s4) + lwu t0, 44(s4) + sw t0, 828(s4) + addi t0, s4, 48 + sd ra, 784(s4) + sd a0, 792(s4) + addi a2, s1, 0 + addi a3, s2, 0 + addi ra, s3, 0 + addi a5, t0, 0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + sd s8, 704(a5) + sd s9, 712(a5) + sd s10, 720(a5) + sd s11, 728(a5) + addi a4, a5, 1536 + addi a4, a4, 1536 + addi a1, a5, 1024 + ld s0, 776(a5) + ld s1, 792(a5) + ld s2, 808(a5) + ld s3, 824(a5) + ld s4, 840(a5) + ld s5, 856(a5) + ld s6, 872(a5) + ld s7, 888(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 768(a5) + ld s1, 784(a5) + ld s2, 800(a5) + ld s3, 816(a5) + ld s4, 832(a5) + ld s5, 848(a5) + ld s6, 864(a5) + ld s7, 880(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + ld t0, 576(a5) + ld t3, 64(a1) + xor t0, t0, t3 + sd t0, 576(a5) + ld t0, 584(a5) + ld t3, 72(a1) + xor t0, t0, t3 + sd t0, 584(a5) + ld t0, 592(a5) + ld t3, 80(a1) + xor t0, t0, t3 + sd t0, 592(a5) + ld t0, 600(a5) + ld t3, 88(a1) + xor t0, t0, t3 + sd t0, 600(a5) + ld t0, 608(a5) + ld t3, 96(a1) + xor t0, t0, t3 + sd t0, 608(a5) + ld t0, 616(a5) + ld t3, 104(a1) + xor t0, t0, t3 + sd t0, 616(a5) + ld t0, 624(a5) + ld t3, 112(a1) + xor t0, t0, t3 + sd t0, 624(a5) + ld t0, 632(a5) + ld t3, 120(a1) + xor t0, t0, t3 + sd t0, 632(a5) + addi a1, a1, 128 +210: + addi a0, a1, 384 +211: + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 576(a5) + xor s0, s0, t0 + sd s0, 576(a5) + ld t0, 584(a5) + xor s1, s1, t0 + sd s1, 584(a5) + ld t0, 592(a5) + xor s2, s2, t0 + sd s2, 592(a5) + ld t0, 600(a5) + xor s3, s3, t0 + sd s3, 600(a5) + ld t0, 608(a5) + xor s4, s4, t0 + sd s4, 608(a5) + ld t0, 616(a5) + xor s5, s5, t0 + sd s5, 616(a5) + ld t0, 624(a5) + xor s6, s6, t0 + sd s6, 624(a5) + ld t0, 632(a5) + xor s7, s7, t0 + sd s7, 632(a5) + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 512(a5) + xor s0, s0, t0 + sd s0, 512(a5) + ld t0, 520(a5) + xor s1, s1, t0 + sd s1, 520(a5) + ld t0, 528(a5) + xor s2, s2, t0 + sd s2, 528(a5) + ld t0, 536(a5) + xor s3, s3, t0 + sd s3, 536(a5) + ld t0, 544(a5) + xor s4, s4, t0 + sd s4, 544(a5) + ld t0, 552(a5) + xor s5, s5, t0 + sd s5, 552(a5) + ld t0, 560(a5) + xor s6, s6, t0 + sd s6, 560(a5) + ld t0, 568(a5) + xor s7, s7, t0 + sd s7, 568(a5) + addi a1, a1, 128 + sub t0, a1, a0 + bnez t0, 211b + sub t0, a1, a4 + bnez t0, 212f + j 213f +212: + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t2, 384(a5) + ld t3, 120(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 112(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 104(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 96(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 88(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 80(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 72(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 64(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 112(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 104(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 96(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 88(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 80(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 72(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 64(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 120(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 512(a5) + ld s1, 520(a5) + ld s2, 528(a5) + ld s3, 536(a5) + ld s4, 544(a5) + ld s5, 552(a5) + ld s6, 560(a5) + ld s7, 568(a5) + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 48(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 40(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 32(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 24(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 16(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 8(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 0(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 56(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 384(a5) + ld t3, 56(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 48(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 40(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 32(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 24(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 16(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 8(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 0(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + addi a1, a1, 128 +213: + sub t0, a1, a4 + bnez t0, 210b + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 776(a5) + sd s1, 792(a5) + sd s2, 808(a5) + sd s3, 824(a5) + sd s4, 840(a5) + sd s5, 856(a5) + sd s6, 872(a5) + sd s7, 888(a5) + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 768(a5) + sd s1, 784(a5) + sd s2, 800(a5) + sd s3, 816(a5) + sd s4, 832(a5) + sd s5, 848(a5) + sd s6, 864(a5) + sd s7, 880(a5) + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + ld s8, 704(a5) + ld s9, 712(a5) + ld s10, 720(a5) + ld s11, 728(a5) + addi s1, a2, 0 + addi s2, a3, 0 + addi s3, ra, 0 + addi s4, a5, -48 + ld ra, 736(a5) + ld a0, 744(a5) + addi t0, zero, 16 + bltu s3, t0, 214f + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 816(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 820(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 824(s4) + xor t0, t0, t1 + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 828(s4) + xor t0, t0, t1 + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 215f +214: + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + addi t2, s4, 816 +216: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 216b +215: + bnez s3, 29b + j 28f +27: +28: + j 26f +25: + beqz s3, 217f +219: + lwu t0, 32(s4) + sw t0, 816(s4) + lwu t0, 36(s4) + sw t0, 820(s4) + lwu t0, 40(s4) + sw t0, 824(s4) + lwu t0, 44(s4) + sw t0, 828(s4) + addi t0, s4, 48 + sd ra, 784(s4) + sd a0, 792(s4) + addi a2, s1, 0 + addi a3, s2, 0 + addi ra, s3, 0 + addi a5, t0, 0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + sd s8, 704(a5) + sd s9, 712(a5) + sd s10, 720(a5) + sd s11, 728(a5) + addi a4, a5, 1536 + addi a4, a4, 1536 + addi a1, a5, 1024 + ld s0, 776(a5) + ld s1, 792(a5) + ld s2, 808(a5) + ld s3, 824(a5) + ld s4, 840(a5) + ld s5, 856(a5) + ld s6, 872(a5) + ld s7, 888(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 768(a5) + ld s1, 784(a5) + ld s2, 800(a5) + ld s3, 816(a5) + ld s4, 832(a5) + ld s5, 848(a5) + ld s6, 864(a5) + ld s7, 880(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + ld t0, 576(a5) + ld t3, 64(a1) + xor t0, t0, t3 + sd t0, 576(a5) + ld t0, 584(a5) + ld t3, 72(a1) + xor t0, t0, t3 + sd t0, 584(a5) + ld t0, 592(a5) + ld t3, 80(a1) + xor t0, t0, t3 + sd t0, 592(a5) + ld t0, 600(a5) + ld t3, 88(a1) + xor t0, t0, t3 + sd t0, 600(a5) + ld t0, 608(a5) + ld t3, 96(a1) + xor t0, t0, t3 + sd t0, 608(a5) + ld t0, 616(a5) + ld t3, 104(a1) + xor t0, t0, t3 + sd t0, 616(a5) + ld t0, 624(a5) + ld t3, 112(a1) + xor t0, t0, t3 + sd t0, 624(a5) + ld t0, 632(a5) + ld t3, 120(a1) + xor t0, t0, t3 + sd t0, 632(a5) + addi a1, a1, 128 +220: + addi a0, a1, 384 +221: + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 576(a5) + xor s0, s0, t0 + sd s0, 576(a5) + ld t0, 584(a5) + xor s1, s1, t0 + sd s1, 584(a5) + ld t0, 592(a5) + xor s2, s2, t0 + sd s2, 592(a5) + ld t0, 600(a5) + xor s3, s3, t0 + sd s3, 600(a5) + ld t0, 608(a5) + xor s4, s4, t0 + sd s4, 608(a5) + ld t0, 616(a5) + xor s5, s5, t0 + sd s5, 616(a5) + ld t0, 624(a5) + xor s6, s6, t0 + sd s6, 624(a5) + ld t0, 632(a5) + xor s7, s7, t0 + sd s7, 632(a5) + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 512(a5) + xor s0, s0, t0 + sd s0, 512(a5) + ld t0, 520(a5) + xor s1, s1, t0 + sd s1, 520(a5) + ld t0, 528(a5) + xor s2, s2, t0 + sd s2, 528(a5) + ld t0, 536(a5) + xor s3, s3, t0 + sd s3, 536(a5) + ld t0, 544(a5) + xor s4, s4, t0 + sd s4, 544(a5) + ld t0, 552(a5) + xor s5, s5, t0 + sd s5, 552(a5) + ld t0, 560(a5) + xor s6, s6, t0 + sd s6, 560(a5) + ld t0, 568(a5) + xor s7, s7, t0 + sd s7, 568(a5) + addi a1, a1, 128 + sub t0, a1, a0 + bnez t0, 221b + sub t0, a1, a4 + bnez t0, 222f + j 223f +222: + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t2, 384(a5) + ld t3, 120(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 112(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 104(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 96(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 88(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 80(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 72(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 64(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 112(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 104(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 96(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 88(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 80(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 72(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 64(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 120(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 512(a5) + ld s1, 520(a5) + ld s2, 528(a5) + ld s3, 536(a5) + ld s4, 544(a5) + ld s5, 552(a5) + ld s6, 560(a5) + ld s7, 568(a5) + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 48(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 40(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 32(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 24(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 16(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 8(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 0(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 56(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 384(a5) + ld t3, 56(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 48(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 40(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 32(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 24(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 16(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 8(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 0(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + addi a1, a1, 128 +223: + sub t0, a1, a4 + bnez t0, 220b + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 776(a5) + sd s1, 792(a5) + sd s2, 808(a5) + sd s3, 824(a5) + sd s4, 840(a5) + sd s5, 856(a5) + sd s6, 872(a5) + sd s7, 888(a5) + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 768(a5) + sd s1, 784(a5) + sd s2, 800(a5) + sd s3, 816(a5) + sd s4, 832(a5) + sd s5, 848(a5) + sd s6, 864(a5) + sd s7, 880(a5) + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + ld s8, 704(a5) + ld s9, 712(a5) + ld s10, 720(a5) + ld s11, 728(a5) + addi s1, a2, 0 + addi s2, a3, 0 + addi s3, ra, 0 + addi s4, a5, -48 + ld ra, 736(a5) + ld a0, 744(a5) + addi t0, zero, 16 + bltu s3, t0, 224f + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + lwu t0, 0(s2) + lwu t1, 816(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 820(s4) + xor t0, t0, t1 + sw t0, 4(s2) + lwu t0, 8(s2) + lwu t1, 824(s4) + xor t0, t0, t1 + sw t0, 8(s2) + lwu t0, 12(s2) + lwu t1, 828(s4) + xor t0, t0, t1 + sw t0, 12(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 225f +224: + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + addi t2, s4, 816 +226: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 226b +225: + bnez s3, 219b + j 218f +217: +218: +26: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lwu t0, 40(s4) + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lwu t0, 44(s4) + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 406 +227: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 227b + addi sp, sp, 1216 + addi sp, sp, 2032 + j 21f +20: + addi sp, sp, -2032 + addi sp, sp, -1216 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 40(s4) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 44(s4) + addi s2, a2, 0 + addi t0, s4, 48 + sd ra, 784(s4) + sd a0, 792(s4) + addi a2, s1, 0 + addi a3, s2, 0 + addi ra, s3, 0 + addi a1, zero, 18 + addi a5, t0, 0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + sd s8, 704(a5) + sd s9, 712(a5) + sd s10, 720(a5) + sd s11, 728(a5) + lui t0, 4080 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 4080 + addiw t1, t1, 255 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 384(a5) + lui t0, 1044496 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 1044496 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 392(a5) + lui t0, 4096 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 400(a5) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4096 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 408(a5) + lui t0, 0 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 1044480 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 416(a5) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 1048560 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 424(a5) + lui t0, 16 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 432(a5) + lui t0, 349525 + addiw t0, t0, 1365 + slli t0, t0, 32 + lui t1, 349525 + addiw t1, t1, 1365 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 448(a5) + lui t0, 209715 + addiw t0, t0, 819 + slli t0, t0, 32 + lui t1, 209715 + addiw t1, t1, 819 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 456(a5) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 464(a5) + addi t0, a1, -18 + beqz t0, 228f + addi a4, a5, 1536 + addi a4, a4, 1536 + addi t1, zero, 34 + j 229f +228: + addi a4, a5, 1536 + addi a4, a4, 1024 + addi t1, zero, 26 +229: + addi a1, a5, 1024 +230: + lbu s0, 0(a0) + lbu t0, 1(a0) + slli t0, t0, 8 + or s0, s0, t0 + lbu t0, 2(a0) + slli t0, t0, 16 + or s0, s0, t0 + lbu t0, 3(a0) + slli t0, t0, 24 + or s0, s0, t0 + lbu t2, 4(a0) + lbu t0, 5(a0) + slli t0, t0, 8 + or t2, t2, t0 + lbu t0, 6(a0) + slli t0, t0, 16 + or t2, t2, t0 + lbu t0, 7(a0) + slli t0, t0, 24 + or t2, t2, t0 + slli t2, t2, 32 + or s0, s0, t2 + addi s1, s0, 0 + addi s2, s0, 0 + addi s3, s0, 0 + addi s4, s0, 0 + addi s5, s0, 0 + addi s6, s0, 0 + addi s7, s0, 0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 0(a1) + sd s1, 8(a1) + sd s2, 16(a1) + sd s3, 24(a1) + sd s4, 32(a1) + sd s5, 40(a1) + sd s6, 48(a1) + sd s7, 56(a1) + addi a1, a1, 64 + addi a0, a0, 8 + addi t1, t1, -1 + bnez t1, 230b + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + ld s8, 704(a5) + ld s9, 712(a5) + ld s10, 720(a5) + ld s11, 728(a5) + addi s1, a2, 0 + addi s2, a3, 0 + addi s3, ra, 0 + addi s4, a5, -48 + ld ra, 736(a5) + ld a0, 744(a5) + andi t0, s2, 3 + beqz t0, 231f + beqz s3, 233f +235: + lwu t0, 32(s4) + sw t0, 816(s4) + lwu t0, 36(s4) + sw t0, 820(s4) + lwu t0, 40(s4) + sw t0, 824(s4) + lwu t0, 44(s4) + sw t0, 828(s4) + addi t0, s4, 48 + sd ra, 784(s4) + sd a0, 792(s4) + addi a2, s1, 0 + addi a3, s2, 0 + addi ra, s3, 0 + addi a5, t0, 0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + sd s8, 704(a5) + sd s9, 712(a5) + sd s10, 720(a5) + sd s11, 728(a5) + addi a4, a5, 1536 + addi a4, a4, 1024 + addi a1, a5, 1024 + ld s0, 776(a5) + ld s1, 792(a5) + ld s2, 808(a5) + ld s3, 824(a5) + ld s4, 840(a5) + ld s5, 856(a5) + ld s6, 872(a5) + ld s7, 888(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 768(a5) + ld s1, 784(a5) + ld s2, 800(a5) + ld s3, 816(a5) + ld s4, 832(a5) + ld s5, 848(a5) + ld s6, 864(a5) + ld s7, 880(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + ld t0, 576(a5) + ld t3, 64(a1) + xor t0, t0, t3 + sd t0, 576(a5) + ld t0, 584(a5) + ld t3, 72(a1) + xor t0, t0, t3 + sd t0, 584(a5) + ld t0, 592(a5) + ld t3, 80(a1) + xor t0, t0, t3 + sd t0, 592(a5) + ld t0, 600(a5) + ld t3, 88(a1) + xor t0, t0, t3 + sd t0, 600(a5) + ld t0, 608(a5) + ld t3, 96(a1) + xor t0, t0, t3 + sd t0, 608(a5) + ld t0, 616(a5) + ld t3, 104(a1) + xor t0, t0, t3 + sd t0, 616(a5) + ld t0, 624(a5) + ld t3, 112(a1) + xor t0, t0, t3 + sd t0, 624(a5) + ld t0, 632(a5) + ld t3, 120(a1) + xor t0, t0, t3 + sd t0, 632(a5) + addi a1, a1, 128 +236: + addi a0, a1, 384 +237: + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 576(a5) + xor s0, s0, t0 + sd s0, 576(a5) + ld t0, 584(a5) + xor s1, s1, t0 + sd s1, 584(a5) + ld t0, 592(a5) + xor s2, s2, t0 + sd s2, 592(a5) + ld t0, 600(a5) + xor s3, s3, t0 + sd s3, 600(a5) + ld t0, 608(a5) + xor s4, s4, t0 + sd s4, 608(a5) + ld t0, 616(a5) + xor s5, s5, t0 + sd s5, 616(a5) + ld t0, 624(a5) + xor s6, s6, t0 + sd s6, 624(a5) + ld t0, 632(a5) + xor s7, s7, t0 + sd s7, 632(a5) + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 512(a5) + xor s0, s0, t0 + sd s0, 512(a5) + ld t0, 520(a5) + xor s1, s1, t0 + sd s1, 520(a5) + ld t0, 528(a5) + xor s2, s2, t0 + sd s2, 528(a5) + ld t0, 536(a5) + xor s3, s3, t0 + sd s3, 536(a5) + ld t0, 544(a5) + xor s4, s4, t0 + sd s4, 544(a5) + ld t0, 552(a5) + xor s5, s5, t0 + sd s5, 552(a5) + ld t0, 560(a5) + xor s6, s6, t0 + sd s6, 560(a5) + ld t0, 568(a5) + xor s7, s7, t0 + sd s7, 568(a5) + addi a1, a1, 128 + sub t0, a1, a0 + bnez t0, 237b + sub t0, a1, a4 + bnez t0, 238f + j 239f +238: + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t2, 384(a5) + ld t3, 120(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 112(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 104(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 96(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 88(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 80(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 72(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 64(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 112(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 104(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 96(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 88(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 80(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 72(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 64(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 120(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 512(a5) + ld s1, 520(a5) + ld s2, 528(a5) + ld s3, 536(a5) + ld s4, 544(a5) + ld s5, 552(a5) + ld s6, 560(a5) + ld s7, 568(a5) + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 48(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 40(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 32(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 24(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 16(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 8(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 0(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 56(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 384(a5) + ld t3, 56(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 48(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 40(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 32(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 24(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 16(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 8(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 0(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + addi a1, a1, 128 +239: + sub t0, a1, a4 + bnez t0, 236b + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 776(a5) + sd s1, 792(a5) + sd s2, 808(a5) + sd s3, 824(a5) + sd s4, 840(a5) + sd s5, 856(a5) + sd s6, 872(a5) + sd s7, 888(a5) + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 768(a5) + sd s1, 784(a5) + sd s2, 800(a5) + sd s3, 816(a5) + sd s4, 832(a5) + sd s5, 848(a5) + sd s6, 864(a5) + sd s7, 880(a5) + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + ld s8, 704(a5) + ld s9, 712(a5) + ld s10, 720(a5) + ld s11, 728(a5) + addi s1, a2, 0 + addi s2, a3, 0 + addi s3, ra, 0 + addi s4, a5, -48 + ld ra, 736(a5) + ld a0, 744(a5) + addi t0, zero, 16 + bltu s3, t0, 240f + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 816(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 820(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 824(s4) + xor t0, t0, t1 + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 828(s4) + xor t0, t0, t1 + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 241f +240: + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + addi t2, s4, 816 +242: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 242b +241: + bnez s3, 235b + j 234f +233: +234: + j 232f +231: + beqz s3, 243f +245: + lwu t0, 32(s4) + sw t0, 816(s4) + lwu t0, 36(s4) + sw t0, 820(s4) + lwu t0, 40(s4) + sw t0, 824(s4) + lwu t0, 44(s4) + sw t0, 828(s4) + addi t0, s4, 48 + sd ra, 784(s4) + sd a0, 792(s4) + addi a2, s1, 0 + addi a3, s2, 0 + addi ra, s3, 0 + addi a5, t0, 0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + sd s8, 704(a5) + sd s9, 712(a5) + sd s10, 720(a5) + sd s11, 728(a5) + addi a4, a5, 1536 + addi a4, a4, 1024 + addi a1, a5, 1024 + ld s0, 776(a5) + ld s1, 792(a5) + ld s2, 808(a5) + ld s3, 824(a5) + ld s4, 840(a5) + ld s5, 856(a5) + ld s6, 872(a5) + ld s7, 888(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 768(a5) + ld s1, 784(a5) + ld s2, 800(a5) + ld s3, 816(a5) + ld s4, 832(a5) + ld s5, 848(a5) + ld s6, 864(a5) + ld s7, 880(a5) + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + ld t0, 576(a5) + ld t3, 64(a1) + xor t0, t0, t3 + sd t0, 576(a5) + ld t0, 584(a5) + ld t3, 72(a1) + xor t0, t0, t3 + sd t0, 584(a5) + ld t0, 592(a5) + ld t3, 80(a1) + xor t0, t0, t3 + sd t0, 592(a5) + ld t0, 600(a5) + ld t3, 88(a1) + xor t0, t0, t3 + sd t0, 600(a5) + ld t0, 608(a5) + ld t3, 96(a1) + xor t0, t0, t3 + sd t0, 608(a5) + ld t0, 616(a5) + ld t3, 104(a1) + xor t0, t0, t3 + sd t0, 616(a5) + ld t0, 624(a5) + ld t3, 112(a1) + xor t0, t0, t3 + sd t0, 624(a5) + ld t0, 632(a5) + ld t3, 120(a1) + xor t0, t0, t3 + sd t0, 632(a5) + addi a1, a1, 128 +246: + addi a0, a1, 384 +247: + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 576(a5) + xor s0, s0, t0 + sd s0, 576(a5) + ld t0, 584(a5) + xor s1, s1, t0 + sd s1, 584(a5) + ld t0, 592(a5) + xor s2, s2, t0 + sd s2, 592(a5) + ld t0, 600(a5) + xor s3, s3, t0 + sd s3, 600(a5) + ld t0, 608(a5) + xor s4, s4, t0 + sd s4, 608(a5) + ld t0, 616(a5) + xor s5, s5, t0 + sd s5, 616(a5) + ld t0, 624(a5) + xor s6, s6, t0 + sd s6, 624(a5) + ld t0, 632(a5) + xor s7, s7, t0 + sd s7, 632(a5) + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t2, 400(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s7, s1 + xor t1, s5, s3 + xor t2, s2, t0 + xor t3, s6, s0 + xor t4, s0, t1 + xor t5, s4, s1 + xor t6, s4, t2 + xor a6, s6, t1 + xor a7, s2, t3 + xor s8, t2, t3 + xor s9, s7, s6 + xor s10, s7, t3 + xori s10, s10, -1 + xor s11, s6, s3 + sd s10, 0(a5) + xor s10, s5, s1 + sd s7, 8(a5) + xor s7, s5, s0 + xor s5, s5, t2 + xor t3, s4, t3 + xor s4, s4, s9 + xor s3, s3, s0 + xori s3, s3, -1 + xor s0, s2, t4 + xor s2, s2, t5 + xori s2, s2, -1 + xor s9, s1, a6 + xori s9, s9, -1 + sd s9, 16(a5) + xor s9, t0, t4 + xor t0, t0, a6 + xor a6, t1, t5 + sd s9, 24(a5) + xor s9, t1, t6 + xor t1, t1, s8 + sd t1, 32(a5) + xor t1, t2, t4 + xori t1, t1, -1 + xor t2, t2, s11 + xori t2, t2, -1 + xor t4, t4, t5 + xori t4, t4, -1 + xor s7, t6, s7 + xori s7, s7, -1 + xor s10, a7, s10 + xori s10, s10, -1 + xor a7, a7, a6 + xori a7, a7, -1 + ld a6, 8(a5) + xor t5, a6, s6 + xori t5, t5, -1 + xor t5, t5, s6 + xor a6, a6, s1 + xori a6, a6, -1 + and s1, s2, s4 + and s6, t5, s10 + xor s6, s6, s1 + and s11, t6, s7 + xor s11, s11, s1 + and s1, s0, t1 + sd s0, 8(a5) + and s0, t0, s5 + xor s0, s0, s1 + sd t0, 40(a5) + and t0, s8, s3 + xor t0, t0, s1 + and s1, t3, s9 + sd t3, 48(a5) + and t3, t4, a7 + xor t3, t3, s1 + sd t4, 56(a5) + ld t4, 16(a5) + sd s8, 64(a5) + ld s8, 0(a5) + sd t6, 72(a5) + and t6, t4, s8 + xor t6, t6, s1 + xor s6, s6, t3 + xor s11, s11, t6 + xor s0, s0, t3 + xor t0, t0, t6 + ld t6, 32(a5) + xor s6, s6, t6 + ld t6, 24(a5) + xor s11, s11, t6 + xor s0, s0, a6 + xor t0, t0, t2 + xor t2, s6, s11 + and s6, s6, s0 + xor a6, t0, s6 + and t6, t2, a6 + xor t6, t6, s11 + xor t3, s0, t0 + xor s11, s11, s6 + and s11, s11, t3 + xor s11, s11, t0 + xor s0, s0, s11 + xor t3, a6, s11 + and t0, t0, t3 + xor s0, t0, s0 + xor a6, a6, t0 + and a6, t6, a6 + xor t2, t2, a6 + xor a6, t2, s0 + xor t0, t6, s11 + xor t3, t6, t2 + xor s6, s11, s0 + xor s1, t0, a6 + and s4, s6, s4 + and s10, s0, s10 + and s7, s11, s7 + and t1, t3, t1 + and s5, t2, s5 + and s3, t6, s3 + and s9, t0, s9 + and a7, s1, a7 + and s8, a6, s8 + and s6, s6, s2 + and s0, s0, t5 + ld t5, 72(a5) + and s11, s11, t5 + ld t5, 8(a5) + and t3, t3, t5 + ld t5, 40(a5) + and t2, t2, t5 + ld t5, 64(a5) + and t6, t6, t5 + ld t5, 48(a5) + and t0, t0, t5 + ld t5, 56(a5) + and s1, s1, t5 + and a6, a6, t4 + xor a7, s10, a7 + xor t1, t1, s3 + xor t4, s9, s8 + xor t5, s4, s1 + xor s11, s11, a7 + xor s2, t3, t1 + sd t1, 16(a5) + xor t1, t0, t4 + xor t6, s7, t6 + xor s9, s9, a6 + xor s8, s8, s6 + xor s6, s6, s0 + xor t2, t2, s2 + xor s1, s1, t1 + sd s1, 56(a5) + xor s1, t5, s11 + xor s4, s4, s7 + xor s10, s10, s5 + xor s3, s3, t5 + xor s0, s0, s9 + xor t3, t3, s11 + xor t0, t0, a7 + xor a6, a6, s8 + ld a7, 16(a5) + xor a7, a7, s6 + xor s4, t4, s4 + xor s2, s2, t6 + xor t1, t1, s6 + xor t6, t6, s8 + xor s9, s9, t0 + ld t0, 56(a5) + xor s8, t2, t0 + xor t2, t2, s1 + xor s5, t0, a7 + xori s5, s5, -1 + xor s1, s1, s0 + xori s1, s1, -1 + xor s10, s10, s3 + xor s3, t3, t6 + xori s3, s3, -1 + xor a6, a6, t2 + xori a6, a6, -1 + xor s7, s2, s9 + xor s6, t1, s10 + xori s6, s6, -1 + addi s2, s1, 0 + addi s1, a6, 0 + addi s0, s8, 0 + ld t2, 408(a5) + addi t1, s7, 0 + xor t0, s7, s6 + and t0, t0, t2 + xor s7, s7, t0 + xor t0, s6, s5 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s5, s4 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s4, s3 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s3, s2 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s2, s1 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s1, s0 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s0, t1 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 416(a5) + addi t1, s0, 0 + xor t0, s0, s1 + and t0, t0, t2 + xor s0, s0, t0 + xor t0, s1, s2 + and t0, t0, t2 + xor s1, s1, t0 + xor t0, s2, s3 + and t0, t0, t2 + xor s2, s2, t0 + xor t0, s3, s4 + and t0, t0, t2 + xor s3, s3, t0 + xor t0, s4, s5 + and t0, t0, t2 + xor s4, s4, t0 + xor t0, s5, s6 + and t0, t0, t2 + xor s5, s5, t0 + xor t0, s6, s7 + and t0, t0, t2 + xor s6, s6, t0 + xor t0, s7, t1 + and t0, t0, t2 + xor s7, s7, t0 + ld t2, 384(a5) + ld t3, 392(a5) + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s0, 56 + slli t0, s0, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 8 + slli t0, s0, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s0, s0, t0 + srli t4, s0, 40 + slli t0, s0, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s1, 56 + slli t0, s1, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 8 + slli t0, s1, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s1, s1, t0 + srli t4, s1, 40 + slli t0, s1, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s2, 56 + slli t0, s2, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 8 + slli t0, s2, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s2, s2, t0 + srli t4, s2, 40 + slli t0, s2, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s3, 56 + slli t0, s3, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 8 + slli t0, s3, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s3, s3, t0 + srli t4, s3, 40 + slli t0, s3, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s4, 56 + slli t0, s4, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 8 + slli t0, s4, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s4, s4, t0 + srli t4, s4, 40 + slli t0, s4, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s5, 56 + slli t0, s5, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 8 + slli t0, s5, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s5, s5, t0 + srli t4, s5, 40 + slli t0, s5, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s6, 56 + slli t0, s6, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 8 + slli t0, s6, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s6, s6, t0 + srli t4, s6, 40 + slli t0, s6, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + srli t4, s7, 56 + slli t0, s7, 8 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 8 + slli t0, s7, 56 + xor t0, t0, t4 + and t0, t0, t3 + xor s7, s7, t0 + srli t4, s7, 40 + slli t0, s7, 24 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t0, 512(a5) + xor s0, s0, t0 + sd s0, 512(a5) + ld t0, 520(a5) + xor s1, s1, t0 + sd s1, 520(a5) + ld t0, 528(a5) + xor s2, s2, t0 + sd s2, 528(a5) + ld t0, 536(a5) + xor s3, s3, t0 + sd s3, 536(a5) + ld t0, 544(a5) + xor s4, s4, t0 + sd s4, 544(a5) + ld t0, 552(a5) + xor s5, s5, t0 + sd s5, 552(a5) + ld t0, 560(a5) + xor s6, s6, t0 + sd s6, 560(a5) + ld t0, 568(a5) + xor s7, s7, t0 + sd s7, 568(a5) + addi a1, a1, 128 + sub t0, a1, a0 + bnez t0, 247b + sub t0, a1, a4 + bnez t0, 248f + j 249f +248: + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t2, 384(a5) + ld t3, 120(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 112(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 104(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 96(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 88(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 80(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 72(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 64(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 112(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 104(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 96(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 88(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 80(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 72(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 64(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 120(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 512(a5) + ld s1, 520(a5) + ld s2, 528(a5) + ld s3, 536(a5) + ld s4, 544(a5) + ld s5, 552(a5) + ld s6, 560(a5) + ld s7, 568(a5) + ld t2, 392(a5) + addi t1, s7, 0 + ld t3, 48(a1) + and t0, s6, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 40(a1) + and t0, s5, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 32(a1) + and t0, s4, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 24(a1) + and t0, s3, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 16(a1) + and t0, s2, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 8(a1) + and t0, s1, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 0(a1) + and t0, s0, t3 + srli t4, t0, 56 + slli t0, t0, 8 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 56(a1) + and t0, t1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + ld t2, 384(a5) + ld t3, 56(a1) + or t0, s7, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s7, s7, t0 + ld t3, 48(a1) + or t0, s6, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s6, s6, t0 + ld t3, 40(a1) + or t0, s5, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s5, s5, t0 + ld t3, 32(a1) + or t0, s4, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s4, s4, t0 + ld t3, 24(a1) + or t0, s3, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s3, s3, t0 + ld t3, 16(a1) + or t0, s2, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s2, s2, t0 + ld t3, 8(a1) + or t0, s1, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s1, s1, t0 + ld t3, 0(a1) + or t0, s0, t3 + srli t4, t0, 8 + slli t0, t0, 56 + xor t0, t0, t4 + and t0, t0, t2 + xor s0, s0, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + addi a1, a1, 128 +249: + sub t0, a1, a4 + bnez t0, 246b + ld t0, 64(a1) + xor s0, s0, t0 + ld t0, 72(a1) + xor s1, s1, t0 + ld t0, 80(a1) + xor s2, s2, t0 + ld t0, 88(a1) + xor s3, s3, t0 + ld t0, 96(a1) + xor s4, s4, t0 + ld t0, 104(a1) + xor s5, s5, t0 + ld t0, 112(a1) + xor s6, s6, t0 + ld t0, 120(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 776(a5) + sd s1, 792(a5) + sd s2, 808(a5) + sd s3, 824(a5) + sd s4, 840(a5) + sd s5, 856(a5) + sd s6, 872(a5) + sd s7, 888(a5) + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + ld t0, 0(a1) + xor s0, s0, t0 + ld t0, 8(a1) + xor s1, s1, t0 + ld t0, 16(a1) + xor s2, s2, t0 + ld t0, 24(a1) + xor s3, s3, t0 + ld t0, 32(a1) + xor s4, s4, t0 + ld t0, 40(a1) + xor s5, s5, t0 + ld t0, 48(a1) + xor s6, s6, t0 + ld t0, 56(a1) + xor s7, s7, t0 + ld t3, 424(a5) + ld t4, 432(a5) + ld t6, 448(a5) + ld a6, 456(a5) + ld a7, 464(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 768(a5) + sd s1, 784(a5) + sd s2, 800(a5) + sd s3, 816(a5) + sd s4, 832(a5) + sd s5, 848(a5) + sd s6, 864(a5) + sd s7, 880(a5) + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + ld s8, 704(a5) + ld s9, 712(a5) + ld s10, 720(a5) + ld s11, 728(a5) + addi s1, a2, 0 + addi s2, a3, 0 + addi s3, ra, 0 + addi s4, a5, -48 + ld ra, 736(a5) + ld a0, 744(a5) + addi t0, zero, 16 + bltu s3, t0, 250f + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + lwu t0, 0(s2) + lwu t1, 816(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 820(s4) + xor t0, t0, t1 + sw t0, 4(s2) + lwu t0, 8(s2) + lwu t1, 824(s4) + xor t0, t0, t1 + sw t0, 8(s2) + lwu t0, 12(s2) + lwu t1, 828(s4) + xor t0, t0, t1 + sw t0, 12(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 251f +250: + lwu t0, 816(s4) + sw t0, 32(s4) + lwu t0, 820(s4) + sw t0, 36(s4) + lwu t0, 824(s4) + sw t0, 40(s4) + lwu t0, 828(s4) + sw t0, 44(s4) + addi t2, s4, 816 +252: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 252b +251: + bnez s3, 245b + j 244f +243: +244: +232: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lwu t0, 40(s4) + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lwu t0, 44(s4) + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 406 +253: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 253b + addi sp, sp, 1216 + addi sp, sp, 2032 +21: + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/cast5_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/cast5_ofb.s index 756e032077b..20899fe11d7 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/cast5_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/cast5_ofb.s @@ -1816,3 +1816,1892 @@ vg_cast5_ofb: 21: ret .option pop + +vg_cast5_ofb_final: + .option push + .option arch, +m, +c + addi t0, a1, 0 + addi a1, a2, 0 + addi a2, a3, 0 + addi a3, a4, 0 + addi t0, t0, -12 + beqz t0, 20f + addi sp, sp, -128 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + addi s2, a2, 0 + andi t0, s2, 3 + beqz t0, 22f + beqz s3, 24f +26: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + sd s0, 56(s4) + sd s5, 64(s4) + sd s6, 72(s4) + sd s7, 80(s4) + sd s8, 88(s4) + sd s9, 96(s4) + sd s10, 104(s4) + sd s11, 112(s4) + sd ra, 120(s4) + addi a2, s4, 48 + addi a3, s1, 0 + addi a4, s2, 0 + addi s11, s3, 0 + addi ra, s4, 0 + lla t4, {VG_CAST5_S1234} + addi a1, zero, 16 + lbu a6, 0(a2) + slli a6, a6, 24 + lbu t0, 1(a2) + slli t0, t0, 16 + or a6, a6, t0 + lbu t0, 2(a2) + slli t0, t0, 8 + or a6, a6, t0 + lbu t0, 3(a2) + or a6, a6, t0 + lbu a7, 4(a2) + slli a7, a7, 24 + lbu t0, 5(a2) + slli t0, t0, 16 + or a7, a7, t0 + lbu t0, 6(a2) + slli t0, t0, 8 + or a7, a7, t0 + lbu t0, 7(a2) + or a7, a7, t0 + addi s8, a0, 0 + addi s9, a1, 0 + addi s10, zero, 1 +27: + beqz s10, 28f + addi t0, s10, -1 + beqz t0, 210f + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + xor t5, t5, a7 + j 211f +210: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + add t5, t5, a7 +211: + j 29f +28: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + sub t5, t5, a7 +29: + lbu t6, 64(s8) + addi t1, zero, 32 + sub t1, t1, t6 + srlw t1, t5, t1 + sllw t5, t5, t6 + or t5, t5, t1 + andi s0, t5, 255 + srliw s1, t5, 8 + andi s1, s1, 255 + srliw s2, t5, 16 + andi s2, s2, 255 + srliw s3, t5, 24 + slli t0, s0, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s1, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s0, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s1, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s0, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s1, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s0, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s1, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s0, s0, 4 + addi s0, s0, -17 + srli s1, s1, 4 + addi s1, s1, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +212: + addi t3, t3, -256 + addi s0, s0, 1 + addi s1, s1, 1 + ld s5, 0(t3) + ld s6, 16(t3) + xor s6, s6, s5 + and s6, s6, t0 + xor s5, s5, s6 + ld s6, 32(t3) + ld a5, 48(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t1 + xor s5, s5, s6 + ld s6, 64(t3) + ld a5, 80(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 96(t3) + ld t6, 112(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t2 + xor s5, s5, s6 + ld s6, 128(t3) + ld a5, 144(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 160(t3) + ld t6, 176(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + ld a5, 192(t3) + ld t6, 208(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 224(t3) + ld s7, 240(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t2 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t5 + xor s5, s5, s6 + srli s6, s0, 32 + srai a5, s1, 63 + slli a5, a5, 32 + or s6, s6, a5 + xor s5, s5, s4 + and s5, s5, s6 + xor s4, s4, s5 + bne t3, t4, 212b + srli s5, s4, 32 + slli s4, s4, 32 + srli s4, s4, 32 + slli t0, s2, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s3, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s2, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s3, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s2, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s3, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s2, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s3, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s2, s2, 4 + addi s2, s2, -17 + srli s3, s3, 4 + addi s3, s3, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +213: + addi t3, t3, -256 + addi s2, s2, 1 + addi s3, s3, 1 + ld s0, 8(t3) + ld s1, 24(t3) + xor s1, s1, s0 + and s1, s1, t0 + xor s0, s0, s1 + ld s1, 40(t3) + ld a5, 56(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t1 + xor s0, s0, s1 + ld s1, 72(t3) + ld a5, 88(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 104(t3) + ld t6, 120(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t2 + xor s0, s0, s1 + ld s1, 136(t3) + ld a5, 152(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 168(t3) + ld t6, 184(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + ld a5, 200(t3) + ld t6, 216(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 232(t3) + ld s7, 248(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t2 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t5 + xor s0, s0, s1 + srli s1, s2, 32 + srai a5, s3, 63 + slli a5, a5, 32 + or s1, s1, a5 + xor s0, s0, s6 + and s0, s0, s1 + xor s6, s6, s0 + bne t3, t4, 213b + srli s7, s6, 32 + slli s6, s6, 32 + srli s6, s6, 32 + beqz s10, 214f + addi t0, s10, -1 + beqz t0, 216f + sub t5, s7, s6 + add t5, t5, s5 + xor t5, t5, s4 + j 217f +216: + xor t5, s7, s6 + sub t5, t5, s5 + add t5, t5, s4 +217: + j 215f +214: + add t5, s7, s6 + xor t5, t5, s5 + sub t5, t5, s4 +215: + xor t5, t5, a6 + addi a6, a7, 0 + addi a7, t5, 0 + addi s8, s8, 4 + addi t0, s10, -2 + beqz t0, 218f + addi s10, s10, 1 + j 219f +218: + addi s10, zero, 0 +219: + addi s9, s9, -1 + bnez s9, 27b + srli t0, a7, 24 + sb t0, 0(a2) + srli t0, a7, 16 + sb t0, 1(a2) + srli t0, a7, 8 + sb t0, 2(a2) + srli t0, a7, 0 + sb t0, 3(a2) + srli t0, a6, 24 + sb t0, 4(a2) + srli t0, a6, 16 + sb t0, 5(a2) + srli t0, a6, 8 + sb t0, 6(a2) + srli t0, a6, 0 + sb t0, 7(a2) + addi s1, a3, 0 + addi s2, a4, 0 + addi s3, s11, 0 + addi s4, ra, 0 + ld s0, 56(s4) + ld s5, 64(s4) + ld s6, 72(s4) + ld s7, 80(s4) + ld s8, 88(s4) + ld s9, 96(s4) + ld s10, 104(s4) + ld s11, 112(s4) + ld ra, 120(s4) + addi t0, zero, 8 + bltu s3, t0, 220f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 48(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 52(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 221f +220: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +222: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 222b +221: + bnez s3, 26b + j 25f +24: +25: + j 23f +22: + beqz s3, 223f +225: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + sd s0, 56(s4) + sd s5, 64(s4) + sd s6, 72(s4) + sd s7, 80(s4) + sd s8, 88(s4) + sd s9, 96(s4) + sd s10, 104(s4) + sd s11, 112(s4) + sd ra, 120(s4) + addi a2, s4, 48 + addi a3, s1, 0 + addi a4, s2, 0 + addi s11, s3, 0 + addi ra, s4, 0 + lla t4, {VG_CAST5_S1234} + addi a1, zero, 16 + lbu a6, 0(a2) + slli a6, a6, 24 + lbu t0, 1(a2) + slli t0, t0, 16 + or a6, a6, t0 + lbu t0, 2(a2) + slli t0, t0, 8 + or a6, a6, t0 + lbu t0, 3(a2) + or a6, a6, t0 + lbu a7, 4(a2) + slli a7, a7, 24 + lbu t0, 5(a2) + slli t0, t0, 16 + or a7, a7, t0 + lbu t0, 6(a2) + slli t0, t0, 8 + or a7, a7, t0 + lbu t0, 7(a2) + or a7, a7, t0 + addi s8, a0, 0 + addi s9, a1, 0 + addi s10, zero, 1 +226: + beqz s10, 227f + addi t0, s10, -1 + beqz t0, 229f + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + xor t5, t5, a7 + j 230f +229: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + add t5, t5, a7 +230: + j 228f +227: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + sub t5, t5, a7 +228: + lbu t6, 64(s8) + addi t1, zero, 32 + sub t1, t1, t6 + srlw t1, t5, t1 + sllw t5, t5, t6 + or t5, t5, t1 + andi s0, t5, 255 + srliw s1, t5, 8 + andi s1, s1, 255 + srliw s2, t5, 16 + andi s2, s2, 255 + srliw s3, t5, 24 + slli t0, s0, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s1, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s0, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s1, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s0, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s1, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s0, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s1, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s0, s0, 4 + addi s0, s0, -17 + srli s1, s1, 4 + addi s1, s1, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +231: + addi t3, t3, -256 + addi s0, s0, 1 + addi s1, s1, 1 + ld s5, 0(t3) + ld s6, 16(t3) + xor s6, s6, s5 + and s6, s6, t0 + xor s5, s5, s6 + ld s6, 32(t3) + ld a5, 48(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t1 + xor s5, s5, s6 + ld s6, 64(t3) + ld a5, 80(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 96(t3) + ld t6, 112(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t2 + xor s5, s5, s6 + ld s6, 128(t3) + ld a5, 144(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 160(t3) + ld t6, 176(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + ld a5, 192(t3) + ld t6, 208(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 224(t3) + ld s7, 240(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t2 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t5 + xor s5, s5, s6 + srli s6, s0, 32 + srai a5, s1, 63 + slli a5, a5, 32 + or s6, s6, a5 + xor s5, s5, s4 + and s5, s5, s6 + xor s4, s4, s5 + bne t3, t4, 231b + srli s5, s4, 32 + slli s4, s4, 32 + srli s4, s4, 32 + slli t0, s2, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s3, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s2, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s3, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s2, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s3, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s2, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s3, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s2, s2, 4 + addi s2, s2, -17 + srli s3, s3, 4 + addi s3, s3, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +232: + addi t3, t3, -256 + addi s2, s2, 1 + addi s3, s3, 1 + ld s0, 8(t3) + ld s1, 24(t3) + xor s1, s1, s0 + and s1, s1, t0 + xor s0, s0, s1 + ld s1, 40(t3) + ld a5, 56(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t1 + xor s0, s0, s1 + ld s1, 72(t3) + ld a5, 88(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 104(t3) + ld t6, 120(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t2 + xor s0, s0, s1 + ld s1, 136(t3) + ld a5, 152(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 168(t3) + ld t6, 184(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + ld a5, 200(t3) + ld t6, 216(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 232(t3) + ld s7, 248(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t2 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t5 + xor s0, s0, s1 + srli s1, s2, 32 + srai a5, s3, 63 + slli a5, a5, 32 + or s1, s1, a5 + xor s0, s0, s6 + and s0, s0, s1 + xor s6, s6, s0 + bne t3, t4, 232b + srli s7, s6, 32 + slli s6, s6, 32 + srli s6, s6, 32 + beqz s10, 233f + addi t0, s10, -1 + beqz t0, 235f + sub t5, s7, s6 + add t5, t5, s5 + xor t5, t5, s4 + j 236f +235: + xor t5, s7, s6 + sub t5, t5, s5 + add t5, t5, s4 +236: + j 234f +233: + add t5, s7, s6 + xor t5, t5, s5 + sub t5, t5, s4 +234: + xor t5, t5, a6 + addi a6, a7, 0 + addi a7, t5, 0 + addi s8, s8, 4 + addi t0, s10, -2 + beqz t0, 237f + addi s10, s10, 1 + j 238f +237: + addi s10, zero, 0 +238: + addi s9, s9, -1 + bnez s9, 226b + srli t0, a7, 24 + sb t0, 0(a2) + srli t0, a7, 16 + sb t0, 1(a2) + srli t0, a7, 8 + sb t0, 2(a2) + srli t0, a7, 0 + sb t0, 3(a2) + srli t0, a6, 24 + sb t0, 4(a2) + srli t0, a6, 16 + sb t0, 5(a2) + srli t0, a6, 8 + sb t0, 6(a2) + srli t0, a6, 0 + sb t0, 7(a2) + addi s1, a3, 0 + addi s2, a4, 0 + addi s3, s11, 0 + addi s4, ra, 0 + ld s0, 56(s4) + ld s5, 64(s4) + ld s6, 72(s4) + ld s7, 80(s4) + ld s8, 88(s4) + ld s9, 96(s4) + ld s10, 104(s4) + ld s11, 112(s4) + ld ra, 120(s4) + addi t0, zero, 8 + bltu s3, t0, 239f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lwu t0, 0(s2) + lwu t1, 48(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 52(s4) + xor t0, t0, t1 + sw t0, 4(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 240f +239: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +241: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 241b +240: + bnez s3, 225b + j 224f +223: +224: +23: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 16 +242: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 242b + addi sp, sp, 128 + j 21f +20: + addi sp, sp, -128 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + addi s2, a2, 0 + andi t0, s2, 3 + beqz t0, 243f + beqz s3, 245f +247: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + sd s0, 56(s4) + sd s5, 64(s4) + sd s6, 72(s4) + sd s7, 80(s4) + sd s8, 88(s4) + sd s9, 96(s4) + sd s10, 104(s4) + sd s11, 112(s4) + sd ra, 120(s4) + addi a2, s4, 48 + addi a3, s1, 0 + addi a4, s2, 0 + addi s11, s3, 0 + addi ra, s4, 0 + lla t4, {VG_CAST5_S1234} + addi a1, zero, 12 + lbu a6, 0(a2) + slli a6, a6, 24 + lbu t0, 1(a2) + slli t0, t0, 16 + or a6, a6, t0 + lbu t0, 2(a2) + slli t0, t0, 8 + or a6, a6, t0 + lbu t0, 3(a2) + or a6, a6, t0 + lbu a7, 4(a2) + slli a7, a7, 24 + lbu t0, 5(a2) + slli t0, t0, 16 + or a7, a7, t0 + lbu t0, 6(a2) + slli t0, t0, 8 + or a7, a7, t0 + lbu t0, 7(a2) + or a7, a7, t0 + addi s8, a0, 0 + addi s9, a1, 0 + addi s10, zero, 1 +248: + beqz s10, 249f + addi t0, s10, -1 + beqz t0, 251f + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + xor t5, t5, a7 + j 252f +251: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + add t5, t5, a7 +252: + j 250f +249: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + sub t5, t5, a7 +250: + lbu t6, 64(s8) + addi t1, zero, 32 + sub t1, t1, t6 + srlw t1, t5, t1 + sllw t5, t5, t6 + or t5, t5, t1 + andi s0, t5, 255 + srliw s1, t5, 8 + andi s1, s1, 255 + srliw s2, t5, 16 + andi s2, s2, 255 + srliw s3, t5, 24 + slli t0, s0, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s1, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s0, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s1, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s0, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s1, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s0, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s1, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s0, s0, 4 + addi s0, s0, -17 + srli s1, s1, 4 + addi s1, s1, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +253: + addi t3, t3, -256 + addi s0, s0, 1 + addi s1, s1, 1 + ld s5, 0(t3) + ld s6, 16(t3) + xor s6, s6, s5 + and s6, s6, t0 + xor s5, s5, s6 + ld s6, 32(t3) + ld a5, 48(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t1 + xor s5, s5, s6 + ld s6, 64(t3) + ld a5, 80(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 96(t3) + ld t6, 112(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t2 + xor s5, s5, s6 + ld s6, 128(t3) + ld a5, 144(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 160(t3) + ld t6, 176(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + ld a5, 192(t3) + ld t6, 208(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 224(t3) + ld s7, 240(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t2 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t5 + xor s5, s5, s6 + srli s6, s0, 32 + srai a5, s1, 63 + slli a5, a5, 32 + or s6, s6, a5 + xor s5, s5, s4 + and s5, s5, s6 + xor s4, s4, s5 + bne t3, t4, 253b + srli s5, s4, 32 + slli s4, s4, 32 + srli s4, s4, 32 + slli t0, s2, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s3, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s2, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s3, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s2, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s3, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s2, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s3, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s2, s2, 4 + addi s2, s2, -17 + srli s3, s3, 4 + addi s3, s3, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +254: + addi t3, t3, -256 + addi s2, s2, 1 + addi s3, s3, 1 + ld s0, 8(t3) + ld s1, 24(t3) + xor s1, s1, s0 + and s1, s1, t0 + xor s0, s0, s1 + ld s1, 40(t3) + ld a5, 56(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t1 + xor s0, s0, s1 + ld s1, 72(t3) + ld a5, 88(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 104(t3) + ld t6, 120(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t2 + xor s0, s0, s1 + ld s1, 136(t3) + ld a5, 152(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 168(t3) + ld t6, 184(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + ld a5, 200(t3) + ld t6, 216(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 232(t3) + ld s7, 248(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t2 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t5 + xor s0, s0, s1 + srli s1, s2, 32 + srai a5, s3, 63 + slli a5, a5, 32 + or s1, s1, a5 + xor s0, s0, s6 + and s0, s0, s1 + xor s6, s6, s0 + bne t3, t4, 254b + srli s7, s6, 32 + slli s6, s6, 32 + srli s6, s6, 32 + beqz s10, 255f + addi t0, s10, -1 + beqz t0, 257f + sub t5, s7, s6 + add t5, t5, s5 + xor t5, t5, s4 + j 258f +257: + xor t5, s7, s6 + sub t5, t5, s5 + add t5, t5, s4 +258: + j 256f +255: + add t5, s7, s6 + xor t5, t5, s5 + sub t5, t5, s4 +256: + xor t5, t5, a6 + addi a6, a7, 0 + addi a7, t5, 0 + addi s8, s8, 4 + addi t0, s10, -2 + beqz t0, 259f + addi s10, s10, 1 + j 260f +259: + addi s10, zero, 0 +260: + addi s9, s9, -1 + bnez s9, 248b + srli t0, a7, 24 + sb t0, 0(a2) + srli t0, a7, 16 + sb t0, 1(a2) + srli t0, a7, 8 + sb t0, 2(a2) + srli t0, a7, 0 + sb t0, 3(a2) + srli t0, a6, 24 + sb t0, 4(a2) + srli t0, a6, 16 + sb t0, 5(a2) + srli t0, a6, 8 + sb t0, 6(a2) + srli t0, a6, 0 + sb t0, 7(a2) + addi s1, a3, 0 + addi s2, a4, 0 + addi s3, s11, 0 + addi s4, ra, 0 + ld s0, 56(s4) + ld s5, 64(s4) + ld s6, 72(s4) + ld s7, 80(s4) + ld s8, 88(s4) + ld s9, 96(s4) + ld s10, 104(s4) + ld s11, 112(s4) + ld ra, 120(s4) + addi t0, zero, 8 + bltu s3, t0, 261f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 48(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 52(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 262f +261: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +263: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 263b +262: + bnez s3, 247b + j 246f +245: +246: + j 244f +243: + beqz s3, 264f +266: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + sd s0, 56(s4) + sd s5, 64(s4) + sd s6, 72(s4) + sd s7, 80(s4) + sd s8, 88(s4) + sd s9, 96(s4) + sd s10, 104(s4) + sd s11, 112(s4) + sd ra, 120(s4) + addi a2, s4, 48 + addi a3, s1, 0 + addi a4, s2, 0 + addi s11, s3, 0 + addi ra, s4, 0 + lla t4, {VG_CAST5_S1234} + addi a1, zero, 12 + lbu a6, 0(a2) + slli a6, a6, 24 + lbu t0, 1(a2) + slli t0, t0, 16 + or a6, a6, t0 + lbu t0, 2(a2) + slli t0, t0, 8 + or a6, a6, t0 + lbu t0, 3(a2) + or a6, a6, t0 + lbu a7, 4(a2) + slli a7, a7, 24 + lbu t0, 5(a2) + slli t0, t0, 16 + or a7, a7, t0 + lbu t0, 6(a2) + slli t0, t0, 8 + or a7, a7, t0 + lbu t0, 7(a2) + or a7, a7, t0 + addi s8, a0, 0 + addi s9, a1, 0 + addi s10, zero, 1 +267: + beqz s10, 268f + addi t0, s10, -1 + beqz t0, 270f + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + xor t5, t5, a7 + j 271f +270: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + add t5, t5, a7 +271: + j 269f +268: + lbu t5, 0(s8) + lbu t0, 1(s8) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(s8) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(s8) + slli t0, t0, 24 + or t5, t5, t0 + sub t5, t5, a7 +269: + lbu t6, 64(s8) + addi t1, zero, 32 + sub t1, t1, t6 + srlw t1, t5, t1 + sllw t5, t5, t6 + or t5, t5, t1 + andi s0, t5, 255 + srliw s1, t5, 8 + andi s1, s1, 255 + srliw s2, t5, 16 + andi s2, s2, 255 + srliw s3, t5, 24 + slli t0, s0, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s1, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s0, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s1, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s0, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s1, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s0, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s1, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s0, s0, 4 + addi s0, s0, -17 + srli s1, s1, 4 + addi s1, s1, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +272: + addi t3, t3, -256 + addi s0, s0, 1 + addi s1, s1, 1 + ld s5, 0(t3) + ld s6, 16(t3) + xor s6, s6, s5 + and s6, s6, t0 + xor s5, s5, s6 + ld s6, 32(t3) + ld a5, 48(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t1 + xor s5, s5, s6 + ld s6, 64(t3) + ld a5, 80(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 96(t3) + ld t6, 112(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t2 + xor s5, s5, s6 + ld s6, 128(t3) + ld a5, 144(t3) + xor a5, a5, s6 + and a5, a5, t0 + xor s6, s6, a5 + ld a5, 160(t3) + ld t6, 176(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t1 + xor s6, s6, a5 + ld a5, 192(t3) + ld t6, 208(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 224(t3) + ld s7, 240(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s6 + and a5, a5, t2 + xor s6, s6, a5 + xor s6, s6, s5 + and s6, s6, t5 + xor s5, s5, s6 + srli s6, s0, 32 + srai a5, s1, 63 + slli a5, a5, 32 + or s6, s6, a5 + xor s5, s5, s4 + and s5, s5, s6 + xor s4, s4, s5 + bne t3, t4, 272b + srli s5, s4, 32 + slli s4, s4, 32 + srli s4, s4, 32 + slli t0, s2, 63 + srai t0, t0, 63 + srli t0, t0, 32 + slli a5, s3, 63 + srai a5, a5, 63 + slli a5, a5, 32 + or t0, t0, a5 + slli t1, s2, 62 + srai t1, t1, 63 + srli t1, t1, 32 + slli a5, s3, 62 + srai a5, a5, 63 + slli a5, a5, 32 + or t1, t1, a5 + slli t2, s2, 61 + srai t2, t2, 63 + srli t2, t2, 32 + slli a5, s3, 61 + srai a5, a5, 63 + slli a5, a5, 32 + or t2, t2, a5 + slli t5, s2, 60 + srai t5, t5, 63 + srli t5, t5, 32 + slli a5, s3, 60 + srai a5, a5, 63 + slli a5, a5, 32 + or t5, t5, a5 + srli s2, s2, 4 + addi s2, s2, -17 + srli s3, s3, 4 + addi s3, s3, -17 + addi t3, t4, 2047 + addi t3, t3, 2047 + addi t3, t3, 2 +273: + addi t3, t3, -256 + addi s2, s2, 1 + addi s3, s3, 1 + ld s0, 8(t3) + ld s1, 24(t3) + xor s1, s1, s0 + and s1, s1, t0 + xor s0, s0, s1 + ld s1, 40(t3) + ld a5, 56(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t1 + xor s0, s0, s1 + ld s1, 72(t3) + ld a5, 88(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 104(t3) + ld t6, 120(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t2 + xor s0, s0, s1 + ld s1, 136(t3) + ld a5, 152(t3) + xor a5, a5, s1 + and a5, a5, t0 + xor s1, s1, a5 + ld a5, 168(t3) + ld t6, 184(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t1 + xor s1, s1, a5 + ld a5, 200(t3) + ld t6, 216(t3) + xor t6, t6, a5 + and t6, t6, t0 + xor a5, a5, t6 + ld t6, 232(t3) + ld s7, 248(t3) + xor s7, s7, t6 + and s7, s7, t0 + xor t6, t6, s7 + xor t6, t6, a5 + and t6, t6, t1 + xor a5, a5, t6 + xor a5, a5, s1 + and a5, a5, t2 + xor s1, s1, a5 + xor s1, s1, s0 + and s1, s1, t5 + xor s0, s0, s1 + srli s1, s2, 32 + srai a5, s3, 63 + slli a5, a5, 32 + or s1, s1, a5 + xor s0, s0, s6 + and s0, s0, s1 + xor s6, s6, s0 + bne t3, t4, 273b + srli s7, s6, 32 + slli s6, s6, 32 + srli s6, s6, 32 + beqz s10, 274f + addi t0, s10, -1 + beqz t0, 276f + sub t5, s7, s6 + add t5, t5, s5 + xor t5, t5, s4 + j 277f +276: + xor t5, s7, s6 + sub t5, t5, s5 + add t5, t5, s4 +277: + j 275f +274: + add t5, s7, s6 + xor t5, t5, s5 + sub t5, t5, s4 +275: + xor t5, t5, a6 + addi a6, a7, 0 + addi a7, t5, 0 + addi s8, s8, 4 + addi t0, s10, -2 + beqz t0, 278f + addi s10, s10, 1 + j 279f +278: + addi s10, zero, 0 +279: + addi s9, s9, -1 + bnez s9, 267b + srli t0, a7, 24 + sb t0, 0(a2) + srli t0, a7, 16 + sb t0, 1(a2) + srli t0, a7, 8 + sb t0, 2(a2) + srli t0, a7, 0 + sb t0, 3(a2) + srli t0, a6, 24 + sb t0, 4(a2) + srli t0, a6, 16 + sb t0, 5(a2) + srli t0, a6, 8 + sb t0, 6(a2) + srli t0, a6, 0 + sb t0, 7(a2) + addi s1, a3, 0 + addi s2, a4, 0 + addi s3, s11, 0 + addi s4, ra, 0 + ld s0, 56(s4) + ld s5, 64(s4) + ld s6, 72(s4) + ld s7, 80(s4) + ld s8, 88(s4) + ld s9, 96(s4) + ld s10, 104(s4) + ld s11, 112(s4) + ld ra, 120(s4) + addi t0, zero, 8 + bltu s3, t0, 280f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lwu t0, 0(s2) + lwu t1, 48(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 52(s4) + xor t0, t0, t1 + sw t0, 4(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 281f +280: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +282: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 282b +281: + bnez s3, 266b + j 265f +264: +265: +244: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 16 +283: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 283b + addi sp, sp, 128 +21: + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/idea_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/idea_ofb.s index 03d47fce260..82dd4375181 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/idea_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/idea_ofb.s @@ -2006,3 +2006,2044 @@ vg_idea_ofb: addi sp, sp, 64 ret .option pop + +vg_idea_ofb_final: + .option push + .option arch, +m, +c + addi sp, sp, -64 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + addi s2, a2, 0 + andi t0, s2, 3 + beqz t0, 20f + beqz s3, 22f +24: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + lui t2, 16 + addi t2, t2, -1 + addi a1, s4, 48 + lbu a3, 0(a1) + slli a3, a3, 8 + lbu t3, 1(a1) + or a3, a3, t3 + lbu a4, 2(a1) + slli a4, a4, 8 + lbu t3, 3(a1) + or a4, a4, t3 + lbu a5, 4(a1) + slli a5, a5, 8 + lbu t3, 5(a1) + or a5, a5, t3 + lbu a6, 6(a1) + slli a6, a6, 8 + lbu t3, 7(a1) + or a6, a6, t3 + addi t0, a3, 0 + lbu t1, 0(a0) + lbu t3, 1(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 6(a0) + lbu t3, 7(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 2(a0) + lbu t3, 3(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 4(a0) + lbu t3, 5(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 8(a0) + lbu t3, 9(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 10(a0) + lbu t3, 11(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 12(a0) + lbu t3, 13(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 18(a0) + lbu t3, 19(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 14(a0) + lbu t3, 15(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 16(a0) + lbu t3, 17(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 20(a0) + lbu t3, 21(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 22(a0) + lbu t3, 23(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 24(a0) + lbu t3, 25(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 30(a0) + lbu t3, 31(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 26(a0) + lbu t3, 27(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 28(a0) + lbu t3, 29(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 32(a0) + lbu t3, 33(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 34(a0) + lbu t3, 35(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 36(a0) + lbu t3, 37(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 42(a0) + lbu t3, 43(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 38(a0) + lbu t3, 39(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 40(a0) + lbu t3, 41(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 44(a0) + lbu t3, 45(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 46(a0) + lbu t3, 47(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 48(a0) + lbu t3, 49(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 54(a0) + lbu t3, 55(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 50(a0) + lbu t3, 51(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 52(a0) + lbu t3, 53(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 56(a0) + lbu t3, 57(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 58(a0) + lbu t3, 59(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 60(a0) + lbu t3, 61(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 66(a0) + lbu t3, 67(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 62(a0) + lbu t3, 63(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 64(a0) + lbu t3, 65(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 68(a0) + lbu t3, 69(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 70(a0) + lbu t3, 71(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 72(a0) + lbu t3, 73(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 78(a0) + lbu t3, 79(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 74(a0) + lbu t3, 75(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 76(a0) + lbu t3, 77(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 80(a0) + lbu t3, 81(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 82(a0) + lbu t3, 83(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 84(a0) + lbu t3, 85(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 90(a0) + lbu t3, 91(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 86(a0) + lbu t3, 87(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 88(a0) + lbu t3, 89(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 92(a0) + lbu t3, 93(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 94(a0) + lbu t3, 95(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 96(a0) + lbu t3, 97(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 102(a0) + lbu t3, 103(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 98(a0) + lbu t3, 99(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + lbu t1, 100(a0) + lbu t3, 101(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + sb a3, 1(a1) + srli t3, a3, 8 + sb t3, 0(a1) + sb a5, 3(a1) + srli t3, a5, 8 + sb t3, 2(a1) + sb a4, 5(a1) + srli t3, a4, 8 + sb t3, 4(a1) + sb a6, 7(a1) + srli t3, a6, 8 + sb t3, 6(a1) + addi t0, zero, 8 + bltu s3, t0, 25f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 48(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 52(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 26f +25: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +27: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 27b +26: + bnez s3, 24b + j 23f +22: +23: + j 21f +20: + beqz s3, 28f +210: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + lui t2, 16 + addi t2, t2, -1 + addi a1, s4, 48 + lbu a3, 0(a1) + slli a3, a3, 8 + lbu t3, 1(a1) + or a3, a3, t3 + lbu a4, 2(a1) + slli a4, a4, 8 + lbu t3, 3(a1) + or a4, a4, t3 + lbu a5, 4(a1) + slli a5, a5, 8 + lbu t3, 5(a1) + or a5, a5, t3 + lbu a6, 6(a1) + slli a6, a6, 8 + lbu t3, 7(a1) + or a6, a6, t3 + addi t0, a3, 0 + lbu t1, 0(a0) + lbu t3, 1(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 6(a0) + lbu t3, 7(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 2(a0) + lbu t3, 3(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 4(a0) + lbu t3, 5(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 8(a0) + lbu t3, 9(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 10(a0) + lbu t3, 11(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 12(a0) + lbu t3, 13(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 18(a0) + lbu t3, 19(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 14(a0) + lbu t3, 15(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 16(a0) + lbu t3, 17(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 20(a0) + lbu t3, 21(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 22(a0) + lbu t3, 23(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 24(a0) + lbu t3, 25(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 30(a0) + lbu t3, 31(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 26(a0) + lbu t3, 27(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 28(a0) + lbu t3, 29(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 32(a0) + lbu t3, 33(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 34(a0) + lbu t3, 35(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 36(a0) + lbu t3, 37(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 42(a0) + lbu t3, 43(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 38(a0) + lbu t3, 39(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 40(a0) + lbu t3, 41(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 44(a0) + lbu t3, 45(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 46(a0) + lbu t3, 47(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 48(a0) + lbu t3, 49(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 54(a0) + lbu t3, 55(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 50(a0) + lbu t3, 51(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 52(a0) + lbu t3, 53(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 56(a0) + lbu t3, 57(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 58(a0) + lbu t3, 59(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 60(a0) + lbu t3, 61(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 66(a0) + lbu t3, 67(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 62(a0) + lbu t3, 63(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 64(a0) + lbu t3, 65(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 68(a0) + lbu t3, 69(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 70(a0) + lbu t3, 71(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 72(a0) + lbu t3, 73(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 78(a0) + lbu t3, 79(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 74(a0) + lbu t3, 75(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 76(a0) + lbu t3, 77(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 80(a0) + lbu t3, 81(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 82(a0) + lbu t3, 83(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 84(a0) + lbu t3, 85(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 90(a0) + lbu t3, 91(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 86(a0) + lbu t3, 87(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + lbu t1, 88(a0) + lbu t3, 89(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + xor t0, a3, a5 + lbu t1, 92(a0) + lbu t3, 93(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a7, t1, 0 + xor t0, a4, a6 + add t0, t0, a7 + lbu t1, 94(a0) + lbu t3, 95(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + add a7, a7, t1 + and a7, a7, t2 + xor a3, a3, t1 + xor a5, a5, t1 + xor a4, a4, a7 + xor a6, a6, a7 + addi t0, a4, 0 + addi a4, a5, 0 + addi a5, t0, 0 + addi t0, a3, 0 + lbu t1, 96(a0) + lbu t3, 97(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a3, t1, 0 + addi t0, a6, 0 + lbu t1, 102(a0) + lbu t3, 103(a0) + slli t3, t3, 8 + or t1, t1, t3 + addi t0, t0, -1 + and t0, t0, t2 + addi t0, t0, 1 + addi t1, t1, -1 + and t1, t1, t2 + addi t1, t1, 1 + mul t0, t0, t1 + and t1, t0, t2 + srli t0, t0, 16 + sub t1, t1, t0 + srli t0, t1, 63 + add t1, t1, t0 + slli t0, t0, 16 + add t1, t1, t0 + and t1, t1, t2 + addi a6, t1, 0 + lbu t1, 98(a0) + lbu t3, 99(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a5, a5, t1 + and a5, a5, t2 + lbu t1, 100(a0) + lbu t3, 101(a0) + slli t3, t3, 8 + or t1, t1, t3 + add a4, a4, t1 + and a4, a4, t2 + sb a3, 1(a1) + srli t3, a3, 8 + sb t3, 0(a1) + sb a5, 3(a1) + srli t3, a5, 8 + sb t3, 2(a1) + sb a4, 5(a1) + srli t3, a4, 8 + sb t3, 4(a1) + sb a6, 7(a1) + srli t3, a6, 8 + sb t3, 6(a1) + addi t0, zero, 8 + bltu s3, t0, 211f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lwu t0, 0(s2) + lwu t1, 48(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 52(s4) + xor t0, t0, t1 + sw t0, 4(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 212f +211: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +213: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 213b +212: + bnez s3, 210b + j 29f +28: +29: +21: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 8 +214: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 214b + addi sp, sp, 64 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/seed_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/seed_ofb.s index 483e2e355e1..a290a28a5f4 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/seed_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/seed_ofb.s @@ -5340,3 +5340,5386 @@ vg_seed_ofb: addi sp, sp, 1104 ret .option pop + +vg_seed_ofb_final: + .option push + .option arch, +m, +c + addi sp, sp, -1104 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 40(s4) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 44(s4) + addi s2, a2, 0 + andi t0, s2, 3 + beqz t0, 20f + beqz s3, 22f +24: + lwu t0, 32(s4) + sw t0, 1080(s4) + lwu t0, 36(s4) + sw t0, 1084(s4) + lwu t0, 40(s4) + sw t0, 1088(s4) + lwu t0, 44(s4) + sw t0, 1092(s4) + addi t0, s4, 48 + addi a5, t0, 0 + sd s0, 936(a5) + sd s1, 944(a5) + sd s2, 952(a5) + sd s3, 960(a5) + sd s4, 968(a5) + sd s5, 976(a5) + sd s6, 984(a5) + sd s7, 992(a5) + sd s8, 1000(a5) + sd s9, 1008(a5) + sd s10, 1016(a5) + sd s11, 1024(a5) + lui t0, 349525 + addiw t0, t0, 1365 + slli t0, t0, 32 + lui t1, 349525 + addiw t1, t1, 1365 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 832(a5) + lui t0, 209715 + addiw t0, t0, 819 + slli t0, t0, 32 + lui t1, 209715 + addiw t1, t1, 819 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 840(a5) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 848(a5) + lui t0, 4080 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 4080 + addiw t1, t1, 255 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 856(a5) + lui t0, 1044496 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 1044496 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 864(a5) + lui t0, 851917 + addiw t0, t0, -4 + slli t0, t0, 32 + lui t1, 851917 + addiw t1, t1, -4 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 872(a5) + lui t0, 3892 + addiw t0, t0, -13 + slli t0, t0, 32 + lui t1, 3892 + addiw t1, t1, -13 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 880(a5) + lui t0, 258048 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 258048 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 888(a5) + lui t0, 16 + addiw t0, t0, -817 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, -817 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 896(a5) + lui t0, 1035504 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 1035504 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 904(a5) + lui t0, 0 + addiw t0, t0, 63 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 63 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 912(a5) + lui t0, 996351 + addiw t0, t0, 768 + slli t0, t0, 32 + lui t1, 996351 + addiw t1, t1, 768 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 920(a5) + lui t0, 946878 + addiw t0, t0, 1835 + slli t0, t0, 32 + lui t1, 946878 + addiw t1, t1, 1835 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 928(a5) + addi a3, a5, 832 + sd ra, 1048(a5) + addi a1, s1, 0 + addi a2, s2, 0 + addi ra, s3, 0 + addi a0, a0, 0 + addi t2, zero, 1 + addi t3, a5, 1032 + addi t4, a5, 0 +25: + lbu t0, 0(t3) + slli t0, t0, 24 + lbu t1, 1(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 2(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 3(t3) + or t0, t0, t1 + sw t0, 576(t4) + lbu t0, 4(t3) + slli t0, t0, 24 + lbu t1, 5(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 6(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 7(t3) + or t0, t0, t1 + sw t0, 640(t4) + lbu t0, 8(t3) + slli t0, t0, 24 + lbu t1, 9(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 10(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 11(t3) + or t0, t0, t1 + sw t0, 704(t4) + lbu t0, 12(t3) + slli t0, t0, 24 + lbu t1, 13(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 14(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 15(t3) + or t0, t0, t1 + sw t0, 768(t4) + addi t3, t3, 16 + addi t4, t4, 4 + addi t2, t2, -1 + bnez t2, 25b + addi a4, zero, 16 +26: + lbu t5, 0(a0) + lbu t0, 1(a0) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(a0) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(a0) + slli t0, t0, 24 + or t5, t5, t0 + lbu t6, 4(a0) + lbu t0, 5(a0) + slli t0, t0, 8 + or t6, t6, t0 + lbu t0, 6(a0) + slli t0, t0, 16 + or t6, t6, t0 + lbu t0, 7(a0) + slli t0, t0, 24 + or t6, t6, t0 + lwu t0, 704(a5) + xor t0, t0, t5 + sw t0, 384(a5) + lwu t1, 768(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 320(a5) + lwu t0, 708(a5) + xor t0, t0, t5 + sw t0, 388(a5) + lwu t1, 772(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 324(a5) + lwu t0, 712(a5) + xor t0, t0, t5 + sw t0, 392(a5) + lwu t1, 776(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 328(a5) + lwu t0, 716(a5) + xor t0, t0, t5 + sw t0, 396(a5) + lwu t1, 780(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 332(a5) + lwu t0, 720(a5) + xor t0, t0, t5 + sw t0, 400(a5) + lwu t1, 784(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 336(a5) + lwu t0, 724(a5) + xor t0, t0, t5 + sw t0, 404(a5) + lwu t1, 788(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 340(a5) + lwu t0, 728(a5) + xor t0, t0, t5 + sw t0, 408(a5) + lwu t1, 792(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 344(a5) + lwu t0, 732(a5) + xor t0, t0, t5 + sw t0, 412(a5) + lwu t1, 796(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 348(a5) + lwu t0, 736(a5) + xor t0, t0, t5 + sw t0, 416(a5) + lwu t1, 800(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 352(a5) + lwu t0, 740(a5) + xor t0, t0, t5 + sw t0, 420(a5) + lwu t1, 804(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 356(a5) + lwu t0, 744(a5) + xor t0, t0, t5 + sw t0, 424(a5) + lwu t1, 808(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 360(a5) + lwu t0, 748(a5) + xor t0, t0, t5 + sw t0, 428(a5) + lwu t1, 812(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 364(a5) + lwu t0, 752(a5) + xor t0, t0, t5 + sw t0, 432(a5) + lwu t1, 816(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 368(a5) + lwu t0, 756(a5) + xor t0, t0, t5 + sw t0, 436(a5) + lwu t1, 820(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 372(a5) + lwu t0, 760(a5) + xor t0, t0, t5 + sw t0, 440(a5) + lwu t1, 824(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 376(a5) + lwu t0, 764(a5) + xor t0, t0, t5 + sw t0, 444(a5) + lwu t1, 828(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 380(a5) + ld s0, 320(a5) + ld s1, 328(a5) + ld s2, 336(a5) + ld s3, 344(a5) + ld s4, 352(a5) + ld s5, 360(a5) + ld s6, 368(a5) + ld s7, 376(a5) + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + addi s0, t1, 0 + xor s0, s0, t2 + xor s0, s0, t4 + addi s1, t3, 0 + xor s1, s1, t4 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t5, 0 + xor s2, s2, t6 + xor s2, s2, a7 + addi s3, t2, 0 + xor s3, s3, t3 + xor s3, s3, t4 + xor s3, s3, t6 + addi s4, t2, 0 + xor s4, s4, t3 + xor s4, s4, t5 + addi s5, t4, 0 + xor s5, s5, t5 + addi s6, t3, 0 + xor s6, s6, t4 + xor s6, s6, t5 + xor s6, s6, t6 + addi s7, t5, 0 + xor s7, s7, t6 + xor s7, s7, a6 + xor t0, s4, s2 + xor t1, s7, s1 + xor t2, s7, s4 + xor t3, s7, s2 + xor s5, s6, s5 + xor t4, s5, s0 + xor s4, t4, s4 + xor t5, t1, t0 + xor t6, t4, s7 + xor s1, t4, s1 + xor a6, s1, t3 + xor s3, s3, t5 + xor s2, s3, s2 + xor s3, s3, s6 + xor s6, s2, s0 + xor a7, s2, s5 + xor s8, s3, t2 + xor s9, s0, s8 + xor s10, a7, s8 + xor s11, a7, t3 + xor s5, s5, s8 + sd s11, 0(a5) + xor s11, t1, s5 + xor s7, s7, s5 + sd s7, 8(a5) + and s7, t5, s2 + sd t5, 16(a5) + and t5, a6, s6 + xor t5, t5, s7 + sd a6, 24(a5) + and a6, s4, s0 + xor a6, a6, s7 + and s7, t1, s5 + sd t1, 32(a5) + and t1, s1, t4 + xor t1, t1, s7 + sd s1, 40(a5) + and s1, t6, s9 + xor s1, s1, s7 + and s7, t2, s8 + sd t2, 48(a5) + and t2, t0, s10 + xor t2, t2, s7 + sd t0, 56(a5) + and t0, t3, a7 + xor t0, t0, s7 + xor t5, t5, t2 + xor a6, a6, t0 + xor t1, t1, t2 + xor s1, s1, t0 + xor t5, t5, s3 + ld s3, 0(a5) + xor a6, a6, s3 + xor t1, t1, s11 + ld s11, 8(a5) + xor s1, s1, s11 + xor s11, t5, a6 + and t5, t5, t1 + xor s3, s1, t5 + and t0, s11, s3 + xor t0, t0, a6 + xor t2, t1, s1 + xor a6, a6, t5 + and a6, a6, t2 + xor a6, a6, s1 + xor t1, t1, a6 + xor t2, s3, a6 + and s1, s1, t2 + xor t1, s1, t1 + xor s3, s3, s1 + and s3, t0, s3 + xor s11, s11, s3 + xor s3, s11, t1 + xor s1, t0, a6 + xor t2, t0, s11 + xor t5, a6, t1 + xor s7, s1, s3 + and s2, t5, s2 + and s6, t1, s6 + and s0, a6, s0 + and s5, t2, s5 + and t4, s11, t4 + and s9, t0, s9 + and s8, s1, s8 + and s10, s7, s10 + and a7, s3, a7 + sd s6, 8(a5) + ld s6, 16(a5) + and t5, t5, s6 + ld s6, 24(a5) + and t1, t1, s6 + and a6, a6, s4 + ld s4, 32(a5) + and t2, t2, s4 + ld s4, 40(a5) + and s11, s11, s4 + and t0, t0, t6 + ld t6, 48(a5) + and s1, s1, t6 + ld t6, 56(a5) + and s7, s7, t6 + and s3, s3, t3 + xor s1, s1, s7 + xor a6, t1, a6 + xor s11, s9, s11 + xor t5, t5, t1 + xor t1, s0, t2 + xor s0, s0, s9 + xor a7, s10, a7 + xor s2, s2, s5 + xor s8, s8, s10 + xor s7, s7, s3 + xor t2, t2, s11 + xor t1, t1, s2 + xor s3, t4, s1 + xor s5, s5, s8 + xor s1, s1, t1 + xor t0, t0, t1 + xor a7, a7, s3 + xor t5, t5, s3 + xor t4, t4, s5 + xor t0, t0, a7 + ld s3, 8(a5) + xor s3, s3, t5 + xor s5, s5, t5 + xor t2, t2, a7 + xori t2, t2, -1 + xor s11, s11, s1 + xori s11, s11, -1 + xor s1, t4, t0 + xor s4, s2, s3 + xor s3, s0, s3 + xor s2, a6, t0 + xor s6, t4, s4 + xori s6, s6, -1 + xor s7, s7, s1 + xori s7, s7, -1 + sd s7, 8(a5) + addi s7, s5, 0 + ld s5, 8(a5) + addi s1, t2, 0 + addi s0, s11, 0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + ld s8, 24(a3) + ld s9, 32(a3) + and s0, t2, s9 + and t0, t3, s8 + xor s0, s0, t0 + and t0, t4, s9 + xor s0, s0, t0 + and t0, t5, s8 + xor s0, s0, t0 + and t0, t6, s8 + xor s0, s0, t0 + and t0, a6, s8 + xor s0, s0, t0 + and s1, t2, s9 + and t0, t3, s8 + xor s1, s1, t0 + xor s1, s1, t5 + and t0, t6, s9 + xor s1, s1, t0 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t1, 0 + and t0, t2, s8 + xor s2, s2, t0 + and t0, t3, s9 + xor s2, s2, t0 + and t0, t4, s9 + xor s2, s2, t0 + xor s2, s2, t5 + xor s2, s2, a6 + addi s3, t1, 0 + and t0, t2, s9 + xor s3, s3, t0 + and t0, t3, s8 + xor s3, s3, t0 + and t0, t4, s9 + xor s3, s3, t0 + xor s3, s3, t5 + xor s3, s3, t6 + xor s3, s3, a6 + and t0, a7, s8 + xor s3, s3, t0 + and s4, t1, s8 + and t0, t3, s8 + xor s4, s4, t0 + xor s4, s4, t4 + and t0, t5, s8 + xor s4, s4, t0 + xor s4, s4, a6 + and t0, a7, s9 + xor s4, s4, t0 + and s5, t1, s8 + and t0, t2, s8 + xor s5, s5, t0 + xor s5, s5, t4 + and t0, t5, s9 + xor s5, s5, t0 + xor s5, s5, t6 + xor s5, s5, a6 + and s6, t1, s8 + and t0, t2, s9 + xor s6, s6, t0 + and t0, t3, s9 + xor s6, s6, t0 + and t0, t4, s9 + xor s6, s6, t0 + and t0, t5, s8 + xor s6, s6, t0 + and t0, t6, s8 + xor s6, s6, t0 + xor s6, s6, a6 + and s7, t2, s8 + xor s7, s7, t4 + and t0, a6, s8 + xor s7, s7, t0 + and t0, a7, s8 + xor s7, s7, t0 + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t2, 40(a3) + ld t3, 48(a3) + ld t6, 56(a3) + ld t4, 64(a3) + ld a6, 72(a3) + ld t5, 80(a3) + ld a7, 88(a3) + ld s8, 96(a3) + and t1, s0, t2 + srli t0, s0, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s0, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s0, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s0, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s0, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s0, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 320(a5) + and t1, s1, t2 + srli t0, s1, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s1, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s1, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s1, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s1, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s1, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 328(a5) + and t1, s2, t2 + srli t0, s2, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s2, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s2, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s2, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s2, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s2, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 336(a5) + and t1, s3, t2 + srli t0, s3, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s3, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s3, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s3, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s3, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s3, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 344(a5) + and t1, s4, t2 + srli t0, s4, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s4, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s4, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s4, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s4, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s4, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 352(a5) + and t1, s5, t2 + srli t0, s5, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s5, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s5, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s5, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s5, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s5, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 360(a5) + and t1, s6, t2 + srli t0, s6, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s6, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s6, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s6, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s6, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s6, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 368(a5) + and t1, s7, t2 + srli t0, s7, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s7, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s7, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s7, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s7, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s7, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 376(a5) + lwu t0, 320(a5) + sw t0, 448(a5) + lwu t1, 384(a5) + add t0, t0, t1 + sw t0, 320(a5) + lwu t0, 324(a5) + sw t0, 452(a5) + lwu t1, 388(a5) + add t0, t0, t1 + sw t0, 324(a5) + lwu t0, 328(a5) + sw t0, 456(a5) + lwu t1, 392(a5) + add t0, t0, t1 + sw t0, 328(a5) + lwu t0, 332(a5) + sw t0, 460(a5) + lwu t1, 396(a5) + add t0, t0, t1 + sw t0, 332(a5) + lwu t0, 336(a5) + sw t0, 464(a5) + lwu t1, 400(a5) + add t0, t0, t1 + sw t0, 336(a5) + lwu t0, 340(a5) + sw t0, 468(a5) + lwu t1, 404(a5) + add t0, t0, t1 + sw t0, 340(a5) + lwu t0, 344(a5) + sw t0, 472(a5) + lwu t1, 408(a5) + add t0, t0, t1 + sw t0, 344(a5) + lwu t0, 348(a5) + sw t0, 476(a5) + lwu t1, 412(a5) + add t0, t0, t1 + sw t0, 348(a5) + lwu t0, 352(a5) + sw t0, 480(a5) + lwu t1, 416(a5) + add t0, t0, t1 + sw t0, 352(a5) + lwu t0, 356(a5) + sw t0, 484(a5) + lwu t1, 420(a5) + add t0, t0, t1 + sw t0, 356(a5) + lwu t0, 360(a5) + sw t0, 488(a5) + lwu t1, 424(a5) + add t0, t0, t1 + sw t0, 360(a5) + lwu t0, 364(a5) + sw t0, 492(a5) + lwu t1, 428(a5) + add t0, t0, t1 + sw t0, 364(a5) + lwu t0, 368(a5) + sw t0, 496(a5) + lwu t1, 432(a5) + add t0, t0, t1 + sw t0, 368(a5) + lwu t0, 372(a5) + sw t0, 500(a5) + lwu t1, 436(a5) + add t0, t0, t1 + sw t0, 372(a5) + lwu t0, 376(a5) + sw t0, 504(a5) + lwu t1, 440(a5) + add t0, t0, t1 + sw t0, 376(a5) + lwu t0, 380(a5) + sw t0, 508(a5) + lwu t1, 444(a5) + add t0, t0, t1 + sw t0, 380(a5) + ld s0, 320(a5) + ld s1, 328(a5) + ld s2, 336(a5) + ld s3, 344(a5) + ld s4, 352(a5) + ld s5, 360(a5) + ld s6, 368(a5) + ld s7, 376(a5) + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + addi s0, t1, 0 + xor s0, s0, t2 + xor s0, s0, t4 + addi s1, t3, 0 + xor s1, s1, t4 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t5, 0 + xor s2, s2, t6 + xor s2, s2, a7 + addi s3, t2, 0 + xor s3, s3, t3 + xor s3, s3, t4 + xor s3, s3, t6 + addi s4, t2, 0 + xor s4, s4, t3 + xor s4, s4, t5 + addi s5, t4, 0 + xor s5, s5, t5 + addi s6, t3, 0 + xor s6, s6, t4 + xor s6, s6, t5 + xor s6, s6, t6 + addi s7, t5, 0 + xor s7, s7, t6 + xor s7, s7, a6 + xor t0, s4, s2 + xor t1, s7, s1 + xor t2, s7, s4 + xor t3, s7, s2 + xor s5, s6, s5 + xor t4, s5, s0 + xor s4, t4, s4 + xor t5, t1, t0 + xor t6, t4, s7 + xor s1, t4, s1 + xor a6, s1, t3 + xor s3, s3, t5 + xor s2, s3, s2 + xor s3, s3, s6 + xor s6, s2, s0 + xor a7, s2, s5 + xor s8, s3, t2 + xor s9, s0, s8 + xor s10, a7, s8 + xor s11, a7, t3 + xor s5, s5, s8 + sd s11, 0(a5) + xor s11, t1, s5 + xor s7, s7, s5 + sd s7, 8(a5) + and s7, t5, s2 + sd t5, 16(a5) + and t5, a6, s6 + xor t5, t5, s7 + sd a6, 24(a5) + and a6, s4, s0 + xor a6, a6, s7 + and s7, t1, s5 + sd t1, 32(a5) + and t1, s1, t4 + xor t1, t1, s7 + sd s1, 40(a5) + and s1, t6, s9 + xor s1, s1, s7 + and s7, t2, s8 + sd t2, 48(a5) + and t2, t0, s10 + xor t2, t2, s7 + sd t0, 56(a5) + and t0, t3, a7 + xor t0, t0, s7 + xor t5, t5, t2 + xor a6, a6, t0 + xor t1, t1, t2 + xor s1, s1, t0 + xor t5, t5, s3 + ld s3, 0(a5) + xor a6, a6, s3 + xor t1, t1, s11 + ld s11, 8(a5) + xor s1, s1, s11 + xor s11, t5, a6 + and t5, t5, t1 + xor s3, s1, t5 + and t0, s11, s3 + xor t0, t0, a6 + xor t2, t1, s1 + xor a6, a6, t5 + and a6, a6, t2 + xor a6, a6, s1 + xor t1, t1, a6 + xor t2, s3, a6 + and s1, s1, t2 + xor t1, s1, t1 + xor s3, s3, s1 + and s3, t0, s3 + xor s11, s11, s3 + xor s3, s11, t1 + xor s1, t0, a6 + xor t2, t0, s11 + xor t5, a6, t1 + xor s7, s1, s3 + and s2, t5, s2 + and s6, t1, s6 + and s0, a6, s0 + and s5, t2, s5 + and t4, s11, t4 + and s9, t0, s9 + and s8, s1, s8 + and s10, s7, s10 + and a7, s3, a7 + sd s6, 8(a5) + ld s6, 16(a5) + and t5, t5, s6 + ld s6, 24(a5) + and t1, t1, s6 + and a6, a6, s4 + ld s4, 32(a5) + and t2, t2, s4 + ld s4, 40(a5) + and s11, s11, s4 + and t0, t0, t6 + ld t6, 48(a5) + and s1, s1, t6 + ld t6, 56(a5) + and s7, s7, t6 + and s3, s3, t3 + xor s1, s1, s7 + xor a6, t1, a6 + xor s11, s9, s11 + xor t5, t5, t1 + xor t1, s0, t2 + xor s0, s0, s9 + xor a7, s10, a7 + xor s2, s2, s5 + xor s8, s8, s10 + xor s7, s7, s3 + xor t2, t2, s11 + xor t1, t1, s2 + xor s3, t4, s1 + xor s5, s5, s8 + xor s1, s1, t1 + xor t0, t0, t1 + xor a7, a7, s3 + xor t5, t5, s3 + xor t4, t4, s5 + xor t0, t0, a7 + ld s3, 8(a5) + xor s3, s3, t5 + xor s5, s5, t5 + xor t2, t2, a7 + xori t2, t2, -1 + xor s11, s11, s1 + xori s11, s11, -1 + xor s1, t4, t0 + xor s4, s2, s3 + xor s3, s0, s3 + xor s2, a6, t0 + xor s6, t4, s4 + xori s6, s6, -1 + xor s7, s7, s1 + xori s7, s7, -1 + sd s7, 8(a5) + addi s7, s5, 0 + ld s5, 8(a5) + addi s1, t2, 0 + addi s0, s11, 0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + ld s8, 24(a3) + ld s9, 32(a3) + and s0, t2, s9 + and t0, t3, s8 + xor s0, s0, t0 + and t0, t4, s9 + xor s0, s0, t0 + and t0, t5, s8 + xor s0, s0, t0 + and t0, t6, s8 + xor s0, s0, t0 + and t0, a6, s8 + xor s0, s0, t0 + and s1, t2, s9 + and t0, t3, s8 + xor s1, s1, t0 + xor s1, s1, t5 + and t0, t6, s9 + xor s1, s1, t0 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t1, 0 + and t0, t2, s8 + xor s2, s2, t0 + and t0, t3, s9 + xor s2, s2, t0 + and t0, t4, s9 + xor s2, s2, t0 + xor s2, s2, t5 + xor s2, s2, a6 + addi s3, t1, 0 + and t0, t2, s9 + xor s3, s3, t0 + and t0, t3, s8 + xor s3, s3, t0 + and t0, t4, s9 + xor s3, s3, t0 + xor s3, s3, t5 + xor s3, s3, t6 + xor s3, s3, a6 + and t0, a7, s8 + xor s3, s3, t0 + and s4, t1, s8 + and t0, t3, s8 + xor s4, s4, t0 + xor s4, s4, t4 + and t0, t5, s8 + xor s4, s4, t0 + xor s4, s4, a6 + and t0, a7, s9 + xor s4, s4, t0 + and s5, t1, s8 + and t0, t2, s8 + xor s5, s5, t0 + xor s5, s5, t4 + and t0, t5, s9 + xor s5, s5, t0 + xor s5, s5, t6 + xor s5, s5, a6 + and s6, t1, s8 + and t0, t2, s9 + xor s6, s6, t0 + and t0, t3, s9 + xor s6, s6, t0 + and t0, t4, s9 + xor s6, s6, t0 + and t0, t5, s8 + xor s6, s6, t0 + and t0, t6, s8 + xor s6, s6, t0 + xor s6, s6, a6 + and s7, t2, s8 + xor s7, s7, t4 + and t0, a6, s8 + xor s7, s7, t0 + and t0, a7, s8 + xor s7, s7, t0 + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t2, 40(a3) + ld t3, 48(a3) + ld t6, 56(a3) + ld t4, 64(a3) + ld a6, 72(a3) + ld t5, 80(a3) + ld a7, 88(a3) + ld s8, 96(a3) + and t1, s0, t2 + srli t0, s0, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s0, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s0, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s0, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s0, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s0, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 320(a5) + and t1, s1, t2 + srli t0, s1, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s1, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s1, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s1, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s1, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s1, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 328(a5) + and t1, s2, t2 + srli t0, s2, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s2, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s2, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s2, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s2, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s2, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 336(a5) + and t1, s3, t2 + srli t0, s3, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s3, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s3, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s3, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s3, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s3, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 344(a5) + and t1, s4, t2 + srli t0, s4, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s4, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s4, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s4, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s4, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s4, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 352(a5) + and t1, s5, t2 + srli t0, s5, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s5, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s5, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s5, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s5, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s5, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 360(a5) + and t1, s6, t2 + srli t0, s6, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s6, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s6, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s6, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s6, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s6, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 368(a5) + and t1, s7, t2 + srli t0, s7, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s7, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s7, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s7, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s7, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s7, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 376(a5) + lwu t0, 320(a5) + sw t0, 512(a5) + lwu t1, 448(a5) + add t0, t0, t1 + sw t0, 320(a5) + lwu t0, 324(a5) + sw t0, 516(a5) + lwu t1, 452(a5) + add t0, t0, t1 + sw t0, 324(a5) + lwu t0, 328(a5) + sw t0, 520(a5) + lwu t1, 456(a5) + add t0, t0, t1 + sw t0, 328(a5) + lwu t0, 332(a5) + sw t0, 524(a5) + lwu t1, 460(a5) + add t0, t0, t1 + sw t0, 332(a5) + lwu t0, 336(a5) + sw t0, 528(a5) + lwu t1, 464(a5) + add t0, t0, t1 + sw t0, 336(a5) + lwu t0, 340(a5) + sw t0, 532(a5) + lwu t1, 468(a5) + add t0, t0, t1 + sw t0, 340(a5) + lwu t0, 344(a5) + sw t0, 536(a5) + lwu t1, 472(a5) + add t0, t0, t1 + sw t0, 344(a5) + lwu t0, 348(a5) + sw t0, 540(a5) + lwu t1, 476(a5) + add t0, t0, t1 + sw t0, 348(a5) + lwu t0, 352(a5) + sw t0, 544(a5) + lwu t1, 480(a5) + add t0, t0, t1 + sw t0, 352(a5) + lwu t0, 356(a5) + sw t0, 548(a5) + lwu t1, 484(a5) + add t0, t0, t1 + sw t0, 356(a5) + lwu t0, 360(a5) + sw t0, 552(a5) + lwu t1, 488(a5) + add t0, t0, t1 + sw t0, 360(a5) + lwu t0, 364(a5) + sw t0, 556(a5) + lwu t1, 492(a5) + add t0, t0, t1 + sw t0, 364(a5) + lwu t0, 368(a5) + sw t0, 560(a5) + lwu t1, 496(a5) + add t0, t0, t1 + sw t0, 368(a5) + lwu t0, 372(a5) + sw t0, 564(a5) + lwu t1, 500(a5) + add t0, t0, t1 + sw t0, 372(a5) + lwu t0, 376(a5) + sw t0, 568(a5) + lwu t1, 504(a5) + add t0, t0, t1 + sw t0, 376(a5) + lwu t0, 380(a5) + sw t0, 572(a5) + lwu t1, 508(a5) + add t0, t0, t1 + sw t0, 380(a5) + ld s0, 320(a5) + ld s1, 328(a5) + ld s2, 336(a5) + ld s3, 344(a5) + ld s4, 352(a5) + ld s5, 360(a5) + ld s6, 368(a5) + ld s7, 376(a5) + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + addi s0, t1, 0 + xor s0, s0, t2 + xor s0, s0, t4 + addi s1, t3, 0 + xor s1, s1, t4 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t5, 0 + xor s2, s2, t6 + xor s2, s2, a7 + addi s3, t2, 0 + xor s3, s3, t3 + xor s3, s3, t4 + xor s3, s3, t6 + addi s4, t2, 0 + xor s4, s4, t3 + xor s4, s4, t5 + addi s5, t4, 0 + xor s5, s5, t5 + addi s6, t3, 0 + xor s6, s6, t4 + xor s6, s6, t5 + xor s6, s6, t6 + addi s7, t5, 0 + xor s7, s7, t6 + xor s7, s7, a6 + xor t0, s4, s2 + xor t1, s7, s1 + xor t2, s7, s4 + xor t3, s7, s2 + xor s5, s6, s5 + xor t4, s5, s0 + xor s4, t4, s4 + xor t5, t1, t0 + xor t6, t4, s7 + xor s1, t4, s1 + xor a6, s1, t3 + xor s3, s3, t5 + xor s2, s3, s2 + xor s3, s3, s6 + xor s6, s2, s0 + xor a7, s2, s5 + xor s8, s3, t2 + xor s9, s0, s8 + xor s10, a7, s8 + xor s11, a7, t3 + xor s5, s5, s8 + sd s11, 0(a5) + xor s11, t1, s5 + xor s7, s7, s5 + sd s7, 8(a5) + and s7, t5, s2 + sd t5, 16(a5) + and t5, a6, s6 + xor t5, t5, s7 + sd a6, 24(a5) + and a6, s4, s0 + xor a6, a6, s7 + and s7, t1, s5 + sd t1, 32(a5) + and t1, s1, t4 + xor t1, t1, s7 + sd s1, 40(a5) + and s1, t6, s9 + xor s1, s1, s7 + and s7, t2, s8 + sd t2, 48(a5) + and t2, t0, s10 + xor t2, t2, s7 + sd t0, 56(a5) + and t0, t3, a7 + xor t0, t0, s7 + xor t5, t5, t2 + xor a6, a6, t0 + xor t1, t1, t2 + xor s1, s1, t0 + xor t5, t5, s3 + ld s3, 0(a5) + xor a6, a6, s3 + xor t1, t1, s11 + ld s11, 8(a5) + xor s1, s1, s11 + xor s11, t5, a6 + and t5, t5, t1 + xor s3, s1, t5 + and t0, s11, s3 + xor t0, t0, a6 + xor t2, t1, s1 + xor a6, a6, t5 + and a6, a6, t2 + xor a6, a6, s1 + xor t1, t1, a6 + xor t2, s3, a6 + and s1, s1, t2 + xor t1, s1, t1 + xor s3, s3, s1 + and s3, t0, s3 + xor s11, s11, s3 + xor s3, s11, t1 + xor s1, t0, a6 + xor t2, t0, s11 + xor t5, a6, t1 + xor s7, s1, s3 + and s2, t5, s2 + and s6, t1, s6 + and s0, a6, s0 + and s5, t2, s5 + and t4, s11, t4 + and s9, t0, s9 + and s8, s1, s8 + and s10, s7, s10 + and a7, s3, a7 + sd s6, 8(a5) + ld s6, 16(a5) + and t5, t5, s6 + ld s6, 24(a5) + and t1, t1, s6 + and a6, a6, s4 + ld s4, 32(a5) + and t2, t2, s4 + ld s4, 40(a5) + and s11, s11, s4 + and t0, t0, t6 + ld t6, 48(a5) + and s1, s1, t6 + ld t6, 56(a5) + and s7, s7, t6 + and s3, s3, t3 + xor s1, s1, s7 + xor a6, t1, a6 + xor s11, s9, s11 + xor t5, t5, t1 + xor t1, s0, t2 + xor s0, s0, s9 + xor a7, s10, a7 + xor s2, s2, s5 + xor s8, s8, s10 + xor s7, s7, s3 + xor t2, t2, s11 + xor t1, t1, s2 + xor s3, t4, s1 + xor s5, s5, s8 + xor s1, s1, t1 + xor t0, t0, t1 + xor a7, a7, s3 + xor t5, t5, s3 + xor t4, t4, s5 + xor t0, t0, a7 + ld s3, 8(a5) + xor s3, s3, t5 + xor s5, s5, t5 + xor t2, t2, a7 + xori t2, t2, -1 + xor s11, s11, s1 + xori s11, s11, -1 + xor s1, t4, t0 + xor s4, s2, s3 + xor s3, s0, s3 + xor s2, a6, t0 + xor s6, t4, s4 + xori s6, s6, -1 + xor s7, s7, s1 + xori s7, s7, -1 + sd s7, 8(a5) + addi s7, s5, 0 + ld s5, 8(a5) + addi s1, t2, 0 + addi s0, s11, 0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + ld s8, 24(a3) + ld s9, 32(a3) + and s0, t2, s9 + and t0, t3, s8 + xor s0, s0, t0 + and t0, t4, s9 + xor s0, s0, t0 + and t0, t5, s8 + xor s0, s0, t0 + and t0, t6, s8 + xor s0, s0, t0 + and t0, a6, s8 + xor s0, s0, t0 + and s1, t2, s9 + and t0, t3, s8 + xor s1, s1, t0 + xor s1, s1, t5 + and t0, t6, s9 + xor s1, s1, t0 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t1, 0 + and t0, t2, s8 + xor s2, s2, t0 + and t0, t3, s9 + xor s2, s2, t0 + and t0, t4, s9 + xor s2, s2, t0 + xor s2, s2, t5 + xor s2, s2, a6 + addi s3, t1, 0 + and t0, t2, s9 + xor s3, s3, t0 + and t0, t3, s8 + xor s3, s3, t0 + and t0, t4, s9 + xor s3, s3, t0 + xor s3, s3, t5 + xor s3, s3, t6 + xor s3, s3, a6 + and t0, a7, s8 + xor s3, s3, t0 + and s4, t1, s8 + and t0, t3, s8 + xor s4, s4, t0 + xor s4, s4, t4 + and t0, t5, s8 + xor s4, s4, t0 + xor s4, s4, a6 + and t0, a7, s9 + xor s4, s4, t0 + and s5, t1, s8 + and t0, t2, s8 + xor s5, s5, t0 + xor s5, s5, t4 + and t0, t5, s9 + xor s5, s5, t0 + xor s5, s5, t6 + xor s5, s5, a6 + and s6, t1, s8 + and t0, t2, s9 + xor s6, s6, t0 + and t0, t3, s9 + xor s6, s6, t0 + and t0, t4, s9 + xor s6, s6, t0 + and t0, t5, s8 + xor s6, s6, t0 + and t0, t6, s8 + xor s6, s6, t0 + xor s6, s6, a6 + and s7, t2, s8 + xor s7, s7, t4 + and t0, a6, s8 + xor s7, s7, t0 + and t0, a7, s8 + xor s7, s7, t0 + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t2, 40(a3) + ld t3, 48(a3) + ld t6, 56(a3) + ld t4, 64(a3) + ld a6, 72(a3) + ld t5, 80(a3) + ld a7, 88(a3) + ld s8, 96(a3) + and t1, s0, t2 + srli t0, s0, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s0, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s0, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s0, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s0, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s0, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 320(a5) + and t1, s1, t2 + srli t0, s1, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s1, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s1, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s1, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s1, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s1, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 328(a5) + and t1, s2, t2 + srli t0, s2, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s2, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s2, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s2, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s2, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s2, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 336(a5) + and t1, s3, t2 + srli t0, s3, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s3, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s3, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s3, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s3, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s3, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 344(a5) + and t1, s4, t2 + srli t0, s4, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s4, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s4, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s4, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s4, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s4, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 352(a5) + and t1, s5, t2 + srli t0, s5, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s5, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s5, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s5, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s5, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s5, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 360(a5) + and t1, s6, t2 + srli t0, s6, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s6, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s6, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s6, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s6, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s6, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 368(a5) + and t1, s7, t2 + srli t0, s7, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s7, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s7, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s7, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s7, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s7, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 376(a5) + lwu t0, 320(a5) + lwu t1, 640(a5) + xor t1, t1, t0 + sw t1, 640(a5) + lwu t1, 512(a5) + add t0, t0, t1 + lwu t1, 576(a5) + xor t0, t0, t1 + sw t0, 576(a5) + lwu t0, 324(a5) + lwu t1, 644(a5) + xor t1, t1, t0 + sw t1, 644(a5) + lwu t1, 516(a5) + add t0, t0, t1 + lwu t1, 580(a5) + xor t0, t0, t1 + sw t0, 580(a5) + lwu t0, 328(a5) + lwu t1, 648(a5) + xor t1, t1, t0 + sw t1, 648(a5) + lwu t1, 520(a5) + add t0, t0, t1 + lwu t1, 584(a5) + xor t0, t0, t1 + sw t0, 584(a5) + lwu t0, 332(a5) + lwu t1, 652(a5) + xor t1, t1, t0 + sw t1, 652(a5) + lwu t1, 524(a5) + add t0, t0, t1 + lwu t1, 588(a5) + xor t0, t0, t1 + sw t0, 588(a5) + lwu t0, 336(a5) + lwu t1, 656(a5) + xor t1, t1, t0 + sw t1, 656(a5) + lwu t1, 528(a5) + add t0, t0, t1 + lwu t1, 592(a5) + xor t0, t0, t1 + sw t0, 592(a5) + lwu t0, 340(a5) + lwu t1, 660(a5) + xor t1, t1, t0 + sw t1, 660(a5) + lwu t1, 532(a5) + add t0, t0, t1 + lwu t1, 596(a5) + xor t0, t0, t1 + sw t0, 596(a5) + lwu t0, 344(a5) + lwu t1, 664(a5) + xor t1, t1, t0 + sw t1, 664(a5) + lwu t1, 536(a5) + add t0, t0, t1 + lwu t1, 600(a5) + xor t0, t0, t1 + sw t0, 600(a5) + lwu t0, 348(a5) + lwu t1, 668(a5) + xor t1, t1, t0 + sw t1, 668(a5) + lwu t1, 540(a5) + add t0, t0, t1 + lwu t1, 604(a5) + xor t0, t0, t1 + sw t0, 604(a5) + lwu t0, 352(a5) + lwu t1, 672(a5) + xor t1, t1, t0 + sw t1, 672(a5) + lwu t1, 544(a5) + add t0, t0, t1 + lwu t1, 608(a5) + xor t0, t0, t1 + sw t0, 608(a5) + lwu t0, 356(a5) + lwu t1, 676(a5) + xor t1, t1, t0 + sw t1, 676(a5) + lwu t1, 548(a5) + add t0, t0, t1 + lwu t1, 612(a5) + xor t0, t0, t1 + sw t0, 612(a5) + lwu t0, 360(a5) + lwu t1, 680(a5) + xor t1, t1, t0 + sw t1, 680(a5) + lwu t1, 552(a5) + add t0, t0, t1 + lwu t1, 616(a5) + xor t0, t0, t1 + sw t0, 616(a5) + lwu t0, 364(a5) + lwu t1, 684(a5) + xor t1, t1, t0 + sw t1, 684(a5) + lwu t1, 556(a5) + add t0, t0, t1 + lwu t1, 620(a5) + xor t0, t0, t1 + sw t0, 620(a5) + lwu t0, 368(a5) + lwu t1, 688(a5) + xor t1, t1, t0 + sw t1, 688(a5) + lwu t1, 560(a5) + add t0, t0, t1 + lwu t1, 624(a5) + xor t0, t0, t1 + sw t0, 624(a5) + lwu t0, 372(a5) + lwu t1, 692(a5) + xor t1, t1, t0 + sw t1, 692(a5) + lwu t1, 564(a5) + add t0, t0, t1 + lwu t1, 628(a5) + xor t0, t0, t1 + sw t0, 628(a5) + lwu t0, 376(a5) + lwu t1, 696(a5) + xor t1, t1, t0 + sw t1, 696(a5) + lwu t1, 568(a5) + add t0, t0, t1 + lwu t1, 632(a5) + xor t0, t0, t1 + sw t0, 632(a5) + lwu t0, 380(a5) + lwu t1, 700(a5) + xor t1, t1, t0 + sw t1, 700(a5) + lwu t1, 572(a5) + add t0, t0, t1 + lwu t1, 636(a5) + xor t0, t0, t1 + sw t0, 636(a5) + ld t0, 576(a5) + ld t1, 704(a5) + sd t1, 576(a5) + sd t0, 704(a5) + ld t0, 584(a5) + ld t1, 712(a5) + sd t1, 584(a5) + sd t0, 712(a5) + ld t0, 592(a5) + ld t1, 720(a5) + sd t1, 592(a5) + sd t0, 720(a5) + ld t0, 600(a5) + ld t1, 728(a5) + sd t1, 600(a5) + sd t0, 728(a5) + ld t0, 608(a5) + ld t1, 736(a5) + sd t1, 608(a5) + sd t0, 736(a5) + ld t0, 616(a5) + ld t1, 744(a5) + sd t1, 616(a5) + sd t0, 744(a5) + ld t0, 624(a5) + ld t1, 752(a5) + sd t1, 624(a5) + sd t0, 752(a5) + ld t0, 632(a5) + ld t1, 760(a5) + sd t1, 632(a5) + sd t0, 760(a5) + ld t0, 640(a5) + ld t1, 768(a5) + sd t1, 640(a5) + sd t0, 768(a5) + ld t0, 648(a5) + ld t1, 776(a5) + sd t1, 648(a5) + sd t0, 776(a5) + ld t0, 656(a5) + ld t1, 784(a5) + sd t1, 656(a5) + sd t0, 784(a5) + ld t0, 664(a5) + ld t1, 792(a5) + sd t1, 664(a5) + sd t0, 792(a5) + ld t0, 672(a5) + ld t1, 800(a5) + sd t1, 672(a5) + sd t0, 800(a5) + ld t0, 680(a5) + ld t1, 808(a5) + sd t1, 680(a5) + sd t0, 808(a5) + ld t0, 688(a5) + ld t1, 816(a5) + sd t1, 688(a5) + sd t0, 816(a5) + ld t0, 696(a5) + ld t1, 824(a5) + sd t1, 696(a5) + sd t0, 824(a5) + addi a0, a0, 8 + addi a4, a4, -1 + bnez a4, 26b + addi a0, a0, -128 + addi t2, zero, 1 + addi t3, a5, 1032 + addi t4, a5, 0 +27: + lwu t0, 704(t4) + srli t1, t0, 24 + sb t1, 0(t3) + srli t1, t0, 16 + sb t1, 1(t3) + srli t1, t0, 8 + sb t1, 2(t3) + srli t1, t0, 0 + sb t1, 3(t3) + lwu t0, 768(t4) + srli t1, t0, 24 + sb t1, 4(t3) + srli t1, t0, 16 + sb t1, 5(t3) + srli t1, t0, 8 + sb t1, 6(t3) + srli t1, t0, 0 + sb t1, 7(t3) + lwu t0, 576(t4) + srli t1, t0, 24 + sb t1, 8(t3) + srli t1, t0, 16 + sb t1, 9(t3) + srli t1, t0, 8 + sb t1, 10(t3) + srli t1, t0, 0 + sb t1, 11(t3) + lwu t0, 640(t4) + srli t1, t0, 24 + sb t1, 12(t3) + srli t1, t0, 16 + sb t1, 13(t3) + srli t1, t0, 8 + sb t1, 14(t3) + srli t1, t0, 0 + sb t1, 15(t3) + addi t3, t3, 16 + addi t4, t4, 4 + addi t2, t2, -1 + bnez t2, 27b + addi a0, a0, 0 + ld s0, 936(a5) + ld s1, 944(a5) + ld s2, 952(a5) + ld s3, 960(a5) + ld s4, 968(a5) + ld s5, 976(a5) + ld s6, 984(a5) + ld s7, 992(a5) + ld s8, 1000(a5) + ld s9, 1008(a5) + ld s10, 1016(a5) + ld s11, 1024(a5) + addi s1, a1, 0 + addi s2, a2, 0 + addi s3, ra, 0 + ld ra, 1048(a5) + addi s4, a5, -48 + addi t0, zero, 16 + bltu s3, t0, 28f + lwu t0, 1080(s4) + sw t0, 32(s4) + lwu t0, 1084(s4) + sw t0, 36(s4) + lwu t0, 1088(s4) + sw t0, 40(s4) + lwu t0, 1092(s4) + sw t0, 44(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 1080(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 1084(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 1088(s4) + xor t0, t0, t1 + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 1092(s4) + xor t0, t0, t1 + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 29f +28: + lwu t0, 1080(s4) + sw t0, 32(s4) + lwu t0, 1084(s4) + sw t0, 36(s4) + lwu t0, 1088(s4) + sw t0, 40(s4) + lwu t0, 1092(s4) + sw t0, 44(s4) + addi t2, s4, 1080 +210: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 210b +29: + bnez s3, 24b + j 23f +22: +23: + j 21f +20: + beqz s3, 211f +213: + lwu t0, 32(s4) + sw t0, 1080(s4) + lwu t0, 36(s4) + sw t0, 1084(s4) + lwu t0, 40(s4) + sw t0, 1088(s4) + lwu t0, 44(s4) + sw t0, 1092(s4) + addi t0, s4, 48 + addi a5, t0, 0 + sd s0, 936(a5) + sd s1, 944(a5) + sd s2, 952(a5) + sd s3, 960(a5) + sd s4, 968(a5) + sd s5, 976(a5) + sd s6, 984(a5) + sd s7, 992(a5) + sd s8, 1000(a5) + sd s9, 1008(a5) + sd s10, 1016(a5) + sd s11, 1024(a5) + lui t0, 349525 + addiw t0, t0, 1365 + slli t0, t0, 32 + lui t1, 349525 + addiw t1, t1, 1365 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 832(a5) + lui t0, 209715 + addiw t0, t0, 819 + slli t0, t0, 32 + lui t1, 209715 + addiw t1, t1, 819 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 840(a5) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 848(a5) + lui t0, 4080 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 4080 + addiw t1, t1, 255 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 856(a5) + lui t0, 1044496 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 1044496 + addiw t1, t1, -256 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 864(a5) + lui t0, 851917 + addiw t0, t0, -4 + slli t0, t0, 32 + lui t1, 851917 + addiw t1, t1, -4 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 872(a5) + lui t0, 3892 + addiw t0, t0, -13 + slli t0, t0, 32 + lui t1, 3892 + addiw t1, t1, -13 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 880(a5) + lui t0, 258048 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 258048 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 888(a5) + lui t0, 16 + addiw t0, t0, -817 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, -817 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 896(a5) + lui t0, 1035504 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 1035504 + addiw t1, t1, 0 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 904(a5) + lui t0, 0 + addiw t0, t0, 63 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 63 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 912(a5) + lui t0, 996351 + addiw t0, t0, 768 + slli t0, t0, 32 + lui t1, 996351 + addiw t1, t1, 768 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 920(a5) + lui t0, 946878 + addiw t0, t0, 1835 + slli t0, t0, 32 + lui t1, 946878 + addiw t1, t1, 1835 + slli t1, t1, 32 + srli t1, t1, 32 + or t0, t0, t1 + sd t0, 928(a5) + addi a3, a5, 832 + sd ra, 1048(a5) + addi a1, s1, 0 + addi a2, s2, 0 + addi ra, s3, 0 + addi a0, a0, 0 + addi t2, zero, 1 + addi t3, a5, 1032 + addi t4, a5, 0 +214: + lbu t0, 0(t3) + slli t0, t0, 24 + lbu t1, 1(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 2(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 3(t3) + or t0, t0, t1 + sw t0, 576(t4) + lbu t0, 4(t3) + slli t0, t0, 24 + lbu t1, 5(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 6(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 7(t3) + or t0, t0, t1 + sw t0, 640(t4) + lbu t0, 8(t3) + slli t0, t0, 24 + lbu t1, 9(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 10(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 11(t3) + or t0, t0, t1 + sw t0, 704(t4) + lbu t0, 12(t3) + slli t0, t0, 24 + lbu t1, 13(t3) + slli t1, t1, 16 + or t0, t0, t1 + lbu t1, 14(t3) + slli t1, t1, 8 + or t0, t0, t1 + lbu t1, 15(t3) + or t0, t0, t1 + sw t0, 768(t4) + addi t3, t3, 16 + addi t4, t4, 4 + addi t2, t2, -1 + bnez t2, 214b + addi a4, zero, 16 +215: + lbu t5, 0(a0) + lbu t0, 1(a0) + slli t0, t0, 8 + or t5, t5, t0 + lbu t0, 2(a0) + slli t0, t0, 16 + or t5, t5, t0 + lbu t0, 3(a0) + slli t0, t0, 24 + or t5, t5, t0 + lbu t6, 4(a0) + lbu t0, 5(a0) + slli t0, t0, 8 + or t6, t6, t0 + lbu t0, 6(a0) + slli t0, t0, 16 + or t6, t6, t0 + lbu t0, 7(a0) + slli t0, t0, 24 + or t6, t6, t0 + lwu t0, 704(a5) + xor t0, t0, t5 + sw t0, 384(a5) + lwu t1, 768(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 320(a5) + lwu t0, 708(a5) + xor t0, t0, t5 + sw t0, 388(a5) + lwu t1, 772(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 324(a5) + lwu t0, 712(a5) + xor t0, t0, t5 + sw t0, 392(a5) + lwu t1, 776(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 328(a5) + lwu t0, 716(a5) + xor t0, t0, t5 + sw t0, 396(a5) + lwu t1, 780(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 332(a5) + lwu t0, 720(a5) + xor t0, t0, t5 + sw t0, 400(a5) + lwu t1, 784(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 336(a5) + lwu t0, 724(a5) + xor t0, t0, t5 + sw t0, 404(a5) + lwu t1, 788(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 340(a5) + lwu t0, 728(a5) + xor t0, t0, t5 + sw t0, 408(a5) + lwu t1, 792(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 344(a5) + lwu t0, 732(a5) + xor t0, t0, t5 + sw t0, 412(a5) + lwu t1, 796(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 348(a5) + lwu t0, 736(a5) + xor t0, t0, t5 + sw t0, 416(a5) + lwu t1, 800(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 352(a5) + lwu t0, 740(a5) + xor t0, t0, t5 + sw t0, 420(a5) + lwu t1, 804(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 356(a5) + lwu t0, 744(a5) + xor t0, t0, t5 + sw t0, 424(a5) + lwu t1, 808(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 360(a5) + lwu t0, 748(a5) + xor t0, t0, t5 + sw t0, 428(a5) + lwu t1, 812(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 364(a5) + lwu t0, 752(a5) + xor t0, t0, t5 + sw t0, 432(a5) + lwu t1, 816(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 368(a5) + lwu t0, 756(a5) + xor t0, t0, t5 + sw t0, 436(a5) + lwu t1, 820(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 372(a5) + lwu t0, 760(a5) + xor t0, t0, t5 + sw t0, 440(a5) + lwu t1, 824(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 376(a5) + lwu t0, 764(a5) + xor t0, t0, t5 + sw t0, 444(a5) + lwu t1, 828(a5) + xor t0, t0, t1 + xor t0, t0, t6 + sw t0, 380(a5) + ld s0, 320(a5) + ld s1, 328(a5) + ld s2, 336(a5) + ld s3, 344(a5) + ld s4, 352(a5) + ld s5, 360(a5) + ld s6, 368(a5) + ld s7, 376(a5) + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + addi s0, t1, 0 + xor s0, s0, t2 + xor s0, s0, t4 + addi s1, t3, 0 + xor s1, s1, t4 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t5, 0 + xor s2, s2, t6 + xor s2, s2, a7 + addi s3, t2, 0 + xor s3, s3, t3 + xor s3, s3, t4 + xor s3, s3, t6 + addi s4, t2, 0 + xor s4, s4, t3 + xor s4, s4, t5 + addi s5, t4, 0 + xor s5, s5, t5 + addi s6, t3, 0 + xor s6, s6, t4 + xor s6, s6, t5 + xor s6, s6, t6 + addi s7, t5, 0 + xor s7, s7, t6 + xor s7, s7, a6 + xor t0, s4, s2 + xor t1, s7, s1 + xor t2, s7, s4 + xor t3, s7, s2 + xor s5, s6, s5 + xor t4, s5, s0 + xor s4, t4, s4 + xor t5, t1, t0 + xor t6, t4, s7 + xor s1, t4, s1 + xor a6, s1, t3 + xor s3, s3, t5 + xor s2, s3, s2 + xor s3, s3, s6 + xor s6, s2, s0 + xor a7, s2, s5 + xor s8, s3, t2 + xor s9, s0, s8 + xor s10, a7, s8 + xor s11, a7, t3 + xor s5, s5, s8 + sd s11, 0(a5) + xor s11, t1, s5 + xor s7, s7, s5 + sd s7, 8(a5) + and s7, t5, s2 + sd t5, 16(a5) + and t5, a6, s6 + xor t5, t5, s7 + sd a6, 24(a5) + and a6, s4, s0 + xor a6, a6, s7 + and s7, t1, s5 + sd t1, 32(a5) + and t1, s1, t4 + xor t1, t1, s7 + sd s1, 40(a5) + and s1, t6, s9 + xor s1, s1, s7 + and s7, t2, s8 + sd t2, 48(a5) + and t2, t0, s10 + xor t2, t2, s7 + sd t0, 56(a5) + and t0, t3, a7 + xor t0, t0, s7 + xor t5, t5, t2 + xor a6, a6, t0 + xor t1, t1, t2 + xor s1, s1, t0 + xor t5, t5, s3 + ld s3, 0(a5) + xor a6, a6, s3 + xor t1, t1, s11 + ld s11, 8(a5) + xor s1, s1, s11 + xor s11, t5, a6 + and t5, t5, t1 + xor s3, s1, t5 + and t0, s11, s3 + xor t0, t0, a6 + xor t2, t1, s1 + xor a6, a6, t5 + and a6, a6, t2 + xor a6, a6, s1 + xor t1, t1, a6 + xor t2, s3, a6 + and s1, s1, t2 + xor t1, s1, t1 + xor s3, s3, s1 + and s3, t0, s3 + xor s11, s11, s3 + xor s3, s11, t1 + xor s1, t0, a6 + xor t2, t0, s11 + xor t5, a6, t1 + xor s7, s1, s3 + and s2, t5, s2 + and s6, t1, s6 + and s0, a6, s0 + and s5, t2, s5 + and t4, s11, t4 + and s9, t0, s9 + and s8, s1, s8 + and s10, s7, s10 + and a7, s3, a7 + sd s6, 8(a5) + ld s6, 16(a5) + and t5, t5, s6 + ld s6, 24(a5) + and t1, t1, s6 + and a6, a6, s4 + ld s4, 32(a5) + and t2, t2, s4 + ld s4, 40(a5) + and s11, s11, s4 + and t0, t0, t6 + ld t6, 48(a5) + and s1, s1, t6 + ld t6, 56(a5) + and s7, s7, t6 + and s3, s3, t3 + xor s1, s1, s7 + xor a6, t1, a6 + xor s11, s9, s11 + xor t5, t5, t1 + xor t1, s0, t2 + xor s0, s0, s9 + xor a7, s10, a7 + xor s2, s2, s5 + xor s8, s8, s10 + xor s7, s7, s3 + xor t2, t2, s11 + xor t1, t1, s2 + xor s3, t4, s1 + xor s5, s5, s8 + xor s1, s1, t1 + xor t0, t0, t1 + xor a7, a7, s3 + xor t5, t5, s3 + xor t4, t4, s5 + xor t0, t0, a7 + ld s3, 8(a5) + xor s3, s3, t5 + xor s5, s5, t5 + xor t2, t2, a7 + xori t2, t2, -1 + xor s11, s11, s1 + xori s11, s11, -1 + xor s1, t4, t0 + xor s4, s2, s3 + xor s3, s0, s3 + xor s2, a6, t0 + xor s6, t4, s4 + xori s6, s6, -1 + xor s7, s7, s1 + xori s7, s7, -1 + sd s7, 8(a5) + addi s7, s5, 0 + ld s5, 8(a5) + addi s1, t2, 0 + addi s0, s11, 0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + ld s8, 24(a3) + ld s9, 32(a3) + and s0, t2, s9 + and t0, t3, s8 + xor s0, s0, t0 + and t0, t4, s9 + xor s0, s0, t0 + and t0, t5, s8 + xor s0, s0, t0 + and t0, t6, s8 + xor s0, s0, t0 + and t0, a6, s8 + xor s0, s0, t0 + and s1, t2, s9 + and t0, t3, s8 + xor s1, s1, t0 + xor s1, s1, t5 + and t0, t6, s9 + xor s1, s1, t0 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t1, 0 + and t0, t2, s8 + xor s2, s2, t0 + and t0, t3, s9 + xor s2, s2, t0 + and t0, t4, s9 + xor s2, s2, t0 + xor s2, s2, t5 + xor s2, s2, a6 + addi s3, t1, 0 + and t0, t2, s9 + xor s3, s3, t0 + and t0, t3, s8 + xor s3, s3, t0 + and t0, t4, s9 + xor s3, s3, t0 + xor s3, s3, t5 + xor s3, s3, t6 + xor s3, s3, a6 + and t0, a7, s8 + xor s3, s3, t0 + and s4, t1, s8 + and t0, t3, s8 + xor s4, s4, t0 + xor s4, s4, t4 + and t0, t5, s8 + xor s4, s4, t0 + xor s4, s4, a6 + and t0, a7, s9 + xor s4, s4, t0 + and s5, t1, s8 + and t0, t2, s8 + xor s5, s5, t0 + xor s5, s5, t4 + and t0, t5, s9 + xor s5, s5, t0 + xor s5, s5, t6 + xor s5, s5, a6 + and s6, t1, s8 + and t0, t2, s9 + xor s6, s6, t0 + and t0, t3, s9 + xor s6, s6, t0 + and t0, t4, s9 + xor s6, s6, t0 + and t0, t5, s8 + xor s6, s6, t0 + and t0, t6, s8 + xor s6, s6, t0 + xor s6, s6, a6 + and s7, t2, s8 + xor s7, s7, t4 + and t0, a6, s8 + xor s7, s7, t0 + and t0, a7, s8 + xor s7, s7, t0 + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t2, 40(a3) + ld t3, 48(a3) + ld t6, 56(a3) + ld t4, 64(a3) + ld a6, 72(a3) + ld t5, 80(a3) + ld a7, 88(a3) + ld s8, 96(a3) + and t1, s0, t2 + srli t0, s0, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s0, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s0, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s0, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s0, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s0, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 320(a5) + and t1, s1, t2 + srli t0, s1, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s1, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s1, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s1, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s1, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s1, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 328(a5) + and t1, s2, t2 + srli t0, s2, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s2, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s2, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s2, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s2, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s2, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 336(a5) + and t1, s3, t2 + srli t0, s3, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s3, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s3, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s3, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s3, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s3, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 344(a5) + and t1, s4, t2 + srli t0, s4, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s4, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s4, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s4, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s4, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s4, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 352(a5) + and t1, s5, t2 + srli t0, s5, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s5, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s5, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s5, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s5, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s5, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 360(a5) + and t1, s6, t2 + srli t0, s6, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s6, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s6, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s6, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s6, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s6, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 368(a5) + and t1, s7, t2 + srli t0, s7, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s7, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s7, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s7, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s7, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s7, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 376(a5) + lwu t0, 320(a5) + sw t0, 448(a5) + lwu t1, 384(a5) + add t0, t0, t1 + sw t0, 320(a5) + lwu t0, 324(a5) + sw t0, 452(a5) + lwu t1, 388(a5) + add t0, t0, t1 + sw t0, 324(a5) + lwu t0, 328(a5) + sw t0, 456(a5) + lwu t1, 392(a5) + add t0, t0, t1 + sw t0, 328(a5) + lwu t0, 332(a5) + sw t0, 460(a5) + lwu t1, 396(a5) + add t0, t0, t1 + sw t0, 332(a5) + lwu t0, 336(a5) + sw t0, 464(a5) + lwu t1, 400(a5) + add t0, t0, t1 + sw t0, 336(a5) + lwu t0, 340(a5) + sw t0, 468(a5) + lwu t1, 404(a5) + add t0, t0, t1 + sw t0, 340(a5) + lwu t0, 344(a5) + sw t0, 472(a5) + lwu t1, 408(a5) + add t0, t0, t1 + sw t0, 344(a5) + lwu t0, 348(a5) + sw t0, 476(a5) + lwu t1, 412(a5) + add t0, t0, t1 + sw t0, 348(a5) + lwu t0, 352(a5) + sw t0, 480(a5) + lwu t1, 416(a5) + add t0, t0, t1 + sw t0, 352(a5) + lwu t0, 356(a5) + sw t0, 484(a5) + lwu t1, 420(a5) + add t0, t0, t1 + sw t0, 356(a5) + lwu t0, 360(a5) + sw t0, 488(a5) + lwu t1, 424(a5) + add t0, t0, t1 + sw t0, 360(a5) + lwu t0, 364(a5) + sw t0, 492(a5) + lwu t1, 428(a5) + add t0, t0, t1 + sw t0, 364(a5) + lwu t0, 368(a5) + sw t0, 496(a5) + lwu t1, 432(a5) + add t0, t0, t1 + sw t0, 368(a5) + lwu t0, 372(a5) + sw t0, 500(a5) + lwu t1, 436(a5) + add t0, t0, t1 + sw t0, 372(a5) + lwu t0, 376(a5) + sw t0, 504(a5) + lwu t1, 440(a5) + add t0, t0, t1 + sw t0, 376(a5) + lwu t0, 380(a5) + sw t0, 508(a5) + lwu t1, 444(a5) + add t0, t0, t1 + sw t0, 380(a5) + ld s0, 320(a5) + ld s1, 328(a5) + ld s2, 336(a5) + ld s3, 344(a5) + ld s4, 352(a5) + ld s5, 360(a5) + ld s6, 368(a5) + ld s7, 376(a5) + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + addi s0, t1, 0 + xor s0, s0, t2 + xor s0, s0, t4 + addi s1, t3, 0 + xor s1, s1, t4 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t5, 0 + xor s2, s2, t6 + xor s2, s2, a7 + addi s3, t2, 0 + xor s3, s3, t3 + xor s3, s3, t4 + xor s3, s3, t6 + addi s4, t2, 0 + xor s4, s4, t3 + xor s4, s4, t5 + addi s5, t4, 0 + xor s5, s5, t5 + addi s6, t3, 0 + xor s6, s6, t4 + xor s6, s6, t5 + xor s6, s6, t6 + addi s7, t5, 0 + xor s7, s7, t6 + xor s7, s7, a6 + xor t0, s4, s2 + xor t1, s7, s1 + xor t2, s7, s4 + xor t3, s7, s2 + xor s5, s6, s5 + xor t4, s5, s0 + xor s4, t4, s4 + xor t5, t1, t0 + xor t6, t4, s7 + xor s1, t4, s1 + xor a6, s1, t3 + xor s3, s3, t5 + xor s2, s3, s2 + xor s3, s3, s6 + xor s6, s2, s0 + xor a7, s2, s5 + xor s8, s3, t2 + xor s9, s0, s8 + xor s10, a7, s8 + xor s11, a7, t3 + xor s5, s5, s8 + sd s11, 0(a5) + xor s11, t1, s5 + xor s7, s7, s5 + sd s7, 8(a5) + and s7, t5, s2 + sd t5, 16(a5) + and t5, a6, s6 + xor t5, t5, s7 + sd a6, 24(a5) + and a6, s4, s0 + xor a6, a6, s7 + and s7, t1, s5 + sd t1, 32(a5) + and t1, s1, t4 + xor t1, t1, s7 + sd s1, 40(a5) + and s1, t6, s9 + xor s1, s1, s7 + and s7, t2, s8 + sd t2, 48(a5) + and t2, t0, s10 + xor t2, t2, s7 + sd t0, 56(a5) + and t0, t3, a7 + xor t0, t0, s7 + xor t5, t5, t2 + xor a6, a6, t0 + xor t1, t1, t2 + xor s1, s1, t0 + xor t5, t5, s3 + ld s3, 0(a5) + xor a6, a6, s3 + xor t1, t1, s11 + ld s11, 8(a5) + xor s1, s1, s11 + xor s11, t5, a6 + and t5, t5, t1 + xor s3, s1, t5 + and t0, s11, s3 + xor t0, t0, a6 + xor t2, t1, s1 + xor a6, a6, t5 + and a6, a6, t2 + xor a6, a6, s1 + xor t1, t1, a6 + xor t2, s3, a6 + and s1, s1, t2 + xor t1, s1, t1 + xor s3, s3, s1 + and s3, t0, s3 + xor s11, s11, s3 + xor s3, s11, t1 + xor s1, t0, a6 + xor t2, t0, s11 + xor t5, a6, t1 + xor s7, s1, s3 + and s2, t5, s2 + and s6, t1, s6 + and s0, a6, s0 + and s5, t2, s5 + and t4, s11, t4 + and s9, t0, s9 + and s8, s1, s8 + and s10, s7, s10 + and a7, s3, a7 + sd s6, 8(a5) + ld s6, 16(a5) + and t5, t5, s6 + ld s6, 24(a5) + and t1, t1, s6 + and a6, a6, s4 + ld s4, 32(a5) + and t2, t2, s4 + ld s4, 40(a5) + and s11, s11, s4 + and t0, t0, t6 + ld t6, 48(a5) + and s1, s1, t6 + ld t6, 56(a5) + and s7, s7, t6 + and s3, s3, t3 + xor s1, s1, s7 + xor a6, t1, a6 + xor s11, s9, s11 + xor t5, t5, t1 + xor t1, s0, t2 + xor s0, s0, s9 + xor a7, s10, a7 + xor s2, s2, s5 + xor s8, s8, s10 + xor s7, s7, s3 + xor t2, t2, s11 + xor t1, t1, s2 + xor s3, t4, s1 + xor s5, s5, s8 + xor s1, s1, t1 + xor t0, t0, t1 + xor a7, a7, s3 + xor t5, t5, s3 + xor t4, t4, s5 + xor t0, t0, a7 + ld s3, 8(a5) + xor s3, s3, t5 + xor s5, s5, t5 + xor t2, t2, a7 + xori t2, t2, -1 + xor s11, s11, s1 + xori s11, s11, -1 + xor s1, t4, t0 + xor s4, s2, s3 + xor s3, s0, s3 + xor s2, a6, t0 + xor s6, t4, s4 + xori s6, s6, -1 + xor s7, s7, s1 + xori s7, s7, -1 + sd s7, 8(a5) + addi s7, s5, 0 + ld s5, 8(a5) + addi s1, t2, 0 + addi s0, s11, 0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + ld s8, 24(a3) + ld s9, 32(a3) + and s0, t2, s9 + and t0, t3, s8 + xor s0, s0, t0 + and t0, t4, s9 + xor s0, s0, t0 + and t0, t5, s8 + xor s0, s0, t0 + and t0, t6, s8 + xor s0, s0, t0 + and t0, a6, s8 + xor s0, s0, t0 + and s1, t2, s9 + and t0, t3, s8 + xor s1, s1, t0 + xor s1, s1, t5 + and t0, t6, s9 + xor s1, s1, t0 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t1, 0 + and t0, t2, s8 + xor s2, s2, t0 + and t0, t3, s9 + xor s2, s2, t0 + and t0, t4, s9 + xor s2, s2, t0 + xor s2, s2, t5 + xor s2, s2, a6 + addi s3, t1, 0 + and t0, t2, s9 + xor s3, s3, t0 + and t0, t3, s8 + xor s3, s3, t0 + and t0, t4, s9 + xor s3, s3, t0 + xor s3, s3, t5 + xor s3, s3, t6 + xor s3, s3, a6 + and t0, a7, s8 + xor s3, s3, t0 + and s4, t1, s8 + and t0, t3, s8 + xor s4, s4, t0 + xor s4, s4, t4 + and t0, t5, s8 + xor s4, s4, t0 + xor s4, s4, a6 + and t0, a7, s9 + xor s4, s4, t0 + and s5, t1, s8 + and t0, t2, s8 + xor s5, s5, t0 + xor s5, s5, t4 + and t0, t5, s9 + xor s5, s5, t0 + xor s5, s5, t6 + xor s5, s5, a6 + and s6, t1, s8 + and t0, t2, s9 + xor s6, s6, t0 + and t0, t3, s9 + xor s6, s6, t0 + and t0, t4, s9 + xor s6, s6, t0 + and t0, t5, s8 + xor s6, s6, t0 + and t0, t6, s8 + xor s6, s6, t0 + xor s6, s6, a6 + and s7, t2, s8 + xor s7, s7, t4 + and t0, a6, s8 + xor s7, s7, t0 + and t0, a7, s8 + xor s7, s7, t0 + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t2, 40(a3) + ld t3, 48(a3) + ld t6, 56(a3) + ld t4, 64(a3) + ld a6, 72(a3) + ld t5, 80(a3) + ld a7, 88(a3) + ld s8, 96(a3) + and t1, s0, t2 + srli t0, s0, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s0, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s0, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s0, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s0, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s0, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 320(a5) + and t1, s1, t2 + srli t0, s1, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s1, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s1, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s1, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s1, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s1, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 328(a5) + and t1, s2, t2 + srli t0, s2, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s2, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s2, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s2, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s2, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s2, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 336(a5) + and t1, s3, t2 + srli t0, s3, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s3, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s3, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s3, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s3, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s3, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 344(a5) + and t1, s4, t2 + srli t0, s4, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s4, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s4, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s4, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s4, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s4, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 352(a5) + and t1, s5, t2 + srli t0, s5, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s5, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s5, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s5, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s5, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s5, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 360(a5) + and t1, s6, t2 + srli t0, s6, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s6, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s6, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s6, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s6, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s6, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 368(a5) + and t1, s7, t2 + srli t0, s7, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s7, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s7, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s7, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s7, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s7, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 376(a5) + lwu t0, 320(a5) + sw t0, 512(a5) + lwu t1, 448(a5) + add t0, t0, t1 + sw t0, 320(a5) + lwu t0, 324(a5) + sw t0, 516(a5) + lwu t1, 452(a5) + add t0, t0, t1 + sw t0, 324(a5) + lwu t0, 328(a5) + sw t0, 520(a5) + lwu t1, 456(a5) + add t0, t0, t1 + sw t0, 328(a5) + lwu t0, 332(a5) + sw t0, 524(a5) + lwu t1, 460(a5) + add t0, t0, t1 + sw t0, 332(a5) + lwu t0, 336(a5) + sw t0, 528(a5) + lwu t1, 464(a5) + add t0, t0, t1 + sw t0, 336(a5) + lwu t0, 340(a5) + sw t0, 532(a5) + lwu t1, 468(a5) + add t0, t0, t1 + sw t0, 340(a5) + lwu t0, 344(a5) + sw t0, 536(a5) + lwu t1, 472(a5) + add t0, t0, t1 + sw t0, 344(a5) + lwu t0, 348(a5) + sw t0, 540(a5) + lwu t1, 476(a5) + add t0, t0, t1 + sw t0, 348(a5) + lwu t0, 352(a5) + sw t0, 544(a5) + lwu t1, 480(a5) + add t0, t0, t1 + sw t0, 352(a5) + lwu t0, 356(a5) + sw t0, 548(a5) + lwu t1, 484(a5) + add t0, t0, t1 + sw t0, 356(a5) + lwu t0, 360(a5) + sw t0, 552(a5) + lwu t1, 488(a5) + add t0, t0, t1 + sw t0, 360(a5) + lwu t0, 364(a5) + sw t0, 556(a5) + lwu t1, 492(a5) + add t0, t0, t1 + sw t0, 364(a5) + lwu t0, 368(a5) + sw t0, 560(a5) + lwu t1, 496(a5) + add t0, t0, t1 + sw t0, 368(a5) + lwu t0, 372(a5) + sw t0, 564(a5) + lwu t1, 500(a5) + add t0, t0, t1 + sw t0, 372(a5) + lwu t0, 376(a5) + sw t0, 568(a5) + lwu t1, 504(a5) + add t0, t0, t1 + sw t0, 376(a5) + lwu t0, 380(a5) + sw t0, 572(a5) + lwu t1, 508(a5) + add t0, t0, t1 + sw t0, 380(a5) + ld s0, 320(a5) + ld s1, 328(a5) + ld s2, 336(a5) + ld s3, 344(a5) + ld s4, 352(a5) + ld s5, 360(a5) + ld s6, 368(a5) + ld s7, 376(a5) + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + addi s0, t1, 0 + xor s0, s0, t2 + xor s0, s0, t4 + addi s1, t3, 0 + xor s1, s1, t4 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t5, 0 + xor s2, s2, t6 + xor s2, s2, a7 + addi s3, t2, 0 + xor s3, s3, t3 + xor s3, s3, t4 + xor s3, s3, t6 + addi s4, t2, 0 + xor s4, s4, t3 + xor s4, s4, t5 + addi s5, t4, 0 + xor s5, s5, t5 + addi s6, t3, 0 + xor s6, s6, t4 + xor s6, s6, t5 + xor s6, s6, t6 + addi s7, t5, 0 + xor s7, s7, t6 + xor s7, s7, a6 + xor t0, s4, s2 + xor t1, s7, s1 + xor t2, s7, s4 + xor t3, s7, s2 + xor s5, s6, s5 + xor t4, s5, s0 + xor s4, t4, s4 + xor t5, t1, t0 + xor t6, t4, s7 + xor s1, t4, s1 + xor a6, s1, t3 + xor s3, s3, t5 + xor s2, s3, s2 + xor s3, s3, s6 + xor s6, s2, s0 + xor a7, s2, s5 + xor s8, s3, t2 + xor s9, s0, s8 + xor s10, a7, s8 + xor s11, a7, t3 + xor s5, s5, s8 + sd s11, 0(a5) + xor s11, t1, s5 + xor s7, s7, s5 + sd s7, 8(a5) + and s7, t5, s2 + sd t5, 16(a5) + and t5, a6, s6 + xor t5, t5, s7 + sd a6, 24(a5) + and a6, s4, s0 + xor a6, a6, s7 + and s7, t1, s5 + sd t1, 32(a5) + and t1, s1, t4 + xor t1, t1, s7 + sd s1, 40(a5) + and s1, t6, s9 + xor s1, s1, s7 + and s7, t2, s8 + sd t2, 48(a5) + and t2, t0, s10 + xor t2, t2, s7 + sd t0, 56(a5) + and t0, t3, a7 + xor t0, t0, s7 + xor t5, t5, t2 + xor a6, a6, t0 + xor t1, t1, t2 + xor s1, s1, t0 + xor t5, t5, s3 + ld s3, 0(a5) + xor a6, a6, s3 + xor t1, t1, s11 + ld s11, 8(a5) + xor s1, s1, s11 + xor s11, t5, a6 + and t5, t5, t1 + xor s3, s1, t5 + and t0, s11, s3 + xor t0, t0, a6 + xor t2, t1, s1 + xor a6, a6, t5 + and a6, a6, t2 + xor a6, a6, s1 + xor t1, t1, a6 + xor t2, s3, a6 + and s1, s1, t2 + xor t1, s1, t1 + xor s3, s3, s1 + and s3, t0, s3 + xor s11, s11, s3 + xor s3, s11, t1 + xor s1, t0, a6 + xor t2, t0, s11 + xor t5, a6, t1 + xor s7, s1, s3 + and s2, t5, s2 + and s6, t1, s6 + and s0, a6, s0 + and s5, t2, s5 + and t4, s11, t4 + and s9, t0, s9 + and s8, s1, s8 + and s10, s7, s10 + and a7, s3, a7 + sd s6, 8(a5) + ld s6, 16(a5) + and t5, t5, s6 + ld s6, 24(a5) + and t1, t1, s6 + and a6, a6, s4 + ld s4, 32(a5) + and t2, t2, s4 + ld s4, 40(a5) + and s11, s11, s4 + and t0, t0, t6 + ld t6, 48(a5) + and s1, s1, t6 + ld t6, 56(a5) + and s7, s7, t6 + and s3, s3, t3 + xor s1, s1, s7 + xor a6, t1, a6 + xor s11, s9, s11 + xor t5, t5, t1 + xor t1, s0, t2 + xor s0, s0, s9 + xor a7, s10, a7 + xor s2, s2, s5 + xor s8, s8, s10 + xor s7, s7, s3 + xor t2, t2, s11 + xor t1, t1, s2 + xor s3, t4, s1 + xor s5, s5, s8 + xor s1, s1, t1 + xor t0, t0, t1 + xor a7, a7, s3 + xor t5, t5, s3 + xor t4, t4, s5 + xor t0, t0, a7 + ld s3, 8(a5) + xor s3, s3, t5 + xor s5, s5, t5 + xor t2, t2, a7 + xori t2, t2, -1 + xor s11, s11, s1 + xori s11, s11, -1 + xor s1, t4, t0 + xor s4, s2, s3 + xor s3, s0, s3 + xor s2, a6, t0 + xor s6, t4, s4 + xori s6, s6, -1 + xor s7, s7, s1 + xori s7, s7, -1 + sd s7, 8(a5) + addi s7, s5, 0 + ld s5, 8(a5) + addi s1, t2, 0 + addi s0, s11, 0 + addi t1, s0, 0 + addi t2, s1, 0 + addi t3, s2, 0 + addi t4, s3, 0 + addi t5, s4, 0 + addi t6, s5, 0 + addi a6, s6, 0 + addi a7, s7, 0 + ld s8, 24(a3) + ld s9, 32(a3) + and s0, t2, s9 + and t0, t3, s8 + xor s0, s0, t0 + and t0, t4, s9 + xor s0, s0, t0 + and t0, t5, s8 + xor s0, s0, t0 + and t0, t6, s8 + xor s0, s0, t0 + and t0, a6, s8 + xor s0, s0, t0 + and s1, t2, s9 + and t0, t3, s8 + xor s1, s1, t0 + xor s1, s1, t5 + and t0, t6, s9 + xor s1, s1, t0 + xor s1, s1, a6 + xor s1, s1, a7 + addi s2, t1, 0 + and t0, t2, s8 + xor s2, s2, t0 + and t0, t3, s9 + xor s2, s2, t0 + and t0, t4, s9 + xor s2, s2, t0 + xor s2, s2, t5 + xor s2, s2, a6 + addi s3, t1, 0 + and t0, t2, s9 + xor s3, s3, t0 + and t0, t3, s8 + xor s3, s3, t0 + and t0, t4, s9 + xor s3, s3, t0 + xor s3, s3, t5 + xor s3, s3, t6 + xor s3, s3, a6 + and t0, a7, s8 + xor s3, s3, t0 + and s4, t1, s8 + and t0, t3, s8 + xor s4, s4, t0 + xor s4, s4, t4 + and t0, t5, s8 + xor s4, s4, t0 + xor s4, s4, a6 + and t0, a7, s9 + xor s4, s4, t0 + and s5, t1, s8 + and t0, t2, s8 + xor s5, s5, t0 + xor s5, s5, t4 + and t0, t5, s9 + xor s5, s5, t0 + xor s5, s5, t6 + xor s5, s5, a6 + and s6, t1, s8 + and t0, t2, s9 + xor s6, s6, t0 + and t0, t3, s9 + xor s6, s6, t0 + and t0, t4, s9 + xor s6, s6, t0 + and t0, t5, s8 + xor s6, s6, t0 + and t0, t6, s8 + xor s6, s6, t0 + xor s6, s6, a6 + and s7, t2, s8 + xor s7, s7, t4 + and t0, a6, s8 + xor s7, s7, t0 + and t0, a7, s8 + xor s7, s7, t0 + ld t6, 0(a3) + ld a6, 8(a3) + ld a7, 16(a3) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + ld t2, 40(a3) + ld t3, 48(a3) + ld t6, 56(a3) + ld t4, 64(a3) + ld a6, 72(a3) + ld t5, 80(a3) + ld a7, 88(a3) + ld s8, 96(a3) + and t1, s0, t2 + srli t0, s0, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s0, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s0, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s0, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s0, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s0, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 320(a5) + and t1, s1, t2 + srli t0, s1, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s1, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s1, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s1, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s1, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s1, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 328(a5) + and t1, s2, t2 + srli t0, s2, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s2, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s2, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s2, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s2, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s2, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 336(a5) + and t1, s3, t2 + srli t0, s3, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s3, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s3, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s3, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s3, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s3, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 344(a5) + and t1, s4, t2 + srli t0, s4, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s4, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s4, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s4, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s4, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s4, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 352(a5) + and t1, s5, t2 + srli t0, s5, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s5, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s5, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s5, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s5, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s5, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 360(a5) + and t1, s6, t2 + srli t0, s6, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s6, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s6, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s6, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s6, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s6, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 368(a5) + and t1, s7, t2 + srli t0, s7, 8 + and t0, t0, t3 + xor t1, t1, t0 + slli t0, s7, 24 + and t0, t0, t6 + xor t1, t1, t0 + srli t0, s7, 16 + and t0, t0, t4 + xor t1, t1, t0 + slli t0, s7, 16 + and t0, t0, a6 + xor t1, t1, t0 + srli t0, s7, 24 + and t0, t0, t5 + xor t1, t1, t0 + slli t0, s7, 8 + and t0, t0, a7 + xor t1, t1, t0 + xor t1, t1, s8 + sd t1, 376(a5) + lwu t0, 320(a5) + lwu t1, 640(a5) + xor t1, t1, t0 + sw t1, 640(a5) + lwu t1, 512(a5) + add t0, t0, t1 + lwu t1, 576(a5) + xor t0, t0, t1 + sw t0, 576(a5) + lwu t0, 324(a5) + lwu t1, 644(a5) + xor t1, t1, t0 + sw t1, 644(a5) + lwu t1, 516(a5) + add t0, t0, t1 + lwu t1, 580(a5) + xor t0, t0, t1 + sw t0, 580(a5) + lwu t0, 328(a5) + lwu t1, 648(a5) + xor t1, t1, t0 + sw t1, 648(a5) + lwu t1, 520(a5) + add t0, t0, t1 + lwu t1, 584(a5) + xor t0, t0, t1 + sw t0, 584(a5) + lwu t0, 332(a5) + lwu t1, 652(a5) + xor t1, t1, t0 + sw t1, 652(a5) + lwu t1, 524(a5) + add t0, t0, t1 + lwu t1, 588(a5) + xor t0, t0, t1 + sw t0, 588(a5) + lwu t0, 336(a5) + lwu t1, 656(a5) + xor t1, t1, t0 + sw t1, 656(a5) + lwu t1, 528(a5) + add t0, t0, t1 + lwu t1, 592(a5) + xor t0, t0, t1 + sw t0, 592(a5) + lwu t0, 340(a5) + lwu t1, 660(a5) + xor t1, t1, t0 + sw t1, 660(a5) + lwu t1, 532(a5) + add t0, t0, t1 + lwu t1, 596(a5) + xor t0, t0, t1 + sw t0, 596(a5) + lwu t0, 344(a5) + lwu t1, 664(a5) + xor t1, t1, t0 + sw t1, 664(a5) + lwu t1, 536(a5) + add t0, t0, t1 + lwu t1, 600(a5) + xor t0, t0, t1 + sw t0, 600(a5) + lwu t0, 348(a5) + lwu t1, 668(a5) + xor t1, t1, t0 + sw t1, 668(a5) + lwu t1, 540(a5) + add t0, t0, t1 + lwu t1, 604(a5) + xor t0, t0, t1 + sw t0, 604(a5) + lwu t0, 352(a5) + lwu t1, 672(a5) + xor t1, t1, t0 + sw t1, 672(a5) + lwu t1, 544(a5) + add t0, t0, t1 + lwu t1, 608(a5) + xor t0, t0, t1 + sw t0, 608(a5) + lwu t0, 356(a5) + lwu t1, 676(a5) + xor t1, t1, t0 + sw t1, 676(a5) + lwu t1, 548(a5) + add t0, t0, t1 + lwu t1, 612(a5) + xor t0, t0, t1 + sw t0, 612(a5) + lwu t0, 360(a5) + lwu t1, 680(a5) + xor t1, t1, t0 + sw t1, 680(a5) + lwu t1, 552(a5) + add t0, t0, t1 + lwu t1, 616(a5) + xor t0, t0, t1 + sw t0, 616(a5) + lwu t0, 364(a5) + lwu t1, 684(a5) + xor t1, t1, t0 + sw t1, 684(a5) + lwu t1, 556(a5) + add t0, t0, t1 + lwu t1, 620(a5) + xor t0, t0, t1 + sw t0, 620(a5) + lwu t0, 368(a5) + lwu t1, 688(a5) + xor t1, t1, t0 + sw t1, 688(a5) + lwu t1, 560(a5) + add t0, t0, t1 + lwu t1, 624(a5) + xor t0, t0, t1 + sw t0, 624(a5) + lwu t0, 372(a5) + lwu t1, 692(a5) + xor t1, t1, t0 + sw t1, 692(a5) + lwu t1, 564(a5) + add t0, t0, t1 + lwu t1, 628(a5) + xor t0, t0, t1 + sw t0, 628(a5) + lwu t0, 376(a5) + lwu t1, 696(a5) + xor t1, t1, t0 + sw t1, 696(a5) + lwu t1, 568(a5) + add t0, t0, t1 + lwu t1, 632(a5) + xor t0, t0, t1 + sw t0, 632(a5) + lwu t0, 380(a5) + lwu t1, 700(a5) + xor t1, t1, t0 + sw t1, 700(a5) + lwu t1, 572(a5) + add t0, t0, t1 + lwu t1, 636(a5) + xor t0, t0, t1 + sw t0, 636(a5) + ld t0, 576(a5) + ld t1, 704(a5) + sd t1, 576(a5) + sd t0, 704(a5) + ld t0, 584(a5) + ld t1, 712(a5) + sd t1, 584(a5) + sd t0, 712(a5) + ld t0, 592(a5) + ld t1, 720(a5) + sd t1, 592(a5) + sd t0, 720(a5) + ld t0, 600(a5) + ld t1, 728(a5) + sd t1, 600(a5) + sd t0, 728(a5) + ld t0, 608(a5) + ld t1, 736(a5) + sd t1, 608(a5) + sd t0, 736(a5) + ld t0, 616(a5) + ld t1, 744(a5) + sd t1, 616(a5) + sd t0, 744(a5) + ld t0, 624(a5) + ld t1, 752(a5) + sd t1, 624(a5) + sd t0, 752(a5) + ld t0, 632(a5) + ld t1, 760(a5) + sd t1, 632(a5) + sd t0, 760(a5) + ld t0, 640(a5) + ld t1, 768(a5) + sd t1, 640(a5) + sd t0, 768(a5) + ld t0, 648(a5) + ld t1, 776(a5) + sd t1, 648(a5) + sd t0, 776(a5) + ld t0, 656(a5) + ld t1, 784(a5) + sd t1, 656(a5) + sd t0, 784(a5) + ld t0, 664(a5) + ld t1, 792(a5) + sd t1, 664(a5) + sd t0, 792(a5) + ld t0, 672(a5) + ld t1, 800(a5) + sd t1, 672(a5) + sd t0, 800(a5) + ld t0, 680(a5) + ld t1, 808(a5) + sd t1, 680(a5) + sd t0, 808(a5) + ld t0, 688(a5) + ld t1, 816(a5) + sd t1, 688(a5) + sd t0, 816(a5) + ld t0, 696(a5) + ld t1, 824(a5) + sd t1, 696(a5) + sd t0, 824(a5) + addi a0, a0, 8 + addi a4, a4, -1 + bnez a4, 215b + addi a0, a0, -128 + addi t2, zero, 1 + addi t3, a5, 1032 + addi t4, a5, 0 +216: + lwu t0, 704(t4) + srli t1, t0, 24 + sb t1, 0(t3) + srli t1, t0, 16 + sb t1, 1(t3) + srli t1, t0, 8 + sb t1, 2(t3) + srli t1, t0, 0 + sb t1, 3(t3) + lwu t0, 768(t4) + srli t1, t0, 24 + sb t1, 4(t3) + srli t1, t0, 16 + sb t1, 5(t3) + srli t1, t0, 8 + sb t1, 6(t3) + srli t1, t0, 0 + sb t1, 7(t3) + lwu t0, 576(t4) + srli t1, t0, 24 + sb t1, 8(t3) + srli t1, t0, 16 + sb t1, 9(t3) + srli t1, t0, 8 + sb t1, 10(t3) + srli t1, t0, 0 + sb t1, 11(t3) + lwu t0, 640(t4) + srli t1, t0, 24 + sb t1, 12(t3) + srli t1, t0, 16 + sb t1, 13(t3) + srli t1, t0, 8 + sb t1, 14(t3) + srli t1, t0, 0 + sb t1, 15(t3) + addi t3, t3, 16 + addi t4, t4, 4 + addi t2, t2, -1 + bnez t2, 216b + addi a0, a0, 0 + ld s0, 936(a5) + ld s1, 944(a5) + ld s2, 952(a5) + ld s3, 960(a5) + ld s4, 968(a5) + ld s5, 976(a5) + ld s6, 984(a5) + ld s7, 992(a5) + ld s8, 1000(a5) + ld s9, 1008(a5) + ld s10, 1016(a5) + ld s11, 1024(a5) + addi s1, a1, 0 + addi s2, a2, 0 + addi s3, ra, 0 + ld ra, 1048(a5) + addi s4, a5, -48 + addi t0, zero, 16 + bltu s3, t0, 217f + lwu t0, 1080(s4) + sw t0, 32(s4) + lwu t0, 1084(s4) + sw t0, 36(s4) + lwu t0, 1088(s4) + sw t0, 40(s4) + lwu t0, 1092(s4) + sw t0, 44(s4) + lwu t0, 0(s2) + lwu t1, 1080(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 1084(s4) + xor t0, t0, t1 + sw t0, 4(s2) + lwu t0, 8(s2) + lwu t1, 1088(s4) + xor t0, t0, t1 + sw t0, 8(s2) + lwu t0, 12(s2) + lwu t1, 1092(s4) + xor t0, t0, t1 + sw t0, 12(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 218f +217: + lwu t0, 1080(s4) + sw t0, 32(s4) + lwu t0, 1084(s4) + sw t0, 36(s4) + lwu t0, 1088(s4) + sw t0, 40(s4) + lwu t0, 1092(s4) + sw t0, 44(s4) + addi t2, s4, 1080 +219: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 219b +218: + bnez s3, 213b + j 212f +211: +212: +21: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lwu t0, 40(s4) + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lwu t0, 44(s4) + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 138 +220: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 220b + addi sp, sp, 1104 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/sm4_ctr.s b/crates/verified-garbage-asm-riscv64/assembly/sm4_ctr.s index 8ddfc3e77ac..eb21bcab94d 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/sm4_ctr.s +++ b/crates/verified-garbage-asm-riscv64/assembly/sm4_ctr.s @@ -19447,3 +19447,71 @@ vg_sm4_ctr: addi sp, sp, 2032 ret .option pop + +vg_sm4_ctr_final: + .option push + .option arch, +m, +c + addi sp, sp, -80 + addi a4, sp, 0 + sd ra, 0(a4) + sd s1, 8(a4) + sd s2, 16(a4) + sd s3, 24(a4) + sd s4, 32(a4) + sd s5, 40(a4) + sd s6, 48(a4) + sd s7, 56(a4) + addi s1, a0, 0 + addi s5, a1, 0 + addi s7, a4, 0 + srli t0, a3, 4 + slli t1, t0, 4 + add s2, a2, t1 + sub s3, a3, t1 + addi a3, t0, 0 + call {vg_sm4_ctr} + beqz s3, 20f + addi t0, zero, 0 + sd t0, 64(s7) + sd t0, 72(s7) + addi a0, s1, 0 + addi a1, s5, 0 + addi a2, s7, 64 + addi a3, zero, 1 + call {vg_sm4_ctr} + addi t2, s7, 64 +22: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 22b + j 21f +20: +21: + ld ra, 0(s7) + ld s1, 8(s7) + ld s2, 16(s7) + ld s3, 24(s7) + ld s4, 32(s7) + ld s5, 40(s7) + ld s6, 48(s7) + ld s7, 56(s7) + addi t5, sp, 0 + addi t6, zero, 0 + sd t6, 0(t5) + sd t6, 8(t5) + sd t6, 16(t5) + sd t6, 24(t5) + sd t6, 32(t5) + sd t6, 40(t5) + sd t6, 48(t5) + sd t6, 56(t5) + sd t6, 64(t5) + sd t6, 72(t5) + addi sp, sp, 80 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/sm4_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/sm4_ofb.s index 8bb50cb4fa8..6f081c949a6 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/sm4_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/sm4_ofb.s @@ -8993,3 +8993,9039 @@ vg_sm4_ofb: addi sp, sp, 2032 ret .option pop + +vg_sm4_ofb_final: + .option push + .option arch, +m, +c + addi sp, sp, -2032 + addi sp, sp, -1200 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 40(s4) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 44(s4) + addi s2, a2, 0 + sd a0, 48(s4) + addi a5, s4, 56 + addi t0, a5, 2040 + addi t0, t0, 1032 + sd s0, 0(t0) + sd s1, 8(t0) + sd s2, 16(t0) + sd s3, 24(t0) + sd s4, 32(t0) + sd s5, 40(t0) + sd s6, 48(t0) + sd s7, 56(t0) + sd s8, 64(t0) + sd s9, 72(t0) + sd s10, 80(t0) + sd s11, 88(t0) + lui t0, 4080 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 4080 + addiw t1, t1, 255 + add t0, t0, t1 + sd t0, 320(a5) + lui t0, 1044496 + addiw t0, t0, -255 + slli t0, t0, 32 + lui t1, 1044496 + addiw t1, t1, -256 + add t0, t0, t1 + sd t0, 328(a5) + lui t0, 16 + addiw t0, t0, -1 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 336(a5) + lui t0, 0 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 344(a5) + lui t0, 16 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, 1 + add t0, t0, t1 + sd t0, 352(a5) + lui t0, 0 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 1048560 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 360(a5) + lui t0, 16 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, -256 + add t0, t0, t1 + sd t0, 368(a5) + lui t0, 4080 + addiw t0, t0, 255 + slli t0, t0, 32 + lui t1, 4080 + addiw t1, t1, 255 + add t0, t0, t1 + sd t0, 376(a5) + lui t0, 349525 + addiw t0, t0, 1365 + slli t0, t0, 32 + lui t1, 349525 + addiw t1, t1, 1365 + add t0, t0, t1 + sd t0, 384(a5) + lui t0, 209715 + addiw t0, t0, 819 + slli t0, t0, 32 + lui t1, 209715 + addiw t1, t1, 819 + add t0, t0, t1 + sd t0, 392(a5) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + add t0, t0, t1 + sd t0, 400(a5) + addi a1, s1, 0 + addi a2, s2, 0 + addi a4, s3, 0 + addi t1, a0, 0 + addi t2, a5, 768 + addi t3, zero, 128 + or t4, t1, t2 + andi t4, t4, 7 + beqz t4, 20f +22: + lbu t4, 0(t1) + sb t4, 0(t2) + addi t1, t1, 1 + addi t2, t2, 1 + addi t3, t3, -1 + bnez t3, 22b + j 21f +20: + srli t3, t3, 3 +23: + ld t4, 0(t1) + sd t4, 0(t2) + addi t1, t1, 8 + addi t2, t2, 8 + addi t3, t3, -1 + bnez t3, 23b +21: + addi a0, a5, 768 + addi a3, a5, 1024 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + ld t1, 0(a0) + ld a6, 344(a5) + and t1, t1, a6 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + ld t1, 0(a0) + srli t1, t1, 32 + ld t3, 336(a5) + srli a7, t1, 48 + slli t0, t1, 16 + xor t0, t0, a7 + xor t1, t1, t0 + and t1, t1, t3 + ld t4, 320(a5) + and t5, t4, t3 + srli a7, t3, 16 + slli t2, t3, 48 + xor t2, t2, a7 + and t4, t4, t2 + srli a7, t1, 16 + slli t0, t1, 48 + xor t0, t0, a7 + and t0, t0, t4 + srli a7, t1, 40 + slli t1, t1, 24 + xor t1, t1, a7 + and t1, t1, t5 + xor t1, t1, t0 + ld t6, 352(a5) + and s0, t1, t6 + srli s1, t1, 1 + and s1, s1, t6 + srli s2, t1, 2 + and s2, s2, t6 + srli s3, t1, 3 + and s3, s3, t6 + srli s4, t1, 4 + and s4, s4, t6 + srli s5, t1, 5 + and s5, s5, t6 + srli s6, t1, 6 + and s6, s6, t6 + srli s7, t1, 7 + and s7, s7, t6 + slli t0, s0, 16 + sub s0, t0, s0 + slli t0, s1, 16 + sub s1, t0, s1 + slli t0, s2, 16 + sub s2, t0, s2 + slli t0, s3, 16 + sub s3, t0, s3 + slli t0, s4, 16 + sub s4, t0, s4 + slli t0, s5, 16 + sub s5, t0, s5 + slli t0, s6, 16 + sub s6, t0, s6 + slli t0, s7, 16 + sub s7, t0, s7 + sd s0, 0(a3) + sd s1, 8(a3) + sd s2, 16(a3) + sd s3, 24(a3) + sd s4, 32(a3) + sd s5, 40(a3) + sd s6, 48(a3) + sd s7, 56(a3) + addi a3, a3, 64 + addi a0, a0, 8 + addi a0, a5, 2040 + addi a0, a0, 1032 + addi t0, a5, 2040 + addi t0, t0, 1032 + ld s0, 0(t0) + ld s1, 8(t0) + ld s2, 16(t0) + ld s3, 24(t0) + ld s4, 32(t0) + ld s5, 40(t0) + ld s6, 48(t0) + ld s7, 56(t0) + ld s8, 64(t0) + ld s9, 72(t0) + ld s10, 80(t0) + ld s11, 88(t0) + addi s1, a1, 0 + addi s2, a2, 0 + addi s3, a4, 0 + addi s4, a5, -56 + ld a0, 48(s4) + andi t0, s2, 3 + beqz t0, 24f + beqz s3, 26f +28: + lwu t0, 32(s4) + sw t0, 824(s4) + lwu t0, 36(s4) + sw t0, 828(s4) + lwu t0, 40(s4) + sw t0, 832(s4) + lwu t0, 44(s4) + sw t0, 836(s4) + addi a5, s4, 56 + addi t0, a5, 2040 + addi t0, t0, 1032 + sd s0, 0(t0) + sd s1, 8(t0) + sd s2, 16(t0) + sd s3, 24(t0) + sd s4, 32(t0) + sd s5, 40(t0) + sd s6, 48(t0) + sd s7, 56(t0) + sd s8, 64(t0) + sd s9, 72(t0) + sd s10, 80(t0) + sd s11, 88(t0) + addi a1, s1, 0 + addi a2, s2, 0 + addi a4, s3, 0 + addi a0, a5, 2040 + addi a0, a0, 1032 + ld t3, 360(a5) + ld t4, 368(a5) + ld t5, 376(a5) + ld t6, 384(a5) + ld a6, 392(a5) + ld a7, 400(a5) + ld s0, 768(a5) + ld s4, 896(a5) + ld s1, 784(a5) + ld s5, 912(a5) + ld s2, 800(a5) + ld s6, 928(a5) + ld s3, 816(a5) + ld s7, 944(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 768(a5) + sd s4, 896(a5) + sd s1, 784(a5) + sd s5, 912(a5) + sd s2, 800(a5) + sd s6, 928(a5) + sd s3, 816(a5) + sd s7, 944(a5) + ld s0, 832(a5) + ld s4, 960(a5) + ld s1, 848(a5) + ld s5, 976(a5) + ld s2, 864(a5) + ld s6, 992(a5) + ld s3, 880(a5) + ld s7, 1008(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 832(a5) + sd s4, 960(a5) + sd s1, 848(a5) + sd s5, 976(a5) + sd s2, 864(a5) + sd s6, 992(a5) + sd s3, 880(a5) + sd s7, 1008(a5) + ld s0, 776(a5) + ld s4, 904(a5) + ld s1, 792(a5) + ld s5, 920(a5) + ld s2, 808(a5) + ld s6, 936(a5) + ld s3, 824(a5) + ld s7, 952(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 776(a5) + sd s4, 904(a5) + sd s1, 792(a5) + sd s5, 920(a5) + sd s2, 808(a5) + sd s6, 936(a5) + sd s3, 824(a5) + sd s7, 952(a5) + ld s0, 840(a5) + ld s4, 968(a5) + ld s1, 856(a5) + ld s5, 984(a5) + ld s2, 872(a5) + ld s6, 1000(a5) + ld s3, 888(a5) + ld s7, 1016(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 840(a5) + sd s4, 968(a5) + sd s1, 856(a5) + sd s5, 984(a5) + sd s2, 872(a5) + sd s6, 1000(a5) + sd s3, 888(a5) + sd s7, 1016(a5) + ld s0, 768(a5) + ld s1, 784(a5) + ld s2, 800(a5) + ld s3, 816(a5) + ld s4, 832(a5) + ld s5, 848(a5) + ld s6, 864(a5) + ld s7, 880(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + ld s0, 896(a5) + ld s1, 912(a5) + ld s2, 928(a5) + ld s3, 944(a5) + ld s4, 960(a5) + ld s5, 976(a5) + ld s6, 992(a5) + ld s7, 1008(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 776(a5) + ld s1, 792(a5) + ld s2, 808(a5) + ld s3, 824(a5) + ld s4, 840(a5) + ld s5, 856(a5) + ld s6, 872(a5) + ld s7, 888(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + ld s0, 904(a5) + ld s1, 920(a5) + ld s2, 936(a5) + ld s3, 952(a5) + ld s4, 968(a5) + ld s5, 984(a5) + ld s6, 1000(a5) + ld s7, 1016(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 704(a5) + sd s1, 712(a5) + sd s2, 720(a5) + sd s3, 728(a5) + sd s4, 736(a5) + sd s5, 744(a5) + sd s6, 752(a5) + sd s7, 760(a5) + addi a3, a5, 1024 +29: + ld s0, 576(a5) + ld t0, 640(a5) + xor s0, s0, t0 + ld t0, 704(a5) + xor s0, s0, t0 + ld t0, 0(a3) + xor s0, s0, t0 + ld s1, 584(a5) + ld t0, 648(a5) + xor s1, s1, t0 + ld t0, 712(a5) + xor s1, s1, t0 + ld t0, 8(a3) + xor s1, s1, t0 + ld s2, 592(a5) + ld t0, 656(a5) + xor s2, s2, t0 + ld t0, 720(a5) + xor s2, s2, t0 + ld t0, 16(a3) + xor s2, s2, t0 + ld s3, 600(a5) + ld t0, 664(a5) + xor s3, s3, t0 + ld t0, 728(a5) + xor s3, s3, t0 + ld t0, 24(a3) + xor s3, s3, t0 + ld s4, 608(a5) + ld t0, 672(a5) + xor s4, s4, t0 + ld t0, 736(a5) + xor s4, s4, t0 + ld t0, 32(a3) + xor s4, s4, t0 + ld s5, 616(a5) + ld t0, 680(a5) + xor s5, s5, t0 + ld t0, 744(a5) + xor s5, s5, t0 + ld t0, 40(a3) + xor s5, s5, t0 + ld s6, 624(a5) + ld t0, 688(a5) + xor s6, s6, t0 + ld t0, 752(a5) + xor s6, s6, t0 + ld t0, 48(a3) + xor s6, s6, t0 + ld s7, 632(a5) + ld t0, 696(a5) + xor s7, s7, t0 + ld t0, 760(a5) + xor s7, s7, t0 + ld t0, 56(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 512(a5) + xor t0, t0, t1 + sd t0, 512(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 520(a5) + xor t0, t0, t1 + sd t0, 520(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 528(a5) + xor t0, t0, t1 + sd t0, 528(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 536(a5) + xor t0, t0, t1 + sd t0, 536(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 544(a5) + xor t0, t0, t1 + sd t0, 544(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 552(a5) + xor t0, t0, t1 + sd t0, 552(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 560(a5) + xor t0, t0, t1 + sd t0, 560(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 568(a5) + xor t0, t0, t1 + sd t0, 568(a5) + ld s0, 640(a5) + ld t0, 704(a5) + xor s0, s0, t0 + ld t0, 512(a5) + xor s0, s0, t0 + ld t0, 64(a3) + xor s0, s0, t0 + ld s1, 648(a5) + ld t0, 712(a5) + xor s1, s1, t0 + ld t0, 520(a5) + xor s1, s1, t0 + ld t0, 72(a3) + xor s1, s1, t0 + ld s2, 656(a5) + ld t0, 720(a5) + xor s2, s2, t0 + ld t0, 528(a5) + xor s2, s2, t0 + ld t0, 80(a3) + xor s2, s2, t0 + ld s3, 664(a5) + ld t0, 728(a5) + xor s3, s3, t0 + ld t0, 536(a5) + xor s3, s3, t0 + ld t0, 88(a3) + xor s3, s3, t0 + ld s4, 672(a5) + ld t0, 736(a5) + xor s4, s4, t0 + ld t0, 544(a5) + xor s4, s4, t0 + ld t0, 96(a3) + xor s4, s4, t0 + ld s5, 680(a5) + ld t0, 744(a5) + xor s5, s5, t0 + ld t0, 552(a5) + xor s5, s5, t0 + ld t0, 104(a3) + xor s5, s5, t0 + ld s6, 688(a5) + ld t0, 752(a5) + xor s6, s6, t0 + ld t0, 560(a5) + xor s6, s6, t0 + ld t0, 112(a3) + xor s6, s6, t0 + ld s7, 696(a5) + ld t0, 760(a5) + xor s7, s7, t0 + ld t0, 568(a5) + xor s7, s7, t0 + ld t0, 120(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 576(a5) + xor t0, t0, t1 + sd t0, 576(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 584(a5) + xor t0, t0, t1 + sd t0, 584(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 592(a5) + xor t0, t0, t1 + sd t0, 592(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 600(a5) + xor t0, t0, t1 + sd t0, 600(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 608(a5) + xor t0, t0, t1 + sd t0, 608(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 616(a5) + xor t0, t0, t1 + sd t0, 616(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 624(a5) + xor t0, t0, t1 + sd t0, 624(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 632(a5) + xor t0, t0, t1 + sd t0, 632(a5) + ld s0, 704(a5) + ld t0, 512(a5) + xor s0, s0, t0 + ld t0, 576(a5) + xor s0, s0, t0 + ld t0, 128(a3) + xor s0, s0, t0 + ld s1, 712(a5) + ld t0, 520(a5) + xor s1, s1, t0 + ld t0, 584(a5) + xor s1, s1, t0 + ld t0, 136(a3) + xor s1, s1, t0 + ld s2, 720(a5) + ld t0, 528(a5) + xor s2, s2, t0 + ld t0, 592(a5) + xor s2, s2, t0 + ld t0, 144(a3) + xor s2, s2, t0 + ld s3, 728(a5) + ld t0, 536(a5) + xor s3, s3, t0 + ld t0, 600(a5) + xor s3, s3, t0 + ld t0, 152(a3) + xor s3, s3, t0 + ld s4, 736(a5) + ld t0, 544(a5) + xor s4, s4, t0 + ld t0, 608(a5) + xor s4, s4, t0 + ld t0, 160(a3) + xor s4, s4, t0 + ld s5, 744(a5) + ld t0, 552(a5) + xor s5, s5, t0 + ld t0, 616(a5) + xor s5, s5, t0 + ld t0, 168(a3) + xor s5, s5, t0 + ld s6, 752(a5) + ld t0, 560(a5) + xor s6, s6, t0 + ld t0, 624(a5) + xor s6, s6, t0 + ld t0, 176(a3) + xor s6, s6, t0 + ld s7, 760(a5) + ld t0, 568(a5) + xor s7, s7, t0 + ld t0, 632(a5) + xor s7, s7, t0 + ld t0, 184(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 640(a5) + xor t0, t0, t1 + sd t0, 640(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 648(a5) + xor t0, t0, t1 + sd t0, 648(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 656(a5) + xor t0, t0, t1 + sd t0, 656(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 664(a5) + xor t0, t0, t1 + sd t0, 664(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 672(a5) + xor t0, t0, t1 + sd t0, 672(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 680(a5) + xor t0, t0, t1 + sd t0, 680(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 688(a5) + xor t0, t0, t1 + sd t0, 688(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 696(a5) + xor t0, t0, t1 + sd t0, 696(a5) + ld s0, 512(a5) + ld t0, 576(a5) + xor s0, s0, t0 + ld t0, 640(a5) + xor s0, s0, t0 + ld t0, 192(a3) + xor s0, s0, t0 + ld s1, 520(a5) + ld t0, 584(a5) + xor s1, s1, t0 + ld t0, 648(a5) + xor s1, s1, t0 + ld t0, 200(a3) + xor s1, s1, t0 + ld s2, 528(a5) + ld t0, 592(a5) + xor s2, s2, t0 + ld t0, 656(a5) + xor s2, s2, t0 + ld t0, 208(a3) + xor s2, s2, t0 + ld s3, 536(a5) + ld t0, 600(a5) + xor s3, s3, t0 + ld t0, 664(a5) + xor s3, s3, t0 + ld t0, 216(a3) + xor s3, s3, t0 + ld s4, 544(a5) + ld t0, 608(a5) + xor s4, s4, t0 + ld t0, 672(a5) + xor s4, s4, t0 + ld t0, 224(a3) + xor s4, s4, t0 + ld s5, 552(a5) + ld t0, 616(a5) + xor s5, s5, t0 + ld t0, 680(a5) + xor s5, s5, t0 + ld t0, 232(a3) + xor s5, s5, t0 + ld s6, 560(a5) + ld t0, 624(a5) + xor s6, s6, t0 + ld t0, 688(a5) + xor s6, s6, t0 + ld t0, 240(a3) + xor s6, s6, t0 + ld s7, 568(a5) + ld t0, 632(a5) + xor s7, s7, t0 + ld t0, 696(a5) + xor s7, s7, t0 + ld t0, 248(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 704(a5) + xor t0, t0, t1 + sd t0, 704(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 712(a5) + xor t0, t0, t1 + sd t0, 712(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 720(a5) + xor t0, t0, t1 + sd t0, 720(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 728(a5) + xor t0, t0, t1 + sd t0, 728(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 736(a5) + xor t0, t0, t1 + sd t0, 736(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 744(a5) + xor t0, t0, t1 + sd t0, 744(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 752(a5) + xor t0, t0, t1 + sd t0, 752(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 760(a5) + xor t0, t0, t1 + sd t0, 760(a5) + addi a3, a3, 256 + sub t0, a3, a0 + bnez t0, 29b + ld t3, 360(a5) + ld t4, 368(a5) + ld t5, 376(a5) + ld t6, 384(a5) + ld a6, 392(a5) + ld a7, 400(a5) + ld s0, 704(a5) + ld s1, 712(a5) + ld s2, 720(a5) + ld s3, 728(a5) + ld s4, 736(a5) + ld s5, 744(a5) + ld s6, 752(a5) + ld s7, 760(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 768(a5) + sd s1, 784(a5) + sd s2, 800(a5) + sd s3, 816(a5) + sd s4, 832(a5) + sd s5, 848(a5) + sd s6, 864(a5) + sd s7, 880(a5) + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 896(a5) + sd s1, 912(a5) + sd s2, 928(a5) + sd s3, 944(a5) + sd s4, 960(a5) + sd s5, 976(a5) + sd s6, 992(a5) + sd s7, 1008(a5) + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 776(a5) + sd s1, 792(a5) + sd s2, 808(a5) + sd s3, 824(a5) + sd s4, 840(a5) + sd s5, 856(a5) + sd s6, 872(a5) + sd s7, 888(a5) + ld s0, 512(a5) + ld s1, 520(a5) + ld s2, 528(a5) + ld s3, 536(a5) + ld s4, 544(a5) + ld s5, 552(a5) + ld s6, 560(a5) + ld s7, 568(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 904(a5) + sd s1, 920(a5) + sd s2, 936(a5) + sd s3, 952(a5) + sd s4, 968(a5) + sd s5, 984(a5) + sd s6, 1000(a5) + sd s7, 1016(a5) + ld s0, 768(a5) + ld s4, 896(a5) + ld s1, 784(a5) + ld s5, 912(a5) + ld s2, 800(a5) + ld s6, 928(a5) + ld s3, 816(a5) + ld s7, 944(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 768(a5) + sd s4, 896(a5) + sd s1, 784(a5) + sd s5, 912(a5) + sd s2, 800(a5) + sd s6, 928(a5) + sd s3, 816(a5) + sd s7, 944(a5) + ld s0, 832(a5) + ld s4, 960(a5) + ld s1, 848(a5) + ld s5, 976(a5) + ld s2, 864(a5) + ld s6, 992(a5) + ld s3, 880(a5) + ld s7, 1008(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 832(a5) + sd s4, 960(a5) + sd s1, 848(a5) + sd s5, 976(a5) + sd s2, 864(a5) + sd s6, 992(a5) + sd s3, 880(a5) + sd s7, 1008(a5) + ld s0, 776(a5) + ld s4, 904(a5) + ld s1, 792(a5) + ld s5, 920(a5) + ld s2, 808(a5) + ld s6, 936(a5) + ld s3, 824(a5) + ld s7, 952(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 776(a5) + sd s4, 904(a5) + sd s1, 792(a5) + sd s5, 920(a5) + sd s2, 808(a5) + sd s6, 936(a5) + sd s3, 824(a5) + sd s7, 952(a5) + ld s0, 840(a5) + ld s4, 968(a5) + ld s1, 856(a5) + ld s5, 984(a5) + ld s2, 872(a5) + ld s6, 1000(a5) + ld s3, 888(a5) + ld s7, 1016(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 840(a5) + sd s4, 968(a5) + sd s1, 856(a5) + sd s5, 984(a5) + sd s2, 872(a5) + sd s6, 1000(a5) + sd s3, 888(a5) + sd s7, 1016(a5) + addi t0, a5, 2040 + addi t0, t0, 1032 + ld s0, 0(t0) + ld s1, 8(t0) + ld s2, 16(t0) + ld s3, 24(t0) + ld s4, 32(t0) + ld s5, 40(t0) + ld s6, 48(t0) + ld s7, 56(t0) + ld s8, 64(t0) + ld s9, 72(t0) + ld s10, 80(t0) + ld s11, 88(t0) + addi s1, a1, 0 + addi s2, a2, 0 + addi s3, a4, 0 + addi s4, a5, -56 + ld a0, 48(s4) + addi t0, zero, 16 + bltu s3, t0, 210f + lwu t0, 824(s4) + sw t0, 32(s4) + lwu t0, 828(s4) + sw t0, 36(s4) + lwu t0, 832(s4) + sw t0, 40(s4) + lwu t0, 836(s4) + sw t0, 44(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 824(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 828(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lbu t0, 8(s2) + lbu t2, 9(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 10(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 11(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 832(s4) + xor t0, t0, t1 + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lbu t0, 12(s2) + lbu t2, 13(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 14(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 15(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 836(s4) + xor t0, t0, t1 + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 211f +210: + lwu t0, 824(s4) + sw t0, 32(s4) + lwu t0, 828(s4) + sw t0, 36(s4) + lwu t0, 832(s4) + sw t0, 40(s4) + lwu t0, 836(s4) + sw t0, 44(s4) + addi t2, s4, 824 +212: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 212b +211: + bnez s3, 28b + j 27f +26: +27: + j 25f +24: + beqz s3, 213f +215: + lwu t0, 32(s4) + sw t0, 824(s4) + lwu t0, 36(s4) + sw t0, 828(s4) + lwu t0, 40(s4) + sw t0, 832(s4) + lwu t0, 44(s4) + sw t0, 836(s4) + addi a5, s4, 56 + addi t0, a5, 2040 + addi t0, t0, 1032 + sd s0, 0(t0) + sd s1, 8(t0) + sd s2, 16(t0) + sd s3, 24(t0) + sd s4, 32(t0) + sd s5, 40(t0) + sd s6, 48(t0) + sd s7, 56(t0) + sd s8, 64(t0) + sd s9, 72(t0) + sd s10, 80(t0) + sd s11, 88(t0) + addi a1, s1, 0 + addi a2, s2, 0 + addi a4, s3, 0 + addi a0, a5, 2040 + addi a0, a0, 1032 + ld t3, 360(a5) + ld t4, 368(a5) + ld t5, 376(a5) + ld t6, 384(a5) + ld a6, 392(a5) + ld a7, 400(a5) + ld s0, 768(a5) + ld s4, 896(a5) + ld s1, 784(a5) + ld s5, 912(a5) + ld s2, 800(a5) + ld s6, 928(a5) + ld s3, 816(a5) + ld s7, 944(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 768(a5) + sd s4, 896(a5) + sd s1, 784(a5) + sd s5, 912(a5) + sd s2, 800(a5) + sd s6, 928(a5) + sd s3, 816(a5) + sd s7, 944(a5) + ld s0, 832(a5) + ld s4, 960(a5) + ld s1, 848(a5) + ld s5, 976(a5) + ld s2, 864(a5) + ld s6, 992(a5) + ld s3, 880(a5) + ld s7, 1008(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 832(a5) + sd s4, 960(a5) + sd s1, 848(a5) + sd s5, 976(a5) + sd s2, 864(a5) + sd s6, 992(a5) + sd s3, 880(a5) + sd s7, 1008(a5) + ld s0, 776(a5) + ld s4, 904(a5) + ld s1, 792(a5) + ld s5, 920(a5) + ld s2, 808(a5) + ld s6, 936(a5) + ld s3, 824(a5) + ld s7, 952(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 776(a5) + sd s4, 904(a5) + sd s1, 792(a5) + sd s5, 920(a5) + sd s2, 808(a5) + sd s6, 936(a5) + sd s3, 824(a5) + sd s7, 952(a5) + ld s0, 840(a5) + ld s4, 968(a5) + ld s1, 856(a5) + ld s5, 984(a5) + ld s2, 872(a5) + ld s6, 1000(a5) + ld s3, 888(a5) + ld s7, 1016(a5) + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + sd s0, 840(a5) + sd s4, 968(a5) + sd s1, 856(a5) + sd s5, 984(a5) + sd s2, 872(a5) + sd s6, 1000(a5) + sd s3, 888(a5) + sd s7, 1016(a5) + ld s0, 768(a5) + ld s1, 784(a5) + ld s2, 800(a5) + ld s3, 816(a5) + ld s4, 832(a5) + ld s5, 848(a5) + ld s6, 864(a5) + ld s7, 880(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 512(a5) + sd s1, 520(a5) + sd s2, 528(a5) + sd s3, 536(a5) + sd s4, 544(a5) + sd s5, 552(a5) + sd s6, 560(a5) + sd s7, 568(a5) + ld s0, 896(a5) + ld s1, 912(a5) + ld s2, 928(a5) + ld s3, 944(a5) + ld s4, 960(a5) + ld s5, 976(a5) + ld s6, 992(a5) + ld s7, 1008(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 576(a5) + sd s1, 584(a5) + sd s2, 592(a5) + sd s3, 600(a5) + sd s4, 608(a5) + sd s5, 616(a5) + sd s6, 624(a5) + sd s7, 632(a5) + ld s0, 776(a5) + ld s1, 792(a5) + ld s2, 808(a5) + ld s3, 824(a5) + ld s4, 840(a5) + ld s5, 856(a5) + ld s6, 872(a5) + ld s7, 888(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 640(a5) + sd s1, 648(a5) + sd s2, 656(a5) + sd s3, 664(a5) + sd s4, 672(a5) + sd s5, 680(a5) + sd s6, 688(a5) + sd s7, 696(a5) + ld s0, 904(a5) + ld s1, 920(a5) + ld s2, 936(a5) + ld s3, 952(a5) + ld s4, 968(a5) + ld s5, 984(a5) + ld s6, 1000(a5) + ld s7, 1016(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 704(a5) + sd s1, 712(a5) + sd s2, 720(a5) + sd s3, 728(a5) + sd s4, 736(a5) + sd s5, 744(a5) + sd s6, 752(a5) + sd s7, 760(a5) + addi a3, a5, 1024 +216: + ld s0, 576(a5) + ld t0, 640(a5) + xor s0, s0, t0 + ld t0, 704(a5) + xor s0, s0, t0 + ld t0, 0(a3) + xor s0, s0, t0 + ld s1, 584(a5) + ld t0, 648(a5) + xor s1, s1, t0 + ld t0, 712(a5) + xor s1, s1, t0 + ld t0, 8(a3) + xor s1, s1, t0 + ld s2, 592(a5) + ld t0, 656(a5) + xor s2, s2, t0 + ld t0, 720(a5) + xor s2, s2, t0 + ld t0, 16(a3) + xor s2, s2, t0 + ld s3, 600(a5) + ld t0, 664(a5) + xor s3, s3, t0 + ld t0, 728(a5) + xor s3, s3, t0 + ld t0, 24(a3) + xor s3, s3, t0 + ld s4, 608(a5) + ld t0, 672(a5) + xor s4, s4, t0 + ld t0, 736(a5) + xor s4, s4, t0 + ld t0, 32(a3) + xor s4, s4, t0 + ld s5, 616(a5) + ld t0, 680(a5) + xor s5, s5, t0 + ld t0, 744(a5) + xor s5, s5, t0 + ld t0, 40(a3) + xor s5, s5, t0 + ld s6, 624(a5) + ld t0, 688(a5) + xor s6, s6, t0 + ld t0, 752(a5) + xor s6, s6, t0 + ld t0, 48(a3) + xor s6, s6, t0 + ld s7, 632(a5) + ld t0, 696(a5) + xor s7, s7, t0 + ld t0, 760(a5) + xor s7, s7, t0 + ld t0, 56(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 512(a5) + xor t0, t0, t1 + sd t0, 512(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 520(a5) + xor t0, t0, t1 + sd t0, 520(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 528(a5) + xor t0, t0, t1 + sd t0, 528(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 536(a5) + xor t0, t0, t1 + sd t0, 536(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 544(a5) + xor t0, t0, t1 + sd t0, 544(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 552(a5) + xor t0, t0, t1 + sd t0, 552(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 560(a5) + xor t0, t0, t1 + sd t0, 560(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 568(a5) + xor t0, t0, t1 + sd t0, 568(a5) + ld s0, 640(a5) + ld t0, 704(a5) + xor s0, s0, t0 + ld t0, 512(a5) + xor s0, s0, t0 + ld t0, 64(a3) + xor s0, s0, t0 + ld s1, 648(a5) + ld t0, 712(a5) + xor s1, s1, t0 + ld t0, 520(a5) + xor s1, s1, t0 + ld t0, 72(a3) + xor s1, s1, t0 + ld s2, 656(a5) + ld t0, 720(a5) + xor s2, s2, t0 + ld t0, 528(a5) + xor s2, s2, t0 + ld t0, 80(a3) + xor s2, s2, t0 + ld s3, 664(a5) + ld t0, 728(a5) + xor s3, s3, t0 + ld t0, 536(a5) + xor s3, s3, t0 + ld t0, 88(a3) + xor s3, s3, t0 + ld s4, 672(a5) + ld t0, 736(a5) + xor s4, s4, t0 + ld t0, 544(a5) + xor s4, s4, t0 + ld t0, 96(a3) + xor s4, s4, t0 + ld s5, 680(a5) + ld t0, 744(a5) + xor s5, s5, t0 + ld t0, 552(a5) + xor s5, s5, t0 + ld t0, 104(a3) + xor s5, s5, t0 + ld s6, 688(a5) + ld t0, 752(a5) + xor s6, s6, t0 + ld t0, 560(a5) + xor s6, s6, t0 + ld t0, 112(a3) + xor s6, s6, t0 + ld s7, 696(a5) + ld t0, 760(a5) + xor s7, s7, t0 + ld t0, 568(a5) + xor s7, s7, t0 + ld t0, 120(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 576(a5) + xor t0, t0, t1 + sd t0, 576(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 584(a5) + xor t0, t0, t1 + sd t0, 584(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 592(a5) + xor t0, t0, t1 + sd t0, 592(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 600(a5) + xor t0, t0, t1 + sd t0, 600(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 608(a5) + xor t0, t0, t1 + sd t0, 608(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 616(a5) + xor t0, t0, t1 + sd t0, 616(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 624(a5) + xor t0, t0, t1 + sd t0, 624(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 632(a5) + xor t0, t0, t1 + sd t0, 632(a5) + ld s0, 704(a5) + ld t0, 512(a5) + xor s0, s0, t0 + ld t0, 576(a5) + xor s0, s0, t0 + ld t0, 128(a3) + xor s0, s0, t0 + ld s1, 712(a5) + ld t0, 520(a5) + xor s1, s1, t0 + ld t0, 584(a5) + xor s1, s1, t0 + ld t0, 136(a3) + xor s1, s1, t0 + ld s2, 720(a5) + ld t0, 528(a5) + xor s2, s2, t0 + ld t0, 592(a5) + xor s2, s2, t0 + ld t0, 144(a3) + xor s2, s2, t0 + ld s3, 728(a5) + ld t0, 536(a5) + xor s3, s3, t0 + ld t0, 600(a5) + xor s3, s3, t0 + ld t0, 152(a3) + xor s3, s3, t0 + ld s4, 736(a5) + ld t0, 544(a5) + xor s4, s4, t0 + ld t0, 608(a5) + xor s4, s4, t0 + ld t0, 160(a3) + xor s4, s4, t0 + ld s5, 744(a5) + ld t0, 552(a5) + xor s5, s5, t0 + ld t0, 616(a5) + xor s5, s5, t0 + ld t0, 168(a3) + xor s5, s5, t0 + ld s6, 752(a5) + ld t0, 560(a5) + xor s6, s6, t0 + ld t0, 624(a5) + xor s6, s6, t0 + ld t0, 176(a3) + xor s6, s6, t0 + ld s7, 760(a5) + ld t0, 568(a5) + xor s7, s7, t0 + ld t0, 632(a5) + xor s7, s7, t0 + ld t0, 184(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 640(a5) + xor t0, t0, t1 + sd t0, 640(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 648(a5) + xor t0, t0, t1 + sd t0, 648(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 656(a5) + xor t0, t0, t1 + sd t0, 656(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 664(a5) + xor t0, t0, t1 + sd t0, 664(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 672(a5) + xor t0, t0, t1 + sd t0, 672(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 680(a5) + xor t0, t0, t1 + sd t0, 680(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 688(a5) + xor t0, t0, t1 + sd t0, 688(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 696(a5) + xor t0, t0, t1 + sd t0, 696(a5) + ld s0, 512(a5) + ld t0, 576(a5) + xor s0, s0, t0 + ld t0, 640(a5) + xor s0, s0, t0 + ld t0, 192(a3) + xor s0, s0, t0 + ld s1, 520(a5) + ld t0, 584(a5) + xor s1, s1, t0 + ld t0, 648(a5) + xor s1, s1, t0 + ld t0, 200(a3) + xor s1, s1, t0 + ld s2, 528(a5) + ld t0, 592(a5) + xor s2, s2, t0 + ld t0, 656(a5) + xor s2, s2, t0 + ld t0, 208(a3) + xor s2, s2, t0 + ld s3, 536(a5) + ld t0, 600(a5) + xor s3, s3, t0 + ld t0, 664(a5) + xor s3, s3, t0 + ld t0, 216(a3) + xor s3, s3, t0 + ld s4, 544(a5) + ld t0, 608(a5) + xor s4, s4, t0 + ld t0, 672(a5) + xor s4, s4, t0 + ld t0, 224(a3) + xor s4, s4, t0 + ld s5, 552(a5) + ld t0, 616(a5) + xor s5, s5, t0 + ld t0, 680(a5) + xor s5, s5, t0 + ld t0, 232(a3) + xor s5, s5, t0 + ld s6, 560(a5) + ld t0, 624(a5) + xor s6, s6, t0 + ld t0, 688(a5) + xor s6, s6, t0 + ld t0, 240(a3) + xor s6, s6, t0 + ld s7, 568(a5) + ld t0, 632(a5) + xor s7, s7, t0 + ld t0, 696(a5) + xor s7, s7, t0 + ld t0, 248(a3) + xor s7, s7, t0 + xor t0, s4, s2 + xor t1, s3, s0 + xor t2, s1, t1 + xor t3, s7, t0 + xor t4, s5, t2 + xor t5, s6, s2 + xor s4, s7, s4 + xor t6, s5, t3 + xor a6, s6, t6 + xor a7, s7, s3 + xor s8, s6, s4 + xor s9, s5, t0 + xor t6, s1, t6 + xori t6, t6, -1 + xor s10, t1, t3 + xor s11, s0, s8 + xor s8, t4, s8 + sd s8, 0(a5) + xor s8, s1, t5 + xor s6, s6, s10 + xor s0, s0, t3 + xori s0, s0, -1 + xor s10, s1, a7 + xor s3, s3, s9 + xori s3, s3, -1 + xor s4, t2, s4 + sd t3, 8(a5) + xor t3, t0, t4 + sd t3, 16(a5) + xor t3, t4, t5 + xor s2, s7, s2 + xori s2, s2, -1 + xor s11, s1, s11 + xori s11, s11, -1 + xor t1, t1, s9 + xor s5, s5, a7 + xori s5, s5, -1 + xor a7, s1, a6 + xor t0, t0, t2 + xori t0, t0, -1 + xor s7, s7, t2 + xori s7, s7, -1 + and t2, a7, t6 + and s9, t4, s3 + xor s9, s9, t2 + sd t4, 24(a5) + and t4, s6, s10 + xor t4, t4, t2 + and t2, s1, t1 + sd s1, 32(a5) + and s1, t5, s5 + xor s1, s1, t2 + sd t5, 40(a5) + and t5, s8, s0 + xor t5, t5, t2 + and t2, s4, t0 + sd s4, 48(a5) + and s4, a6, s7 + xor s4, s4, t2 + sd a6, 56(a5) + ld a6, 8(a5) + sd s8, 64(a5) + and s8, t3, a6 + xor s8, s8, t2 + xor s9, s9, s4 + xor t4, t4, s8 + xor s1, s1, s4 + xor t5, t5, s8 + xor s9, s9, s2 + ld s2, 0(a5) + xor t4, t4, s2 + ld s2, 16(a5) + xor s1, s1, s2 + xor t5, t5, s11 + xor s11, s9, t4 + and s9, s9, s1 + xor s2, t5, s9 + and s8, s11, s2 + xor s8, s8, t4 + xor s4, s1, t5 + xor t4, t4, s9 + and t4, t4, s4 + xor t4, t4, t5 + xor s1, s1, t4 + xor s4, s2, t4 + and t5, t5, s4 + xor s1, t5, s1 + xor s2, s2, t5 + and s2, s8, s2 + xor s11, s11, s2 + xor s2, s11, s1 + xor t5, s8, t4 + xor s4, s8, s11 + xor s9, t4, s1 + xor t2, t5, s2 + and t6, s9, t6 + and s3, s1, s3 + and s10, t4, s10 + and t1, s4, t1 + and s5, s11, s5 + and s0, s8, s0 + and t0, t5, t0 + and s7, t2, s7 + and a6, s2, a6 + and s9, s9, a7 + ld a7, 24(a5) + and s1, s1, a7 + and t4, t4, s6 + ld s6, 32(a5) + and s4, s4, s6 + ld s6, 40(a5) + and s11, s11, s6 + ld s6, 64(a5) + and s8, s8, s6 + ld s6, 48(a5) + and t5, t5, s6 + ld s6, 56(a5) + and t2, t2, s6 + and s2, s2, t3 + xor s9, s9, t5 + xor t0, t0, s1 + xor s0, t6, s0 + xor t3, s11, t0 + xor s8, s8, t3 + xor a6, s3, a6 + xor t3, s7, s8 + xor s2, s2, s9 + xor s6, s5, s0 + xor a7, t3, s2 + sd s5, 56(a5) + xor s5, t4, s6 + sd a7, 48(a5) + xor a7, t2, a6 + xor s9, s9, a7 + xor s0, t1, s0 + xor s0, s9, s0 + xor t4, t4, s2 + xor s11, s11, t2 + xor s4, s4, t5 + xor t0, t0, s6 + xor a6, a6, s5 + xor s8, s8, a6 + xori s8, s8, -1 + xor s1, s1, s0 + xor s10, s10, t3 + xor s0, s7, s1 + xori s0, s0, -1 + xor s7, s11, s4 + xori s7, s7, -1 + xor t6, t6, s3 + ld s3, 48(a5) + xor t1, t1, s3 + xor s3, s3, t6 + xor s6, s5, s10 + xori s6, s6, -1 + ld s10, 56(a5) + xor s2, s10, t1 + xor s4, s9, t0 + xori s4, s4, -1 + addi s5, s3, 0 + addi s3, t4, 0 + addi s1, s8, 0 + srli a7, s6, 16 + slli t2, s6, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s0 + srli a7, s0, 48 + slli t1, s0, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 704(a5) + xor t0, t0, t1 + sd t0, 704(a5) + srli a7, s7, 16 + slli t2, s7, 48 + xor t2, t2, a7 + srli a7, t2, 16 + slli t1, t2, 48 + xor t1, t1, a7 + xor t0, t2, t1 + srli a7, t2, 32 + slli t1, t2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s1 + srli a7, s1, 48 + slli t1, s1, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 712(a5) + xor t0, t0, t1 + sd t0, 712(a5) + srli a7, s0, 16 + slli t1, s0, 48 + xor t1, t1, a7 + xor t0, s0, t1 + srli a7, s0, 32 + slli t1, s0, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s2 + srli a7, s2, 48 + slli t1, s2, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 720(a5) + xor t0, t0, t1 + sd t0, 720(a5) + srli a7, s1, 16 + slli t1, s1, 48 + xor t1, t1, a7 + xor t0, s1, t1 + srli a7, s1, 32 + slli t1, s1, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s3 + srli a7, s3, 48 + slli t1, s3, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 728(a5) + xor t0, t0, t1 + sd t0, 728(a5) + srli a7, s2, 16 + slli t1, s2, 48 + xor t1, t1, a7 + xor t0, s2, t1 + srli a7, s2, 32 + slli t1, s2, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s4 + srli a7, s4, 48 + slli t1, s4, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 736(a5) + xor t0, t0, t1 + sd t0, 736(a5) + srli a7, s3, 16 + slli t1, s3, 48 + xor t1, t1, a7 + xor t0, s3, t1 + srli a7, s3, 32 + slli t1, s3, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s5 + srli a7, s5, 48 + slli t1, s5, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 744(a5) + xor t0, t0, t1 + sd t0, 744(a5) + srli a7, s4, 16 + slli t1, s4, 48 + xor t1, t1, a7 + xor t0, s4, t1 + srli a7, s4, 32 + slli t1, s4, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s6 + srli a7, s6, 48 + slli t1, s6, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 752(a5) + xor t0, t0, t1 + sd t0, 752(a5) + srli a7, s5, 16 + slli t1, s5, 48 + xor t1, t1, a7 + xor t0, s5, t1 + srli a7, s5, 32 + slli t1, s5, 32 + xor t1, t1, a7 + xor t0, t0, t1 + xor t0, t0, s7 + srli a7, s7, 48 + slli t1, s7, 16 + xor t1, t1, a7 + xor t0, t0, t1 + ld t1, 760(a5) + xor t0, t0, t1 + sd t0, 760(a5) + addi a3, a3, 256 + sub t0, a3, a0 + bnez t0, 216b + ld t3, 360(a5) + ld t4, 368(a5) + ld t5, 376(a5) + ld t6, 384(a5) + ld a6, 392(a5) + ld a7, 400(a5) + ld s0, 704(a5) + ld s1, 712(a5) + ld s2, 720(a5) + ld s3, 728(a5) + ld s4, 736(a5) + ld s5, 744(a5) + ld s6, 752(a5) + ld s7, 760(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 768(a5) + sd s1, 784(a5) + sd s2, 800(a5) + sd s3, 816(a5) + sd s4, 832(a5) + sd s5, 848(a5) + sd s6, 864(a5) + sd s7, 880(a5) + ld s0, 640(a5) + ld s1, 648(a5) + ld s2, 656(a5) + ld s3, 664(a5) + ld s4, 672(a5) + ld s5, 680(a5) + ld s6, 688(a5) + ld s7, 696(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 896(a5) + sd s1, 912(a5) + sd s2, 928(a5) + sd s3, 944(a5) + sd s4, 960(a5) + sd s5, 976(a5) + sd s6, 992(a5) + sd s7, 1008(a5) + ld s0, 576(a5) + ld s1, 584(a5) + ld s2, 592(a5) + ld s3, 600(a5) + ld s4, 608(a5) + ld s5, 616(a5) + ld s6, 624(a5) + ld s7, 632(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 776(a5) + sd s1, 792(a5) + sd s2, 808(a5) + sd s3, 824(a5) + sd s4, 840(a5) + sd s5, 856(a5) + sd s6, 872(a5) + sd s7, 888(a5) + ld s0, 512(a5) + ld s1, 520(a5) + ld s2, 528(a5) + ld s3, 536(a5) + ld s4, 544(a5) + ld s5, 552(a5) + ld s6, 560(a5) + ld s7, 568(a5) + srli t0, s0, 1 + xor t0, t0, s1 + and t0, t0, t6 + xor s1, s1, t0 + slli t0, t0, 1 + xor s0, s0, t0 + srli t0, s2, 1 + xor t0, t0, s3 + and t0, t0, t6 + xor s3, s3, t0 + slli t0, t0, 1 + xor s2, s2, t0 + srli t0, s4, 1 + xor t0, t0, s5 + and t0, t0, t6 + xor s5, s5, t0 + slli t0, t0, 1 + xor s4, s4, t0 + srli t0, s6, 1 + xor t0, t0, s7 + and t0, t0, t6 + xor s7, s7, t0 + slli t0, t0, 1 + xor s6, s6, t0 + srli t0, s0, 2 + xor t0, t0, s2 + and t0, t0, a6 + xor s2, s2, t0 + slli t0, t0, 2 + xor s0, s0, t0 + srli t0, s1, 2 + xor t0, t0, s3 + and t0, t0, a6 + xor s3, s3, t0 + slli t0, t0, 2 + xor s1, s1, t0 + srli t0, s4, 2 + xor t0, t0, s6 + and t0, t0, a6 + xor s6, s6, t0 + slli t0, t0, 2 + xor s4, s4, t0 + srli t0, s5, 2 + xor t0, t0, s7 + and t0, t0, a6 + xor s7, s7, t0 + slli t0, t0, 2 + xor s5, s5, t0 + srli t0, s0, 4 + xor t0, t0, s4 + and t0, t0, a7 + xor s4, s4, t0 + slli t0, t0, 4 + xor s0, s0, t0 + srli t0, s1, 4 + xor t0, t0, s5 + and t0, t0, a7 + xor s5, s5, t0 + slli t0, t0, 4 + xor s1, s1, t0 + srli t0, s2, 4 + xor t0, t0, s6 + and t0, t0, a7 + xor s6, s6, t0 + slli t0, t0, 4 + xor s2, s2, t0 + srli t0, s3, 4 + xor t0, t0, s7 + and t0, t0, a7 + xor s7, s7, t0 + slli t0, t0, 4 + xor s3, s3, t0 + sd s0, 904(a5) + sd s1, 920(a5) + sd s2, 936(a5) + sd s3, 952(a5) + sd s4, 968(a5) + sd s5, 984(a5) + sd s6, 1000(a5) + sd s7, 1016(a5) + ld s0, 768(a5) + ld s4, 896(a5) + ld s1, 784(a5) + ld s5, 912(a5) + ld s2, 800(a5) + ld s6, 928(a5) + ld s3, 816(a5) + ld s7, 944(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 768(a5) + sd s4, 896(a5) + sd s1, 784(a5) + sd s5, 912(a5) + sd s2, 800(a5) + sd s6, 928(a5) + sd s3, 816(a5) + sd s7, 944(a5) + ld s0, 832(a5) + ld s4, 960(a5) + ld s1, 848(a5) + ld s5, 976(a5) + ld s2, 864(a5) + ld s6, 992(a5) + ld s3, 880(a5) + ld s7, 1008(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 832(a5) + sd s4, 960(a5) + sd s1, 848(a5) + sd s5, 976(a5) + sd s2, 864(a5) + sd s6, 992(a5) + sd s3, 880(a5) + sd s7, 1008(a5) + ld s0, 776(a5) + ld s4, 904(a5) + ld s1, 792(a5) + ld s5, 920(a5) + ld s2, 808(a5) + ld s6, 936(a5) + ld s3, 824(a5) + ld s7, 952(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 776(a5) + sd s4, 904(a5) + sd s1, 792(a5) + sd s5, 920(a5) + sd s2, 808(a5) + sd s6, 936(a5) + sd s3, 824(a5) + sd s7, 952(a5) + ld s0, 840(a5) + ld s4, 968(a5) + ld s1, 856(a5) + ld s5, 984(a5) + ld s2, 872(a5) + ld s6, 1000(a5) + ld s3, 888(a5) + ld s7, 1016(a5) + srli t0, s0, 8 + xor t0, t0, s4 + and t0, t0, t5 + xor s4, s4, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s5 + and t0, t0, t5 + xor s5, s5, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s6 + and t0, t0, t5 + xor s6, s6, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s7 + and t0, t0, t5 + xor s7, s7, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s0, 8 + xor t0, t0, s0 + and t0, t0, t4 + xor s0, s0, t0 + slli t0, t0, 8 + xor s0, s0, t0 + srli t0, s1, 8 + xor t0, t0, s1 + and t0, t0, t4 + xor s1, s1, t0 + slli t0, t0, 8 + xor s1, s1, t0 + srli t0, s2, 8 + xor t0, t0, s2 + and t0, t0, t4 + xor s2, s2, t0 + slli t0, t0, 8 + xor s2, s2, t0 + srli t0, s3, 8 + xor t0, t0, s3 + and t0, t0, t4 + xor s3, s3, t0 + slli t0, t0, 8 + xor s3, s3, t0 + srli t0, s4, 8 + xor t0, t0, s4 + and t0, t0, t4 + xor s4, s4, t0 + slli t0, t0, 8 + xor s4, s4, t0 + srli t0, s5, 8 + xor t0, t0, s5 + and t0, t0, t4 + xor s5, s5, t0 + slli t0, t0, 8 + xor s5, s5, t0 + srli t0, s6, 8 + xor t0, t0, s6 + and t0, t0, t4 + xor s6, s6, t0 + slli t0, t0, 8 + xor s6, s6, t0 + srli t0, s7, 8 + xor t0, t0, s7 + and t0, t0, t4 + xor s7, s7, t0 + slli t0, t0, 8 + xor s7, s7, t0 + srli t0, s0, 16 + xor t0, t0, s0 + and t0, t0, t3 + xor s0, s0, t0 + slli t0, t0, 16 + xor s0, s0, t0 + srli t0, s1, 16 + xor t0, t0, s1 + and t0, t0, t3 + xor s1, s1, t0 + slli t0, t0, 16 + xor s1, s1, t0 + srli t0, s2, 16 + xor t0, t0, s2 + and t0, t0, t3 + xor s2, s2, t0 + slli t0, t0, 16 + xor s2, s2, t0 + srli t0, s3, 16 + xor t0, t0, s3 + and t0, t0, t3 + xor s3, s3, t0 + slli t0, t0, 16 + xor s3, s3, t0 + srli t0, s4, 16 + xor t0, t0, s4 + and t0, t0, t3 + xor s4, s4, t0 + slli t0, t0, 16 + xor s4, s4, t0 + srli t0, s5, 16 + xor t0, t0, s5 + and t0, t0, t3 + xor s5, s5, t0 + slli t0, t0, 16 + xor s5, s5, t0 + srli t0, s6, 16 + xor t0, t0, s6 + and t0, t0, t3 + xor s6, s6, t0 + slli t0, t0, 16 + xor s6, s6, t0 + srli t0, s7, 16 + xor t0, t0, s7 + and t0, t0, t3 + xor s7, s7, t0 + slli t0, t0, 16 + xor s7, s7, t0 + sd s0, 840(a5) + sd s4, 968(a5) + sd s1, 856(a5) + sd s5, 984(a5) + sd s2, 872(a5) + sd s6, 1000(a5) + sd s3, 888(a5) + sd s7, 1016(a5) + addi t0, a5, 2040 + addi t0, t0, 1032 + ld s0, 0(t0) + ld s1, 8(t0) + ld s2, 16(t0) + ld s3, 24(t0) + ld s4, 32(t0) + ld s5, 40(t0) + ld s6, 48(t0) + ld s7, 56(t0) + ld s8, 64(t0) + ld s9, 72(t0) + ld s10, 80(t0) + ld s11, 88(t0) + addi s1, a1, 0 + addi s2, a2, 0 + addi s3, a4, 0 + addi s4, a5, -56 + ld a0, 48(s4) + addi t0, zero, 16 + bltu s3, t0, 217f + lwu t0, 824(s4) + sw t0, 32(s4) + lwu t0, 828(s4) + sw t0, 36(s4) + lwu t0, 832(s4) + sw t0, 40(s4) + lwu t0, 836(s4) + sw t0, 44(s4) + lwu t0, 0(s2) + lwu t1, 824(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 828(s4) + xor t0, t0, t1 + sw t0, 4(s2) + lwu t0, 8(s2) + lwu t1, 832(s4) + xor t0, t0, t1 + sw t0, 8(s2) + lwu t0, 12(s2) + lwu t1, 836(s4) + xor t0, t0, t1 + sw t0, 12(s2) + addi s2, s2, 16 + addi s3, s3, -16 + j 218f +217: + lwu t0, 824(s4) + sw t0, 32(s4) + lwu t0, 828(s4) + sw t0, 36(s4) + lwu t0, 832(s4) + sw t0, 40(s4) + lwu t0, 836(s4) + sw t0, 44(s4) + addi t2, s4, 824 +219: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 219b +218: + bnez s3, 215b + j 214f +213: +214: +25: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + lwu t0, 40(s4) + sb t0, 8(s2) + srli t2, t0, 8 + sb t2, 9(s2) + srli t2, t0, 16 + sb t2, 10(s2) + srli t2, t0, 24 + sb t2, 11(s2) + lwu t0, 44(s4) + sb t0, 12(s2) + srli t2, t0, 8 + sb t2, 13(s2) + srli t2, t0, 16 + sb t2, 14(s2) + srli t2, t0, 24 + sb t2, 15(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 404 +220: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 220b + addi sp, sp, 1200 + addi sp, sp, 2032 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/assembly/triple_des_ofb.s b/crates/verified-garbage-asm-riscv64/assembly/triple_des_ofb.s index 85ce71b976d..7e498bf1a0b 100644 --- a/crates/verified-garbage-asm-riscv64/assembly/triple_des_ofb.s +++ b/crates/verified-garbage-asm-riscv64/assembly/triple_des_ofb.s @@ -2690,3 +2690,2728 @@ vg_triple_des_ofb: addi sp, sp, 944 ret .option pop + +vg_triple_des_ofb_final: + .option push + .option arch, +m, +c + addi sp, sp, -944 + addi t0, sp, 0 + sd s1, 0(t0) + sd s2, 8(t0) + sd s3, 16(t0) + sd s4, 24(t0) + addi s4, t0, 0 + addi s1, a1, 0 + addi s2, a1, 0 + addi s3, a3, 0 + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 32(s4) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + sw t0, 36(s4) + addi s2, a2, 0 + addi t0, s4, 560 + addi t2, a0, 0 + addi t4, zero, 384 +20: + lbu t1, 0(t2) + sb t1, 0(t0) + addi t2, t2, 1 + addi t0, t0, 1 + addi t4, t4, -1 + bnez t4, 20b + andi t0, s2, 3 + beqz t0, 21f + beqz s3, 23f +25: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + sd s5, 56(s4) + sd s6, 64(s4) + sd s7, 72(s4) + sd s8, 80(s4) + sd s9, 88(s4) + sd s10, 96(s4) + lui t0, 577791 + addiw t0, t0, -1625 + slli t0, t0, 32 + lui t1, 297411 + addiw t1, t1, -1923 + add t0, t0, t1 + sd t0, 120(s4) + lui t0, 514972 + addiw t0, t0, 1995 + slli t0, t0, 32 + lui t1, 1006958 + addiw t1, t1, 857 + add t0, t0, t1 + sd t0, 128(s4) + lui t0, 167205 + addiw t0, t0, 62 + slli t0, t0, 32 + lui t1, 548376 + addiw t1, t1, 2018 + add t0, t0, t1 + sd t0, 136(s4) + lui t0, 949404 + addiw t0, t0, 1990 + slli t0, t0, 32 + lui t1, 650735 + addiw t1, t1, 1965 + add t0, t0, t1 + sd t0, 144(s4) + lui t0, 912917 + addiw t0, t0, -1333 + slli t0, t0, 32 + lui t1, 151463 + addiw t1, t1, 1048 + add t0, t0, t1 + sd t0, 152(s4) + lui t0, 613275 + addiw t0, t0, -1339 + slli t0, t0, 32 + lui t1, 511468 + addiw t1, t1, 933 + add t0, t0, t1 + sd t0, 160(s4) + lui t0, 272347 + addiw t0, t0, -761 + slli t0, t0, 32 + lui t1, 730620 + addiw t1, t1, -703 + add t0, t0, t1 + sd t0, 168(s4) + lui t0, 369978 + addiw t0, t0, 1843 + slli t0, t0, 32 + lui t1, 358874 + addiw t1, t1, 825 + add t0, t0, t1 + sd t0, 176(s4) + lui t0, 923080 + addiw t0, t0, 1425 + slli t0, t0, 32 + lui t1, 647834 + addiw t1, t1, -61 + add t0, t0, t1 + sd t0, 184(s4) + lui t0, 443197 + addiw t0, t0, 1588 + slli t0, t0, 32 + lui t1, 764907 + addiw t1, t1, 2009 + add t0, t0, t1 + sd t0, 192(s4) + lui t0, 653439 + addiw t0, t0, 995 + slli t0, t0, 32 + lui t1, 497702 + addiw t1, t1, 159 + add t0, t0, t1 + sd t0, 200(s4) + lui t0, 1042229 + addiw t0, t0, 1965 + slli t0, t0, 32 + lui t1, 687598 + addiw t1, t1, 825 + add t0, t0, t1 + sd t0, 208(s4) + lui t0, 97124 + addiw t0, t0, -131 + slli t0, t0, 32 + lui t1, 965742 + addiw t1, t1, 446 + add t0, t0, t1 + sd t0, 216(s4) + lui t0, 234364 + addiw t0, t0, -1364 + slli t0, t0, 32 + lui t1, 443387 + addiw t1, t1, 825 + add t0, t0, t1 + sd t0, 224(s4) + lui t0, 475776 + addiw t0, t0, 1754 + slli t0, t0, 32 + lui t1, 115598 + addiw t1, t1, -1244 + add t0, t0, t1 + sd t0, 232(s4) + lui t0, 812632 + addiw t0, t0, -164 + slli t0, t0, 32 + lui t1, 453076 + addiw t1, t1, -267 + add t0, t0, t1 + sd t0, 240(s4) + lui t0, 997947 + addiw t0, t0, 757 + slli t0, t0, 32 + lui t1, 988933 + addiw t1, t1, 1546 + add t0, t0, t1 + sd t0, 248(s4) + lui t0, 355759 + addiw t0, t0, 821 + slli t0, t0, 32 + lui t1, 228455 + addiw t1, t1, -1037 + add t0, t0, t1 + sd t0, 256(s4) + lui t0, 807395 + addiw t0, t0, -446 + slli t0, t0, 32 + lui t1, 221408 + addiw t1, t1, -1732 + add t0, t0, t1 + sd t0, 264(s4) + lui t0, 773613 + addiw t0, t0, 1622 + slli t0, t0, 32 + lui t1, 814790 + addiw t1, t1, -87 + add t0, t0, t1 + sd t0, 272(s4) + lui t0, 432450 + addiw t0, t0, -920 + slli t0, t0, 32 + lui t1, 369724 + addiw t1, t1, 934 + add t0, t0, t1 + sd t0, 280(s4) + lui t0, 350061 + addiw t0, t0, -1478 + slli t0, t0, 32 + lui t1, 349677 + addiw t1, t1, -1691 + add t0, t0, t1 + sd t0, 288(s4) + lui t0, 773308 + addiw t0, t0, 1973 + slli t0, t0, 32 + lui t1, 457282 + addiw t1, t1, -293 + add t0, t0, t1 + sd t0, 296(s4) + lui t0, 439792 + addiw t0, t0, -1444 + slli t0, t0, 32 + lui t1, 355758 + addiw t1, t1, 2005 + add t0, t0, t1 + sd t0, 304(s4) + lui t0, 238487 + addiw t0, t0, -1185 + slli t0, t0, 32 + lui t1, 815585 + addiw t1, t1, -1291 + add t0, t0, t1 + sd t0, 312(s4) + lui t0, 443229 + addiw t0, t0, 1994 + slli t0, t0, 32 + lui t1, 382958 + addiw t1, t1, -363 + add t0, t0, t1 + sd t0, 320(s4) + lui t0, 353801 + addiw t0, t0, 1066 + slli t0, t0, 32 + lui t1, 658810 + addiw t1, t1, 1376 + add t0, t0, t1 + sd t0, 328(s4) + lui t0, 379968 + addiw t0, t0, -172 + slli t0, t0, 32 + lui t1, 933327 + addiw t1, t1, -1477 + add t0, t0, t1 + sd t0, 336(s4) + lui t0, 656557 + addiw t0, t0, 385 + slli t0, t0, 32 + lui t1, 56148 + addiw t1, t1, -935 + add t0, t0, t1 + sd t0, 344(s4) + lui t0, 211421 + addiw t0, t0, -342 + slli t0, t0, 32 + lui t1, 443238 + addiw t1, t1, -667 + add t0, t0, t1 + sd t0, 352(s4) + lui t0, 48984 + addiw t0, t0, -2016 + slli t0, t0, 32 + lui t1, 865972 + addiw t1, t1, 647 + add t0, t0, t1 + sd t0, 360(s4) + lui t0, 982268 + addiw t0, t0, -1373 + slli t0, t0, 32 + lui t1, 523070 + addiw t1, t1, -411 + add t0, t0, t1 + sd t0, 368(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 64 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 376(s4) + lui t0, 0 + addiw t0, t0, 4 + slli t0, t0, 32 + lui t1, 1048560 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 384(s4) + lui t0, 0 + addiw t0, t0, 1023 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 1023 + add t0, t0, t1 + sd t0, 392(s4) + lui t0, 64 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 64 + addiw t1, t1, -256 + add t0, t0, t1 + sd t0, 400(s4) + lui t0, 1008 + addiw t0, t0, 63 + slli t0, t0, 32 + lui t1, 1008 + addiw t1, t1, 63 + add t0, t0, t1 + sd t0, 408(s4) + lui t0, 16128 + addiw t0, t0, 1008 + slli t0, t0, 32 + lui t1, 16128 + addiw t1, t1, 1008 + add t0, t0, t1 + sd t0, 416(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4096 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 424(s4) + lui t0, 16 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 1044480 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 432(s4) + lui t0, 1 + addiw t0, t0, -1 + slli t0, t0, 32 + lui t1, 1 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 440(s4) + lui t0, 4095 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4095 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 448(s4) + lui t0, 1008 + addiw t0, t0, 63 + slli t0, t0, 32 + lui t1, 1008 + addiw t1, t1, 63 + add t0, t0, t1 + sd t0, 456(s4) + lui t0, 64513 + addiw t0, t0, -64 + slli t0, t0, 32 + lui t1, 64513 + addiw t1, t1, -64 + add t0, t0, t1 + sd t0, 464(s4) + lui t0, 4112 + addiw t0, t0, 257 + slli t0, t0, 32 + lui t1, 4112 + addiw t1, t1, 257 + add t0, t0, t1 + sd t0, 472(s4) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + add t0, t0, t1 + sd t0, 480(s4) + lui t0, 0 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 488(s4) + lui t0, 16417 + addiw t0, t0, -2048 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 496(s4) + lui t0, 16 + addiw t0, t0, 8 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 504(s4) + lui t0, 64 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 32768 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 512(s4) + lui t0, 0 + addiw t0, t0, 512 + slli t0, t0, 32 + lui t1, 64 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 520(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 16384 + addiw t1, t1, 256 + add t0, t0, t1 + sd t0, 528(s4) + lui t0, 0 + addiw t0, t0, 4 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 536(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4096 + addiw t1, t1, 1024 + add t0, t0, t1 + sd t0, 544(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 129 + addiw t1, t1, -2044 + add t0, t0, t1 + sd t0, 552(s4) + lbu t0, 48(s4) + slli t0, t0, 8 + lbu t1, 49(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 50(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 51(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 52(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 53(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 54(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 55(s4) + or t0, t0, t1 + andi t2, t0, 0 + srli t3, t0, 6 + andi t3, t3, 1 + slli t3, t3, 63 + xor t2, t2, t3 + srli t3, t0, 14 + andi t3, t3, 1 + slli t3, t3, 62 + xor t2, t2, t3 + srli t3, t0, 22 + andi t3, t3, 1 + slli t3, t3, 61 + xor t2, t2, t3 + srli t3, t0, 30 + andi t3, t3, 1 + slli t3, t3, 60 + xor t2, t2, t3 + srli t3, t0, 38 + andi t3, t3, 1 + slli t3, t3, 59 + xor t2, t2, t3 + srli t3, t0, 46 + andi t3, t3, 1 + slli t3, t3, 58 + xor t2, t2, t3 + srli t3, t0, 54 + andi t3, t3, 1 + slli t3, t3, 57 + xor t2, t2, t3 + srli t3, t0, 62 + andi t3, t3, 1 + slli t3, t3, 56 + xor t2, t2, t3 + srli t3, t0, 4 + andi t3, t3, 1 + slli t3, t3, 55 + xor t2, t2, t3 + srli t3, t0, 12 + andi t3, t3, 1 + slli t3, t3, 54 + xor t2, t2, t3 + srli t3, t0, 20 + andi t3, t3, 1 + slli t3, t3, 53 + xor t2, t2, t3 + srli t3, t0, 28 + andi t3, t3, 1 + slli t3, t3, 52 + xor t2, t2, t3 + srli t3, t0, 36 + andi t3, t3, 1 + slli t3, t3, 51 + xor t2, t2, t3 + srli t3, t0, 44 + andi t3, t3, 1 + slli t3, t3, 50 + xor t2, t2, t3 + srli t3, t0, 52 + andi t3, t3, 1 + slli t3, t3, 49 + xor t2, t2, t3 + srli t3, t0, 60 + andi t3, t3, 1 + slli t3, t3, 48 + xor t2, t2, t3 + srli t3, t0, 2 + andi t3, t3, 1 + slli t3, t3, 47 + xor t2, t2, t3 + srli t3, t0, 10 + andi t3, t3, 1 + slli t3, t3, 46 + xor t2, t2, t3 + srli t3, t0, 18 + andi t3, t3, 1 + slli t3, t3, 45 + xor t2, t2, t3 + srli t3, t0, 26 + andi t3, t3, 1 + slli t3, t3, 44 + xor t2, t2, t3 + srli t3, t0, 34 + andi t3, t3, 1 + slli t3, t3, 43 + xor t2, t2, t3 + srli t3, t0, 42 + andi t3, t3, 1 + slli t3, t3, 42 + xor t2, t2, t3 + srli t3, t0, 50 + andi t3, t3, 1 + slli t3, t3, 41 + xor t2, t2, t3 + srli t3, t0, 58 + andi t3, t3, 1 + slli t3, t3, 40 + xor t2, t2, t3 + addi t3, t0, 0 + andi t3, t3, 1 + slli t3, t3, 39 + xor t2, t2, t3 + srli t3, t0, 8 + andi t3, t3, 1 + slli t3, t3, 38 + xor t2, t2, t3 + srli t3, t0, 16 + andi t3, t3, 1 + slli t3, t3, 37 + xor t2, t2, t3 + srli t3, t0, 24 + andi t3, t3, 1 + slli t3, t3, 36 + xor t2, t2, t3 + srli t3, t0, 32 + andi t3, t3, 1 + slli t3, t3, 35 + xor t2, t2, t3 + srli t3, t0, 40 + andi t3, t3, 1 + slli t3, t3, 34 + xor t2, t2, t3 + srli t3, t0, 48 + andi t3, t3, 1 + slli t3, t3, 33 + xor t2, t2, t3 + srli t3, t0, 56 + andi t3, t3, 1 + slli t3, t3, 32 + xor t2, t2, t3 + srli t3, t0, 7 + andi t3, t3, 1 + slli t3, t3, 31 + xor t2, t2, t3 + srli t3, t0, 15 + andi t3, t3, 1 + slli t3, t3, 30 + xor t2, t2, t3 + srli t3, t0, 23 + andi t3, t3, 1 + slli t3, t3, 29 + xor t2, t2, t3 + srli t3, t0, 31 + andi t3, t3, 1 + slli t3, t3, 28 + xor t2, t2, t3 + srli t3, t0, 39 + andi t3, t3, 1 + slli t3, t3, 27 + xor t2, t2, t3 + srli t3, t0, 47 + andi t3, t3, 1 + slli t3, t3, 26 + xor t2, t2, t3 + srli t3, t0, 55 + andi t3, t3, 1 + slli t3, t3, 25 + xor t2, t2, t3 + srli t3, t0, 63 + andi t3, t3, 1 + slli t3, t3, 24 + xor t2, t2, t3 + srli t3, t0, 5 + andi t3, t3, 1 + slli t3, t3, 23 + xor t2, t2, t3 + srli t3, t0, 13 + andi t3, t3, 1 + slli t3, t3, 22 + xor t2, t2, t3 + srli t3, t0, 21 + andi t3, t3, 1 + slli t3, t3, 21 + xor t2, t2, t3 + srli t3, t0, 29 + andi t3, t3, 1 + slli t3, t3, 20 + xor t2, t2, t3 + srli t3, t0, 37 + andi t3, t3, 1 + slli t3, t3, 19 + xor t2, t2, t3 + srli t3, t0, 45 + andi t3, t3, 1 + slli t3, t3, 18 + xor t2, t2, t3 + srli t3, t0, 53 + andi t3, t3, 1 + slli t3, t3, 17 + xor t2, t2, t3 + srli t3, t0, 61 + andi t3, t3, 1 + slli t3, t3, 16 + xor t2, t2, t3 + srli t3, t0, 3 + andi t3, t3, 1 + slli t3, t3, 15 + xor t2, t2, t3 + srli t3, t0, 11 + andi t3, t3, 1 + slli t3, t3, 14 + xor t2, t2, t3 + srli t3, t0, 19 + andi t3, t3, 1 + slli t3, t3, 13 + xor t2, t2, t3 + srli t3, t0, 27 + andi t3, t3, 1 + slli t3, t3, 12 + xor t2, t2, t3 + srli t3, t0, 35 + andi t3, t3, 1 + slli t3, t3, 11 + xor t2, t2, t3 + srli t3, t0, 43 + andi t3, t3, 1 + slli t3, t3, 10 + xor t2, t2, t3 + srli t3, t0, 51 + andi t3, t3, 1 + slli t3, t3, 9 + xor t2, t2, t3 + srli t3, t0, 59 + andi t3, t3, 1 + slli t3, t3, 8 + xor t2, t2, t3 + srli t3, t0, 1 + andi t3, t3, 1 + slli t3, t3, 7 + xor t2, t2, t3 + srli t3, t0, 9 + andi t3, t3, 1 + slli t3, t3, 6 + xor t2, t2, t3 + srli t3, t0, 17 + andi t3, t3, 1 + slli t3, t3, 5 + xor t2, t2, t3 + srli t3, t0, 25 + andi t3, t3, 1 + slli t3, t3, 4 + xor t2, t2, t3 + srli t3, t0, 33 + andi t3, t3, 1 + slli t3, t3, 3 + xor t2, t2, t3 + srli t3, t0, 41 + andi t3, t3, 1 + slli t3, t3, 2 + xor t2, t2, t3 + srli t3, t0, 49 + andi t3, t3, 1 + slli t3, t3, 1 + xor t2, t2, t3 + srli t3, t0, 57 + andi t3, t3, 1 + xor t2, t2, t3 + srli a1, t2, 32 + slli a2, t2, 32 + srli a2, a2, 32 + addi a6, zero, 3 +26: + addi t6, a6, -3 + beqz t6, 27f + addi t6, a6, -2 + beqz t6, 29f + addi a3, s4, 816 + addi a4, zero, 16 + addi a5, zero, 8 + j 210f +29: + addi a3, s4, 808 + addi a4, zero, 16 + addi a5, zero, -8 +210: + j 28f +27: + addi a3, s4, 560 + addi a4, zero, 16 + addi a5, zero, 8 +28: +211: + ld t4, 0(a3) + ld t0, 488(s4) + and t0, a2, t0 + slli t1, t0, 1 + srli t2, t0, 31 + xor t1, t1, t2 + slli t2, t0, 33 + xor t0, t1, t2 + ld t1, 376(s4) + and t1, t0, t1 + ld t2, 384(s4) + and t2, t0, t2 + slli t2, t2, 16 + xor t0, t1, t2 + ld t1, 392(s4) + and t1, t0, t1 + ld t2, 400(s4) + and t2, t0, t2 + slli t2, t2, 8 + xor t0, t1, t2 + ld t1, 408(s4) + and t1, t0, t1 + ld t2, 416(s4) + and t2, t0, t2 + slli t2, t2, 4 + xor t0, t1, t2 + ld t1, 424(s4) + and t1, t4, t1 + ld t2, 432(s4) + and t2, t4, t2 + slli t2, t2, 8 + xor t4, t1, t2 + ld t1, 440(s4) + and t1, t4, t1 + ld t2, 448(s4) + and t2, t4, t2 + slli t2, t2, 4 + xor t4, t1, t2 + ld t1, 456(s4) + and t1, t4, t1 + ld t2, 464(s4) + and t2, t4, t2 + slli t2, t2, 2 + xor t4, t1, t2 + xor t0, t0, t4 + ld t3, 472(s4) + and s5, t0, t3 + slli t1, s5, 1 + xor s5, s5, t1 + slli t1, s5, 2 + xor s5, s5, t1 + slli t1, s5, 4 + xor s5, s5, t1 + srli s6, t0, 1 + and s6, s6, t3 + slli t1, s6, 1 + xor s6, s6, t1 + slli t1, s6, 2 + xor s6, s6, t1 + slli t1, s6, 4 + xor s6, s6, t1 + srli s7, t0, 2 + and s7, s7, t3 + slli t1, s7, 1 + xor s7, s7, t1 + slli t1, s7, 2 + xor s7, s7, t1 + slli t1, s7, 4 + xor s7, s7, t1 + srli s8, t0, 3 + and s8, s8, t3 + slli t1, s8, 1 + xor s8, s8, t1 + slli t1, s8, 2 + xor s8, s8, t1 + slli t1, s8, 4 + xor s8, s8, t1 + srli s9, t0, 4 + and s9, s9, t3 + slli t1, s9, 1 + xor s9, s9, t1 + slli t1, s9, 2 + xor s9, s9, t1 + slli t1, s9, 4 + xor s9, s9, t1 + srli s10, t0, 5 + and s10, s10, t3 + slli t1, s10, 1 + xor s10, s10, t1 + slli t1, s10, 2 + xor s10, s10, t1 + slli t1, s10, 4 + xor s10, s10, t1 + ld t0, 120(s4) + ld t1, 128(s4) + and t1, t1, s5 + xor t0, t0, t1 + ld t1, 136(s4) + ld t2, 144(s4) + and t2, t2, s5 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s6 + xor t0, t0, t1 + ld t1, 152(s4) + ld t2, 160(s4) + and t2, t2, s5 + xor t1, t1, t2 + ld t2, 168(s4) + ld t3, 176(s4) + and t3, t3, s5 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s6 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s7 + xor t0, t0, t1 + ld t1, 184(s4) + ld t2, 192(s4) + and t2, t2, s5 + xor t1, t1, t2 + ld t2, 200(s4) + ld t3, 208(s4) + and t3, t3, s5 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s6 + xor t1, t1, t2 + ld t2, 216(s4) + ld t3, 224(s4) + and t3, t3, s5 + xor t2, t2, t3 + ld t3, 232(s4) + ld t4, 240(s4) + and t4, t4, s5 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s6 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s7 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s8 + xor t0, t0, t1 + ld t1, 248(s4) + ld t2, 256(s4) + and t2, t2, s5 + xor t1, t1, t2 + ld t2, 264(s4) + ld t3, 272(s4) + and t3, t3, s5 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s6 + xor t1, t1, t2 + ld t2, 280(s4) + ld t3, 288(s4) + and t3, t3, s5 + xor t2, t2, t3 + ld t3, 296(s4) + ld t4, 304(s4) + and t4, t4, s5 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s6 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s7 + xor t1, t1, t2 + ld t2, 312(s4) + ld t3, 320(s4) + and t3, t3, s5 + xor t2, t2, t3 + ld t3, 328(s4) + ld t4, 336(s4) + and t4, t4, s5 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s6 + xor t2, t2, t3 + ld t3, 344(s4) + ld t4, 352(s4) + and t4, t4, s5 + xor t3, t3, t4 + ld t4, 360(s4) + ld t5, 368(s4) + and t5, t5, s5 + xor t4, t4, t5 + xor t4, t3, t4 + and t4, t4, s6 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s7 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s8 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s9 + xor t0, t0, t1 + ld t6, 480(s4) + xor t6, s10, t6 + and t0, t0, t6 + srli t1, t0, 4 + xor t0, t0, t1 + srli t1, t0, 57 + andi t1, t1, 1 + slli t1, t1, 1 + xor a1, a1, t1 + srli t1, t0, 51 + andi t1, t1, 33 + slli t1, t1, 4 + xor a1, a1, t1 + srli t1, t0, 59 + andi t1, t1, 1 + slli t1, t1, 15 + xor a1, a1, t1 + srli t1, t0, 40 + andi t1, t1, 1 + slli t1, t1, 2 + xor a1, a1, t1 + ld t1, 496(s4) + and t1, t1, t0 + srli t1, t1, 35 + xor a1, a1, t1 + ld t1, 504(s4) + and t1, t1, t0 + srli t1, t1, 29 + xor a1, a1, t1 + srli t1, t0, 42 + andi t1, t1, 1 + slli t1, t1, 16 + xor a1, a1, t1 + ld t1, 512(s4) + and t1, t1, t0 + srli t1, t1, 20 + xor a1, a1, t1 + ld t1, 520(s4) + and t1, t1, t0 + srli t1, t1, 15 + xor a1, a1, t1 + srli t1, t0, 33 + andi t1, t1, 1 + slli t1, t1, 22 + xor a1, a1, t1 + ld t1, 528(s4) + and t1, t1, t0 + srli t1, t1, 8 + xor a1, a1, t1 + ld t1, 536(s4) + and t1, t1, t0 + srli t1, t1, 3 + xor a1, a1, t1 + ld t1, 544(s4) + and t1, t1, t0 + xor a1, a1, t1 + srli t1, t0, 17 + andi t1, t1, 257 + slli t1, t1, 21 + xor a1, a1, t1 + andi t1, t0, 1 + slli t1, t1, 5 + xor a1, a1, t1 + ld t1, 552(s4) + and t1, t1, t0 + slli t1, t1, 9 + xor a1, a1, t1 + srli t1, t0, 1 + andi t1, t1, 257 + slli t1, t1, 17 + xor a1, a1, t1 + srli t1, t0, 3 + andi t1, t1, 1 + slli t1, t1, 27 + xor a1, a1, t1 + addi t0, a1, 0 + addi a1, a2, 0 + addi a2, t0, 0 + add a3, a3, a5 + addi a4, a4, -1 + bnez a4, 211b + addi t0, a1, 0 + addi a1, a2, 0 + addi a2, t0, 0 + addi a6, a6, -1 + bnez a6, 26b + slli t0, a1, 32 + xor t0, t0, a2 + andi t2, t0, 0 + srli t3, t0, 24 + andi t3, t3, 1 + slli t3, t3, 63 + xor t2, t2, t3 + srli t3, t0, 56 + andi t3, t3, 1 + slli t3, t3, 62 + xor t2, t2, t3 + srli t3, t0, 16 + andi t3, t3, 1 + slli t3, t3, 61 + xor t2, t2, t3 + srli t3, t0, 48 + andi t3, t3, 1 + slli t3, t3, 60 + xor t2, t2, t3 + srli t3, t0, 8 + andi t3, t3, 1 + slli t3, t3, 59 + xor t2, t2, t3 + srli t3, t0, 40 + andi t3, t3, 1 + slli t3, t3, 58 + xor t2, t2, t3 + addi t3, t0, 0 + andi t3, t3, 1 + slli t3, t3, 57 + xor t2, t2, t3 + srli t3, t0, 32 + andi t3, t3, 1 + slli t3, t3, 56 + xor t2, t2, t3 + srli t3, t0, 25 + andi t3, t3, 1 + slli t3, t3, 55 + xor t2, t2, t3 + srli t3, t0, 57 + andi t3, t3, 1 + slli t3, t3, 54 + xor t2, t2, t3 + srli t3, t0, 17 + andi t3, t3, 1 + slli t3, t3, 53 + xor t2, t2, t3 + srli t3, t0, 49 + andi t3, t3, 1 + slli t3, t3, 52 + xor t2, t2, t3 + srli t3, t0, 9 + andi t3, t3, 1 + slli t3, t3, 51 + xor t2, t2, t3 + srli t3, t0, 41 + andi t3, t3, 1 + slli t3, t3, 50 + xor t2, t2, t3 + srli t3, t0, 1 + andi t3, t3, 1 + slli t3, t3, 49 + xor t2, t2, t3 + srli t3, t0, 33 + andi t3, t3, 1 + slli t3, t3, 48 + xor t2, t2, t3 + srli t3, t0, 26 + andi t3, t3, 1 + slli t3, t3, 47 + xor t2, t2, t3 + srli t3, t0, 58 + andi t3, t3, 1 + slli t3, t3, 46 + xor t2, t2, t3 + srli t3, t0, 18 + andi t3, t3, 1 + slli t3, t3, 45 + xor t2, t2, t3 + srli t3, t0, 50 + andi t3, t3, 1 + slli t3, t3, 44 + xor t2, t2, t3 + srli t3, t0, 10 + andi t3, t3, 1 + slli t3, t3, 43 + xor t2, t2, t3 + srli t3, t0, 42 + andi t3, t3, 1 + slli t3, t3, 42 + xor t2, t2, t3 + srli t3, t0, 2 + andi t3, t3, 1 + slli t3, t3, 41 + xor t2, t2, t3 + srli t3, t0, 34 + andi t3, t3, 1 + slli t3, t3, 40 + xor t2, t2, t3 + srli t3, t0, 27 + andi t3, t3, 1 + slli t3, t3, 39 + xor t2, t2, t3 + srli t3, t0, 59 + andi t3, t3, 1 + slli t3, t3, 38 + xor t2, t2, t3 + srli t3, t0, 19 + andi t3, t3, 1 + slli t3, t3, 37 + xor t2, t2, t3 + srli t3, t0, 51 + andi t3, t3, 1 + slli t3, t3, 36 + xor t2, t2, t3 + srli t3, t0, 11 + andi t3, t3, 1 + slli t3, t3, 35 + xor t2, t2, t3 + srli t3, t0, 43 + andi t3, t3, 1 + slli t3, t3, 34 + xor t2, t2, t3 + srli t3, t0, 3 + andi t3, t3, 1 + slli t3, t3, 33 + xor t2, t2, t3 + srli t3, t0, 35 + andi t3, t3, 1 + slli t3, t3, 32 + xor t2, t2, t3 + srli t3, t0, 28 + andi t3, t3, 1 + slli t3, t3, 31 + xor t2, t2, t3 + srli t3, t0, 60 + andi t3, t3, 1 + slli t3, t3, 30 + xor t2, t2, t3 + srli t3, t0, 20 + andi t3, t3, 1 + slli t3, t3, 29 + xor t2, t2, t3 + srli t3, t0, 52 + andi t3, t3, 1 + slli t3, t3, 28 + xor t2, t2, t3 + srli t3, t0, 12 + andi t3, t3, 1 + slli t3, t3, 27 + xor t2, t2, t3 + srli t3, t0, 44 + andi t3, t3, 1 + slli t3, t3, 26 + xor t2, t2, t3 + srli t3, t0, 4 + andi t3, t3, 1 + slli t3, t3, 25 + xor t2, t2, t3 + srli t3, t0, 36 + andi t3, t3, 1 + slli t3, t3, 24 + xor t2, t2, t3 + srli t3, t0, 29 + andi t3, t3, 1 + slli t3, t3, 23 + xor t2, t2, t3 + srli t3, t0, 61 + andi t3, t3, 1 + slli t3, t3, 22 + xor t2, t2, t3 + srli t3, t0, 21 + andi t3, t3, 1 + slli t3, t3, 21 + xor t2, t2, t3 + srli t3, t0, 53 + andi t3, t3, 1 + slli t3, t3, 20 + xor t2, t2, t3 + srli t3, t0, 13 + andi t3, t3, 1 + slli t3, t3, 19 + xor t2, t2, t3 + srli t3, t0, 45 + andi t3, t3, 1 + slli t3, t3, 18 + xor t2, t2, t3 + srli t3, t0, 5 + andi t3, t3, 1 + slli t3, t3, 17 + xor t2, t2, t3 + srli t3, t0, 37 + andi t3, t3, 1 + slli t3, t3, 16 + xor t2, t2, t3 + srli t3, t0, 30 + andi t3, t3, 1 + slli t3, t3, 15 + xor t2, t2, t3 + srli t3, t0, 62 + andi t3, t3, 1 + slli t3, t3, 14 + xor t2, t2, t3 + srli t3, t0, 22 + andi t3, t3, 1 + slli t3, t3, 13 + xor t2, t2, t3 + srli t3, t0, 54 + andi t3, t3, 1 + slli t3, t3, 12 + xor t2, t2, t3 + srli t3, t0, 14 + andi t3, t3, 1 + slli t3, t3, 11 + xor t2, t2, t3 + srli t3, t0, 46 + andi t3, t3, 1 + slli t3, t3, 10 + xor t2, t2, t3 + srli t3, t0, 6 + andi t3, t3, 1 + slli t3, t3, 9 + xor t2, t2, t3 + srli t3, t0, 38 + andi t3, t3, 1 + slli t3, t3, 8 + xor t2, t2, t3 + srli t3, t0, 31 + andi t3, t3, 1 + slli t3, t3, 7 + xor t2, t2, t3 + srli t3, t0, 63 + andi t3, t3, 1 + slli t3, t3, 6 + xor t2, t2, t3 + srli t3, t0, 23 + andi t3, t3, 1 + slli t3, t3, 5 + xor t2, t2, t3 + srli t3, t0, 55 + andi t3, t3, 1 + slli t3, t3, 4 + xor t2, t2, t3 + srli t3, t0, 15 + andi t3, t3, 1 + slli t3, t3, 3 + xor t2, t2, t3 + srli t3, t0, 47 + andi t3, t3, 1 + slli t3, t3, 2 + xor t2, t2, t3 + srli t3, t0, 7 + andi t3, t3, 1 + slli t3, t3, 1 + xor t2, t2, t3 + srli t3, t0, 39 + andi t3, t3, 1 + xor t2, t2, t3 + srli t1, t2, 56 + sb t1, 48(s4) + srli t1, t2, 48 + sb t1, 49(s4) + srli t1, t2, 40 + sb t1, 50(s4) + srli t1, t2, 32 + sb t1, 51(s4) + srli t1, t2, 24 + sb t1, 52(s4) + srli t1, t2, 16 + sb t1, 53(s4) + srli t1, t2, 8 + sb t1, 54(s4) + srli t1, t2, 0 + sb t1, 55(s4) + ld s5, 56(s4) + ld s6, 64(s4) + ld s7, 72(s4) + ld s8, 80(s4) + ld s9, 88(s4) + ld s10, 96(s4) + addi t0, zero, 8 + bltu s3, t0, 212f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lbu t0, 0(s2) + lbu t2, 1(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 2(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 3(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 48(s4) + xor t0, t0, t1 + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lbu t0, 4(s2) + lbu t2, 5(s2) + slli t2, t2, 8 + or t0, t0, t2 + lbu t2, 6(s2) + slli t2, t2, 16 + or t0, t0, t2 + lbu t2, 7(s2) + slli t2, t2, 24 + or t0, t0, t2 + lwu t1, 52(s4) + xor t0, t0, t1 + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 213f +212: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +214: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 214b +213: + bnez s3, 25b + j 24f +23: +24: + j 22f +21: + beqz s3, 215f +217: + lwu t0, 32(s4) + sw t0, 48(s4) + lwu t0, 36(s4) + sw t0, 52(s4) + sd s5, 56(s4) + sd s6, 64(s4) + sd s7, 72(s4) + sd s8, 80(s4) + sd s9, 88(s4) + sd s10, 96(s4) + lui t0, 577791 + addiw t0, t0, -1625 + slli t0, t0, 32 + lui t1, 297411 + addiw t1, t1, -1923 + add t0, t0, t1 + sd t0, 120(s4) + lui t0, 514972 + addiw t0, t0, 1995 + slli t0, t0, 32 + lui t1, 1006958 + addiw t1, t1, 857 + add t0, t0, t1 + sd t0, 128(s4) + lui t0, 167205 + addiw t0, t0, 62 + slli t0, t0, 32 + lui t1, 548376 + addiw t1, t1, 2018 + add t0, t0, t1 + sd t0, 136(s4) + lui t0, 949404 + addiw t0, t0, 1990 + slli t0, t0, 32 + lui t1, 650735 + addiw t1, t1, 1965 + add t0, t0, t1 + sd t0, 144(s4) + lui t0, 912917 + addiw t0, t0, -1333 + slli t0, t0, 32 + lui t1, 151463 + addiw t1, t1, 1048 + add t0, t0, t1 + sd t0, 152(s4) + lui t0, 613275 + addiw t0, t0, -1339 + slli t0, t0, 32 + lui t1, 511468 + addiw t1, t1, 933 + add t0, t0, t1 + sd t0, 160(s4) + lui t0, 272347 + addiw t0, t0, -761 + slli t0, t0, 32 + lui t1, 730620 + addiw t1, t1, -703 + add t0, t0, t1 + sd t0, 168(s4) + lui t0, 369978 + addiw t0, t0, 1843 + slli t0, t0, 32 + lui t1, 358874 + addiw t1, t1, 825 + add t0, t0, t1 + sd t0, 176(s4) + lui t0, 923080 + addiw t0, t0, 1425 + slli t0, t0, 32 + lui t1, 647834 + addiw t1, t1, -61 + add t0, t0, t1 + sd t0, 184(s4) + lui t0, 443197 + addiw t0, t0, 1588 + slli t0, t0, 32 + lui t1, 764907 + addiw t1, t1, 2009 + add t0, t0, t1 + sd t0, 192(s4) + lui t0, 653439 + addiw t0, t0, 995 + slli t0, t0, 32 + lui t1, 497702 + addiw t1, t1, 159 + add t0, t0, t1 + sd t0, 200(s4) + lui t0, 1042229 + addiw t0, t0, 1965 + slli t0, t0, 32 + lui t1, 687598 + addiw t1, t1, 825 + add t0, t0, t1 + sd t0, 208(s4) + lui t0, 97124 + addiw t0, t0, -131 + slli t0, t0, 32 + lui t1, 965742 + addiw t1, t1, 446 + add t0, t0, t1 + sd t0, 216(s4) + lui t0, 234364 + addiw t0, t0, -1364 + slli t0, t0, 32 + lui t1, 443387 + addiw t1, t1, 825 + add t0, t0, t1 + sd t0, 224(s4) + lui t0, 475776 + addiw t0, t0, 1754 + slli t0, t0, 32 + lui t1, 115598 + addiw t1, t1, -1244 + add t0, t0, t1 + sd t0, 232(s4) + lui t0, 812632 + addiw t0, t0, -164 + slli t0, t0, 32 + lui t1, 453076 + addiw t1, t1, -267 + add t0, t0, t1 + sd t0, 240(s4) + lui t0, 997947 + addiw t0, t0, 757 + slli t0, t0, 32 + lui t1, 988933 + addiw t1, t1, 1546 + add t0, t0, t1 + sd t0, 248(s4) + lui t0, 355759 + addiw t0, t0, 821 + slli t0, t0, 32 + lui t1, 228455 + addiw t1, t1, -1037 + add t0, t0, t1 + sd t0, 256(s4) + lui t0, 807395 + addiw t0, t0, -446 + slli t0, t0, 32 + lui t1, 221408 + addiw t1, t1, -1732 + add t0, t0, t1 + sd t0, 264(s4) + lui t0, 773613 + addiw t0, t0, 1622 + slli t0, t0, 32 + lui t1, 814790 + addiw t1, t1, -87 + add t0, t0, t1 + sd t0, 272(s4) + lui t0, 432450 + addiw t0, t0, -920 + slli t0, t0, 32 + lui t1, 369724 + addiw t1, t1, 934 + add t0, t0, t1 + sd t0, 280(s4) + lui t0, 350061 + addiw t0, t0, -1478 + slli t0, t0, 32 + lui t1, 349677 + addiw t1, t1, -1691 + add t0, t0, t1 + sd t0, 288(s4) + lui t0, 773308 + addiw t0, t0, 1973 + slli t0, t0, 32 + lui t1, 457282 + addiw t1, t1, -293 + add t0, t0, t1 + sd t0, 296(s4) + lui t0, 439792 + addiw t0, t0, -1444 + slli t0, t0, 32 + lui t1, 355758 + addiw t1, t1, 2005 + add t0, t0, t1 + sd t0, 304(s4) + lui t0, 238487 + addiw t0, t0, -1185 + slli t0, t0, 32 + lui t1, 815585 + addiw t1, t1, -1291 + add t0, t0, t1 + sd t0, 312(s4) + lui t0, 443229 + addiw t0, t0, 1994 + slli t0, t0, 32 + lui t1, 382958 + addiw t1, t1, -363 + add t0, t0, t1 + sd t0, 320(s4) + lui t0, 353801 + addiw t0, t0, 1066 + slli t0, t0, 32 + lui t1, 658810 + addiw t1, t1, 1376 + add t0, t0, t1 + sd t0, 328(s4) + lui t0, 379968 + addiw t0, t0, -172 + slli t0, t0, 32 + lui t1, 933327 + addiw t1, t1, -1477 + add t0, t0, t1 + sd t0, 336(s4) + lui t0, 656557 + addiw t0, t0, 385 + slli t0, t0, 32 + lui t1, 56148 + addiw t1, t1, -935 + add t0, t0, t1 + sd t0, 344(s4) + lui t0, 211421 + addiw t0, t0, -342 + slli t0, t0, 32 + lui t1, 443238 + addiw t1, t1, -667 + add t0, t0, t1 + sd t0, 352(s4) + lui t0, 48984 + addiw t0, t0, -2016 + slli t0, t0, 32 + lui t1, 865972 + addiw t1, t1, 647 + add t0, t0, t1 + sd t0, 360(s4) + lui t0, 982268 + addiw t0, t0, -1373 + slli t0, t0, 32 + lui t1, 523070 + addiw t1, t1, -411 + add t0, t0, t1 + sd t0, 368(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 64 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 376(s4) + lui t0, 0 + addiw t0, t0, 4 + slli t0, t0, 32 + lui t1, 1048560 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 384(s4) + lui t0, 0 + addiw t0, t0, 1023 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 1023 + add t0, t0, t1 + sd t0, 392(s4) + lui t0, 64 + addiw t0, t0, -256 + slli t0, t0, 32 + lui t1, 64 + addiw t1, t1, -256 + add t0, t0, t1 + sd t0, 400(s4) + lui t0, 1008 + addiw t0, t0, 63 + slli t0, t0, 32 + lui t1, 1008 + addiw t1, t1, 63 + add t0, t0, t1 + sd t0, 408(s4) + lui t0, 16128 + addiw t0, t0, 1008 + slli t0, t0, 32 + lui t1, 16128 + addiw t1, t1, 1008 + add t0, t0, t1 + sd t0, 416(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4096 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 424(s4) + lui t0, 16 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 1044480 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 432(s4) + lui t0, 1 + addiw t0, t0, -1 + slli t0, t0, 32 + lui t1, 1 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 440(s4) + lui t0, 4095 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4095 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 448(s4) + lui t0, 1008 + addiw t0, t0, 63 + slli t0, t0, 32 + lui t1, 1008 + addiw t1, t1, 63 + add t0, t0, t1 + sd t0, 456(s4) + lui t0, 64513 + addiw t0, t0, -64 + slli t0, t0, 32 + lui t1, 64513 + addiw t1, t1, -64 + add t0, t0, t1 + sd t0, 464(s4) + lui t0, 4112 + addiw t0, t0, 257 + slli t0, t0, 32 + lui t1, 4112 + addiw t1, t1, 257 + add t0, t0, t1 + sd t0, 472(s4) + lui t0, 61681 + addiw t0, t0, -241 + slli t0, t0, 32 + lui t1, 61681 + addiw t1, t1, -241 + add t0, t0, t1 + sd t0, 480(s4) + lui t0, 0 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, -1 + add t0, t0, t1 + sd t0, 488(s4) + lui t0, 16417 + addiw t0, t0, -2048 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 496(s4) + lui t0, 16 + addiw t0, t0, 8 + slli t0, t0, 32 + lui t1, 0 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 504(s4) + lui t0, 64 + addiw t0, t0, 1 + slli t0, t0, 32 + lui t1, 32768 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 512(s4) + lui t0, 0 + addiw t0, t0, 512 + slli t0, t0, 32 + lui t1, 64 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 520(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 16384 + addiw t1, t1, 256 + add t0, t0, t1 + sd t0, 528(s4) + lui t0, 0 + addiw t0, t0, 4 + slli t0, t0, 32 + lui t1, 16 + addiw t1, t1, 0 + add t0, t0, t1 + sd t0, 536(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 4096 + addiw t1, t1, 1024 + add t0, t0, t1 + sd t0, 544(s4) + lui t0, 0 + addiw t0, t0, 0 + slli t0, t0, 32 + lui t1, 129 + addiw t1, t1, -2044 + add t0, t0, t1 + sd t0, 552(s4) + lbu t0, 48(s4) + slli t0, t0, 8 + lbu t1, 49(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 50(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 51(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 52(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 53(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 54(s4) + or t0, t0, t1 + slli t0, t0, 8 + lbu t1, 55(s4) + or t0, t0, t1 + andi t2, t0, 0 + srli t3, t0, 6 + andi t3, t3, 1 + slli t3, t3, 63 + xor t2, t2, t3 + srli t3, t0, 14 + andi t3, t3, 1 + slli t3, t3, 62 + xor t2, t2, t3 + srli t3, t0, 22 + andi t3, t3, 1 + slli t3, t3, 61 + xor t2, t2, t3 + srli t3, t0, 30 + andi t3, t3, 1 + slli t3, t3, 60 + xor t2, t2, t3 + srli t3, t0, 38 + andi t3, t3, 1 + slli t3, t3, 59 + xor t2, t2, t3 + srli t3, t0, 46 + andi t3, t3, 1 + slli t3, t3, 58 + xor t2, t2, t3 + srli t3, t0, 54 + andi t3, t3, 1 + slli t3, t3, 57 + xor t2, t2, t3 + srli t3, t0, 62 + andi t3, t3, 1 + slli t3, t3, 56 + xor t2, t2, t3 + srli t3, t0, 4 + andi t3, t3, 1 + slli t3, t3, 55 + xor t2, t2, t3 + srli t3, t0, 12 + andi t3, t3, 1 + slli t3, t3, 54 + xor t2, t2, t3 + srli t3, t0, 20 + andi t3, t3, 1 + slli t3, t3, 53 + xor t2, t2, t3 + srli t3, t0, 28 + andi t3, t3, 1 + slli t3, t3, 52 + xor t2, t2, t3 + srli t3, t0, 36 + andi t3, t3, 1 + slli t3, t3, 51 + xor t2, t2, t3 + srli t3, t0, 44 + andi t3, t3, 1 + slli t3, t3, 50 + xor t2, t2, t3 + srli t3, t0, 52 + andi t3, t3, 1 + slli t3, t3, 49 + xor t2, t2, t3 + srli t3, t0, 60 + andi t3, t3, 1 + slli t3, t3, 48 + xor t2, t2, t3 + srli t3, t0, 2 + andi t3, t3, 1 + slli t3, t3, 47 + xor t2, t2, t3 + srli t3, t0, 10 + andi t3, t3, 1 + slli t3, t3, 46 + xor t2, t2, t3 + srli t3, t0, 18 + andi t3, t3, 1 + slli t3, t3, 45 + xor t2, t2, t3 + srli t3, t0, 26 + andi t3, t3, 1 + slli t3, t3, 44 + xor t2, t2, t3 + srli t3, t0, 34 + andi t3, t3, 1 + slli t3, t3, 43 + xor t2, t2, t3 + srli t3, t0, 42 + andi t3, t3, 1 + slli t3, t3, 42 + xor t2, t2, t3 + srli t3, t0, 50 + andi t3, t3, 1 + slli t3, t3, 41 + xor t2, t2, t3 + srli t3, t0, 58 + andi t3, t3, 1 + slli t3, t3, 40 + xor t2, t2, t3 + addi t3, t0, 0 + andi t3, t3, 1 + slli t3, t3, 39 + xor t2, t2, t3 + srli t3, t0, 8 + andi t3, t3, 1 + slli t3, t3, 38 + xor t2, t2, t3 + srli t3, t0, 16 + andi t3, t3, 1 + slli t3, t3, 37 + xor t2, t2, t3 + srli t3, t0, 24 + andi t3, t3, 1 + slli t3, t3, 36 + xor t2, t2, t3 + srli t3, t0, 32 + andi t3, t3, 1 + slli t3, t3, 35 + xor t2, t2, t3 + srli t3, t0, 40 + andi t3, t3, 1 + slli t3, t3, 34 + xor t2, t2, t3 + srli t3, t0, 48 + andi t3, t3, 1 + slli t3, t3, 33 + xor t2, t2, t3 + srli t3, t0, 56 + andi t3, t3, 1 + slli t3, t3, 32 + xor t2, t2, t3 + srli t3, t0, 7 + andi t3, t3, 1 + slli t3, t3, 31 + xor t2, t2, t3 + srli t3, t0, 15 + andi t3, t3, 1 + slli t3, t3, 30 + xor t2, t2, t3 + srli t3, t0, 23 + andi t3, t3, 1 + slli t3, t3, 29 + xor t2, t2, t3 + srli t3, t0, 31 + andi t3, t3, 1 + slli t3, t3, 28 + xor t2, t2, t3 + srli t3, t0, 39 + andi t3, t3, 1 + slli t3, t3, 27 + xor t2, t2, t3 + srli t3, t0, 47 + andi t3, t3, 1 + slli t3, t3, 26 + xor t2, t2, t3 + srli t3, t0, 55 + andi t3, t3, 1 + slli t3, t3, 25 + xor t2, t2, t3 + srli t3, t0, 63 + andi t3, t3, 1 + slli t3, t3, 24 + xor t2, t2, t3 + srli t3, t0, 5 + andi t3, t3, 1 + slli t3, t3, 23 + xor t2, t2, t3 + srli t3, t0, 13 + andi t3, t3, 1 + slli t3, t3, 22 + xor t2, t2, t3 + srli t3, t0, 21 + andi t3, t3, 1 + slli t3, t3, 21 + xor t2, t2, t3 + srli t3, t0, 29 + andi t3, t3, 1 + slli t3, t3, 20 + xor t2, t2, t3 + srli t3, t0, 37 + andi t3, t3, 1 + slli t3, t3, 19 + xor t2, t2, t3 + srli t3, t0, 45 + andi t3, t3, 1 + slli t3, t3, 18 + xor t2, t2, t3 + srli t3, t0, 53 + andi t3, t3, 1 + slli t3, t3, 17 + xor t2, t2, t3 + srli t3, t0, 61 + andi t3, t3, 1 + slli t3, t3, 16 + xor t2, t2, t3 + srli t3, t0, 3 + andi t3, t3, 1 + slli t3, t3, 15 + xor t2, t2, t3 + srli t3, t0, 11 + andi t3, t3, 1 + slli t3, t3, 14 + xor t2, t2, t3 + srli t3, t0, 19 + andi t3, t3, 1 + slli t3, t3, 13 + xor t2, t2, t3 + srli t3, t0, 27 + andi t3, t3, 1 + slli t3, t3, 12 + xor t2, t2, t3 + srli t3, t0, 35 + andi t3, t3, 1 + slli t3, t3, 11 + xor t2, t2, t3 + srli t3, t0, 43 + andi t3, t3, 1 + slli t3, t3, 10 + xor t2, t2, t3 + srli t3, t0, 51 + andi t3, t3, 1 + slli t3, t3, 9 + xor t2, t2, t3 + srli t3, t0, 59 + andi t3, t3, 1 + slli t3, t3, 8 + xor t2, t2, t3 + srli t3, t0, 1 + andi t3, t3, 1 + slli t3, t3, 7 + xor t2, t2, t3 + srli t3, t0, 9 + andi t3, t3, 1 + slli t3, t3, 6 + xor t2, t2, t3 + srli t3, t0, 17 + andi t3, t3, 1 + slli t3, t3, 5 + xor t2, t2, t3 + srli t3, t0, 25 + andi t3, t3, 1 + slli t3, t3, 4 + xor t2, t2, t3 + srli t3, t0, 33 + andi t3, t3, 1 + slli t3, t3, 3 + xor t2, t2, t3 + srli t3, t0, 41 + andi t3, t3, 1 + slli t3, t3, 2 + xor t2, t2, t3 + srli t3, t0, 49 + andi t3, t3, 1 + slli t3, t3, 1 + xor t2, t2, t3 + srli t3, t0, 57 + andi t3, t3, 1 + xor t2, t2, t3 + srli a1, t2, 32 + slli a2, t2, 32 + srli a2, a2, 32 + addi a6, zero, 3 +218: + addi t6, a6, -3 + beqz t6, 219f + addi t6, a6, -2 + beqz t6, 221f + addi a3, s4, 816 + addi a4, zero, 16 + addi a5, zero, 8 + j 222f +221: + addi a3, s4, 808 + addi a4, zero, 16 + addi a5, zero, -8 +222: + j 220f +219: + addi a3, s4, 560 + addi a4, zero, 16 + addi a5, zero, 8 +220: +223: + ld t4, 0(a3) + ld t0, 488(s4) + and t0, a2, t0 + slli t1, t0, 1 + srli t2, t0, 31 + xor t1, t1, t2 + slli t2, t0, 33 + xor t0, t1, t2 + ld t1, 376(s4) + and t1, t0, t1 + ld t2, 384(s4) + and t2, t0, t2 + slli t2, t2, 16 + xor t0, t1, t2 + ld t1, 392(s4) + and t1, t0, t1 + ld t2, 400(s4) + and t2, t0, t2 + slli t2, t2, 8 + xor t0, t1, t2 + ld t1, 408(s4) + and t1, t0, t1 + ld t2, 416(s4) + and t2, t0, t2 + slli t2, t2, 4 + xor t0, t1, t2 + ld t1, 424(s4) + and t1, t4, t1 + ld t2, 432(s4) + and t2, t4, t2 + slli t2, t2, 8 + xor t4, t1, t2 + ld t1, 440(s4) + and t1, t4, t1 + ld t2, 448(s4) + and t2, t4, t2 + slli t2, t2, 4 + xor t4, t1, t2 + ld t1, 456(s4) + and t1, t4, t1 + ld t2, 464(s4) + and t2, t4, t2 + slli t2, t2, 2 + xor t4, t1, t2 + xor t0, t0, t4 + ld t3, 472(s4) + and s5, t0, t3 + slli t1, s5, 1 + xor s5, s5, t1 + slli t1, s5, 2 + xor s5, s5, t1 + slli t1, s5, 4 + xor s5, s5, t1 + srli s6, t0, 1 + and s6, s6, t3 + slli t1, s6, 1 + xor s6, s6, t1 + slli t1, s6, 2 + xor s6, s6, t1 + slli t1, s6, 4 + xor s6, s6, t1 + srli s7, t0, 2 + and s7, s7, t3 + slli t1, s7, 1 + xor s7, s7, t1 + slli t1, s7, 2 + xor s7, s7, t1 + slli t1, s7, 4 + xor s7, s7, t1 + srli s8, t0, 3 + and s8, s8, t3 + slli t1, s8, 1 + xor s8, s8, t1 + slli t1, s8, 2 + xor s8, s8, t1 + slli t1, s8, 4 + xor s8, s8, t1 + srli s9, t0, 4 + and s9, s9, t3 + slli t1, s9, 1 + xor s9, s9, t1 + slli t1, s9, 2 + xor s9, s9, t1 + slli t1, s9, 4 + xor s9, s9, t1 + srli s10, t0, 5 + and s10, s10, t3 + slli t1, s10, 1 + xor s10, s10, t1 + slli t1, s10, 2 + xor s10, s10, t1 + slli t1, s10, 4 + xor s10, s10, t1 + ld t0, 120(s4) + ld t1, 128(s4) + and t1, t1, s5 + xor t0, t0, t1 + ld t1, 136(s4) + ld t2, 144(s4) + and t2, t2, s5 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s6 + xor t0, t0, t1 + ld t1, 152(s4) + ld t2, 160(s4) + and t2, t2, s5 + xor t1, t1, t2 + ld t2, 168(s4) + ld t3, 176(s4) + and t3, t3, s5 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s6 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s7 + xor t0, t0, t1 + ld t1, 184(s4) + ld t2, 192(s4) + and t2, t2, s5 + xor t1, t1, t2 + ld t2, 200(s4) + ld t3, 208(s4) + and t3, t3, s5 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s6 + xor t1, t1, t2 + ld t2, 216(s4) + ld t3, 224(s4) + and t3, t3, s5 + xor t2, t2, t3 + ld t3, 232(s4) + ld t4, 240(s4) + and t4, t4, s5 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s6 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s7 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s8 + xor t0, t0, t1 + ld t1, 248(s4) + ld t2, 256(s4) + and t2, t2, s5 + xor t1, t1, t2 + ld t2, 264(s4) + ld t3, 272(s4) + and t3, t3, s5 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s6 + xor t1, t1, t2 + ld t2, 280(s4) + ld t3, 288(s4) + and t3, t3, s5 + xor t2, t2, t3 + ld t3, 296(s4) + ld t4, 304(s4) + and t4, t4, s5 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s6 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s7 + xor t1, t1, t2 + ld t2, 312(s4) + ld t3, 320(s4) + and t3, t3, s5 + xor t2, t2, t3 + ld t3, 328(s4) + ld t4, 336(s4) + and t4, t4, s5 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s6 + xor t2, t2, t3 + ld t3, 344(s4) + ld t4, 352(s4) + and t4, t4, s5 + xor t3, t3, t4 + ld t4, 360(s4) + ld t5, 368(s4) + and t5, t5, s5 + xor t4, t4, t5 + xor t4, t3, t4 + and t4, t4, s6 + xor t3, t3, t4 + xor t3, t2, t3 + and t3, t3, s7 + xor t2, t2, t3 + xor t2, t1, t2 + and t2, t2, s8 + xor t1, t1, t2 + xor t1, t0, t1 + and t1, t1, s9 + xor t0, t0, t1 + ld t6, 480(s4) + xor t6, s10, t6 + and t0, t0, t6 + srli t1, t0, 4 + xor t0, t0, t1 + srli t1, t0, 57 + andi t1, t1, 1 + slli t1, t1, 1 + xor a1, a1, t1 + srli t1, t0, 51 + andi t1, t1, 33 + slli t1, t1, 4 + xor a1, a1, t1 + srli t1, t0, 59 + andi t1, t1, 1 + slli t1, t1, 15 + xor a1, a1, t1 + srli t1, t0, 40 + andi t1, t1, 1 + slli t1, t1, 2 + xor a1, a1, t1 + ld t1, 496(s4) + and t1, t1, t0 + srli t1, t1, 35 + xor a1, a1, t1 + ld t1, 504(s4) + and t1, t1, t0 + srli t1, t1, 29 + xor a1, a1, t1 + srli t1, t0, 42 + andi t1, t1, 1 + slli t1, t1, 16 + xor a1, a1, t1 + ld t1, 512(s4) + and t1, t1, t0 + srli t1, t1, 20 + xor a1, a1, t1 + ld t1, 520(s4) + and t1, t1, t0 + srli t1, t1, 15 + xor a1, a1, t1 + srli t1, t0, 33 + andi t1, t1, 1 + slli t1, t1, 22 + xor a1, a1, t1 + ld t1, 528(s4) + and t1, t1, t0 + srli t1, t1, 8 + xor a1, a1, t1 + ld t1, 536(s4) + and t1, t1, t0 + srli t1, t1, 3 + xor a1, a1, t1 + ld t1, 544(s4) + and t1, t1, t0 + xor a1, a1, t1 + srli t1, t0, 17 + andi t1, t1, 257 + slli t1, t1, 21 + xor a1, a1, t1 + andi t1, t0, 1 + slli t1, t1, 5 + xor a1, a1, t1 + ld t1, 552(s4) + and t1, t1, t0 + slli t1, t1, 9 + xor a1, a1, t1 + srli t1, t0, 1 + andi t1, t1, 257 + slli t1, t1, 17 + xor a1, a1, t1 + srli t1, t0, 3 + andi t1, t1, 1 + slli t1, t1, 27 + xor a1, a1, t1 + addi t0, a1, 0 + addi a1, a2, 0 + addi a2, t0, 0 + add a3, a3, a5 + addi a4, a4, -1 + bnez a4, 223b + addi t0, a1, 0 + addi a1, a2, 0 + addi a2, t0, 0 + addi a6, a6, -1 + bnez a6, 218b + slli t0, a1, 32 + xor t0, t0, a2 + andi t2, t0, 0 + srli t3, t0, 24 + andi t3, t3, 1 + slli t3, t3, 63 + xor t2, t2, t3 + srli t3, t0, 56 + andi t3, t3, 1 + slli t3, t3, 62 + xor t2, t2, t3 + srli t3, t0, 16 + andi t3, t3, 1 + slli t3, t3, 61 + xor t2, t2, t3 + srli t3, t0, 48 + andi t3, t3, 1 + slli t3, t3, 60 + xor t2, t2, t3 + srli t3, t0, 8 + andi t3, t3, 1 + slli t3, t3, 59 + xor t2, t2, t3 + srli t3, t0, 40 + andi t3, t3, 1 + slli t3, t3, 58 + xor t2, t2, t3 + addi t3, t0, 0 + andi t3, t3, 1 + slli t3, t3, 57 + xor t2, t2, t3 + srli t3, t0, 32 + andi t3, t3, 1 + slli t3, t3, 56 + xor t2, t2, t3 + srli t3, t0, 25 + andi t3, t3, 1 + slli t3, t3, 55 + xor t2, t2, t3 + srli t3, t0, 57 + andi t3, t3, 1 + slli t3, t3, 54 + xor t2, t2, t3 + srli t3, t0, 17 + andi t3, t3, 1 + slli t3, t3, 53 + xor t2, t2, t3 + srli t3, t0, 49 + andi t3, t3, 1 + slli t3, t3, 52 + xor t2, t2, t3 + srli t3, t0, 9 + andi t3, t3, 1 + slli t3, t3, 51 + xor t2, t2, t3 + srli t3, t0, 41 + andi t3, t3, 1 + slli t3, t3, 50 + xor t2, t2, t3 + srli t3, t0, 1 + andi t3, t3, 1 + slli t3, t3, 49 + xor t2, t2, t3 + srli t3, t0, 33 + andi t3, t3, 1 + slli t3, t3, 48 + xor t2, t2, t3 + srli t3, t0, 26 + andi t3, t3, 1 + slli t3, t3, 47 + xor t2, t2, t3 + srli t3, t0, 58 + andi t3, t3, 1 + slli t3, t3, 46 + xor t2, t2, t3 + srli t3, t0, 18 + andi t3, t3, 1 + slli t3, t3, 45 + xor t2, t2, t3 + srli t3, t0, 50 + andi t3, t3, 1 + slli t3, t3, 44 + xor t2, t2, t3 + srli t3, t0, 10 + andi t3, t3, 1 + slli t3, t3, 43 + xor t2, t2, t3 + srli t3, t0, 42 + andi t3, t3, 1 + slli t3, t3, 42 + xor t2, t2, t3 + srli t3, t0, 2 + andi t3, t3, 1 + slli t3, t3, 41 + xor t2, t2, t3 + srli t3, t0, 34 + andi t3, t3, 1 + slli t3, t3, 40 + xor t2, t2, t3 + srli t3, t0, 27 + andi t3, t3, 1 + slli t3, t3, 39 + xor t2, t2, t3 + srli t3, t0, 59 + andi t3, t3, 1 + slli t3, t3, 38 + xor t2, t2, t3 + srli t3, t0, 19 + andi t3, t3, 1 + slli t3, t3, 37 + xor t2, t2, t3 + srli t3, t0, 51 + andi t3, t3, 1 + slli t3, t3, 36 + xor t2, t2, t3 + srli t3, t0, 11 + andi t3, t3, 1 + slli t3, t3, 35 + xor t2, t2, t3 + srli t3, t0, 43 + andi t3, t3, 1 + slli t3, t3, 34 + xor t2, t2, t3 + srli t3, t0, 3 + andi t3, t3, 1 + slli t3, t3, 33 + xor t2, t2, t3 + srli t3, t0, 35 + andi t3, t3, 1 + slli t3, t3, 32 + xor t2, t2, t3 + srli t3, t0, 28 + andi t3, t3, 1 + slli t3, t3, 31 + xor t2, t2, t3 + srli t3, t0, 60 + andi t3, t3, 1 + slli t3, t3, 30 + xor t2, t2, t3 + srli t3, t0, 20 + andi t3, t3, 1 + slli t3, t3, 29 + xor t2, t2, t3 + srli t3, t0, 52 + andi t3, t3, 1 + slli t3, t3, 28 + xor t2, t2, t3 + srli t3, t0, 12 + andi t3, t3, 1 + slli t3, t3, 27 + xor t2, t2, t3 + srli t3, t0, 44 + andi t3, t3, 1 + slli t3, t3, 26 + xor t2, t2, t3 + srli t3, t0, 4 + andi t3, t3, 1 + slli t3, t3, 25 + xor t2, t2, t3 + srli t3, t0, 36 + andi t3, t3, 1 + slli t3, t3, 24 + xor t2, t2, t3 + srli t3, t0, 29 + andi t3, t3, 1 + slli t3, t3, 23 + xor t2, t2, t3 + srli t3, t0, 61 + andi t3, t3, 1 + slli t3, t3, 22 + xor t2, t2, t3 + srli t3, t0, 21 + andi t3, t3, 1 + slli t3, t3, 21 + xor t2, t2, t3 + srli t3, t0, 53 + andi t3, t3, 1 + slli t3, t3, 20 + xor t2, t2, t3 + srli t3, t0, 13 + andi t3, t3, 1 + slli t3, t3, 19 + xor t2, t2, t3 + srli t3, t0, 45 + andi t3, t3, 1 + slli t3, t3, 18 + xor t2, t2, t3 + srli t3, t0, 5 + andi t3, t3, 1 + slli t3, t3, 17 + xor t2, t2, t3 + srli t3, t0, 37 + andi t3, t3, 1 + slli t3, t3, 16 + xor t2, t2, t3 + srli t3, t0, 30 + andi t3, t3, 1 + slli t3, t3, 15 + xor t2, t2, t3 + srli t3, t0, 62 + andi t3, t3, 1 + slli t3, t3, 14 + xor t2, t2, t3 + srli t3, t0, 22 + andi t3, t3, 1 + slli t3, t3, 13 + xor t2, t2, t3 + srli t3, t0, 54 + andi t3, t3, 1 + slli t3, t3, 12 + xor t2, t2, t3 + srli t3, t0, 14 + andi t3, t3, 1 + slli t3, t3, 11 + xor t2, t2, t3 + srli t3, t0, 46 + andi t3, t3, 1 + slli t3, t3, 10 + xor t2, t2, t3 + srli t3, t0, 6 + andi t3, t3, 1 + slli t3, t3, 9 + xor t2, t2, t3 + srli t3, t0, 38 + andi t3, t3, 1 + slli t3, t3, 8 + xor t2, t2, t3 + srli t3, t0, 31 + andi t3, t3, 1 + slli t3, t3, 7 + xor t2, t2, t3 + srli t3, t0, 63 + andi t3, t3, 1 + slli t3, t3, 6 + xor t2, t2, t3 + srli t3, t0, 23 + andi t3, t3, 1 + slli t3, t3, 5 + xor t2, t2, t3 + srli t3, t0, 55 + andi t3, t3, 1 + slli t3, t3, 4 + xor t2, t2, t3 + srli t3, t0, 15 + andi t3, t3, 1 + slli t3, t3, 3 + xor t2, t2, t3 + srli t3, t0, 47 + andi t3, t3, 1 + slli t3, t3, 2 + xor t2, t2, t3 + srli t3, t0, 7 + andi t3, t3, 1 + slli t3, t3, 1 + xor t2, t2, t3 + srli t3, t0, 39 + andi t3, t3, 1 + xor t2, t2, t3 + srli t1, t2, 56 + sb t1, 48(s4) + srli t1, t2, 48 + sb t1, 49(s4) + srli t1, t2, 40 + sb t1, 50(s4) + srli t1, t2, 32 + sb t1, 51(s4) + srli t1, t2, 24 + sb t1, 52(s4) + srli t1, t2, 16 + sb t1, 53(s4) + srli t1, t2, 8 + sb t1, 54(s4) + srli t1, t2, 0 + sb t1, 55(s4) + ld s5, 56(s4) + ld s6, 64(s4) + ld s7, 72(s4) + ld s8, 80(s4) + ld s9, 88(s4) + ld s10, 96(s4) + addi t0, zero, 8 + bltu s3, t0, 224f + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + lwu t0, 0(s2) + lwu t1, 48(s4) + xor t0, t0, t1 + sw t0, 0(s2) + lwu t0, 4(s2) + lwu t1, 52(s4) + xor t0, t0, t1 + sw t0, 4(s2) + addi s2, s2, 8 + addi s3, s3, -8 + j 225f +224: + lwu t0, 48(s4) + sw t0, 32(s4) + lwu t0, 52(s4) + sw t0, 36(s4) + addi t2, s4, 48 +226: + lbu t0, 0(s2) + lbu t1, 0(t2) + xor t0, t0, t1 + sb t0, 0(s2) + addi s2, s2, 1 + addi t2, t2, 1 + addi s3, s3, -1 + bnez s3, 226b +225: + bnez s3, 217b + j 216f +215: +216: +22: + addi s2, s1, 0 + lwu t0, 32(s4) + sb t0, 0(s2) + srli t2, t0, 8 + sb t2, 1(s2) + srli t2, t0, 16 + sb t2, 2(s2) + srli t2, t0, 24 + sb t2, 3(s2) + lwu t0, 36(s4) + sb t0, 4(s2) + srli t2, t0, 8 + sb t2, 5(s2) + srli t2, t0, 16 + sb t2, 6(s2) + srli t2, t0, 24 + sb t2, 7(s2) + addi t3, s4, 0 + ld s1, 0(t3) + ld s2, 8(t3) + ld s3, 16(t3) + ld s4, 24(t3) + addi t0, zero, 0 + addi t1, t3, 0 + addi t2, zero, 118 +227: + sd t0, 0(t1) + addi t1, t1, 8 + addi t2, t2, -1 + bnez t2, 227b + addi sp, sp, 944 + ret + .option pop diff --git a/crates/verified-garbage-asm-riscv64/src/aes_ctr.rs b/crates/verified-garbage-asm-riscv64/src/aes_ctr.rs index fe42d88cb5d..b4aff42af8c 100644 --- a/crates/verified-garbage-asm-riscv64/src/aes_ctr.rs +++ b/crates/verified-garbage-asm-riscv64/src/aes_ctr.rs @@ -191,3 +191,94 @@ j 21f vg_aes_ctr32 = sym super::aes::vg_aes_ctr32::vg_aes_ctr32, ) } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes, and aligned for `u64`. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the 80 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x715d +.insn 2, 0x880a +.insn 4, 0x00183023 +.insn 4, 0x00983423 +.insn 4, 0x01283823 +.insn 4, 0x01383c23 +.insn 4, 0x03483023 +.insn 4, 0x03583423 +.insn 4, 0x03683823 +.insn 4, 0x03783c23 +.insn 2, 0x84aa +.insn 2, 0x8a2e +.insn 2, 0x8ab2 +.insn 2, 0x8b3e +.insn 2, 0x8bc2 +.insn 4, 0x00475293 +.insn 4, 0x00429313 +.insn 4, 0x00668933 +.insn 4, 0x406709b3 +.insn 2, 0x8716 +call {vg_aes_ctr} +beqz s3, 20f +.insn 2, 0x4281 +.insn 4, 0x045bb023 +.insn 4, 0x045bb423 +.insn 2, 0x8526 +.insn 2, 0x85d2 +.insn 2, 0x8656 +.insn 4, 0x040b8693 +.insn 2, 0x4705 +.insn 2, 0x87da +call {vg_aes_ctr} +.insn 4, 0x040b8393 +22: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 22b +j 21f +20: +21: +.insn 4, 0x000bb083 +.insn 4, 0x008bb483 +.insn 4, 0x010bb903 +.insn 4, 0x018bb983 +.insn 4, 0x020bba03 +.insn 4, 0x028bba83 +.insn 4, 0x030bbb03 +.insn 4, 0x038bbb83 +.insn 2, 0x8f0a +.insn 2, 0x4f81 +.insn 4, 0x01ff3023 +.insn 4, 0x01ff3423 +.insn 4, 0x01ff3823 +.insn 4, 0x01ff3c23 +.insn 4, 0x03ff3023 +.insn 4, 0x03ff3423 +.insn 4, 0x03ff3823 +.insn 4, 0x03ff3c23 +.insn 4, 0x05ff3023 +.insn 4, 0x05ff3423 +.insn 2, 0x6161 +.insn 2, 0x8082 +.option pop", + vg_aes_ctr = sym super::aes_ctr::vg_aes_ctr, + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/aes_ofb.rs b/crates/verified-garbage-asm-riscv64/src/aes_ofb.rs index 07659c4a995..f50ab49ef60 100644 --- a/crates/verified-garbage-asm-riscv64/src/aes_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/aes_ofb.rs @@ -40,6 +40,92 @@ call {vg_aes_ofb_chain} ) } +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes, and aligned for `u64`. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the 64 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x7139 +.insn 2, 0x880a +.insn 4, 0x00183023 +.insn 4, 0x00983423 +.insn 4, 0x01283823 +.insn 4, 0x01383c23 +.insn 4, 0x03483023 +.insn 4, 0x03583423 +.insn 4, 0x03683823 +.insn 4, 0x03783c23 +.insn 2, 0x84aa +.insn 2, 0x8a2e +.insn 2, 0x8ab2 +.insn 2, 0x8b3e +.insn 2, 0x8bc2 +.insn 4, 0x00475293 +.insn 4, 0x00429313 +.insn 4, 0x00668933 +.insn 4, 0x406709b3 +.insn 2, 0x8716 +call {vg_aes_ofb} +beqz s3, 20f +.insn 2, 0x8526 +.insn 2, 0x85d2 +.insn 2, 0x8656 +.insn 2, 0x4685 +.insn 2, 0x875a +call {vg_aes_encrypt_blocks} +.insn 2, 0x83d6 +22: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 22b +j 21f +20: +21: +.insn 4, 0x000bb083 +.insn 4, 0x008bb483 +.insn 4, 0x010bb903 +.insn 4, 0x018bb983 +.insn 4, 0x020bba03 +.insn 4, 0x028bba83 +.insn 4, 0x030bbb03 +.insn 4, 0x038bbb83 +.insn 2, 0x8f0a +.insn 2, 0x4f81 +.insn 4, 0x01ff3023 +.insn 4, 0x01ff3423 +.insn 4, 0x01ff3823 +.insn 4, 0x01ff3c23 +.insn 4, 0x03ff3023 +.insn 4, 0x03ff3423 +.insn 4, 0x03ff3823 +.insn 4, 0x03ff3c23 +.insn 2, 0x6121 +.insn 2, 0x8082 +.option pop", + vg_aes_ofb = sym super::aes_ofb::vg_aes_ofb, + vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, + ) +} + #[rustfmt::skip] #[path = "internal/vg_aes_ofb_chain.rs"] pub(crate) mod vg_aes_ofb_chain; diff --git a/crates/verified-garbage-asm-riscv64/src/blowfish_ofb.rs b/crates/verified-garbage-asm-riscv64/src/blowfish_ofb.rs index 9592b929a61..07cb73fbbc7 100644 --- a/crates/verified-garbage-asm-riscv64/src/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/blowfish_ofb.rs @@ -4045,3 +4045,4084 @@ bnez t2, 211b .option pop", ) } + +/// Blowfish-OFB encryption or decryption (NIST SP 800-38A §6.4, Schneier, FSE 1994) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Blowfish encryption under the schedule written by `vg_blowfish_expand_key`. +/// +/// Contract: `VG.Spec.Blowfish.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 4168 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 4224 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_blowfish_ofb_final(schedule: *const [u8; 4168], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x7135 +.insn 4, 0x81010113 +.insn 4, 0x81010113 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 2, 0x8932 +.insn 4, 0x038a0293 +.insn 2, 0x83aa +.insn 4, 0x41200e93 +.insn 2, 0x0e8a +20: +.insn 4, 0x0003c303 +.insn 4, 0x00628023 +.insn 2, 0x0385 +.insn 2, 0x0285 +.insn 2, 0x1efd +bnez t4, 20b +.insn 4, 0x00397293 +beqz t0, 21f +beqz s3, 23f +25: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x038a0893 +.insn 4, 0x030a0593 +.insn 4, 0x0005c683 +.insn 2, 0x06e2 +.insn 4, 0x0015ce83 +.insn 2, 0x0ec2 +.insn 4, 0x01d6e6b3 +.insn 4, 0x0025ce83 +.insn 2, 0x0ea2 +.insn 4, 0x01d6e6b3 +.insn 4, 0x0035ce83 +.insn 4, 0x01d6e6b3 +.insn 4, 0x0045c703 +.insn 2, 0x0762 +.insn 4, 0x0055ce83 +.insn 2, 0x0ec2 +.insn 4, 0x01d76733 +.insn 4, 0x0065ce83 +.insn 2, 0x0ea2 +.insn 4, 0x01d76733 +.insn 4, 0x0075ce83 +.insn 4, 0x01d76733 +.insn 4, 0x7ff88813 +.insn 4, 0x7ff80813 +.insn 2, 0x0809 +26: +.insn 4, 0x00086e83 +.insn 4, 0x01d6c6b3 +.insn 4, 0x02069313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0186de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 4, 0x0073e7b3 +.insn 4, 0x40088893 +.insn 4, 0x02869313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0106de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 2, 0x979e +.insn 4, 0x40088893 +.insn 4, 0x03069313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0086de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 4, 0x0077c7b3 +.insn 4, 0x40088893 +.insn 4, 0x03869313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0006de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 2, 0x979e +.insn 4, 0x80088893 +.insn 4, 0xc0088893 +.insn 2, 0x8f3d +.insn 4, 0x00d6eeb3 +.insn 4, 0x00e766b3 +.insn 4, 0x01dee733 +.insn 2, 0x0811 +.insn 4, 0x41180eb3 +.insn 4, 0x801e8e93 +.insn 4, 0x801e8e93 +.insn 4, 0xfbee8e93 +bnez t4, 26b +.insn 4, 0x00086e83 +.insn 4, 0x01d6ceb3 +.insn 4, 0x00486683 +.insn 2, 0x8eb9 +.insn 4, 0x01dee733 +.insn 4, 0x0186de93 +.insn 4, 0x01d58023 +.insn 4, 0x0106de93 +.insn 4, 0x01d580a3 +.insn 4, 0x0086de93 +.insn 4, 0x01d58123 +.insn 4, 0x0006de93 +.insn 4, 0x01d581a3 +.insn 4, 0x01875e93 +.insn 4, 0x01d58223 +.insn 4, 0x01075e93 +.insn 4, 0x01d582a3 +.insn 4, 0x00875e93 +.insn 4, 0x01d58323 +.insn 4, 0x00075e93 +.insn 4, 0x01d583a3 +.insn 2, 0x05a1 +.insn 2, 0x167d +.insn 2, 0x42a1 +bltu s3, t0, 27f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 28f +27: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +29: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 29b +28: +bnez s3, 25b +j 24f +23: +24: +j 22f +21: +beqz s3, 210f +212: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x038a0893 +.insn 4, 0x030a0593 +.insn 4, 0x0005c683 +.insn 2, 0x06e2 +.insn 4, 0x0015ce83 +.insn 2, 0x0ec2 +.insn 4, 0x01d6e6b3 +.insn 4, 0x0025ce83 +.insn 2, 0x0ea2 +.insn 4, 0x01d6e6b3 +.insn 4, 0x0035ce83 +.insn 4, 0x01d6e6b3 +.insn 4, 0x0045c703 +.insn 2, 0x0762 +.insn 4, 0x0055ce83 +.insn 2, 0x0ec2 +.insn 4, 0x01d76733 +.insn 4, 0x0065ce83 +.insn 2, 0x0ea2 +.insn 4, 0x01d76733 +.insn 4, 0x0075ce83 +.insn 4, 0x01d76733 +.insn 4, 0x7ff88813 +.insn 4, 0x7ff80813 +.insn 2, 0x0809 +213: +.insn 4, 0x00086e83 +.insn 4, 0x01d6c6b3 +.insn 4, 0x02069313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0186de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 4, 0x0073e7b3 +.insn 4, 0x40088893 +.insn 4, 0x02869313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0106de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 2, 0x979e +.insn 4, 0x40088893 +.insn 4, 0x03069313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0086de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 4, 0x0077c7b3 +.insn 4, 0x40088893 +.insn 4, 0x03869313 +.insn 4, 0x03b35313 +.insn 2, 0x4e05 +.insn 4, 0x006e1333 +.insn 4, 0x03f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0008b383 +.insn 4, 0x01c3f3b3 +.insn 4, 0x1008bf03 +.insn 4, 0x01cf7f33 +.insn 4, 0x2008bf83 +.insn 4, 0x01cfffb3 +.insn 4, 0x3008b283 +.insn 4, 0x01c2f2b3 +.insn 4, 0x03e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3088be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3108be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3188be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3208be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3288be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3308be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3388be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3408be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3488be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3508be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3588be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3608be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3688be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3708be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x03031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3788be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02f31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3808be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02e31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3888be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02d31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3908be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02c31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3988be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02b31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02a31e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3a88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02931e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02831e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3b88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02731e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02631e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3c88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02531e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02431e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3d88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02331e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02231e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3e88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02131e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f08be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x02031e13 +.insn 4, 0x43fe5e13 +.insn 4, 0x0f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d3e3b3 +.insn 4, 0x1f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01df6f33 +.insn 4, 0x2f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01dfefb3 +.insn 4, 0x3f88be83 +.insn 4, 0x01cefeb3 +.insn 4, 0x01d2e2b3 +.insn 4, 0x0006de13 +.insn 4, 0x007e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3d3b3 +.insn 4, 0x0ff3f393 +.insn 4, 0x01cf5f33 +.insn 4, 0x0fff7f13 +.insn 2, 0x0f22 +.insn 4, 0x01cfdfb3 +.insn 4, 0x0fffff93 +.insn 2, 0x0fc2 +.insn 4, 0x01c2d2b3 +.insn 4, 0x0ff2f293 +.insn 2, 0x02e2 +.insn 4, 0x01e3e3b3 +.insn 4, 0x005fefb3 +.insn 4, 0x01f3e3b3 +.insn 2, 0x979e +.insn 4, 0x80088893 +.insn 4, 0xc0088893 +.insn 2, 0x8f3d +.insn 4, 0x00d6eeb3 +.insn 4, 0x00e766b3 +.insn 4, 0x01dee733 +.insn 2, 0x0811 +.insn 4, 0x41180eb3 +.insn 4, 0x801e8e93 +.insn 4, 0x801e8e93 +.insn 4, 0xfbee8e93 +bnez t4, 213b +.insn 4, 0x00086e83 +.insn 4, 0x01d6ceb3 +.insn 4, 0x00486683 +.insn 2, 0x8eb9 +.insn 4, 0x01dee733 +.insn 4, 0x0186de93 +.insn 4, 0x01d58023 +.insn 4, 0x0106de93 +.insn 4, 0x01d580a3 +.insn 4, 0x0086de93 +.insn 4, 0x01d58123 +.insn 4, 0x0006de93 +.insn 4, 0x01d581a3 +.insn 4, 0x01875e93 +.insn 4, 0x01d58223 +.insn 4, 0x01075e93 +.insn 4, 0x01d582a3 +.insn 4, 0x00875e93 +.insn 4, 0x01d58323 +.insn 4, 0x00075e93 +.insn 4, 0x01d583a3 +.insn 2, 0x05a1 +.insn 2, 0x167d +.insn 2, 0x42a1 +bltu s3, t0, 214f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00096283 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 215f +214: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +216: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 216b +215: +bnez s3, 212b +j 211f +210: +211: +22: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 4, 0x21000393 +217: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 217b +.insn 4, 0x7f010113 +.insn 4, 0x7f010113 +.insn 2, 0x610d +.insn 2, 0x8082 +.option pop", + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/camellia_ctr.rs b/crates/verified-garbage-asm-riscv64/src/camellia_ctr.rs index 7a3b7c9d9d2..d85d5efe288 100644 --- a/crates/verified-garbage-asm-riscv64/src/camellia_ctr.rs +++ b/crates/verified-garbage-asm-riscv64/src/camellia_ctr.rs @@ -22477,3 +22477,90 @@ bnez t2, 269b .option pop", ) } + +/// Camellia-CTR encryption or decryption (NIST SP 800-38A §6.5, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ctrFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 3328 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ctr_final(schedule: *const [u8; 272], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x715d +.insn 2, 0x878a +.insn 4, 0x0017b023 +.insn 2, 0xe784 +.insn 4, 0x0127b823 +.insn 4, 0x0137bc23 +.insn 4, 0x0347b023 +.insn 4, 0x0357b423 +.insn 4, 0x0367b823 +.insn 4, 0x0377bc23 +.insn 2, 0x84aa +.insn 2, 0x8a2e +.insn 2, 0x8ab2 +.insn 2, 0x8bbe +.insn 4, 0x00475293 +.insn 4, 0x00429313 +.insn 4, 0x00668933 +.insn 4, 0x406709b3 +.insn 2, 0x8716 +call {vg_camellia_ctr} +beqz s3, 20f +.insn 2, 0x4281 +.insn 4, 0x045bb023 +.insn 4, 0x045bb423 +.insn 2, 0x8526 +.insn 2, 0x85d2 +.insn 2, 0x8656 +.insn 4, 0x040b8693 +.insn 2, 0x4705 +call {vg_camellia_ctr} +.insn 4, 0x040b8393 +22: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 22b +j 21f +20: +21: +.insn 4, 0x000bb083 +.insn 4, 0x008bb483 +.insn 4, 0x010bb903 +.insn 4, 0x018bb983 +.insn 4, 0x020bba03 +.insn 4, 0x028bba83 +.insn 4, 0x030bbb03 +.insn 4, 0x038bbb83 +.insn 2, 0x8f0a +.insn 2, 0x4f81 +.insn 4, 0x01ff3023 +.insn 4, 0x01ff3423 +.insn 4, 0x01ff3823 +.insn 4, 0x01ff3c23 +.insn 4, 0x03ff3023 +.insn 4, 0x03ff3423 +.insn 4, 0x03ff3823 +.insn 4, 0x03ff3c23 +.insn 4, 0x05ff3023 +.insn 4, 0x05ff3423 +.insn 2, 0x6161 +.insn 2, 0x8082 +.option pop", + vg_camellia_ctr = sym super::camellia_ctr::vg_camellia_ctr, + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/camellia_ofb.rs b/crates/verified-garbage-asm-riscv64/src/camellia_ofb.rs index d71f672ff5b..2a76e6a316c 100644 --- a/crates/verified-garbage-asm-riscv64/src/camellia_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/camellia_ofb.rs @@ -9821,3 +9821,9914 @@ bnez t2, 241b .option pop", ) } + +/// Camellia-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 3248 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ofb_final(schedule: *const [u8; 272], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x82ae +.insn 2, 0x85b2 +.insn 2, 0x8636 +.insn 2, 0x86ba +.insn 2, 0x12b9 +beqz t0, 20f +.insn 4, 0x81010113 +.insn 4, 0xb4010113 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2423 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2623 +.insn 2, 0x8932 +.insn 4, 0x030a0293 +.insn 4, 0x301a3823 +.insn 4, 0x30aa3c23 +.insn 2, 0x8626 +.insn 2, 0x86ca +.insn 2, 0x80ce +.insn 2, 0x45e1 +.insn 2, 0x8796 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x2d87b023 +.insn 4, 0x2d97b423 +.insn 4, 0x2da7b823 +.insn 4, 0x2db7bc23 +.insn 4, 0x00ff02b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0x00ff0337 +.insn 4, 0x0ff3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857b023 +.insn 4, 0xff0102b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0xff010337 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857b423 +.insn 4, 0x010002b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857b823 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x01000337 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857bc23 +.insn 4, 0x000002b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0xff000337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1a57b023 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 2, 0x7341 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1a57b423 +.insn 2, 0x62c1 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1a57b823 +.insn 4, 0x555552b7 +.insn 4, 0x5552829b +.insn 2, 0x1282 +.insn 4, 0x55555337 +.insn 4, 0x5553031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1c57b023 +.insn 4, 0x333332b7 +.insn 4, 0x3332829b +.insn 2, 0x1282 +.insn 4, 0x33333337 +.insn 4, 0x3333031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1c57b423 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1c57b823 +.insn 4, 0xfee58293 +beqz t0, 22f +.insn 4, 0x60078713 +.insn 4, 0x60070713 +.insn 4, 0x02200313 +j 23f +22: +.insn 4, 0x60078713 +.insn 4, 0x40070713 +.insn 2, 0x4369 +23: +.insn 4, 0x40078593 +24: +.insn 4, 0x00054403 +.insn 4, 0x00154283 +.insn 2, 0x02a2 +.insn 4, 0x00546433 +.insn 4, 0x00254283 +.insn 2, 0x02c2 +.insn 4, 0x00546433 +.insn 4, 0x00354283 +.insn 2, 0x02e2 +.insn 4, 0x00546433 +.insn 4, 0x00454383 +.insn 4, 0x00554283 +.insn 2, 0x02a2 +.insn 4, 0x0053e3b3 +.insn 4, 0x00654283 +.insn 2, 0x02c2 +.insn 4, 0x0053e3b3 +.insn 4, 0x00754283 +.insn 2, 0x02e2 +.insn 4, 0x0053e3b3 +.insn 2, 0x1382 +.insn 4, 0x00746433 +.insn 2, 0x84a2 +.insn 2, 0x8922 +.insn 2, 0x89a2 +.insn 2, 0x8a22 +.insn 2, 0x8aa2 +.insn 2, 0x8b22 +.insn 2, 0x8ba2 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0xe180 +.insn 2, 0xe584 +.insn 4, 0x0125b823 +.insn 4, 0x0135bc23 +.insn 4, 0x0345b023 +.insn 4, 0x0355b423 +.insn 4, 0x0365b823 +.insn 4, 0x0375bc23 +.insn 4, 0x04058593 +.insn 2, 0x0521 +.insn 2, 0x137d +bnez t1, 24b +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x2c07bc03 +.insn 4, 0x2c87bc83 +.insn 4, 0x2d07bd03 +.insn 4, 0x2d87bd83 +.insn 2, 0x84b2 +.insn 2, 0x8936 +.insn 2, 0x8986 +.insn 4, 0xfd078a13 +.insn 4, 0x2e07b083 +.insn 4, 0x2e87b503 +.insn 4, 0x00397293 +beqz t0, 25f +beqz s3, 27f +29: +.insn 4, 0x020a6283 +.insn 4, 0x325a2823 +.insn 4, 0x024a6283 +.insn 4, 0x325a2a23 +.insn 4, 0x028a6283 +.insn 4, 0x325a2c23 +.insn 4, 0x02ca6283 +.insn 4, 0x325a2e23 +.insn 4, 0x030a0293 +.insn 4, 0x301a3823 +.insn 4, 0x30aa3c23 +.insn 2, 0x8626 +.insn 2, 0x86ca +.insn 2, 0x80ce +.insn 2, 0x8796 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x2d87b023 +.insn 4, 0x2d97b423 +.insn 4, 0x2da7b823 +.insn 4, 0x2db7bc23 +.insn 4, 0x60078713 +.insn 4, 0x60070713 +.insn 4, 0x40078593 +.insn 4, 0x3087b403 +.insn 4, 0x3187b483 +.insn 4, 0x3287b903 +.insn 4, 0x3387b983 +.insn 4, 0x3487ba03 +.insn 4, 0x3587ba83 +.insn 4, 0x3687bb03 +.insn 4, 0x3787bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3107b483 +.insn 4, 0x3207b903 +.insn 4, 0x3307b983 +.insn 4, 0x3407ba03 +.insn 4, 0x3507ba83 +.insn 4, 0x3607bb03 +.insn 4, 0x3707bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x2407b283 +.insn 4, 0x0405be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b023 +.insn 4, 0x2487b283 +.insn 4, 0x0485be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b423 +.insn 4, 0x2507b283 +.insn 4, 0x0505be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b823 +.insn 4, 0x2587b283 +.insn 4, 0x0585be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457bc23 +.insn 4, 0x2607b283 +.insn 4, 0x0605be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b023 +.insn 4, 0x2687b283 +.insn 4, 0x0685be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b423 +.insn 4, 0x2707b283 +.insn 4, 0x0705be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b823 +.insn 4, 0x2787b283 +.insn 4, 0x0785be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657bc23 +.insn 4, 0x08058593 +210: +.insn 4, 0x18058513 +211: +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2497b423 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x2527b823 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2537bc23 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2747b023 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x2757b423 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2767b823 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2777bc23 +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2097b423 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x2127b823 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2137bc23 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2347b023 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x2357b423 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2367b823 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +.insn 4, 0x40a582b3 +bnez t0, 211b +.insn 4, 0x40e582b3 +bnez t0, 212f +j 213f +212: +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x1807b383 +.insn 4, 0x0785be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0705be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0685be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0605be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0585be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0505be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0485be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0405be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0705be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0685be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0605be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0585be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0505be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0485be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0405be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0785be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2087b483 +.insn 4, 0x2107b903 +.insn 4, 0x2187b983 +.insn 4, 0x2207ba03 +.insn 4, 0x2287ba83 +.insn 4, 0x2307bb03 +.insn 4, 0x2387bb83 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0305be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0285be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0205be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0185be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0105be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0085be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0005be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0385be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1807b383 +.insn 4, 0x0385be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0305be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0285be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0205be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0185be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0105be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0085be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0005be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +213: +.insn 4, 0x40e582b3 +bnez t0, 210b +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3547b423 +.insn 4, 0x3557bc23 +.insn 4, 0x3767b423 +.insn 4, 0x3777bc23 +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b023 +.insn 4, 0x3097b823 +.insn 4, 0x3327b023 +.insn 4, 0x3337b823 +.insn 4, 0x3547b023 +.insn 4, 0x3557b823 +.insn 4, 0x3767b023 +.insn 4, 0x3777b823 +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x2c07bc03 +.insn 4, 0x2c87bc83 +.insn 4, 0x2d07bd03 +.insn 4, 0x2d87bd83 +.insn 2, 0x84b2 +.insn 2, 0x8936 +.insn 2, 0x8986 +.insn 4, 0xfd078a13 +.insn 4, 0x2e07b083 +.insn 4, 0x2e87b503 +.insn 2, 0x42c1 +bltu s3, t0, 214f +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x330a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x334a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x338a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x33ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 215f +214: +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x330a0393 +216: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 216b +215: +bnez s3, 29b +j 28f +27: +28: +j 26f +25: +beqz s3, 217f +219: +.insn 4, 0x020a6283 +.insn 4, 0x325a2823 +.insn 4, 0x024a6283 +.insn 4, 0x325a2a23 +.insn 4, 0x028a6283 +.insn 4, 0x325a2c23 +.insn 4, 0x02ca6283 +.insn 4, 0x325a2e23 +.insn 4, 0x030a0293 +.insn 4, 0x301a3823 +.insn 4, 0x30aa3c23 +.insn 2, 0x8626 +.insn 2, 0x86ca +.insn 2, 0x80ce +.insn 2, 0x8796 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x2d87b023 +.insn 4, 0x2d97b423 +.insn 4, 0x2da7b823 +.insn 4, 0x2db7bc23 +.insn 4, 0x60078713 +.insn 4, 0x60070713 +.insn 4, 0x40078593 +.insn 4, 0x3087b403 +.insn 4, 0x3187b483 +.insn 4, 0x3287b903 +.insn 4, 0x3387b983 +.insn 4, 0x3487ba03 +.insn 4, 0x3587ba83 +.insn 4, 0x3687bb03 +.insn 4, 0x3787bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3107b483 +.insn 4, 0x3207b903 +.insn 4, 0x3307b983 +.insn 4, 0x3407ba03 +.insn 4, 0x3507ba83 +.insn 4, 0x3607bb03 +.insn 4, 0x3707bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x2407b283 +.insn 4, 0x0405be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b023 +.insn 4, 0x2487b283 +.insn 4, 0x0485be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b423 +.insn 4, 0x2507b283 +.insn 4, 0x0505be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b823 +.insn 4, 0x2587b283 +.insn 4, 0x0585be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457bc23 +.insn 4, 0x2607b283 +.insn 4, 0x0605be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b023 +.insn 4, 0x2687b283 +.insn 4, 0x0685be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b423 +.insn 4, 0x2707b283 +.insn 4, 0x0705be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b823 +.insn 4, 0x2787b283 +.insn 4, 0x0785be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657bc23 +.insn 4, 0x08058593 +220: +.insn 4, 0x18058513 +221: +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2497b423 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x2527b823 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2537bc23 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2747b023 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x2757b423 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2767b823 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2777bc23 +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2097b423 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x2127b823 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2137bc23 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2347b023 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x2357b423 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2367b823 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +.insn 4, 0x40a582b3 +bnez t0, 221b +.insn 4, 0x40e582b3 +bnez t0, 222f +j 223f +222: +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x1807b383 +.insn 4, 0x0785be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0705be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0685be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0605be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0585be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0505be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0485be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0405be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0705be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0685be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0605be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0585be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0505be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0485be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0405be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0785be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2087b483 +.insn 4, 0x2107b903 +.insn 4, 0x2187b983 +.insn 4, 0x2207ba03 +.insn 4, 0x2287ba83 +.insn 4, 0x2307bb03 +.insn 4, 0x2387bb83 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0305be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0285be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0205be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0185be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0105be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0085be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0005be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0385be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1807b383 +.insn 4, 0x0385be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0305be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0285be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0205be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0185be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0105be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0085be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0005be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +223: +.insn 4, 0x40e582b3 +bnez t0, 220b +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3547b423 +.insn 4, 0x3557bc23 +.insn 4, 0x3767b423 +.insn 4, 0x3777bc23 +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b023 +.insn 4, 0x3097b823 +.insn 4, 0x3327b023 +.insn 4, 0x3337b823 +.insn 4, 0x3547b023 +.insn 4, 0x3557b823 +.insn 4, 0x3767b023 +.insn 4, 0x3777b823 +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x2c07bc03 +.insn 4, 0x2c87bc83 +.insn 4, 0x2d07bd03 +.insn 4, 0x2d87bd83 +.insn 2, 0x84b2 +.insn 2, 0x8936 +.insn 2, 0x8986 +.insn 4, 0xfd078a13 +.insn 4, 0x2e07b083 +.insn 4, 0x2e87b503 +.insn 2, 0x42c1 +bltu s3, t0, 224f +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x00096283 +.insn 4, 0x330a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x334a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 4, 0x00896283 +.insn 4, 0x338a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592423 +.insn 4, 0x00c96283 +.insn 4, 0x33ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592623 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 225f +224: +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x330a0393 +226: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 226b +225: +bnez s3, 219b +j 218f +217: +218: +26: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x028a6283 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x02ca6283 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 4, 0x19600393 +227: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 227b +.insn 4, 0x4c010113 +.insn 4, 0x7f010113 +j 21f +20: +.insn 4, 0x81010113 +.insn 4, 0xb4010113 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2423 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2623 +.insn 2, 0x8932 +.insn 4, 0x030a0293 +.insn 4, 0x301a3823 +.insn 4, 0x30aa3c23 +.insn 2, 0x8626 +.insn 2, 0x86ca +.insn 2, 0x80ce +.insn 2, 0x45c9 +.insn 2, 0x8796 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x2d87b023 +.insn 4, 0x2d97b423 +.insn 4, 0x2da7b823 +.insn 4, 0x2db7bc23 +.insn 4, 0x00ff02b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0x00ff0337 +.insn 4, 0x0ff3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857b023 +.insn 4, 0xff0102b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0xff010337 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857b423 +.insn 4, 0x010002b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857b823 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x01000337 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1857bc23 +.insn 4, 0x000002b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0xff000337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1a57b023 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 2, 0x7341 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1a57b423 +.insn 2, 0x62c1 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1a57b823 +.insn 4, 0x555552b7 +.insn 4, 0x5552829b +.insn 2, 0x1282 +.insn 4, 0x55555337 +.insn 4, 0x5553031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1c57b023 +.insn 4, 0x333332b7 +.insn 4, 0x3332829b +.insn 2, 0x1282 +.insn 4, 0x33333337 +.insn 4, 0x3333031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1c57b423 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x1c57b823 +.insn 4, 0xfee58293 +beqz t0, 228f +.insn 4, 0x60078713 +.insn 4, 0x60070713 +.insn 4, 0x02200313 +j 229f +228: +.insn 4, 0x60078713 +.insn 4, 0x40070713 +.insn 2, 0x4369 +229: +.insn 4, 0x40078593 +230: +.insn 4, 0x00054403 +.insn 4, 0x00154283 +.insn 2, 0x02a2 +.insn 4, 0x00546433 +.insn 4, 0x00254283 +.insn 2, 0x02c2 +.insn 4, 0x00546433 +.insn 4, 0x00354283 +.insn 2, 0x02e2 +.insn 4, 0x00546433 +.insn 4, 0x00454383 +.insn 4, 0x00554283 +.insn 2, 0x02a2 +.insn 4, 0x0053e3b3 +.insn 4, 0x00654283 +.insn 2, 0x02c2 +.insn 4, 0x0053e3b3 +.insn 4, 0x00754283 +.insn 2, 0x02e2 +.insn 4, 0x0053e3b3 +.insn 2, 0x1382 +.insn 4, 0x00746433 +.insn 2, 0x84a2 +.insn 2, 0x8922 +.insn 2, 0x89a2 +.insn 2, 0x8a22 +.insn 2, 0x8aa2 +.insn 2, 0x8b22 +.insn 2, 0x8ba2 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0xe180 +.insn 2, 0xe584 +.insn 4, 0x0125b823 +.insn 4, 0x0135bc23 +.insn 4, 0x0345b023 +.insn 4, 0x0355b423 +.insn 4, 0x0365b823 +.insn 4, 0x0375bc23 +.insn 4, 0x04058593 +.insn 2, 0x0521 +.insn 2, 0x137d +bnez t1, 230b +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x2c07bc03 +.insn 4, 0x2c87bc83 +.insn 4, 0x2d07bd03 +.insn 4, 0x2d87bd83 +.insn 2, 0x84b2 +.insn 2, 0x8936 +.insn 2, 0x8986 +.insn 4, 0xfd078a13 +.insn 4, 0x2e07b083 +.insn 4, 0x2e87b503 +.insn 4, 0x00397293 +beqz t0, 231f +beqz s3, 233f +235: +.insn 4, 0x020a6283 +.insn 4, 0x325a2823 +.insn 4, 0x024a6283 +.insn 4, 0x325a2a23 +.insn 4, 0x028a6283 +.insn 4, 0x325a2c23 +.insn 4, 0x02ca6283 +.insn 4, 0x325a2e23 +.insn 4, 0x030a0293 +.insn 4, 0x301a3823 +.insn 4, 0x30aa3c23 +.insn 2, 0x8626 +.insn 2, 0x86ca +.insn 2, 0x80ce +.insn 2, 0x8796 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x2d87b023 +.insn 4, 0x2d97b423 +.insn 4, 0x2da7b823 +.insn 4, 0x2db7bc23 +.insn 4, 0x60078713 +.insn 4, 0x40070713 +.insn 4, 0x40078593 +.insn 4, 0x3087b403 +.insn 4, 0x3187b483 +.insn 4, 0x3287b903 +.insn 4, 0x3387b983 +.insn 4, 0x3487ba03 +.insn 4, 0x3587ba83 +.insn 4, 0x3687bb03 +.insn 4, 0x3787bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3107b483 +.insn 4, 0x3207b903 +.insn 4, 0x3307b983 +.insn 4, 0x3407ba03 +.insn 4, 0x3507ba83 +.insn 4, 0x3607bb03 +.insn 4, 0x3707bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x2407b283 +.insn 4, 0x0405be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b023 +.insn 4, 0x2487b283 +.insn 4, 0x0485be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b423 +.insn 4, 0x2507b283 +.insn 4, 0x0505be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b823 +.insn 4, 0x2587b283 +.insn 4, 0x0585be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457bc23 +.insn 4, 0x2607b283 +.insn 4, 0x0605be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b023 +.insn 4, 0x2687b283 +.insn 4, 0x0685be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b423 +.insn 4, 0x2707b283 +.insn 4, 0x0705be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b823 +.insn 4, 0x2787b283 +.insn 4, 0x0785be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657bc23 +.insn 4, 0x08058593 +236: +.insn 4, 0x18058513 +237: +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2497b423 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x2527b823 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2537bc23 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2747b023 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x2757b423 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2767b823 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2777bc23 +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2097b423 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x2127b823 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2137bc23 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2347b023 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x2357b423 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2367b823 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +.insn 4, 0x40a582b3 +bnez t0, 237b +.insn 4, 0x40e582b3 +bnez t0, 238f +j 239f +238: +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x1807b383 +.insn 4, 0x0785be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0705be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0685be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0605be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0585be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0505be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0485be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0405be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0705be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0685be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0605be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0585be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0505be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0485be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0405be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0785be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2087b483 +.insn 4, 0x2107b903 +.insn 4, 0x2187b983 +.insn 4, 0x2207ba03 +.insn 4, 0x2287ba83 +.insn 4, 0x2307bb03 +.insn 4, 0x2387bb83 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0305be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0285be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0205be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0185be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0105be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0085be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0005be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0385be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1807b383 +.insn 4, 0x0385be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0305be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0285be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0205be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0185be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0105be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0085be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0005be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +239: +.insn 4, 0x40e582b3 +bnez t0, 236b +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3547b423 +.insn 4, 0x3557bc23 +.insn 4, 0x3767b423 +.insn 4, 0x3777bc23 +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b023 +.insn 4, 0x3097b823 +.insn 4, 0x3327b023 +.insn 4, 0x3337b823 +.insn 4, 0x3547b023 +.insn 4, 0x3557b823 +.insn 4, 0x3767b023 +.insn 4, 0x3777b823 +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x2c07bc03 +.insn 4, 0x2c87bc83 +.insn 4, 0x2d07bd03 +.insn 4, 0x2d87bd83 +.insn 2, 0x84b2 +.insn 2, 0x8936 +.insn 2, 0x8986 +.insn 4, 0xfd078a13 +.insn 4, 0x2e07b083 +.insn 4, 0x2e87b503 +.insn 2, 0x42c1 +bltu s3, t0, 240f +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x330a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x334a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x338a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x33ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 241f +240: +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x330a0393 +242: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 242b +241: +bnez s3, 235b +j 234f +233: +234: +j 232f +231: +beqz s3, 243f +245: +.insn 4, 0x020a6283 +.insn 4, 0x325a2823 +.insn 4, 0x024a6283 +.insn 4, 0x325a2a23 +.insn 4, 0x028a6283 +.insn 4, 0x325a2c23 +.insn 4, 0x02ca6283 +.insn 4, 0x325a2e23 +.insn 4, 0x030a0293 +.insn 4, 0x301a3823 +.insn 4, 0x30aa3c23 +.insn 2, 0x8626 +.insn 2, 0x86ca +.insn 2, 0x80ce +.insn 2, 0x8796 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x2d87b023 +.insn 4, 0x2d97b423 +.insn 4, 0x2da7b823 +.insn 4, 0x2db7bc23 +.insn 4, 0x60078713 +.insn 4, 0x40070713 +.insn 4, 0x40078593 +.insn 4, 0x3087b403 +.insn 4, 0x3187b483 +.insn 4, 0x3287b903 +.insn 4, 0x3387b983 +.insn 4, 0x3487ba03 +.insn 4, 0x3587ba83 +.insn 4, 0x3687bb03 +.insn 4, 0x3787bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3107b483 +.insn 4, 0x3207b903 +.insn 4, 0x3307b983 +.insn 4, 0x3407ba03 +.insn 4, 0x3507ba83 +.insn 4, 0x3607bb03 +.insn 4, 0x3707bb83 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x2407b283 +.insn 4, 0x0405be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b023 +.insn 4, 0x2487b283 +.insn 4, 0x0485be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b423 +.insn 4, 0x2507b283 +.insn 4, 0x0505be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457b823 +.insn 4, 0x2587b283 +.insn 4, 0x0585be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2457bc23 +.insn 4, 0x2607b283 +.insn 4, 0x0605be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b023 +.insn 4, 0x2687b283 +.insn 4, 0x0685be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b423 +.insn 4, 0x2707b283 +.insn 4, 0x0705be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657b823 +.insn 4, 0x2787b283 +.insn 4, 0x0785be03 +.insn 4, 0x01c2c2b3 +.insn 4, 0x2657bc23 +.insn 4, 0x08058593 +246: +.insn 4, 0x18058513 +247: +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2497b423 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x2527b823 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2537bc23 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2747b023 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x2757b423 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2767b823 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2777bc23 +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1907b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x009bc2b3 +.insn 4, 0x013ac333 +.insn 4, 0x005943b3 +.insn 4, 0x008b4e33 +.insn 4, 0x00644eb3 +.insn 4, 0x009a4f33 +.insn 4, 0x007a4fb3 +.insn 4, 0x006b4833 +.insn 4, 0x01c948b3 +.insn 4, 0x01c3cc33 +.insn 4, 0x016bccb3 +.insn 4, 0x01cbcd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x013b4db3 +.insn 4, 0x01a7b023 +.insn 4, 0x009acd33 +.insn 4, 0x0177b423 +.insn 4, 0x008acbb3 +.insn 4, 0x007acab3 +.insn 4, 0x01ca4e33 +.insn 4, 0x019a4a33 +.insn 4, 0x0089c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x01d94433 +.insn 4, 0x01e94933 +.insn 4, 0xfff94913 +.insn 4, 0x0104ccb3 +.insn 4, 0xfffccc93 +.insn 4, 0x0197b823 +.insn 4, 0x01d2ccb3 +.insn 4, 0x0102c2b3 +.insn 4, 0x01e34833 +.insn 4, 0x0197bc23 +.insn 4, 0x01f34cb3 +.insn 4, 0x01834333 +.insn 4, 0x0267b023 +.insn 4, 0x01d3c333 +.insn 4, 0xfff34313 +.insn 4, 0x01b3c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x01eeceb3 +.insn 4, 0xfffece93 +.insn 4, 0x017fcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01a8cd33 +.insn 4, 0xfffd4d13 +.insn 4, 0x0108c8b3 +.insn 4, 0xfff8c893 +.insn 4, 0x0087b803 +.insn 4, 0x01684f33 +.insn 4, 0xffff4f13 +.insn 4, 0x016f4f33 +.insn 4, 0x00984833 +.insn 4, 0xfff84813 +.insn 4, 0x014974b3 +.insn 4, 0x01af7b33 +.insn 4, 0x009b4b33 +.insn 4, 0x017ffdb3 +.insn 4, 0x009dcdb3 +.insn 4, 0x006474b3 +.insn 2, 0xe780 +.insn 4, 0x0152f433 +.insn 2, 0x8c25 +.insn 4, 0x0257b423 +.insn 4, 0x013c72b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x019e74b3 +.insn 4, 0x03c7b823 +.insn 4, 0x011efe33 +.insn 4, 0x009e4e33 +.insn 4, 0x03d7bc23 +.insn 4, 0x0107be83 +.insn 4, 0x0587b023 +.insn 4, 0x0007bc03 +.insn 4, 0x05f7b423 +.insn 4, 0x018effb3 +.insn 4, 0x009fcfb3 +.insn 4, 0x01cb4b33 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01c44433 +.insn 4, 0x01f2c2b3 +.insn 4, 0x0207bf83 +.insn 4, 0x01fb4b33 +.insn 4, 0x0187bf83 +.insn 4, 0x01fdcdb3 +.insn 4, 0x01044433 +.insn 4, 0x0072c2b3 +.insn 4, 0x01bb43b3 +.insn 4, 0x008b7b33 +.insn 4, 0x0162c833 +.insn 4, 0x0103ffb3 +.insn 4, 0x01bfcfb3 +.insn 4, 0x00544e33 +.insn 4, 0x016dcdb3 +.insn 4, 0x01cdfdb3 +.insn 4, 0x005dcdb3 +.insn 4, 0x01b44433 +.insn 4, 0x01b84e33 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0082c433 +.insn 4, 0x00584833 +.insn 4, 0x010ff833 +.insn 4, 0x0103c3b3 +.insn 4, 0x0083c833 +.insn 4, 0x01bfc2b3 +.insn 4, 0x007fce33 +.insn 4, 0x008dcb33 +.insn 4, 0x0102c4b3 +.insn 4, 0x014b7a33 +.insn 4, 0x01a47d33 +.insn 4, 0x017dfbb3 +.insn 4, 0x006e7333 +.insn 4, 0x0153fab3 +.insn 4, 0x013ff9b3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0114f8b3 +.insn 4, 0x01887c33 +.insn 4, 0x012b7b33 +.insn 4, 0x01e47433 +.insn 4, 0x0487bf03 +.insn 4, 0x01edfdb3 +.insn 4, 0x0087bf03 +.insn 4, 0x01ee7e33 +.insn 4, 0x0287bf03 +.insn 4, 0x01e3f3b3 +.insn 4, 0x0407bf03 +.insn 4, 0x01efffb3 +.insn 4, 0x0307bf03 +.insn 4, 0x01e2f2b3 +.insn 4, 0x0387bf03 +.insn 4, 0x01e4f4b3 +.insn 4, 0x01d87833 +.insn 4, 0x011d48b3 +.insn 4, 0x01334333 +.insn 4, 0x018cceb3 +.insn 4, 0x009a4f33 +.insn 4, 0x011dcdb3 +.insn 4, 0x006e4933 +.insn 4, 0x0067b823 +.insn 4, 0x01d2c333 +.insn 4, 0x01fbcfb3 +.insn 4, 0x010cccb3 +.insn 4, 0x016c4c33 +.insn 4, 0x008b4b33 +.insn 4, 0x0123c3b3 +.insn 4, 0x0064c4b3 +.insn 2, 0xff84 +.insn 4, 0x01bf44b3 +.insn 4, 0x017a4a33 +.insn 4, 0x015d4d33 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01944433 +.insn 4, 0x01be4e33 +.insn 4, 0x0112c2b3 +.insn 4, 0x01884833 +.insn 4, 0x0107b883 +.insn 4, 0x0168c8b3 +.insn 4, 0x014eca33 +.insn 4, 0x01f94933 +.insn 4, 0x01634333 +.insn 4, 0x018fcfb3 +.insn 4, 0x005cccb3 +.insn 4, 0x0387b283 +.insn 4, 0x0053cc33 +.insn 4, 0x0093c3b3 +.insn 4, 0x0112cab3 +.insn 4, 0xfffaca93 +.insn 2, 0x8ca1 +.insn 4, 0xfff4c493 +.insn 4, 0x013d4d33 +.insn 4, 0x01fe49b3 +.insn 4, 0xfff9c993 +.insn 4, 0x00784833 +.insn 4, 0xfff84813 +.insn 4, 0x01994bb3 +.insn 4, 0x01a34b33 +.insn 4, 0xfffb4b13 +.insn 2, 0x8926 +.insn 2, 0x84c2 +.insn 2, 0x8462 +.insn 4, 0x1987b383 +.insn 2, 0x835e +.insn 4, 0x016bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x015b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x014ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x013a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0129c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x009942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0084c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x006442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1a07b383 +.insn 2, 0x8322 +.insn 4, 0x009442b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0124c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x013942b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0149c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x015a42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x016ac2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x017b42b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x006bc2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x1807b383 +.insn 4, 0x1887be03 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x03845e93 +.insn 4, 0x00841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x00845e93 +.insn 4, 0x03841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 4, 0x02845e93 +.insn 4, 0x01841293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0384de93 +.insn 4, 0x00849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0084de93 +.insn 4, 0x03849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0284de93 +.insn 4, 0x01849293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x03895e93 +.insn 4, 0x00891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x00895e93 +.insn 4, 0x03891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 4, 0x02895e93 +.insn 4, 0x01891293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0389de93 +.insn 4, 0x00899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0089de93 +.insn 4, 0x03899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0289de93 +.insn 4, 0x01899293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x038a5e93 +.insn 4, 0x008a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008a5e93 +.insn 4, 0x038a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x028a5e93 +.insn 4, 0x018a1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x038ade93 +.insn 4, 0x008a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008ade93 +.insn 4, 0x038a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x028ade93 +.insn 4, 0x018a9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x038b5e93 +.insn 4, 0x008b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008b5e93 +.insn 4, 0x038b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x028b5e93 +.insn 4, 0x018b1293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x038bde93 +.insn 4, 0x008b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x008bde93 +.insn 4, 0x038b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x028bde93 +.insn 4, 0x018b9293 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2097b423 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x2127b823 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2137bc23 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2347b023 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x2357b423 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2367b823 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +.insn 4, 0x40a582b3 +bnez t0, 247b +.insn 4, 0x40e582b3 +bnez t0, 248f +j 249f +248: +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x1807b383 +.insn 4, 0x0785be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0705be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0685be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0605be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0585be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0505be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0485be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0405be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0705be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0685be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0605be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0585be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0505be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0485be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0405be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0785be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2087b483 +.insn 4, 0x2107b903 +.insn 4, 0x2187b983 +.insn 4, 0x2207ba03 +.insn 4, 0x2287ba83 +.insn 4, 0x2307bb03 +.insn 4, 0x2387bb83 +.insn 4, 0x1887b383 +.insn 2, 0x835e +.insn 4, 0x0305be03 +.insn 4, 0x01cb72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0285be03 +.insn 4, 0x01caf2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0205be03 +.insn 4, 0x01ca72b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0185be03 +.insn 4, 0x01c9f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0105be03 +.insn 4, 0x01c972b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0085be03 +.insn 4, 0x01c4f2b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0005be03 +.insn 4, 0x01c472b3 +.insn 4, 0x0382de93 +.insn 2, 0x02a2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0385be03 +.insn 4, 0x01c372b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x1807b383 +.insn 4, 0x0385be03 +.insn 4, 0x01cbe2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0305be03 +.insn 4, 0x01cb62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x0285be03 +.insn 4, 0x01cae2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x0205be03 +.insn 4, 0x01ca62b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x0185be03 +.insn 4, 0x01c9e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x0105be03 +.insn 4, 0x01c962b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00594933 +.insn 4, 0x0085be03 +.insn 4, 0x01c4e2b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0005be03 +.insn 4, 0x01c462b3 +.insn 4, 0x0082de93 +.insn 2, 0x12e2 +.insn 4, 0x01d2c2b3 +.insn 4, 0x0072f2b3 +.insn 4, 0x00544433 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x08058593 +249: +.insn 4, 0x40e582b3 +bnez t0, 246b +.insn 4, 0x0405b283 +.insn 4, 0x00544433 +.insn 4, 0x0485b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0505b283 +.insn 4, 0x00594933 +.insn 4, 0x0585b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0605b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0685b283 +.insn 4, 0x005acab3 +.insn 4, 0x0705b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0785b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3547b423 +.insn 4, 0x3557bc23 +.insn 4, 0x3767b423 +.insn 4, 0x3777bc23 +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x0005b283 +.insn 4, 0x00544433 +.insn 4, 0x0085b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0105b283 +.insn 4, 0x00594933 +.insn 4, 0x0185b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0205b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0285b283 +.insn 4, 0x005acab3 +.insn 4, 0x0305b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0385b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x1a87be03 +.insn 4, 0x1b07be83 +.insn 4, 0x1c07bf83 +.insn 4, 0x1c87b803 +.insn 4, 0x1d07b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b023 +.insn 4, 0x3097b823 +.insn 4, 0x3327b023 +.insn 4, 0x3337b823 +.insn 4, 0x3547b023 +.insn 4, 0x3557b823 +.insn 4, 0x3767b023 +.insn 4, 0x3777b823 +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x2c07bc03 +.insn 4, 0x2c87bc83 +.insn 4, 0x2d07bd03 +.insn 4, 0x2d87bd83 +.insn 2, 0x84b2 +.insn 2, 0x8936 +.insn 2, 0x8986 +.insn 4, 0xfd078a13 +.insn 4, 0x2e07b083 +.insn 4, 0x2e87b503 +.insn 2, 0x42c1 +bltu s3, t0, 250f +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x00096283 +.insn 4, 0x330a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x334a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 4, 0x00896283 +.insn 4, 0x338a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592423 +.insn 4, 0x00c96283 +.insn 4, 0x33ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592623 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 251f +250: +.insn 4, 0x330a6283 +.insn 4, 0x025a2023 +.insn 4, 0x334a6283 +.insn 4, 0x025a2223 +.insn 4, 0x338a6283 +.insn 4, 0x025a2423 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2623 +.insn 4, 0x330a0393 +252: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 252b +251: +bnez s3, 245b +j 244f +243: +244: +232: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x028a6283 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x02ca6283 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 4, 0x19600393 +253: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 253b +.insn 4, 0x4c010113 +.insn 4, 0x7f010113 +21: +.insn 2, 0x8082 +.option pop", + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/cast5_ofb.rs b/crates/verified-garbage-asm-riscv64/src/cast5_ofb.rs index eeba8c04f78..30a358a04d3 100644 --- a/crates/verified-garbage-asm-riscv64/src/cast5_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/cast5_ofb.rs @@ -1832,3 +1832,1909 @@ bnez t2, 271b VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, ) } + +/// CAST5-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 2144 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is CAST5 encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_cast5_expand_key` writes them. +/// +/// Contract: `VG.Spec.Cast5.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 12 (for a key of up to 10 bytes) or 16 (for a longer one). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 128 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_cast5_ofb_final(schedule: *const [u8; 128], rounds: usize, iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x82ae +.insn 2, 0x85b2 +.insn 2, 0x8636 +.insn 2, 0x86ba +.insn 2, 0x12d1 +beqz t0, 20f +.insn 2, 0x7119 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 2, 0x8932 +.insn 4, 0x00397293 +beqz t0, 22f +beqz s3, 24f +26: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x028a3c23 +.insn 4, 0x055a3023 +.insn 4, 0x056a3423 +.insn 4, 0x057a3823 +.insn 4, 0x058a3c23 +.insn 4, 0x079a3023 +.insn 4, 0x07aa3423 +.insn 4, 0x07ba3823 +.insn 4, 0x061a3c23 +.insn 4, 0x030a0613 +.insn 2, 0x86a6 +.insn 2, 0x874a +.insn 2, 0x8dce +.insn 2, 0x80d2 +lla t4, {VG_CAST5_S1234} +.insn 2, 0x45c1 +.insn 4, 0x00064803 +.insn 2, 0x0862 +.insn 4, 0x00164283 +.insn 2, 0x02c2 +.insn 4, 0x00586833 +.insn 4, 0x00264283 +.insn 2, 0x02a2 +.insn 4, 0x00586833 +.insn 4, 0x00364283 +.insn 4, 0x00586833 +.insn 4, 0x00464883 +.insn 2, 0x08e2 +.insn 4, 0x00564283 +.insn 2, 0x02c2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00664283 +.insn 2, 0x02a2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00764283 +.insn 4, 0x0058e8b3 +.insn 2, 0x8c2a +.insn 2, 0x8cae +.insn 2, 0x4d05 +27: +beqz s10, 28f +.insn 4, 0xfffd0293 +beqz t0, 210f +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x011f4f33 +j 211f +210: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 2, 0x9f46 +211: +j 29f +28: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x411f0f33 +29: +.insn 4, 0x040c4f83 +.insn 4, 0x02000313 +.insn 4, 0x41f30333 +.insn 4, 0x006f533b +.insn 4, 0x01ff1f3b +.insn 4, 0x006f6f33 +.insn 4, 0x0fff7413 +.insn 4, 0x008f549b +.insn 4, 0x0ff4f493 +.insn 4, 0x010f591b +.insn 4, 0x0ff97913 +.insn 4, 0x018f599b +.insn 4, 0x03f41293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e41313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d41393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c41f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 2, 0x8011 +.insn 2, 0x143d +.insn 2, 0x8091 +.insn 2, 0x14bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +212: +.insn 4, 0xf00e0e13 +.insn 2, 0x0405 +.insn 2, 0x0485 +.insn 4, 0x000e3a83 +.insn 4, 0x010e3b03 +.insn 4, 0x015b4b33 +.insn 4, 0x005b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x020e3b03 +.insn 4, 0x030e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x006b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x040e3b03 +.insn 4, 0x050e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x060e3783 +.insn 4, 0x070e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x007b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x080e3b03 +.insn 4, 0x090e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0a0e3783 +.insn 4, 0x0b0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0c0e3783 +.insn 4, 0x0d0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e0e3f83 +.insn 4, 0x0f0e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0077f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x01eb7b33 +.insn 4, 0x016acab3 +.insn 4, 0x02045b13 +.insn 4, 0x43f4d793 +.insn 2, 0x1782 +.insn 4, 0x00fb6b33 +.insn 4, 0x014acab3 +.insn 4, 0x016afab3 +.insn 4, 0x015a4a33 +bne t3, t4, 212b +.insn 4, 0x020a5a93 +.insn 2, 0x1a02 +.insn 4, 0x020a5a13 +.insn 4, 0x03f91293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e91313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d91393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c91f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 4, 0x00495913 +.insn 2, 0x193d +.insn 4, 0x0049d993 +.insn 2, 0x19bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +213: +.insn 4, 0xf00e0e13 +.insn 2, 0x0905 +.insn 2, 0x0985 +.insn 4, 0x008e3403 +.insn 4, 0x018e3483 +.insn 2, 0x8ca1 +.insn 4, 0x0054f4b3 +.insn 2, 0x8c25 +.insn 4, 0x028e3483 +.insn 4, 0x038e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0064f4b3 +.insn 2, 0x8c25 +.insn 4, 0x048e3483 +.insn 4, 0x058e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x068e3783 +.insn 4, 0x078e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0074f4b3 +.insn 2, 0x8c25 +.insn 4, 0x088e3483 +.insn 4, 0x098e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0a8e3783 +.insn 4, 0x0b8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0c8e3783 +.insn 4, 0x0d8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e8e3f83 +.insn 4, 0x0f8e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0077f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x01e4f4b3 +.insn 2, 0x8c25 +.insn 4, 0x02095493 +.insn 4, 0x43f9d793 +.insn 2, 0x1782 +.insn 2, 0x8cdd +.insn 4, 0x01644433 +.insn 2, 0x8c65 +.insn 4, 0x008b4b33 +bne t3, t4, 213b +.insn 4, 0x020b5b93 +.insn 2, 0x1b02 +.insn 4, 0x020b5b13 +beqz s10, 214f +.insn 4, 0xfffd0293 +beqz t0, 216f +.insn 4, 0x416b8f33 +.insn 2, 0x9f56 +.insn 4, 0x014f4f33 +j 217f +216: +.insn 4, 0x016bcf33 +.insn 4, 0x415f0f33 +.insn 2, 0x9f52 +217: +j 215f +214: +.insn 4, 0x016b8f33 +.insn 4, 0x015f4f33 +.insn 4, 0x414f0f33 +215: +.insn 4, 0x010f4f33 +.insn 2, 0x8846 +.insn 2, 0x88fa +.insn 2, 0x0c11 +.insn 4, 0xffed0293 +beqz t0, 218f +.insn 2, 0x0d05 +j 219f +218: +.insn 2, 0x4d01 +219: +.insn 2, 0x1cfd +bnez s9, 27b +.insn 4, 0x0188d293 +.insn 4, 0x00560023 +.insn 4, 0x0108d293 +.insn 4, 0x005600a3 +.insn 4, 0x0088d293 +.insn 4, 0x00560123 +.insn 4, 0x0008d293 +.insn 4, 0x005601a3 +.insn 4, 0x01885293 +.insn 4, 0x00560223 +.insn 4, 0x01085293 +.insn 4, 0x005602a3 +.insn 4, 0x00885293 +.insn 4, 0x00560323 +.insn 4, 0x00085293 +.insn 4, 0x005603a3 +.insn 2, 0x84b6 +.insn 2, 0x893a +.insn 2, 0x89ee +.insn 2, 0x8a06 +.insn 4, 0x038a3403 +.insn 4, 0x040a3a83 +.insn 4, 0x048a3b03 +.insn 4, 0x050a3b83 +.insn 4, 0x058a3c03 +.insn 4, 0x060a3c83 +.insn 4, 0x068a3d03 +.insn 4, 0x070a3d83 +.insn 4, 0x078a3083 +.insn 2, 0x42a1 +bltu s3, t0, 220f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 221f +220: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +222: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 222b +221: +bnez s3, 26b +j 25f +24: +25: +j 23f +22: +beqz s3, 223f +225: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x028a3c23 +.insn 4, 0x055a3023 +.insn 4, 0x056a3423 +.insn 4, 0x057a3823 +.insn 4, 0x058a3c23 +.insn 4, 0x079a3023 +.insn 4, 0x07aa3423 +.insn 4, 0x07ba3823 +.insn 4, 0x061a3c23 +.insn 4, 0x030a0613 +.insn 2, 0x86a6 +.insn 2, 0x874a +.insn 2, 0x8dce +.insn 2, 0x80d2 +lla t4, {VG_CAST5_S1234} +.insn 2, 0x45c1 +.insn 4, 0x00064803 +.insn 2, 0x0862 +.insn 4, 0x00164283 +.insn 2, 0x02c2 +.insn 4, 0x00586833 +.insn 4, 0x00264283 +.insn 2, 0x02a2 +.insn 4, 0x00586833 +.insn 4, 0x00364283 +.insn 4, 0x00586833 +.insn 4, 0x00464883 +.insn 2, 0x08e2 +.insn 4, 0x00564283 +.insn 2, 0x02c2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00664283 +.insn 2, 0x02a2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00764283 +.insn 4, 0x0058e8b3 +.insn 2, 0x8c2a +.insn 2, 0x8cae +.insn 2, 0x4d05 +226: +beqz s10, 227f +.insn 4, 0xfffd0293 +beqz t0, 229f +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x011f4f33 +j 230f +229: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 2, 0x9f46 +230: +j 228f +227: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x411f0f33 +228: +.insn 4, 0x040c4f83 +.insn 4, 0x02000313 +.insn 4, 0x41f30333 +.insn 4, 0x006f533b +.insn 4, 0x01ff1f3b +.insn 4, 0x006f6f33 +.insn 4, 0x0fff7413 +.insn 4, 0x008f549b +.insn 4, 0x0ff4f493 +.insn 4, 0x010f591b +.insn 4, 0x0ff97913 +.insn 4, 0x018f599b +.insn 4, 0x03f41293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e41313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d41393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c41f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 2, 0x8011 +.insn 2, 0x143d +.insn 2, 0x8091 +.insn 2, 0x14bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +231: +.insn 4, 0xf00e0e13 +.insn 2, 0x0405 +.insn 2, 0x0485 +.insn 4, 0x000e3a83 +.insn 4, 0x010e3b03 +.insn 4, 0x015b4b33 +.insn 4, 0x005b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x020e3b03 +.insn 4, 0x030e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x006b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x040e3b03 +.insn 4, 0x050e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x060e3783 +.insn 4, 0x070e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x007b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x080e3b03 +.insn 4, 0x090e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0a0e3783 +.insn 4, 0x0b0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0c0e3783 +.insn 4, 0x0d0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e0e3f83 +.insn 4, 0x0f0e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0077f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x01eb7b33 +.insn 4, 0x016acab3 +.insn 4, 0x02045b13 +.insn 4, 0x43f4d793 +.insn 2, 0x1782 +.insn 4, 0x00fb6b33 +.insn 4, 0x014acab3 +.insn 4, 0x016afab3 +.insn 4, 0x015a4a33 +bne t3, t4, 231b +.insn 4, 0x020a5a93 +.insn 2, 0x1a02 +.insn 4, 0x020a5a13 +.insn 4, 0x03f91293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e91313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d91393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c91f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 4, 0x00495913 +.insn 2, 0x193d +.insn 4, 0x0049d993 +.insn 2, 0x19bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +232: +.insn 4, 0xf00e0e13 +.insn 2, 0x0905 +.insn 2, 0x0985 +.insn 4, 0x008e3403 +.insn 4, 0x018e3483 +.insn 2, 0x8ca1 +.insn 4, 0x0054f4b3 +.insn 2, 0x8c25 +.insn 4, 0x028e3483 +.insn 4, 0x038e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0064f4b3 +.insn 2, 0x8c25 +.insn 4, 0x048e3483 +.insn 4, 0x058e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x068e3783 +.insn 4, 0x078e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0074f4b3 +.insn 2, 0x8c25 +.insn 4, 0x088e3483 +.insn 4, 0x098e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0a8e3783 +.insn 4, 0x0b8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0c8e3783 +.insn 4, 0x0d8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e8e3f83 +.insn 4, 0x0f8e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0077f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x01e4f4b3 +.insn 2, 0x8c25 +.insn 4, 0x02095493 +.insn 4, 0x43f9d793 +.insn 2, 0x1782 +.insn 2, 0x8cdd +.insn 4, 0x01644433 +.insn 2, 0x8c65 +.insn 4, 0x008b4b33 +bne t3, t4, 232b +.insn 4, 0x020b5b93 +.insn 2, 0x1b02 +.insn 4, 0x020b5b13 +beqz s10, 233f +.insn 4, 0xfffd0293 +beqz t0, 235f +.insn 4, 0x416b8f33 +.insn 2, 0x9f56 +.insn 4, 0x014f4f33 +j 236f +235: +.insn 4, 0x016bcf33 +.insn 4, 0x415f0f33 +.insn 2, 0x9f52 +236: +j 234f +233: +.insn 4, 0x016b8f33 +.insn 4, 0x015f4f33 +.insn 4, 0x414f0f33 +234: +.insn 4, 0x010f4f33 +.insn 2, 0x8846 +.insn 2, 0x88fa +.insn 2, 0x0c11 +.insn 4, 0xffed0293 +beqz t0, 237f +.insn 2, 0x0d05 +j 238f +237: +.insn 2, 0x4d01 +238: +.insn 2, 0x1cfd +bnez s9, 226b +.insn 4, 0x0188d293 +.insn 4, 0x00560023 +.insn 4, 0x0108d293 +.insn 4, 0x005600a3 +.insn 4, 0x0088d293 +.insn 4, 0x00560123 +.insn 4, 0x0008d293 +.insn 4, 0x005601a3 +.insn 4, 0x01885293 +.insn 4, 0x00560223 +.insn 4, 0x01085293 +.insn 4, 0x005602a3 +.insn 4, 0x00885293 +.insn 4, 0x00560323 +.insn 4, 0x00085293 +.insn 4, 0x005603a3 +.insn 2, 0x84b6 +.insn 2, 0x893a +.insn 2, 0x89ee +.insn 2, 0x8a06 +.insn 4, 0x038a3403 +.insn 4, 0x040a3a83 +.insn 4, 0x048a3b03 +.insn 4, 0x050a3b83 +.insn 4, 0x058a3c03 +.insn 4, 0x060a3c83 +.insn 4, 0x068a3d03 +.insn 4, 0x070a3d83 +.insn 4, 0x078a3083 +.insn 2, 0x42a1 +bltu s3, t0, 239f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00096283 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 240f +239: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +241: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 241b +240: +bnez s3, 225b +j 224f +223: +224: +23: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 2, 0x43c1 +242: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 242b +.insn 2, 0x6109 +j 21f +20: +.insn 2, 0x7119 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 2, 0x8932 +.insn 4, 0x00397293 +beqz t0, 243f +beqz s3, 245f +247: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x028a3c23 +.insn 4, 0x055a3023 +.insn 4, 0x056a3423 +.insn 4, 0x057a3823 +.insn 4, 0x058a3c23 +.insn 4, 0x079a3023 +.insn 4, 0x07aa3423 +.insn 4, 0x07ba3823 +.insn 4, 0x061a3c23 +.insn 4, 0x030a0613 +.insn 2, 0x86a6 +.insn 2, 0x874a +.insn 2, 0x8dce +.insn 2, 0x80d2 +lla t4, {VG_CAST5_S1234} +.insn 2, 0x45b1 +.insn 4, 0x00064803 +.insn 2, 0x0862 +.insn 4, 0x00164283 +.insn 2, 0x02c2 +.insn 4, 0x00586833 +.insn 4, 0x00264283 +.insn 2, 0x02a2 +.insn 4, 0x00586833 +.insn 4, 0x00364283 +.insn 4, 0x00586833 +.insn 4, 0x00464883 +.insn 2, 0x08e2 +.insn 4, 0x00564283 +.insn 2, 0x02c2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00664283 +.insn 2, 0x02a2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00764283 +.insn 4, 0x0058e8b3 +.insn 2, 0x8c2a +.insn 2, 0x8cae +.insn 2, 0x4d05 +248: +beqz s10, 249f +.insn 4, 0xfffd0293 +beqz t0, 251f +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x011f4f33 +j 252f +251: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 2, 0x9f46 +252: +j 250f +249: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x411f0f33 +250: +.insn 4, 0x040c4f83 +.insn 4, 0x02000313 +.insn 4, 0x41f30333 +.insn 4, 0x006f533b +.insn 4, 0x01ff1f3b +.insn 4, 0x006f6f33 +.insn 4, 0x0fff7413 +.insn 4, 0x008f549b +.insn 4, 0x0ff4f493 +.insn 4, 0x010f591b +.insn 4, 0x0ff97913 +.insn 4, 0x018f599b +.insn 4, 0x03f41293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e41313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d41393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c41f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 2, 0x8011 +.insn 2, 0x143d +.insn 2, 0x8091 +.insn 2, 0x14bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +253: +.insn 4, 0xf00e0e13 +.insn 2, 0x0405 +.insn 2, 0x0485 +.insn 4, 0x000e3a83 +.insn 4, 0x010e3b03 +.insn 4, 0x015b4b33 +.insn 4, 0x005b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x020e3b03 +.insn 4, 0x030e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x006b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x040e3b03 +.insn 4, 0x050e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x060e3783 +.insn 4, 0x070e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x007b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x080e3b03 +.insn 4, 0x090e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0a0e3783 +.insn 4, 0x0b0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0c0e3783 +.insn 4, 0x0d0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e0e3f83 +.insn 4, 0x0f0e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0077f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x01eb7b33 +.insn 4, 0x016acab3 +.insn 4, 0x02045b13 +.insn 4, 0x43f4d793 +.insn 2, 0x1782 +.insn 4, 0x00fb6b33 +.insn 4, 0x014acab3 +.insn 4, 0x016afab3 +.insn 4, 0x015a4a33 +bne t3, t4, 253b +.insn 4, 0x020a5a93 +.insn 2, 0x1a02 +.insn 4, 0x020a5a13 +.insn 4, 0x03f91293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e91313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d91393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c91f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 4, 0x00495913 +.insn 2, 0x193d +.insn 4, 0x0049d993 +.insn 2, 0x19bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +254: +.insn 4, 0xf00e0e13 +.insn 2, 0x0905 +.insn 2, 0x0985 +.insn 4, 0x008e3403 +.insn 4, 0x018e3483 +.insn 2, 0x8ca1 +.insn 4, 0x0054f4b3 +.insn 2, 0x8c25 +.insn 4, 0x028e3483 +.insn 4, 0x038e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0064f4b3 +.insn 2, 0x8c25 +.insn 4, 0x048e3483 +.insn 4, 0x058e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x068e3783 +.insn 4, 0x078e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0074f4b3 +.insn 2, 0x8c25 +.insn 4, 0x088e3483 +.insn 4, 0x098e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0a8e3783 +.insn 4, 0x0b8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0c8e3783 +.insn 4, 0x0d8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e8e3f83 +.insn 4, 0x0f8e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0077f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x01e4f4b3 +.insn 2, 0x8c25 +.insn 4, 0x02095493 +.insn 4, 0x43f9d793 +.insn 2, 0x1782 +.insn 2, 0x8cdd +.insn 4, 0x01644433 +.insn 2, 0x8c65 +.insn 4, 0x008b4b33 +bne t3, t4, 254b +.insn 4, 0x020b5b93 +.insn 2, 0x1b02 +.insn 4, 0x020b5b13 +beqz s10, 255f +.insn 4, 0xfffd0293 +beqz t0, 257f +.insn 4, 0x416b8f33 +.insn 2, 0x9f56 +.insn 4, 0x014f4f33 +j 258f +257: +.insn 4, 0x016bcf33 +.insn 4, 0x415f0f33 +.insn 2, 0x9f52 +258: +j 256f +255: +.insn 4, 0x016b8f33 +.insn 4, 0x015f4f33 +.insn 4, 0x414f0f33 +256: +.insn 4, 0x010f4f33 +.insn 2, 0x8846 +.insn 2, 0x88fa +.insn 2, 0x0c11 +.insn 4, 0xffed0293 +beqz t0, 259f +.insn 2, 0x0d05 +j 260f +259: +.insn 2, 0x4d01 +260: +.insn 2, 0x1cfd +bnez s9, 248b +.insn 4, 0x0188d293 +.insn 4, 0x00560023 +.insn 4, 0x0108d293 +.insn 4, 0x005600a3 +.insn 4, 0x0088d293 +.insn 4, 0x00560123 +.insn 4, 0x0008d293 +.insn 4, 0x005601a3 +.insn 4, 0x01885293 +.insn 4, 0x00560223 +.insn 4, 0x01085293 +.insn 4, 0x005602a3 +.insn 4, 0x00885293 +.insn 4, 0x00560323 +.insn 4, 0x00085293 +.insn 4, 0x005603a3 +.insn 2, 0x84b6 +.insn 2, 0x893a +.insn 2, 0x89ee +.insn 2, 0x8a06 +.insn 4, 0x038a3403 +.insn 4, 0x040a3a83 +.insn 4, 0x048a3b03 +.insn 4, 0x050a3b83 +.insn 4, 0x058a3c03 +.insn 4, 0x060a3c83 +.insn 4, 0x068a3d03 +.insn 4, 0x070a3d83 +.insn 4, 0x078a3083 +.insn 2, 0x42a1 +bltu s3, t0, 261f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 262f +261: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +263: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 263b +262: +bnez s3, 247b +j 246f +245: +246: +j 244f +243: +beqz s3, 264f +266: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x028a3c23 +.insn 4, 0x055a3023 +.insn 4, 0x056a3423 +.insn 4, 0x057a3823 +.insn 4, 0x058a3c23 +.insn 4, 0x079a3023 +.insn 4, 0x07aa3423 +.insn 4, 0x07ba3823 +.insn 4, 0x061a3c23 +.insn 4, 0x030a0613 +.insn 2, 0x86a6 +.insn 2, 0x874a +.insn 2, 0x8dce +.insn 2, 0x80d2 +lla t4, {VG_CAST5_S1234} +.insn 2, 0x45b1 +.insn 4, 0x00064803 +.insn 2, 0x0862 +.insn 4, 0x00164283 +.insn 2, 0x02c2 +.insn 4, 0x00586833 +.insn 4, 0x00264283 +.insn 2, 0x02a2 +.insn 4, 0x00586833 +.insn 4, 0x00364283 +.insn 4, 0x00586833 +.insn 4, 0x00464883 +.insn 2, 0x08e2 +.insn 4, 0x00564283 +.insn 2, 0x02c2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00664283 +.insn 2, 0x02a2 +.insn 4, 0x0058e8b3 +.insn 4, 0x00764283 +.insn 4, 0x0058e8b3 +.insn 2, 0x8c2a +.insn 2, 0x8cae +.insn 2, 0x4d05 +267: +beqz s10, 268f +.insn 4, 0xfffd0293 +beqz t0, 270f +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x011f4f33 +j 271f +270: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 2, 0x9f46 +271: +j 269f +268: +.insn 4, 0x000c4f03 +.insn 4, 0x001c4283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x002c4283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x003c4283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x411f0f33 +269: +.insn 4, 0x040c4f83 +.insn 4, 0x02000313 +.insn 4, 0x41f30333 +.insn 4, 0x006f533b +.insn 4, 0x01ff1f3b +.insn 4, 0x006f6f33 +.insn 4, 0x0fff7413 +.insn 4, 0x008f549b +.insn 4, 0x0ff4f493 +.insn 4, 0x010f591b +.insn 4, 0x0ff97913 +.insn 4, 0x018f599b +.insn 4, 0x03f41293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e41313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d41393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c41f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c49793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 2, 0x8011 +.insn 2, 0x143d +.insn 2, 0x8091 +.insn 2, 0x14bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +272: +.insn 4, 0xf00e0e13 +.insn 2, 0x0405 +.insn 2, 0x0485 +.insn 4, 0x000e3a83 +.insn 4, 0x010e3b03 +.insn 4, 0x015b4b33 +.insn 4, 0x005b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x020e3b03 +.insn 4, 0x030e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x006b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x040e3b03 +.insn 4, 0x050e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x060e3783 +.insn 4, 0x070e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x007b7b33 +.insn 4, 0x016acab3 +.insn 4, 0x080e3b03 +.insn 4, 0x090e3783 +.insn 4, 0x0167c7b3 +.insn 4, 0x0057f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0a0e3783 +.insn 4, 0x0b0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0067f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x0c0e3783 +.insn 4, 0x0d0e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e0e3f83 +.insn 4, 0x0f0e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0167c7b3 +.insn 4, 0x0077f7b3 +.insn 4, 0x00fb4b33 +.insn 4, 0x015b4b33 +.insn 4, 0x01eb7b33 +.insn 4, 0x016acab3 +.insn 4, 0x02045b13 +.insn 4, 0x43f4d793 +.insn 2, 0x1782 +.insn 4, 0x00fb6b33 +.insn 4, 0x014acab3 +.insn 4, 0x016afab3 +.insn 4, 0x015a4a33 +bne t3, t4, 272b +.insn 4, 0x020a5a93 +.insn 2, 0x1a02 +.insn 4, 0x020a5a13 +.insn 4, 0x03f91293 +.insn 4, 0x43f2d293 +.insn 4, 0x0202d293 +.insn 4, 0x03f99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f2e2b3 +.insn 4, 0x03e91313 +.insn 4, 0x43f35313 +.insn 4, 0x02035313 +.insn 4, 0x03e99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f36333 +.insn 4, 0x03d91393 +.insn 4, 0x43f3d393 +.insn 4, 0x0203d393 +.insn 4, 0x03d99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00f3e3b3 +.insn 4, 0x03c91f13 +.insn 4, 0x43ff5f13 +.insn 4, 0x020f5f13 +.insn 4, 0x03c99793 +.insn 2, 0x97fd +.insn 2, 0x1782 +.insn 4, 0x00ff6f33 +.insn 4, 0x00495913 +.insn 2, 0x193d +.insn 4, 0x0049d993 +.insn 2, 0x19bd +.insn 4, 0x7ffe8e13 +.insn 4, 0x7ffe0e13 +.insn 2, 0x0e09 +273: +.insn 4, 0xf00e0e13 +.insn 2, 0x0905 +.insn 2, 0x0985 +.insn 4, 0x008e3403 +.insn 4, 0x018e3483 +.insn 2, 0x8ca1 +.insn 4, 0x0054f4b3 +.insn 2, 0x8c25 +.insn 4, 0x028e3483 +.insn 4, 0x038e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0064f4b3 +.insn 2, 0x8c25 +.insn 4, 0x048e3483 +.insn 4, 0x058e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x068e3783 +.insn 4, 0x078e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x0074f4b3 +.insn 2, 0x8c25 +.insn 4, 0x088e3483 +.insn 4, 0x098e3783 +.insn 2, 0x8fa5 +.insn 4, 0x0057f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0a8e3783 +.insn 4, 0x0b8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0067f7b3 +.insn 2, 0x8cbd +.insn 4, 0x0c8e3783 +.insn 4, 0x0d8e3f83 +.insn 4, 0x00ffcfb3 +.insn 4, 0x005fffb3 +.insn 4, 0x01f7c7b3 +.insn 4, 0x0e8e3f83 +.insn 4, 0x0f8e3b83 +.insn 4, 0x01fbcbb3 +.insn 4, 0x005bfbb3 +.insn 4, 0x017fcfb3 +.insn 4, 0x00ffcfb3 +.insn 4, 0x006fffb3 +.insn 4, 0x01f7c7b3 +.insn 2, 0x8fa5 +.insn 4, 0x0077f7b3 +.insn 2, 0x8cbd +.insn 2, 0x8ca1 +.insn 4, 0x01e4f4b3 +.insn 2, 0x8c25 +.insn 4, 0x02095493 +.insn 4, 0x43f9d793 +.insn 2, 0x1782 +.insn 2, 0x8cdd +.insn 4, 0x01644433 +.insn 2, 0x8c65 +.insn 4, 0x008b4b33 +bne t3, t4, 273b +.insn 4, 0x020b5b93 +.insn 2, 0x1b02 +.insn 4, 0x020b5b13 +beqz s10, 274f +.insn 4, 0xfffd0293 +beqz t0, 276f +.insn 4, 0x416b8f33 +.insn 2, 0x9f56 +.insn 4, 0x014f4f33 +j 277f +276: +.insn 4, 0x016bcf33 +.insn 4, 0x415f0f33 +.insn 2, 0x9f52 +277: +j 275f +274: +.insn 4, 0x016b8f33 +.insn 4, 0x015f4f33 +.insn 4, 0x414f0f33 +275: +.insn 4, 0x010f4f33 +.insn 2, 0x8846 +.insn 2, 0x88fa +.insn 2, 0x0c11 +.insn 4, 0xffed0293 +beqz t0, 278f +.insn 2, 0x0d05 +j 279f +278: +.insn 2, 0x4d01 +279: +.insn 2, 0x1cfd +bnez s9, 267b +.insn 4, 0x0188d293 +.insn 4, 0x00560023 +.insn 4, 0x0108d293 +.insn 4, 0x005600a3 +.insn 4, 0x0088d293 +.insn 4, 0x00560123 +.insn 4, 0x0008d293 +.insn 4, 0x005601a3 +.insn 4, 0x01885293 +.insn 4, 0x00560223 +.insn 4, 0x01085293 +.insn 4, 0x005602a3 +.insn 4, 0x00885293 +.insn 4, 0x00560323 +.insn 4, 0x00085293 +.insn 4, 0x005603a3 +.insn 2, 0x84b6 +.insn 2, 0x893a +.insn 2, 0x89ee +.insn 2, 0x8a06 +.insn 4, 0x038a3403 +.insn 4, 0x040a3a83 +.insn 4, 0x048a3b03 +.insn 4, 0x050a3b83 +.insn 4, 0x058a3c03 +.insn 4, 0x060a3c83 +.insn 4, 0x068a3d03 +.insn 4, 0x070a3d83 +.insn 4, 0x078a3083 +.insn 2, 0x42a1 +bltu s3, t0, 280f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00096283 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 281f +280: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +282: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 282b +281: +bnez s3, 266b +j 265f +264: +265: +244: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 2, 0x43c1 +283: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 283b +.insn 2, 0x6109 +21: +.insn 2, 0x8082 +.option pop", + VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/idea_ofb.rs b/crates/verified-garbage-asm-riscv64/src/idea_ofb.rs index d3fd1608c02..d15f248737e 100644 --- a/crates/verified-garbage-asm-riscv64/src/idea_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/idea_ofb.rs @@ -2020,3 +2020,2059 @@ bnez t2, 28b .option pop", ) } + +/// IDEA-OFB encryption or decryption (NIST SP 800-38A §6.4, Lai 1992 §3.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is IDEA encryption under the encryption subkeys written by `vg_idea_expand_key`. +/// +/// Contract: `VG.Spec.Idea.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 104 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 64 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_idea_ofb_final(schedule: *const [u8; 104], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x7139 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 2, 0x8932 +.insn 4, 0x00397293 +beqz t0, 20f +beqz s3, 22f +24: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 2, 0x63c1 +.insn 2, 0x13fd +.insn 4, 0x030a0593 +.insn 4, 0x0005c683 +.insn 2, 0x06a2 +.insn 4, 0x0015ce03 +.insn 4, 0x01c6e6b3 +.insn 4, 0x0025c703 +.insn 2, 0x0722 +.insn 4, 0x0035ce03 +.insn 4, 0x01c76733 +.insn 4, 0x0045c783 +.insn 2, 0x07a2 +.insn 4, 0x0055ce03 +.insn 4, 0x01c7e7b3 +.insn 4, 0x0065c803 +.insn 2, 0x0822 +.insn 4, 0x0075ce03 +.insn 4, 0x01c86833 +.insn 2, 0x82b6 +.insn 4, 0x00054303 +.insn 4, 0x00154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x00654303 +.insn 4, 0x00754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x00254303 +.insn 4, 0x00354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x00454303 +.insn 4, 0x00554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x00854303 +.insn 4, 0x00954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x00a54303 +.insn 4, 0x00b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x00c54303 +.insn 4, 0x00d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x01254303 +.insn 4, 0x01354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x00e54303 +.insn 4, 0x00f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x01054303 +.insn 4, 0x01154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x01454303 +.insn 4, 0x01554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x01654303 +.insn 4, 0x01754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x01854303 +.insn 4, 0x01954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x01e54303 +.insn 4, 0x01f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x01a54303 +.insn 4, 0x01b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x01c54303 +.insn 4, 0x01d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x02054303 +.insn 4, 0x02154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x02254303 +.insn 4, 0x02354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x02454303 +.insn 4, 0x02554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x02a54303 +.insn 4, 0x02b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x02654303 +.insn 4, 0x02754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x02854303 +.insn 4, 0x02954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x02c54303 +.insn 4, 0x02d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x02e54303 +.insn 4, 0x02f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x03054303 +.insn 4, 0x03154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x03654303 +.insn 4, 0x03754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x03254303 +.insn 4, 0x03354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x03454303 +.insn 4, 0x03554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x03854303 +.insn 4, 0x03954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x03a54303 +.insn 4, 0x03b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x03c54303 +.insn 4, 0x03d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x04254303 +.insn 4, 0x04354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x03e54303 +.insn 4, 0x03f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x04054303 +.insn 4, 0x04154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x04454303 +.insn 4, 0x04554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x04654303 +.insn 4, 0x04754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x04854303 +.insn 4, 0x04954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x04e54303 +.insn 4, 0x04f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x04a54303 +.insn 4, 0x04b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x04c54303 +.insn 4, 0x04d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x05054303 +.insn 4, 0x05154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x05254303 +.insn 4, 0x05354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x05454303 +.insn 4, 0x05554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x05a54303 +.insn 4, 0x05b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x05654303 +.insn 4, 0x05754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x05854303 +.insn 4, 0x05954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x05c54303 +.insn 4, 0x05d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x05e54303 +.insn 4, 0x05f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x06054303 +.insn 4, 0x06154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x06654303 +.insn 4, 0x06754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x06254303 +.insn 4, 0x06354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x06454303 +.insn 4, 0x06554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x00d580a3 +.insn 4, 0x0086de13 +.insn 4, 0x01c58023 +.insn 4, 0x00f581a3 +.insn 4, 0x0087de13 +.insn 4, 0x01c58123 +.insn 4, 0x00e582a3 +.insn 4, 0x00875e13 +.insn 4, 0x01c58223 +.insn 4, 0x010583a3 +.insn 4, 0x00885e13 +.insn 4, 0x01c58323 +.insn 2, 0x42a1 +bltu s3, t0, 25f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 26f +25: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +27: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 27b +26: +bnez s3, 24b +j 23f +22: +23: +j 21f +20: +beqz s3, 28f +210: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 2, 0x63c1 +.insn 2, 0x13fd +.insn 4, 0x030a0593 +.insn 4, 0x0005c683 +.insn 2, 0x06a2 +.insn 4, 0x0015ce03 +.insn 4, 0x01c6e6b3 +.insn 4, 0x0025c703 +.insn 2, 0x0722 +.insn 4, 0x0035ce03 +.insn 4, 0x01c76733 +.insn 4, 0x0045c783 +.insn 2, 0x07a2 +.insn 4, 0x0055ce03 +.insn 4, 0x01c7e7b3 +.insn 4, 0x0065c803 +.insn 2, 0x0822 +.insn 4, 0x0075ce03 +.insn 4, 0x01c86833 +.insn 2, 0x82b6 +.insn 4, 0x00054303 +.insn 4, 0x00154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x00654303 +.insn 4, 0x00754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x00254303 +.insn 4, 0x00354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x00454303 +.insn 4, 0x00554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x00854303 +.insn 4, 0x00954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x00a54303 +.insn 4, 0x00b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x00c54303 +.insn 4, 0x00d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x01254303 +.insn 4, 0x01354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x00e54303 +.insn 4, 0x00f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x01054303 +.insn 4, 0x01154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x01454303 +.insn 4, 0x01554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x01654303 +.insn 4, 0x01754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x01854303 +.insn 4, 0x01954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x01e54303 +.insn 4, 0x01f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x01a54303 +.insn 4, 0x01b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x01c54303 +.insn 4, 0x01d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x02054303 +.insn 4, 0x02154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x02254303 +.insn 4, 0x02354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x02454303 +.insn 4, 0x02554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x02a54303 +.insn 4, 0x02b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x02654303 +.insn 4, 0x02754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x02854303 +.insn 4, 0x02954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x02c54303 +.insn 4, 0x02d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x02e54303 +.insn 4, 0x02f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x03054303 +.insn 4, 0x03154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x03654303 +.insn 4, 0x03754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x03254303 +.insn 4, 0x03354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x03454303 +.insn 4, 0x03554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x03854303 +.insn 4, 0x03954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x03a54303 +.insn 4, 0x03b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x03c54303 +.insn 4, 0x03d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x04254303 +.insn 4, 0x04354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x03e54303 +.insn 4, 0x03f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x04054303 +.insn 4, 0x04154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x04454303 +.insn 4, 0x04554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x04654303 +.insn 4, 0x04754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x04854303 +.insn 4, 0x04954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x04e54303 +.insn 4, 0x04f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x04a54303 +.insn 4, 0x04b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x04c54303 +.insn 4, 0x04d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x05054303 +.insn 4, 0x05154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x05254303 +.insn 4, 0x05354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x05454303 +.insn 4, 0x05554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x05a54303 +.insn 4, 0x05b54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x05654303 +.insn 4, 0x05754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x05854303 +.insn 4, 0x05954e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x00f6c2b3 +.insn 4, 0x05c54303 +.insn 4, 0x05d54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x889a +.insn 4, 0x010742b3 +.insn 2, 0x92c6 +.insn 4, 0x05e54303 +.insn 4, 0x05f54e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x989a +.insn 4, 0x0078f8b3 +.insn 4, 0x0066c6b3 +.insn 4, 0x0067c7b3 +.insn 4, 0x01174733 +.insn 4, 0x01184833 +.insn 2, 0x82ba +.insn 2, 0x873e +.insn 2, 0x8796 +.insn 2, 0x82b6 +.insn 4, 0x06054303 +.insn 4, 0x06154e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x869a +.insn 2, 0x82c2 +.insn 4, 0x06654303 +.insn 4, 0x06754e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x12fd +.insn 4, 0x0072f2b3 +.insn 2, 0x0285 +.insn 2, 0x137d +.insn 4, 0x00737333 +.insn 2, 0x0305 +.insn 4, 0x026282b3 +.insn 4, 0x0072f333 +.insn 4, 0x0102d293 +.insn 4, 0x40530333 +.insn 4, 0x03f35293 +.insn 2, 0x9316 +.insn 2, 0x02c2 +.insn 2, 0x9316 +.insn 4, 0x00737333 +.insn 2, 0x881a +.insn 4, 0x06254303 +.insn 4, 0x06354e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x979a +.insn 4, 0x0077f7b3 +.insn 4, 0x06454303 +.insn 4, 0x06554e03 +.insn 2, 0x0e22 +.insn 4, 0x01c36333 +.insn 2, 0x971a +.insn 4, 0x00777733 +.insn 4, 0x00d580a3 +.insn 4, 0x0086de13 +.insn 4, 0x01c58023 +.insn 4, 0x00f581a3 +.insn 4, 0x0087de13 +.insn 4, 0x01c58123 +.insn 4, 0x00e582a3 +.insn 4, 0x00875e13 +.insn 4, 0x01c58223 +.insn 4, 0x010583a3 +.insn 4, 0x00885e13 +.insn 4, 0x01c58323 +.insn 2, 0x42a1 +bltu s3, t0, 211f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00096283 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 212f +211: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +213: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 213b +212: +bnez s3, 210b +j 29f +28: +29: +21: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 2, 0x43a1 +214: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 214b +.insn 2, 0x6121 +.insn 2, 0x8082 +.option pop", + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/seed_ofb.rs b/crates/verified-garbage-asm-riscv64/src/seed_ofb.rs index 4a91ac44539..0c337861cf0 100644 --- a/crates/verified-garbage-asm-riscv64/src/seed_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/seed_ofb.rs @@ -5354,3 +5354,5401 @@ bnez t2, 214b .option pop", ) } + +/// SEED-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 4269 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SEED encryption under the schedule written by `vg_seed_expand_key`. +/// +/// Contract: `VG.Spec.Seed.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 1104 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_seed_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 4, 0xbb010113 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2423 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2623 +.insn 2, 0x8932 +.insn 4, 0x00397293 +beqz t0, 20f +beqz s3, 22f +24: +.insn 4, 0x020a6283 +.insn 4, 0x425a2c23 +.insn 4, 0x024a6283 +.insn 4, 0x425a2e23 +.insn 4, 0x028a6283 +.insn 4, 0x445a2023 +.insn 4, 0x02ca6283 +.insn 4, 0x445a2223 +.insn 4, 0x030a0293 +.insn 2, 0x8796 +.insn 4, 0x3a87b423 +.insn 4, 0x3a97b823 +.insn 4, 0x3b27bc23 +.insn 4, 0x3d37b023 +.insn 4, 0x3d47b423 +.insn 4, 0x3d57b823 +.insn 4, 0x3d67bc23 +.insn 4, 0x3f77b023 +.insn 4, 0x3f87b423 +.insn 4, 0x3f97b823 +.insn 4, 0x3fa7bc23 +.insn 4, 0x41b7b023 +.insn 4, 0x555552b7 +.insn 4, 0x5552829b +.insn 2, 0x1282 +.insn 4, 0x55555337 +.insn 4, 0x5553031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457b023 +.insn 4, 0x333332b7 +.insn 4, 0x3332829b +.insn 2, 0x1282 +.insn 4, 0x33333337 +.insn 4, 0x3333031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457b423 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457b823 +.insn 4, 0x00ff02b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0x00ff0337 +.insn 4, 0x0ff3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457bc23 +.insn 4, 0xff0102b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0xff010337 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657b023 +.insn 4, 0xcffcd2b7 +.insn 2, 0x32f1 +.insn 2, 0x1282 +.insn 4, 0xcffcd337 +.insn 2, 0x3371 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657b423 +.insn 4, 0x00f342b7 +.insn 2, 0x32cd +.insn 2, 0x1282 +.insn 4, 0x00f34337 +.insn 2, 0x334d +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657b823 +.insn 4, 0x3f0002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x3f000337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657bc23 +.insn 2, 0x62c1 +.insn 4, 0xccf2829b +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 4, 0xccf3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857b023 +.insn 4, 0xfccf02b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0xfccf0337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857b423 +.insn 4, 0x000002b7 +.insn 4, 0x03f2829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 4, 0x03f3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857b823 +.insn 4, 0xf33ff2b7 +.insn 4, 0x3002829b +.insn 2, 0x1282 +.insn 4, 0xf33ff337 +.insn 4, 0x3003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857bc23 +.insn 4, 0xe72be2b7 +.insn 4, 0x72b2829b +.insn 2, 0x1282 +.insn 4, 0xe72be337 +.insn 4, 0x72b3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3a57b023 +.insn 4, 0x34078693 +.insn 4, 0x4017bc23 +.insn 2, 0x85a6 +.insn 2, 0x864a +.insn 2, 0x80ce +.insn 2, 0x852a +.insn 2, 0x4385 +.insn 4, 0x40878e13 +.insn 2, 0x8ebe +25: +.insn 4, 0x000e4283 +.insn 2, 0x02e2 +.insn 4, 0x001e4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x002e4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x003e4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x245ea023 +.insn 4, 0x004e4283 +.insn 2, 0x02e2 +.insn 4, 0x005e4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x006e4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x007e4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x285ea023 +.insn 4, 0x008e4283 +.insn 2, 0x02e2 +.insn 4, 0x009e4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x00ae4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x00be4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x2c5ea023 +.insn 4, 0x00ce4283 +.insn 2, 0x02e2 +.insn 4, 0x00de4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x00ee4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x00fe4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x305ea023 +.insn 2, 0x0e41 +.insn 2, 0x0e91 +.insn 2, 0x13fd +bnez t2, 25b +.insn 2, 0x4741 +26: +.insn 4, 0x00054f03 +.insn 4, 0x00154283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x00254283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x00354283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x00454f83 +.insn 4, 0x00554283 +.insn 2, 0x02a2 +.insn 4, 0x005fefb3 +.insn 4, 0x00654283 +.insn 2, 0x02c2 +.insn 4, 0x005fefb3 +.insn 4, 0x00754283 +.insn 2, 0x02e2 +.insn 4, 0x005fefb3 +.insn 4, 0x2c07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a023 +.insn 4, 0x3007e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a023 +.insn 4, 0x2c47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a223 +.insn 4, 0x3047e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a223 +.insn 4, 0x2c87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a423 +.insn 4, 0x3087e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a423 +.insn 4, 0x2cc7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a623 +.insn 4, 0x30c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a623 +.insn 4, 0x2d07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a823 +.insn 4, 0x3107e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a823 +.insn 4, 0x2d47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857aa23 +.insn 4, 0x3147e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457aa23 +.insn 4, 0x2d87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857ac23 +.insn 4, 0x3187e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457ac23 +.insn 4, 0x2dc7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857ae23 +.insn 4, 0x31c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457ae23 +.insn 4, 0x2e07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a023 +.insn 4, 0x3207e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a023 +.insn 4, 0x2e47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a223 +.insn 4, 0x3247e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a223 +.insn 4, 0x2e87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a423 +.insn 4, 0x3287e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a423 +.insn 4, 0x2ec7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a623 +.insn 4, 0x32c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a623 +.insn 4, 0x2f07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a823 +.insn 4, 0x3307e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a823 +.insn 4, 0x2f47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57aa23 +.insn 4, 0x3347e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657aa23 +.insn 4, 0x2f87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57ac23 +.insn 4, 0x3387e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657ac23 +.insn 4, 0x2fc7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57ae23 +.insn 4, 0x33c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657ae23 +.insn 4, 0x1407b403 +.insn 4, 0x1487b483 +.insn 4, 0x1507b903 +.insn 4, 0x1587b983 +.insn 4, 0x1607ba03 +.insn 4, 0x1687ba83 +.insn 4, 0x1707bb03 +.insn 4, 0x1787bb83 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 2, 0x841a +.insn 4, 0x00744433 +.insn 4, 0x01d44433 +.insn 2, 0x84f2 +.insn 4, 0x01d4c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x897a +.insn 4, 0x01f94933 +.insn 4, 0x01194933 +.insn 2, 0x899e +.insn 4, 0x01c9c9b3 +.insn 4, 0x01d9c9b3 +.insn 4, 0x01f9c9b3 +.insn 2, 0x8a1e +.insn 4, 0x01ca4a33 +.insn 4, 0x01ea4a33 +.insn 2, 0x8af6 +.insn 4, 0x01eacab3 +.insn 2, 0x8b72 +.insn 4, 0x01db4b33 +.insn 4, 0x01eb4b33 +.insn 4, 0x01fb4b33 +.insn 2, 0x8bfa +.insn 4, 0x01fbcbb3 +.insn 4, 0x010bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x009bc333 +.insn 4, 0x014bc3b3 +.insn 4, 0x012bce33 +.insn 4, 0x015b4ab3 +.insn 4, 0x008aceb3 +.insn 4, 0x014eca33 +.insn 4, 0x00534f33 +.insn 4, 0x017ecfb3 +.insn 4, 0x009ec4b3 +.insn 4, 0x01c4c833 +.insn 4, 0x01e9c9b3 +.insn 4, 0x0129c933 +.insn 4, 0x0169c9b3 +.insn 4, 0x00894b33 +.insn 4, 0x015948b3 +.insn 4, 0x0079cc33 +.insn 4, 0x01844cb3 +.insn 4, 0x0188cd33 +.insn 4, 0x01c8cdb3 +.insn 4, 0x018acab3 +.insn 4, 0x01b7b023 +.insn 4, 0x01534db3 +.insn 4, 0x015bcbb3 +.insn 4, 0x0177b423 +.insn 4, 0x012f7bb3 +.insn 4, 0x01e7b823 +.insn 4, 0x01687f33 +.insn 4, 0x017f4f33 +.insn 4, 0x0107bc23 +.insn 4, 0x008a7833 +.insn 4, 0x01784833 +.insn 4, 0x01537bb3 +.insn 4, 0x0267b023 +.insn 4, 0x01d4f333 +.insn 4, 0x01734333 +.insn 2, 0xf784 +.insn 4, 0x019ff4b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x0183fbb3 +.insn 4, 0x0277b823 +.insn 4, 0x01a2f3b3 +.insn 4, 0x0173c3b3 +.insn 4, 0x0257bc23 +.insn 4, 0x011e72b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x007f4f33 +.insn 4, 0x00584833 +.insn 4, 0x00734333 +.insn 4, 0x0054c4b3 +.insn 4, 0x013f4f33 +.insn 4, 0x0007b983 +.insn 4, 0x01384833 +.insn 4, 0x01b34333 +.insn 4, 0x0087bd83 +.insn 4, 0x01b4c4b3 +.insn 4, 0x010f4db3 +.insn 4, 0x006f7f33 +.insn 4, 0x01e4c9b3 +.insn 4, 0x013df2b3 +.insn 4, 0x0102c2b3 +.insn 4, 0x009343b3 +.insn 4, 0x01e84833 +.insn 4, 0x00787833 +.insn 4, 0x00984833 +.insn 4, 0x01034333 +.insn 4, 0x0109c3b3 +.insn 4, 0x0074f4b3 +.insn 4, 0x0064c333 +.insn 4, 0x0099c9b3 +.insn 4, 0x0132f9b3 +.insn 4, 0x013dcdb3 +.insn 4, 0x006dc9b3 +.insn 4, 0x0102c4b3 +.insn 4, 0x01b2c3b3 +.insn 4, 0x00684f33 +.insn 4, 0x0134cbb3 +.insn 4, 0x012f7933 +.insn 4, 0x01637b33 +.insn 4, 0x00887433 +.insn 4, 0x0153fab3 +.insn 4, 0x01ddfeb3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0184fc33 +.insn 4, 0x01abfd33 +.insn 4, 0x0119f8b3 +.insn 4, 0x0167b423 +.insn 4, 0x0107bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0187bb03 +.insn 4, 0x01637333 +.insn 4, 0x01487833 +.insn 4, 0x0207ba03 +.insn 4, 0x0143f3b3 +.insn 4, 0x0287ba03 +.insn 4, 0x014dfdb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0307bf83 +.insn 4, 0x01f4f4b3 +.insn 4, 0x0387bf83 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01c9f9b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x01034833 +.insn 4, 0x01bccdb3 +.insn 4, 0x006f4f33 +.insn 4, 0x00744333 +.insn 4, 0x01944433 +.insn 4, 0x011d48b3 +.insn 4, 0x01594933 +.insn 4, 0x01ac4c33 +.insn 4, 0x013bcbb3 +.insn 4, 0x01b3c3b3 +.insn 4, 0x01234333 +.insn 4, 0x009ec9b3 +.insn 4, 0x018acab3 +.insn 4, 0x0064c4b3 +.insn 4, 0x0062c2b3 +.insn 4, 0x0138c8b3 +.insn 4, 0x013f4f33 +.insn 4, 0x015eceb3 +.insn 4, 0x0112c2b3 +.insn 4, 0x0087b983 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01eacab3 +.insn 4, 0x0113c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x009dcdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x005ec4b3 +.insn 4, 0x01394a33 +.insn 4, 0x013449b3 +.insn 4, 0x00584933 +.insn 4, 0x014ecb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x009bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x0177b423 +.insn 2, 0x8bd6 +.insn 4, 0x0087ba83 +.insn 2, 0x849e +.insn 2, 0x846e +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 4, 0x0186bc03 +.insn 4, 0x0206bc83 +.insn 4, 0x0193f433 +.insn 4, 0x018e72b3 +.insn 4, 0x00544433 +.insn 4, 0x019ef2b3 +.insn 4, 0x00544433 +.insn 4, 0x018f72b3 +.insn 4, 0x00544433 +.insn 4, 0x018ff2b3 +.insn 4, 0x00544433 +.insn 4, 0x018872b3 +.insn 4, 0x00544433 +.insn 4, 0x0193f4b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x01e4c4b3 +.insn 4, 0x019ff2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x891a +.insn 4, 0x0183f2b3 +.insn 4, 0x00594933 +.insn 4, 0x019e72b3 +.insn 4, 0x00594933 +.insn 4, 0x019ef2b3 +.insn 4, 0x00594933 +.insn 4, 0x01e94933 +.insn 4, 0x01094933 +.insn 2, 0x899a +.insn 4, 0x0193f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x019ef2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01f9c9b3 +.insn 4, 0x0109c9b3 +.insn 4, 0x0188f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01837a33 +.insn 4, 0x018e72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01da4a33 +.insn 4, 0x018f72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x010a4a33 +.insn 4, 0x0198f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01837ab3 +.insn 4, 0x0183f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x01dacab3 +.insn 4, 0x019f72b3 +.insn 4, 0x005acab3 +.insn 4, 0x01facab3 +.insn 4, 0x010acab3 +.insn 4, 0x01837b33 +.insn 4, 0x0193f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019e72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019ef2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018f72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018ff2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x010b4b33 +.insn 4, 0x0183fbb3 +.insn 4, 0x01dbcbb3 +.insn 4, 0x018872b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0188f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0286b383 +.insn 4, 0x0306be03 +.insn 4, 0x0386bf83 +.insn 4, 0x0406be83 +.insn 4, 0x0486b803 +.insn 4, 0x0506bf03 +.insn 4, 0x0586b883 +.insn 4, 0x0606bc03 +.insn 4, 0x00747333 +.insn 4, 0x00845293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01841293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01045293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01041293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01845293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00841293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b023 +.insn 4, 0x0074f333 +.insn 4, 0x0084d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01849293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0104d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01049293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0184d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00849293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b423 +.insn 4, 0x00797333 +.insn 4, 0x00895293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01891293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01095293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01091293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01895293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00891293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b823 +.insn 4, 0x0079f333 +.insn 4, 0x0089d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01899293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0109d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01099293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0189d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00899293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467bc23 +.insn 4, 0x007a7333 +.insn 4, 0x008a5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b023 +.insn 4, 0x007af333 +.insn 4, 0x008ad293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010ad293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018ad293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b423 +.insn 4, 0x007b7333 +.insn 4, 0x008b5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b823 +.insn 4, 0x007bf333 +.insn 4, 0x008bd293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010bd293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018bd293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667bc23 +.insn 4, 0x1407e283 +.insn 4, 0x1c57a023 +.insn 4, 0x1807e303 +.insn 2, 0x929a +.insn 4, 0x1457a023 +.insn 4, 0x1447e283 +.insn 4, 0x1c57a223 +.insn 4, 0x1847e303 +.insn 2, 0x929a +.insn 4, 0x1457a223 +.insn 4, 0x1487e283 +.insn 4, 0x1c57a423 +.insn 4, 0x1887e303 +.insn 2, 0x929a +.insn 4, 0x1457a423 +.insn 4, 0x14c7e283 +.insn 4, 0x1c57a623 +.insn 4, 0x18c7e303 +.insn 2, 0x929a +.insn 4, 0x1457a623 +.insn 4, 0x1507e283 +.insn 4, 0x1c57a823 +.insn 4, 0x1907e303 +.insn 2, 0x929a +.insn 4, 0x1457a823 +.insn 4, 0x1547e283 +.insn 4, 0x1c57aa23 +.insn 4, 0x1947e303 +.insn 2, 0x929a +.insn 4, 0x1457aa23 +.insn 4, 0x1587e283 +.insn 4, 0x1c57ac23 +.insn 4, 0x1987e303 +.insn 2, 0x929a +.insn 4, 0x1457ac23 +.insn 4, 0x15c7e283 +.insn 4, 0x1c57ae23 +.insn 4, 0x19c7e303 +.insn 2, 0x929a +.insn 4, 0x1457ae23 +.insn 4, 0x1607e283 +.insn 4, 0x1e57a023 +.insn 4, 0x1a07e303 +.insn 2, 0x929a +.insn 4, 0x1657a023 +.insn 4, 0x1647e283 +.insn 4, 0x1e57a223 +.insn 4, 0x1a47e303 +.insn 2, 0x929a +.insn 4, 0x1657a223 +.insn 4, 0x1687e283 +.insn 4, 0x1e57a423 +.insn 4, 0x1a87e303 +.insn 2, 0x929a +.insn 4, 0x1657a423 +.insn 4, 0x16c7e283 +.insn 4, 0x1e57a623 +.insn 4, 0x1ac7e303 +.insn 2, 0x929a +.insn 4, 0x1657a623 +.insn 4, 0x1707e283 +.insn 4, 0x1e57a823 +.insn 4, 0x1b07e303 +.insn 2, 0x929a +.insn 4, 0x1657a823 +.insn 4, 0x1747e283 +.insn 4, 0x1e57aa23 +.insn 4, 0x1b47e303 +.insn 2, 0x929a +.insn 4, 0x1657aa23 +.insn 4, 0x1787e283 +.insn 4, 0x1e57ac23 +.insn 4, 0x1b87e303 +.insn 2, 0x929a +.insn 4, 0x1657ac23 +.insn 4, 0x17c7e283 +.insn 4, 0x1e57ae23 +.insn 4, 0x1bc7e303 +.insn 2, 0x929a +.insn 4, 0x1657ae23 +.insn 4, 0x1407b403 +.insn 4, 0x1487b483 +.insn 4, 0x1507b903 +.insn 4, 0x1587b983 +.insn 4, 0x1607ba03 +.insn 4, 0x1687ba83 +.insn 4, 0x1707bb03 +.insn 4, 0x1787bb83 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 2, 0x841a +.insn 4, 0x00744433 +.insn 4, 0x01d44433 +.insn 2, 0x84f2 +.insn 4, 0x01d4c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x897a +.insn 4, 0x01f94933 +.insn 4, 0x01194933 +.insn 2, 0x899e +.insn 4, 0x01c9c9b3 +.insn 4, 0x01d9c9b3 +.insn 4, 0x01f9c9b3 +.insn 2, 0x8a1e +.insn 4, 0x01ca4a33 +.insn 4, 0x01ea4a33 +.insn 2, 0x8af6 +.insn 4, 0x01eacab3 +.insn 2, 0x8b72 +.insn 4, 0x01db4b33 +.insn 4, 0x01eb4b33 +.insn 4, 0x01fb4b33 +.insn 2, 0x8bfa +.insn 4, 0x01fbcbb3 +.insn 4, 0x010bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x009bc333 +.insn 4, 0x014bc3b3 +.insn 4, 0x012bce33 +.insn 4, 0x015b4ab3 +.insn 4, 0x008aceb3 +.insn 4, 0x014eca33 +.insn 4, 0x00534f33 +.insn 4, 0x017ecfb3 +.insn 4, 0x009ec4b3 +.insn 4, 0x01c4c833 +.insn 4, 0x01e9c9b3 +.insn 4, 0x0129c933 +.insn 4, 0x0169c9b3 +.insn 4, 0x00894b33 +.insn 4, 0x015948b3 +.insn 4, 0x0079cc33 +.insn 4, 0x01844cb3 +.insn 4, 0x0188cd33 +.insn 4, 0x01c8cdb3 +.insn 4, 0x018acab3 +.insn 4, 0x01b7b023 +.insn 4, 0x01534db3 +.insn 4, 0x015bcbb3 +.insn 4, 0x0177b423 +.insn 4, 0x012f7bb3 +.insn 4, 0x01e7b823 +.insn 4, 0x01687f33 +.insn 4, 0x017f4f33 +.insn 4, 0x0107bc23 +.insn 4, 0x008a7833 +.insn 4, 0x01784833 +.insn 4, 0x01537bb3 +.insn 4, 0x0267b023 +.insn 4, 0x01d4f333 +.insn 4, 0x01734333 +.insn 2, 0xf784 +.insn 4, 0x019ff4b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x0183fbb3 +.insn 4, 0x0277b823 +.insn 4, 0x01a2f3b3 +.insn 4, 0x0173c3b3 +.insn 4, 0x0257bc23 +.insn 4, 0x011e72b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x007f4f33 +.insn 4, 0x00584833 +.insn 4, 0x00734333 +.insn 4, 0x0054c4b3 +.insn 4, 0x013f4f33 +.insn 4, 0x0007b983 +.insn 4, 0x01384833 +.insn 4, 0x01b34333 +.insn 4, 0x0087bd83 +.insn 4, 0x01b4c4b3 +.insn 4, 0x010f4db3 +.insn 4, 0x006f7f33 +.insn 4, 0x01e4c9b3 +.insn 4, 0x013df2b3 +.insn 4, 0x0102c2b3 +.insn 4, 0x009343b3 +.insn 4, 0x01e84833 +.insn 4, 0x00787833 +.insn 4, 0x00984833 +.insn 4, 0x01034333 +.insn 4, 0x0109c3b3 +.insn 4, 0x0074f4b3 +.insn 4, 0x0064c333 +.insn 4, 0x0099c9b3 +.insn 4, 0x0132f9b3 +.insn 4, 0x013dcdb3 +.insn 4, 0x006dc9b3 +.insn 4, 0x0102c4b3 +.insn 4, 0x01b2c3b3 +.insn 4, 0x00684f33 +.insn 4, 0x0134cbb3 +.insn 4, 0x012f7933 +.insn 4, 0x01637b33 +.insn 4, 0x00887433 +.insn 4, 0x0153fab3 +.insn 4, 0x01ddfeb3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0184fc33 +.insn 4, 0x01abfd33 +.insn 4, 0x0119f8b3 +.insn 4, 0x0167b423 +.insn 4, 0x0107bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0187bb03 +.insn 4, 0x01637333 +.insn 4, 0x01487833 +.insn 4, 0x0207ba03 +.insn 4, 0x0143f3b3 +.insn 4, 0x0287ba03 +.insn 4, 0x014dfdb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0307bf83 +.insn 4, 0x01f4f4b3 +.insn 4, 0x0387bf83 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01c9f9b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x01034833 +.insn 4, 0x01bccdb3 +.insn 4, 0x006f4f33 +.insn 4, 0x00744333 +.insn 4, 0x01944433 +.insn 4, 0x011d48b3 +.insn 4, 0x01594933 +.insn 4, 0x01ac4c33 +.insn 4, 0x013bcbb3 +.insn 4, 0x01b3c3b3 +.insn 4, 0x01234333 +.insn 4, 0x009ec9b3 +.insn 4, 0x018acab3 +.insn 4, 0x0064c4b3 +.insn 4, 0x0062c2b3 +.insn 4, 0x0138c8b3 +.insn 4, 0x013f4f33 +.insn 4, 0x015eceb3 +.insn 4, 0x0112c2b3 +.insn 4, 0x0087b983 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01eacab3 +.insn 4, 0x0113c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x009dcdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x005ec4b3 +.insn 4, 0x01394a33 +.insn 4, 0x013449b3 +.insn 4, 0x00584933 +.insn 4, 0x014ecb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x009bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x0177b423 +.insn 2, 0x8bd6 +.insn 4, 0x0087ba83 +.insn 2, 0x849e +.insn 2, 0x846e +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 4, 0x0186bc03 +.insn 4, 0x0206bc83 +.insn 4, 0x0193f433 +.insn 4, 0x018e72b3 +.insn 4, 0x00544433 +.insn 4, 0x019ef2b3 +.insn 4, 0x00544433 +.insn 4, 0x018f72b3 +.insn 4, 0x00544433 +.insn 4, 0x018ff2b3 +.insn 4, 0x00544433 +.insn 4, 0x018872b3 +.insn 4, 0x00544433 +.insn 4, 0x0193f4b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x01e4c4b3 +.insn 4, 0x019ff2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x891a +.insn 4, 0x0183f2b3 +.insn 4, 0x00594933 +.insn 4, 0x019e72b3 +.insn 4, 0x00594933 +.insn 4, 0x019ef2b3 +.insn 4, 0x00594933 +.insn 4, 0x01e94933 +.insn 4, 0x01094933 +.insn 2, 0x899a +.insn 4, 0x0193f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x019ef2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01f9c9b3 +.insn 4, 0x0109c9b3 +.insn 4, 0x0188f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01837a33 +.insn 4, 0x018e72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01da4a33 +.insn 4, 0x018f72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x010a4a33 +.insn 4, 0x0198f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01837ab3 +.insn 4, 0x0183f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x01dacab3 +.insn 4, 0x019f72b3 +.insn 4, 0x005acab3 +.insn 4, 0x01facab3 +.insn 4, 0x010acab3 +.insn 4, 0x01837b33 +.insn 4, 0x0193f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019e72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019ef2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018f72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018ff2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x010b4b33 +.insn 4, 0x0183fbb3 +.insn 4, 0x01dbcbb3 +.insn 4, 0x018872b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0188f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0286b383 +.insn 4, 0x0306be03 +.insn 4, 0x0386bf83 +.insn 4, 0x0406be83 +.insn 4, 0x0486b803 +.insn 4, 0x0506bf03 +.insn 4, 0x0586b883 +.insn 4, 0x0606bc03 +.insn 4, 0x00747333 +.insn 4, 0x00845293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01841293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01045293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01041293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01845293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00841293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b023 +.insn 4, 0x0074f333 +.insn 4, 0x0084d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01849293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0104d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01049293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0184d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00849293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b423 +.insn 4, 0x00797333 +.insn 4, 0x00895293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01891293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01095293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01091293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01895293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00891293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b823 +.insn 4, 0x0079f333 +.insn 4, 0x0089d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01899293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0109d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01099293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0189d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00899293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467bc23 +.insn 4, 0x007a7333 +.insn 4, 0x008a5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b023 +.insn 4, 0x007af333 +.insn 4, 0x008ad293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010ad293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018ad293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b423 +.insn 4, 0x007b7333 +.insn 4, 0x008b5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b823 +.insn 4, 0x007bf333 +.insn 4, 0x008bd293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010bd293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018bd293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667bc23 +.insn 4, 0x1407e283 +.insn 4, 0x2057a023 +.insn 4, 0x1c07e303 +.insn 2, 0x929a +.insn 4, 0x1457a023 +.insn 4, 0x1447e283 +.insn 4, 0x2057a223 +.insn 4, 0x1c47e303 +.insn 2, 0x929a +.insn 4, 0x1457a223 +.insn 4, 0x1487e283 +.insn 4, 0x2057a423 +.insn 4, 0x1c87e303 +.insn 2, 0x929a +.insn 4, 0x1457a423 +.insn 4, 0x14c7e283 +.insn 4, 0x2057a623 +.insn 4, 0x1cc7e303 +.insn 2, 0x929a +.insn 4, 0x1457a623 +.insn 4, 0x1507e283 +.insn 4, 0x2057a823 +.insn 4, 0x1d07e303 +.insn 2, 0x929a +.insn 4, 0x1457a823 +.insn 4, 0x1547e283 +.insn 4, 0x2057aa23 +.insn 4, 0x1d47e303 +.insn 2, 0x929a +.insn 4, 0x1457aa23 +.insn 4, 0x1587e283 +.insn 4, 0x2057ac23 +.insn 4, 0x1d87e303 +.insn 2, 0x929a +.insn 4, 0x1457ac23 +.insn 4, 0x15c7e283 +.insn 4, 0x2057ae23 +.insn 4, 0x1dc7e303 +.insn 2, 0x929a +.insn 4, 0x1457ae23 +.insn 4, 0x1607e283 +.insn 4, 0x2257a023 +.insn 4, 0x1e07e303 +.insn 2, 0x929a +.insn 4, 0x1657a023 +.insn 4, 0x1647e283 +.insn 4, 0x2257a223 +.insn 4, 0x1e47e303 +.insn 2, 0x929a +.insn 4, 0x1657a223 +.insn 4, 0x1687e283 +.insn 4, 0x2257a423 +.insn 4, 0x1e87e303 +.insn 2, 0x929a +.insn 4, 0x1657a423 +.insn 4, 0x16c7e283 +.insn 4, 0x2257a623 +.insn 4, 0x1ec7e303 +.insn 2, 0x929a +.insn 4, 0x1657a623 +.insn 4, 0x1707e283 +.insn 4, 0x2257a823 +.insn 4, 0x1f07e303 +.insn 2, 0x929a +.insn 4, 0x1657a823 +.insn 4, 0x1747e283 +.insn 4, 0x2257aa23 +.insn 4, 0x1f47e303 +.insn 2, 0x929a +.insn 4, 0x1657aa23 +.insn 4, 0x1787e283 +.insn 4, 0x2257ac23 +.insn 4, 0x1f87e303 +.insn 2, 0x929a +.insn 4, 0x1657ac23 +.insn 4, 0x17c7e283 +.insn 4, 0x2257ae23 +.insn 4, 0x1fc7e303 +.insn 2, 0x929a +.insn 4, 0x1657ae23 +.insn 4, 0x1407b403 +.insn 4, 0x1487b483 +.insn 4, 0x1507b903 +.insn 4, 0x1587b983 +.insn 4, 0x1607ba03 +.insn 4, 0x1687ba83 +.insn 4, 0x1707bb03 +.insn 4, 0x1787bb83 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 2, 0x841a +.insn 4, 0x00744433 +.insn 4, 0x01d44433 +.insn 2, 0x84f2 +.insn 4, 0x01d4c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x897a +.insn 4, 0x01f94933 +.insn 4, 0x01194933 +.insn 2, 0x899e +.insn 4, 0x01c9c9b3 +.insn 4, 0x01d9c9b3 +.insn 4, 0x01f9c9b3 +.insn 2, 0x8a1e +.insn 4, 0x01ca4a33 +.insn 4, 0x01ea4a33 +.insn 2, 0x8af6 +.insn 4, 0x01eacab3 +.insn 2, 0x8b72 +.insn 4, 0x01db4b33 +.insn 4, 0x01eb4b33 +.insn 4, 0x01fb4b33 +.insn 2, 0x8bfa +.insn 4, 0x01fbcbb3 +.insn 4, 0x010bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x009bc333 +.insn 4, 0x014bc3b3 +.insn 4, 0x012bce33 +.insn 4, 0x015b4ab3 +.insn 4, 0x008aceb3 +.insn 4, 0x014eca33 +.insn 4, 0x00534f33 +.insn 4, 0x017ecfb3 +.insn 4, 0x009ec4b3 +.insn 4, 0x01c4c833 +.insn 4, 0x01e9c9b3 +.insn 4, 0x0129c933 +.insn 4, 0x0169c9b3 +.insn 4, 0x00894b33 +.insn 4, 0x015948b3 +.insn 4, 0x0079cc33 +.insn 4, 0x01844cb3 +.insn 4, 0x0188cd33 +.insn 4, 0x01c8cdb3 +.insn 4, 0x018acab3 +.insn 4, 0x01b7b023 +.insn 4, 0x01534db3 +.insn 4, 0x015bcbb3 +.insn 4, 0x0177b423 +.insn 4, 0x012f7bb3 +.insn 4, 0x01e7b823 +.insn 4, 0x01687f33 +.insn 4, 0x017f4f33 +.insn 4, 0x0107bc23 +.insn 4, 0x008a7833 +.insn 4, 0x01784833 +.insn 4, 0x01537bb3 +.insn 4, 0x0267b023 +.insn 4, 0x01d4f333 +.insn 4, 0x01734333 +.insn 2, 0xf784 +.insn 4, 0x019ff4b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x0183fbb3 +.insn 4, 0x0277b823 +.insn 4, 0x01a2f3b3 +.insn 4, 0x0173c3b3 +.insn 4, 0x0257bc23 +.insn 4, 0x011e72b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x007f4f33 +.insn 4, 0x00584833 +.insn 4, 0x00734333 +.insn 4, 0x0054c4b3 +.insn 4, 0x013f4f33 +.insn 4, 0x0007b983 +.insn 4, 0x01384833 +.insn 4, 0x01b34333 +.insn 4, 0x0087bd83 +.insn 4, 0x01b4c4b3 +.insn 4, 0x010f4db3 +.insn 4, 0x006f7f33 +.insn 4, 0x01e4c9b3 +.insn 4, 0x013df2b3 +.insn 4, 0x0102c2b3 +.insn 4, 0x009343b3 +.insn 4, 0x01e84833 +.insn 4, 0x00787833 +.insn 4, 0x00984833 +.insn 4, 0x01034333 +.insn 4, 0x0109c3b3 +.insn 4, 0x0074f4b3 +.insn 4, 0x0064c333 +.insn 4, 0x0099c9b3 +.insn 4, 0x0132f9b3 +.insn 4, 0x013dcdb3 +.insn 4, 0x006dc9b3 +.insn 4, 0x0102c4b3 +.insn 4, 0x01b2c3b3 +.insn 4, 0x00684f33 +.insn 4, 0x0134cbb3 +.insn 4, 0x012f7933 +.insn 4, 0x01637b33 +.insn 4, 0x00887433 +.insn 4, 0x0153fab3 +.insn 4, 0x01ddfeb3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0184fc33 +.insn 4, 0x01abfd33 +.insn 4, 0x0119f8b3 +.insn 4, 0x0167b423 +.insn 4, 0x0107bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0187bb03 +.insn 4, 0x01637333 +.insn 4, 0x01487833 +.insn 4, 0x0207ba03 +.insn 4, 0x0143f3b3 +.insn 4, 0x0287ba03 +.insn 4, 0x014dfdb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0307bf83 +.insn 4, 0x01f4f4b3 +.insn 4, 0x0387bf83 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01c9f9b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x01034833 +.insn 4, 0x01bccdb3 +.insn 4, 0x006f4f33 +.insn 4, 0x00744333 +.insn 4, 0x01944433 +.insn 4, 0x011d48b3 +.insn 4, 0x01594933 +.insn 4, 0x01ac4c33 +.insn 4, 0x013bcbb3 +.insn 4, 0x01b3c3b3 +.insn 4, 0x01234333 +.insn 4, 0x009ec9b3 +.insn 4, 0x018acab3 +.insn 4, 0x0064c4b3 +.insn 4, 0x0062c2b3 +.insn 4, 0x0138c8b3 +.insn 4, 0x013f4f33 +.insn 4, 0x015eceb3 +.insn 4, 0x0112c2b3 +.insn 4, 0x0087b983 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01eacab3 +.insn 4, 0x0113c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x009dcdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x005ec4b3 +.insn 4, 0x01394a33 +.insn 4, 0x013449b3 +.insn 4, 0x00584933 +.insn 4, 0x014ecb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x009bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x0177b423 +.insn 2, 0x8bd6 +.insn 4, 0x0087ba83 +.insn 2, 0x849e +.insn 2, 0x846e +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 4, 0x0186bc03 +.insn 4, 0x0206bc83 +.insn 4, 0x0193f433 +.insn 4, 0x018e72b3 +.insn 4, 0x00544433 +.insn 4, 0x019ef2b3 +.insn 4, 0x00544433 +.insn 4, 0x018f72b3 +.insn 4, 0x00544433 +.insn 4, 0x018ff2b3 +.insn 4, 0x00544433 +.insn 4, 0x018872b3 +.insn 4, 0x00544433 +.insn 4, 0x0193f4b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x01e4c4b3 +.insn 4, 0x019ff2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x891a +.insn 4, 0x0183f2b3 +.insn 4, 0x00594933 +.insn 4, 0x019e72b3 +.insn 4, 0x00594933 +.insn 4, 0x019ef2b3 +.insn 4, 0x00594933 +.insn 4, 0x01e94933 +.insn 4, 0x01094933 +.insn 2, 0x899a +.insn 4, 0x0193f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x019ef2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01f9c9b3 +.insn 4, 0x0109c9b3 +.insn 4, 0x0188f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01837a33 +.insn 4, 0x018e72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01da4a33 +.insn 4, 0x018f72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x010a4a33 +.insn 4, 0x0198f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01837ab3 +.insn 4, 0x0183f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x01dacab3 +.insn 4, 0x019f72b3 +.insn 4, 0x005acab3 +.insn 4, 0x01facab3 +.insn 4, 0x010acab3 +.insn 4, 0x01837b33 +.insn 4, 0x0193f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019e72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019ef2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018f72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018ff2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x010b4b33 +.insn 4, 0x0183fbb3 +.insn 4, 0x01dbcbb3 +.insn 4, 0x018872b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0188f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0286b383 +.insn 4, 0x0306be03 +.insn 4, 0x0386bf83 +.insn 4, 0x0406be83 +.insn 4, 0x0486b803 +.insn 4, 0x0506bf03 +.insn 4, 0x0586b883 +.insn 4, 0x0606bc03 +.insn 4, 0x00747333 +.insn 4, 0x00845293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01841293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01045293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01041293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01845293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00841293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b023 +.insn 4, 0x0074f333 +.insn 4, 0x0084d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01849293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0104d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01049293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0184d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00849293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b423 +.insn 4, 0x00797333 +.insn 4, 0x00895293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01891293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01095293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01091293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01895293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00891293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b823 +.insn 4, 0x0079f333 +.insn 4, 0x0089d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01899293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0109d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01099293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0189d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00899293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467bc23 +.insn 4, 0x007a7333 +.insn 4, 0x008a5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b023 +.insn 4, 0x007af333 +.insn 4, 0x008ad293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010ad293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018ad293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b423 +.insn 4, 0x007b7333 +.insn 4, 0x008b5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b823 +.insn 4, 0x007bf333 +.insn 4, 0x008bd293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010bd293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018bd293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667bc23 +.insn 4, 0x1407e283 +.insn 4, 0x2807e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a023 +.insn 4, 0x2007e303 +.insn 2, 0x929a +.insn 4, 0x2407e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a023 +.insn 4, 0x1447e283 +.insn 4, 0x2847e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a223 +.insn 4, 0x2047e303 +.insn 2, 0x929a +.insn 4, 0x2447e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a223 +.insn 4, 0x1487e283 +.insn 4, 0x2887e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a423 +.insn 4, 0x2087e303 +.insn 2, 0x929a +.insn 4, 0x2487e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a423 +.insn 4, 0x14c7e283 +.insn 4, 0x28c7e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a623 +.insn 4, 0x20c7e303 +.insn 2, 0x929a +.insn 4, 0x24c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a623 +.insn 4, 0x1507e283 +.insn 4, 0x2907e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a823 +.insn 4, 0x2107e303 +.insn 2, 0x929a +.insn 4, 0x2507e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a823 +.insn 4, 0x1547e283 +.insn 4, 0x2947e303 +.insn 4, 0x00534333 +.insn 4, 0x2867aa23 +.insn 4, 0x2147e303 +.insn 2, 0x929a +.insn 4, 0x2547e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457aa23 +.insn 4, 0x1587e283 +.insn 4, 0x2987e303 +.insn 4, 0x00534333 +.insn 4, 0x2867ac23 +.insn 4, 0x2187e303 +.insn 2, 0x929a +.insn 4, 0x2587e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457ac23 +.insn 4, 0x15c7e283 +.insn 4, 0x29c7e303 +.insn 4, 0x00534333 +.insn 4, 0x2867ae23 +.insn 4, 0x21c7e303 +.insn 2, 0x929a +.insn 4, 0x25c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457ae23 +.insn 4, 0x1607e283 +.insn 4, 0x2a07e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a023 +.insn 4, 0x2207e303 +.insn 2, 0x929a +.insn 4, 0x2607e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a023 +.insn 4, 0x1647e283 +.insn 4, 0x2a47e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a223 +.insn 4, 0x2247e303 +.insn 2, 0x929a +.insn 4, 0x2647e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a223 +.insn 4, 0x1687e283 +.insn 4, 0x2a87e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a423 +.insn 4, 0x2287e303 +.insn 2, 0x929a +.insn 4, 0x2687e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a423 +.insn 4, 0x16c7e283 +.insn 4, 0x2ac7e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a623 +.insn 4, 0x22c7e303 +.insn 2, 0x929a +.insn 4, 0x26c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a623 +.insn 4, 0x1707e283 +.insn 4, 0x2b07e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a823 +.insn 4, 0x2307e303 +.insn 2, 0x929a +.insn 4, 0x2707e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a823 +.insn 4, 0x1747e283 +.insn 4, 0x2b47e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67aa23 +.insn 4, 0x2347e303 +.insn 2, 0x929a +.insn 4, 0x2747e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657aa23 +.insn 4, 0x1787e283 +.insn 4, 0x2b87e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67ac23 +.insn 4, 0x2387e303 +.insn 2, 0x929a +.insn 4, 0x2787e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657ac23 +.insn 4, 0x17c7e283 +.insn 4, 0x2bc7e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67ae23 +.insn 4, 0x23c7e303 +.insn 2, 0x929a +.insn 4, 0x27c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657ae23 +.insn 4, 0x2407b283 +.insn 4, 0x2c07b303 +.insn 4, 0x2467b023 +.insn 4, 0x2c57b023 +.insn 4, 0x2487b283 +.insn 4, 0x2c87b303 +.insn 4, 0x2467b423 +.insn 4, 0x2c57b423 +.insn 4, 0x2507b283 +.insn 4, 0x2d07b303 +.insn 4, 0x2467b823 +.insn 4, 0x2c57b823 +.insn 4, 0x2587b283 +.insn 4, 0x2d87b303 +.insn 4, 0x2467bc23 +.insn 4, 0x2c57bc23 +.insn 4, 0x2607b283 +.insn 4, 0x2e07b303 +.insn 4, 0x2667b023 +.insn 4, 0x2e57b023 +.insn 4, 0x2687b283 +.insn 4, 0x2e87b303 +.insn 4, 0x2667b423 +.insn 4, 0x2e57b423 +.insn 4, 0x2707b283 +.insn 4, 0x2f07b303 +.insn 4, 0x2667b823 +.insn 4, 0x2e57b823 +.insn 4, 0x2787b283 +.insn 4, 0x2f87b303 +.insn 4, 0x2667bc23 +.insn 4, 0x2e57bc23 +.insn 4, 0x2807b283 +.insn 4, 0x3007b303 +.insn 4, 0x2867b023 +.insn 4, 0x3057b023 +.insn 4, 0x2887b283 +.insn 4, 0x3087b303 +.insn 4, 0x2867b423 +.insn 4, 0x3057b423 +.insn 4, 0x2907b283 +.insn 4, 0x3107b303 +.insn 4, 0x2867b823 +.insn 4, 0x3057b823 +.insn 4, 0x2987b283 +.insn 4, 0x3187b303 +.insn 4, 0x2867bc23 +.insn 4, 0x3057bc23 +.insn 4, 0x2a07b283 +.insn 4, 0x3207b303 +.insn 4, 0x2a67b023 +.insn 4, 0x3257b023 +.insn 4, 0x2a87b283 +.insn 4, 0x3287b303 +.insn 4, 0x2a67b423 +.insn 4, 0x3257b423 +.insn 4, 0x2b07b283 +.insn 4, 0x3307b303 +.insn 4, 0x2a67b823 +.insn 4, 0x3257b823 +.insn 4, 0x2b87b283 +.insn 4, 0x3387b303 +.insn 4, 0x2a67bc23 +.insn 4, 0x3257bc23 +.insn 2, 0x0521 +.insn 2, 0x177d +bnez a4, 26b +.insn 4, 0xf8050513 +.insn 2, 0x4385 +.insn 4, 0x40878e13 +.insn 2, 0x8ebe +27: +.insn 4, 0x2c0ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0023 +.insn 4, 0x0102d313 +.insn 4, 0x006e00a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0123 +.insn 4, 0x0002d313 +.insn 4, 0x006e01a3 +.insn 4, 0x300ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0223 +.insn 4, 0x0102d313 +.insn 4, 0x006e02a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0323 +.insn 4, 0x0002d313 +.insn 4, 0x006e03a3 +.insn 4, 0x240ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0423 +.insn 4, 0x0102d313 +.insn 4, 0x006e04a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0523 +.insn 4, 0x0002d313 +.insn 4, 0x006e05a3 +.insn 4, 0x280ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0623 +.insn 4, 0x0102d313 +.insn 4, 0x006e06a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0723 +.insn 4, 0x0002d313 +.insn 4, 0x006e07a3 +.insn 2, 0x0e41 +.insn 2, 0x0e91 +.insn 2, 0x13fd +bnez t2, 27b +.insn 2, 0x852a +.insn 4, 0x3a87b403 +.insn 4, 0x3b07b483 +.insn 4, 0x3b87b903 +.insn 4, 0x3c07b983 +.insn 4, 0x3c87ba03 +.insn 4, 0x3d07ba83 +.insn 4, 0x3d87bb03 +.insn 4, 0x3e07bb83 +.insn 4, 0x3e87bc03 +.insn 4, 0x3f07bc83 +.insn 4, 0x3f87bd03 +.insn 4, 0x4007bd83 +.insn 2, 0x84ae +.insn 2, 0x8932 +.insn 2, 0x8986 +.insn 4, 0x4187b083 +.insn 4, 0xfd078a13 +.insn 2, 0x42c1 +bltu s3, t0, 28f +.insn 4, 0x438a6283 +.insn 4, 0x025a2023 +.insn 4, 0x43ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x440a6283 +.insn 4, 0x025a2423 +.insn 4, 0x444a6283 +.insn 4, 0x025a2623 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x438a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x43ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x440a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x444a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 29f +28: +.insn 4, 0x438a6283 +.insn 4, 0x025a2023 +.insn 4, 0x43ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x440a6283 +.insn 4, 0x025a2423 +.insn 4, 0x444a6283 +.insn 4, 0x025a2623 +.insn 4, 0x438a0393 +210: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 210b +29: +bnez s3, 24b +j 23f +22: +23: +j 21f +20: +beqz s3, 211f +213: +.insn 4, 0x020a6283 +.insn 4, 0x425a2c23 +.insn 4, 0x024a6283 +.insn 4, 0x425a2e23 +.insn 4, 0x028a6283 +.insn 4, 0x445a2023 +.insn 4, 0x02ca6283 +.insn 4, 0x445a2223 +.insn 4, 0x030a0293 +.insn 2, 0x8796 +.insn 4, 0x3a87b423 +.insn 4, 0x3a97b823 +.insn 4, 0x3b27bc23 +.insn 4, 0x3d37b023 +.insn 4, 0x3d47b423 +.insn 4, 0x3d57b823 +.insn 4, 0x3d67bc23 +.insn 4, 0x3f77b023 +.insn 4, 0x3f87b423 +.insn 4, 0x3f97b823 +.insn 4, 0x3fa7bc23 +.insn 4, 0x41b7b023 +.insn 4, 0x555552b7 +.insn 4, 0x5552829b +.insn 2, 0x1282 +.insn 4, 0x55555337 +.insn 4, 0x5553031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457b023 +.insn 4, 0x333332b7 +.insn 4, 0x3332829b +.insn 2, 0x1282 +.insn 4, 0x33333337 +.insn 4, 0x3333031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457b423 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457b823 +.insn 4, 0x00ff02b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0x00ff0337 +.insn 4, 0x0ff3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3457bc23 +.insn 4, 0xff0102b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0xff010337 +.insn 4, 0xf003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657b023 +.insn 4, 0xcffcd2b7 +.insn 2, 0x32f1 +.insn 2, 0x1282 +.insn 4, 0xcffcd337 +.insn 2, 0x3371 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657b423 +.insn 4, 0x00f342b7 +.insn 2, 0x32cd +.insn 2, 0x1282 +.insn 4, 0x00f34337 +.insn 2, 0x334d +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657b823 +.insn 4, 0x3f0002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x3f000337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3657bc23 +.insn 2, 0x62c1 +.insn 4, 0xccf2829b +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 4, 0xccf3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857b023 +.insn 4, 0xfccf02b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0xfccf0337 +.insn 2, 0x2301 +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857b423 +.insn 4, 0x000002b7 +.insn 4, 0x03f2829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 4, 0x03f3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857b823 +.insn 4, 0xf33ff2b7 +.insn 4, 0x3002829b +.insn 2, 0x1282 +.insn 4, 0xf33ff337 +.insn 4, 0x3003031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3857bc23 +.insn 4, 0xe72be2b7 +.insn 4, 0x72b2829b +.insn 2, 0x1282 +.insn 4, 0xe72be337 +.insn 4, 0x72b3031b +.insn 2, 0x1302 +.insn 4, 0x02035313 +.insn 4, 0x0062e2b3 +.insn 4, 0x3a57b023 +.insn 4, 0x34078693 +.insn 4, 0x4017bc23 +.insn 2, 0x85a6 +.insn 2, 0x864a +.insn 2, 0x80ce +.insn 2, 0x852a +.insn 2, 0x4385 +.insn 4, 0x40878e13 +.insn 2, 0x8ebe +214: +.insn 4, 0x000e4283 +.insn 2, 0x02e2 +.insn 4, 0x001e4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x002e4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x003e4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x245ea023 +.insn 4, 0x004e4283 +.insn 2, 0x02e2 +.insn 4, 0x005e4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x006e4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x007e4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x285ea023 +.insn 4, 0x008e4283 +.insn 2, 0x02e2 +.insn 4, 0x009e4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x00ae4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x00be4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x2c5ea023 +.insn 4, 0x00ce4283 +.insn 2, 0x02e2 +.insn 4, 0x00de4303 +.insn 2, 0x0342 +.insn 4, 0x0062e2b3 +.insn 4, 0x00ee4303 +.insn 2, 0x0322 +.insn 4, 0x0062e2b3 +.insn 4, 0x00fe4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x305ea023 +.insn 2, 0x0e41 +.insn 2, 0x0e91 +.insn 2, 0x13fd +bnez t2, 214b +.insn 2, 0x4741 +215: +.insn 4, 0x00054f03 +.insn 4, 0x00154283 +.insn 2, 0x02a2 +.insn 4, 0x005f6f33 +.insn 4, 0x00254283 +.insn 2, 0x02c2 +.insn 4, 0x005f6f33 +.insn 4, 0x00354283 +.insn 2, 0x02e2 +.insn 4, 0x005f6f33 +.insn 4, 0x00454f83 +.insn 4, 0x00554283 +.insn 2, 0x02a2 +.insn 4, 0x005fefb3 +.insn 4, 0x00654283 +.insn 2, 0x02c2 +.insn 4, 0x005fefb3 +.insn 4, 0x00754283 +.insn 2, 0x02e2 +.insn 4, 0x005fefb3 +.insn 4, 0x2c07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a023 +.insn 4, 0x3007e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a023 +.insn 4, 0x2c47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a223 +.insn 4, 0x3047e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a223 +.insn 4, 0x2c87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a423 +.insn 4, 0x3087e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a423 +.insn 4, 0x2cc7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a623 +.insn 4, 0x30c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a623 +.insn 4, 0x2d07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857a823 +.insn 4, 0x3107e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457a823 +.insn 4, 0x2d47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857aa23 +.insn 4, 0x3147e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457aa23 +.insn 4, 0x2d87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857ac23 +.insn 4, 0x3187e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457ac23 +.insn 4, 0x2dc7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1857ae23 +.insn 4, 0x31c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1457ae23 +.insn 4, 0x2e07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a023 +.insn 4, 0x3207e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a023 +.insn 4, 0x2e47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a223 +.insn 4, 0x3247e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a223 +.insn 4, 0x2e87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a423 +.insn 4, 0x3287e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a423 +.insn 4, 0x2ec7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a623 +.insn 4, 0x32c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a623 +.insn 4, 0x2f07e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57a823 +.insn 4, 0x3307e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657a823 +.insn 4, 0x2f47e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57aa23 +.insn 4, 0x3347e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657aa23 +.insn 4, 0x2f87e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57ac23 +.insn 4, 0x3387e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657ac23 +.insn 4, 0x2fc7e283 +.insn 4, 0x01e2c2b3 +.insn 4, 0x1a57ae23 +.insn 4, 0x33c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x01f2c2b3 +.insn 4, 0x1657ae23 +.insn 4, 0x1407b403 +.insn 4, 0x1487b483 +.insn 4, 0x1507b903 +.insn 4, 0x1587b983 +.insn 4, 0x1607ba03 +.insn 4, 0x1687ba83 +.insn 4, 0x1707bb03 +.insn 4, 0x1787bb83 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 2, 0x841a +.insn 4, 0x00744433 +.insn 4, 0x01d44433 +.insn 2, 0x84f2 +.insn 4, 0x01d4c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x897a +.insn 4, 0x01f94933 +.insn 4, 0x01194933 +.insn 2, 0x899e +.insn 4, 0x01c9c9b3 +.insn 4, 0x01d9c9b3 +.insn 4, 0x01f9c9b3 +.insn 2, 0x8a1e +.insn 4, 0x01ca4a33 +.insn 4, 0x01ea4a33 +.insn 2, 0x8af6 +.insn 4, 0x01eacab3 +.insn 2, 0x8b72 +.insn 4, 0x01db4b33 +.insn 4, 0x01eb4b33 +.insn 4, 0x01fb4b33 +.insn 2, 0x8bfa +.insn 4, 0x01fbcbb3 +.insn 4, 0x010bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x009bc333 +.insn 4, 0x014bc3b3 +.insn 4, 0x012bce33 +.insn 4, 0x015b4ab3 +.insn 4, 0x008aceb3 +.insn 4, 0x014eca33 +.insn 4, 0x00534f33 +.insn 4, 0x017ecfb3 +.insn 4, 0x009ec4b3 +.insn 4, 0x01c4c833 +.insn 4, 0x01e9c9b3 +.insn 4, 0x0129c933 +.insn 4, 0x0169c9b3 +.insn 4, 0x00894b33 +.insn 4, 0x015948b3 +.insn 4, 0x0079cc33 +.insn 4, 0x01844cb3 +.insn 4, 0x0188cd33 +.insn 4, 0x01c8cdb3 +.insn 4, 0x018acab3 +.insn 4, 0x01b7b023 +.insn 4, 0x01534db3 +.insn 4, 0x015bcbb3 +.insn 4, 0x0177b423 +.insn 4, 0x012f7bb3 +.insn 4, 0x01e7b823 +.insn 4, 0x01687f33 +.insn 4, 0x017f4f33 +.insn 4, 0x0107bc23 +.insn 4, 0x008a7833 +.insn 4, 0x01784833 +.insn 4, 0x01537bb3 +.insn 4, 0x0267b023 +.insn 4, 0x01d4f333 +.insn 4, 0x01734333 +.insn 2, 0xf784 +.insn 4, 0x019ff4b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x0183fbb3 +.insn 4, 0x0277b823 +.insn 4, 0x01a2f3b3 +.insn 4, 0x0173c3b3 +.insn 4, 0x0257bc23 +.insn 4, 0x011e72b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x007f4f33 +.insn 4, 0x00584833 +.insn 4, 0x00734333 +.insn 4, 0x0054c4b3 +.insn 4, 0x013f4f33 +.insn 4, 0x0007b983 +.insn 4, 0x01384833 +.insn 4, 0x01b34333 +.insn 4, 0x0087bd83 +.insn 4, 0x01b4c4b3 +.insn 4, 0x010f4db3 +.insn 4, 0x006f7f33 +.insn 4, 0x01e4c9b3 +.insn 4, 0x013df2b3 +.insn 4, 0x0102c2b3 +.insn 4, 0x009343b3 +.insn 4, 0x01e84833 +.insn 4, 0x00787833 +.insn 4, 0x00984833 +.insn 4, 0x01034333 +.insn 4, 0x0109c3b3 +.insn 4, 0x0074f4b3 +.insn 4, 0x0064c333 +.insn 4, 0x0099c9b3 +.insn 4, 0x0132f9b3 +.insn 4, 0x013dcdb3 +.insn 4, 0x006dc9b3 +.insn 4, 0x0102c4b3 +.insn 4, 0x01b2c3b3 +.insn 4, 0x00684f33 +.insn 4, 0x0134cbb3 +.insn 4, 0x012f7933 +.insn 4, 0x01637b33 +.insn 4, 0x00887433 +.insn 4, 0x0153fab3 +.insn 4, 0x01ddfeb3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0184fc33 +.insn 4, 0x01abfd33 +.insn 4, 0x0119f8b3 +.insn 4, 0x0167b423 +.insn 4, 0x0107bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0187bb03 +.insn 4, 0x01637333 +.insn 4, 0x01487833 +.insn 4, 0x0207ba03 +.insn 4, 0x0143f3b3 +.insn 4, 0x0287ba03 +.insn 4, 0x014dfdb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0307bf83 +.insn 4, 0x01f4f4b3 +.insn 4, 0x0387bf83 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01c9f9b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x01034833 +.insn 4, 0x01bccdb3 +.insn 4, 0x006f4f33 +.insn 4, 0x00744333 +.insn 4, 0x01944433 +.insn 4, 0x011d48b3 +.insn 4, 0x01594933 +.insn 4, 0x01ac4c33 +.insn 4, 0x013bcbb3 +.insn 4, 0x01b3c3b3 +.insn 4, 0x01234333 +.insn 4, 0x009ec9b3 +.insn 4, 0x018acab3 +.insn 4, 0x0064c4b3 +.insn 4, 0x0062c2b3 +.insn 4, 0x0138c8b3 +.insn 4, 0x013f4f33 +.insn 4, 0x015eceb3 +.insn 4, 0x0112c2b3 +.insn 4, 0x0087b983 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01eacab3 +.insn 4, 0x0113c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x009dcdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x005ec4b3 +.insn 4, 0x01394a33 +.insn 4, 0x013449b3 +.insn 4, 0x00584933 +.insn 4, 0x014ecb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x009bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x0177b423 +.insn 2, 0x8bd6 +.insn 4, 0x0087ba83 +.insn 2, 0x849e +.insn 2, 0x846e +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 4, 0x0186bc03 +.insn 4, 0x0206bc83 +.insn 4, 0x0193f433 +.insn 4, 0x018e72b3 +.insn 4, 0x00544433 +.insn 4, 0x019ef2b3 +.insn 4, 0x00544433 +.insn 4, 0x018f72b3 +.insn 4, 0x00544433 +.insn 4, 0x018ff2b3 +.insn 4, 0x00544433 +.insn 4, 0x018872b3 +.insn 4, 0x00544433 +.insn 4, 0x0193f4b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x01e4c4b3 +.insn 4, 0x019ff2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x891a +.insn 4, 0x0183f2b3 +.insn 4, 0x00594933 +.insn 4, 0x019e72b3 +.insn 4, 0x00594933 +.insn 4, 0x019ef2b3 +.insn 4, 0x00594933 +.insn 4, 0x01e94933 +.insn 4, 0x01094933 +.insn 2, 0x899a +.insn 4, 0x0193f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x019ef2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01f9c9b3 +.insn 4, 0x0109c9b3 +.insn 4, 0x0188f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01837a33 +.insn 4, 0x018e72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01da4a33 +.insn 4, 0x018f72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x010a4a33 +.insn 4, 0x0198f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01837ab3 +.insn 4, 0x0183f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x01dacab3 +.insn 4, 0x019f72b3 +.insn 4, 0x005acab3 +.insn 4, 0x01facab3 +.insn 4, 0x010acab3 +.insn 4, 0x01837b33 +.insn 4, 0x0193f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019e72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019ef2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018f72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018ff2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x010b4b33 +.insn 4, 0x0183fbb3 +.insn 4, 0x01dbcbb3 +.insn 4, 0x018872b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0188f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0286b383 +.insn 4, 0x0306be03 +.insn 4, 0x0386bf83 +.insn 4, 0x0406be83 +.insn 4, 0x0486b803 +.insn 4, 0x0506bf03 +.insn 4, 0x0586b883 +.insn 4, 0x0606bc03 +.insn 4, 0x00747333 +.insn 4, 0x00845293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01841293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01045293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01041293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01845293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00841293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b023 +.insn 4, 0x0074f333 +.insn 4, 0x0084d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01849293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0104d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01049293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0184d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00849293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b423 +.insn 4, 0x00797333 +.insn 4, 0x00895293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01891293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01095293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01091293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01895293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00891293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b823 +.insn 4, 0x0079f333 +.insn 4, 0x0089d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01899293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0109d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01099293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0189d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00899293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467bc23 +.insn 4, 0x007a7333 +.insn 4, 0x008a5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b023 +.insn 4, 0x007af333 +.insn 4, 0x008ad293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010ad293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018ad293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b423 +.insn 4, 0x007b7333 +.insn 4, 0x008b5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b823 +.insn 4, 0x007bf333 +.insn 4, 0x008bd293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010bd293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018bd293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667bc23 +.insn 4, 0x1407e283 +.insn 4, 0x1c57a023 +.insn 4, 0x1807e303 +.insn 2, 0x929a +.insn 4, 0x1457a023 +.insn 4, 0x1447e283 +.insn 4, 0x1c57a223 +.insn 4, 0x1847e303 +.insn 2, 0x929a +.insn 4, 0x1457a223 +.insn 4, 0x1487e283 +.insn 4, 0x1c57a423 +.insn 4, 0x1887e303 +.insn 2, 0x929a +.insn 4, 0x1457a423 +.insn 4, 0x14c7e283 +.insn 4, 0x1c57a623 +.insn 4, 0x18c7e303 +.insn 2, 0x929a +.insn 4, 0x1457a623 +.insn 4, 0x1507e283 +.insn 4, 0x1c57a823 +.insn 4, 0x1907e303 +.insn 2, 0x929a +.insn 4, 0x1457a823 +.insn 4, 0x1547e283 +.insn 4, 0x1c57aa23 +.insn 4, 0x1947e303 +.insn 2, 0x929a +.insn 4, 0x1457aa23 +.insn 4, 0x1587e283 +.insn 4, 0x1c57ac23 +.insn 4, 0x1987e303 +.insn 2, 0x929a +.insn 4, 0x1457ac23 +.insn 4, 0x15c7e283 +.insn 4, 0x1c57ae23 +.insn 4, 0x19c7e303 +.insn 2, 0x929a +.insn 4, 0x1457ae23 +.insn 4, 0x1607e283 +.insn 4, 0x1e57a023 +.insn 4, 0x1a07e303 +.insn 2, 0x929a +.insn 4, 0x1657a023 +.insn 4, 0x1647e283 +.insn 4, 0x1e57a223 +.insn 4, 0x1a47e303 +.insn 2, 0x929a +.insn 4, 0x1657a223 +.insn 4, 0x1687e283 +.insn 4, 0x1e57a423 +.insn 4, 0x1a87e303 +.insn 2, 0x929a +.insn 4, 0x1657a423 +.insn 4, 0x16c7e283 +.insn 4, 0x1e57a623 +.insn 4, 0x1ac7e303 +.insn 2, 0x929a +.insn 4, 0x1657a623 +.insn 4, 0x1707e283 +.insn 4, 0x1e57a823 +.insn 4, 0x1b07e303 +.insn 2, 0x929a +.insn 4, 0x1657a823 +.insn 4, 0x1747e283 +.insn 4, 0x1e57aa23 +.insn 4, 0x1b47e303 +.insn 2, 0x929a +.insn 4, 0x1657aa23 +.insn 4, 0x1787e283 +.insn 4, 0x1e57ac23 +.insn 4, 0x1b87e303 +.insn 2, 0x929a +.insn 4, 0x1657ac23 +.insn 4, 0x17c7e283 +.insn 4, 0x1e57ae23 +.insn 4, 0x1bc7e303 +.insn 2, 0x929a +.insn 4, 0x1657ae23 +.insn 4, 0x1407b403 +.insn 4, 0x1487b483 +.insn 4, 0x1507b903 +.insn 4, 0x1587b983 +.insn 4, 0x1607ba03 +.insn 4, 0x1687ba83 +.insn 4, 0x1707bb03 +.insn 4, 0x1787bb83 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 2, 0x841a +.insn 4, 0x00744433 +.insn 4, 0x01d44433 +.insn 2, 0x84f2 +.insn 4, 0x01d4c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x897a +.insn 4, 0x01f94933 +.insn 4, 0x01194933 +.insn 2, 0x899e +.insn 4, 0x01c9c9b3 +.insn 4, 0x01d9c9b3 +.insn 4, 0x01f9c9b3 +.insn 2, 0x8a1e +.insn 4, 0x01ca4a33 +.insn 4, 0x01ea4a33 +.insn 2, 0x8af6 +.insn 4, 0x01eacab3 +.insn 2, 0x8b72 +.insn 4, 0x01db4b33 +.insn 4, 0x01eb4b33 +.insn 4, 0x01fb4b33 +.insn 2, 0x8bfa +.insn 4, 0x01fbcbb3 +.insn 4, 0x010bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x009bc333 +.insn 4, 0x014bc3b3 +.insn 4, 0x012bce33 +.insn 4, 0x015b4ab3 +.insn 4, 0x008aceb3 +.insn 4, 0x014eca33 +.insn 4, 0x00534f33 +.insn 4, 0x017ecfb3 +.insn 4, 0x009ec4b3 +.insn 4, 0x01c4c833 +.insn 4, 0x01e9c9b3 +.insn 4, 0x0129c933 +.insn 4, 0x0169c9b3 +.insn 4, 0x00894b33 +.insn 4, 0x015948b3 +.insn 4, 0x0079cc33 +.insn 4, 0x01844cb3 +.insn 4, 0x0188cd33 +.insn 4, 0x01c8cdb3 +.insn 4, 0x018acab3 +.insn 4, 0x01b7b023 +.insn 4, 0x01534db3 +.insn 4, 0x015bcbb3 +.insn 4, 0x0177b423 +.insn 4, 0x012f7bb3 +.insn 4, 0x01e7b823 +.insn 4, 0x01687f33 +.insn 4, 0x017f4f33 +.insn 4, 0x0107bc23 +.insn 4, 0x008a7833 +.insn 4, 0x01784833 +.insn 4, 0x01537bb3 +.insn 4, 0x0267b023 +.insn 4, 0x01d4f333 +.insn 4, 0x01734333 +.insn 2, 0xf784 +.insn 4, 0x019ff4b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x0183fbb3 +.insn 4, 0x0277b823 +.insn 4, 0x01a2f3b3 +.insn 4, 0x0173c3b3 +.insn 4, 0x0257bc23 +.insn 4, 0x011e72b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x007f4f33 +.insn 4, 0x00584833 +.insn 4, 0x00734333 +.insn 4, 0x0054c4b3 +.insn 4, 0x013f4f33 +.insn 4, 0x0007b983 +.insn 4, 0x01384833 +.insn 4, 0x01b34333 +.insn 4, 0x0087bd83 +.insn 4, 0x01b4c4b3 +.insn 4, 0x010f4db3 +.insn 4, 0x006f7f33 +.insn 4, 0x01e4c9b3 +.insn 4, 0x013df2b3 +.insn 4, 0x0102c2b3 +.insn 4, 0x009343b3 +.insn 4, 0x01e84833 +.insn 4, 0x00787833 +.insn 4, 0x00984833 +.insn 4, 0x01034333 +.insn 4, 0x0109c3b3 +.insn 4, 0x0074f4b3 +.insn 4, 0x0064c333 +.insn 4, 0x0099c9b3 +.insn 4, 0x0132f9b3 +.insn 4, 0x013dcdb3 +.insn 4, 0x006dc9b3 +.insn 4, 0x0102c4b3 +.insn 4, 0x01b2c3b3 +.insn 4, 0x00684f33 +.insn 4, 0x0134cbb3 +.insn 4, 0x012f7933 +.insn 4, 0x01637b33 +.insn 4, 0x00887433 +.insn 4, 0x0153fab3 +.insn 4, 0x01ddfeb3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0184fc33 +.insn 4, 0x01abfd33 +.insn 4, 0x0119f8b3 +.insn 4, 0x0167b423 +.insn 4, 0x0107bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0187bb03 +.insn 4, 0x01637333 +.insn 4, 0x01487833 +.insn 4, 0x0207ba03 +.insn 4, 0x0143f3b3 +.insn 4, 0x0287ba03 +.insn 4, 0x014dfdb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0307bf83 +.insn 4, 0x01f4f4b3 +.insn 4, 0x0387bf83 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01c9f9b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x01034833 +.insn 4, 0x01bccdb3 +.insn 4, 0x006f4f33 +.insn 4, 0x00744333 +.insn 4, 0x01944433 +.insn 4, 0x011d48b3 +.insn 4, 0x01594933 +.insn 4, 0x01ac4c33 +.insn 4, 0x013bcbb3 +.insn 4, 0x01b3c3b3 +.insn 4, 0x01234333 +.insn 4, 0x009ec9b3 +.insn 4, 0x018acab3 +.insn 4, 0x0064c4b3 +.insn 4, 0x0062c2b3 +.insn 4, 0x0138c8b3 +.insn 4, 0x013f4f33 +.insn 4, 0x015eceb3 +.insn 4, 0x0112c2b3 +.insn 4, 0x0087b983 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01eacab3 +.insn 4, 0x0113c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x009dcdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x005ec4b3 +.insn 4, 0x01394a33 +.insn 4, 0x013449b3 +.insn 4, 0x00584933 +.insn 4, 0x014ecb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x009bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x0177b423 +.insn 2, 0x8bd6 +.insn 4, 0x0087ba83 +.insn 2, 0x849e +.insn 2, 0x846e +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 4, 0x0186bc03 +.insn 4, 0x0206bc83 +.insn 4, 0x0193f433 +.insn 4, 0x018e72b3 +.insn 4, 0x00544433 +.insn 4, 0x019ef2b3 +.insn 4, 0x00544433 +.insn 4, 0x018f72b3 +.insn 4, 0x00544433 +.insn 4, 0x018ff2b3 +.insn 4, 0x00544433 +.insn 4, 0x018872b3 +.insn 4, 0x00544433 +.insn 4, 0x0193f4b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x01e4c4b3 +.insn 4, 0x019ff2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x891a +.insn 4, 0x0183f2b3 +.insn 4, 0x00594933 +.insn 4, 0x019e72b3 +.insn 4, 0x00594933 +.insn 4, 0x019ef2b3 +.insn 4, 0x00594933 +.insn 4, 0x01e94933 +.insn 4, 0x01094933 +.insn 2, 0x899a +.insn 4, 0x0193f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x019ef2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01f9c9b3 +.insn 4, 0x0109c9b3 +.insn 4, 0x0188f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01837a33 +.insn 4, 0x018e72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01da4a33 +.insn 4, 0x018f72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x010a4a33 +.insn 4, 0x0198f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01837ab3 +.insn 4, 0x0183f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x01dacab3 +.insn 4, 0x019f72b3 +.insn 4, 0x005acab3 +.insn 4, 0x01facab3 +.insn 4, 0x010acab3 +.insn 4, 0x01837b33 +.insn 4, 0x0193f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019e72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019ef2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018f72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018ff2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x010b4b33 +.insn 4, 0x0183fbb3 +.insn 4, 0x01dbcbb3 +.insn 4, 0x018872b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0188f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0286b383 +.insn 4, 0x0306be03 +.insn 4, 0x0386bf83 +.insn 4, 0x0406be83 +.insn 4, 0x0486b803 +.insn 4, 0x0506bf03 +.insn 4, 0x0586b883 +.insn 4, 0x0606bc03 +.insn 4, 0x00747333 +.insn 4, 0x00845293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01841293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01045293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01041293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01845293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00841293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b023 +.insn 4, 0x0074f333 +.insn 4, 0x0084d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01849293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0104d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01049293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0184d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00849293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b423 +.insn 4, 0x00797333 +.insn 4, 0x00895293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01891293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01095293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01091293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01895293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00891293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b823 +.insn 4, 0x0079f333 +.insn 4, 0x0089d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01899293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0109d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01099293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0189d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00899293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467bc23 +.insn 4, 0x007a7333 +.insn 4, 0x008a5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b023 +.insn 4, 0x007af333 +.insn 4, 0x008ad293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010ad293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018ad293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b423 +.insn 4, 0x007b7333 +.insn 4, 0x008b5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b823 +.insn 4, 0x007bf333 +.insn 4, 0x008bd293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010bd293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018bd293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667bc23 +.insn 4, 0x1407e283 +.insn 4, 0x2057a023 +.insn 4, 0x1c07e303 +.insn 2, 0x929a +.insn 4, 0x1457a023 +.insn 4, 0x1447e283 +.insn 4, 0x2057a223 +.insn 4, 0x1c47e303 +.insn 2, 0x929a +.insn 4, 0x1457a223 +.insn 4, 0x1487e283 +.insn 4, 0x2057a423 +.insn 4, 0x1c87e303 +.insn 2, 0x929a +.insn 4, 0x1457a423 +.insn 4, 0x14c7e283 +.insn 4, 0x2057a623 +.insn 4, 0x1cc7e303 +.insn 2, 0x929a +.insn 4, 0x1457a623 +.insn 4, 0x1507e283 +.insn 4, 0x2057a823 +.insn 4, 0x1d07e303 +.insn 2, 0x929a +.insn 4, 0x1457a823 +.insn 4, 0x1547e283 +.insn 4, 0x2057aa23 +.insn 4, 0x1d47e303 +.insn 2, 0x929a +.insn 4, 0x1457aa23 +.insn 4, 0x1587e283 +.insn 4, 0x2057ac23 +.insn 4, 0x1d87e303 +.insn 2, 0x929a +.insn 4, 0x1457ac23 +.insn 4, 0x15c7e283 +.insn 4, 0x2057ae23 +.insn 4, 0x1dc7e303 +.insn 2, 0x929a +.insn 4, 0x1457ae23 +.insn 4, 0x1607e283 +.insn 4, 0x2257a023 +.insn 4, 0x1e07e303 +.insn 2, 0x929a +.insn 4, 0x1657a023 +.insn 4, 0x1647e283 +.insn 4, 0x2257a223 +.insn 4, 0x1e47e303 +.insn 2, 0x929a +.insn 4, 0x1657a223 +.insn 4, 0x1687e283 +.insn 4, 0x2257a423 +.insn 4, 0x1e87e303 +.insn 2, 0x929a +.insn 4, 0x1657a423 +.insn 4, 0x16c7e283 +.insn 4, 0x2257a623 +.insn 4, 0x1ec7e303 +.insn 2, 0x929a +.insn 4, 0x1657a623 +.insn 4, 0x1707e283 +.insn 4, 0x2257a823 +.insn 4, 0x1f07e303 +.insn 2, 0x929a +.insn 4, 0x1657a823 +.insn 4, 0x1747e283 +.insn 4, 0x2257aa23 +.insn 4, 0x1f47e303 +.insn 2, 0x929a +.insn 4, 0x1657aa23 +.insn 4, 0x1787e283 +.insn 4, 0x2257ac23 +.insn 4, 0x1f87e303 +.insn 2, 0x929a +.insn 4, 0x1657ac23 +.insn 4, 0x17c7e283 +.insn 4, 0x2257ae23 +.insn 4, 0x1fc7e303 +.insn 2, 0x929a +.insn 4, 0x1657ae23 +.insn 4, 0x1407b403 +.insn 4, 0x1487b483 +.insn 4, 0x1507b903 +.insn 4, 0x1587b983 +.insn 4, 0x1607ba03 +.insn 4, 0x1687ba83 +.insn 4, 0x1707bb03 +.insn 4, 0x1787bb83 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 2, 0x841a +.insn 4, 0x00744433 +.insn 4, 0x01d44433 +.insn 2, 0x84f2 +.insn 4, 0x01d4c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x897a +.insn 4, 0x01f94933 +.insn 4, 0x01194933 +.insn 2, 0x899e +.insn 4, 0x01c9c9b3 +.insn 4, 0x01d9c9b3 +.insn 4, 0x01f9c9b3 +.insn 2, 0x8a1e +.insn 4, 0x01ca4a33 +.insn 4, 0x01ea4a33 +.insn 2, 0x8af6 +.insn 4, 0x01eacab3 +.insn 2, 0x8b72 +.insn 4, 0x01db4b33 +.insn 4, 0x01eb4b33 +.insn 4, 0x01fb4b33 +.insn 2, 0x8bfa +.insn 4, 0x01fbcbb3 +.insn 4, 0x010bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x009bc333 +.insn 4, 0x014bc3b3 +.insn 4, 0x012bce33 +.insn 4, 0x015b4ab3 +.insn 4, 0x008aceb3 +.insn 4, 0x014eca33 +.insn 4, 0x00534f33 +.insn 4, 0x017ecfb3 +.insn 4, 0x009ec4b3 +.insn 4, 0x01c4c833 +.insn 4, 0x01e9c9b3 +.insn 4, 0x0129c933 +.insn 4, 0x0169c9b3 +.insn 4, 0x00894b33 +.insn 4, 0x015948b3 +.insn 4, 0x0079cc33 +.insn 4, 0x01844cb3 +.insn 4, 0x0188cd33 +.insn 4, 0x01c8cdb3 +.insn 4, 0x018acab3 +.insn 4, 0x01b7b023 +.insn 4, 0x01534db3 +.insn 4, 0x015bcbb3 +.insn 4, 0x0177b423 +.insn 4, 0x012f7bb3 +.insn 4, 0x01e7b823 +.insn 4, 0x01687f33 +.insn 4, 0x017f4f33 +.insn 4, 0x0107bc23 +.insn 4, 0x008a7833 +.insn 4, 0x01784833 +.insn 4, 0x01537bb3 +.insn 4, 0x0267b023 +.insn 4, 0x01d4f333 +.insn 4, 0x01734333 +.insn 2, 0xf784 +.insn 4, 0x019ff4b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x0183fbb3 +.insn 4, 0x0277b823 +.insn 4, 0x01a2f3b3 +.insn 4, 0x0173c3b3 +.insn 4, 0x0257bc23 +.insn 4, 0x011e72b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x007f4f33 +.insn 4, 0x00584833 +.insn 4, 0x00734333 +.insn 4, 0x0054c4b3 +.insn 4, 0x013f4f33 +.insn 4, 0x0007b983 +.insn 4, 0x01384833 +.insn 4, 0x01b34333 +.insn 4, 0x0087bd83 +.insn 4, 0x01b4c4b3 +.insn 4, 0x010f4db3 +.insn 4, 0x006f7f33 +.insn 4, 0x01e4c9b3 +.insn 4, 0x013df2b3 +.insn 4, 0x0102c2b3 +.insn 4, 0x009343b3 +.insn 4, 0x01e84833 +.insn 4, 0x00787833 +.insn 4, 0x00984833 +.insn 4, 0x01034333 +.insn 4, 0x0109c3b3 +.insn 4, 0x0074f4b3 +.insn 4, 0x0064c333 +.insn 4, 0x0099c9b3 +.insn 4, 0x0132f9b3 +.insn 4, 0x013dcdb3 +.insn 4, 0x006dc9b3 +.insn 4, 0x0102c4b3 +.insn 4, 0x01b2c3b3 +.insn 4, 0x00684f33 +.insn 4, 0x0134cbb3 +.insn 4, 0x012f7933 +.insn 4, 0x01637b33 +.insn 4, 0x00887433 +.insn 4, 0x0153fab3 +.insn 4, 0x01ddfeb3 +.insn 4, 0x0192fcb3 +.insn 4, 0x0184fc33 +.insn 4, 0x01abfd33 +.insn 4, 0x0119f8b3 +.insn 4, 0x0167b423 +.insn 4, 0x0107bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0187bb03 +.insn 4, 0x01637333 +.insn 4, 0x01487833 +.insn 4, 0x0207ba03 +.insn 4, 0x0143f3b3 +.insn 4, 0x0287ba03 +.insn 4, 0x014dfdb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0307bf83 +.insn 4, 0x01f4f4b3 +.insn 4, 0x0387bf83 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01c9f9b3 +.insn 4, 0x0174c4b3 +.insn 4, 0x01034833 +.insn 4, 0x01bccdb3 +.insn 4, 0x006f4f33 +.insn 4, 0x00744333 +.insn 4, 0x01944433 +.insn 4, 0x011d48b3 +.insn 4, 0x01594933 +.insn 4, 0x01ac4c33 +.insn 4, 0x013bcbb3 +.insn 4, 0x01b3c3b3 +.insn 4, 0x01234333 +.insn 4, 0x009ec9b3 +.insn 4, 0x018acab3 +.insn 4, 0x0064c4b3 +.insn 4, 0x0062c2b3 +.insn 4, 0x0138c8b3 +.insn 4, 0x013f4f33 +.insn 4, 0x015eceb3 +.insn 4, 0x0112c2b3 +.insn 4, 0x0087b983 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01eacab3 +.insn 4, 0x0113c3b3 +.insn 4, 0xfff3c393 +.insn 4, 0x009dcdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x005ec4b3 +.insn 4, 0x01394a33 +.insn 4, 0x013449b3 +.insn 4, 0x00584933 +.insn 4, 0x014ecb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x009bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x0177b423 +.insn 2, 0x8bd6 +.insn 4, 0x0087ba83 +.insn 2, 0x849e +.insn 2, 0x846e +.insn 2, 0x8322 +.insn 2, 0x83a6 +.insn 2, 0x8e4a +.insn 2, 0x8ece +.insn 2, 0x8f52 +.insn 2, 0x8fd6 +.insn 2, 0x885a +.insn 2, 0x88de +.insn 4, 0x0186bc03 +.insn 4, 0x0206bc83 +.insn 4, 0x0193f433 +.insn 4, 0x018e72b3 +.insn 4, 0x00544433 +.insn 4, 0x019ef2b3 +.insn 4, 0x00544433 +.insn 4, 0x018f72b3 +.insn 4, 0x00544433 +.insn 4, 0x018ff2b3 +.insn 4, 0x00544433 +.insn 4, 0x018872b3 +.insn 4, 0x00544433 +.insn 4, 0x0193f4b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x01e4c4b3 +.insn 4, 0x019ff2b3 +.insn 4, 0x0054c4b3 +.insn 4, 0x0104c4b3 +.insn 4, 0x0114c4b3 +.insn 2, 0x891a +.insn 4, 0x0183f2b3 +.insn 4, 0x00594933 +.insn 4, 0x019e72b3 +.insn 4, 0x00594933 +.insn 4, 0x019ef2b3 +.insn 4, 0x00594933 +.insn 4, 0x01e94933 +.insn 4, 0x01094933 +.insn 2, 0x899a +.insn 4, 0x0193f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x018e72b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x019ef2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01e9c9b3 +.insn 4, 0x01f9c9b3 +.insn 4, 0x0109c9b3 +.insn 4, 0x0188f2b3 +.insn 4, 0x0059c9b3 +.insn 4, 0x01837a33 +.insn 4, 0x018e72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01da4a33 +.insn 4, 0x018f72b3 +.insn 4, 0x005a4a33 +.insn 4, 0x010a4a33 +.insn 4, 0x0198f2b3 +.insn 4, 0x005a4a33 +.insn 4, 0x01837ab3 +.insn 4, 0x0183f2b3 +.insn 4, 0x005acab3 +.insn 4, 0x01dacab3 +.insn 4, 0x019f72b3 +.insn 4, 0x005acab3 +.insn 4, 0x01facab3 +.insn 4, 0x010acab3 +.insn 4, 0x01837b33 +.insn 4, 0x0193f2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019e72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x019ef2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018f72b3 +.insn 4, 0x005b4b33 +.insn 4, 0x018ff2b3 +.insn 4, 0x005b4b33 +.insn 4, 0x010b4b33 +.insn 4, 0x0183fbb3 +.insn 4, 0x01dbcbb3 +.insn 4, 0x018872b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0188f2b3 +.insn 4, 0x005bcbb3 +.insn 4, 0x0006bf83 +.insn 4, 0x0086b803 +.insn 4, 0x0106b883 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x0286b383 +.insn 4, 0x0306be03 +.insn 4, 0x0386bf83 +.insn 4, 0x0406be83 +.insn 4, 0x0486b803 +.insn 4, 0x0506bf03 +.insn 4, 0x0586b883 +.insn 4, 0x0606bc03 +.insn 4, 0x00747333 +.insn 4, 0x00845293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01841293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01045293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01041293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01845293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00841293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b023 +.insn 4, 0x0074f333 +.insn 4, 0x0084d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01849293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0104d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01049293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0184d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00849293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b423 +.insn 4, 0x00797333 +.insn 4, 0x00895293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01891293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01095293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01091293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01895293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00891293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467b823 +.insn 4, 0x0079f333 +.insn 4, 0x0089d293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01899293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0109d293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01099293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x0189d293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x00899293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1467bc23 +.insn 4, 0x007a7333 +.insn 4, 0x008a5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b023 +.insn 4, 0x007af333 +.insn 4, 0x008ad293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018a9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010ad293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010a9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018ad293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008a9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b423 +.insn 4, 0x007b7333 +.insn 4, 0x008b5293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b1293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b5293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b1293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b5293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b1293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667b823 +.insn 4, 0x007bf333 +.insn 4, 0x008bd293 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018b9293 +.insn 4, 0x01f2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010bd293 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x010b9293 +.insn 4, 0x0102f2b3 +.insn 4, 0x00534333 +.insn 4, 0x018bd293 +.insn 4, 0x01e2f2b3 +.insn 4, 0x00534333 +.insn 4, 0x008b9293 +.insn 4, 0x0112f2b3 +.insn 4, 0x00534333 +.insn 4, 0x01834333 +.insn 4, 0x1667bc23 +.insn 4, 0x1407e283 +.insn 4, 0x2807e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a023 +.insn 4, 0x2007e303 +.insn 2, 0x929a +.insn 4, 0x2407e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a023 +.insn 4, 0x1447e283 +.insn 4, 0x2847e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a223 +.insn 4, 0x2047e303 +.insn 2, 0x929a +.insn 4, 0x2447e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a223 +.insn 4, 0x1487e283 +.insn 4, 0x2887e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a423 +.insn 4, 0x2087e303 +.insn 2, 0x929a +.insn 4, 0x2487e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a423 +.insn 4, 0x14c7e283 +.insn 4, 0x28c7e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a623 +.insn 4, 0x20c7e303 +.insn 2, 0x929a +.insn 4, 0x24c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a623 +.insn 4, 0x1507e283 +.insn 4, 0x2907e303 +.insn 4, 0x00534333 +.insn 4, 0x2867a823 +.insn 4, 0x2107e303 +.insn 2, 0x929a +.insn 4, 0x2507e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457a823 +.insn 4, 0x1547e283 +.insn 4, 0x2947e303 +.insn 4, 0x00534333 +.insn 4, 0x2867aa23 +.insn 4, 0x2147e303 +.insn 2, 0x929a +.insn 4, 0x2547e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457aa23 +.insn 4, 0x1587e283 +.insn 4, 0x2987e303 +.insn 4, 0x00534333 +.insn 4, 0x2867ac23 +.insn 4, 0x2187e303 +.insn 2, 0x929a +.insn 4, 0x2587e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457ac23 +.insn 4, 0x15c7e283 +.insn 4, 0x29c7e303 +.insn 4, 0x00534333 +.insn 4, 0x2867ae23 +.insn 4, 0x21c7e303 +.insn 2, 0x929a +.insn 4, 0x25c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457ae23 +.insn 4, 0x1607e283 +.insn 4, 0x2a07e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a023 +.insn 4, 0x2207e303 +.insn 2, 0x929a +.insn 4, 0x2607e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a023 +.insn 4, 0x1647e283 +.insn 4, 0x2a47e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a223 +.insn 4, 0x2247e303 +.insn 2, 0x929a +.insn 4, 0x2647e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a223 +.insn 4, 0x1687e283 +.insn 4, 0x2a87e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a423 +.insn 4, 0x2287e303 +.insn 2, 0x929a +.insn 4, 0x2687e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a423 +.insn 4, 0x16c7e283 +.insn 4, 0x2ac7e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a623 +.insn 4, 0x22c7e303 +.insn 2, 0x929a +.insn 4, 0x26c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a623 +.insn 4, 0x1707e283 +.insn 4, 0x2b07e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67a823 +.insn 4, 0x2307e303 +.insn 2, 0x929a +.insn 4, 0x2707e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657a823 +.insn 4, 0x1747e283 +.insn 4, 0x2b47e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67aa23 +.insn 4, 0x2347e303 +.insn 2, 0x929a +.insn 4, 0x2747e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657aa23 +.insn 4, 0x1787e283 +.insn 4, 0x2b87e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67ac23 +.insn 4, 0x2387e303 +.insn 2, 0x929a +.insn 4, 0x2787e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657ac23 +.insn 4, 0x17c7e283 +.insn 4, 0x2bc7e303 +.insn 4, 0x00534333 +.insn 4, 0x2a67ae23 +.insn 4, 0x23c7e303 +.insn 2, 0x929a +.insn 4, 0x27c7e303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657ae23 +.insn 4, 0x2407b283 +.insn 4, 0x2c07b303 +.insn 4, 0x2467b023 +.insn 4, 0x2c57b023 +.insn 4, 0x2487b283 +.insn 4, 0x2c87b303 +.insn 4, 0x2467b423 +.insn 4, 0x2c57b423 +.insn 4, 0x2507b283 +.insn 4, 0x2d07b303 +.insn 4, 0x2467b823 +.insn 4, 0x2c57b823 +.insn 4, 0x2587b283 +.insn 4, 0x2d87b303 +.insn 4, 0x2467bc23 +.insn 4, 0x2c57bc23 +.insn 4, 0x2607b283 +.insn 4, 0x2e07b303 +.insn 4, 0x2667b023 +.insn 4, 0x2e57b023 +.insn 4, 0x2687b283 +.insn 4, 0x2e87b303 +.insn 4, 0x2667b423 +.insn 4, 0x2e57b423 +.insn 4, 0x2707b283 +.insn 4, 0x2f07b303 +.insn 4, 0x2667b823 +.insn 4, 0x2e57b823 +.insn 4, 0x2787b283 +.insn 4, 0x2f87b303 +.insn 4, 0x2667bc23 +.insn 4, 0x2e57bc23 +.insn 4, 0x2807b283 +.insn 4, 0x3007b303 +.insn 4, 0x2867b023 +.insn 4, 0x3057b023 +.insn 4, 0x2887b283 +.insn 4, 0x3087b303 +.insn 4, 0x2867b423 +.insn 4, 0x3057b423 +.insn 4, 0x2907b283 +.insn 4, 0x3107b303 +.insn 4, 0x2867b823 +.insn 4, 0x3057b823 +.insn 4, 0x2987b283 +.insn 4, 0x3187b303 +.insn 4, 0x2867bc23 +.insn 4, 0x3057bc23 +.insn 4, 0x2a07b283 +.insn 4, 0x3207b303 +.insn 4, 0x2a67b023 +.insn 4, 0x3257b023 +.insn 4, 0x2a87b283 +.insn 4, 0x3287b303 +.insn 4, 0x2a67b423 +.insn 4, 0x3257b423 +.insn 4, 0x2b07b283 +.insn 4, 0x3307b303 +.insn 4, 0x2a67b823 +.insn 4, 0x3257b823 +.insn 4, 0x2b87b283 +.insn 4, 0x3387b303 +.insn 4, 0x2a67bc23 +.insn 4, 0x3257bc23 +.insn 2, 0x0521 +.insn 2, 0x177d +bnez a4, 215b +.insn 4, 0xf8050513 +.insn 2, 0x4385 +.insn 4, 0x40878e13 +.insn 2, 0x8ebe +216: +.insn 4, 0x2c0ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0023 +.insn 4, 0x0102d313 +.insn 4, 0x006e00a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0123 +.insn 4, 0x0002d313 +.insn 4, 0x006e01a3 +.insn 4, 0x300ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0223 +.insn 4, 0x0102d313 +.insn 4, 0x006e02a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0323 +.insn 4, 0x0002d313 +.insn 4, 0x006e03a3 +.insn 4, 0x240ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0423 +.insn 4, 0x0102d313 +.insn 4, 0x006e04a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0523 +.insn 4, 0x0002d313 +.insn 4, 0x006e05a3 +.insn 4, 0x280ee283 +.insn 4, 0x0182d313 +.insn 4, 0x006e0623 +.insn 4, 0x0102d313 +.insn 4, 0x006e06a3 +.insn 4, 0x0082d313 +.insn 4, 0x006e0723 +.insn 4, 0x0002d313 +.insn 4, 0x006e07a3 +.insn 2, 0x0e41 +.insn 2, 0x0e91 +.insn 2, 0x13fd +bnez t2, 216b +.insn 2, 0x852a +.insn 4, 0x3a87b403 +.insn 4, 0x3b07b483 +.insn 4, 0x3b87b903 +.insn 4, 0x3c07b983 +.insn 4, 0x3c87ba03 +.insn 4, 0x3d07ba83 +.insn 4, 0x3d87bb03 +.insn 4, 0x3e07bb83 +.insn 4, 0x3e87bc03 +.insn 4, 0x3f07bc83 +.insn 4, 0x3f87bd03 +.insn 4, 0x4007bd83 +.insn 2, 0x84ae +.insn 2, 0x8932 +.insn 2, 0x8986 +.insn 4, 0x4187b083 +.insn 4, 0xfd078a13 +.insn 2, 0x42c1 +bltu s3, t0, 217f +.insn 4, 0x438a6283 +.insn 4, 0x025a2023 +.insn 4, 0x43ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x440a6283 +.insn 4, 0x025a2423 +.insn 4, 0x444a6283 +.insn 4, 0x025a2623 +.insn 4, 0x00096283 +.insn 4, 0x438a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x43ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 4, 0x00896283 +.insn 4, 0x440a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592423 +.insn 4, 0x00c96283 +.insn 4, 0x444a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592623 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 218f +217: +.insn 4, 0x438a6283 +.insn 4, 0x025a2023 +.insn 4, 0x43ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x440a6283 +.insn 4, 0x025a2423 +.insn 4, 0x444a6283 +.insn 4, 0x025a2623 +.insn 4, 0x438a0393 +219: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 219b +218: +bnez s3, 213b +j 212f +211: +212: +21: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x028a6283 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x02ca6283 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 4, 0x08a00393 +220: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 220b +.insn 4, 0x45010113 +.insn 2, 0x8082 +.option pop", + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/sm4_ctr.rs b/crates/verified-garbage-asm-riscv64/src/sm4_ctr.rs index 05de503864d..1ca0b67c425 100644 --- a/crates/verified-garbage-asm-riscv64/src/sm4_ctr.rs +++ b/crates/verified-garbage-asm-riscv64/src/sm4_ctr.rs @@ -19461,3 +19461,87 @@ bnez t2, 222b .option pop", ) } + +/// SM4-CTR encryption or decryption (NIST SP 800-38A §6.5, draft-ribose-cfrg-sm4-10 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ctrFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the 3312 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ctr_final(schedule: *const [u8; 128], ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 2, 0x715d +.insn 2, 0x870a +.insn 4, 0x00173023 +.insn 2, 0xe704 +.insn 4, 0x01273823 +.insn 4, 0x01373c23 +.insn 4, 0x03473023 +.insn 4, 0x03573423 +.insn 4, 0x03673823 +.insn 4, 0x03773c23 +.insn 2, 0x84aa +.insn 2, 0x8aae +.insn 2, 0x8bba +.insn 4, 0x0046d293 +.insn 4, 0x00429313 +.insn 4, 0x00660933 +.insn 4, 0x406689b3 +.insn 2, 0x8696 +call {vg_sm4_ctr} +beqz s3, 20f +.insn 2, 0x4281 +.insn 4, 0x045bb023 +.insn 4, 0x045bb423 +.insn 2, 0x8526 +.insn 2, 0x85d6 +.insn 4, 0x040b8613 +.insn 2, 0x4685 +call {vg_sm4_ctr} +.insn 4, 0x040b8393 +22: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 22b +j 21f +20: +21: +.insn 4, 0x000bb083 +.insn 4, 0x008bb483 +.insn 4, 0x010bb903 +.insn 4, 0x018bb983 +.insn 4, 0x020bba03 +.insn 4, 0x028bba83 +.insn 4, 0x030bbb03 +.insn 4, 0x038bbb83 +.insn 2, 0x8f0a +.insn 2, 0x4f81 +.insn 4, 0x01ff3023 +.insn 4, 0x01ff3423 +.insn 4, 0x01ff3823 +.insn 4, 0x01ff3c23 +.insn 4, 0x03ff3023 +.insn 4, 0x03ff3423 +.insn 4, 0x03ff3823 +.insn 4, 0x03ff3c23 +.insn 4, 0x05ff3023 +.insn 4, 0x05ff3423 +.insn 2, 0x6161 +.insn 2, 0x8082 +.option pop", + vg_sm4_ctr = sym super::sm4_ctr::vg_sm4_ctr, + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/sm4_ofb.rs b/crates/verified-garbage-asm-riscv64/src/sm4_ofb.rs index d875f4f9c43..f3e3941f899 100644 --- a/crates/verified-garbage-asm-riscv64/src/sm4_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/sm4_ofb.rs @@ -9007,3 +9007,9054 @@ bnez t2, 214b .option pop", ) } + +/// SM4-OFB encryption or decryption (NIST SP 800-38A §6.4, GB/T 32907-2016 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 3232 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 4, 0x81010113 +.insn 4, 0xb5010113 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2423 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2623 +.insn 2, 0x8932 +.insn 4, 0x02aa3823 +.insn 4, 0x038a0793 +.insn 4, 0x7f878293 +.insn 4, 0x40828293 +.insn 4, 0x0082b023 +.insn 4, 0x0092b423 +.insn 4, 0x0122b823 +.insn 4, 0x0132bc23 +.insn 4, 0x0342b023 +.insn 4, 0x0352b423 +.insn 4, 0x0362b823 +.insn 4, 0x0372bc23 +.insn 4, 0x0582b023 +.insn 4, 0x0592b423 +.insn 4, 0x05a2b823 +.insn 4, 0x05b2bc23 +.insn 4, 0x00ff02b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0x00ff0337 +.insn 4, 0x0ff3031b +.insn 2, 0x929a +.insn 4, 0x1457b023 +.insn 4, 0xff0102b7 +.insn 4, 0xf012829b +.insn 2, 0x1282 +.insn 4, 0xff010337 +.insn 4, 0xf003031b +.insn 2, 0x929a +.insn 4, 0x1457b423 +.insn 2, 0x62c1 +.insn 2, 0x32fd +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1457b823 +.insn 4, 0x000002b7 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1457bc23 +.insn 2, 0x62c1 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 2, 0x2305 +.insn 2, 0x929a +.insn 4, 0x1657b023 +.insn 4, 0x000002b7 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 2, 0x7341 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1657b423 +.insn 2, 0x62c1 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 4, 0xf003031b +.insn 2, 0x929a +.insn 4, 0x1657b823 +.insn 4, 0x00ff02b7 +.insn 4, 0x0ff2829b +.insn 2, 0x1282 +.insn 4, 0x00ff0337 +.insn 4, 0x0ff3031b +.insn 2, 0x929a +.insn 4, 0x1657bc23 +.insn 4, 0x555552b7 +.insn 4, 0x5552829b +.insn 2, 0x1282 +.insn 4, 0x55555337 +.insn 4, 0x5553031b +.insn 2, 0x929a +.insn 4, 0x1857b023 +.insn 4, 0x333332b7 +.insn 4, 0x3332829b +.insn 2, 0x1282 +.insn 4, 0x33333337 +.insn 4, 0x3333031b +.insn 2, 0x929a +.insn 4, 0x1857b423 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x929a +.insn 4, 0x1857b823 +.insn 2, 0x85a6 +.insn 2, 0x864a +.insn 2, 0x874e +.insn 2, 0x832a +.insn 4, 0x30078393 +.insn 4, 0x08000e13 +.insn 4, 0x00736eb3 +.insn 4, 0x007efe93 +beqz t4, 20f +22: +.insn 4, 0x00034e83 +.insn 4, 0x01d38023 +.insn 2, 0x0305 +.insn 2, 0x0385 +.insn 2, 0x1e7d +bnez t3, 22b +j 21f +20: +.insn 4, 0x003e5e13 +23: +.insn 4, 0x00033e83 +.insn 4, 0x01d3b023 +.insn 2, 0x0321 +.insn 2, 0x03a1 +.insn 2, 0x1e7d +bnez t3, 23b +21: +.insn 4, 0x30078513 +.insn 4, 0x40078693 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x00053303 +.insn 4, 0x1587b803 +.insn 4, 0x01037333 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 4, 0x00053303 +.insn 4, 0x02035313 +.insn 4, 0x1507be03 +.insn 4, 0x03035893 +.insn 4, 0x01031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x00534333 +.insn 4, 0x01c37333 +.insn 4, 0x1407be83 +.insn 4, 0x01ceff33 +.insn 4, 0x010e5893 +.insn 4, 0x030e1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x007efeb3 +.insn 4, 0x01035893 +.insn 4, 0x03031293 +.insn 4, 0x0112c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x02835893 +.insn 2, 0x0362 +.insn 4, 0x01134333 +.insn 4, 0x01e37333 +.insn 4, 0x00534333 +.insn 4, 0x1607bf83 +.insn 4, 0x01f37433 +.insn 4, 0x00135493 +.insn 4, 0x01f4f4b3 +.insn 4, 0x00235913 +.insn 4, 0x01f97933 +.insn 4, 0x00335993 +.insn 4, 0x01f9f9b3 +.insn 4, 0x00435a13 +.insn 4, 0x01fa7a33 +.insn 4, 0x00535a93 +.insn 4, 0x01fafab3 +.insn 4, 0x00635b13 +.insn 4, 0x01fb7b33 +.insn 4, 0x00735b93 +.insn 4, 0x01fbfbb3 +.insn 4, 0x01041293 +.insn 4, 0x40828433 +.insn 4, 0x01049293 +.insn 4, 0x409284b3 +.insn 4, 0x01091293 +.insn 4, 0x41228933 +.insn 4, 0x01099293 +.insn 4, 0x413289b3 +.insn 4, 0x010a1293 +.insn 4, 0x41428a33 +.insn 4, 0x010a9293 +.insn 4, 0x41528ab3 +.insn 4, 0x010b1293 +.insn 4, 0x41628b33 +.insn 4, 0x010b9293 +.insn 4, 0x41728bb3 +.insn 2, 0xe280 +.insn 2, 0xe684 +.insn 4, 0x0126b823 +.insn 4, 0x0136bc23 +.insn 4, 0x0346b023 +.insn 4, 0x0356b423 +.insn 4, 0x0366b823 +.insn 4, 0x0376bc23 +.insn 4, 0x04068693 +.insn 2, 0x0521 +.insn 4, 0x7f878513 +.insn 4, 0x40850513 +.insn 4, 0x7f878293 +.insn 4, 0x40828293 +.insn 4, 0x0002b403 +.insn 4, 0x0082b483 +.insn 4, 0x0102b903 +.insn 4, 0x0182b983 +.insn 4, 0x0202ba03 +.insn 4, 0x0282ba83 +.insn 4, 0x0302bb03 +.insn 4, 0x0382bb83 +.insn 4, 0x0402bc03 +.insn 4, 0x0482bc83 +.insn 4, 0x0502bd03 +.insn 4, 0x0582bd83 +.insn 2, 0x84ae +.insn 2, 0x8932 +.insn 2, 0x89ba +.insn 4, 0xfc878a13 +.insn 4, 0x030a3503 +.insn 4, 0x00397293 +beqz t0, 24f +beqz s3, 26f +28: +.insn 4, 0x020a6283 +.insn 4, 0x325a2c23 +.insn 4, 0x024a6283 +.insn 4, 0x325a2e23 +.insn 4, 0x028a6283 +.insn 4, 0x345a2023 +.insn 4, 0x02ca6283 +.insn 4, 0x345a2223 +.insn 4, 0x038a0793 +.insn 4, 0x7f878293 +.insn 4, 0x40828293 +.insn 4, 0x0082b023 +.insn 4, 0x0092b423 +.insn 4, 0x0122b823 +.insn 4, 0x0132bc23 +.insn 4, 0x0342b023 +.insn 4, 0x0352b423 +.insn 4, 0x0362b823 +.insn 4, 0x0372bc23 +.insn 4, 0x0582b023 +.insn 4, 0x0592b423 +.insn 4, 0x05a2b823 +.insn 4, 0x05b2bc23 +.insn 2, 0x85a6 +.insn 2, 0x864a +.insn 2, 0x874e +.insn 4, 0x7f878513 +.insn 4, 0x40850513 +.insn 4, 0x1687be03 +.insn 4, 0x1707be83 +.insn 4, 0x1787bf03 +.insn 4, 0x1807bf83 +.insn 4, 0x1887b803 +.insn 4, 0x1907b883 +.insn 4, 0x3007b403 +.insn 4, 0x3807ba03 +.insn 4, 0x3107b483 +.insn 4, 0x3907ba83 +.insn 4, 0x3207b903 +.insn 4, 0x3a07bb03 +.insn 4, 0x3307b983 +.insn 4, 0x3b07bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b023 +.insn 4, 0x3947b023 +.insn 4, 0x3097b823 +.insn 4, 0x3957b823 +.insn 4, 0x3327b023 +.insn 4, 0x3b67b023 +.insn 4, 0x3337b823 +.insn 4, 0x3b77b823 +.insn 4, 0x3407b403 +.insn 4, 0x3c07ba03 +.insn 4, 0x3507b483 +.insn 4, 0x3d07ba83 +.insn 4, 0x3607b903 +.insn 4, 0x3e07bb03 +.insn 4, 0x3707b983 +.insn 4, 0x3f07bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3487b023 +.insn 4, 0x3d47b023 +.insn 4, 0x3497b823 +.insn 4, 0x3d57b823 +.insn 4, 0x3727b023 +.insn 4, 0x3f67b023 +.insn 4, 0x3737b823 +.insn 4, 0x3f77b823 +.insn 4, 0x3087b403 +.insn 4, 0x3887ba03 +.insn 4, 0x3187b483 +.insn 4, 0x3987ba83 +.insn 4, 0x3287b903 +.insn 4, 0x3a87bb03 +.insn 4, 0x3387b983 +.insn 4, 0x3b87bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b423 +.insn 4, 0x3947b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3957bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3b67b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3b77bc23 +.insn 4, 0x3487b403 +.insn 4, 0x3c87ba03 +.insn 4, 0x3587b483 +.insn 4, 0x3d87ba83 +.insn 4, 0x3687b903 +.insn 4, 0x3e87bb03 +.insn 4, 0x3787b983 +.insn 4, 0x3f87bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3487b423 +.insn 4, 0x3d47b423 +.insn 4, 0x3497bc23 +.insn 4, 0x3d57bc23 +.insn 4, 0x3727b423 +.insn 4, 0x3f67b423 +.insn 4, 0x3737bc23 +.insn 4, 0x3f77bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3107b483 +.insn 4, 0x3207b903 +.insn 4, 0x3307b983 +.insn 4, 0x3407ba03 +.insn 4, 0x3507ba83 +.insn 4, 0x3607bb03 +.insn 4, 0x3707bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x3807b403 +.insn 4, 0x3907b483 +.insn 4, 0x3a07b903 +.insn 4, 0x3b07b983 +.insn 4, 0x3c07ba03 +.insn 4, 0x3d07ba83 +.insn 4, 0x3e07bb03 +.insn 4, 0x3f07bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x3087b403 +.insn 4, 0x3187b483 +.insn 4, 0x3287b903 +.insn 4, 0x3387b983 +.insn 4, 0x3487ba03 +.insn 4, 0x3587ba83 +.insn 4, 0x3687bb03 +.insn 4, 0x3787bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x3887b403 +.insn 4, 0x3987b483 +.insn 4, 0x3a87b903 +.insn 4, 0x3b87b983 +.insn 4, 0x3c87ba03 +.insn 4, 0x3d87ba83 +.insn 4, 0x3e87bb03 +.insn 4, 0x3f87bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2c87b023 +.insn 4, 0x2c97b423 +.insn 4, 0x2d27b823 +.insn 4, 0x2d37bc23 +.insn 4, 0x2f47b023 +.insn 4, 0x2f57b423 +.insn 4, 0x2f67b823 +.insn 4, 0x2f77bc23 +.insn 4, 0x40078693 +29: +.insn 4, 0x2407b403 +.insn 4, 0x2807b283 +.insn 4, 0x00544433 +.insn 4, 0x2c07b283 +.insn 4, 0x00544433 +.insn 4, 0x0006b283 +.insn 4, 0x00544433 +.insn 4, 0x2487b483 +.insn 4, 0x2887b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2c87b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0086b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2507b903 +.insn 4, 0x2907b283 +.insn 4, 0x00594933 +.insn 4, 0x2d07b283 +.insn 4, 0x00594933 +.insn 4, 0x0106b283 +.insn 4, 0x00594933 +.insn 4, 0x2587b983 +.insn 4, 0x2987b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2d87b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0186b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2607ba03 +.insn 4, 0x2a07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2e07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0206b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2687ba83 +.insn 4, 0x2a87b283 +.insn 4, 0x005acab3 +.insn 4, 0x2e87b283 +.insn 4, 0x005acab3 +.insn 4, 0x0286b283 +.insn 4, 0x005acab3 +.insn 4, 0x2707bb03 +.insn 4, 0x2b07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2f07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0306b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2787bb83 +.insn 4, 0x2b87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2f87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0386b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2007b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2087b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2107b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2187b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2207b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2287b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2307b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2387b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257bc23 +.insn 4, 0x2807b403 +.insn 4, 0x2c07b283 +.insn 4, 0x00544433 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x0406b283 +.insn 4, 0x00544433 +.insn 4, 0x2887b483 +.insn 4, 0x2c87b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0486b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2907b903 +.insn 4, 0x2d07b283 +.insn 4, 0x00594933 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x0506b283 +.insn 4, 0x00594933 +.insn 4, 0x2987b983 +.insn 4, 0x2d87b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0586b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2a07ba03 +.insn 4, 0x2e07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0606b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2a87ba83 +.insn 4, 0x2e87b283 +.insn 4, 0x005acab3 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x0686b283 +.insn 4, 0x005acab3 +.insn 4, 0x2b07bb03 +.insn 4, 0x2f07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0706b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2b87bb83 +.insn 4, 0x2f87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0786b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2407b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2487b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2507b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2587b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2607b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2687b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2707b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2787b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657bc23 +.insn 4, 0x2c07b403 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x0806b283 +.insn 4, 0x00544433 +.insn 4, 0x2c87b483 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0886b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2d07b903 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x0906b283 +.insn 4, 0x00594933 +.insn 4, 0x2d87b983 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0986b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2e07ba03 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0a06b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2e87ba83 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x0a86b283 +.insn 4, 0x005acab3 +.insn 4, 0x2f07bb03 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0b06b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2f87bb83 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0b86b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2807b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2887b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2907b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2987b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2b07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2b87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x2807b283 +.insn 4, 0x00544433 +.insn 4, 0x0c06b283 +.insn 4, 0x00544433 +.insn 4, 0x2087b483 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2887b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0c86b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2107b903 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x2907b283 +.insn 4, 0x00594933 +.insn 4, 0x0d06b283 +.insn 4, 0x00594933 +.insn 4, 0x2187b983 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2987b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0d86b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2207ba03 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2a07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0e06b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2287ba83 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x2a87b283 +.insn 4, 0x005acab3 +.insn 4, 0x0e86b283 +.insn 4, 0x005acab3 +.insn 4, 0x2307bb03 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2b07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0f06b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2387bb83 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2b87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0f86b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2d07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2d87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2f07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2f87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57bc23 +.insn 4, 0x10068693 +.insn 4, 0x40a682b3 +bnez t0, 29b +.insn 4, 0x1687be03 +.insn 4, 0x1707be83 +.insn 4, 0x1787bf03 +.insn 4, 0x1807bf83 +.insn 4, 0x1887b803 +.insn 4, 0x1907b883 +.insn 4, 0x2c07b403 +.insn 4, 0x2c87b483 +.insn 4, 0x2d07b903 +.insn 4, 0x2d87b983 +.insn 4, 0x2e07ba03 +.insn 4, 0x2e87ba83 +.insn 4, 0x2f07bb03 +.insn 4, 0x2f87bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b023 +.insn 4, 0x3097b823 +.insn 4, 0x3327b023 +.insn 4, 0x3337b823 +.insn 4, 0x3547b023 +.insn 4, 0x3557b823 +.insn 4, 0x3767b023 +.insn 4, 0x3777b823 +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3887b023 +.insn 4, 0x3897b823 +.insn 4, 0x3b27b023 +.insn 4, 0x3b37b823 +.insn 4, 0x3d47b023 +.insn 4, 0x3d57b823 +.insn 4, 0x3f67b023 +.insn 4, 0x3f77b823 +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3547b423 +.insn 4, 0x3557bc23 +.insn 4, 0x3767b423 +.insn 4, 0x3777bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2087b483 +.insn 4, 0x2107b903 +.insn 4, 0x2187b983 +.insn 4, 0x2207ba03 +.insn 4, 0x2287ba83 +.insn 4, 0x2307bb03 +.insn 4, 0x2387bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3887b423 +.insn 4, 0x3897bc23 +.insn 4, 0x3b27b423 +.insn 4, 0x3b37bc23 +.insn 4, 0x3d47b423 +.insn 4, 0x3d57bc23 +.insn 4, 0x3f67b423 +.insn 4, 0x3f77bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3807ba03 +.insn 4, 0x3107b483 +.insn 4, 0x3907ba83 +.insn 4, 0x3207b903 +.insn 4, 0x3a07bb03 +.insn 4, 0x3307b983 +.insn 4, 0x3b07bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b023 +.insn 4, 0x3947b023 +.insn 4, 0x3097b823 +.insn 4, 0x3957b823 +.insn 4, 0x3327b023 +.insn 4, 0x3b67b023 +.insn 4, 0x3337b823 +.insn 4, 0x3b77b823 +.insn 4, 0x3407b403 +.insn 4, 0x3c07ba03 +.insn 4, 0x3507b483 +.insn 4, 0x3d07ba83 +.insn 4, 0x3607b903 +.insn 4, 0x3e07bb03 +.insn 4, 0x3707b983 +.insn 4, 0x3f07bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3487b023 +.insn 4, 0x3d47b023 +.insn 4, 0x3497b823 +.insn 4, 0x3d57b823 +.insn 4, 0x3727b023 +.insn 4, 0x3f67b023 +.insn 4, 0x3737b823 +.insn 4, 0x3f77b823 +.insn 4, 0x3087b403 +.insn 4, 0x3887ba03 +.insn 4, 0x3187b483 +.insn 4, 0x3987ba83 +.insn 4, 0x3287b903 +.insn 4, 0x3a87bb03 +.insn 4, 0x3387b983 +.insn 4, 0x3b87bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b423 +.insn 4, 0x3947b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3957bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3b67b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3b77bc23 +.insn 4, 0x3487b403 +.insn 4, 0x3c87ba03 +.insn 4, 0x3587b483 +.insn 4, 0x3d87ba83 +.insn 4, 0x3687b903 +.insn 4, 0x3e87bb03 +.insn 4, 0x3787b983 +.insn 4, 0x3f87bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3487b423 +.insn 4, 0x3d47b423 +.insn 4, 0x3497bc23 +.insn 4, 0x3d57bc23 +.insn 4, 0x3727b423 +.insn 4, 0x3f67b423 +.insn 4, 0x3737bc23 +.insn 4, 0x3f77bc23 +.insn 4, 0x7f878293 +.insn 4, 0x40828293 +.insn 4, 0x0002b403 +.insn 4, 0x0082b483 +.insn 4, 0x0102b903 +.insn 4, 0x0182b983 +.insn 4, 0x0202ba03 +.insn 4, 0x0282ba83 +.insn 4, 0x0302bb03 +.insn 4, 0x0382bb83 +.insn 4, 0x0402bc03 +.insn 4, 0x0482bc83 +.insn 4, 0x0502bd03 +.insn 4, 0x0582bd83 +.insn 2, 0x84ae +.insn 2, 0x8932 +.insn 2, 0x89ba +.insn 4, 0xfc878a13 +.insn 4, 0x030a3503 +.insn 2, 0x42c1 +bltu s3, t0, 210f +.insn 4, 0x338a6283 +.insn 4, 0x025a2023 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x340a6283 +.insn 4, 0x025a2423 +.insn 4, 0x344a6283 +.insn 4, 0x025a2623 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x338a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x33ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x00894283 +.insn 4, 0x00994383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00a94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00b94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x340a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x00c94283 +.insn 4, 0x00d94383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00e94383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00f94383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x344a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 211f +210: +.insn 4, 0x338a6283 +.insn 4, 0x025a2023 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x340a6283 +.insn 4, 0x025a2423 +.insn 4, 0x344a6283 +.insn 4, 0x025a2623 +.insn 4, 0x338a0393 +212: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 212b +211: +bnez s3, 28b +j 27f +26: +27: +j 25f +24: +beqz s3, 213f +215: +.insn 4, 0x020a6283 +.insn 4, 0x325a2c23 +.insn 4, 0x024a6283 +.insn 4, 0x325a2e23 +.insn 4, 0x028a6283 +.insn 4, 0x345a2023 +.insn 4, 0x02ca6283 +.insn 4, 0x345a2223 +.insn 4, 0x038a0793 +.insn 4, 0x7f878293 +.insn 4, 0x40828293 +.insn 4, 0x0082b023 +.insn 4, 0x0092b423 +.insn 4, 0x0122b823 +.insn 4, 0x0132bc23 +.insn 4, 0x0342b023 +.insn 4, 0x0352b423 +.insn 4, 0x0362b823 +.insn 4, 0x0372bc23 +.insn 4, 0x0582b023 +.insn 4, 0x0592b423 +.insn 4, 0x05a2b823 +.insn 4, 0x05b2bc23 +.insn 2, 0x85a6 +.insn 2, 0x864a +.insn 2, 0x874e +.insn 4, 0x7f878513 +.insn 4, 0x40850513 +.insn 4, 0x1687be03 +.insn 4, 0x1707be83 +.insn 4, 0x1787bf03 +.insn 4, 0x1807bf83 +.insn 4, 0x1887b803 +.insn 4, 0x1907b883 +.insn 4, 0x3007b403 +.insn 4, 0x3807ba03 +.insn 4, 0x3107b483 +.insn 4, 0x3907ba83 +.insn 4, 0x3207b903 +.insn 4, 0x3a07bb03 +.insn 4, 0x3307b983 +.insn 4, 0x3b07bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b023 +.insn 4, 0x3947b023 +.insn 4, 0x3097b823 +.insn 4, 0x3957b823 +.insn 4, 0x3327b023 +.insn 4, 0x3b67b023 +.insn 4, 0x3337b823 +.insn 4, 0x3b77b823 +.insn 4, 0x3407b403 +.insn 4, 0x3c07ba03 +.insn 4, 0x3507b483 +.insn 4, 0x3d07ba83 +.insn 4, 0x3607b903 +.insn 4, 0x3e07bb03 +.insn 4, 0x3707b983 +.insn 4, 0x3f07bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3487b023 +.insn 4, 0x3d47b023 +.insn 4, 0x3497b823 +.insn 4, 0x3d57b823 +.insn 4, 0x3727b023 +.insn 4, 0x3f67b023 +.insn 4, 0x3737b823 +.insn 4, 0x3f77b823 +.insn 4, 0x3087b403 +.insn 4, 0x3887ba03 +.insn 4, 0x3187b483 +.insn 4, 0x3987ba83 +.insn 4, 0x3287b903 +.insn 4, 0x3a87bb03 +.insn 4, 0x3387b983 +.insn 4, 0x3b87bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b423 +.insn 4, 0x3947b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3957bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3b67b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3b77bc23 +.insn 4, 0x3487b403 +.insn 4, 0x3c87ba03 +.insn 4, 0x3587b483 +.insn 4, 0x3d87ba83 +.insn 4, 0x3687b903 +.insn 4, 0x3e87bb03 +.insn 4, 0x3787b983 +.insn 4, 0x3f87bb83 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x3487b423 +.insn 4, 0x3d47b423 +.insn 4, 0x3497bc23 +.insn 4, 0x3d57bc23 +.insn 4, 0x3727b423 +.insn 4, 0x3f67b423 +.insn 4, 0x3737bc23 +.insn 4, 0x3f77bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3107b483 +.insn 4, 0x3207b903 +.insn 4, 0x3307b983 +.insn 4, 0x3407ba03 +.insn 4, 0x3507ba83 +.insn 4, 0x3607bb03 +.insn 4, 0x3707bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2087b023 +.insn 4, 0x2097b423 +.insn 4, 0x2127b823 +.insn 4, 0x2137bc23 +.insn 4, 0x2347b023 +.insn 4, 0x2357b423 +.insn 4, 0x2367b823 +.insn 4, 0x2377bc23 +.insn 4, 0x3807b403 +.insn 4, 0x3907b483 +.insn 4, 0x3a07b903 +.insn 4, 0x3b07b983 +.insn 4, 0x3c07ba03 +.insn 4, 0x3d07ba83 +.insn 4, 0x3e07bb03 +.insn 4, 0x3f07bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2487b023 +.insn 4, 0x2497b423 +.insn 4, 0x2527b823 +.insn 4, 0x2537bc23 +.insn 4, 0x2747b023 +.insn 4, 0x2757b423 +.insn 4, 0x2767b823 +.insn 4, 0x2777bc23 +.insn 4, 0x3087b403 +.insn 4, 0x3187b483 +.insn 4, 0x3287b903 +.insn 4, 0x3387b983 +.insn 4, 0x3487ba03 +.insn 4, 0x3587ba83 +.insn 4, 0x3687bb03 +.insn 4, 0x3787bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2887b023 +.insn 4, 0x2897b423 +.insn 4, 0x2927b823 +.insn 4, 0x2937bc23 +.insn 4, 0x2b47b023 +.insn 4, 0x2b57b423 +.insn 4, 0x2b67b823 +.insn 4, 0x2b77bc23 +.insn 4, 0x3887b403 +.insn 4, 0x3987b483 +.insn 4, 0x3a87b903 +.insn 4, 0x3b87b983 +.insn 4, 0x3c87ba03 +.insn 4, 0x3d87ba83 +.insn 4, 0x3e87bb03 +.insn 4, 0x3f87bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x2c87b023 +.insn 4, 0x2c97b423 +.insn 4, 0x2d27b823 +.insn 4, 0x2d37bc23 +.insn 4, 0x2f47b023 +.insn 4, 0x2f57b423 +.insn 4, 0x2f67b823 +.insn 4, 0x2f77bc23 +.insn 4, 0x40078693 +216: +.insn 4, 0x2407b403 +.insn 4, 0x2807b283 +.insn 4, 0x00544433 +.insn 4, 0x2c07b283 +.insn 4, 0x00544433 +.insn 4, 0x0006b283 +.insn 4, 0x00544433 +.insn 4, 0x2487b483 +.insn 4, 0x2887b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2c87b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0086b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2507b903 +.insn 4, 0x2907b283 +.insn 4, 0x00594933 +.insn 4, 0x2d07b283 +.insn 4, 0x00594933 +.insn 4, 0x0106b283 +.insn 4, 0x00594933 +.insn 4, 0x2587b983 +.insn 4, 0x2987b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2d87b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0186b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2607ba03 +.insn 4, 0x2a07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2e07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0206b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2687ba83 +.insn 4, 0x2a87b283 +.insn 4, 0x005acab3 +.insn 4, 0x2e87b283 +.insn 4, 0x005acab3 +.insn 4, 0x0286b283 +.insn 4, 0x005acab3 +.insn 4, 0x2707bb03 +.insn 4, 0x2b07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2f07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0306b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2787bb83 +.insn 4, 0x2b87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2f87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0386b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2007b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2087b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2107b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2187b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2057bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2207b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2287b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2307b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2387b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2257bc23 +.insn 4, 0x2807b403 +.insn 4, 0x2c07b283 +.insn 4, 0x00544433 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x0406b283 +.insn 4, 0x00544433 +.insn 4, 0x2887b483 +.insn 4, 0x2c87b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0486b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2907b903 +.insn 4, 0x2d07b283 +.insn 4, 0x00594933 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x0506b283 +.insn 4, 0x00594933 +.insn 4, 0x2987b983 +.insn 4, 0x2d87b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0586b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2a07ba03 +.insn 4, 0x2e07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0606b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2a87ba83 +.insn 4, 0x2e87b283 +.insn 4, 0x005acab3 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x0686b283 +.insn 4, 0x005acab3 +.insn 4, 0x2b07bb03 +.insn 4, 0x2f07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0706b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2b87bb83 +.insn 4, 0x2f87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0786b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2407b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2487b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2507b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2587b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2457bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2607b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2687b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2707b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2787b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2657bc23 +.insn 4, 0x2c07b403 +.insn 4, 0x2007b283 +.insn 4, 0x00544433 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x0806b283 +.insn 4, 0x00544433 +.insn 4, 0x2c87b483 +.insn 4, 0x2087b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0886b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2d07b903 +.insn 4, 0x2107b283 +.insn 4, 0x00594933 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x0906b283 +.insn 4, 0x00594933 +.insn 4, 0x2d87b983 +.insn 4, 0x2187b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0986b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2e07ba03 +.insn 4, 0x2207b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0a06b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2e87ba83 +.insn 4, 0x2287b283 +.insn 4, 0x005acab3 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x0a86b283 +.insn 4, 0x005acab3 +.insn 4, 0x2f07bb03 +.insn 4, 0x2307b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0b06b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2f87bb83 +.insn 4, 0x2387b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0b86b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2807b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2887b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2907b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2987b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2857bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2b07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2b87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2a57bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2407b283 +.insn 4, 0x00544433 +.insn 4, 0x2807b283 +.insn 4, 0x00544433 +.insn 4, 0x0c06b283 +.insn 4, 0x00544433 +.insn 4, 0x2087b483 +.insn 4, 0x2487b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2887b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x0c86b283 +.insn 4, 0x0054c4b3 +.insn 4, 0x2107b903 +.insn 4, 0x2507b283 +.insn 4, 0x00594933 +.insn 4, 0x2907b283 +.insn 4, 0x00594933 +.insn 4, 0x0d06b283 +.insn 4, 0x00594933 +.insn 4, 0x2187b983 +.insn 4, 0x2587b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2987b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x0d86b283 +.insn 4, 0x0059c9b3 +.insn 4, 0x2207ba03 +.insn 4, 0x2607b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2a07b283 +.insn 4, 0x005a4a33 +.insn 4, 0x0e06b283 +.insn 4, 0x005a4a33 +.insn 4, 0x2287ba83 +.insn 4, 0x2687b283 +.insn 4, 0x005acab3 +.insn 4, 0x2a87b283 +.insn 4, 0x005acab3 +.insn 4, 0x0e86b283 +.insn 4, 0x005acab3 +.insn 4, 0x2307bb03 +.insn 4, 0x2707b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2b07b283 +.insn 4, 0x005b4b33 +.insn 4, 0x0f06b283 +.insn 4, 0x005b4b33 +.insn 4, 0x2387bb83 +.insn 4, 0x2787b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x2b87b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x0f86b283 +.insn 4, 0x005bcbb3 +.insn 4, 0x012a42b3 +.insn 4, 0x0089c333 +.insn 4, 0x0064c3b3 +.insn 4, 0x005bce33 +.insn 4, 0x007aceb3 +.insn 4, 0x012b4f33 +.insn 4, 0x014bca33 +.insn 4, 0x01cacfb3 +.insn 4, 0x01fb4833 +.insn 4, 0x013bc8b3 +.insn 4, 0x014b4c33 +.insn 4, 0x005accb3 +.insn 4, 0x01f4cfb3 +.insn 4, 0xffffcf93 +.insn 4, 0x01c34d33 +.insn 4, 0x01844db3 +.insn 4, 0x018ecc33 +.insn 4, 0x0187b023 +.insn 4, 0x01e4cc33 +.insn 4, 0x01ab4b33 +.insn 4, 0x01c44433 +.insn 4, 0xfff44413 +.insn 4, 0x0114cd33 +.insn 4, 0x0199c9b3 +.insn 4, 0xfff9c993 +.insn 4, 0x0143ca33 +.insn 4, 0x01c7b423 +.insn 4, 0x01d2ce33 +.insn 4, 0x01c7b823 +.insn 4, 0x01eece33 +.insn 4, 0x012bc933 +.insn 4, 0xfff94913 +.insn 4, 0x01b4cdb3 +.insn 4, 0xfffdcd93 +.insn 4, 0x01934333 +.insn 4, 0x011acab3 +.insn 4, 0xfffaca93 +.insn 4, 0x0104c8b3 +.insn 4, 0x0072c2b3 +.insn 4, 0xfff2c293 +.insn 4, 0x007bcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x01f8f3b3 +.insn 4, 0x013efcb3 +.insn 4, 0x007cccb3 +.insn 4, 0x01d7bc23 +.insn 4, 0x01ab7eb3 +.insn 4, 0x007eceb3 +.insn 4, 0x0064f3b3 +.insn 2, 0xf384 +.insn 4, 0x015f74b3 +.insn 4, 0x0074c4b3 +.insn 4, 0x03e7b423 +.insn 4, 0x008c7f33 +.insn 4, 0x007f4f33 +.insn 4, 0x005a73b3 +.insn 4, 0x0347b823 +.insn 4, 0x01787a33 +.insn 4, 0x007a4a33 +.insn 4, 0x0307bc23 +.insn 4, 0x0087b803 +.insn 4, 0x0587b023 +.insn 4, 0x010e7c33 +.insn 4, 0x007c4c33 +.insn 4, 0x014cccb3 +.insn 4, 0x018eceb3 +.insn 4, 0x0144c4b3 +.insn 4, 0x018f4f33 +.insn 4, 0x012cccb3 +.insn 4, 0x0007b903 +.insn 4, 0x012eceb3 +.insn 4, 0x0107b903 +.insn 4, 0x0124c4b3 +.insn 4, 0x01bf4f33 +.insn 4, 0x01dccdb3 +.insn 4, 0x009cfcb3 +.insn 4, 0x019f4933 +.insn 4, 0x012dfc33 +.insn 4, 0x01dc4c33 +.insn 4, 0x01e4ca33 +.insn 4, 0x019eceb3 +.insn 4, 0x014efeb3 +.insn 4, 0x01eeceb3 +.insn 4, 0x01d4c4b3 +.insn 4, 0x01d94a33 +.insn 4, 0x014f7f33 +.insn 4, 0x009f44b3 +.insn 4, 0x01e94933 +.insn 4, 0x012c7933 +.insn 4, 0x012dcdb3 +.insn 4, 0x009dc933 +.insn 4, 0x01dc4f33 +.insn 4, 0x01bc4a33 +.insn 4, 0x009eccb3 +.insn 4, 0x012f43b3 +.insn 4, 0x01fcffb3 +.insn 4, 0x0134f9b3 +.insn 4, 0x01aefd33 +.insn 4, 0x006a7333 +.insn 4, 0x015dfab3 +.insn 4, 0x008c7433 +.insn 4, 0x005f72b3 +.insn 4, 0x0173fbb3 +.insn 4, 0x01097833 +.insn 4, 0x011cfcb3 +.insn 4, 0x0187b883 +.insn 4, 0x0114f4b3 +.insn 4, 0x016efeb3 +.insn 4, 0x0207bb03 +.insn 4, 0x016a7a33 +.insn 4, 0x0287bb03 +.insn 4, 0x016dfdb3 +.insn 4, 0x0407bb03 +.insn 4, 0x016c7c33 +.insn 4, 0x0307bb03 +.insn 4, 0x016f7f33 +.insn 4, 0x0387bb03 +.insn 4, 0x0163f3b3 +.insn 4, 0x01c97933 +.insn 4, 0x01ecccb3 +.insn 4, 0x0092c2b3 +.insn 4, 0x008fc433 +.insn 4, 0x005dce33 +.insn 4, 0x01cc4c33 +.insn 4, 0x0109c833 +.insn 4, 0x018bce33 +.insn 4, 0x01994933 +.insn 4, 0x008acb33 +.insn 4, 0x012e48b3 +.insn 4, 0x0357bc23 +.insn 4, 0x016ecab3 +.insn 4, 0x0317b823 +.insn 4, 0x0103c8b3 +.insn 4, 0x011cccb3 +.insn 4, 0x00834433 +.insn 4, 0x008cc433 +.insn 4, 0x012eceb3 +.insn 4, 0x007dcdb3 +.insn 4, 0x01ea4a33 +.insn 4, 0x0162c2b3 +.insn 4, 0x01584833 +.insn 4, 0x010c4c33 +.insn 4, 0xfffc4c13 +.insn 2, 0x8ca1 +.insn 4, 0x01cd4d33 +.insn 4, 0x009bc433 +.insn 4, 0xfff44413 +.insn 4, 0x014dcbb3 +.insn 4, 0xfffbcb93 +.insn 4, 0x013fcfb3 +.insn 4, 0x0307b983 +.insn 4, 0x01334333 +.insn 4, 0x01f9c9b3 +.insn 4, 0x01aacb33 +.insn 4, 0xfffb4b13 +.insn 4, 0x0387bd03 +.insn 4, 0x006d4933 +.insn 4, 0x005cca33 +.insn 4, 0xfffa4a13 +.insn 2, 0x8ace +.insn 2, 0x89f6 +.insn 2, 0x84e2 +.insn 4, 0x010b5893 +.insn 4, 0x030b1393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0082c2b3 +.insn 4, 0x03045893 +.insn 4, 0x01041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57b023 +.insn 4, 0x010bd893 +.insn 4, 0x030b9393 +.insn 4, 0x0113c3b3 +.insn 4, 0x0103d893 +.insn 4, 0x03039313 +.insn 4, 0x01134333 +.insn 4, 0x0063c2b3 +.insn 4, 0x0203d893 +.insn 4, 0x02039313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0092c2b3 +.insn 4, 0x0304d893 +.insn 4, 0x01049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57b423 +.insn 4, 0x01045893 +.insn 4, 0x03041313 +.insn 4, 0x01134333 +.insn 4, 0x006442b3 +.insn 4, 0x02045893 +.insn 4, 0x02041313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0122c2b3 +.insn 4, 0x03095893 +.insn 4, 0x01091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2d07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57b823 +.insn 4, 0x0104d893 +.insn 4, 0x03049313 +.insn 4, 0x01134333 +.insn 4, 0x0064c2b3 +.insn 4, 0x0204d893 +.insn 4, 0x02049313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0132c2b3 +.insn 4, 0x0309d893 +.insn 4, 0x01099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2d87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2c57bc23 +.insn 4, 0x01095893 +.insn 4, 0x03091313 +.insn 4, 0x01134333 +.insn 4, 0x006942b3 +.insn 4, 0x02095893 +.insn 4, 0x02091313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0142c2b3 +.insn 4, 0x030a5893 +.insn 4, 0x010a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57b023 +.insn 4, 0x0109d893 +.insn 4, 0x03099313 +.insn 4, 0x01134333 +.insn 4, 0x0069c2b3 +.insn 4, 0x0209d893 +.insn 4, 0x02099313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0152c2b3 +.insn 4, 0x030ad893 +.insn 4, 0x010a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57b423 +.insn 4, 0x010a5893 +.insn 4, 0x030a1313 +.insn 4, 0x01134333 +.insn 4, 0x006a42b3 +.insn 4, 0x020a5893 +.insn 4, 0x020a1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0162c2b3 +.insn 4, 0x030b5893 +.insn 4, 0x010b1313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2f07b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57b823 +.insn 4, 0x010ad893 +.insn 4, 0x030a9313 +.insn 4, 0x01134333 +.insn 4, 0x006ac2b3 +.insn 4, 0x020ad893 +.insn 4, 0x020a9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0172c2b3 +.insn 4, 0x030bd893 +.insn 4, 0x010b9313 +.insn 4, 0x01134333 +.insn 4, 0x0062c2b3 +.insn 4, 0x2f87b303 +.insn 4, 0x0062c2b3 +.insn 4, 0x2e57bc23 +.insn 4, 0x10068693 +.insn 4, 0x40a682b3 +bnez t0, 216b +.insn 4, 0x1687be03 +.insn 4, 0x1707be83 +.insn 4, 0x1787bf03 +.insn 4, 0x1807bf83 +.insn 4, 0x1887b803 +.insn 4, 0x1907b883 +.insn 4, 0x2c07b403 +.insn 4, 0x2c87b483 +.insn 4, 0x2d07b903 +.insn 4, 0x2d87b983 +.insn 4, 0x2e07ba03 +.insn 4, 0x2e87ba83 +.insn 4, 0x2f07bb03 +.insn 4, 0x2f87bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b023 +.insn 4, 0x3097b823 +.insn 4, 0x3327b023 +.insn 4, 0x3337b823 +.insn 4, 0x3547b023 +.insn 4, 0x3557b823 +.insn 4, 0x3767b023 +.insn 4, 0x3777b823 +.insn 4, 0x2807b403 +.insn 4, 0x2887b483 +.insn 4, 0x2907b903 +.insn 4, 0x2987b983 +.insn 4, 0x2a07ba03 +.insn 4, 0x2a87ba83 +.insn 4, 0x2b07bb03 +.insn 4, 0x2b87bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3887b023 +.insn 4, 0x3897b823 +.insn 4, 0x3b27b023 +.insn 4, 0x3b37b823 +.insn 4, 0x3d47b023 +.insn 4, 0x3d57b823 +.insn 4, 0x3f67b023 +.insn 4, 0x3f77b823 +.insn 4, 0x2407b403 +.insn 4, 0x2487b483 +.insn 4, 0x2507b903 +.insn 4, 0x2587b983 +.insn 4, 0x2607ba03 +.insn 4, 0x2687ba83 +.insn 4, 0x2707bb03 +.insn 4, 0x2787bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3087b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3547b423 +.insn 4, 0x3557bc23 +.insn 4, 0x3767b423 +.insn 4, 0x3777bc23 +.insn 4, 0x2007b403 +.insn 4, 0x2087b483 +.insn 4, 0x2107b903 +.insn 4, 0x2187b983 +.insn 4, 0x2207ba03 +.insn 4, 0x2287ba83 +.insn 4, 0x2307bb03 +.insn 4, 0x2387bb83 +.insn 4, 0x00145293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x0286 +.insn 4, 0x00544433 +.insn 4, 0x00195293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x0286 +.insn 4, 0x00594933 +.insn 4, 0x001a5293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0286 +.insn 4, 0x005a4a33 +.insn 4, 0x001b5293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0286 +.insn 4, 0x005b4b33 +.insn 4, 0x00245293 +.insn 4, 0x0122c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x00594933 +.insn 2, 0x028a +.insn 4, 0x00544433 +.insn 4, 0x0024d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x028a +.insn 4, 0x0054c4b3 +.insn 4, 0x002a5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x028a +.insn 4, 0x005a4a33 +.insn 4, 0x002ad293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0102f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x028a +.insn 4, 0x005acab3 +.insn 4, 0x00445293 +.insn 4, 0x0142c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x0292 +.insn 4, 0x00544433 +.insn 4, 0x0044d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x0292 +.insn 4, 0x0054c4b3 +.insn 4, 0x00495293 +.insn 4, 0x0162c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x0292 +.insn 4, 0x00594933 +.insn 4, 0x0049d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x0112f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x0292 +.insn 4, 0x0059c9b3 +.insn 4, 0x3887b423 +.insn 4, 0x3897bc23 +.insn 4, 0x3b27b423 +.insn 4, 0x3b37bc23 +.insn 4, 0x3d47b423 +.insn 4, 0x3d57bc23 +.insn 4, 0x3f67b423 +.insn 4, 0x3f77bc23 +.insn 4, 0x3007b403 +.insn 4, 0x3807ba03 +.insn 4, 0x3107b483 +.insn 4, 0x3907ba83 +.insn 4, 0x3207b903 +.insn 4, 0x3a07bb03 +.insn 4, 0x3307b983 +.insn 4, 0x3b07bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b023 +.insn 4, 0x3947b023 +.insn 4, 0x3097b823 +.insn 4, 0x3957b823 +.insn 4, 0x3327b023 +.insn 4, 0x3b67b023 +.insn 4, 0x3337b823 +.insn 4, 0x3b77b823 +.insn 4, 0x3407b403 +.insn 4, 0x3c07ba03 +.insn 4, 0x3507b483 +.insn 4, 0x3d07ba83 +.insn 4, 0x3607b903 +.insn 4, 0x3e07bb03 +.insn 4, 0x3707b983 +.insn 4, 0x3f07bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3487b023 +.insn 4, 0x3d47b023 +.insn 4, 0x3497b823 +.insn 4, 0x3d57b823 +.insn 4, 0x3727b023 +.insn 4, 0x3f67b023 +.insn 4, 0x3737b823 +.insn 4, 0x3f77b823 +.insn 4, 0x3087b403 +.insn 4, 0x3887ba03 +.insn 4, 0x3187b483 +.insn 4, 0x3987ba83 +.insn 4, 0x3287b903 +.insn 4, 0x3a87bb03 +.insn 4, 0x3387b983 +.insn 4, 0x3b87bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3087b423 +.insn 4, 0x3947b423 +.insn 4, 0x3097bc23 +.insn 4, 0x3957bc23 +.insn 4, 0x3327b423 +.insn 4, 0x3b67b423 +.insn 4, 0x3337bc23 +.insn 4, 0x3b77bc23 +.insn 4, 0x3487b403 +.insn 4, 0x3c87ba03 +.insn 4, 0x3587b483 +.insn 4, 0x3d87ba83 +.insn 4, 0x3687b903 +.insn 4, 0x3e87bb03 +.insn 4, 0x3787b983 +.insn 4, 0x3f87bb83 +.insn 4, 0x00845293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01e2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x00845293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02a2 +.insn 4, 0x00544433 +.insn 4, 0x0084d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02a2 +.insn 4, 0x0054c4b3 +.insn 4, 0x00895293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02a2 +.insn 4, 0x00594933 +.insn 4, 0x0089d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02a2 +.insn 4, 0x0059c9b3 +.insn 4, 0x008a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02a2 +.insn 4, 0x005a4a33 +.insn 4, 0x008ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02a2 +.insn 4, 0x005acab3 +.insn 4, 0x008b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02a2 +.insn 4, 0x005b4b33 +.insn 4, 0x008bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01d2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02a2 +.insn 4, 0x005bcbb3 +.insn 4, 0x01045293 +.insn 4, 0x0082c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00544433 +.insn 2, 0x02c2 +.insn 4, 0x00544433 +.insn 4, 0x0104d293 +.insn 4, 0x0092c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0054c4b3 +.insn 2, 0x02c2 +.insn 4, 0x0054c4b3 +.insn 4, 0x01095293 +.insn 4, 0x0122c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x00594933 +.insn 2, 0x02c2 +.insn 4, 0x00594933 +.insn 4, 0x0109d293 +.insn 4, 0x0132c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x0059c9b3 +.insn 2, 0x02c2 +.insn 4, 0x0059c9b3 +.insn 4, 0x010a5293 +.insn 4, 0x0142c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005a4a33 +.insn 2, 0x02c2 +.insn 4, 0x005a4a33 +.insn 4, 0x010ad293 +.insn 4, 0x0152c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005acab3 +.insn 2, 0x02c2 +.insn 4, 0x005acab3 +.insn 4, 0x010b5293 +.insn 4, 0x0162c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005b4b33 +.insn 2, 0x02c2 +.insn 4, 0x005b4b33 +.insn 4, 0x010bd293 +.insn 4, 0x0172c2b3 +.insn 4, 0x01c2f2b3 +.insn 4, 0x005bcbb3 +.insn 2, 0x02c2 +.insn 4, 0x005bcbb3 +.insn 4, 0x3487b423 +.insn 4, 0x3d47b423 +.insn 4, 0x3497bc23 +.insn 4, 0x3d57bc23 +.insn 4, 0x3727b423 +.insn 4, 0x3f67b423 +.insn 4, 0x3737bc23 +.insn 4, 0x3f77bc23 +.insn 4, 0x7f878293 +.insn 4, 0x40828293 +.insn 4, 0x0002b403 +.insn 4, 0x0082b483 +.insn 4, 0x0102b903 +.insn 4, 0x0182b983 +.insn 4, 0x0202ba03 +.insn 4, 0x0282ba83 +.insn 4, 0x0302bb03 +.insn 4, 0x0382bb83 +.insn 4, 0x0402bc03 +.insn 4, 0x0482bc83 +.insn 4, 0x0502bd03 +.insn 4, 0x0582bd83 +.insn 2, 0x84ae +.insn 2, 0x8932 +.insn 2, 0x89ba +.insn 4, 0xfc878a13 +.insn 4, 0x030a3503 +.insn 2, 0x42c1 +bltu s3, t0, 217f +.insn 4, 0x338a6283 +.insn 4, 0x025a2023 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x340a6283 +.insn 4, 0x025a2423 +.insn 4, 0x344a6283 +.insn 4, 0x025a2623 +.insn 4, 0x00096283 +.insn 4, 0x338a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x33ca6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 4, 0x00896283 +.insn 4, 0x340a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592423 +.insn 4, 0x00c96283 +.insn 4, 0x344a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592623 +.insn 2, 0x0941 +.insn 2, 0x19c1 +j 218f +217: +.insn 4, 0x338a6283 +.insn 4, 0x025a2023 +.insn 4, 0x33ca6283 +.insn 4, 0x025a2223 +.insn 4, 0x340a6283 +.insn 4, 0x025a2423 +.insn 4, 0x344a6283 +.insn 4, 0x025a2623 +.insn 4, 0x338a0393 +219: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 219b +218: +bnez s3, 215b +j 214f +213: +214: +25: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 4, 0x028a6283 +.insn 4, 0x00590423 +.insn 4, 0x0082d393 +.insn 4, 0x007904a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790523 +.insn 4, 0x0182d393 +.insn 4, 0x007905a3 +.insn 4, 0x02ca6283 +.insn 4, 0x00590623 +.insn 4, 0x0082d393 +.insn 4, 0x007906a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790723 +.insn 4, 0x0182d393 +.insn 4, 0x007907a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 4, 0x19400393 +220: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 220b +.insn 4, 0x4b010113 +.insn 4, 0x7f010113 +.insn 2, 0x8082 +.option pop", + ) +} diff --git a/crates/verified-garbage-asm-riscv64/src/triple_des_ofb.rs b/crates/verified-garbage-asm-riscv64/src/triple_des_ofb.rs index 3bb4881eccc..7285c90cd80 100644 --- a/crates/verified-garbage-asm-riscv64/src/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/triple_des_ofb.rs @@ -2704,3 +2704,2743 @@ bnez t2, 221b .option pop", ) } + +/// Triple DES-OFB encryption or decryption (NIST SP 800-38A §6.4, FIPS 46-3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Triple DES encryption under the schedule written by `vg_triple_des_expand_key`. +/// +/// Contract: `VG.Spec.TripleDes.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 384 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the 944 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_triple_des_ofb_final(schedule: *const [u8; 384], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r".option push +.option arch, +m, +c +.insn 4, 0xc5010113 +.insn 2, 0x828a +.insn 4, 0x0092b023 +.insn 4, 0x0122b423 +.insn 4, 0x0132b823 +.insn 4, 0x0142bc23 +.insn 2, 0x8a16 +.insn 2, 0x84ae +.insn 2, 0x892e +.insn 2, 0x89b6 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2023 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x025a2223 +.insn 2, 0x8932 +.insn 4, 0x230a0293 +.insn 2, 0x83aa +.insn 4, 0x18000e93 +20: +.insn 4, 0x0003c303 +.insn 4, 0x00628023 +.insn 2, 0x0385 +.insn 2, 0x0285 +.insn 2, 0x1efd +bnez t4, 20b +.insn 4, 0x00397293 +beqz t0, 21f +beqz s3, 23f +25: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x035a3c23 +.insn 4, 0x056a3023 +.insn 4, 0x057a3423 +.insn 4, 0x058a3823 +.insn 4, 0x059a3c23 +.insn 4, 0x07aa3023 +.insn 4, 0x8d0ff2b7 +.insn 4, 0x9a72829b +.insn 2, 0x1282 +.insn 4, 0x489c3337 +.insn 4, 0x87d3031b +.insn 2, 0x929a +.insn 4, 0x065a3c23 +.insn 4, 0x7db9c2b7 +.insn 4, 0x7cb2829b +.insn 2, 0x1282 +.insn 4, 0xf5d6e337 +.insn 4, 0x3593031b +.insn 2, 0x929a +.insn 4, 0x085a3023 +.insn 4, 0x28d252b7 +.insn 4, 0x03e2829b +.insn 2, 0x1282 +.insn 4, 0x85e18337 +.insn 4, 0x7e23031b +.insn 2, 0x929a +.insn 4, 0x085a3423 +.insn 4, 0xe7c9c2b7 +.insn 4, 0x7c62829b +.insn 2, 0x1282 +.insn 4, 0x9edef337 +.insn 4, 0x7ad3031b +.insn 2, 0x929a +.insn 4, 0x085a3823 +.insn 4, 0xdee152b7 +.insn 4, 0xacb2829b +.insn 2, 0x1282 +.insn 4, 0x24fa7337 +.insn 4, 0x4183031b +.insn 2, 0x929a +.insn 4, 0x085a3c23 +.insn 4, 0x95b9b2b7 +.insn 4, 0xac52829b +.insn 2, 0x1282 +.insn 4, 0x7cdec337 +.insn 4, 0x3a53031b +.insn 2, 0x929a +.insn 4, 0x0a5a3023 +.insn 4, 0x427db2b7 +.insn 4, 0xd072829b +.insn 2, 0x1282 +.insn 4, 0xb25fc337 +.insn 4, 0xd413031b +.insn 2, 0x929a +.insn 4, 0x0a5a3423 +.insn 4, 0x5a53a2b7 +.insn 4, 0x7332829b +.insn 2, 0x1282 +.insn 4, 0x579da337 +.insn 4, 0x3393031b +.insn 2, 0x929a +.insn 4, 0x0a5a3823 +.insn 4, 0xe15c82b7 +.insn 4, 0x5912829b +.insn 2, 0x1282 +.insn 4, 0x9e29a337 +.insn 4, 0xfc33031b +.insn 2, 0x929a +.insn 4, 0x0a5a3c23 +.insn 4, 0x6c33d2b7 +.insn 4, 0x6342829b +.insn 2, 0x1282 +.insn 4, 0xbabeb337 +.insn 4, 0x7d93031b +.insn 2, 0x929a +.insn 4, 0x0c5a3023 +.insn 4, 0x9f87f2b7 +.insn 4, 0x3e32829b +.insn 2, 0x1282 +.insn 4, 0x79826337 +.insn 4, 0x09f3031b +.insn 2, 0x929a +.insn 4, 0x0c5a3423 +.insn 4, 0xfe7352b7 +.insn 4, 0x7ad2829b +.insn 2, 0x1282 +.insn 4, 0xa7dee337 +.insn 4, 0x3393031b +.insn 2, 0x929a +.insn 4, 0x0c5a3823 +.insn 4, 0x17b642b7 +.insn 4, 0xf7d2829b +.insn 2, 0x1282 +.insn 4, 0xebc6e337 +.insn 4, 0x1be3031b +.insn 2, 0x929a +.insn 4, 0x0c5a3c23 +.insn 4, 0x3937c2b7 +.insn 4, 0xaac2829b +.insn 2, 0x1282 +.insn 4, 0x6c3fb337 +.insn 4, 0x3393031b +.insn 2, 0x929a +.insn 4, 0x0e5a3023 +.insn 4, 0x742802b7 +.insn 4, 0x6da2829b +.insn 2, 0x1282 +.insn 4, 0x1c38e337 +.insn 4, 0xb243031b +.insn 2, 0x929a +.insn 4, 0x0e5a3423 +.insn 4, 0xc66582b7 +.insn 4, 0xf5c2829b +.insn 2, 0x1282 +.insn 4, 0x6e9d4337 +.insn 4, 0xef53031b +.insn 2, 0x929a +.insn 4, 0x0e5a3823 +.insn 4, 0xf3a3b2b7 +.insn 4, 0x2f52829b +.insn 2, 0x1282 +.insn 4, 0xf1705337 +.insn 4, 0x60a3031b +.insn 2, 0x929a +.insn 4, 0x0e5a3c23 +.insn 4, 0x56daf2b7 +.insn 4, 0x3352829b +.insn 2, 0x1282 +.insn 4, 0x37c67337 +.insn 4, 0xbf33031b +.insn 2, 0x929a +.insn 4, 0x105a3023 +.insn 4, 0xc51e32b7 +.insn 4, 0xe422829b +.insn 2, 0x1282 +.insn 4, 0x360e0337 +.insn 4, 0x93c3031b +.insn 2, 0x929a +.insn 4, 0x105a3423 +.insn 4, 0xbcded2b7 +.insn 4, 0x6562829b +.insn 2, 0x1282 +.insn 4, 0xc6ec6337 +.insn 4, 0xfa93031b +.insn 2, 0x929a +.insn 4, 0x105a3823 +.insn 4, 0x699422b7 +.insn 4, 0xc682829b +.insn 2, 0x1282 +.insn 4, 0x5a43c337 +.insn 4, 0x3a63031b +.insn 2, 0x929a +.insn 4, 0x105a3c23 +.insn 4, 0x5576d2b7 +.insn 4, 0xa3a2829b +.insn 2, 0x1282 +.insn 4, 0x555ed337 +.insn 4, 0x9653031b +.insn 2, 0x929a +.insn 4, 0x125a3023 +.insn 4, 0xbccbc2b7 +.insn 4, 0x7b52829b +.insn 2, 0x1282 +.insn 4, 0x6fa42337 +.insn 4, 0xedb3031b +.insn 2, 0x929a +.insn 4, 0x125a3423 +.insn 4, 0x6b5f02b7 +.insn 4, 0xa5c2829b +.insn 2, 0x1282 +.insn 4, 0x56dae337 +.insn 4, 0x7d53031b +.insn 2, 0x929a +.insn 4, 0x125a3823 +.insn 4, 0x3a3972b7 +.insn 4, 0xb5f2829b +.insn 2, 0x1282 +.insn 4, 0xc71e1337 +.insn 4, 0xaf53031b +.insn 2, 0x929a +.insn 4, 0x125a3c23 +.insn 4, 0x6c35d2b7 +.insn 4, 0x7ca2829b +.insn 2, 0x1282 +.insn 4, 0x5d7ee337 +.insn 4, 0xe953031b +.insn 2, 0x929a +.insn 4, 0x145a3023 +.insn 4, 0x566092b7 +.insn 4, 0x42a2829b +.insn 2, 0x1282 +.insn 4, 0xa0d7a337 +.insn 4, 0x5603031b +.insn 2, 0x929a +.insn 4, 0x145a3423 +.insn 4, 0x5cc402b7 +.insn 4, 0xf542829b +.insn 2, 0x1282 +.insn 4, 0xe3dcf337 +.insn 4, 0xa3b3031b +.insn 2, 0x929a +.insn 4, 0x145a3823 +.insn 4, 0xa04ad2b7 +.insn 4, 0x1812829b +.insn 2, 0x1282 +.insn 4, 0x0db54337 +.insn 4, 0xc593031b +.insn 2, 0x929a +.insn 4, 0x145a3c23 +.insn 4, 0x339dd2b7 +.insn 4, 0xeaa2829b +.insn 2, 0x1282 +.insn 4, 0x6c366337 +.insn 4, 0xd653031b +.insn 2, 0x929a +.insn 4, 0x165a3023 +.insn 4, 0x0bf582b7 +.insn 4, 0x8202829b +.insn 2, 0x1282 +.insn 4, 0xd36b4337 +.insn 4, 0x2873031b +.insn 2, 0x929a +.insn 4, 0x165a3423 +.insn 4, 0xefcfc2b7 +.insn 4, 0xaa32829b +.insn 2, 0x1282 +.insn 4, 0x7fb3e337 +.insn 4, 0xe653031b +.insn 2, 0x929a +.insn 4, 0x165a3823 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x00040337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x165a3c23 +.insn 4, 0x000002b7 +.insn 2, 0x2291 +.insn 2, 0x1282 +.insn 2, 0x7341 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x185a3023 +.insn 4, 0x000002b7 +.insn 4, 0x3ff2829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 4, 0x3ff3031b +.insn 2, 0x929a +.insn 4, 0x185a3423 +.insn 4, 0x000402b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0x00040337 +.insn 4, 0xf003031b +.insn 2, 0x929a +.insn 4, 0x185a3823 +.insn 4, 0x003f02b7 +.insn 4, 0x03f2829b +.insn 2, 0x1282 +.insn 4, 0x003f0337 +.insn 4, 0x03f3031b +.insn 2, 0x929a +.insn 4, 0x185a3c23 +.insn 4, 0x03f002b7 +.insn 4, 0x3f02829b +.insn 2, 0x1282 +.insn 4, 0x03f00337 +.insn 4, 0x3f03031b +.insn 2, 0x929a +.insn 4, 0x1a5a3023 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x01000337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1a5a3423 +.insn 2, 0x62c1 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0xff000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1a5a3823 +.insn 2, 0x6285 +.insn 2, 0x32fd +.insn 2, 0x1282 +.insn 2, 0x6305 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1a5a3c23 +.insn 4, 0x00fff2b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x00fff337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1c5a3023 +.insn 4, 0x003f02b7 +.insn 4, 0x03f2829b +.insn 2, 0x1282 +.insn 4, 0x003f0337 +.insn 4, 0x03f3031b +.insn 2, 0x929a +.insn 4, 0x1c5a3423 +.insn 4, 0x0fc012b7 +.insn 4, 0xfc02829b +.insn 2, 0x1282 +.insn 4, 0x0fc01337 +.insn 4, 0xfc03031b +.insn 2, 0x929a +.insn 4, 0x1c5a3823 +.insn 4, 0x010102b7 +.insn 4, 0x1012829b +.insn 2, 0x1282 +.insn 4, 0x01010337 +.insn 4, 0x1013031b +.insn 2, 0x929a +.insn 4, 0x1c5a3c23 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x929a +.insn 4, 0x1e5a3023 +.insn 4, 0x000002b7 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1e5a3423 +.insn 4, 0x040212b7 +.insn 4, 0x8002829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1e5a3823 +.insn 2, 0x62c1 +.insn 2, 0x22a1 +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1e5a3c23 +.insn 4, 0x000402b7 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 4, 0x08000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x205a3023 +.insn 4, 0x000002b7 +.insn 4, 0x2002829b +.insn 2, 0x1282 +.insn 4, 0x00040337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x205a3423 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x04000337 +.insn 4, 0x1003031b +.insn 2, 0x929a +.insn 4, 0x205a3823 +.insn 4, 0x000002b7 +.insn 2, 0x2291 +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x205a3c23 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x01000337 +.insn 4, 0x4003031b +.insn 2, 0x929a +.insn 4, 0x225a3023 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x00081337 +.insn 4, 0x8043031b +.insn 2, 0x929a +.insn 4, 0x225a3423 +.insn 4, 0x030a4283 +.insn 2, 0x02a2 +.insn 4, 0x031a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x032a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x033a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x034a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x035a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x036a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x037a4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x0002f393 +.insn 4, 0x0062de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0162de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0262de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0362de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0042de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0142de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0242de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0342de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0022de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0122de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0222de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0322de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e22 +.insn 4, 0x01c3c3b3 +.insn 2, 0x8e16 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0082de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0102de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0182de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0202de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0282de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0302de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0382de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e02 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0072de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0172de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0272de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0372de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0052de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0152de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0252de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0352de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0032de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0132de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0232de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0332de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e22 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0012de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0092de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0112de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0192de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0212de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0292de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0312de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0392de13 +.insn 4, 0x001e7e13 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0203d593 +.insn 4, 0x02039613 +.insn 2, 0x9201 +.insn 2, 0x480d +26: +.insn 4, 0xffd80f93 +beqz t6, 27f +.insn 4, 0xffe80f93 +beqz t6, 29f +.insn 4, 0x330a0693 +.insn 2, 0x4741 +.insn 2, 0x47a1 +j 210f +29: +.insn 4, 0x328a0693 +.insn 2, 0x4741 +.insn 2, 0x57e1 +210: +j 28f +27: +.insn 4, 0x230a0693 +.insn 2, 0x4741 +.insn 2, 0x47a1 +28: +211: +.insn 4, 0x0006be83 +.insn 4, 0x1e8a3283 +.insn 4, 0x005672b3 +.insn 4, 0x00129313 +.insn 4, 0x01f2d393 +.insn 4, 0x00734333 +.insn 4, 0x02129393 +.insn 4, 0x007342b3 +.insn 4, 0x178a3303 +.insn 4, 0x0062f333 +.insn 4, 0x180a3383 +.insn 4, 0x0072f3b3 +.insn 2, 0x03c2 +.insn 4, 0x007342b3 +.insn 4, 0x188a3303 +.insn 4, 0x0062f333 +.insn 4, 0x190a3383 +.insn 4, 0x0072f3b3 +.insn 2, 0x03a2 +.insn 4, 0x007342b3 +.insn 4, 0x198a3303 +.insn 4, 0x0062f333 +.insn 4, 0x1a0a3383 +.insn 4, 0x0072f3b3 +.insn 2, 0x0392 +.insn 4, 0x007342b3 +.insn 4, 0x1a8a3303 +.insn 4, 0x006ef333 +.insn 4, 0x1b0a3383 +.insn 4, 0x007ef3b3 +.insn 2, 0x03a2 +.insn 4, 0x00734eb3 +.insn 4, 0x1b8a3303 +.insn 4, 0x006ef333 +.insn 4, 0x1c0a3383 +.insn 4, 0x007ef3b3 +.insn 2, 0x0392 +.insn 4, 0x00734eb3 +.insn 4, 0x1c8a3303 +.insn 4, 0x006ef333 +.insn 4, 0x1d0a3383 +.insn 4, 0x007ef3b3 +.insn 2, 0x038a +.insn 4, 0x00734eb3 +.insn 4, 0x01d2c2b3 +.insn 4, 0x1d8a3e03 +.insn 4, 0x01c2fab3 +.insn 4, 0x001a9313 +.insn 4, 0x006acab3 +.insn 4, 0x002a9313 +.insn 4, 0x006acab3 +.insn 4, 0x004a9313 +.insn 4, 0x006acab3 +.insn 4, 0x0012db13 +.insn 4, 0x01cb7b33 +.insn 4, 0x001b1313 +.insn 4, 0x006b4b33 +.insn 4, 0x002b1313 +.insn 4, 0x006b4b33 +.insn 4, 0x004b1313 +.insn 4, 0x006b4b33 +.insn 4, 0x0022db93 +.insn 4, 0x01cbfbb3 +.insn 4, 0x001b9313 +.insn 4, 0x006bcbb3 +.insn 4, 0x002b9313 +.insn 4, 0x006bcbb3 +.insn 4, 0x004b9313 +.insn 4, 0x006bcbb3 +.insn 4, 0x0032dc13 +.insn 4, 0x01cc7c33 +.insn 4, 0x001c1313 +.insn 4, 0x006c4c33 +.insn 4, 0x002c1313 +.insn 4, 0x006c4c33 +.insn 4, 0x004c1313 +.insn 4, 0x006c4c33 +.insn 4, 0x0042dc93 +.insn 4, 0x01ccfcb3 +.insn 4, 0x001c9313 +.insn 4, 0x006cccb3 +.insn 4, 0x002c9313 +.insn 4, 0x006cccb3 +.insn 4, 0x004c9313 +.insn 4, 0x006cccb3 +.insn 4, 0x0052dd13 +.insn 4, 0x01cd7d33 +.insn 4, 0x001d1313 +.insn 4, 0x006d4d33 +.insn 4, 0x002d1313 +.insn 4, 0x006d4d33 +.insn 4, 0x004d1313 +.insn 4, 0x006d4d33 +.insn 4, 0x078a3283 +.insn 4, 0x080a3303 +.insn 4, 0x01537333 +.insn 4, 0x0062c2b3 +.insn 4, 0x088a3303 +.insn 4, 0x090a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01637333 +.insn 4, 0x0062c2b3 +.insn 4, 0x098a3303 +.insn 4, 0x0a0a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0a8a3383 +.insn 4, 0x0b0a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0163f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01737333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0b8a3303 +.insn 4, 0x0c0a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0c8a3383 +.insn 4, 0x0d0a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0163f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0d8a3383 +.insn 4, 0x0e0a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0e8a3e03 +.insn 4, 0x0f0a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x016e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0173f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01837333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0f8a3303 +.insn 4, 0x100a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x108a3383 +.insn 4, 0x110a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0163f3b3 +.insn 4, 0x00734333 +.insn 4, 0x118a3383 +.insn 4, 0x120a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x128a3e03 +.insn 4, 0x130a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x016e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0173f3b3 +.insn 4, 0x00734333 +.insn 4, 0x138a3383 +.insn 4, 0x140a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x148a3e03 +.insn 4, 0x150a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x016e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x158a3e03 +.insn 4, 0x160a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x168a3e83 +.insn 4, 0x170a3f03 +.insn 4, 0x015f7f33 +.insn 4, 0x01eeceb3 +.insn 4, 0x01de4eb3 +.insn 4, 0x016efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x017e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0183f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01937333 +.insn 4, 0x0062c2b3 +.insn 4, 0x1e0a3f83 +.insn 4, 0x01fd4fb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0042d313 +.insn 4, 0x0062c2b3 +.insn 4, 0x0392d313 +.insn 4, 0x00137313 +.insn 2, 0x0306 +.insn 4, 0x0065c5b3 +.insn 4, 0x0332d313 +.insn 4, 0x02137313 +.insn 2, 0x0312 +.insn 4, 0x0065c5b3 +.insn 4, 0x03b2d313 +.insn 4, 0x00137313 +.insn 2, 0x033e +.insn 4, 0x0065c5b3 +.insn 4, 0x0282d313 +.insn 4, 0x00137313 +.insn 2, 0x030a +.insn 4, 0x0065c5b3 +.insn 4, 0x1f0a3303 +.insn 4, 0x00537333 +.insn 4, 0x02335313 +.insn 4, 0x0065c5b3 +.insn 4, 0x1f8a3303 +.insn 4, 0x00537333 +.insn 4, 0x01d35313 +.insn 4, 0x0065c5b3 +.insn 4, 0x02a2d313 +.insn 4, 0x00137313 +.insn 2, 0x0342 +.insn 4, 0x0065c5b3 +.insn 4, 0x200a3303 +.insn 4, 0x00537333 +.insn 4, 0x01435313 +.insn 4, 0x0065c5b3 +.insn 4, 0x208a3303 +.insn 4, 0x00537333 +.insn 4, 0x00f35313 +.insn 4, 0x0065c5b3 +.insn 4, 0x0212d313 +.insn 4, 0x00137313 +.insn 2, 0x035a +.insn 4, 0x0065c5b3 +.insn 4, 0x210a3303 +.insn 4, 0x00537333 +.insn 4, 0x00835313 +.insn 4, 0x0065c5b3 +.insn 4, 0x218a3303 +.insn 4, 0x00537333 +.insn 4, 0x00335313 +.insn 4, 0x0065c5b3 +.insn 4, 0x220a3303 +.insn 4, 0x00537333 +.insn 4, 0x0065c5b3 +.insn 4, 0x0112d313 +.insn 4, 0x10137313 +.insn 2, 0x0356 +.insn 4, 0x0065c5b3 +.insn 4, 0x0012f313 +.insn 2, 0x0316 +.insn 4, 0x0065c5b3 +.insn 4, 0x228a3303 +.insn 4, 0x00537333 +.insn 2, 0x0326 +.insn 4, 0x0065c5b3 +.insn 4, 0x0012d313 +.insn 4, 0x10137313 +.insn 2, 0x0346 +.insn 4, 0x0065c5b3 +.insn 4, 0x0032d313 +.insn 4, 0x00137313 +.insn 2, 0x036e +.insn 4, 0x0065c5b3 +.insn 2, 0x82ae +.insn 2, 0x85b2 +.insn 2, 0x8616 +.insn 2, 0x96be +.insn 2, 0x177d +bnez a4, 211b +.insn 2, 0x82ae +.insn 2, 0x85b2 +.insn 2, 0x8616 +.insn 2, 0x187d +bnez a6, 26b +.insn 4, 0x02059293 +.insn 4, 0x00c2c2b3 +.insn 4, 0x0002f393 +.insn 4, 0x0182de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0382de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0102de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0302de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0082de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0282de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6a +.insn 4, 0x01c3c3b3 +.insn 2, 0x8e16 +.insn 4, 0x001e7e13 +.insn 2, 0x1e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0202de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0192de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0392de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0112de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0312de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0092de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0292de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0012de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0212de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0122de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0322de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0022de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0222de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e22 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0132de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0332de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0032de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0232de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e02 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0142de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0342de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0042de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0242de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0152de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0352de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0052de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0252de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0162de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0362de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0062de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0262de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e22 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0172de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0372de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0072de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0272de13 +.insn 4, 0x001e7e13 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0383d313 +.insn 4, 0x026a0823 +.insn 4, 0x0303d313 +.insn 4, 0x026a08a3 +.insn 4, 0x0283d313 +.insn 4, 0x026a0923 +.insn 4, 0x0203d313 +.insn 4, 0x026a09a3 +.insn 4, 0x0183d313 +.insn 4, 0x026a0a23 +.insn 4, 0x0103d313 +.insn 4, 0x026a0aa3 +.insn 4, 0x0083d313 +.insn 4, 0x026a0b23 +.insn 4, 0x0003d313 +.insn 4, 0x026a0ba3 +.insn 4, 0x038a3a83 +.insn 4, 0x040a3b03 +.insn 4, 0x048a3b83 +.insn 4, 0x050a3c03 +.insn 4, 0x058a3c83 +.insn 4, 0x060a3d03 +.insn 2, 0x42a1 +bltu s3, t0, 212f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00094283 +.insn 4, 0x00194383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00294383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00394383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x00494283 +.insn 4, 0x00594383 +.insn 2, 0x03a2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00694383 +.insn 2, 0x03c2 +.insn 4, 0x0072e2b3 +.insn 4, 0x00794383 +.insn 2, 0x03e2 +.insn 4, 0x0072e2b3 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 213f +212: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +214: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 214b +213: +bnez s3, 25b +j 24f +23: +24: +j 22f +21: +beqz s3, 215f +217: +.insn 4, 0x020a6283 +.insn 4, 0x025a2823 +.insn 4, 0x024a6283 +.insn 4, 0x025a2a23 +.insn 4, 0x035a3c23 +.insn 4, 0x056a3023 +.insn 4, 0x057a3423 +.insn 4, 0x058a3823 +.insn 4, 0x059a3c23 +.insn 4, 0x07aa3023 +.insn 4, 0x8d0ff2b7 +.insn 4, 0x9a72829b +.insn 2, 0x1282 +.insn 4, 0x489c3337 +.insn 4, 0x87d3031b +.insn 2, 0x929a +.insn 4, 0x065a3c23 +.insn 4, 0x7db9c2b7 +.insn 4, 0x7cb2829b +.insn 2, 0x1282 +.insn 4, 0xf5d6e337 +.insn 4, 0x3593031b +.insn 2, 0x929a +.insn 4, 0x085a3023 +.insn 4, 0x28d252b7 +.insn 4, 0x03e2829b +.insn 2, 0x1282 +.insn 4, 0x85e18337 +.insn 4, 0x7e23031b +.insn 2, 0x929a +.insn 4, 0x085a3423 +.insn 4, 0xe7c9c2b7 +.insn 4, 0x7c62829b +.insn 2, 0x1282 +.insn 4, 0x9edef337 +.insn 4, 0x7ad3031b +.insn 2, 0x929a +.insn 4, 0x085a3823 +.insn 4, 0xdee152b7 +.insn 4, 0xacb2829b +.insn 2, 0x1282 +.insn 4, 0x24fa7337 +.insn 4, 0x4183031b +.insn 2, 0x929a +.insn 4, 0x085a3c23 +.insn 4, 0x95b9b2b7 +.insn 4, 0xac52829b +.insn 2, 0x1282 +.insn 4, 0x7cdec337 +.insn 4, 0x3a53031b +.insn 2, 0x929a +.insn 4, 0x0a5a3023 +.insn 4, 0x427db2b7 +.insn 4, 0xd072829b +.insn 2, 0x1282 +.insn 4, 0xb25fc337 +.insn 4, 0xd413031b +.insn 2, 0x929a +.insn 4, 0x0a5a3423 +.insn 4, 0x5a53a2b7 +.insn 4, 0x7332829b +.insn 2, 0x1282 +.insn 4, 0x579da337 +.insn 4, 0x3393031b +.insn 2, 0x929a +.insn 4, 0x0a5a3823 +.insn 4, 0xe15c82b7 +.insn 4, 0x5912829b +.insn 2, 0x1282 +.insn 4, 0x9e29a337 +.insn 4, 0xfc33031b +.insn 2, 0x929a +.insn 4, 0x0a5a3c23 +.insn 4, 0x6c33d2b7 +.insn 4, 0x6342829b +.insn 2, 0x1282 +.insn 4, 0xbabeb337 +.insn 4, 0x7d93031b +.insn 2, 0x929a +.insn 4, 0x0c5a3023 +.insn 4, 0x9f87f2b7 +.insn 4, 0x3e32829b +.insn 2, 0x1282 +.insn 4, 0x79826337 +.insn 4, 0x09f3031b +.insn 2, 0x929a +.insn 4, 0x0c5a3423 +.insn 4, 0xfe7352b7 +.insn 4, 0x7ad2829b +.insn 2, 0x1282 +.insn 4, 0xa7dee337 +.insn 4, 0x3393031b +.insn 2, 0x929a +.insn 4, 0x0c5a3823 +.insn 4, 0x17b642b7 +.insn 4, 0xf7d2829b +.insn 2, 0x1282 +.insn 4, 0xebc6e337 +.insn 4, 0x1be3031b +.insn 2, 0x929a +.insn 4, 0x0c5a3c23 +.insn 4, 0x3937c2b7 +.insn 4, 0xaac2829b +.insn 2, 0x1282 +.insn 4, 0x6c3fb337 +.insn 4, 0x3393031b +.insn 2, 0x929a +.insn 4, 0x0e5a3023 +.insn 4, 0x742802b7 +.insn 4, 0x6da2829b +.insn 2, 0x1282 +.insn 4, 0x1c38e337 +.insn 4, 0xb243031b +.insn 2, 0x929a +.insn 4, 0x0e5a3423 +.insn 4, 0xc66582b7 +.insn 4, 0xf5c2829b +.insn 2, 0x1282 +.insn 4, 0x6e9d4337 +.insn 4, 0xef53031b +.insn 2, 0x929a +.insn 4, 0x0e5a3823 +.insn 4, 0xf3a3b2b7 +.insn 4, 0x2f52829b +.insn 2, 0x1282 +.insn 4, 0xf1705337 +.insn 4, 0x60a3031b +.insn 2, 0x929a +.insn 4, 0x0e5a3c23 +.insn 4, 0x56daf2b7 +.insn 4, 0x3352829b +.insn 2, 0x1282 +.insn 4, 0x37c67337 +.insn 4, 0xbf33031b +.insn 2, 0x929a +.insn 4, 0x105a3023 +.insn 4, 0xc51e32b7 +.insn 4, 0xe422829b +.insn 2, 0x1282 +.insn 4, 0x360e0337 +.insn 4, 0x93c3031b +.insn 2, 0x929a +.insn 4, 0x105a3423 +.insn 4, 0xbcded2b7 +.insn 4, 0x6562829b +.insn 2, 0x1282 +.insn 4, 0xc6ec6337 +.insn 4, 0xfa93031b +.insn 2, 0x929a +.insn 4, 0x105a3823 +.insn 4, 0x699422b7 +.insn 4, 0xc682829b +.insn 2, 0x1282 +.insn 4, 0x5a43c337 +.insn 4, 0x3a63031b +.insn 2, 0x929a +.insn 4, 0x105a3c23 +.insn 4, 0x5576d2b7 +.insn 4, 0xa3a2829b +.insn 2, 0x1282 +.insn 4, 0x555ed337 +.insn 4, 0x9653031b +.insn 2, 0x929a +.insn 4, 0x125a3023 +.insn 4, 0xbccbc2b7 +.insn 4, 0x7b52829b +.insn 2, 0x1282 +.insn 4, 0x6fa42337 +.insn 4, 0xedb3031b +.insn 2, 0x929a +.insn 4, 0x125a3423 +.insn 4, 0x6b5f02b7 +.insn 4, 0xa5c2829b +.insn 2, 0x1282 +.insn 4, 0x56dae337 +.insn 4, 0x7d53031b +.insn 2, 0x929a +.insn 4, 0x125a3823 +.insn 4, 0x3a3972b7 +.insn 4, 0xb5f2829b +.insn 2, 0x1282 +.insn 4, 0xc71e1337 +.insn 4, 0xaf53031b +.insn 2, 0x929a +.insn 4, 0x125a3c23 +.insn 4, 0x6c35d2b7 +.insn 4, 0x7ca2829b +.insn 2, 0x1282 +.insn 4, 0x5d7ee337 +.insn 4, 0xe953031b +.insn 2, 0x929a +.insn 4, 0x145a3023 +.insn 4, 0x566092b7 +.insn 4, 0x42a2829b +.insn 2, 0x1282 +.insn 4, 0xa0d7a337 +.insn 4, 0x5603031b +.insn 2, 0x929a +.insn 4, 0x145a3423 +.insn 4, 0x5cc402b7 +.insn 4, 0xf542829b +.insn 2, 0x1282 +.insn 4, 0xe3dcf337 +.insn 4, 0xa3b3031b +.insn 2, 0x929a +.insn 4, 0x145a3823 +.insn 4, 0xa04ad2b7 +.insn 4, 0x1812829b +.insn 2, 0x1282 +.insn 4, 0x0db54337 +.insn 4, 0xc593031b +.insn 2, 0x929a +.insn 4, 0x145a3c23 +.insn 4, 0x339dd2b7 +.insn 4, 0xeaa2829b +.insn 2, 0x1282 +.insn 4, 0x6c366337 +.insn 4, 0xd653031b +.insn 2, 0x929a +.insn 4, 0x165a3023 +.insn 4, 0x0bf582b7 +.insn 4, 0x8202829b +.insn 2, 0x1282 +.insn 4, 0xd36b4337 +.insn 4, 0x2873031b +.insn 2, 0x929a +.insn 4, 0x165a3423 +.insn 4, 0xefcfc2b7 +.insn 4, 0xaa32829b +.insn 2, 0x1282 +.insn 4, 0x7fb3e337 +.insn 4, 0xe653031b +.insn 2, 0x929a +.insn 4, 0x165a3823 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x00040337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x165a3c23 +.insn 4, 0x000002b7 +.insn 2, 0x2291 +.insn 2, 0x1282 +.insn 2, 0x7341 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x185a3023 +.insn 4, 0x000002b7 +.insn 4, 0x3ff2829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 4, 0x3ff3031b +.insn 2, 0x929a +.insn 4, 0x185a3423 +.insn 4, 0x000402b7 +.insn 4, 0xf002829b +.insn 2, 0x1282 +.insn 4, 0x00040337 +.insn 4, 0xf003031b +.insn 2, 0x929a +.insn 4, 0x185a3823 +.insn 4, 0x003f02b7 +.insn 4, 0x03f2829b +.insn 2, 0x1282 +.insn 4, 0x003f0337 +.insn 4, 0x03f3031b +.insn 2, 0x929a +.insn 4, 0x185a3c23 +.insn 4, 0x03f002b7 +.insn 4, 0x3f02829b +.insn 2, 0x1282 +.insn 4, 0x03f00337 +.insn 4, 0x3f03031b +.insn 2, 0x929a +.insn 4, 0x1a5a3023 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x01000337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1a5a3423 +.insn 2, 0x62c1 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0xff000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1a5a3823 +.insn 2, 0x6285 +.insn 2, 0x32fd +.insn 2, 0x1282 +.insn 2, 0x6305 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1a5a3c23 +.insn 4, 0x00fff2b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x00fff337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1c5a3023 +.insn 4, 0x003f02b7 +.insn 4, 0x03f2829b +.insn 2, 0x1282 +.insn 4, 0x003f0337 +.insn 4, 0x03f3031b +.insn 2, 0x929a +.insn 4, 0x1c5a3423 +.insn 4, 0x0fc012b7 +.insn 4, 0xfc02829b +.insn 2, 0x1282 +.insn 4, 0x0fc01337 +.insn 4, 0xfc03031b +.insn 2, 0x929a +.insn 4, 0x1c5a3823 +.insn 4, 0x010102b7 +.insn 4, 0x1012829b +.insn 2, 0x1282 +.insn 4, 0x01010337 +.insn 4, 0x1013031b +.insn 2, 0x929a +.insn 4, 0x1c5a3c23 +.insn 4, 0x0f0f12b7 +.insn 4, 0xf0f2829b +.insn 2, 0x1282 +.insn 4, 0x0f0f1337 +.insn 4, 0xf0f3031b +.insn 2, 0x929a +.insn 4, 0x1e5a3023 +.insn 4, 0x000002b7 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x337d +.insn 2, 0x929a +.insn 4, 0x1e5a3423 +.insn 4, 0x040212b7 +.insn 4, 0x8002829b +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1e5a3823 +.insn 2, 0x62c1 +.insn 2, 0x22a1 +.insn 2, 0x1282 +.insn 4, 0x00000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x1e5a3c23 +.insn 4, 0x000402b7 +.insn 2, 0x2285 +.insn 2, 0x1282 +.insn 4, 0x08000337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x205a3023 +.insn 4, 0x000002b7 +.insn 4, 0x2002829b +.insn 2, 0x1282 +.insn 4, 0x00040337 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x205a3423 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x04000337 +.insn 4, 0x1003031b +.insn 2, 0x929a +.insn 4, 0x205a3823 +.insn 4, 0x000002b7 +.insn 2, 0x2291 +.insn 2, 0x1282 +.insn 2, 0x6341 +.insn 2, 0x2301 +.insn 2, 0x929a +.insn 4, 0x205a3c23 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x01000337 +.insn 4, 0x4003031b +.insn 2, 0x929a +.insn 4, 0x225a3023 +.insn 4, 0x000002b7 +.insn 2, 0x2281 +.insn 2, 0x1282 +.insn 4, 0x00081337 +.insn 4, 0x8043031b +.insn 2, 0x929a +.insn 4, 0x225a3423 +.insn 4, 0x030a4283 +.insn 2, 0x02a2 +.insn 4, 0x031a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x032a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x033a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x034a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x035a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x036a4303 +.insn 4, 0x0062e2b3 +.insn 2, 0x02a2 +.insn 4, 0x037a4303 +.insn 4, 0x0062e2b3 +.insn 4, 0x0002f393 +.insn 4, 0x0062de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0162de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0262de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0362de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0042de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0142de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0242de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0342de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0022de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0122de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0222de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0322de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e22 +.insn 4, 0x01c3c3b3 +.insn 2, 0x8e16 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0082de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0102de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0182de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0202de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0282de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0302de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0382de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e02 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0072de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0172de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0272de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0372de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0052de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0152de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0252de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0352de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0032de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x00b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0132de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0232de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0332de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x03b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e22 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0012de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0092de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0112de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0192de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0212de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0292de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0312de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0392de13 +.insn 4, 0x001e7e13 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0203d593 +.insn 4, 0x02039613 +.insn 2, 0x9201 +.insn 2, 0x480d +218: +.insn 4, 0xffd80f93 +beqz t6, 219f +.insn 4, 0xffe80f93 +beqz t6, 221f +.insn 4, 0x330a0693 +.insn 2, 0x4741 +.insn 2, 0x47a1 +j 222f +221: +.insn 4, 0x328a0693 +.insn 2, 0x4741 +.insn 2, 0x57e1 +222: +j 220f +219: +.insn 4, 0x230a0693 +.insn 2, 0x4741 +.insn 2, 0x47a1 +220: +223: +.insn 4, 0x0006be83 +.insn 4, 0x1e8a3283 +.insn 4, 0x005672b3 +.insn 4, 0x00129313 +.insn 4, 0x01f2d393 +.insn 4, 0x00734333 +.insn 4, 0x02129393 +.insn 4, 0x007342b3 +.insn 4, 0x178a3303 +.insn 4, 0x0062f333 +.insn 4, 0x180a3383 +.insn 4, 0x0072f3b3 +.insn 2, 0x03c2 +.insn 4, 0x007342b3 +.insn 4, 0x188a3303 +.insn 4, 0x0062f333 +.insn 4, 0x190a3383 +.insn 4, 0x0072f3b3 +.insn 2, 0x03a2 +.insn 4, 0x007342b3 +.insn 4, 0x198a3303 +.insn 4, 0x0062f333 +.insn 4, 0x1a0a3383 +.insn 4, 0x0072f3b3 +.insn 2, 0x0392 +.insn 4, 0x007342b3 +.insn 4, 0x1a8a3303 +.insn 4, 0x006ef333 +.insn 4, 0x1b0a3383 +.insn 4, 0x007ef3b3 +.insn 2, 0x03a2 +.insn 4, 0x00734eb3 +.insn 4, 0x1b8a3303 +.insn 4, 0x006ef333 +.insn 4, 0x1c0a3383 +.insn 4, 0x007ef3b3 +.insn 2, 0x0392 +.insn 4, 0x00734eb3 +.insn 4, 0x1c8a3303 +.insn 4, 0x006ef333 +.insn 4, 0x1d0a3383 +.insn 4, 0x007ef3b3 +.insn 2, 0x038a +.insn 4, 0x00734eb3 +.insn 4, 0x01d2c2b3 +.insn 4, 0x1d8a3e03 +.insn 4, 0x01c2fab3 +.insn 4, 0x001a9313 +.insn 4, 0x006acab3 +.insn 4, 0x002a9313 +.insn 4, 0x006acab3 +.insn 4, 0x004a9313 +.insn 4, 0x006acab3 +.insn 4, 0x0012db13 +.insn 4, 0x01cb7b33 +.insn 4, 0x001b1313 +.insn 4, 0x006b4b33 +.insn 4, 0x002b1313 +.insn 4, 0x006b4b33 +.insn 4, 0x004b1313 +.insn 4, 0x006b4b33 +.insn 4, 0x0022db93 +.insn 4, 0x01cbfbb3 +.insn 4, 0x001b9313 +.insn 4, 0x006bcbb3 +.insn 4, 0x002b9313 +.insn 4, 0x006bcbb3 +.insn 4, 0x004b9313 +.insn 4, 0x006bcbb3 +.insn 4, 0x0032dc13 +.insn 4, 0x01cc7c33 +.insn 4, 0x001c1313 +.insn 4, 0x006c4c33 +.insn 4, 0x002c1313 +.insn 4, 0x006c4c33 +.insn 4, 0x004c1313 +.insn 4, 0x006c4c33 +.insn 4, 0x0042dc93 +.insn 4, 0x01ccfcb3 +.insn 4, 0x001c9313 +.insn 4, 0x006cccb3 +.insn 4, 0x002c9313 +.insn 4, 0x006cccb3 +.insn 4, 0x004c9313 +.insn 4, 0x006cccb3 +.insn 4, 0x0052dd13 +.insn 4, 0x01cd7d33 +.insn 4, 0x001d1313 +.insn 4, 0x006d4d33 +.insn 4, 0x002d1313 +.insn 4, 0x006d4d33 +.insn 4, 0x004d1313 +.insn 4, 0x006d4d33 +.insn 4, 0x078a3283 +.insn 4, 0x080a3303 +.insn 4, 0x01537333 +.insn 4, 0x0062c2b3 +.insn 4, 0x088a3303 +.insn 4, 0x090a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01637333 +.insn 4, 0x0062c2b3 +.insn 4, 0x098a3303 +.insn 4, 0x0a0a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0a8a3383 +.insn 4, 0x0b0a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0163f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01737333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0b8a3303 +.insn 4, 0x0c0a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0c8a3383 +.insn 4, 0x0d0a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0163f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0d8a3383 +.insn 4, 0x0e0a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0e8a3e03 +.insn 4, 0x0f0a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x016e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0173f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01837333 +.insn 4, 0x0062c2b3 +.insn 4, 0x0f8a3303 +.insn 4, 0x100a3383 +.insn 4, 0x0153f3b3 +.insn 4, 0x00734333 +.insn 4, 0x108a3383 +.insn 4, 0x110a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0163f3b3 +.insn 4, 0x00734333 +.insn 4, 0x118a3383 +.insn 4, 0x120a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x128a3e03 +.insn 4, 0x130a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x016e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0173f3b3 +.insn 4, 0x00734333 +.insn 4, 0x138a3383 +.insn 4, 0x140a3e03 +.insn 4, 0x015e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x148a3e03 +.insn 4, 0x150a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x016e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x158a3e03 +.insn 4, 0x160a3e83 +.insn 4, 0x015efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x168a3e83 +.insn 4, 0x170a3f03 +.insn 4, 0x015f7f33 +.insn 4, 0x01eeceb3 +.insn 4, 0x01de4eb3 +.insn 4, 0x016efeb3 +.insn 4, 0x01de4e33 +.insn 4, 0x01c3ce33 +.insn 4, 0x017e7e33 +.insn 4, 0x01c3c3b3 +.insn 4, 0x007343b3 +.insn 4, 0x0183f3b3 +.insn 4, 0x00734333 +.insn 4, 0x0062c333 +.insn 4, 0x01937333 +.insn 4, 0x0062c2b3 +.insn 4, 0x1e0a3f83 +.insn 4, 0x01fd4fb3 +.insn 4, 0x01f2f2b3 +.insn 4, 0x0042d313 +.insn 4, 0x0062c2b3 +.insn 4, 0x0392d313 +.insn 4, 0x00137313 +.insn 2, 0x0306 +.insn 4, 0x0065c5b3 +.insn 4, 0x0332d313 +.insn 4, 0x02137313 +.insn 2, 0x0312 +.insn 4, 0x0065c5b3 +.insn 4, 0x03b2d313 +.insn 4, 0x00137313 +.insn 2, 0x033e +.insn 4, 0x0065c5b3 +.insn 4, 0x0282d313 +.insn 4, 0x00137313 +.insn 2, 0x030a +.insn 4, 0x0065c5b3 +.insn 4, 0x1f0a3303 +.insn 4, 0x00537333 +.insn 4, 0x02335313 +.insn 4, 0x0065c5b3 +.insn 4, 0x1f8a3303 +.insn 4, 0x00537333 +.insn 4, 0x01d35313 +.insn 4, 0x0065c5b3 +.insn 4, 0x02a2d313 +.insn 4, 0x00137313 +.insn 2, 0x0342 +.insn 4, 0x0065c5b3 +.insn 4, 0x200a3303 +.insn 4, 0x00537333 +.insn 4, 0x01435313 +.insn 4, 0x0065c5b3 +.insn 4, 0x208a3303 +.insn 4, 0x00537333 +.insn 4, 0x00f35313 +.insn 4, 0x0065c5b3 +.insn 4, 0x0212d313 +.insn 4, 0x00137313 +.insn 2, 0x035a +.insn 4, 0x0065c5b3 +.insn 4, 0x210a3303 +.insn 4, 0x00537333 +.insn 4, 0x00835313 +.insn 4, 0x0065c5b3 +.insn 4, 0x218a3303 +.insn 4, 0x00537333 +.insn 4, 0x00335313 +.insn 4, 0x0065c5b3 +.insn 4, 0x220a3303 +.insn 4, 0x00537333 +.insn 4, 0x0065c5b3 +.insn 4, 0x0112d313 +.insn 4, 0x10137313 +.insn 2, 0x0356 +.insn 4, 0x0065c5b3 +.insn 4, 0x0012f313 +.insn 2, 0x0316 +.insn 4, 0x0065c5b3 +.insn 4, 0x228a3303 +.insn 4, 0x00537333 +.insn 2, 0x0326 +.insn 4, 0x0065c5b3 +.insn 4, 0x0012d313 +.insn 4, 0x10137313 +.insn 2, 0x0346 +.insn 4, 0x0065c5b3 +.insn 4, 0x0032d313 +.insn 4, 0x00137313 +.insn 2, 0x036e +.insn 4, 0x0065c5b3 +.insn 2, 0x82ae +.insn 2, 0x85b2 +.insn 2, 0x8616 +.insn 2, 0x96be +.insn 2, 0x177d +bnez a4, 223b +.insn 2, 0x82ae +.insn 2, 0x85b2 +.insn 2, 0x8616 +.insn 2, 0x187d +bnez a6, 218b +.insn 4, 0x02059293 +.insn 4, 0x00c2c2b3 +.insn 4, 0x0002f393 +.insn 4, 0x0182de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0382de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0102de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0302de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0082de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0282de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e6a +.insn 4, 0x01c3c3b3 +.insn 2, 0x8e16 +.insn 4, 0x001e7e13 +.insn 2, 0x1e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0202de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0192de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0392de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0112de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0312de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0092de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x0292de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0012de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0212de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0122de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0322de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02a2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0022de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0222de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e22 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0132de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0332de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02b2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0032de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0232de13 +.insn 4, 0x001e7e13 +.insn 2, 0x1e02 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e7a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0142de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e76 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0342de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e72 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02c2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e6a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0042de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e66 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0242de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e62 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e5a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0152de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e56 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0352de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e52 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02d2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e4a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0052de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e46 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0252de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e42 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e3a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0162de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e36 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0362de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e32 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02e2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e2a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0062de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e26 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0262de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e22 +.insn 4, 0x01c3c3b3 +.insn 4, 0x01f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1e +.insn 4, 0x01c3c3b3 +.insn 4, 0x03f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e1a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0172de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e16 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0372de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e12 +.insn 4, 0x01c3c3b3 +.insn 4, 0x00f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0e +.insn 4, 0x01c3c3b3 +.insn 4, 0x02f2de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e0a +.insn 4, 0x01c3c3b3 +.insn 4, 0x0072de13 +.insn 4, 0x001e7e13 +.insn 2, 0x0e06 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0272de13 +.insn 4, 0x001e7e13 +.insn 4, 0x01c3c3b3 +.insn 4, 0x0383d313 +.insn 4, 0x026a0823 +.insn 4, 0x0303d313 +.insn 4, 0x026a08a3 +.insn 4, 0x0283d313 +.insn 4, 0x026a0923 +.insn 4, 0x0203d313 +.insn 4, 0x026a09a3 +.insn 4, 0x0183d313 +.insn 4, 0x026a0a23 +.insn 4, 0x0103d313 +.insn 4, 0x026a0aa3 +.insn 4, 0x0083d313 +.insn 4, 0x026a0b23 +.insn 4, 0x0003d313 +.insn 4, 0x026a0ba3 +.insn 4, 0x038a3a83 +.insn 4, 0x040a3b03 +.insn 4, 0x048a3b83 +.insn 4, 0x050a3c03 +.insn 4, 0x058a3c83 +.insn 4, 0x060a3d03 +.insn 2, 0x42a1 +bltu s3, t0, 224f +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x00096283 +.insn 4, 0x030a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592023 +.insn 4, 0x00496283 +.insn 4, 0x034a6303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00592223 +.insn 2, 0x0921 +.insn 2, 0x19e1 +j 225f +224: +.insn 4, 0x030a6283 +.insn 4, 0x025a2023 +.insn 4, 0x034a6283 +.insn 4, 0x025a2223 +.insn 4, 0x030a0393 +226: +.insn 4, 0x00094283 +.insn 4, 0x0003c303 +.insn 4, 0x0062c2b3 +.insn 4, 0x00590023 +.insn 2, 0x0905 +.insn 2, 0x0385 +.insn 2, 0x19fd +bnez s3, 226b +225: +bnez s3, 217b +j 216f +215: +216: +22: +.insn 2, 0x8926 +.insn 4, 0x020a6283 +.insn 4, 0x00590023 +.insn 4, 0x0082d393 +.insn 4, 0x007900a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790123 +.insn 4, 0x0182d393 +.insn 4, 0x007901a3 +.insn 4, 0x024a6283 +.insn 4, 0x00590223 +.insn 4, 0x0082d393 +.insn 4, 0x007902a3 +.insn 4, 0x0102d393 +.insn 4, 0x00790323 +.insn 4, 0x0182d393 +.insn 4, 0x007903a3 +.insn 2, 0x8e52 +.insn 4, 0x000e3483 +.insn 4, 0x008e3903 +.insn 4, 0x010e3983 +.insn 4, 0x018e3a03 +.insn 2, 0x4281 +.insn 2, 0x8372 +.insn 4, 0x07600393 +227: +.insn 4, 0x00533023 +.insn 2, 0x0321 +.insn 2, 0x13fd +bnez t2, 227b +.insn 4, 0x3b010113 +.insn 2, 0x8082 +.option pop", + ) +} diff --git a/crates/verified-garbage-asm-x86/assembly/aes_ctr.s b/crates/verified-garbage-asm-x86/assembly/aes_ctr.s index f338b268dde..84477a87d0e 100644 --- a/crates/verified-garbage-asm-x86/assembly/aes_ctr.s +++ b/crates/verified-garbage-asm-x86/assembly/aes_ctr.s @@ -112,6 +112,116 @@ vg_aes_ctr_aesni: ret .p2align 6 +vg_aes_ctr_final_aesni: + lea esp, [esp-64] + mov eax, DWORD PTR [esp+68] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+72] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+76] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+80] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+84] + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+88] + mov DWORD PTR [esp+24], eax + mov eax, esp + add eax, 32 + mov DWORD PTR [esp+28], eax + mov eax, DWORD PTR [esp+28] + mov DWORD PTR [eax], ebx + mov DWORD PTR [eax+4], esi + mov DWORD PTR [eax+8], edi + mov DWORD PTR [eax+12], ebp + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov ebx, DWORD PTR [esp+16] + mov esi, DWORD PTR [esp+20] + shr esi, 4 + mov edi, DWORD PTR [esp+24] + push edi + push esi + push ebx + push edx + push ecx + push eax + call {vg_aes_ctr_aesni} + pop eax + pop eax + pop eax + pop eax + pop eax + pop eax + mov eax, DWORD PTR [esp+20] + and eax, 15 + test eax, eax + je 20f + mov eax, DWORD PTR [esp+28] + mov ecx, 0 + mov DWORD PTR [eax+16], ecx + mov DWORD PTR [eax+20], ecx + mov DWORD PTR [eax+24], ecx + mov DWORD PTR [eax+28], ecx + mov ebx, eax + add ebx, 16 + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov esi, 1 + mov edi, DWORD PTR [esp+24] + push edi + push esi + push ebx + push edx + push ecx + push eax + call {vg_aes_ctr_aesni} + pop eax + pop eax + pop eax + pop eax + pop eax + pop eax + mov ebx, DWORD PTR [esp+28] + add ebx, 16 + mov esi, DWORD PTR [esp+16] + mov ebp, DWORD PTR [esp+20] + mov eax, ebp + and ebp, 15 + sub eax, ebp + add esi, eax +22: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 22b + jmp 21f +20: +21: + mov eax, DWORD PTR [esp+28] + mov ebx, DWORD PTR [eax] + mov esi, DWORD PTR [eax+4] + mov edi, DWORD PTR [eax+8] + mov ebp, DWORD PTR [eax+12] + mov ecx, 0 + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + lea esp, [esp+64] + ret + .p2align 6 + vg_aes_ctr: mov eax, DWORD PTR [esp+24] mov DWORD PTR [eax+2064], ebx @@ -219,3 +329,113 @@ vg_aes_ctr: mov ebp, DWORD PTR [eax+2076] ret .p2align 6 + +vg_aes_ctr_final: + lea esp, [esp-64] + mov eax, DWORD PTR [esp+68] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+72] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+76] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+80] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+84] + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+88] + mov DWORD PTR [esp+24], eax + mov eax, esp + add eax, 32 + mov DWORD PTR [esp+28], eax + mov eax, DWORD PTR [esp+28] + mov DWORD PTR [eax], ebx + mov DWORD PTR [eax+4], esi + mov DWORD PTR [eax+8], edi + mov DWORD PTR [eax+12], ebp + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov ebx, DWORD PTR [esp+16] + mov esi, DWORD PTR [esp+20] + shr esi, 4 + mov edi, DWORD PTR [esp+24] + push edi + push esi + push ebx + push edx + push ecx + push eax + call {vg_aes_ctr} + pop eax + pop eax + pop eax + pop eax + pop eax + pop eax + mov eax, DWORD PTR [esp+20] + and eax, 15 + test eax, eax + je 20f + mov eax, DWORD PTR [esp+28] + mov ecx, 0 + mov DWORD PTR [eax+16], ecx + mov DWORD PTR [eax+20], ecx + mov DWORD PTR [eax+24], ecx + mov DWORD PTR [eax+28], ecx + mov ebx, eax + add ebx, 16 + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov esi, 1 + mov edi, DWORD PTR [esp+24] + push edi + push esi + push ebx + push edx + push ecx + push eax + call {vg_aes_ctr} + pop eax + pop eax + pop eax + pop eax + pop eax + pop eax + mov ebx, DWORD PTR [esp+28] + add ebx, 16 + mov esi, DWORD PTR [esp+16] + mov ebp, DWORD PTR [esp+20] + mov eax, ebp + and ebp, 15 + sub eax, ebp + add esi, eax +22: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 22b + jmp 21f +20: +21: + mov eax, DWORD PTR [esp+28] + mov ebx, DWORD PTR [eax] + mov esi, DWORD PTR [eax+4] + mov edi, DWORD PTR [eax+8] + mov ebp, DWORD PTR [eax+12] + mov ecx, 0 + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + lea esp, [esp+64] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/aes_ofb.s b/crates/verified-garbage-asm-x86/assembly/aes_ofb.s index a919d81bdbf..3d826497ece 100644 --- a/crates/verified-garbage-asm-x86/assembly/aes_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/aes_ofb.s @@ -68,6 +68,101 @@ vg_aes_ofb_aesni: ret .p2align 6 +vg_aes_ofb_final_aesni: + lea esp, [esp-48] + mov eax, DWORD PTR [esp+52] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+56] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+60] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+64] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+68] + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+72] + mov DWORD PTR [esp+24], eax + mov eax, esp + add eax, 32 + mov DWORD PTR [esp+28], eax + mov eax, DWORD PTR [esp+28] + mov DWORD PTR [eax], ebx + mov DWORD PTR [eax+4], esi + mov DWORD PTR [eax+8], edi + mov DWORD PTR [eax+12], ebp + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov ebx, DWORD PTR [esp+16] + mov esi, DWORD PTR [esp+20] + shr esi, 4 + mov edi, DWORD PTR [esp+24] + push edi + push esi + push ebx + push edx + push ecx + push eax + call {vg_aes_ofb_aesni} + pop eax + pop eax + pop eax + pop eax + pop eax + pop eax + mov eax, DWORD PTR [esp+20] + and eax, 15 + test eax, eax + je 20f + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov ebx, DWORD PTR [esp+12] + mov edi, 1 + mov ebp, DWORD PTR [esp+24] + push ebp + push edi + push ebx + push ecx + push eax + call {vg_aes_encrypt_blocks_aesni} + pop eax + pop eax + pop eax + pop eax + pop eax + mov ebx, DWORD PTR [esp+12] + mov esi, DWORD PTR [esp+16] + mov ebp, DWORD PTR [esp+20] + mov eax, ebp + and ebp, 15 + sub eax, ebp + add esi, eax +22: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 22b + jmp 21f +20: +21: + mov eax, DWORD PTR [esp+28] + mov ebx, DWORD PTR [eax] + mov esi, DWORD PTR [eax+4] + mov edi, DWORD PTR [eax+8] + mov ebp, DWORD PTR [eax+12] + mov ecx, 0 + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + lea esp, [esp+48] + ret + .p2align 6 + vg_aes_ofb: mov eax, DWORD PTR [esp+24] mov DWORD PTR [eax+2064], ebx @@ -131,3 +226,98 @@ vg_aes_ofb: mov ebp, DWORD PTR [eax+2076] ret .p2align 6 + +vg_aes_ofb_final: + lea esp, [esp-48] + mov eax, DWORD PTR [esp+52] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+56] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+60] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+64] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+68] + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+72] + mov DWORD PTR [esp+24], eax + mov eax, esp + add eax, 32 + mov DWORD PTR [esp+28], eax + mov eax, DWORD PTR [esp+28] + mov DWORD PTR [eax], ebx + mov DWORD PTR [eax+4], esi + mov DWORD PTR [eax+8], edi + mov DWORD PTR [eax+12], ebp + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov ebx, DWORD PTR [esp+16] + mov esi, DWORD PTR [esp+20] + shr esi, 4 + mov edi, DWORD PTR [esp+24] + push edi + push esi + push ebx + push edx + push ecx + push eax + call {vg_aes_ofb} + pop eax + pop eax + pop eax + pop eax + pop eax + pop eax + mov eax, DWORD PTR [esp+20] + and eax, 15 + test eax, eax + je 20f + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov ebx, DWORD PTR [esp+12] + mov edi, 1 + mov ebp, DWORD PTR [esp+24] + push ebp + push edi + push ebx + push ecx + push eax + call {vg_aes_encrypt_blocks} + pop eax + pop eax + pop eax + pop eax + pop eax + mov ebx, DWORD PTR [esp+12] + mov esi, DWORD PTR [esp+16] + mov ebp, DWORD PTR [esp+20] + mov eax, ebp + and ebp, 15 + sub eax, ebp + add esi, eax +22: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 22b + jmp 21f +20: +21: + mov eax, DWORD PTR [esp+28] + mov ebx, DWORD PTR [eax] + mov esi, DWORD PTR [eax+4] + mov edi, DWORD PTR [eax+8] + mov ebp, DWORD PTR [eax+12] + mov ecx, 0 + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + lea esp, [esp+48] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/blowfish_ofb.s b/crates/verified-garbage-asm-x86/assembly/blowfish_ofb.s index b1b54e9f80b..8395ed8fe76 100644 --- a/crates/verified-garbage-asm-x86/assembly/blowfish_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/blowfish_ofb.s @@ -419,3 +419,441 @@ vg_blowfish_ofb: lea esp, [esp+112] ret .p2align 6 + +vg_blowfish_ofb_final: + lea esp, [esp-112] + mov eax, DWORD PTR [esp+116] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+120] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+124] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+128] + mov DWORD PTR [esp+16], eax + mov eax, esp + add eax, 24 + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [eax+48], ebx + mov DWORD PTR [eax+52], esi + mov DWORD PTR [eax+56], edi + mov DWORD PTR [eax+60], ebp + mov edi, eax + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+72], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+76], eax + mov eax, DWORD PTR [esp+12] + mov DWORD PTR [edi+64], eax + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+68], eax + test eax, eax + je 20f +22: + mov esi, DWORD PTR [edi+64] + mov ebp, DWORD PTR [edi+68] + mov eax, DWORD PTR [edi+72] + mov DWORD PTR [edi+40], eax + mov eax, DWORD PTR [edi+76] + mov DWORD PTR [edi+44], eax + mov ebp, edi + mov ebx, ebp + add ebx, 40 + mov DWORD PTR [ebp+32], ebx + mov ebx, DWORD PTR [ebp+32] + mov eax, DWORD PTR [ebx] + bswap eax + mov DWORD PTR [ebp+16], eax + mov eax, DWORD PTR [ebx+4] + bswap eax + mov DWORD PTR [ebp+20], eax + mov ebx, DWORD PTR [esp+4] + add ebx, 4096 + mov DWORD PTR [ebp+28], ebx +23: + mov ebx, DWORD PTR [ebp+28] + mov ecx, DWORD PTR [ebx] + mov eax, DWORD PTR [ebp+16] + xor eax, ecx + mov DWORD PTR [ebp+16], eax + mov esi, DWORD PTR [ebp+16] + shr esi, 24 + and esi, 255 + mov eax, 255 + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 24 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 16 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edi, 0 + mov ebx, DWORD PTR [esp+4] +24: + cmp esi, 4 + sbb edx, edx + and edx, eax + sub esi, 4 + mov ecx, DWORD PTR [ebx] + and ecx, edx + or edi, ecx + mov ecx, DWORD PTR [ebx+256] + and ecx, edx + ror ecx, 24 + or edi, ecx + mov ecx, DWORD PTR [ebx+512] + and ecx, edx + ror ecx, 16 + or edi, ecx + mov ecx, DWORD PTR [ebx+768] + and ecx, edx + ror ecx, 8 + or edi, ecx + add ebx, 4 + mov ecx, DWORD PTR [esp+4] + sub ecx, ebx + cmp ecx, -256 + jne 24b + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 8 + xor edi, ecx + and edi, edx + xor edi, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 16 + xor edi, ecx + and edi, edx + xor edi, ecx + mov DWORD PTR [ebp+24], edi + mov esi, DWORD PTR [ebp+16] + shr esi, 16 + and esi, 255 + mov eax, 255 + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 24 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 16 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edi, 0 + mov ebx, DWORD PTR [esp+4] +25: + cmp esi, 4 + sbb edx, edx + and edx, eax + sub esi, 4 + mov ecx, DWORD PTR [ebx+1024] + and ecx, edx + or edi, ecx + mov ecx, DWORD PTR [ebx+1280] + and ecx, edx + ror ecx, 24 + or edi, ecx + mov ecx, DWORD PTR [ebx+1536] + and ecx, edx + ror ecx, 16 + or edi, ecx + mov ecx, DWORD PTR [ebx+1792] + and ecx, edx + ror ecx, 8 + or edi, ecx + add ebx, 4 + mov ecx, DWORD PTR [esp+4] + sub ecx, ebx + cmp ecx, -256 + jne 25b + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 8 + xor edi, ecx + and edi, edx + xor edi, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 16 + xor edi, ecx + and edi, edx + xor edi, ecx + mov ecx, DWORD PTR [ebp+24] + add ecx, edi + mov DWORD PTR [ebp+24], ecx + mov esi, DWORD PTR [ebp+16] + shr esi, 8 + and esi, 255 + mov eax, 255 + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 24 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 16 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edi, 0 + mov ebx, DWORD PTR [esp+4] +26: + cmp esi, 4 + sbb edx, edx + and edx, eax + sub esi, 4 + mov ecx, DWORD PTR [ebx+2048] + and ecx, edx + or edi, ecx + mov ecx, DWORD PTR [ebx+2304] + and ecx, edx + ror ecx, 24 + or edi, ecx + mov ecx, DWORD PTR [ebx+2560] + and ecx, edx + ror ecx, 16 + or edi, ecx + mov ecx, DWORD PTR [ebx+2816] + and ecx, edx + ror ecx, 8 + or edi, ecx + add ebx, 4 + mov ecx, DWORD PTR [esp+4] + sub ecx, ebx + cmp ecx, -256 + jne 26b + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 8 + xor edi, ecx + and edi, edx + xor edi, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 16 + xor edi, ecx + and edi, edx + xor edi, ecx + mov ecx, DWORD PTR [ebp+24] + xor ecx, edi + mov DWORD PTR [ebp+24], ecx + mov esi, DWORD PTR [ebp+16] + and esi, 255 + mov eax, 255 + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 24 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, eax + ror ecx, 16 + xor eax, ecx + and eax, edx + xor eax, ecx + mov edi, 0 + mov ebx, DWORD PTR [esp+4] +27: + cmp esi, 4 + sbb edx, edx + and edx, eax + sub esi, 4 + mov ecx, DWORD PTR [ebx+3072] + and ecx, edx + or edi, ecx + mov ecx, DWORD PTR [ebx+3328] + and ecx, edx + ror ecx, 24 + or edi, ecx + mov ecx, DWORD PTR [ebx+3584] + and ecx, edx + ror ecx, 16 + or edi, ecx + mov ecx, DWORD PTR [ebx+3840] + and ecx, edx + ror ecx, 8 + or edi, ecx + add ebx, 4 + mov ecx, DWORD PTR [esp+4] + sub ecx, ebx + cmp ecx, -256 + jne 27b + mov edx, esi + and edx, 1 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 8 + xor edi, ecx + and edi, edx + xor edi, ecx + mov edx, esi + and edx, 2 + cmp edx, 1 + sbb edx, edx + mov ecx, edi + ror ecx, 16 + xor edi, ecx + and edi, edx + xor edi, ecx + mov ecx, DWORD PTR [ebp+24] + add ecx, edi + mov DWORD PTR [ebp+24], ecx + mov eax, DWORD PTR [ebp+20] + xor eax, DWORD PTR [ebp+24] + mov ecx, DWORD PTR [ebp+16] + mov DWORD PTR [ebp+20], ecx + mov DWORD PTR [ebp+16], eax + mov ebx, DWORD PTR [ebp+28] + add ebx, 4 + mov DWORD PTR [ebp+28], ebx + mov ecx, DWORD PTR [esp+4] + sub ecx, ebx + cmp ecx, -4160 + jne 23b + mov ebx, DWORD PTR [ebp+28] + mov ecx, DWORD PTR [ebx] + xor ecx, DWORD PTR [ebp+16] + mov eax, DWORD PTR [ebx+4] + xor eax, DWORD PTR [ebp+20] + mov DWORD PTR [ebp+16], eax + mov DWORD PTR [ebp+20], ecx + mov eax, DWORD PTR [ebp+16] + bswap eax + mov DWORD PTR [ebp+40], eax + mov eax, DWORD PTR [ebp+20] + bswap eax + mov DWORD PTR [ebp+44], eax + mov edi, ebp + mov esi, DWORD PTR [edi+64] + mov ebp, DWORD PTR [edi+68] + cmp ebp, 8 + jb 28f + mov eax, DWORD PTR [edi+40] + mov DWORD PTR [edi+72], eax + mov eax, DWORD PTR [edi+44] + mov DWORD PTR [edi+76], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+40] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+44] + mov DWORD PTR [esi+4], eax + add esi, 8 + sub ebp, 8 + mov DWORD PTR [edi+64], esi + mov DWORD PTR [edi+68], ebp + jmp 29f +28: + mov eax, DWORD PTR [edi+40] + mov DWORD PTR [edi+72], eax + mov eax, DWORD PTR [edi+44] + mov DWORD PTR [edi+76], eax + mov ebx, edi + add ebx, 40 +210: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 210b + mov DWORD PTR [edi+64], esi + mov DWORD PTR [edi+68], ebp +29: + jne 22b + jmp 21f +20: +21: + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [edi+72] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+76] + mov DWORD PTR [esi+4], eax + mov ebx, DWORD PTR [edi+48] + mov esi, DWORD PTR [edi+52] + mov ebp, DWORD PTR [edi+60] + mov edi, DWORD PTR [edi+56] + mov ecx, 0 + mov DWORD PTR [esp+24], ecx + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + lea esp, [esp+112] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/camellia_ctr.s b/crates/verified-garbage-asm-x86/assembly/camellia_ctr.s index 26904e67ea9..edb7f00830d 100644 --- a/crates/verified-garbage-asm-x86/assembly/camellia_ctr.s +++ b/crates/verified-garbage-asm-x86/assembly/camellia_ctr.s @@ -1246,3 +1246,105 @@ vg_camellia_ctr: lea esp, [esp+2756] ret .p2align 6 + +vg_camellia_ctr_final: + lea esp, [esp-60] + mov eax, DWORD PTR [esp+64] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+68] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+72] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+76] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+80] + mov DWORD PTR [esp+20], eax + mov eax, esp + add eax, 28 + mov DWORD PTR [esp+24], eax + mov eax, DWORD PTR [esp+24] + mov DWORD PTR [eax], ebx + mov DWORD PTR [eax+4], esi + mov DWORD PTR [eax+8], edi + mov DWORD PTR [eax+12], ebp + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov ebx, DWORD PTR [esp+16] + mov esi, DWORD PTR [esp+20] + shr esi, 4 + push esi + push ebx + push edx + push ecx + push eax + call {vg_camellia_ctr} + pop eax + pop eax + pop eax + pop eax + pop eax + mov eax, DWORD PTR [esp+20] + and eax, 15 + test eax, eax + je 20f + mov eax, DWORD PTR [esp+24] + mov ecx, 0 + mov DWORD PTR [eax+16], ecx + mov DWORD PTR [eax+20], ecx + mov DWORD PTR [eax+24], ecx + mov DWORD PTR [eax+28], ecx + mov ebx, eax + add ebx, 16 + mov eax, DWORD PTR [esp+4] + mov ecx, DWORD PTR [esp+8] + mov edx, DWORD PTR [esp+12] + mov esi, 1 + push esi + push ebx + push edx + push ecx + push eax + call {vg_camellia_ctr} + pop eax + pop eax + pop eax + pop eax + pop eax + mov ebx, DWORD PTR [esp+24] + add ebx, 16 + mov esi, DWORD PTR [esp+16] + mov ebp, DWORD PTR [esp+20] + mov eax, ebp + and ebp, 15 + sub eax, ebp + add esi, eax +22: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 22b + jmp 21f +20: +21: + mov eax, DWORD PTR [esp+24] + mov ebx, DWORD PTR [eax] + mov esi, DWORD PTR [eax+4] + mov edi, DWORD PTR [eax+8] + mov ebp, DWORD PTR [eax+12] + mov ecx, 0 + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + lea esp, [esp+60] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/camellia_ofb.s b/crates/verified-garbage-asm-x86/assembly/camellia_ofb.s index dec4dbdfa94..7e86f73203e 100644 --- a/crates/verified-garbage-asm-x86/assembly/camellia_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/camellia_ofb.s @@ -1234,3 +1234,1260 @@ vg_camellia_ofb: lea esp, [esp+2756] ret .p2align 6 + +vg_camellia_ofb_final: + lea esp, [esp-2756] + mov eax, DWORD PTR [esp+2760] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+2764] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+2768] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+2772] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+2776] + mov DWORD PTR [esp+20], eax + mov eax, esp + add eax, 28 + mov DWORD PTR [esp+24], eax + mov eax, DWORD PTR [esp+24] + mov DWORD PTR [eax+2688], ebx + mov DWORD PTR [eax+2692], esi + mov DWORD PTR [eax+2696], edi + mov DWORD PTR [eax+2700], ebp + mov edi, eax + mov esi, DWORD PTR [esp+12] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+2712], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+2716], eax + mov eax, DWORD PTR [esi+8] + mov DWORD PTR [edi+2720], eax + mov eax, DWORD PTR [esi+12] + mov DWORD PTR [edi+2724], eax + mov eax, DWORD PTR [esp+8] + cmp eax, 18 + je 20f + mov ecx, DWORD PTR [esp+4] + mov esi, edi + add esi, 416 + mov ebp, 34 +22: + mov eax, DWORD PTR [ecx] + mov DWORD PTR [edi], eax + mov ebx, DWORD PTR [edi] + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 1 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+4], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 2 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+8], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 3 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+12], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 4 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+16], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 5 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+20], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 6 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+24], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 7 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+28], ebx + mov eax, DWORD PTR [ecx+4] + mov DWORD PTR [edi], eax + mov ebx, DWORD PTR [edi] + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+32], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 1 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+36], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 2 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+40], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 3 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+44], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 4 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+48], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 5 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+52], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 6 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+56], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 7 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+60], ebx + add esi, 64 + add ecx, 8 + sub ebp, 1 + jne 22b + jmp 21f +20: + mov ecx, DWORD PTR [esp+4] + mov esi, edi + add esi, 416 + mov ebp, 26 +23: + mov eax, DWORD PTR [ecx] + mov DWORD PTR [edi], eax + mov ebx, DWORD PTR [edi] + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 1 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+4], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 2 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+8], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 3 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+12], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 4 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+16], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 5 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+20], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 6 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+24], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 7 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+28], ebx + mov eax, DWORD PTR [ecx+4] + mov DWORD PTR [edi], eax + mov ebx, DWORD PTR [edi] + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+32], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 1 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+36], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 2 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+40], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 3 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+44], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 4 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+48], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 5 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+52], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 6 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+56], ebx + mov ebx, DWORD PTR [edi] + shr ebx, 7 + and ebx, 16843009 + mov edx, ebx + ror edx, 31 + xor ebx, edx + mov edx, ebx + ror edx, 30 + xor ebx, edx + mov edx, ebx + ror edx, 28 + xor ebx, edx + mov DWORD PTR [esi+60], ebx + add esi, 64 + add ecx, 8 + sub ebp, 1 + jne 23b +21: + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+2704], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [edi+2708], eax + test eax, eax + je 24f +26: + mov esi, DWORD PTR [edi+2704] + mov ebp, DWORD PTR [edi+2708] + mov eax, DWORD PTR [edi+2712] + mov DWORD PTR [edi+288], eax + mov eax, DWORD PTR [edi+2716] + mov DWORD PTR [edi+292], eax + mov eax, DWORD PTR [edi+2720] + mov DWORD PTR [edi+296], eax + mov eax, DWORD PTR [edi+2724] + mov DWORD PTR [edi+300], eax + mov eax, DWORD PTR [esp+8] + mov ecx, edi + mov edx, 336 + push edx + push ecx + push eax + call {vg_camellia_crypt_prepared} + pop eax + pop eax + pop eax + mov esi, DWORD PTR [edi+2704] + mov ebp, DWORD PTR [edi+2708] + cmp ebp, 16 + jb 27f + mov eax, DWORD PTR [edi+288] + mov DWORD PTR [edi+2712], eax + mov eax, DWORD PTR [edi+292] + mov DWORD PTR [edi+2716], eax + mov eax, DWORD PTR [edi+296] + mov DWORD PTR [edi+2720], eax + mov eax, DWORD PTR [edi+300] + mov DWORD PTR [edi+2724], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+288] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+292] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [esi+8] + xor eax, DWORD PTR [edi+296] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [esi+12] + xor eax, DWORD PTR [edi+300] + mov DWORD PTR [esi+12], eax + add esi, 16 + sub ebp, 16 + mov DWORD PTR [edi+2704], esi + mov DWORD PTR [edi+2708], ebp + jmp 28f +27: + mov eax, DWORD PTR [edi+288] + mov DWORD PTR [edi+2712], eax + mov eax, DWORD PTR [edi+292] + mov DWORD PTR [edi+2716], eax + mov eax, DWORD PTR [edi+296] + mov DWORD PTR [edi+2720], eax + mov eax, DWORD PTR [edi+300] + mov DWORD PTR [edi+2724], eax + mov ebx, edi + add ebx, 288 +29: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 29b + mov DWORD PTR [edi+2704], esi + mov DWORD PTR [edi+2708], ebp +28: + jne 26b + jmp 25f +24: +25: + mov esi, DWORD PTR [esp+12] + mov eax, DWORD PTR [edi+2712] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+2716] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [edi+2720] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [edi+2724] + mov DWORD PTR [esi+12], eax + mov ebx, DWORD PTR [edi+2688] + mov esi, DWORD PTR [edi+2692] + mov ebp, DWORD PTR [edi+2700] + mov edi, DWORD PTR [edi+2696] + mov ecx, 0 + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + mov DWORD PTR [esp+112], ecx + mov DWORD PTR [esp+116], ecx + mov DWORD PTR [esp+120], ecx + mov DWORD PTR [esp+124], ecx + mov DWORD PTR [esp+128], ecx + mov DWORD PTR [esp+132], ecx + mov DWORD PTR [esp+136], ecx + mov DWORD PTR [esp+140], ecx + mov DWORD PTR [esp+144], ecx + mov DWORD PTR [esp+148], ecx + mov DWORD PTR [esp+152], ecx + mov DWORD PTR [esp+156], ecx + mov DWORD PTR [esp+160], ecx + mov DWORD PTR [esp+164], ecx + mov DWORD PTR [esp+168], ecx + mov DWORD PTR [esp+172], ecx + mov DWORD PTR [esp+176], ecx + mov DWORD PTR [esp+180], ecx + mov DWORD PTR [esp+184], ecx + mov DWORD PTR [esp+188], ecx + mov DWORD PTR [esp+192], ecx + mov DWORD PTR [esp+196], ecx + mov DWORD PTR [esp+200], ecx + mov DWORD PTR [esp+204], ecx + mov DWORD PTR [esp+208], ecx + mov DWORD PTR [esp+212], ecx + mov DWORD PTR [esp+216], ecx + mov DWORD PTR [esp+220], ecx + mov DWORD PTR [esp+224], ecx + mov DWORD PTR [esp+228], ecx + mov DWORD PTR [esp+232], ecx + mov DWORD PTR [esp+236], ecx + mov DWORD PTR [esp+240], ecx + mov DWORD PTR [esp+244], ecx + mov DWORD PTR [esp+248], ecx + mov DWORD PTR [esp+252], ecx + mov DWORD PTR [esp+256], ecx + mov DWORD PTR [esp+260], ecx + mov DWORD PTR [esp+264], ecx + mov DWORD PTR [esp+268], ecx + mov DWORD PTR [esp+272], ecx + mov DWORD PTR [esp+276], ecx + mov DWORD PTR [esp+280], ecx + mov DWORD PTR [esp+284], ecx + mov DWORD PTR [esp+288], ecx + mov DWORD PTR [esp+292], ecx + mov DWORD PTR [esp+296], ecx + mov DWORD PTR [esp+300], ecx + mov DWORD PTR [esp+304], ecx + mov DWORD PTR [esp+308], ecx + mov DWORD PTR [esp+312], ecx + mov DWORD PTR [esp+316], ecx + mov DWORD PTR [esp+320], ecx + mov DWORD PTR [esp+324], ecx + mov DWORD PTR [esp+328], ecx + mov DWORD PTR [esp+332], ecx + mov DWORD PTR [esp+336], ecx + mov DWORD PTR [esp+340], ecx + mov DWORD PTR [esp+344], ecx + mov DWORD PTR [esp+348], ecx + mov DWORD PTR [esp+352], ecx + mov DWORD PTR [esp+356], ecx + mov DWORD PTR [esp+360], ecx + mov DWORD PTR [esp+364], ecx + mov DWORD PTR [esp+368], ecx + mov DWORD PTR [esp+372], ecx + mov DWORD PTR [esp+376], ecx + mov DWORD PTR [esp+380], ecx + mov DWORD PTR [esp+384], ecx + mov DWORD PTR [esp+388], ecx + mov DWORD PTR [esp+392], ecx + mov DWORD PTR [esp+396], ecx + mov DWORD PTR [esp+400], ecx + mov DWORD PTR [esp+404], ecx + mov DWORD PTR [esp+408], ecx + mov DWORD PTR [esp+412], ecx + mov DWORD PTR [esp+416], ecx + mov DWORD PTR [esp+420], ecx + mov DWORD PTR [esp+424], ecx + mov DWORD PTR [esp+428], ecx + mov DWORD PTR [esp+432], ecx + mov DWORD PTR [esp+436], ecx + mov DWORD PTR [esp+440], ecx + mov DWORD PTR [esp+444], ecx + mov DWORD PTR [esp+448], ecx + mov DWORD PTR [esp+452], ecx + mov DWORD PTR [esp+456], ecx + mov DWORD PTR [esp+460], ecx + mov DWORD PTR [esp+464], ecx + mov DWORD PTR [esp+468], ecx + mov DWORD PTR [esp+472], ecx + mov DWORD PTR [esp+476], ecx + mov DWORD PTR [esp+480], ecx + mov DWORD PTR [esp+484], ecx + mov DWORD PTR [esp+488], ecx + mov DWORD PTR [esp+492], ecx + mov DWORD PTR [esp+496], ecx + mov DWORD PTR [esp+500], ecx + mov DWORD PTR [esp+504], ecx + mov DWORD PTR [esp+508], ecx + mov DWORD PTR [esp+512], ecx + mov DWORD PTR [esp+516], ecx + mov DWORD PTR [esp+520], ecx + mov DWORD PTR [esp+524], ecx + mov DWORD PTR [esp+528], ecx + mov DWORD PTR [esp+532], ecx + mov DWORD PTR [esp+536], ecx + mov DWORD PTR [esp+540], ecx + mov DWORD PTR [esp+544], ecx + mov DWORD PTR [esp+548], ecx + mov DWORD PTR [esp+552], ecx + mov DWORD PTR [esp+556], ecx + mov DWORD PTR [esp+560], ecx + mov DWORD PTR [esp+564], ecx + mov DWORD PTR [esp+568], ecx + mov DWORD PTR [esp+572], ecx + mov DWORD PTR [esp+576], ecx + mov DWORD PTR [esp+580], ecx + mov DWORD PTR [esp+584], ecx + mov DWORD PTR [esp+588], ecx + mov DWORD PTR [esp+592], ecx + mov DWORD PTR [esp+596], ecx + mov DWORD PTR [esp+600], ecx + mov DWORD PTR [esp+604], ecx + mov DWORD PTR [esp+608], ecx + mov DWORD PTR [esp+612], ecx + mov DWORD PTR [esp+616], ecx + mov DWORD PTR [esp+620], ecx + mov DWORD PTR [esp+624], ecx + mov DWORD PTR [esp+628], ecx + mov DWORD PTR [esp+632], ecx + mov DWORD PTR [esp+636], ecx + mov DWORD PTR [esp+640], ecx + mov DWORD PTR [esp+644], ecx + mov DWORD PTR [esp+648], ecx + mov DWORD PTR [esp+652], ecx + mov DWORD PTR [esp+656], ecx + mov DWORD PTR [esp+660], ecx + mov DWORD PTR [esp+664], ecx + mov DWORD PTR [esp+668], ecx + mov DWORD PTR [esp+672], ecx + mov DWORD PTR [esp+676], ecx + mov DWORD PTR [esp+680], ecx + mov DWORD PTR [esp+684], ecx + mov DWORD PTR [esp+688], ecx + mov DWORD PTR [esp+692], ecx + mov DWORD PTR [esp+696], ecx + mov DWORD PTR [esp+700], ecx + mov DWORD PTR [esp+704], ecx + mov DWORD PTR [esp+708], ecx + mov DWORD PTR [esp+712], ecx + mov DWORD PTR [esp+716], ecx + mov DWORD PTR [esp+720], ecx + mov DWORD PTR [esp+724], ecx + mov DWORD PTR [esp+728], ecx + mov DWORD PTR [esp+732], ecx + mov DWORD PTR [esp+736], ecx + mov DWORD PTR [esp+740], ecx + mov DWORD PTR [esp+744], ecx + mov DWORD PTR [esp+748], ecx + mov DWORD PTR [esp+752], ecx + mov DWORD PTR [esp+756], ecx + mov DWORD PTR [esp+760], ecx + mov DWORD PTR [esp+764], ecx + mov DWORD PTR [esp+768], ecx + mov DWORD PTR [esp+772], ecx + mov DWORD PTR [esp+776], ecx + mov DWORD PTR [esp+780], ecx + mov DWORD PTR [esp+784], ecx + mov DWORD PTR [esp+788], ecx + mov DWORD PTR [esp+792], ecx + mov DWORD PTR [esp+796], ecx + mov DWORD PTR [esp+800], ecx + mov DWORD PTR [esp+804], ecx + mov DWORD PTR [esp+808], ecx + mov DWORD PTR [esp+812], ecx + mov DWORD PTR [esp+816], ecx + mov DWORD PTR [esp+820], ecx + mov DWORD PTR [esp+824], ecx + mov DWORD PTR [esp+828], ecx + mov DWORD PTR [esp+832], ecx + mov DWORD PTR [esp+836], ecx + mov DWORD PTR [esp+840], ecx + mov DWORD PTR [esp+844], ecx + mov DWORD PTR [esp+848], ecx + mov DWORD PTR [esp+852], ecx + mov DWORD PTR [esp+856], ecx + mov DWORD PTR [esp+860], ecx + mov DWORD PTR [esp+864], ecx + mov DWORD PTR [esp+868], ecx + mov DWORD PTR [esp+872], ecx + mov DWORD PTR [esp+876], ecx + mov DWORD PTR [esp+880], ecx + mov DWORD PTR [esp+884], ecx + mov DWORD PTR [esp+888], ecx + mov DWORD PTR [esp+892], ecx + mov DWORD PTR [esp+896], ecx + mov DWORD PTR [esp+900], ecx + mov DWORD PTR [esp+904], ecx + mov DWORD PTR [esp+908], ecx + mov DWORD PTR [esp+912], ecx + mov DWORD PTR [esp+916], ecx + mov DWORD PTR [esp+920], ecx + mov DWORD PTR [esp+924], ecx + mov DWORD PTR [esp+928], ecx + mov DWORD PTR [esp+932], ecx + mov DWORD PTR [esp+936], ecx + mov DWORD PTR [esp+940], ecx + mov DWORD PTR [esp+944], ecx + mov DWORD PTR [esp+948], ecx + mov DWORD PTR [esp+952], ecx + mov DWORD PTR [esp+956], ecx + mov DWORD PTR [esp+960], ecx + mov DWORD PTR [esp+964], ecx + mov DWORD PTR [esp+968], ecx + mov DWORD PTR [esp+972], ecx + mov DWORD PTR [esp+976], ecx + mov DWORD PTR [esp+980], ecx + mov DWORD PTR [esp+984], ecx + mov DWORD PTR [esp+988], ecx + mov DWORD PTR [esp+992], ecx + mov DWORD PTR [esp+996], ecx + mov DWORD PTR [esp+1000], ecx + mov DWORD PTR [esp+1004], ecx + mov DWORD PTR [esp+1008], ecx + mov DWORD PTR [esp+1012], ecx + mov DWORD PTR [esp+1016], ecx + mov DWORD PTR [esp+1020], ecx + mov DWORD PTR [esp+1024], ecx + mov DWORD PTR [esp+1028], ecx + mov DWORD PTR [esp+1032], ecx + mov DWORD PTR [esp+1036], ecx + mov DWORD PTR [esp+1040], ecx + mov DWORD PTR [esp+1044], ecx + mov DWORD PTR [esp+1048], ecx + mov DWORD PTR [esp+1052], ecx + mov DWORD PTR [esp+1056], ecx + mov DWORD PTR [esp+1060], ecx + mov DWORD PTR [esp+1064], ecx + mov DWORD PTR [esp+1068], ecx + mov DWORD PTR [esp+1072], ecx + mov DWORD PTR [esp+1076], ecx + mov DWORD PTR [esp+1080], ecx + mov DWORD PTR [esp+1084], ecx + mov DWORD PTR [esp+1088], ecx + mov DWORD PTR [esp+1092], ecx + mov DWORD PTR [esp+1096], ecx + mov DWORD PTR [esp+1100], ecx + mov DWORD PTR [esp+1104], ecx + mov DWORD PTR [esp+1108], ecx + mov DWORD PTR [esp+1112], ecx + mov DWORD PTR [esp+1116], ecx + mov DWORD PTR [esp+1120], ecx + mov DWORD PTR [esp+1124], ecx + mov DWORD PTR [esp+1128], ecx + mov DWORD PTR [esp+1132], ecx + mov DWORD PTR [esp+1136], ecx + mov DWORD PTR [esp+1140], ecx + mov DWORD PTR [esp+1144], ecx + mov DWORD PTR [esp+1148], ecx + mov DWORD PTR [esp+1152], ecx + mov DWORD PTR [esp+1156], ecx + mov DWORD PTR [esp+1160], ecx + mov DWORD PTR [esp+1164], ecx + mov DWORD PTR [esp+1168], ecx + mov DWORD PTR [esp+1172], ecx + mov DWORD PTR [esp+1176], ecx + mov DWORD PTR [esp+1180], ecx + mov DWORD PTR [esp+1184], ecx + mov DWORD PTR [esp+1188], ecx + mov DWORD PTR [esp+1192], ecx + mov DWORD PTR [esp+1196], ecx + mov DWORD PTR [esp+1200], ecx + mov DWORD PTR [esp+1204], ecx + mov DWORD PTR [esp+1208], ecx + mov DWORD PTR [esp+1212], ecx + mov DWORD PTR [esp+1216], ecx + mov DWORD PTR [esp+1220], ecx + mov DWORD PTR [esp+1224], ecx + mov DWORD PTR [esp+1228], ecx + mov DWORD PTR [esp+1232], ecx + mov DWORD PTR [esp+1236], ecx + mov DWORD PTR [esp+1240], ecx + mov DWORD PTR [esp+1244], ecx + mov DWORD PTR [esp+1248], ecx + mov DWORD PTR [esp+1252], ecx + mov DWORD PTR [esp+1256], ecx + mov DWORD PTR [esp+1260], ecx + mov DWORD PTR [esp+1264], ecx + mov DWORD PTR [esp+1268], ecx + mov DWORD PTR [esp+1272], ecx + mov DWORD PTR [esp+1276], ecx + mov DWORD PTR [esp+1280], ecx + mov DWORD PTR [esp+1284], ecx + mov DWORD PTR [esp+1288], ecx + mov DWORD PTR [esp+1292], ecx + mov DWORD PTR [esp+1296], ecx + mov DWORD PTR [esp+1300], ecx + mov DWORD PTR [esp+1304], ecx + mov DWORD PTR [esp+1308], ecx + mov DWORD PTR [esp+1312], ecx + mov DWORD PTR [esp+1316], ecx + mov DWORD PTR [esp+1320], ecx + mov DWORD PTR [esp+1324], ecx + mov DWORD PTR [esp+1328], ecx + mov DWORD PTR [esp+1332], ecx + mov DWORD PTR [esp+1336], ecx + mov DWORD PTR [esp+1340], ecx + mov DWORD PTR [esp+1344], ecx + mov DWORD PTR [esp+1348], ecx + mov DWORD PTR [esp+1352], ecx + mov DWORD PTR [esp+1356], ecx + mov DWORD PTR [esp+1360], ecx + mov DWORD PTR [esp+1364], ecx + mov DWORD PTR [esp+1368], ecx + mov DWORD PTR [esp+1372], ecx + mov DWORD PTR [esp+1376], ecx + mov DWORD PTR [esp+1380], ecx + mov DWORD PTR [esp+1384], ecx + mov DWORD PTR [esp+1388], ecx + mov DWORD PTR [esp+1392], ecx + mov DWORD PTR [esp+1396], ecx + mov DWORD PTR [esp+1400], ecx + mov DWORD PTR [esp+1404], ecx + mov DWORD PTR [esp+1408], ecx + mov DWORD PTR [esp+1412], ecx + mov DWORD PTR [esp+1416], ecx + mov DWORD PTR [esp+1420], ecx + mov DWORD PTR [esp+1424], ecx + mov DWORD PTR [esp+1428], ecx + mov DWORD PTR [esp+1432], ecx + mov DWORD PTR [esp+1436], ecx + mov DWORD PTR [esp+1440], ecx + mov DWORD PTR [esp+1444], ecx + mov DWORD PTR [esp+1448], ecx + mov DWORD PTR [esp+1452], ecx + mov DWORD PTR [esp+1456], ecx + mov DWORD PTR [esp+1460], ecx + mov DWORD PTR [esp+1464], ecx + mov DWORD PTR [esp+1468], ecx + mov DWORD PTR [esp+1472], ecx + mov DWORD PTR [esp+1476], ecx + mov DWORD PTR [esp+1480], ecx + mov DWORD PTR [esp+1484], ecx + mov DWORD PTR [esp+1488], ecx + mov DWORD PTR [esp+1492], ecx + mov DWORD PTR [esp+1496], ecx + mov DWORD PTR [esp+1500], ecx + mov DWORD PTR [esp+1504], ecx + mov DWORD PTR [esp+1508], ecx + mov DWORD PTR [esp+1512], ecx + mov DWORD PTR [esp+1516], ecx + mov DWORD PTR [esp+1520], ecx + mov DWORD PTR [esp+1524], ecx + mov DWORD PTR [esp+1528], ecx + mov DWORD PTR [esp+1532], ecx + mov DWORD PTR [esp+1536], ecx + mov DWORD PTR [esp+1540], ecx + mov DWORD PTR [esp+1544], ecx + mov DWORD PTR [esp+1548], ecx + mov DWORD PTR [esp+1552], ecx + mov DWORD PTR [esp+1556], ecx + mov DWORD PTR [esp+1560], ecx + mov DWORD PTR [esp+1564], ecx + mov DWORD PTR [esp+1568], ecx + mov DWORD PTR [esp+1572], ecx + mov DWORD PTR [esp+1576], ecx + mov DWORD PTR [esp+1580], ecx + mov DWORD PTR [esp+1584], ecx + mov DWORD PTR [esp+1588], ecx + mov DWORD PTR [esp+1592], ecx + mov DWORD PTR [esp+1596], ecx + mov DWORD PTR [esp+1600], ecx + mov DWORD PTR [esp+1604], ecx + mov DWORD PTR [esp+1608], ecx + mov DWORD PTR [esp+1612], ecx + mov DWORD PTR [esp+1616], ecx + mov DWORD PTR [esp+1620], ecx + mov DWORD PTR [esp+1624], ecx + mov DWORD PTR [esp+1628], ecx + mov DWORD PTR [esp+1632], ecx + mov DWORD PTR [esp+1636], ecx + mov DWORD PTR [esp+1640], ecx + mov DWORD PTR [esp+1644], ecx + mov DWORD PTR [esp+1648], ecx + mov DWORD PTR [esp+1652], ecx + mov DWORD PTR [esp+1656], ecx + mov DWORD PTR [esp+1660], ecx + mov DWORD PTR [esp+1664], ecx + mov DWORD PTR [esp+1668], ecx + mov DWORD PTR [esp+1672], ecx + mov DWORD PTR [esp+1676], ecx + mov DWORD PTR [esp+1680], ecx + mov DWORD PTR [esp+1684], ecx + mov DWORD PTR [esp+1688], ecx + mov DWORD PTR [esp+1692], ecx + mov DWORD PTR [esp+1696], ecx + mov DWORD PTR [esp+1700], ecx + mov DWORD PTR [esp+1704], ecx + mov DWORD PTR [esp+1708], ecx + mov DWORD PTR [esp+1712], ecx + mov DWORD PTR [esp+1716], ecx + mov DWORD PTR [esp+1720], ecx + mov DWORD PTR [esp+1724], ecx + mov DWORD PTR [esp+1728], ecx + mov DWORD PTR [esp+1732], ecx + mov DWORD PTR [esp+1736], ecx + mov DWORD PTR [esp+1740], ecx + mov DWORD PTR [esp+1744], ecx + mov DWORD PTR [esp+1748], ecx + mov DWORD PTR [esp+1752], ecx + mov DWORD PTR [esp+1756], ecx + mov DWORD PTR [esp+1760], ecx + mov DWORD PTR [esp+1764], ecx + mov DWORD PTR [esp+1768], ecx + mov DWORD PTR [esp+1772], ecx + mov DWORD PTR [esp+1776], ecx + mov DWORD PTR [esp+1780], ecx + mov DWORD PTR [esp+1784], ecx + mov DWORD PTR [esp+1788], ecx + mov DWORD PTR [esp+1792], ecx + mov DWORD PTR [esp+1796], ecx + mov DWORD PTR [esp+1800], ecx + mov DWORD PTR [esp+1804], ecx + mov DWORD PTR [esp+1808], ecx + mov DWORD PTR [esp+1812], ecx + mov DWORD PTR [esp+1816], ecx + mov DWORD PTR [esp+1820], ecx + mov DWORD PTR [esp+1824], ecx + mov DWORD PTR [esp+1828], ecx + mov DWORD PTR [esp+1832], ecx + mov DWORD PTR [esp+1836], ecx + mov DWORD PTR [esp+1840], ecx + mov DWORD PTR [esp+1844], ecx + mov DWORD PTR [esp+1848], ecx + mov DWORD PTR [esp+1852], ecx + mov DWORD PTR [esp+1856], ecx + mov DWORD PTR [esp+1860], ecx + mov DWORD PTR [esp+1864], ecx + mov DWORD PTR [esp+1868], ecx + mov DWORD PTR [esp+1872], ecx + mov DWORD PTR [esp+1876], ecx + mov DWORD PTR [esp+1880], ecx + mov DWORD PTR [esp+1884], ecx + mov DWORD PTR [esp+1888], ecx + mov DWORD PTR [esp+1892], ecx + mov DWORD PTR [esp+1896], ecx + mov DWORD PTR [esp+1900], ecx + mov DWORD PTR [esp+1904], ecx + mov DWORD PTR [esp+1908], ecx + mov DWORD PTR [esp+1912], ecx + mov DWORD PTR [esp+1916], ecx + mov DWORD PTR [esp+1920], ecx + mov DWORD PTR [esp+1924], ecx + mov DWORD PTR [esp+1928], ecx + mov DWORD PTR [esp+1932], ecx + mov DWORD PTR [esp+1936], ecx + mov DWORD PTR [esp+1940], ecx + mov DWORD PTR [esp+1944], ecx + mov DWORD PTR [esp+1948], ecx + mov DWORD PTR [esp+1952], ecx + mov DWORD PTR [esp+1956], ecx + mov DWORD PTR [esp+1960], ecx + mov DWORD PTR [esp+1964], ecx + mov DWORD PTR [esp+1968], ecx + mov DWORD PTR [esp+1972], ecx + mov DWORD PTR [esp+1976], ecx + mov DWORD PTR [esp+1980], ecx + mov DWORD PTR [esp+1984], ecx + mov DWORD PTR [esp+1988], ecx + mov DWORD PTR [esp+1992], ecx + mov DWORD PTR [esp+1996], ecx + mov DWORD PTR [esp+2000], ecx + mov DWORD PTR [esp+2004], ecx + mov DWORD PTR [esp+2008], ecx + mov DWORD PTR [esp+2012], ecx + mov DWORD PTR [esp+2016], ecx + mov DWORD PTR [esp+2020], ecx + mov DWORD PTR [esp+2024], ecx + mov DWORD PTR [esp+2028], ecx + mov DWORD PTR [esp+2032], ecx + mov DWORD PTR [esp+2036], ecx + mov DWORD PTR [esp+2040], ecx + mov DWORD PTR [esp+2044], ecx + mov DWORD PTR [esp+2048], ecx + mov DWORD PTR [esp+2052], ecx + mov DWORD PTR [esp+2056], ecx + mov DWORD PTR [esp+2060], ecx + mov DWORD PTR [esp+2064], ecx + mov DWORD PTR [esp+2068], ecx + mov DWORD PTR [esp+2072], ecx + mov DWORD PTR [esp+2076], ecx + mov DWORD PTR [esp+2080], ecx + mov DWORD PTR [esp+2084], ecx + mov DWORD PTR [esp+2088], ecx + mov DWORD PTR [esp+2092], ecx + mov DWORD PTR [esp+2096], ecx + mov DWORD PTR [esp+2100], ecx + mov DWORD PTR [esp+2104], ecx + mov DWORD PTR [esp+2108], ecx + mov DWORD PTR [esp+2112], ecx + mov DWORD PTR [esp+2116], ecx + mov DWORD PTR [esp+2120], ecx + mov DWORD PTR [esp+2124], ecx + mov DWORD PTR [esp+2128], ecx + mov DWORD PTR [esp+2132], ecx + mov DWORD PTR [esp+2136], ecx + mov DWORD PTR [esp+2140], ecx + mov DWORD PTR [esp+2144], ecx + mov DWORD PTR [esp+2148], ecx + mov DWORD PTR [esp+2152], ecx + mov DWORD PTR [esp+2156], ecx + mov DWORD PTR [esp+2160], ecx + mov DWORD PTR [esp+2164], ecx + mov DWORD PTR [esp+2168], ecx + mov DWORD PTR [esp+2172], ecx + mov DWORD PTR [esp+2176], ecx + mov DWORD PTR [esp+2180], ecx + mov DWORD PTR [esp+2184], ecx + mov DWORD PTR [esp+2188], ecx + mov DWORD PTR [esp+2192], ecx + mov DWORD PTR [esp+2196], ecx + mov DWORD PTR [esp+2200], ecx + mov DWORD PTR [esp+2204], ecx + mov DWORD PTR [esp+2208], ecx + mov DWORD PTR [esp+2212], ecx + mov DWORD PTR [esp+2216], ecx + mov DWORD PTR [esp+2220], ecx + mov DWORD PTR [esp+2224], ecx + mov DWORD PTR [esp+2228], ecx + mov DWORD PTR [esp+2232], ecx + mov DWORD PTR [esp+2236], ecx + mov DWORD PTR [esp+2240], ecx + mov DWORD PTR [esp+2244], ecx + mov DWORD PTR [esp+2248], ecx + mov DWORD PTR [esp+2252], ecx + mov DWORD PTR [esp+2256], ecx + mov DWORD PTR [esp+2260], ecx + mov DWORD PTR [esp+2264], ecx + mov DWORD PTR [esp+2268], ecx + mov DWORD PTR [esp+2272], ecx + mov DWORD PTR [esp+2276], ecx + mov DWORD PTR [esp+2280], ecx + mov DWORD PTR [esp+2284], ecx + mov DWORD PTR [esp+2288], ecx + mov DWORD PTR [esp+2292], ecx + mov DWORD PTR [esp+2296], ecx + mov DWORD PTR [esp+2300], ecx + mov DWORD PTR [esp+2304], ecx + mov DWORD PTR [esp+2308], ecx + mov DWORD PTR [esp+2312], ecx + mov DWORD PTR [esp+2316], ecx + mov DWORD PTR [esp+2320], ecx + mov DWORD PTR [esp+2324], ecx + mov DWORD PTR [esp+2328], ecx + mov DWORD PTR [esp+2332], ecx + mov DWORD PTR [esp+2336], ecx + mov DWORD PTR [esp+2340], ecx + mov DWORD PTR [esp+2344], ecx + mov DWORD PTR [esp+2348], ecx + mov DWORD PTR [esp+2352], ecx + mov DWORD PTR [esp+2356], ecx + mov DWORD PTR [esp+2360], ecx + mov DWORD PTR [esp+2364], ecx + mov DWORD PTR [esp+2368], ecx + mov DWORD PTR [esp+2372], ecx + mov DWORD PTR [esp+2376], ecx + mov DWORD PTR [esp+2380], ecx + mov DWORD PTR [esp+2384], ecx + mov DWORD PTR [esp+2388], ecx + mov DWORD PTR [esp+2392], ecx + mov DWORD PTR [esp+2396], ecx + mov DWORD PTR [esp+2400], ecx + mov DWORD PTR [esp+2404], ecx + mov DWORD PTR [esp+2408], ecx + mov DWORD PTR [esp+2412], ecx + mov DWORD PTR [esp+2416], ecx + mov DWORD PTR [esp+2420], ecx + mov DWORD PTR [esp+2424], ecx + mov DWORD PTR [esp+2428], ecx + mov DWORD PTR [esp+2432], ecx + mov DWORD PTR [esp+2436], ecx + mov DWORD PTR [esp+2440], ecx + mov DWORD PTR [esp+2444], ecx + mov DWORD PTR [esp+2448], ecx + mov DWORD PTR [esp+2452], ecx + mov DWORD PTR [esp+2456], ecx + mov DWORD PTR [esp+2460], ecx + mov DWORD PTR [esp+2464], ecx + mov DWORD PTR [esp+2468], ecx + mov DWORD PTR [esp+2472], ecx + mov DWORD PTR [esp+2476], ecx + mov DWORD PTR [esp+2480], ecx + mov DWORD PTR [esp+2484], ecx + mov DWORD PTR [esp+2488], ecx + mov DWORD PTR [esp+2492], ecx + mov DWORD PTR [esp+2496], ecx + mov DWORD PTR [esp+2500], ecx + mov DWORD PTR [esp+2504], ecx + mov DWORD PTR [esp+2508], ecx + mov DWORD PTR [esp+2512], ecx + mov DWORD PTR [esp+2516], ecx + mov DWORD PTR [esp+2520], ecx + mov DWORD PTR [esp+2524], ecx + mov DWORD PTR [esp+2528], ecx + mov DWORD PTR [esp+2532], ecx + mov DWORD PTR [esp+2536], ecx + mov DWORD PTR [esp+2540], ecx + mov DWORD PTR [esp+2544], ecx + mov DWORD PTR [esp+2548], ecx + mov DWORD PTR [esp+2552], ecx + mov DWORD PTR [esp+2556], ecx + mov DWORD PTR [esp+2560], ecx + mov DWORD PTR [esp+2564], ecx + mov DWORD PTR [esp+2568], ecx + mov DWORD PTR [esp+2572], ecx + mov DWORD PTR [esp+2576], ecx + mov DWORD PTR [esp+2580], ecx + mov DWORD PTR [esp+2584], ecx + mov DWORD PTR [esp+2588], ecx + mov DWORD PTR [esp+2592], ecx + mov DWORD PTR [esp+2596], ecx + mov DWORD PTR [esp+2600], ecx + mov DWORD PTR [esp+2604], ecx + mov DWORD PTR [esp+2608], ecx + mov DWORD PTR [esp+2612], ecx + mov DWORD PTR [esp+2616], ecx + mov DWORD PTR [esp+2620], ecx + mov DWORD PTR [esp+2624], ecx + mov DWORD PTR [esp+2628], ecx + mov DWORD PTR [esp+2632], ecx + mov DWORD PTR [esp+2636], ecx + mov DWORD PTR [esp+2640], ecx + mov DWORD PTR [esp+2644], ecx + mov DWORD PTR [esp+2648], ecx + mov DWORD PTR [esp+2652], ecx + mov DWORD PTR [esp+2656], ecx + mov DWORD PTR [esp+2660], ecx + mov DWORD PTR [esp+2664], ecx + mov DWORD PTR [esp+2668], ecx + mov DWORD PTR [esp+2672], ecx + mov DWORD PTR [esp+2676], ecx + mov DWORD PTR [esp+2680], ecx + mov DWORD PTR [esp+2684], ecx + mov DWORD PTR [esp+2688], ecx + mov DWORD PTR [esp+2692], ecx + mov DWORD PTR [esp+2696], ecx + mov DWORD PTR [esp+2700], ecx + mov DWORD PTR [esp+2704], ecx + mov DWORD PTR [esp+2708], ecx + mov DWORD PTR [esp+2712], ecx + mov DWORD PTR [esp+2716], ecx + mov DWORD PTR [esp+2720], ecx + mov DWORD PTR [esp+2724], ecx + mov DWORD PTR [esp+2728], ecx + mov DWORD PTR [esp+2732], ecx + mov DWORD PTR [esp+2736], ecx + mov DWORD PTR [esp+2740], ecx + mov DWORD PTR [esp+2744], ecx + mov DWORD PTR [esp+2748], ecx + mov DWORD PTR [esp+2752], ecx + lea esp, [esp+2756] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/cast5_ofb.s b/crates/verified-garbage-asm-x86/assembly/cast5_ofb.s index 4b7ae1f231c..1971255490d 100644 --- a/crates/verified-garbage-asm-x86/assembly/cast5_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/cast5_ofb.s @@ -750,3 +750,772 @@ vg_cast5_ofb: lea esp, [esp+332] ret .p2align 6 + +vg_cast5_ofb_final: + lea esp, [esp-332] + mov eax, DWORD PTR [esp+336] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+340] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+344] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+348] + mov DWORD PTR [esp+16], eax + mov eax, DWORD PTR [esp+352] + mov DWORD PTR [esp+20], eax + mov eax, esp + add eax, 28 + mov DWORD PTR [esp+24], eax + mov eax, DWORD PTR [esp+24] + mov DWORD PTR [eax+264], ebx + mov DWORD PTR [eax+268], esi + mov DWORD PTR [eax+272], edi + mov DWORD PTR [eax+276], ebp + mov edi, eax + mov esi, DWORD PTR [esp+12] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+288], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+292], eax + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+280], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [edi+284], eax + test eax, eax + je 20f +22: + mov esi, DWORD PTR [edi+280] + mov ebp, DWORD PTR [edi+284] + mov eax, DWORD PTR [edi+288] + mov DWORD PTR [edi+256], eax + mov eax, DWORD PTR [edi+292] + mov DWORD PTR [edi+260], eax + mov esi, edi + mov eax, DWORD PTR [esp+4] + mov DWORD PTR [esi+48], eax + mov eax, DWORD PTR [esp+8] + mov DWORD PTR [esi+52], eax + mov eax, esi + add eax, 256 + mov DWORD PTR [esi+56], eax + mov edx, DWORD PTR [esi+56] + mov ebx, DWORD PTR [edx] + bswap ebx + mov ebp, DWORD PTR [edx+4] + bswap ebp + mov edx, DWORD PTR [esi+48] + mov DWORD PTR [esi+64], edx + mov ecx, DWORD PTR [esi+52] + shr ecx, 2 + add ecx, 1 + mov DWORD PTR [esi+68], ecx + mov ecx, DWORD PTR [esi+52] + cmp ecx, 16 +23: + mov edx, DWORD PTR [esi+64] + mov eax, DWORD PTR [edx] + add eax, ebp + mov ecx, DWORD PTR [edx+64] + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 31 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 30 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 28 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 24 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 16 + xor eax, edi + and eax, edx + xor eax, edi + mov ecx, eax + and ecx, 255 + mov edx, eax + shr edx, 8 + and edx, 255 + mov edi, eax + shr edi, 16 + and edi, 255 + shr eax, 24 + movd xmm0, ecx + movd xmm4, edx + punpckldq xmm0, xmm4 + movd xmm4, edi + movd xmm5, eax + punpckldq xmm4, xmm5 + punpcklqdq xmm0, xmm4 + call 2f +2: + mov eax, DWORD PTR [esp] + .byte 0x81, 192 + .long {VG_CAST5_S1234} + pop ecx + mov ecx, eax + mov edx, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + mov eax, 1 + movd xmm3, eax + pshufd xmm3, xmm3, 0 + mov eax, -1 + movd xmm6, eax + pshufd xmm6, xmm6, 0 +24: + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+16] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+32] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+48] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + add ecx, 64 + sub edx, 1 + jne 24b + movdqu XMMWORD PTR [esi], xmm1 + mov eax, DWORD PTR [esi+12] + xor eax, DWORD PTR [esi+8] + sub eax, DWORD PTR [esi+4] + add eax, DWORD PTR [esi] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + mov edx, DWORD PTR [esi+64] + add edx, 4 + mov DWORD PTR [esi+64], edx + mov edx, DWORD PTR [esi+64] + mov eax, DWORD PTR [edx] + xor eax, ebp + mov ecx, DWORD PTR [edx+64] + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 31 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 30 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 28 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 24 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 16 + xor eax, edi + and eax, edx + xor eax, edi + mov ecx, eax + and ecx, 255 + mov edx, eax + shr edx, 8 + and edx, 255 + mov edi, eax + shr edi, 16 + and edi, 255 + shr eax, 24 + movd xmm0, ecx + movd xmm4, edx + punpckldq xmm0, xmm4 + movd xmm4, edi + movd xmm5, eax + punpckldq xmm4, xmm5 + punpcklqdq xmm0, xmm4 + call 2f +2: + mov eax, DWORD PTR [esp] + .byte 0x81, 192 + .long {VG_CAST5_S1234} + pop ecx + mov ecx, eax + mov edx, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + mov eax, 1 + movd xmm3, eax + pshufd xmm3, xmm3, 0 + mov eax, -1 + movd xmm6, eax + pshufd xmm6, xmm6, 0 +25: + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+16] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+32] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+48] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + add ecx, 64 + sub edx, 1 + jne 25b + movdqu XMMWORD PTR [esi], xmm1 + mov eax, DWORD PTR [esi+12] + sub eax, DWORD PTR [esi+8] + add eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [esi] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + mov edx, DWORD PTR [esi+64] + add edx, 4 + mov DWORD PTR [esi+64], edx + mov edx, DWORD PTR [esi+64] + mov eax, DWORD PTR [edx] + sub eax, ebp + mov ecx, DWORD PTR [edx+64] + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 31 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 30 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 28 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 24 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 16 + xor eax, edi + and eax, edx + xor eax, edi + mov ecx, eax + and ecx, 255 + mov edx, eax + shr edx, 8 + and edx, 255 + mov edi, eax + shr edi, 16 + and edi, 255 + shr eax, 24 + movd xmm0, ecx + movd xmm4, edx + punpckldq xmm0, xmm4 + movd xmm4, edi + movd xmm5, eax + punpckldq xmm4, xmm5 + punpcklqdq xmm0, xmm4 + call 2f +2: + mov eax, DWORD PTR [esp] + .byte 0x81, 192 + .long {VG_CAST5_S1234} + pop ecx + mov ecx, eax + mov edx, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + mov eax, 1 + movd xmm3, eax + pshufd xmm3, xmm3, 0 + mov eax, -1 + movd xmm6, eax + pshufd xmm6, xmm6, 0 +26: + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+16] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+32] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+48] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + add ecx, 64 + sub edx, 1 + jne 26b + movdqu XMMWORD PTR [esi], xmm1 + mov eax, DWORD PTR [esi+12] + add eax, DWORD PTR [esi+8] + xor eax, DWORD PTR [esi+4] + sub eax, DWORD PTR [esi] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + mov edx, DWORD PTR [esi+64] + add edx, 4 + mov DWORD PTR [esi+64], edx + mov edx, DWORD PTR [esi+68] + sub edx, 1 + mov DWORD PTR [esi+68], edx + jne 23b + mov ecx, DWORD PTR [esi+52] + cmp ecx, 16 + je 27f + jmp 28f +27: + mov edx, DWORD PTR [esi+64] + mov eax, DWORD PTR [edx] + add eax, ebp + mov ecx, DWORD PTR [edx+64] + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 31 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 30 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 28 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 24 + xor eax, edi + and eax, edx + xor eax, edi + shr ecx, 1 + mov edx, ecx + and edx, 1 + sub edx, 1 + mov edi, eax + ror edi, 16 + xor eax, edi + and eax, edx + xor eax, edi + mov ecx, eax + and ecx, 255 + mov edx, eax + shr edx, 8 + and edx, 255 + mov edi, eax + shr edi, 16 + and edi, 255 + shr eax, 24 + movd xmm0, ecx + movd xmm4, edx + punpckldq xmm0, xmm4 + movd xmm4, edi + movd xmm5, eax + punpckldq xmm4, xmm5 + punpcklqdq xmm0, xmm4 + call 2f +2: + mov eax, DWORD PTR [esp] + .byte 0x81, 192 + .long {VG_CAST5_S1234} + pop ecx + mov ecx, eax + mov edx, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + mov eax, 1 + movd xmm3, eax + pshufd xmm3, xmm3, 0 + mov eax, -1 + movd xmm6, eax + pshufd xmm6, xmm6, 0 +29: + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+16] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+32] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + movdqa xmm4, xmm0 + pxor xmm4, xmm2 + paddd xmm4, xmm6 + psrld xmm4, 8 + movdqa xmm7, xmm4 + pslld xmm7, 8 + por xmm4, xmm7 + movdqu xmm5, XMMWORD PTR [ecx+48] + pand xmm5, xmm4 + por xmm1, xmm5 + paddd xmm2, xmm3 + add ecx, 64 + sub edx, 1 + jne 29b + movdqu XMMWORD PTR [esi], xmm1 + mov eax, DWORD PTR [esi+12] + xor eax, DWORD PTR [esi+8] + sub eax, DWORD PTR [esi+4] + add eax, DWORD PTR [esi] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + mov edx, DWORD PTR [esi+64] + add edx, 4 + mov DWORD PTR [esi+64], edx +28: + mov edx, DWORD PTR [esi+56] + mov eax, DWORD PTR [esi+280] + mov ecx, DWORD PTR [esi+284] + bswap ebp + mov DWORD PTR [edx], ebp + bswap ebx + mov DWORD PTR [edx+4], ebx + mov DWORD PTR [esi+280], eax + mov DWORD PTR [esi+284], ecx + mov edi, esi + mov esi, DWORD PTR [edi+280] + mov ebp, DWORD PTR [edi+284] + cmp ebp, 8 + jb 210f + mov eax, DWORD PTR [edi+256] + mov DWORD PTR [edi+288], eax + mov eax, DWORD PTR [edi+260] + mov DWORD PTR [edi+292], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+256] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+260] + mov DWORD PTR [esi+4], eax + add esi, 8 + sub ebp, 8 + mov DWORD PTR [edi+280], esi + mov DWORD PTR [edi+284], ebp + jmp 211f +210: + mov eax, DWORD PTR [edi+256] + mov DWORD PTR [edi+288], eax + mov eax, DWORD PTR [edi+260] + mov DWORD PTR [edi+292], eax + mov ebx, edi + add ebx, 256 +212: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 212b + mov DWORD PTR [edi+280], esi + mov DWORD PTR [edi+284], ebp +211: + jne 22b + jmp 21f +20: +21: + mov esi, DWORD PTR [esp+12] + mov eax, DWORD PTR [edi+288] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+292] + mov DWORD PTR [esi+4], eax + mov ebx, DWORD PTR [edi+264] + mov esi, DWORD PTR [edi+268] + mov ebp, DWORD PTR [edi+276] + mov edi, DWORD PTR [edi+272] + mov ecx, 0 + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + mov DWORD PTR [esp+112], ecx + mov DWORD PTR [esp+116], ecx + mov DWORD PTR [esp+120], ecx + mov DWORD PTR [esp+124], ecx + mov DWORD PTR [esp+128], ecx + mov DWORD PTR [esp+132], ecx + mov DWORD PTR [esp+136], ecx + mov DWORD PTR [esp+140], ecx + mov DWORD PTR [esp+144], ecx + mov DWORD PTR [esp+148], ecx + mov DWORD PTR [esp+152], ecx + mov DWORD PTR [esp+156], ecx + mov DWORD PTR [esp+160], ecx + mov DWORD PTR [esp+164], ecx + mov DWORD PTR [esp+168], ecx + mov DWORD PTR [esp+172], ecx + mov DWORD PTR [esp+176], ecx + mov DWORD PTR [esp+180], ecx + mov DWORD PTR [esp+184], ecx + mov DWORD PTR [esp+188], ecx + mov DWORD PTR [esp+192], ecx + mov DWORD PTR [esp+196], ecx + mov DWORD PTR [esp+200], ecx + mov DWORD PTR [esp+204], ecx + mov DWORD PTR [esp+208], ecx + mov DWORD PTR [esp+212], ecx + mov DWORD PTR [esp+216], ecx + mov DWORD PTR [esp+220], ecx + mov DWORD PTR [esp+224], ecx + mov DWORD PTR [esp+228], ecx + mov DWORD PTR [esp+232], ecx + mov DWORD PTR [esp+236], ecx + mov DWORD PTR [esp+240], ecx + mov DWORD PTR [esp+244], ecx + mov DWORD PTR [esp+248], ecx + mov DWORD PTR [esp+252], ecx + mov DWORD PTR [esp+256], ecx + mov DWORD PTR [esp+260], ecx + mov DWORD PTR [esp+264], ecx + mov DWORD PTR [esp+268], ecx + mov DWORD PTR [esp+272], ecx + mov DWORD PTR [esp+276], ecx + mov DWORD PTR [esp+280], ecx + mov DWORD PTR [esp+284], ecx + mov DWORD PTR [esp+288], ecx + mov DWORD PTR [esp+292], ecx + mov DWORD PTR [esp+296], ecx + mov DWORD PTR [esp+300], ecx + mov DWORD PTR [esp+304], ecx + mov DWORD PTR [esp+308], ecx + mov DWORD PTR [esp+312], ecx + mov DWORD PTR [esp+316], ecx + mov DWORD PTR [esp+320], ecx + mov DWORD PTR [esp+324], ecx + mov DWORD PTR [esp+328], ecx + lea esp, [esp+332] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/idea_ofb.s b/crates/verified-garbage-asm-x86/assembly/idea_ofb.s index a7b5e02c175..132e3cc3277 100644 --- a/crates/verified-garbage-asm-x86/assembly/idea_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/idea_ofb.s @@ -986,3 +986,1008 @@ vg_idea_ofb: lea esp, [esp+208] ret .p2align 6 + +vg_idea_ofb_final: + lea esp, [esp-208] + mov eax, DWORD PTR [esp+212] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+216] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+220] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+224] + mov DWORD PTR [esp+16], eax + mov eax, esp + add eax, 24 + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [eax+140], ebx + mov DWORD PTR [eax+144], esi + mov DWORD PTR [eax+148], edi + mov DWORD PTR [eax+152], ebp + mov edi, eax + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+164], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+168], eax + mov esi, edi + mov edx, DWORD PTR [esp+4] + mov eax, DWORD PTR [edx] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edx+4] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [edx+8] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [edx+12] + mov DWORD PTR [esi+12], eax + mov eax, DWORD PTR [edx+16] + mov DWORD PTR [esi+16], eax + mov eax, DWORD PTR [edx+20] + mov DWORD PTR [esi+20], eax + mov eax, DWORD PTR [edx+24] + mov DWORD PTR [esi+24], eax + mov eax, DWORD PTR [edx+28] + mov DWORD PTR [esi+28], eax + mov eax, DWORD PTR [edx+32] + mov DWORD PTR [esi+32], eax + mov eax, DWORD PTR [edx+36] + mov DWORD PTR [esi+36], eax + mov eax, DWORD PTR [edx+40] + mov DWORD PTR [esi+40], eax + mov eax, DWORD PTR [edx+44] + mov DWORD PTR [esi+44], eax + mov eax, DWORD PTR [edx+48] + mov DWORD PTR [esi+48], eax + mov eax, DWORD PTR [edx+52] + mov DWORD PTR [esi+52], eax + mov eax, DWORD PTR [edx+56] + mov DWORD PTR [esi+56], eax + mov eax, DWORD PTR [edx+60] + mov DWORD PTR [esi+60], eax + mov eax, DWORD PTR [edx+64] + mov DWORD PTR [esi+64], eax + mov eax, DWORD PTR [edx+68] + mov DWORD PTR [esi+68], eax + mov eax, DWORD PTR [edx+72] + mov DWORD PTR [esi+72], eax + mov eax, DWORD PTR [edx+76] + mov DWORD PTR [esi+76], eax + mov eax, DWORD PTR [edx+80] + mov DWORD PTR [esi+80], eax + mov eax, DWORD PTR [edx+84] + mov DWORD PTR [esi+84], eax + mov eax, DWORD PTR [edx+88] + mov DWORD PTR [esi+88], eax + mov eax, DWORD PTR [edx+92] + mov DWORD PTR [esi+92], eax + mov eax, DWORD PTR [edx+96] + mov DWORD PTR [esi+96], eax + mov eax, DWORD PTR [edx+100] + mov DWORD PTR [esi+100], eax + mov eax, DWORD PTR [esp+12] + mov DWORD PTR [edi+156], eax + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+160], eax + test eax, eax + je 20f +22: + mov esi, DWORD PTR [edi+156] + mov ebp, DWORD PTR [edi+160] + mov eax, DWORD PTR [edi+164] + mov DWORD PTR [edi+132], eax + mov eax, DWORD PTR [edi+168] + mov DWORD PTR [edi+136], eax + mov esi, edi + mov eax, edi + add eax, 132 + mov DWORD PTR [esi+108], eax + mov eax, DWORD PTR [esi+108] + mov ebx, DWORD PTR [eax] + bswap ebx + mov ecx, ebx + shr ebx, 16 + and ecx, 65535 + mov edi, DWORD PTR [eax+4] + bswap edi + mov ebp, edi + shr edi, 16 + and ebp, 65535 + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+6] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add ecx, DWORD PTR [esi+2] + and ecx, 65535 + add edi, DWORD PTR [esi+4] + and edi, 65535 + mov eax, ebx + xor eax, edi + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+8] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, ecx + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+10] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor edi, edx + xor ecx, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+12] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+18] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add edi, DWORD PTR [esi+14] + and edi, 65535 + add ecx, DWORD PTR [esi+16] + and ecx, 65535 + mov eax, ebx + xor eax, ecx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+20] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, edi + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+22] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor ecx, edx + xor edi, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+24] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+30] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add ecx, DWORD PTR [esi+26] + and ecx, 65535 + add edi, DWORD PTR [esi+28] + and edi, 65535 + mov eax, ebx + xor eax, edi + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+32] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, ecx + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+34] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor edi, edx + xor ecx, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+36] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+42] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add edi, DWORD PTR [esi+38] + and edi, 65535 + add ecx, DWORD PTR [esi+40] + and ecx, 65535 + mov eax, ebx + xor eax, ecx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+44] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, edi + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+46] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor ecx, edx + xor edi, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+48] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+54] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add ecx, DWORD PTR [esi+50] + and ecx, 65535 + add edi, DWORD PTR [esi+52] + and edi, 65535 + mov eax, ebx + xor eax, edi + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+56] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, ecx + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+58] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor edi, edx + xor ecx, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+60] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+66] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add edi, DWORD PTR [esi+62] + and edi, 65535 + add ecx, DWORD PTR [esi+64] + and ecx, 65535 + mov eax, ebx + xor eax, ecx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+68] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, edi + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+70] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor ecx, edx + xor edi, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+72] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+78] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add ecx, DWORD PTR [esi+74] + and ecx, 65535 + add edi, DWORD PTR [esi+76] + and edi, 65535 + mov eax, ebx + xor eax, edi + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+80] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, ecx + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+82] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor edi, edx + xor ecx, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+84] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+90] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add edi, DWORD PTR [esi+86] + and edi, 65535 + add ecx, DWORD PTR [esi+88] + and ecx, 65535 + mov eax, ebx + xor eax, ecx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+92] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov DWORD PTR [esi+104], edx + mov eax, edi + xor eax, ebp + add eax, edx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+94] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov eax, DWORD PTR [esi+104] + add eax, edx + and eax, 65535 + xor ebx, edx + xor ecx, edx + xor edi, eax + xor ebp, eax + mov eax, ebx + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+96] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebx, edx + mov eax, ebp + sub eax, 1 + and eax, 65535 + add eax, 1 + mov edx, DWORD PTR [esi+102] + sub edx, 1 + and edx, 65535 + add edx, 1 + mul edx + sub eax, 1 + mov edx, eax + and edx, 65535 + add edx, 1 + shr eax, 16 + sub edx, eax + mov eax, edx + shr eax, 31 + add edx, eax + and edx, 65535 + mov ebp, edx + add edi, DWORD PTR [esi+98] + and edi, 65535 + add ecx, DWORD PTR [esi+100] + and ecx, 65535 + ror ebx, 16 + or ebx, edi + bswap ebx + mov DWORD PTR [esi+132], ebx + ror ecx, 16 + or ecx, ebp + bswap ecx + mov DWORD PTR [esi+136], ecx + mov edi, esi + mov esi, DWORD PTR [edi+156] + mov ebp, DWORD PTR [edi+160] + cmp ebp, 8 + jb 23f + mov eax, DWORD PTR [edi+132] + mov DWORD PTR [edi+164], eax + mov eax, DWORD PTR [edi+136] + mov DWORD PTR [edi+168], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+132] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+136] + mov DWORD PTR [esi+4], eax + add esi, 8 + sub ebp, 8 + mov DWORD PTR [edi+156], esi + mov DWORD PTR [edi+160], ebp + jmp 24f +23: + mov eax, DWORD PTR [edi+132] + mov DWORD PTR [edi+164], eax + mov eax, DWORD PTR [edi+136] + mov DWORD PTR [edi+168], eax + mov ebx, edi + add ebx, 132 +25: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 25b + mov DWORD PTR [edi+156], esi + mov DWORD PTR [edi+160], ebp +24: + jne 22b + jmp 21f +20: +21: + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [edi+164] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+168] + mov DWORD PTR [esi+4], eax + mov ebx, DWORD PTR [edi+140] + mov esi, DWORD PTR [edi+144] + mov ebp, DWORD PTR [edi+152] + mov edi, DWORD PTR [edi+148] + mov ecx, 0 + mov DWORD PTR [esp+24], ecx + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + mov DWORD PTR [esp+112], ecx + mov DWORD PTR [esp+116], ecx + mov DWORD PTR [esp+120], ecx + mov DWORD PTR [esp+124], ecx + mov DWORD PTR [esp+128], ecx + mov DWORD PTR [esp+132], ecx + mov DWORD PTR [esp+136], ecx + mov DWORD PTR [esp+140], ecx + mov DWORD PTR [esp+144], ecx + mov DWORD PTR [esp+148], ecx + mov DWORD PTR [esp+152], ecx + mov DWORD PTR [esp+156], ecx + mov DWORD PTR [esp+160], ecx + mov DWORD PTR [esp+164], ecx + mov DWORD PTR [esp+168], ecx + mov DWORD PTR [esp+172], ecx + mov DWORD PTR [esp+176], ecx + mov DWORD PTR [esp+180], ecx + mov DWORD PTR [esp+184], ecx + mov DWORD PTR [esp+188], ecx + mov DWORD PTR [esp+192], ecx + mov DWORD PTR [esp+196], ecx + mov DWORD PTR [esp+200], ecx + mov DWORD PTR [esp+204], ecx + lea esp, [esp+208] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/seed_ofb.s b/crates/verified-garbage-asm-x86/assembly/seed_ofb.s index 9b65bbd288b..73d7d3a91e0 100644 --- a/crates/verified-garbage-asm-x86/assembly/seed_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/seed_ofb.s @@ -400,3 +400,426 @@ vg_seed_ofb: lea esp, [esp+1168] ret .p2align 6 + +vg_seed_ofb_final: + lea esp, [esp-1168] + mov eax, DWORD PTR [esp+1172] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+1176] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+1180] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+1184] + mov DWORD PTR [esp+16], eax + mov eax, esp + add eax, 24 + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [eax+1104], ebx + mov DWORD PTR [eax+1108], esi + mov DWORD PTR [eax+1112], edi + mov DWORD PTR [eax+1116], ebp + mov edi, eax + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+1128], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+1132], eax + mov eax, DWORD PTR [esi+8] + mov DWORD PTR [edi+1136], eax + mov eax, DWORD PTR [esi+12] + mov DWORD PTR [edi+1140], eax + mov eax, DWORD PTR [esp+12] + mov DWORD PTR [edi+1120], eax + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+1124], eax + test eax, eax + je 20f +22: + mov esi, DWORD PTR [edi+1120] + mov ebp, DWORD PTR [edi+1124] + mov eax, DWORD PTR [edi+1128] + mov DWORD PTR [edi+1088], eax + mov eax, DWORD PTR [edi+1132] + mov DWORD PTR [edi+1092], eax + mov eax, DWORD PTR [edi+1136] + mov DWORD PTR [edi+1096], eax + mov eax, DWORD PTR [edi+1140] + mov DWORD PTR [edi+1100], eax + mov esi, DWORD PTR [edi+1120] + mov ebp, DWORD PTR [edi+1124] + mov eax, DWORD PTR [esp+4] + mov ecx, edi + add ecx, 1088 + mov edx, 1 + push edi + push edx + push ecx + push eax + call {vg_seed_encrypt_blocks} + pop eax + pop eax + pop eax + pop eax + mov edi, DWORD PTR [esp+20] + mov DWORD PTR [edi+1120], esi + mov DWORD PTR [edi+1124], ebp + mov esi, DWORD PTR [edi+1120] + mov ebp, DWORD PTR [edi+1124] + cmp ebp, 16 + jb 23f + mov eax, DWORD PTR [edi+1088] + mov DWORD PTR [edi+1128], eax + mov eax, DWORD PTR [edi+1092] + mov DWORD PTR [edi+1132], eax + mov eax, DWORD PTR [edi+1096] + mov DWORD PTR [edi+1136], eax + mov eax, DWORD PTR [edi+1100] + mov DWORD PTR [edi+1140], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+1088] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+1092] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [esi+8] + xor eax, DWORD PTR [edi+1096] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [esi+12] + xor eax, DWORD PTR [edi+1100] + mov DWORD PTR [esi+12], eax + add esi, 16 + sub ebp, 16 + mov DWORD PTR [edi+1120], esi + mov DWORD PTR [edi+1124], ebp + jmp 24f +23: + mov eax, DWORD PTR [edi+1088] + mov DWORD PTR [edi+1128], eax + mov eax, DWORD PTR [edi+1092] + mov DWORD PTR [edi+1132], eax + mov eax, DWORD PTR [edi+1096] + mov DWORD PTR [edi+1136], eax + mov eax, DWORD PTR [edi+1100] + mov DWORD PTR [edi+1140], eax + mov ebx, edi + add ebx, 1088 +25: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 25b + mov DWORD PTR [edi+1120], esi + mov DWORD PTR [edi+1124], ebp +24: + jne 22b + jmp 21f +20: +21: + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [edi+1128] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+1132] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [edi+1136] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [edi+1140] + mov DWORD PTR [esi+12], eax + mov ebx, DWORD PTR [edi+1104] + mov esi, DWORD PTR [edi+1108] + mov ebp, DWORD PTR [edi+1116] + mov edi, DWORD PTR [edi+1112] + mov ecx, 0 + mov DWORD PTR [esp+24], ecx + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + mov DWORD PTR [esp+112], ecx + mov DWORD PTR [esp+116], ecx + mov DWORD PTR [esp+120], ecx + mov DWORD PTR [esp+124], ecx + mov DWORD PTR [esp+128], ecx + mov DWORD PTR [esp+132], ecx + mov DWORD PTR [esp+136], ecx + mov DWORD PTR [esp+140], ecx + mov DWORD PTR [esp+144], ecx + mov DWORD PTR [esp+148], ecx + mov DWORD PTR [esp+152], ecx + mov DWORD PTR [esp+156], ecx + mov DWORD PTR [esp+160], ecx + mov DWORD PTR [esp+164], ecx + mov DWORD PTR [esp+168], ecx + mov DWORD PTR [esp+172], ecx + mov DWORD PTR [esp+176], ecx + mov DWORD PTR [esp+180], ecx + mov DWORD PTR [esp+184], ecx + mov DWORD PTR [esp+188], ecx + mov DWORD PTR [esp+192], ecx + mov DWORD PTR [esp+196], ecx + mov DWORD PTR [esp+200], ecx + mov DWORD PTR [esp+204], ecx + mov DWORD PTR [esp+208], ecx + mov DWORD PTR [esp+212], ecx + mov DWORD PTR [esp+216], ecx + mov DWORD PTR [esp+220], ecx + mov DWORD PTR [esp+224], ecx + mov DWORD PTR [esp+228], ecx + mov DWORD PTR [esp+232], ecx + mov DWORD PTR [esp+236], ecx + mov DWORD PTR [esp+240], ecx + mov DWORD PTR [esp+244], ecx + mov DWORD PTR [esp+248], ecx + mov DWORD PTR [esp+252], ecx + mov DWORD PTR [esp+256], ecx + mov DWORD PTR [esp+260], ecx + mov DWORD PTR [esp+264], ecx + mov DWORD PTR [esp+268], ecx + mov DWORD PTR [esp+272], ecx + mov DWORD PTR [esp+276], ecx + mov DWORD PTR [esp+280], ecx + mov DWORD PTR [esp+284], ecx + mov DWORD PTR [esp+288], ecx + mov DWORD PTR [esp+292], ecx + mov DWORD PTR [esp+296], ecx + mov DWORD PTR [esp+300], ecx + mov DWORD PTR [esp+304], ecx + mov DWORD PTR [esp+308], ecx + mov DWORD PTR [esp+312], ecx + mov DWORD PTR [esp+316], ecx + mov DWORD PTR [esp+320], ecx + mov DWORD PTR [esp+324], ecx + mov DWORD PTR [esp+328], ecx + mov DWORD PTR [esp+332], ecx + mov DWORD PTR [esp+336], ecx + mov DWORD PTR [esp+340], ecx + mov DWORD PTR [esp+344], ecx + mov DWORD PTR [esp+348], ecx + mov DWORD PTR [esp+352], ecx + mov DWORD PTR [esp+356], ecx + mov DWORD PTR [esp+360], ecx + mov DWORD PTR [esp+364], ecx + mov DWORD PTR [esp+368], ecx + mov DWORD PTR [esp+372], ecx + mov DWORD PTR [esp+376], ecx + mov DWORD PTR [esp+380], ecx + mov DWORD PTR [esp+384], ecx + mov DWORD PTR [esp+388], ecx + mov DWORD PTR [esp+392], ecx + mov DWORD PTR [esp+396], ecx + mov DWORD PTR [esp+400], ecx + mov DWORD PTR [esp+404], ecx + mov DWORD PTR [esp+408], ecx + mov DWORD PTR [esp+412], ecx + mov DWORD PTR [esp+416], ecx + mov DWORD PTR [esp+420], ecx + mov DWORD PTR [esp+424], ecx + mov DWORD PTR [esp+428], ecx + mov DWORD PTR [esp+432], ecx + mov DWORD PTR [esp+436], ecx + mov DWORD PTR [esp+440], ecx + mov DWORD PTR [esp+444], ecx + mov DWORD PTR [esp+448], ecx + mov DWORD PTR [esp+452], ecx + mov DWORD PTR [esp+456], ecx + mov DWORD PTR [esp+460], ecx + mov DWORD PTR [esp+464], ecx + mov DWORD PTR [esp+468], ecx + mov DWORD PTR [esp+472], ecx + mov DWORD PTR [esp+476], ecx + mov DWORD PTR [esp+480], ecx + mov DWORD PTR [esp+484], ecx + mov DWORD PTR [esp+488], ecx + mov DWORD PTR [esp+492], ecx + mov DWORD PTR [esp+496], ecx + mov DWORD PTR [esp+500], ecx + mov DWORD PTR [esp+504], ecx + mov DWORD PTR [esp+508], ecx + mov DWORD PTR [esp+512], ecx + mov DWORD PTR [esp+516], ecx + mov DWORD PTR [esp+520], ecx + mov DWORD PTR [esp+524], ecx + mov DWORD PTR [esp+528], ecx + mov DWORD PTR [esp+532], ecx + mov DWORD PTR [esp+536], ecx + mov DWORD PTR [esp+540], ecx + mov DWORD PTR [esp+544], ecx + mov DWORD PTR [esp+548], ecx + mov DWORD PTR [esp+552], ecx + mov DWORD PTR [esp+556], ecx + mov DWORD PTR [esp+560], ecx + mov DWORD PTR [esp+564], ecx + mov DWORD PTR [esp+568], ecx + mov DWORD PTR [esp+572], ecx + mov DWORD PTR [esp+576], ecx + mov DWORD PTR [esp+580], ecx + mov DWORD PTR [esp+584], ecx + mov DWORD PTR [esp+588], ecx + mov DWORD PTR [esp+592], ecx + mov DWORD PTR [esp+596], ecx + mov DWORD PTR [esp+600], ecx + mov DWORD PTR [esp+604], ecx + mov DWORD PTR [esp+608], ecx + mov DWORD PTR [esp+612], ecx + mov DWORD PTR [esp+616], ecx + mov DWORD PTR [esp+620], ecx + mov DWORD PTR [esp+624], ecx + mov DWORD PTR [esp+628], ecx + mov DWORD PTR [esp+632], ecx + mov DWORD PTR [esp+636], ecx + mov DWORD PTR [esp+640], ecx + mov DWORD PTR [esp+644], ecx + mov DWORD PTR [esp+648], ecx + mov DWORD PTR [esp+652], ecx + mov DWORD PTR [esp+656], ecx + mov DWORD PTR [esp+660], ecx + mov DWORD PTR [esp+664], ecx + mov DWORD PTR [esp+668], ecx + mov DWORD PTR [esp+672], ecx + mov DWORD PTR [esp+676], ecx + mov DWORD PTR [esp+680], ecx + mov DWORD PTR [esp+684], ecx + mov DWORD PTR [esp+688], ecx + mov DWORD PTR [esp+692], ecx + mov DWORD PTR [esp+696], ecx + mov DWORD PTR [esp+700], ecx + mov DWORD PTR [esp+704], ecx + mov DWORD PTR [esp+708], ecx + mov DWORD PTR [esp+712], ecx + mov DWORD PTR [esp+716], ecx + mov DWORD PTR [esp+720], ecx + mov DWORD PTR [esp+724], ecx + mov DWORD PTR [esp+728], ecx + mov DWORD PTR [esp+732], ecx + mov DWORD PTR [esp+736], ecx + mov DWORD PTR [esp+740], ecx + mov DWORD PTR [esp+744], ecx + mov DWORD PTR [esp+748], ecx + mov DWORD PTR [esp+752], ecx + mov DWORD PTR [esp+756], ecx + mov DWORD PTR [esp+760], ecx + mov DWORD PTR [esp+764], ecx + mov DWORD PTR [esp+768], ecx + mov DWORD PTR [esp+772], ecx + mov DWORD PTR [esp+776], ecx + mov DWORD PTR [esp+780], ecx + mov DWORD PTR [esp+784], ecx + mov DWORD PTR [esp+788], ecx + mov DWORD PTR [esp+792], ecx + mov DWORD PTR [esp+796], ecx + mov DWORD PTR [esp+800], ecx + mov DWORD PTR [esp+804], ecx + mov DWORD PTR [esp+808], ecx + mov DWORD PTR [esp+812], ecx + mov DWORD PTR [esp+816], ecx + mov DWORD PTR [esp+820], ecx + mov DWORD PTR [esp+824], ecx + mov DWORD PTR [esp+828], ecx + mov DWORD PTR [esp+832], ecx + mov DWORD PTR [esp+836], ecx + mov DWORD PTR [esp+840], ecx + mov DWORD PTR [esp+844], ecx + mov DWORD PTR [esp+848], ecx + mov DWORD PTR [esp+852], ecx + mov DWORD PTR [esp+856], ecx + mov DWORD PTR [esp+860], ecx + mov DWORD PTR [esp+864], ecx + mov DWORD PTR [esp+868], ecx + mov DWORD PTR [esp+872], ecx + mov DWORD PTR [esp+876], ecx + mov DWORD PTR [esp+880], ecx + mov DWORD PTR [esp+884], ecx + mov DWORD PTR [esp+888], ecx + mov DWORD PTR [esp+892], ecx + mov DWORD PTR [esp+896], ecx + mov DWORD PTR [esp+900], ecx + mov DWORD PTR [esp+904], ecx + mov DWORD PTR [esp+908], ecx + mov DWORD PTR [esp+912], ecx + mov DWORD PTR [esp+916], ecx + mov DWORD PTR [esp+920], ecx + mov DWORD PTR [esp+924], ecx + mov DWORD PTR [esp+928], ecx + mov DWORD PTR [esp+932], ecx + mov DWORD PTR [esp+936], ecx + mov DWORD PTR [esp+940], ecx + mov DWORD PTR [esp+944], ecx + mov DWORD PTR [esp+948], ecx + mov DWORD PTR [esp+952], ecx + mov DWORD PTR [esp+956], ecx + mov DWORD PTR [esp+960], ecx + mov DWORD PTR [esp+964], ecx + mov DWORD PTR [esp+968], ecx + mov DWORD PTR [esp+972], ecx + mov DWORD PTR [esp+976], ecx + mov DWORD PTR [esp+980], ecx + mov DWORD PTR [esp+984], ecx + mov DWORD PTR [esp+988], ecx + mov DWORD PTR [esp+992], ecx + mov DWORD PTR [esp+996], ecx + mov DWORD PTR [esp+1000], ecx + mov DWORD PTR [esp+1004], ecx + mov DWORD PTR [esp+1008], ecx + mov DWORD PTR [esp+1012], ecx + mov DWORD PTR [esp+1016], ecx + mov DWORD PTR [esp+1020], ecx + mov DWORD PTR [esp+1024], ecx + mov DWORD PTR [esp+1028], ecx + mov DWORD PTR [esp+1032], ecx + mov DWORD PTR [esp+1036], ecx + mov DWORD PTR [esp+1040], ecx + mov DWORD PTR [esp+1044], ecx + mov DWORD PTR [esp+1048], ecx + mov DWORD PTR [esp+1052], ecx + mov DWORD PTR [esp+1056], ecx + mov DWORD PTR [esp+1060], ecx + mov DWORD PTR [esp+1064], ecx + mov DWORD PTR [esp+1068], ecx + mov DWORD PTR [esp+1072], ecx + mov DWORD PTR [esp+1076], ecx + mov DWORD PTR [esp+1080], ecx + mov DWORD PTR [esp+1084], ecx + mov DWORD PTR [esp+1088], ecx + mov DWORD PTR [esp+1092], ecx + mov DWORD PTR [esp+1096], ecx + mov DWORD PTR [esp+1100], ecx + mov DWORD PTR [esp+1104], ecx + mov DWORD PTR [esp+1108], ecx + mov DWORD PTR [esp+1112], ecx + mov DWORD PTR [esp+1116], ecx + mov DWORD PTR [esp+1120], ecx + mov DWORD PTR [esp+1124], ecx + mov DWORD PTR [esp+1128], ecx + mov DWORD PTR [esp+1132], ecx + mov DWORD PTR [esp+1136], ecx + mov DWORD PTR [esp+1140], ecx + mov DWORD PTR [esp+1144], ecx + mov DWORD PTR [esp+1148], ecx + mov DWORD PTR [esp+1152], ecx + mov DWORD PTR [esp+1156], ecx + mov DWORD PTR [esp+1160], ecx + mov DWORD PTR [esp+1164], ecx + lea esp, [esp+1168] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/sm4_ctr.s b/crates/verified-garbage-asm-x86/assembly/sm4_ctr.s index 3834019c1c6..531006850e2 100644 --- a/crates/verified-garbage-asm-x86/assembly/sm4_ctr.s +++ b/crates/verified-garbage-asm-x86/assembly/sm4_ctr.s @@ -499,3 +499,97 @@ vg_sm4_ctr: lea esp, [esp+1496] ret .p2align 6 + +vg_sm4_ctr_final: + lea esp, [esp-56] + mov eax, DWORD PTR [esp+60] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+64] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+68] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+72] + mov DWORD PTR [esp+16], eax + mov eax, esp + add eax, 24 + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [eax], ebx + mov DWORD PTR [eax+4], esi + mov DWORD PTR [eax+8], edi + mov DWORD PTR [eax+12], ebp + mov eax, DWORD PTR [esp+4] + mov edx, DWORD PTR [esp+8] + mov ebx, DWORD PTR [esp+12] + mov esi, DWORD PTR [esp+16] + shr esi, 4 + push esi + push ebx + push edx + push eax + call {vg_sm4_ctr} + pop eax + pop eax + pop eax + pop eax + mov eax, DWORD PTR [esp+16] + and eax, 15 + test eax, eax + je 20f + mov eax, DWORD PTR [esp+20] + mov ecx, 0 + mov DWORD PTR [eax+16], ecx + mov DWORD PTR [eax+20], ecx + mov DWORD PTR [eax+24], ecx + mov DWORD PTR [eax+28], ecx + mov ebx, eax + add ebx, 16 + mov eax, DWORD PTR [esp+4] + mov edx, DWORD PTR [esp+8] + mov esi, 1 + push esi + push ebx + push edx + push eax + call {vg_sm4_ctr} + pop eax + pop eax + pop eax + pop eax + mov ebx, DWORD PTR [esp+20] + add ebx, 16 + mov esi, DWORD PTR [esp+12] + mov ebp, DWORD PTR [esp+16] + mov eax, ebp + and ebp, 15 + sub eax, ebp + add esi, eax +22: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 22b + jmp 21f +20: +21: + mov eax, DWORD PTR [esp+20] + mov ebx, DWORD PTR [eax] + mov esi, DWORD PTR [eax+4] + mov edi, DWORD PTR [eax+8] + mov ebp, DWORD PTR [eax+12] + mov ecx, 0 + mov DWORD PTR [esp+24], ecx + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + lea esp, [esp+56] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/sm4_ofb.s b/crates/verified-garbage-asm-x86/assembly/sm4_ofb.s index 921c2752074..65a6c6011d3 100644 --- a/crates/verified-garbage-asm-x86/assembly/sm4_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/sm4_ofb.s @@ -487,3 +487,513 @@ vg_sm4_ofb: lea esp, [esp+1496] ret .p2align 6 + +vg_sm4_ofb_final: + lea esp, [esp-1496] + mov eax, DWORD PTR [esp+1500] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+1504] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+1508] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+1512] + mov DWORD PTR [esp+16], eax + mov eax, esp + add eax, 24 + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [eax+1432], ebx + mov DWORD PTR [eax+1436], esi + mov DWORD PTR [eax+1440], edi + mov DWORD PTR [eax+1444], ebp + mov edi, eax + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+1456], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+1460], eax + mov eax, DWORD PTR [esi+8] + mov DWORD PTR [edi+1464], eax + mov eax, DWORD PTR [esi+12] + mov DWORD PTR [edi+1468], eax + mov eax, 179 + mov edx, 0 + mov ecx, DWORD PTR [esp+4] + push eax + push edi + push edx + push ecx + call {vg_sm4_prepare_keys} + pop eax + pop eax + pop eax + pop eax + mov edi, DWORD PTR [esp+20] + mov eax, DWORD PTR [esp+12] + mov DWORD PTR [edi+1448], eax + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+1452], eax + test eax, eax + je 20f +22: + mov esi, DWORD PTR [edi+1448] + mov ebp, DWORD PTR [edi+1452] + mov eax, DWORD PTR [edi+1456] + mov DWORD PTR [edi+256], eax + mov eax, DWORD PTR [edi+1460] + mov DWORD PTR [edi+260], eax + mov eax, DWORD PTR [edi+1464] + mov DWORD PTR [edi+264], eax + mov eax, DWORD PTR [edi+1468] + mov DWORD PTR [edi+268], eax + mov esi, DWORD PTR [edi+1448] + mov ebp, DWORD PTR [edi+1452] + mov eax, 179 + push eax + push edi + call {vg_sm4_crypt_prepared} + pop eax + pop eax + mov DWORD PTR [edi+1448], esi + mov DWORD PTR [edi+1452], ebp + mov esi, DWORD PTR [edi+1448] + mov ebp, DWORD PTR [edi+1452] + cmp ebp, 16 + jb 23f + mov eax, DWORD PTR [edi+256] + mov DWORD PTR [edi+1456], eax + mov eax, DWORD PTR [edi+260] + mov DWORD PTR [edi+1460], eax + mov eax, DWORD PTR [edi+264] + mov DWORD PTR [edi+1464], eax + mov eax, DWORD PTR [edi+268] + mov DWORD PTR [edi+1468], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+256] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+260] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [esi+8] + xor eax, DWORD PTR [edi+264] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [esi+12] + xor eax, DWORD PTR [edi+268] + mov DWORD PTR [esi+12], eax + add esi, 16 + sub ebp, 16 + mov DWORD PTR [edi+1448], esi + mov DWORD PTR [edi+1452], ebp + jmp 24f +23: + mov eax, DWORD PTR [edi+256] + mov DWORD PTR [edi+1456], eax + mov eax, DWORD PTR [edi+260] + mov DWORD PTR [edi+1460], eax + mov eax, DWORD PTR [edi+264] + mov DWORD PTR [edi+1464], eax + mov eax, DWORD PTR [edi+268] + mov DWORD PTR [edi+1468], eax + mov ebx, edi + add ebx, 256 +25: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 25b + mov DWORD PTR [edi+1448], esi + mov DWORD PTR [edi+1452], ebp +24: + jne 22b + jmp 21f +20: +21: + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [edi+1456] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+1460] + mov DWORD PTR [esi+4], eax + mov eax, DWORD PTR [edi+1464] + mov DWORD PTR [esi+8], eax + mov eax, DWORD PTR [edi+1468] + mov DWORD PTR [esi+12], eax + mov ebx, DWORD PTR [edi+1432] + mov esi, DWORD PTR [edi+1436] + mov ebp, DWORD PTR [edi+1444] + mov edi, DWORD PTR [edi+1440] + mov ecx, 0 + mov DWORD PTR [esp+24], ecx + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + mov DWORD PTR [esp+112], ecx + mov DWORD PTR [esp+116], ecx + mov DWORD PTR [esp+120], ecx + mov DWORD PTR [esp+124], ecx + mov DWORD PTR [esp+128], ecx + mov DWORD PTR [esp+132], ecx + mov DWORD PTR [esp+136], ecx + mov DWORD PTR [esp+140], ecx + mov DWORD PTR [esp+144], ecx + mov DWORD PTR [esp+148], ecx + mov DWORD PTR [esp+152], ecx + mov DWORD PTR [esp+156], ecx + mov DWORD PTR [esp+160], ecx + mov DWORD PTR [esp+164], ecx + mov DWORD PTR [esp+168], ecx + mov DWORD PTR [esp+172], ecx + mov DWORD PTR [esp+176], ecx + mov DWORD PTR [esp+180], ecx + mov DWORD PTR [esp+184], ecx + mov DWORD PTR [esp+188], ecx + mov DWORD PTR [esp+192], ecx + mov DWORD PTR [esp+196], ecx + mov DWORD PTR [esp+200], ecx + mov DWORD PTR [esp+204], ecx + mov DWORD PTR [esp+208], ecx + mov DWORD PTR [esp+212], ecx + mov DWORD PTR [esp+216], ecx + mov DWORD PTR [esp+220], ecx + mov DWORD PTR [esp+224], ecx + mov DWORD PTR [esp+228], ecx + mov DWORD PTR [esp+232], ecx + mov DWORD PTR [esp+236], ecx + mov DWORD PTR [esp+240], ecx + mov DWORD PTR [esp+244], ecx + mov DWORD PTR [esp+248], ecx + mov DWORD PTR [esp+252], ecx + mov DWORD PTR [esp+256], ecx + mov DWORD PTR [esp+260], ecx + mov DWORD PTR [esp+264], ecx + mov DWORD PTR [esp+268], ecx + mov DWORD PTR [esp+272], ecx + mov DWORD PTR [esp+276], ecx + mov DWORD PTR [esp+280], ecx + mov DWORD PTR [esp+284], ecx + mov DWORD PTR [esp+288], ecx + mov DWORD PTR [esp+292], ecx + mov DWORD PTR [esp+296], ecx + mov DWORD PTR [esp+300], ecx + mov DWORD PTR [esp+304], ecx + mov DWORD PTR [esp+308], ecx + mov DWORD PTR [esp+312], ecx + mov DWORD PTR [esp+316], ecx + mov DWORD PTR [esp+320], ecx + mov DWORD PTR [esp+324], ecx + mov DWORD PTR [esp+328], ecx + mov DWORD PTR [esp+332], ecx + mov DWORD PTR [esp+336], ecx + mov DWORD PTR [esp+340], ecx + mov DWORD PTR [esp+344], ecx + mov DWORD PTR [esp+348], ecx + mov DWORD PTR [esp+352], ecx + mov DWORD PTR [esp+356], ecx + mov DWORD PTR [esp+360], ecx + mov DWORD PTR [esp+364], ecx + mov DWORD PTR [esp+368], ecx + mov DWORD PTR [esp+372], ecx + mov DWORD PTR [esp+376], ecx + mov DWORD PTR [esp+380], ecx + mov DWORD PTR [esp+384], ecx + mov DWORD PTR [esp+388], ecx + mov DWORD PTR [esp+392], ecx + mov DWORD PTR [esp+396], ecx + mov DWORD PTR [esp+400], ecx + mov DWORD PTR [esp+404], ecx + mov DWORD PTR [esp+408], ecx + mov DWORD PTR [esp+412], ecx + mov DWORD PTR [esp+416], ecx + mov DWORD PTR [esp+420], ecx + mov DWORD PTR [esp+424], ecx + mov DWORD PTR [esp+428], ecx + mov DWORD PTR [esp+432], ecx + mov DWORD PTR [esp+436], ecx + mov DWORD PTR [esp+440], ecx + mov DWORD PTR [esp+444], ecx + mov DWORD PTR [esp+448], ecx + mov DWORD PTR [esp+452], ecx + mov DWORD PTR [esp+456], ecx + mov DWORD PTR [esp+460], ecx + mov DWORD PTR [esp+464], ecx + mov DWORD PTR [esp+468], ecx + mov DWORD PTR [esp+472], ecx + mov DWORD PTR [esp+476], ecx + mov DWORD PTR [esp+480], ecx + mov DWORD PTR [esp+484], ecx + mov DWORD PTR [esp+488], ecx + mov DWORD PTR [esp+492], ecx + mov DWORD PTR [esp+496], ecx + mov DWORD PTR [esp+500], ecx + mov DWORD PTR [esp+504], ecx + mov DWORD PTR [esp+508], ecx + mov DWORD PTR [esp+512], ecx + mov DWORD PTR [esp+516], ecx + mov DWORD PTR [esp+520], ecx + mov DWORD PTR [esp+524], ecx + mov DWORD PTR [esp+528], ecx + mov DWORD PTR [esp+532], ecx + mov DWORD PTR [esp+536], ecx + mov DWORD PTR [esp+540], ecx + mov DWORD PTR [esp+544], ecx + mov DWORD PTR [esp+548], ecx + mov DWORD PTR [esp+552], ecx + mov DWORD PTR [esp+556], ecx + mov DWORD PTR [esp+560], ecx + mov DWORD PTR [esp+564], ecx + mov DWORD PTR [esp+568], ecx + mov DWORD PTR [esp+572], ecx + mov DWORD PTR [esp+576], ecx + mov DWORD PTR [esp+580], ecx + mov DWORD PTR [esp+584], ecx + mov DWORD PTR [esp+588], ecx + mov DWORD PTR [esp+592], ecx + mov DWORD PTR [esp+596], ecx + mov DWORD PTR [esp+600], ecx + mov DWORD PTR [esp+604], ecx + mov DWORD PTR [esp+608], ecx + mov DWORD PTR [esp+612], ecx + mov DWORD PTR [esp+616], ecx + mov DWORD PTR [esp+620], ecx + mov DWORD PTR [esp+624], ecx + mov DWORD PTR [esp+628], ecx + mov DWORD PTR [esp+632], ecx + mov DWORD PTR [esp+636], ecx + mov DWORD PTR [esp+640], ecx + mov DWORD PTR [esp+644], ecx + mov DWORD PTR [esp+648], ecx + mov DWORD PTR [esp+652], ecx + mov DWORD PTR [esp+656], ecx + mov DWORD PTR [esp+660], ecx + mov DWORD PTR [esp+664], ecx + mov DWORD PTR [esp+668], ecx + mov DWORD PTR [esp+672], ecx + mov DWORD PTR [esp+676], ecx + mov DWORD PTR [esp+680], ecx + mov DWORD PTR [esp+684], ecx + mov DWORD PTR [esp+688], ecx + mov DWORD PTR [esp+692], ecx + mov DWORD PTR [esp+696], ecx + mov DWORD PTR [esp+700], ecx + mov DWORD PTR [esp+704], ecx + mov DWORD PTR [esp+708], ecx + mov DWORD PTR [esp+712], ecx + mov DWORD PTR [esp+716], ecx + mov DWORD PTR [esp+720], ecx + mov DWORD PTR [esp+724], ecx + mov DWORD PTR [esp+728], ecx + mov DWORD PTR [esp+732], ecx + mov DWORD PTR [esp+736], ecx + mov DWORD PTR [esp+740], ecx + mov DWORD PTR [esp+744], ecx + mov DWORD PTR [esp+748], ecx + mov DWORD PTR [esp+752], ecx + mov DWORD PTR [esp+756], ecx + mov DWORD PTR [esp+760], ecx + mov DWORD PTR [esp+764], ecx + mov DWORD PTR [esp+768], ecx + mov DWORD PTR [esp+772], ecx + mov DWORD PTR [esp+776], ecx + mov DWORD PTR [esp+780], ecx + mov DWORD PTR [esp+784], ecx + mov DWORD PTR [esp+788], ecx + mov DWORD PTR [esp+792], ecx + mov DWORD PTR [esp+796], ecx + mov DWORD PTR [esp+800], ecx + mov DWORD PTR [esp+804], ecx + mov DWORD PTR [esp+808], ecx + mov DWORD PTR [esp+812], ecx + mov DWORD PTR [esp+816], ecx + mov DWORD PTR [esp+820], ecx + mov DWORD PTR [esp+824], ecx + mov DWORD PTR [esp+828], ecx + mov DWORD PTR [esp+832], ecx + mov DWORD PTR [esp+836], ecx + mov DWORD PTR [esp+840], ecx + mov DWORD PTR [esp+844], ecx + mov DWORD PTR [esp+848], ecx + mov DWORD PTR [esp+852], ecx + mov DWORD PTR [esp+856], ecx + mov DWORD PTR [esp+860], ecx + mov DWORD PTR [esp+864], ecx + mov DWORD PTR [esp+868], ecx + mov DWORD PTR [esp+872], ecx + mov DWORD PTR [esp+876], ecx + mov DWORD PTR [esp+880], ecx + mov DWORD PTR [esp+884], ecx + mov DWORD PTR [esp+888], ecx + mov DWORD PTR [esp+892], ecx + mov DWORD PTR [esp+896], ecx + mov DWORD PTR [esp+900], ecx + mov DWORD PTR [esp+904], ecx + mov DWORD PTR [esp+908], ecx + mov DWORD PTR [esp+912], ecx + mov DWORD PTR [esp+916], ecx + mov DWORD PTR [esp+920], ecx + mov DWORD PTR [esp+924], ecx + mov DWORD PTR [esp+928], ecx + mov DWORD PTR [esp+932], ecx + mov DWORD PTR [esp+936], ecx + mov DWORD PTR [esp+940], ecx + mov DWORD PTR [esp+944], ecx + mov DWORD PTR [esp+948], ecx + mov DWORD PTR [esp+952], ecx + mov DWORD PTR [esp+956], ecx + mov DWORD PTR [esp+960], ecx + mov DWORD PTR [esp+964], ecx + mov DWORD PTR [esp+968], ecx + mov DWORD PTR [esp+972], ecx + mov DWORD PTR [esp+976], ecx + mov DWORD PTR [esp+980], ecx + mov DWORD PTR [esp+984], ecx + mov DWORD PTR [esp+988], ecx + mov DWORD PTR [esp+992], ecx + mov DWORD PTR [esp+996], ecx + mov DWORD PTR [esp+1000], ecx + mov DWORD PTR [esp+1004], ecx + mov DWORD PTR [esp+1008], ecx + mov DWORD PTR [esp+1012], ecx + mov DWORD PTR [esp+1016], ecx + mov DWORD PTR [esp+1020], ecx + mov DWORD PTR [esp+1024], ecx + mov DWORD PTR [esp+1028], ecx + mov DWORD PTR [esp+1032], ecx + mov DWORD PTR [esp+1036], ecx + mov DWORD PTR [esp+1040], ecx + mov DWORD PTR [esp+1044], ecx + mov DWORD PTR [esp+1048], ecx + mov DWORD PTR [esp+1052], ecx + mov DWORD PTR [esp+1056], ecx + mov DWORD PTR [esp+1060], ecx + mov DWORD PTR [esp+1064], ecx + mov DWORD PTR [esp+1068], ecx + mov DWORD PTR [esp+1072], ecx + mov DWORD PTR [esp+1076], ecx + mov DWORD PTR [esp+1080], ecx + mov DWORD PTR [esp+1084], ecx + mov DWORD PTR [esp+1088], ecx + mov DWORD PTR [esp+1092], ecx + mov DWORD PTR [esp+1096], ecx + mov DWORD PTR [esp+1100], ecx + mov DWORD PTR [esp+1104], ecx + mov DWORD PTR [esp+1108], ecx + mov DWORD PTR [esp+1112], ecx + mov DWORD PTR [esp+1116], ecx + mov DWORD PTR [esp+1120], ecx + mov DWORD PTR [esp+1124], ecx + mov DWORD PTR [esp+1128], ecx + mov DWORD PTR [esp+1132], ecx + mov DWORD PTR [esp+1136], ecx + mov DWORD PTR [esp+1140], ecx + mov DWORD PTR [esp+1144], ecx + mov DWORD PTR [esp+1148], ecx + mov DWORD PTR [esp+1152], ecx + mov DWORD PTR [esp+1156], ecx + mov DWORD PTR [esp+1160], ecx + mov DWORD PTR [esp+1164], ecx + mov DWORD PTR [esp+1168], ecx + mov DWORD PTR [esp+1172], ecx + mov DWORD PTR [esp+1176], ecx + mov DWORD PTR [esp+1180], ecx + mov DWORD PTR [esp+1184], ecx + mov DWORD PTR [esp+1188], ecx + mov DWORD PTR [esp+1192], ecx + mov DWORD PTR [esp+1196], ecx + mov DWORD PTR [esp+1200], ecx + mov DWORD PTR [esp+1204], ecx + mov DWORD PTR [esp+1208], ecx + mov DWORD PTR [esp+1212], ecx + mov DWORD PTR [esp+1216], ecx + mov DWORD PTR [esp+1220], ecx + mov DWORD PTR [esp+1224], ecx + mov DWORD PTR [esp+1228], ecx + mov DWORD PTR [esp+1232], ecx + mov DWORD PTR [esp+1236], ecx + mov DWORD PTR [esp+1240], ecx + mov DWORD PTR [esp+1244], ecx + mov DWORD PTR [esp+1248], ecx + mov DWORD PTR [esp+1252], ecx + mov DWORD PTR [esp+1256], ecx + mov DWORD PTR [esp+1260], ecx + mov DWORD PTR [esp+1264], ecx + mov DWORD PTR [esp+1268], ecx + mov DWORD PTR [esp+1272], ecx + mov DWORD PTR [esp+1276], ecx + mov DWORD PTR [esp+1280], ecx + mov DWORD PTR [esp+1284], ecx + mov DWORD PTR [esp+1288], ecx + mov DWORD PTR [esp+1292], ecx + mov DWORD PTR [esp+1296], ecx + mov DWORD PTR [esp+1300], ecx + mov DWORD PTR [esp+1304], ecx + mov DWORD PTR [esp+1308], ecx + mov DWORD PTR [esp+1312], ecx + mov DWORD PTR [esp+1316], ecx + mov DWORD PTR [esp+1320], ecx + mov DWORD PTR [esp+1324], ecx + mov DWORD PTR [esp+1328], ecx + mov DWORD PTR [esp+1332], ecx + mov DWORD PTR [esp+1336], ecx + mov DWORD PTR [esp+1340], ecx + mov DWORD PTR [esp+1344], ecx + mov DWORD PTR [esp+1348], ecx + mov DWORD PTR [esp+1352], ecx + mov DWORD PTR [esp+1356], ecx + mov DWORD PTR [esp+1360], ecx + mov DWORD PTR [esp+1364], ecx + mov DWORD PTR [esp+1368], ecx + mov DWORD PTR [esp+1372], ecx + mov DWORD PTR [esp+1376], ecx + mov DWORD PTR [esp+1380], ecx + mov DWORD PTR [esp+1384], ecx + mov DWORD PTR [esp+1388], ecx + mov DWORD PTR [esp+1392], ecx + mov DWORD PTR [esp+1396], ecx + mov DWORD PTR [esp+1400], ecx + mov DWORD PTR [esp+1404], ecx + mov DWORD PTR [esp+1408], ecx + mov DWORD PTR [esp+1412], ecx + mov DWORD PTR [esp+1416], ecx + mov DWORD PTR [esp+1420], ecx + mov DWORD PTR [esp+1424], ecx + mov DWORD PTR [esp+1428], ecx + mov DWORD PTR [esp+1432], ecx + mov DWORD PTR [esp+1436], ecx + mov DWORD PTR [esp+1440], ecx + mov DWORD PTR [esp+1444], ecx + mov DWORD PTR [esp+1448], ecx + mov DWORD PTR [esp+1452], ecx + mov DWORD PTR [esp+1456], ecx + mov DWORD PTR [esp+1460], ecx + mov DWORD PTR [esp+1464], ecx + mov DWORD PTR [esp+1468], ecx + mov DWORD PTR [esp+1472], ecx + mov DWORD PTR [esp+1476], ecx + mov DWORD PTR [esp+1480], ecx + mov DWORD PTR [esp+1484], ecx + mov DWORD PTR [esp+1488], ecx + mov DWORD PTR [esp+1492], ecx + lea esp, [esp+1496] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/assembly/triple_des_ofb.s b/crates/verified-garbage-asm-x86/assembly/triple_des_ofb.s index 1413b839f86..51229b09aa8 100644 --- a/crates/verified-garbage-asm-x86/assembly/triple_des_ofb.s +++ b/crates/verified-garbage-asm-x86/assembly/triple_des_ofb.s @@ -519,3 +519,541 @@ vg_triple_des_ofb: lea esp, [esp+968] ret .p2align 6 + +vg_triple_des_ofb_final: + lea esp, [esp-968] + mov eax, DWORD PTR [esp+972] + mov DWORD PTR [esp+4], eax + mov eax, DWORD PTR [esp+976] + mov DWORD PTR [esp+8], eax + mov eax, DWORD PTR [esp+980] + mov DWORD PTR [esp+12], eax + mov eax, DWORD PTR [esp+984] + mov DWORD PTR [esp+16], eax + mov eax, esp + add eax, 24 + mov DWORD PTR [esp+20], eax + mov eax, DWORD PTR [esp+20] + mov DWORD PTR [eax+904], ebx + mov DWORD PTR [eax+908], esi + mov DWORD PTR [eax+912], edi + mov DWORD PTR [eax+916], ebp + mov edi, eax + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [esi] + mov DWORD PTR [edi+928], eax + mov eax, DWORD PTR [esi+4] + mov DWORD PTR [edi+932], eax + mov ecx, DWORD PTR [esp+4] + mov eax, DWORD PTR [ecx] + mov DWORD PTR [edi+520], eax + mov eax, DWORD PTR [ecx+4] + mov DWORD PTR [edi+524], eax + mov eax, DWORD PTR [ecx+8] + mov DWORD PTR [edi+528], eax + mov eax, DWORD PTR [ecx+12] + mov DWORD PTR [edi+532], eax + mov eax, DWORD PTR [ecx+16] + mov DWORD PTR [edi+536], eax + mov eax, DWORD PTR [ecx+20] + mov DWORD PTR [edi+540], eax + mov eax, DWORD PTR [ecx+24] + mov DWORD PTR [edi+544], eax + mov eax, DWORD PTR [ecx+28] + mov DWORD PTR [edi+548], eax + mov eax, DWORD PTR [ecx+32] + mov DWORD PTR [edi+552], eax + mov eax, DWORD PTR [ecx+36] + mov DWORD PTR [edi+556], eax + mov eax, DWORD PTR [ecx+40] + mov DWORD PTR [edi+560], eax + mov eax, DWORD PTR [ecx+44] + mov DWORD PTR [edi+564], eax + mov eax, DWORD PTR [ecx+48] + mov DWORD PTR [edi+568], eax + mov eax, DWORD PTR [ecx+52] + mov DWORD PTR [edi+572], eax + mov eax, DWORD PTR [ecx+56] + mov DWORD PTR [edi+576], eax + mov eax, DWORD PTR [ecx+60] + mov DWORD PTR [edi+580], eax + mov eax, DWORD PTR [ecx+64] + mov DWORD PTR [edi+584], eax + mov eax, DWORD PTR [ecx+68] + mov DWORD PTR [edi+588], eax + mov eax, DWORD PTR [ecx+72] + mov DWORD PTR [edi+592], eax + mov eax, DWORD PTR [ecx+76] + mov DWORD PTR [edi+596], eax + mov eax, DWORD PTR [ecx+80] + mov DWORD PTR [edi+600], eax + mov eax, DWORD PTR [ecx+84] + mov DWORD PTR [edi+604], eax + mov eax, DWORD PTR [ecx+88] + mov DWORD PTR [edi+608], eax + mov eax, DWORD PTR [ecx+92] + mov DWORD PTR [edi+612], eax + mov eax, DWORD PTR [ecx+96] + mov DWORD PTR [edi+616], eax + mov eax, DWORD PTR [ecx+100] + mov DWORD PTR [edi+620], eax + mov eax, DWORD PTR [ecx+104] + mov DWORD PTR [edi+624], eax + mov eax, DWORD PTR [ecx+108] + mov DWORD PTR [edi+628], eax + mov eax, DWORD PTR [ecx+112] + mov DWORD PTR [edi+632], eax + mov eax, DWORD PTR [ecx+116] + mov DWORD PTR [edi+636], eax + mov eax, DWORD PTR [ecx+120] + mov DWORD PTR [edi+640], eax + mov eax, DWORD PTR [ecx+124] + mov DWORD PTR [edi+644], eax + mov eax, DWORD PTR [ecx+128] + mov DWORD PTR [edi+648], eax + mov eax, DWORD PTR [ecx+132] + mov DWORD PTR [edi+652], eax + mov eax, DWORD PTR [ecx+136] + mov DWORD PTR [edi+656], eax + mov eax, DWORD PTR [ecx+140] + mov DWORD PTR [edi+660], eax + mov eax, DWORD PTR [ecx+144] + mov DWORD PTR [edi+664], eax + mov eax, DWORD PTR [ecx+148] + mov DWORD PTR [edi+668], eax + mov eax, DWORD PTR [ecx+152] + mov DWORD PTR [edi+672], eax + mov eax, DWORD PTR [ecx+156] + mov DWORD PTR [edi+676], eax + mov eax, DWORD PTR [ecx+160] + mov DWORD PTR [edi+680], eax + mov eax, DWORD PTR [ecx+164] + mov DWORD PTR [edi+684], eax + mov eax, DWORD PTR [ecx+168] + mov DWORD PTR [edi+688], eax + mov eax, DWORD PTR [ecx+172] + mov DWORD PTR [edi+692], eax + mov eax, DWORD PTR [ecx+176] + mov DWORD PTR [edi+696], eax + mov eax, DWORD PTR [ecx+180] + mov DWORD PTR [edi+700], eax + mov eax, DWORD PTR [ecx+184] + mov DWORD PTR [edi+704], eax + mov eax, DWORD PTR [ecx+188] + mov DWORD PTR [edi+708], eax + mov eax, DWORD PTR [ecx+192] + mov DWORD PTR [edi+712], eax + mov eax, DWORD PTR [ecx+196] + mov DWORD PTR [edi+716], eax + mov eax, DWORD PTR [ecx+200] + mov DWORD PTR [edi+720], eax + mov eax, DWORD PTR [ecx+204] + mov DWORD PTR [edi+724], eax + mov eax, DWORD PTR [ecx+208] + mov DWORD PTR [edi+728], eax + mov eax, DWORD PTR [ecx+212] + mov DWORD PTR [edi+732], eax + mov eax, DWORD PTR [ecx+216] + mov DWORD PTR [edi+736], eax + mov eax, DWORD PTR [ecx+220] + mov DWORD PTR [edi+740], eax + mov eax, DWORD PTR [ecx+224] + mov DWORD PTR [edi+744], eax + mov eax, DWORD PTR [ecx+228] + mov DWORD PTR [edi+748], eax + mov eax, DWORD PTR [ecx+232] + mov DWORD PTR [edi+752], eax + mov eax, DWORD PTR [ecx+236] + mov DWORD PTR [edi+756], eax + mov eax, DWORD PTR [ecx+240] + mov DWORD PTR [edi+760], eax + mov eax, DWORD PTR [ecx+244] + mov DWORD PTR [edi+764], eax + mov eax, DWORD PTR [ecx+248] + mov DWORD PTR [edi+768], eax + mov eax, DWORD PTR [ecx+252] + mov DWORD PTR [edi+772], eax + mov eax, DWORD PTR [ecx+256] + mov DWORD PTR [edi+776], eax + mov eax, DWORD PTR [ecx+260] + mov DWORD PTR [edi+780], eax + mov eax, DWORD PTR [ecx+264] + mov DWORD PTR [edi+784], eax + mov eax, DWORD PTR [ecx+268] + mov DWORD PTR [edi+788], eax + mov eax, DWORD PTR [ecx+272] + mov DWORD PTR [edi+792], eax + mov eax, DWORD PTR [ecx+276] + mov DWORD PTR [edi+796], eax + mov eax, DWORD PTR [ecx+280] + mov DWORD PTR [edi+800], eax + mov eax, DWORD PTR [ecx+284] + mov DWORD PTR [edi+804], eax + mov eax, DWORD PTR [ecx+288] + mov DWORD PTR [edi+808], eax + mov eax, DWORD PTR [ecx+292] + mov DWORD PTR [edi+812], eax + mov eax, DWORD PTR [ecx+296] + mov DWORD PTR [edi+816], eax + mov eax, DWORD PTR [ecx+300] + mov DWORD PTR [edi+820], eax + mov eax, DWORD PTR [ecx+304] + mov DWORD PTR [edi+824], eax + mov eax, DWORD PTR [ecx+308] + mov DWORD PTR [edi+828], eax + mov eax, DWORD PTR [ecx+312] + mov DWORD PTR [edi+832], eax + mov eax, DWORD PTR [ecx+316] + mov DWORD PTR [edi+836], eax + mov eax, DWORD PTR [ecx+320] + mov DWORD PTR [edi+840], eax + mov eax, DWORD PTR [ecx+324] + mov DWORD PTR [edi+844], eax + mov eax, DWORD PTR [ecx+328] + mov DWORD PTR [edi+848], eax + mov eax, DWORD PTR [ecx+332] + mov DWORD PTR [edi+852], eax + mov eax, DWORD PTR [ecx+336] + mov DWORD PTR [edi+856], eax + mov eax, DWORD PTR [ecx+340] + mov DWORD PTR [edi+860], eax + mov eax, DWORD PTR [ecx+344] + mov DWORD PTR [edi+864], eax + mov eax, DWORD PTR [ecx+348] + mov DWORD PTR [edi+868], eax + mov eax, DWORD PTR [ecx+352] + mov DWORD PTR [edi+872], eax + mov eax, DWORD PTR [ecx+356] + mov DWORD PTR [edi+876], eax + mov eax, DWORD PTR [ecx+360] + mov DWORD PTR [edi+880], eax + mov eax, DWORD PTR [ecx+364] + mov DWORD PTR [edi+884], eax + mov eax, DWORD PTR [ecx+368] + mov DWORD PTR [edi+888], eax + mov eax, DWORD PTR [ecx+372] + mov DWORD PTR [edi+892], eax + mov eax, DWORD PTR [ecx+376] + mov DWORD PTR [edi+896], eax + mov eax, DWORD PTR [ecx+380] + mov DWORD PTR [edi+900], eax + mov eax, DWORD PTR [esp+12] + mov DWORD PTR [edi+920], eax + mov eax, DWORD PTR [esp+16] + mov DWORD PTR [edi+924], eax + test eax, eax + je 20f +22: + mov esi, DWORD PTR [edi+920] + mov ebp, DWORD PTR [edi+924] + mov eax, DWORD PTR [edi+928] + mov DWORD PTR [edi+512], eax + mov eax, DWORD PTR [edi+932] + mov DWORD PTR [edi+516], eax + mov esi, DWORD PTR [edi+920] + mov ebp, DWORD PTR [edi+924] + mov eax, edi + mov ecx, edi + add ecx, 512 + mov edx, edi + add edx, 520 + push eax + push ecx + push edx + call {vg_triple_des_encrypt_block} + pop eax + pop eax + pop eax + mov DWORD PTR [edi+920], esi + mov DWORD PTR [edi+924], ebp + mov esi, DWORD PTR [edi+920] + mov ebp, DWORD PTR [edi+924] + cmp ebp, 8 + jb 23f + mov eax, DWORD PTR [edi+512] + mov DWORD PTR [edi+928], eax + mov eax, DWORD PTR [edi+516] + mov DWORD PTR [edi+932], eax + mov eax, DWORD PTR [esi] + xor eax, DWORD PTR [edi+512] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [esi+4] + xor eax, DWORD PTR [edi+516] + mov DWORD PTR [esi+4], eax + add esi, 8 + sub ebp, 8 + mov DWORD PTR [edi+920], esi + mov DWORD PTR [edi+924], ebp + jmp 24f +23: + mov eax, DWORD PTR [edi+512] + mov DWORD PTR [edi+928], eax + mov eax, DWORD PTR [edi+516] + mov DWORD PTR [edi+932], eax + mov ebx, edi + add ebx, 512 +25: + movzx eax, BYTE PTR [ebx] + movzx ecx, BYTE PTR [esi] + xor ecx, eax + mov BYTE PTR [esi], cl + add ebx, 1 + add esi, 1 + sub ebp, 1 + jne 25b + mov DWORD PTR [edi+920], esi + mov DWORD PTR [edi+924], ebp +24: + jne 22b + jmp 21f +20: +21: + mov esi, DWORD PTR [esp+8] + mov eax, DWORD PTR [edi+928] + mov DWORD PTR [esi], eax + mov eax, DWORD PTR [edi+932] + mov DWORD PTR [esi+4], eax + mov ebx, DWORD PTR [edi+904] + mov esi, DWORD PTR [edi+908] + mov ebp, DWORD PTR [edi+916] + mov edi, DWORD PTR [edi+912] + mov ecx, 0 + mov DWORD PTR [esp+24], ecx + mov DWORD PTR [esp+28], ecx + mov DWORD PTR [esp+32], ecx + mov DWORD PTR [esp+36], ecx + mov DWORD PTR [esp+40], ecx + mov DWORD PTR [esp+44], ecx + mov DWORD PTR [esp+48], ecx + mov DWORD PTR [esp+52], ecx + mov DWORD PTR [esp+56], ecx + mov DWORD PTR [esp+60], ecx + mov DWORD PTR [esp+64], ecx + mov DWORD PTR [esp+68], ecx + mov DWORD PTR [esp+72], ecx + mov DWORD PTR [esp+76], ecx + mov DWORD PTR [esp+80], ecx + mov DWORD PTR [esp+84], ecx + mov DWORD PTR [esp+88], ecx + mov DWORD PTR [esp+92], ecx + mov DWORD PTR [esp+96], ecx + mov DWORD PTR [esp+100], ecx + mov DWORD PTR [esp+104], ecx + mov DWORD PTR [esp+108], ecx + mov DWORD PTR [esp+112], ecx + mov DWORD PTR [esp+116], ecx + mov DWORD PTR [esp+120], ecx + mov DWORD PTR [esp+124], ecx + mov DWORD PTR [esp+128], ecx + mov DWORD PTR [esp+132], ecx + mov DWORD PTR [esp+136], ecx + mov DWORD PTR [esp+140], ecx + mov DWORD PTR [esp+144], ecx + mov DWORD PTR [esp+148], ecx + mov DWORD PTR [esp+152], ecx + mov DWORD PTR [esp+156], ecx + mov DWORD PTR [esp+160], ecx + mov DWORD PTR [esp+164], ecx + mov DWORD PTR [esp+168], ecx + mov DWORD PTR [esp+172], ecx + mov DWORD PTR [esp+176], ecx + mov DWORD PTR [esp+180], ecx + mov DWORD PTR [esp+184], ecx + mov DWORD PTR [esp+188], ecx + mov DWORD PTR [esp+192], ecx + mov DWORD PTR [esp+196], ecx + mov DWORD PTR [esp+200], ecx + mov DWORD PTR [esp+204], ecx + mov DWORD PTR [esp+208], ecx + mov DWORD PTR [esp+212], ecx + mov DWORD PTR [esp+216], ecx + mov DWORD PTR [esp+220], ecx + mov DWORD PTR [esp+224], ecx + mov DWORD PTR [esp+228], ecx + mov DWORD PTR [esp+232], ecx + mov DWORD PTR [esp+236], ecx + mov DWORD PTR [esp+240], ecx + mov DWORD PTR [esp+244], ecx + mov DWORD PTR [esp+248], ecx + mov DWORD PTR [esp+252], ecx + mov DWORD PTR [esp+256], ecx + mov DWORD PTR [esp+260], ecx + mov DWORD PTR [esp+264], ecx + mov DWORD PTR [esp+268], ecx + mov DWORD PTR [esp+272], ecx + mov DWORD PTR [esp+276], ecx + mov DWORD PTR [esp+280], ecx + mov DWORD PTR [esp+284], ecx + mov DWORD PTR [esp+288], ecx + mov DWORD PTR [esp+292], ecx + mov DWORD PTR [esp+296], ecx + mov DWORD PTR [esp+300], ecx + mov DWORD PTR [esp+304], ecx + mov DWORD PTR [esp+308], ecx + mov DWORD PTR [esp+312], ecx + mov DWORD PTR [esp+316], ecx + mov DWORD PTR [esp+320], ecx + mov DWORD PTR [esp+324], ecx + mov DWORD PTR [esp+328], ecx + mov DWORD PTR [esp+332], ecx + mov DWORD PTR [esp+336], ecx + mov DWORD PTR [esp+340], ecx + mov DWORD PTR [esp+344], ecx + mov DWORD PTR [esp+348], ecx + mov DWORD PTR [esp+352], ecx + mov DWORD PTR [esp+356], ecx + mov DWORD PTR [esp+360], ecx + mov DWORD PTR [esp+364], ecx + mov DWORD PTR [esp+368], ecx + mov DWORD PTR [esp+372], ecx + mov DWORD PTR [esp+376], ecx + mov DWORD PTR [esp+380], ecx + mov DWORD PTR [esp+384], ecx + mov DWORD PTR [esp+388], ecx + mov DWORD PTR [esp+392], ecx + mov DWORD PTR [esp+396], ecx + mov DWORD PTR [esp+400], ecx + mov DWORD PTR [esp+404], ecx + mov DWORD PTR [esp+408], ecx + mov DWORD PTR [esp+412], ecx + mov DWORD PTR [esp+416], ecx + mov DWORD PTR [esp+420], ecx + mov DWORD PTR [esp+424], ecx + mov DWORD PTR [esp+428], ecx + mov DWORD PTR [esp+432], ecx + mov DWORD PTR [esp+436], ecx + mov DWORD PTR [esp+440], ecx + mov DWORD PTR [esp+444], ecx + mov DWORD PTR [esp+448], ecx + mov DWORD PTR [esp+452], ecx + mov DWORD PTR [esp+456], ecx + mov DWORD PTR [esp+460], ecx + mov DWORD PTR [esp+464], ecx + mov DWORD PTR [esp+468], ecx + mov DWORD PTR [esp+472], ecx + mov DWORD PTR [esp+476], ecx + mov DWORD PTR [esp+480], ecx + mov DWORD PTR [esp+484], ecx + mov DWORD PTR [esp+488], ecx + mov DWORD PTR [esp+492], ecx + mov DWORD PTR [esp+496], ecx + mov DWORD PTR [esp+500], ecx + mov DWORD PTR [esp+504], ecx + mov DWORD PTR [esp+508], ecx + mov DWORD PTR [esp+512], ecx + mov DWORD PTR [esp+516], ecx + mov DWORD PTR [esp+520], ecx + mov DWORD PTR [esp+524], ecx + mov DWORD PTR [esp+528], ecx + mov DWORD PTR [esp+532], ecx + mov DWORD PTR [esp+536], ecx + mov DWORD PTR [esp+540], ecx + mov DWORD PTR [esp+544], ecx + mov DWORD PTR [esp+548], ecx + mov DWORD PTR [esp+552], ecx + mov DWORD PTR [esp+556], ecx + mov DWORD PTR [esp+560], ecx + mov DWORD PTR [esp+564], ecx + mov DWORD PTR [esp+568], ecx + mov DWORD PTR [esp+572], ecx + mov DWORD PTR [esp+576], ecx + mov DWORD PTR [esp+580], ecx + mov DWORD PTR [esp+584], ecx + mov DWORD PTR [esp+588], ecx + mov DWORD PTR [esp+592], ecx + mov DWORD PTR [esp+596], ecx + mov DWORD PTR [esp+600], ecx + mov DWORD PTR [esp+604], ecx + mov DWORD PTR [esp+608], ecx + mov DWORD PTR [esp+612], ecx + mov DWORD PTR [esp+616], ecx + mov DWORD PTR [esp+620], ecx + mov DWORD PTR [esp+624], ecx + mov DWORD PTR [esp+628], ecx + mov DWORD PTR [esp+632], ecx + mov DWORD PTR [esp+636], ecx + mov DWORD PTR [esp+640], ecx + mov DWORD PTR [esp+644], ecx + mov DWORD PTR [esp+648], ecx + mov DWORD PTR [esp+652], ecx + mov DWORD PTR [esp+656], ecx + mov DWORD PTR [esp+660], ecx + mov DWORD PTR [esp+664], ecx + mov DWORD PTR [esp+668], ecx + mov DWORD PTR [esp+672], ecx + mov DWORD PTR [esp+676], ecx + mov DWORD PTR [esp+680], ecx + mov DWORD PTR [esp+684], ecx + mov DWORD PTR [esp+688], ecx + mov DWORD PTR [esp+692], ecx + mov DWORD PTR [esp+696], ecx + mov DWORD PTR [esp+700], ecx + mov DWORD PTR [esp+704], ecx + mov DWORD PTR [esp+708], ecx + mov DWORD PTR [esp+712], ecx + mov DWORD PTR [esp+716], ecx + mov DWORD PTR [esp+720], ecx + mov DWORD PTR [esp+724], ecx + mov DWORD PTR [esp+728], ecx + mov DWORD PTR [esp+732], ecx + mov DWORD PTR [esp+736], ecx + mov DWORD PTR [esp+740], ecx + mov DWORD PTR [esp+744], ecx + mov DWORD PTR [esp+748], ecx + mov DWORD PTR [esp+752], ecx + mov DWORD PTR [esp+756], ecx + mov DWORD PTR [esp+760], ecx + mov DWORD PTR [esp+764], ecx + mov DWORD PTR [esp+768], ecx + mov DWORD PTR [esp+772], ecx + mov DWORD PTR [esp+776], ecx + mov DWORD PTR [esp+780], ecx + mov DWORD PTR [esp+784], ecx + mov DWORD PTR [esp+788], ecx + mov DWORD PTR [esp+792], ecx + mov DWORD PTR [esp+796], ecx + mov DWORD PTR [esp+800], ecx + mov DWORD PTR [esp+804], ecx + mov DWORD PTR [esp+808], ecx + mov DWORD PTR [esp+812], ecx + mov DWORD PTR [esp+816], ecx + mov DWORD PTR [esp+820], ecx + mov DWORD PTR [esp+824], ecx + mov DWORD PTR [esp+828], ecx + mov DWORD PTR [esp+832], ecx + mov DWORD PTR [esp+836], ecx + mov DWORD PTR [esp+840], ecx + mov DWORD PTR [esp+844], ecx + mov DWORD PTR [esp+848], ecx + mov DWORD PTR [esp+852], ecx + mov DWORD PTR [esp+856], ecx + mov DWORD PTR [esp+860], ecx + mov DWORD PTR [esp+864], ecx + mov DWORD PTR [esp+868], ecx + mov DWORD PTR [esp+872], ecx + mov DWORD PTR [esp+876], ecx + mov DWORD PTR [esp+880], ecx + mov DWORD PTR [esp+884], ecx + mov DWORD PTR [esp+888], ecx + mov DWORD PTR [esp+892], ecx + mov DWORD PTR [esp+896], ecx + mov DWORD PTR [esp+900], ecx + mov DWORD PTR [esp+904], ecx + mov DWORD PTR [esp+908], ecx + mov DWORD PTR [esp+912], ecx + mov DWORD PTR [esp+916], ecx + mov DWORD PTR [esp+920], ecx + mov DWORD PTR [esp+924], ecx + mov DWORD PTR [esp+928], ecx + mov DWORD PTR [esp+932], ecx + mov DWORD PTR [esp+936], ecx + mov DWORD PTR [esp+940], ecx + mov DWORD PTR [esp+944], ecx + mov DWORD PTR [esp+948], ecx + mov DWORD PTR [esp+952], ecx + mov DWORD PTR [esp+956], ecx + mov DWORD PTR [esp+960], ecx + mov DWORD PTR [esp+964], ecx + lea esp, [esp+968] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86/src/aes_ctr.rs b/crates/verified-garbage-asm-x86/src/aes_ctr.rs index 34817e1d9e8..42a7612c37c 100644 --- a/crates/verified-garbage-asm-x86/src/aes_ctr.rs +++ b/crates/verified-garbage-asm-x86/src/aes_ctr.rs @@ -40,6 +40,46 @@ jmp 21f ) } +/// The CPU features `vg_aes_ctr_final_aesni` requires (`Artifact.features`). +pub const VG_AES_CTR_FINAL_AESNI_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES); + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 116 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes` target feature. +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final_aesni(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "jWQkwItEJESJRCQEi0QkSIlEJAiLRCRMiUQkDItEJFCJRCQQi0QkVIlEJBSLRCRYiUQkGIngg8AgiUQkHItEJByJGIlwBIl4CIloDItEJASLTCQIi1QkDItcJBCLdCQUwe4Ei3wkGFdWU1JRUA==" +call {vg_aes_ctr_aesni} +.base64 "WFhYWFhYi0QkFIPgD4XA" +je 20f +.base64 "i0QkHLkAAAAAiUgQiUgUiUgYiUgcicODwxCLRCQEi0wkCItUJAy+AQAAAIt8JBhXVlNSUVA=" +call {vg_aes_ctr_aesni} +.base64 "WFhYWFhYi1wkHIPDEIt0JBCLbCQUieiD5Q8p6AHG" +22: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "i0QkHIsYi3AEi3gIi2gMuQAAAACJTCQgiUwkJIlMJCiJTCQsiUwkMIlMJDSJTCQ4iUwkPI1kJEDD" +.p2align 6"#, + vg_aes_ctr_aesni = sym super::aes_ctr::vg_aes_ctr_aesni, + ) +} + /// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of whole blocks, in place: XORs the `n` 16-byte blocks at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `n = 0`), so that a further call continues the message. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. /// /// Contract: `VG.Spec.Ctr.aesContract`. Constant time: only the pointers, `rounds`, `n` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. @@ -72,3 +112,39 @@ jmp 21f vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, ) } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 116 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ctr_final(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "jWQkwItEJESJRCQEi0QkSIlEJAiLRCRMiUQkDItEJFCJRCQQi0QkVIlEJBSLRCRYiUQkGIngg8AgiUQkHItEJByJGIlwBIl4CIloDItEJASLTCQIi1QkDItcJBCLdCQUwe4Ei3wkGFdWU1JRUA==" +call {vg_aes_ctr} +.base64 "WFhYWFhYi0QkFIPgD4XA" +je 20f +.base64 "i0QkHLkAAAAAiUgQiUgUiUgYiUgcicODwxCLRCQEi0wkCItUJAy+AQAAAIt8JBhXVlNSUVA=" +call {vg_aes_ctr} +.base64 "WFhYWFhYi1wkHIPDEIt0JBCLbCQUieiD5Q8p6AHG" +22: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "i0QkHIsYi3AEi3gIi2gMuQAAAACJTCQgiUwkJIlMJCiJTCQsiUwkMIlMJDSJTCQ4iUwkPI1kJEDD" +.p2align 6"#, + vg_aes_ctr = sym super::aes_ctr::vg_aes_ctr, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/aes_ofb.rs b/crates/verified-garbage-asm-x86/src/aes_ofb.rs index 9d4b4f34cf2..88d2fb8e4fe 100644 --- a/crates/verified-garbage-asm-x86/src/aes_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/aes_ofb.rs @@ -40,6 +40,47 @@ jmp 21f ) } +/// The CPU features `vg_aes_ofb_final_aesni` requires (`Artifact.features`). +pub const VG_AES_OFB_FINAL_AESNI_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES); + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 100 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes` target feature. +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final_aesni(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "jWQk0ItEJDSJRCQEi0QkOIlEJAiLRCQ8iUQkDItEJECJRCQQi0QkRIlEJBSLRCRIiUQkGIngg8AgiUQkHItEJByJGIlwBIl4CIloDItEJASLTCQIi1QkDItcJBCLdCQUwe4Ei3wkGFdWU1JRUA==" +call {vg_aes_ofb_aesni} +.base64 "WFhYWFhYi0QkFIPgD4XA" +je 20f +.base64 "i0QkBItMJAiLXCQMvwEAAACLbCQYVVdTUVA=" +call {vg_aes_encrypt_blocks_aesni} +.base64 "WFhYWFiLXCQMi3QkEItsJBSJ6IPlDynoAcY=" +22: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "i0QkHIsYi3AEi3gIi2gMuQAAAACJTCQgiUwkJIlMJCiJTCQsjWQkMMM=" +.p2align 6"#, + vg_aes_ofb_aesni = sym super::aes_ofb::vg_aes_ofb_aesni, + vg_aes_encrypt_blocks_aesni = sym super::aes::vg_aes_encrypt_blocks_aesni, + ) +} + /// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of whole blocks, in place: XORs the `n` 16-byte blocks at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, and replaces `*iv` with `Oₙ` (leaving it unchanged if `n = 0`), so that a further call continues the message. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. /// /// Contract: `VG.Spec.Ofb.aesContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data. @@ -72,3 +113,40 @@ jmp 21f vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, ) } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 100 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_aes_ofb_final(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "jWQk0ItEJDSJRCQEi0QkOIlEJAiLRCQ8iUQkDItEJECJRCQQi0QkRIlEJBSLRCRIiUQkGIngg8AgiUQkHItEJByJGIlwBIl4CIloDItEJASLTCQIi1QkDItcJBCLdCQUwe4Ei3wkGFdWU1JRUA==" +call {vg_aes_ofb} +.base64 "WFhYWFhYi0QkFIPgD4XA" +je 20f +.base64 "i0QkBItMJAiLXCQMvwEAAACLbCQYVVdTUVA=" +call {vg_aes_encrypt_blocks} +.base64 "WFhYWFiLXCQMi3QkEItsJBSJ6IPlDynoAcY=" +22: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "i0QkHIsYi3AEi3gIi2gMuQAAAACJTCQgiUwkJIlMJCiJTCQsjWQkMMM=" +.p2align 6"#, + vg_aes_ofb = sym super::aes_ofb::vg_aes_ofb, + vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/blowfish_ofb.rs b/crates/verified-garbage-asm-x86/src/blowfish_ofb.rs index c394e76610b..6116b7e88d5 100644 --- a/crates/verified-garbage-asm-x86/src/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/blowfish_ofb.rs @@ -51,3 +51,62 @@ jmp 21f .p2align 6"#, ) } + +/// Blowfish-OFB encryption or decryption (NIST SP 800-38A §6.4, Schneier, FSE 1994) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Blowfish encryption under the schedule written by `vg_blowfish_expand_key`. +/// +/// Contract: `VG.Spec.Blowfish.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 4168 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 112 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_blowfish_ofb_final(schedule: *const [u8; 4168], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jWQkkItEJHSJRCQEi0QkeIlEJAiLRCR8iUQkDIuEJIAAAACJRCQQieCDwBiJRCQUi0QkFIlYMIlwNIl4OIloPInHi3QkCIsGiUdIi0YEiUdMi0QkDIlHQItEJBCJR0SFwA==" +je 20f +22: +.base64 "i3dAi29Ei0dIiUcoi0dMiUcsif2J64PDKIldIItdIIsDD8iJRRCLQwQPyIlFFItcJASBwwAQAACJXRw=" +23: +.base64 "i10ciwuLRRAxyIlFEIt1EMHuGIHm/wAAALj/AAAAifKD4gGD+gEZ0onBwckYMcgh0DHIifKD4gKD+gEZ0onBwckQMcgh0DHIvwAAAACLXCQE" +24: +.base64 "g/4EGdIhwoPuBIsLIdEJz4uLAAEAACHRwckYCc+LiwACAAAh0cHJEAnPi4sAAwAAIdHByQgJz4PDBItMJAQp2YH5AP///w==" +jne 24b +.base64 "ifKD4gGD+gEZ0on5wckIMc8h1zHPifKD4gKD+gEZ0on5wckQMc8h1zHPiX0Yi3UQwe4Qgeb/AAAAuP8AAACJ8oPiAYP6ARnSicHByRgxyCHQMciJ8oPiAoP6ARnSicHByRAxyCHQMci/AAAAAItcJAQ=" +25: +.base64 "g/4EGdIhwoPuBIuLAAQAACHRCc+LiwAFAAAh0cHJGAnPi4sABgAAIdHByRAJz4uLAAcAACHRwckICc+DwwSLTCQEKdmB+QD///8=" +jne 25b +.base64 "ifKD4gGD+gEZ0on5wckIMc8h1zHPifKD4gKD+gEZ0on5wckQMc8h1zHPi00YAfmJTRiLdRDB7giB5v8AAAC4/wAAAInyg+IBg/oBGdKJwcHJGDHIIdAxyInyg+ICg/oBGdKJwcHJEDHIIdAxyL8AAAAAi1wkBA==" +26: +.base64 "g/4EGdIhwoPuBIuLAAgAACHRCc+LiwAJAAAh0cHJGAnPi4sACgAAIdHByRAJz4uLAAsAACHRwckICc+DwwSLTCQEKdmB+QD///8=" +jne 26b +.base64 "ifKD4gGD+gEZ0on5wckIMc8h1zHPifKD4gKD+gEZ0on5wckQMc8h1zHPi00YMfmJTRiLdRCB5v8AAAC4/wAAAInyg+IBg/oBGdKJwcHJGDHIIdAxyInyg+ICg/oBGdKJwcHJEDHIIdAxyL8AAAAAi1wkBA==" +27: +.base64 "g/4EGdIhwoPuBIuLAAwAACHRCc+LiwANAAAh0cHJGAnPi4sADgAAIdHByRAJz4uLAA8AACHRwckICc+DwwSLTCQEKdmB+QD///8=" +jne 27b +.base64 "ifKD4gGD+gEZ0on5wckIMc8h1zHPifKD4gKD+gEZ0on5wckQMc8h1zHPi00YAfmJTRiLRRQzRRiLTRCJTRSJRRCLXRyDwwSJXRyLTCQEKdmB+cDv//8=" +jne 23b +.base64 "i10ciwszTRCLQwQzRRSJRRCJTRSLRRAPyIlFKItFFA/IiUUsie+Ld0CLb0SD/Qg=" +jb 28f +.base64 "i0coiUdIi0csiUdMiwYzRyiJBotGBDNHLIlGBIPGCIPtCIl3QIlvRA==" +jmp 29f +28: +.base64 "i0coiUdIi0csiUdMifuDwyg=" +210: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 210b +.base64 "iXdAiW9E" +29: +jne 22b +jmp 21f +20: +21: +.base64 "i3QkCItHSIkGi0dMiUYEi18wi3c0i288i384uQAAAACJTCQYiUwkHIlMJCCJTCQkiUwkKIlMJCyJTCQwiUwkNIlMJDiJTCQ8iUwkQIlMJESJTCRIiUwkTIlMJFCJTCRUiUwkWIlMJFyJTCRgiUwkZIlMJGiJTCRsjWQkcMM=" +.p2align 6"#, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/camellia_ctr.rs b/crates/verified-garbage-asm-x86/src/camellia_ctr.rs index dc5294f1226..3814500e577 100644 --- a/crates/verified-garbage-asm-x86/src/camellia_ctr.rs +++ b/crates/verified-garbage-asm-x86/src/camellia_ctr.rs @@ -48,3 +48,39 @@ jmp 25f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-CTR encryption or decryption (NIST SP 800-38A §6.5, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ctrFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the counter block or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 2856 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ctr_final(schedule: *const [u8; 272], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jWQkxItEJECJRCQEi0QkRIlEJAiLRCRIiUQkDItEJEyJRCQQi0QkUIlEJBSJ4IPAHIlEJBiLRCQYiRiJcASJeAiJaAyLRCQEi0wkCItUJAyLXCQQi3QkFMHuBFZTUlFQ" +call {vg_camellia_ctr} +.base64 "WFhYWFiLRCQUg+APhcA=" +je 20f +.base64 "i0QkGLkAAAAAiUgQiUgUiUgYiUgcicODwxCLRCQEi0wkCItUJAy+AQAAAFZTUlFQ" +call {vg_camellia_ctr} +.base64 "WFhYWFiLXCQYg8MQi3QkEItsJBSJ6IPlDynoAcY=" +22: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "i0QkGIsYi3AEi3gIi2gMuQAAAACJTCQciUwkIIlMJCSJTCQoiUwkLIlMJDCJTCQ0iUwkOI1kJDzD" +.p2align 6"#, + vg_camellia_ctr = sym super::camellia_ctr::vg_camellia_ctr, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/camellia_ofb.rs b/crates/verified-garbage-asm-x86/src/camellia_ofb.rs index b3d86222f78..62937439608 100644 --- a/crates/verified-garbage-asm-x86/src/camellia_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/camellia_ofb.rs @@ -48,3 +48,59 @@ jmp 25f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 2772 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_camellia_ofb_final(schedule: *const [u8; 272], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jaQkPPX//4uEJMgKAACJRCQEi4QkzAoAAIlEJAiLhCTQCgAAiUQkDIuEJNQKAACJRCQQi4Qk2AoAAIlEJBSJ4IPAHIlEJBiLRCQYiZiACgAAibCECgAAibiICgAAiaiMCgAAiceLdCQMiwaJh5gKAACLRgSJh5wKAACLRgiJh6AKAACLRgyJh6QKAACLRCQIg/gS" +je 20f +.base64 "i0wkBIn+gcagAQAAvSIAAAA=" +22: +.base64 "iwGJB4sfgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiR6LH9HrgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4Eix/B6wKB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXgiLH8HrA4HjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leDIsfwesEgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4Qix/B6wWB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXhSLH8HrBoHjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leGIsfwesHgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4ci0EEiQeLH4HjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leIIsf0euB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXiSLH8HrAoHjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leKIsfwesDgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4six/B6wSB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXjCLH8HrBYHjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leNIsfwesGgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV44ix/B6weB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXjyDxkCDwQiD7QE=" +jne 22b +jmp 21f +20: +.base64 "i0wkBIn+gcagAQAAvRoAAAA=" +23: +.base64 "iwGJB4sfgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiR6LH9HrgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4Eix/B6wKB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXgiLH8HrA4HjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leDIsfwesEgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4Qix/B6wWB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXhSLH8HrBoHjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leGIsfwesHgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4ci0EEiQeLH4HjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leIIsf0euB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXiSLH8HrAoHjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leKIsfwesDgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV4six/B6wSB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXjCLH8HrBYHjAQEBAYnawcofMdOJ2sHKHjHTidrByhwx04leNIsfwesGgeMBAQEBidrByh8x04nawcoeMdOJ2sHKHDHTiV44ix/B6weB4wEBAQGJ2sHKHzHTidrByh4x04nawcocMdOJXjyDxkCDwQiD7QE=" +jne 23b +21: +.base64 "i0QkEImHkAoAAItEJBSJh5QKAACFwA==" +je 24f +26: +.base64 "i7eQCgAAi6+UCgAAi4eYCgAAiYcgAQAAi4ecCgAAiYckAQAAi4egCgAAiYcoAQAAi4ekCgAAiYcsAQAAi0QkCIn5ulABAABSUVA=" +call {vg_camellia_crypt_prepared} +.base64 "WFhYi7eQCgAAi6+UCgAAg/0Q" +jb 27f +.base64 "i4cgAQAAiYeYCgAAi4ckAQAAiYecCgAAi4coAQAAiYegCgAAi4csAQAAiYekCgAAiwYzhyABAACJBotGBDOHJAEAAIlGBItGCDOHKAEAAIlGCItGDDOHLAEAAIlGDIPGEIPtEIm3kAoAAImvlAoAAA==" +jmp 28f +27: +.base64 "i4cgAQAAiYeYCgAAi4ckAQAAiYecCgAAi4coAQAAiYegCgAAi4csAQAAiYekCgAAifuBwyABAAA=" +29: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 29b +.base64 "ibeQCgAAia+UCgAA" +28: +jne 26b +jmp 25f +24: +25: +.base64 "i3QkDIuHmAoAAIkGi4ecCgAAiUYEi4egCgAAiUYIi4ekCgAAiUYMi5+ACgAAi7eECgAAi6+MCgAAi7+ICgAAuQAAAACJTCQciUwkIIlMJCSJTCQoiUwkLIlMJDCJTCQ0iUwkOIlMJDyJTCRAiUwkRIlMJEiJTCRMiUwkUIlMJFSJTCRYiUwkXIlMJGCJTCRkiUwkaIlMJGyJTCRwiUwkdIlMJHiJTCR8iYwkgAAAAImMJIQAAACJjCSIAAAAiYwkjAAAAImMJJAAAACJjCSUAAAAiYwkmAAAAImMJJwAAACJjCSgAAAAiYwkpAAAAImMJKgAAACJjCSsAAAAiYwksAAAAImMJLQAAACJjCS4AAAAiYwkvAAAAImMJMAAAACJjCTEAAAAiYwkyAAAAImMJMwAAACJjCTQAAAAiYwk1AAAAImMJNgAAACJjCTcAAAAiYwk4AAAAImMJOQAAACJjCToAAAAiYwk7AAAAImMJPAAAACJjCT0AAAAiYwk+AAAAImMJPwAAACJjCQAAQAAiYwkBAEAAImMJAgBAACJjCQMAQAAiYwkEAEAAImMJBQBAACJjCQYAQAAiYwkHAEAAImMJCABAACJjCQkAQAAiYwkKAEAAImMJCwBAACJjCQwAQAAiYwkNAEAAImMJDgBAACJjCQ8AQAAiYwkQAEAAImMJEQBAACJjCRIAQAAiYwkTAEAAImMJFABAACJjCRUAQAAiYwkWAEAAImMJFwBAACJjCRgAQAAiYwkZAEAAImMJGgBAACJjCRsAQAAiYwkcAEAAImMJHQBAACJjCR4AQAAiYwkfAEAAImMJIABAACJjCSEAQAAiYwkiAEAAImMJIwBAACJjCSQAQAAiYwklAEAAImMJJgBAACJjCScAQAAiYwkoAEAAImMJKQBAACJjCSoAQAAiYwkrAEAAImMJLABAACJjCS0AQAAiYwkuAEAAImMJLwBAACJjCTAAQAAiYwkxAEAAImMJMgBAACJjCTMAQAAiYwk0AEAAImMJNQBAACJjCTYAQAAiYwk3AEAAImMJOABAACJjCTkAQAAiYwk6AEAAImMJOwBAACJjCTwAQAAiYwk9AEAAImMJPgBAACJjCT8AQAAiYwkAAIAAImMJAQCAACJjCQIAgAAiYwkDAIAAImMJBACAACJjCQUAgAAiYwkGAIAAImMJBwCAACJjCQgAgAAiYwkJAIAAImMJCgCAACJjCQsAgAAiYwkMAIAAImMJDQCAACJjCQ4AgAAiYwkPAIAAImMJEACAACJjCREAgAAiYwkSAIAAImMJEwCAACJjCRQAgAAiYwkVAIAAImMJFgCAACJjCRcAgAAiYwkYAIAAImMJGQCAACJjCRoAgAAiYwkbAIAAImMJHACAACJjCR0AgAAiYwkeAIAAImMJHwCAACJjCSAAgAAiYwkhAIAAImMJIgCAACJjCSMAgAAiYwkkAIAAImMJJQCAACJjCSYAgAAiYwknAIAAImMJKACAACJjCSkAgAAiYwkqAIAAImMJKwCAACJjCSwAgAAiYwktAIAAImMJLgCAACJjCS8AgAAiYwkwAIAAImMJMQCAACJjCTIAgAAiYwkzAIAAImMJNACAACJjCTUAgAAiYwk2AIAAImMJNwCAACJjCTgAgAAiYwk5AIAAImMJOgCAACJjCTsAgAAiYwk8AIAAImMJPQCAACJjCT4AgAAiYwk/AIAAImMJAADAACJjCQEAwAAiYwkCAMAAImMJAwDAACJjCQQAwAAiYwkFAMAAImMJBgDAACJjCQcAwAAiYwkIAMAAImMJCQDAACJjCQoAwAAiYwkLAMAAImMJDADAACJjCQ0AwAAiYwkOAMAAImMJDwDAACJjCRAAwAAiYwkRAMAAImMJEgDAACJjCRMAwAAiYwkUAMAAImMJFQDAACJjCRYAwAAiYwkXAMAAImMJGADAACJjCRkAwAAiYwkaAMAAImMJGwDAACJjCRwAwAAiYwkdAMAAImMJHgDAACJjCR8AwAAiYwkgAMAAImMJIQDAACJjCSIAwAAiYwkjAMAAImMJJADAACJjCSUAwAAiYwkmAMAAImMJJwDAACJjCSgAwAAiYwkpAMAAImMJKgDAACJjCSsAwAAiYwksAMAAImMJLQDAACJjCS4AwAAiYwkvAMAAImMJMADAACJjCTEAwAAiYwkyAMAAImMJMwDAACJjCTQAwAAiYwk1AMAAImMJNgDAACJjCTcAwAAiYwk4AMAAImMJOQDAACJjCToAwAAiYwk7AMAAImMJPADAACJjCT0AwAAiYwk+AMAAImMJPwDAACJjCQABAAAiYwkBAQAAImMJAgEAACJjCQMBAAAiYwkEAQAAImMJBQEAACJjCQYBAAAiYwkHAQAAImMJCAEAACJjCQkBAAAiYwkKAQAAImMJCwEAACJjCQwBAAAiYwkNAQAAImMJDgEAACJjCQ8BAAAiYwkQAQAAImMJEQEAACJjCRIBAAAiYwkTAQAAImMJFAEAACJjCRUBAAAiYwkWAQAAImMJFwEAACJjCRgBAAAiYwkZAQAAImMJGgEAACJjCRsBAAAiYwkcAQAAImMJHQEAACJjCR4BAAAiYwkfAQAAImMJIAEAACJjCSEBAAAiYwkiAQAAImMJIwEAACJjCSQBAAAiYwklAQAAImMJJgEAACJjCScBAAAiYwkoAQAAImMJKQEAACJjCSoBAAAiYwkrAQAAImMJLAEAACJjCS0BAAAiYwkuAQAAImMJLwEAACJjCTABAAAiYwkxAQAAImMJMgEAACJjCTMBAAAiYwk0AQAAImMJNQEAACJjCTYBAAAiYwk3AQAAImMJOAEAACJjCTkBAAAiYwk6AQAAImMJOwEAACJjCTwBAAAiYwk9AQAAImMJPgEAACJjCT8BAAAiYwkAAUAAImMJAQFAACJjCQIBQAAiYwkDAUAAImMJBAFAACJjCQUBQAAiYwkGAUAAImMJBwFAACJjCQgBQAAiYwkJAUAAImMJCgFAACJjCQsBQAAiYwkMAUAAImMJDQFAACJjCQ4BQAAiYwkPAUAAImMJEAFAACJjCREBQAAiYwkSAUAAImMJEwFAACJjCRQBQAAiYwkVAUAAImMJFgFAACJjCRcBQAAiYwkYAUAAImMJGQFAACJjCRoBQAAiYwkbAUAAImMJHAFAACJjCR0BQAAiYwkeAUAAImMJHwFAACJjCSABQAAiYwkhAUAAImMJIgFAACJjCSMBQAAiYwkkAUAAImMJJQFAACJjCSYBQAAiYwknAUAAImMJKAFAACJjCSkBQAAiYwkqAUAAImMJKwFAACJjCSwBQAAiYwktAUAAImMJLgFAACJjCS8BQAAiYwkwAUAAImMJMQFAACJjCTIBQAAiYwkzAUAAImMJNAFAACJjCTUBQAAiYwk2AUAAImMJNwFAACJjCTgBQAAiYwk5AUAAImMJOgFAACJjCTsBQAAiYwk8AUAAImMJPQFAACJjCT4BQAAiYwk/AUAAImMJAAGAACJjCQEBgAAiYwkCAYAAImMJAwGAACJjCQQBgAAiYwkFAYAAImMJBgGAACJjCQcBgAAiYwkIAYAAImMJCQGAACJjCQoBgAAiYwkLAYAAImMJDAGAACJjCQ0BgAAiYwkOAYAAImMJDwGAACJjCRABgAAiYwkRAYAAImMJEgGAACJjCRMBgAAiYwkUAYAAImMJFQGAACJjCRYBgAAiYwkXAYAAImMJGAGAACJjCRkBgAAiYwkaAYAAImMJGwGAACJjCRwBgAAiYwkdAYAAImMJHgGAACJjCR8BgAAiYwkgAYAAImMJIQGAACJjCSIBgAAiYwkjAYAAImMJJAGAACJjCSUBgAAiYwkmAYAAImMJJwGAACJjCSgBgAAiYwkpAYAAImMJKgGAACJjCSsBgAAiYwksAYAAImMJLQGAACJjCS4BgAAiYwkvAYAAImMJMAGAACJjCTEBgAAiYwkyAYAAImMJMwGAACJjCTQBgAAiYwk1AYAAImMJNgGAACJjCTcBgAAiYwk4AYAAImMJOQGAACJjCToBgAAiYwk7AYAAImMJPAGAACJjCT0BgAAiYwk+AYAAImMJPwGAACJjCQABwAAiYwkBAcAAImMJAgHAACJjCQMBwAAiYwkEAcAAImMJBQHAACJjCQYBwAAiYwkHAcAAImMJCAHAACJjCQkBwAAiYwkKAcAAImMJCwHAACJjCQwBwAAiYwkNAcAAImMJDgHAACJjCQ8BwAAiYwkQAcAAImMJEQHAACJjCRIBwAAiYwkTAcAAImMJFAHAACJjCRUBwAAiYwkWAcAAImMJFwHAACJjCRgBwAAiYwkZAcAAImMJGgHAACJjCRsBwAAiYwkcAcAAImMJHQHAACJjCR4BwAAiYwkfAcAAImMJIAHAACJjCSEBwAAiYwkiAcAAImMJIwHAACJjCSQBwAAiYwklAcAAImMJJgHAACJjCScBwAAiYwkoAcAAImMJKQHAACJjCSoBwAAiYwkrAcAAImMJLAHAACJjCS0BwAAiYwkuAcAAImMJLwHAACJjCTABwAAiYwkxAcAAImMJMgHAACJjCTMBwAAiYwk0AcAAImMJNQHAACJjCTYBwAAiYwk3AcAAImMJOAHAACJjCTkBwAAiYwk6AcAAImMJOwHAACJjCTwBwAAiYwk9AcAAImMJPgHAACJjCT8BwAAiYwkAAgAAImMJAQIAACJjCQICAAAiYwkDAgAAImMJBAIAACJjCQUCAAAiYwkGAgAAImMJBwIAACJjCQgCAAAiYwkJAgAAImMJCgIAACJjCQsCAAAiYwkMAgAAImMJDQIAACJjCQ4CAAAiYwkPAgAAImMJEAIAACJjCRECAAAiYwkSAgAAImMJEwIAACJjCRQCAAAiYwkVAgAAImMJFgIAACJjCRcCAAAiYwkYAgAAImMJGQIAACJjCRoCAAAiYwkbAgAAImMJHAIAACJjCR0CAAAiYwkeAgAAImMJHwIAACJjCSACAAAiYwkhAgAAImMJIgIAACJjCSMCAAAiYwkkAgAAImMJJQIAACJjCSYCAAAiYwknAgAAImMJKAIAACJjCSkCAAAiYwkqAgAAImMJKwIAACJjCSwCAAAiYwktAgAAImMJLgIAACJjCS8CAAAiYwkwAgAAImMJMQIAACJjCTICAAAiYwkzAgAAImMJNAIAACJjCTUCAAAiYwk2AgAAImMJNwIAACJjCTgCAAAiYwk5AgAAImMJOgIAACJjCTsCAAAiYwk8AgAAImMJPQIAACJjCT4CAAAiYwk/AgAAImMJAAJAACJjCQECQAAiYwkCAkAAImMJAwJAACJjCQQCQAAiYwkFAkAAImMJBgJAACJjCQcCQAAiYwkIAkAAImMJCQJAACJjCQoCQAAiYwkLAkAAImMJDAJAACJjCQ0CQAAiYwkOAkAAImMJDwJAACJjCRACQAAiYwkRAkAAImMJEgJAACJjCRMCQAAiYwkUAkAAImMJFQJAACJjCRYCQAAiYwkXAkAAImMJGAJAACJjCRkCQAAiYwkaAkAAImMJGwJAACJjCRwCQAAiYwkdAkAAImMJHgJAACJjCR8CQAAiYwkgAkAAImMJIQJAACJjCSICQAAiYwkjAkAAImMJJAJAACJjCSUCQAAiYwkmAkAAImMJJwJAACJjCSgCQAAiYwkpAkAAImMJKgJAACJjCSsCQAAiYwksAkAAImMJLQJAACJjCS4CQAAiYwkvAkAAImMJMAJAACJjCTECQAAiYwkyAkAAImMJMwJAACJjCTQCQAAiYwk1AkAAImMJNgJAACJjCTcCQAAiYwk4AkAAImMJOQJAACJjCToCQAAiYwk7AkAAImMJPAJAACJjCT0CQAAiYwk+AkAAImMJPwJAACJjCQACgAAiYwkBAoAAImMJAgKAACJjCQMCgAAiYwkEAoAAImMJBQKAACJjCQYCgAAiYwkHAoAAImMJCAKAACJjCQkCgAAiYwkKAoAAImMJCwKAACJjCQwCgAAiYwkNAoAAImMJDgKAACJjCQ8CgAAiYwkQAoAAImMJEQKAACJjCRICgAAiYwkTAoAAImMJFAKAACJjCRUCgAAiYwkWAoAAImMJFwKAACJjCRgCgAAiYwkZAoAAImMJGgKAACJjCRsCgAAiYwkcAoAAImMJHQKAACJjCR4CgAAiYwkfAoAAImMJIAKAACJjCSECgAAiYwkiAoAAImMJIwKAACJjCSQCgAAiYwklAoAAImMJJgKAACJjCScCgAAiYwkoAoAAImMJKQKAACJjCSoCgAAiYwkrAoAAImMJLAKAACJjCS0CgAAiYwkuAoAAImMJLwKAACJjCTACgAAjaQkxAoAAMM=" +.p2align 6"#, + vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/cast5_ofb.rs b/crates/verified-garbage-asm-x86/src/cast5_ofb.rs index 2ebf47b2534..0851ed43442 100644 --- a/crates/verified-garbage-asm-x86/src/cast5_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/cast5_ofb.rs @@ -83,3 +83,94 @@ jmp 21f VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, ) } + +/// CAST5-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 2144 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is CAST5 encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_cast5_expand_key` writes them. +/// +/// Contract: `VG.Spec.Cast5.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 12 (for a key of up to 10 bytes) or 16 (for a longer one). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 336 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_cast5_ofb_final(schedule: *const [u8; 128], rounds: usize, iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jaQktP7//4uEJFABAACJRCQEi4QkVAEAAIlEJAiLhCRYAQAAiUQkDIuEJFwBAACJRCQQi4QkYAEAAIlEJBSJ4IPAHIlEJBiLRCQYiZgIAQAAibAMAQAAibgQAQAAiagUAQAAiceLdCQMiwaJhyABAACLRgSJhyQBAACLRCQQiYcYAQAAi0QkFImHHAEAAIXA" +je 20f +22: +.base64 "i7cYAQAAi68cAQAAi4cgAQAAiYcAAQAAi4ckAQAAiYcEAQAAif6LRCQEiUYwi0QkCIlGNInwBQABAACJRjiLVjiLGg/Li2oED82LVjCJVkCLTjTB6QKDwQGJTkSLTjSD+RA=" +23: +.base64 "i1ZAiwIB6ItKQInKg+IBg+oBicfBzx8x+CHQMfjR6YnKg+IBg+oBicfBzx4x+CHQMfjR6YnKg+IBg+oBicfBzxwx+CHQMfjR6YnKg+IBg+oBicfBzxgx+CHQMfjR6YnKg+IBg+oBicfBzxAx+CHQMfiJwYHh/wAAAInCweoIgeL/AAAAicfB7xCB5/8AAADB6BhmD27BZg9u4mYPYsRmD27nZg9u6GYPYuVmD2zE" +call 2f +2: +mov eax, DWORD PTR [esp] +.byte 0x81, 192 +.long {VG_CAST5_S1234} - 2b +.base64 "WYnBukAAAABmD+/JZg/v0rgBAAAAZg9u2GYPcNsAuP////9mD27wZg9w9gA=" +24: +.base64 "Zg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vKWYP2+xmD+vNZg/+02YPb+BmD+/iZg/+5mYPctQIZg9v/GYPcvcIZg/r5/MPb2kQZg/b7GYP681mD/7TZg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vaSBmD9vsZg/rzWYP/tNmD2/gZg/v4mYP/uZmD3LUCGYPb/xmD3L3CGYP6+fzD29pMGYP2+xmD+vNZg/+04PBQIPqAQ==" +jne 24b +.base64 "8w9/DotGDDNGCCtGBAMGMdiJ64nFi1ZAg8IEiVZAi1ZAiwIx6ItKQInKg+IBg+oBicfBzx8x+CHQMfjR6YnKg+IBg+oBicfBzx4x+CHQMfjR6YnKg+IBg+oBicfBzxwx+CHQMfjR6YnKg+IBg+oBicfBzxgx+CHQMfjR6YnKg+IBg+oBicfBzxAx+CHQMfiJwYHh/wAAAInCweoIgeL/AAAAicfB7xCB5/8AAADB6BhmD27BZg9u4mYPYsRmD27nZg9u6GYPYuVmD2zE" +call 2f +2: +mov eax, DWORD PTR [esp] +.byte 0x81, 192 +.long {VG_CAST5_S1234} - 2b +.base64 "WYnBukAAAABmD+/JZg/v0rgBAAAAZg9u2GYPcNsAuP////9mD27wZg9w9gA=" +25: +.base64 "Zg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vKWYP2+xmD+vNZg/+02YPb+BmD+/iZg/+5mYPctQIZg9v/GYPcvcIZg/r5/MPb2kQZg/b7GYP681mD/7TZg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vaSBmD9vsZg/rzWYP/tNmD2/gZg/v4mYP/uZmD3LUCGYPb/xmD3L3CGYP6+fzD29pMGYP2+xmD+vNZg/+04PBQIPqAQ==" +jne 25b +.base64 "8w9/DotGDCtGCANGBDMGMdiJ64nFi1ZAg8IEiVZAi1ZAiwIp6ItKQInKg+IBg+oBicfBzx8x+CHQMfjR6YnKg+IBg+oBicfBzx4x+CHQMfjR6YnKg+IBg+oBicfBzxwx+CHQMfjR6YnKg+IBg+oBicfBzxgx+CHQMfjR6YnKg+IBg+oBicfBzxAx+CHQMfiJwYHh/wAAAInCweoIgeL/AAAAicfB7xCB5/8AAADB6BhmD27BZg9u4mYPYsRmD27nZg9u6GYPYuVmD2zE" +call 2f +2: +mov eax, DWORD PTR [esp] +.byte 0x81, 192 +.long {VG_CAST5_S1234} - 2b +.base64 "WYnBukAAAABmD+/JZg/v0rgBAAAAZg9u2GYPcNsAuP////9mD27wZg9w9gA=" +26: +.base64 "Zg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vKWYP2+xmD+vNZg/+02YPb+BmD+/iZg/+5mYPctQIZg9v/GYPcvcIZg/r5/MPb2kQZg/b7GYP681mD/7TZg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vaSBmD9vsZg/rzWYP/tNmD2/gZg/v4mYP/uZmD3LUCGYPb/xmD3L3CGYP6+fzD29pMGYP2+xmD+vNZg/+04PBQIPqAQ==" +jne 26b +.base64 "8w9/DotGDANGCDNGBCsGMdiJ64nFi1ZAg8IEiVZAi1ZEg+oBiVZE" +jne 23b +.base64 "i040g/kQ" +je 27f +jmp 28f +27: +.base64 "i1ZAiwIB6ItKQInKg+IBg+oBicfBzx8x+CHQMfjR6YnKg+IBg+oBicfBzx4x+CHQMfjR6YnKg+IBg+oBicfBzxwx+CHQMfjR6YnKg+IBg+oBicfBzxgx+CHQMfjR6YnKg+IBg+oBicfBzxAx+CHQMfiJwYHh/wAAAInCweoIgeL/AAAAicfB7xCB5/8AAADB6BhmD27BZg9u4mYPYsRmD27nZg9u6GYPYuVmD2zE" +call 2f +2: +mov eax, DWORD PTR [esp] +.byte 0x81, 192 +.long {VG_CAST5_S1234} - 2b +.base64 "WYnBukAAAABmD+/JZg/v0rgBAAAAZg9u2GYPcNsAuP////9mD27wZg9w9gA=" +29: +.base64 "Zg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vKWYP2+xmD+vNZg/+02YPb+BmD+/iZg/+5mYPctQIZg9v/GYPcvcIZg/r5/MPb2kQZg/b7GYP681mD/7TZg9v4GYP7+JmD/7mZg9y1AhmD2/8Zg9y9whmD+vn8w9vaSBmD9vsZg/rzWYP/tNmD2/gZg/v4mYP/uZmD3LUCGYPb/xmD3L3CGYP6+fzD29pMGYP2+xmD+vNZg/+04PBQIPqAQ==" +jne 29b +.base64 "8w9/DotGDDNGCCtGBAMGMdiJ64nFi1ZAg8IEiVZA" +28: +.base64 "i1Y4i4YYAQAAi44cAQAAD82JKg/LiVoEiYYYAQAAiY4cAQAAifeLtxgBAACLrxwBAACD/Qg=" +jb 210f +.base64 "i4cAAQAAiYcgAQAAi4cEAQAAiYckAQAAiwYzhwABAACJBotGBDOHBAEAAIlGBIPGCIPtCIm3GAEAAImvHAEAAA==" +jmp 211f +210: +.base64 "i4cAAQAAiYcgAQAAi4cEAQAAiYckAQAAifuBwwABAAA=" +212: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 212b +.base64 "ibcYAQAAia8cAQAA" +211: +jne 22b +jmp 21f +20: +21: +.base64 "i3QkDIuHIAEAAIkGi4ckAQAAiUYEi58IAQAAi7cMAQAAi68UAQAAi78QAQAAuQAAAACJTCQciUwkIIlMJCSJTCQoiUwkLIlMJDCJTCQ0iUwkOIlMJDyJTCRAiUwkRIlMJEiJTCRMiUwkUIlMJFSJTCRYiUwkXIlMJGCJTCRkiUwkaIlMJGyJTCRwiUwkdIlMJHiJTCR8iYwkgAAAAImMJIQAAACJjCSIAAAAiYwkjAAAAImMJJAAAACJjCSUAAAAiYwkmAAAAImMJJwAAACJjCSgAAAAiYwkpAAAAImMJKgAAACJjCSsAAAAiYwksAAAAImMJLQAAACJjCS4AAAAiYwkvAAAAImMJMAAAACJjCTEAAAAiYwkyAAAAImMJMwAAACJjCTQAAAAiYwk1AAAAImMJNgAAACJjCTcAAAAiYwk4AAAAImMJOQAAACJjCToAAAAiYwk7AAAAImMJPAAAACJjCT0AAAAiYwk+AAAAImMJPwAAACJjCQAAQAAiYwkBAEAAImMJAgBAACJjCQMAQAAiYwkEAEAAImMJBQBAACJjCQYAQAAiYwkHAEAAImMJCABAACJjCQkAQAAiYwkKAEAAImMJCwBAACJjCQwAQAAiYwkNAEAAImMJDgBAACJjCQ8AQAAiYwkQAEAAImMJEQBAACJjCRIAQAAjaQkTAEAAMM=" +.p2align 6"#, + VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/idea_ofb.rs b/crates/verified-garbage-asm-x86/src/idea_ofb.rs index 6205962d4fe..4b6baf26b31 100644 --- a/crates/verified-garbage-asm-x86/src/idea_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/idea_ofb.rs @@ -31,3 +31,42 @@ jmp 21f .p2align 6"#, ) } + +/// IDEA-OFB encryption or decryption (NIST SP 800-38A §6.4, Lai 1992 §3.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is IDEA encryption under the encryption subkeys written by `vg_idea_expand_key`. +/// +/// Contract: `VG.Spec.Idea.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 104 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 208 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_idea_ofb_final(schedule: *const [u8; 104], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jaQkMP///4uEJNQAAACJRCQEi4Qk2AAAAIlEJAiLhCTcAAAAiUQkDIuEJOAAAACJRCQQieCDwBiJRCQUi0QkFImYjAAAAImwkAAAAIm4lAAAAImomAAAAInHi3QkCIsGiYekAAAAi0YEiYeoAAAAif6LVCQEiwKJBotCBIlGBItCCIlGCItCDIlGDItCEIlGEItCFIlGFItCGIlGGItCHIlGHItCIIlGIItCJIlGJItCKIlGKItCLIlGLItCMIlGMItCNIlGNItCOIlGOItCPIlGPItCQIlGQItCRIlGRItCSIlGSItCTIlGTItCUIlGUItCVIlGVItCWIlGWItCXIlGXItCYIlGYItCZIlGZItEJAyJh5wAAACLRCQQiYegAAAAhcA=" +je 20f +22: +.base64 "i7ecAAAAi6+gAAAAi4ekAAAAiYeEAAAAi4eoAAAAiYeIAAAAif6J+AWEAAAAiUZsi0ZsixgPy4nZwesQgeH//wAAi3gED8+J/cHvEIHl//8AAInYg+gBJf//AACDwAGLFoPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVgaD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDTgKB4f//AAADfgSB5///AACJ2DH4g+gBJf//AACDwAGLVgiD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoicgx6AHQg+gBJf//AACDwAGLVgqD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdcxwTHFidiD6AEl//8AAIPAAYtWDIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVhKD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDfg6B5///AAADThCB4f//AACJ2DHIg+gBJf//AACDwAGLVhSD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoifgx6AHQg+gBJf//AACDwAGLVhaD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdExxzHFidiD6AEl//8AAIPAAYtWGIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVh6D6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDThqB4f//AAADfhyB5///AACJ2DH4g+gBJf//AACDwAGLViCD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoicgx6AHQg+gBJf//AACDwAGLViKD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdcxwTHFidiD6AEl//8AAIPAAYtWJIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLViqD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDfiaB5///AAADTiiB4f//AACJ2DHIg+gBJf//AACDwAGLViyD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoifgx6AHQg+gBJf//AACDwAGLVi6D6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdExxzHFidiD6AEl//8AAIPAAYtWMIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVjaD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDTjKB4f//AAADfjSB5///AACJ2DH4g+gBJf//AACDwAGLVjiD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoicgx6AHQg+gBJf//AACDwAGLVjqD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdcxwTHFidiD6AEl//8AAIPAAYtWPIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVkKD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDfj6B5///AAADTkCB4f//AACJ2DHIg+gBJf//AACDwAGLVkSD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoifgx6AHQg+gBJf//AACDwAGLVkaD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdExxzHFidiD6AEl//8AAIPAAYtWSIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVk6D6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDTkqB4f//AAADfkyB5///AACJ2DH4g+gBJf//AACDwAGLVlCD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoicgx6AHQg+gBJf//AACDwAGLVlKD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdcxwTHFidiD6AEl//8AAIPAAYtWVIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVlqD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDflaB5///AAADTliB4f//AACJ2DHIg+gBJf//AACDwAGLVlyD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAiVZoifgx6AHQg+gBJf//AACDwAGLVl6D6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAi0ZoAdAl//8AADHTMdExxzHFidiD6AEl//8AAIPAAYtWYIPqAYHi//8AAIPCAffig+gBicKB4v//AACDwgHB6BApwonQwegfAcKB4v//AACJ04nog+gBJf//AACDwAGLVmaD6gGB4v//AACDwgH34oPoAYnCgeL//wAAg8IBwegQKcKJ0MHoHwHCgeL//wAAidUDfmKB5///AAADTmSB4f//AADByxAJ+w/LiZ6EAAAAwckQCekPyYmOiAAAAIn3i7ecAAAAi6+gAAAAg/0I" +jb 23f +.base64 "i4eEAAAAiYekAAAAi4eIAAAAiYeoAAAAiwYzh4QAAACJBotGBDOHiAAAAIlGBIPGCIPtCIm3nAAAAImvoAAAAA==" +jmp 24f +23: +.base64 "i4eEAAAAiYekAAAAi4eIAAAAiYeoAAAAifuBw4QAAAA=" +25: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 25b +.base64 "ibecAAAAia+gAAAA" +24: +jne 22b +jmp 21f +20: +21: +.base64 "i3QkCIuHpAAAAIkGi4eoAAAAiUYEi5+MAAAAi7eQAAAAi6+YAAAAi7+UAAAAuQAAAACJTCQYiUwkHIlMJCCJTCQkiUwkKIlMJCyJTCQwiUwkNIlMJDiJTCQ8iUwkQIlMJESJTCRIiUwkTIlMJFCJTCRUiUwkWIlMJFyJTCRgiUwkZIlMJGiJTCRsiUwkcIlMJHSJTCR4iUwkfImMJIAAAACJjCSEAAAAiYwkiAAAAImMJIwAAACJjCSQAAAAiYwklAAAAImMJJgAAACJjCScAAAAiYwkoAAAAImMJKQAAACJjCSoAAAAiYwkrAAAAImMJLAAAACJjCS0AAAAiYwkuAAAAImMJLwAAACJjCTAAAAAiYwkxAAAAImMJMgAAACJjCTMAAAAjaQk0AAAAMM=" +.p2align 6"#, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/seed_ofb.rs b/crates/verified-garbage-asm-x86/src/seed_ofb.rs index 657e98bdbfe..8e5f9bb3c8b 100644 --- a/crates/verified-garbage-asm-x86/src/seed_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/seed_ofb.rs @@ -34,3 +34,45 @@ jmp 21f vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, ) } + +/// SEED-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 4269 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SEED encryption under the schedule written by `vg_seed_expand_key`. +/// +/// Contract: `VG.Spec.Seed.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 1188 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_seed_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jaQkcPv//4uEJJQEAACJRCQEi4QkmAQAAIlEJAiLhCScBAAAiUQkDIuEJKAEAACJRCQQieCDwBiJRCQUi0QkFImYUAQAAImwVAQAAIm4WAQAAImoXAQAAInHi3QkCIsGiYdoBAAAi0YEiYdsBAAAi0YIiYdwBAAAi0YMiYd0BAAAi0QkDImHYAQAAItEJBCJh2QEAACFwA==" +je 20f +22: +.base64 "i7dgBAAAi69kBAAAi4doBAAAiYdABAAAi4dsBAAAiYdEBAAAi4dwBAAAiYdIBAAAi4d0BAAAiYdMBAAAi7dgBAAAi69kBAAAi0QkBIn5gcFABAAAugEAAABXUlFQ" +call {vg_seed_encrypt_blocks} +.base64 "WFhYWIt8JBSJt2AEAACJr2QEAACLt2AEAACLr2QEAACD/RA=" +jb 23f +.base64 "i4dABAAAiYdoBAAAi4dEBAAAiYdsBAAAi4dIBAAAiYdwBAAAi4dMBAAAiYd0BAAAiwYzh0AEAACJBotGBDOHRAQAAIlGBItGCDOHSAQAAIlGCItGDDOHTAQAAIlGDIPGEIPtEIm3YAQAAImvZAQAAA==" +jmp 24f +23: +.base64 "i4dABAAAiYdoBAAAi4dEBAAAiYdsBAAAi4dIBAAAiYdwBAAAi4dMBAAAiYd0BAAAifuBw0AEAAA=" +25: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 25b +.base64 "ibdgBAAAia9kBAAA" +24: +jne 22b +jmp 21f +20: +21: +.base64 "i3QkCIuHaAQAAIkGi4dsBAAAiUYEi4dwBAAAiUYIi4d0BAAAiUYMi59QBAAAi7dUBAAAi69cBAAAi79YBAAAuQAAAACJTCQYiUwkHIlMJCCJTCQkiUwkKIlMJCyJTCQwiUwkNIlMJDiJTCQ8iUwkQIlMJESJTCRIiUwkTIlMJFCJTCRUiUwkWIlMJFyJTCRgiUwkZIlMJGiJTCRsiUwkcIlMJHSJTCR4iUwkfImMJIAAAACJjCSEAAAAiYwkiAAAAImMJIwAAACJjCSQAAAAiYwklAAAAImMJJgAAACJjCScAAAAiYwkoAAAAImMJKQAAACJjCSoAAAAiYwkrAAAAImMJLAAAACJjCS0AAAAiYwkuAAAAImMJLwAAACJjCTAAAAAiYwkxAAAAImMJMgAAACJjCTMAAAAiYwk0AAAAImMJNQAAACJjCTYAAAAiYwk3AAAAImMJOAAAACJjCTkAAAAiYwk6AAAAImMJOwAAACJjCTwAAAAiYwk9AAAAImMJPgAAACJjCT8AAAAiYwkAAEAAImMJAQBAACJjCQIAQAAiYwkDAEAAImMJBABAACJjCQUAQAAiYwkGAEAAImMJBwBAACJjCQgAQAAiYwkJAEAAImMJCgBAACJjCQsAQAAiYwkMAEAAImMJDQBAACJjCQ4AQAAiYwkPAEAAImMJEABAACJjCREAQAAiYwkSAEAAImMJEwBAACJjCRQAQAAiYwkVAEAAImMJFgBAACJjCRcAQAAiYwkYAEAAImMJGQBAACJjCRoAQAAiYwkbAEAAImMJHABAACJjCR0AQAAiYwkeAEAAImMJHwBAACJjCSAAQAAiYwkhAEAAImMJIgBAACJjCSMAQAAiYwkkAEAAImMJJQBAACJjCSYAQAAiYwknAEAAImMJKABAACJjCSkAQAAiYwkqAEAAImMJKwBAACJjCSwAQAAiYwktAEAAImMJLgBAACJjCS8AQAAiYwkwAEAAImMJMQBAACJjCTIAQAAiYwkzAEAAImMJNABAACJjCTUAQAAiYwk2AEAAImMJNwBAACJjCTgAQAAiYwk5AEAAImMJOgBAACJjCTsAQAAiYwk8AEAAImMJPQBAACJjCT4AQAAiYwk/AEAAImMJAACAACJjCQEAgAAiYwkCAIAAImMJAwCAACJjCQQAgAAiYwkFAIAAImMJBgCAACJjCQcAgAAiYwkIAIAAImMJCQCAACJjCQoAgAAiYwkLAIAAImMJDACAACJjCQ0AgAAiYwkOAIAAImMJDwCAACJjCRAAgAAiYwkRAIAAImMJEgCAACJjCRMAgAAiYwkUAIAAImMJFQCAACJjCRYAgAAiYwkXAIAAImMJGACAACJjCRkAgAAiYwkaAIAAImMJGwCAACJjCRwAgAAiYwkdAIAAImMJHgCAACJjCR8AgAAiYwkgAIAAImMJIQCAACJjCSIAgAAiYwkjAIAAImMJJACAACJjCSUAgAAiYwkmAIAAImMJJwCAACJjCSgAgAAiYwkpAIAAImMJKgCAACJjCSsAgAAiYwksAIAAImMJLQCAACJjCS4AgAAiYwkvAIAAImMJMACAACJjCTEAgAAiYwkyAIAAImMJMwCAACJjCTQAgAAiYwk1AIAAImMJNgCAACJjCTcAgAAiYwk4AIAAImMJOQCAACJjCToAgAAiYwk7AIAAImMJPACAACJjCT0AgAAiYwk+AIAAImMJPwCAACJjCQAAwAAiYwkBAMAAImMJAgDAACJjCQMAwAAiYwkEAMAAImMJBQDAACJjCQYAwAAiYwkHAMAAImMJCADAACJjCQkAwAAiYwkKAMAAImMJCwDAACJjCQwAwAAiYwkNAMAAImMJDgDAACJjCQ8AwAAiYwkQAMAAImMJEQDAACJjCRIAwAAiYwkTAMAAImMJFADAACJjCRUAwAAiYwkWAMAAImMJFwDAACJjCRgAwAAiYwkZAMAAImMJGgDAACJjCRsAwAAiYwkcAMAAImMJHQDAACJjCR4AwAAiYwkfAMAAImMJIADAACJjCSEAwAAiYwkiAMAAImMJIwDAACJjCSQAwAAiYwklAMAAImMJJgDAACJjCScAwAAiYwkoAMAAImMJKQDAACJjCSoAwAAiYwkrAMAAImMJLADAACJjCS0AwAAiYwkuAMAAImMJLwDAACJjCTAAwAAiYwkxAMAAImMJMgDAACJjCTMAwAAiYwk0AMAAImMJNQDAACJjCTYAwAAiYwk3AMAAImMJOADAACJjCTkAwAAiYwk6AMAAImMJOwDAACJjCTwAwAAiYwk9AMAAImMJPgDAACJjCT8AwAAiYwkAAQAAImMJAQEAACJjCQIBAAAiYwkDAQAAImMJBAEAACJjCQUBAAAiYwkGAQAAImMJBwEAACJjCQgBAAAiYwkJAQAAImMJCgEAACJjCQsBAAAiYwkMAQAAImMJDQEAACJjCQ4BAAAiYwkPAQAAImMJEAEAACJjCREBAAAiYwkSAQAAImMJEwEAACJjCRQBAAAiYwkVAQAAImMJFgEAACJjCRcBAAAiYwkYAQAAImMJGQEAACJjCRoBAAAiYwkbAQAAImMJHAEAACJjCR0BAAAiYwkeAQAAImMJHwEAACJjCSABAAAiYwkhAQAAImMJIgEAACJjCSMBAAAjaQkkAQAAMM=" +.p2align 6"#, + vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/sm4_ctr.rs b/crates/verified-garbage-asm-x86/src/sm4_ctr.rs index e154a800457..d7a5836e076 100644 --- a/crates/verified-garbage-asm-x86/src/sm4_ctr.rs +++ b/crates/verified-garbage-asm-x86/src/sm4_ctr.rs @@ -37,3 +37,38 @@ jmp 21f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-CTR encryption or decryption (NIST SP 800-38A §6.5, draft-ribose-cfrg-sm4-10 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ctrFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the counter block or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 1592 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ctr_final(schedule: *const [u8; 128], ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jWQkyItEJDyJRCQEi0QkQIlEJAiLRCREiUQkDItEJEiJRCQQieCDwBiJRCQUi0QkFIkYiXAEiXgIiWgMi0QkBItUJAiLXCQMi3QkEMHuBFZTUlA=" +call {vg_sm4_ctr} +.base64 "WFhYWItEJBCD4A+FwA==" +je 20f +.base64 "i0QkFLkAAAAAiUgQiUgUiUgYiUgcicODwxCLRCQEi1QkCL4BAAAAVlNSUA==" +call {vg_sm4_ctr} +.base64 "WFhYWItcJBSDwxCLdCQMi2wkEInog+UPKegBxg==" +22: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "i0QkFIsYi3AEi3gIi2gMuQAAAACJTCQYiUwkHIlMJCCJTCQkiUwkKIlMJCyJTCQwiUwkNI1kJDjD" +.p2align 6"#, + vg_sm4_ctr = sym super::sm4_ctr::vg_sm4_ctr, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/sm4_ofb.rs b/crates/verified-garbage-asm-x86/src/sm4_ofb.rs index 7c01384766d..358bbca73c0 100644 --- a/crates/verified-garbage-asm-x86/src/sm4_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/sm4_ofb.rs @@ -37,3 +37,48 @@ jmp 21f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-OFB encryption or decryption (NIST SP 800-38A §6.4, GB/T 32907-2016 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 1516 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_sm4_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jaQkKPr//4uEJNwFAACJRCQEi4Qk4AUAAIlEJAiLhCTkBQAAiUQkDIuEJOgFAACJRCQQieCDwBiJRCQUi0QkFImYmAUAAImwnAUAAIm4oAUAAImopAUAAInHi3QkCIsGiYewBQAAi0YEiYe0BQAAi0YIiYe4BQAAi0YMiYe8BQAAuLMAAAC6AAAAAItMJARQV1JR" +call {vg_sm4_prepare_keys} +.base64 "WFhYWIt8JBSLRCQMiYeoBQAAi0QkEImHrAUAAIXA" +je 20f +22: +.base64 "i7eoBQAAi6+sBQAAi4ewBQAAiYcAAQAAi4e0BQAAiYcEAQAAi4e4BQAAiYcIAQAAi4e8BQAAiYcMAQAAi7eoBQAAi6+sBQAAuLMAAABQVw==" +call {vg_sm4_crypt_prepared} +.base64 "WFiJt6gFAACJr6wFAACLt6gFAACLr6wFAACD/RA=" +jb 23f +.base64 "i4cAAQAAiYewBQAAi4cEAQAAiYe0BQAAi4cIAQAAiYe4BQAAi4cMAQAAiYe8BQAAiwYzhwABAACJBotGBDOHBAEAAIlGBItGCDOHCAEAAIlGCItGDDOHDAEAAIlGDIPGEIPtEIm3qAUAAImvrAUAAA==" +jmp 24f +23: +.base64 "i4cAAQAAiYewBQAAi4cEAQAAiYe0BQAAi4cIAQAAiYe4BQAAi4cMAQAAiYe8BQAAifuBwwABAAA=" +25: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 25b +.base64 "ibeoBQAAia+sBQAA" +24: +jne 22b +jmp 21f +20: +21: +.base64 "i3QkCIuHsAUAAIkGi4e0BQAAiUYEi4e4BQAAiUYIi4e8BQAAiUYMi5+YBQAAi7ecBQAAi6+kBQAAi7+gBQAAuQAAAACJTCQYiUwkHIlMJCCJTCQkiUwkKIlMJCyJTCQwiUwkNIlMJDiJTCQ8iUwkQIlMJESJTCRIiUwkTIlMJFCJTCRUiUwkWIlMJFyJTCRgiUwkZIlMJGiJTCRsiUwkcIlMJHSJTCR4iUwkfImMJIAAAACJjCSEAAAAiYwkiAAAAImMJIwAAACJjCSQAAAAiYwklAAAAImMJJgAAACJjCScAAAAiYwkoAAAAImMJKQAAACJjCSoAAAAiYwkrAAAAImMJLAAAACJjCS0AAAAiYwkuAAAAImMJLwAAACJjCTAAAAAiYwkxAAAAImMJMgAAACJjCTMAAAAiYwk0AAAAImMJNQAAACJjCTYAAAAiYwk3AAAAImMJOAAAACJjCTkAAAAiYwk6AAAAImMJOwAAACJjCTwAAAAiYwk9AAAAImMJPgAAACJjCT8AAAAiYwkAAEAAImMJAQBAACJjCQIAQAAiYwkDAEAAImMJBABAACJjCQUAQAAiYwkGAEAAImMJBwBAACJjCQgAQAAiYwkJAEAAImMJCgBAACJjCQsAQAAiYwkMAEAAImMJDQBAACJjCQ4AQAAiYwkPAEAAImMJEABAACJjCREAQAAiYwkSAEAAImMJEwBAACJjCRQAQAAiYwkVAEAAImMJFgBAACJjCRcAQAAiYwkYAEAAImMJGQBAACJjCRoAQAAiYwkbAEAAImMJHABAACJjCR0AQAAiYwkeAEAAImMJHwBAACJjCSAAQAAiYwkhAEAAImMJIgBAACJjCSMAQAAiYwkkAEAAImMJJQBAACJjCSYAQAAiYwknAEAAImMJKABAACJjCSkAQAAiYwkqAEAAImMJKwBAACJjCSwAQAAiYwktAEAAImMJLgBAACJjCS8AQAAiYwkwAEAAImMJMQBAACJjCTIAQAAiYwkzAEAAImMJNABAACJjCTUAQAAiYwk2AEAAImMJNwBAACJjCTgAQAAiYwk5AEAAImMJOgBAACJjCTsAQAAiYwk8AEAAImMJPQBAACJjCT4AQAAiYwk/AEAAImMJAACAACJjCQEAgAAiYwkCAIAAImMJAwCAACJjCQQAgAAiYwkFAIAAImMJBgCAACJjCQcAgAAiYwkIAIAAImMJCQCAACJjCQoAgAAiYwkLAIAAImMJDACAACJjCQ0AgAAiYwkOAIAAImMJDwCAACJjCRAAgAAiYwkRAIAAImMJEgCAACJjCRMAgAAiYwkUAIAAImMJFQCAACJjCRYAgAAiYwkXAIAAImMJGACAACJjCRkAgAAiYwkaAIAAImMJGwCAACJjCRwAgAAiYwkdAIAAImMJHgCAACJjCR8AgAAiYwkgAIAAImMJIQCAACJjCSIAgAAiYwkjAIAAImMJJACAACJjCSUAgAAiYwkmAIAAImMJJwCAACJjCSgAgAAiYwkpAIAAImMJKgCAACJjCSsAgAAiYwksAIAAImMJLQCAACJjCS4AgAAiYwkvAIAAImMJMACAACJjCTEAgAAiYwkyAIAAImMJMwCAACJjCTQAgAAiYwk1AIAAImMJNgCAACJjCTcAgAAiYwk4AIAAImMJOQCAACJjCToAgAAiYwk7AIAAImMJPACAACJjCT0AgAAiYwk+AIAAImMJPwCAACJjCQAAwAAiYwkBAMAAImMJAgDAACJjCQMAwAAiYwkEAMAAImMJBQDAACJjCQYAwAAiYwkHAMAAImMJCADAACJjCQkAwAAiYwkKAMAAImMJCwDAACJjCQwAwAAiYwkNAMAAImMJDgDAACJjCQ8AwAAiYwkQAMAAImMJEQDAACJjCRIAwAAiYwkTAMAAImMJFADAACJjCRUAwAAiYwkWAMAAImMJFwDAACJjCRgAwAAiYwkZAMAAImMJGgDAACJjCRsAwAAiYwkcAMAAImMJHQDAACJjCR4AwAAiYwkfAMAAImMJIADAACJjCSEAwAAiYwkiAMAAImMJIwDAACJjCSQAwAAiYwklAMAAImMJJgDAACJjCScAwAAiYwkoAMAAImMJKQDAACJjCSoAwAAiYwkrAMAAImMJLADAACJjCS0AwAAiYwkuAMAAImMJLwDAACJjCTAAwAAiYwkxAMAAImMJMgDAACJjCTMAwAAiYwk0AMAAImMJNQDAACJjCTYAwAAiYwk3AMAAImMJOADAACJjCTkAwAAiYwk6AMAAImMJOwDAACJjCTwAwAAiYwk9AMAAImMJPgDAACJjCT8AwAAiYwkAAQAAImMJAQEAACJjCQIBAAAiYwkDAQAAImMJBAEAACJjCQUBAAAiYwkGAQAAImMJBwEAACJjCQgBAAAiYwkJAQAAImMJCgEAACJjCQsBAAAiYwkMAQAAImMJDQEAACJjCQ4BAAAiYwkPAQAAImMJEAEAACJjCREBAAAiYwkSAQAAImMJEwEAACJjCRQBAAAiYwkVAQAAImMJFgEAACJjCRcBAAAiYwkYAQAAImMJGQEAACJjCRoBAAAiYwkbAQAAImMJHAEAACJjCR0BAAAiYwkeAQAAImMJHwEAACJjCSABAAAiYwkhAQAAImMJIgEAACJjCSMBAAAiYwkkAQAAImMJJQEAACJjCSYBAAAiYwknAQAAImMJKAEAACJjCSkBAAAiYwkqAQAAImMJKwEAACJjCSwBAAAiYwktAQAAImMJLgEAACJjCS8BAAAiYwkwAQAAImMJMQEAACJjCTIBAAAiYwkzAQAAImMJNAEAACJjCTUBAAAiYwk2AQAAImMJNwEAACJjCTgBAAAiYwk5AQAAImMJOgEAACJjCTsBAAAiYwk8AQAAImMJPQEAACJjCT4BAAAiYwk/AQAAImMJAAFAACJjCQEBQAAiYwkCAUAAImMJAwFAACJjCQQBQAAiYwkFAUAAImMJBgFAACJjCQcBQAAiYwkIAUAAImMJCQFAACJjCQoBQAAiYwkLAUAAImMJDAFAACJjCQ0BQAAiYwkOAUAAImMJDwFAACJjCRABQAAiYwkRAUAAImMJEgFAACJjCRMBQAAiYwkUAUAAImMJFQFAACJjCRYBQAAiYwkXAUAAImMJGAFAACJjCRkBQAAiYwkaAUAAImMJGwFAACJjCRwBQAAiYwkdAUAAImMJHgFAACJjCR8BQAAiYwkgAUAAImMJIQFAACJjCSIBQAAiYwkjAUAAImMJJAFAACJjCSUBQAAiYwkmAUAAImMJJwFAACJjCSgBQAAiYwkpAUAAImMJKgFAACJjCSsBQAAiYwksAUAAImMJLQFAACJjCS4BQAAiYwkvAUAAImMJMAFAACJjCTEBQAAiYwkyAUAAImMJMwFAACJjCTQBQAAiYwk1AUAAI2kJNgFAADD" +.p2align 6"#, + vg_sm4_prepare_keys = sym super::sm4::vg_sm4_prepare_keys::vg_sm4_prepare_keys, + vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-x86/src/triple_des_ofb.rs b/crates/verified-garbage-asm-x86/src/triple_des_ofb.rs index 3d5ac15f3db..65b62ddb8b0 100644 --- a/crates/verified-garbage-asm-x86/src/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/triple_des_ofb.rs @@ -34,3 +34,45 @@ jmp 21f vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, ) } + +/// Triple DES-OFB encryption or decryption (NIST SP 800-38A §6.4, FIPS 46-3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Triple DES encryption under the schedule written by `vg_triple_des_expand_key`. +/// +/// Contract: `VG.Spec.TripleDes.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// The function may overwrite the arguments on the stack, as the calling convention lets it. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 384 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the arguments on the stack, overlap the return address on the stack or the 984 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "C" fn vg_triple_des_ofb_final(schedule: *const [u8; 384], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "jaQkOPz//4uEJMwDAACJRCQEi4Qk0AMAAIlEJAiLhCTUAwAAiUQkDIuEJNgDAACJRCQQieCDwBiJRCQUi0QkFImYiAMAAImwjAMAAIm4kAMAAImolAMAAInHi3QkCIsGiYegAwAAi0YEiYekAwAAi0wkBIsBiYcIAgAAi0EEiYcMAgAAi0EIiYcQAgAAi0EMiYcUAgAAi0EQiYcYAgAAi0EUiYccAgAAi0EYiYcgAgAAi0EciYckAgAAi0EgiYcoAgAAi0EkiYcsAgAAi0EoiYcwAgAAi0EsiYc0AgAAi0EwiYc4AgAAi0E0iYc8AgAAi0E4iYdAAgAAi0E8iYdEAgAAi0FAiYdIAgAAi0FEiYdMAgAAi0FIiYdQAgAAi0FMiYdUAgAAi0FQiYdYAgAAi0FUiYdcAgAAi0FYiYdgAgAAi0FciYdkAgAAi0FgiYdoAgAAi0FkiYdsAgAAi0FoiYdwAgAAi0FsiYd0AgAAi0FwiYd4AgAAi0F0iYd8AgAAi0F4iYeAAgAAi0F8iYeEAgAAi4GAAAAAiYeIAgAAi4GEAAAAiYeMAgAAi4GIAAAAiYeQAgAAi4GMAAAAiYeUAgAAi4GQAAAAiYeYAgAAi4GUAAAAiYecAgAAi4GYAAAAiYegAgAAi4GcAAAAiYekAgAAi4GgAAAAiYeoAgAAi4GkAAAAiYesAgAAi4GoAAAAiYewAgAAi4GsAAAAiYe0AgAAi4GwAAAAiYe4AgAAi4G0AAAAiYe8AgAAi4G4AAAAiYfAAgAAi4G8AAAAiYfEAgAAi4HAAAAAiYfIAgAAi4HEAAAAiYfMAgAAi4HIAAAAiYfQAgAAi4HMAAAAiYfUAgAAi4HQAAAAiYfYAgAAi4HUAAAAiYfcAgAAi4HYAAAAiYfgAgAAi4HcAAAAiYfkAgAAi4HgAAAAiYfoAgAAi4HkAAAAiYfsAgAAi4HoAAAAiYfwAgAAi4HsAAAAiYf0AgAAi4HwAAAAiYf4AgAAi4H0AAAAiYf8AgAAi4H4AAAAiYcAAwAAi4H8AAAAiYcEAwAAi4EAAQAAiYcIAwAAi4EEAQAAiYcMAwAAi4EIAQAAiYcQAwAAi4EMAQAAiYcUAwAAi4EQAQAAiYcYAwAAi4EUAQAAiYccAwAAi4EYAQAAiYcgAwAAi4EcAQAAiYckAwAAi4EgAQAAiYcoAwAAi4EkAQAAiYcsAwAAi4EoAQAAiYcwAwAAi4EsAQAAiYc0AwAAi4EwAQAAiYc4AwAAi4E0AQAAiYc8AwAAi4E4AQAAiYdAAwAAi4E8AQAAiYdEAwAAi4FAAQAAiYdIAwAAi4FEAQAAiYdMAwAAi4FIAQAAiYdQAwAAi4FMAQAAiYdUAwAAi4FQAQAAiYdYAwAAi4FUAQAAiYdcAwAAi4FYAQAAiYdgAwAAi4FcAQAAiYdkAwAAi4FgAQAAiYdoAwAAi4FkAQAAiYdsAwAAi4FoAQAAiYdwAwAAi4FsAQAAiYd0AwAAi4FwAQAAiYd4AwAAi4F0AQAAiYd8AwAAi4F4AQAAiYeAAwAAi4F8AQAAiYeEAwAAi0QkDImHmAMAAItEJBCJh5wDAACFwA==" +je 20f +22: +.base64 "i7eYAwAAi6+cAwAAi4egAwAAiYcAAgAAi4ekAwAAiYcEAgAAi7eYAwAAi6+cAwAAifiJ+YHBAAIAAIn6gcIIAgAAUFFS" +call {vg_triple_des_encrypt_block} +.base64 "WFhYibeYAwAAia+cAwAAi7eYAwAAi6+cAwAAg/0I" +jb 23f +.base64 "i4cAAgAAiYegAwAAi4cEAgAAiYekAwAAiwYzhwACAACJBotGBDOHBAIAAIlGBIPGCIPtCIm3mAMAAImvnAMAAA==" +jmp 24f +23: +.base64 "i4cAAgAAiYegAwAAi4cEAgAAiYekAwAAifuBwwACAAA=" +25: +.base64 "D7YDD7YOMcGIDoPDAYPGAYPtAQ==" +jne 25b +.base64 "ibeYAwAAia+cAwAA" +24: +jne 22b +jmp 21f +20: +21: +.base64 "i3QkCIuHoAMAAIkGi4ekAwAAiUYEi5+IAwAAi7eMAwAAi6+UAwAAi7+QAwAAuQAAAACJTCQYiUwkHIlMJCCJTCQkiUwkKIlMJCyJTCQwiUwkNIlMJDiJTCQ8iUwkQIlMJESJTCRIiUwkTIlMJFCJTCRUiUwkWIlMJFyJTCRgiUwkZIlMJGiJTCRsiUwkcIlMJHSJTCR4iUwkfImMJIAAAACJjCSEAAAAiYwkiAAAAImMJIwAAACJjCSQAAAAiYwklAAAAImMJJgAAACJjCScAAAAiYwkoAAAAImMJKQAAACJjCSoAAAAiYwkrAAAAImMJLAAAACJjCS0AAAAiYwkuAAAAImMJLwAAACJjCTAAAAAiYwkxAAAAImMJMgAAACJjCTMAAAAiYwk0AAAAImMJNQAAACJjCTYAAAAiYwk3AAAAImMJOAAAACJjCTkAAAAiYwk6AAAAImMJOwAAACJjCTwAAAAiYwk9AAAAImMJPgAAACJjCT8AAAAiYwkAAEAAImMJAQBAACJjCQIAQAAiYwkDAEAAImMJBABAACJjCQUAQAAiYwkGAEAAImMJBwBAACJjCQgAQAAiYwkJAEAAImMJCgBAACJjCQsAQAAiYwkMAEAAImMJDQBAACJjCQ4AQAAiYwkPAEAAImMJEABAACJjCREAQAAiYwkSAEAAImMJEwBAACJjCRQAQAAiYwkVAEAAImMJFgBAACJjCRcAQAAiYwkYAEAAImMJGQBAACJjCRoAQAAiYwkbAEAAImMJHABAACJjCR0AQAAiYwkeAEAAImMJHwBAACJjCSAAQAAiYwkhAEAAImMJIgBAACJjCSMAQAAiYwkkAEAAImMJJQBAACJjCSYAQAAiYwknAEAAImMJKABAACJjCSkAQAAiYwkqAEAAImMJKwBAACJjCSwAQAAiYwktAEAAImMJLgBAACJjCS8AQAAiYwkwAEAAImMJMQBAACJjCTIAQAAiYwkzAEAAImMJNABAACJjCTUAQAAiYwk2AEAAImMJNwBAACJjCTgAQAAiYwk5AEAAImMJOgBAACJjCTsAQAAiYwk8AEAAImMJPQBAACJjCT4AQAAiYwk/AEAAImMJAACAACJjCQEAgAAiYwkCAIAAImMJAwCAACJjCQQAgAAiYwkFAIAAImMJBgCAACJjCQcAgAAiYwkIAIAAImMJCQCAACJjCQoAgAAiYwkLAIAAImMJDACAACJjCQ0AgAAiYwkOAIAAImMJDwCAACJjCRAAgAAiYwkRAIAAImMJEgCAACJjCRMAgAAiYwkUAIAAImMJFQCAACJjCRYAgAAiYwkXAIAAImMJGACAACJjCRkAgAAiYwkaAIAAImMJGwCAACJjCRwAgAAiYwkdAIAAImMJHgCAACJjCR8AgAAiYwkgAIAAImMJIQCAACJjCSIAgAAiYwkjAIAAImMJJACAACJjCSUAgAAiYwkmAIAAImMJJwCAACJjCSgAgAAiYwkpAIAAImMJKgCAACJjCSsAgAAiYwksAIAAImMJLQCAACJjCS4AgAAiYwkvAIAAImMJMACAACJjCTEAgAAiYwkyAIAAImMJMwCAACJjCTQAgAAiYwk1AIAAImMJNgCAACJjCTcAgAAiYwk4AIAAImMJOQCAACJjCToAgAAiYwk7AIAAImMJPACAACJjCT0AgAAiYwk+AIAAImMJPwCAACJjCQAAwAAiYwkBAMAAImMJAgDAACJjCQMAwAAiYwkEAMAAImMJBQDAACJjCQYAwAAiYwkHAMAAImMJCADAACJjCQkAwAAiYwkKAMAAImMJCwDAACJjCQwAwAAiYwkNAMAAImMJDgDAACJjCQ8AwAAiYwkQAMAAImMJEQDAACJjCRIAwAAiYwkTAMAAImMJFADAACJjCRUAwAAiYwkWAMAAImMJFwDAACJjCRgAwAAiYwkZAMAAImMJGgDAACJjCRsAwAAiYwkcAMAAImMJHQDAACJjCR4AwAAiYwkfAMAAImMJIADAACJjCSEAwAAiYwkiAMAAImMJIwDAACJjCSQAwAAiYwklAMAAImMJJgDAACJjCScAwAAiYwkoAMAAImMJKQDAACJjCSoAwAAiYwkrAMAAImMJLADAACJjCS0AwAAiYwkuAMAAImMJLwDAACJjCTAAwAAiYwkxAMAAI2kJMgDAADD" +.p2align 6"#, + vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/assembly/aes_ctr.s b/crates/verified-garbage-asm-x86_64/assembly/aes_ctr.s index ccf637332ef..cbdc34cc74f 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/aes_ctr.s +++ b/crates/verified-garbage-asm-x86_64/assembly/aes_ctr.s @@ -69,6 +69,77 @@ vg_aes_ctr_aesni: ret .p2align 6 +vg_aes_ctr_final_aesni: + lea rsp, [rsp-80] + mov rax, rsp + add rax, 16 + mov QWORD PTR [rsp+8], rax + mov rax, QWORD PTR [rsp+8] + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, r9 + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_aes_ctr_aesni} + test r14, r14 + je 20f + mov rax, QWORD PTR [rsp+8] + mov r10d, 0 + mov QWORD PTR [rax+48], r10 + mov QWORD PTR [rax+56], r10 + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov rcx, rax + add rcx, 48 + mov r8d, 1 + mov r9, r15 + call {vg_aes_ctr_aesni} + mov rax, QWORD PTR [rsp+8] + add rax, 48 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, QWORD PTR [rsp+8] + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + lea rsp, [rsp+80] + ret + .p2align 6 + vg_aes_ctr: mov QWORD PTR [r9+2064], rbx mov QWORD PTR [r9+2072], rbp @@ -134,6 +205,77 @@ vg_aes_ctr: ret .p2align 6 +vg_aes_ctr_final: + lea rsp, [rsp-80] + mov rax, rsp + add rax, 16 + mov QWORD PTR [rsp+8], rax + mov rax, QWORD PTR [rsp+8] + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, r9 + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_aes_ctr} + test r14, r14 + je 20f + mov rax, QWORD PTR [rsp+8] + mov r10d, 0 + mov QWORD PTR [rax+48], r10 + mov QWORD PTR [rax+56], r10 + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov rcx, rax + add rcx, 48 + mov r8d, 1 + mov r9, r15 + call {vg_aes_ctr} + mov rax, QWORD PTR [rsp+8] + add rax, 48 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, QWORD PTR [rsp+8] + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + lea rsp, [rsp+80] + ret + .p2align 6 + vg_aes_ctr_vaes: mov QWORD PTR [r9+2064], rbx mov QWORD PTR [r9+2072], rbp @@ -198,3 +340,74 @@ vg_aes_ctr_vaes: mov r15, QWORD PTR [r15+2104] ret .p2align 6 + +vg_aes_ctr_final_vaes: + lea rsp, [rsp-80] + mov rax, rsp + add rax, 16 + mov QWORD PTR [rsp+8], rax + mov rax, QWORD PTR [rsp+8] + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, r9 + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_aes_ctr_vaes} + test r14, r14 + je 20f + mov rax, QWORD PTR [rsp+8] + mov r10d, 0 + mov QWORD PTR [rax+48], r10 + mov QWORD PTR [rax+56], r10 + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov rcx, rax + add rcx, 48 + mov r8d, 1 + mov r9, r15 + call {vg_aes_ctr_vaes} + mov rax, QWORD PTR [rsp+8] + add rax, 48 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, QWORD PTR [rsp+8] + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + lea rsp, [rsp+80] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/aes_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/aes_ofb.s index 4988bc06f7c..4409e49c125 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/aes_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/aes_ofb.s @@ -47,6 +47,68 @@ vg_aes_ofb_aesni: ret .p2align 6 +vg_aes_ofb_final_aesni: + lea rsp, [rsp-64] + mov rax, rsp + add rax, 16 + mov QWORD PTR [rsp+8], rax + mov rax, QWORD PTR [rsp+8] + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, r9 + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_aes_ofb_aesni} + test r14, r14 + je 20f + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov ecx, 1 + mov r8, r15 + call {vg_aes_encrypt_blocks_aesni} + mov rax, r12 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, QWORD PTR [rsp+8] + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + lea rsp, [rsp+64] + ret + .p2align 6 + vg_aes_ofb: mov QWORD PTR [r9+2064], rbx mov QWORD PTR [r9+2072], rbp @@ -90,6 +152,68 @@ vg_aes_ofb: ret .p2align 6 +vg_aes_ofb_final: + lea rsp, [rsp-64] + mov rax, rsp + add rax, 16 + mov QWORD PTR [rsp+8], rax + mov rax, QWORD PTR [rsp+8] + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, r9 + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_aes_ofb} + test r14, r14 + je 20f + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov ecx, 1 + mov r8, r15 + call {vg_aes_encrypt_blocks} + mov rax, r12 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, QWORD PTR [rsp+8] + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + lea rsp, [rsp+64] + ret + .p2align 6 + vg_aes_ofb_vaes: mov QWORD PTR [r9+2064], rbx mov QWORD PTR [r9+2072], rbp @@ -132,3 +256,65 @@ vg_aes_ofb_vaes: mov r15, QWORD PTR [r15+2104] ret .p2align 6 + +vg_aes_ofb_final_vaes: + lea rsp, [rsp-64] + mov rax, rsp + add rax, 16 + mov QWORD PTR [rsp+8], rax + mov rax, QWORD PTR [rsp+8] + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, r9 + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_aes_ofb_vaes} + test r14, r14 + je 20f + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov ecx, 1 + mov r8, r15 + call {vg_aes_encrypt_blocks_vaes} + mov rax, r12 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, QWORD PTR [rsp+8] + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + lea rsp, [rsp+64] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/blowfish_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/blowfish_ofb.s index 19b0c8150cd..4869acecdfb 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/blowfish_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/blowfish_ofb.s @@ -512,3 +512,528 @@ vg_blowfish_ofb: lea rsp, [rsp+96] ret .p2align 6 + +vg_blowfish_ofb_final: + lea rsp, [rsp-96] + mov r8, rsp + add r8, 8 + mov r9, r8 + mov QWORD PTR [r9+24], rbx + mov QWORD PTR [r9+32], rbp + mov QWORD PTR [r9+40], r12 + mov QWORD PTR [r9+48], r13 + mov QWORD PTR [r9+56], r14 + mov QWORD PTR [r9+64], r15 + movq xmm15, rsi + mov r12, rdx + mov r13, rcx + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9], rbp + test r13, r13 + je 20f +22: + movq r14, xmm15 + mov rdx, r9 + mov rsi, r9 + mov rcx, r9 + add rcx, 8 + movabs r11, 281479271743489 + movq xmm13, r11 + movabs r11, 281479271743489 + movq xmm12, r11 + punpcklqdq xmm13, xmm12 + movabs r11, 4503668347895824 + movq xmm14, r11 + movabs r11, 4503668347895824 + movq xmm12, r11 + punpcklqdq xmm14, xmm12 + movabs r11, 71777214294589695 + movq xmm15, r11 + movabs r11, 71777214294589695 + movq xmm12, r11 + punpcklqdq xmm15, xmm12 + mov r11d, DWORD PTR [rsi] + bswap r11d + movq xmm0, r11 + mov r11d, DWORD PTR [rsi+4] + bswap r11d + movq xmm1, r11 + mov eax, 0 + mov r10d, 16 +23: + mov r11d, DWORD PTR [rdi+rax*1+4096] + movq xmm12, r11 + pxor xmm0, xmm12 + movdqa xmm3, xmm0 + pslld xmm3, 0 + psrld xmm3, 24 + punpcklwd xmm3, xmm3 + pshufd xmm3, xmm3, 0 + movabs r11, 1688867040264192 + movq xmm4, r11 + movabs r11, 3940701214212104 + movq xmm12, r11 + punpcklqdq xmm4, xmm12 + pxor xmm8, xmm8 + pxor xmm9, xmm9 + pxor xmm10, xmm10 + pxor xmm11, xmm11 + mov r8d, 0 + mov r9d, 16 +24: + movdqa xmm6, xmm4 + pxor xmm6, xmm3 + psubw xmm6, xmm13 + psraw xmm6, 15 + movdqa xmm7, xmm4 + paddw xmm7, xmm13 + pxor xmm7, xmm3 + psubw xmm7, xmm13 + psraw xmm7, 15 + pand xmm6, xmm15 + psllw xmm7, 8 + por xmm6, xmm7 + movdqu xmm12, XMMWORD PTR [rdi+r8*1] + pand xmm12, xmm6 + por xmm8, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+256] + pand xmm12, xmm6 + por xmm9, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+512] + pand xmm12, xmm6 + por xmm10, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+768] + pand xmm12, xmm6 + por xmm11, xmm12 + paddw xmm4, xmm14 + add r8, 16 + sub r9, 1 + jne 24b + pshufd xmm12, xmm8, 78 + por xmm8, xmm12 + pshufd xmm12, xmm8, 177 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 16 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 8 + por xmm8, xmm12 + pslld xmm8, 24 + psrld xmm8, 24 + pshufd xmm12, xmm9, 78 + por xmm9, xmm12 + pshufd xmm12, xmm9, 177 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 16 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 8 + por xmm9, xmm12 + pslld xmm9, 24 + psrld xmm9, 24 + pshufd xmm12, xmm10, 78 + por xmm10, xmm12 + pshufd xmm12, xmm10, 177 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 16 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 8 + por xmm10, xmm12 + pslld xmm10, 24 + psrld xmm10, 24 + pshufd xmm12, xmm11, 78 + por xmm11, xmm12 + pshufd xmm12, xmm11, 177 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 16 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 8 + por xmm11, xmm12 + pslld xmm11, 24 + psrld xmm11, 24 + pslld xmm9, 8 + pslld xmm10, 16 + pslld xmm11, 24 + por xmm8, xmm9 + por xmm8, xmm10 + por xmm8, xmm11 + movdqa xmm2, xmm8 + movdqa xmm3, xmm0 + pslld xmm3, 8 + psrld xmm3, 24 + punpcklwd xmm3, xmm3 + pshufd xmm3, xmm3, 0 + movabs r11, 1688867040264192 + movq xmm4, r11 + movabs r11, 3940701214212104 + movq xmm12, r11 + punpcklqdq xmm4, xmm12 + pxor xmm8, xmm8 + pxor xmm9, xmm9 + pxor xmm10, xmm10 + pxor xmm11, xmm11 + mov r8d, 0 + mov r9d, 16 +25: + movdqa xmm6, xmm4 + pxor xmm6, xmm3 + psubw xmm6, xmm13 + psraw xmm6, 15 + movdqa xmm7, xmm4 + paddw xmm7, xmm13 + pxor xmm7, xmm3 + psubw xmm7, xmm13 + psraw xmm7, 15 + pand xmm6, xmm15 + psllw xmm7, 8 + por xmm6, xmm7 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+1024] + pand xmm12, xmm6 + por xmm8, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+1280] + pand xmm12, xmm6 + por xmm9, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+1536] + pand xmm12, xmm6 + por xmm10, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+1792] + pand xmm12, xmm6 + por xmm11, xmm12 + paddw xmm4, xmm14 + add r8, 16 + sub r9, 1 + jne 25b + pshufd xmm12, xmm8, 78 + por xmm8, xmm12 + pshufd xmm12, xmm8, 177 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 16 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 8 + por xmm8, xmm12 + pslld xmm8, 24 + psrld xmm8, 24 + pshufd xmm12, xmm9, 78 + por xmm9, xmm12 + pshufd xmm12, xmm9, 177 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 16 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 8 + por xmm9, xmm12 + pslld xmm9, 24 + psrld xmm9, 24 + pshufd xmm12, xmm10, 78 + por xmm10, xmm12 + pshufd xmm12, xmm10, 177 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 16 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 8 + por xmm10, xmm12 + pslld xmm10, 24 + psrld xmm10, 24 + pshufd xmm12, xmm11, 78 + por xmm11, xmm12 + pshufd xmm12, xmm11, 177 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 16 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 8 + por xmm11, xmm12 + pslld xmm11, 24 + psrld xmm11, 24 + pslld xmm9, 8 + pslld xmm10, 16 + pslld xmm11, 24 + por xmm8, xmm9 + por xmm8, xmm10 + por xmm8, xmm11 + paddd xmm2, xmm8 + movdqa xmm3, xmm0 + pslld xmm3, 16 + psrld xmm3, 24 + punpcklwd xmm3, xmm3 + pshufd xmm3, xmm3, 0 + movabs r11, 1688867040264192 + movq xmm4, r11 + movabs r11, 3940701214212104 + movq xmm12, r11 + punpcklqdq xmm4, xmm12 + pxor xmm8, xmm8 + pxor xmm9, xmm9 + pxor xmm10, xmm10 + pxor xmm11, xmm11 + mov r8d, 0 + mov r9d, 16 +26: + movdqa xmm6, xmm4 + pxor xmm6, xmm3 + psubw xmm6, xmm13 + psraw xmm6, 15 + movdqa xmm7, xmm4 + paddw xmm7, xmm13 + pxor xmm7, xmm3 + psubw xmm7, xmm13 + psraw xmm7, 15 + pand xmm6, xmm15 + psllw xmm7, 8 + por xmm6, xmm7 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+2048] + pand xmm12, xmm6 + por xmm8, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+2304] + pand xmm12, xmm6 + por xmm9, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+2560] + pand xmm12, xmm6 + por xmm10, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+2816] + pand xmm12, xmm6 + por xmm11, xmm12 + paddw xmm4, xmm14 + add r8, 16 + sub r9, 1 + jne 26b + pshufd xmm12, xmm8, 78 + por xmm8, xmm12 + pshufd xmm12, xmm8, 177 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 16 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 8 + por xmm8, xmm12 + pslld xmm8, 24 + psrld xmm8, 24 + pshufd xmm12, xmm9, 78 + por xmm9, xmm12 + pshufd xmm12, xmm9, 177 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 16 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 8 + por xmm9, xmm12 + pslld xmm9, 24 + psrld xmm9, 24 + pshufd xmm12, xmm10, 78 + por xmm10, xmm12 + pshufd xmm12, xmm10, 177 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 16 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 8 + por xmm10, xmm12 + pslld xmm10, 24 + psrld xmm10, 24 + pshufd xmm12, xmm11, 78 + por xmm11, xmm12 + pshufd xmm12, xmm11, 177 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 16 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 8 + por xmm11, xmm12 + pslld xmm11, 24 + psrld xmm11, 24 + pslld xmm9, 8 + pslld xmm10, 16 + pslld xmm11, 24 + por xmm8, xmm9 + por xmm8, xmm10 + por xmm8, xmm11 + pxor xmm2, xmm8 + movdqa xmm3, xmm0 + pslld xmm3, 24 + psrld xmm3, 24 + punpcklwd xmm3, xmm3 + pshufd xmm3, xmm3, 0 + movabs r11, 1688867040264192 + movq xmm4, r11 + movabs r11, 3940701214212104 + movq xmm12, r11 + punpcklqdq xmm4, xmm12 + pxor xmm8, xmm8 + pxor xmm9, xmm9 + pxor xmm10, xmm10 + pxor xmm11, xmm11 + mov r8d, 0 + mov r9d, 16 +27: + movdqa xmm6, xmm4 + pxor xmm6, xmm3 + psubw xmm6, xmm13 + psraw xmm6, 15 + movdqa xmm7, xmm4 + paddw xmm7, xmm13 + pxor xmm7, xmm3 + psubw xmm7, xmm13 + psraw xmm7, 15 + pand xmm6, xmm15 + psllw xmm7, 8 + por xmm6, xmm7 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+3072] + pand xmm12, xmm6 + por xmm8, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+3328] + pand xmm12, xmm6 + por xmm9, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+3584] + pand xmm12, xmm6 + por xmm10, xmm12 + movdqu xmm12, XMMWORD PTR [rdi+r8*1+3840] + pand xmm12, xmm6 + por xmm11, xmm12 + paddw xmm4, xmm14 + add r8, 16 + sub r9, 1 + jne 27b + pshufd xmm12, xmm8, 78 + por xmm8, xmm12 + pshufd xmm12, xmm8, 177 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 16 + por xmm8, xmm12 + movdqa xmm12, xmm8 + psrld xmm12, 8 + por xmm8, xmm12 + pslld xmm8, 24 + psrld xmm8, 24 + pshufd xmm12, xmm9, 78 + por xmm9, xmm12 + pshufd xmm12, xmm9, 177 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 16 + por xmm9, xmm12 + movdqa xmm12, xmm9 + psrld xmm12, 8 + por xmm9, xmm12 + pslld xmm9, 24 + psrld xmm9, 24 + pshufd xmm12, xmm10, 78 + por xmm10, xmm12 + pshufd xmm12, xmm10, 177 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 16 + por xmm10, xmm12 + movdqa xmm12, xmm10 + psrld xmm12, 8 + por xmm10, xmm12 + pslld xmm10, 24 + psrld xmm10, 24 + pshufd xmm12, xmm11, 78 + por xmm11, xmm12 + pshufd xmm12, xmm11, 177 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 16 + por xmm11, xmm12 + movdqa xmm12, xmm11 + psrld xmm12, 8 + por xmm11, xmm12 + pslld xmm11, 24 + psrld xmm11, 24 + pslld xmm9, 8 + pslld xmm10, 16 + pslld xmm11, 24 + por xmm8, xmm9 + por xmm8, xmm10 + por xmm8, xmm11 + paddd xmm2, xmm8 + pxor xmm1, xmm2 + movdqa xmm12, xmm0 + movdqa xmm0, xmm1 + movdqa xmm1, xmm12 + add rax, 4 + sub r10, 1 + jne 23b + mov r11d, DWORD PTR [rdi+4160] + movq xmm12, r11 + pxor xmm0, xmm12 + mov r11d, DWORD PTR [rdi+4164] + movq xmm12, r11 + pxor xmm1, xmm12 + movdqu XMMWORD PTR [rcx], xmm1 + mov r11d, DWORD PTR [rcx] + bswap r11d + mov DWORD PTR [rsi], r11d + movdqu XMMWORD PTR [rcx], xmm0 + mov r11d, DWORD PTR [rcx] + bswap r11d + mov DWORD PTR [rsi+4], r11d + mov r9, rdx + movq xmm15, r14 + cmp r13, 8 + jb 28f + mov rax, QWORD PTR [r12] + xor rax, QWORD PTR [r9] + mov QWORD PTR [r12], rax + add r12, 8 + sub r13, 8 + jmp 29f +28: + mov rax, r9 + add rax, 0 +210: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r12] + xor rcx, r10 + mov BYTE PTR [r12], cl + add rax, 1 + add r12, 1 + sub r13, 1 + jne 210b +29: + jne 22b + jmp 21f +20: +21: + movq rax, xmm15 + mov rbp, QWORD PTR [r9] + mov QWORD PTR [rax], rbp + mov rbx, QWORD PTR [r9+24] + mov rbp, QWORD PTR [r9+32] + mov r12, QWORD PTR [r9+40] + mov r13, QWORD PTR [r9+48] + mov r14, QWORD PTR [r9+56] + mov r15, QWORD PTR [r9+64] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + lea rsp, [rsp+96] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/camellia_ctr.s b/crates/verified-garbage-asm-x86_64/assembly/camellia_ctr.s index 579d5833d29..5dfcc17377e 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/camellia_ctr.s +++ b/crates/verified-garbage-asm-x86_64/assembly/camellia_ctr.s @@ -1037,3 +1037,72 @@ vg_camellia_ctr: lea rsp, [rsp+3280] ret .p2align 6 + +vg_camellia_ctr_final: + lea rsp, [rsp-72] + mov r9, rsp + add r9, 8 + mov rax, r9 + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov rbp, rsi + mov r12, rdx + mov r15, rax + mov r14, r8 + and r14, 15 + mov r13, r8 + sub r13, r14 + add r13, rcx + shr r8, 4 + call {vg_camellia_ctr} + test r14, r14 + je 20f + mov rax, r15 + mov r10d, 0 + mov QWORD PTR [rax+48], r10 + mov QWORD PTR [rax+56], r10 + mov rdi, rbx + mov rsi, rbp + mov rdx, r12 + mov rcx, rax + add rcx, 48 + mov r8d, 1 + call {vg_camellia_ctr} + mov rax, r15 + add rax, 48 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, r15 + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + lea rsp, [rsp+72] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/camellia_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/camellia_ofb.s index 888d29fb8a5..285b9e0de12 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/camellia_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/camellia_ofb.s @@ -952,3 +952,968 @@ vg_camellia_ofb: lea rsp, [rsp+3280] ret .p2align 6 + +vg_camellia_ofb_final: + lea rsp, [rsp-3280] + mov r9, rsp + add r9, 8 + mov r9, r9 + mov QWORD PTR [r9+3208], rbx + mov QWORD PTR [r9+3216], rbp + mov QWORD PTR [r9+3224], r12 + mov QWORD PTR [r9+3232], r13 + mov QWORD PTR [r9+3240], r14 + mov QWORD PTR [r9+3248], r15 + movq xmm15, rdx + mov rdx, rcx + mov r8, r8 + movabs r14, 71777214294589695 + mov QWORD PTR [r9+384], r14 + movabs r14, -71777214294589696 + mov QWORD PTR [r9+392], r14 + movabs r14, 72056494526300160 + mov QWORD PTR [r9+400], r14 + movabs r14, 16776960 + mov QWORD PTR [r9+408], r14 + movabs r14, 1099494850560 + mov QWORD PTR [r9+416], r14 + cmp rsi, 18 + je 20f + mov rsi, r9 + add rsi, 768 + movabs r15, 34 +22: + mov rax, QWORD PTR [rdi] + mov rbx, rax + mov rcx, rax + mov rbp, rax + mov r10, rax + mov r11, rax + mov r12, rax + mov r13, rax + movabs r14, 4294901760 + mov QWORD PTR [r9+8], r14 + movabs r14, 280375465148160 + mov QWORD PTR [r9+16], r14 + movabs r14, 6148914691236517205 + mov QWORD PTR [r9+32], r14 + movabs r14, 3689348814741910323 + mov QWORD PTR [r9+40], r14 + movabs r14, 1085102592571150095 + mov QWORD PTR [r9+48], r14 + mov r14, rax + shr r14, 16 + xor r14, rax + and r14, QWORD PTR [r9+8] + xor rax, r14 + ror r14, 48 + xor rax, r14 + mov r14, rbx + shr r14, 16 + xor r14, rbx + and r14, QWORD PTR [r9+8] + xor rbx, r14 + ror r14, 48 + xor rbx, r14 + mov r14, rcx + shr r14, 16 + xor r14, rcx + and r14, QWORD PTR [r9+8] + xor rcx, r14 + ror r14, 48 + xor rcx, r14 + mov r14, rbp + shr r14, 16 + xor r14, rbp + and r14, QWORD PTR [r9+8] + xor rbp, r14 + ror r14, 48 + xor rbp, r14 + mov r14, r10 + shr r14, 16 + xor r14, r10 + and r14, QWORD PTR [r9+8] + xor r10, r14 + ror r14, 48 + xor r10, r14 + mov r14, r11 + shr r14, 16 + xor r14, r11 + and r14, QWORD PTR [r9+8] + xor r11, r14 + ror r14, 48 + xor r11, r14 + mov r14, r12 + shr r14, 16 + xor r14, r12 + and r14, QWORD PTR [r9+8] + xor r12, r14 + ror r14, 48 + xor r12, r14 + mov r14, r13 + shr r14, 16 + xor r14, r13 + and r14, QWORD PTR [r9+8] + xor r13, r14 + ror r14, 48 + xor r13, r14 + mov r14, rax + shr r14, 8 + xor r14, rax + and r14, QWORD PTR [r9+16] + xor rax, r14 + ror r14, 56 + xor rax, r14 + mov r14, rbx + shr r14, 8 + xor r14, rbx + and r14, QWORD PTR [r9+16] + xor rbx, r14 + ror r14, 56 + xor rbx, r14 + mov r14, rcx + shr r14, 8 + xor r14, rcx + and r14, QWORD PTR [r9+16] + xor rcx, r14 + ror r14, 56 + xor rcx, r14 + mov r14, rbp + shr r14, 8 + xor r14, rbp + and r14, QWORD PTR [r9+16] + xor rbp, r14 + ror r14, 56 + xor rbp, r14 + mov r14, r10 + shr r14, 8 + xor r14, r10 + and r14, QWORD PTR [r9+16] + xor r10, r14 + ror r14, 56 + xor r10, r14 + mov r14, r11 + shr r14, 8 + xor r14, r11 + and r14, QWORD PTR [r9+16] + xor r11, r14 + ror r14, 56 + xor r11, r14 + mov r14, r12 + shr r14, 8 + xor r14, r12 + and r14, QWORD PTR [r9+16] + xor r12, r14 + ror r14, 56 + xor r12, r14 + mov r14, r13 + shr r14, 8 + xor r14, r13 + and r14, QWORD PTR [r9+16] + xor r13, r14 + ror r14, 56 + xor r13, r14 + mov r14, rax + shr r14, 1 + xor r14, rbx + and r14, QWORD PTR [r9+32] + xor rbx, r14 + ror r14, 63 + xor rax, r14 + mov r14, rcx + shr r14, 1 + xor r14, rbp + and r14, QWORD PTR [r9+32] + xor rbp, r14 + ror r14, 63 + xor rcx, r14 + mov r14, r10 + shr r14, 1 + xor r14, r11 + and r14, QWORD PTR [r9+32] + xor r11, r14 + ror r14, 63 + xor r10, r14 + mov r14, r12 + shr r14, 1 + xor r14, r13 + and r14, QWORD PTR [r9+32] + xor r13, r14 + ror r14, 63 + xor r12, r14 + mov r14, rax + shr r14, 2 + xor r14, rcx + and r14, QWORD PTR [r9+40] + xor rcx, r14 + ror r14, 62 + xor rax, r14 + mov r14, rbx + shr r14, 2 + xor r14, rbp + and r14, QWORD PTR [r9+40] + xor rbp, r14 + ror r14, 62 + xor rbx, r14 + mov r14, r10 + shr r14, 2 + xor r14, r12 + and r14, QWORD PTR [r9+40] + xor r12, r14 + ror r14, 62 + xor r10, r14 + mov r14, r11 + shr r14, 2 + xor r14, r13 + and r14, QWORD PTR [r9+40] + xor r13, r14 + ror r14, 62 + xor r11, r14 + mov r14, rax + shr r14, 4 + xor r14, r10 + and r14, QWORD PTR [r9+48] + xor r10, r14 + ror r14, 60 + xor rax, r14 + mov r14, rbx + shr r14, 4 + xor r14, r11 + and r14, QWORD PTR [r9+48] + xor r11, r14 + ror r14, 60 + xor rbx, r14 + mov r14, rcx + shr r14, 4 + xor r14, r12 + and r14, QWORD PTR [r9+48] + xor r12, r14 + ror r14, 60 + xor rcx, r14 + mov r14, rbp + shr r14, 4 + xor r14, r13 + and r14, QWORD PTR [r9+48] + xor r13, r14 + ror r14, 60 + xor rbp, r14 + mov QWORD PTR [rsi], rax + mov QWORD PTR [rsi+8], rbx + mov QWORD PTR [rsi+16], rcx + mov QWORD PTR [rsi+24], rbp + mov QWORD PTR [rsi+32], r10 + mov QWORD PTR [rsi+40], r11 + mov QWORD PTR [rsi+48], r12 + mov QWORD PTR [rsi+56], r13 + add rsi, 64 + add rdi, 8 + sub r15, 1 + jne 22b + mov rdi, r9 + add rdi, 2816 + movabs rdi, 24 + jmp 21f +20: + mov rsi, r9 + add rsi, 768 + movabs r15, 26 +23: + mov rax, QWORD PTR [rdi] + mov rbx, rax + mov rcx, rax + mov rbp, rax + mov r10, rax + mov r11, rax + mov r12, rax + mov r13, rax + movabs r14, 4294901760 + mov QWORD PTR [r9+8], r14 + movabs r14, 280375465148160 + mov QWORD PTR [r9+16], r14 + movabs r14, 6148914691236517205 + mov QWORD PTR [r9+32], r14 + movabs r14, 3689348814741910323 + mov QWORD PTR [r9+40], r14 + movabs r14, 1085102592571150095 + mov QWORD PTR [r9+48], r14 + mov r14, rax + shr r14, 16 + xor r14, rax + and r14, QWORD PTR [r9+8] + xor rax, r14 + ror r14, 48 + xor rax, r14 + mov r14, rbx + shr r14, 16 + xor r14, rbx + and r14, QWORD PTR [r9+8] + xor rbx, r14 + ror r14, 48 + xor rbx, r14 + mov r14, rcx + shr r14, 16 + xor r14, rcx + and r14, QWORD PTR [r9+8] + xor rcx, r14 + ror r14, 48 + xor rcx, r14 + mov r14, rbp + shr r14, 16 + xor r14, rbp + and r14, QWORD PTR [r9+8] + xor rbp, r14 + ror r14, 48 + xor rbp, r14 + mov r14, r10 + shr r14, 16 + xor r14, r10 + and r14, QWORD PTR [r9+8] + xor r10, r14 + ror r14, 48 + xor r10, r14 + mov r14, r11 + shr r14, 16 + xor r14, r11 + and r14, QWORD PTR [r9+8] + xor r11, r14 + ror r14, 48 + xor r11, r14 + mov r14, r12 + shr r14, 16 + xor r14, r12 + and r14, QWORD PTR [r9+8] + xor r12, r14 + ror r14, 48 + xor r12, r14 + mov r14, r13 + shr r14, 16 + xor r14, r13 + and r14, QWORD PTR [r9+8] + xor r13, r14 + ror r14, 48 + xor r13, r14 + mov r14, rax + shr r14, 8 + xor r14, rax + and r14, QWORD PTR [r9+16] + xor rax, r14 + ror r14, 56 + xor rax, r14 + mov r14, rbx + shr r14, 8 + xor r14, rbx + and r14, QWORD PTR [r9+16] + xor rbx, r14 + ror r14, 56 + xor rbx, r14 + mov r14, rcx + shr r14, 8 + xor r14, rcx + and r14, QWORD PTR [r9+16] + xor rcx, r14 + ror r14, 56 + xor rcx, r14 + mov r14, rbp + shr r14, 8 + xor r14, rbp + and r14, QWORD PTR [r9+16] + xor rbp, r14 + ror r14, 56 + xor rbp, r14 + mov r14, r10 + shr r14, 8 + xor r14, r10 + and r14, QWORD PTR [r9+16] + xor r10, r14 + ror r14, 56 + xor r10, r14 + mov r14, r11 + shr r14, 8 + xor r14, r11 + and r14, QWORD PTR [r9+16] + xor r11, r14 + ror r14, 56 + xor r11, r14 + mov r14, r12 + shr r14, 8 + xor r14, r12 + and r14, QWORD PTR [r9+16] + xor r12, r14 + ror r14, 56 + xor r12, r14 + mov r14, r13 + shr r14, 8 + xor r14, r13 + and r14, QWORD PTR [r9+16] + xor r13, r14 + ror r14, 56 + xor r13, r14 + mov r14, rax + shr r14, 1 + xor r14, rbx + and r14, QWORD PTR [r9+32] + xor rbx, r14 + ror r14, 63 + xor rax, r14 + mov r14, rcx + shr r14, 1 + xor r14, rbp + and r14, QWORD PTR [r9+32] + xor rbp, r14 + ror r14, 63 + xor rcx, r14 + mov r14, r10 + shr r14, 1 + xor r14, r11 + and r14, QWORD PTR [r9+32] + xor r11, r14 + ror r14, 63 + xor r10, r14 + mov r14, r12 + shr r14, 1 + xor r14, r13 + and r14, QWORD PTR [r9+32] + xor r13, r14 + ror r14, 63 + xor r12, r14 + mov r14, rax + shr r14, 2 + xor r14, rcx + and r14, QWORD PTR [r9+40] + xor rcx, r14 + ror r14, 62 + xor rax, r14 + mov r14, rbx + shr r14, 2 + xor r14, rbp + and r14, QWORD PTR [r9+40] + xor rbp, r14 + ror r14, 62 + xor rbx, r14 + mov r14, r10 + shr r14, 2 + xor r14, r12 + and r14, QWORD PTR [r9+40] + xor r12, r14 + ror r14, 62 + xor r10, r14 + mov r14, r11 + shr r14, 2 + xor r14, r13 + and r14, QWORD PTR [r9+40] + xor r13, r14 + ror r14, 62 + xor r11, r14 + mov r14, rax + shr r14, 4 + xor r14, r10 + and r14, QWORD PTR [r9+48] + xor r10, r14 + ror r14, 60 + xor rax, r14 + mov r14, rbx + shr r14, 4 + xor r14, r11 + and r14, QWORD PTR [r9+48] + xor r11, r14 + ror r14, 60 + xor rbx, r14 + mov r14, rcx + shr r14, 4 + xor r14, r12 + and r14, QWORD PTR [r9+48] + xor r12, r14 + ror r14, 60 + xor rcx, r14 + mov r14, rbp + shr r14, 4 + xor r14, r13 + and r14, QWORD PTR [r9+48] + xor r13, r14 + ror r14, 60 + xor rbp, r14 + mov QWORD PTR [rsi], rax + mov QWORD PTR [rsi+8], rbx + mov QWORD PTR [rsi+16], rcx + mov QWORD PTR [rsi+24], rbp + mov QWORD PTR [rsi+32], r10 + mov QWORD PTR [rsi+40], r11 + mov QWORD PTR [rsi+48], r12 + mov QWORD PTR [rsi+56], r13 + add rsi, 64 + add rdi, 8 + sub r15, 1 + jne 23b + mov rdi, r9 + add rdi, 2304 + movabs rdi, 18 +21: + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9+3016], rbp + mov rbp, QWORD PTR [rax+8] + mov QWORD PTR [r9+3024], rbp + test r8, r8 + je 24f +26: + mov r12, rdx + mov r13, r8 + mov r14, rdi + mov rsi, r9 + movabs rdx, 401 + call {vg_camellia_crypt_prepared} + mov rdx, r12 + mov r8, r13 + mov rdi, r14 + cmp r8, 16 + jb 27f + mov rax, QWORD PTR [rdx] + xor rax, QWORD PTR [r9+3016] + mov QWORD PTR [rdx], rax + mov rax, QWORD PTR [rdx+8] + xor rax, QWORD PTR [r9+3024] + mov QWORD PTR [rdx+8], rax + add rdx, 16 + sub r8, 16 + jmp 28f +27: + mov rax, r9 + add rax, 3016 +29: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [rdx] + xor rcx, r10 + mov BYTE PTR [rdx], cl + add rax, 1 + add rdx, 1 + sub r8, 1 + jne 29b +28: + jne 26b + jmp 25f +24: +25: + movq rax, xmm15 + mov rbp, QWORD PTR [r9+3016] + mov QWORD PTR [rax], rbp + mov rbp, QWORD PTR [r9+3024] + mov QWORD PTR [rax+8], rbp + mov rbx, QWORD PTR [r9+3208] + mov rbp, QWORD PTR [r9+3216] + mov r12, QWORD PTR [r9+3224] + mov r13, QWORD PTR [r9+3232] + mov r14, QWORD PTR [r9+3240] + mov r15, QWORD PTR [r9+3248] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + mov QWORD PTR [rsp+96], r11 + mov QWORD PTR [rsp+104], r11 + mov QWORD PTR [rsp+112], r11 + mov QWORD PTR [rsp+120], r11 + mov QWORD PTR [rsp+128], r11 + mov QWORD PTR [rsp+136], r11 + mov QWORD PTR [rsp+144], r11 + mov QWORD PTR [rsp+152], r11 + mov QWORD PTR [rsp+160], r11 + mov QWORD PTR [rsp+168], r11 + mov QWORD PTR [rsp+176], r11 + mov QWORD PTR [rsp+184], r11 + mov QWORD PTR [rsp+192], r11 + mov QWORD PTR [rsp+200], r11 + mov QWORD PTR [rsp+208], r11 + mov QWORD PTR [rsp+216], r11 + mov QWORD PTR [rsp+224], r11 + mov QWORD PTR [rsp+232], r11 + mov QWORD PTR [rsp+240], r11 + mov QWORD PTR [rsp+248], r11 + mov QWORD PTR [rsp+256], r11 + mov QWORD PTR [rsp+264], r11 + mov QWORD PTR [rsp+272], r11 + mov QWORD PTR [rsp+280], r11 + mov QWORD PTR [rsp+288], r11 + mov QWORD PTR [rsp+296], r11 + mov QWORD PTR [rsp+304], r11 + mov QWORD PTR [rsp+312], r11 + mov QWORD PTR [rsp+320], r11 + mov QWORD PTR [rsp+328], r11 + mov QWORD PTR [rsp+336], r11 + mov QWORD PTR [rsp+344], r11 + mov QWORD PTR [rsp+352], r11 + mov QWORD PTR [rsp+360], r11 + mov QWORD PTR [rsp+368], r11 + mov QWORD PTR [rsp+376], r11 + mov QWORD PTR [rsp+384], r11 + mov QWORD PTR [rsp+392], r11 + mov QWORD PTR [rsp+400], r11 + mov QWORD PTR [rsp+408], r11 + mov QWORD PTR [rsp+416], r11 + mov QWORD PTR [rsp+424], r11 + mov QWORD PTR [rsp+432], r11 + mov QWORD PTR [rsp+440], r11 + mov QWORD PTR [rsp+448], r11 + mov QWORD PTR [rsp+456], r11 + mov QWORD PTR [rsp+464], r11 + mov QWORD PTR [rsp+472], r11 + mov QWORD PTR [rsp+480], r11 + mov QWORD PTR [rsp+488], r11 + mov QWORD PTR [rsp+496], r11 + mov QWORD PTR [rsp+504], r11 + mov QWORD PTR [rsp+512], r11 + mov QWORD PTR [rsp+520], r11 + mov QWORD PTR [rsp+528], r11 + mov QWORD PTR [rsp+536], r11 + mov QWORD PTR [rsp+544], r11 + mov QWORD PTR [rsp+552], r11 + mov QWORD PTR [rsp+560], r11 + mov QWORD PTR [rsp+568], r11 + mov QWORD PTR [rsp+576], r11 + mov QWORD PTR [rsp+584], r11 + mov QWORD PTR [rsp+592], r11 + mov QWORD PTR [rsp+600], r11 + mov QWORD PTR [rsp+608], r11 + mov QWORD PTR [rsp+616], r11 + mov QWORD PTR [rsp+624], r11 + mov QWORD PTR [rsp+632], r11 + mov QWORD PTR [rsp+640], r11 + mov QWORD PTR [rsp+648], r11 + mov QWORD PTR [rsp+656], r11 + mov QWORD PTR [rsp+664], r11 + mov QWORD PTR [rsp+672], r11 + mov QWORD PTR [rsp+680], r11 + mov QWORD PTR [rsp+688], r11 + mov QWORD PTR [rsp+696], r11 + mov QWORD PTR [rsp+704], r11 + mov QWORD PTR [rsp+712], r11 + mov QWORD PTR [rsp+720], r11 + mov QWORD PTR [rsp+728], r11 + mov QWORD PTR [rsp+736], r11 + mov QWORD PTR [rsp+744], r11 + mov QWORD PTR [rsp+752], r11 + mov QWORD PTR [rsp+760], r11 + mov QWORD PTR [rsp+768], r11 + mov QWORD PTR [rsp+776], r11 + mov QWORD PTR [rsp+784], r11 + mov QWORD PTR [rsp+792], r11 + mov QWORD PTR [rsp+800], r11 + mov QWORD PTR [rsp+808], r11 + mov QWORD PTR [rsp+816], r11 + mov QWORD PTR [rsp+824], r11 + mov QWORD PTR [rsp+832], r11 + mov QWORD PTR [rsp+840], r11 + mov QWORD PTR [rsp+848], r11 + mov QWORD PTR [rsp+856], r11 + mov QWORD PTR [rsp+864], r11 + mov QWORD PTR [rsp+872], r11 + mov QWORD PTR [rsp+880], r11 + mov QWORD PTR [rsp+888], r11 + mov QWORD PTR [rsp+896], r11 + mov QWORD PTR [rsp+904], r11 + mov QWORD PTR [rsp+912], r11 + mov QWORD PTR [rsp+920], r11 + mov QWORD PTR [rsp+928], r11 + mov QWORD PTR [rsp+936], r11 + mov QWORD PTR [rsp+944], r11 + mov QWORD PTR [rsp+952], r11 + mov QWORD PTR [rsp+960], r11 + mov QWORD PTR [rsp+968], r11 + mov QWORD PTR [rsp+976], r11 + mov QWORD PTR [rsp+984], r11 + mov QWORD PTR [rsp+992], r11 + mov QWORD PTR [rsp+1000], r11 + mov QWORD PTR [rsp+1008], r11 + mov QWORD PTR [rsp+1016], r11 + mov QWORD PTR [rsp+1024], r11 + mov QWORD PTR [rsp+1032], r11 + mov QWORD PTR [rsp+1040], r11 + mov QWORD PTR [rsp+1048], r11 + mov QWORD PTR [rsp+1056], r11 + mov QWORD PTR [rsp+1064], r11 + mov QWORD PTR [rsp+1072], r11 + mov QWORD PTR [rsp+1080], r11 + mov QWORD PTR [rsp+1088], r11 + mov QWORD PTR [rsp+1096], r11 + mov QWORD PTR [rsp+1104], r11 + mov QWORD PTR [rsp+1112], r11 + mov QWORD PTR [rsp+1120], r11 + mov QWORD PTR [rsp+1128], r11 + mov QWORD PTR [rsp+1136], r11 + mov QWORD PTR [rsp+1144], r11 + mov QWORD PTR [rsp+1152], r11 + mov QWORD PTR [rsp+1160], r11 + mov QWORD PTR [rsp+1168], r11 + mov QWORD PTR [rsp+1176], r11 + mov QWORD PTR [rsp+1184], r11 + mov QWORD PTR [rsp+1192], r11 + mov QWORD PTR [rsp+1200], r11 + mov QWORD PTR [rsp+1208], r11 + mov QWORD PTR [rsp+1216], r11 + mov QWORD PTR [rsp+1224], r11 + mov QWORD PTR [rsp+1232], r11 + mov QWORD PTR [rsp+1240], r11 + mov QWORD PTR [rsp+1248], r11 + mov QWORD PTR [rsp+1256], r11 + mov QWORD PTR [rsp+1264], r11 + mov QWORD PTR [rsp+1272], r11 + mov QWORD PTR [rsp+1280], r11 + mov QWORD PTR [rsp+1288], r11 + mov QWORD PTR [rsp+1296], r11 + mov QWORD PTR [rsp+1304], r11 + mov QWORD PTR [rsp+1312], r11 + mov QWORD PTR [rsp+1320], r11 + mov QWORD PTR [rsp+1328], r11 + mov QWORD PTR [rsp+1336], r11 + mov QWORD PTR [rsp+1344], r11 + mov QWORD PTR [rsp+1352], r11 + mov QWORD PTR [rsp+1360], r11 + mov QWORD PTR [rsp+1368], r11 + mov QWORD PTR [rsp+1376], r11 + mov QWORD PTR [rsp+1384], r11 + mov QWORD PTR [rsp+1392], r11 + mov QWORD PTR [rsp+1400], r11 + mov QWORD PTR [rsp+1408], r11 + mov QWORD PTR [rsp+1416], r11 + mov QWORD PTR [rsp+1424], r11 + mov QWORD PTR [rsp+1432], r11 + mov QWORD PTR [rsp+1440], r11 + mov QWORD PTR [rsp+1448], r11 + mov QWORD PTR [rsp+1456], r11 + mov QWORD PTR [rsp+1464], r11 + mov QWORD PTR [rsp+1472], r11 + mov QWORD PTR [rsp+1480], r11 + mov QWORD PTR [rsp+1488], r11 + mov QWORD PTR [rsp+1496], r11 + mov QWORD PTR [rsp+1504], r11 + mov QWORD PTR [rsp+1512], r11 + mov QWORD PTR [rsp+1520], r11 + mov QWORD PTR [rsp+1528], r11 + mov QWORD PTR [rsp+1536], r11 + mov QWORD PTR [rsp+1544], r11 + mov QWORD PTR [rsp+1552], r11 + mov QWORD PTR [rsp+1560], r11 + mov QWORD PTR [rsp+1568], r11 + mov QWORD PTR [rsp+1576], r11 + mov QWORD PTR [rsp+1584], r11 + mov QWORD PTR [rsp+1592], r11 + mov QWORD PTR [rsp+1600], r11 + mov QWORD PTR [rsp+1608], r11 + mov QWORD PTR [rsp+1616], r11 + mov QWORD PTR [rsp+1624], r11 + mov QWORD PTR [rsp+1632], r11 + mov QWORD PTR [rsp+1640], r11 + mov QWORD PTR [rsp+1648], r11 + mov QWORD PTR [rsp+1656], r11 + mov QWORD PTR [rsp+1664], r11 + mov QWORD PTR [rsp+1672], r11 + mov QWORD PTR [rsp+1680], r11 + mov QWORD PTR [rsp+1688], r11 + mov QWORD PTR [rsp+1696], r11 + mov QWORD PTR [rsp+1704], r11 + mov QWORD PTR [rsp+1712], r11 + mov QWORD PTR [rsp+1720], r11 + mov QWORD PTR [rsp+1728], r11 + mov QWORD PTR [rsp+1736], r11 + mov QWORD PTR [rsp+1744], r11 + mov QWORD PTR [rsp+1752], r11 + mov QWORD PTR [rsp+1760], r11 + mov QWORD PTR [rsp+1768], r11 + mov QWORD PTR [rsp+1776], r11 + mov QWORD PTR [rsp+1784], r11 + mov QWORD PTR [rsp+1792], r11 + mov QWORD PTR [rsp+1800], r11 + mov QWORD PTR [rsp+1808], r11 + mov QWORD PTR [rsp+1816], r11 + mov QWORD PTR [rsp+1824], r11 + mov QWORD PTR [rsp+1832], r11 + mov QWORD PTR [rsp+1840], r11 + mov QWORD PTR [rsp+1848], r11 + mov QWORD PTR [rsp+1856], r11 + mov QWORD PTR [rsp+1864], r11 + mov QWORD PTR [rsp+1872], r11 + mov QWORD PTR [rsp+1880], r11 + mov QWORD PTR [rsp+1888], r11 + mov QWORD PTR [rsp+1896], r11 + mov QWORD PTR [rsp+1904], r11 + mov QWORD PTR [rsp+1912], r11 + mov QWORD PTR [rsp+1920], r11 + mov QWORD PTR [rsp+1928], r11 + mov QWORD PTR [rsp+1936], r11 + mov QWORD PTR [rsp+1944], r11 + mov QWORD PTR [rsp+1952], r11 + mov QWORD PTR [rsp+1960], r11 + mov QWORD PTR [rsp+1968], r11 + mov QWORD PTR [rsp+1976], r11 + mov QWORD PTR [rsp+1984], r11 + mov QWORD PTR [rsp+1992], r11 + mov QWORD PTR [rsp+2000], r11 + mov QWORD PTR [rsp+2008], r11 + mov QWORD PTR [rsp+2016], r11 + mov QWORD PTR [rsp+2024], r11 + mov QWORD PTR [rsp+2032], r11 + mov QWORD PTR [rsp+2040], r11 + mov QWORD PTR [rsp+2048], r11 + mov QWORD PTR [rsp+2056], r11 + mov QWORD PTR [rsp+2064], r11 + mov QWORD PTR [rsp+2072], r11 + mov QWORD PTR [rsp+2080], r11 + mov QWORD PTR [rsp+2088], r11 + mov QWORD PTR [rsp+2096], r11 + mov QWORD PTR [rsp+2104], r11 + mov QWORD PTR [rsp+2112], r11 + mov QWORD PTR [rsp+2120], r11 + mov QWORD PTR [rsp+2128], r11 + mov QWORD PTR [rsp+2136], r11 + mov QWORD PTR [rsp+2144], r11 + mov QWORD PTR [rsp+2152], r11 + mov QWORD PTR [rsp+2160], r11 + mov QWORD PTR [rsp+2168], r11 + mov QWORD PTR [rsp+2176], r11 + mov QWORD PTR [rsp+2184], r11 + mov QWORD PTR [rsp+2192], r11 + mov QWORD PTR [rsp+2200], r11 + mov QWORD PTR [rsp+2208], r11 + mov QWORD PTR [rsp+2216], r11 + mov QWORD PTR [rsp+2224], r11 + mov QWORD PTR [rsp+2232], r11 + mov QWORD PTR [rsp+2240], r11 + mov QWORD PTR [rsp+2248], r11 + mov QWORD PTR [rsp+2256], r11 + mov QWORD PTR [rsp+2264], r11 + mov QWORD PTR [rsp+2272], r11 + mov QWORD PTR [rsp+2280], r11 + mov QWORD PTR [rsp+2288], r11 + mov QWORD PTR [rsp+2296], r11 + mov QWORD PTR [rsp+2304], r11 + mov QWORD PTR [rsp+2312], r11 + mov QWORD PTR [rsp+2320], r11 + mov QWORD PTR [rsp+2328], r11 + mov QWORD PTR [rsp+2336], r11 + mov QWORD PTR [rsp+2344], r11 + mov QWORD PTR [rsp+2352], r11 + mov QWORD PTR [rsp+2360], r11 + mov QWORD PTR [rsp+2368], r11 + mov QWORD PTR [rsp+2376], r11 + mov QWORD PTR [rsp+2384], r11 + mov QWORD PTR [rsp+2392], r11 + mov QWORD PTR [rsp+2400], r11 + mov QWORD PTR [rsp+2408], r11 + mov QWORD PTR [rsp+2416], r11 + mov QWORD PTR [rsp+2424], r11 + mov QWORD PTR [rsp+2432], r11 + mov QWORD PTR [rsp+2440], r11 + mov QWORD PTR [rsp+2448], r11 + mov QWORD PTR [rsp+2456], r11 + mov QWORD PTR [rsp+2464], r11 + mov QWORD PTR [rsp+2472], r11 + mov QWORD PTR [rsp+2480], r11 + mov QWORD PTR [rsp+2488], r11 + mov QWORD PTR [rsp+2496], r11 + mov QWORD PTR [rsp+2504], r11 + mov QWORD PTR [rsp+2512], r11 + mov QWORD PTR [rsp+2520], r11 + mov QWORD PTR [rsp+2528], r11 + mov QWORD PTR [rsp+2536], r11 + mov QWORD PTR [rsp+2544], r11 + mov QWORD PTR [rsp+2552], r11 + mov QWORD PTR [rsp+2560], r11 + mov QWORD PTR [rsp+2568], r11 + mov QWORD PTR [rsp+2576], r11 + mov QWORD PTR [rsp+2584], r11 + mov QWORD PTR [rsp+2592], r11 + mov QWORD PTR [rsp+2600], r11 + mov QWORD PTR [rsp+2608], r11 + mov QWORD PTR [rsp+2616], r11 + mov QWORD PTR [rsp+2624], r11 + mov QWORD PTR [rsp+2632], r11 + mov QWORD PTR [rsp+2640], r11 + mov QWORD PTR [rsp+2648], r11 + mov QWORD PTR [rsp+2656], r11 + mov QWORD PTR [rsp+2664], r11 + mov QWORD PTR [rsp+2672], r11 + mov QWORD PTR [rsp+2680], r11 + mov QWORD PTR [rsp+2688], r11 + mov QWORD PTR [rsp+2696], r11 + mov QWORD PTR [rsp+2704], r11 + mov QWORD PTR [rsp+2712], r11 + mov QWORD PTR [rsp+2720], r11 + mov QWORD PTR [rsp+2728], r11 + mov QWORD PTR [rsp+2736], r11 + mov QWORD PTR [rsp+2744], r11 + mov QWORD PTR [rsp+2752], r11 + mov QWORD PTR [rsp+2760], r11 + mov QWORD PTR [rsp+2768], r11 + mov QWORD PTR [rsp+2776], r11 + mov QWORD PTR [rsp+2784], r11 + mov QWORD PTR [rsp+2792], r11 + mov QWORD PTR [rsp+2800], r11 + mov QWORD PTR [rsp+2808], r11 + mov QWORD PTR [rsp+2816], r11 + mov QWORD PTR [rsp+2824], r11 + mov QWORD PTR [rsp+2832], r11 + mov QWORD PTR [rsp+2840], r11 + mov QWORD PTR [rsp+2848], r11 + mov QWORD PTR [rsp+2856], r11 + mov QWORD PTR [rsp+2864], r11 + mov QWORD PTR [rsp+2872], r11 + mov QWORD PTR [rsp+2880], r11 + mov QWORD PTR [rsp+2888], r11 + mov QWORD PTR [rsp+2896], r11 + mov QWORD PTR [rsp+2904], r11 + mov QWORD PTR [rsp+2912], r11 + mov QWORD PTR [rsp+2920], r11 + mov QWORD PTR [rsp+2928], r11 + mov QWORD PTR [rsp+2936], r11 + mov QWORD PTR [rsp+2944], r11 + mov QWORD PTR [rsp+2952], r11 + mov QWORD PTR [rsp+2960], r11 + mov QWORD PTR [rsp+2968], r11 + mov QWORD PTR [rsp+2976], r11 + mov QWORD PTR [rsp+2984], r11 + mov QWORD PTR [rsp+2992], r11 + mov QWORD PTR [rsp+3000], r11 + mov QWORD PTR [rsp+3008], r11 + mov QWORD PTR [rsp+3016], r11 + mov QWORD PTR [rsp+3024], r11 + mov QWORD PTR [rsp+3032], r11 + mov QWORD PTR [rsp+3040], r11 + mov QWORD PTR [rsp+3048], r11 + mov QWORD PTR [rsp+3056], r11 + mov QWORD PTR [rsp+3064], r11 + mov QWORD PTR [rsp+3072], r11 + mov QWORD PTR [rsp+3080], r11 + mov QWORD PTR [rsp+3088], r11 + mov QWORD PTR [rsp+3096], r11 + mov QWORD PTR [rsp+3104], r11 + mov QWORD PTR [rsp+3112], r11 + mov QWORD PTR [rsp+3120], r11 + mov QWORD PTR [rsp+3128], r11 + mov QWORD PTR [rsp+3136], r11 + mov QWORD PTR [rsp+3144], r11 + mov QWORD PTR [rsp+3152], r11 + mov QWORD PTR [rsp+3160], r11 + mov QWORD PTR [rsp+3168], r11 + mov QWORD PTR [rsp+3176], r11 + mov QWORD PTR [rsp+3184], r11 + mov QWORD PTR [rsp+3192], r11 + mov QWORD PTR [rsp+3200], r11 + mov QWORD PTR [rsp+3208], r11 + mov QWORD PTR [rsp+3216], r11 + mov QWORD PTR [rsp+3224], r11 + mov QWORD PTR [rsp+3232], r11 + mov QWORD PTR [rsp+3240], r11 + mov QWORD PTR [rsp+3248], r11 + mov QWORD PTR [rsp+3256], r11 + mov QWORD PTR [rsp+3264], r11 + mov QWORD PTR [rsp+3272], r11 + lea rsp, [rsp+3280] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/cast5_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/cast5_ofb.s index 6475b23f06c..fa183f825f0 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/cast5_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/cast5_ofb.s @@ -591,3 +591,607 @@ vg_cast5_ofb: lea rsp, [rsp+240] ret .p2align 6 + +vg_cast5_ofb_final: + lea rsp, [rsp-240] + mov r9, rsp + add r9, 8 + mov r9, r9 + mov QWORD PTR [r9+168], rbx + mov QWORD PTR [r9+176], rbp + mov QWORD PTR [r9+184], r12 + mov QWORD PTR [r9+192], r13 + mov QWORD PTR [r9+200], r14 + mov QWORD PTR [r9+208], r15 + movq xmm15, rdx + mov r12, rcx + mov r13, r8 + mov rax, QWORD PTR [rdi] + mov QWORD PTR [r9+40], rax + mov rax, QWORD PTR [rdi+8] + mov QWORD PTR [r9+48], rax + mov rax, QWORD PTR [rdi+16] + mov QWORD PTR [r9+56], rax + mov rax, QWORD PTR [rdi+24] + mov QWORD PTR [r9+64], rax + mov rax, QWORD PTR [rdi+32] + mov QWORD PTR [r9+72], rax + mov rax, QWORD PTR [rdi+40] + mov QWORD PTR [r9+80], rax + mov rax, QWORD PTR [rdi+48] + mov QWORD PTR [r9+88], rax + mov rax, QWORD PTR [rdi+56] + mov QWORD PTR [r9+96], rax + mov rax, QWORD PTR [rdi+64] + mov QWORD PTR [r9+104], rax + mov rax, QWORD PTR [rdi+72] + mov QWORD PTR [r9+112], rax + mov rax, QWORD PTR [rdi+80] + mov QWORD PTR [r9+120], rax + mov rax, QWORD PTR [rdi+88] + mov QWORD PTR [r9+128], rax + mov rax, QWORD PTR [rdi+96] + mov QWORD PTR [r9+136], rax + mov rax, QWORD PTR [rdi+104] + mov QWORD PTR [r9+144], rax + mov rax, QWORD PTR [rdi+112] + mov QWORD PTR [r9+152], rax + mov rax, QWORD PTR [rdi+120] + mov QWORD PTR [r9+160], rax + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9+16], rbp + test r13, r13 + je 20f +22: + movq rcx, xmm15 + mov r8, r9 + mov QWORD PTR [r8+24], r12 + mov QWORD PTR [r8+32], r13 + mov rdx, r9 + add rdx, 16 + mov rdi, r9 + add rdi, 40 + mov ebx, DWORD PTR [rdx] + bswap ebx + mov ebp, DWORD PTR [rdx+4] + bswap ebp + mov r12, rdi + mov r13, rsi + shr r13, 2 + add r13, 1 + cmp rsi, 16 +23: + mov eax, DWORD PTR [r12] + add eax, ebp + mov r9d, DWORD PTR [r12+64] + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 31 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 30 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 28 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 24 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 16 + xor eax, r15d + and eax, r14d + xor eax, r15d + mov r9d, eax + and r9d, 255 + mov r14d, eax + shr r14d, 8 + and r14d, 255 + shl r14, 32 + or r9, r14 + movq xmm0, r9 + mov r9d, eax + shr r9d, 16 + and r9d, 255 + mov r14d, eax + shr r14d, 24 + shl r14, 32 + or r9, r14 + movq xmm4, r9 + punpcklqdq xmm0, xmm4 + lea r10, {VG_CAST5_S1234} + mov r11d, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + pcmpeqd xmm3, xmm3 + psrld xmm3, 31 + movdqa xmm4, xmm0 + pand xmm4, xmm3 + pxor xmm6, xmm6 + psubd xmm6, xmm4 + movdqa xmm4, xmm0 + psrld xmm4, 1 + pand xmm4, xmm3 + pxor xmm7, xmm7 + psubd xmm7, xmm4 + movdqa xmm8, xmm0 + psrld xmm8, 2 +24: + movdqu xmm4, XMMWORD PTR [r10] + movdqu xmm5, XMMWORD PTR [r10+16] + pxor xmm5, xmm4 + pand xmm5, xmm6 + pxor xmm4, xmm5 + movdqu xmm9, XMMWORD PTR [r10+32] + movdqu xmm5, XMMWORD PTR [r10+48] + pxor xmm5, xmm9 + pand xmm5, xmm6 + pxor xmm9, xmm5 + pxor xmm9, xmm4 + pand xmm9, xmm7 + pxor xmm4, xmm9 + movdqa xmm5, xmm8 + pcmpeqd xmm5, xmm2 + pand xmm4, xmm5 + por xmm1, xmm4 + paddd xmm2, xmm3 + add r10, 64 + sub r11, 1 + jne 24b + movdqu XMMWORD PTR [r8], xmm1 + mov eax, DWORD PTR [r8+12] + xor eax, DWORD PTR [r8+8] + sub eax, DWORD PTR [r8+4] + add eax, DWORD PTR [r8] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + add r12, 4 + mov eax, DWORD PTR [r12] + xor eax, ebp + mov r9d, DWORD PTR [r12+64] + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 31 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 30 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 28 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 24 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 16 + xor eax, r15d + and eax, r14d + xor eax, r15d + mov r9d, eax + and r9d, 255 + mov r14d, eax + shr r14d, 8 + and r14d, 255 + shl r14, 32 + or r9, r14 + movq xmm0, r9 + mov r9d, eax + shr r9d, 16 + and r9d, 255 + mov r14d, eax + shr r14d, 24 + shl r14, 32 + or r9, r14 + movq xmm4, r9 + punpcklqdq xmm0, xmm4 + lea r10, {VG_CAST5_S1234} + mov r11d, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + pcmpeqd xmm3, xmm3 + psrld xmm3, 31 + movdqa xmm4, xmm0 + pand xmm4, xmm3 + pxor xmm6, xmm6 + psubd xmm6, xmm4 + movdqa xmm4, xmm0 + psrld xmm4, 1 + pand xmm4, xmm3 + pxor xmm7, xmm7 + psubd xmm7, xmm4 + movdqa xmm8, xmm0 + psrld xmm8, 2 +25: + movdqu xmm4, XMMWORD PTR [r10] + movdqu xmm5, XMMWORD PTR [r10+16] + pxor xmm5, xmm4 + pand xmm5, xmm6 + pxor xmm4, xmm5 + movdqu xmm9, XMMWORD PTR [r10+32] + movdqu xmm5, XMMWORD PTR [r10+48] + pxor xmm5, xmm9 + pand xmm5, xmm6 + pxor xmm9, xmm5 + pxor xmm9, xmm4 + pand xmm9, xmm7 + pxor xmm4, xmm9 + movdqa xmm5, xmm8 + pcmpeqd xmm5, xmm2 + pand xmm4, xmm5 + por xmm1, xmm4 + paddd xmm2, xmm3 + add r10, 64 + sub r11, 1 + jne 25b + movdqu XMMWORD PTR [r8], xmm1 + mov eax, DWORD PTR [r8+12] + sub eax, DWORD PTR [r8+8] + add eax, DWORD PTR [r8+4] + xor eax, DWORD PTR [r8] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + add r12, 4 + mov eax, DWORD PTR [r12] + sub eax, ebp + mov r9d, DWORD PTR [r12+64] + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 31 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 30 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 28 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 24 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 16 + xor eax, r15d + and eax, r14d + xor eax, r15d + mov r9d, eax + and r9d, 255 + mov r14d, eax + shr r14d, 8 + and r14d, 255 + shl r14, 32 + or r9, r14 + movq xmm0, r9 + mov r9d, eax + shr r9d, 16 + and r9d, 255 + mov r14d, eax + shr r14d, 24 + shl r14, 32 + or r9, r14 + movq xmm4, r9 + punpcklqdq xmm0, xmm4 + lea r10, {VG_CAST5_S1234} + mov r11d, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + pcmpeqd xmm3, xmm3 + psrld xmm3, 31 + movdqa xmm4, xmm0 + pand xmm4, xmm3 + pxor xmm6, xmm6 + psubd xmm6, xmm4 + movdqa xmm4, xmm0 + psrld xmm4, 1 + pand xmm4, xmm3 + pxor xmm7, xmm7 + psubd xmm7, xmm4 + movdqa xmm8, xmm0 + psrld xmm8, 2 +26: + movdqu xmm4, XMMWORD PTR [r10] + movdqu xmm5, XMMWORD PTR [r10+16] + pxor xmm5, xmm4 + pand xmm5, xmm6 + pxor xmm4, xmm5 + movdqu xmm9, XMMWORD PTR [r10+32] + movdqu xmm5, XMMWORD PTR [r10+48] + pxor xmm5, xmm9 + pand xmm5, xmm6 + pxor xmm9, xmm5 + pxor xmm9, xmm4 + pand xmm9, xmm7 + pxor xmm4, xmm9 + movdqa xmm5, xmm8 + pcmpeqd xmm5, xmm2 + pand xmm4, xmm5 + por xmm1, xmm4 + paddd xmm2, xmm3 + add r10, 64 + sub r11, 1 + jne 26b + movdqu XMMWORD PTR [r8], xmm1 + mov eax, DWORD PTR [r8+12] + add eax, DWORD PTR [r8+8] + xor eax, DWORD PTR [r8+4] + sub eax, DWORD PTR [r8] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + add r12, 4 + sub r13, 1 + jne 23b + cmp rsi, 16 + je 27f + jmp 28f +27: + mov eax, DWORD PTR [r12] + add eax, ebp + mov r9d, DWORD PTR [r12+64] + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 31 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 30 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 28 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 24 + xor eax, r15d + and eax, r14d + xor eax, r15d + shr r9d, 1 + mov r14d, r9d + and r14d, 1 + sub r14d, 1 + mov r15d, eax + ror r15d, 16 + xor eax, r15d + and eax, r14d + xor eax, r15d + mov r9d, eax + and r9d, 255 + mov r14d, eax + shr r14d, 8 + and r14d, 255 + shl r14, 32 + or r9, r14 + movq xmm0, r9 + mov r9d, eax + shr r9d, 16 + and r9d, 255 + mov r14d, eax + shr r14d, 24 + shl r14, 32 + or r9, r14 + movq xmm4, r9 + punpcklqdq xmm0, xmm4 + lea r10, {VG_CAST5_S1234} + mov r11d, 64 + pxor xmm1, xmm1 + pxor xmm2, xmm2 + pcmpeqd xmm3, xmm3 + psrld xmm3, 31 + movdqa xmm4, xmm0 + pand xmm4, xmm3 + pxor xmm6, xmm6 + psubd xmm6, xmm4 + movdqa xmm4, xmm0 + psrld xmm4, 1 + pand xmm4, xmm3 + pxor xmm7, xmm7 + psubd xmm7, xmm4 + movdqa xmm8, xmm0 + psrld xmm8, 2 +29: + movdqu xmm4, XMMWORD PTR [r10] + movdqu xmm5, XMMWORD PTR [r10+16] + pxor xmm5, xmm4 + pand xmm5, xmm6 + pxor xmm4, xmm5 + movdqu xmm9, XMMWORD PTR [r10+32] + movdqu xmm5, XMMWORD PTR [r10+48] + pxor xmm5, xmm9 + pand xmm5, xmm6 + pxor xmm9, xmm5 + pxor xmm9, xmm4 + pand xmm9, xmm7 + pxor xmm4, xmm9 + movdqa xmm5, xmm8 + pcmpeqd xmm5, xmm2 + pand xmm4, xmm5 + por xmm1, xmm4 + paddd xmm2, xmm3 + add r10, 64 + sub r11, 1 + jne 29b + movdqu XMMWORD PTR [r8], xmm1 + mov eax, DWORD PTR [r8+12] + xor eax, DWORD PTR [r8+8] + sub eax, DWORD PTR [r8+4] + add eax, DWORD PTR [r8] + xor eax, ebx + mov ebx, ebp + mov ebp, eax + add r12, 4 +28: + bswap ebp + mov DWORD PTR [rdx], ebp + bswap ebx + mov DWORD PTR [rdx+4], ebx + add rdx, 8 + sub rcx, 1 + mov r12, QWORD PTR [r8+24] + mov r13, QWORD PTR [r8+32] + mov r9, r8 + add rcx, 1 + movq xmm15, rcx + cmp r13, 8 + jb 210f + mov rax, QWORD PTR [r12] + xor rax, QWORD PTR [r9+16] + mov QWORD PTR [r12], rax + add r12, 8 + sub r13, 8 + jmp 211f +210: + mov rax, r9 + add rax, 16 +212: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r12] + xor rcx, r10 + mov BYTE PTR [r12], cl + add rax, 1 + add r12, 1 + sub r13, 1 + jne 212b +211: + jne 22b + jmp 21f +20: +21: + movq rax, xmm15 + mov rbp, QWORD PTR [r9+16] + mov QWORD PTR [rax], rbp + mov rbx, QWORD PTR [r9+168] + mov rbp, QWORD PTR [r9+176] + mov r12, QWORD PTR [r9+184] + mov r13, QWORD PTR [r9+192] + mov r14, QWORD PTR [r9+200] + mov r15, QWORD PTR [r9+208] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + mov QWORD PTR [rsp+96], r11 + mov QWORD PTR [rsp+104], r11 + mov QWORD PTR [rsp+112], r11 + mov QWORD PTR [rsp+120], r11 + mov QWORD PTR [rsp+128], r11 + mov QWORD PTR [rsp+136], r11 + mov QWORD PTR [rsp+144], r11 + mov QWORD PTR [rsp+152], r11 + mov QWORD PTR [rsp+160], r11 + mov QWORD PTR [rsp+168], r11 + mov QWORD PTR [rsp+176], r11 + mov QWORD PTR [rsp+184], r11 + mov QWORD PTR [rsp+192], r11 + mov QWORD PTR [rsp+200], r11 + mov QWORD PTR [rsp+208], r11 + mov QWORD PTR [rsp+216], r11 + mov QWORD PTR [rsp+224], r11 + mov QWORD PTR [rsp+232], r11 + lea rsp, [rsp+240] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/idea_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/idea_ofb.s index 31d047ff2bd..ec282f6e56a 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/idea_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/idea_ofb.s @@ -956,3 +956,972 @@ vg_idea_ofb: lea rsp, [rsp+184] ret .p2align 6 + +vg_idea_ofb_final: + lea rsp, [rsp-184] + mov r8, rsp + add r8, 8 + mov r9, r8 + mov QWORD PTR [r9+112], rbx + mov QWORD PTR [r9+120], rbp + mov QWORD PTR [r9+128], r12 + mov QWORD PTR [r9+136], r13 + mov QWORD PTR [r9+144], r14 + mov QWORD PTR [r9+152], r15 + movq xmm15, rsi + mov r12, rdx + mov r13, rcx + mov rax, QWORD PTR [rdi] + mov QWORD PTR [r9+8], rax + mov rax, QWORD PTR [rdi+8] + mov QWORD PTR [r9+16], rax + mov rax, QWORD PTR [rdi+16] + mov QWORD PTR [r9+24], rax + mov rax, QWORD PTR [rdi+24] + mov QWORD PTR [r9+32], rax + mov rax, QWORD PTR [rdi+32] + mov QWORD PTR [r9+40], rax + mov rax, QWORD PTR [rdi+40] + mov QWORD PTR [r9+48], rax + mov rax, QWORD PTR [rdi+48] + mov QWORD PTR [r9+56], rax + mov rax, QWORD PTR [rdi+56] + mov QWORD PTR [r9+64], rax + mov rax, QWORD PTR [rdi+64] + mov QWORD PTR [r9+72], rax + mov rax, QWORD PTR [rdi+72] + mov QWORD PTR [r9+80], rax + mov rax, QWORD PTR [rdi+80] + mov QWORD PTR [r9+88], rax + mov rax, QWORD PTR [rdi+88] + mov QWORD PTR [r9+96], rax + mov rax, QWORD PTR [rdi+96] + mov QWORD PTR [r9+104], rax + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9], rbp + test r13, r13 + je 20f +22: + mov rcx, r9 + mov rdi, r9 + add rdi, 8 + mov rsi, r9 + movzx r8d, BYTE PTR [rsi] + shl r8, 8 + movzx eax, BYTE PTR [rsi+1] + or r8, rax + movzx r9d, BYTE PTR [rsi+2] + shl r9, 8 + movzx eax, BYTE PTR [rsi+3] + or r9, rax + movzx r10d, BYTE PTR [rsi+4] + shl r10, 8 + movzx eax, BYTE PTR [rsi+5] + or r10, rax + movzx r11d, BYTE PTR [rsi+6] + shl r11, 8 + movzx eax, BYTE PTR [rsi+7] + or r11, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+6] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+2] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+4] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+8] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+10] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+12] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+18] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+14] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+16] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+20] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+22] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+24] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+30] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+26] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+28] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+32] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+34] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+36] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+42] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+38] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+40] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+44] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+46] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+48] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+54] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+50] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+52] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+56] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+58] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+60] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+66] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+62] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+64] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+68] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+70] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+72] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+78] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+74] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+76] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+80] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+82] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+84] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+90] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+86] + add r9, rdx + and r9, 65535 + mov rdx, QWORD PTR [rdi+88] + add r10, rdx + and r10, 65535 + mov rax, r8 + xor rax, r10 + mov rdx, QWORD PTR [rdi+92] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov rbx, rdx + mov rax, r9 + xor rax, r11 + add rax, rbx + mov rdx, QWORD PTR [rdi+94] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + add rbx, rdx + and rbx, 65535 + xor r8, rdx + xor r10, rdx + xor r9, rbx + xor r11, rbx + mov rax, r9 + mov r9, r10 + mov r10, rax + mov rax, r8 + mov rdx, QWORD PTR [rdi+96] + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r8, rdx + mov rax, r11 + mov rdx, QWORD PTR [rdi+96] + shr rdx, 48 + sub rax, 1 + and rax, 65535 + add rax, 1 + sub rdx, 1 + and rdx, 65535 + add rdx, 1 + imul rax, rdx + mov rdx, rax + and rdx, 65535 + shr rax, 16 + sub rdx, rax + mov rax, rdx + shr rax, 63 + add rdx, rax + shl rax, 16 + add rdx, rax + and rdx, 65535 + mov r11, rdx + mov rdx, QWORD PTR [rdi+96] + shr rdx, 16 + add r10, rdx + and r10, 65535 + mov rdx, QWORD PTR [rdi+96] + shr rdx, 32 + add r9, rdx + and r9, 65535 + mov BYTE PTR [rsi+1], r8b + mov rax, r8 + shr rax, 8 + mov BYTE PTR [rsi], al + mov BYTE PTR [rsi+3], r10b + mov rax, r10 + shr rax, 8 + mov BYTE PTR [rsi+2], al + mov BYTE PTR [rsi+5], r9b + mov rax, r9 + shr rax, 8 + mov BYTE PTR [rsi+4], al + mov BYTE PTR [rsi+7], r11b + mov rax, r11 + shr rax, 8 + mov BYTE PTR [rsi+6], al + mov r9, rcx + cmp r13, 8 + jb 23f + mov rax, QWORD PTR [r12] + xor rax, QWORD PTR [r9] + mov QWORD PTR [r12], rax + add r12, 8 + sub r13, 8 + jmp 24f +23: + mov rax, r9 + add rax, 0 +25: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r12] + xor rcx, r10 + mov BYTE PTR [r12], cl + add rax, 1 + add r12, 1 + sub r13, 1 + jne 25b +24: + jne 22b + jmp 21f +20: +21: + movq rax, xmm15 + mov rbp, QWORD PTR [r9] + mov QWORD PTR [rax], rbp + mov rbx, QWORD PTR [r9+112] + mov rbp, QWORD PTR [r9+120] + mov r12, QWORD PTR [r9+128] + mov r13, QWORD PTR [r9+136] + mov r14, QWORD PTR [r9+144] + mov r15, QWORD PTR [r9+152] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + mov QWORD PTR [rsp+96], r11 + mov QWORD PTR [rsp+104], r11 + mov QWORD PTR [rsp+112], r11 + mov QWORD PTR [rsp+120], r11 + mov QWORD PTR [rsp+128], r11 + mov QWORD PTR [rsp+136], r11 + mov QWORD PTR [rsp+144], r11 + mov QWORD PTR [rsp+152], r11 + mov QWORD PTR [rsp+160], r11 + mov QWORD PTR [rsp+168], r11 + mov QWORD PTR [rsp+176], r11 + lea rsp, [rsp+184] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/seed_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/seed_ofb.s index 22205f6c2d7..eb5c5b30a4b 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/seed_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/seed_ofb.s @@ -290,3 +290,306 @@ vg_seed_ofb: lea rsp, [rsp+1544] ret .p2align 6 + +vg_seed_ofb_final: + lea rsp, [rsp-1544] + mov r8, rsp + add r8, 8 + mov r9, r8 + mov QWORD PTR [r9+1472], rbx + mov QWORD PTR [r9+1480], rbp + mov QWORD PTR [r9+1488], r12 + mov QWORD PTR [r9+1496], r13 + mov QWORD PTR [r9+1504], r14 + mov QWORD PTR [r9+1512], r15 + movq xmm15, rsi + mov r12, rdx + mov r13, rcx + mov rax, QWORD PTR [rdi] + mov QWORD PTR [r9+1344], rax + mov rax, QWORD PTR [rdi+8] + mov QWORD PTR [r9+1352], rax + mov rax, QWORD PTR [rdi+16] + mov QWORD PTR [r9+1360], rax + mov rax, QWORD PTR [rdi+24] + mov QWORD PTR [r9+1368], rax + mov rax, QWORD PTR [rdi+32] + mov QWORD PTR [r9+1376], rax + mov rax, QWORD PTR [rdi+40] + mov QWORD PTR [r9+1384], rax + mov rax, QWORD PTR [rdi+48] + mov QWORD PTR [r9+1392], rax + mov rax, QWORD PTR [rdi+56] + mov QWORD PTR [r9+1400], rax + mov rax, QWORD PTR [rdi+64] + mov QWORD PTR [r9+1408], rax + mov rax, QWORD PTR [rdi+72] + mov QWORD PTR [r9+1416], rax + mov rax, QWORD PTR [rdi+80] + mov QWORD PTR [r9+1424], rax + mov rax, QWORD PTR [rdi+88] + mov QWORD PTR [r9+1432], rax + mov rax, QWORD PTR [rdi+96] + mov QWORD PTR [r9+1440], rax + mov rax, QWORD PTR [rdi+104] + mov QWORD PTR [r9+1448], rax + mov rax, QWORD PTR [rdi+112] + mov QWORD PTR [r9+1456], rax + mov rax, QWORD PTR [rdi+120] + mov QWORD PTR [r9+1464], rax + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9+1088], rbp + mov rbp, QWORD PTR [rax+8] + mov QWORD PTR [r9+1096], rbp + test r13, r13 + je 20f +22: + movq xmm12, r9 + movq xmm13, r12 + movq xmm14, r13 + mov rdi, r9 + add rdi, 1344 + mov rsi, r9 + add rsi, 1088 + movabs rdx, 16 + mov rcx, r9 + call {vg_seed_encrypt_blocks} + movq r9, xmm12 + movq r12, xmm13 + movq r13, xmm14 + cmp r13, 16 + jb 23f + mov rax, QWORD PTR [r12] + xor rax, QWORD PTR [r9+1088] + mov QWORD PTR [r12], rax + mov rax, QWORD PTR [r12+8] + xor rax, QWORD PTR [r9+1096] + mov QWORD PTR [r12+8], rax + add r12, 16 + sub r13, 16 + jmp 24f +23: + mov rax, r9 + add rax, 1088 +25: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r12] + xor rcx, r10 + mov BYTE PTR [r12], cl + add rax, 1 + add r12, 1 + sub r13, 1 + jne 25b +24: + jne 22b + jmp 21f +20: +21: + movq rax, xmm15 + mov rbp, QWORD PTR [r9+1088] + mov QWORD PTR [rax], rbp + mov rbp, QWORD PTR [r9+1096] + mov QWORD PTR [rax+8], rbp + mov rbx, QWORD PTR [r9+1472] + mov rbp, QWORD PTR [r9+1480] + mov r12, QWORD PTR [r9+1488] + mov r13, QWORD PTR [r9+1496] + mov r14, QWORD PTR [r9+1504] + mov r15, QWORD PTR [r9+1512] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + mov QWORD PTR [rsp+96], r11 + mov QWORD PTR [rsp+104], r11 + mov QWORD PTR [rsp+112], r11 + mov QWORD PTR [rsp+120], r11 + mov QWORD PTR [rsp+128], r11 + mov QWORD PTR [rsp+136], r11 + mov QWORD PTR [rsp+144], r11 + mov QWORD PTR [rsp+152], r11 + mov QWORD PTR [rsp+160], r11 + mov QWORD PTR [rsp+168], r11 + mov QWORD PTR [rsp+176], r11 + mov QWORD PTR [rsp+184], r11 + mov QWORD PTR [rsp+192], r11 + mov QWORD PTR [rsp+200], r11 + mov QWORD PTR [rsp+208], r11 + mov QWORD PTR [rsp+216], r11 + mov QWORD PTR [rsp+224], r11 + mov QWORD PTR [rsp+232], r11 + mov QWORD PTR [rsp+240], r11 + mov QWORD PTR [rsp+248], r11 + mov QWORD PTR [rsp+256], r11 + mov QWORD PTR [rsp+264], r11 + mov QWORD PTR [rsp+272], r11 + mov QWORD PTR [rsp+280], r11 + mov QWORD PTR [rsp+288], r11 + mov QWORD PTR [rsp+296], r11 + mov QWORD PTR [rsp+304], r11 + mov QWORD PTR [rsp+312], r11 + mov QWORD PTR [rsp+320], r11 + mov QWORD PTR [rsp+328], r11 + mov QWORD PTR [rsp+336], r11 + mov QWORD PTR [rsp+344], r11 + mov QWORD PTR [rsp+352], r11 + mov QWORD PTR [rsp+360], r11 + mov QWORD PTR [rsp+368], r11 + mov QWORD PTR [rsp+376], r11 + mov QWORD PTR [rsp+384], r11 + mov QWORD PTR [rsp+392], r11 + mov QWORD PTR [rsp+400], r11 + mov QWORD PTR [rsp+408], r11 + mov QWORD PTR [rsp+416], r11 + mov QWORD PTR [rsp+424], r11 + mov QWORD PTR [rsp+432], r11 + mov QWORD PTR [rsp+440], r11 + mov QWORD PTR [rsp+448], r11 + mov QWORD PTR [rsp+456], r11 + mov QWORD PTR [rsp+464], r11 + mov QWORD PTR [rsp+472], r11 + mov QWORD PTR [rsp+480], r11 + mov QWORD PTR [rsp+488], r11 + mov QWORD PTR [rsp+496], r11 + mov QWORD PTR [rsp+504], r11 + mov QWORD PTR [rsp+512], r11 + mov QWORD PTR [rsp+520], r11 + mov QWORD PTR [rsp+528], r11 + mov QWORD PTR [rsp+536], r11 + mov QWORD PTR [rsp+544], r11 + mov QWORD PTR [rsp+552], r11 + mov QWORD PTR [rsp+560], r11 + mov QWORD PTR [rsp+568], r11 + mov QWORD PTR [rsp+576], r11 + mov QWORD PTR [rsp+584], r11 + mov QWORD PTR [rsp+592], r11 + mov QWORD PTR [rsp+600], r11 + mov QWORD PTR [rsp+608], r11 + mov QWORD PTR [rsp+616], r11 + mov QWORD PTR [rsp+624], r11 + mov QWORD PTR [rsp+632], r11 + mov QWORD PTR [rsp+640], r11 + mov QWORD PTR [rsp+648], r11 + mov QWORD PTR [rsp+656], r11 + mov QWORD PTR [rsp+664], r11 + mov QWORD PTR [rsp+672], r11 + mov QWORD PTR [rsp+680], r11 + mov QWORD PTR [rsp+688], r11 + mov QWORD PTR [rsp+696], r11 + mov QWORD PTR [rsp+704], r11 + mov QWORD PTR [rsp+712], r11 + mov QWORD PTR [rsp+720], r11 + mov QWORD PTR [rsp+728], r11 + mov QWORD PTR [rsp+736], r11 + mov QWORD PTR [rsp+744], r11 + mov QWORD PTR [rsp+752], r11 + mov QWORD PTR [rsp+760], r11 + mov QWORD PTR [rsp+768], r11 + mov QWORD PTR [rsp+776], r11 + mov QWORD PTR [rsp+784], r11 + mov QWORD PTR [rsp+792], r11 + mov QWORD PTR [rsp+800], r11 + mov QWORD PTR [rsp+808], r11 + mov QWORD PTR [rsp+816], r11 + mov QWORD PTR [rsp+824], r11 + mov QWORD PTR [rsp+832], r11 + mov QWORD PTR [rsp+840], r11 + mov QWORD PTR [rsp+848], r11 + mov QWORD PTR [rsp+856], r11 + mov QWORD PTR [rsp+864], r11 + mov QWORD PTR [rsp+872], r11 + mov QWORD PTR [rsp+880], r11 + mov QWORD PTR [rsp+888], r11 + mov QWORD PTR [rsp+896], r11 + mov QWORD PTR [rsp+904], r11 + mov QWORD PTR [rsp+912], r11 + mov QWORD PTR [rsp+920], r11 + mov QWORD PTR [rsp+928], r11 + mov QWORD PTR [rsp+936], r11 + mov QWORD PTR [rsp+944], r11 + mov QWORD PTR [rsp+952], r11 + mov QWORD PTR [rsp+960], r11 + mov QWORD PTR [rsp+968], r11 + mov QWORD PTR [rsp+976], r11 + mov QWORD PTR [rsp+984], r11 + mov QWORD PTR [rsp+992], r11 + mov QWORD PTR [rsp+1000], r11 + mov QWORD PTR [rsp+1008], r11 + mov QWORD PTR [rsp+1016], r11 + mov QWORD PTR [rsp+1024], r11 + mov QWORD PTR [rsp+1032], r11 + mov QWORD PTR [rsp+1040], r11 + mov QWORD PTR [rsp+1048], r11 + mov QWORD PTR [rsp+1056], r11 + mov QWORD PTR [rsp+1064], r11 + mov QWORD PTR [rsp+1072], r11 + mov QWORD PTR [rsp+1080], r11 + mov QWORD PTR [rsp+1088], r11 + mov QWORD PTR [rsp+1096], r11 + mov QWORD PTR [rsp+1104], r11 + mov QWORD PTR [rsp+1112], r11 + mov QWORD PTR [rsp+1120], r11 + mov QWORD PTR [rsp+1128], r11 + mov QWORD PTR [rsp+1136], r11 + mov QWORD PTR [rsp+1144], r11 + mov QWORD PTR [rsp+1152], r11 + mov QWORD PTR [rsp+1160], r11 + mov QWORD PTR [rsp+1168], r11 + mov QWORD PTR [rsp+1176], r11 + mov QWORD PTR [rsp+1184], r11 + mov QWORD PTR [rsp+1192], r11 + mov QWORD PTR [rsp+1200], r11 + mov QWORD PTR [rsp+1208], r11 + mov QWORD PTR [rsp+1216], r11 + mov QWORD PTR [rsp+1224], r11 + mov QWORD PTR [rsp+1232], r11 + mov QWORD PTR [rsp+1240], r11 + mov QWORD PTR [rsp+1248], r11 + mov QWORD PTR [rsp+1256], r11 + mov QWORD PTR [rsp+1264], r11 + mov QWORD PTR [rsp+1272], r11 + mov QWORD PTR [rsp+1280], r11 + mov QWORD PTR [rsp+1288], r11 + mov QWORD PTR [rsp+1296], r11 + mov QWORD PTR [rsp+1304], r11 + mov QWORD PTR [rsp+1312], r11 + mov QWORD PTR [rsp+1320], r11 + mov QWORD PTR [rsp+1328], r11 + mov QWORD PTR [rsp+1336], r11 + mov QWORD PTR [rsp+1344], r11 + mov QWORD PTR [rsp+1352], r11 + mov QWORD PTR [rsp+1360], r11 + mov QWORD PTR [rsp+1368], r11 + mov QWORD PTR [rsp+1376], r11 + mov QWORD PTR [rsp+1384], r11 + mov QWORD PTR [rsp+1392], r11 + mov QWORD PTR [rsp+1400], r11 + mov QWORD PTR [rsp+1408], r11 + mov QWORD PTR [rsp+1416], r11 + mov QWORD PTR [rsp+1424], r11 + mov QWORD PTR [rsp+1432], r11 + mov QWORD PTR [rsp+1440], r11 + mov QWORD PTR [rsp+1448], r11 + mov QWORD PTR [rsp+1456], r11 + mov QWORD PTR [rsp+1464], r11 + mov QWORD PTR [rsp+1472], r11 + mov QWORD PTR [rsp+1480], r11 + mov QWORD PTR [rsp+1488], r11 + mov QWORD PTR [rsp+1496], r11 + mov QWORD PTR [rsp+1504], r11 + mov QWORD PTR [rsp+1512], r11 + mov QWORD PTR [rsp+1520], r11 + mov QWORD PTR [rsp+1528], r11 + mov QWORD PTR [rsp+1536], r11 + lea rsp, [rsp+1544] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/sm4_ctr.s b/crates/verified-garbage-asm-x86_64/assembly/sm4_ctr.s index c10c519a920..1ac164ba327 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/sm4_ctr.s +++ b/crates/verified-garbage-asm-x86_64/assembly/sm4_ctr.s @@ -1066,3 +1066,70 @@ vg_sm4_ctr: lea rsp, [rsp+3208] ret .p2align 6 + +vg_sm4_ctr_final: + lea rsp, [rsp-72] + mov r8, rsp + add r8, 8 + mov rax, r8 + mov QWORD PTR [rax], rbx + mov QWORD PTR [rax+8], rbp + mov QWORD PTR [rax+16], r12 + mov QWORD PTR [rax+24], r13 + mov QWORD PTR [rax+32], r14 + mov QWORD PTR [rax+40], r15 + mov rbx, rdi + mov r12, rsi + mov r15, rax + mov r14, rcx + and r14, 15 + mov r13, rcx + sub r13, r14 + add r13, rdx + shr rcx, 4 + call {vg_sm4_ctr} + test r14, r14 + je 20f + mov rax, r15 + mov r10d, 0 + mov QWORD PTR [rax+48], r10 + mov QWORD PTR [rax+56], r10 + mov rdi, rbx + mov rsi, r12 + mov rdx, rax + add rdx, 48 + mov ecx, 1 + call {vg_sm4_ctr} + mov rax, r15 + add rax, 48 +22: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r13] + xor rcx, r10 + mov BYTE PTR [r13], cl + add rax, 1 + add r13, 1 + sub r14, 1 + jne 22b + jmp 21f +20: +21: + mov rax, r15 + mov rbx, QWORD PTR [rax] + mov rbp, QWORD PTR [rax+8] + mov r12, QWORD PTR [rax+16] + mov r13, QWORD PTR [rax+24] + mov r14, QWORD PTR [rax+32] + mov r15, QWORD PTR [rax+40] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + lea rsp, [rsp+72] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/sm4_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/sm4_ofb.s index a70921517bc..3510bb4a126 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/sm4_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/sm4_ofb.s @@ -917,3 +917,933 @@ vg_sm4_ofb: lea rsp, [rsp+3208] ret .p2align 6 + +vg_sm4_ofb_final: + lea rsp, [rsp-3208] + mov r8, rsp + add r8, 8 + mov r9, r8 + mov QWORD PTR [r9+3136], rbx + mov QWORD PTR [r9+3144], rbp + mov QWORD PTR [r9+3152], r12 + mov QWORD PTR [r9+3160], r13 + mov QWORD PTR [r9+3168], r14 + mov QWORD PTR [r9+3176], r15 + movq xmm15, rsi + mov rdx, rdx + mov r8, rcx + movabs r14, 71777214294589695 + mov QWORD PTR [r9+384], r14 + movabs r14, -71777214294589696 + mov QWORD PTR [r9+392], r14 + movabs r14, 281470681808895 + mov QWORD PTR [r9+400], r14 + mov rsi, r9 + add rsi, 1024 + movabs r15, 16 +20: + mov rax, QWORD PTR [rdi] + movabs r14, 4294901760 + mov QWORD PTR [r9+8], r14 + movabs r14, 280375465148160 + mov QWORD PTR [r9+16], r14 + movabs r14, 71777214294589695 + mov QWORD PTR [r9+24], r14 + movabs r14, 6148914691236517205 + mov QWORD PTR [r9+32], r14 + movabs r14, 3689348814741910323 + mov QWORD PTR [r9+40], r14 + movabs r14, 1085102592571150095 + mov QWORD PTR [r9+48], r14 + mov r14, rax + shr r14, 16 + xor r14, rax + and r14, QWORD PTR [r9+8] + xor rax, r14 + ror r14, 48 + xor rax, r14 + mov r14, rax + shr r14, 8 + xor r14, rax + and r14, QWORD PTR [r9+16] + xor rax, r14 + ror r14, 56 + xor rax, r14 + mov rbx, rax + mov rcx, rax + mov rbp, rax + mov r10, rax + mov r11, rax + mov r12, rax + mov r13, rax + mov r14, rax + shr r14, 1 + xor r14, rbx + and r14, QWORD PTR [r9+32] + xor rbx, r14 + ror r14, 63 + xor rax, r14 + mov r14, rcx + shr r14, 1 + xor r14, rbp + and r14, QWORD PTR [r9+32] + xor rbp, r14 + ror r14, 63 + xor rcx, r14 + mov r14, r10 + shr r14, 1 + xor r14, r11 + and r14, QWORD PTR [r9+32] + xor r11, r14 + ror r14, 63 + xor r10, r14 + mov r14, r12 + shr r14, 1 + xor r14, r13 + and r14, QWORD PTR [r9+32] + xor r13, r14 + ror r14, 63 + xor r12, r14 + mov r14, rax + shr r14, 2 + xor r14, rcx + and r14, QWORD PTR [r9+40] + xor rcx, r14 + ror r14, 62 + xor rax, r14 + mov r14, rbx + shr r14, 2 + xor r14, rbp + and r14, QWORD PTR [r9+40] + xor rbp, r14 + ror r14, 62 + xor rbx, r14 + mov r14, r10 + shr r14, 2 + xor r14, r12 + and r14, QWORD PTR [r9+40] + xor r12, r14 + ror r14, 62 + xor r10, r14 + mov r14, r11 + shr r14, 2 + xor r14, r13 + and r14, QWORD PTR [r9+40] + xor r13, r14 + ror r14, 62 + xor r11, r14 + mov r14, rax + shr r14, 4 + xor r14, r10 + and r14, QWORD PTR [r9+48] + xor r10, r14 + ror r14, 60 + xor rax, r14 + mov r14, rbx + shr r14, 4 + xor r14, r11 + and r14, QWORD PTR [r9+48] + xor r11, r14 + ror r14, 60 + xor rbx, r14 + mov r14, rcx + shr r14, 4 + xor r14, r12 + and r14, QWORD PTR [r9+48] + xor r12, r14 + ror r14, 60 + xor rcx, r14 + mov r14, rbp + shr r14, 4 + xor r14, r13 + and r14, QWORD PTR [r9+48] + xor r13, r14 + ror r14, 60 + xor rbp, r14 + and rax, QWORD PTR [r9+384] + mov r14, rax + ror r14, 56 + xor rax, r14 + ror rax, 32 + mov r14, rax + shr r14, 16 + xor r14, rax + and r14, QWORD PTR [r9+400] + xor rax, r14 + ror r14, 48 + xor rax, r14 + and rbx, QWORD PTR [r9+384] + mov r14, rbx + ror r14, 56 + xor rbx, r14 + ror rbx, 32 + mov r14, rbx + shr r14, 16 + xor r14, rbx + and r14, QWORD PTR [r9+400] + xor rbx, r14 + ror r14, 48 + xor rbx, r14 + and rcx, QWORD PTR [r9+384] + mov r14, rcx + ror r14, 56 + xor rcx, r14 + ror rcx, 32 + mov r14, rcx + shr r14, 16 + xor r14, rcx + and r14, QWORD PTR [r9+400] + xor rcx, r14 + ror r14, 48 + xor rcx, r14 + and rbp, QWORD PTR [r9+384] + mov r14, rbp + ror r14, 56 + xor rbp, r14 + ror rbp, 32 + mov r14, rbp + shr r14, 16 + xor r14, rbp + and r14, QWORD PTR [r9+400] + xor rbp, r14 + ror r14, 48 + xor rbp, r14 + and r10, QWORD PTR [r9+384] + mov r14, r10 + ror r14, 56 + xor r10, r14 + ror r10, 32 + mov r14, r10 + shr r14, 16 + xor r14, r10 + and r14, QWORD PTR [r9+400] + xor r10, r14 + ror r14, 48 + xor r10, r14 + and r11, QWORD PTR [r9+384] + mov r14, r11 + ror r14, 56 + xor r11, r14 + ror r11, 32 + mov r14, r11 + shr r14, 16 + xor r14, r11 + and r14, QWORD PTR [r9+400] + xor r11, r14 + ror r14, 48 + xor r11, r14 + and r12, QWORD PTR [r9+384] + mov r14, r12 + ror r14, 56 + xor r12, r14 + ror r12, 32 + mov r14, r12 + shr r14, 16 + xor r14, r12 + and r14, QWORD PTR [r9+400] + xor r12, r14 + ror r14, 48 + xor r12, r14 + and r13, QWORD PTR [r9+384] + mov r14, r13 + ror r14, 56 + xor r13, r14 + ror r13, 32 + mov r14, r13 + shr r14, 16 + xor r14, r13 + and r14, QWORD PTR [r9+400] + xor r13, r14 + ror r14, 48 + xor r13, r14 + mov QWORD PTR [rsi], rax + mov QWORD PTR [rsi+8], rbx + mov QWORD PTR [rsi+16], rcx + mov QWORD PTR [rsi+24], rbp + mov QWORD PTR [rsi+32], r10 + mov QWORD PTR [rsi+40], r11 + mov QWORD PTR [rsi+48], r12 + mov QWORD PTR [rsi+56], r13 + add rsi, 64 + mov rax, QWORD PTR [rdi] + movabs r14, 4294901760 + mov QWORD PTR [r9+8], r14 + movabs r14, 280375465148160 + mov QWORD PTR [r9+16], r14 + movabs r14, 71777214294589695 + mov QWORD PTR [r9+24], r14 + movabs r14, 6148914691236517205 + mov QWORD PTR [r9+32], r14 + movabs r14, 3689348814741910323 + mov QWORD PTR [r9+40], r14 + movabs r14, 1085102592571150095 + mov QWORD PTR [r9+48], r14 + mov r14, rax + shr r14, 16 + xor r14, rax + and r14, QWORD PTR [r9+8] + xor rax, r14 + ror r14, 48 + xor rax, r14 + mov r14, rax + shr r14, 8 + xor r14, rax + and r14, QWORD PTR [r9+16] + xor rax, r14 + ror r14, 56 + xor rax, r14 + mov rbx, rax + mov rcx, rax + mov rbp, rax + mov r10, rax + mov r11, rax + mov r12, rax + mov r13, rax + mov r14, rax + shr r14, 1 + xor r14, rbx + and r14, QWORD PTR [r9+32] + xor rbx, r14 + ror r14, 63 + xor rax, r14 + mov r14, rcx + shr r14, 1 + xor r14, rbp + and r14, QWORD PTR [r9+32] + xor rbp, r14 + ror r14, 63 + xor rcx, r14 + mov r14, r10 + shr r14, 1 + xor r14, r11 + and r14, QWORD PTR [r9+32] + xor r11, r14 + ror r14, 63 + xor r10, r14 + mov r14, r12 + shr r14, 1 + xor r14, r13 + and r14, QWORD PTR [r9+32] + xor r13, r14 + ror r14, 63 + xor r12, r14 + mov r14, rax + shr r14, 2 + xor r14, rcx + and r14, QWORD PTR [r9+40] + xor rcx, r14 + ror r14, 62 + xor rax, r14 + mov r14, rbx + shr r14, 2 + xor r14, rbp + and r14, QWORD PTR [r9+40] + xor rbp, r14 + ror r14, 62 + xor rbx, r14 + mov r14, r10 + shr r14, 2 + xor r14, r12 + and r14, QWORD PTR [r9+40] + xor r12, r14 + ror r14, 62 + xor r10, r14 + mov r14, r11 + shr r14, 2 + xor r14, r13 + and r14, QWORD PTR [r9+40] + xor r13, r14 + ror r14, 62 + xor r11, r14 + mov r14, rax + shr r14, 4 + xor r14, r10 + and r14, QWORD PTR [r9+48] + xor r10, r14 + ror r14, 60 + xor rax, r14 + mov r14, rbx + shr r14, 4 + xor r14, r11 + and r14, QWORD PTR [r9+48] + xor r11, r14 + ror r14, 60 + xor rbx, r14 + mov r14, rcx + shr r14, 4 + xor r14, r12 + and r14, QWORD PTR [r9+48] + xor r12, r14 + ror r14, 60 + xor rcx, r14 + mov r14, rbp + shr r14, 4 + xor r14, r13 + and r14, QWORD PTR [r9+48] + xor r13, r14 + ror r14, 60 + xor rbp, r14 + and rax, QWORD PTR [r9+392] + mov r14, rax + ror r14, 8 + xor rax, r14 + ror rax, 32 + mov r14, rax + shr r14, 16 + xor r14, rax + and r14, QWORD PTR [r9+400] + xor rax, r14 + ror r14, 48 + xor rax, r14 + and rbx, QWORD PTR [r9+392] + mov r14, rbx + ror r14, 8 + xor rbx, r14 + ror rbx, 32 + mov r14, rbx + shr r14, 16 + xor r14, rbx + and r14, QWORD PTR [r9+400] + xor rbx, r14 + ror r14, 48 + xor rbx, r14 + and rcx, QWORD PTR [r9+392] + mov r14, rcx + ror r14, 8 + xor rcx, r14 + ror rcx, 32 + mov r14, rcx + shr r14, 16 + xor r14, rcx + and r14, QWORD PTR [r9+400] + xor rcx, r14 + ror r14, 48 + xor rcx, r14 + and rbp, QWORD PTR [r9+392] + mov r14, rbp + ror r14, 8 + xor rbp, r14 + ror rbp, 32 + mov r14, rbp + shr r14, 16 + xor r14, rbp + and r14, QWORD PTR [r9+400] + xor rbp, r14 + ror r14, 48 + xor rbp, r14 + and r10, QWORD PTR [r9+392] + mov r14, r10 + ror r14, 8 + xor r10, r14 + ror r10, 32 + mov r14, r10 + shr r14, 16 + xor r14, r10 + and r14, QWORD PTR [r9+400] + xor r10, r14 + ror r14, 48 + xor r10, r14 + and r11, QWORD PTR [r9+392] + mov r14, r11 + ror r14, 8 + xor r11, r14 + ror r11, 32 + mov r14, r11 + shr r14, 16 + xor r14, r11 + and r14, QWORD PTR [r9+400] + xor r11, r14 + ror r14, 48 + xor r11, r14 + and r12, QWORD PTR [r9+392] + mov r14, r12 + ror r14, 8 + xor r12, r14 + ror r12, 32 + mov r14, r12 + shr r14, 16 + xor r14, r12 + and r14, QWORD PTR [r9+400] + xor r12, r14 + ror r14, 48 + xor r12, r14 + and r13, QWORD PTR [r9+392] + mov r14, r13 + ror r14, 8 + xor r13, r14 + ror r13, 32 + mov r14, r13 + shr r14, 16 + xor r14, r13 + and r14, QWORD PTR [r9+400] + xor r13, r14 + ror r14, 48 + xor r13, r14 + mov QWORD PTR [rsi], rax + mov QWORD PTR [rsi+8], rbx + mov QWORD PTR [rsi+16], rcx + mov QWORD PTR [rsi+24], rbp + mov QWORD PTR [rsi+32], r10 + mov QWORD PTR [rsi+40], r11 + mov QWORD PTR [rsi+48], r12 + mov QWORD PTR [rsi+56], r13 + add rsi, 64 + add rdi, 8 + sub r15, 1 + jne 20b + mov rdi, r9 + add rdi, 3072 + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9+768], rbp + mov rbp, QWORD PTR [rax+8] + mov QWORD PTR [r9+776], rbp + test r8, r8 + je 21f +23: + mov rdi, r9 + movabs rsi, 392 + call {vg_sm4_crypt_prepared} + cmp r8, 16 + jb 24f + mov rax, QWORD PTR [rdx] + xor rax, QWORD PTR [r9+768] + mov QWORD PTR [rdx], rax + mov rax, QWORD PTR [rdx+8] + xor rax, QWORD PTR [r9+776] + mov QWORD PTR [rdx+8], rax + add rdx, 16 + sub r8, 16 + jmp 25f +24: + mov rax, r9 + add rax, 768 +26: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [rdx] + xor rcx, r10 + mov BYTE PTR [rdx], cl + add rax, 1 + add rdx, 1 + sub r8, 1 + jne 26b +25: + jne 23b + jmp 22f +21: +22: + movq rax, xmm15 + mov rbp, QWORD PTR [r9+768] + mov QWORD PTR [rax], rbp + mov rbp, QWORD PTR [r9+776] + mov QWORD PTR [rax+8], rbp + mov rbx, QWORD PTR [r9+3136] + mov rbp, QWORD PTR [r9+3144] + mov r12, QWORD PTR [r9+3152] + mov r13, QWORD PTR [r9+3160] + mov r14, QWORD PTR [r9+3168] + mov r15, QWORD PTR [r9+3176] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + mov QWORD PTR [rsp+96], r11 + mov QWORD PTR [rsp+104], r11 + mov QWORD PTR [rsp+112], r11 + mov QWORD PTR [rsp+120], r11 + mov QWORD PTR [rsp+128], r11 + mov QWORD PTR [rsp+136], r11 + mov QWORD PTR [rsp+144], r11 + mov QWORD PTR [rsp+152], r11 + mov QWORD PTR [rsp+160], r11 + mov QWORD PTR [rsp+168], r11 + mov QWORD PTR [rsp+176], r11 + mov QWORD PTR [rsp+184], r11 + mov QWORD PTR [rsp+192], r11 + mov QWORD PTR [rsp+200], r11 + mov QWORD PTR [rsp+208], r11 + mov QWORD PTR [rsp+216], r11 + mov QWORD PTR [rsp+224], r11 + mov QWORD PTR [rsp+232], r11 + mov QWORD PTR [rsp+240], r11 + mov QWORD PTR [rsp+248], r11 + mov QWORD PTR [rsp+256], r11 + mov QWORD PTR [rsp+264], r11 + mov QWORD PTR [rsp+272], r11 + mov QWORD PTR [rsp+280], r11 + mov QWORD PTR [rsp+288], r11 + mov QWORD PTR [rsp+296], r11 + mov QWORD PTR [rsp+304], r11 + mov QWORD PTR [rsp+312], r11 + mov QWORD PTR [rsp+320], r11 + mov QWORD PTR [rsp+328], r11 + mov QWORD PTR [rsp+336], r11 + mov QWORD PTR [rsp+344], r11 + mov QWORD PTR [rsp+352], r11 + mov QWORD PTR [rsp+360], r11 + mov QWORD PTR [rsp+368], r11 + mov QWORD PTR [rsp+376], r11 + mov QWORD PTR [rsp+384], r11 + mov QWORD PTR [rsp+392], r11 + mov QWORD PTR [rsp+400], r11 + mov QWORD PTR [rsp+408], r11 + mov QWORD PTR [rsp+416], r11 + mov QWORD PTR [rsp+424], r11 + mov QWORD PTR [rsp+432], r11 + mov QWORD PTR [rsp+440], r11 + mov QWORD PTR [rsp+448], r11 + mov QWORD PTR [rsp+456], r11 + mov QWORD PTR [rsp+464], r11 + mov QWORD PTR [rsp+472], r11 + mov QWORD PTR [rsp+480], r11 + mov QWORD PTR [rsp+488], r11 + mov QWORD PTR [rsp+496], r11 + mov QWORD PTR [rsp+504], r11 + mov QWORD PTR [rsp+512], r11 + mov QWORD PTR [rsp+520], r11 + mov QWORD PTR [rsp+528], r11 + mov QWORD PTR [rsp+536], r11 + mov QWORD PTR [rsp+544], r11 + mov QWORD PTR [rsp+552], r11 + mov QWORD PTR [rsp+560], r11 + mov QWORD PTR [rsp+568], r11 + mov QWORD PTR [rsp+576], r11 + mov QWORD PTR [rsp+584], r11 + mov QWORD PTR [rsp+592], r11 + mov QWORD PTR [rsp+600], r11 + mov QWORD PTR [rsp+608], r11 + mov QWORD PTR [rsp+616], r11 + mov QWORD PTR [rsp+624], r11 + mov QWORD PTR [rsp+632], r11 + mov QWORD PTR [rsp+640], r11 + mov QWORD PTR [rsp+648], r11 + mov QWORD PTR [rsp+656], r11 + mov QWORD PTR [rsp+664], r11 + mov QWORD PTR [rsp+672], r11 + mov QWORD PTR [rsp+680], r11 + mov QWORD PTR [rsp+688], r11 + mov QWORD PTR [rsp+696], r11 + mov QWORD PTR [rsp+704], r11 + mov QWORD PTR [rsp+712], r11 + mov QWORD PTR [rsp+720], r11 + mov QWORD PTR [rsp+728], r11 + mov QWORD PTR [rsp+736], r11 + mov QWORD PTR [rsp+744], r11 + mov QWORD PTR [rsp+752], r11 + mov QWORD PTR [rsp+760], r11 + mov QWORD PTR [rsp+768], r11 + mov QWORD PTR [rsp+776], r11 + mov QWORD PTR [rsp+784], r11 + mov QWORD PTR [rsp+792], r11 + mov QWORD PTR [rsp+800], r11 + mov QWORD PTR [rsp+808], r11 + mov QWORD PTR [rsp+816], r11 + mov QWORD PTR [rsp+824], r11 + mov QWORD PTR [rsp+832], r11 + mov QWORD PTR [rsp+840], r11 + mov QWORD PTR [rsp+848], r11 + mov QWORD PTR [rsp+856], r11 + mov QWORD PTR [rsp+864], r11 + mov QWORD PTR [rsp+872], r11 + mov QWORD PTR [rsp+880], r11 + mov QWORD PTR [rsp+888], r11 + mov QWORD PTR [rsp+896], r11 + mov QWORD PTR [rsp+904], r11 + mov QWORD PTR [rsp+912], r11 + mov QWORD PTR [rsp+920], r11 + mov QWORD PTR [rsp+928], r11 + mov QWORD PTR [rsp+936], r11 + mov QWORD PTR [rsp+944], r11 + mov QWORD PTR [rsp+952], r11 + mov QWORD PTR [rsp+960], r11 + mov QWORD PTR [rsp+968], r11 + mov QWORD PTR [rsp+976], r11 + mov QWORD PTR [rsp+984], r11 + mov QWORD PTR [rsp+992], r11 + mov QWORD PTR [rsp+1000], r11 + mov QWORD PTR [rsp+1008], r11 + mov QWORD PTR [rsp+1016], r11 + mov QWORD PTR [rsp+1024], r11 + mov QWORD PTR [rsp+1032], r11 + mov QWORD PTR [rsp+1040], r11 + mov QWORD PTR [rsp+1048], r11 + mov QWORD PTR [rsp+1056], r11 + mov QWORD PTR [rsp+1064], r11 + mov QWORD PTR [rsp+1072], r11 + mov QWORD PTR [rsp+1080], r11 + mov QWORD PTR [rsp+1088], r11 + mov QWORD PTR [rsp+1096], r11 + mov QWORD PTR [rsp+1104], r11 + mov QWORD PTR [rsp+1112], r11 + mov QWORD PTR [rsp+1120], r11 + mov QWORD PTR [rsp+1128], r11 + mov QWORD PTR [rsp+1136], r11 + mov QWORD PTR [rsp+1144], r11 + mov QWORD PTR [rsp+1152], r11 + mov QWORD PTR [rsp+1160], r11 + mov QWORD PTR [rsp+1168], r11 + mov QWORD PTR [rsp+1176], r11 + mov QWORD PTR [rsp+1184], r11 + mov QWORD PTR [rsp+1192], r11 + mov QWORD PTR [rsp+1200], r11 + mov QWORD PTR [rsp+1208], r11 + mov QWORD PTR [rsp+1216], r11 + mov QWORD PTR [rsp+1224], r11 + mov QWORD PTR [rsp+1232], r11 + mov QWORD PTR [rsp+1240], r11 + mov QWORD PTR [rsp+1248], r11 + mov QWORD PTR [rsp+1256], r11 + mov QWORD PTR [rsp+1264], r11 + mov QWORD PTR [rsp+1272], r11 + mov QWORD PTR [rsp+1280], r11 + mov QWORD PTR [rsp+1288], r11 + mov QWORD PTR [rsp+1296], r11 + mov QWORD PTR [rsp+1304], r11 + mov QWORD PTR [rsp+1312], r11 + mov QWORD PTR [rsp+1320], r11 + mov QWORD PTR [rsp+1328], r11 + mov QWORD PTR [rsp+1336], r11 + mov QWORD PTR [rsp+1344], r11 + mov QWORD PTR [rsp+1352], r11 + mov QWORD PTR [rsp+1360], r11 + mov QWORD PTR [rsp+1368], r11 + mov QWORD PTR [rsp+1376], r11 + mov QWORD PTR [rsp+1384], r11 + mov QWORD PTR [rsp+1392], r11 + mov QWORD PTR [rsp+1400], r11 + mov QWORD PTR [rsp+1408], r11 + mov QWORD PTR [rsp+1416], r11 + mov QWORD PTR [rsp+1424], r11 + mov QWORD PTR [rsp+1432], r11 + mov QWORD PTR [rsp+1440], r11 + mov QWORD PTR [rsp+1448], r11 + mov QWORD PTR [rsp+1456], r11 + mov QWORD PTR [rsp+1464], r11 + mov QWORD PTR [rsp+1472], r11 + mov QWORD PTR [rsp+1480], r11 + mov QWORD PTR [rsp+1488], r11 + mov QWORD PTR [rsp+1496], r11 + mov QWORD PTR [rsp+1504], r11 + mov QWORD PTR [rsp+1512], r11 + mov QWORD PTR [rsp+1520], r11 + mov QWORD PTR [rsp+1528], r11 + mov QWORD PTR [rsp+1536], r11 + mov QWORD PTR [rsp+1544], r11 + mov QWORD PTR [rsp+1552], r11 + mov QWORD PTR [rsp+1560], r11 + mov QWORD PTR [rsp+1568], r11 + mov QWORD PTR [rsp+1576], r11 + mov QWORD PTR [rsp+1584], r11 + mov QWORD PTR [rsp+1592], r11 + mov QWORD PTR [rsp+1600], r11 + mov QWORD PTR [rsp+1608], r11 + mov QWORD PTR [rsp+1616], r11 + mov QWORD PTR [rsp+1624], r11 + mov QWORD PTR [rsp+1632], r11 + mov QWORD PTR [rsp+1640], r11 + mov QWORD PTR [rsp+1648], r11 + mov QWORD PTR [rsp+1656], r11 + mov QWORD PTR [rsp+1664], r11 + mov QWORD PTR [rsp+1672], r11 + mov QWORD PTR [rsp+1680], r11 + mov QWORD PTR [rsp+1688], r11 + mov QWORD PTR [rsp+1696], r11 + mov QWORD PTR [rsp+1704], r11 + mov QWORD PTR [rsp+1712], r11 + mov QWORD PTR [rsp+1720], r11 + mov QWORD PTR [rsp+1728], r11 + mov QWORD PTR [rsp+1736], r11 + mov QWORD PTR [rsp+1744], r11 + mov QWORD PTR [rsp+1752], r11 + mov QWORD PTR [rsp+1760], r11 + mov QWORD PTR [rsp+1768], r11 + mov QWORD PTR [rsp+1776], r11 + mov QWORD PTR [rsp+1784], r11 + mov QWORD PTR [rsp+1792], r11 + mov QWORD PTR [rsp+1800], r11 + mov QWORD PTR [rsp+1808], r11 + mov QWORD PTR [rsp+1816], r11 + mov QWORD PTR [rsp+1824], r11 + mov QWORD PTR [rsp+1832], r11 + mov QWORD PTR [rsp+1840], r11 + mov QWORD PTR [rsp+1848], r11 + mov QWORD PTR [rsp+1856], r11 + mov QWORD PTR [rsp+1864], r11 + mov QWORD PTR [rsp+1872], r11 + mov QWORD PTR [rsp+1880], r11 + mov QWORD PTR [rsp+1888], r11 + mov QWORD PTR [rsp+1896], r11 + mov QWORD PTR [rsp+1904], r11 + mov QWORD PTR [rsp+1912], r11 + mov QWORD PTR [rsp+1920], r11 + mov QWORD PTR [rsp+1928], r11 + mov QWORD PTR [rsp+1936], r11 + mov QWORD PTR [rsp+1944], r11 + mov QWORD PTR [rsp+1952], r11 + mov QWORD PTR [rsp+1960], r11 + mov QWORD PTR [rsp+1968], r11 + mov QWORD PTR [rsp+1976], r11 + mov QWORD PTR [rsp+1984], r11 + mov QWORD PTR [rsp+1992], r11 + mov QWORD PTR [rsp+2000], r11 + mov QWORD PTR [rsp+2008], r11 + mov QWORD PTR [rsp+2016], r11 + mov QWORD PTR [rsp+2024], r11 + mov QWORD PTR [rsp+2032], r11 + mov QWORD PTR [rsp+2040], r11 + mov QWORD PTR [rsp+2048], r11 + mov QWORD PTR [rsp+2056], r11 + mov QWORD PTR [rsp+2064], r11 + mov QWORD PTR [rsp+2072], r11 + mov QWORD PTR [rsp+2080], r11 + mov QWORD PTR [rsp+2088], r11 + mov QWORD PTR [rsp+2096], r11 + mov QWORD PTR [rsp+2104], r11 + mov QWORD PTR [rsp+2112], r11 + mov QWORD PTR [rsp+2120], r11 + mov QWORD PTR [rsp+2128], r11 + mov QWORD PTR [rsp+2136], r11 + mov QWORD PTR [rsp+2144], r11 + mov QWORD PTR [rsp+2152], r11 + mov QWORD PTR [rsp+2160], r11 + mov QWORD PTR [rsp+2168], r11 + mov QWORD PTR [rsp+2176], r11 + mov QWORD PTR [rsp+2184], r11 + mov QWORD PTR [rsp+2192], r11 + mov QWORD PTR [rsp+2200], r11 + mov QWORD PTR [rsp+2208], r11 + mov QWORD PTR [rsp+2216], r11 + mov QWORD PTR [rsp+2224], r11 + mov QWORD PTR [rsp+2232], r11 + mov QWORD PTR [rsp+2240], r11 + mov QWORD PTR [rsp+2248], r11 + mov QWORD PTR [rsp+2256], r11 + mov QWORD PTR [rsp+2264], r11 + mov QWORD PTR [rsp+2272], r11 + mov QWORD PTR [rsp+2280], r11 + mov QWORD PTR [rsp+2288], r11 + mov QWORD PTR [rsp+2296], r11 + mov QWORD PTR [rsp+2304], r11 + mov QWORD PTR [rsp+2312], r11 + mov QWORD PTR [rsp+2320], r11 + mov QWORD PTR [rsp+2328], r11 + mov QWORD PTR [rsp+2336], r11 + mov QWORD PTR [rsp+2344], r11 + mov QWORD PTR [rsp+2352], r11 + mov QWORD PTR [rsp+2360], r11 + mov QWORD PTR [rsp+2368], r11 + mov QWORD PTR [rsp+2376], r11 + mov QWORD PTR [rsp+2384], r11 + mov QWORD PTR [rsp+2392], r11 + mov QWORD PTR [rsp+2400], r11 + mov QWORD PTR [rsp+2408], r11 + mov QWORD PTR [rsp+2416], r11 + mov QWORD PTR [rsp+2424], r11 + mov QWORD PTR [rsp+2432], r11 + mov QWORD PTR [rsp+2440], r11 + mov QWORD PTR [rsp+2448], r11 + mov QWORD PTR [rsp+2456], r11 + mov QWORD PTR [rsp+2464], r11 + mov QWORD PTR [rsp+2472], r11 + mov QWORD PTR [rsp+2480], r11 + mov QWORD PTR [rsp+2488], r11 + mov QWORD PTR [rsp+2496], r11 + mov QWORD PTR [rsp+2504], r11 + mov QWORD PTR [rsp+2512], r11 + mov QWORD PTR [rsp+2520], r11 + mov QWORD PTR [rsp+2528], r11 + mov QWORD PTR [rsp+2536], r11 + mov QWORD PTR [rsp+2544], r11 + mov QWORD PTR [rsp+2552], r11 + mov QWORD PTR [rsp+2560], r11 + mov QWORD PTR [rsp+2568], r11 + mov QWORD PTR [rsp+2576], r11 + mov QWORD PTR [rsp+2584], r11 + mov QWORD PTR [rsp+2592], r11 + mov QWORD PTR [rsp+2600], r11 + mov QWORD PTR [rsp+2608], r11 + mov QWORD PTR [rsp+2616], r11 + mov QWORD PTR [rsp+2624], r11 + mov QWORD PTR [rsp+2632], r11 + mov QWORD PTR [rsp+2640], r11 + mov QWORD PTR [rsp+2648], r11 + mov QWORD PTR [rsp+2656], r11 + mov QWORD PTR [rsp+2664], r11 + mov QWORD PTR [rsp+2672], r11 + mov QWORD PTR [rsp+2680], r11 + mov QWORD PTR [rsp+2688], r11 + mov QWORD PTR [rsp+2696], r11 + mov QWORD PTR [rsp+2704], r11 + mov QWORD PTR [rsp+2712], r11 + mov QWORD PTR [rsp+2720], r11 + mov QWORD PTR [rsp+2728], r11 + mov QWORD PTR [rsp+2736], r11 + mov QWORD PTR [rsp+2744], r11 + mov QWORD PTR [rsp+2752], r11 + mov QWORD PTR [rsp+2760], r11 + mov QWORD PTR [rsp+2768], r11 + mov QWORD PTR [rsp+2776], r11 + mov QWORD PTR [rsp+2784], r11 + mov QWORD PTR [rsp+2792], r11 + mov QWORD PTR [rsp+2800], r11 + mov QWORD PTR [rsp+2808], r11 + mov QWORD PTR [rsp+2816], r11 + mov QWORD PTR [rsp+2824], r11 + mov QWORD PTR [rsp+2832], r11 + mov QWORD PTR [rsp+2840], r11 + mov QWORD PTR [rsp+2848], r11 + mov QWORD PTR [rsp+2856], r11 + mov QWORD PTR [rsp+2864], r11 + mov QWORD PTR [rsp+2872], r11 + mov QWORD PTR [rsp+2880], r11 + mov QWORD PTR [rsp+2888], r11 + mov QWORD PTR [rsp+2896], r11 + mov QWORD PTR [rsp+2904], r11 + mov QWORD PTR [rsp+2912], r11 + mov QWORD PTR [rsp+2920], r11 + mov QWORD PTR [rsp+2928], r11 + mov QWORD PTR [rsp+2936], r11 + mov QWORD PTR [rsp+2944], r11 + mov QWORD PTR [rsp+2952], r11 + mov QWORD PTR [rsp+2960], r11 + mov QWORD PTR [rsp+2968], r11 + mov QWORD PTR [rsp+2976], r11 + mov QWORD PTR [rsp+2984], r11 + mov QWORD PTR [rsp+2992], r11 + mov QWORD PTR [rsp+3000], r11 + mov QWORD PTR [rsp+3008], r11 + mov QWORD PTR [rsp+3016], r11 + mov QWORD PTR [rsp+3024], r11 + mov QWORD PTR [rsp+3032], r11 + mov QWORD PTR [rsp+3040], r11 + mov QWORD PTR [rsp+3048], r11 + mov QWORD PTR [rsp+3056], r11 + mov QWORD PTR [rsp+3064], r11 + mov QWORD PTR [rsp+3072], r11 + mov QWORD PTR [rsp+3080], r11 + mov QWORD PTR [rsp+3088], r11 + mov QWORD PTR [rsp+3096], r11 + mov QWORD PTR [rsp+3104], r11 + mov QWORD PTR [rsp+3112], r11 + mov QWORD PTR [rsp+3120], r11 + mov QWORD PTR [rsp+3128], r11 + mov QWORD PTR [rsp+3136], r11 + mov QWORD PTR [rsp+3144], r11 + mov QWORD PTR [rsp+3152], r11 + mov QWORD PTR [rsp+3160], r11 + mov QWORD PTR [rsp+3168], r11 + mov QWORD PTR [rsp+3176], r11 + mov QWORD PTR [rsp+3184], r11 + mov QWORD PTR [rsp+3192], r11 + mov QWORD PTR [rsp+3200], r11 + lea rsp, [rsp+3208] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/assembly/triple_des_ofb.s b/crates/verified-garbage-asm-x86_64/assembly/triple_des_ofb.s index 07939b7bee1..114946e13ad 100644 --- a/crates/verified-garbage-asm-x86_64/assembly/triple_des_ofb.s +++ b/crates/verified-garbage-asm-x86_64/assembly/triple_des_ofb.s @@ -270,3 +270,286 @@ vg_triple_des_ofb: lea rsp, [rsp+976] ret .p2align 6 + +vg_triple_des_ofb_final: + lea rsp, [rsp-976] + mov r8, rsp + add r8, 8 + mov r9, r8 + mov QWORD PTR [r9+904], rbx + mov QWORD PTR [r9+912], rbp + mov QWORD PTR [r9+920], r12 + mov QWORD PTR [r9+928], r13 + mov QWORD PTR [r9+936], r14 + mov QWORD PTR [r9+944], r15 + movq xmm15, rsi + mov r12, rdx + mov r13, rcx + mov rax, QWORD PTR [rdi] + mov QWORD PTR [r9+520], rax + mov rax, QWORD PTR [rdi+8] + mov QWORD PTR [r9+528], rax + mov rax, QWORD PTR [rdi+16] + mov QWORD PTR [r9+536], rax + mov rax, QWORD PTR [rdi+24] + mov QWORD PTR [r9+544], rax + mov rax, QWORD PTR [rdi+32] + mov QWORD PTR [r9+552], rax + mov rax, QWORD PTR [rdi+40] + mov QWORD PTR [r9+560], rax + mov rax, QWORD PTR [rdi+48] + mov QWORD PTR [r9+568], rax + mov rax, QWORD PTR [rdi+56] + mov QWORD PTR [r9+576], rax + mov rax, QWORD PTR [rdi+64] + mov QWORD PTR [r9+584], rax + mov rax, QWORD PTR [rdi+72] + mov QWORD PTR [r9+592], rax + mov rax, QWORD PTR [rdi+80] + mov QWORD PTR [r9+600], rax + mov rax, QWORD PTR [rdi+88] + mov QWORD PTR [r9+608], rax + mov rax, QWORD PTR [rdi+96] + mov QWORD PTR [r9+616], rax + mov rax, QWORD PTR [rdi+104] + mov QWORD PTR [r9+624], rax + mov rax, QWORD PTR [rdi+112] + mov QWORD PTR [r9+632], rax + mov rax, QWORD PTR [rdi+120] + mov QWORD PTR [r9+640], rax + mov rax, QWORD PTR [rdi+128] + mov QWORD PTR [r9+648], rax + mov rax, QWORD PTR [rdi+136] + mov QWORD PTR [r9+656], rax + mov rax, QWORD PTR [rdi+144] + mov QWORD PTR [r9+664], rax + mov rax, QWORD PTR [rdi+152] + mov QWORD PTR [r9+672], rax + mov rax, QWORD PTR [rdi+160] + mov QWORD PTR [r9+680], rax + mov rax, QWORD PTR [rdi+168] + mov QWORD PTR [r9+688], rax + mov rax, QWORD PTR [rdi+176] + mov QWORD PTR [r9+696], rax + mov rax, QWORD PTR [rdi+184] + mov QWORD PTR [r9+704], rax + mov rax, QWORD PTR [rdi+192] + mov QWORD PTR [r9+712], rax + mov rax, QWORD PTR [rdi+200] + mov QWORD PTR [r9+720], rax + mov rax, QWORD PTR [rdi+208] + mov QWORD PTR [r9+728], rax + mov rax, QWORD PTR [rdi+216] + mov QWORD PTR [r9+736], rax + mov rax, QWORD PTR [rdi+224] + mov QWORD PTR [r9+744], rax + mov rax, QWORD PTR [rdi+232] + mov QWORD PTR [r9+752], rax + mov rax, QWORD PTR [rdi+240] + mov QWORD PTR [r9+760], rax + mov rax, QWORD PTR [rdi+248] + mov QWORD PTR [r9+768], rax + mov rax, QWORD PTR [rdi+256] + mov QWORD PTR [r9+776], rax + mov rax, QWORD PTR [rdi+264] + mov QWORD PTR [r9+784], rax + mov rax, QWORD PTR [rdi+272] + mov QWORD PTR [r9+792], rax + mov rax, QWORD PTR [rdi+280] + mov QWORD PTR [r9+800], rax + mov rax, QWORD PTR [rdi+288] + mov QWORD PTR [r9+808], rax + mov rax, QWORD PTR [rdi+296] + mov QWORD PTR [r9+816], rax + mov rax, QWORD PTR [rdi+304] + mov QWORD PTR [r9+824], rax + mov rax, QWORD PTR [rdi+312] + mov QWORD PTR [r9+832], rax + mov rax, QWORD PTR [rdi+320] + mov QWORD PTR [r9+840], rax + mov rax, QWORD PTR [rdi+328] + mov QWORD PTR [r9+848], rax + mov rax, QWORD PTR [rdi+336] + mov QWORD PTR [r9+856], rax + mov rax, QWORD PTR [rdi+344] + mov QWORD PTR [r9+864], rax + mov rax, QWORD PTR [rdi+352] + mov QWORD PTR [r9+872], rax + mov rax, QWORD PTR [rdi+360] + mov QWORD PTR [r9+880], rax + mov rax, QWORD PTR [rdi+368] + mov QWORD PTR [r9+888], rax + mov rax, QWORD PTR [rdi+376] + mov QWORD PTR [r9+896], rax + movq rax, xmm15 + mov rbp, QWORD PTR [rax] + mov QWORD PTR [r9+512], rbp + test r13, r13 + je 20f +22: + mov rdi, r9 + add rdi, 520 + mov rsi, r9 + add rsi, 512 + mov rdx, r9 + call {vg_triple_des_encrypt_block} + mov r9, rdx + cmp r13, 8 + jb 23f + mov rax, QWORD PTR [r12] + xor rax, QWORD PTR [r9+512] + mov QWORD PTR [r12], rax + add r12, 8 + sub r13, 8 + jmp 24f +23: + mov rax, r9 + add rax, 512 +25: + movzx r10d, BYTE PTR [rax] + movzx ecx, BYTE PTR [r12] + xor rcx, r10 + mov BYTE PTR [r12], cl + add rax, 1 + add r12, 1 + sub r13, 1 + jne 25b +24: + jne 22b + jmp 21f +20: +21: + movq rax, xmm15 + mov rbp, QWORD PTR [r9+512] + mov QWORD PTR [rax], rbp + mov rbx, QWORD PTR [r9+904] + mov rbp, QWORD PTR [r9+912] + mov r12, QWORD PTR [r9+920] + mov r13, QWORD PTR [r9+928] + mov r14, QWORD PTR [r9+936] + mov r15, QWORD PTR [r9+944] + mov r11d, 0 + mov QWORD PTR [rsp+8], r11 + mov QWORD PTR [rsp+16], r11 + mov QWORD PTR [rsp+24], r11 + mov QWORD PTR [rsp+32], r11 + mov QWORD PTR [rsp+40], r11 + mov QWORD PTR [rsp+48], r11 + mov QWORD PTR [rsp+56], r11 + mov QWORD PTR [rsp+64], r11 + mov QWORD PTR [rsp+72], r11 + mov QWORD PTR [rsp+80], r11 + mov QWORD PTR [rsp+88], r11 + mov QWORD PTR [rsp+96], r11 + mov QWORD PTR [rsp+104], r11 + mov QWORD PTR [rsp+112], r11 + mov QWORD PTR [rsp+120], r11 + mov QWORD PTR [rsp+128], r11 + mov QWORD PTR [rsp+136], r11 + mov QWORD PTR [rsp+144], r11 + mov QWORD PTR [rsp+152], r11 + mov QWORD PTR [rsp+160], r11 + mov QWORD PTR [rsp+168], r11 + mov QWORD PTR [rsp+176], r11 + mov QWORD PTR [rsp+184], r11 + mov QWORD PTR [rsp+192], r11 + mov QWORD PTR [rsp+200], r11 + mov QWORD PTR [rsp+208], r11 + mov QWORD PTR [rsp+216], r11 + mov QWORD PTR [rsp+224], r11 + mov QWORD PTR [rsp+232], r11 + mov QWORD PTR [rsp+240], r11 + mov QWORD PTR [rsp+248], r11 + mov QWORD PTR [rsp+256], r11 + mov QWORD PTR [rsp+264], r11 + mov QWORD PTR [rsp+272], r11 + mov QWORD PTR [rsp+280], r11 + mov QWORD PTR [rsp+288], r11 + mov QWORD PTR [rsp+296], r11 + mov QWORD PTR [rsp+304], r11 + mov QWORD PTR [rsp+312], r11 + mov QWORD PTR [rsp+320], r11 + mov QWORD PTR [rsp+328], r11 + mov QWORD PTR [rsp+336], r11 + mov QWORD PTR [rsp+344], r11 + mov QWORD PTR [rsp+352], r11 + mov QWORD PTR [rsp+360], r11 + mov QWORD PTR [rsp+368], r11 + mov QWORD PTR [rsp+376], r11 + mov QWORD PTR [rsp+384], r11 + mov QWORD PTR [rsp+392], r11 + mov QWORD PTR [rsp+400], r11 + mov QWORD PTR [rsp+408], r11 + mov QWORD PTR [rsp+416], r11 + mov QWORD PTR [rsp+424], r11 + mov QWORD PTR [rsp+432], r11 + mov QWORD PTR [rsp+440], r11 + mov QWORD PTR [rsp+448], r11 + mov QWORD PTR [rsp+456], r11 + mov QWORD PTR [rsp+464], r11 + mov QWORD PTR [rsp+472], r11 + mov QWORD PTR [rsp+480], r11 + mov QWORD PTR [rsp+488], r11 + mov QWORD PTR [rsp+496], r11 + mov QWORD PTR [rsp+504], r11 + mov QWORD PTR [rsp+512], r11 + mov QWORD PTR [rsp+520], r11 + mov QWORD PTR [rsp+528], r11 + mov QWORD PTR [rsp+536], r11 + mov QWORD PTR [rsp+544], r11 + mov QWORD PTR [rsp+552], r11 + mov QWORD PTR [rsp+560], r11 + mov QWORD PTR [rsp+568], r11 + mov QWORD PTR [rsp+576], r11 + mov QWORD PTR [rsp+584], r11 + mov QWORD PTR [rsp+592], r11 + mov QWORD PTR [rsp+600], r11 + mov QWORD PTR [rsp+608], r11 + mov QWORD PTR [rsp+616], r11 + mov QWORD PTR [rsp+624], r11 + mov QWORD PTR [rsp+632], r11 + mov QWORD PTR [rsp+640], r11 + mov QWORD PTR [rsp+648], r11 + mov QWORD PTR [rsp+656], r11 + mov QWORD PTR [rsp+664], r11 + mov QWORD PTR [rsp+672], r11 + mov QWORD PTR [rsp+680], r11 + mov QWORD PTR [rsp+688], r11 + mov QWORD PTR [rsp+696], r11 + mov QWORD PTR [rsp+704], r11 + mov QWORD PTR [rsp+712], r11 + mov QWORD PTR [rsp+720], r11 + mov QWORD PTR [rsp+728], r11 + mov QWORD PTR [rsp+736], r11 + mov QWORD PTR [rsp+744], r11 + mov QWORD PTR [rsp+752], r11 + mov QWORD PTR [rsp+760], r11 + mov QWORD PTR [rsp+768], r11 + mov QWORD PTR [rsp+776], r11 + mov QWORD PTR [rsp+784], r11 + mov QWORD PTR [rsp+792], r11 + mov QWORD PTR [rsp+800], r11 + mov QWORD PTR [rsp+808], r11 + mov QWORD PTR [rsp+816], r11 + mov QWORD PTR [rsp+824], r11 + mov QWORD PTR [rsp+832], r11 + mov QWORD PTR [rsp+840], r11 + mov QWORD PTR [rsp+848], r11 + mov QWORD PTR [rsp+856], r11 + mov QWORD PTR [rsp+864], r11 + mov QWORD PTR [rsp+872], r11 + mov QWORD PTR [rsp+880], r11 + mov QWORD PTR [rsp+888], r11 + mov QWORD PTR [rsp+896], r11 + mov QWORD PTR [rsp+904], r11 + mov QWORD PTR [rsp+912], r11 + mov QWORD PTR [rsp+920], r11 + mov QWORD PTR [rsp+928], r11 + mov QWORD PTR [rsp+936], r11 + mov QWORD PTR [rsp+944], r11 + mov QWORD PTR [rsp+952], r11 + mov QWORD PTR [rsp+960], r11 + mov QWORD PTR [rsp+968], r11 + lea rsp, [rsp+976] + ret + .p2align 6 diff --git a/crates/verified-garbage-asm-x86_64/src/aes_ctr.rs b/crates/verified-garbage-asm-x86_64/src/aes_ctr.rs index ff6969749d0..b34a1fa83ab 100644 --- a/crates/verified-garbage-asm-x86_64/src/aes_ctr.rs +++ b/crates/verified-garbage-asm-x86_64/src/aes_ctr.rs @@ -46,6 +46,46 @@ jmp 21f ) } +/// The CPU features `vg_aes_ctr_final_aesni` requires (`Artifact.features`). +pub const VG_AES_CTR_FINAL_AESNI_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES | verified_garbage_cpu::feature::SSSE3); + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 96 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes` and `ssse3` target features. +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_aes_ctr_final_aesni(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "SI1kJLBIieBIg8AQSIlEJAhIi0QkCEiJGEiJaAhMiWAQTIloGEyJcCBMiXgoSIn7SIn1SYnUTYnPTYnGSYPmD02JxU0p9UkBzUnB6AQ=" +call {vg_aes_ctr_aesni} +.base64 "TYX2" +je 20f +.base64 "SItEJAhBugAAAABMiVAwTIlQOEiJ30iJ7kyJ4kiJwUiDwTBBuAEAAABNifk=" +call {vg_aes_ctr_aesni} +.base64 "SItEJAhIg8Aw" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "SItEJAhIixhIi2gITItgEEyLaBhMi3AgTIt4KEG7AAAAAEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhIjWQkUMM=" +.p2align 6"#, + vg_aes_ctr_aesni = sym super::aes_ctr::vg_aes_ctr_aesni, + ) +} + /// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of whole blocks, in place: XORs the `n` 16-byte blocks at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `n = 0`), so that a further call continues the message. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. /// /// Contract: `VG.Spec.Ctr.aesContract`. Constant time: only the pointers, `rounds`, `n` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. @@ -85,6 +125,42 @@ jmp 21f ) } +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 96 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_aes_ctr_final(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "SI1kJLBIieBIg8AQSIlEJAhIi0QkCEiJGEiJaAhMiWAQTIloGEyJcCBMiXgoSIn7SIn1SYnUTYnPTYnGSYPmD02JxU0p9UkBzUnB6AQ=" +call {vg_aes_ctr} +.base64 "TYX2" +je 20f +.base64 "SItEJAhBugAAAABMiVAwTIlQOEiJ30iJ7kyJ4kiJwUiDwTBBuAEAAABNifk=" +call {vg_aes_ctr} +.base64 "SItEJAhIg8Aw" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "SItEJAhIixhIi2gITItgEEyLaBhMi3AgTIt4KEG7AAAAAEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhIjWQkUMM=" +.p2align 6"#, + vg_aes_ctr = sym super::aes_ctr::vg_aes_ctr, + ) +} + /// The CPU features `vg_aes_ctr_vaes` requires (`Artifact.features`). pub const VG_AES_CTR_VAES_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES | verified_garbage_cpu::feature::AVX | verified_garbage_cpu::feature::AVX2 | verified_garbage_cpu::feature::SSSE3 | verified_garbage_cpu::feature::VAES); @@ -127,3 +203,43 @@ jmp 21f vg_aes_ctr32_vaes = sym super::aes::vg_aes_ctr32_vaes::vg_aes_ctr32_vaes, ) } + +/// The CPU features `vg_aes_ctr_final_vaes` requires (`Artifact.features`). +pub const VG_AES_CTR_FINAL_VAES_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES | verified_garbage_cpu::feature::AVX | verified_garbage_cpu::feature::AVX2 | verified_garbage_cpu::feature::SSSE3 | verified_garbage_cpu::feature::VAES); + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 96 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes`, `avx`, `avx2`, `ssse3` and `vaes` target features. +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_aes_ctr_final_vaes(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "SI1kJLBIieBIg8AQSIlEJAhIi0QkCEiJGEiJaAhMiWAQTIloGEyJcCBMiXgoSIn7SIn1SYnUTYnPTYnGSYPmD02JxU0p9UkBzUnB6AQ=" +call {vg_aes_ctr_vaes} +.base64 "TYX2" +je 20f +.base64 "SItEJAhBugAAAABMiVAwTIlQOEiJ30iJ7kyJ4kiJwUiDwTBBuAEAAABNifk=" +call {vg_aes_ctr_vaes} +.base64 "SItEJAhIg8Aw" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "SItEJAhIixhIi2gITItgEEyLaBhMi3AgTIt4KEG7AAAAAEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhIjWQkUMM=" +.p2align 6"#, + vg_aes_ctr_vaes = sym super::aes_ctr::vg_aes_ctr_vaes, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/aes_ofb.rs b/crates/verified-garbage-asm-x86_64/src/aes_ofb.rs index 4a2321213d1..197a32877d0 100644 --- a/crates/verified-garbage-asm-x86_64/src/aes_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/aes_ofb.rs @@ -40,6 +40,47 @@ jmp 21f ) } +/// The CPU features `vg_aes_ofb_final_aesni` requires (`Artifact.features`). +pub const VG_AES_OFB_FINAL_AESNI_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES); + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 80 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes` target feature. +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_aes_ofb_final_aesni(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "SI1kJMBIieBIg8AQSIlEJAhIi0QkCEiJGEiJaAhMiWAQTIloGEyJcCBMiXgoSIn7SIn1SYnUTYnPTYnGSYPmD02JxU0p9UkBzUnB6AQ=" +call {vg_aes_ofb_aesni} +.base64 "TYX2" +je 20f +.base64 "SInfSInuTIniuQEAAABNifg=" +call {vg_aes_encrypt_blocks_aesni} +.base64 "TIng" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "SItEJAhIixhIi2gITItgEEyLaBhMi3AgTIt4KEG7AAAAAEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEiNZCRAww==" +.p2align 6"#, + vg_aes_ofb_aesni = sym super::aes_ofb::vg_aes_ofb_aesni, + vg_aes_encrypt_blocks_aesni = sym super::aes::vg_aes_encrypt_blocks_aesni, + ) +} + /// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of whole blocks, in place: XORs the `n` 16-byte blocks at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, and replaces `*iv` with `Oₙ` (leaving it unchanged if `n = 0`), so that a further call continues the message. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. /// /// Contract: `VG.Spec.Ofb.aesContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data. @@ -73,6 +114,43 @@ jmp 21f ) } +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 80 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_aes_ofb_final(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "SI1kJMBIieBIg8AQSIlEJAhIi0QkCEiJGEiJaAhMiWAQTIloGEyJcCBMiXgoSIn7SIn1SYnUTYnPTYnGSYPmD02JxU0p9UkBzUnB6AQ=" +call {vg_aes_ofb} +.base64 "TYX2" +je 20f +.base64 "SInfSInuTIniuQEAAABNifg=" +call {vg_aes_encrypt_blocks} +.base64 "TIng" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "SItEJAhIixhIi2gITItgEEyLaBhMi3AgTIt4KEG7AAAAAEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEiNZCRAww==" +.p2align 6"#, + vg_aes_ofb = sym super::aes_ofb::vg_aes_ofb, + vg_aes_encrypt_blocks = sym super::aes::vg_aes_encrypt_blocks, + ) +} + /// The CPU features `vg_aes_ofb_vaes` requires (`Artifact.features`). pub const VG_AES_OFB_VAES_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES | verified_garbage_cpu::feature::AVX | verified_garbage_cpu::feature::AVX2 | verified_garbage_cpu::feature::VAES); @@ -109,3 +187,44 @@ jmp 21f vg_aes_encrypt_blocks_vaes = sym super::aes::vg_aes_encrypt_blocks_vaes, ) } + +/// The CPU features `vg_aes_ofb_final_vaes` requires (`Artifact.features`). +pub const VG_AES_OFB_FINAL_VAES_FEATURES: verified_garbage_cpu::Features = verified_garbage_cpu::Features(verified_garbage_cpu::feature::AES | verified_garbage_cpu::feature::AVX | verified_garbage_cpu::feature::AVX2 | verified_garbage_cpu::feature::VAES); + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 80 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +/// * The CPU must support the `aes`, `avx`, `avx2` and `vaes` target features. +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_aes_ofb_final_vaes(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + core::arch::naked_asm!( + r#".base64 "SI1kJMBIieBIg8AQSIlEJAhIi0QkCEiJGEiJaAhMiWAQTIloGEyJcCBMiXgoSIn7SIn1SYnUTYnPTYnGSYPmD02JxU0p9UkBzUnB6AQ=" +call {vg_aes_ofb_vaes} +.base64 "TYX2" +je 20f +.base64 "SInfSInuTIniuQEAAABNifg=" +call {vg_aes_encrypt_blocks_vaes} +.base64 "TIng" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "SItEJAhIixhIi2gITItgEEyLaBhMi3AgTIt4KEG7AAAAAEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEiNZCRAww==" +.p2align 6"#, + vg_aes_ofb_vaes = sym super::aes_ofb::vg_aes_ofb_vaes, + vg_aes_encrypt_blocks_vaes = sym super::aes::vg_aes_encrypt_blocks_vaes, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/blowfish_ofb.rs b/crates/verified-garbage-asm-x86_64/src/blowfish_ofb.rs index c4db86dbdae..442a12542b3 100644 --- a/crates/verified-garbage-asm-x86_64/src/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/blowfish_ofb.rs @@ -49,3 +49,59 @@ jmp 21f .p2align 6"#, ) } + +/// Blowfish-OFB encryption or decryption (NIST SP 800-38A §6.4, Schneier, FSE 1994) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Blowfish encryption under the schedule written by `vg_blowfish_expand_key`. +/// +/// Contract: `VG.Spec.Blowfish.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 4168 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 96 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_blowfish_ofb_final(schedule: *const [u8; 4168], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI1kJKBJieBJg8AITYnBSYlZGEmJaSBNiWEoTYlpME2JcThNiXlAZkwPbv5JidRJic1mTA9++EiLKEmJKU2F7Q==" +je 20f +22: +.base64 "Zk0Pfv5MicpMic5MiclIg8EISbsBAAEAAQABAGZND27rSbsBAAEAAQABAGZND27jZkUPbOxJuxAAEAAQABAAZk0PbvNJuxAAEAAQABAAZk0PbuNmRQ9s9Em7/wD/AP8A/wBmTQ9u+0m7/wD/AP8A/wBmTQ9u42ZFD2z8RIseQQ/LZkkPbsNEi14EQQ/LZkkPbsu4AAAAAEG6EAAAAA==" +23: +.base64 "RIucBwAQAABmTQ9u42ZBD+/EZg9v2GYPcvMAZg9y0xhmD2HbZg9w2wBJuwAAAgAEAAYAZkkPbuNJuwgACgAMAA4AZk0PbuNmQQ9s5GZFD+/AZkUP78lmRQ/v0mZFD+/bQbgAAAAAQbkQAAAA" +24: +.base64 "Zg9v9GYP7/NmQQ/59WYPceYPZg9v/GZBD/39Zg/v+2ZBD/n9Zg9x5w9mQQ/b92YPcfcIZg/r9/NGD28kB2ZED9vmZkUP68TzRg9vpAcAAQAAZkQP2+ZmRQ/rzPNGD2+kBwACAABmRA/b5mZFD+vU80YPb6QHAAMAAGZED9vmZkUP69xmQQ/95kmDwBBJg+kB" +jne 24b +.base64 "ZkUPcOBOZkUP68RmRQ9w4LFmRQ/rxGZFD2/gZkEPctQQZkUP68RmRQ9v4GZBD3LUCGZFD+vEZkEPcvAYZkEPctAYZkUPcOFOZkUP68xmRQ9w4bFmRQ/rzGZFD2/hZkEPctQQZkUP68xmRQ9v4WZBD3LUCGZFD+vMZkEPcvEYZkEPctEYZkUPcOJOZkUP69RmRQ9w4rFmRQ/r1GZFD2/iZkEPctQQZkUP69RmRQ9v4mZBD3LUCGZFD+vUZkEPcvIYZkEPctIYZkUPcONOZkUP69xmRQ9w47FmRQ/r3GZFD2/jZkEPctQQZkUP69xmRQ9v42ZBD3LUCGZFD+vcZkEPcvMYZkEPctMYZkEPcvEIZkEPcvIQZkEPcvMYZkUP68FmRQ/rwmZFD+vDZkEPb9BmD2/YZg9y8whmD3LTGGYPYdtmD3DbAEm7AAACAAQABgBmSQ9u40m7CAAKAAwADgBmTQ9u42ZBD2zkZkUP78BmRQ/vyWZFD+/SZkUP79tBuAAAAABBuRAAAAA=" +25: +.base64 "Zg9v9GYP7/NmQQ/59WYPceYPZg9v/GZBD/39Zg/v+2ZBD/n9Zg9x5w9mQQ/b92YPcfcIZg/r9/NGD2+kBwAEAABmRA/b5mZFD+vE80YPb6QHAAUAAGZED9vmZkUP68zzRg9vpAcABgAAZkQP2+ZmRQ/r1PNGD2+kBwAHAABmRA/b5mZFD+vcZkEP/eZJg8AQSYPpAQ==" +jne 25b +.base64 "ZkUPcOBOZkUP68RmRQ9w4LFmRQ/rxGZFD2/gZkEPctQQZkUP68RmRQ9v4GZBD3LUCGZFD+vEZkEPcvAYZkEPctAYZkUPcOFOZkUP68xmRQ9w4bFmRQ/rzGZFD2/hZkEPctQQZkUP68xmRQ9v4WZBD3LUCGZFD+vMZkEPcvEYZkEPctEYZkUPcOJOZkUP69RmRQ9w4rFmRQ/r1GZFD2/iZkEPctQQZkUP69RmRQ9v4mZBD3LUCGZFD+vUZkEPcvIYZkEPctIYZkUPcONOZkUP69xmRQ9w47FmRQ/r3GZFD2/jZkEPctQQZkUP69xmRQ9v42ZBD3LUCGZFD+vcZkEPcvMYZkEPctMYZkEPcvEIZkEPcvIQZkEPcvMYZkUP68FmRQ/rwmZFD+vDZkEP/tBmD2/YZg9y8xBmD3LTGGYPYdtmD3DbAEm7AAACAAQABgBmSQ9u40m7CAAKAAwADgBmTQ9u42ZBD2zkZkUP78BmRQ/vyWZFD+/SZkUP79tBuAAAAABBuRAAAAA=" +26: +.base64 "Zg9v9GYP7/NmQQ/59WYPceYPZg9v/GZBD/39Zg/v+2ZBD/n9Zg9x5w9mQQ/b92YPcfcIZg/r9/NGD2+kBwAIAABmRA/b5mZFD+vE80YPb6QHAAkAAGZED9vmZkUP68zzRg9vpAcACgAAZkQP2+ZmRQ/r1PNGD2+kBwALAABmRA/b5mZFD+vcZkEP/eZJg8AQSYPpAQ==" +jne 26b +.base64 "ZkUPcOBOZkUP68RmRQ9w4LFmRQ/rxGZFD2/gZkEPctQQZkUP68RmRQ9v4GZBD3LUCGZFD+vEZkEPcvAYZkEPctAYZkUPcOFOZkUP68xmRQ9w4bFmRQ/rzGZFD2/hZkEPctQQZkUP68xmRQ9v4WZBD3LUCGZFD+vMZkEPcvEYZkEPctEYZkUPcOJOZkUP69RmRQ9w4rFmRQ/r1GZFD2/iZkEPctQQZkUP69RmRQ9v4mZBD3LUCGZFD+vUZkEPcvIYZkEPctIYZkUPcONOZkUP69xmRQ9w47FmRQ/r3GZFD2/jZkEPctQQZkUP69xmRQ9v42ZBD3LUCGZFD+vcZkEPcvMYZkEPctMYZkEPcvEIZkEPcvIQZkEPcvMYZkUP68FmRQ/rwmZFD+vDZkEP79BmD2/YZg9y8xhmD3LTGGYPYdtmD3DbAEm7AAACAAQABgBmSQ9u40m7CAAKAAwADgBmTQ9u42ZBD2zkZkUP78BmRQ/vyWZFD+/SZkUP79tBuAAAAABBuRAAAAA=" +27: +.base64 "Zg9v9GYP7/NmQQ/59WYPceYPZg9v/GZBD/39Zg/v+2ZBD/n9Zg9x5w9mQQ/b92YPcfcIZg/r9/NGD2+kBwAMAABmRA/b5mZFD+vE80YPb6QHAA0AAGZED9vmZkUP68zzRg9vpAcADgAAZkQP2+ZmRQ/r1PNGD2+kBwAPAABmRA/b5mZFD+vcZkEP/eZJg8AQSYPpAQ==" +jne 27b +.base64 "ZkUPcOBOZkUP68RmRQ9w4LFmRQ/rxGZFD2/gZkEPctQQZkUP68RmRQ9v4GZBD3LUCGZFD+vEZkEPcvAYZkEPctAYZkUPcOFOZkUP68xmRQ9w4bFmRQ/rzGZFD2/hZkEPctQQZkUP68xmRQ9v4WZBD3LUCGZFD+vMZkEPcvEYZkEPctEYZkUPcOJOZkUP69RmRQ9w4rFmRQ/r1GZFD2/iZkEPctQQZkUP69RmRQ9v4mZBD3LUCGZFD+vUZkEPcvIYZkEPctIYZkUPcONOZkUP69xmRQ9w47FmRQ/r3GZFD2/jZkEPctQQZkUP69xmRQ9v42ZBD3LUCGZFD+vcZkEPcvMYZkEPctMYZkEPcvEIZkEPcvIQZkEPcvMYZkUP68FmRQ/rwmZFD+vDZkEP/tBmD+/KZkQPb+BmD2/BZkEPb8xIg8AESYPqAQ==" +jne 23b +.base64 "RIufQBAAAGZND27jZkEP78REi59EEAAAZk0PbuNmQQ/vzPMPfwlEixlBD8tEiR7zD38BRIsZQQ/LRIleBEmJ0WZND27+SYP9CA==" +jb 28f +.base64 "SYsEJEkzAUmJBCRJg8QISYPtCA==" +jmp 29f +28: +.base64 "TInISIPAAA==" +210: +.base64 "RA+2EEEPtgwkTDHRQYgMJEiDwAFJg8QBSYPtAQ==" +jne 210b +29: +jne 22b +jmp 21f +20: +21: +.base64 "ZkwPfvhJiylIiShJi1kYSYtpIE2LYShNi2kwTYtxOE2LeUBBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhMiVwkUEyJXCRYSI1kJGDD" +.p2align 6"#, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/camellia_ctr.rs b/crates/verified-garbage-asm-x86_64/src/camellia_ctr.rs index b04792c4f50..4f43164536d 100644 --- a/crates/verified-garbage-asm-x86_64/src/camellia_ctr.rs +++ b/crates/verified-garbage-asm-x86_64/src/camellia_ctr.rs @@ -58,3 +58,37 @@ jmp 25f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-CTR encryption or decryption (NIST SP 800-38A §6.5, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ctrFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the return address on the stack or the 3368 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_camellia_ctr_final(schedule: *const [u8; 272], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI1kJLhJieFJg8EITInISIkYSIloCEyJYBBMiWgYTIlwIEyJeChIiftIifVJidRJicdNicZJg+YPTYnFTSn1SQHNScHoBA==" +call {vg_camellia_ctr} +.base64 "TYX2" +je 20f +.base64 "TIn4QboAAAAATIlQMEyJUDhIid9Iie5MieJIicFIg8EwQbgBAAAA" +call {vg_camellia_ctr} +.base64 "TIn4SIPAMA==" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "TIn4SIsYSItoCEyLYBBMi2gYTItwIEyLeChBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRASI1kJEjD" +.p2align 6"#, + vg_camellia_ctr = sym super::camellia_ctr::vg_camellia_ctr, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/camellia_ofb.rs b/crates/verified-garbage-asm-x86_64/src/camellia_ofb.rs index a3f37f430ed..3bab8af7270 100644 --- a/crates/verified-garbage-asm-x86_64/src/camellia_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/camellia_ofb.rs @@ -48,3 +48,58 @@ jmp 25f vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, ) } + +/// Camellia-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 3713 §2.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Camellia encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_camellia_expand_key` writes them. +/// +/// Contract: `VG.Spec.Camellia.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 272 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 18 (for a key of 16 bytes) or 24 (for one of 24 or 32). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 3288 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_camellia_ofb_final(schedule: *const [u8; 272], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI2kJDDz//9JieFJg8EITYnJSYmZiAwAAEmJqZAMAABNiaGYDAAATYmpoAwAAE2JsagMAABNibmwDAAAZkwPbvpIicpNicBJvv8A/wD/AP8ATYmxgAEAAEm+AP8A/wD/AP9NibGIAQAASb4AAAAAAP//AE2JsZABAABJvgD//wAAAAAATYmxmAEAAEm+AAAA//8AAABNibGgAQAASIP+Eg==" +je 20f +.base64 "TInOSIHGAAMAAEm/IgAAAAAAAAA=" +22: +.base64 "SIsHSInDSInBSInFSYnCSYnDSYnESYnFSb4AAP//AAAAAE2JcQhJvgD/AAAA/wAATYlxEEm+VVVVVVVVVVVNiXEgSb4zMzMzMzMzM02JcShJvg8PDw8PDw8PTYlxMEmJxknB7hBJMcZNI3EITDHwScHOMEwx8EmJ3knB7hBJMd5NI3EITDHzScHOMEwx80mJzknB7hBJMc5NI3EITDHxScHOMEwx8UmJ7knB7hBJMe5NI3EITDH1ScHOMEwx9U2J1knB7hBNMdZNI3EITTHyScHOME0x8k2J3knB7hBNMd5NI3EITTHzScHOME0x802J5knB7hBNMeZNI3EITTH0ScHOME0x9E2J7knB7hBNMe5NI3EITTH1ScHOME0x9UmJxknB7ghJMcZNI3EQTDHwScHOOEwx8EmJ3knB7ghJMd5NI3EQTDHzScHOOEwx80mJzknB7ghJMc5NI3EQTDHxScHOOEwx8UmJ7knB7ghJMe5NI3EQTDH1ScHOOEwx9U2J1knB7ghNMdZNI3EQTTHyScHOOE0x8k2J3knB7ghNMd5NI3EQTTHzScHOOE0x802J5knB7ghNMeZNI3EQTTH0ScHOOE0x9E2J7knB7ghNMe5NI3EQTTH1ScHOOE0x9UmJxknR7kkx3k0jcSBMMfNJwc4/TDHwSYnOSdHuSTHuTSNxIEwx9UnBzj9MMfFNidZJ0e5NMd5NI3EgTTHzScHOP00x8k2J5knR7k0x7k0jcSBNMfVJwc4/TTH0SYnGScHuAkkxzk0jcShMMfFJwc4+TDHwSYneScHuAkkx7k0jcShMMfVJwc4+TDHzTYnWScHuAk0x5k0jcShNMfRJwc4+TTHyTYneScHuAk0x7k0jcShNMfVJwc4+TTHzSYnGScHuBE0x1k0jcTBNMfJJwc48TDHwSYneScHuBE0x3k0jcTBNMfNJwc48TDHzSYnOScHuBE0x5k0jcTBNMfRJwc48TDHxSYnuScHuBE0x7k0jcTBNMfVJwc48TDH1SIkGSIleCEiJThBIiW4YTIlWIEyJXihMiWYwTIluOEiDxkBIg8cISYPvAQ==" +jne 22b +.base64 "TInPSIHHAAsAAEi/GAAAAAAAAAA=" +jmp 21f +20: +.base64 "TInOSIHGAAMAAEm/GgAAAAAAAAA=" +23: +.base64 "SIsHSInDSInBSInFSYnCSYnDSYnESYnFSb4AAP//AAAAAE2JcQhJvgD/AAAA/wAATYlxEEm+VVVVVVVVVVVNiXEgSb4zMzMzMzMzM02JcShJvg8PDw8PDw8PTYlxMEmJxknB7hBJMcZNI3EITDHwScHOMEwx8EmJ3knB7hBJMd5NI3EITDHzScHOMEwx80mJzknB7hBJMc5NI3EITDHxScHOMEwx8UmJ7knB7hBJMe5NI3EITDH1ScHOMEwx9U2J1knB7hBNMdZNI3EITTHyScHOME0x8k2J3knB7hBNMd5NI3EITTHzScHOME0x802J5knB7hBNMeZNI3EITTH0ScHOME0x9E2J7knB7hBNMe5NI3EITTH1ScHOME0x9UmJxknB7ghJMcZNI3EQTDHwScHOOEwx8EmJ3knB7ghJMd5NI3EQTDHzScHOOEwx80mJzknB7ghJMc5NI3EQTDHxScHOOEwx8UmJ7knB7ghJMe5NI3EQTDH1ScHOOEwx9U2J1knB7ghNMdZNI3EQTTHyScHOOE0x8k2J3knB7ghNMd5NI3EQTTHzScHOOE0x802J5knB7ghNMeZNI3EQTTH0ScHOOE0x9E2J7knB7ghNMe5NI3EQTTH1ScHOOE0x9UmJxknR7kkx3k0jcSBMMfNJwc4/TDHwSYnOSdHuSTHuTSNxIEwx9UnBzj9MMfFNidZJ0e5NMd5NI3EgTTHzScHOP00x8k2J5knR7k0x7k0jcSBNMfVJwc4/TTH0SYnGScHuAkkxzk0jcShMMfFJwc4+TDHwSYneScHuAkkx7k0jcShMMfVJwc4+TDHzTYnWScHuAk0x5k0jcShNMfRJwc4+TTHyTYneScHuAk0x7k0jcShNMfVJwc4+TTHzSYnGScHuBE0x1k0jcTBNMfJJwc48TDHwSYneScHuBE0x3k0jcTBNMfNJwc48TDHzSYnOScHuBE0x5k0jcTBNMfRJwc48TDHxSYnuScHuBE0x7k0jcTBNMfVJwc48TDH1SIkGSIleCEiJThBIiW4YTIlWIEyJXihMiWYwTIluOEiDxkBIg8cISYPvAQ==" +jne 23b +.base64 "TInPSIHHAAkAAEi/EgAAAAAAAAA=" +21: +.base64 "ZkwPfvhIiyhJianICwAASItoCEmJqdALAABNhcA=" +je 24f +26: +.base64 "SYnUTYnFSYn+TInOSLqRAQAAAAAAAA==" +call {vg_camellia_crypt_prepared} +.base64 "TIniTYnoTIn3SYP4EA==" +jb 27f +.base64 "SIsCSTOByAsAAEiJAkiLQghJM4HQCwAASIlCCEiDwhBJg+gQ" +jmp 28f +27: +.base64 "TInISAXICwAA" +29: +.base64 "RA+2EA+2Ckwx0YgKSIPAAUiDwgFJg+gB" +jne 29b +28: +jne 26b +jmp 25f +24: +25: +.base64 "ZkwPfvhJi6nICwAASIkoSYup0AsAAEiJaAhJi5mIDAAASYupkAwAAE2LoZgMAABNi6mgDAAATYuxqAwAAE2LubAMAABBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhMiVwkUEyJXCRYTIlcJGBMiVwkaEyJXCRwTIlcJHhMiZwkgAAAAEyJnCSIAAAATImcJJAAAABMiZwkmAAAAEyJnCSgAAAATImcJKgAAABMiZwksAAAAEyJnCS4AAAATImcJMAAAABMiZwkyAAAAEyJnCTQAAAATImcJNgAAABMiZwk4AAAAEyJnCToAAAATImcJPAAAABMiZwk+AAAAEyJnCQAAQAATImcJAgBAABMiZwkEAEAAEyJnCQYAQAATImcJCABAABMiZwkKAEAAEyJnCQwAQAATImcJDgBAABMiZwkQAEAAEyJnCRIAQAATImcJFABAABMiZwkWAEAAEyJnCRgAQAATImcJGgBAABMiZwkcAEAAEyJnCR4AQAATImcJIABAABMiZwkiAEAAEyJnCSQAQAATImcJJgBAABMiZwkoAEAAEyJnCSoAQAATImcJLABAABMiZwkuAEAAEyJnCTAAQAATImcJMgBAABMiZwk0AEAAEyJnCTYAQAATImcJOABAABMiZwk6AEAAEyJnCTwAQAATImcJPgBAABMiZwkAAIAAEyJnCQIAgAATImcJBACAABMiZwkGAIAAEyJnCQgAgAATImcJCgCAABMiZwkMAIAAEyJnCQ4AgAATImcJEACAABMiZwkSAIAAEyJnCRQAgAATImcJFgCAABMiZwkYAIAAEyJnCRoAgAATImcJHACAABMiZwkeAIAAEyJnCSAAgAATImcJIgCAABMiZwkkAIAAEyJnCSYAgAATImcJKACAABMiZwkqAIAAEyJnCSwAgAATImcJLgCAABMiZwkwAIAAEyJnCTIAgAATImcJNACAABMiZwk2AIAAEyJnCTgAgAATImcJOgCAABMiZwk8AIAAEyJnCT4AgAATImcJAADAABMiZwkCAMAAEyJnCQQAwAATImcJBgDAABMiZwkIAMAAEyJnCQoAwAATImcJDADAABMiZwkOAMAAEyJnCRAAwAATImcJEgDAABMiZwkUAMAAEyJnCRYAwAATImcJGADAABMiZwkaAMAAEyJnCRwAwAATImcJHgDAABMiZwkgAMAAEyJnCSIAwAATImcJJADAABMiZwkmAMAAEyJnCSgAwAATImcJKgDAABMiZwksAMAAEyJnCS4AwAATImcJMADAABMiZwkyAMAAEyJnCTQAwAATImcJNgDAABMiZwk4AMAAEyJnCToAwAATImcJPADAABMiZwk+AMAAEyJnCQABAAATImcJAgEAABMiZwkEAQAAEyJnCQYBAAATImcJCAEAABMiZwkKAQAAEyJnCQwBAAATImcJDgEAABMiZwkQAQAAEyJnCRIBAAATImcJFAEAABMiZwkWAQAAEyJnCRgBAAATImcJGgEAABMiZwkcAQAAEyJnCR4BAAATImcJIAEAABMiZwkiAQAAEyJnCSQBAAATImcJJgEAABMiZwkoAQAAEyJnCSoBAAATImcJLAEAABMiZwkuAQAAEyJnCTABAAATImcJMgEAABMiZwk0AQAAEyJnCTYBAAATImcJOAEAABMiZwk6AQAAEyJnCTwBAAATImcJPgEAABMiZwkAAUAAEyJnCQIBQAATImcJBAFAABMiZwkGAUAAEyJnCQgBQAATImcJCgFAABMiZwkMAUAAEyJnCQ4BQAATImcJEAFAABMiZwkSAUAAEyJnCRQBQAATImcJFgFAABMiZwkYAUAAEyJnCRoBQAATImcJHAFAABMiZwkeAUAAEyJnCSABQAATImcJIgFAABMiZwkkAUAAEyJnCSYBQAATImcJKAFAABMiZwkqAUAAEyJnCSwBQAATImcJLgFAABMiZwkwAUAAEyJnCTIBQAATImcJNAFAABMiZwk2AUAAEyJnCTgBQAATImcJOgFAABMiZwk8AUAAEyJnCT4BQAATImcJAAGAABMiZwkCAYAAEyJnCQQBgAATImcJBgGAABMiZwkIAYAAEyJnCQoBgAATImcJDAGAABMiZwkOAYAAEyJnCRABgAATImcJEgGAABMiZwkUAYAAEyJnCRYBgAATImcJGAGAABMiZwkaAYAAEyJnCRwBgAATImcJHgGAABMiZwkgAYAAEyJnCSIBgAATImcJJAGAABMiZwkmAYAAEyJnCSgBgAATImcJKgGAABMiZwksAYAAEyJnCS4BgAATImcJMAGAABMiZwkyAYAAEyJnCTQBgAATImcJNgGAABMiZwk4AYAAEyJnCToBgAATImcJPAGAABMiZwk+AYAAEyJnCQABwAATImcJAgHAABMiZwkEAcAAEyJnCQYBwAATImcJCAHAABMiZwkKAcAAEyJnCQwBwAATImcJDgHAABMiZwkQAcAAEyJnCRIBwAATImcJFAHAABMiZwkWAcAAEyJnCRgBwAATImcJGgHAABMiZwkcAcAAEyJnCR4BwAATImcJIAHAABMiZwkiAcAAEyJnCSQBwAATImcJJgHAABMiZwkoAcAAEyJnCSoBwAATImcJLAHAABMiZwkuAcAAEyJnCTABwAATImcJMgHAABMiZwk0AcAAEyJnCTYBwAATImcJOAHAABMiZwk6AcAAEyJnCTwBwAATImcJPgHAABMiZwkAAgAAEyJnCQICAAATImcJBAIAABMiZwkGAgAAEyJnCQgCAAATImcJCgIAABMiZwkMAgAAEyJnCQ4CAAATImcJEAIAABMiZwkSAgAAEyJnCRQCAAATImcJFgIAABMiZwkYAgAAEyJnCRoCAAATImcJHAIAABMiZwkeAgAAEyJnCSACAAATImcJIgIAABMiZwkkAgAAEyJnCSYCAAATImcJKAIAABMiZwkqAgAAEyJnCSwCAAATImcJLgIAABMiZwkwAgAAEyJnCTICAAATImcJNAIAABMiZwk2AgAAEyJnCTgCAAATImcJOgIAABMiZwk8AgAAEyJnCT4CAAATImcJAAJAABMiZwkCAkAAEyJnCQQCQAATImcJBgJAABMiZwkIAkAAEyJnCQoCQAATImcJDAJAABMiZwkOAkAAEyJnCRACQAATImcJEgJAABMiZwkUAkAAEyJnCRYCQAATImcJGAJAABMiZwkaAkAAEyJnCRwCQAATImcJHgJAABMiZwkgAkAAEyJnCSICQAATImcJJAJAABMiZwkmAkAAEyJnCSgCQAATImcJKgJAABMiZwksAkAAEyJnCS4CQAATImcJMAJAABMiZwkyAkAAEyJnCTQCQAATImcJNgJAABMiZwk4AkAAEyJnCToCQAATImcJPAJAABMiZwk+AkAAEyJnCQACgAATImcJAgKAABMiZwkEAoAAEyJnCQYCgAATImcJCAKAABMiZwkKAoAAEyJnCQwCgAATImcJDgKAABMiZwkQAoAAEyJnCRICgAATImcJFAKAABMiZwkWAoAAEyJnCRgCgAATImcJGgKAABMiZwkcAoAAEyJnCR4CgAATImcJIAKAABMiZwkiAoAAEyJnCSQCgAATImcJJgKAABMiZwkoAoAAEyJnCSoCgAATImcJLAKAABMiZwkuAoAAEyJnCTACgAATImcJMgKAABMiZwk0AoAAEyJnCTYCgAATImcJOAKAABMiZwk6AoAAEyJnCTwCgAATImcJPgKAABMiZwkAAsAAEyJnCQICwAATImcJBALAABMiZwkGAsAAEyJnCQgCwAATImcJCgLAABMiZwkMAsAAEyJnCQ4CwAATImcJEALAABMiZwkSAsAAEyJnCRQCwAATImcJFgLAABMiZwkYAsAAEyJnCRoCwAATImcJHALAABMiZwkeAsAAEyJnCSACwAATImcJIgLAABMiZwkkAsAAEyJnCSYCwAATImcJKALAABMiZwkqAsAAEyJnCSwCwAATImcJLgLAABMiZwkwAsAAEyJnCTICwAATImcJNALAABMiZwk2AsAAEyJnCTgCwAATImcJOgLAABMiZwk8AsAAEyJnCT4CwAATImcJAAMAABMiZwkCAwAAEyJnCQQDAAATImcJBgMAABMiZwkIAwAAEyJnCQoDAAATImcJDAMAABMiZwkOAwAAEyJnCRADAAATImcJEgMAABMiZwkUAwAAEyJnCRYDAAATImcJGAMAABMiZwkaAwAAEyJnCRwDAAATImcJHgMAABMiZwkgAwAAEyJnCSIDAAATImcJJAMAABMiZwkmAwAAEyJnCSgDAAATImcJKgMAABMiZwksAwAAEyJnCS4DAAATImcJMAMAABMiZwkyAwAAEiNpCTQDAAAww==" +.p2align 6"#, + vg_camellia_crypt_prepared = sym super::camellia::vg_camellia_crypt_prepared::vg_camellia_crypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/cast5_ofb.rs b/crates/verified-garbage-asm-x86_64/src/cast5_ofb.rs index 23d0cc132b6..be29c8d0ce3 100644 --- a/crates/verified-garbage-asm-x86_64/src/cast5_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/cast5_ofb.rs @@ -65,3 +65,75 @@ jmp 21f VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, ) } + +/// CAST5-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 2144 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is CAST5 encryption with `rounds` rounds under the subkeys at `schedule`, as `vg_cast5_expand_key` writes them. +/// +/// Contract: `VG.Spec.Cast5.ofbFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `rounds` must be 12 (for a key of up to 10 bytes) or 16 (for a longer one). +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 240 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_cast5_ofb_final(schedule: *const [u8; 128], rounds: usize, iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI2kJBD///9JieFJg8EITYnJSYmZqAAAAEmJqbAAAABNiaG4AAAATYmpwAAAAE2JscgAAABNibnQAAAAZkwPbvpJicxNicVIiwdJiUEoSItHCEmJQTBIi0cQSYlBOEiLRxhJiUFASItHIEmJQUhIi0coSYlBUEiLRzBJiUFYSItHOEmJQWBIi0dASYlBaEiLR0hJiUFwSItHUEmJQXhIi0dYSYmBgAAAAEiLR2BJiYGIAAAASItHaEmJgZAAAABIi0dwSYmBmAAAAEiLR3hJiYGgAAAAZkwPfvhIiyhJiWkQTYXt" +je 20f +22: +.base64 "ZkwPfvlNichNiWAYTYloIEyJykiDwhBMic9Ig8coixoPy4tqBA/NSYn8SYn1ScHtAkmDxQFIg/4Q" +23: +.base64 "QYsEJAHoRYtMJEBFic5Bg+YBQYPuAUGJx0HBzx9EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzx5EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxxEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxhEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxBEMfhEIfBEMfhBicFBgeH/AAAAQYnGQcHuCEGB5v8AAABJweYgTQnxZkkPbsFBicFBwekQQYHh/wAAAEGJxkHB7hhJweYgTQnxZkkPbuFmD2zE" +lea r10, [rip + {VG_CAST5_S1234}] +.base64 "QbtAAAAAZg/vyWYP79JmD3bbZg9y0x9mD2/gZg/b42YP7/ZmD/r0Zg9v4GYPctQBZg/b42YP7/9mD/r8ZkQPb8BmQQ9y0AI=" +24: +.base64 "80EPbyLzQQ9vahBmD+/sZg/b7mYP7+XzRQ9vSiDzQQ9vajBmQQ/v6WYP2+5mRA/vzWZED+/MZkQP289mQQ/v4WZBD2/oZg926mYP2+VmD+vMZg/+00mDwkBJg+sB" +jne 24b +.base64 "80EPfwhBi0AMQTNACEErQARBAwAx2InricVJg8QEQYsEJDHoRYtMJEBFic5Bg+YBQYPuAUGJx0HBzx9EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzx5EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxxEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxhEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxBEMfhEIfBEMfhBicFBgeH/AAAAQYnGQcHuCEGB5v8AAABJweYgTQnxZkkPbsFBicFBwekQQYHh/wAAAEGJxkHB7hhJweYgTQnxZkkPbuFmD2zE" +lea r10, [rip + {VG_CAST5_S1234}] +.base64 "QbtAAAAAZg/vyWYP79JmD3bbZg9y0x9mD2/gZg/b42YP7/ZmD/r0Zg9v4GYPctQBZg/b42YP7/9mD/r8ZkQPb8BmQQ9y0AI=" +25: +.base64 "80EPbyLzQQ9vahBmD+/sZg/b7mYP7+XzRQ9vSiDzQQ9vajBmQQ/v6WYP2+5mRA/vzWZED+/MZkQP289mQQ/v4WZBD2/oZg926mYP2+VmD+vMZg/+00mDwkBJg+sB" +jne 25b +.base64 "80EPfwhBi0AMQStACEEDQARBMwAx2InricVJg8QEQYsEJCnoRYtMJEBFic5Bg+YBQYPuAUGJx0HBzx9EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzx5EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxxEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxhEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxBEMfhEIfBEMfhBicFBgeH/AAAAQYnGQcHuCEGB5v8AAABJweYgTQnxZkkPbsFBicFBwekQQYHh/wAAAEGJxkHB7hhJweYgTQnxZkkPbuFmD2zE" +lea r10, [rip + {VG_CAST5_S1234}] +.base64 "QbtAAAAAZg/vyWYP79JmD3bbZg9y0x9mD2/gZg/b42YP7/ZmD/r0Zg9v4GYPctQBZg/b42YP7/9mD/r8ZkQPb8BmQQ9y0AI=" +26: +.base64 "80EPbyLzQQ9vahBmD+/sZg/b7mYP7+XzRQ9vSiDzQQ9vajBmQQ/v6WYP2+5mRA/vzWZED+/MZkQP289mQQ/v4WZBD2/oZg926mYP2+VmD+vMZg/+00mDwkBJg+sB" +jne 26b +.base64 "80EPfwhBi0AMQQNACEEzQARBKwAx2InricVJg8QESYPtAQ==" +jne 23b +.base64 "SIP+EA==" +je 27f +jmp 28f +27: +.base64 "QYsEJAHoRYtMJEBFic5Bg+YBQYPuAUGJx0HBzx9EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzx5EMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxxEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxhEMfhEIfBEMfhB0elFic5Bg+YBQYPuAUGJx0HBzxBEMfhEIfBEMfhBicFBgeH/AAAAQYnGQcHuCEGB5v8AAABJweYgTQnxZkkPbsFBicFBwekQQYHh/wAAAEGJxkHB7hhJweYgTQnxZkkPbuFmD2zE" +lea r10, [rip + {VG_CAST5_S1234}] +.base64 "QbtAAAAAZg/vyWYP79JmD3bbZg9y0x9mD2/gZg/b42YP7/ZmD/r0Zg9v4GYPctQBZg/b42YP7/9mD/r8ZkQPb8BmQQ9y0AI=" +29: +.base64 "80EPbyLzQQ9vahBmD+/sZg/b7mYP7+XzRQ9vSiDzQQ9vajBmQQ/v6WYP2+5mRA/vzWZED+/MZkQP289mQQ/v4WZBD2/oZg926mYP2+VmD+vMZg/+00mDwkBJg+sB" +jne 29b +.base64 "80EPfwhBi0AMQTNACEErQARBAwAx2InricVJg8QE" +28: +.base64 "D82JKg/LiVoESIPCCEiD6QFNi2AYTYtoIE2JwUiDwQFmTA9u+UmD/Qg=" +jb 210f +.base64 "SYsEJEkzQRBJiQQkSYPECEmD7Qg=" +jmp 211f +210: +.base64 "TInISIPAEA==" +212: +.base64 "RA+2EEEPtgwkTDHRQYgMJEiDwAFJg8QBSYPtAQ==" +jne 212b +211: +jne 22b +jmp 21f +20: +21: +.base64 "ZkwPfvhJi2kQSIkoSYuZqAAAAEmLqbAAAABNi6G4AAAATYupwAAAAE2LscgAAABNi7nQAAAAQbsAAAAATIlcJAhMiVwkEEyJXCQYTIlcJCBMiVwkKEyJXCQwTIlcJDhMiVwkQEyJXCRITIlcJFBMiVwkWEyJXCRgTIlcJGhMiVwkcEyJXCR4TImcJIAAAABMiZwkiAAAAEyJnCSQAAAATImcJJgAAABMiZwkoAAAAEyJnCSoAAAATImcJLAAAABMiZwkuAAAAEyJnCTAAAAATImcJMgAAABMiZwk0AAAAEyJnCTYAAAATImcJOAAAABMiZwk6AAAAEiNpCTwAAAAww==" +.p2align 6"#, + VG_CAST5_S1234 = sym super::consts::VG_CAST5_S1234, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/idea_ofb.rs b/crates/verified-garbage-asm-x86_64/src/idea_ofb.rs index 2e1ca8ce36f..27972340cd8 100644 --- a/crates/verified-garbage-asm-x86_64/src/idea_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/idea_ofb.rs @@ -29,3 +29,39 @@ jmp 21f .p2align 6"#, ) } + +/// IDEA-OFB encryption or decryption (NIST SP 800-38A §6.4, Lai 1992 §3.3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is IDEA encryption under the encryption subkeys written by `vg_idea_expand_key`. +/// +/// Contract: `VG.Spec.Idea.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the subkeys, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 104 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 184 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_idea_ofb_final(schedule: *const [u8; 104], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI2kJEj///9JieBJg8AITYnBSYlZcEmJaXhNiaGAAAAATYmpiAAAAE2JsZAAAABNibmYAAAAZkwPbv5JidRJic1IiwdJiUEISItHCEmJQRBIi0cQSYlBGEiLRxhJiUEgSItHIEmJQShIi0coSYlBMEiLRzBJiUE4SItHOEmJQUBIi0dASYlBSEiLR0hJiUFQSItHUEmJQVhIi0dYSYlBYEiLR2BJiUFoZkwPfvhIiyhJiSlNhe0=" +je 20f +22: +.base64 "TInJTInPSIPHCEyJzkQPtgZJweAID7ZGAUkJwEQPtk4CScHhCA+2RgNJCcFED7ZWBEnB4ggPtkYFSQnCRA+2XgZJweMID7ZGB0kJw0yJwEiLF0iD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASYnQTInYSItXBkiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASYnTSItXAkkB0UmB4f//AABIi1cESQHSSYHi//8AAEyJwEwx0EiLVwhIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEiJ00yJyEwx2EgB2EiLVwpIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEgB00iB4///AABJMdBJMdJJMdlJMdtMichNidFJicJMicBIi1cMSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidBMidhIi1cSSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidNIi1cOSQHRSYHh//8AAEiLVxBJAdJJgeL//wAATInATDHQSItXFEiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASInTTInITDHYSAHYSItXFkiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASAHTSIHj//8AAEkx0Ekx0kkx2Ukx20yJyE2J0UmJwkyJwEiLVxhIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEmJ0EyJ2EiLVx5Ig+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEmJ00iLVxpJAdFJgeH//wAASItXHEkB0kmB4v//AABMicBMMdBIi1cgSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABIidNMichMMdhIAdhIi1ciSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABIAdNIgeP//wAASTHQSTHSSTHZSTHbTInITYnRSYnCTInASItXJEiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASYnQTInYSItXKkiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASYnTSItXJkkB0UmB4f//AABIi1coSQHSSYHi//8AAEyJwEwx0EiLVyxIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEiJ00yJyEwx2EgB2EiLVy5Ig+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEgB00iB4///AABJMdBJMdJJMdlJMdtMichNidFJicJMicBIi1cwSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidBMidhIi1c2SIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidNIi1cySQHRSYHh//8AAEiLVzRJAdJJgeL//wAATInATDHQSItXOEiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASInTTInITDHYSAHYSItXOkiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASAHTSIHj//8AAEkx0Ekx0kkx2Ukx20yJyE2J0UmJwkyJwEiLVzxIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEmJ0EyJ2EiLV0JIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEmJ00iLVz5JAdFJgeH//wAASItXQEkB0kmB4v//AABMicBMMdBIi1dESIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABIidNMichMMdhIAdhIi1dGSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABIAdNIgeP//wAASTHQSTHSSTHZSTHbTInITYnRSYnCTInASItXSEiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASYnQTInYSItXTkiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASYnTSItXSkkB0UmB4f//AABIi1dMSQHSSYHi//8AAEyJwEwx0EiLV1BIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEiJ00yJyEwx2EgB2EiLV1JIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEgB00iB4///AABJMdBJMdJJMdlJMdtMichNidFJicJMicBIi1dUSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidBMidhIi1daSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidNIi1dWSQHRSYHh//8AAEiLV1hJAdJJgeL//wAATInATDHQSItXXEiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASInTTInITDHYSAHYSItXXkiD6AFIJf//AABIg8ABSIPqAUiB4v//AABIg8IBSA+vwkiJwkiB4v//AABIwegQSCnCSInQSMHoP0gBwkjB4BBIAcJIgeL//wAASAHTSIHj//8AAEkx0Ekx0kkx2Ukx20yJyE2J0UmJwkyJwEiLV2BIg+gBSCX//wAASIPAAUiD6gFIgeL//wAASIPCAUgPr8JIicJIgeL//wAASMHoEEgpwkiJ0EjB6D9IAcJIweAQSAHCSIHi//8AAEmJ0EyJ2EiLV2BIweowSIPoAUgl//8AAEiDwAFIg+oBSIHi//8AAEiDwgFID6/CSInCSIHi//8AAEjB6BBIKcJIidBIweg/SAHCSMHgEEgBwkiB4v//AABJidNIi1dgSMHqEEkB0kmB4v//AABIi1dgSMHqIEkB0UmB4f//AABEiEYBTInASMHoCIgGRIhWA0yJ0EjB6AiIRgJEiE4FTInISMHoCIhGBESIXgdMidhIwegIiEYGSYnJSYP9CA==" +jb 23f +.base64 "SYsEJEkzAUmJBCRJg8QISYPtCA==" +jmp 24f +23: +.base64 "TInISIPAAA==" +25: +.base64 "RA+2EEEPtgwkTDHRQYgMJEiDwAFJg8QBSYPtAQ==" +jne 25b +24: +jne 22b +jmp 21f +20: +21: +.base64 "ZkwPfvhJiylIiShJi1lwSYtpeE2LoYAAAABNi6mIAAAATYuxkAAAAE2LuZgAAABBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhMiVwkUEyJXCRYTIlcJGBMiVwkaEyJXCRwTIlcJHhMiZwkgAAAAEyJnCSIAAAATImcJJAAAABMiZwkmAAAAEyJnCSgAAAATImcJKgAAABMiZwksAAAAEiNpCS4AAAAww==" +.p2align 6"#, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/seed_ofb.rs b/crates/verified-garbage-asm-x86_64/src/seed_ofb.rs index d2acad0c3b7..1e05a14057b 100644 --- a/crates/verified-garbage-asm-x86_64/src/seed_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/seed_ofb.rs @@ -32,3 +32,42 @@ jmp 21f vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, ) } + +/// SEED-OFB encryption or decryption (NIST SP 800-38A §6.4, RFC 4269 §2) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SEED encryption under the schedule written by `vg_seed_expand_key`. +/// +/// Contract: `VG.Spec.Seed.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 1552 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_seed_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI2kJPj5//9JieBJg8AITYnBSYmZwAUAAEmJqcgFAABNiaHQBQAATYmp2AUAAE2JseAFAABNibnoBQAAZkwPbv5JidRJic1IiwdJiYFABQAASItHCEmJgUgFAABIi0cQSYmBUAUAAEiLRxhJiYFYBQAASItHIEmJgWAFAABIi0coSYmBaAUAAEiLRzBJiYFwBQAASItHOEmJgXgFAABIi0dASYmBgAUAAEiLR0hJiYGIBQAASItHUEmJgZAFAABIi0dYSYmBmAUAAEiLR2BJiYGgBQAASItHaEmJgagFAABIi0dwSYmBsAUAAEiLR3hJiYG4BQAAZkwPfvhIiyhJialABAAASItoCEmJqUgEAABNhe0=" +je 20f +22: +.base64 "Zk0PbuFmTQ9u7GZND271TInPSIHHQAUAAEyJzkiBxkAEAABIuhAAAAAAAAAATInJ" +call {vg_seed_encrypt_blocks} +.base64 "Zk0PfuFmTQ9+7GZND371SYP9EA==" +jb 23f +.base64 "SYsEJEkzgUAEAABJiQQkSYtEJAhJM4FIBAAASYlEJAhJg8QQSYPtEA==" +jmp 24f +23: +.base64 "TInISAVABAAA" +25: +.base64 "RA+2EEEPtgwkTDHRQYgMJEiDwAFJg8QBSYPtAQ==" +jne 25b +24: +jne 22b +jmp 21f +20: +21: +.base64 "ZkwPfvhJi6lABAAASIkoSYupSAQAAEiJaAhJi5nABQAASYupyAUAAE2LodAFAABNi6nYBQAATYux4AUAAE2LuegFAABBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhMiVwkUEyJXCRYTIlcJGBMiVwkaEyJXCRwTIlcJHhMiZwkgAAAAEyJnCSIAAAATImcJJAAAABMiZwkmAAAAEyJnCSgAAAATImcJKgAAABMiZwksAAAAEyJnCS4AAAATImcJMAAAABMiZwkyAAAAEyJnCTQAAAATImcJNgAAABMiZwk4AAAAEyJnCToAAAATImcJPAAAABMiZwk+AAAAEyJnCQAAQAATImcJAgBAABMiZwkEAEAAEyJnCQYAQAATImcJCABAABMiZwkKAEAAEyJnCQwAQAATImcJDgBAABMiZwkQAEAAEyJnCRIAQAATImcJFABAABMiZwkWAEAAEyJnCRgAQAATImcJGgBAABMiZwkcAEAAEyJnCR4AQAATImcJIABAABMiZwkiAEAAEyJnCSQAQAATImcJJgBAABMiZwkoAEAAEyJnCSoAQAATImcJLABAABMiZwkuAEAAEyJnCTAAQAATImcJMgBAABMiZwk0AEAAEyJnCTYAQAATImcJOABAABMiZwk6AEAAEyJnCTwAQAATImcJPgBAABMiZwkAAIAAEyJnCQIAgAATImcJBACAABMiZwkGAIAAEyJnCQgAgAATImcJCgCAABMiZwkMAIAAEyJnCQ4AgAATImcJEACAABMiZwkSAIAAEyJnCRQAgAATImcJFgCAABMiZwkYAIAAEyJnCRoAgAATImcJHACAABMiZwkeAIAAEyJnCSAAgAATImcJIgCAABMiZwkkAIAAEyJnCSYAgAATImcJKACAABMiZwkqAIAAEyJnCSwAgAATImcJLgCAABMiZwkwAIAAEyJnCTIAgAATImcJNACAABMiZwk2AIAAEyJnCTgAgAATImcJOgCAABMiZwk8AIAAEyJnCT4AgAATImcJAADAABMiZwkCAMAAEyJnCQQAwAATImcJBgDAABMiZwkIAMAAEyJnCQoAwAATImcJDADAABMiZwkOAMAAEyJnCRAAwAATImcJEgDAABMiZwkUAMAAEyJnCRYAwAATImcJGADAABMiZwkaAMAAEyJnCRwAwAATImcJHgDAABMiZwkgAMAAEyJnCSIAwAATImcJJADAABMiZwkmAMAAEyJnCSgAwAATImcJKgDAABMiZwksAMAAEyJnCS4AwAATImcJMADAABMiZwkyAMAAEyJnCTQAwAATImcJNgDAABMiZwk4AMAAEyJnCToAwAATImcJPADAABMiZwk+AMAAEyJnCQABAAATImcJAgEAABMiZwkEAQAAEyJnCQYBAAATImcJCAEAABMiZwkKAQAAEyJnCQwBAAATImcJDgEAABMiZwkQAQAAEyJnCRIBAAATImcJFAEAABMiZwkWAQAAEyJnCRgBAAATImcJGgEAABMiZwkcAQAAEyJnCR4BAAATImcJIAEAABMiZwkiAQAAEyJnCSQBAAATImcJJgEAABMiZwkoAQAAEyJnCSoBAAATImcJLAEAABMiZwkuAQAAEyJnCTABAAATImcJMgEAABMiZwk0AQAAEyJnCTYBAAATImcJOAEAABMiZwk6AQAAEyJnCTwBAAATImcJPgEAABMiZwkAAUAAEyJnCQIBQAATImcJBAFAABMiZwkGAUAAEyJnCQgBQAATImcJCgFAABMiZwkMAUAAEyJnCQ4BQAATImcJEAFAABMiZwkSAUAAEyJnCRQBQAATImcJFgFAABMiZwkYAUAAEyJnCRoBQAATImcJHAFAABMiZwkeAUAAEyJnCSABQAATImcJIgFAABMiZwkkAUAAEyJnCSYBQAATImcJKAFAABMiZwkqAUAAEyJnCSwBQAATImcJLgFAABMiZwkwAUAAEyJnCTIBQAATImcJNAFAABMiZwk2AUAAEyJnCTgBQAATImcJOgFAABMiZwk8AUAAEyJnCT4BQAATImcJAAGAABIjaQkCAYAAMM=" +.p2align 6"#, + vg_seed_encrypt_blocks = sym super::seed::vg_seed_encrypt_blocks::vg_seed_encrypt_blocks, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/sm4_ctr.rs b/crates/verified-garbage-asm-x86_64/src/sm4_ctr.rs index ea7ec66c502..5a70a637c5b 100644 --- a/crates/verified-garbage-asm-x86_64/src/sm4_ctr.rs +++ b/crates/verified-garbage-asm-x86_64/src/sm4_ctr.rs @@ -46,3 +46,36 @@ jmp 22f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-CTR encryption or decryption (NIST SP 800-38A §6.5, draft-ribose-cfrg-sm4-10 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ctrFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the counter block or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `ctr` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr` and `data` may overlap the return address on the stack or the 3296 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_sm4_ctr_final(schedule: *const [u8; 128], ctr: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI1kJLhJieBJg8AITInASIkYSIloCEyJYBBMiWgYTIlwIEyJeChIiftJifRJicdJic5Jg+YPSYnNTSn1SQHVSMHpBA==" +call {vg_sm4_ctr} +.base64 "TYX2" +je 20f +.base64 "TIn4QboAAAAATIlQMEyJUDhIid9MieZIicJIg8IwuQEAAAA=" +call {vg_sm4_ctr} +.base64 "TIn4SIPAMA==" +22: +.base64 "RA+2EEEPtk0ATDHRQYhNAEiDwAFJg8UBSYPuAQ==" +jne 22b +jmp 21f +20: +21: +.base64 "TIn4SIsYSItoCEyLYBBMi2gYTItwIEyLeChBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRASI1kJEjD" +.p2align 6"#, + vg_sm4_ctr = sym super::sm4_ctr::vg_sm4_ctr, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/sm4_ofb.rs b/crates/verified-garbage-asm-x86_64/src/sm4_ofb.rs index 76b1543b4ec..8af6efb6cad 100644 --- a/crates/verified-garbage-asm-x86_64/src/sm4_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/sm4_ofb.rs @@ -36,3 +36,46 @@ jmp 22f vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, ) } + +/// SM4-OFB encryption or decryption (NIST SP 800-38A §6.4, GB/T 32907-2016 §7.1) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is SM4 encryption under the schedule written by `vg_sm4_expand_key`. +/// +/// Contract: `VG.Spec.Sm4.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 128 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 3216 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_sm4_ofb_final(schedule: *const [u8; 128], iv: *mut [u8; 16], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI2kJHjz//9JieBJg8AITYnBSYmZQAwAAEmJqUgMAABNiaFQDAAATYmpWAwAAE2JsWAMAABNibloDAAAZkwPbv5IidJJichJvv8A/wD/AP8ATYmxgAEAAEm+AP8A/wD/AP9NibGIAQAASb7//wAA//8AAE2JsZABAABMic5IgcYABAAASb8QAAAAAAAAAA==" +20: +.base64 "SIsHSb4AAP//AAAAAE2JcQhJvgD/AAAA/wAATYlxEEm+/wD/AP8A/wBNiXEYSb5VVVVVVVVVVU2JcSBJvjMzMzMzMzMzTYlxKEm+Dw8PDw8PDw9NiXEwSYnGScHuEEkxxk0jcQhMMfBJwc4wTDHwSYnGScHuCEkxxk0jcRBMMfBJwc44TDHwSInDSInBSInFSYnCSYnDSYnESYnFSYnGSdHuSTHeTSNxIEwx80nBzj9MMfBJic5J0e5JMe5NI3EgTDH1ScHOP0wx8U2J1knR7k0x3k0jcSBNMfNJwc4/TTHyTYnmSdHuTTHuTSNxIE0x9UnBzj9NMfRJicZJwe4CSTHOTSNxKEwx8UnBzj5MMfBJid5Jwe4CSTHuTSNxKEwx9UnBzj5MMfNNidZJwe4CTTHmTSNxKE0x9EnBzj5NMfJNid5Jwe4CTTHuTSNxKE0x9UnBzj5NMfNJicZJwe4ETTHWTSNxME0x8knBzjxMMfBJid5Jwe4ETTHeTSNxME0x80nBzjxMMfNJic5Jwe4ETTHmTSNxME0x9EnBzjxMMfFJie5Jwe4ETTHuTSNxME0x9UnBzjxMMfVJI4GAAQAASYnGScHOOEwx8EjByCBJicZJwe4QSTHGTSOxkAEAAEwx8EnBzjBMMfBJI5mAAQAASYneScHOOEwx80jByyBJid5Jwe4QSTHeTSOxkAEAAEwx80nBzjBMMfNJI4mAAQAASYnOScHOOEwx8UjBySBJic5Jwe4QSTHOTSOxkAEAAEwx8UnBzjBMMfFJI6mAAQAASYnuScHOOEwx9UjBzSBJie5Jwe4QSTHuTSOxkAEAAEwx9UnBzjBMMfVNI5GAAQAATYnWScHOOE0x8knByiBNidZJwe4QTTHWTSOxkAEAAE0x8knBzjBNMfJNI5mAAQAATYneScHOOE0x80nByyBNid5Jwe4QTTHeTSOxkAEAAE0x80nBzjBNMfNNI6GAAQAATYnmScHOOE0x9EnBzCBNieZJwe4QTTHmTSOxkAEAAE0x9EnBzjBNMfRNI6mAAQAATYnuScHOOE0x9UnBzSBNie5Jwe4QTTHuTSOxkAEAAE0x9UnBzjBNMfVIiQZIiV4ISIlOEEiJbhhMiVYgTIleKEyJZjBMiW44SIPGQEiLB0m+AAD//wAAAABNiXEISb4A/wAAAP8AAE2JcRBJvv8A/wD/AP8ATYlxGEm+VVVVVVVVVVVNiXEgSb4zMzMzMzMzM02JcShJvg8PDw8PDw8PTYlxMEmJxknB7hBJMcZNI3EITDHwScHOMEwx8EmJxknB7ghJMcZNI3EQTDHwScHOOEwx8EiJw0iJwUiJxUmJwkmJw0mJxEmJxUmJxknR7kkx3k0jcSBMMfNJwc4/TDHwSYnOSdHuSTHuTSNxIEwx9UnBzj9MMfFNidZJ0e5NMd5NI3EgTTHzScHOP00x8k2J5knR7k0x7k0jcSBNMfVJwc4/TTH0SYnGScHuAkkxzk0jcShMMfFJwc4+TDHwSYneScHuAkkx7k0jcShMMfVJwc4+TDHzTYnWScHuAk0x5k0jcShNMfRJwc4+TTHyTYneScHuAk0x7k0jcShNMfVJwc4+TTHzSYnGScHuBE0x1k0jcTBNMfJJwc48TDHwSYneScHuBE0x3k0jcTBNMfNJwc48TDHzSYnOScHuBE0x5k0jcTBNMfRJwc48TDHxSYnuScHuBE0x7k0jcTBNMfVJwc48TDH1SSOBiAEAAEmJxknBzghMMfBIwcggSYnGScHuEEkxxk0jsZABAABMMfBJwc4wTDHwSSOZiAEAAEmJ3knBzghMMfNIwcsgSYneScHuEEkx3k0jsZABAABMMfNJwc4wTDHzSSOJiAEAAEmJzknBzghMMfFIwckgSYnOScHuEEkxzk0jsZABAABMMfFJwc4wTDHxSSOpiAEAAEmJ7knBzghMMfVIwc0gSYnuScHuEEkx7k0jsZABAABMMfVJwc4wTDH1TSORiAEAAE2J1knBzghNMfJJwcogTYnWScHuEE0x1k0jsZABAABNMfJJwc4wTTHyTSOZiAEAAE2J3knBzghNMfNJwcsgTYneScHuEE0x3k0jsZABAABNMfNJwc4wTTHzTSOhiAEAAE2J5knBzghNMfRJwcwgTYnmScHuEE0x5k0jsZABAABNMfRJwc4wTTH0TSOpiAEAAE2J7knBzghNMfVJwc0gTYnuScHuEE0x7k0jsZABAABNMfVJwc4wTTH1SIkGSIleCEiJThBIiW4YTIlWIEyJXihMiWYwTIluOEiDxkBIg8cISYPvAQ==" +jne 20b +.base64 "TInPSIHHAAwAAGZMD374SIsoSYmpAAMAAEiLaAhJiakIAwAATYXA" +je 21f +23: +.base64 "TInPSL6IAQAAAAAAAA==" +call {vg_sm4_crypt_prepared} +.base64 "SYP4EA==" +jb 24f +.base64 "SIsCSTOBAAMAAEiJAkiLQghJM4EIAwAASIlCCEiDwhBJg+gQ" +jmp 25f +24: +.base64 "TInISAUAAwAA" +26: +.base64 "RA+2EA+2Ckwx0YgKSIPAAUiDwgFJg+gB" +jne 26b +25: +jne 23b +jmp 22f +21: +22: +.base64 "ZkwPfvhJi6kAAwAASIkoSYupCAMAAEiJaAhJi5lADAAASYupSAwAAE2LoVAMAABNi6lYDAAATYuxYAwAAE2LuWgMAABBuwAAAABMiVwkCEyJXCQQTIlcJBhMiVwkIEyJXCQoTIlcJDBMiVwkOEyJXCRATIlcJEhMiVwkUEyJXCRYTIlcJGBMiVwkaEyJXCRwTIlcJHhMiZwkgAAAAEyJnCSIAAAATImcJJAAAABMiZwkmAAAAEyJnCSgAAAATImcJKgAAABMiZwksAAAAEyJnCS4AAAATImcJMAAAABMiZwkyAAAAEyJnCTQAAAATImcJNgAAABMiZwk4AAAAEyJnCToAAAATImcJPAAAABMiZwk+AAAAEyJnCQAAQAATImcJAgBAABMiZwkEAEAAEyJnCQYAQAATImcJCABAABMiZwkKAEAAEyJnCQwAQAATImcJDgBAABMiZwkQAEAAEyJnCRIAQAATImcJFABAABMiZwkWAEAAEyJnCRgAQAATImcJGgBAABMiZwkcAEAAEyJnCR4AQAATImcJIABAABMiZwkiAEAAEyJnCSQAQAATImcJJgBAABMiZwkoAEAAEyJnCSoAQAATImcJLABAABMiZwkuAEAAEyJnCTAAQAATImcJMgBAABMiZwk0AEAAEyJnCTYAQAATImcJOABAABMiZwk6AEAAEyJnCTwAQAATImcJPgBAABMiZwkAAIAAEyJnCQIAgAATImcJBACAABMiZwkGAIAAEyJnCQgAgAATImcJCgCAABMiZwkMAIAAEyJnCQ4AgAATImcJEACAABMiZwkSAIAAEyJnCRQAgAATImcJFgCAABMiZwkYAIAAEyJnCRoAgAATImcJHACAABMiZwkeAIAAEyJnCSAAgAATImcJIgCAABMiZwkkAIAAEyJnCSYAgAATImcJKACAABMiZwkqAIAAEyJnCSwAgAATImcJLgCAABMiZwkwAIAAEyJnCTIAgAATImcJNACAABMiZwk2AIAAEyJnCTgAgAATImcJOgCAABMiZwk8AIAAEyJnCT4AgAATImcJAADAABMiZwkCAMAAEyJnCQQAwAATImcJBgDAABMiZwkIAMAAEyJnCQoAwAATImcJDADAABMiZwkOAMAAEyJnCRAAwAATImcJEgDAABMiZwkUAMAAEyJnCRYAwAATImcJGADAABMiZwkaAMAAEyJnCRwAwAATImcJHgDAABMiZwkgAMAAEyJnCSIAwAATImcJJADAABMiZwkmAMAAEyJnCSgAwAATImcJKgDAABMiZwksAMAAEyJnCS4AwAATImcJMADAABMiZwkyAMAAEyJnCTQAwAATImcJNgDAABMiZwk4AMAAEyJnCToAwAATImcJPADAABMiZwk+AMAAEyJnCQABAAATImcJAgEAABMiZwkEAQAAEyJnCQYBAAATImcJCAEAABMiZwkKAQAAEyJnCQwBAAATImcJDgEAABMiZwkQAQAAEyJnCRIBAAATImcJFAEAABMiZwkWAQAAEyJnCRgBAAATImcJGgEAABMiZwkcAQAAEyJnCR4BAAATImcJIAEAABMiZwkiAQAAEyJnCSQBAAATImcJJgEAABMiZwkoAQAAEyJnCSoBAAATImcJLAEAABMiZwkuAQAAEyJnCTABAAATImcJMgEAABMiZwk0AQAAEyJnCTYBAAATImcJOAEAABMiZwk6AQAAEyJnCTwBAAATImcJPgEAABMiZwkAAUAAEyJnCQIBQAATImcJBAFAABMiZwkGAUAAEyJnCQgBQAATImcJCgFAABMiZwkMAUAAEyJnCQ4BQAATImcJEAFAABMiZwkSAUAAEyJnCRQBQAATImcJFgFAABMiZwkYAUAAEyJnCRoBQAATImcJHAFAABMiZwkeAUAAEyJnCSABQAATImcJIgFAABMiZwkkAUAAEyJnCSYBQAATImcJKAFAABMiZwkqAUAAEyJnCSwBQAATImcJLgFAABMiZwkwAUAAEyJnCTIBQAATImcJNAFAABMiZwk2AUAAEyJnCTgBQAATImcJOgFAABMiZwk8AUAAEyJnCT4BQAATImcJAAGAABMiZwkCAYAAEyJnCQQBgAATImcJBgGAABMiZwkIAYAAEyJnCQoBgAATImcJDAGAABMiZwkOAYAAEyJnCRABgAATImcJEgGAABMiZwkUAYAAEyJnCRYBgAATImcJGAGAABMiZwkaAYAAEyJnCRwBgAATImcJHgGAABMiZwkgAYAAEyJnCSIBgAATImcJJAGAABMiZwkmAYAAEyJnCSgBgAATImcJKgGAABMiZwksAYAAEyJnCS4BgAATImcJMAGAABMiZwkyAYAAEyJnCTQBgAATImcJNgGAABMiZwk4AYAAEyJnCToBgAATImcJPAGAABMiZwk+AYAAEyJnCQABwAATImcJAgHAABMiZwkEAcAAEyJnCQYBwAATImcJCAHAABMiZwkKAcAAEyJnCQwBwAATImcJDgHAABMiZwkQAcAAEyJnCRIBwAATImcJFAHAABMiZwkWAcAAEyJnCRgBwAATImcJGgHAABMiZwkcAcAAEyJnCR4BwAATImcJIAHAABMiZwkiAcAAEyJnCSQBwAATImcJJgHAABMiZwkoAcAAEyJnCSoBwAATImcJLAHAABMiZwkuAcAAEyJnCTABwAATImcJMgHAABMiZwk0AcAAEyJnCTYBwAATImcJOAHAABMiZwk6AcAAEyJnCTwBwAATImcJPgHAABMiZwkAAgAAEyJnCQICAAATImcJBAIAABMiZwkGAgAAEyJnCQgCAAATImcJCgIAABMiZwkMAgAAEyJnCQ4CAAATImcJEAIAABMiZwkSAgAAEyJnCRQCAAATImcJFgIAABMiZwkYAgAAEyJnCRoCAAATImcJHAIAABMiZwkeAgAAEyJnCSACAAATImcJIgIAABMiZwkkAgAAEyJnCSYCAAATImcJKAIAABMiZwkqAgAAEyJnCSwCAAATImcJLgIAABMiZwkwAgAAEyJnCTICAAATImcJNAIAABMiZwk2AgAAEyJnCTgCAAATImcJOgIAABMiZwk8AgAAEyJnCT4CAAATImcJAAJAABMiZwkCAkAAEyJnCQQCQAATImcJBgJAABMiZwkIAkAAEyJnCQoCQAATImcJDAJAABMiZwkOAkAAEyJnCRACQAATImcJEgJAABMiZwkUAkAAEyJnCRYCQAATImcJGAJAABMiZwkaAkAAEyJnCRwCQAATImcJHgJAABMiZwkgAkAAEyJnCSICQAATImcJJAJAABMiZwkmAkAAEyJnCSgCQAATImcJKgJAABMiZwksAkAAEyJnCS4CQAATImcJMAJAABMiZwkyAkAAEyJnCTQCQAATImcJNgJAABMiZwk4AkAAEyJnCToCQAATImcJPAJAABMiZwk+AkAAEyJnCQACgAATImcJAgKAABMiZwkEAoAAEyJnCQYCgAATImcJCAKAABMiZwkKAoAAEyJnCQwCgAATImcJDgKAABMiZwkQAoAAEyJnCRICgAATImcJFAKAABMiZwkWAoAAEyJnCRgCgAATImcJGgKAABMiZwkcAoAAEyJnCR4CgAATImcJIAKAABMiZwkiAoAAEyJnCSQCgAATImcJJgKAABMiZwkoAoAAEyJnCSoCgAATImcJLAKAABMiZwkuAoAAEyJnCTACgAATImcJMgKAABMiZwk0AoAAEyJnCTYCgAATImcJOAKAABMiZwk6AoAAEyJnCTwCgAATImcJPgKAABMiZwkAAsAAEyJnCQICwAATImcJBALAABMiZwkGAsAAEyJnCQgCwAATImcJCgLAABMiZwkMAsAAEyJnCQ4CwAATImcJEALAABMiZwkSAsAAEyJnCRQCwAATImcJFgLAABMiZwkYAsAAEyJnCRoCwAATImcJHALAABMiZwkeAsAAEyJnCSACwAATImcJIgLAABMiZwkkAsAAEyJnCSYCwAATImcJKALAABMiZwkqAsAAEyJnCSwCwAATImcJLgLAABMiZwkwAsAAEyJnCTICwAATImcJNALAABMiZwk2AsAAEyJnCTgCwAATImcJOgLAABMiZwk8AsAAEyJnCT4CwAATImcJAAMAABMiZwkCAwAAEyJnCQQDAAATImcJBgMAABMiZwkIAwAAEyJnCQoDAAATImcJDAMAABMiZwkOAwAAEyJnCRADAAATImcJEgMAABMiZwkUAwAAEyJnCRYDAAATImcJGAMAABMiZwkaAwAAEyJnCRwDAAATImcJHgMAABMiZwkgAwAAEiNpCSIDAAAww==" +.p2align 6"#, + vg_sm4_crypt_prepared = sym super::sm4::vg_sm4_crypt_prepared::vg_sm4_crypt_prepared, + ) +} diff --git a/crates/verified-garbage-asm-x86_64/src/triple_des_ofb.rs b/crates/verified-garbage-asm-x86_64/src/triple_des_ofb.rs index bc5446a05a6..3c001d6a3d6 100644 --- a/crates/verified-garbage-asm-x86_64/src/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/triple_des_ofb.rs @@ -32,3 +32,42 @@ jmp 21f vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, ) } + +/// Triple DES-OFB encryption or decryption (NIST SP 800-38A §6.4, FIPS 46-3) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 8, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is Triple DES encryption under the schedule written by `vg_triple_des_expand_key`. +/// +/// Contract: `VG.Spec.TripleDes.ofbFinalContract`. Constant time: only the pointers and `len` may affect timing, not the schedule, the chaining value or the data. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 384 bytes. +/// * `iv` must be valid for reads and writes of 8 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `iv` and `data` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv` and `data` may overlap the return address on the stack or the 984 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[unsafe(naked)] +pub unsafe extern "sysv64" fn vg_triple_des_ofb_final(schedule: *const [u8; 384], iv: *mut [u8; 8], data: *mut u8, len: usize) { + core::arch::naked_asm!( + r#".base64 "SI2kJDD8//9JieBJg8AITYnBSYmZiAMAAEmJqZADAABNiaGYAwAATYmpoAMAAE2JsagDAABNibmwAwAAZkwPbv5JidRJic1IiwdJiYEIAgAASItHCEmJgRACAABIi0cQSYmBGAIAAEiLRxhJiYEgAgAASItHIEmJgSgCAABIi0coSYmBMAIAAEiLRzBJiYE4AgAASItHOEmJgUACAABIi0dASYmBSAIAAEiLR0hJiYFQAgAASItHUEmJgVgCAABIi0dYSYmBYAIAAEiLR2BJiYFoAgAASItHaEmJgXACAABIi0dwSYmBeAIAAEiLR3hJiYGAAgAASIuHgAAAAEmJgYgCAABIi4eIAAAASYmBkAIAAEiLh5AAAABJiYGYAgAASIuHmAAAAEmJgaACAABIi4egAAAASYmBqAIAAEiLh6gAAABJiYGwAgAASIuHsAAAAEmJgbgCAABIi4e4AAAASYmBwAIAAEiLh8AAAABJiYHIAgAASIuHyAAAAEmJgdACAABIi4fQAAAASYmB2AIAAEiLh9gAAABJiYHgAgAASIuH4AAAAEmJgegCAABIi4foAAAASYmB8AIAAEiLh/AAAABJiYH4AgAASIuH+AAAAEmJgQADAABIi4cAAQAASYmBCAMAAEiLhwgBAABJiYEQAwAASIuHEAEAAEmJgRgDAABIi4cYAQAASYmBIAMAAEiLhyABAABJiYEoAwAASIuHKAEAAEmJgTADAABIi4cwAQAASYmBOAMAAEiLhzgBAABJiYFAAwAASIuHQAEAAEmJgUgDAABIi4dIAQAASYmBUAMAAEiLh1ABAABJiYFYAwAASIuHWAEAAEmJgWADAABIi4dgAQAASYmBaAMAAEiLh2gBAABJiYFwAwAASIuHcAEAAEmJgXgDAABIi4d4AQAASYmBgAMAAGZMD374SIsoSYmpAAIAAE2F7Q==" +je 20f +22: +.base64 "TInPSIHHCAIAAEyJzkiBxgACAABMico=" +call {vg_triple_des_encrypt_block} +.base64 "SYnRSYP9CA==" +jb 23f +.base64 "SYsEJEkzgQACAABJiQQkSYPECEmD7Qg=" +jmp 24f +23: +.base64 "TInISAUAAgAA" +25: +.base64 "RA+2EEEPtgwkTDHRQYgMJEiDwAFJg8QBSYPtAQ==" +jne 25b +24: +jne 22b +jmp 21f +20: +21: +.base64 "ZkwPfvhJi6kAAgAASIkoSYuZiAMAAEmLqZADAABNi6GYAwAATYupoAMAAE2LsagDAABNi7mwAwAAQbsAAAAATIlcJAhMiVwkEEyJXCQYTIlcJCBMiVwkKEyJXCQwTIlcJDhMiVwkQEyJXCRITIlcJFBMiVwkWEyJXCRgTIlcJGhMiVwkcEyJXCR4TImcJIAAAABMiZwkiAAAAEyJnCSQAAAATImcJJgAAABMiZwkoAAAAEyJnCSoAAAATImcJLAAAABMiZwkuAAAAEyJnCTAAAAATImcJMgAAABMiZwk0AAAAEyJnCTYAAAATImcJOAAAABMiZwk6AAAAEyJnCTwAAAATImcJPgAAABMiZwkAAEAAEyJnCQIAQAATImcJBABAABMiZwkGAEAAEyJnCQgAQAATImcJCgBAABMiZwkMAEAAEyJnCQ4AQAATImcJEABAABMiZwkSAEAAEyJnCRQAQAATImcJFgBAABMiZwkYAEAAEyJnCRoAQAATImcJHABAABMiZwkeAEAAEyJnCSAAQAATImcJIgBAABMiZwkkAEAAEyJnCSYAQAATImcJKABAABMiZwkqAEAAEyJnCSwAQAATImcJLgBAABMiZwkwAEAAEyJnCTIAQAATImcJNABAABMiZwk2AEAAEyJnCTgAQAATImcJOgBAABMiZwk8AEAAEyJnCT4AQAATImcJAACAABMiZwkCAIAAEyJnCQQAgAATImcJBgCAABMiZwkIAIAAEyJnCQoAgAATImcJDACAABMiZwkOAIAAEyJnCRAAgAATImcJEgCAABMiZwkUAIAAEyJnCRYAgAATImcJGACAABMiZwkaAIAAEyJnCRwAgAATImcJHgCAABMiZwkgAIAAEyJnCSIAgAATImcJJACAABMiZwkmAIAAEyJnCSgAgAATImcJKgCAABMiZwksAIAAEyJnCS4AgAATImcJMACAABMiZwkyAIAAEyJnCTQAgAATImcJNgCAABMiZwk4AIAAEyJnCToAgAATImcJPACAABMiZwk+AIAAEyJnCQAAwAATImcJAgDAABMiZwkEAMAAEyJnCQYAwAATImcJCADAABMiZwkKAMAAEyJnCQwAwAATImcJDgDAABMiZwkQAMAAEyJnCRIAwAATImcJFADAABMiZwkWAMAAEyJnCRgAwAATImcJGgDAABMiZwkcAMAAEyJnCR4AwAATImcJIADAABMiZwkiAMAAEyJnCSQAwAATImcJJgDAABMiZwkoAMAAEyJnCSoAwAATImcJLADAABMiZwkuAMAAEyJnCTAAwAATImcJMgDAABIjaQk0AMAAMM=" +.p2align 6"#, + vg_triple_des_encrypt_block = sym super::triple_des::vg_triple_des_encrypt_block::vg_triple_des_encrypt_block, + ) +} diff --git a/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean b/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean index 5a473d6808d..5e5737deb26 100644 --- a/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean +++ b/lean/VerifiedGarbage/Proof/Camellia/X86_64/CtrFinal.lean @@ -619,7 +619,7 @@ theorem tail_args_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KWhole s simp only [Spill.saveMem, zeroSlots, Spill.slot, Offset.add_add], z₂] exact AesCtr.X86_64.zero_bytes _ _ -theorem cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by +theorem ctr_cipher_length (sk : Spec.Camellia.Subkeys) (b : List Byte) : (Spec.Camellia.cipher sk b).length = 16 := by simp [Spec.Camellia.cipher] /-- What the call on the block leaves. -/ @@ -709,7 +709,7 @@ theorem tail_call_wp {s₀ : State} (hp : KPre s₀) {s : State} (h : KTArgs s · exact (hp.data_sv.sub_left (blk_sub s₀)).sub_right (blk_sv_sub s₀) · exact hp.stk_data.symm.sub_left (blk_sub s₀)] exact h.blocks - · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (cipher_length _) eZ pb + · exact Modes.CtrFinal.bytesAt_of_blocksAt_one (ctr_cipher_length _) eZ pb theorem key_load_wp {s₀ s : State} (h : KTCall s₀ s) : WP isa (.block ctrFinalLoad) s (Loaded (KTCall s₀) s₀) := WP.of_runBlock ⟨_, load_ok s, s, h, by rw [h.r15]⟩ @@ -876,7 +876,7 @@ theorem final_wp {s₀ : State} (hp : KPre s₀) : theorem final_post {s₀ s₁ s' : State} (h : KDone s₀ s₁) (hm : s'.mem = s₁.mem) : ctrFinalX86_64.post s₀ s' := by show Spec.Ctr.CryptFinal (kCiph s₀) s₀.mem s'.mem (fIv s₀) (fD s₀) (fL s₀) - exact Modes.CtrFinal.cryptFinal_of (cipher_length _) (by rw [hm]; exact h.blocks) + exact Modes.CtrFinal.cryptFinal_of (ctr_cipher_length _) (by rw [hm]; exact h.blocks) (fun q hq => by rw [hm]; exact h.tail q hq) (by rw [hm]; exact h.ctr) theorem ctrFinal_mx : ctrFinal.allInstrs (fun i => !loadsMxcsr i) = true := by lit_decide From 595e6e71bfa13802aef189071b5205e3106e8a80 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 14:36:03 +0000 Subject: [PATCH 18/18] Regenerate the dispatchers for the OFB and CTR final functions #4428 emits a dispatcher for every function's implementations; the final functions are new implementations of the OFB and CTR modules. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TKUFHGJJidJdRDMDSSd58W --- .../src/dispatch/aes_ctr.rs | 29 ++++++++++++++++ .../src/dispatch/aes_ofb.rs | 29 ++++++++++++++++ .../src/dispatch/blowfish_ofb.rs | 6 ++++ .../src/dispatch/camellia_ctr.rs | 6 ++++ .../src/dispatch/camellia_ofb.rs | 6 ++++ .../src/dispatch/cast5_ofb.rs | 6 ++++ .../src/dispatch/idea_ofb.rs | 6 ++++ .../src/dispatch/seed_ofb.rs | 6 ++++ .../src/dispatch/sm4_ctr.rs | 6 ++++ .../src/dispatch/sm4_ofb.rs | 6 ++++ .../src/dispatch/triple_des_ofb.rs | 6 ++++ .../src/dispatch/aes_ctr.rs | 6 ++++ .../src/dispatch/aes_ofb.rs | 6 ++++ .../src/dispatch/blowfish_ofb.rs | 6 ++++ .../src/dispatch/camellia_ctr.rs | 6 ++++ .../src/dispatch/camellia_ofb.rs | 6 ++++ .../src/dispatch/cast5_ofb.rs | 6 ++++ .../src/dispatch/idea_ofb.rs | 6 ++++ .../src/dispatch/seed_ofb.rs | 6 ++++ .../src/dispatch/sm4_ctr.rs | 6 ++++ .../src/dispatch/sm4_ofb.rs | 6 ++++ .../src/dispatch/triple_des_ofb.rs | 6 ++++ .../src/dispatch/aes_ctr.rs | 6 ++++ .../src/dispatch/aes_ofb.rs | 6 ++++ .../src/dispatch/blowfish_ofb.rs | 6 ++++ .../src/dispatch/camellia_ctr.rs | 6 ++++ .../src/dispatch/camellia_ofb.rs | 6 ++++ .../src/dispatch/cast5_ofb.rs | 6 ++++ .../src/dispatch/idea_ofb.rs | 6 ++++ .../src/dispatch/seed_ofb.rs | 6 ++++ .../src/dispatch/sm4_ctr.rs | 6 ++++ .../src/dispatch/sm4_ofb.rs | 6 ++++ .../src/dispatch/triple_des_ofb.rs | 6 ++++ .../src/dispatch/aes_ctr.rs | 6 ++++ .../src/dispatch/aes_ofb.rs | 6 ++++ .../src/dispatch/blowfish_ofb.rs | 6 ++++ .../src/dispatch/camellia_ctr.rs | 6 ++++ .../src/dispatch/camellia_ofb.rs | 6 ++++ .../src/dispatch/cast5_ofb.rs | 6 ++++ .../src/dispatch/idea_ofb.rs | 6 ++++ .../src/dispatch/seed_ofb.rs | 6 ++++ .../src/dispatch/sm4_ctr.rs | 6 ++++ .../src/dispatch/sm4_ofb.rs | 6 ++++ .../src/dispatch/triple_des_ofb.rs | 6 ++++ .../src/dispatch/aes_ctr.rs | 29 ++++++++++++++++ .../src/dispatch/aes_ofb.rs | 29 ++++++++++++++++ .../src/dispatch/blowfish_ofb.rs | 6 ++++ .../src/dispatch/camellia_ctr.rs | 6 ++++ .../src/dispatch/camellia_ofb.rs | 6 ++++ .../src/dispatch/cast5_ofb.rs | 6 ++++ .../src/dispatch/idea_ofb.rs | 6 ++++ .../src/dispatch/seed_ofb.rs | 6 ++++ .../src/dispatch/sm4_ctr.rs | 6 ++++ .../src/dispatch/sm4_ofb.rs | 6 ++++ .../src/dispatch/triple_des_ofb.rs | 6 ++++ .../src/dispatch/aes_ctr.rs | 34 +++++++++++++++++++ .../src/dispatch/aes_ofb.rs | 34 +++++++++++++++++++ .../src/dispatch/blowfish_ofb.rs | 6 ++++ .../src/dispatch/camellia_ctr.rs | 6 ++++ .../src/dispatch/camellia_ofb.rs | 6 ++++ .../src/dispatch/cast5_ofb.rs | 6 ++++ .../src/dispatch/idea_ofb.rs | 6 ++++ .../src/dispatch/seed_ofb.rs | 6 ++++ .../src/dispatch/sm4_ctr.rs | 6 ++++ .../src/dispatch/sm4_ofb.rs | 6 ++++ .../src/dispatch/triple_des_ofb.rs | 6 ++++ 66 files changed, 544 insertions(+) diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ctr.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ctr.rs index 3da098ad909..ce996806b2c 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ctr.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ctr.rs @@ -30,3 +30,32 @@ pub unsafe fn vg_aes_ctr_auto(schedule: *const [u8; 240], rounds: usize, ctr: *m // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. unsafe { crate::aes_ctr::vg_aes_ctr(schedule, rounds, ctr, data, n, scratch) } } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ctr_final_aes` if the CPU supports its features (`VG_AES_CTR_FINAL_AES_FEATURES`); or else `vg_aes_ctr_final`, which needs no CPU feature. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the 80 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[allow(clippy::too_many_arguments)] +#[inline] +pub unsafe fn vg_aes_ctr_final_auto(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + let cpu = verified_garbage_cpu::detected(); + if cpu.contains(crate::aes_ctr::VG_AES_CTR_FINAL_AES_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ctr_final_aes`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ctr::vg_aes_ctr_final_aes(schedule, rounds, ctr, data, len, scratch) }; + } + // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. + unsafe { crate::aes_ctr::vg_aes_ctr_final(schedule, rounds, ctr, data, len, scratch) } +} diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ofb.rs index a22c2893302..3157f9d3da5 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/aes_ofb.rs @@ -30,3 +30,32 @@ pub unsafe fn vg_aes_ofb_auto(schedule: *const [u8; 240], rounds: usize, iv: *mu // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. unsafe { crate::aes_ofb::vg_aes_ofb(schedule, rounds, iv, data, n, scratch) } } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ofb_final_aes` if the CPU supports its features (`VG_AES_OFB_FINAL_AES_FEATURES`); or else `vg_aes_ofb_final`, which needs no CPU feature. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the 64 bytes of stack below the stack pointer, or wrap around the end of the address space (no Rust object does). +#[allow(clippy::too_many_arguments)] +#[inline] +pub unsafe fn vg_aes_ofb_final_auto(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + let cpu = verified_garbage_cpu::detected(); + if cpu.contains(crate::aes_ofb::VG_AES_OFB_FINAL_AES_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ofb_final_aes`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ofb::vg_aes_ofb_final_aes(schedule, rounds, iv, data, len, scratch) }; + } + // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. + unsafe { crate::aes_ofb::vg_aes_ofb_final(schedule, rounds, iv, data, len, scratch) } +} diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/blowfish_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/blowfish_ofb.rs index 062e688dc54..2bf3c6d8e2a 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/blowfish_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::blowfish_ofb::vg_blowfish_ofb as vg_blowfish_ofb_auto; + +/// `vg_blowfish_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::blowfish_ofb::vg_blowfish_ofb_final as vg_blowfish_ofb_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ctr.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ctr.rs index 238a96d3dd2..d6d45504e65 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ctr.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ctr::vg_camellia_ctr as vg_camellia_ctr_auto; + +/// `vg_camellia_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ctr::vg_camellia_ctr_final as vg_camellia_ctr_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ofb.rs index b96cda3d3ce..b74941cc2de 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/camellia_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ofb::vg_camellia_ofb as vg_camellia_ofb_auto; + +/// `vg_camellia_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ofb::vg_camellia_ofb_final as vg_camellia_ofb_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/cast5_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/cast5_ofb.rs index b781e6274d2..6126a72bde3 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/cast5_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/cast5_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::cast5_ofb::vg_cast5_ofb as vg_cast5_ofb_auto; + +/// `vg_cast5_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::cast5_ofb::vg_cast5_ofb_final as vg_cast5_ofb_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/idea_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/idea_ofb.rs index 678c81a8082..2f29bad0235 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/idea_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/idea_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::idea_ofb::vg_idea_ofb as vg_idea_ofb_auto; + +/// `vg_idea_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::idea_ofb::vg_idea_ofb_final as vg_idea_ofb_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/seed_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/seed_ofb.rs index 917cbde1a0f..032acfdc4c7 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/seed_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/seed_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::seed_ofb::vg_seed_ofb as vg_seed_ofb_auto; + +/// `vg_seed_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::seed_ofb::vg_seed_ofb_final as vg_seed_ofb_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ctr.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ctr.rs index cfc3ba796f6..e4e28aa72e2 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ctr.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ctr::vg_sm4_ctr as vg_sm4_ctr_auto; + +/// `vg_sm4_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ctr::vg_sm4_ctr_final as vg_sm4_ctr_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ofb.rs index ff59c59232b..9d7901eea69 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/sm4_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ofb::vg_sm4_ofb as vg_sm4_ofb_auto; + +/// `vg_sm4_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ofb::vg_sm4_ofb_final as vg_sm4_ofb_final_auto; diff --git a/crates/verified-garbage-asm-aarch64/src/dispatch/triple_des_ofb.rs b/crates/verified-garbage-asm-aarch64/src/dispatch/triple_des_ofb.rs index 2ab70ba1d6a..1c84e6f1ccf 100644 --- a/crates/verified-garbage-asm-aarch64/src/dispatch/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-aarch64/src/dispatch/triple_des_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::triple_des_ofb::vg_triple_des_ofb as vg_triple_des_ofb_auto; + +/// `vg_triple_des_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::triple_des_ofb::vg_triple_des_ofb_final as vg_triple_des_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/aes_ctr.rs b/crates/verified-garbage-asm-arm/src/dispatch/aes_ctr.rs index d0caa9c9329..3a7b1615a8f 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/aes_ctr.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/aes_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::aes_ctr::vg_aes_ctr as vg_aes_ctr_auto; + +/// `vg_aes_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::aes_ctr::vg_aes_ctr_final as vg_aes_ctr_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/aes_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/aes_ofb.rs index 7e6a624c4e3..d8c7daed509 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/aes_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/aes_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::aes_ofb::vg_aes_ofb as vg_aes_ofb_auto; + +/// `vg_aes_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::aes_ofb::vg_aes_ofb_final as vg_aes_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/blowfish_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/blowfish_ofb.rs index a6a1a92ecb9..a411ca72023 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/blowfish_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::blowfish_ofb::vg_blowfish_ofb as vg_blowfish_ofb_auto; + +/// `vg_blowfish_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::blowfish_ofb::vg_blowfish_ofb_final as vg_blowfish_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/camellia_ctr.rs b/crates/verified-garbage-asm-arm/src/dispatch/camellia_ctr.rs index 949e6d66b1a..fd7cbbe2cfd 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/camellia_ctr.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/camellia_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ctr::vg_camellia_ctr as vg_camellia_ctr_auto; + +/// `vg_camellia_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ctr::vg_camellia_ctr_final as vg_camellia_ctr_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/camellia_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/camellia_ofb.rs index 7bba10407e6..c1909d0587f 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/camellia_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/camellia_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ofb::vg_camellia_ofb as vg_camellia_ofb_auto; + +/// `vg_camellia_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ofb::vg_camellia_ofb_final as vg_camellia_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/cast5_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/cast5_ofb.rs index e7d06cf0f50..f4b31683fc7 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/cast5_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/cast5_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::cast5_ofb::vg_cast5_ofb as vg_cast5_ofb_auto; + +/// `vg_cast5_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::cast5_ofb::vg_cast5_ofb_final as vg_cast5_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/idea_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/idea_ofb.rs index dbf513d1417..be32fe60af4 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/idea_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/idea_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::idea_ofb::vg_idea_ofb as vg_idea_ofb_auto; + +/// `vg_idea_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::idea_ofb::vg_idea_ofb_final as vg_idea_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/seed_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/seed_ofb.rs index a1327718bdf..fae1c0681e9 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/seed_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/seed_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::seed_ofb::vg_seed_ofb as vg_seed_ofb_auto; + +/// `vg_seed_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::seed_ofb::vg_seed_ofb_final as vg_seed_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/sm4_ctr.rs b/crates/verified-garbage-asm-arm/src/dispatch/sm4_ctr.rs index a2155fe86c4..8c694b5bbe2 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/sm4_ctr.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/sm4_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ctr::vg_sm4_ctr as vg_sm4_ctr_auto; + +/// `vg_sm4_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ctr::vg_sm4_ctr_final as vg_sm4_ctr_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/sm4_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/sm4_ofb.rs index e105ca1b04c..5f59aa94708 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/sm4_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/sm4_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ofb::vg_sm4_ofb as vg_sm4_ofb_auto; + +/// `vg_sm4_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ofb::vg_sm4_ofb_final as vg_sm4_ofb_final_auto; diff --git a/crates/verified-garbage-asm-arm/src/dispatch/triple_des_ofb.rs b/crates/verified-garbage-asm-arm/src/dispatch/triple_des_ofb.rs index e7ff86e8b69..d4f7eec2c2c 100644 --- a/crates/verified-garbage-asm-arm/src/dispatch/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-arm/src/dispatch/triple_des_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::triple_des_ofb::vg_triple_des_ofb as vg_triple_des_ofb_auto; + +/// `vg_triple_des_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::triple_des_ofb::vg_triple_des_ofb_final as vg_triple_des_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ctr.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ctr.rs index 9f6c925579b..f95ee1e576d 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ctr.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::aes_ctr::vg_aes_ctr as vg_aes_ctr_auto; + +/// `vg_aes_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::aes_ctr::vg_aes_ctr_final as vg_aes_ctr_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ofb.rs index 46121a351cb..c8f458fce99 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/aes_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::aes_ofb::vg_aes_ofb as vg_aes_ofb_auto; + +/// `vg_aes_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::aes_ofb::vg_aes_ofb_final as vg_aes_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/blowfish_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/blowfish_ofb.rs index 43ed4c1c1d9..6da29f8016b 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/blowfish_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::blowfish_ofb::vg_blowfish_ofb as vg_blowfish_ofb_auto; + +/// `vg_blowfish_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::blowfish_ofb::vg_blowfish_ofb_final as vg_blowfish_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ctr.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ctr.rs index 9a330b0008c..db36e8a5e3d 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ctr.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ctr::vg_camellia_ctr as vg_camellia_ctr_auto; + +/// `vg_camellia_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ctr::vg_camellia_ctr_final as vg_camellia_ctr_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ofb.rs index e72eddee1b0..7b773d6917d 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/camellia_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ofb::vg_camellia_ofb as vg_camellia_ofb_auto; + +/// `vg_camellia_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ofb::vg_camellia_ofb_final as vg_camellia_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/cast5_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/cast5_ofb.rs index e3990dc4b53..a26a1211cea 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/cast5_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/cast5_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::cast5_ofb::vg_cast5_ofb as vg_cast5_ofb_auto; + +/// `vg_cast5_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::cast5_ofb::vg_cast5_ofb_final as vg_cast5_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/idea_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/idea_ofb.rs index 7524e016a06..582b760d233 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/idea_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/idea_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::idea_ofb::vg_idea_ofb as vg_idea_ofb_auto; + +/// `vg_idea_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::idea_ofb::vg_idea_ofb_final as vg_idea_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/seed_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/seed_ofb.rs index 2cd972b16bf..c81ea866ce6 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/seed_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/seed_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::seed_ofb::vg_seed_ofb as vg_seed_ofb_auto; + +/// `vg_seed_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::seed_ofb::vg_seed_ofb_final as vg_seed_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ctr.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ctr.rs index 5e05e19e6ce..ed17b669804 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ctr.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ctr::vg_sm4_ctr as vg_sm4_ctr_auto; + +/// `vg_sm4_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ctr::vg_sm4_ctr_final as vg_sm4_ctr_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ofb.rs index e40e75661d7..41fa366c60b 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/sm4_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ofb::vg_sm4_ofb as vg_sm4_ofb_auto; + +/// `vg_sm4_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ofb::vg_sm4_ofb_final as vg_sm4_ofb_final_auto; diff --git a/crates/verified-garbage-asm-powerpc64le/src/dispatch/triple_des_ofb.rs b/crates/verified-garbage-asm-powerpc64le/src/dispatch/triple_des_ofb.rs index 4ec4cadbbc1..52ea0be5fcc 100644 --- a/crates/verified-garbage-asm-powerpc64le/src/dispatch/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-powerpc64le/src/dispatch/triple_des_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::triple_des_ofb::vg_triple_des_ofb as vg_triple_des_ofb_auto; + +/// `vg_triple_des_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::triple_des_ofb::vg_triple_des_ofb_final as vg_triple_des_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ctr.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ctr.rs index 058cedd35c7..5df55f3fece 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ctr.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::aes_ctr::vg_aes_ctr as vg_aes_ctr_auto; + +/// `vg_aes_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::aes_ctr::vg_aes_ctr_final as vg_aes_ctr_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ofb.rs index 31e97d6863b..155b7dd25fc 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/aes_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::aes_ofb::vg_aes_ofb as vg_aes_ofb_auto; + +/// `vg_aes_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::aes_ofb::vg_aes_ofb_final as vg_aes_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/blowfish_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/blowfish_ofb.rs index 755662221d2..cfaa4ad0d50 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/blowfish_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::blowfish_ofb::vg_blowfish_ofb as vg_blowfish_ofb_auto; + +/// `vg_blowfish_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::blowfish_ofb::vg_blowfish_ofb_final as vg_blowfish_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ctr.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ctr.rs index 43fc410fc3a..cc979acf511 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ctr.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ctr::vg_camellia_ctr as vg_camellia_ctr_auto; + +/// `vg_camellia_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ctr::vg_camellia_ctr_final as vg_camellia_ctr_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ofb.rs index 0a4f02cf39c..18f853e2064 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/camellia_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ofb::vg_camellia_ofb as vg_camellia_ofb_auto; + +/// `vg_camellia_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ofb::vg_camellia_ofb_final as vg_camellia_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/cast5_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/cast5_ofb.rs index fed251b14c6..fc99a24aacc 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/cast5_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/cast5_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::cast5_ofb::vg_cast5_ofb as vg_cast5_ofb_auto; + +/// `vg_cast5_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::cast5_ofb::vg_cast5_ofb_final as vg_cast5_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/idea_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/idea_ofb.rs index d2ad19ddd8d..766704eb479 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/idea_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/idea_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::idea_ofb::vg_idea_ofb as vg_idea_ofb_auto; + +/// `vg_idea_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::idea_ofb::vg_idea_ofb_final as vg_idea_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/seed_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/seed_ofb.rs index 86e858119f9..bc8efb0ce80 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/seed_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/seed_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::seed_ofb::vg_seed_ofb as vg_seed_ofb_auto; + +/// `vg_seed_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::seed_ofb::vg_seed_ofb_final as vg_seed_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ctr.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ctr.rs index 458b8802d4c..30ed7206657 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ctr.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ctr::vg_sm4_ctr as vg_sm4_ctr_auto; + +/// `vg_sm4_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ctr::vg_sm4_ctr_final as vg_sm4_ctr_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ofb.rs index 71709532f90..bdbe77980bb 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/sm4_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ofb::vg_sm4_ofb as vg_sm4_ofb_auto; + +/// `vg_sm4_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ofb::vg_sm4_ofb_final as vg_sm4_ofb_final_auto; diff --git a/crates/verified-garbage-asm-riscv64/src/dispatch/triple_des_ofb.rs b/crates/verified-garbage-asm-riscv64/src/dispatch/triple_des_ofb.rs index 7eeef4a6384..f184eee726a 100644 --- a/crates/verified-garbage-asm-riscv64/src/dispatch/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-riscv64/src/dispatch/triple_des_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::triple_des_ofb::vg_triple_des_ofb as vg_triple_des_ofb_auto; + +/// `vg_triple_des_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::triple_des_ofb::vg_triple_des_ofb_final as vg_triple_des_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/aes_ctr.rs b/crates/verified-garbage-asm-x86/src/dispatch/aes_ctr.rs index 7c3a2994c43..4e4f3708af1 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/aes_ctr.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/aes_ctr.rs @@ -30,3 +30,32 @@ pub unsafe fn vg_aes_ctr_auto(schedule: *const [u8; 240], rounds: usize, ctr: *m // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. unsafe { crate::aes_ctr::vg_aes_ctr(schedule, rounds, ctr, data, n, scratch) } } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ctr_final_aesni` if the CPU supports its features (`VG_AES_CTR_FINAL_AESNI_FEATURES`); or else `vg_aes_ctr_final`, which needs no CPU feature. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 116 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[allow(clippy::too_many_arguments)] +#[inline] +pub unsafe fn vg_aes_ctr_final_auto(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + let cpu = verified_garbage_cpu::detected(); + if cpu.contains(crate::aes_ctr::VG_AES_CTR_FINAL_AESNI_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ctr_final_aesni`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ctr::vg_aes_ctr_final_aesni(schedule, rounds, ctr, data, len, scratch) }; + } + // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. + unsafe { crate::aes_ctr::vg_aes_ctr_final(schedule, rounds, ctr, data, len, scratch) } +} diff --git a/crates/verified-garbage-asm-x86/src/dispatch/aes_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/aes_ofb.rs index f6f480c8610..8cc4c9cae16 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/aes_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/aes_ofb.rs @@ -30,3 +30,32 @@ pub unsafe fn vg_aes_ofb_auto(schedule: *const [u8; 240], rounds: usize, iv: *mu // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. unsafe { crate::aes_ofb::vg_aes_ofb(schedule, rounds, iv, data, n, scratch) } } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ofb_final_aesni` if the CPU supports its features (`VG_AES_OFB_FINAL_AESNI_FEATURES`); or else `vg_aes_ofb_final`, which needs no CPU feature. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other, `schedule` or the arguments on the stack (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 100 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[allow(clippy::too_many_arguments)] +#[inline] +pub unsafe fn vg_aes_ofb_final_auto(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + let cpu = verified_garbage_cpu::detected(); + if cpu.contains(crate::aes_ofb::VG_AES_OFB_FINAL_AESNI_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ofb_final_aesni`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ofb::vg_aes_ofb_final_aesni(schedule, rounds, iv, data, len, scratch) }; + } + // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. + unsafe { crate::aes_ofb::vg_aes_ofb_final(schedule, rounds, iv, data, len, scratch) } +} diff --git a/crates/verified-garbage-asm-x86/src/dispatch/blowfish_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/blowfish_ofb.rs index b6abdca2646..bbc3c1cd037 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/blowfish_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::blowfish_ofb::vg_blowfish_ofb as vg_blowfish_ofb_auto; + +/// `vg_blowfish_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::blowfish_ofb::vg_blowfish_ofb_final as vg_blowfish_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/camellia_ctr.rs b/crates/verified-garbage-asm-x86/src/dispatch/camellia_ctr.rs index 72138ef6a54..a5ca4425a31 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/camellia_ctr.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/camellia_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ctr::vg_camellia_ctr as vg_camellia_ctr_auto; + +/// `vg_camellia_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ctr::vg_camellia_ctr_final as vg_camellia_ctr_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/camellia_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/camellia_ofb.rs index 857260bda42..1e83c004474 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/camellia_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/camellia_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ofb::vg_camellia_ofb as vg_camellia_ofb_auto; + +/// `vg_camellia_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ofb::vg_camellia_ofb_final as vg_camellia_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/cast5_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/cast5_ofb.rs index fca48644ad8..005875015c9 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/cast5_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/cast5_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::cast5_ofb::vg_cast5_ofb as vg_cast5_ofb_auto; + +/// `vg_cast5_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::cast5_ofb::vg_cast5_ofb_final as vg_cast5_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/idea_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/idea_ofb.rs index 0fee1b849a5..ede5adebbf9 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/idea_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/idea_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::idea_ofb::vg_idea_ofb as vg_idea_ofb_auto; + +/// `vg_idea_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::idea_ofb::vg_idea_ofb_final as vg_idea_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/seed_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/seed_ofb.rs index 1b53e71ce24..ceae0c3cc0e 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/seed_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/seed_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::seed_ofb::vg_seed_ofb as vg_seed_ofb_auto; + +/// `vg_seed_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::seed_ofb::vg_seed_ofb_final as vg_seed_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/sm4_ctr.rs b/crates/verified-garbage-asm-x86/src/dispatch/sm4_ctr.rs index 487d72146c7..34bd81ec78e 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/sm4_ctr.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/sm4_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ctr::vg_sm4_ctr as vg_sm4_ctr_auto; + +/// `vg_sm4_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ctr::vg_sm4_ctr_final as vg_sm4_ctr_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/sm4_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/sm4_ofb.rs index e054c1e551f..98f2ea0e792 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/sm4_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/sm4_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ofb::vg_sm4_ofb as vg_sm4_ofb_auto; + +/// `vg_sm4_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ofb::vg_sm4_ofb_final as vg_sm4_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86/src/dispatch/triple_des_ofb.rs b/crates/verified-garbage-asm-x86/src/dispatch/triple_des_ofb.rs index 6439b82df86..c5c80207dc1 100644 --- a/crates/verified-garbage-asm-x86/src/dispatch/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-x86/src/dispatch/triple_des_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::triple_des_ofb::vg_triple_des_ofb as vg_triple_des_ofb_auto; + +/// `vg_triple_des_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::triple_des_ofb::vg_triple_des_ofb_final as vg_triple_des_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ctr.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ctr.rs index 0ff6b7216b3..c25d9db6faa 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ctr.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ctr.rs @@ -35,3 +35,37 @@ pub unsafe fn vg_aes_ctr_auto(schedule: *const [u8; 240], rounds: usize, ctr: *m // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. unsafe { crate::aes_ctr::vg_aes_ctr(schedule, rounds, ctr, data, n, scratch) } } + +/// AES-CTR encryption or decryption (NIST SP 800-38A §6.5) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Tⱼ)`, where `T₁` is the block at `*ctr` and `Tⱼ₊₁ = Tⱼ + 1 mod 2¹²⁸` (Appendix B.1's standard incrementing function on the whole block, read as a big-endian integer), a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*ctr` with `Tₙ₊₁` (leaving it unchanged if `len = 0`), so that a further call continues the message if `len` is a multiple of 16; after a partial last block the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ctr.aesFinalContract`. Constant time: only the pointers, `rounds`, `len` and the last four bytes of `*ctr` (the 32-bit counter, public in OpenSSL, BoringSSL and AWS-LC, which split the blocks where it wraps) may affect timing, not the key schedule, the rest of the counter block or the data. +/// +/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ctr_final_vaes` if the CPU supports its features (`VG_AES_CTR_FINAL_VAES_FEATURES`); `vg_aes_ctr_final_aesni` if the CPU supports its features (`VG_AES_CTR_FINAL_AESNI_FEATURES`); or else `vg_aes_ctr_final`, which needs no CPU feature. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `ctr` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `ctr`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `ctr`, `data` and `scratch` may overlap the return address on the stack or the 96 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[allow(clippy::too_many_arguments)] +#[inline] +pub unsafe fn vg_aes_ctr_final_auto(schedule: *const [u8; 240], rounds: usize, ctr: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + let cpu = verified_garbage_cpu::detected(); + if cpu.contains(crate::aes_ctr::VG_AES_CTR_FINAL_VAES_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ctr_final_vaes`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ctr::vg_aes_ctr_final_vaes(schedule, rounds, ctr, data, len, scratch) }; + } + if cpu.contains(crate::aes_ctr::VG_AES_CTR_FINAL_AESNI_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ctr_final_aesni`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ctr::vg_aes_ctr_final_aesni(schedule, rounds, ctr, data, len, scratch) }; + } + // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. + unsafe { crate::aes_ctr::vg_aes_ctr_final(schedule, rounds, ctr, data, len, scratch) } +} diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ofb.rs index c3554e2ed8a..5b56b468f83 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/aes_ofb.rs @@ -35,3 +35,37 @@ pub unsafe fn vg_aes_ofb_auto(schedule: *const [u8; 240], rounds: usize, iv: *mu // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. unsafe { crate::aes_ofb::vg_aes_ofb(schedule, rounds, iv, data, n, scratch) } } + +/// AES-OFB encryption or decryption (NIST SP 800-38A §6.4) of the last piece of a message, of any length, in place: XORs the `len` bytes at `data` with the output blocks `Oⱼ = CIPH_K(Oⱼ₋₁)`, where `O₀` is the block at `*iv`, a partial last block `Pₙ*` of `u` bytes with `MSB_u(Oₙ)`, and replaces `*iv` with the last output block used, `Oₙ` (leaving it unchanged if `len = 0`): so that a further call continues the message if `len` is a multiple of 16, and otherwise keystream, to be wiped, after which the message must end. `CIPH_K` is AES (FIPS 197) with `rounds` rounds and the key schedule in the first `16 * (rounds + 1)` bytes of `*schedule`, as `vg_aes_expand_key` writes it. +/// +/// Contract: `VG.Spec.Ofb.aesFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data. +/// +/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ofb_final_vaes` if the CPU supports its features (`VG_AES_OFB_FINAL_VAES_FEATURES`); `vg_aes_ofb_final_aesni` if the CPU supports its features (`VG_AES_OFB_FINAL_AESNI_FEATURES`); or else `vg_aes_ofb_final`, which needs no CPU feature. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes. +/// +/// # Safety +/// +/// * `schedule` must be valid for reads of 240 bytes. +/// * `iv` must be valid for reads and writes of 16 bytes. +/// * `data` must be valid for reads and writes of `len` bytes. +/// * `scratch` must be valid for reads and writes of 2176 bytes. +/// * `rounds` must be 10, 12 or 14. +/// * The contents of `scratch` on return are unspecified. +/// * `iv`, `data` and `scratch` must not overlap each other or `schedule` (distinct Rust objects never do). +/// * None of `schedule`, `iv`, `data` and `scratch` may overlap the return address on the stack or the 80 bytes of stack below it, or wrap around the end of the address space (no Rust object does). +#[allow(clippy::too_many_arguments)] +#[inline] +pub unsafe fn vg_aes_ofb_final_auto(schedule: *const [u8; 240], rounds: usize, iv: *mut [u8; 16], data: *mut u8, len: usize, scratch: *mut [u64; 272]) { + let cpu = verified_garbage_cpu::detected(); + if cpu.contains(crate::aes_ofb::VG_AES_OFB_FINAL_VAES_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ofb_final_vaes`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ofb::vg_aes_ofb_final_vaes(schedule, rounds, iv, data, len, scratch) }; + } + if cpu.contains(crate::aes_ofb::VG_AES_OFB_FINAL_AESNI_FEATURES) { + // SAFETY: the caller's obligations, which are `vg_aes_ofb_final_aesni`'s, and the CPU + // has the features it needs. + return unsafe { crate::aes_ofb::vg_aes_ofb_final_aesni(schedule, rounds, iv, data, len, scratch) }; + } + // SAFETY: the caller's obligations, which are the base's; it needs no CPU feature. + unsafe { crate::aes_ofb::vg_aes_ofb_final(schedule, rounds, iv, data, len, scratch) } +} diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/blowfish_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/blowfish_ofb.rs index f7671250c4f..c2a3f6caa10 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/blowfish_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/blowfish_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::blowfish_ofb::vg_blowfish_ofb as vg_blowfish_ofb_auto; + +/// `vg_blowfish_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::blowfish_ofb::vg_blowfish_ofb_final as vg_blowfish_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ctr.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ctr.rs index 0d51aaee796..901c800feff 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ctr.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ctr::vg_camellia_ctr as vg_camellia_ctr_auto; + +/// `vg_camellia_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ctr::vg_camellia_ctr_final as vg_camellia_ctr_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ofb.rs index 1c2caa59484..521cf7a6a34 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/camellia_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::camellia_ofb::vg_camellia_ofb as vg_camellia_ofb_auto; + +/// `vg_camellia_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::camellia_ofb::vg_camellia_ofb_final as vg_camellia_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/cast5_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/cast5_ofb.rs index ee344f86399..e598ad8379f 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/cast5_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/cast5_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::cast5_ofb::vg_cast5_ofb as vg_cast5_ofb_auto; + +/// `vg_cast5_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::cast5_ofb::vg_cast5_ofb_final as vg_cast5_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/idea_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/idea_ofb.rs index 9c776544071..bb1650cfc4c 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/idea_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/idea_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::idea_ofb::vg_idea_ofb as vg_idea_ofb_auto; + +/// `vg_idea_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::idea_ofb::vg_idea_ofb_final as vg_idea_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/seed_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/seed_ofb.rs index 3b6f8a28fd7..343b37eaedb 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/seed_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/seed_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::seed_ofb::vg_seed_ofb as vg_seed_ofb_auto; + +/// `vg_seed_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::seed_ofb::vg_seed_ofb_final as vg_seed_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ctr.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ctr.rs index 11af0088a4a..d03f4a86c64 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ctr.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ctr.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ctr::vg_sm4_ctr as vg_sm4_ctr_auto; + +/// `vg_sm4_ctr_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ctr::vg_sm4_ctr_final as vg_sm4_ctr_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ofb.rs index cc06b36774a..ba3c82d28b3 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/sm4_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::sm4_ofb::vg_sm4_ofb as vg_sm4_ofb_auto; + +/// `vg_sm4_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::sm4_ofb::vg_sm4_ofb_final as vg_sm4_ofb_final_auto; diff --git a/crates/verified-garbage-asm-x86_64/src/dispatch/triple_des_ofb.rs b/crates/verified-garbage-asm-x86_64/src/dispatch/triple_des_ofb.rs index edbeff39553..96c75f1e523 100644 --- a/crates/verified-garbage-asm-x86_64/src/dispatch/triple_des_ofb.rs +++ b/crates/verified-garbage-asm-x86_64/src/dispatch/triple_des_ofb.rs @@ -7,3 +7,9 @@ /// target. #[allow(unused_imports)] pub use crate::triple_des_ofb::vg_triple_des_ofb as vg_triple_des_ofb_auto; + +/// `vg_triple_des_ofb_final`, the only implementation of it on this target, which needs no CPU feature +/// (`VG.Rust.Group`): another name of it, so that the code calling it is the same on every +/// target. +#[allow(unused_imports)] +pub use crate::triple_des_ofb::vg_triple_des_ofb_final as vg_triple_des_ofb_final_auto;