OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 AlgorithmError error; | 49 AlgorithmError error; |
50 bool success = normalizeAlgorithm(raw, op, algorithm, &error); | 50 bool success = normalizeAlgorithm(raw, op, algorithm, &error); |
51 if (!success) | 51 if (!success) |
52 result->completeWithError(error.errorType, error.errorDetails); | 52 result->completeWithError(error.errorType, error.errorDetails); |
53 return success; | 53 return success; |
54 } | 54 } |
55 | 55 |
56 static bool canAccessWebCrypto(ScriptState* scriptState, CryptoResult* result) | 56 static bool canAccessWebCrypto(ScriptState* scriptState, CryptoResult* result) |
57 { | 57 { |
58 String errorMessage; | 58 String errorMessage; |
59 if (!scriptState->executionContext()->isPrivilegedContext(errorMessage, Exec
utionContext::WebCryptoPrivilegeCheck)) { | 59 if (!scriptState->executionContext()->isSecureContext(errorMessage, Executio
nContext::WebCryptoSecureContextCheck)) { |
60 result->completeWithError(WebCryptoErrorTypeNotSupported, errorMessage); | 60 result->completeWithError(WebCryptoErrorTypeNotSupported, errorMessage); |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 return true; | 64 return true; |
65 } | 65 } |
66 | 66 |
67 static bool copyStringProperty(const char* property, const Dictionary& source, J
SONObject* destination) | 67 static bool copyStringProperty(const char* property, const Dictionary& source, J
SONObject* destination) |
68 { | 68 { |
69 String value; | 69 String value; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 if (!parseAlgorithm(rawDerivedKeyType, WebCryptoOperationGetKeyLength, keyLe
ngthAlgorithm, result)) | 420 if (!parseAlgorithm(rawDerivedKeyType, WebCryptoOperationGetKeyLength, keyLe
ngthAlgorithm, result)) |
421 return promise; | 421 return promise; |
422 | 422 |
423 histogramAlgorithmAndKey(scriptState->executionContext(), algorithm, baseKey
->key()); | 423 histogramAlgorithmAndKey(scriptState->executionContext(), algorithm, baseKey
->key()); |
424 histogramAlgorithm(scriptState->executionContext(), importAlgorithm); | 424 histogramAlgorithm(scriptState->executionContext(), importAlgorithm); |
425 Platform::current()->crypto()->deriveKey(algorithm, baseKey->key(), importAl
gorithm, keyLengthAlgorithm, extractable, keyUsages, result->result()); | 425 Platform::current()->crypto()->deriveKey(algorithm, baseKey->key(), importAl
gorithm, keyLengthAlgorithm, extractable, keyUsages, result->result()); |
426 return promise; | 426 return promise; |
427 } | 427 } |
428 | 428 |
429 } // namespace blink | 429 } // namespace blink |
OLD | NEW |