Issue #2 - provisional resolution to RFC3339 date encoding
Fixes an issue where a GF(256) remainder used for reed-solomon error correction bytes is a codeword short on return from division. This may not be the final resolution to the wider issue.
This commit is contained in:
parent
b272cb7c5a
commit
0408ab8857
@ -25,9 +25,14 @@ encode(Bin, Degree) when Degree > 0 ->
|
|||||||
Data = binary_to_list(Bin),
|
Data = binary_to_list(Bin),
|
||||||
Coeffs = gf256:monomial_product(Field, Data, 1, Degree),
|
Coeffs = gf256:monomial_product(Field, Data, 1, Degree),
|
||||||
{_Quotient, Remainder} = gf256:divide(Field, Coeffs, Generator),
|
{_Quotient, Remainder} = gf256:divide(Field, Coeffs, Generator),
|
||||||
ErrorCorrectionBytes = list_to_binary(Remainder),
|
Remainder0 = zero_pad(Degree, Remainder),
|
||||||
|
ErrorCorrectionBytes = list_to_binary(Remainder0),
|
||||||
<<ErrorCorrectionBytes/binary>>.
|
<<ErrorCorrectionBytes/binary>>.
|
||||||
|
|
||||||
|
zero_pad(Length, R) when length(R) < Length ->
|
||||||
|
zero_pad(Length, [0|R]);
|
||||||
|
zero_pad(_, R) ->
|
||||||
|
R.
|
||||||
%%
|
%%
|
||||||
bch_code(Byte, Poly) ->
|
bch_code(Byte, Poly) ->
|
||||||
MSB = msb(Poly),
|
MSB = msb(Poly),
|
||||||
|
Loading…
Reference in New Issue
Block a user