| 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 21 matching lines...) Expand all Loading... |
| 32 #define NormalizeAlgorithm_h | 32 #define NormalizeAlgorithm_h |
| 33 | 33 |
| 34 #include "public/platform/WebCryptoAlgorithm.h" | 34 #include "public/platform/WebCryptoAlgorithm.h" |
| 35 #include "wtf/Assertions.h" | 35 #include "wtf/Assertions.h" |
| 36 #include "wtf/Forward.h" | 36 #include "wtf/Forward.h" |
| 37 | 37 |
| 38 namespace blink { class WebCryptoAlgorithm; } | 38 namespace blink { class WebCryptoAlgorithm; } |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 class CryptoResult; |
| 42 class Dictionary; | 43 class Dictionary; |
| 43 class ExceptionState; | |
| 44 | 44 |
| 45 enum AlgorithmOperation { | 45 enum AlgorithmOperation { |
| 46 Encrypt, | 46 Encrypt, |
| 47 Decrypt, | 47 Decrypt, |
| 48 Sign, | 48 Sign, |
| 49 Verify, | 49 Verify, |
| 50 Digest, | 50 Digest, |
| 51 GenerateKey, | 51 GenerateKey, |
| 52 ImportKey, | 52 ImportKey, |
| 53 DeriveKey, | 53 DeriveKey, |
| 54 WrapKey, | 54 WrapKey, |
| 55 UnwrapKey, | 55 UnwrapKey, |
| 56 // <---- End of list (keep this up-to-date) | 56 // <---- End of list (keep this up-to-date) |
| 57 LastAlgorithmOperation = UnwrapKey, | 57 LastAlgorithmOperation = UnwrapKey, |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Converts a javascript Dictionary to a WebCryptoAlgorithm object. | 60 // Converts a javascript Dictionary to a WebCryptoAlgorithm object. |
| 61 // | 61 // |
| 62 // This corresponds with "normalizing" [1] the algorithm, and then validating | 62 // This corresponds with "normalizing" [1] the algorithm, and then validating |
| 63 // the expected parameters for the algorithm/operation combination. | 63 // the expected parameters for the algorithm/operation combination. |
| 64 // | 64 // |
| 65 // On success returns true and sets the WebCryptoAlgorithm. | 65 // On success returns true and sets the WebCryptoAlgorithm. |
| 66 // | 66 // |
| 67 // On failure parseAlgorithm returns false. errorDetails will be filled | 67 // On failure parseAlgorithm returns false and completes the CryptoResult |
| 68 // with a (non-localized) debug string. Additionally the ExceptionState *may* | 68 // with a (non-localized) debug string. |
| 69 // be set (the web crypto spec only defines a handeful of errors as resulting | |
| 70 // in exceptions). | |
| 71 // | 69 // |
| 72 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules | 70 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules |
| 73 bool parseAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoAlgor
ithm&, String& errorDetails, ExceptionState&) WARN_UNUSED_RETURN; | 71 bool parseAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoAlgor
ithm&, CryptoResult*) WARN_UNUSED_RETURN; |
| 74 | 72 |
| 75 // Returns a null-terminated C-string literal. Caller can assume the pointer | 73 // Returns a null-terminated C-string literal. Caller can assume the pointer |
| 76 // will be valid for the program's entire runtime. | 74 // will be valid for the program's entire runtime. |
| 77 const char* algorithmIdToName(blink::WebCryptoAlgorithmId); | 75 const char* algorithmIdToName(blink::WebCryptoAlgorithmId); |
| 78 | 76 |
| 79 } // namespace WebCore | 77 } // namespace WebCore |
| 80 | 78 |
| 81 #endif | 79 #endif |
| OLD | NEW |