Changeset 173872 in webkit


Ignore:
Timestamp:
Sep 23, 2014 8:17:52 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Adds implementation of Subtle Crypto digest algorithms
https://bugs.webkit.org/show_bug.cgi?id=133319

Source/WebCore:

Patch by Eduardo Lima Mitev <elima@igalia.com> on 2014-09-23
Reviewed by Philippe Normand.

Tests are already in place under crypto/subtle/sha-*.html

  • crypto/gtk/CryptoDigestGtk.cpp:

(WebCore::CryptoDigest::CryptoDigest):
(WebCore::CryptoDigest::~CryptoDigest):
(WebCore::CryptoDigest::create):
(WebCore::CryptoDigest::addBytes):
(WebCore::CryptoDigest::computeHash):

LayoutTests:

Leaves all crypto/subtle tests skipped and whitelist only those related to
digest algorithms (sha-*.html). When enough crypto algorithms are implemented,
we can invert the approach and blacklist only those tests whose algorithms are
not implemented.

Patch by Eduardo Lima Mitev <elima@igalia.com> on 2014-09-23
Reviewed by Philippe Normand.

  • platform/gtk/TestExpectations: Unskip tests for Subtle-Crypto digest algorithms.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r173867 r173872  
     12014-09-23  Eduardo Lima Mitev  <elima@igalia.com>
     2
     3        [GTK] Adds implementation of Subtle Crypto digest algorithms
     4        https://bugs.webkit.org/show_bug.cgi?id=133319
     5
     6        Leaves all crypto/subtle tests skipped and whitelist only those related to
     7        digest algorithms (sha-*.html). When enough crypto algorithms are implemented,
     8        we can invert the approach and blacklist only those tests whose algorithms are
     9        not implemented.
     10
     11        Reviewed by Philippe Normand.
     12
     13        * platform/gtk/TestExpectations: Unskip tests for Subtle-Crypto digest algorithms.
     14
    1152014-09-23  Ion Rosca  <rosca@adobe.com>
    216
  • trunk/LayoutTests/platform/gtk/TestExpectations

    • Property svn:executable deleted
    r173809 r173872  
    356356webkit.org/b/117975 fast/text/international/synthesized-italic-vertical-latin.html [ Skip ]
    357357
    358 # crypto.subtle is not yet enabled
    359 Bug(GTK) crypto/subtle [ Skip ]
     358# crypto.subtle is not yet enabled, but digest algorithms are already implemented
     359# and their tests are whitelisted
     360webkit.org/b/133122 crypto/subtle [ Skip ]
     361webkit.org/b/133319 crypto/subtle/sha-1.html [ Pass ]
     362webkit.org/b/133319 crypto/subtle/sha-224.html [ Pass ]
     363webkit.org/b/133319 crypto/subtle/sha-256.html [ Pass ]
     364webkit.org/b/133319 crypto/subtle/sha-384.html [ Pass ]
     365webkit.org/b/133319 crypto/subtle/sha-512.html [ Pass ]
    360366
    361367# QuickTime plug-in not relevant to this port
  • trunk/Source/WebCore/ChangeLog

    r173868 r173872  
     12014-09-23  Eduardo Lima Mitev  <elima@igalia.com>
     2
     3        [GTK] Adds implementation of Subtle Crypto digest algorithms
     4        https://bugs.webkit.org/show_bug.cgi?id=133319
     5
     6        Reviewed by Philippe Normand.
     7
     8        Tests are already in place under crypto/subtle/sha-*.html
     9
     10        * crypto/gtk/CryptoDigestGtk.cpp:
     11        (WebCore::CryptoDigest::CryptoDigest):
     12        (WebCore::CryptoDigest::~CryptoDigest):
     13        (WebCore::CryptoDigest::create):
     14        (WebCore::CryptoDigest::addBytes):
     15        (WebCore::CryptoDigest::computeHash):
     16
    1172014-09-15  Sergio Villar Senin  <svillar@igalia.com>
    218
  • trunk/Source/WebCore/crypto/gtk/CryptoDigestGtk.cpp

    r172389 r173872  
    2929#if ENABLE(SUBTLE_CRYPTO)
    3030
    31 #include "NotImplemented.h"
     31#include <gnutls/gnutls.h>
     32#include <gnutls/crypto.h>
    3233
    3334namespace WebCore {
    3435
    3536struct CryptoDigestContext {
     37    gnutls_digest_algorithm_t algorithm;
     38    gnutls_hash_hd_t hash;
    3639};
    3740
     
    3942    : m_context(new CryptoDigestContext)
    4043{
    41     notImplemented();
    4244}
    4345
    4446CryptoDigest::~CryptoDigest()
    4547{
    46     notImplemented();
     48    gnutls_hash_deinit(m_context->hash, 0);
    4749}
    48 
    4950
    5051std::unique_ptr<CryptoDigest> CryptoDigest::create(CryptoAlgorithmIdentifier algorithm)
    5152{
    52     notImplemented();
    53     UNUSED_PARAM(algorithm);
     53    gnutls_digest_algorithm_t gnutlsAlgorithm;
    5454
    55     return 0;
     55    switch (algorithm) {
     56    case CryptoAlgorithmIdentifier::SHA_1: {
     57        gnutlsAlgorithm = GNUTLS_DIG_SHA1;
     58        break;
     59    }
     60    case CryptoAlgorithmIdentifier::SHA_224: {
     61        gnutlsAlgorithm = GNUTLS_DIG_SHA224;
     62        break;
     63    }
     64    case CryptoAlgorithmIdentifier::SHA_256: {
     65        gnutlsAlgorithm = GNUTLS_DIG_SHA256;
     66        break;
     67    }
     68    case CryptoAlgorithmIdentifier::SHA_384: {
     69        gnutlsAlgorithm = GNUTLS_DIG_SHA384;
     70        break;
     71    }
     72    case CryptoAlgorithmIdentifier::SHA_512: {
     73        gnutlsAlgorithm = GNUTLS_DIG_SHA512;
     74        break;
     75    }
     76    default:
     77        return nullptr;
     78    }
     79
     80    std::unique_ptr<CryptoDigest> digest(new CryptoDigest);
     81    digest->m_context->algorithm = gnutlsAlgorithm;
     82
     83    int ret = gnutls_hash_init(&digest->m_context->hash, gnutlsAlgorithm);
     84    if (ret != GNUTLS_E_SUCCESS)
     85        return nullptr;
     86
     87    return digest;
    5688}
    5789
    5890void CryptoDigest::addBytes(const void* input, size_t length)
    5991{
    60     notImplemented();
    61     UNUSED_PARAM(input);
    62     UNUSED_PARAM(length);
     92    gnutls_hash(m_context->hash, input, length);
    6393}
    6494
    6595Vector<uint8_t> CryptoDigest::computeHash()
    6696{
    67     notImplemented();
    68     Vector<uint8_t> result(0);
     97    Vector<uint8_t> result;
     98    int digestLen = gnutls_hash_get_len(m_context->algorithm);
     99    result.resize(digestLen);
     100
     101    gnutls_hash_output(m_context->hash, result.data());
     102
    69103    return result;
    70104}
Note: See TracChangeset for help on using the changeset viewer.