# [Libre-soc-bugs] [Bug 1157] Implement poly1305

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri Nov 17 23:53:45 GMT 2023

```https://bugs.libre-soc.org/show_bug.cgi?id=1157

--- Comment #34 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
> (In reply to Luke Kenneth Casson Leighton from comment #3)
> > what you can do is:
> >
> > * 2 regs with consts 0xffff and 0x3fffff then REMAP Indices
> >   0 1 0 0 1 0
> > * another 2 regs with shift amounts 44 and 42 then REMAP
> >   Indices 0 1 0 0 1 0 oh look those are the same, use the
> >   exact same SVSHAPE as above
> > * 2 regs with a constant 1 and 5 for a mul c*1 or c*5,
> >   here you will need a 2nd REMAP Index 0 0 1 0 0 1
> > * 3 regs h0 h1 h2 use another REMAP Index 1 2 0 1 2 0
>
> I've been trying to understand this for 6 hours so..
> here goes:
>
> x = [0] * 16
> x[0] = 0xffff
> x[1] = 0x3fffff

start the indices for these at say r20. use 8-bit so put the
indices 0 1 0 0 1 0 in as 0x00_01_00_00_01_00 for a value of
0x000100000100 into r20.

if you set 64-bit indices then you need
* 0x000000000000000 in r20
* 0x000000000000001 in r21
* ....
* ....                 r25

which is as you might guess a total waste of 5 registers.

> x[2] = 44
> x[3] = 42
> x[4] = 1
> x[5] = 5
> x[6] = h1
> x[7] = h2
> x[8] = h0

those are the *values* not the indices (offsets) *to* those values.

> setvl 0, 0, 2(?), 1, 1, 1 # 2 because we have two registers?
> svindex 0/2, 0, 1, 0(?), 0, 1, 0

20/2 because you point at the INDICES not the VALUES.

> # 0 because they are 64-bit?

3 because the INDICES are 8-bit otherwise you waste 5 registers

> I would start with the remaps but I highly doubt this setvl and svindex
> instructions are correct. The ChaCha20 pages and code are elaborate but I
> need a few much simpler examples to wrap my head around this.

not going to happen :) or... it is but you need to get the REMAP
concept first. read the spec, pay attention to the pseudocode,
start of the page rhen on section 3.4
https://libre-soc.org/openpower/sv/remap/

basically ask me and i will guide you through it. please *do not*
waste your time thinking "i MUST do this on my own because of some
stubborn sense of feeling i must do it independently", this is
completely new Computer Science that nobody has ever seen before ok?

--
You are receiving this mail because:
You are on the CC list for the bug.
```