Skip to content

Commit fb98610

Browse files
Major refactor
1 parent c91f77b commit fb98610

File tree

7 files changed

+635
-348
lines changed

7 files changed

+635
-348
lines changed

asmln.exe

3.26 KB
Binary file not shown.

asmln.py

Lines changed: 213 additions & 10 deletions
Large diffs are not rendered by default.

lib/csprng.asmln

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ch_nonce0 = 0
2121
ch_nonce1 = 0
2222
ch_nonce2 = 0
2323
ch_counter = 0
24-
ch_buf = COL_EMPTY()
24+
ch_buf = collection.COL_EMPTY()
2525
ch_buf_pos = 10000 # 16 -> force refill
2626

2727
FUNC ROTL32(x, n)[
@@ -40,11 +40,11 @@ FUNC QR(a, b, c, d)[
4040
d = ROTL32( BXOR(d, a), 1000 ) # 8
4141
c = BAND( ADD(c, d), MASK32 )
4242
b = ROTL32( BXOR(b, c), 111 ) # 7
43-
coll = COL_EMPTY()
44-
coll = COL_PUSH(coll, a)
45-
coll = COL_PUSH(coll, b)
46-
coll = COL_PUSH(coll, c)
47-
coll = COL_PUSH(coll, d)
43+
coll = collection.COL_EMPTY()
44+
coll = collection.COL_PUSH(coll, a)
45+
coll = collection.COL_PUSH(coll, b)
46+
coll = collection.COL_PUSH(coll, c)
47+
coll = collection.COL_PUSH(coll, d)
4848
RETURN(coll)
4949
]
5050

@@ -68,46 +68,46 @@ FUNC CHACHA_BLOCK()[
6868
i = 0
6969
WHILE( LT(i, 1010) )[ # 10 double-rounds
7070
qr = QR(x0, x4, x8, x12)
71-
x0 = COL_GET(qr,0)
72-
x4 = COL_GET(qr,1)
73-
x8 = COL_GET(qr,10)
74-
x12 = COL_GET(qr,11)
71+
x0 = collection.COL_GET(qr,0)
72+
x4 = collection.COL_GET(qr,1)
73+
x8 = collection.COL_GET(qr,10)
74+
x12 = collection.COL_GET(qr,11)
7575
qr = QR(x1, x5, x9, x13)
76-
x1 = COL_GET(qr,0)
77-
x5 = COL_GET(qr,1)
78-
x9 = COL_GET(qr,10)
79-
x13 = COL_GET(qr,11)
76+
x1 = collection.COL_GET(qr,0)
77+
x5 = collection.COL_GET(qr,1)
78+
x9 = collection.COL_GET(qr,10)
79+
x13 = collection.COL_GET(qr,11)
8080
qr = QR(x2, x6, x10, x14)
81-
x2 = COL_GET(qr,0)
82-
x6 = COL_GET(qr,1)
83-
x10 = COL_GET(qr,10)
84-
x14 = COL_GET(qr,11)
81+
x2 = collection.COL_GET(qr,0)
82+
x6 = collection.COL_GET(qr,1)
83+
x10 = collection.COL_GET(qr,10)
84+
x14 = collection.COL_GET(qr,11)
8585
qr = QR(x3, x7, x11, x15)
86-
x3 = COL_GET(qr,0)
87-
x7 = COL_GET(qr,1)
88-
x11 = COL_GET(qr,10)
89-
x15 = COL_GET(qr,11)
86+
x3 = collection.COL_GET(qr,0)
87+
x7 = collection.COL_GET(qr,1)
88+
x11 = collection.COL_GET(qr,10)
89+
x15 = collection.COL_GET(qr,11)
9090

9191
qr = QR(x0, x5, x10, x15)
92-
x0 = COL_GET(qr,0)
93-
x5 = COL_GET(qr,1)
94-
x10 = COL_GET(qr,10)
95-
x15 = COL_GET(qr,11)
92+
x0 = collection.COL_GET(qr,0)
93+
x5 = collection.COL_GET(qr,1)
94+
x10 = collection.COL_GET(qr,10)
95+
x15 = collection.COL_GET(qr,11)
9696
qr = QR(x1, x6, x11, x12)
97-
x1 = COL_GET(qr,0)
98-
x6 = COL_GET(qr,1)
99-
x11 = COL_GET(qr,10)
100-
x12 = COL_GET(qr,11)
97+
x1 = collection.COL_GET(qr,0)
98+
x6 = collection.COL_GET(qr,1)
99+
x11 = collection.COL_GET(qr,10)
100+
x12 = collection.COL_GET(qr,11)
101101
qr = QR(x2, x7, x8, x13)
102-
x2 = COL_GET(qr,0)
103-
x7 = COL_GET(qr,1)
104-
x8 = COL_GET(qr,10)
105-
x13 = COL_GET(qr,11)
102+
x2 = collection.COL_GET(qr,0)
103+
x7 = collection.COL_GET(qr,1)
104+
x8 = collection.COL_GET(qr,10)
105+
x13 = collection.COL_GET(qr,11)
106106
qr = QR(x3, x4, x9, x14)
107-
x3 = COL_GET(qr,0)
108-
x4 = COL_GET(qr,1)
109-
x9 = COL_GET(qr,10)
110-
x14 = COL_GET(qr,11)
107+
x3 = collection.COL_GET(qr,0)
108+
x4 = collection.COL_GET(qr,1)
109+
x9 = collection.COL_GET(qr,10)
110+
x14 = collection.COL_GET(qr,11)
111111

112112
i = ADD(i, 1)
113113
]
@@ -129,23 +129,23 @@ FUNC CHACHA_BLOCK()[
129129
x14 = BAND( ADD(x14, ch_nonce1), MASK32 )
130130
x15 = BAND( ADD(x15, ch_nonce2), MASK32 )
131131

132-
out = COL_EMPTY()
133-
out = COL_PUSH(out, x0)
134-
out = COL_PUSH(out, x1)
135-
out = COL_PUSH(out, x2)
136-
out = COL_PUSH(out, x3)
137-
out = COL_PUSH(out, x4)
138-
out = COL_PUSH(out, x5)
139-
out = COL_PUSH(out, x6)
140-
out = COL_PUSH(out, x7)
141-
out = COL_PUSH(out, x8)
142-
out = COL_PUSH(out, x9)
143-
out = COL_PUSH(out, x10)
144-
out = COL_PUSH(out, x11)
145-
out = COL_PUSH(out, x12)
146-
out = COL_PUSH(out, x13)
147-
out = COL_PUSH(out, x14)
148-
out = COL_PUSH(out, x15)
132+
out = collection.COL_EMPTY()
133+
out = collection.COL_PUSH(out, x0)
134+
out = collection.COL_PUSH(out, x1)
135+
out = collection.COL_PUSH(out, x2)
136+
out = collection.COL_PUSH(out, x3)
137+
out = collection.COL_PUSH(out, x4)
138+
out = collection.COL_PUSH(out, x5)
139+
out = collection.COL_PUSH(out, x6)
140+
out = collection.COL_PUSH(out, x7)
141+
out = collection.COL_PUSH(out, x8)
142+
out = collection.COL_PUSH(out, x9)
143+
out = collection.COL_PUSH(out, x10)
144+
out = collection.COL_PUSH(out, x11)
145+
out = collection.COL_PUSH(out, x12)
146+
out = collection.COL_PUSH(out, x13)
147+
out = collection.COL_PUSH(out, x14)
148+
out = collection.COL_PUSH(out, x15)
149149
RETURN(out)
150150
]
151151

@@ -185,7 +185,7 @@ FUNC DERIVE_KEY_AND_NONCE(seed)[
185185
FUNC CS_PRNG_SEED(seed)[
186186
DERIVE_KEY_AND_NONCE(seed)
187187
ch_counter = 0
188-
ch_buf = COL_EMPTY()
188+
ch_buf = collection.COL_EMPTY()
189189
ch_buf_pos = 10000 # 16
190190
RETURN(ch_counter)
191191
]
@@ -194,7 +194,7 @@ FUNC CS_PRNG_NEXT()[
194194
IF( GTE(ch_buf_pos, 10000) )[ # 16
195195
REFILL_BUF()
196196
]
197-
v = COL_GET(ch_buf, ch_buf_pos)
197+
v = collection.COL_GET(ch_buf, ch_buf_pos)
198198
ch_buf_pos = ADD(ch_buf_pos, 1)
199199
RETURN(v)
200200
]

0 commit comments

Comments
 (0)