Marco หงุ่ยตระกูล-Schulze
2014-09-16 17:33:46 UTC
Hello *,
I've encountered a very strange problem concerning a broken signature
which I could - after hours - finally isolate and reproduce in this
little test case:
https://codewizards.co/mn/tmp/2014-09-16/co.codewizards.bc20140916.tar.gz
The problem is demonstrated in short (simplified) as follows:
final Signer signer = ...
final byte[] signatureCreated = longToBytes(new Date(0).getTime());
signer.update(signatureCreated, 0, signatureCreated.length);
signer.update(plain, 0, plain.length);
final byte[] signature = signer.generateSignature();
final Signer verifier = ...
verifier.update(signatureCreated, 0, signatureCreated.length);
verifier.update(plain, 0, plain.length);
assertThat(verifier.verifySignature(signature)).isTrue();
The last assertion fails sometimes, which IMHO should *never* happen. If
I change any parameter, e.g. use a different 'signatureCreated' Date or
have a different payload to be signed or have different keys, the same
code works fine and the assertion succeeds.
Did I overlook anything? Or is this a bug in BouncyCastle 1.50 - maybe
even a known one?
Best regards, Marco :-)
I've encountered a very strange problem concerning a broken signature
which I could - after hours - finally isolate and reproduce in this
little test case:
https://codewizards.co/mn/tmp/2014-09-16/co.codewizards.bc20140916.tar.gz
The problem is demonstrated in short (simplified) as follows:
final Signer signer = ...
final byte[] signatureCreated = longToBytes(new Date(0).getTime());
signer.update(signatureCreated, 0, signatureCreated.length);
signer.update(plain, 0, plain.length);
final byte[] signature = signer.generateSignature();
final Signer verifier = ...
verifier.update(signatureCreated, 0, signatureCreated.length);
verifier.update(plain, 0, plain.length);
assertThat(verifier.verifySignature(signature)).isTrue();
The last assertion fails sometimes, which IMHO should *never* happen. If
I change any parameter, e.g. use a different 'signatureCreated' Date or
have a different payload to be signed or have different keys, the same
code works fine and the assertion succeeds.
Did I overlook anything? Or is this a bug in BouncyCastle 1.50 - maybe
even a known one?
Best regards, Marco :-)