Changeset 173874 in webkit
- Timestamp:
- Sep 23, 2014 9:41:45 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r173873 r173874 1 2014-09-23 Eduardo Lima Mitev <elima@igalia.com> 2 3 [GTK] Adds implementation of subtle crypto HMAC algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=133320 5 6 Reviewed by Philippe Normand. 7 8 * platform/gtk/TestExpectations: Whitelists HMAC related tests that are passing 9 1 10 2014-09-23 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 11 -
trunk/LayoutTests/platform/gtk/TestExpectations
r173872 r173874 364 364 webkit.org/b/133319 crypto/subtle/sha-384.html [ Pass ] 365 365 webkit.org/b/133319 crypto/subtle/sha-512.html [ Pass ] 366 webkit.org/b/133320 crypto/subtle/hmac-check-algorithm.html [ Pass ] 367 webkit.org/b/133320 crypto/subtle/hmac-export-key.html [ Pass ] 368 webkit.org/b/133320 crypto/subtle/hmac-generate-key.html [ Pass ] 369 webkit.org/b/133320 crypto/subtle/hmac-import-jwk.html [ Pass ] 370 webkit.org/b/133320 crypto/subtle/hmac-sign-verify-empty-key.html [ Pass ] 371 webkit.org/b/133320 crypto/subtle/hmac-sign-verify.html [ Pass ] 366 372 367 373 # QuickTime plug-in not relevant to this port -
trunk/Source/WebCore/ChangeLog
r173872 r173874 1 2014-09-23 Eduardo Lima Mitev <elima@igalia.com> 2 3 [GTK] Adds implementation of subtle crypto HMAC algorithm 4 https://bugs.webkit.org/show_bug.cgi?id=133320 5 6 Reviewed by Philippe Normand. 7 8 Tests are already in place under crypto/subtle/hmac-*.html 9 10 * crypto/gtk/CryptoAlgorithmHMACGtk.cpp: 11 (WebCore::getGnutlsDigestAlgorithm): 12 (WebCore::calculateSignature): 13 (WebCore::CryptoAlgorithmHMAC::platformSign): 14 (WebCore::CryptoAlgorithmHMAC::platformVerify): 15 1 16 2014-09-23 Eduardo Lima Mitev <elima@igalia.com> 2 17 -
trunk/Source/WebCore/crypto/gtk/CryptoAlgorithmHMACGtk.cpp
r172389 r173874 32 32 #include "CryptoKeyHMAC.h" 33 33 #include "ExceptionCode.h" 34 #include "NotImplemented.h" 34 #include <gnutls/gnutls.h> 35 #include <gnutls/crypto.h> 36 #include <wtf/CryptographicUtilities.h> 35 37 36 38 namespace WebCore { 37 39 40 static gnutls_mac_algorithm_t getGnutlsDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction) 41 { 42 switch (hashFunction) { 43 case CryptoAlgorithmIdentifier::SHA_1: 44 return GNUTLS_MAC_SHA1; 45 case CryptoAlgorithmIdentifier::SHA_224: 46 return GNUTLS_MAC_SHA224; 47 case CryptoAlgorithmIdentifier::SHA_256: 48 return GNUTLS_MAC_SHA256; 49 case CryptoAlgorithmIdentifier::SHA_384: 50 return GNUTLS_MAC_SHA384; 51 case CryptoAlgorithmIdentifier::SHA_512: 52 return GNUTLS_MAC_SHA512; 53 default: 54 return GNUTLS_MAC_UNKNOWN; 55 } 56 } 57 58 static Vector<uint8_t> calculateSignature(gnutls_mac_algorithm_t algorithm, const Vector<uint8_t>& key, const CryptoOperationData& data) 59 { 60 size_t digestLength = gnutls_hmac_get_len(algorithm); 61 62 Vector<uint8_t> result(digestLength); 63 const void* keyData = key.data() ? key.data() : reinterpret_cast<const uint8_t*>(""); 64 int ret = gnutls_hmac_fast(algorithm, keyData, key.size(), data.first, data.second, result.data()); 65 ASSERT(ret == GNUTLS_E_SUCCESS); 66 UNUSED_PARAM(ret); 67 68 return result; 69 } 70 38 71 void CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParams& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec) 39 72 { 40 notImplemented(); 41 ec = NOT_SUPPORTED_ERR; 42 failureCallback(); 73 gnutls_mac_algorithm_t algorithm = getGnutlsDigestAlgorithm(parameters.hash); 74 if (algorithm == GNUTLS_MAC_UNKNOWN) { 75 ec = NOT_SUPPORTED_ERR; 76 failureCallback(); 77 return; 78 } 43 79 44 UNUSED_PARAM(parameters); 45 UNUSED_PARAM(key); 46 UNUSED_PARAM(data); 47 UNUSED_PARAM(callback); 48 UNUSED_PARAM(ec); 80 Vector<uint8_t> signature = calculateSignature(algorithm, key.key(), data); 81 82 callback(signature); 49 83 } 50 84 51 85 void CryptoAlgorithmHMAC::platformVerify(const CryptoAlgorithmHmacParams& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& expectedSignature, const CryptoOperationData& data, BoolCallback callback, VoidCallback failureCallback, ExceptionCode& ec) 52 86 { 53 notImplemented(); 54 ec = NOT_SUPPORTED_ERR; 55 failureCallback(); 87 gnutls_mac_algorithm_t algorithm = getGnutlsDigestAlgorithm(parameters.hash); 88 if (algorithm == GNUTLS_MAC_UNKNOWN) { 89 ec = NOT_SUPPORTED_ERR; 90 failureCallback(); 91 return; 92 } 56 93 57 UNUSED_PARAM(parameters);58 UNUSED_PARAM(key); 59 UNUSED_PARAM(expectedSignature);60 UNUSED_PARAM(data);61 UNUSED_PARAM(callback); 62 UNUSED_PARAM(ec);94 Vector<uint8_t> signature = calculateSignature(algorithm, key.key(), data); 95 96 // Using a constant time comparison to prevent timing attacks. 97 bool result = signature.size() == expectedSignature.second && !constantTimeMemcmp(signature.data(), expectedSignature.first, signature.size()); 98 99 callback(result); 63 100 } 64 101
Note: See TracChangeset
for help on using the changeset viewer.