Test append mode for signers verify_signature

This commit is contained in:
Martin Willi
2010-08-19 12:35:53 +02:00
parent fd86fb5183
commit 6c620d5ee0
2 changed files with 6 additions and 3 deletions
+2 -3
View File
@@ -361,11 +361,10 @@ METHOD(crypto_tester_t, test_signer, bool,
/* signature to existing buffer, using append mode */ /* signature to existing buffer, using append mode */
if (data.len > 2) if (data.len > 2)
{ {
memset(mac.ptr, 0, mac.len);
signer->allocate_signature(signer, chunk_create(data.ptr, 1), NULL); signer->allocate_signature(signer, chunk_create(data.ptr, 1), NULL);
signer->get_signature(signer, chunk_create(data.ptr + 1, 1), NULL); signer->get_signature(signer, chunk_create(data.ptr + 1, 1), NULL);
signer->get_signature(signer, chunk_skip(data, 2), mac.ptr); if (!signer->verify_signature(signer, chunk_skip(data, 2),
if (!memeq(vector->mac, mac.ptr, mac.len)) chunk_create(vector->mac, mac.len)))
{ {
failed = TRUE; failed = TRUE;
} }
@@ -106,6 +106,10 @@ struct signer_t {
/** /**
* Verify a signature. * Verify a signature.
* *
* To verify a signature of multiple chunks of data, pass the
* data to get_signature() with a NULL buffer. verify_signature() acts
* as a final call and includes all data fed to get_signature().
*
* @param data a chunk containing the data to verify * @param data a chunk containing the data to verify
* @param signature a chunk containing the signature * @param signature a chunk containing the signature
* @return TRUE, if signature is valid, FALSE otherwise * @return TRUE, if signature is valid, FALSE otherwise