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:
Steven Charles Davis 2014-01-17 20:50:04 -06:00
parent b272cb7c5a
commit 0408ab8857

View File

@ -25,9 +25,14 @@ encode(Bin, Degree) when Degree > 0 ->
Data = binary_to_list(Bin),
Coeffs = gf256:monomial_product(Field, Data, 1, Degree),
{_Quotient, Remainder} = gf256:divide(Field, Coeffs, Generator),
ErrorCorrectionBytes = list_to_binary(Remainder),
Remainder0 = zero_pad(Degree, Remainder),
ErrorCorrectionBytes = list_to_binary(Remainder0),
<<ErrorCorrectionBytes/binary>>.
zero_pad(Length, R) when length(R) < Length ->
zero_pad(Length, [0|R]);
zero_pad(_, R) ->
R.
%%
bch_code(Byte, Poly) ->
MSB = msb(Poly),