Jun Sun
2014-07-30 16:43:28 UTC
Hi there,
I realized it may be a bug in this class when raw signature is support by crypto provider. The thing is:
1. The "build" method of this class return a new ContentVerifierProvider.
2. In "get" method of ContentVerifierProvider, couple of things are done:
a. a SignatureOutputStream object is created with normal algorithm ID such as "SHA256WITHxxx".
b. a raw signature object is created with "NONEWITHxxx" as algorithm ID, in case raw signature is supported by the crypto provider.
c. the raw signature object is returned in RawSigVerifier object.
3. The problem here is: RawSigVerifier extends SigVerifier and only implemented a verify function defined in RawContentVerifier interface with 2 parameters:
public boolean verify(byte[] digest, byte[] expected)
but the return type of get method is ContentVerifier, which defines a verify function with only 1 parameter:
boolean verify(byte[] expected);
4. When the verify method is called, the 1 parameter version is used, actually it goes to the verify method defined in SigVerifier class, and it actually calls stream.verify that use the normal signature object instead of raw signature object verify the signature. That means the raw signature is never used.
So I think it may be a bug.
Jun?
I realized it may be a bug in this class when raw signature is support by crypto provider. The thing is:
1. The "build" method of this class return a new ContentVerifierProvider.
2. In "get" method of ContentVerifierProvider, couple of things are done:
a. a SignatureOutputStream object is created with normal algorithm ID such as "SHA256WITHxxx".
b. a raw signature object is created with "NONEWITHxxx" as algorithm ID, in case raw signature is supported by the crypto provider.
c. the raw signature object is returned in RawSigVerifier object.
3. The problem here is: RawSigVerifier extends SigVerifier and only implemented a verify function defined in RawContentVerifier interface with 2 parameters:
public boolean verify(byte[] digest, byte[] expected)
but the return type of get method is ContentVerifier, which defines a verify function with only 1 parameter:
boolean verify(byte[] expected);
4. When the verify method is called, the 1 parameter version is used, actually it goes to the verify method defined in SigVerifier class, and it actually calls stream.verify that use the normal signature object instead of raw signature object verify the signature. That means the raw signature is never used.
So I think it may be a bug.
Jun?