1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ContentSecurityPolicyParsers_h
6 #define ContentSecurityPolicyParsers_h
8 #include "platform/Crypto.h"
9 #include "platform/PlatformExport.h"
10 #include "wtf/Vector.h"
11 #include "wtf/unicode/Unicode.h"
15 typedef std::pair<unsigned, DigestValue> CSPHashValue;
17 enum ContentSecurityPolicyHeaderType {
18 ContentSecurityPolicyHeaderTypeReport,
19 ContentSecurityPolicyHeaderTypeEnforce
22 enum ContentSecurityPolicyHeaderSource {
23 ContentSecurityPolicyHeaderSourceHTTP,
24 ContentSecurityPolicyHeaderSourceMeta
27 enum ContentSecurityPolicyHashAlgorithm {
28 ContentSecurityPolicyHashAlgorithmNone = 0,
29 ContentSecurityPolicyHashAlgorithmSha1 = 1 << 1,
30 ContentSecurityPolicyHashAlgorithmSha256 = 1 << 2,
31 ContentSecurityPolicyHashAlgorithmSha384 = 1 << 3,
32 ContentSecurityPolicyHashAlgorithmSha512 = 1 << 4
35 PLATFORM_EXPORT bool isCSPDirectiveNameCharacter(UChar);
36 PLATFORM_EXPORT bool isCSPDirectiveValueCharacter(UChar);
37 PLATFORM_EXPORT bool isNonceCharacter(UChar);
38 PLATFORM_EXPORT bool isSourceCharacter(UChar);
39 PLATFORM_EXPORT bool isPathComponentCharacter(UChar);
40 PLATFORM_EXPORT bool isHostCharacter(UChar);
41 PLATFORM_EXPORT bool isSchemeContinuationCharacter(UChar);
42 PLATFORM_EXPORT bool isNotASCIISpace(UChar);
43 PLATFORM_EXPORT bool isNotColonOrSlash(UChar);
44 PLATFORM_EXPORT bool isMediaTypeCharacter(UChar);
46 // Only checks for general Base64 encoded chars, not '=' chars since '=' is
47 // positional and may only appear at the end of a Base64 encoded string.
48 PLATFORM_EXPORT bool isBase64EncodedCharacter(UChar);
50 } // namespace WebCore