Title: [214609] trunk/Source/WebCore/PAL
- Revision
- 214609
- Author
- zandober...@gmail.com
- Date
- 2017-03-30 09:28:47 -0700 (Thu, 30 Mar 2017)
Log Message
[GCrypt] Add the Utilities.h header
https://bugs.webkit.org/show_bug.cgi?id=170269
Reviewed by Michael Catanzaro.
Add a libgcrypt-specific Utilities.h header under PAL. It will contain
common functions that are shared throughout the code that leverages
libgcrypt.
* pal/crypto/gcrypt/Utilities.h: Added.
(PAL::GCrypt::logError): Use WTFLogAlways() to report the passed-in libgcrypt error.
(PAL::GCrypt::aesAlgorithmForKeySize): Return a GCRY_CIPHER_AES{128,192,256} value
that matches up with the passed-in key size.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (214608 => 214609)
--- trunk/Source/WebCore/PAL/ChangeLog 2017-03-30 16:18:13 UTC (rev 214608)
+++ trunk/Source/WebCore/PAL/ChangeLog 2017-03-30 16:28:47 UTC (rev 214609)
@@ -1,3 +1,19 @@
+2017-03-30 Zan Dobersek <zdober...@igalia.com>
+
+ [GCrypt] Add the Utilities.h header
+ https://bugs.webkit.org/show_bug.cgi?id=170269
+
+ Reviewed by Michael Catanzaro.
+
+ Add a libgcrypt-specific Utilities.h header under PAL. It will contain
+ common functions that are shared throughout the code that leverages
+ libgcrypt.
+
+ * pal/crypto/gcrypt/Utilities.h: Added.
+ (PAL::GCrypt::logError): Use WTFLogAlways() to report the passed-in libgcrypt error.
+ (PAL::GCrypt::aesAlgorithmForKeySize): Return a GCRY_CIPHER_AES{128,192,256} value
+ that matches up with the passed-in key size.
+
2017-03-29 Zan Dobersek <zdober...@igalia.com>
[GCrypt] Add a Handle<> class to help with GCrypt object lifetime control
Added: trunk/Source/WebCore/PAL/pal/crypto/gcrypt/Utilities.h (0 => 214609)
--- trunk/Source/WebCore/PAL/pal/crypto/gcrypt/Utilities.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/crypto/gcrypt/Utilities.h 2017-03-30 16:28:47 UTC (rev 214609)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 Metrological Group B.V.
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <gcrypt.h>
+#include <wtf/Assertions.h>
+
+namespace PAL {
+namespace GCrypt {
+
+static inline void logError(gcry_error_t error)
+{
+ WTFLogAlways("libgcrypt error: source '%s', description '%s'",
+ gcry_strsource(error), gcry_strerror(error));
+}
+
+static inline std::optional<int> aesAlgorithmForKeySize(size_t keySize)
+{
+ switch (keySize) {
+ case 128:
+ return GCRY_CIPHER_AES128;
+ case 192:
+ return GCRY_CIPHER_AES192;
+ case 256:
+ return GCRY_CIPHER_AES256;
+ default:
+ return std::nullopt;
+ }
+}
+
+} // namespace GCrypt
+} // namespace PAL
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes