Diff
Modified: trunk/Source/WebCore/ChangeLog (158944 => 158945)
--- trunk/Source/WebCore/ChangeLog 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/ChangeLog 2013-11-08 21:07:13 UTC (rev 158945)
@@ -1,5 +1,24 @@
2013-11-08 Alexey Proskuryakov <[email protected]>
+ https://bugs.webkit.org/show_bug.cgi?id=124064
+ Some WebCrypto files are not in correct directories
+
+ Rubber-stamped by Anders Carlsson.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * crypto/CryptoAlgorithmAesCbcParams.h: Removed.
+ * crypto/CryptoAlgorithmAesKeyGenParams.h: Removed.
+ * crypto/CryptoKeyAES.cpp: Removed.
+ * crypto/CryptoKeyAES.h: Removed.
+ * crypto/CryptoKeyMac.cpp: Removed.
+ * crypto/keys/CryptoKeyAES.cpp: Copied from Source/WebCore/crypto/CryptoKeyAES.cpp.
+ * crypto/keys/CryptoKeyAES.h: Copied from Source/WebCore/crypto/CryptoKeyAES.h.
+ * crypto/mac/CryptoKeyMac.cpp: Copied from Source/WebCore/crypto/CryptoKeyMac.cpp.
+ * crypto/parameters/CryptoAlgorithmAesCbcParams.h: Copied from Source/WebCore/crypto/CryptoAlgorithmAesCbcParams.h.
+ * crypto/parameters/CryptoAlgorithmAesKeyGenParams.h: Copied from Source/WebCore/crypto/CryptoAlgorithmAesKeyGenParams.h.
+
+2013-11-08 Alexey Proskuryakov <[email protected]>
+
Implement JWK key import for HMAC and AES-CBC
https://bugs.webkit.org/show_bug.cgi?id=124059
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (158944 => 158945)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-11-08 21:07:13 UTC (rev 158945)
@@ -12610,14 +12610,14 @@
E125F8331822F18A00D84CD9 /* CryptoKeyHMAC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoKeyHMAC.cpp; path = keys/CryptoKeyHMAC.cpp; sourceTree = "<group>"; };
E125F8341822F18A00D84CD9 /* CryptoKeyHMAC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoKeyHMAC.h; path = keys/CryptoKeyHMAC.h; sourceTree = "<group>"; };
E125F8371822F1EB00D84CD9 /* CryptoAlgorithmHMACMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmHMACMac.cpp; path = mac/CryptoAlgorithmHMACMac.cpp; sourceTree = "<group>"; };
- E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesCbcParams.h; sourceTree = "<group>"; };
+ E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmAesCbcParams.h; path = parameters/CryptoAlgorithmAesCbcParams.h; sourceTree = "<group>"; };
E125F83B182411E700D84CD9 /* JSCryptoOperationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoOperationData.cpp; sourceTree = "<group>"; };
E125F83C182411E700D84CD9 /* JSCryptoOperationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoOperationData.h; sourceTree = "<group>"; };
E125F83F1824253A00D84CD9 /* CryptoAlgorithmAES_CBC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CBC.cpp; sourceTree = "<group>"; };
E125F8401824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAES_CBC.h; sourceTree = "<group>"; };
E125F843182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmAES_CBCMac.cpp; path = mac/CryptoAlgorithmAES_CBCMac.cpp; sourceTree = "<group>"; };
- E125F84B1824289D00D84CD9 /* CryptoKeyAES.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyAES.cpp; sourceTree = "<group>"; };
- E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyAES.h; sourceTree = "<group>"; };
+ E125F84B1824289D00D84CD9 /* CryptoKeyAES.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoKeyAES.cpp; path = keys/CryptoKeyAES.cpp; sourceTree = "<group>"; };
+ E125F84C1824289D00D84CD9 /* CryptoKeyAES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoKeyAES.h; path = keys/CryptoKeyAES.h; sourceTree = "<group>"; };
E125F84F18283A5600D84CD9 /* JSCryptoKeySerializationJWK.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeySerializationJWK.cpp; sourceTree = "<group>"; };
E125F85018283A5600D84CD9 /* JSCryptoKeySerializationJWK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeySerializationJWK.h; sourceTree = "<group>"; };
E125F855182C0F8300D84CD9 /* CryptoKeySerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeySerialization.h; sourceTree = "<group>"; };
@@ -12714,8 +12714,8 @@
E19AC3EB1824DC7900349426 /* CryptoAlgorithmSHA384.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmSHA384.h; sourceTree = "<group>"; };
E19AC3EC1824DC7900349426 /* CryptoAlgorithmSHA512.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmSHA512.cpp; sourceTree = "<group>"; };
E19AC3ED1824DC7900349426 /* CryptoAlgorithmSHA512.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmSHA512.h; sourceTree = "<group>"; };
- E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; };
- E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyMac.cpp; sourceTree = "<group>"; };
+ E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmAesKeyGenParams.h; path = parameters/CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; };
+ E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoKeyMac.cpp; path = mac/CryptoKeyMac.cpp; sourceTree = "<group>"; };
E19DA29B18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmHmacKeyParams.h; path = parameters/CryptoAlgorithmHmacKeyParams.h; sourceTree = "<group>"; };
E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContainerNodeAlgorithms.h; sourceTree = "<group>"; };
E1A3162B134BC32D007C9A4F /* WebNSAttributedStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNSAttributedStringExtras.h; sourceTree = "<group>"; };
Deleted: trunk/Source/WebCore/crypto/CryptoAlgorithmAesCbcParams.h (158944 => 158945)
--- trunk/Source/WebCore/crypto/CryptoAlgorithmAesCbcParams.h 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmAesCbcParams.h 2013-11-08 21:07:13 UTC (rev 158945)
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#ifndef CryptoAlgorithmAesCbcParams_h
-#define CryptoAlgorithmAesCbcParams_h
-
-#include "CryptoAlgorithmParameters.h"
-#include <wtf/FixedArray.h>
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoAlgorithmAesCbcParams FINAL : public CryptoAlgorithmParameters {
-public:
- // The initialization vector. MUST be 16 bytes.
- FixedArray<char, 16> iv;
-};
-
-}
-
-#endif // ENABLE(SUBTLE_CRYPTO)
-#endif // CryptoAlgorithmAesCbcParams_h
Deleted: trunk/Source/WebCore/crypto/CryptoAlgorithmAesKeyGenParams.h (158944 => 158945)
--- trunk/Source/WebCore/crypto/CryptoAlgorithmAesKeyGenParams.h 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmAesKeyGenParams.h 2013-11-08 21:07:13 UTC (rev 158945)
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#ifndef CryptoAlgorithmAesKeyGenParams_h
-#define CryptoAlgorithmAesKeyGenParams_h
-
-#include "CryptoAlgorithmParameters.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoAlgorithmAesKeyGenParams FINAL : public CryptoAlgorithmParameters {
-public:
- // The length, in bits, of the key.
- unsigned length;
-};
-
-}
-
-#endif // ENABLE(SUBTLE_CRYPTO)
-#endif // CryptoAlgorithmAesKeyGenParams_h
Deleted: trunk/Source/WebCore/crypto/CryptoKeyAES.cpp (158944 => 158945)
--- trunk/Source/WebCore/crypto/CryptoKeyAES.cpp 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/crypto/CryptoKeyAES.cpp 2013-11-08 21:07:13 UTC (rev 158945)
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#include "config.h"
-#include "CryptoKeyAES.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-#include "CryptoAlgorithmDescriptionBuilder.h"
-#include "CryptoAlgorithmRegistry.h"
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-CryptoKeyAES::CryptoKeyAES(CryptoAlgorithmIdentifier algorithm, const Vector<char>& key, bool extractable, CryptoKeyUsage usage)
- : CryptoKey(algorithm, CryptoKeyType::Secret, extractable, usage)
- , m_key(key)
-{
- ASSERT(algorithm == CryptoAlgorithmIdentifier::AES_CTR
- || algorithm == CryptoAlgorithmIdentifier::AES_CBC
- || algorithm == CryptoAlgorithmIdentifier::AES_CMAC
- || algorithm == CryptoAlgorithmIdentifier::AES_GCM
- || algorithm == CryptoAlgorithmIdentifier::AES_CFB);
-}
-
-CryptoKeyAES::~CryptoKeyAES()
-{
-}
-
-PassRefPtr<CryptoKeyAES> CryptoKeyAES::generate(CryptoAlgorithmIdentifier algorithm, size_t lengthBits, bool extractable, CryptoKeyUsage usages)
-{
- if (lengthBits % 8)
- return nullptr;
- return adoptRef(new CryptoKeyAES(algorithm, randomData(lengthBits / 8), extractable, usages));
-}
-
-void CryptoKeyAES::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const
-{
- CryptoKey::buildAlgorithmDescription(builder);
- builder.add("length", m_key.size() * 8);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
Deleted: trunk/Source/WebCore/crypto/CryptoKeyAES.h (158944 => 158945)
--- trunk/Source/WebCore/crypto/CryptoKeyAES.h 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/crypto/CryptoKeyAES.h 2013-11-08 21:07:13 UTC (rev 158945)
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#ifndef CryptoKeyAES_h
-#define CryptoKeyAES_h
-
-#include "CryptoAlgorithmIdentifier.h"
-#include "CryptoKey.h"
-#include <wtf/Vector.h>
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoKeyAES FINAL : public CryptoKey {
-public:
- static PassRefPtr<CryptoKeyAES> create(CryptoAlgorithmIdentifier algorithm, const Vector<char>& key, bool extractable, CryptoKeyUsage usage)
- {
- return adoptRef(new CryptoKeyAES(algorithm, key, extractable, usage));
- }
- virtual ~CryptoKeyAES();
-
- static PassRefPtr<CryptoKeyAES> generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsage);
-
- virtual CryptoKeyClass keyClass() const OVERRIDE { return CryptoKeyClass::AES; }
-
- const Vector<char>& key() const { return m_key; }
-
- virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&) const OVERRIDE;
-
-private:
- CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector<char>& key, bool extractable, CryptoKeyUsage);
-
- Vector<char> m_key;
-};
-
-inline const CryptoKeyAES* asCryptoKeyAES(const CryptoKey& key)
-{
- if (key.keyClass() != CryptoKeyClass::AES)
- return nullptr;
- return static_cast<const CryptoKeyAES*>(&key);
-}
-
-inline CryptoKeyAES* asCryptoKeyAES(CryptoKey& key)
-{
- if (key.keyClass() != CryptoKeyClass::AES)
- return nullptr;
- return static_cast<CryptoKeyAES*>(&key);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
-
-
-#endif // CryptoKeyAES_h
Deleted: trunk/Source/WebCore/crypto/CryptoKeyMac.cpp (158944 => 158945)
--- trunk/Source/WebCore/crypto/CryptoKeyMac.cpp 2013-11-08 21:05:13 UTC (rev 158944)
+++ trunk/Source/WebCore/crypto/CryptoKeyMac.cpp 2013-11-08 21:07:13 UTC (rev 158945)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#include "config.h"
-#include "CryptoKey.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-#if defined(__has_include) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
-#if __has_include(<CommonCrypto/CommonRandomSPI.h>)
-#include <CommonCrypto/CommonRandomSPI.h>
-#endif
-#endif
-
-typedef struct __CCRandom *CCRandomRef;
-extern const CCRandomRef kCCRandomDefault;
-extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-
-namespace WebCore {
-
-Vector<char> CryptoKey::randomData(size_t size)
-{
- Vector<char> result(size);
- CCRandomCopyBytes(kCCRandomDefault, result.data(), result.size());
- return result;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
Copied: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (from rev 158942, trunk/Source/WebCore/crypto/CryptoKeyAES.cpp) (0 => 158945)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (rev 0)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp 2013-11-08 21:07:13 UTC (rev 158945)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "CryptoKeyAES.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "CryptoAlgorithmDescriptionBuilder.h"
+#include "CryptoAlgorithmRegistry.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+CryptoKeyAES::CryptoKeyAES(CryptoAlgorithmIdentifier algorithm, const Vector<char>& key, bool extractable, CryptoKeyUsage usage)
+ : CryptoKey(algorithm, CryptoKeyType::Secret, extractable, usage)
+ , m_key(key)
+{
+ ASSERT(algorithm == CryptoAlgorithmIdentifier::AES_CTR
+ || algorithm == CryptoAlgorithmIdentifier::AES_CBC
+ || algorithm == CryptoAlgorithmIdentifier::AES_CMAC
+ || algorithm == CryptoAlgorithmIdentifier::AES_GCM
+ || algorithm == CryptoAlgorithmIdentifier::AES_CFB);
+}
+
+CryptoKeyAES::~CryptoKeyAES()
+{
+}
+
+PassRefPtr<CryptoKeyAES> CryptoKeyAES::generate(CryptoAlgorithmIdentifier algorithm, size_t lengthBits, bool extractable, CryptoKeyUsage usages)
+{
+ if (lengthBits % 8)
+ return nullptr;
+ return adoptRef(new CryptoKeyAES(algorithm, randomData(lengthBits / 8), extractable, usages));
+}
+
+void CryptoKeyAES::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const
+{
+ CryptoKey::buildAlgorithmDescription(builder);
+ builder.add("length", m_key.size() * 8);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
Copied: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (from rev 158942, trunk/Source/WebCore/crypto/CryptoKeyAES.h) (0 => 158945)
--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (rev 0)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h 2013-11-08 21:07:13 UTC (rev 158945)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef CryptoKeyAES_h
+#define CryptoKeyAES_h
+
+#include "CryptoAlgorithmIdentifier.h"
+#include "CryptoKey.h"
+#include <wtf/Vector.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoKeyAES FINAL : public CryptoKey {
+public:
+ static PassRefPtr<CryptoKeyAES> create(CryptoAlgorithmIdentifier algorithm, const Vector<char>& key, bool extractable, CryptoKeyUsage usage)
+ {
+ return adoptRef(new CryptoKeyAES(algorithm, key, extractable, usage));
+ }
+ virtual ~CryptoKeyAES();
+
+ static PassRefPtr<CryptoKeyAES> generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsage);
+
+ virtual CryptoKeyClass keyClass() const OVERRIDE { return CryptoKeyClass::AES; }
+
+ const Vector<char>& key() const { return m_key; }
+
+ virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&) const OVERRIDE;
+
+private:
+ CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector<char>& key, bool extractable, CryptoKeyUsage);
+
+ Vector<char> m_key;
+};
+
+inline const CryptoKeyAES* asCryptoKeyAES(const CryptoKey& key)
+{
+ if (key.keyClass() != CryptoKeyClass::AES)
+ return nullptr;
+ return static_cast<const CryptoKeyAES*>(&key);
+}
+
+inline CryptoKeyAES* asCryptoKeyAES(CryptoKey& key)
+{
+ if (key.keyClass() != CryptoKeyClass::AES)
+ return nullptr;
+ return static_cast<CryptoKeyAES*>(&key);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
+
+
+#endif // CryptoKeyAES_h
Copied: trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp (from rev 158942, trunk/Source/WebCore/crypto/CryptoKeyMac.cpp) (0 => 158945)
--- trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp (rev 0)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp 2013-11-08 21:07:13 UTC (rev 158945)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "CryptoKey.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#if defined(__has_include) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
+#if __has_include(<CommonCrypto/CommonRandomSPI.h>)
+#include <CommonCrypto/CommonRandomSPI.h>
+#endif
+#endif
+
+typedef struct __CCRandom *CCRandomRef;
+extern const CCRandomRef kCCRandomDefault;
+extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
+
+namespace WebCore {
+
+Vector<char> CryptoKey::randomData(size_t size)
+{
+ Vector<char> result(size);
+ CCRandomCopyBytes(kCCRandomDefault, result.data(), result.size());
+ return result;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
Copied: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h (from rev 158942, trunk/Source/WebCore/crypto/CryptoAlgorithmAesCbcParams.h) (0 => 158945)
--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h (rev 0)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h 2013-11-08 21:07:13 UTC (rev 158945)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef CryptoAlgorithmAesCbcParams_h
+#define CryptoAlgorithmAesCbcParams_h
+
+#include "CryptoAlgorithmParameters.h"
+#include <wtf/FixedArray.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmAesCbcParams FINAL : public CryptoAlgorithmParameters {
+public:
+ // The initialization vector. MUST be 16 bytes.
+ FixedArray<char, 16> iv;
+};
+
+}
+
+#endif // ENABLE(SUBTLE_CRYPTO)
+#endif // CryptoAlgorithmAesCbcParams_h
Copied: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h (from rev 158942, trunk/Source/WebCore/crypto/CryptoAlgorithmAesKeyGenParams.h) (0 => 158945)
--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h (rev 0)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h 2013-11-08 21:07:13 UTC (rev 158945)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef CryptoAlgorithmAesKeyGenParams_h
+#define CryptoAlgorithmAesKeyGenParams_h
+
+#include "CryptoAlgorithmParameters.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmAesKeyGenParams FINAL : public CryptoAlgorithmParameters {
+public:
+ // The length, in bits, of the key.
+ unsigned length;
+};
+
+}
+
+#endif // ENABLE(SUBTLE_CRYPTO)
+#endif // CryptoAlgorithmAesKeyGenParams_h