added dsrd implementation of first half of blocks poly1305_svp64
authorSadoon Albader <sadoon@albader.co>
Tue, 9 Jan 2024 16:34:53 +0000 (19:34 +0300)
committerSadoon Albader <sadoon@albader.co>
Tue, 9 Jan 2024 16:34:53 +0000 (19:34 +0300)
crypto/poly1305/poly1305-donna-test.py

index 999d9a04e1a74e158ef3a6f09c6de753cf77d809..2637b188cd0d67b6b22b81e930d9af0dc746fba0 100644 (file)
@@ -238,6 +238,31 @@ class Poly1305Donna(object):
             lst = list(lst)
             final_regs = simulation_svp(lst, initial_regs)
 
+            initial_regs = [0] * 32
+            initial_regs[0] = t0
+            initial_regs[1] = t1
+            initial_regs[2] = 20
+            initial_regs[3] = 24
+            initial_regs[4] = 44
+            initial_regs[5] = hibit
+            initial_regs[20] = h2
+            initial_regs[21] = h1
+            initial_regs[22] = h0
+
+            # Syntax : dsrd RT,RA,RB,RC
+            # or RT,RC = DSRD(RA,RB)
+            lst = SVP64Asm([
+                    'dsrd 11, 1, 3, 12',
+                    'dsrd 6, 0, 4, 13',
+                    'setvl 0, 0, 2, 0, 1, 1',
+                    'sv.rldicl *12, *12, %d, 20' %(64-20),
+                    'sv.or *11, *11, *5',
+                    'setvl 0, 0, 3, 0, 1, 1',
+                    'sv.add *20, *20, *11'
+                    ])
+            lst = list(lst)
+            final_regs_dsrd = simulation_svp(lst, initial_regs)
+
             h0 += t0 & 0xfffffffffff;
             h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
             h2 += (((t1 >> 24)             ) & 0x3ffffffffff) | hibit;
@@ -246,6 +271,10 @@ class Poly1305Donna(object):
             assert (h1 == final_regs[4].value), "h1 and h1_sim are uneqaul!"
             assert (h2 == final_regs[5].value), "h2 and h2_sim are unequal!"
 
+            assert (h0 == final_regs_dsrd[22].value), "h0 and h0_dsrd are unequal!"
+            assert (h1 == final_regs_dsrd[21].value), "h1 and h1_dsrd are uneqaul!"
+            assert (h2 == final_regs_dsrd[20].value), "h2 and h2_dsrd are unequal!"
+
             print("    loop h+t %x %x %x" % (h0, h1, h2))
 
             #/* h *= r */