Bugs, features, coding issues Help

Forums » Bugs, features, coding issues » Interleaver prime computation

Interleaver prime computation


Thanks to a colleague at ATLAS, a discrepancy between the JANUS reference implementation 'janus-m-3.0.3' and the ANEP-87 document was found.

It affects only packets with cargo of certain lengths.


Taking the Matlab implementation, the interleaver prime computation
function was:

old impelmentation
function prime = interleaver_prime(data_len, k)
    if (nargin < 2)
        k = 5;
    end

    done = 0;

    while done == 0,
        testp = max(primes(k));
        if ((data_len / k < k) && rem(data_len, testp) ~= 0)
            done = 1;
        end
        k = k + 1;
    end

    prime = testp;
end



Where the data block length was compared with the index 'k' and not with
the prime number 'testp' as in the corrected code:

new implementation
function prime = interleaver_prime(data_len, k)
    if (nargin < 2)
        k = 5;
    end

    done = 0;

    while done == 0,
        testp = max(primes(k));
        if ((data_len / testp < testp) && rem(data_len, testp) ~= 0)
            done = 1;
        end
        k = k + 1;
    end

    prime = testp;
end


This problem also affects older versions of C and Matlab implementations.

The corrected version produces an interleaving pattern that is (for some lengths only) incompatible with the one of the previous versions.

Bellow we present a table with cargo lengths up to 256 computed with the old and new methods (consecutive lines with equal values are omitted with the .....).

len old corrected
...............
25 7 7
26 5 7
27 5 7
28 5 11
29 5 7
30 7 7
31 5 7
32 5 7
33 5 7
34 5 7
35 11 11
...............
49 11 11
50 7 11
51 7 11
52 7 11
53 7 11
54 7 11
55 7 13
56 11 11
57 7 11
58 7 11
59 7 11
60 7 11
61 7 11
62 7 11
63 11 11
64 7 11
65 7 11
66 7 13
67 7 11
68 7 11
69 7 11
70 11 11
71 7 11
72 7 11
73 7 11
74 7 11
75 7 11
76 7 11
77 13 13
78 7 11
79 7 11
80 7 11
81 7 11
82 7 11
83 7 11
84 11 11
85 7 11
86 7 11
87 7 11
88 7 13
89 7 11
90 7 11
91 11 11
92 7 11
93 7 11
94 7 11
95 7 11
96 7 11
97 7 11
98 11 11
99 7 13
100 11 11
...............
121 13 13
122 11 13
123 11 13
124 11 13
125 11 13
126 11 13
127 11 13
128 11 13
129 11 13
130 11 17
131 11 13
132 13 13
133 11 13
134 11 13
135 11 13
136 11 13
137 11 13
138 11 13
139 11 13
140 11 13
141 11 13
142 11 13
143 17 17
...............
169 17 17
170 13 19
171 13 17
172 13 17
173 13 17
174 13 17
175 13 17
176 13 17
177 13 17
178 13 17
179 13 17
180 13 17
181 13 17
182 17 17
183 13 17
184 13 17
185 13 17
186 13 17
187 13 19
188 13 17
189 13 17
190 13 17
191 13 17
192 13 17
193 13 17
194 13 17
195 17 17
196 13 17
197 13 17
198 13 17
199 13 17
200 13 17
201 13 17
202 13 17
203 13 17
204 13 19
205 13 17
206 13 17
207 13 17
208 17 17
209 13 17
210 13 17
211 13 17
212 13 17
213 13 17
214 13 17
215 13 17
216 13 17
217 13 17
218 13 17
219 13 17
220 13 17
221 19 19
222 13 17
223 13 17
224 13 17
225 13 17
226 13 17
227 13 17
228 13 17
229 13 17
230 13 17
231 13 17
232 13 17
233 13 17
234 17 17
235 13 17
236 13 17
237 13 17
238 13 19
239 13 17
240 13 17
241 13 17
242 13 17
243 13 17
244 13 17
245 13 17
246 13 17
247 17 17
248 13 17
249 13 17
250 13 17
251 13 17
252 13 17
253 13 17
254 13 17
255 13 19
256 17 17


We expect to upload corrected versions of the code soon.

Thank you.

Giovanni

Show posts: