mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-28 12:34:31 +00:00
Remove the default arguments on MessageAuthenticationCode,
as discussed with Justin. It basically made sense to have a default of SHA1 for HMAC, but when we went away from having all the specific classes, defaulting all MAC to be HMAC(SHA1) was a bit of a stretch. svn path=/trunk/kdesupport/qca/; revision=605322
This commit is contained in:
parent
e6fff0cecb
commit
6ad4fb500e
1
TODO
1
TODO
@ -19,7 +19,6 @@
|
|||||||
reports true, but then when the object is created, it doesn't actually
|
reports true, but then when the object is created, it doesn't actually
|
||||||
support the feature (because the wrong provider was used).
|
support the feature (because the wrong provider was used).
|
||||||
why is Random returning unsigned?
|
why is Random returning unsigned?
|
||||||
why does the MessageAuthenticationCode constructor have default args?
|
|
||||||
code:
|
code:
|
||||||
don't create qobjects during init (that means you, keystoremanager)
|
don't create qobjects during init (that means you, keystoremanager)
|
||||||
functions that don't trip a scan should do so on the first try
|
functions that don't trip a scan should do so on the first try
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
@ -47,13 +47,13 @@ int main(int argc, char **argv)
|
|||||||
if( !QCA::isSupported("hmac(sha1)") ) {
|
if( !QCA::isSupported("hmac(sha1)") ) {
|
||||||
printf("HMAC(SHA1) not supported!\n");
|
printf("HMAC(SHA1) not supported!\n");
|
||||||
} else {
|
} else {
|
||||||
// create the required object. This is equivalent
|
// create the required object using HMAC with SHA-1, and an
|
||||||
// to QCA::MessageAuthenticationCode hmacObject("hmac(sha1)").
|
// empty key.
|
||||||
QCA::MessageAuthenticationCode hmacObject;
|
QCA::MessageAuthenticationCode hmacObject( "hmac(sha1)", QSecureArray() );
|
||||||
|
|
||||||
// create the key
|
// create the key
|
||||||
QCA::SymmetricKey keyObject(key);
|
QCA::SymmetricKey keyObject(key);
|
||||||
|
|
||||||
// set the HMAC object to use the key
|
// set the HMAC object to use the key
|
||||||
hmacObject.setup(key);
|
hmacObject.setup(key);
|
||||||
// that could also have been done in the
|
// that could also have been done in the
|
||||||
|
@ -641,7 +641,8 @@ namespace QCA
|
|||||||
|
|
||||||
MessageAuthenticationCode is a class for accessing the various
|
MessageAuthenticationCode is a class for accessing the various
|
||||||
message authentication code algorithms within %QCA.
|
message authentication code algorithms within %QCA.
|
||||||
HMAC using SHA1 ("hmac(sha1)")is recommended for new applications.
|
HMAC using SHA1 ("hmac(sha1)") or HMAC using SHA256 ("hmac(sha256)")
|
||||||
|
is recommended for new applications.
|
||||||
|
|
||||||
Note that if your application is potentially susceptable to "replay attacks"
|
Note that if your application is potentially susceptable to "replay attacks"
|
||||||
where the message is sent more than once, you should include a counter in
|
where the message is sent more than once, you should include a counter in
|
||||||
@ -661,8 +662,8 @@ namespace QCA
|
|||||||
\param key the shared key
|
\param key the shared key
|
||||||
\param provider the provider to use, if a particular provider is required
|
\param provider the provider to use, if a particular provider is required
|
||||||
*/
|
*/
|
||||||
MessageAuthenticationCode(const QString &type = "hmac(sha1)",
|
MessageAuthenticationCode(const QString &type,
|
||||||
const SymmetricKey &key = SymmetricKey(),
|
const SymmetricKey &key,
|
||||||
const QString &provider = QString());
|
const QString &provider = QString());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +108,7 @@ void MACUnitTest::HMACMD5()
|
|||||||
md5hmac4.update( data4 );
|
md5hmac4.update( data4 );
|
||||||
QCOMPARE( QCA::arrayToHex( md5hmac4.final() ), QString( "697eaf0aca3a3aea3a75164746ffaa79" ) );
|
QCOMPARE( QCA::arrayToHex( md5hmac4.final() ), QString( "697eaf0aca3a3aea3a75164746ffaa79" ) );
|
||||||
|
|
||||||
QCA::MessageAuthenticationCode md5hmac5( "hmac(md5)" );
|
QCA::MessageAuthenticationCode md5hmac5( "hmac(md5)", QSecureArray() );
|
||||||
QCA::SymmetricKey key5( QCA::hexToArray( "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" ) );
|
QCA::SymmetricKey key5( QCA::hexToArray( "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" ) );
|
||||||
md5hmac5.setup( key5 );
|
md5hmac5.setup( key5 );
|
||||||
QSecureArray data5( "Test With Truncation" );
|
QSecureArray data5( "Test With Truncation" );
|
||||||
@ -479,7 +479,7 @@ void MACUnitTest::HMACSHA1()
|
|||||||
QCOMPARE( sha1hmacLenTest.validKeyLength( -2 ), false );
|
QCOMPARE( sha1hmacLenTest.validKeyLength( -2 ), false );
|
||||||
|
|
||||||
// These tests are from RFC2202, Section 3.
|
// These tests are from RFC2202, Section 3.
|
||||||
QCA::MessageAuthenticationCode test1; // should be default
|
QCA::MessageAuthenticationCode test1( "hmac(sha1)", QSecureArray() );
|
||||||
QCA::SymmetricKey key1( QCA::hexToArray( "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" ) );
|
QCA::SymmetricKey key1( QCA::hexToArray( "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" ) );
|
||||||
test1.setup( key1 );
|
test1.setup( key1 );
|
||||||
QSecureArray data1( "Hi There" );
|
QSecureArray data1( "Hi There" );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user